#ident "$URL: svn://elmer/devel/SVN/SDDAS/trunk/libCfg/CfgPath.c $ %D% SwRI" #include #include #include "libCfg.h" #include "libCfg_local.h" /* * StrHier Source - node in the Projects tree for start of query * SDDAS_CHAR *item - string for query * SDDAS_INT level - level in tree to add directory node names * * Return a static character string to a data path defined by the item value. Additional * path information is added based on the parent name of the Source. The number of * path names added is dependent upon the level. */ SDDAS_CHAR *CfgPath (StrHier Source, SDDAS_CHAR *item, SDDAS_INT level) { StrHier S; static SDDAS_CHAR path [256]; SDDAS_CHAR *p; int i, j; if ((p = CfgItem (Source, item, 0)) == NULL) return NULL; memset (path, 0, 256); strcpy (path, p); if (path [strlen (path)-1] != '%') { for (i = 0, S = Source; StrHierParent (S); S = StrHierParent (S), i++); i--; for (; --level >= 0;) { strcat (path, "/"); strcat (path, SNAME (S)); for (j = --i, S = Source; j >= 0; S = StrHierParent (S), j--); } } else path [strlen (path)-1] = '\0'; return path; }