Changeset 12916
- Timestamp:
- Apr 18, 2007, 4:10:12 PM (19 years ago)
- Location:
- trunk/psModules/src/config
- Files:
-
- 3 edited
-
pmConfig.h (modified) (5 diffs)
-
pmConfigRecipes.c (modified) (8 diffs)
-
pmConfigRecipes.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfig.h
r12906 r12916 5 5 * @author Eugene Magnier, IfA 6 6 * 7 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-04-1 8 22:42:33$7 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-04-19 02:10:12 $ 9 9 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 10 10 */ … … 61 61 62 62 /// Allocator for pmConfig 63 pmConfig *pmConfigAlloc(int *argc, /// Number of command-line arguments 64 char **argv /// Command-line arguments 65 ); 63 pmConfig *pmConfigAlloc(); 66 64 67 65 /// Set static configuration information … … 84 82 pmConfig *pmConfigRead(int *argc, ///< Number of command-line arguments 85 83 char **argv, ///< Array of command-line arguments 86 c har *defaultRecipe ///< name of top-level recipe for this program84 const char *defaultRecipe ///< name of top-level recipe for this program 87 85 ); 88 86 … … 143 141 /// Given the 'file' and 'list' arguments (e.g., "-file" and "-list"), find the arguments associated with 144 142 /// these words and interpret them as lists of files. Return an array of the resulting filenames. 145 psArray *pmConfigFileSets(pmConfig *config, ///< Configuration, containing command-line arguments 143 psArray *pmConfigFileSets(int *argc, ///< Number of arguments (I/O) 144 char **argv, ///< Array of arguments 146 145 const char *file, ///< CL argument specifying a filename 147 146 const char *list ///< CL argument specifying a text file with a list of filenames … … 153 152 /// stuffs the array of filenames into the metadata under "name". 154 153 bool pmConfigFileSetsMD(psMetadata *metadata, ///< Metadata into which to stuff the array 155 pmConfig *config, ///< Configuration (which command-line arguments) 154 int *argc, ///< Number of arguments (I/O) 155 char **argv, ///< Array of arguments 156 156 const char *name, ///< Name for array in the metadata 157 157 const char *file, ///< CL argument specifying a filename -
trunk/psModules/src/config/pmConfigRecipes.c
r12890 r12916 51 51 52 52 // this function may be called several times. it attempts to load the recipe data from one of 53 // three locations: config->site, config->camera, and config->argv. We cannot read the recipes53 // three locations: config->site, config->camera, and argv. We cannot read the recipes 54 54 // from config->camera until a camera has been read BUT, the argv recipes must override the 55 55 // camera and site recipes. … … 124 124 125 125 // search for options of the form -D KEY VALUE or -D RECIPE:KEY VALUE 126 bool pmConfigLoadRecipeOptions ( pmConfig *config, char *flag)126 bool pmConfigLoadRecipeOptions (int *argc, char **argv, pmConfig *config, char *flag) 127 127 { 128 128 bool success; … … 140 140 141 141 // -D key value (all added as string) 142 while ((argNum = psArgumentGet (* config->argc, config->argv, flag))) {143 psArgumentRemove (argNum, config->argc, config->argv);142 while ((argNum = psArgumentGet (*argc, argv, flag))) { 143 psArgumentRemove (argNum, argc, argv); 144 144 145 145 // do we have enough arguments? 146 if (argNum + 1 >= * config->argc) {146 if (argNum + 1 >= *argc) { 147 147 psError(PS_ERR_IO, true, "insufficient parameters for command-line argument -D"); 148 148 return false; … … 152 152 const char *recipeName = NULL; 153 153 char *key; 154 psArray *words = psStringSplitArray( config->argv[argNum], ":", false);154 psArray *words = psStringSplitArray(argv[argNum], ":", false); 155 155 switch (words->n) { 156 156 case 1: … … 182 182 bool valid = false; 183 183 if (!strcmp (flag, "-D")) { 184 psMetadataAddStr (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", config->argv[argNum+1]);184 psMetadataAddStr (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", argv[argNum+1]); 185 185 valid = true; 186 186 } 187 187 if (!strcmp (flag, "-Di")) { 188 psMetadataAddS32 (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", atoi( config->argv[argNum+1]));188 psMetadataAddS32 (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", atoi(argv[argNum+1])); 189 189 valid = true; 190 190 } 191 191 if (!strcmp (flag, "-Df")) { 192 psMetadataAddF32 (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", atof( config->argv[argNum+1]));192 psMetadataAddF32 (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", atof(argv[argNum+1])); 193 193 valid = true; 194 194 } 195 195 if (!strcmp (flag, "-Db")) { 196 if (!strcasecmp ( config->argv[argNum+1], "true")) {196 if (!strcasecmp (argv[argNum+1], "true")) { 197 197 psMetadataAddBool (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", true); 198 198 } else { … … 204 204 assert (valid); // flag may be: -D, -Df, -Di, -Db 205 205 206 psArgumentRemove (argNum, config->argc, config->argv);207 psArgumentRemove (argNum, config->argc, config->argv);206 psArgumentRemove (argNum, argc, argv); 207 psArgumentRemove (argNum, argc, argv); 208 208 } 209 209 return true; … … 214 214 // if VALUE is not an exiting file, it is a symbolic lookup: it is saved on config->recipeSymbols 215 215 // for later interpolation (pmConfigReadRecipes with option CL) 216 bool pmConfigLoadRecipeArguments ( pmConfig *config)216 bool pmConfigLoadRecipeArguments (int *argc, char **argv, pmConfig *config) 217 217 { 218 218 bool success; … … 228 228 // Go through the command-line arguments 229 229 int argNum; // Argument number for "-recipe" 230 while ((argNum = psArgumentGet(* config->argc, config->argv, "-recipe")) > 0) {231 psArgumentRemove(argNum, config->argc, config->argv);232 if (argNum + 1 >= * config->argc) {230 while ((argNum = psArgumentGet(*argc, argv, "-recipe")) > 0) { 231 psArgumentRemove(argNum, argc, argv); 232 if (argNum + 1 >= *argc) { 233 233 psError(PS_ERR_IO, false, "-recipe command-line switch provided without the required recipe and source\n"); 234 234 return false; 235 235 } 236 236 237 char *recipeName = psStringCopy( config->argv[argNum]); // Name of the recipe238 psArgumentRemove(argNum, config->argc, config->argv);239 char *recipeSource = psStringCopy( config->argv[argNum]); // Source of the recipe240 psArgumentRemove(argNum, config->argc, config->argv);237 char *recipeName = psStringCopy(argv[argNum]); // Name of the recipe 238 psArgumentRemove(argNum, argc, argv); 239 char *recipeSource = psStringCopy(argv[argNum]); // Source of the recipe 240 psArgumentRemove(argNum, argc, argv); 241 241 242 242 if (access(recipeSource, R_OK) == 0) { -
trunk/psModules/src/config/pmConfigRecipes.h
r11251 r12916 6 6 * @author Eugene Magnier, IfA 7 7 * 8 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 1-24 01:05:41$8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-04-19 02:10:12 $ 10 10 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 11 11 */ … … 26 26 27 27 28 bool pmConfigLoadRecipeArguments ( pmConfig *config);29 bool pmConfigLoadRecipeOptions ( pmConfig *config, char *flag);28 bool pmConfigLoadRecipeArguments (int *argc, char **argv, pmConfig *config); 29 bool pmConfigLoadRecipeOptions (int *argc, char **argv, pmConfig *config, char *flag); 30 30 psMetadata *pmConfigRecipeOptions (pmConfig *config, char *recipe); 31 31
Note:
See TracChangeset
for help on using the changeset viewer.
