Changeset 27684
- Timestamp:
- Apr 14, 2010, 3:53:21 PM (16 years ago)
- Location:
- trunk/ippToPsps/src
- Files:
-
- 3 edited
-
ippToPsps.c (modified) (7 diffs)
-
ippToPsps.h (modified) (1 diff)
-
main.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/src/ippToPsps.c
r27433 r27684 18 18 #include "ippToPsps.h" 19 19 20 extern boolippToPsps_batchInit(IppToPsps *data);21 extern boolippToPsps_batchDetection(IppToPsps *data);22 extern boolippToPsps_batchStack(IppToPsps *data);23 extern boolippToPsps_batchDifference(IppToPsps *data);20 extern int ippToPsps_batchInit(IppToPsps *data); 21 extern int ippToPsps_batchDetection(IppToPsps *data); 22 extern int ippToPsps_batchStack(IppToPsps *data); 23 extern int ippToPsps_batchDifference(IppToPsps *data); 24 24 25 25 // Destructor 26 26 static void ippToPsps_Destructor(IppToPsps* this) { 27 27 28 // if unsuccessful, then delete FITS file 29 if (!this->success) { 30 31 psError(PS_ERR_UNKNOWN, false, "Failed, so deleting %s", this->fitsOutPath); 32 33 // if process failed, we need to delete that FITS file 34 if (remove(this->fitsOutPath) == -1) { 35 36 psError(PS_ERR_UNKNOWN, false, "Unable to delete %s", this->fitsOutPath); 37 } 38 } 39 // ...otherwise, close file 40 else { 41 42 int status = 0; 43 if (fits_close_file(this->fitsOut, &status)) { 44 45 psError(PS_ERR_IO, false, "Unable to close FITS file %s", this->fitsOutPath); 46 fits_report_error(stderr, status); 28 // if we created an output file... 29 if (this->fitsOut) { 30 31 // if unsuccessful, then delete FITS file 32 if (this->exitCode != PS_EXIT_SUCCESS) { 33 34 psError(PS_ERR_UNKNOWN, false, "Failed, so deleting %s", this->fitsOutPath); 35 36 // if process failed, we need to delete that FITS file 37 if (remove(this->fitsOutPath) == -1) { 38 39 psError(PS_ERR_UNKNOWN, false, "Unable to delete %s", this->fitsOutPath); 40 } 41 } 42 // ...otherwise, close file 43 else { 44 45 int status = 0; 46 if (fits_close_file(this->fitsOut, &status)) { 47 48 psError(PS_ERR_IO, false, "Unable to close FITS file %s", this->fitsOutPath); 49 fits_report_error(stderr, status); 50 } 47 51 } 48 52 } … … 77 81 78 82 psError(PS_ERR_UNKNOWN, false, "Unable to open file at %s", this->fitsInPath); 79 return NULL;83 return false; 80 84 } 81 85 … … 188 192 189 193 // Runs the requested process 190 static bool ippToPsps_run(IppToPsps *this) { 191 192 // which product? 193 switch(this->product) { 194 195 case PRODUCT_INIT: 196 this->success = ippToPsps_batchInit(this); 197 break; 198 case PRODUCT_DETECTION: 199 this->success = ippToPsps_batchDetection(this); 200 break; 201 case PRODUCT_STACK: 202 this->success = ippToPsps_batchStack(this); 203 break; 204 case PRODUCT_DIFFERENCE: 205 this->success = ippToPsps_batchDifference(this); 206 break; 207 default: 208 psError(PS_ERR_UNKNOWN, false, "Unable to run for this product type (%d)", this->product); 209 this->success = false; 210 break; 211 } 212 213 return this->success; 194 static int ippToPsps_run(IppToPsps *this) { 195 196 if(this->exitCode == PS_EXIT_SUCCESS) { 197 198 // which product? 199 switch(this->product) { 200 201 case PRODUCT_INIT: 202 this->exitCode = ippToPsps_batchInit(this); 203 break; 204 case PRODUCT_DETECTION: 205 this->exitCode = ippToPsps_batchDetection(this); 206 break; 207 case PRODUCT_STACK: 208 this->exitCode = ippToPsps_batchStack(this); 209 break; 210 case PRODUCT_DIFFERENCE: 211 this->exitCode = ippToPsps_batchDifference(this); 212 break; 213 default: 214 psError(PS_ERR_UNKNOWN, false, "Unable to run for this product type (%d)", this->product); 215 this->exitCode = false; 216 break; 217 } 218 } 219 220 return this->exitCode; 214 221 } 215 222 … … 236 243 this->dvoConfig = dvoConfigRead(argc, argv); 237 244 this->pmconfig = pmConfigRead(argc, argv, NULL); 238 this-> success = false;245 this->exitCode = PS_EXIT_SUCCESS; 239 246 this->run = ippToPsps_run; 240 247 … … 242 249 243 250 psError(PS_ERR_UNKNOWN, false, "Unable to read configuration."); 244 return NULL; 251 this->exitCode = PS_EXIT_CONFIG_ERROR; 252 return this; 245 253 } 246 254 … … 248 256 249 257 psFree(this); 250 return NULL; 251 } 252 253 if (this->product != PRODUCT_INIT && !ippToPsps_readInputFilePaths(this)) return NULL; 258 this->exitCode = PS_EXIT_CONFIG_ERROR; 259 return this; 260 } 261 262 if (this->product != PRODUCT_INIT && !ippToPsps_readInputFilePaths(this)) { 263 264 this->exitCode = PS_EXIT_DATA_ERROR; 265 return this; 266 } 254 267 255 268 if (this->product == PRODUCT_INIT) … … 272 285 fits_report_error(stderr, status); 273 286 psError(PS_ERR_IO, false, "Unable to create file at: '%s'", this->fitsOutPath); 274 return NULL; 287 this->exitCode = PS_EXIT_SYS_ERROR; 288 return this; 275 289 } 276 290 277 291 this->config = ippToPspsConfig_Constructor(this->configsDir); 278 if (this->config == NULL) return NULL; 292 if (this->config == NULL) { 293 294 this->exitCode = PS_EXIT_CONFIG_ERROR; 295 return this; 296 } 279 297 280 298 // ready results file, if necessary -
trunk/ippToPsps/src/ippToPsps.h
r27345 r27684 34 34 dvoConfig* dvoConfig; // dvo database 35 35 IppToPspsConfig* config; // config structure 36 bool success; // overall success/failure36 int exitCode; // ps exit code 37 37 38 bool(*run)();38 int (*run)(); 39 39 40 40 } IppToPsps; -
trunk/ippToPsps/src/main.c
r27345 r27684 18 18 ippToPsps_VersionPrint(); 19 19 20 int ret = PS_EXIT_SUCCESS;20 int exitCode; 21 21 22 22 // create ippToPsps 23 23 IppToPsps *ippToPsps = ippToPsps_Constructor(&argc, argv); 24 25 if (!ippToPsps) ret = PS_EXIT_CONFIG_ERROR; 26 else { 27 28 if (!ippToPsps->run(ippToPsps)) ret = PS_EXIT_DATA_ERROR; 29 psFree(ippToPsps); 30 } 24 ippToPsps->run(ippToPsps); 25 exitCode = ippToPsps->exitCode; 26 psFree(ippToPsps); 31 27 32 28 double secs = psTimerMark("ippToPsps"); 33 29 34 psLogMsg("ippToPsps", 3, "ippToPsps completed %ssuccessfully in %.1f %s\n", 35 (ret == PS_EXIT_SUCCESS) ? "" : "un", 30 psLogMsg("ippToPsps", 3, "ippToPsps completed %ssuccessfully, with exit code %d, in %.1f %s\n", 31 (exitCode == PS_EXIT_SUCCESS) ? "" : "un", 32 exitCode, 36 33 (secs<60.0) ? secs : (secs/60.0), 37 34 (secs<60.0) ? "sec(s)" : "min(s)"); … … 41 38 psLibFinalize(); 42 39 43 return ret;40 return exitCode; 44 41 }
Note:
See TracChangeset
for help on using the changeset viewer.
