IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 3, 2004, 3:05:00 PM (22 years ago)
Author:
desonia
Message:

changed the psError signature to match SDRS. Also made misc. cleanups as
I was combing the files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/xml/psXML.c

    r2204 r2273  
    99*  @author Ross Harman, MHPCC
    1010*
    11 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2004-10-27 00:57:30 $
     11*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2004-11-04 01:04:57 $
    1313*
    1414*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2929#include "psMetadata.h"
    3030#include "psMetadataIO.h"
     31#include "psConstants.h"
     32#include "psAstronomyErrors.h"
    3133
    3234
     
    3840#define FITS_ERROR(STRING,PS_ERROR) \
    3941fits_get_errstatus(status, fitsErr); \
    40 psError(__func__, STRING, PS_ERROR, fitsErr); \
     42psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr); \
    4143status = 0; \
    4244fits_close_file(fd, &status); \
    4345if(status){ \
    4446    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); \
    4648} \
    4749status = 0; \
     
    281283            default:
    282284                *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);
    284288            }
    285289
     
    302306    psMetadataType type;
    303307
    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,);
    318311
    319312    type = metadataItem->type;
     
    336329        break;
    337330    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);
    339334    }
    340335}
     
    358353    fitsfile *fd = NULL;
    359354
    360     if(fileName == NULL) {
    361         psError(__func__, "Null fileName not allowed");
    362         return NULL;
    363     }
     355    PS_PTR_CHECK_NULL(fileName,NULL);
    364356
    365357    fits_open_file(&fd, fileName, READONLY, &status);
     
    369361    }
    370362
    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);
    376367        return NULL;
    377368    }
     
    435426        case 'X':
    436427        default:
    437             psError(__func__, "Invalid psMetadataType: %c", keyType);
     428            psError(PS_ERR_IO, true,
     429                    PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID,
     430                    keyType);
    438431            return output;
    439432        }
    440433
    441434        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);
    443438            return output;
    444439        }
     
    471466
    472467    // 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);
    478473        return -1;
    479474    }
     
    486481    // Create reusable line for continuous read
    487482    line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char));
    488     if (line == NULL) {
    489         psAbort(__func__, "Failed to allocate reusable line");
    490     }
    491483
    492484    // While loop to parse the file
     
    504496            if(repeatedChars(linePtr, '@') > 1) {
    505497                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);
    507501                continue;
    508502            } else if(repeatedChars(linePtr, '*') > 1) {
    509503                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);
    511507                continue;
    512508            } else if(repeatedChars(linePtr, '~') > 0) {
    513509                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);
    515513                continue;
    516514            }
     
    521519                failedLines++;
    522520                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);
    524524                continue;
    525525            }
     
    530530                failedLines++;
    531531                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);
    533535                continue;
    534536            } else if(!strncmp(strType, "*", 1)) {
     
    551553            } else {
    552554                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);
    554558                continue;
    555559            }
     
    565569                    failedLines++;
    566570                    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);
    568574                    continue;
    569575                }
     
    575581                failedLines++;
    576582                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);
    578586                continue;
    579587            }
     
    589597                    } else {
    590598                        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);
    593602                        continue;
    594603                    }
     
    608617                    status = 0;
    609618                    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);
    611622                    continue;
    612623                }
     
    619630                    status = 0;
    620631                    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);
    622635                    continue;
    623636                }
     
    631644                    status = 0;
    632645                    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);
    634649                    continue;
    635650                }
     
    645660                    status = 0;
    646661                    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);
    648665                    continue;
    649666                }
     
    651668            default:
    652669                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);
    654673                continue;
    655674            } // switch
Note: See TracChangeset for help on using the changeset viewer.