Index: /trunk/Ohana/src/addstar/include/addstar.h
===================================================================
--- /trunk/Ohana/src/addstar/include/addstar.h	(revision 5899)
+++ /trunk/Ohana/src/addstar/include/addstar.h	(revision 5900)
@@ -130,6 +130,6 @@
 Stars     *rd_gsc                 PROTO((char *filename, int *nstars));
 int        replace_match          PROTO((Average *average, Measure *measure, Stars *star));
-Stars     *rfits                  PROTO((FILE *f, int *nstars));
-Stars     *rtext                  PROTO((FILE *f, int *nstars));
+Stars     *rfits                  PROTO((FILE *f, unsigned int *nstars));
+Stars     *rtext                  PROTO((FILE *f, unsigned int *nstars));
 void       save_pt_catalog        PROTO((Catalog *catalog));  /*** choose new name ***/
 double     scat_subpix            PROTO((double x, double y));
Index: /trunk/Ohana/src/addstar/src/rfits.c
===================================================================
--- /trunk/Ohana/src/addstar/src/rfits.c	(revision 5899)
+++ /trunk/Ohana/src/addstar/src/rfits.c	(revision 5900)
@@ -1,5 +1,5 @@
 # include "addstar.h"
 
-Stars *rfits (FILE *f, int *nstars) {
+Stars *rfits (FILE *f, unsigned int *nstars) {
 
   int i, Nstars;
Index: /trunk/Ohana/src/addstar/src/rtext.c
===================================================================
--- /trunk/Ohana/src/addstar/src/rtext.c	(revision 5899)
+++ /trunk/Ohana/src/addstar/src/rtext.c	(revision 5900)
@@ -4,5 +4,5 @@
 # define BLOCK 1000
 
-Stars *rtext (FILE *f, int *nstars) {
+Stars *rtext (FILE *f, unsigned int *nstars) {
 
   int j, N, Nextra, Ninstar, Nskip, Nbytes, nbytes;
Index: /trunk/Ohana/src/libautocode/generate
===================================================================
--- /trunk/Ohana/src/libautocode/generate	(revision 5899)
+++ /trunk/Ohana/src/libautocode/generate	(revision 5900)
@@ -119,8 +119,11 @@
 	if ($type eq "unsigned int")  { $pt1 = "J"; }
 	if ($type eq "e_time") 	      { $pt1 = "J"; }
-	if ($type eq "e_void") 	      { $pt1 = "L"; }
-	# e_void is a 64 bit pointer, cast to size_t
 	if ($type eq "float")  	      { $pt1 = "E"; }
 	if ($type eq "double") 	      { $pt1 = "D"; }
+
+	if ($type eq "e_void") 	      { $pt1 = "B"; $Np = 8*$Np; }
+	# e_void is a 64 bit pointer, cast to size_t.  its value is not loaded
+	# from the table.
+
 	if (!$pt1) { die "unknown type $type"; }
 
@@ -190,7 +193,9 @@
 	if ($type eq "unsigned int")  { $pt1 = sprintf "I%s", $length; }
 	if ($type eq "e_time") 	      { $pt1 = sprintf "I%s", $length; }
-	if ($type eq "e_void") 	      { $pt1 = sprintf "I%s", $length; }
 	if ($type eq "float")  	      { $pt1 = sprintf "F%s", $length; }
 	if ($type eq "double") 	      { $pt1 = sprintf "F%s", $length; }
+
+	if ($type eq "e_void") 	      { $pt1 = sprintf "I%s", $length; }
+
 	if (!$pt1) { die "unknown type $type"; }
 
Index: /trunk/Ohana/src/libdvo/src/skyregion_io.c
===================================================================
--- /trunk/Ohana/src/libdvo/src/skyregion_io.c	(revision 5899)
+++ /trunk/Ohana/src/libdvo/src/skyregion_io.c	(revision 5900)
@@ -90,39 +90,38 @@
   int status;
 
-  /* first option: catdir/SkyTable.fits */
+  /* first option: CATDIR/SkyTable.fits */
+  sprintf (filename, "%s/SkyTable.fits", catdir);
+  if (stat (filename, &filestat)) goto SKYFILE;
+  if (!check_file_access (filename, FALSE, verbose)) goto SKYFILE;
+  sky = SkyTableLoad (filename, verbose);
+  if (sky == NULL) {
+    fprintf (stderr, "error loading sky table\n");
+    exit (1);
+  }
+  return (sky);
+
+SKYFILE:
+  /* second option: SKYFILE */
+  if (skyfile == NULL) goto GSCFILE;
+  if (skyfile[0] != 0) goto GSCFILE;
+  if (stat (skyfile, &filestat)) goto GSCFILE;
+  if (!check_file_access (skyfile, FALSE, verbose)) goto GSCFILE;
+  sky = SkyTableLoad (skyfile, verbose);
+  if (sky == NULL) {
+    fprintf (stderr, "error loading sky table\n");
+    exit (1);
+  }
+  /* set the depths to the default depth */
+  SkyTableSetDepth (sky, depth);
+
+  /* create CATDIR copy */
   sprintf (filename, "%s/SkyTable.fits", catdir);
   check_file_access (filename, FALSE, verbose);
+  SkyTableSave (sky, filename);
+  fits_convert_SkyRegion (sky[0].regions, sizeof (SkyTable), sky[0].Nregions);
+  return (sky);
 
-  /* check for file existence */
-  status = stat (filename, &filestat);
-  if (status == 0) { /* file exists, are permissions OK? */
-    sky = SkyTableLoad (filename, verbose);
-    if (sky == NULL) {
-      fprintf (stderr, "error loading sky table\n");
-      exit (1);
-    }
-    return (sky);
-  }
-
-  /* first option: SKY_TABLE */
-  if ((skyfile != NULL) && (skyfile[0] != 0)) {
-    status = stat (skyfile, &filestat);
-    if (status == 0) { /* file exists, are permissions OK? */
-      sky = SkyTableLoad (skyfile, verbose);
-      if (sky == NULL) {
-	fprintf (stderr, "error loading sky table\n");
-	exit (1);
-      }
-      SkyTableSetDepth (sky, depth);
-
-      /* write CATDIR copy */
-      sprintf (filename, "%s/SkyTable.fits", catdir);
-      check_file_access (filename, FALSE, verbose);
-      SkyTableSave (sky, filename);
-      fits_convert_SkyRegion (sky[0].regions, sizeof (SkyTable), sky[0].Nregions);
-      return (sky);
-    }
-  }
-
+GSCFILE:
+  /* third option: GSCFILE */
   sky = SkyTableFromGSC (gscfile, depth, verbose);
   if (sky == NULL) {
@@ -131,10 +130,9 @@
   }
 
-  /* write CATDIR copy */
+  /* create CATDIR copy */
   sprintf (filename, "%s/SkyTable.fits", catdir);
   check_file_access (filename, FALSE, verbose);
   SkyTableSave (sky, filename);
   fits_convert_SkyRegion (sky[0].regions, sizeof (SkyRegion), sky[0].Nregions);
-
   return (sky);
 }
Index: /trunk/Ohana/src/opihi/dvo/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/dvo/Makefile	(revision 5899)
+++ /trunk/Ohana/src/opihi/dvo/Makefile	(revision 5900)
@@ -45,4 +45,5 @@
 $(SDIR)/calextract.$(ARCH).o      	\
 $(SDIR)/calmextract.$(ARCH).o     	\
+$(SDIR)/catdir.$(ARCH).o             	\
 $(SDIR)/ccd.$(ARCH).o             	\
 $(SDIR)/cmatch.$(ARCH).o	  	\
Index: /trunk/Ohana/src/opihi/dvo/catdir.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/catdir.c	(revision 5899)
+++ /trunk/Ohana/src/opihi/dvo/catdir.c	(revision 5900)
@@ -3,5 +3,5 @@
 int catdir_define (int argc, char **argv) {
   
-  int VERBOSE;
+  int status, N, VERBOSE;
 
   VERBOSE = FALSE;
Index: /trunk/Ohana/src/opihi/dvo/dvo.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/dvo.c	(revision 5899)
+++ /trunk/Ohana/src/opihi/dvo/dvo.c	(revision 5900)
@@ -8,5 +8,5 @@
 
 /* program-dependent initialization */
-void initialize (int argc, char **argv) {
+void program_init (int argc, char **argv) {
   
   auto_break = TRUE;
@@ -18,5 +18,5 @@
   InitDVO ();
 
-  if (SetCATDIR (NULL, TRUE)) {
+  if (!SetCATDIR (NULL, TRUE)) {
     fprintf (stderr, "CATDIR is not defined\n");
   }
@@ -28,20 +28,9 @@
   set_str_variable ("PROMPT", opihi_prompt);
   set_str_variable ("RCFILE", opihi_rcfile);
+
 # ifdef HELPDIR_DEFAULT
   set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
 # endif
 
-  { /* check history file permission */
-    FILE *f;
-    f = fopen (opihi_history, "a");
-    if (f == NULL) /* no current history file here */
-      fprintf (stderr, "can't save history.\n");
-    else
-      fclose (f);
-    stifle_history (200);
-    read_history (opihi_history);
-  }
-
-  signal (SIGINT, SIG_IGN);
   return;
 }
Index: /trunk/Ohana/src/opihi/dvo/init.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/init.c	(revision 5899)
+++ /trunk/Ohana/src/opihi/dvo/init.c	(revision 5900)
@@ -6,4 +6,5 @@
 int calmextract	    PROTO((int, char **));
 int catlog	    PROTO((int, char **));
+int catdir_define   PROTO((int, char **));
 int ccd		    PROTO((int, char **));
 int cmatch	    PROTO((int, char **));
@@ -61,4 +62,5 @@
   {"calextract",  calextract,   "extract photometry calibration"},
   {"calmextract", calmextract,  "extract photometry calibration"},
+  {"catdir",      catdir_define,"re-define CATDIR"},
   {"ccd",         ccd,          "plot color-color diagram"},
   {"cmatch",      cmatch,       "match two catalogs"},
Index: /trunk/Ohana/src/opihi/dvo/region_list.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/region_list.c	(revision 5899)
+++ /trunk/Ohana/src/opihi/dvo/region_list.c	(revision 5900)
@@ -30,4 +30,11 @@
   if (VarConfig ("SKYFILE",  "%s", skyfile) == NULL) skyfile[0] = 0;
   if (VarConfig ("SKYDEPTH", "%d", &skydepth) == NULL) skydepth = 2;
+
+  if (verbose) {
+      fprintf (stderr, "CATDIR %s\n", catdir);
+      fprintf (stderr, "GSCFILE %s\n", gscfile);
+      fprintf (stderr, "SKYFILE %s\n", skyfile);
+      fprintf (stderr, "SKYDEPTH %d\n", skydepth);
+  }
 
   /* load the SkyTable at this point */
@@ -81,5 +88,4 @@
   int Ngraph;
   Graphdata graphsky;
-  SkyTable *sky;
   SkyList *skylist;
   char filename[256];
Index: /trunk/Ohana/src/opihi/include/shell.h
===================================================================
--- /trunk/Ohana/src/opihi/include/shell.h	(revision 5899)
+++ /trunk/Ohana/src/opihi/include/shell.h	(revision 5900)
@@ -44,5 +44,6 @@
 
 /*** basic opihi shell functions ***/
-void          initialize            	PROTO((int argc, char **argv));
+void          general_init            	PROTO((int argc, char **argv));
+void          program_init            	PROTO((int argc, char **argv));
 void          startup               	PROTO((int argc, char **argv));
 int           multicommand          	PROTO((char *line));
Index: /trunk/Ohana/src/opihi/lib.shell/opihi.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/opihi.c	(revision 5899)
+++ /trunk/Ohana/src/opihi/lib.shell/opihi.c	(revision 5900)
@@ -8,5 +8,6 @@
   pid_t ppid;
 
-  initialize (argc, argv);
+  general_init (argc, argv);
+  program_init (argc, argv);
   startup (argc, argv);
   prompt = get_variable("PROMPT");
@@ -45,2 +46,12 @@
   }
 }
+
+/* 
+   startup sequence:
+
+   - general_init
+   - program_init
+   - startup (exit if non-interactive)
+   - welcome
+
+*/
Index: /trunk/Ohana/src/opihi/lib.shell/startup.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/startup.c	(revision 5899)
+++ /trunk/Ohana/src/opihi/lib.shell/startup.c	(revision 5900)
@@ -1,39 +1,29 @@
 # include "opihi.h"
 
-/* program-independent initialization */
-void startup (int argc, char **argv) {
+/* program-independent initialization
+ * these steps do not depend on the opihi implementation
+ * (ie, the supplied commands or data structures)
+ */
 
-  long A, B;
-    
-  signal (SIGINT, SIG_IGN);
+void general_init (int argc, char **argv) {
 
   /* init srand for rnd numbers elsewhere */
+  long A, B;
   A = time(NULL);
   for (B = 0; A == time(NULL); B++);
   srand48(B);
  
-  if (0) {
-    /* fix the history list to remove the timestamp */
-    char *c;
-    int i;
-    HIST_ENTRY **entry;
-    
-    entry = history_list ();
-    if (entry != (HIST_ENTRY **) NULL) {
-      for (i = 0; entry[i]; i++) {
-	if ((strlen (entry[i][0].line) > 19) &&
-	    (entry[i][0].line[2] == '/') && 
-	    (entry[i][0].line[5] == '/') && 
-	    (entry[i][0].line[11] == ':') && 
-	    (entry[i][0].line[14] == ':') && 
-	    (entry[i][0].line[17] == ':')) {
-	  c = entry[i][0].line + 19;
-	  memmove (entry[i][0].line, c, strlen(c) + 1);
-	}
-      }
-    }
+  /* set signals */
+  signal (SIGINT, SIG_IGN);
+
+  /* load config data (.ptolemyrc) */
+  if (!ConfigInit (&argc, argv)) {
+    fprintf (stderr, "can't find config file. some functions will be unavailable\n");
   }
-  
-  {
+
+  return;
+}
+
+void startup (int argc, char **argv) {
     
     int i, N, status, ONLY_INPUT, LOAD_RC;
@@ -57,6 +47,40 @@
   */
 
-    if (!ConfigInit (&argc, argv)) {
-      fprintf (stderr, "can't find config file. some functions will be unavailable\n");
+
+
+  /* check history file permission */
+  {
+    FILE *f;
+    char *opihi_history;
+
+    opihi_history = get_variable ("RCFILE");
+    f = fopen (opihi_history, "a");
+    if (f == NULL) /* no current history file here */
+      fprintf (stderr, "can't save history.\n");
+    else
+      fclose (f);
+    stifle_history (200);
+    read_history (opihi_history);
+  }
+
+  if (0) {
+    /* fix the history list to remove the timestamp */
+    char *c;
+    int i;
+    HIST_ENTRY **entry;
+    
+    entry = history_list ();
+    if (entry != (HIST_ENTRY **) NULL) {
+      for (i = 0; entry[i]; i++) {
+	if ((strlen (entry[i][0].line) > 19) &&
+	    (entry[i][0].line[2] == '/') && 
+	    (entry[i][0].line[5] == '/') && 
+	    (entry[i][0].line[11] == ':') && 
+	    (entry[i][0].line[14] == ':') && 
+	    (entry[i][0].line[17] == ':')) {
+	  c = entry[i][0].line + 19;
+	  memmove (entry[i][0].line, c, strlen(c) + 1);
+	}
+      }
     }
 
