Changeset 2273 for trunk/psLib/src/xml/psXML.c
- Timestamp:
- Nov 3, 2004, 3:05:00 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/xml/psXML.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/xml/psXML.c
r2204 r2273 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 00:57:30$11 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-04 01:04:57 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 #include "psMetadata.h" 30 30 #include "psMetadataIO.h" 31 #include "psConstants.h" 32 #include "psAstronomyErrors.h" 31 33 32 34 … … 38 40 #define FITS_ERROR(STRING,PS_ERROR) \ 39 41 fits_get_errstatus(status, fitsErr); \ 40 psError( __func__, STRING, PS_ERROR, fitsErr); \42 psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \ 41 43 status = 0; \ 42 44 fits_close_file(fd, &status); \ 43 45 if(status){ \ 44 46 fits_get_errstatus(status, fitsErr); \ 45 psError( __func__, "Couldn't close FITS file. FITS error: %s", fitsErr); \47 psError(PS_ERR_IO,true, "Couldn't close FITS file. FITS error: %s", fitsErr); \ 46 48 } \ 47 49 status = 0; \ … … 281 283 default: 282 284 *status = 1; 283 psError(__func__, "Invalid type: %d", elemType); 285 psError(PS_ERR_BAD_PARAMETER_VALUE,true, 286 PS_ERRORTEXT_psMetadataIO_TYPE_INVALID, 287 elemType); 284 288 } 285 289 … … 302 306 psMetadataType type; 303 307 304 if (fd == NULL) { 305 psError(__func__, "Null file descriptor not allowed"); 306 return; 307 } 308 309 if (format == NULL) { 310 psError(__func__, "Null format not allowed"); 311 return; 312 } 313 314 if (metadataItem == NULL) { 315 psError(__func__, "Null metadata not allowed"); 316 return; 317 } 308 PS_PTR_CHECK_NULL(fd,); 309 PS_PTR_CHECK_NULL(format,); 310 PS_PTR_CHECK_NULL(metadataItem,); 318 311 319 312 type = metadataItem->type; … … 336 329 break; 337 330 default: 338 psError(__func__, " Invalid psMetadataType to print: %d", type); 331 psError(PS_ERR_BAD_PARAMETER_TYPE,true, 332 PS_ERRORTEXT_psMetadata_METATYPE_INVALID, 333 (int)type); 339 334 } 340 335 } … … 358 353 fitsfile *fd = NULL; 359 354 360 if(fileName == NULL) { 361 psError(__func__, "Null fileName not allowed"); 362 return NULL; 363 } 355 PS_PTR_CHECK_NULL(fileName,NULL); 364 356 365 357 fits_open_file(&fd, fileName, READONLY, &status); … … 369 361 } 370 362 371 if (extName == NULL && extNum == 0) { 372 psError(__func__, "Null extName and extNum = 0 not allowed"); 373 return NULL; 374 } else if (extName && (extNum != -1) ) { 375 psError(__func__, "If extName specified, extNum arguments should be -1."); 363 if (extName == NULL && extNum < 1) { 364 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 365 PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE, 366 extNum); 376 367 return NULL; 377 368 } … … 435 426 case 'X': 436 427 default: 437 psError(__func__, "Invalid psMetadataType: %c", keyType); 428 psError(PS_ERR_IO, true, 429 PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID, 430 keyType); 438 431 return output; 439 432 } 440 433 441 434 if (!success) { 442 psError(__func__, "Failed to add metadata item. Name: %s", keyName); 435 psError(PS_ERR_UNKNOWN, false, 436 PS_ERRORTEXT_psMetadataIO_ADD_FAILED, 437 keyName); 443 438 return output; 444 439 } … … 471 466 472 467 // Check for nulls 473 if(fileName == NULL) {474 psError(__func__, "Null fileName not allowed");475 return -1;476 } else if((fp=fopen(fileName, "r")) == NULL) {477 psError(__func__, "Couldn't open file. Name: %s",fileName);468 PS_PTR_CHECK_NULL(fileName,-1); 469 if((fp=fopen(fileName, "r")) == NULL) { 470 psError(PS_ERR_IO, true, 471 PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED, 472 fileName); 478 473 return -1; 479 474 } … … 486 481 // Create reusable line for continuous read 487 482 line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char)); 488 if (line == NULL) {489 psAbort(__func__, "Failed to allocate reusable line");490 }491 483 492 484 // While loop to parse the file … … 504 496 if(repeatedChars(linePtr, '@') > 1) { 505 497 failedLines++; 506 psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line); 498 psError(PS_ERR_IO, true, 499 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 500 '@', lineCount, fileName); 507 501 continue; 508 502 } else if(repeatedChars(linePtr, '*') > 1) { 509 503 failedLines++; 510 psError(__func__, "More than one * charecter not allowed. Line %d: %s", lineCount, line); 504 psError(PS_ERR_IO, true, 505 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 506 '*', lineCount, fileName); 511 507 continue; 512 508 } else if(repeatedChars(linePtr, '~') > 0) { 513 509 failedLines++; 514 psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line); 510 psError(PS_ERR_IO, true, 511 PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, 512 '~', lineCount, fileName); 515 513 continue; 516 514 } … … 521 519 failedLines++; 522 520 status = 0; 523 psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line); 521 psError(PS_ERR_IO, true, 522 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 523 "name",lineCount, fileName); 524 524 continue; 525 525 } … … 530 530 failedLines++; 531 531 status = 0; 532 psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line); 532 psError(PS_ERR_IO, true, 533 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 534 "type",lineCount, fileName); 533 535 continue; 534 536 } else if(!strncmp(strType, "*", 1)) { … … 551 553 } else { 552 554 failedLines++; 553 psError(__func__, "Invalid psMetadataType. Type: %s Line %d: %s", strType, lineCount, line); 555 psError(PS_ERR_IO, true, 556 PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID, 557 strType, lineCount, fileName); 554 558 continue; 555 559 } … … 565 569 failedLines++; 566 570 status = 0; 567 psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line); 571 psError(PS_ERR_IO, true, 572 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 573 "value",lineCount, fileName); 568 574 continue; 569 575 } … … 575 581 failedLines++; 576 582 status = 0; 577 psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line); 583 psError(PS_ERR_IO, true, 584 PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, 585 "comment",lineCount, fileName); 578 586 continue; 579 587 } … … 589 597 } else { 590 598 failedLines++; 591 psError(__func__, "Overwrite for name not allowed. Name: %s. Line %d: %s", strName, 592 lineCount, line); 599 psError(PS_ERR_IO, true, 600 PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM, 601 strName, lineCount, fileName); 593 602 continue; 594 603 } … … 608 617 status = 0; 609 618 failedLines++; 610 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 619 psError(PS_ERR_IO, true, 620 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 621 strValue, strName, strType, lineCount, fileName); 611 622 continue; 612 623 } … … 619 630 status = 0; 620 631 failedLines++; 621 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 632 psError(PS_ERR_IO, true, 633 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 634 strValue, strName, strType, lineCount, fileName); 622 635 continue; 623 636 } … … 631 644 status = 0; 632 645 failedLines++; 633 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 646 psError(PS_ERR_IO, true, 647 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 648 strValue, strName, strType, lineCount, fileName); 634 649 continue; 635 650 } … … 645 660 status = 0; 646 661 failedLines++; 647 psError(__func__, "Failed to parse value. Value: %s Line %d: %s", strValue, lineCount, line); 662 psError(PS_ERR_IO, true, 663 PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, 664 strValue, strName, strType, lineCount, fileName); 648 665 continue; 649 666 } … … 651 668 default: 652 669 failedLines++; 653 psError(__func__, "Invalid psMetadataType. Type: %d Line %d: %s", mdType, lineCount, line); 670 psError(PS_ERR_IO, true, 671 PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID, 672 mdType, lineCount, fileName); 654 673 continue; 655 674 } // switch
Note:
See TracChangeset
for help on using the changeset viewer.
