IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7820


Ignore:
Timestamp:
Jul 5, 2006, 2:39:22 PM (20 years ago)
Author:
jhoblitt
Message:

update p0searchConfig()

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/regtool.h

    r7815 r7820  
    55
    66typedef enum {
    7     P0SEARCH_MODE_NODE      = 0x0,
     7    P0SEARCH_MODE_NONE      = 0x0,
    88    P0SEARCH_MODE_PENDING,
    99    P0SEARCH_MODE_UPDATE
  • trunk/ippTools/src/regtoolConfig.c

    r7815 r7820  
    66
    77#include "pxtools.h"
    8 #include "dettool.h"
     8#include "p0search.h"
    99
    1010// this function can not fail -- exits on error
    11 bool p0searchConfig(pxConfig *config, int argc, char **argv) {
     11pxConfig *p0searchConfig(pxConfig *config, int argc, char **argv) {
    1212    if (!config) {
    1313        config = pxConfigAlloc();
     
    1515
    1616    // setup site config
    17     config->modules = pmConfigRead(argc, argv);
     17    config->modules = pmConfigRead(&argc, argv);
    1818    if (!config->modules) {
    1919        psError(PS_ERR_UNKNOWN, false, "Can't find site configuration");
    2020        goto FAIL;
    2121    }
    22     argc = config->argc;
    2322
    2423    // -pending
     
    5049
    5150#define PXTOOL_MODE(option, modeval, argset) \
     51{ \
     52    int N = 0; \
    5253    if ((N = psArgumentGet (argc, argv, option))) { \
    5354        psArgumentRemove (N, &argc, argv); \
     
    5758        config->mode = modeval; \
    5859        config->args = psMemIncrRefCounter(argset); \
    59     }
     60    } \
     61}
    6062
    6163    // find which mode we're running under
    6264    PXTOOL_MODE("-pending",     P0SEARCH_MODE_PENDING,      pendingArgs);
    63     PXTOOL_MODE("-update",      P0SEARCH_MODE_UPDATE,       updatergs);
    64 
     65    PXTOOL_MODE("-update",      P0SEARCH_MODE_UPDATE,       updateArgs);
    6566
    6667    bool argErr = false;
     
    6869        argErr = true;
    6970        fprintf (stderr, "mode argument is required\n");
    70     } else if (! psArgumentParse(args, &argc, argv) || argc != 1) {
     71    } else if (! psArgumentParse(config->args, &argc, argv) || argc != 1) {
    7172        argErr = true;
    7273        fprintf (stderr, "error parsing arguments\n");
     
    104105{
    105106    psString str = NULL;
    106     int n = 0;
    107107    bool status = false;
    108     bool boolean = false;
    109108
     109    addWhereStr(exp_id);
     110    // convert '-inst' to 'camera'
     111    if ((str = psMetadataLookupStr(&status, config->args, "-inst"))) {
     112        if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
     113            psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
     114            goto FAIL;
     115        }
     116    }
     117    addWhereStr(telescope);
     118    addWhereStr(exp_type);
     119    addWhereStr(class_id);
     120    addWhereStr(filter);
     121}
    110122
    111     switch (config->mode) {
    112         bool status;
    113         case PX_MODE_PENDING:
    114             // -exp_id
    115             config->exp_id = psMetadataLookupStr(&status, args, "-exp_id");
    116             psMemIncrRefCounter(config->exp_id);
    117             EMPTY_TO_NULL_STRING(config->exp_id);
    118             // -inst
    119             config->camera_name = psMetadataLookupStr(&status, args, "-inst");
    120             psMemIncrRefCounter(config->camera_name);
    121             EMPTY_TO_NULL_STRING(config->camera_name);
    122             // -telescope
    123             config->camera_name = psMetadataLookupStr(&status, args,
    124                 "-telescope");
    125             psMemIncrRefCounter(config->telescope);
    126             EMPTY_TO_NULL_STRING(config->telescope);
    127             // -exp_type
    128             config->class = psMetadataLookupStr(&status, args, "-exp_type");
    129             psMemIncrRefCounter(config->exp_type);
    130             EMPTY_TO_NULL_STRING(config->exp_type);
    131             // -class
    132             config->class = psMetadataLookupStr(&status, args, "-class");
    133             psMemIncrRefCounter(config->class);
    134             EMPTY_TO_NULL_STRING(config->class);
    135             break;
    136         case PX_MODE_UPDATE:
    137             // -exp_id
    138             config->exp_id = psMetadataLookupStr(&status, args, "-exp_id");
    139             psMemIncrRefCounter(config->exp_id);
    140             EMPTY_TO_NULL_STRING(config->exp_id);
    141             // -filter
    142             config->filter = psMetadataLookupStr(&status, args, "-filter");
    143             psMemIncrRefCounter(config->filter);
    144             EMPTY_TO_NULL_STRING(config->filter);
    145 
    146             break;
    147         default:
    148             psAbort(argv[0], "invalid option (this should not happen)");
     123    if (config->where->list->n < 1) {
     124        psFree(config->where);
     125        config->where = NULL;
    149126    }
    150127
    151     psFree(args);
    152     psFree(pendingArgs);
    153     psFree(updateArgs);
    154 
    155 
    156     psMetadata *where = psMetadataAlloc();
    157 
    158     if (config->camera_name != NULL) {
    159         if (!psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, "==",
    160             config->camera_name)) {
    161             psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
    162             psFree(where);
    163             return NULL;
    164         }
    165     }
    166     if (config->filter != NULL) {
    167         psMetadataAddStr(where, PS_LIST_TAIL, "filter", 0, "==",
    168             config->filter);
    169     }
    170     if (config->exp_id != NULL) {
    171         psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==",
    172             config->exp_id);
    173     }
    174     if (config->class != NULL) {
    175         psMetadataAddStr(where, PS_LIST_TAIL, "class", 0, "==",
    176             config->class);
    177     }
    178     if (config->class_id != NULL) {
    179         psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==",
    180              config->class_id);
    181     }
    182 
    183     /*
    184     // psMetadataConfig does not support times yet
    185     if (!psTimeIsZero(config->start) && !psTimeIsZero(config->stop)) {
    186         psMetadataAddTime (where, PS_LIST_TAIL, "TIME_START", 0, "<", config->stop);
    187         psMetadataAddTime (where, PS_LIST_TAIL, "TIME_STOP", 0, ">", config->start);
    188     }
    189     */
    190 
    191     if (where->list->n < 1) {
    192         psFree(where);
    193         where = NULL;
    194     }
    195 
    196     config->where = where;
    197 
    198 
    199     // add the input and output images to the args list
    200     //psMetadataAddStr (args, PS_LIST_TAIL, "-output", 0, "Name of the output image", argv[1]);
    201128
    202129    // define Database handle, if used
Note: See TracChangeset for help on using the changeset viewer.