IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 4, 2006, 1:30:57 PM (20 years ago)
Author:
jhoblitt
Message:

reimplemented pendingimfileMode()

File:
1 edited

Legend:

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

    r9239 r9249  
    147147    PS_ASSERT_PTR_NON_NULL(config, NULL);
    148148
    149     psArray *pendingFrames = p2PendingFrameSearch(config);
    150     if (!pendingFrames) {
    151         psErr *err = psErrorLast();
    152         if (strstr(err->msg, "no p2PendingExp rows found")) {
    153             psFree(err);
    154             return true;
    155         } else {
    156             psError(PS_ERR_UNKNOWN, false, "no p2PendingFrames found");
    157             psFree(err);
    158             return false;
    159         }
    160         psFree(err);
    161     }
    162     bool status = p2PendingFramePrint(stdout, config, pendingFrames);
    163     if (!status) {
    164         psError(PS_ERR_UNKNOWN, false,"p2PendingFramePrint() failed");
    165         psFree(pendingFrames);
    166         return false;
    167     }
    168 
    169     psFree(pendingFrames);
     149    // XXX does this need to be constrained so that it won't return any results
     150    // if a match p2PendingExp hasn't been registered?
     151    psString query = psStringCopy("SELECT * FROM p2PendingImfile");
     152
     153    if (config->where) {
     154        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "rawImfile");
     155        psStringAppend(&query, " AND %s", whereClause);
     156        psFree(whereClause);
     157    }
     158
     159    if (!p_psDBRunQuery(config->dbh, query)) {
     160        psError(PS_ERR_UNKNOWN, false, "database error");
     161        psFree(query);
     162        return false;
     163    }
     164    psFree(query);
     165
     166    psArray *output = p_psDBFetchResult(config->dbh);
     167    if (!output) {
     168        psError(PS_ERR_UNKNOWN, false, "database error");
     169        return false;
     170    }
     171    if (!psArrayLength(output)) {
     172        // XXX check psError here
     173        psError(PS_ERR_UNKNOWN, false, "no p2PendingImfile rows found");
     174        psFree(output);
     175        return true;
     176    }
     177
     178    bool simple = false;
     179    {
     180        bool status = false;
     181        simple = psMetadataLookupBool(&status, config->args, "-simple");
     182        if (!status) {
     183            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     184            return false;
     185        }
     186    }
     187
     188    // negative simple so the default is true
     189    if (!ippdbPrintMetadatas(stdout, output, "p2PendingImfile", !simple)) {
     190        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     191        psFree(output);
     192        return false;
     193    }
     194
     195    psFree(output);
    170196
    171197    return true;
Note: See TracChangeset for help on using the changeset viewer.