IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 22, 2008, 10:23:58 AM (18 years ago)
Author:
eugene
Message:

added -unmasked mode to chiptool; added various restrictions to dettool -runs

File:
1 edited

Legend:

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

    r16556 r16613  
    4242static bool blockMode(pxConfig *config);
    4343static bool maskedMode(pxConfig *config);
     44static bool unmaskedMode(pxConfig *config);
    4445static bool unblockMode(pxConfig *config);
    4546
     
    7172        MODECASE(CHIPTOOL_MODE_BLOCK,                   blockMode);
    7273        MODECASE(CHIPTOOL_MODE_MASKED,                  maskedMode);
     74        MODECASE(CHIPTOOL_MODE_UNMASKED,                unmaskedMode);
    7375        MODECASE(CHIPTOOL_MODE_UNBLOCK,                 unblockMode);
    7476        default:
     
    504506
    505507    if (psDBAffectedRows(config->dbh) < 1) {
    506         psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row");
     508        psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row");
    507509        return false;
    508510    }
     
    545547    PS_ASSERT_PTR_NON_NULL(config, false);
    546548
     549    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     550
     551    psMetadata *where = psMetadataAlloc();
     552
     553    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     554
     555    if (where->list->n < 1) {
     556        psFree(where);
     557        where = NULL;
     558    }
     559
    547560    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    548561
    549562    psString query = psStringCopy("SELECT * FROM chipMask");
     563
     564    if (where) {
     565        psString whereClause = psDBGenerateWhereSQL(where, NULL);
     566        psFree(where);
     567        psStringAppend(&query, " %s", whereClause);
     568        psFree(whereClause);
     569    }
     570
     571    // treat limit == 0 as "no limit"
     572    if (limit) {
     573        psString limitString = psDBGenerateLimitSQL(limit);
     574        psStringAppend(&query, " %s", limitString);
     575        psFree(limitString);
     576    }
    550577
    551578    if (!p_psDBRunQuery(config->dbh, query)) {
     
    575602    // negative simple so the default is true
    576603    if (!ippdbPrintMetadatas(stdout, output, "chipMask", !simple)) {
     604        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     605        psFree(output);
     606        return false;
     607    }
     608
     609    psFree(output);
     610
     611    return true;
     612}
     613
     614// return the list of labels which are NOT blocked
     615static bool unmaskedMode(pxConfig *config)
     616{
     617    PS_ASSERT_PTR_NON_NULL(config, false);
     618
     619    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     620    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     621
     622    psMetadata *where = psMetadataAlloc();
     623
     624    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     625
     626    if (where->list->n < 1) {
     627        psFree(where);
     628        where = NULL;
     629    }
     630
     631    psString query = pxDataGet("chiptool_unmasked.sql");
     632    if (!query) {
     633        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     634        return false;
     635    }
     636   
     637    if (where) {
     638        psString whereClause = psDBGenerateWhereSQL(where, "chipUnmask");
     639        psFree(where);
     640        psStringAppend(&query, " %s", whereClause);
     641        psFree(whereClause);
     642    }
     643
     644    // treat limit == 0 as "no limit"
     645    if (limit) {
     646        psString limitString = psDBGenerateLimitSQL(limit);
     647        psStringAppend(&query, " %s", limitString);
     648        psFree(limitString);
     649    }
     650
     651    if (!p_psDBRunQuery(config->dbh, query)) {
     652        psError(PS_ERR_UNKNOWN, false, "database error");
     653        psFree(query);
     654        return false;
     655    }
     656    psFree(query);
     657
     658    psArray *output = p_psDBFetchResult(config->dbh);
     659    if (!output) {
     660        psError(PS_ERR_UNKNOWN, false, "database error");
     661        return false;
     662    }
     663    if (!psArrayLength(output)) {
     664        psTrace("chiptool", PS_LOG_INFO, "no rows found");
     665        psFree(output);
     666        return true;
     667    }
     668
     669    if (!convertIdToStr(output)) {
     670        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
     671        psFree(output);
     672        return false;
     673    }
     674
     675    // negative simple so the default is true
     676    if (!ippdbPrintMetadatas(stdout, output, "chipUnmask", !simple)) {
    577677        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    578678        psFree(output);
Note: See TracChangeset for help on using the changeset viewer.