IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 5, 2006, 11:47:33 AM (20 years ago)
Author:
Paul Price
Message:

Fixing tracing to use conventional system for facility names.
Removing errors within psMetadataLookupMetadata by using psMetadataLookup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfigRecipes.c

    r10470 r10481  
    6464    if (config->site && (source & PM_RECIPE_SOURCE_SITE)) {
    6565        if (!loadRecipeFiles(config, config->site, PM_RECIPE_SOURCE_SITE, "site configuration")) {
    66             psLogMsg ("psModules.pmConfig", PS_LOG_WARN, "Failed to read recipes from site config");
    67         } else {
    68             psTrace ("psModules.pmConfig", 3, "read recipes from site config");
     66            psLogMsg ("psModules.config", PS_LOG_WARN, "Failed to read recipes from site config");
     67        } else {
     68            psTrace ("psModules.config", 3, "read recipes from site config");
    6969        }
    7070    }
     
    7676    if (config->camera && (source & PM_RECIPE_SOURCE_CAMERA) && !(config->recipesRead & PM_RECIPE_SOURCE_CAMERA)) {
    7777        if (!loadRecipeFiles(config, config->camera, PM_RECIPE_SOURCE_CAMERA, "camera configuration")) {
    78             psLogMsg ("psModules.pmConfig", PS_LOG_DETAIL, "no recipe supplied by camera config");
    79         } else {
    80             psTrace ("psModules.pmConfig", 3, "read recipes from camera config");
     78            psLogMsg ("psModules.config", PS_LOG_DETAIL, "no recipe supplied by camera config");
     79        } else {
     80            psTrace ("psModules.config", 3, "read recipes from camera config");
    8181        }
    8282    }
     
    8585    if (config->arguments && (source & PM_RECIPE_SOURCE_CL)) {
    8686        if (!loadRecipeFromArguments(config)) {
    87             psLogMsg ("psModules.pmConfig", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");
    88         } else {
    89             psTrace ("psModules.pmConfig", 3, "read recipes from command-line arguments");
     87            psLogMsg ("psModules.config", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");
     88        } else {
     89            psTrace ("psModules.config", 3, "read recipes from command-line arguments");
    9090        }
    9191        if (!loadRecipeSymbols(config)) {
    92             psLogMsg ("psModules.pmConfig", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");
    93         } else {
    94             psTrace ("psModules.pmConfig", 3, "read recipes from command-line arguments");
     92            psLogMsg ("psModules.config", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");
     93        } else {
     94            psTrace ("psModules.config", 3, "read recipes from command-line arguments");
    9595        }
    9696        if (!loadRecipeOptions(config)) {
    97             psLogMsg ("psModules.pmConfig", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");
    98         } else {
    99             psTrace ("psModules.pmConfig", 3, "read recipes from command-line arguments");
     97            psLogMsg ("psModules.config", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");
     98        } else {
     99            psTrace ("psModules.config", 3, "read recipes from command-line arguments");
    100100        }
    101101    }
     
    117117    // save the recipes onto config->arguments:RECIPES
    118118    // increment so we can free below (is a NOP is options is NULL)
    119     psMetadata *options = psMemIncrRefCounter (psMetadataLookupMetadata(NULL, config->arguments, "OPTIONS"));
    120     if (!options) {
    121         options = psMetadataAlloc ();
    122         psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "OPTIONS",  PS_DATA_METADATA, "", options);
     119    psMetadata *options;                // OPTIONS on the arguments
     120    psMetadataItem *optionsItem = psMetadataLookup(config->arguments, "OPTIONS");
     121    if (optionsItem) {
     122        if (optionsItem->type != PS_DATA_METADATA) {
     123            psAbort(__func__, "OPTIONS is not of type METADATA.");
     124        }
     125        options = psMemIncrRefCounter(optionsItem->data.V);
     126    } else {
     127        options = psMetadataAlloc();
     128        psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "OPTIONS",  PS_DATA_METADATA,
     129                         "Command-line options specified with -D", options);
    123130    }
    124131
     
    200207bool pmConfigLoadRecipeArguments (pmConfig *config)
    201208{
     209    psMetadata *recipes;                // Recipes in the arguments list
     210    psMetadataItem *recipesItem = psMetadataLookup(config->arguments, "RECIPES");
     211    if (recipesItem) {
     212        if (recipesItem->type != PS_DATA_METADATA) {
     213            psAbort(__func__, "RECIPES is not of type METADATA.");
     214        }
     215        recipes = psMemIncrRefCounter(recipesItem->data.V);
     216    } else {
     217        recipes = psMetadataAlloc();
     218        psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "RECIPES",  PS_DATA_METADATA, "", recipes);
     219    }
     220
    202221
    203222    // Go through the command-line arguments
     
    218237            // The source is a file: load onto config->arguments
    219238            // save the recipes onto config->arguments:RECIPES
    220             psMetadata *recipes = psMemIncrRefCounter (psMetadataLookupMetadata(NULL, config->arguments, "RECIPES"));
    221             if (!recipes) {
    222                 recipes = psMetadataAlloc ();
    223                 psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "RECIPES",  PS_DATA_METADATA, "", recipes);
    224             }
    225239
    226240            psMetadata *recipe = NULL;      // Recipe from file
     
    228242                psString comment = psStringCopy("Recipe added at command line from ");
    229243                psStringAppend(&comment, "%s", recipeSource);
    230                 psMetadataAdd(recipes, PS_LIST_TAIL, recipeName, PS_DATA_METADATA | PS_META_REPLACE, comment, recipe);
     244                psMetadataAdd(recipes, PS_LIST_TAIL, recipeName, PS_DATA_METADATA | PS_META_REPLACE,
     245                              comment, recipe);
    231246                psFree(comment);
    232247                psFree(recipe);                 // Drop reference
     
    234249                psAbort ("pmConfig.c", "error reading config file %s\n", recipeSource);
    235250            }
    236             psFree (recipes);
    237251        } else {
    238252            // Assume it's a symbolic reference to something that's not yet read in.
    239253            // it will be loaded later by pmConfigReadRecipes with option CL
    240             psMetadataAddStr(config->recipeSymbols, PS_LIST_TAIL, recipeName, PS_META_REPLACE, "", recipeSource);
    241         }
    242         psTrace ("psModules.pmConfig", 3, "read recipe %s from %s", recipeName, recipeSource);
     254            psMetadataAddStr(config->recipeSymbols, PS_LIST_TAIL, recipeName, PS_META_REPLACE, "",
     255                             recipeSource);
     256        }
     257        psTrace ("psModules.config", 3, "read recipe %s from %s", recipeName, recipeSource);
    243258        psFree(recipeName);
    244259        psFree(recipeSource);
    245260    } // Iterating through the command-line arguments
    246261
     262    psFree(recipes);                    // Drop reference
    247263    return true;
    248264}
     
    262278    }
    263279    if (!source) {
    264         psTrace("psModules.pmConfig", 4, "The %s has not been read --- cannot read recipes from this "
     280        psTrace("psModules.config", 4, "The %s has not been read --- cannot read recipes from this "
    265281                "location.\n", sourceName);
    266282        config->recipesRead &= ~sourceType;
     
    270286    psMetadata *recipes = psMetadataLookupMetadata(NULL, source, "RECIPES"); // The list of recipes
    271287    if (!recipes) {
    272         psLogMsg("psModules.pmConfig", PS_LOG_WARN, "RECIPES not found in the %s\n", sourceName);
     288        psLogMsg("psModules.config", PS_LOG_WARN, "RECIPES not found in the %s\n", sourceName);
    273289        config->recipesRead &= ~sourceType;
    274290        return false;
     
    289305        psString comment = NULL;
    290306        psStringAppend(&comment, "Recipe added at %s from %s", sourceName, (char*)fileItem->data.V);
    291         psTrace ("psModules.pmConfig", 3, comment);
    292         psMetadataAddS32(config->recipesSource, PS_LIST_TAIL, fileItem->name, PS_META_REPLACE, comment, sourceType);
     307        psTrace ("psModules.config", 3, comment);
     308        psMetadataAddS32(config->recipesSource, PS_LIST_TAIL, fileItem->name, PS_META_REPLACE,
     309                         comment, sourceType);
    293310        psFree(comment);
    294311        #endif
     
    304321
    305322        // if this named recipe exists, supplement it
    306         psMetadata *current = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->recipes,
    307                               fileItem->name));
    308         current = psMetadataCopy (current, recipe);
     323        psMetadata *current = NULL;     // Current, extant recipe of the same name, to be supplemented
     324        psMetadataItem *currentItem = psMetadataLookup(config->recipes, fileItem->name);
     325        if (currentItem) {
     326            if (currentItem->type != PS_DATA_METADATA) {
     327                psAbort(__func__, "Item from recipes is not of type METADATA.");
     328            }
     329            current = psMemIncrRefCounter(currentItem->data.V);
     330            psTrace("psModules.config", 3, "Supplementing %s from %s within %s.\n", currentItem->name,
     331                    fileItem->name, sourceName);
     332        }
     333        current = psMetadataCopy(current, recipe);
    309334        psFree(recipe);  // Drop reference
    310335        psMetadataAdd(config->recipes, PS_LIST_TAIL, fileItem->name, PS_DATA_METADATA | PS_META_REPLACE,
     
    325350    assert(config);
    326351    if (!config->arguments) {
    327         psTrace("psModules.pmConfig", 4, "no config->arguments metadata, nothing to read here");
     352        psTrace("psModules.config", 4, "no config->arguments metadata, nothing to read here");
    328353        return false;
    329354    }
     
    331356    psMetadata *recipes = psMetadataLookupMetadata(NULL, config->arguments, "RECIPES"); // The list of recipes
    332357    if (!recipes) {
    333         psTrace("psModules.pmConfig", 4, "no RECIPES in config->arguments, nothing to read here");
     358        psTrace("psModules.config", 4, "no RECIPES in config->arguments, nothing to read here");
    334359        return false;
    335360    }
     
    415440    assert(config);
    416441    if (!config->arguments) {
    417         psTrace("psModules.pmConfig", 4, "no config->arguments metadata, nothing to read here");
     442        psTrace("psModules.config", 4, "no config->arguments metadata, nothing to read here");
    418443        return false;
    419444    }
     
    421446    psMetadata *recipes = psMetadataLookupMetadata(NULL, config->arguments, "OPTIONS"); // The list of recipes
    422447    if (!recipes) {
    423         psTrace("psModules.pmConfig", 4, "no OPTIONS in config->arguments, nothing to read here");
     448        psTrace("psModules.config", 4, "no OPTIONS in config->arguments, nothing to read here");
    424449        return false;
    425450    }
Note: See TracChangeset for help on using the changeset viewer.