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/difftool.c

    r15415 r16170  
    9797
    9898    // required options
    99     bool status = false;
    100     psString workdir = psMetadataLookupStr(&status, config->args, "-workdir");
    101     if (!status) {
    102         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -workdir");
    103         return false;
    104     }
    105     if (!workdir) {
    106         psError(PS_ERR_UNKNOWN, true, "-workdir is required");
    107         return false;
    108     }
    109 
    110     psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id");
    111     if (!status) {
    112         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id");
    113         return false;
    114     }
    115     if (!skycell_id) {
    116         psError(PS_ERR_UNKNOWN, true, "-skycell_id is required");
    117         return false;
    118     }
    119 
    120     psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");
    121     if (!status) {
    122         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");
    123         return false;
    124     }
    125     if (!tess_id) {
    126         psError(PS_ERR_UNKNOWN, true, "-tess_id is required");
    127         return false;
    128     }
    129 
    130     psTime *registered = NULL;
    131     {
    132         psString registeredStr = psMetadataLookupStr(&status, config->args, "-registered");
    133         if (!status) {
    134             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -registered");
    135             return false;
    136         }
    137         // pass through NULL as this is an optional field
    138         if (registeredStr) {
    139             registered = psTimeFromISO(registeredStr, PS_TIME_UTC);
    140         } else {
    141             registered = NULL;
    142         }
    143     }
     99    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false);
     100    PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);
     101    PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false);
     102
     103    // default
     104    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     105    PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
    144106
    145107    diffRunRow *run = diffRunRowAlloc(
     
    152114            tess_id
    153115    );
    154     psFree(registered);
    155116    if (!run) {
    156117        psError(PS_ERR_UNKNOWN, false, "failed to alloc diffRun object");
     
    166127    run->diff_id = psDBLastInsertID(config->dbh);
    167128
    168     bool simple = false;
    169     {
    170         bool status = false;
    171         simple = psMetadataLookupBool(&status, config->args, "-simple");
    172         if (!status) {
    173             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    174             psFree(run);
    175             return false;
    176         }
    177     }
    178 
    179129    if (!diffRunPrintObject(stdout, run, !simple)) {
    180130            psError(PS_ERR_UNKNOWN, false, "failed to print object");
     
    193143    PS_ASSERT_PTR_NON_NULL(config, false);
    194144
    195     bool status = false;
    196     psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id");
    197     if (!status) {
    198         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id");
    199         return false;
    200     }
    201     if (!diff_id) {
    202         psError(PS_ERR_UNKNOWN, true, "-diff_id is required");
    203         return false;
    204     }
    205 
    206     psString state = psMetadataLookupStr(&status, config->args, "-state");
    207     if (!status) {
    208         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state");
    209         return false;
    210     }
    211     if (!state) {
    212         psError(PS_ERR_UNKNOWN, true, "-state is required");
    213         return false;
    214     }
     145    // required options
     146    PXOPT_LOOKUP_STR(diff_id, config->args, "-diff_id", true, false);
     147    PXOPT_LOOKUP_STR(state, config->args, "-state", true, false);
    215148
    216149    if (state) {
     
    227160    PS_ASSERT_PTR_NON_NULL(config, false);
    228161
    229     bool status = false;
    230     psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id");
    231     if (!status) {
    232         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id");
    233         return false;
    234     }
    235     if (!diff_id) {
    236         psError(PS_ERR_UNKNOWN, true, "-diff_id is required");
    237         return false;
    238     }
    239 
    240     psString stack_id = psMetadataLookupStr(&status, config->args, "-stack_id");
    241     if (!status) {
    242         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stack_id");
    243         return false;
    244     }
    245 
    246     psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id");
    247     if (!status) {
    248         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warp_id");
    249         return false;
    250     }
    251 
    252     psString kind = psMetadataLookupStr(&status, config->args, "-kind");
    253     if (!status) {
    254         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -kind");
    255         return false;
    256     }
     162    // required options
     163    PXOPT_LOOKUP_STR(diff_id, config->args, "-diff_id", true, false);
     164
     165    // optional
     166    PXOPT_LOOKUP_STR(stack_id, config->args, "-stack_id", false, false);
     167    PXOPT_LOOKUP_STR(warp_id, config->args, "-warp_id", false, false);
     168    PXOPT_LOOKUP_STR(kind, config->args, "-kind", false, false);
    257169
    258170    // defaults to false
    259     bool template = psMetadataLookupBool(&status, config->args, "-template");
    260     if (!status) {
    261         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -template");
    262         return false;
    263     }
     171    PXOPT_LOOKUP_BOOL(template, config->args, "-template", false);
    264172
    265173    // must provide either stack_id or warp_id but not BOTH
     
    345253    }
    346254
     255    bool status;
    347256    psS32 count = psMetadataLookupS32(&status, output->data[0], "count(diff_id)");
    348257
     
    371280    PS_ASSERT_PTR_NON_NULL(config, false);
    372281
    373     bool status = false;
    374     psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    375     if (!status) {
    376         psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
    377         return false;
    378     }
     282    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     283    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    379284
    380285    // find all rawImfiles matching the default query
     
    425330    }
    426331
    427     bool simple = false;
    428     {
    429         bool status = false;
    430         simple = psMetadataLookupBool(&status, config->args, "-simple");
    431         if (!status) {
    432             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    433             return false;
    434         }
    435     }
    436 
    437332    if (psArrayLength(output)) {
    438333        if (!convertIdToStr(output)) {
     
    460355    PS_ASSERT_PTR_NON_NULL(config, false);
    461356
    462     bool status = false;
    463     psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    464     if (!status) {
    465         psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
    466         return false;
    467     }
     357    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     358    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    468359
    469360    psString query = pxDataGet("difftool_todiffskyfile.sql");
     
    513404    }
    514405
    515     bool simple = false;
    516     {
    517         bool status = false;
    518         simple = psMetadataLookupBool(&status, config->args, "-simple");
    519         if (!status) {
    520             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    521             return false;
    522         }
    523     }
    524 
    525406    if (psArrayLength(output)) {
    526407        if (!convertIdToStr(output)) {
     
    548429    PS_ASSERT_PTR_NON_NULL(config, false);
    549430
    550     bool status = false;
    551     psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id");
    552     if (!status) {
    553         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id");
    554         return false;
    555     }
    556     if (!diff_id) {
    557         psError(PS_ERR_UNKNOWN, true, "-diff_id is required");
    558         return false;
    559     }
    560 
    561     psS16 code = psMetadataLookupS16(&status, config->args, "-code");
    562     if (!status) {
    563         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");
    564         return false;
    565     }
    566 
    567     psString uri = psMetadataLookupStr(&status, config->args, "-uri");
    568     if (!status) {
    569         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri");
    570         return false;
    571     }
     431    // required
     432    PXOPT_LOOKUP_STR(diff_id, config->args, "-diff_id", true, false);
     433
     434    // default to 0
     435    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
     436
     437    PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false);
    572438    if (code == 0 && !uri) {
    573439        psError(PS_ERR_UNKNOWN, true, "-uri is required");
     
    575441    }
    576442
    577     psString path_base = psMetadataLookupStr(&status, config->args, "-path_base");
    578     if (!status) {
    579         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -path_base");
    580         return false;
    581     }
     443    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
    582444    if (code == 0 && !path_base) {
    583445        psError(PS_ERR_UNKNOWN, true, "-path_base is required");
     
    586448
    587449    // optional
    588     psF64 bg = psMetadataLookupF64(&status, config->args, "-bg");
    589     if (!status) {
    590         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg");
    591         return false;
    592     }
    593 
    594     psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev");
    595     if (!status) {
    596         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev");
    597         return false;
    598     }
    599 
    600     psF64 good_frac = psMetadataLookupF64(&status, config->args, "-good_frac");
    601     if (!status) {
    602         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -good_frac");
    603         return false;
    604     }
     450    PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false);
     451    PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false);
     452    PXOPT_LOOKUP_F64(good_frac, config->args, "-good_frac", false, false);
    605453
    606454    if (!psDBTransaction(config->dbh)) {
     
    647495    PS_ASSERT_PTR_NON_NULL(config, false);
    648496
    649     bool status = false;
    650     psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    651     if (!status) {
    652         psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
    653         return false;
    654     }
     497    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     498    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    655499
    656500    psString query = pxDataGet("difftool_skyfile.sql");
     
    700544    }
    701545
    702     bool simple = false;
    703     {
    704         bool status = false;
    705         simple = psMetadataLookupBool(&status, config->args, "-simple");
    706         if (!status) {
    707             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    708             return false;
    709         }
    710     }
    711 
    712546    if (psArrayLength(output)) {
    713547        if (!convertIdToStr(output)) {
     
    791625
    792626
    793 
    794 
    795 
    796627static bool definepoprunMode(pxConfig *config)
    797628{
     
    799630
    800631    // required options
    801     bool status = false;
    802     psString workdir = psMetadataLookupStr(&status, config->args, "-workdir");
    803     if (!status) {
    804         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -workdir");
    805         return false;
    806     }
    807     if (!workdir) {
    808         psError(PS_ERR_UNKNOWN, true, "-workdir is required");
    809         return false;
    810     }
    811 
    812     psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id");
    813     if (!status) {
    814         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id");
    815         return false;
    816     }
    817     if (!skycell_id) {
    818         psError(PS_ERR_UNKNOWN, true, "-skycell_id is required");
    819         return false;
    820     }
    821 
    822     psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");
    823     if (!status) {
    824         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");
    825         return false;
    826     }
    827     if (!tess_id) {
    828         psError(PS_ERR_UNKNOWN, true, "-tess_id is required");
    829         return false;
    830     }
    831 
    832     psString template_stack_id = psMetadataLookupStr(&status, config->args, "-template_stack_id");
    833     if (!status) {
    834         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -template_stack_id");
    835         return false;
    836     }
    837     psString template_warp_id = psMetadataLookupStr(&status, config->args, "-template_warp_id");
    838     if (!status) {
    839         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -template_warp_id");
    840         return false;
    841     }
     632    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false);
     633    PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);
     634    PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false);
     635
     636    // optional
     637    PXOPT_LOOKUP_STR(template_stack_id, config->args, "-template_stack_id", false, false);
     638    PXOPT_LOOKUP_STR(template_warp_id, config->args, "-template_warp_id", false, false);
     639
    842640    if (template_stack_id && template_warp_id) {
    843641        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Only one template can be defined.");
     
    850648    }
    851649
    852     psString input_stack_id = psMetadataLookupStr(&status, config->args, "-input_stack_id");
    853     if (!status) {
    854         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -input_stack_id");
    855         return false;
    856     }
    857     psString input_warp_id = psMetadataLookupStr(&status, config->args, "-input_warp_id");
    858     if (!status) {
    859         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -input_warp_id");
    860         return false;
    861     }
     650    PXOPT_LOOKUP_STR(input_stack_id, config->args, "-input_stack_id", false, false);
     651    PXOPT_LOOKUP_STR(input_warp_id, config->args, "-input_warp_id", false, false);
    862652    if (input_stack_id && input_warp_id) {
    863653        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Only one input can be defined.");
     
    870660    }
    871661
    872     psString kind = NULL;
    873 
    874     psTime *registered = NULL;
    875     {
    876         psString registeredStr = psMetadataLookupStr(&status, config->args, "-registered");
    877         if (!status) {
    878             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -registered");
    879             return false;
    880         }
    881         // pass through NULL as this is an optional field
    882         if (registeredStr) {
    883             registered = psTimeFromISO(registeredStr, PS_TIME_UTC);
    884         } else {
    885             registered = NULL;
    886         }
    887     }
    888 
    889     bool simple = false;
    890     {
    891         bool status = false;
    892         simple = psMetadataLookupBool(&status, config->args, "-simple");
    893         if (!status) {
    894             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    895             return false;
    896         }
    897     }
     662    // default
     663    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     664    PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
    898665
    899666    diffRunRow *run = diffRunRowAlloc(
     
    906673            tess_id
    907674    );
    908     psFree(registered);
    909675
    910676    if (!run) {
     
    936702            skycell_id,
    937703            tess_id,
    938             kind
     704            NULL    // kind
    939705        )) {
    940706        if (!psDBRollback(config->dbh)) {
     
    953719            skycell_id,
    954720            tess_id,
    955             kind
     721            NULL    // kind
    956722        )) {
    957723        if (!psDBRollback(config->dbh)) {
Note: See TracChangeset for help on using the changeset viewer.