Index: /trunk/psLib/src/astronomy/psMetadata.c
===================================================================
--- /trunk/psLib/src/astronomy/psMetadata.c	(revision 1351)
+++ /trunk/psLib/src/astronomy/psMetadata.c	(revision 1352)
@@ -11,6 +11,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-07-30 19:36:52 $
+*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-07-31 00:17:01 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -43,4 +43,7 @@
 // Maximum metadata error length
 #define MAX_ERR_MESSAGE_LENGTH 1024
+
+// Maximum line size
+#define MAX_LINE_SIZE 80
 
 /******************************************************************************/
@@ -565,6 +568,87 @@
 psMetadata *psMetadataReadHeader( psMetadata *output, const char *extname, int extnum, const char *filename )
 {
-    return NULL;
-    
+    char line[ MAX_VAL_SIZE ];
+    char keyName[ MAX_VAL_SIZE ];
+    char keyValue[ MAX_VAL_SIZE ];
+    char keyComment[ MAX_VAL_SIZE ];
+    int status = 0;
+    extnumCtr = 1;
+    FILE *fd = NULL;
+    
+    if ( filename == NULL ) {
+            psError( __func__, "Null file name not allowed" );
+            return NULL;
+        }
+        
+    if ( extname == NULL && extnum == 0 ) {
+            psError( __func__, "Null extname AND extnum = 0 not allowed" );
+            return NULL;
+        } else if ( extname && extnum ) {
+            psError( __func__, "Both extname AND extnum arguments should not have valid values." );
+            return NULL;
+        }
+        
+    fd = fopen( filename, "r" );
+    if ( fd == NULL ) {
+            psError( __func__, "Null FITS file descriptor not allowed" );
+            return NULL;
+        }
+        
+    // Allocate metadata if user didn't
+    if ( output == NULL ) {
+            output = psMetadataAlloc();
+            psError( __func__, "Failed to allocate metadata" );
+            return NULL;
+        }
+        
+    // Move to user designated HDU number or HDU name in text file. HDU numbers starts at one.
+    /* TODO    if(extname == NULL) {
+                return output;
+            }
+        } else if(extnum > 0) {
+                return output;
+            }
+        }
+     
+     
+         line = fgets(line, MAX_LINE_SIZE+1, fp);
+         while(line != NULL) {
+     
+             if(!strncmp("END", line, 3)){
+                 extnumCtr++;
+             }
+     
+             if(extnumCtr == extnum) {
+     
+                 // Put text into metadata
+                 if(!strncmp("COMMENT", line, 7)){
+                     // COMMENT keywords have no "=" sign
+                     //TODO
+                 } else if (strchr(line, '\'') != NULL){
+     
+                     // Output and logging keywords have tic (') characters
+                     keyName = strtok(line, "=");
+                     keyValue = strtok(NULL, "'");
+                     keyValue = strtok(NULL, "'");
+                     keyComment = strtok(NULL, "XXX");
+     
+     
+                 } else
+     
+                     // Everything else is considered to be the standard name and value
+                     keyName = strtok(line, "=");
+                     keyValue = strtok(NULL, "/");
+                     keyComment = strtok(NULL, "XXX");
+                 }
+     
+     
+             }
+     
+             // Read next line
+             line = fgets(line, MAX_LINE_SIZE+1, fp);
+         }
+     
+    */ 
+    return output;
 }
 
@@ -600,4 +684,5 @@
     if ( output == NULL ) {
             output = psMetadataAlloc();
+            psError( __func__, "Failed to allocate metadata" );
             return NULL;
         }
@@ -610,5 +695,5 @@
                     status = 0;
                     fits_close_file( fd, &status );
-                    return NULL;
+                    return output;
                 }
         } else if ( extnum > 0 ) {
@@ -621,5 +706,5 @@
                     fits_close_file( fd, &status );
                     psFree( tempExtname );
-                    return NULL;
+                    return output;
                 }
             psFree( tempExtname );
@@ -632,5 +717,5 @@
             status = 0;
             fits_close_file( fd, &status );
-            return NULL;
+            return output;
         }
         
@@ -642,5 +727,5 @@
                     status = 0;
                     fits_close_file( fd, &status );
-                    return NULL;
+                    return output;
                 }
                 
@@ -650,5 +735,5 @@
                     status = 0;
                     fits_close_file( fd, &status );
-                    return NULL;
+                    return output;
                 }
                 
@@ -670,5 +755,5 @@
                     default:
                     psError( __func__, "Invalid psMetadataType: %c", keyType );
-                    return NULL;
+                    return output;
                 }
                 
Index: /trunk/psLib/src/collections/psMetadata.c
===================================================================
--- /trunk/psLib/src/collections/psMetadata.c	(revision 1351)
+++ /trunk/psLib/src/collections/psMetadata.c	(revision 1352)
@@ -11,6 +11,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-07-30 19:36:52 $
+*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-07-31 00:17:01 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -43,4 +43,7 @@
 // Maximum metadata error length
 #define MAX_ERR_MESSAGE_LENGTH 1024
+
+// Maximum line size
+#define MAX_LINE_SIZE 80
 
 /******************************************************************************/
@@ -565,6 +568,87 @@
 psMetadata *psMetadataReadHeader( psMetadata *output, const char *extname, int extnum, const char *filename )
 {
-    return NULL;
-    
+    char line[ MAX_VAL_SIZE ];
+    char keyName[ MAX_VAL_SIZE ];
+    char keyValue[ MAX_VAL_SIZE ];
+    char keyComment[ MAX_VAL_SIZE ];
+    int status = 0;
+    extnumCtr = 1;
+    FILE *fd = NULL;
+    
+    if ( filename == NULL ) {
+            psError( __func__, "Null file name not allowed" );
+            return NULL;
+        }
+        
+    if ( extname == NULL && extnum == 0 ) {
+            psError( __func__, "Null extname AND extnum = 0 not allowed" );
+            return NULL;
+        } else if ( extname && extnum ) {
+            psError( __func__, "Both extname AND extnum arguments should not have valid values." );
+            return NULL;
+        }
+        
+    fd = fopen( filename, "r" );
+    if ( fd == NULL ) {
+            psError( __func__, "Null FITS file descriptor not allowed" );
+            return NULL;
+        }
+        
+    // Allocate metadata if user didn't
+    if ( output == NULL ) {
+            output = psMetadataAlloc();
+            psError( __func__, "Failed to allocate metadata" );
+            return NULL;
+        }
+        
+    // Move to user designated HDU number or HDU name in text file. HDU numbers starts at one.
+    /* TODO    if(extname == NULL) {
+                return output;
+            }
+        } else if(extnum > 0) {
+                return output;
+            }
+        }
+     
+     
+         line = fgets(line, MAX_LINE_SIZE+1, fp);
+         while(line != NULL) {
+     
+             if(!strncmp("END", line, 3)){
+                 extnumCtr++;
+             }
+     
+             if(extnumCtr == extnum) {
+     
+                 // Put text into metadata
+                 if(!strncmp("COMMENT", line, 7)){
+                     // COMMENT keywords have no "=" sign
+                     //TODO
+                 } else if (strchr(line, '\'') != NULL){
+     
+                     // Output and logging keywords have tic (') characters
+                     keyName = strtok(line, "=");
+                     keyValue = strtok(NULL, "'");
+                     keyValue = strtok(NULL, "'");
+                     keyComment = strtok(NULL, "XXX");
+     
+     
+                 } else
+     
+                     // Everything else is considered to be the standard name and value
+                     keyName = strtok(line, "=");
+                     keyValue = strtok(NULL, "/");
+                     keyComment = strtok(NULL, "XXX");
+                 }
+     
+     
+             }
+     
+             // Read next line
+             line = fgets(line, MAX_LINE_SIZE+1, fp);
+         }
+     
+    */ 
+    return output;
 }
 
@@ -600,4 +684,5 @@
     if ( output == NULL ) {
             output = psMetadataAlloc();
+            psError( __func__, "Failed to allocate metadata" );
             return NULL;
         }
@@ -610,5 +695,5 @@
                     status = 0;
                     fits_close_file( fd, &status );
-                    return NULL;
+                    return output;
                 }
         } else if ( extnum > 0 ) {
@@ -621,5 +706,5 @@
                     fits_close_file( fd, &status );
                     psFree( tempExtname );
-                    return NULL;
+                    return output;
                 }
             psFree( tempExtname );
@@ -632,5 +717,5 @@
             status = 0;
             fits_close_file( fd, &status );
-            return NULL;
+            return output;
         }
         
@@ -642,5 +727,5 @@
                     status = 0;
                     fits_close_file( fd, &status );
-                    return NULL;
+                    return output;
                 }
                 
@@ -650,5 +735,5 @@
                     status = 0;
                     fits_close_file( fd, &status );
-                    return NULL;
+                    return output;
                 }
                 
@@ -670,5 +755,5 @@
                     default:
                     psError( __func__, "Invalid psMetadataType: %c", keyType );
-                    return NULL;
+                    return output;
                 }
                 
Index: /trunk/psLib/src/types/psMetadata.c
===================================================================
--- /trunk/psLib/src/types/psMetadata.c	(revision 1351)
+++ /trunk/psLib/src/types/psMetadata.c	(revision 1352)
@@ -11,6 +11,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-07-30 19:36:52 $
+*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-07-31 00:17:01 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -43,4 +43,7 @@
 // Maximum metadata error length
 #define MAX_ERR_MESSAGE_LENGTH 1024
+
+// Maximum line size
+#define MAX_LINE_SIZE 80
 
 /******************************************************************************/
@@ -565,6 +568,87 @@
 psMetadata *psMetadataReadHeader( psMetadata *output, const char *extname, int extnum, const char *filename )
 {
-    return NULL;
-    
+    char line[ MAX_VAL_SIZE ];
+    char keyName[ MAX_VAL_SIZE ];
+    char keyValue[ MAX_VAL_SIZE ];
+    char keyComment[ MAX_VAL_SIZE ];
+    int status = 0;
+    extnumCtr = 1;
+    FILE *fd = NULL;
+    
+    if ( filename == NULL ) {
+            psError( __func__, "Null file name not allowed" );
+            return NULL;
+        }
+        
+    if ( extname == NULL && extnum == 0 ) {
+            psError( __func__, "Null extname AND extnum = 0 not allowed" );
+            return NULL;
+        } else if ( extname && extnum ) {
+            psError( __func__, "Both extname AND extnum arguments should not have valid values." );
+            return NULL;
+        }
+        
+    fd = fopen( filename, "r" );
+    if ( fd == NULL ) {
+            psError( __func__, "Null FITS file descriptor not allowed" );
+            return NULL;
+        }
+        
+    // Allocate metadata if user didn't
+    if ( output == NULL ) {
+            output = psMetadataAlloc();
+            psError( __func__, "Failed to allocate metadata" );
+            return NULL;
+        }
+        
+    // Move to user designated HDU number or HDU name in text file. HDU numbers starts at one.
+    /* TODO    if(extname == NULL) {
+                return output;
+            }
+        } else if(extnum > 0) {
+                return output;
+            }
+        }
+     
+     
+         line = fgets(line, MAX_LINE_SIZE+1, fp);
+         while(line != NULL) {
+     
+             if(!strncmp("END", line, 3)){
+                 extnumCtr++;
+             }
+     
+             if(extnumCtr == extnum) {
+     
+                 // Put text into metadata
+                 if(!strncmp("COMMENT", line, 7)){
+                     // COMMENT keywords have no "=" sign
+                     //TODO
+                 } else if (strchr(line, '\'') != NULL){
+     
+                     // Output and logging keywords have tic (') characters
+                     keyName = strtok(line, "=");
+                     keyValue = strtok(NULL, "'");
+                     keyValue = strtok(NULL, "'");
+                     keyComment = strtok(NULL, "XXX");
+     
+     
+                 } else
+     
+                     // Everything else is considered to be the standard name and value
+                     keyName = strtok(line, "=");
+                     keyValue = strtok(NULL, "/");
+                     keyComment = strtok(NULL, "XXX");
+                 }
+     
+     
+             }
+     
+             // Read next line
+             line = fgets(line, MAX_LINE_SIZE+1, fp);
+         }
+     
+    */ 
+    return output;
 }
 
@@ -600,4 +684,5 @@
     if ( output == NULL ) {
             output = psMetadataAlloc();
+            psError( __func__, "Failed to allocate metadata" );
             return NULL;
         }
@@ -610,5 +695,5 @@
                     status = 0;
                     fits_close_file( fd, &status );
-                    return NULL;
+                    return output;
                 }
         } else if ( extnum > 0 ) {
@@ -621,5 +706,5 @@
                     fits_close_file( fd, &status );
                     psFree( tempExtname );
-                    return NULL;
+                    return output;
                 }
             psFree( tempExtname );
@@ -632,5 +717,5 @@
             status = 0;
             fits_close_file( fd, &status );
-            return NULL;
+            return output;
         }
         
@@ -642,5 +727,5 @@
                     status = 0;
                     fits_close_file( fd, &status );
-                    return NULL;
+                    return output;
                 }
                 
@@ -650,5 +735,5 @@
                     status = 0;
                     fits_close_file( fd, &status );
-                    return NULL;
+                    return output;
                 }
                 
@@ -670,5 +755,5 @@
                     default:
                     psError( __func__, "Invalid psMetadataType: %c", keyType );
-                    return NULL;
+                    return output;
                 }
                 
