IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 18, 2007, 4:10:12 PM (19 years ago)
Author:
rhl
Message:

pmConfig no longer owns arg[cv];

File:
1 edited

Legend:

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

    r12890 r12916  
    5151
    5252// 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 recipes
     53// three locations: config->site, config->camera, and argv.  We cannot read the recipes
    5454// from config->camera until a camera has been read BUT, the argv recipes must override the
    5555// camera and site recipes.
     
    124124
    125125// search for options of the form -D KEY VALUE or -D RECIPE:KEY VALUE
    126 bool pmConfigLoadRecipeOptions (pmConfig *config, char *flag)
     126bool pmConfigLoadRecipeOptions (int *argc, char **argv, pmConfig *config, char *flag)
    127127{
    128128    bool success;
     
    140140
    141141    // -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);
    144144
    145145        // do we have enough arguments?
    146         if (argNum + 1 >= *config->argc) {
     146        if (argNum + 1 >= *argc) {
    147147            psError(PS_ERR_IO, true, "insufficient parameters for command-line argument -D");
    148148            return false;
     
    152152        const char *recipeName = NULL;
    153153        char *key;
    154         psArray *words = psStringSplitArray(config->argv[argNum], ":", false);
     154        psArray *words = psStringSplitArray(argv[argNum], ":", false);
    155155        switch (words->n) {
    156156        case 1:
     
    182182        bool valid = false;
    183183        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]);
    185185            valid = true;
    186186        }
    187187        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]));
    189189            valid = true;
    190190        }
    191191        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]));
    193193            valid = true;
    194194        }
    195195        if (!strcmp (flag, "-Db")) {
    196             if (!strcasecmp (config->argv[argNum+1], "true")) {
     196            if (!strcasecmp (argv[argNum+1], "true")) {
    197197                psMetadataAddBool (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", true);
    198198            } else {
     
    204204        assert (valid);  // flag may be: -D, -Df, -Di, -Db
    205205
    206         psArgumentRemove (argNum, config->argc, config->argv);
    207         psArgumentRemove (argNum, config->argc, config->argv);
     206        psArgumentRemove (argNum, argc, argv);
     207        psArgumentRemove (argNum, argc, argv);
    208208    }
    209209    return true;
     
    214214// if VALUE is not an exiting file, it is a symbolic lookup: it is saved on config->recipeSymbols
    215215// for later interpolation (pmConfigReadRecipes with option CL)
    216 bool pmConfigLoadRecipeArguments (pmConfig *config)
     216bool pmConfigLoadRecipeArguments (int *argc, char **argv, pmConfig *config)
    217217{
    218218    bool success;
     
    228228    // Go through the command-line arguments
    229229    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) {
    233233            psError(PS_ERR_IO, false, "-recipe command-line switch provided without the required recipe and source\n");
    234234            return false;
    235235        }
    236236
    237         char *recipeName = psStringCopy(config->argv[argNum]); // Name of the recipe
    238         psArgumentRemove(argNum, config->argc, config->argv);
    239         char *recipeSource = psStringCopy(config->argv[argNum]); // Source of the recipe
    240         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);
    241241
    242242        if (access(recipeSource, R_OK) == 0) {
Note: See TracChangeset for help on using the changeset viewer.