Changeset 24413 for branches/pap_mops/ippTools/src
- Timestamp:
- Jun 15, 2009, 1:45:42 PM (17 years ago)
- Location:
- branches/pap_mops/ippTools/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_mops/ippTools/src
- Property svn:ignore
-
old new 34 34 disttool 35 35 receivetool 36 37 pubtool
-
- Property svn:ignore
-
branches/pap_mops/ippTools/src/pubtool.c
r24377 r24413 1 1 /* 2 * receivetool.c2 * pubtool.c 3 3 * 4 4 * Copyright (C) 2008 … … 29 29 #include "pxtools.h" 30 30 #include "pxdata.h" 31 #include "receivetool.h" 32 33 static bool definesourceMode(pxConfig *config); 34 static bool listMode(pxConfig *config); 35 static bool addfilesetMode(pxConfig *config); 36 static bool updatelastMode(pxConfig *config); 37 static bool pendingfilesetMode(pxConfig *config); 38 static bool updatefilesetMode(pxConfig *config); 39 static bool addfileMode(pxConfig *config); 40 static bool pendingfileMode(pxConfig *config); 41 static bool addresultMode(pxConfig *config); 42 static bool toadvanceMode(pxConfig *config); 31 #include "pubtool.h" 32 33 static bool defineclientMode(pxConfig *config); 34 static bool definerunMode(pxConfig *config); 35 static bool pendingMode(pxConfig *config); 36 static bool addMode(pxConfig *config); 43 37 static bool revertMode(pxConfig *config); 38 static bool advanceMode(pxConfig *config); 44 39 45 40 # define MODECASE(caseName, func) \ … … 55 50 psLibInit(NULL); 56 51 57 pxConfig *config = receivetoolConfig(NULL, argc, argv);52 pxConfig *config = pubtoolConfig(NULL, argc, argv); 58 53 if (!config) { 59 54 psError(PXTOOLS_ERR_CONFIG, false, "failed to configure"); … … 62 57 63 58 switch (config->mode) { 64 MODECASE(RECEIVETOOL_MODE_DEFINESOURCE, definesourceMode); 65 MODECASE(RECEIVETOOL_MODE_LIST, listMode); 66 MODECASE(RECEIVETOOL_MODE_ADDFILESET, addfilesetMode); 67 MODECASE(RECEIVETOOL_MODE_UPDATELAST, updatelastMode); 68 MODECASE(RECEIVETOOL_MODE_PENDINGFILESET, pendingfilesetMode); 69 MODECASE(RECEIVETOOL_MODE_UPDATEFILESET, updatefilesetMode); 70 MODECASE(RECEIVETOOL_MODE_TOADVANCE, toadvanceMode); 71 MODECASE(RECEIVETOOL_MODE_ADDFILE, addfileMode); 72 MODECASE(RECEIVETOOL_MODE_PENDINGFILE, pendingfileMode); 73 MODECASE(RECEIVETOOL_MODE_ADDRESULT, addresultMode); 74 MODECASE(RECEIVETOOL_MODE_REVERT, revertMode); 59 MODECASE(PUBTOOL_MODE_DEFINECLIENT, defineclientMode); 60 MODECASE(PUBTOOL_MODE_DEFINERUN, definerunMode); 61 MODECASE(PUBTOOL_MODE_PENDING, pendingMode); 62 MODECASE(PUBTOOL_MODE_ADD, addMode); 63 MODECASE(PUBTOOL_MODE_REVERT, revertMode); 64 MODECASE(PUBTOOL_MODE_ADVANCE, advanceMode); 75 65 default: 76 66 psAbort("invalid option (this should not happen)"); … … 94 84 } 95 85 96 static bool define sourceMode(pxConfig *config)86 static bool defineclientMode(pxConfig *config) 97 87 { 98 88 PS_ASSERT_PTR_NON_NULL(config, false); 99 89 100 90 // required 101 PXOPT_LOOKUP_STR(source, config->args, "-source", true, false); 102 PXOPT_LOOKUP_STR(product, config->args, "-product", true, false); 103 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false); 91 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 92 PXOPT_LOOKUP_STR(destination, config->args, "-destination", true, false); 104 93 105 94 // optional 95 PXOPT_LOOKUP_STR(format, config->args, "-format", false, false); 106 96 PXOPT_LOOKUP_STR(comment, config->args, "-comment", false, false); 107 PXOPT_LOOKUP_STR(last, config->args, "-last", false, false); 108 PXOPT_LOOKUP_STR(status_product, config->args, "-status_product", false, false); 109 PXOPT_LOOKUP_STR(ds_dbname, config->args, "-ds_dbname", false, false); 110 PXOPT_LOOKUP_STR(ds_dbhost, config->args, "-ds_dbhost", false, false); 111 112 if (!receiveSourceInsert(config->dbh, 0, source, product, workdir, comment, last, status_product, ds_dbname, ds_dbhost)) { 113 psError(PS_ERR_UNKNOWN, false, "Database error"); 114 return false; 115 } 116 117 return true; 118 } 119 120 static bool listMode(pxConfig *config) 97 98 if (!publishClientInsert(config->dbh, 0, stage, destination, format, comment)) { 99 psError(PS_ERR_UNKNOWN, false, "Database error"); 100 return false; 101 } 102 103 return true; 104 } 105 106 static bool definerunMode(pxConfig *config) 121 107 { 122 108 PS_ASSERT_PTR_NON_NULL(config, false); … … 124 110 psMetadata *where = psMetadataAlloc(); // WHERE conditions 125 111 126 // required127 PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "==");128 PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "==");129 PXOPT_COPY_S64(config->args, where, "-comment", "receiveSource.comment", "LIKE");130 131 112 // optional 132 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 133 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 134 135 psString query = pxDataGet("receivetool_list.sql"); 113 PXOPT_COPY_STR(config->args, where, "-client_id", "client_id", "=="); 114 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 115 116 PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false); 117 118 psString query = pxDataGet("pubtool_definerun.sql"); // Query to run 136 119 if (!query) { 137 120 psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement"); … … 140 123 } 141 124 125 if (!psDBTransaction(config->dbh)) { 126 psError(PS_ERR_UNKNOWN, false, "Database error"); 127 psFree(where); 128 return false; 129 } 130 131 psString whereClause = psStringCopy(""); // Additional constraints to add to query 142 132 if (psListLength(where->list)) { 143 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 144 psStringAppend(&query, " WHERE %s", whereClause); 133 psString clause = psDBGenerateWhereConditionSQL(where, NULL); 134 psStringAppend(&whereClause, " AND %s", clause); 135 psFree(clause); 136 } 137 psFree(where); 138 139 if (!p_psDBRunQueryF(config->dbh, query, whereClause, whereClause)) { 140 psError(PS_ERR_UNKNOWN, false, "Database error"); 141 psFree(query); 145 142 psFree(whereClause); 146 } 147 psFree(where); 148 149 if (limit) { 150 psString limitString = psDBGenerateLimitSQL(limit); 151 psStringAppend(&query, " %s", limitString); 152 psFree(limitString); 153 } 154 155 if (!p_psDBRunQuery(config->dbh, query)) { 156 psError(PS_ERR_UNKNOWN, false, "Database error"); 157 psFree(query); 143 if (!psDBTransaction(config->dbh)) { 144 psError(PS_ERR_UNKNOWN, false, "Database error"); 145 } 158 146 return false; 159 147 } 160 148 psFree(query); 161 162 psArray *output = p_psDBFetchResult(config->dbh); 149 psFree(whereClause); 150 151 psArray *output = p_psDBFetchResult(config->dbh); // Output of SELECT statement 163 152 if (!output) { 164 153 psError(PS_ERR_UNKNOWN, false, "Database error"); 154 if (!psDBTransaction(config->dbh)) { 155 psError(PS_ERR_UNKNOWN, false, "Database error"); 156 } 165 157 return false; 166 158 } 167 159 if (!psArrayLength(output)) { 168 psTrace(" receivetool", PS_LOG_INFO, "No rows found");160 psTrace("pubtool", PS_LOG_INFO, "No rows found"); 169 161 psFree(output); 162 if (!psDBTransaction(config->dbh)) { 163 psError(PS_ERR_UNKNOWN, false, "Database error"); 164 } 170 165 return true; 171 166 } 172 if (!ippdbPrintMetadatas(stdout, output, "receiveSource", !simple)) { 173 psError(PS_ERR_UNKNOWN, false, "Failed to print array"); 174 psFree(output); 175 return false; 176 } 177 psFree(output); 178 179 return true; 180 } 181 182 static bool addfilesetMode(pxConfig *config) 183 { 184 PS_ASSERT_PTR_NON_NULL(config, false); 185 186 // required 187 PXOPT_LOOKUP_S64(source_id, config->args, "-src_id", true, false); 188 psMetadataItem *filesets = psMetadataLookup(config->args, "-fileset"); 189 if (!filesets) { 190 psError(PS_ERR_UNKNOWN, true, "-fileset is required"); 191 return false; 192 } 193 194 psString query = pxDataGet("receivetool_addfileset.sql"); 195 if (!query) { 196 psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement"); 197 return false; 198 } 199 200 if (!psDBTransaction(config->dbh)) { 201 psError(PS_ERR_UNKNOWN, false, "Database error"); 202 return false; 203 } 204 205 psString source_id_str = NULL; // source_id as a string 206 psStringAppend(&source_id_str, "%" PRId64, source_id); 207 208 psListIterator *iter = psListIteratorAlloc(filesets->data.list, PS_LIST_HEAD, false); // Iterator 209 psMetadataItem *item = NULL; // Item from iteration 210 while ((item = psListGetAndIncrement(iter))) { 211 psAssert(item && item->data.V && item->type == PS_DATA_STRING, "Argument is bad"); 212 const char *fileset = item->data.str; // Fileset name 213 214 if (!p_psDBRunQueryF(config->dbh, query, source_id_str, fileset)) { 215 psError(PS_ERR_UNKNOWN, false, "Database error"); 216 psFree(source_id_str); 217 psFree(query); 218 psFree(iter); 167 168 for (int i = 0; i < output->n; i++) { 169 psMetadata *row = output->data[i]; // Row of interest 170 psS64 client = psMetadataLookupS64(NULL, row, "client_id"); // Client identifier 171 psS64 stage = psMetadataLookupS64(NULL, row, "stage_id"); // Stage identifier 172 173 if (!publishRunInsert(config->dbh, 0, client, stage, set_label, "new")) { 174 psError(PS_ERR_UNKNOWN, false, "Unable to add fileset"); 175 psFree(output); 219 176 if (!psDBTransaction(config->dbh)) { 220 177 psError(PS_ERR_UNKNOWN, false, "Database error"); … … 222 179 return false; 223 180 } 224 225 psArray *output = p_psDBFetchResult(config->dbh); // Output of query 226 if (!output) { 227 psError(PS_ERR_UNKNOWN, false, "Database error"); 228 psFree(source_id_str); 229 psFree(query); 230 psFree(iter); 231 return false; 232 } 233 if (psArrayLength(output) > 0) { 234 psTrace("receivetool", PS_LOG_INFO, "Fileset %s is already present", fileset); 235 psFree(output); 236 continue; 237 } 238 psFree(output); 239 240 if (!receiveFilesetInsert(config->dbh, 0, source_id, fileset, "reg", NULL, NULL, 0)) { 241 psError(PS_ERR_UNKNOWN, false, "Unable to add fileset"); 242 psFree(source_id_str); 243 psFree(query); 244 psFree(iter); 245 if (!psDBTransaction(config->dbh)) { 246 psError(PS_ERR_UNKNOWN, false, "Database error"); 247 } 248 return false; 249 } 250 } 251 psFree(iter); 252 psFree(query); 253 psFree(source_id_str); 254 255 if (!psDBCommit(config->dbh)) { 256 psError(PS_ERR_UNKNOWN, false, "Database error"); 257 return false; 258 } 259 260 return true; 261 } 262 263 static bool updatelastMode(pxConfig *config) 264 { 265 PS_ASSERT_PTR_NON_NULL(config, false); 181 } 182 psFree(output); 183 184 if (!psDBTransaction(config->dbh)) { 185 psError(PS_ERR_UNKNOWN, false, "Database error"); 186 return false; 187 } 188 189 return true; 190 } 191 192 static bool pendingMode(pxConfig *config) 193 { 194 PS_ASSERT_PTR_NON_NULL(config, false); 195 196 psMetadata *where = psMetadataAlloc(); // WHERE conditions 266 197 267 198 // required 268 PXOPT_LOOKUP_S64(source_id, config->args, "-src_id", true, false); 269 PXOPT_LOOKUP_STR(fileset, config->args, "-fileset", true, false); 270 271 psString query = NULL; // Query to execute 272 psStringAppend(&query, "UPDATE receiveSource SET fileset_last = \'%s\' WHERE source_id = %" PRId64, 273 fileset, source_id); 274 275 if (!p_psDBRunQuery(config->dbh, query)) { 276 psError(PS_ERR_UNKNOWN, false, "Database error"); 277 psFree(query); 278 return false; 279 } 280 psFree(query); 281 282 return true; 283 } 284 285 286 static bool pendingfilesetMode(pxConfig *config) 287 { 288 PS_ASSERT_PTR_NON_NULL(config, false); 289 290 psMetadata *where = psMetadataAlloc(); // WHERE conditions 291 292 // required 293 PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "=="); 294 PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "=="); 295 PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE"); 199 PXOPT_COPY_STR(config->args, where, "-client_id", "publishClient.client_id", "=="); 200 PXOPT_COPY_STR(config->args, where, "-stage", "publishClient.stage", "=="); 201 PXOPT_COPY_STR(config->args, where, "-comment", "publishClient.comment", "LIKE"); 202 PXOPT_COPY_STR(config->args, where, "-label", "publishRun.label", "=="); 296 203 297 204 // optional … … 299 206 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 300 207 301 psString query = pxDataGet(" receivetool_pendingfileset.sql");208 psString query = pxDataGet("pubtool_pending.sql"); 302 209 if (!query) { 303 210 psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement"); … … 332 239 } 333 240 if (!psArrayLength(output)) { 334 psTrace(" receivetool", PS_LOG_INFO, "No rows found");241 psTrace("pubtool", PS_LOG_INFO, "No rows found"); 335 242 psFree(output); 336 243 return true; 337 244 } 338 if (!ippdbPrintMetadatas(stdout, output, " receiveFileset", !simple)) {245 if (!ippdbPrintMetadatas(stdout, output, "publishRun", !simple)) { 339 246 psError(PS_ERR_UNKNOWN, false, "Failed to print array"); 340 247 psFree(output); … … 346 253 } 347 254 348 static bool add fileMode(pxConfig *config)255 static bool addMode(pxConfig *config) 349 256 { 350 257 PS_ASSERT_PTR_NON_NULL(config, false); 351 258 352 259 // required 353 PXOPT_LOOKUP_S64(fileset_id, config->args, "-fileset_id", true, false); 354 PXOPT_LOOKUP_STR(file_list, config->args, "-file_list", true, false); 355 356 unsigned int numBad; 357 psMetadata *files = psMetadataConfigRead(NULL, &numBad, file_list, false); 358 if (!files) { 359 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to cleanly read MDC file with file list."); 360 return false; 361 } 362 363 364 if (!psDBTransaction(config->dbh)) { 365 psError(PS_ERR_UNKNOWN, false, "Database error"); 366 return false; 367 } 368 369 psMetadataIterator *iter = psMetadataIteratorAlloc(files, PS_LIST_HEAD, NULL); // Iterator 370 psMetadataItem *item; 371 while ((item = psMetadataGetAndIncrement(iter))) { 372 psMetadata *md = item->data.md; 373 psString file = psMetadataLookupStr(NULL, md, "file"); 374 psS64 bytes = psMetadataLookupS64(NULL, md, "bytes"); 375 psString md5sum = psMetadataLookupStr(NULL, md, "md5sum"); 376 psString file_type = psMetadataLookupStr(NULL, md, "file_type"); 377 psString component = psMetadataLookupStr(NULL, md, "component"); 378 379 if (!file) { 380 psError(PS_ERR_UNKNOWN, false, "failed to find value for file"); 381 return false; 382 } 383 if (!component) { 384 psError(PS_ERR_UNKNOWN, false, "failed to find value for component"); 385 return false; 386 } 387 388 if (!receiveFileInsert(config->dbh, 0, fileset_id, file, bytes, md5sum, file_type, component)) { 389 psError(PS_ERR_UNKNOWN, false, "Unable to add file"); 390 if (!psDBRollback(config->dbh)) { 391 psError(PS_ERR_UNKNOWN, false, "Database error"); 392 return false; 393 } 394 psFree(iter); 395 return false; 396 } 397 } 398 399 psFree(iter); 400 401 if (!psDBCommit(config->dbh)) { 402 psError(PS_ERR_UNKNOWN, false, "Database error"); 403 return false; 404 } 405 406 return true; 407 } 408 409 static bool pendingfileMode(pxConfig *config) 260 PXOPT_LOOKUP_S64(pub_id, config->args, "-pub_id", true, false); 261 PXOPT_LOOKUP_STR(component, config->args, "-component", true, false); 262 263 // optional 264 PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false); 265 266 if (!publishFileInsert(config->dbh, pub_id, component, fault)) { 267 psError(PS_ERR_UNKNOWN, false, "Unable to add file"); 268 return false; 269 } 270 271 return true; 272 } 273 274 275 276 277 static bool revertMode(pxConfig *config) 410 278 { 411 279 PS_ASSERT_PTR_NON_NULL(config, false); 412 280 413 281 psMetadata *where = psMetadataAlloc(); // WHERE conditions 414 415 // required 416 PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "=="); 417 PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "=="); 418 PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE"); 419 PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveFile.fileset_id", "=="); 420 PXOPT_COPY_S64(config->args, where, "-file_id", "receiveFile.file_id", "=="); 421 422 // optional 423 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 424 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 425 426 psString query = pxDataGet("receivetool_pendingfile.sql"); 282 PXOPT_COPY_S64(config->args, where, "-pub_id", "pub_id", "=="); 283 PXOPT_COPY_S32(config->args, where, "-fault", "fault", "=="); 284 PXOPT_COPY_STR(config->args, where, "-client_id", "client_id", "=="); 285 PXOPT_COPY_STR(config->args, where, "-component", "component", "=="); 286 PXOPT_COPY_STR(config->args, where, "-comment", "comment", "LIKE"); 287 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 288 289 psString query = pxDataGet("pubtool_revert.sql"); 427 290 if (!query) { 428 291 psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement"); … … 438 301 psFree(where); 439 302 440 if (limit) {441 psString limitString = psDBGenerateLimitSQL(limit);442 psStringAppend(&query, " %s", limitString);443 psFree(limitString);444 }445 446 303 if (!p_psDBRunQuery(config->dbh, query)) { 447 304 psError(PS_ERR_UNKNOWN, false, "Database error"); … … 451 308 psFree(query); 452 309 453 psArray *output = p_psDBFetchResult(config->dbh); 454 if (!output) { 455 psError(PS_ERR_UNKNOWN, false, "Database error"); 456 return false; 457 } 458 if (!psArrayLength(output)) { 459 psTrace("receivetool", PS_LOG_INFO, "No rows found"); 460 psFree(output); 461 return true; 462 } 463 if (!ippdbPrintMetadatas(stdout, output, "receiveFile", !simple)) { 464 psError(PS_ERR_UNKNOWN, false, "Failed to print array"); 465 psFree(output); 466 return false; 467 } 468 psFree(output); 469 470 return true; 471 } 472 473 static bool addresultMode(pxConfig *config) 474 { 475 PS_ASSERT_PTR_NON_NULL(config, false); 476 477 // required 478 PXOPT_LOOKUP_S64(file_id, config->args, "-file_id", true, false); 479 480 // optional 481 PXOPT_LOOKUP_F32(dtime_copy, config->args, "-dtime_copy", false, false); 482 PXOPT_LOOKUP_F32(dtime_extract, config->args, "-dtime_extract", false, false); 483 PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false); 484 485 if (!receiveResultInsert(config->dbh, file_id, dtime_copy, dtime_extract, fault)) { 486 psError(PS_ERR_UNKNOWN, false, "Database error"); 487 return false; 488 } 489 490 return true; 491 } 492 493 static bool revertMode(pxConfig *config) 494 { 495 PS_ASSERT_PTR_NON_NULL(config, false); 496 497 psMetadata *where = psMetadataAlloc(); // WHERE conditions 498 499 PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveResult.fileset_id", "=="); 500 PXOPT_COPY_S32(config->args, where, "-fault", "receiveResult.fault", "=="); 501 PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "=="); 502 PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "=="); 503 PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE"); 504 505 psString query = pxDataGet("receivetool_revert.sql"); 310 return true; 311 } 312 static bool advanceMode(pxConfig *config) 313 { 314 PS_ASSERT_PTR_NON_NULL(config, false); 315 316 psString query = pxDataGet("pubtool_advance.sql"); 506 317 if (!query) { 507 318 psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement"); 508 psFree(where); 509 return false; 510 } 511 512 if (psListLength(where->list)) { 513 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 514 psStringAppend(&query, " AND %s", whereClause); 515 psFree(whereClause); 516 } 517 psFree(where); 319 return false; 320 } 518 321 519 322 if (!p_psDBRunQuery(config->dbh, query)) { … … 526 329 return true; 527 330 } 528 static bool toadvanceMode(pxConfig *config)529 {530 PS_ASSERT_PTR_NON_NULL(config, false);531 532 psMetadata *where = psMetadataAlloc(); // WHERE conditions533 534 // optional535 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);536 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);537 538 psString query = pxDataGet("receivetool_toadvance.sql");539 if (!query) {540 psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement");541 psFree(where);542 return false;543 }544 545 if (psListLength(where->list)) {546 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);547 psStringAppend(&query, " AND %s", whereClause);548 psFree(whereClause);549 }550 psFree(where);551 552 if (limit) {553 psString limitString = psDBGenerateLimitSQL(limit);554 psStringAppend(&query, " %s", limitString);555 psFree(limitString);556 }557 558 if (!p_psDBRunQuery(config->dbh, query)) {559 psError(PS_ERR_UNKNOWN, false, "Database error");560 psFree(query);561 return false;562 }563 psFree(query);564 565 psArray *output = p_psDBFetchResult(config->dbh);566 if (!output) {567 psError(PS_ERR_UNKNOWN, false, "Database error");568 return false;569 }570 if (!psArrayLength(output)) {571 psTrace("receivetool", PS_LOG_INFO, "No rows found");572 psFree(output);573 return true;574 }575 if (!ippdbPrintMetadatas(stdout, output, "toadvanceFilesets", !simple)) {576 psError(PS_ERR_UNKNOWN, false, "Failed to print array");577 psFree(output);578 return false;579 }580 psFree(output);581 582 return true;583 }584 585 static bool updatefilesetMode(pxConfig *config)586 {587 PS_ASSERT_PTR_NON_NULL(config, false);588 589 // required590 PXOPT_LOOKUP_S64(fileset_id, config->args, "-fileset_id", true, false);591 592 // to chanage593 PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false);594 PXOPT_LOOKUP_STR(destdir, config->args, "-destdir", false, false);595 PXOPT_LOOKUP_STR(dirinfo, config->args, "-dirinfo", false, false);596 PXOPT_LOOKUP_STR(dbinfo, config->args, "-dbinfo", false, false);597 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);598 599 if (!fault && !dirinfo &&!dbinfo && !state) {600 psError(PS_ERR_UNKNOWN, true, "at least one of -fault, -dirinfo, -dbinfo, -set_state are required");601 return false;602 }603 604 psString query = NULL; // Query to execute605 psStringAppend(&query, "UPDATE receiveFileset SET ");606 607 psString sep = "";608 if (fault) {609 psStringAppend(&query, "%s fault = %d", sep, fault);610 sep = ",";611 }612 if (dirinfo) {613 psStringAppend(&query, "%s dirinfo = '%s'", sep, dirinfo);614 sep = ",";615 }616 if (dbinfo) {617 psStringAppend(&query, "%s dbinfo = '%s'", sep, dbinfo);618 sep = ",";619 }620 if (state) {621 psStringAppend(&query, "%s state = '%s'", sep, state);622 sep = ",";623 }624 625 psStringAppend(&query, " WHERE fileset_id = %" PRId64, fileset_id);626 627 if (!p_psDBRunQuery(config->dbh, query)) {628 psError(PS_ERR_UNKNOWN, false, "Database error");629 psFree(query);630 return false;631 }632 psFree(query);633 634 return true;635 } -
branches/pap_mops/ippTools/src/pubtoolConfig.c
r24377 r24413 46 46 psMetadata *defineclientArgs = psMetadataAlloc(); 47 47 psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-stage", 0, "define stage (required)", NULL); 48 psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-comment", 0, "define comment", NULL);49 48 psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-destination", 0, "define destination (required)", NULL); 50 49 psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-format", 0, "define format", NULL); 50 psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-comment", 0, "define comment", NULL); 51 51 52 52 // -definerun 53 53 psMetadata *definerunArgs = psMetadataAlloc(); 54 psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-client_id", 0, "define client_id (required)", 0);55 54 psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-set_label", 0, "define label", 0); 55 psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-client_id", 0, "search by client_id", 0); 56 56 psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-label", 0, "search by label", 0); 57 57 … … 61 61 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-stage", 0, "search on source", NULL); 62 62 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL); 63 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-label", 0, "search on label", NULL); 63 64 psMetadataAddBool(pendingArgs, PS_LIST_TAIL, "-simple", 0, "use simple output format?", false); 64 65 psMetadataAddU64(pendingArgs, PS_LIST_TAIL, "-limit", 0, "limit result set", 0); 65 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-label", 0, "search on label", NULL);66 66 67 67 // -add … … 82 82 // -advance 83 83 psMetadata *advanceArgs = psMetadataAlloc(); 84 psMetadataAddS64(advanceArgs, PS_LIST_TAIL, "-pub_id", 0, "search on pub_id", 0);85 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-label", 0, "search on label", NULL);86 84 87 85 psMetadata *argSets = psMetadataAlloc();
Note:
See TracChangeset
for help on using the changeset viewer.
