IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 25, 2008, 1:23:41 PM (18 years ago)
Author:
jhoblitt
Message:

add warptool -block/-masked/-unblock modes

File:
1 edited

Legend:

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

    r17142 r17145  
    4343static bool warpedMode(pxConfig *config);
    4444static bool revertwarpedMode(pxConfig *config);
     45static bool blockMode(pxConfig *config);
     46static bool maskedMode(pxConfig *config);
     47static bool unblockMode(pxConfig *config);
    4548
    4649static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile);
     
    7780        MODECASE(WARPTOOL_MODE_WARPED,            warpedMode);
    7881        MODECASE(WARPTOOL_MODE_REVERTWARPED,      revertwarpedMode);
     82        MODECASE(WARPTOOL_MODE_BLOCK,             blockMode);
     83        MODECASE(WARPTOOL_MODE_MASKED,            maskedMode);
     84        MODECASE(WARPTOOL_MODE_UNBLOCK,           unblockMode);
     85
    7986        default:
    8087            psAbort("invalid option (this should not happen)");
     
    926933
    927934
     935static bool blockMode(pxConfig *config)
     936{
     937    PS_ASSERT_PTR_NON_NULL(config, false);
     938
     939    PXOPT_LOOKUP_STR(label, config->args, "-label", true, false);
     940
     941    if (!warpMaskInsert(config->dbh, label)) {
     942        psError(PS_ERR_UNKNOWN, false, "database error");
     943        return false;
     944    }
     945
     946    return true;
     947}
     948
     949
     950static bool maskedMode(pxConfig *config)
     951{
     952    PS_ASSERT_PTR_NON_NULL(config, false);
     953
     954    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     955
     956    psString query = psStringCopy("SELECT * FROM warpMask");
     957
     958    if (!p_psDBRunQuery(config->dbh, query)) {
     959        psError(PS_ERR_UNKNOWN, false, "database error");
     960        psFree(query);
     961        return false;
     962    }
     963    psFree(query);
     964
     965    psArray *output = p_psDBFetchResult(config->dbh);
     966    if (!output) {
     967        psError(PS_ERR_UNKNOWN, false, "database error");
     968        return false;
     969    }
     970    if (!psArrayLength(output)) {
     971        psTrace("warpool", PS_LOG_INFO, "no rows found");
     972        psFree(output);
     973        return true;
     974    }
     975
     976    if (!convertIdToStr(output)) {
     977        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
     978        psFree(output);
     979        return false;
     980    }
     981
     982    // negative simple so the default is true
     983    if (!ippdbPrintMetadatas(stdout, output, "warpMask", !simple)) {
     984        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     985        psFree(output);
     986        return false;
     987    }
     988
     989    psFree(output);
     990
     991    return true;
     992}
     993
     994
     995static bool unblockMode(pxConfig *config)
     996{
     997    PS_ASSERT_PTR_NON_NULL(config, false);
     998
     999    PXOPT_LOOKUP_STR(label, config->args, "-label", true, false);
     1000
     1001    char *query = "DELETE FROM warpMask WHERE label = '%s'";
     1002
     1003    if (!p_psDBRunQuery(config->dbh, query, label)) {
     1004        psError(PS_ERR_UNKNOWN, false, "database error");
     1005        return false;
     1006    }
     1007
     1008    return true;
     1009}
     1010
     1011
    9281012static bool isValidMode(pxConfig *config, const char *mode)
    9291013{
Note: See TracChangeset for help on using the changeset viewer.