Index: trunk/Ohana/src/libdvo/src/LoadPhotcodes.c
===================================================================
--- trunk/Ohana/src/libdvo/src/LoadPhotcodes.c	(revision 28244)
+++ trunk/Ohana/src/libdvo/src/LoadPhotcodes.c	(revision 28246)
@@ -15,5 +15,5 @@
   if (LoadPhotcodesText (master_file)) { 
     if (!check_file_access (catdir_file, TRUE, TRUE, TRUE)) return TRUE;
-    SavePhotcodesFITS (catdir_file);
+    if (!SavePhotcodesFITS (catdir_file)) return FALSE;
     return TRUE;
   }
Index: trunk/Ohana/src/libdvo/src/SavePhotcodesFITS.c
===================================================================
--- trunk/Ohana/src/libdvo/src/SavePhotcodesFITS.c	(revision 28244)
+++ trunk/Ohana/src/libdvo/src/SavePhotcodesFITS.c	(revision 28246)
@@ -32,8 +32,8 @@
 
   /* convert FITS format data to internal format (byteswaps & EXTNAME) */
-  gfits_db_create (&db);
-  gfits_table_set_PhotCode_PS1_V2 (&db.ftable, photcode_output, table[0].Ncode);
-  gfits_db_save (&db);
-  gfits_db_close (&db);
+  if (!gfits_db_create (&db)) return (FALSE);
+  if (!gfits_table_set_PhotCode_PS1_V2 (&db.ftable, photcode_output, table[0].Ncode)) return (FALSE);
+  if (!gfits_db_save (&db)) return (FALSE);
+  if (!gfits_db_close (&db)) return (FALSE);
 
   free (photcode_output);
Index: trunk/Ohana/src/libdvo/src/dvo_image.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_image.c	(revision 28244)
+++ trunk/Ohana/src/libdvo/src/dvo_image.c	(revision 28246)
@@ -120,14 +120,17 @@
   /* adjust header */
   Nimages = 0;
-  gfits_scan (&db[0].header, "NIMAGES", OFF_T_FMT, 1,  &Nimages);
+  if (!gfits_scan (&db[0].header, "NIMAGES", OFF_T_FMT, 1,  &Nimages)) return (FALSE);
   Nimages += Nnew;
-  gfits_modify (&db[0].header, "NIMAGES", OFF_T_FMT, 1,  Nimages);
-
-  gfits_table_to_vtable (&db[0].ftable, &db[0].vtable, 0, 0);
-  gfits_vadd_rows (&db[0].vtable, (char *) new, Nnew, sizeof(Image));
+
+  if (!gfits_modify (&db[0].header, "NIMAGES", OFF_T_FMT, 1,  Nimages)) return (FALSE);
+
+  if (!gfits_table_to_vtable (&db[0].ftable, &db[0].vtable, 0, 0)) return (FALSE);
+
+  if (!gfits_vadd_rows (&db[0].vtable, (char *) new, Nnew, sizeof(Image))) return (FALSE);
 
   /* check that primary header and table header agree */
   if (Nimages != db[0].theader.Naxis[1]) {
     fprintf (stderr, "header / table length mismatch!\n");
+    return (FALSE);
   }
   return (TRUE);
@@ -157,5 +160,5 @@
       exit (2);
   }
-  return (TRUE);
+  return (status);
 }
 
Index: trunk/Ohana/src/libdvo/src/fits_db.c
===================================================================
--- trunk/Ohana/src/libdvo/src/fits_db.c	(revision 28244)
+++ trunk/Ohana/src/libdvo/src/fits_db.c	(revision 28246)
@@ -20,9 +20,9 @@
 /* create an empty db */
 int gfits_db_create (FITS_DB *db) {
-  gfits_init_header (&db[0].header);    
+  if (!gfits_init_header (&db[0].header)) return (FALSE);
   db[0].header.extend = TRUE;
-  gfits_create_header (&db[0].header);
-  gfits_create_matrix (&db[0].header, &db[0].matrix);
-  gfits_print (&db[0].header, "NEXTEND", "%d", 1, 1);
+  if (!gfits_create_header (&db[0].header))  return (FALSE);
+  if (!gfits_create_matrix (&db[0].header, &db[0].matrix)) return (FALSE);
+  if (!gfits_print (&db[0].header, "NEXTEND", "%d", 1, 1)) return (FALSE);
   db[0].ftable.header = &db[0].theader;
   return (TRUE);
Index: trunk/Ohana/src/libfits/header/F_modify.c
===================================================================
--- trunk/Ohana/src/libfits/header/F_modify.c	(revision 28244)
+++ trunk/Ohana/src/libfits/header/F_modify.c	(revision 28246)
@@ -51,21 +51,20 @@
 
   /* write the numeric modes */
-  if (!strcmp (mode, "%d"))   snprintf (string, 81, "%-8s= %20d / %-s ",    field, va_arg (argp, int),       	      comment);
-  if (!strcmp (mode, "%ld"))  snprintf (string, 81, "%-8s= %20ld / %-s ",   field, va_arg (argp, long),      	      comment);
-  if (!strcmp (mode, OFF_T_FMT)) snprintf (string, 81, "%-8s= %20lld / %-s ",  field, va_arg (argp, long long), 	      comment);
-  if (!strcmp (mode, "%Ld"))  snprintf (string, 81, "%-8s= %20lld / %-s ",  field, va_arg (argp, long long), 	      comment);
-  if (!strcmp (mode, "%u"))   snprintf (string, 81, "%-8s= %20u / %-s ",    field, va_arg (argp, unsigned),  	      comment);
-  if (!strcmp (mode, "%lu"))  snprintf (string, 81, "%-8s= %20lu / %-s ",   field, va_arg (argp, unsigned long),      comment);
-  if (!strcmp (mode, "%llu")) snprintf (string, 81, "%-8s= %20llu / %-s ",  field, va_arg (argp, unsigned long long), comment);
-  if (!strcmp (mode, "%Lu"))  snprintf (string, 81, "%-8s= %20llu / %-s ",  field, va_arg (argp, unsigned long long), comment);
-  if (!strcmp (mode, "%hd"))  snprintf (string, 81, "%-8s= %20d / %-s ",    field, va_arg (argp, int),      	      comment); 
-  if (!strcmp (mode, "%f"))   snprintf (string, 81, "%-8s= %20.10f / %-s ", field, va_arg (argp, double),   	      comment); 
-  if (!strcmp (mode, "%lf"))  snprintf (string, 81, "%-8s= %20.10f / %-s ", field, va_arg (argp, double),   	      comment); 
-  if (!strcmp (mode, "%e"))   snprintf (string, 81, "%-8s= %20.10E / %-s ", field, va_arg (argp, double),   	      comment); 
-  if (!strcmp (mode, "%le"))  snprintf (string, 81, "%-8s= %20.10E / %-s ", field, va_arg (argp, double),   	      comment); 
-  if (!strcmp (mode, "%g"))   snprintf (string, 81, "%-8s= %20.10G / %-s ", field, va_arg (argp, double),   	      comment); 
-  if (!strcmp (mode, "%lg"))  snprintf (string, 81, "%-8s= %20.10G / %-s ", field, va_arg (argp, double),   	      comment); 
-
-  if (!strcmp (mode, "%jd"))  snprintf (string, 81, "%-8s= %20jd / %-s ",   field, va_arg (argp, intmax_t), 	      comment);
+  if (!strcmp (mode, "%d"))   { snprintf (string, 81, "%-8s= %20d / %-s ",    field, va_arg (argp, int),       	      	comment); goto found_it; }
+  if (!strcmp (mode, "%ld"))  { snprintf (string, 81, "%-8s= %20ld / %-s ",   field, va_arg (argp, long),      	      	comment); goto found_it; }
+  if (!strcmp (mode, "%lld")) { snprintf (string, 81, "%-8s= %20lld / %-s ",  field, va_arg (argp, long long), 	      	comment); goto found_it; }
+  if (!strcmp (mode, "%Ld"))  { snprintf (string, 81, "%-8s= %20lld / %-s ",  field, va_arg (argp, long long), 	      	comment); goto found_it; }
+  if (!strcmp (mode, "%u"))   { snprintf (string, 81, "%-8s= %20u / %-s ",    field, va_arg (argp, unsigned),  	      	comment); goto found_it; }
+  if (!strcmp (mode, "%lu"))  { snprintf (string, 81, "%-8s= %20lu / %-s ",   field, va_arg (argp, unsigned long),      comment); goto found_it; }
+  if (!strcmp (mode, "%llu")) { snprintf (string, 81, "%-8s= %20llu / %-s ",  field, va_arg (argp, unsigned long long), comment); goto found_it; }
+  if (!strcmp (mode, "%Lu"))  { snprintf (string, 81, "%-8s= %20llu / %-s ",  field, va_arg (argp, unsigned long long), comment); goto found_it; }
+  if (!strcmp (mode, "%hd"))  { snprintf (string, 81, "%-8s= %20d / %-s ",    field, va_arg (argp, int),      	        comment); goto found_it; } 
+  if (!strcmp (mode, "%f"))   { snprintf (string, 81, "%-8s= %20.10f / %-s ", field, va_arg (argp, double),   	        comment); goto found_it; } 
+  if (!strcmp (mode, "%lf"))  { snprintf (string, 81, "%-8s= %20.10f / %-s ", field, va_arg (argp, double),   	        comment); goto found_it; } 
+  if (!strcmp (mode, "%e"))   { snprintf (string, 81, "%-8s= %20.10E / %-s ", field, va_arg (argp, double),   	        comment); goto found_it; } 
+  if (!strcmp (mode, "%le"))  { snprintf (string, 81, "%-8s= %20.10E / %-s ", field, va_arg (argp, double),   	        comment); goto found_it; } 
+  if (!strcmp (mode, "%g"))   { snprintf (string, 81, "%-8s= %20.10G / %-s ", field, va_arg (argp, double),   	        comment); goto found_it; } 
+  if (!strcmp (mode, "%lg"))  { snprintf (string, 81, "%-8s= %20.10G / %-s ", field, va_arg (argp, double),   	        comment); goto found_it; } 
+  if (!strcmp (mode, "%jd"))  { snprintf (string, 81, "%-8s= %20jd / %-s ",   field, va_arg (argp, intmax_t), 	        comment); goto found_it; }
 
   /* string value.  Quotes must be at least 18 chars apart */
@@ -73,6 +72,11 @@
     strncpy (data, va_arg (argp, char *), 68);
     snprintf (string, 81, "%-8s= '%-18s' / %-s ", field, data, comment);
-  }
-
+    goto found_it;
+  }
+
+  /* failed to find mode */
+  return (FALSE);
+
+found_it:
   strncpy (p, string, 80);
   va_end (argp);
Index: trunk/Ohana/src/libfits/header/F_print.c
===================================================================
--- trunk/Ohana/src/libfits/header/F_print.c	(revision 28244)
+++ trunk/Ohana/src/libfits/header/F_print.c	(revision 28246)
@@ -46,21 +46,20 @@
 
   /* write the numeric modes */
-  if (!strcmp (mode, "%d"))  { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); }
-  if (!strcmp (mode, "%ld")) { snprintf (string, 81, "%-8s= %20ld / %46s ",   field, va_arg (argp, long),               blank); }
-  if (!strcmp (mode, OFF_T_FMT)){ snprintf (string, 81, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); }
-  if (!strcmp (mode, "%Ld")) { snprintf (string, 81, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); }
-  if (!strcmp (mode, "%u"))  { snprintf (string, 81, "%-8s= %20u / %46s ",    field, va_arg (argp, unsigned),           blank); }
-  if (!strcmp (mode, "%lu")) { snprintf (string, 81, "%-8s= %20lu / %46s ",   field, va_arg (argp, unsigned long),      blank); }
-  if (!strcmp (mode, "%llu")){ snprintf (string, 81, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); }
-  if (!strcmp (mode, "%Lu")) { snprintf (string, 81, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); }
-  if (!strcmp (mode, "%hd")) { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); }
-  if (!strcmp (mode, "%f"))  { snprintf (string, 81, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); }
-  if (!strcmp (mode, "%lf")) { snprintf (string, 81, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); }
-  if (!strcmp (mode, "%e"))  { snprintf (string, 81, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); }
-  if (!strcmp (mode, "%le")) { snprintf (string, 81, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); }
-  if (!strcmp (mode, "%g"))  { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); }
-  if (!strcmp (mode, "%lg")) { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); }
-
-  if (!strcmp (mode, "%jd")) { snprintf (string, 81, "%-8s= %20jd / %46s ",   field, va_arg (argp, intmax_t),           blank); }
+  if (!strcmp (mode, "%d"))  { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); goto found_it; }
+  if (!strcmp (mode, "%ld")) { snprintf (string, 81, "%-8s= %20ld / %46s ",   field, va_arg (argp, long),               blank); goto found_it; }
+  if (!strcmp (mode, "%lld")){ snprintf (string, 81, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); goto found_it; }
+  if (!strcmp (mode, "%Ld")) { snprintf (string, 81, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); goto found_it; }
+  if (!strcmp (mode, "%u"))  { snprintf (string, 81, "%-8s= %20u / %46s ",    field, va_arg (argp, unsigned),           blank); goto found_it; }
+  if (!strcmp (mode, "%lu")) { snprintf (string, 81, "%-8s= %20lu / %46s ",   field, va_arg (argp, unsigned long),      blank); goto found_it; }
+  if (!strcmp (mode, "%llu")){ snprintf (string, 81, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); goto found_it; }
+  if (!strcmp (mode, "%Lu")) { snprintf (string, 81, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); goto found_it; }
+  if (!strcmp (mode, "%hd")) { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); goto found_it; }
+  if (!strcmp (mode, "%f"))  { snprintf (string, 81, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
+  if (!strcmp (mode, "%lf")) { snprintf (string, 81, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
+  if (!strcmp (mode, "%e"))  { snprintf (string, 81, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
+  if (!strcmp (mode, "%le")) { snprintf (string, 81, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
+  if (!strcmp (mode, "%g"))  { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
+  if (!strcmp (mode, "%lg")) { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
+  if (!strcmp (mode, "%jd")) { snprintf (string, 81, "%-8s= %20jd / %46s ",   field, va_arg (argp, intmax_t),           blank); goto found_it; }
 
   /* string value.  Quotes must be at least 18 chars apart.  Longer lines will this should be fixed to allow arbitrary string lengths, up to 69 chars */
@@ -69,8 +68,10 @@
     line[68] = 0;
     snprintf (string, 81, "%-8s= '%-18s' / %46s ", field, line, blank);
+    goto found_it;
   }
+  return (FALSE);
 
+found_it:
   strncpy (p, string, 80);
-  
   va_end (argp);
   return (TRUE);
Index: trunk/Ohana/src/libfits/header/F_scan.c
===================================================================
--- trunk/Ohana/src/libfits/header/F_scan.c	(revision 28244)
+++ trunk/Ohana/src/libfits/header/F_scan.c	(revision 28246)
@@ -61,4 +61,150 @@
   s = gfits_keyword_start (p); /* points at first char (not ') */
   q = gfits_keyword_end (p); /* points at following space or ' */
+
+  if (!strcmp (mode, "%f") || !strcmp (mode, "%lf")) {
+    fvalue = strtod (s, &q);
+    if ((*q == 'd') || (*q == 'D')) 
+      fvalue *= pow (10.0, atof (q + 1));
+
+    if (!strcmp (mode, "%f"))   { *va_arg (argp, float *)  = fvalue; return (TRUE); }
+    if (!strcmp (mode, "%lf"))  { *va_arg (argp, double *) = fvalue; return (TRUE); }
+  }
+
+  value = strtoll (s, &q, 0);
+  if ((*q == 'd') || (*q == 'D')) value *= pow (10.0, atof (q + 1));
+
+  if (!strcmp (mode, "%d"))   { *va_arg (argp, int *)       	     = value; return (TRUE); }
+  if (!strcmp (mode, "%ld"))  { *va_arg (argp, long *)      	     = value; return (TRUE); }
+  if (!strcmp (mode, "%lld")) { *va_arg (argp, long long *) 	     = value; return (TRUE); }
+  if (!strcmp (mode, "%Ld"))  { *va_arg (argp, long long *) 	     = value; return (TRUE); }
+  if (!strcmp (mode, "%u"))   { *va_arg (argp, unsigned *)  	     = value; return (TRUE); }
+  if (!strcmp (mode, "%lu"))  { *va_arg (argp, unsigned long *)      = value; return (TRUE); }
+  if (!strcmp (mode, "%llu")) { *va_arg (argp, unsigned long long *) = value; return (TRUE); }
+  if (!strcmp (mode, "%Lu"))  { *va_arg (argp, unsigned long long *) = value; return (TRUE); }
+  if (!strcmp (mode, "%hd"))  { *va_arg (argp, short *)     	     = value; return (TRUE); }
+
+  // XXX is this safe for 64bit off_t and 32bit off_t?
+  if (!strcmp (mode, "%jd"))  { *va_arg (argp, intmax_t *) 	     = value; return (TRUE); }
+
+  /* no valid mode found */
+  return (FALSE);
+}
+
+// alternate version for the special types (boolean, comments, COMMENT)
+int gfits_vscan_alt (Header *header, char *field, char *mode, int N, va_list argp) {
+
+  char *p, *q, *s, tmp[81];
+  int Nchar, status;
+
+  /* find the correct line with field */
+  p = gfits_header_field (header, field, N);
+  if (p == NULL) {
+    status = gfits_vscan_hierarch (header, field, mode, N, argp);
+    return (status);
+  }
+
+  /* non-data entry (COMMENT, HISTORY) */
+  if (!strcmp (mode, "%S")) {
+    strncpy (va_arg (argp, char *), p + 8, FT_HISTORY_LENGTH);
+    return (TRUE);
+  }
+
+  /* all others require '=' in column 8 */
+  if (p[8] != '=') return (FALSE);
+
+  /* comment from data line */
+  if (!strcmp (mode, "%C")) {
+    q = gfits_keyword_end (p) + 3;
+    q = MIN (p + 80, q);
+    bzero (tmp, 81);
+    Nchar = MIN (80, p + 80 - q);
+    memcpy (tmp, q, Nchar);
+    stripwhite (tmp);
+    strcpy (va_arg (argp, char *), tmp);
+    return (TRUE);
+  }
+
+  /* boolean data, requires int target */
+  if (!strcmp (mode, "%t")) {
+    s = gfits_keyword_start (p);
+    if (*s == 'T') {
+      *va_arg (argp, int *) = TRUE;
+      return (TRUE);
+    }
+    if (*s == 'F') {
+      *va_arg (argp, int *) = FALSE;   
+      return (TRUE);
+    }
+  }
+
+  /* no valid mode found */
+  return (FALSE);
+}
+
+# define HIERARCH_LENGTH 71
+int gfits_vscan_hierarch (Header *header, char *field, char *mode, int N, va_list argp) {
+
+  char *p, *q, *s, tmp[81];
+  int Nchar, Nfield;
+  long long value;
+  double fvalue;
+  
+  /* find the correct line with field */
+  p = gfits_header_hierarch_field (header, field, N);
+  if (p == NULL) return (FALSE);
+
+  /* non-data entries (COMMENT, HISTORY) are not allowed */
+  if (!strcmp (mode, "%S")) {
+    return (FALSE);
+  }
+
+  /* all others require '=' in column p + 1 + strlen(field) */
+  Nfield = strlen (field);
+  if (p[Nfield + 1] != '=') return (FALSE);
+
+  /* comment from data line */
+  if (!strcmp (mode, "%C")) {
+    q = gfits_hierarch_keyword_end (p, field);
+    if (!q) return (FALSE);
+    q += 3;
+    q = MIN (p + HIERARCH_LENGTH, q);
+    bzero (tmp, 81);
+    Nchar = MIN (HIERARCH_LENGTH, p + HIERARCH_LENGTH - q);
+    memcpy (tmp, q, Nchar);
+    stripwhite (tmp);
+    strcpy (va_arg (argp, char *), tmp);
+    return (TRUE);
+  }
+
+  /* extract data into char array (exclude containing ' chars) */
+  if (!strcmp (mode, "%s")) {
+    s = gfits_hierarch_keyword_start (p, field); /* points at first char (not ') */
+    q = gfits_hierarch_keyword_end (p, field); /* points at following space or ' */
+
+    Nchar = MIN (HIERARCH_LENGTH, MAX (0, (q - s)));
+    bzero (tmp, 81);
+    memcpy (tmp, s, Nchar);
+    stripwhite (tmp);
+    strcpy (va_arg (argp, char *), tmp);
+    return (TRUE);
+  }
+  
+  /* boolean data, requires int target */
+  if (!strcmp (mode, "%t")) {
+    s = gfits_hierarch_keyword_start (p, field);
+    if (*s == 'T') {
+      *va_arg (argp, int *) = TRUE;
+      return (TRUE);
+    }
+    if (*s == 'F') {
+      *va_arg (argp, int *) = FALSE;   
+      return (TRUE);
+    }
+  }
+
+  /* remaining options are numerical data */
+  /* need to interpret 1.0d5 as 1.0e5 */
+  s = gfits_hierarch_keyword_start (p, field); /* points at first char (not ') */
+  q = gfits_hierarch_keyword_end (p, field); /* points at following space or ' */
 
   if (!strcmp (mode, "%f") || !strcmp (mode, "%lf")) {
@@ -84,154 +230,8 @@
   if (!strcmp (mode, "%hd"))  { *va_arg (argp, short *)     	     = value; return (TRUE); }
 
-  // XXX is this safe for 64bit off_t and 32bit off_t?
-  if (!strcmp (mode, "%jd"))  { *va_arg (argp, intmax_t *) 	     = value; return (TRUE); }
-
   /* no valid mode found */
   return (FALSE);
 }
 
-// alternate version for the special types (boolean, comments, COMMENT)
-int gfits_vscan_alt (Header *header, char *field, char *mode, int N, va_list argp) {
-
-  char *p, *q, *s, tmp[81];
-  int Nchar, status;
-
-  /* find the correct line with field */
-  p = gfits_header_field (header, field, N);
-  if (p == NULL) {
-    status = gfits_vscan_hierarch (header, field, mode, N, argp);
-    return (status);
-  }
-
-  /* non-data entry (COMMENT, HISTORY) */
-  if (!strcmp (mode, "%S")) {
-    strncpy (va_arg (argp, char *), p + 8, FT_HISTORY_LENGTH);
-    return (TRUE);
-  }
-
-  /* all others require '=' in column 8 */
-  if (p[8] != '=') return (FALSE);
-
-  /* comment from data line */
-  if (!strcmp (mode, "%C")) {
-    q = gfits_keyword_end (p) + 3;
-    q = MIN (p + 80, q);
-    bzero (tmp, 81);
-    Nchar = MIN (80, p + 80 - q);
-    memcpy (tmp, q, Nchar);
-    stripwhite (tmp);
-    strcpy (va_arg (argp, char *), tmp);
-    return (TRUE);
-  }
-
-  /* boolean data, requires int target */
-  if (!strcmp (mode, "%t")) {
-    s = gfits_keyword_start (p);
-    if (*s == 'T') {
-      *va_arg (argp, int *) = TRUE;
-      return (TRUE);
-    }
-    if (*s == 'F') {
-      *va_arg (argp, int *) = FALSE;   
-      return (TRUE);
-    }
-  }
-
-  /* no valid mode found */
-  return (FALSE);
-}
-
-# define HIERARCH_LENGTH 71
-int gfits_vscan_hierarch (Header *header, char *field, char *mode, int N, va_list argp) {
-
-  char *p, *q, *s, tmp[81];
-  int Nchar, Nfield;
-  long long value;
-  double fvalue;
-  
-  /* find the correct line with field */
-  p = gfits_header_hierarch_field (header, field, N);
-  if (p == NULL) return (FALSE);
-
-  /* non-data entries (COMMENT, HISTORY) are not allowed */
-  if (!strcmp (mode, "%S")) {
-    return (FALSE);
-  }
-
-  /* all others require '=' in column p + 1 + strlen(field) */
-  Nfield = strlen (field);
-  if (p[Nfield + 1] != '=') return (FALSE);
-
-  /* comment from data line */
-  if (!strcmp (mode, "%C")) {
-    q = gfits_hierarch_keyword_end (p, field);
-    if (!q) return (FALSE);
-    q += 3;
-    q = MIN (p + HIERARCH_LENGTH, q);
-    bzero (tmp, 81);
-    Nchar = MIN (HIERARCH_LENGTH, p + HIERARCH_LENGTH - q);
-    memcpy (tmp, q, Nchar);
-    stripwhite (tmp);
-    strcpy (va_arg (argp, char *), tmp);
-    return (TRUE);
-  }
-
-  /* extract data into char array (exclude containing ' chars) */
-  if (!strcmp (mode, "%s")) {
-    s = gfits_hierarch_keyword_start (p, field); /* points at first char (not ') */
-    q = gfits_hierarch_keyword_end (p, field); /* points at following space or ' */
-
-    Nchar = MIN (HIERARCH_LENGTH, MAX (0, (q - s)));
-    bzero (tmp, 81);
-    memcpy (tmp, s, Nchar);
-    stripwhite (tmp);
-    strcpy (va_arg (argp, char *), tmp);
-    return (TRUE);
-  }
-  
-  /* boolean data, requires int target */
-  if (!strcmp (mode, "%t")) {
-    s = gfits_hierarch_keyword_start (p, field);
-    if (*s == 'T') {
-      *va_arg (argp, int *) = TRUE;
-      return (TRUE);
-    }
-    if (*s == 'F') {
-      *va_arg (argp, int *) = FALSE;   
-      return (TRUE);
-    }
-  }
-
-  /* remaining options are numerical data */
-  /* need to interpret 1.0d5 as 1.0e5 */
-  s = gfits_hierarch_keyword_start (p, field); /* points at first char (not ') */
-  q = gfits_hierarch_keyword_end (p, field); /* points at following space or ' */
-
-  if (!strcmp (mode, "%f") || !strcmp (mode, "%lf")) {
-    fvalue = strtod (s, &q);
-    if ((*q == 'd') || (*q == 'D')) 
-      fvalue *= pow (10.0, atof (q + 1));
-
-    if (!strcmp (mode, "%f"))   { *va_arg (argp, float *)  = fvalue; return (TRUE); }
-    if (!strcmp (mode, "%lf"))  { *va_arg (argp, double *) = fvalue; return (TRUE); }
-  }
-
-  value = strtoll (s, &q, 0);
-  if ((*q == 'd') || (*q == 'D')) value *= pow (10.0, atof (q + 1));
-
-  if (!strcmp (mode, "%d"))   { *va_arg (argp, int *)       	     = value; return (TRUE); }
-  if (!strcmp (mode, "%ld"))  { *va_arg (argp, long *)      	     = value; return (TRUE); }
-  if (!strcmp (mode, OFF_T_FMT)) { *va_arg (argp, long long *) 	     = value; return (TRUE); }
-  if (!strcmp (mode, "%Ld"))  { *va_arg (argp, long long *) 	     = value; return (TRUE); }
-  if (!strcmp (mode, "%u"))   { *va_arg (argp, unsigned *)  	     = value; return (TRUE); }
-  if (!strcmp (mode, "%lu"))  { *va_arg (argp, unsigned long *)      = value; return (TRUE); }
-  if (!strcmp (mode, "%llu")) { *va_arg (argp, unsigned long long *) = value; return (TRUE); }
-  if (!strcmp (mode, "%Lu"))  { *va_arg (argp, unsigned long long *) = value; return (TRUE); }
-  if (!strcmp (mode, "%hd"))  { *va_arg (argp, short *)     	     = value; return (TRUE); }
-
-  /* no valid mode found */
-  return (FALSE);
-}
-
 /* if the variable argument stuff breaks on another system, look 
 at F_modify.c as it has the old code */
