#ident "$URL: svn://elmer/devel/SVN/SDDAS/trunk/libCfg/P_Config.c $ %D% SwRI" #include #include #include #include #include "ant.h" #include "libCfg_local.h" /*************************************** * private routines ***************************************/ LinkList aConfig(config_t *handle, char *prefix, StrHier parent) { static int level = 0; LinkList L = NULL; StrHier S; static def_t deflist[] = { {"Strings", T_STRPTR_ARRY, (void *)NULL, IS_REQUIRED}, {NULL}, }; char new_prefix[80]; int n_strings, i; memset(new_prefix, 0, sizeof(new_prefix)); deflist[0].required = IS_OPTIONAL; if (parse_config(handle, prefix, deflist) != 0) { return NULL; } n_strings = deflist[0].n_values; if (!(S=StrHierCreateNodes(n_strings))) { return NULL; } for (i=0; ivalue)[i]; S[i].str = val; S[i].number = i+1; L = LinkAppend(L, (void *)&S[i]); S[i].parent = parent; pos = strstr(val, ".scf"); if (pos) S[i].GetNextItems = SCFNextItems; else if (level == 4) S[i].GetNextItems = VIDFNextItems; else S[i].GetNextItems = IDFSNextItems; } free(deflist->value); /* * JM - commented this out so we could accept hierarchies of less than 5 * if (++level > 4) { level--; return L; } */ for (i=0; i')) new_prefix [j] = '_'; /* convert spaces, commas, and ">" to an underscore */ S[i].sublist = aConfig(handle, new_prefix, &S[i]); } level--; return L; } /*************************************** * private routines ***************************************/ /* * char *file - name of the config file * * This routine returns a tree definition of all projects in the configuration file */ LinkList P_Config(char *file) { config_t *p_handle; LinkList ret; if ((p_handle = open_config(file, 0)) == NULL) { fprintf(stderr, "...Error opening %s\n", file); exit(3); } ret = aConfig(p_handle, NULL, NULL); close_config(p_handle); return ret; }