IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 16, 2008, 3:58:22 PM (18 years ago)
Author:
jhoblitt
Message:

rename chiptool -pendingcleanup -> -pendingcleanuprun
add chiptool -pendingcleanupimfile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/ippTools/src/chiptool.c

    r18153 r18154  
    4545static bool unmaskedMode(pxConfig *config);
    4646static bool unblockMode(pxConfig *config);
    47 static bool pendingcleanupMode(pxConfig *config);
     47static bool pendingcleanuprunMode(pxConfig *config);
     48static bool pendingcleanupimfileMode(pxConfig *config);
    4849static bool donecleanupMode(pxConfig *config);
    4950static bool runMode(pxConfig *config);
     
    6869
    6970    switch (config->mode) {
    70         MODECASE(CHIPTOOL_MODE_DEFINEBYQUERY,                   definebyqueryMode);
     71        MODECASE(CHIPTOOL_MODE_DEFINEBYQUERY,           definebyqueryMode);
    7172        MODECASE(CHIPTOOL_MODE_UPDATERUN,               updaterunMode);
    7273        MODECASE(CHIPTOOL_MODE_PENDINGIMFILE,           pendingimfileMode);
     
    7980        MODECASE(CHIPTOOL_MODE_UNMASKED,                unmaskedMode);
    8081        MODECASE(CHIPTOOL_MODE_UNBLOCK,                 unblockMode);
    81         MODECASE(CHIPTOOL_MODE_PENDINGCLEANUP,          pendingcleanupMode);
     82        MODECASE(CHIPTOOL_MODE_PENDINGCLEANUPRUN,       pendingcleanuprunMode);
     83        MODECASE(CHIPTOOL_MODE_PENDINGCLEANUPIMFILE,    pendingcleanupimfileMode);
    8284        MODECASE(CHIPTOOL_MODE_DONECLEANUP,             donecleanupMode);
    8385        MODECASE(CHIPTOOL_MODE_RUN,                     runMode);
     
    942944
    943945
    944 static bool pendingcleanupMode(pxConfig *config)
     946static bool pendingcleanuprunMode(pxConfig *config)
    945947{
    946948    PS_ASSERT_PTR_NON_NULL(config, NULL);
     
    952954    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
    953955
    954     psString query = pxDataGet("chiptool_pendingcleanup.sql");
     956    psString query = pxDataGet("chiptool_pendingcleanuprun.sql");
    955957    if (!query) {
    956958        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     
    997999
    9981000    // negative simple so the default is true
    999     if (!ippdbPrintMetadatas(stdout, output, "chipPendingCleanup", !simple)) {
     1001    if (!ippdbPrintMetadatas(stdout, output, "chipPendingCleanupRun", !simple)) {
     1002        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1003        psFree(output);
     1004        return false;
     1005    }
     1006
     1007    psFree(output);
     1008
     1009    return true;
     1010}
     1011
     1012
     1013static bool pendingcleanupimfileMode(pxConfig *config)
     1014{
     1015    PS_ASSERT_PTR_NON_NULL(config, NULL);
     1016
     1017    PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", false, false);
     1018    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1019    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1020
     1021    psMetadata *where = psMetadataAlloc();
     1022    if (chip_id) {
     1023        PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
     1024    }
     1025    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     1026
     1027    psString query = pxDataGet("chiptool_pendingcleanupimfile.sql");
     1028    if (!query) {
     1029        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1030        return false;
     1031    }
     1032
     1033    if (where && psListLength(where->list)) {
     1034        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1035        psStringAppend(&query, " AND %s", whereClause);
     1036        psFree(whereClause);
     1037    }
     1038    psFree(where);
     1039
     1040    // treat limit == 0 as "no limit"
     1041    if (limit) {
     1042        psString limitString = psDBGenerateLimitSQL(limit);
     1043        psStringAppend(&query, " %s", limitString);
     1044        psFree(limitString);
     1045    }
     1046
     1047    if (!p_psDBRunQuery(config->dbh, query)) {
     1048        psError(PS_ERR_UNKNOWN, false, "database error");
     1049        psFree(query);
     1050        return false;
     1051    }
     1052    psFree(query);
     1053
     1054    psArray *output = p_psDBFetchResult(config->dbh);
     1055    if (!output) {
     1056        psError(PS_ERR_UNKNOWN, false, "database error");
     1057        return false;
     1058    }
     1059    if (!psArrayLength(output)) {
     1060        psTrace("chiptool", PS_LOG_INFO, "no rows found");
     1061        psFree(output);
     1062        return true;
     1063    }
     1064
     1065    if (!convertIdToStr(output)) {
     1066        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
     1067        psFree(output);
     1068        return false;
     1069    }
     1070
     1071    // negative simple so the default is true
     1072    if (!ippdbPrintMetadatas(stdout, output, "chipPendingCleanupImfile", !simple)) {
    10001073        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    10011074        psFree(output);
Note: See TracChangeset for help on using the changeset viewer.