Changeset 9967 for trunk/ippTools/src/pztool.c
- Timestamp:
- Nov 13, 2006, 4:00:40 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pztool.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pztool.c
r9735 r9967 32 32 static bool pendingMode(pxConfig *config); 33 33 static bool copydoneMode(pxConfig *config); 34 static bool summitExpPrint(FILE *stream, summitExpRow *summitExp); 34 35 35 static psArray *pztoolPendingExp(pxConfig *config); 36 36 static psArray *pztoolPendingImfiles(pxConfig *config); … … 78 78 PS_ASSERT_PTR_NON_NULL(config, false); 79 79 80 psArray *summit = summitExpSelectRowObjects(config->dbh, 81 config->where, MAX_ROWS); 82 if (!summit) { 83 psError(PS_ERR_UNKNOWN, false, "no summitExp rows found"); \ 84 return false; 85 } 86 87 psArray *new = newExpSelectRowObjects(config->dbh, 88 config->where, MAX_ROWS); 89 if (!new) { 90 psError(PS_ERR_UNKNOWN, false, "no newExp rows found"); \ 91 } 92 93 if (new) { 94 for (long i = 0; i < summit->n; i++) { 95 summitExpRow *summitExp = summit->data[i]; 96 for (long j = 0; j < summit->n; j++) { 97 newExpRow *newExp = new->data[j]; 98 if (strcmp(summitExp->exp_id, newExp->exp_id) == 0) { 99 psArrayRemoveData(summit, summitExp); 100 // dec the counter as the array just got shorter 101 //and we don't want to skip elemnts 102 i--; 103 break; 104 } 105 } 106 } 107 psFree(new); 108 } 109 110 for (long i = 0; i < summit->n; i++) { 111 if (!summitExpPrint(stdout, summit->data[i])) { 112 psError(PS_ERR_UNKNOWN, false,"summitExpPrint() failed"); 80 psString query = psStringCopy( 81 "SELECT" 82 " summitExp.*" 83 " FROM summitExp" 84 " LEFT JOIN newExp" 85 " USING(exp_id, camera, telescope)" 86 " WHERE" 87 " newExp.exp_id is NULL" 88 " AND newExp.camera IS NULL" 89 " AND newExp.telescope IS NULL" 90 ); 91 92 if (config->where) { 93 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "newExp"); 94 psStringAppend(&query, " AND %s", whereClause); 95 psFree(whereClause); 96 } 97 98 if (!p_psDBRunQuery(config->dbh, query)) { 99 psError(PS_ERR_UNKNOWN, false, "database error"); 100 psFree(query); 101 return false; 102 } 103 psFree(query); 104 105 psArray *output = p_psDBFetchResult(config->dbh); 106 if (!output) { 107 psError(PS_ERR_UNKNOWN, false, "database error"); 108 return false; 109 } 110 if (!psArrayLength(output)) { 111 psError(PS_ERR_UNKNOWN, false, "no newExp rows found"); 112 psFree(output); 113 return true; 114 } 115 116 bool simple = false; 117 { 118 bool status = false; 119 simple = psMetadataLookupBool(&status, config->args, "-simple"); 120 if (!status) { 121 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 113 122 return false; 114 123 } 115 124 } 125 126 // negative simple so the default is true 127 if (!ippdbPrintMetadatas(stdout, output, "newExp", !simple)) { 128 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 129 psFree(output); 130 return false; 131 } 132 133 psFree(output); 116 134 117 135 return true; … … 201 219 202 220 return false; 203 }204 205 static bool summitExpPrint(FILE *stream, summitExpRow *summitExp)206 {207 PS_ASSERT_PTR_NON_NULL(stream, false);208 PS_ASSERT_PTR_NON_NULL(summitExp, false);209 210 fprintf(stream, "%s %s %s %s %s\n",211 summitExp->exp_id,212 summitExp->camera,213 summitExp->telescope,214 summitExp->exp_type,215 summitExp->uri216 );217 218 return true;219 221 } 220 222
Note:
See TracChangeset
for help on using the changeset viewer.
