IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16100


Ignore:
Timestamp:
Jan 16, 2008, 3:26:27 PM (18 years ago)
Author:
jhoblitt
Message:

convert to PXOPT_* macros

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/end_stage/ippTools/src/difftool.c

    r15415 r16100  
    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     }
     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    // optional
     104    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    129105
    130106    psTime *registered = NULL;
    131107    {
     108        bool status;
    132109        psString registeredStr = psMetadataLookupStr(&status, config->args, "-registered");
    133110        if (!status) {
     
    166143    run->diff_id = psDBLastInsertID(config->dbh);
    167144
    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 
    179145    if (!diffRunPrintObject(stdout, run, !simple)) {
    180146            psError(PS_ERR_UNKNOWN, false, "failed to print object");
     
    193159    PS_ASSERT_PTR_NON_NULL(config, false);
    194160
    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     }
     161    // required options
     162    PXOPT_LOOKUP_STR(diff_id, config->args, "-diff_id", true, false);
     163    PXOPT_LOOKUP_STR(state, config->args, "-state", true, false);
    215164
    216165    if (state) {
     
    227176    PS_ASSERT_PTR_NON_NULL(config, false);
    228177
    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     }
     178    // required options
     179    PXOPT_LOOKUP_STR(diff_id, config->args, "-diff_id", true, false);
     180
     181    // optional
     182    PXOPT_LOOKUP_STR(stack_id, config->args, "-stack_id", false, false);
     183    PXOPT_LOOKUP_STR(warp_id, config->args, "-warp_id", false, false);
     184    PXOPT_LOOKUP_STR(kind, config->args, "-kind", false, false);
    257185
    258186    // 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     }
     187    PXOPT_LOOKUP_BOOL(template, config->args, "-template", false);
    264188
    265189    // must provide either stack_id or warp_id but not BOTH
     
    345269    }
    346270
     271    bool status;
    347272    psS32 count = psMetadataLookupS32(&status, output->data[0], "count(diff_id)");
    348273
     
    371296    PS_ASSERT_PTR_NON_NULL(config, false);
    372297
    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     }
     298    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     299    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    379300
    380301    // find all rawImfiles matching the default query
     
    425346    }
    426347
    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 
    437348    if (psArrayLength(output)) {
    438349        if (!convertIdToStr(output)) {
     
    460371    PS_ASSERT_PTR_NON_NULL(config, false);
    461372
    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     }
     373    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     374    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    468375
    469376    psString query = pxDataGet("difftool_todiffskyfile.sql");
     
    513420    }
    514421
    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 
    525422    if (psArrayLength(output)) {
    526423        if (!convertIdToStr(output)) {
     
    548445    PS_ASSERT_PTR_NON_NULL(config, false);
    549446
    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     }
     447    // required
     448    PXOPT_LOOKUP_STR(diff_id, config->args, "-diff_id", true, false);
     449
     450    // default to 0
     451    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
     452
     453    PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false);
    572454    if (code == 0 && !uri) {
    573455        psError(PS_ERR_UNKNOWN, true, "-uri is required");
     
    575457    }
    576458
    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     }
     459    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
    582460    if (code == 0 && !path_base) {
    583461        psError(PS_ERR_UNKNOWN, true, "-path_base is required");
     
    586464
    587465    // 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     }
     466    PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false);
     467    PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false);
     468    PXOPT_LOOKUP_F64(good_frac, config->args, "-good_frac", false, false);
    605469
    606470    if (!psDBTransaction(config->dbh)) {
     
    647511    PS_ASSERT_PTR_NON_NULL(config, false);
    648512
    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     }
     513    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     514    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    655515
    656516    psString query = pxDataGet("difftool_skyfile.sql");
     
    700560    }
    701561
    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 
    712562    if (psArrayLength(output)) {
    713563        if (!convertIdToStr(output)) {
     
    791641
    792642
    793 
    794 
    795 
    796643static bool definepoprunMode(pxConfig *config)
    797644{
     
    799646
    800647    // 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     }
     648    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false);
     649    PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);
     650    PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false);
     651
     652    // optional
     653    PXOPT_LOOKUP_STR(template_stack_id, config->args, "-template_stack_id", false, false);
     654    PXOPT_LOOKUP_STR(template_warp_id, config->args, "-template_warp_id", false, false);
     655
    842656    if (template_stack_id && template_warp_id) {
    843657        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Only one template can be defined.");
     
    850664    }
    851665
    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     }
     666    PXOPT_LOOKUP_STR(input_stack_id, config->args, "-input_stack_id", false, false);
     667    PXOPT_LOOKUP_STR(input_warp_id, config->args, "-input_warp_id", false, false);
    862668    if (input_stack_id && input_warp_id) {
    863669        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Only one input can be defined.");
     
    870676    }
    871677
    872     psString kind = NULL;
    873 
    874678    psTime *registered = NULL;
    875679    {
     680        bool status;
    876681        psString registeredStr = psMetadataLookupStr(&status, config->args, "-registered");
    877682        if (!status) {
     
    887692    }
    888693
    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     }
     694    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    898695
    899696    diffRunRow *run = diffRunRowAlloc(
     
    936733            skycell_id,
    937734            tess_id,
    938             kind
     735            NULL    // kind
    939736        )) {
    940737        if (!psDBRollback(config->dbh)) {
     
    953750            skycell_id,
    954751            tess_id,
    955             kind
     752            NULL    // kind
    956753        )) {
    957754        if (!psDBRollback(config->dbh)) {
Note: See TracChangeset for help on using the changeset viewer.