IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31903


Ignore:
Timestamp:
Jul 19, 2011, 12:01:08 PM (15 years ago)
Author:
eugene
Message:

added -get-key option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppConfigDump/src/ppConfigDump.c

    r29925 r31903  
    101101    psMetadataAddStr(arguments, PS_LIST_TAIL, "-dump-format", 0, "Filename for camera format", NULL);
    102102    psMetadataAddStr(arguments, PS_LIST_TAIL, "-dump-recipes", 0, "Filename for recipes", NULL);
     103
     104    psMetadataAddStr(arguments, PS_LIST_TAIL, "-get-key", PS_META_DUPLICATE_OK, "Key to return", NULL);
     105
    103106    psMetadata *recipeArgs = psMetadataAlloc(); // Options for dumping a single recipe
    104107    psMetadataAddStr(recipeArgs, PS_LIST_TAIL, "recipe", 0, "Name of recipe", NULL);
     
    112115        fprintf(stderr, "       [-dump-camera FILE.mdc] [-dump-format FILE.mdc] [-dump-recipes FILE.mdc]\n");
    113116        fprintf(stderr, "       [-dump-recipe RECIPE FILE.mdc]\n");
     117        fprintf(stderr, "       [-get-key KEY]\n");
    114118        fprintf(stderr, "\n");
    115119        fprintf(stderr, "       FILE.mdc may be \"-\", in which case the file is written to stdout.\n");
     
    191195    }
    192196
     197    // parse the -get-key stuff:
     198    psMetadataItem *item = psMetadataLookup(arguments, "-get-key");
     199    psAssert (item->type == PS_DATA_METADATA_MULTI, "created above with this type");
     200    psListIterator *iter = psListIteratorAlloc(item->data.list, 0, false);
     201    psMetadataItem *mItem = NULL;
     202    while ((mItem = psListGetAndIncrement(iter))) {
     203        char *getKey = mItem->data.str;
     204        if (!getKey) continue;
     205        psMetadataItem *keyItem = psMetadataLookup (config->camera, getKey);
     206        if (!keyItem) continue;
     207        psString str = psMetadataItemFormat(keyItem);
     208        fprintf (stdout, "%s", str);
     209        psFree (str);
     210    }
     211    psFree(iter);
     212       
    193213    die(PS_EXIT_SUCCESS);
    194214}
    195 
Note: See TracChangeset for help on using the changeset viewer.