IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 14, 2008, 3:18:02 PM (18 years ago)
Author:
Paul Price
Message:

Updating tables for magic (adding fault codes, removing skyfilemask)

File:
1 edited

Legend:

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

    r18336 r18520  
    4141static bool tomaskMode(pxConfig *config);
    4242static bool addmaskMode(pxConfig *config);
    43 static bool toskyfilemaskMode(pxConfig *config);
    44 static bool addskyfilemaskMode(pxConfig *config);
    4543
    4644static bool setmagicRunState(pxConfig *config, psS64 magic_id, const char *state);
     
    7573        MODECASE(MAGICTOOL_MODE_TOMASK,         tomaskMode);
    7674        MODECASE(MAGICTOOL_MODE_ADDMASK,        addmaskMode);
    77         MODECASE(MAGICTOOL_MODE_TOSKYFILEMASK,  toskyfilemaskMode);
    78         MODECASE(MAGICTOOL_MODE_ADDSKYFILEMASK, addskyfilemaskMode);
    7975        default:
    8076            psAbort("invalid option (this should not happen)");
     
    211207                NULL,       // label
    212208                NULL,       // dvodb
    213                 NULL        // registered
     209                NULL,       // registered
     210                0           // fault
    214211        );
    215212        if (!run) {
     
    262259    PS_ASSERT_PTR_NON_NULL(config, false);
    263260
    264     // required 
     261    // required
    265262    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false);
    266263
     
    278275            label,
    279276            dvodb,
    280             registered
     277            registered,
     278            0
    281279    );
    282280    psFree(registered);
    283281    if (!run) {
    284282        psError(PS_ERR_UNKNOWN, false, "failed to alloc magicRun object");
    285         return true;
     283        return false;
    286284    }
    287285    if (!magicRunInsertObject(config->dbh, run)) {
    288286        psError(PS_ERR_UNKNOWN, false, "database error");
    289287        psFree(run);
    290         return true;
     288        return false;
    291289    }
    292290
     
    444442        return false;
    445443    }
    446    
     444
    447445    return true;
    448446}
     
    491489        return false;
    492490    }
    493    
     491
    494492    return true;
    495493}
     
    589587        return true;
    590588    }
    591      
     589
    592590    psHash *forest = psHashAlloc(psArrayLength(magicTree));
    593591
     
    642640    PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false);
    643641    PXOPT_LOOKUP_STR(node, config->args, "-node", true, false);
    644     PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false);
     642
     643    // optional
     644    PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false);
     645
     646    // default values
     647    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
    645648
    646649    if (!magicNodeResultInsert(config->dbh,
    647                 (psS64)atoll(magic_id),
    648                 node,
    649                 uri
     650                               (psS64)atoll(magic_id),
     651                               node,
     652                               uri,
     653                               code
    650654        )) {
    651655        psError(PS_ERR_UNKNOWN, false, "database error");
     
    726730    // required
    727731    PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false);
    728     PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false);
     732
     733    // optional
     734    PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false);
     735    PXOPT_LOOKUP_S32(streaks, config->args, "-streaks", false, false);
     736
     737    // default values
     738    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
    729739
    730740    if (!magicMaskInsert(config->dbh,
    731                 (psS64)atoll(magic_id),
    732                 uri
    733         )) {
    734         psError(PS_ERR_UNKNOWN, false, "database error");
    735         return false;
    736     }
    737 
    738     return true;
    739 }
    740 
    741 
    742 static bool toskyfilemaskMode(pxConfig *config)
    743 {
    744     PS_ASSERT_PTR_NON_NULL(config, false);
    745 
    746     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    747     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    748 
    749     psString query = pxDataGet("magictool_toskyfilemask.sql");
    750     if (!query) {
    751         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    752         return false;
    753     }
    754 
    755     // treat limit == 0 as "no limit"
    756     if (limit) {
    757         psString limitString = psDBGenerateLimitSQL(limit);
    758         psStringAppend(&query, " %s", limitString);
    759         psFree(limitString);
    760     }
    761 
    762     if (!p_psDBRunQuery(config->dbh, query)) {
    763         psError(PS_ERR_UNKNOWN, false, "database error");
    764         psFree(query);
    765         return false;
    766     }
    767     psFree(query);
    768 
    769     psArray *output = p_psDBFetchResult(config->dbh);
    770     if (!output) {
    771         psErrorCode err = psErrorCodeLast();
    772         switch (err) {
    773             case PS_ERR_DB_CLIENT:
    774                 psError(PXTOOLS_ERR_SYS, false, "database error");
    775             case PS_ERR_DB_SERVER:
    776                 psError(PXTOOLS_ERR_PROG, false, "database error");
    777             default:
    778                 psError(PXTOOLS_ERR_PROG, false, "unknown error");
    779         }
    780 
    781         return false;
    782     }
    783     if (!psArrayLength(output)) {
    784         psTrace("magictool", PS_LOG_INFO, "no rows found");
    785         psFree(output);
    786         return true;
    787     }
    788 
    789     if (psArrayLength(output)) {
    790         // negative simple so the default is true
    791         if (!ippdbPrintMetadatas(stdout, output, "toskyfilemask", !simple)) {
    792             psError(PS_ERR_UNKNOWN, false, "failed to print array");
    793             psFree(output);
    794             return false;
    795         }
    796     }
    797 
    798     psFree(output);
    799 
    800     return true;
    801 }
    802 
    803 
    804 static bool addskyfilemaskMode(pxConfig *config)
    805 {
    806     PS_ASSERT_PTR_NON_NULL(config, false);
    807 
    808     // required
    809     PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false);
    810     PXOPT_LOOKUP_STR(diff_id, config->args, "diff_id", true, false);
    811     PXOPT_LOOKUP_STR(uri, config->args, "uri", true, false);
    812 
    813     if (!magicSkyfileMaskInsert(config->dbh,
    814                 (psS64)atoll(magic_id),
    815                 (psS64)atoll(diff_id),
    816                 uri
     741                         (psS64)atoll(magic_id),
     742                         uri,
     743                         streaks,
     744                         code
    817745        )) {
    818746        psError(PS_ERR_UNKNOWN, false, "database error");
Note: See TracChangeset for help on using the changeset viewer.