Changeset 31030 for trunk/ippToPsps/src/Fits.c
- Timestamp:
- Mar 23, 2011, 4:27:17 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/src/Fits.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/src/Fits.c
r31016 r31030 26 26 if (!strncmp(typename, "TSTRING", 7)) return TSTRING; 27 27 28 psError(PS_ERR_IO, false, "*Fits: Don't understand data type '%s'", typename);28 // this->logger->print(this->logger, MSG_ERROR, "Fits: Don't understand data type '%s'", typename); 29 29 30 30 return 0; … … 36 36 static void destroy(Fits* this) { 37 37 38 this->logger->print(this->logger, MSG_DEBUG, "Fits: Destructor\n"); 39 38 40 int status = 0; 39 41 if (fits_close_file(this->file, &status)) { 40 42 41 psError(PS_ERR_IO, false, "* Fits: Unable to close FITS file");43 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to close FITS file '%s'\n", this->path); 42 44 fits_report_error(stderr, status); 43 45 } 44 46 else 45 psLogMsg("ippToPsps", PS_LOG_INFO, "* Fits: Closed '%s'", this->path); 47 this->logger->print(this->logger, MSG_INFO, "Fits: Closed FITS file '%s'\n", this->path); 48 49 free(this); 46 50 } 47 51 … … 56 60 if (status) { 57 61 58 psError(PS_ERR_IO, false, "* Fits: Could not get value for header key '%s'\n", name);62 this->logger->print(this->logger, MSG_ERROR, "Fits: Could not get value for header key '%s' from file at '%s'\n", name, this->path); 59 63 return false; 60 64 } … … 82 86 if (status) { 83 87 84 psError(PS_ERR_IO, false, "* Fits: Failed to read vector column %d row %ld", col, row);88 this->logger->print(this->logger, MSG_ERROR, "Fits: Failed to read vector column %d row %ld\n", col, row); 85 89 return false; 86 90 } … … 98 102 if (status) { 99 103 100 psError(PS_ERR_IO, false, "*Fits: Could not get column number for '%s'\n", name);104 this->logger->print(this->logger, MSG_ERROR, "Fits: Could not get column number for '%s'\n", name); 101 105 return false; 102 106 } … … 119 123 if (status) { 120 124 121 psError(PS_ERR_IO, false, "* Fits: Unable to read col '%s'", name);125 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to read col '%s'\n", name); 122 126 return false; 123 127 } … … 127 131 if (status) { 128 132 129 psError(PS_ERR_IO, false, "* Fits: Unable to read type info for '%s'", name);133 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to read type info for '%s'\n", name); 130 134 return false; 131 135 } … … 143 147 if (fits_movnam_hdu(this->file, type, name, 0, &status)) { 144 148 145 psError(PS_ERR_IO, false, "* Fits: Can't move to table extension named '%s'\n", name); 149 this->logger->print(this->logger, MSG_ERROR, "Fits: Can't move to table extension named '%s'\n", name); 150 return false; 146 151 } 147 152 … … 173 178 if (fits_get_num_rows(this->file, count, &status)) { 174 179 175 psError(PS_ERR_IO, false, "*Fits: Count not count rows in this table\n");180 this->logger->print(this->logger, MSG_ERROR, "Fits: Count not count rows in this table\n"); 176 181 return false; 177 182 } … … 196 201 if (remove(this->path) == -1) { 197 202 198 psError(PS_ERR_UNKNOWN, false, "* Fits: Unable to delete '%s'", this->path); 199 return false; 200 } 203 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to delete '%s'\n", this->path); 204 return false; 205 } 206 207 this->logger->print(this->logger, MSG_INFO, "Fits: Deleted FITS file at '%s'\n", this->path); 201 208 202 209 return true; … … 228 235 if (status) { 229 236 230 psError(PS_ERR_IO, false, "* Fits: Unable to delet rows using rowlist\n");237 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to delete rows using rowlist\n"); 231 238 return false; 232 239 } … … 283 290 else { 284 291 285 psError(PS_ERR_IO, false, "* Fits: Don't support datatype '%d' yet\n", datatype);286 return false; 287 } 288 289 if (status) { 290 291 psError(PS_ERR_IO, false, "*Fits: Unable to read column data from column %d\n", colnum);292 this->logger->print(this->logger, MSG_ERROR, "Fits: Don't understand datatype '%d'\n", datatype); 293 return false; 294 } 295 296 if (status) { 297 298 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to read column data from column %d\n", colnum); 292 299 return false; 293 300 … … 331 338 if (status) { 332 339 333 psError(PS_ERR_IO, false, "*Fits: Unable to write column data for column %d\n", colnum);340 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to write column data for column %d\n", colnum); 334 341 return false; 335 342 … … 355 362 if (status) { 356 363 357 psError(PS_ERR_IO,"* Fits: Unable to create table: '%s'", name);364 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to create table: '%s'\n", name); 358 365 return false; 359 366 } … … 366 373 Initilization common to all constructors 367 374 */ 368 static void init(Fits* this) { 375 static Fits* init(const char* path, Logger* logger) { 376 377 Fits* this = (Fits*)calloc(1, sizeof(Fits)); 378 379 // fields 380 strcpy(this->path, path); 381 this->logger = logger; 369 382 370 383 // method pointers … … 390 403 assert(this); 391 404 405 return this; 392 406 } 393 407 … … 398 412 399 413 */ 400 Fits* existing_Fits(char* path) { 401 402 Fits* this = (Fits*)calloc(1, sizeof(Fits)); 403 404 int status = 0; 405 strcpy(this->path, path); 406 407 if (fits_open_file(&this->file, this->path, READONLY, &status)) { 408 409 psError(PS_ERR_IO, false, "* Fits: Unable to open FITS file here %s\n", path); 414 Fits* existing_Fits(const char* path, Logger* logger) { 415 416 Fits* this = init(path, logger); 417 this->logger->print(this->logger, MSG_DEBUG, "Fits: Constructor for existing file at '%s'\n", path); 418 419 int status = 0; 420 if (fits_open_file(&this->file, path, READONLY, &status)) { 421 422 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to open FITS file here %s\n", path); 410 423 this->file = NULL; 411 424 } 412 425 413 init(this);414 426 415 427 return this; … … 421 433 Returns a new Fits object representing a new FITS file. 422 434 */ 423 Fits* new_Fits(char* path) { 424 425 Fits* this = (Fits*)calloc(1, sizeof(Fits)); 426 427 int status = 0; 428 strcpy(this->path, path); 429 430 if (fits_create_file(&this->file, this->path, &status)) { 431 432 psError(PS_ERR_IO, false, "* Fits: Unable to create file here '%s'", path); 435 Fits* new_Fits(const char* path, Logger* logger) { 436 437 Fits* this = init(path, logger); 438 this->logger->print(this->logger, MSG_DEBUG, "Fits: Constructor for new file at '%s'\n", path); 439 440 int status = 0; 441 if (fits_create_file(&this->file, path, &status)) { 442 443 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to create FITS file here '%s'\n", path); 433 444 this->file = NULL; 434 445 } 435 446 436 init(this);437 438 447 return this; 439 448 }
Note:
See TracChangeset
for help on using the changeset viewer.
