IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1352


Ignore:
Timestamp:
Jul 30, 2004, 2:17:01 PM (22 years ago)
Author:
harman
Message:

Added more functions

Location:
trunk/psLib/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astronomy/psMetadata.c

    r1351 r1352  
    1111*  @author Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2004-07-30 19:36:52 $
     13*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2004-07-31 00:17:01 $
    1515*
    1616*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4343// Maximum metadata error length
    4444#define MAX_ERR_MESSAGE_LENGTH 1024
     45
     46// Maximum line size
     47#define MAX_LINE_SIZE 80
    4548
    4649/******************************************************************************/
     
    565568psMetadata *psMetadataReadHeader( psMetadata *output, const char *extname, int extnum, const char *filename )
    566569{
    567     return NULL;
    568    
     570    char line[ MAX_VAL_SIZE ];
     571    char keyName[ MAX_VAL_SIZE ];
     572    char keyValue[ MAX_VAL_SIZE ];
     573    char keyComment[ MAX_VAL_SIZE ];
     574    int status = 0;
     575    extnumCtr = 1;
     576    FILE *fd = NULL;
     577   
     578    if ( filename == NULL ) {
     579            psError( __func__, "Null file name not allowed" );
     580            return NULL;
     581        }
     582       
     583    if ( extname == NULL && extnum == 0 ) {
     584            psError( __func__, "Null extname AND extnum = 0 not allowed" );
     585            return NULL;
     586        } else if ( extname && extnum ) {
     587            psError( __func__, "Both extname AND extnum arguments should not have valid values." );
     588            return NULL;
     589        }
     590       
     591    fd = fopen( filename, "r" );
     592    if ( fd == NULL ) {
     593            psError( __func__, "Null FITS file descriptor not allowed" );
     594            return NULL;
     595        }
     596       
     597    // Allocate metadata if user didn't
     598    if ( output == NULL ) {
     599            output = psMetadataAlloc();
     600            psError( __func__, "Failed to allocate metadata" );
     601            return NULL;
     602        }
     603       
     604    // Move to user designated HDU number or HDU name in text file. HDU numbers starts at one.
     605    /* TODO    if(extname == NULL) {
     606                return output;
     607            }
     608        } else if(extnum > 0) {
     609                return output;
     610            }
     611        }
     612     
     613     
     614         line = fgets(line, MAX_LINE_SIZE+1, fp);
     615         while(line != NULL) {
     616     
     617             if(!strncmp("END", line, 3)){
     618                 extnumCtr++;
     619             }
     620     
     621             if(extnumCtr == extnum) {
     622     
     623                 // Put text into metadata
     624                 if(!strncmp("COMMENT", line, 7)){
     625                     // COMMENT keywords have no "=" sign
     626                     //TODO
     627                 } else if (strchr(line, '\'') != NULL){
     628     
     629                     // Output and logging keywords have tic (') characters
     630                     keyName = strtok(line, "=");
     631                     keyValue = strtok(NULL, "'");
     632                     keyValue = strtok(NULL, "'");
     633                     keyComment = strtok(NULL, "XXX");
     634     
     635     
     636                 } else
     637     
     638                     // Everything else is considered to be the standard name and value
     639                     keyName = strtok(line, "=");
     640                     keyValue = strtok(NULL, "/");
     641                     keyComment = strtok(NULL, "XXX");
     642                 }
     643     
     644     
     645             }
     646     
     647             // Read next line
     648             line = fgets(line, MAX_LINE_SIZE+1, fp);
     649         }
     650     
     651    */
     652    return output;
    569653}
    570654
     
    600684    if ( output == NULL ) {
    601685            output = psMetadataAlloc();
     686            psError( __func__, "Failed to allocate metadata" );
    602687            return NULL;
    603688        }
     
    610695                    status = 0;
    611696                    fits_close_file( fd, &status );
    612                     return NULL;
     697                    return output;
    613698                }
    614699        } else if ( extnum > 0 ) {
     
    621706                    fits_close_file( fd, &status );
    622707                    psFree( tempExtname );
    623                     return NULL;
     708                    return output;
    624709                }
    625710            psFree( tempExtname );
     
    632717            status = 0;
    633718            fits_close_file( fd, &status );
    634             return NULL;
     719            return output;
    635720        }
    636721       
     
    642727                    status = 0;
    643728                    fits_close_file( fd, &status );
    644                     return NULL;
     729                    return output;
    645730                }
    646731               
     
    650735                    status = 0;
    651736                    fits_close_file( fd, &status );
    652                     return NULL;
     737                    return output;
    653738                }
    654739               
     
    670755                    default:
    671756                    psError( __func__, "Invalid psMetadataType: %c", keyType );
    672                     return NULL;
     757                    return output;
    673758                }
    674759               
  • trunk/psLib/src/collections/psMetadata.c

    r1351 r1352  
    1111*  @author Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2004-07-30 19:36:52 $
     13*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2004-07-31 00:17:01 $
    1515*
    1616*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4343// Maximum metadata error length
    4444#define MAX_ERR_MESSAGE_LENGTH 1024
     45
     46// Maximum line size
     47#define MAX_LINE_SIZE 80
    4548
    4649/******************************************************************************/
     
    565568psMetadata *psMetadataReadHeader( psMetadata *output, const char *extname, int extnum, const char *filename )
    566569{
    567     return NULL;
    568    
     570    char line[ MAX_VAL_SIZE ];
     571    char keyName[ MAX_VAL_SIZE ];
     572    char keyValue[ MAX_VAL_SIZE ];
     573    char keyComment[ MAX_VAL_SIZE ];
     574    int status = 0;
     575    extnumCtr = 1;
     576    FILE *fd = NULL;
     577   
     578    if ( filename == NULL ) {
     579            psError( __func__, "Null file name not allowed" );
     580            return NULL;
     581        }
     582       
     583    if ( extname == NULL && extnum == 0 ) {
     584            psError( __func__, "Null extname AND extnum = 0 not allowed" );
     585            return NULL;
     586        } else if ( extname && extnum ) {
     587            psError( __func__, "Both extname AND extnum arguments should not have valid values." );
     588            return NULL;
     589        }
     590       
     591    fd = fopen( filename, "r" );
     592    if ( fd == NULL ) {
     593            psError( __func__, "Null FITS file descriptor not allowed" );
     594            return NULL;
     595        }
     596       
     597    // Allocate metadata if user didn't
     598    if ( output == NULL ) {
     599            output = psMetadataAlloc();
     600            psError( __func__, "Failed to allocate metadata" );
     601            return NULL;
     602        }
     603       
     604    // Move to user designated HDU number or HDU name in text file. HDU numbers starts at one.
     605    /* TODO    if(extname == NULL) {
     606                return output;
     607            }
     608        } else if(extnum > 0) {
     609                return output;
     610            }
     611        }
     612     
     613     
     614         line = fgets(line, MAX_LINE_SIZE+1, fp);
     615         while(line != NULL) {
     616     
     617             if(!strncmp("END", line, 3)){
     618                 extnumCtr++;
     619             }
     620     
     621             if(extnumCtr == extnum) {
     622     
     623                 // Put text into metadata
     624                 if(!strncmp("COMMENT", line, 7)){
     625                     // COMMENT keywords have no "=" sign
     626                     //TODO
     627                 } else if (strchr(line, '\'') != NULL){
     628     
     629                     // Output and logging keywords have tic (') characters
     630                     keyName = strtok(line, "=");
     631                     keyValue = strtok(NULL, "'");
     632                     keyValue = strtok(NULL, "'");
     633                     keyComment = strtok(NULL, "XXX");
     634     
     635     
     636                 } else
     637     
     638                     // Everything else is considered to be the standard name and value
     639                     keyName = strtok(line, "=");
     640                     keyValue = strtok(NULL, "/");
     641                     keyComment = strtok(NULL, "XXX");
     642                 }
     643     
     644     
     645             }
     646     
     647             // Read next line
     648             line = fgets(line, MAX_LINE_SIZE+1, fp);
     649         }
     650     
     651    */
     652    return output;
    569653}
    570654
     
    600684    if ( output == NULL ) {
    601685            output = psMetadataAlloc();
     686            psError( __func__, "Failed to allocate metadata" );
    602687            return NULL;
    603688        }
     
    610695                    status = 0;
    611696                    fits_close_file( fd, &status );
    612                     return NULL;
     697                    return output;
    613698                }
    614699        } else if ( extnum > 0 ) {
     
    621706                    fits_close_file( fd, &status );
    622707                    psFree( tempExtname );
    623                     return NULL;
     708                    return output;
    624709                }
    625710            psFree( tempExtname );
     
    632717            status = 0;
    633718            fits_close_file( fd, &status );
    634             return NULL;
     719            return output;
    635720        }
    636721       
     
    642727                    status = 0;
    643728                    fits_close_file( fd, &status );
    644                     return NULL;
     729                    return output;
    645730                }
    646731               
     
    650735                    status = 0;
    651736                    fits_close_file( fd, &status );
    652                     return NULL;
     737                    return output;
    653738                }
    654739               
     
    670755                    default:
    671756                    psError( __func__, "Invalid psMetadataType: %c", keyType );
    672                     return NULL;
     757                    return output;
    673758                }
    674759               
  • trunk/psLib/src/types/psMetadata.c

    r1351 r1352  
    1111*  @author Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2004-07-30 19:36:52 $
     13*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2004-07-31 00:17:01 $
    1515*
    1616*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4343// Maximum metadata error length
    4444#define MAX_ERR_MESSAGE_LENGTH 1024
     45
     46// Maximum line size
     47#define MAX_LINE_SIZE 80
    4548
    4649/******************************************************************************/
     
    565568psMetadata *psMetadataReadHeader( psMetadata *output, const char *extname, int extnum, const char *filename )
    566569{
    567     return NULL;
    568    
     570    char line[ MAX_VAL_SIZE ];
     571    char keyName[ MAX_VAL_SIZE ];
     572    char keyValue[ MAX_VAL_SIZE ];
     573    char keyComment[ MAX_VAL_SIZE ];
     574    int status = 0;
     575    extnumCtr = 1;
     576    FILE *fd = NULL;
     577   
     578    if ( filename == NULL ) {
     579            psError( __func__, "Null file name not allowed" );
     580            return NULL;
     581        }
     582       
     583    if ( extname == NULL && extnum == 0 ) {
     584            psError( __func__, "Null extname AND extnum = 0 not allowed" );
     585            return NULL;
     586        } else if ( extname && extnum ) {
     587            psError( __func__, "Both extname AND extnum arguments should not have valid values." );
     588            return NULL;
     589        }
     590       
     591    fd = fopen( filename, "r" );
     592    if ( fd == NULL ) {
     593            psError( __func__, "Null FITS file descriptor not allowed" );
     594            return NULL;
     595        }
     596       
     597    // Allocate metadata if user didn't
     598    if ( output == NULL ) {
     599            output = psMetadataAlloc();
     600            psError( __func__, "Failed to allocate metadata" );
     601            return NULL;
     602        }
     603       
     604    // Move to user designated HDU number or HDU name in text file. HDU numbers starts at one.
     605    /* TODO    if(extname == NULL) {
     606                return output;
     607            }
     608        } else if(extnum > 0) {
     609                return output;
     610            }
     611        }
     612     
     613     
     614         line = fgets(line, MAX_LINE_SIZE+1, fp);
     615         while(line != NULL) {
     616     
     617             if(!strncmp("END", line, 3)){
     618                 extnumCtr++;
     619             }
     620     
     621             if(extnumCtr == extnum) {
     622     
     623                 // Put text into metadata
     624                 if(!strncmp("COMMENT", line, 7)){
     625                     // COMMENT keywords have no "=" sign
     626                     //TODO
     627                 } else if (strchr(line, '\'') != NULL){
     628     
     629                     // Output and logging keywords have tic (') characters
     630                     keyName = strtok(line, "=");
     631                     keyValue = strtok(NULL, "'");
     632                     keyValue = strtok(NULL, "'");
     633                     keyComment = strtok(NULL, "XXX");
     634     
     635     
     636                 } else
     637     
     638                     // Everything else is considered to be the standard name and value
     639                     keyName = strtok(line, "=");
     640                     keyValue = strtok(NULL, "/");
     641                     keyComment = strtok(NULL, "XXX");
     642                 }
     643     
     644     
     645             }
     646     
     647             // Read next line
     648             line = fgets(line, MAX_LINE_SIZE+1, fp);
     649         }
     650     
     651    */
     652    return output;
    569653}
    570654
     
    600684    if ( output == NULL ) {
    601685            output = psMetadataAlloc();
     686            psError( __func__, "Failed to allocate metadata" );
    602687            return NULL;
    603688        }
     
    610695                    status = 0;
    611696                    fits_close_file( fd, &status );
    612                     return NULL;
     697                    return output;
    613698                }
    614699        } else if ( extnum > 0 ) {
     
    621706                    fits_close_file( fd, &status );
    622707                    psFree( tempExtname );
    623                     return NULL;
     708                    return output;
    624709                }
    625710            psFree( tempExtname );
     
    632717            status = 0;
    633718            fits_close_file( fd, &status );
    634             return NULL;
     719            return output;
    635720        }
    636721       
     
    642727                    status = 0;
    643728                    fits_close_file( fd, &status );
    644                     return NULL;
     729                    return output;
    645730                }
    646731               
     
    650735                    status = 0;
    651736                    fits_close_file( fd, &status );
    652                     return NULL;
     737                    return output;
    653738                }
    654739               
     
    670755                    default:
    671756                    psError( __func__, "Invalid psMetadataType: %c", keyType );
    672                     return NULL;
     757                    return output;
    673758                }
    674759               
Note: See TracChangeset for help on using the changeset viewer.