IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 20, 2008, 3:48:37 PM (18 years ago)
Author:
eugene
Message:

merging changes from JHs end_stage branch (new end_stage field and related features; substantial cleanup via macros)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/camtool.c

    r15957 r16170  
    8989}
    9090
    91 #define ADDRENAMEPARAMSTR(from, to, oldname, newname, comment) \
    92 { \
    93     bool status = false; \
    94     psString str = psMetadataLookupStr(&status, from, "-" oldname); \
    95     if (!status) { \
    96         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" oldname); \
    97         return false; \
    98     } \
    99     if (str) { \
    100         if (!psMetadataAddStr(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, comment, str)) { \
    101             psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \
    102             psFree(to); \
    103             return false; \
    104         } \
    105     } \
    106 }
    107 
    108 #define ADDPARAMSTR(from, to, name) \
    109   ADDRENAMEPARAMSTR(from, to, name, name, "==")
    110 
    111 #define ADDRENAMEPARAMF(from, to, type, oldname, newname, comment) \
    112 { \
    113     bool status = false; \
    114     ps##type var = psMetadataLookup##type(&status, from, "-" oldname); \
    115     if (!status) { \
    116         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" oldname); \
    117         return false; \
    118     } \
    119     if (!isnan(var)) { \
    120         if (!psMetadataAdd##type(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, comment, var)) { \
    121             psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \
    122             psFree(to); \
    123             return false; \
    124         } \
    125     } \
    126 }
    127 
    128 #define ADDPARAMF(from, to, type, name) \
    129   ADDRENAMEPARAMF(from, to, type, name, name, "==")
    13091
    13192static bool queueMode(pxConfig *config)
    13293{
    13394    PS_ASSERT_PTR_NON_NULL(config, NULL);
     95
     96    PXOPT_LOOKUP_STR(chip_id, config->args, "-chip_id", false, false);
     97    PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", false, false);
    13498
    13599    psMetadata *where = psMetadataAlloc();
    136100    // convert chip_id into a psS64
    137 {
    138     bool status = false;
    139     psString var = psMetadataLookupStr(&status, config->args, "-chip_id");
    140     if (!status) {
    141         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -chip_id");
    142         return false;
    143     }
    144     if (var) {
    145         if (!psMetadataAddS64(where, PS_LIST_TAIL, "chip_id", 0, "==", (psS64)atoll(var))) {
     101    if (chip_id) {
     102        if (!psMetadataAddS64(where, PS_LIST_TAIL, "chip_id", 0, "==", (psS64)atoll(chip_id))) {
    146103            psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id");
    147104            psFree(where);
     
    149106        }
    150107    }
    151 }
     108 
    152109    // convert exp_id into a psS64
    153 {
    154     bool status = false;
    155     psString var = psMetadataLookupStr(&status, config->args, "-exp_id");
    156     if (!status) {
    157         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
    158         return false;
    159     }
    160     if (var) {
    161         if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", 0, "==", (psS64)atoll(var))) {
     110    if (exp_id) {
     111        if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", 0, "==", (psS64)atoll(exp_id))) {
    162112            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
    163113            psFree(where);
     
    165115        }
    166116    }
    167 }
    168     ADDPARAMSTR(config->args, where, "exp_name");
    169     ADDRENAMEPARAMSTR(config->args, where, "inst", "camera", "==");
    170     ADDPARAMSTR(config->args, where, "telescope");
    171     ADDPARAMSTR(config->args, where, "dateobs_begin");
    172     ADDPARAMSTR(config->args, where, "dateobs_end");
    173     ADDPARAMSTR(config->args, where, "exp_tag");
    174     ADDPARAMSTR(config->args, where, "exp_type");
    175     ADDPARAMSTR(config->args, where, "filelevel");
    176     ADDPARAMSTR(config->args, where, "reduction");
    177     ADDPARAMSTR(config->args, where, "filter");
    178     ADDRENAMEPARAMF(config->args, where, F64, "airmass_min", "airmass", ">=");
    179     ADDRENAMEPARAMF(config->args, where, F64, "airmass_max", "airmass", "<");
    180     ADDRENAMEPARAMF(config->args, where, F64, "ra_min", "ra", ">=");
    181     ADDRENAMEPARAMF(config->args, where, F64, "ra_max", "ra", "<");
    182     ADDRENAMEPARAMF(config->args, where, F64, "decl_min", "decl", ">=");
    183     ADDRENAMEPARAMF(config->args, where, F64, "decl_max", "decl", "<");
    184     ADDRENAMEPARAMF(config->args, where, F32, "exp_time_min", "exp_time", ">=");
    185     ADDRENAMEPARAMF(config->args, where, F32, "exp_time_max", "exp_time", "<");
    186     ADDRENAMEPARAMF(config->args, where, F32, "sat_pixel_frac_min", "sat_pixel_frac", ">=");
    187     ADDRENAMEPARAMF(config->args, where, F32, "sat_pixel_frac_max", "sat_pixel_frac", "<");
    188     ADDRENAMEPARAMF(config->args, where, F64, "bg_min", "bt", ">=");
    189     ADDRENAMEPARAMF(config->args, where, F64, "bg_max", "bt", "<");
    190     ADDRENAMEPARAMF(config->args, where, F64, "bg_stdev_min", "bg_stdev", ">=");
    191     ADDRENAMEPARAMF(config->args, where, F64, "bg_stdev_max", "bg_stdev", "<");
    192     ADDRENAMEPARAMF(config->args, where, F64, "bg_mean_stdev_min", "bg_mean_stdev", ">=");
    193     ADDRENAMEPARAMF(config->args, where, F64, "bg_mean_stdev_max", "bg_mean_stdev", "<");
    194     ADDRENAMEPARAMF(config->args, where, F64, "alt_min", "alt", ">=");
    195     ADDRENAMEPARAMF(config->args, where, F64, "alt_max", "alt", "<");
    196     ADDRENAMEPARAMF(config->args, where, F64, "az_min", "az", ">=");
    197     ADDRENAMEPARAMF(config->args, where, F64, "az_max", "az", "<");
    198     ADDRENAMEPARAMF(config->args, where, F32, "ccd_temp_min", "ccd_temp", ">=");
    199     ADDRENAMEPARAMF(config->args, where, F32, "ccd_temp_max", "ccd_temp", "<");
    200     ADDRENAMEPARAMF(config->args, where, F64, "posang_min", "posang", ">=");
    201     ADDRENAMEPARAMF(config->args, where, F64, "posang_max", "posang", "<");
    202     ADDPARAMSTR(config->args, where, "object");
    203     ADDRENAMEPARAMF(config->args, where, F32, "solang_min", "solang", ">=");
    204     ADDRENAMEPARAMF(config->args, where, F32, "solang_max", "solang", "<");
     117
     118    PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "==");
     119    PXOPT_COPY_STR(config->args, where, "-inst", "camera", "==");
     120    PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "==");
     121    PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">=");
     122    PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<=");
     123    PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "==");
     124    PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "==");
     125    PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "==");
     126    PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "==");
     127    PXOPT_COPY_STR(config->args, where, "-filter", "filter", "==");
     128
     129    PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">=");
     130    PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<");
     131    PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">=");
     132    PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<");
     133    PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">=");
     134    PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<");
     135    PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">=");
     136    PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<");
     137    PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">=");
     138    PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<");
     139    PXOPT_COPY_F64(config->args, where, "-bg_min", "bt", ">=");
     140    PXOPT_COPY_F64(config->args, where, "-bg_max", "bt", "<");
     141    PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">=");
     142    PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<");
     143    PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">=");
     144    PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<");
     145    PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">=");
     146    PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<");
     147    PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">=");
     148    PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<");
     149    PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "ccd_temp", ">=");
     150    PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "ccd_temp", "<");
     151    PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">=");
     152    PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<");
     153    PXOPT_COPY_STR(config->args, where, "-object", "object", "==");
     154    PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">=");
     155    PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<");
    205156
    206157    if (where->list->n < 1) {
     
    209160    }
    210161
    211     bool status = false;
    212     psString workdir = psMetadataLookupStr(&status, config->args, "-set_workdir");
    213     if (!status) {
    214         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_workdir");
    215         return false;
    216     }
    217 
    218     psString label = psMetadataLookupStr(&status, config->args, "-set_label");
    219     if (!status) {
    220         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_label");
    221         return false;
    222     }
    223 
    224     psString reduction = psMetadataLookupStr(&status, config->args, "-set_reduction");
    225     if (!status) {
    226         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_reduction");
    227         return false;
    228     }
    229 
    230     psString expgroup = psMetadataLookupStr(&status, config->args, "-set_expgroup");
    231     if (!status) {
    232         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_expgroup");
    233         return false;
    234     }
    235 
    236     psString dvodb = psMetadataLookupStr(&status, config->args, "-set_dvodb");
    237     if (!status) {
    238         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_dvodb");
    239         return false;
    240     }
     162    PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false);
     163    PXOPT_LOOKUP_STR(label, config->args, "-set_label", true, false);
     164    PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", true, false);
     165    PXOPT_LOOKUP_STR(expgroup, config->args, "-set_expgroup", true, false);
     166    PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", true, false);
     167    PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", true, false);
     168    PXOPT_LOOKUP_STR(end_stage, config->args, "-set_end_stage", true, false);
    241169
    242170    // find the exp_id of all the exposures that we want to queue up.
     
    303231                    reduction      ? reduction    : row->reduction,
    304232                    expgroup    ? expgroup  : row->expgroup,
    305                     dvodb       ? dvodb     : row->dvodb
     233                    dvodb       ? dvodb     : row->dvodb,
     234                    tess_id     ? tess_id   : row->tess_id,
     235                    end_stage   ? end_stage : row->end_stage
    306236        )) {
    307237            if (!psDBRollback(config->dbh)) {
     
    330260    PS_ASSERT_PTR_NON_NULL(config, false);
    331261
    332     bool status = false;
    333     psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    334     if (!status) {
    335         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit");
    336         return false;
    337     }
     262    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     263    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    338264
    339265    psString query = pxDataGet("camtool_find_pendingexp.sql");
     
    374300    }
    375301
    376     bool simple = false;
    377     {
    378         bool status = false;
    379         simple = psMetadataLookupBool(&status, config->args, "-simple");
    380         if (!status) {
    381             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    382             return false;
    383         }
    384     }
    385 
    386302    if (!convertIdToStr(output)) {
    387303        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
     
    405321{
    406322    PS_ASSERT_PTR_NON_NULL(config, false);
     323
     324    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    407325
    408326    psString query = pxDataGet("camtool_find_pendingimfile.sql");
     
    436354    }
    437355
    438     bool simple = false;
    439     {
    440         bool status = false;
    441         simple = psMetadataLookupBool(&status, config->args, "-simple");
    442         if (!status) {
    443             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    444             return false;
    445         }
    446     }
    447 
    448356    if (!convertIdToStr(output)) {
    449357        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
     
    468376    PS_ASSERT_PTR_NON_NULL(config, false);
    469377
    470     bool status = false;
    471     psString cam_id = psMetadataLookupStr(&status, config->args, "-cam_id");
    472     if (!status) {
    473         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -cam_id");
    474         return false;
    475     }
    476     if (!cam_id) {
    477         psError(PS_ERR_UNKNOWN, true, "-cam_id is required");
    478         return false;
    479     }
    480 
    481     psString uri = psMetadataLookupStr(&status, config->args, "-uri");
    482     if (!status) {
    483         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri");
    484         return false;
    485     }
    486     if (!uri) {
    487         psError(PS_ERR_UNKNOWN, true, "-uri is required");
    488         return false;
    489     }
    490 
    491     psF64 bg = psMetadataLookupF64(&status, config->args, "-bg");
    492     if (!status) {
    493         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg");
    494         return false;
    495     }
    496 
    497     psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev");
    498     if (!status) {
    499         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev");
    500         return false;
    501     }
    502 
    503     psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev");
    504     if (!status) {
    505         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev");
    506         return false;
    507     }
    508 
    509     psF32 sigma_ra = psMetadataLookupF32(&status, config->args, "-sigma_ra");
    510     if (!status) {
    511         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -sigma_ra");
    512         return false;
    513     }
    514     //if (isnan(sigma_ra)) {
    515     //  psError(PS_ERR_UNKNOWN, true, "-sigma_ra is required");
    516     //  return false;
    517     //}
    518 
    519     psF32 sigma_dec = psMetadataLookupF32(&status, config->args, "-sigma_dec");
    520     if (!status) {
    521         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -sigma_dec");
    522         return false;
    523     }
    524     //if (isnan(sigma_dec)) {
    525     //  psError(PS_ERR_UNKNOWN, true, "-sigma_dec is required");
    526     //  return false;
    527     //}
    528 
    529     psF32 zp_mean = psMetadataLookupF32(&status, config->args, "-zp_mean");
    530     if (!status) {
    531         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -zp_mean");
    532         return false;
    533     }
    534     //if (isnan(zp_mean)) {
    535     //  psError(PS_ERR_UNKNOWN, true, "-zp_mean is required");
    536     //  return false;
    537     //}
    538 
    539     psF32 zp_stdev = psMetadataLookupF32(&status, config->args, "-zp_stdev");
    540     if (!status) {
    541         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -zp_stdev");
    542         return false;
    543     }
    544     //if (isnan(zp_stdev)) {
    545     //  psError(PS_ERR_UNKNOWN, true, "-zp_stdev is required");
    546     //  return false;
    547     //}
    548 
    549     psF32 fwhm = psMetadataLookupF32(&status, config->args, "-fwhm");
    550     if (!status) {
    551         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fwhm");
    552         return false;
    553     }
    554     //if (isnan(fwhm)) {
    555     //  psError(PS_ERR_UNKNOWN, true, "-fwhm is required");
    556     //  return false;
    557     //}
    558 
    559     psF32 fwhm_range = psMetadataLookupF32(&status, config->args, "-fwhm_range");
    560     if (!status) {
    561         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fwhm_range");
    562         return false;
    563     }
    564     //if (isnan(fwhm_range)) {
    565     //  psError(PS_ERR_UNKNOWN, true, "-fwhm_range is required");
    566     //  return false;
    567     //}
    568 
    569     psS32 n_stars = psMetadataLookupS32(&status, config->args, "-n_stars");
    570     if (!status) {
    571         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -n_stars");
    572         return false;
    573     }
    574     if (n_stars < 0) {
    575         psError(PS_ERR_UNKNOWN, true, "-n_stars is required");
    576         return false;
    577     }
    578 
    579     psS32 n_extended = psMetadataLookupS32(&status, config->args, "-n_extended");
    580     if (!status) {
    581         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -n_extended");
    582         return false;
    583     }
     378    // required
     379    PXOPT_LOOKUP_STR(cam_id, config->args, "-cam_id", true, false);
     380    PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false);
     381
     382    // optional
     383    PXOPT_LOOKUP_F32(bg, config->args, "-bg", false, false);
     384    PXOPT_LOOKUP_F32(bg_stdev, config->args, "-bg_stdev", false, false);
     385    PXOPT_LOOKUP_F32(bg_mean_stdev, config->args, "-bg_mean_stdev", false, false);
     386    PXOPT_LOOKUP_F32(sigma_ra, config->args, "-sigma_ra", false, false);
     387    PXOPT_LOOKUP_F32(sigma_dec, config->args, "-sigma_dec", false, false);
     388    PXOPT_LOOKUP_F32(zp_mean, config->args, "-zp_mean", false, false);
     389    PXOPT_LOOKUP_F32(zp_stdev, config->args, "-zp_stdev", false, false);
     390    PXOPT_LOOKUP_F32(fwhm, config->args, "-fwhm", false, false);
     391    PXOPT_LOOKUP_F32(fwhm_range, config->args, "-fwhm_range", false, false);
     392    PXOPT_LOOKUP_F32(n_stars, config->args, "-n_stars", false, false);
     393    PXOPT_LOOKUP_F32(n_extended, config->args, "-n_extended", false, false);
    584394    if (n_extended < 0) {
    585395        psError(PS_ERR_UNKNOWN, true, "-n_extended is required");
    586396        return false;
    587397    }
    588 
    589     psS32 n_cr = psMetadataLookupS32(&status, config->args, "-n_cr");
    590     if (!status) {
    591         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -n_cr");
    592         return false;
    593     }
     398    PXOPT_LOOKUP_F32(n_cr, config->args, "-n_cr", false, false);
    594399    if (n_cr < 0) {
    595400        psError(PS_ERR_UNKNOWN, true, "-n_cr is required");
    596401        return false;
    597402    }
    598 
    599     psS32 n_astrom = psMetadataLookupS32(&status, config->args, "-n_astrom");
    600     if (!status) {
    601         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -n_astrom");
    602         return false;
    603     }
     403    PXOPT_LOOKUP_F32(n_astrom, config->args, "-n_astrom", false, false);
    604404    if (n_astrom < 0) {
    605405        psError(PS_ERR_UNKNOWN, true, "-n_astrom is required");
     
    607407    }
    608408
    609     // optional
    610     psString path_base = psMetadataLookupStr(&status, config->args, "-path_base");
    611     if (!status) {
    612         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -path_base");
    613         return false;
    614     }
     409    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false);
    615410
    616411    // default
    617     psS16 code = psMetadataLookupS16(&status, config->args, "-code");
    618     if (!status) {
    619         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");
    620         return false;
    621     }
     412    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
    622413
    623414    psString query = pxDataGet("camtool_find_pendingexp.sql");
     
    674465    camRunRow *pendingRow = camRunObjectFromMetadata(output->data[0]);
    675466    psFree(output);
    676     // create a new camProcessedImfile object
    677467    camProcessedExpRow *row = camProcessedExpRowAlloc(
    678468        pendingRow->cam_id,
     
    697487    psFree(pendingRow);
    698488
    699     // insert the new row into the camProcessedImfile table
    700489    if (!camProcessedExpInsertObject(config->dbh, row)) {
    701490        // rollback
     
    730519    PS_ASSERT_PTR_NON_NULL(config, false);
    731520
    732     bool status = false;
    733     psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    734     if (!status) {
    735         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit");
    736         return false;
    737     }
    738 
    739     bool faulted = psMetadataLookupU64(&status, config->args, "-faulted");
    740     if (!status) {
    741         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted");
    742         return false;
    743     }
     521    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     522    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     523    PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
    744524
    745525    psString query = pxDataGet("camtool_find_processedexp.sql");
     
    788568    }
    789569
    790     bool simple = false;
    791     {
    792         bool status = false;
    793         simple = psMetadataLookupBool(&status, config->args, "-simple");
    794         if (!status) {
    795             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    796             return false;
    797         }
    798     }
    799 
    800570    if (!convertIdToStr(output)) {
    801571        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
     
    853623    PS_ASSERT_PTR_NON_NULL(config, false);
    854624
    855     bool status = false;
    856     psS16 code = psMetadataLookupS16(&status, config->args, "-code");
    857     if (!status) {
    858         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");
    859         return false;
    860     }
    861     if (code == INT16_MAX) {
    862         psError(PS_ERR_UNKNOWN, true, "-code is required");
    863         return false;
    864     }
     625    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
    865626
    866627    if (!pxSetFaultCode(config->dbh, "camProcessedExp", config->where, code)) {
     
    877638    PS_ASSERT_PTR_NON_NULL(config, false);
    878639
    879     bool status = false;
    880     psString label = psMetadataLookupStr(&status, config->args, "-label");
    881     if (!status) {
    882         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label");
    883         return false;
    884     }
    885     if (!label) {
    886         psError(PS_ERR_UNKNOWN, true, "-label is required");
    887         return false;
    888     }
     640    PXOPT_LOOKUP_STR(label, config->args, "-label", true, false);
    889641
    890642    if (!camMaskInsert(config->dbh, label)) {
     
    900652{
    901653    PS_ASSERT_PTR_NON_NULL(config, false);
     654
     655    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    902656
    903657    psString query = psStringCopy("SELECT * FROM camMask");
     
    919673        psFree(output);
    920674        return true;
    921     }
    922 
    923     bool simple = false;
    924     {
    925         bool status = false;
    926         simple = psMetadataLookupBool(&status, config->args, "-simple");
    927         if (!status) {
    928             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    929             return false;
    930         }
    931675    }
    932676
     
    954698    PS_ASSERT_PTR_NON_NULL(config, false);
    955699
    956     bool status = false;
    957     psString label = psMetadataLookupStr(&status, config->args, "-label");
    958     if (!status) {
    959         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label");
    960         return false;
    961     }
    962     if (!label) {
    963         psError(PS_ERR_UNKNOWN, true, "-label is required");
    964         return false;
    965     }
     700    PXOPT_LOOKUP_STR(label, config->args, "-label", true, false);
    966701
    967702    char *query = "DELETE FROM camMask WHERE label = '%s'";
     
    969704    if (!p_psDBRunQuery(config->dbh, query, label)) {
    970705        psError(PS_ERR_UNKNOWN, false, "database error");
    971         psFree(query);
    972         return false;
    973     }
    974 
    975     return true;
    976 }
     706        return false;
     707    }
     708
     709    return true;
     710}
Note: See TracChangeset for help on using the changeset viewer.