Index: trunk/Ohana/src/libautocode/Makefile
===================================================================
--- trunk/Ohana/src/libautocode/Makefile	(revision 3593)
+++ trunk/Ohana/src/libautocode/Makefile	(revision 3609)
@@ -29,4 +29,5 @@
 # remember to add entries here to libohana/Makefile:AOBJ as well
 LIBOBJ = \
+$(SRC)/regimage.$(ARCH).o \
 $(SRC)/detreg.$(ARCH).o \
 $(SRC)/photreg.$(ARCH).o \
@@ -37,4 +38,5 @@
 
 LIBINC = \
+$(INC)/regimage.h \
 $(INC)/detreg.h \
 $(INC)/photreg.h \
@@ -44,11 +46,10 @@
 $(INC)/spectrum-ascii.h
 
-COMINC = \
-$(DEF)/common.h
-
 $(LIBOBJ): $(INC)/autocode.h
 
 $(INC)/autocode.h: $(LIBINC)
-	cat $(COMINC) $(LIBINC) > $(INC)/autocode.h
+	cat $(DEF)/common.h >  $(INC)/autocode.h
+	cat $(LIBINC)       >> $(INC)/autocode.h
+	@echo "# endif"     >> $(INC)/autocode.h
 	@echo done with libautocode.a:
 
Index: trunk/Ohana/src/libautocode/def/common.h
===================================================================
--- trunk/Ohana/src/libautocode/def/common.h	(revision 3593)
+++ trunk/Ohana/src/libautocode/def/common.h	(revision 3609)
@@ -1,5 +1,7 @@
-# include <stdio.h>
-# include <stdarg.h>
-# include <fitsio.h>
+# include <ohana.h>
+
+# ifndef AUTOCODE_H
+# define AUTOCODE_H
+/* matched endif is added by Makefile */
 
 # ifndef TRUE
@@ -32,4 +34,9 @@
 
 # define e_time unsigned int
+# define rawshort short
+
+/*** rawshort is used to handle the broken pre-autocode photreg tables
+     fix the tables and remove this
+***/
 
 /*** this file uses data types which must have fixed sizes regardless 
Index: trunk/Ohana/src/libautocode/def/photreg.d
===================================================================
--- trunk/Ohana/src/libautocode/def/photreg.d	(revision 3593)
+++ trunk/Ohana/src/libautocode/def/photreg.d	(revision 3609)
@@ -17,5 +17,5 @@
 FIELD photcode,   PHOTCODE,   short, 	   photcode,                  photcode
 FIELD label,      LABEL,      char[64],    data label
-FIELD refcode,    REFCODE,    short, 	   photcode,                  photcode
+FIELD refcode,    REFCODE,    rawshort,	   photcode,                  photcode
 FIELD Ntime,      N_TIME,     int, 	   number of times
 FIELD Nmeas,      N_MEAS,     int, 	   number of measurements
Index: trunk/Ohana/src/libautocode/def/regimage.d
===================================================================
--- trunk/Ohana/src/libautocode/def/regimage.d	(revision 3609)
+++ trunk/Ohana/src/libautocode/def/regimage.d	(revision 3609)
@@ -0,0 +1,37 @@
+STRUCT  RegImage
+EXTNAME IMAGE_DATABASE
+TYPE    BINTABLE
+SIZE    360
+
+# elements of data structure / FITS table
+
+FIELD filename,         FILE,       char[64],     filename in db
+FIELD pathname,     	PATH,       char[128],    fullpath in db
+FIELD filter,       	FILTER,     char[32],     filter name
+FIELD instrument,   	INSTRUMENT, char[32],     instrument
+FIELD ccd,	        CCD,        char,   	  ccd identifier
+FIELD mode,	        MODE,       char,   	  mef/split/etc
+FIELD type,	        TYPE,       char,   	  object/flat/bias/etc
+FIELD flag,	        FLAG,       char,   	  data flags
+FIELD seq,	        SEQ,        char,   	  sequence number
+FIELD seqtime,          SEQTIME,    float,        exposure time per slice,   seconds
+FIELD junk,	        JUNK,       char[19],     space for expansion
+FIELD exptime,	        EXPTIME,    float,  	  exposure time,             seconds
+FIELD airmass,	        AIRMASS,    float,  	  airmass
+FIELD sky,	        SKY,        float,  	  background level,          counts / pixel
+FIELD bias,	        BIAS,       float,  	  bias level,                counts / pixel
+FIELD fwhm,	        FWHM,       float,  	  image quality,             pixels
+FIELD telfocus,	        TELFOCUS,   float,  	  telescope focus,           microns
+FIELD xprobe,	        XPROBE,     float,  	  bonnette probe x pos,      microns
+FIELD yprobe,	        YPROBE,     float,  	  bonnette probe y pos,      microns
+FIELD zprobe,	        ZPROBE,     float,  	  bonnette focus,            microns
+FIELD dettemp,	        DETTEMP,    float,  	  detector temperature,      deg celcius
+FIELD teltemp_0,       	TELTEMP0,   float,  	  other temperature,         deg celcius
+FIELD teltemp_1,       	TELTEMP1,   float,  	  other temperature,         deg celcius
+FIELD teltemp_2,       	TELTEMP2,   float,  	  other temperature,         deg celcius
+FIELD teltemp_3,       	TELTEMP3,   float,  	  other temperature,         deg celcius
+FIELD rotangle,	        ROTANGLE,   float,  	  camera rotation angle,     degrees
+FIELD ra,	        RA,         float,  	  image ra,                  degrees
+FIELD dec,	        DEC,        float,  	  image dec,                 degrees
+FIELD obstime,	        OBS_TIME,   e_time, 	  time of measurement,       seconds since 01 Jan 1970 UT
+FIELD regtime,	        REG_TIME,   e_time, 	  time of registration,      seconds since 01 Jan 1970 UT
Index: trunk/Ohana/src/libautocode/generate
===================================================================
--- trunk/Ohana/src/libautocode/generate	(revision 3593)
+++ trunk/Ohana/src/libautocode/generate	(revision 3609)
@@ -41,5 +41,6 @@
 	# not a simple key/value entry
 	if ($key eq "FIELD") {
-	    ($element, $field, $format, $comment, $unit) = split (/,\s+/, $value);
+	    ($element, $field, $format, $comment, $unit) = split (/,\s+/, $value, 5);
+#	    print "$element : $field : $format : $comment : $unit\n";
 	    push @element, $element;
 	    push @field,   $field;
@@ -106,4 +107,6 @@
 	if ($type eq "float")  { $pt1 = "E"; }
 	if ($type eq "double") { $pt1 = "D"; }
+
+	if ($type eq "rawshort") { $pt1 = "I"; }
 
 	printf FILE "  fits_define_bintable_column (header, ";
@@ -130,4 +133,6 @@
 	if ($type eq "double") { $pt1 = sprintf "F%s", $length; }
 
+	if ($type eq "rawshort")  { $pt1 = sprintf "I%s", $length; }
+
 	printf FILE "  fits_define_table_column (header, ";
 	printf FILE "\"%s\", ",   $pt1;
@@ -179,4 +184,9 @@
 	    next;
 	}
+	# this is a patch for old photreg tables: provide a fix for the tables
+	if ($type eq "rawshort")  {
+	    $N +=2;
+	    next;
+	}
 	if ($type eq "short")  {
 	    $T = "BYTE";
@@ -229,4 +239,6 @@
 	if ($type eq "float")  { $Nbytes += 4; }
 	if ($type eq "double") { $Nbytes += 8; }
+
+	if ($type eq "rawshort")  { $Nbytes += 2; }
     }
     return ($Nbytes);
