Changeset 6569
- Timestamp:
- Mar 9, 2006, 4:05:10 PM (20 years ago)
- Location:
- branches/rel10_ifa/psModules/src/config
- Files:
-
- 2 edited
-
pmConfig.c (modified) (8 diffs)
-
pmConfig.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psModules/src/config/pmConfig.c
r6553 r6569 3 3 * @author PAP, IfA 4 4 * 5 * @version $Revision: 1.7.4. 3$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-03- 09 03:09:28$5 * @version $Revision: 1.7.4.4 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-03-10 02:05:06 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 23 23 psFree(config->site); 24 24 psFree(config->camera); 25 psFree(config->recipe );25 psFree(config->recipes); 26 26 psFree(config->arguments); 27 27 psFree(config->database); … … 36 36 config->site = NULL; 37 37 config->camera = NULL; 38 config->recipe = NULL;38 config->recipes = NULL; 39 39 config->arguments = NULL; 40 40 config->database = NULL; … … 85 85 pmConfig *pmConfigRead( 86 86 int *argc, 87 char **argv, 88 const char *recipeName) 87 char **argv) 89 88 { 90 89 PS_ASSERT_INT_POSITIVE(*argc, false); 91 90 PS_ASSERT_PTR_NON_NULL(argv, false); 92 91 93 pmConfig *config = pmConfigAlloc(); // The configuration, containing site, camera and recipe 92 pmConfig *config = pmConfigAlloc(); // The configuration, containing site, camera and recipes 94 93 95 94 // … … 164 163 } 165 164 166 // 167 // Next, we do a similar thing for the recipe configuration file. The 168 // file is read and parsed into psMetadata struct "recipe". 169 // 170 // 171 argNum = psArgumentGet(*argc, argv, "-recipe"); 172 if (argNum > 0) { 173 psArgumentRemove(argNum, argc, argv); 174 if (argNum >= *argc) { 175 psLogMsg(__func__, PS_LOG_WARN, 176 "-recipe command-line switch provided without the required filename --- ignored.\n"); 177 } else { 178 psArgumentRemove(argNum, argc, argv); 179 readConfig(&config->recipe, argv[argNum], "recipe"); 180 } 181 } 182 // Or, load the recipe from the camera file, if appropriate 183 if (! config->recipe && config->camera && recipeName) { 184 pmConfigRecipeFromCamera(config, recipeName); 165 // Load the recipes from the camera file, if appropriate 166 if (! config->recipes && config->camera) { 167 pmConfigReadRecipes(config); 185 168 } 186 169 … … 470 453 } 471 454 455 // Now we have the camera, we can read the recipes 456 if (!config->recipes) { 457 pmConfigReadRecipes(config); 458 } 459 472 460 return format; 473 461 } … … 482 470 } 483 471 484 bool pmConfigRe cipeFromCamera(485 pmConfig *config ,486 const char *recipeName)472 bool pmConfigReadRecipes( 473 pmConfig *config 474 ) 487 475 { 488 476 PS_ASSERT_PTR_NON_NULL(config, false); 489 477 PS_ASSERT_PTR_NON_NULL(config->camera, false); 490 PS_ASSERT_PTR_NON_NULL(recipeName, false);491 478 492 479 bool mdok = true; // Status of MD lookup … … 496 483 return false; 497 484 } 498 psString recipeFileName = psMetadataLookupStr(&mdok, recipes, recipeName); 499 (void)readConfig(&config->recipe, recipeFileName, "recipe"); 485 // Go through the recipes and load each one 486 psMetadataIterator *recipesIter = psMetadataIteratorAlloc(recipes, PS_LIST_HEAD, NULL); // Iterator 487 psMetadataItem *recipesItem = NULL; // Item from iteration 488 while ((recipesItem = psMetadataGetAndIncrement(recipesIter))) { 489 if (recipesItem->type != PS_DATA_STRING) { 490 psLogMsg(__func__, PS_LOG_WARN, "Filename for recipe %s isn't of type STR --- ignored.\n", 491 recipesItem->name); 492 continue; 493 } 494 495 psMetadata *recipe = NULL; // Recipe from file 496 if (readConfig(&recipe, recipesItem->data.V, "recipe")) { 497 psMetadataAdd(config->recipes, PS_LIST_TAIL, recipesItem->name, 498 PS_DATA_METADATA | PS_META_REPLACE, recipesItem->comment, recipe); 499 } 500 psFree(recipe); // Drop reference 501 } 502 psFree(recipesIter); 500 503 501 504 return true; -
branches/rel10_ifa/psModules/src/config/pmConfig.h
r6553 r6569 3 3 * @author PAP, IfA 4 4 * 5 * @version $Revision: 1.3.4. 1$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-03- 09 03:09:28$5 * @version $Revision: 1.3.4.2 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-03-10 02:05:10 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 psMetadata *site; // Site configuration 21 21 psMetadata *camera; // Camera specification 22 psMetadata *recipe ; // Recipefor processing22 psMetadata *recipes; // Recipes for processing 23 23 psMetadata *arguments; // Command-line arguments 24 24 psDB *database; // Database handle … … 46 46 pmConfig *pmConfigRead( 47 47 int *argc, 48 char **argv, 49 const char *recipeName); 50 48 char **argv); 51 49 52 50 /** pmConfigValidateCamera … … 78 76 /** pmConfigRecipeFromCamera 79 77 * 80 * pmConfigRecipeFromCamera shall load the recipe configuration based on the 81 * recipeName and the list of known recipes contained in the camera 78 * pmConfigRecipeFromCamera shall load the recipes from the list of known recipes contained in the camera 82 79 * configuration. 83 80 * 84 81 */ 85 bool pmConfigRecipeFromCamera( 86 pmConfig *config, 87 const char *recipeName 82 bool pmConfigReadRecipes( 83 pmConfig *config 88 84 ); 89 85
Note:
See TracChangeset
for help on using the changeset viewer.
