Changeset 17957 for branches/faketool/ippTools/src/faketool.c
- Timestamp:
- Jun 5, 2008, 4:29:29 PM (18 years ago)
- File:
-
- 1 edited
-
branches/faketool/ippTools/src/faketool.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/faketool/ippTools/src/faketool.c
r17938 r17957 35 35 static bool queueMode(pxConfig *config); 36 36 static bool updaterunMode(pxConfig *config); 37 static bool pendingexpMode(pxConfig *config); 37 38 static bool pendingimfileMode(pxConfig *config); 38 39 static bool addprocessedimfileMode(pxConfig *config); … … 66 67 MODECASE(FAKETOOL_MODE_QUEUE, queueMode); 67 68 MODECASE(FAKETOOL_MODE_UPDATERUN, updaterunMode); 69 MODECASE(FAKETOOL_MODE_PENDINGEXP, pendingexpMode); 68 70 MODECASE(FAKETOOL_MODE_PENDINGIMFILE, pendingimfileMode); 69 71 MODECASE(FAKETOOL_MODE_ADDPROCESSEDIMFILE, addprocessedimfileMode); … … 178 180 179 181 if (where && psListLength(where->list)) { 180 psString whereClause = psDBGenerateWhere ConditionSQL(where, "camRun");181 psStringAppend(&query, " AND%s", whereClause);182 psString whereClause = psDBGenerateWhereSQL(where, NULL); 183 psStringAppend(&query, " %s", whereClause); 182 184 psFree(whereClause); 183 185 } … … 353 355 354 356 357 static bool pendingexpMode(pxConfig *config) 358 { 359 PS_ASSERT_PTR_NON_NULL(config, false); 360 361 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 362 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 363 364 psMetadata *where = psMetadataAlloc(); 365 PXOPT_COPY_STR(config->args, where, "-fake_id", "fake_id", "=="); 366 PXOPT_COPY_STR(config->args, where, "-cam_id", "cam_id", "=="); 367 PXOPT_COPY_STR(config->args, where, "-chip_id", "chip_id", "=="); 368 369 psString query = pxDataGet("faketool_find_pendingexp.sql"); 370 if (!query) { 371 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 372 psFree(where); 373 return false; 374 } 375 376 if (where && psListLength(where->list)) { 377 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 378 psStringAppend(&query, " AND %s", whereClause); 379 psFree(whereClause); 380 } 381 psFree(where); 382 383 // treat limit == 0 as "no limit" 384 if (limit) { 385 psString limitString = psDBGenerateLimitSQL(limit); 386 psStringAppend(&query, " %s", limitString); 387 psFree(limitString); 388 } 389 390 if (!p_psDBRunQuery(config->dbh, query)) { 391 psError(PS_ERR_UNKNOWN, false, "database error"); 392 psFree(query); 393 return false; 394 } 395 psFree(query); 396 397 psArray *output = p_psDBFetchResult(config->dbh); 398 if (!output) { 399 psError(PS_ERR_UNKNOWN, false, "database error"); 400 return false; 401 } 402 if (!psArrayLength(output)) { 403 psTrace("camtool", PS_LOG_INFO, "no rows found"); 404 psFree(output); 405 return true; 406 } 407 408 if (!convertIdToStr(output)) { 409 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings"); 410 psFree(output); 411 return false; 412 } 413 414 // negate simple so the default is true 415 if (!ippdbPrintMetadatas(stdout, output, "fakePendingExp", !simple)) { 416 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 417 psFree(output); 418 return false; 419 } 420 421 psFree(output); 422 423 return true; 424 } 425 426 355 427 static bool pendingimfileMode(pxConfig *config) 356 428 { … … 705 777 PXOPT_LOOKUP_S16(code, config->args, "-code", true, false); 706 778 707 if (!pxSetFaultCode(config->dbh, "fakeProcessedImfile", config->where, code)) { 779 psMetadata *where = psMetadataAlloc(); 780 PXOPT_LOOKUP_STR(fake_id, config->args, "-fake_id", false, false); 781 // convert fake_id into a psS64 782 if (fake_id) { 783 if (!psMetadataAddS64(where, PS_LIST_TAIL, "fake_id", 0, "==", (psS64)atoll(fake_id))) { 784 psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id"); 785 psFree(where); 786 return false; 787 } 788 } 789 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 790 791 if (!pxSetFaultCode(config->dbh, "fakeProcessedImfile", where, code)) { 708 792 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 709 return false; 710 } 793 psFree(where); 794 return false; 795 } 796 psFree(where); 711 797 712 798 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
