Index: /trunk/Ohana/Configure.in
===================================================================
--- /trunk/Ohana/Configure.in	(revision 12839)
+++ /trunk/Ohana/Configure.in	(revision 12840)
@@ -18,4 +18,5 @@
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS  = @LDFLAGS@
+DLLTYPE  = @DLLTYPE@
 
 # flags for external dependencies
Index: /trunk/Ohana/Makefile.Common
===================================================================
--- /trunk/Ohana/Makefile.Common	(revision 12839)
+++ /trunk/Ohana/Makefile.Common	(revision 12840)
@@ -62,8 +62,22 @@
 	@echo ""
 
+$(LIB)/%.$(ARCH).dylib:
+	@if [ ! -d $(LIB) ]; then mkdir -p $(LIB); fi
+	rm -f $@
+	gcc -dynamiclib -o $@ $^ -lc
+	@echo "compiled shared library $*"
+	@echo ""
+
 # shared objects have a different compilation on solaris:
 # gcc -shared -o $@ $^ -lc
 
 $(DESTLIB)/%.so: $(LIB)/%.$(ARCH).so
+	@if [ ! -d $(DESTLIB) ]; then mkdir -p $(DESTLIB); fi
+	rm -f $@
+	cp $< $@
+	@echo "installed shared library $*"
+	@echo ""
+
+$(DESTLIB)/%.dylib: $(LIB)/%.$(ARCH).dylib
 	@if [ ! -d $(DESTLIB) ]; then mkdir -p $(DESTLIB); fi
 	rm -f $@
Index: /trunk/Ohana/Makefile.in
===================================================================
--- /trunk/Ohana/Makefile.in	(revision 12839)
+++ /trunk/Ohana/Makefile.in	(revision 12840)
@@ -46,4 +46,5 @@
 relphot     \
 shell       \
+tools       \
 tcl         \
 uniphot
Index: /trunk/Ohana/configure
===================================================================
--- /trunk/Ohana/configure	(revision 12839)
+++ /trunk/Ohana/configure	(revision 12840)
@@ -39,3 +39,4 @@
 done
 
+echo ./configure.tcsh $args
 ./configure.tcsh $args
Index: /trunk/Ohana/configure.tcsh
===================================================================
--- /trunk/Ohana/configure.tcsh	(revision 12839)
+++ /trunk/Ohana/configure.tcsh	(revision 12840)
@@ -5,13 +5,4 @@
 
 # we need to be able to list the required libraries for a given distribution
-
-# libX11.a
-# libsocket.a
-# libnsl.a
-# libpng.a
-# libjpeg.a
-# libz.a
-# libreadline.a
-# libtermcap.a
 
 # evaluate command-line options
@@ -28,4 +19,5 @@
 set datadir  = ""
 set sysconfdir  = ""
+set exec_prefix = ""
 
 set root    = ""
@@ -67,5 +59,12 @@
      set prefix = `echo $1 | tr = ' ' | awk '{print $2}'`
    endif
-   set exec_prefix = $prefix
+   breaksw;
+  case --exec-prefix*
+   if ("$1" == "--exec-prefix") then
+     shift
+     set exec_prefix = $1
+   else
+     set exec_prefix = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
    breaksw;
   case --bindir*
@@ -88,7 +87,7 @@
    if ("$1" == "--includedir") then
      shift
-     set includedir = $1
-   else
-     set includedir = `echo $1 | tr = ' ' | awk '{print $2}'`
+     set incdir = $1
+   else
+     set incdir = `echo $1 | tr = ' ' | awk '{print $2}'`
    endif
    breaksw;
@@ -131,4 +130,12 @@
 if ($#args != 1) goto usage
 
+if ("$exec_prefix" == "") then
+  set exec_prefix = $prefix
+endif
+
+# replace $exec_prefix in variables
+#echo "setting libdir ($libdir)"
+#set libdir = `echo $libdir | sed 's|\$exec_prefix|$exec_prefix|'`
+
 # set values for CC, CFLAGS, CPPFLAGS, LDFLAGS
 if (! $?CC) then
@@ -152,9 +159,16 @@
 endif  
 
-set syslibpath = "/lib /usr/lib /usr/X11R6/lib /usr/openwin/lib /usr/local/lib"
-set needlibs   = "png z jpeg readline X11 pthread m"
+set syslibpath = "/lib /usr/lib /usr/X11R6/lib /usr/local/lib"
+set needlibs   = ""
+set needlibs   = "$needlibs png"
+set needlibs   = "$needlibs z"
+set needlibs   = "$needlibs jpeg"
+set needlibs   = "$needlibs readline"
+set needlibs   = "$needlibs X11"
+set needlibs   = "$needlibs pthread"
+set needlibs   = "$needlibs m"
 
 # /usr/local/include/libpng is really pretty lame...
-set sysincpath = "/usr/include /usr/local/include /usr/X11R6/include /usr/openwin/include /usr/local/include/libpng"
+set sysincpath = "/usr/include /usr/local/include /usr/X11R6/include"
 
 set needincs = ""
@@ -210,4 +224,5 @@
 set sys=`uname -s` 
 set ranlib = "ranlib"
+set dlltype = "so"
 switch ($sys)
  case IRIX64:
@@ -222,4 +237,6 @@
    endif
    # sun (at least) seems to need the socket library (linux does not)
+   set syslibpath = "$syslibpath /usr/openwin/lib"
+   set sysincpath = "$sysincpath /usr/openwin/include"
    set needlibs = "$needlibs libsocket libnsl"
    set ranlib = "touch"
@@ -234,4 +251,14 @@
    endif
    breaksw;
+ case Darwin:
+   set arch="darwin";
+   set mach=`uname -m`
+   if ("$mach" == "i386") then
+    set arch="darwin_x86";
+   endif
+   set syslibpath = "$syslibpath /sw/lib /usr/local/lib/mysql"
+   set sysincpath = "$sysincpath /sw/include /usr/include/sys"
+   set dlltype = dylib
+   breaksw;
  case HP-UX:
     set arch="hpux";
@@ -247,11 +274,23 @@
 set root = `pwd`
 if ($prefix == "") set prefix = $root
-if ($vararch) then
-  set inc = $prefix/include/$arch
-  set lib = $prefix/lib/$arch
-else
-  set inc = $prefix/include
-  set lib = $prefix/lib
-endif
+
+# set the install include directory
+if ($incdir == "") then
+  if ($vararch) then
+    set incdir = $prefix/include/$arch
+  else
+    set incdir = $prefix/include
+  endif
+endif
+
+# set the install lib directory
+if ($libdir == "") then
+  if ($vararch) then
+    set libdir = $prefix/lib/$arch
+  else
+    set libdir = $prefix/lib
+  endif
+endif
+
 if ($?LD_LIBRARY_PATH) then 
   set libpath = `echo $LD_LIBRARY_PATH | tr ':' ' '`
@@ -268,24 +307,24 @@
 set nonomatch
 foreach f ( $needlibs )
-    foreach g ( $syslibpath $lib $libpath )
-        if (! -e $g) continue
-	set name = $g/lib$f.a
-	if (-e $name[1]) goto got_lib;
-	set name = $g/lib$f.so*
-	if (-e $name[1]) goto got_lib;
-    end
-    echo "missing lib$f"
-    set faillibs = "$faillibs lib$f"
-    continue
+  foreach g ( $syslibpath $libdir $libpath )
+    set name = $g/lib$f.a
+    if (-e $name[1]) goto got_lib;
+    set name = $g/lib$f.$dlltype
+    if (-e $name[1]) goto got_lib;
+  end
+  echo "missing lib$f"
+  set faillibs = "$faillibs lib$f"
+  continue
 got_lib:
-    echo "found lib$f ($name[$#name])"
-    echo "$libdirs" | grep -- "-L$g " > /dev/null
-    if ($status) then
-      set libdirs  = "$libdirs-L$g "
-    endif
-    echo "$libflags" | grep -- "-l$f " > /dev/null
-    if ($status) then
-      set libflags = "$libflags-l$f "
-    endif
+  echo "found lib$f ($name[1])"
+  set gotlibdir = `dirname $name[1]`
+  echo "$libdirs" | grep -- "-L$gotlibdir " > /dev/null
+  if ($status) then
+    set libdirs  = "$libdirs-L$gotlibdir "
+  endif
+  echo "$libflags" | grep -- "-l$f " > /dev/null
+  if ($status) then
+    set libflags = "$libflags-l$f "
+  endif
 end
 
@@ -293,9 +332,9 @@
 # check for termcap, curses, etc
 foreach f ( ncurses curses termcap )
-    foreach g ( $syslibpath $lib $libpath )
-	set name = $g/lib$f.a
-	if (-e $name[1]) goto got_curses;
-	set name = $g/lib$f.so*
-	if (-e $name[1]) goto got_curses;
+    foreach g ( $syslibpath $libdir $libpath )
+        set name = $g/lib$f.a
+        if (-e $name[1]) goto got_curses;
+        set name = $g/lib$f.$dlltype
+        if (-e $name[1]) goto got_curses;
     end
 end
@@ -324,5 +363,12 @@
 endif    
 
-# check for headers
+# add the CPATH
+if ($?CPATH) then 
+  set incpath = `echo $CPATH | tr ':' ' '`
+else
+  set incpath = ""
+endif
+
+# check for headers (including in subdirectories)
 echo ""
 echo "searching for needed external header files..."
@@ -330,5 +376,5 @@
 set incdirs = ""
 foreach f ( $needincs )
-  foreach g ( $sysincpath $inc )
+  foreach g ( $incdir $incpath $sysincpath )
     set name = "$g/$f"
     if (-e $name) goto got_inc;
@@ -338,5 +384,5 @@
   continue
 got_inc:
-  echo "found $f ($name)"
+  echo "found $f ($name[1])"
   echo "$incdirs" | grep -- "-I$g " > /dev/null
   if ($status) then
@@ -453,4 +499,5 @@
 ./config.tools fixconf @CPPFLAGS@ "$CPPFLAGS"
 ./config.tools fixconf @LDFLAGS@ "$LDFLAGS"
+./config.tools fixconf @DLLTYPE@  "$dlltype"
 
 # other architecture dependent options
Index: /trunk/Ohana/src/addstar/include/addstar.h
===================================================================
--- /trunk/Ohana/src/addstar/include/addstar.h	(revision 12839)
+++ /trunk/Ohana/src/addstar/include/addstar.h	(revision 12840)
@@ -82,4 +82,6 @@
 int    	ACCEPT_ASTROM;  // accept even bad astrometry solutions (NASTRO == 0)
 int    	ACCEPT_MOTION;  // accept reference proper motion measurements
+int    	ACCEPT_TIME;    // accept time stamp (or 0)
+int    	NO_STARS;       // ignore the stars
 int    	TEXTMODE;       // force input file to be loaded as RAW
 int     SUBPIX;         // apply a subpix correction
Index: /trunk/Ohana/src/addstar/src/ReadImageHeader.c
===================================================================
--- /trunk/Ohana/src/addstar/src/ReadImageHeader.c	(revision 12839)
+++ /trunk/Ohana/src/addstar/src/ReadImageHeader.c	(revision 12840)
@@ -24,5 +24,5 @@
   image[0].NY = Ny;
 
-  if (!gfits_scan (header, "TZERO",   "%d",  1, &image[0].tzero)) {
+  if (!gfits_scan (header, "TZERO",   "%d",  1, &image[0].tzero) && !ACCEPT_TIME) {
     image[0].tzero = parse_time (header);
   }
@@ -155,5 +155,5 @@
 
   /* find expected number of stars */
-  if (!gfits_scan (header, "NSTARS", "%d", 1, &image[0].nstar)) {
+  if (!gfits_scan (header, "NSTARS", "%d", 1, &image[0].nstar) && !NO_STARS) {
     fprintf (stderr, "can't get NSTARS from header\n");
     return (FALSE);
Index: /trunk/Ohana/src/addstar/src/SetSignals.c
===================================================================
--- /trunk/Ohana/src/addstar/src/SetSignals.c	(revision 12839)
+++ /trunk/Ohana/src/addstar/src/SetSignals.c	(revision 12840)
@@ -30,14 +30,18 @@
   for (i = 0; i < 36; i++) {
     switch (i) {
-      /* can't redirect this signals */
-    case SIGKILL:    /* kill -9: cannot be caught or ignored */
-    case SIGSTOP:    /* SIGSTOP: cannot be caught or ignored */
+      /* can't redirect these signals */
+    case SIGKILL:    /* kill -9: cannot be caught or ignored (POSIX.1-1990) */
+    case SIGSTOP:    /* SIGSTOP: cannot be caught or ignored (POSIX.1-1990) */
       /* ignore these signals */
-    case SIGCHLD:    /* child halted: ignore */
-    case SIGPWR:     /* power failure - why ignore this? */
-    case SIGWINCH:   /* window resized */
-    case SIGCONT:    /* continue - maintain this action */
-    case SIGTSTP:    /* stop signal sent from tty - why ignore? */
-    case SIGURG:     /* socket signal, ignore this */
+    case SIGCHLD:    /* child halted: ignore (POSIX.1-1990) */
+    case SIGCONT:    /* continue - maintain this action (POSIX.1-1990) */
+    case SIGTSTP:    /* stop signal sent from tty - why ignore? (POSIX.1-1990) */
+    case SIGURG:     /* socket signal, ignore this (POSIX.1-2001) */
+# ifdef (SIGPWR)
+    case SIGPWR:     /* power failure - why ignore this? (Sys V) */
+# endif
+# ifdef (SIGWINCH)
+    case SIGWINCH:   /* window resized (4.3BSD) */
+# endif
       break;
       
Index: /trunk/Ohana/src/addstar/src/args.c
===================================================================
--- /trunk/Ohana/src/addstar/src/args.c	(revision 12839)
+++ /trunk/Ohana/src/addstar/src/args.c	(revision 12840)
@@ -242,4 +242,16 @@
   if ((N = get_argument (argc, argv, "-accept-motion"))) {
     ACCEPT_MOTION = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+  /* accept bad header astrometry */
+  ACCEPT_TIME = FALSE;
+  if ((N = get_argument (argc, argv, "-accept-time"))) {
+    ACCEPT_TIME = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+  /* skip the stars */
+  NO_STARS = FALSE;
+  if ((N = get_argument (argc, argv, "-no-stars"))) {
+    NO_STARS = TRUE;
     remove_argument (N, &argc, argv);
   }
Index: /trunk/Ohana/src/delstar/src/SetSignals.c
===================================================================
--- /trunk/Ohana/src/delstar/src/SetSignals.c	(revision 12839)
+++ /trunk/Ohana/src/delstar/src/SetSignals.c	(revision 12840)
@@ -30,14 +30,18 @@
   for (i = 0; i < 36; i++) {
     switch (i) {
-      /* can't redirect this signals */
-    case SIGKILL:    /* kill -9: cannot be caught or ignored */
-    case SIGSTOP:    /* SIGSTOP: cannot be caught or ignored */
+      /* can't redirect these signals */
+    case SIGKILL:    /* kill -9: cannot be caught or ignored (POSIX.1-1990) */
+    case SIGSTOP:    /* SIGSTOP: cannot be caught or ignored (POSIX.1-1990) */
       /* ignore these signals */
-    case SIGCHLD:    /* child halted: ignore */
-    case SIGPWR:     /* power failure - why ignore this? */
-    case SIGWINCH:   /* window resized */
-    case SIGCONT:    /* continue - maintain this action */
-    case SIGTSTP:    /* stop signal sent from tty - why ignore? */
-    case SIGURG:     /* socket signal, ignore this */
+    case SIGCHLD:    /* child halted: ignore (POSIX.1-1990) */
+    case SIGCONT:    /* continue - maintain this action (POSIX.1-1990) */
+    case SIGTSTP:    /* stop signal sent from tty - why ignore? (POSIX.1-1990) */
+    case SIGURG:     /* socket signal, ignore this (POSIX.1-2001) */
+# ifdef (SIGPWR)
+    case SIGPWR:     /* power failure - why ignore this? (Sys V) */
+# endif
+# ifdef (SIGWINCH)
+    case SIGWINCH:   /* window resized (4.3BSD) */
+# endif
       break;
       
Index: /trunk/Ohana/src/getstar/Makefile
===================================================================
--- /trunk/Ohana/src/getstar/Makefile	(revision 12839)
+++ /trunk/Ohana/src/getstar/Makefile	(revision 12840)
@@ -22,4 +22,7 @@
 dvoImageOverlaps: $(BIN)/dvoImageOverlaps.$(ARCH)
 dvoImageOverlaps.install: $(DESTBIN)/dvoImageOverlaps
+
+dvoImageExtract: $(BIN)/dvoImageExtract.$(ARCH)
+dvoImageExtract.install: $(DESTBIN)/dvoImageExtract
 
 install: getstar.install dvoImageOverlaps.install
@@ -52,2 +55,15 @@
 $(OVERLAPS): $(INC)/dvoImageOverlaps.h
 $(BIN)/dvoImageOverlaps.$(ARCH): $(OVERLAPS)
+
+EXTRACT = \
+$(SRC)/dvoImageExtract.$(ARCH).o 	 \
+$(SRC)/ConfigInit_extract.$(ARCH).o 	 \
+$(SRC)/args_extract.$(ARCH).o		 \
+$(SRC)/Shutdown.$(ARCH).o	         \
+$(SRC)/SetSignals.$(ARCH).o	         \
+$(SRC)/WriteImages.$(ARCH).o             \
+$(SRC)/WriteImageFITS.$(ARCH).o          \
+$(SRC)/SelectImages.$(ARCH).o       
+
+$(EXTRACT): $(INC)/dvoImageExtract.h
+$(BIN)/dvoImageExtract.$(ARCH): $(EXTRACT)
Index: /trunk/Ohana/src/getstar/include/dvoImageExtract.h
===================================================================
--- /trunk/Ohana/src/getstar/include/dvoImageExtract.h	(revision 12840)
+++ /trunk/Ohana/src/getstar/include/dvoImageExtract.h	(revision 12840)
@@ -0,0 +1,33 @@
+# include <ohana.h>
+# include <dvo.h>
+# include <signal.h>
+# include <glob.h>
+
+enum {NONE, SIMPLE_CMP, SIMPLE_CMF, SIMPLE_MEF, MOSAIC_CMP, MOSAIC_CMF, MOSAIC_MEF, MOSAIC_PHU};
+
+int       VERBOSE;
+
+char OUTPUT[256];
+char GSCFILE[256];
+char CATDIR[256];
+char CATMODE[16];    /* raw, mef, split, mysql */
+char CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
+char SKY_TABLE[256];
+int  SKY_DEPTH;
+char   ImageCat[256];
+char *OUTFILE;
+Coords *MOSAIC;         // carries the mosaic into ReadImageHeader
+
+int  args_extract    	 PROTO((int argc, char **argv));
+int  ConfigInit_extract  PROTO((int *argc, char **argv));
+int  Shutdown         	 PROTO((char *format, ...));
+void TrapSignal       	 PROTO((int sig));
+void SetProtect       	 PROTO((int mode));
+int  SetSignals       	 PROTO(());
+
+int GetFileMode (Header *header);
+int edge_check (double *x1, double *y1, double *x2, double *y2);
+
+int  WriteImageFITS (FILE *f, Image *image);
+int  WriteImages (char *filename, Image *images, int Nimages, int *matches, int Nmatches);
+int *SelectImages (char *filename, Image *dbImages, int NdbImages, int *Nmatch);
Index: /trunk/Ohana/src/getstar/src/ConfigInit_extract.c
===================================================================
--- /trunk/Ohana/src/getstar/src/ConfigInit_extract.c	(revision 12840)
+++ /trunk/Ohana/src/getstar/src/ConfigInit_extract.c	(revision 12840)
@@ -0,0 +1,46 @@
+# include "dvoImageExtract.h"
+
+int ConfigInit_extract (int *argc, char **argv) {
+
+  char *config, *file;
+  char CatdirPhotcodeFile[256];
+  char MasterPhotcodeFile[256];
+
+  /*** load configuration info ***/
+  file = SelectConfigFile (argc, argv, "ptolemy");
+  config = LoadConfigFile (file);
+  if (config == (char *) NULL) {
+    fprintf (stderr, "ERROR: can't find configuration file %s\n", file);
+    if (file != (char *) NULL) free (file);
+    exit (1);
+  }
+  if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);
+
+  ScanConfig (config, "GSCFILE",                "%s", 0, GSCFILE);
+  ScanConfig (config, "CATDIR",                 "%s", 0, CATDIR);
+  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
+  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
+  ScanConfig (config, "PHOTCODE_FILE",         	"%s",  0, MasterPhotcodeFile);
+  if (!ScanConfig (config, "SKY_DEPTH",         "%d",  0, &SKY_DEPTH)) {
+    SKY_DEPTH = 2;
+  }
+  if (!ScanConfig (config, "SKY_TABLE",         "%s",  0, SKY_TABLE)) {
+    SKY_TABLE[0] = 0;
+  }
+  sprintf (ImageCat, "%s/Images.dat", CATDIR);
+
+  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
+  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
+
+  /* XXX this does not yet write out the master photcode table */
+  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
+  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
+    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
+    exit (1);
+  }
+
+  free (config);
+  free (file);
+
+  return (TRUE);
+}
Index: /trunk/Ohana/src/getstar/src/SelectImages.c
===================================================================
--- /trunk/Ohana/src/getstar/src/SelectImages.c	(revision 12840)
+++ /trunk/Ohana/src/getstar/src/SelectImages.c	(revision 12840)
@@ -0,0 +1,37 @@
+# include "dvoImageExtract.h"
+
+/* given image, find catalog images which overlap it */
+int *SelectImages (char *filename, Image *images, int Nimages, int *Nmatch) {
+  
+  int i, Nchar, status;
+  int NMATCH, nmatch, *match;
+
+  /* matches here are only based on string comparisons */
+
+  /* match represents the subset of matched images */
+  nmatch = 0;
+  NMATCH = 20;
+  ALLOCATE (match, int, NMATCH);
+
+  /* setup links for mosaic WRP and DIS entries */
+  BuildChipMatch (images, Nimages);
+
+  Nchar = strlen (filename);
+
+  for (i = 0; i < Nimages; i++) {
+
+    if (strncmp (images[i].name, filename, Nchar)) continue;
+
+    match[nmatch] = i;
+    nmatch ++;
+    if (nmatch == NMATCH) {
+      NMATCH += 20;
+      REALLOCATE (match, int, NMATCH);
+    }
+  }  
+
+  if (VERBOSE) fprintf (stderr, "found %d matching images\n", nmatch);
+
+  *Nmatch = nmatch;
+  return (match);
+}
Index: /trunk/Ohana/src/getstar/src/SetSignals.c
===================================================================
--- /trunk/Ohana/src/getstar/src/SetSignals.c	(revision 12839)
+++ /trunk/Ohana/src/getstar/src/SetSignals.c	(revision 12840)
@@ -30,14 +30,18 @@
   for (i = 0; i < 36; i++) {
     switch (i) {
-      /* can't redirect this signals */
-    case SIGKILL:    /* kill -9: cannot be caught or ignored */
-    case SIGSTOP:    /* SIGSTOP: cannot be caught or ignored */
+      /* can't redirect these signals */
+    case SIGKILL:    /* kill -9: cannot be caught or ignored (POSIX.1-1990) */
+    case SIGSTOP:    /* SIGSTOP: cannot be caught or ignored (POSIX.1-1990) */
       /* ignore these signals */
-    case SIGCHLD:    /* child halted: ignore */
-    case SIGPWR:     /* power failure - why ignore this? */
-    case SIGWINCH:   /* window resized */
-    case SIGCONT:    /* continue - maintain this action */
-    case SIGTSTP:    /* stop signal sent from tty - why ignore? */
-    case SIGURG:     /* socket signal, ignore this */
+    case SIGCHLD:    /* child halted: ignore (POSIX.1-1990) */
+    case SIGCONT:    /* continue - maintain this action (POSIX.1-1990) */
+    case SIGTSTP:    /* stop signal sent from tty - why ignore? (POSIX.1-1990) */
+    case SIGURG:     /* socket signal, ignore this (POSIX.1-2001) */
+# ifdef (SIGPWR)
+    case SIGPWR:     /* power failure - why ignore this? (Sys V) */
+# endif
+# ifdef (SIGWINCH)
+    case SIGWINCH:   /* window resized (4.3BSD) */
+# endif
       break;
       
Index: /trunk/Ohana/src/getstar/src/WriteImageFITS.c
===================================================================
--- /trunk/Ohana/src/getstar/src/WriteImageFITS.c	(revision 12840)
+++ /trunk/Ohana/src/getstar/src/WriteImageFITS.c	(revision 12840)
@@ -0,0 +1,42 @@
+# include "dvoImageExtract.h"
+
+/* given image, find catalog images which overlap it */
+int WriteImageFITS (FILE *f, Image *image) {
+  
+  int Nstars;
+  Header header;
+  Matrix matrix;
+  Header theader;
+  FTable table;
+
+  gfits_init_header (&header);
+  header.extend = TRUE;
+  header.Naxes = 2;
+  if (image) {
+    header.Naxis[0] = image[0].NX;
+    header.Naxis[1] = image[0].NY;
+  }
+  gfits_create_header (&header);
+
+  if (image) {
+    PutCoords (&image[0].coords, &header);
+  }
+  /* create (NOT empty) data matrix */
+  gfits_create_matrix (&header, &matrix);
+
+  gfits_fwrite_header  (f, &header);
+  gfits_fwrite_matrix  (f, &matrix);
+  return (TRUE);
+
+  Nstars = 0;
+  if (image) Nstars = image[0].nstar;
+
+  table.header = &theader;
+  gfits_table_set_SMPData (&table, NULL, Nstars);
+  gfits_fwrite_Theader (f, &theader);
+  gfits_fwrite_table   (f, &table);
+
+  return TRUE;
+}
+
+// XXX this is a temporary hack to get skycell output working
Index: /trunk/Ohana/src/getstar/src/WriteImages.c
===================================================================
--- /trunk/Ohana/src/getstar/src/WriteImages.c	(revision 12840)
+++ /trunk/Ohana/src/getstar/src/WriteImages.c	(revision 12840)
@@ -0,0 +1,56 @@
+# include "dvoImageExtract.h"
+
+/* given image, find catalog images which overlap it */
+int WriteImages (char *filename, Image *images, int Nimages, int *matches, int Nmatches) {
+  
+  int i, N, status;
+  int NMATCH, nmatch, *match;
+  int nWRP, newWRP, isWRP;
+  FILE *f;
+
+  /* matches here are only based on string comparisons */
+
+  f = fopen (filename, "w");
+  if (f == NULL) {
+    fprintf (stderr, "failed to open output file %s\n", filename);
+    exit (1);
+  }
+
+  nWRP = -1;
+  isWRP = FALSE;
+  for (i = 0; i < Nmatches; i++) {
+    if (!strcmp (&images[0].coords.ctype[4], "-WRP")) {
+      if (!FindMosaicForImage (images, Nimages, i)) {
+	fprintf (stderr, "failed to find matching mosaic\n");
+	exit (1);
+      }
+      if (isWRP) {
+	newWRP = GetRegisteredMosaic();
+	if (newWRP != nWRP) {
+	  fprintf (stderr, "only one mosaic allowed in an output file\n");
+	  exit (1);
+	}
+      } else {
+	nWRP = GetRegisteredMosaic();
+	isWRP = TRUE;
+      }
+    }      
+  }
+
+  if (isWRP) {
+    WriteImageFITS (f, &images[nWRP]);
+  } else {
+    // write a blank
+    if (Nmatches > 1) {
+      WriteImageFITS (f, NULL);
+    }
+  }
+
+  for (i = 0; i < Nmatches; i++) {
+    N = matches[i];
+    WriteImageFITS (f, &images[N]);
+  }  
+
+  fclose (f);
+  return TRUE;
+}
Index: /trunk/Ohana/src/getstar/src/args_extract.c
===================================================================
--- /trunk/Ohana/src/getstar/src/args_extract.c	(revision 12840)
+++ /trunk/Ohana/src/getstar/src/args_extract.c	(revision 12840)
@@ -0,0 +1,38 @@
+# include "dvoImageExtract.h"
+
+void help () {
+  fprintf (stderr, "USAGE: \n"
+	   "dvoExtractImages (imageID) [-o output]\n"
+    );
+  exit (2);
+}
+
+int args_extract (int argc, char **argv) {
+  
+  int N;
+
+  /* check for help request */
+  if (get_argument (argc, argv, "-help") ||
+      get_argument (argc, argv, "-h")) {
+    help ();
+  }
+
+  /* check for command line options */
+  VERBOSE = FALSE;
+  if ((N = get_argument (argc, argv, "-v"))) {
+    VERBOSE = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+
+  /* check for command line options */
+  OUTFILE = NULL;
+  if ((N = get_argument (argc, argv, "-o"))) {
+    remove_argument (N, &argc, argv);
+    OUTFILE = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if (argc != 2) help();
+
+  return (TRUE);
+}
Index: /trunk/Ohana/src/getstar/src/dvoImageExtract.c
===================================================================
--- /trunk/Ohana/src/getstar/src/dvoImageExtract.c	(revision 12840)
+++ /trunk/Ohana/src/getstar/src/dvoImageExtract.c	(revision 12840)
@@ -0,0 +1,51 @@
+# include "dvoImageExtract.h"
+
+int main (int argc, char **argv) {
+
+  int i, Nimages, status;
+  int Nmatches, *matches;
+  Image *images;
+  Catalog catalog;
+  FITS_DB db;
+
+  SetSignals ();
+  ConfigInit_extract (&argc, argv);
+  args_extract (argc, argv);
+
+  /*** update the image table ***/
+  /* setup image table format and lock */
+  db.mode   = dvo_catalog_catmode (CATMODE);
+  db.format = dvo_catalog_catformat (CATFORMAT);
+  status    = dvo_image_lock (&db, ImageCat, 3600.0, LCK_SOFT);  // shorter timeout?
+  if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
+
+  /* load or create the image table */
+  if (db.dbstate == LCK_EMPTY) {
+    fprintf (stderr, "no images in database (%s)\n", ImageCat);
+    exit (1);
+  } else {
+    if (!dvo_image_load (&db, VERBOSE, FALSE)) {
+      Shutdown ("can't read image catalog %s", db.filename);
+    }
+  }
+  dvo_image_unlock (&db);
+
+  // convert database table to internal structure
+  images = gfits_table_get_Image (&db.ftable, &Nimages, &db.swapped);
+  
+  matches = SelectImages (argv[1], images, Nimages, &Nmatches);
+  WriteImages (OUTFILE, images, Nimages, matches, Nmatches);
+
+  exit (0);
+}
+
+/* This program extracts images headers from a DVO database and writes them 
+   in cmf format (headers + object tables).
+
+   If multiple images are selected, they must be from the same exposures (how?).
+
+   If images are selected with WRP astrometry, the associated DIS image header is first written to
+   the output file.
+ 
+   USAGE: dvoExtractImages (imageID[s]) -o output.cmf
+*/
Index: /trunk/Ohana/src/libdvo/include/dvo.h
===================================================================
--- /trunk/Ohana/src/libdvo/include/dvo.h	(revision 12839)
+++ /trunk/Ohana/src/libdvo/include/dvo.h	(revision 12840)
@@ -241,4 +241,5 @@
 char *libdvo_version ();
 
+int GetRegisteredMosaic ();
 int FindMosaicForImage (Image *images, int Nimages, int entry);
 int FindMosaicForImage_TableSearch (Image *images, int Nimages, int entry);
Index: /trunk/Ohana/src/libdvo/src/mosaic_astrom.c
===================================================================
--- /trunk/Ohana/src/libdvo/src/mosaic_astrom.c	(revision 12839)
+++ /trunk/Ohana/src/libdvo/src/mosaic_astrom.c	(revision 12840)
@@ -3,8 +3,14 @@
 /* chip-match table: j = ChipMatch[i], images[j] is DIS for images[i] WRP */
 
+static int    iDIS = -1;      // DIS entry in ChipMatch[]
 static int    Ndis = 0;
 static int    *DISentry = NULL;
 static e_time *DIStzero = NULL;
 static int    *ChipMatch = NULL;
+
+/* what is the currently registered mosaic image? */
+int GetRegisteredMosaic () {
+  return (iDIS);
+}
 
 /* given an image array and a current entry of type WRP, find matching DIS & Register it */
@@ -42,4 +48,6 @@
     /* found a valid match */
     RegisterMosaic (&images[i].coords);
+    iDIS = i;
+    return (TRUE);
   }
 
@@ -50,4 +58,5 @@
     /* found a valid match */
     RegisterMosaic (&images[i].coords);
+    iDIS = i;
     return (TRUE);
   }
@@ -72,4 +81,5 @@
 
   RegisterMosaic (&images[N].coords);
+  iDIS = N;
   return (TRUE);
 }
Index: /trunk/Ohana/src/libohana/Makefile
===================================================================
--- /trunk/Ohana/src/libohana/Makefile	(revision 12839)
+++ /trunk/Ohana/src/libohana/Makefile	(revision 12840)
@@ -19,6 +19,6 @@
 TFLAGS        = $(FULL_CFLAGS) $(FULL_LDFLAGS) -ltap_ohana
 
-install: $(DESTLIB)/libohana.a $(DESTLIB)/libohana.so
-libohana: $(LIB)/libohana.$(ARCH).a $(LIB)/libohana.$(ARCH).so
+install: $(DESTLIB)/libohana.a $(DESTLIB)/libohana.$(DLLTYPE)
+libohana: $(LIB)/libohana.$(ARCH).a $(LIB)/libohana.$(ARCH).$(DLLTYPE)
 testcode: install $(TEST)
 test:
@@ -50,8 +50,8 @@
 
 $(LIB)/libohana.$(ARCH).a: $(OBJS)
-$(LIB)/libohana.$(ARCH).so: $(OBJS)
+$(LIB)/libohana.$(ARCH).$(DLLTYPE): $(OBJS)
 
 $(DESTLIB)/libohana.a:  $(LIB)/libohana.$(ARCH).a
-$(DESTLIB)/libohana.so: $(LIB)/libohana.$(ARCH).so
+$(DESTLIB)/libohana.$(DLLTYPE): $(LIB)/libohana.$(ARCH).$(DLLTYPE)
 
 $(TESTDIR)/%.$(ARCH) : $(TESTDIR)/%.c
Index: /trunk/Ohana/src/opihi/cmd.astro/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/Makefile	(revision 12839)
+++ /trunk/Ohana/src/opihi/cmd.astro/Makefile	(revision 12840)
@@ -50,9 +50,9 @@
 $(SRC)/imfit-fgauss.$(ARCH).o	   \
 $(SRC)/imfit-pgauss.$(ARCH).o	   \
-$(SRC)/imfit-Pgauss.$(ARCH).o	   \
+$(SRC)/imfit-pgauss-psf.$(ARCH).o	   \
 $(SRC)/imfit-qgauss.$(ARCH).o	   \
-$(SRC)/imfit-Qgauss.$(ARCH).o	   \
+$(SRC)/imfit-qgauss-psf.$(ARCH).o	   \
 $(SRC)/imfit-sgauss.$(ARCH).o	   \
-$(SRC)/imfit-Sgauss.$(ARCH).o	   \
+$(SRC)/imfit-sgauss-psf.$(ARCH).o	   \
 $(SRC)/imfit-qfgauss.$(ARCH).o	   \
 $(SRC)/imfit-qrgauss.$(ARCH).o	   
Index: unk/Ohana/src/opihi/cmd.astro/imfit-Pgauss.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/imfit-Pgauss.c	(revision 12839)
+++ 	(revision )
@@ -1,66 +1,0 @@
-# include "imfit.h"
-
-float PgaussTD (float, float, float *, int, float *);
-void  PgaussCL ();
-
-void  Pgauss_setup (char *name) {
-
-  if (strcmp(name, "Pgauss")) return;
-
-  fitfunc = PgaussTD;
-  imfit_cleanup = PgaussCL;
-  Npar = 4;
-  Nfpar = 3;
-
-  /* allocate free and fixed parameters */
-  ALLOCATE (par, float, MAX (Npar, 1));
-  bzero (par, Npar*sizeof(float));
-  ALLOCATE (fpar, float, MAX (Nfpar, 1));
-  bzero (fpar, Nfpar*sizeof(float));
-
-  par[0] = get_variable_default ("Xg", 0);
-  par[1] = get_variable_default ("Yg", 0);
-  par[2] = get_variable_default ("Zpk", 10000);
-  par[3] = get_variable_default ("Sg", 0.0);
-  sky = &par[3];
-
-  fpar[0] = 2.35 / get_variable_default ("SXg", 2.0);
-  fpar[1] = 2.35 / get_variable_default ("SYg", 2.0);
-  fpar[2] = get_variable_default ("SXYg", 0);
-}
-
-void PgaussCL () {
-  set_variable ("Xg",   par[0]);
-  set_variable ("Yg",   par[1]);
-  set_variable ("Zpk",  par[2]);
-  set_variable ("Sg",   par[3]);
-}
-
-/* pseudo 2D gaussian -- x, y, (sx), (sy), (sxy), I, sky */
-float PgaussTD (float x, float y, float *par, int Npar, float *dpar) {
-
-  float X, Y, px, py;
-  float z, r, q, f;
-
-  /* par -> fpar: (2,0), (3,1), (4,2) */
-
-  X = x - par[0];
-  Y = y - par[1];
-  
-  px = fpar[0]*X;
-  py = fpar[1]*Y;
-
-  z = 0.5*SQ(px) + 0.5*SQ(py) + fpar[2]*X*Y;
-  r = 1.0 / (1 + z + 0.5*z*z*(1 + z/3)); /* ~ exp (-Z) */
-  f = par[2]*r + par[3];
-  q = par[2]*r*r*(1 + z + 0.5*z*z);
-  /* note difference from gaussian: q = par[5]*r */
-
-  if (dpar != NULL) {
-    dpar[0] = q*(2*px*fpar[0] + fpar[2]*Y);
-    dpar[1] = q*(2*py*fpar[1] + fpar[2]*X);
-    dpar[2] = +r;
-    dpar[3] = +1;
-  }
-  return (f);
-}
Index: unk/Ohana/src/opihi/cmd.astro/imfit-Qgauss.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/imfit-Qgauss.c	(revision 12839)
+++ 	(revision )
@@ -1,68 +1,0 @@
-# include "imfit.h"
-
-float QgaussTD (float, float, float *, int, float *);
-void  QgaussCL ();
-
-void Qgauss_setup (char *name) {
-
-  if (strcmp(name, "Qgauss")) return;
-
-  fitfunc = QgaussTD;
-  imfit_cleanup = QgaussCL;
-  Npar = 4;
-  Nfpar = 5;
-
-  /* allocate free and fixed parameters */
-  ALLOCATE (par, float, MAX (Npar, 1));
-  bzero (par, Npar*sizeof(float));
-  ALLOCATE (fpar, float, MAX (Nfpar, 1));
-  bzero (fpar, Nfpar*sizeof(float));
-
-  par[0]  = get_variable_default ("Xg", 0);
-  par[1]  = get_variable_default ("Yg", 0);
-  par[2]  = get_variable_default ("Zpk", 10000);
-  par[3]  = get_variable_default ("Sg", 0.0);
-
-  fpar[0] = 2.35 / get_variable_default ("SXg", 15.0);
-  fpar[1] = 2.35 / get_variable_default ("SYg", 15.0);
-  fpar[2] = get_variable_default ("SXYg", 0.0);
-  fpar[3] = get_variable_default ("Sr", 1.0);
-  fpar[4] = get_variable_default ("Npow", 2.25);
-
-  sky = &par[3];
-}
-
-void QgaussCL () {
-  set_variable ("Xg",  par[0]);
-  set_variable ("Yg",  par[1]);
-  set_variable ("Zpk", par[2]);
-  set_variable ("Sg",  par[3]);
-}
-
-/* one component, two slopes: (1 + z^M + z^N)^(-1) -- x, y, sx, sy, sxy, I, sky, sr */
-float QgaussTD (float x, float y, float *par, int Npar, float *dpar) {
-
-  float X, Y, px, py;
-  float z, r, q, f;
-
-  X = x - par[0];
-  Y = y - par[1];
-  
-  px = fpar[0]*X;
-  py = fpar[1]*Y;
-
-  z = 0.5*SQ(px) + 0.5*SQ(py) + fpar[2]*X*Y;
-
-  r = 1.0 / (1 + fpar[3]*z + pow(z,fpar[4]));
-  f = par[2]*r + par[3];
-  q = par[2]*SQ(r)*(fpar[3] + fpar[4]*pow(z,(fpar[4]-1)));
-
-  if (dpar != NULL) {
-    dpar[0] = q*(2*px*fpar[0] + fpar[2]*Y);
-    dpar[1] = q*(2*py*fpar[1] + fpar[2]*X);
-    dpar[2] = +r;
-    dpar[3] = +1;
-  }
-  return (f);
-}
-
Index: unk/Ohana/src/opihi/cmd.astro/imfit-Sgauss.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/imfit-Sgauss.c	(revision 12839)
+++ 	(revision )
@@ -1,74 +1,0 @@
-# include "imfit.h"
-
-float SgaussTD (float, float, float *, int, float *);
-void  SgaussCL ();
-
-void Sgauss_setup (char *name) {
-
-  if (strcmp(name, "Sgauss")) return;
-
-  fitfunc = SgaussTD;
-  imfit_cleanup = SgaussCL;
-  Npar = 4;
-  Nfpar = 7;
-
-  /* allocate free and fixed parameters */
-  ALLOCATE (par, float, MAX (Npar, 1));
-  bzero (par, Npar*sizeof(float));
-  ALLOCATE (fpar, float, MAX (Nfpar, 1));
-  bzero (fpar, Nfpar*sizeof(float));
-
-  par[0] = get_variable_default ("Xg", 0);
-  par[1] = get_variable_default ("Yg", 0);
-  par[2] = get_variable_default ("Zpk", 10000);
-  par[3] = get_variable_default ("Sg", 0.0);
-
-  fpar[0] = 2.35 / get_variable_default ("SXg", 15.0);
-  fpar[1] = 2.35 / get_variable_default ("SYg", 15.0);
-  fpar[2] = get_variable_default ("SXYg", 0.0);
-  fpar[3] = 2.35 / get_variable_default ("SXf", 15.0);
-  fpar[4] = 2.35 / get_variable_default ("SYf", 15.0);
-  fpar[5] = get_variable_default ("SXYf", 0.0);
-  fpar[6] = get_variable_default ("Npow", 2.25);
-
-  sky = &par[3];
-}
-
-void SgaussCL () {
-  set_variable ("Xg",   par[0]);
-  set_variable ("Yg",   par[1]);
-  set_variable ("Zpk",  par[2]);
-  set_variable ("Sg",   par[3]);
-}
-
-/* two components: (1 + z_1 + z_2^N)^(-1) -- x, y, sx1, sy1, sxy1, I, sky, sx2, sy2, sxy2 */
-float SgaussTD (float x, float y, float *par, int Npar, float *dpar) {
-
-  float X, Y, px1, py1, px2, py2;
-  float z1, z2, r, q1, q2, f;
-
-  X = x - par[0];
-  Y = y - par[1];
-  
-  px1 = fpar[0]*X;
-  py1 = fpar[1]*Y;
-  px2 = fpar[3]*X;
-  py2 = fpar[4]*Y;
-
-  z1 = 0.5*SQ(px1) + 0.5*SQ(py1) + fpar[2]*X*Y;
-  z2 = 0.5*SQ(px2) + 0.5*SQ(py2) + fpar[5]*X*Y;
-
-  r = 1.0 / (1 + z1 + pow(z2,fpar[6]));
-  f = par[2]*r + par[3];
-
-  q1 = par[2]*SQ(r);
-  q2 = par[2]*SQ(r)*fpar[6]*pow(z2,(fpar[6]-1));
-
-  if (dpar != NULL) {
-    dpar[0] = q1*(2*px1*fpar[0] + fpar[2]*Y) + q2*(2*px2*fpar[3] + fpar[5]*Y);
-    dpar[1] = q1*(2*py1*fpar[1] + fpar[2]*X) + q2*(2*py2*fpar[4] + fpar[5]*X);
-    dpar[2] = +r;
-    dpar[3] = +1;
-  }
-  return (f);
-}
Index: /trunk/Ohana/src/opihi/cmd.astro/imfit-pgauss-psf.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/imfit-pgauss-psf.c	(revision 12840)
+++ /trunk/Ohana/src/opihi/cmd.astro/imfit-pgauss-psf.c	(revision 12840)
@@ -0,0 +1,66 @@
+# include "imfit.h"
+
+float pgauss_psfTD (float, float, float *, int, float *);
+void  pgauss_psfCL ();
+
+void  pgauss_psf_setup (char *name) {
+
+  if (strcmp(name, "pgauss_psf")) return;
+
+  fitfunc = pgauss_psfTD;
+  imfit_cleanup = pgauss_psfCL;
+  Npar = 4;
+  Nfpar = 3;
+
+  /* allocate free and fixed parameters */
+  ALLOCATE (par, float, MAX (Npar, 1));
+  bzero (par, Npar*sizeof(float));
+  ALLOCATE (fpar, float, MAX (Nfpar, 1));
+  bzero (fpar, Nfpar*sizeof(float));
+
+  par[0] = get_variable_default ("Xg", 0);
+  par[1] = get_variable_default ("Yg", 0);
+  par[2] = get_variable_default ("Zpk", 10000);
+  par[3] = get_variable_default ("Sg", 0.0);
+  sky = &par[3];
+
+  fpar[0] = 2.35 / get_variable_default ("SXg", 2.0);
+  fpar[1] = 2.35 / get_variable_default ("SYg", 2.0);
+  fpar[2] = get_variable_default ("SXYg", 0);
+}
+
+void pgauss_psfCL () {
+  set_variable ("Xg",   par[0]);
+  set_variable ("Yg",   par[1]);
+  set_variable ("Zpk",  par[2]);
+  set_variable ("Sg",   par[3]);
+}
+
+/* pseudo 2D gaussian -- x, y, (sx), (sy), (sxy), I, sky */
+float pgauss_psfTD (float x, float y, float *par, int Npar, float *dpar) {
+
+  float X, Y, px, py;
+  float z, r, q, f;
+
+  /* par -> fpar: (2,0), (3,1), (4,2) */
+
+  X = x - par[0];
+  Y = y - par[1];
+  
+  px = fpar[0]*X;
+  py = fpar[1]*Y;
+
+  z = 0.5*SQ(px) + 0.5*SQ(py) + fpar[2]*X*Y;
+  r = 1.0 / (1 + z + 0.5*z*z*(1 + z/3)); /* ~ exp (-Z) */
+  f = par[2]*r + par[3];
+  q = par[2]*r*r*(1 + z + 0.5*z*z);
+  /* note difference from gaussian: q = par[5]*r */
+
+  if (dpar != NULL) {
+    dpar[0] = q*(2*px*fpar[0] + fpar[2]*Y);
+    dpar[1] = q*(2*py*fpar[1] + fpar[2]*X);
+    dpar[2] = +r;
+    dpar[3] = +1;
+  }
+  return (f);
+}
Index: /trunk/Ohana/src/opihi/cmd.astro/imfit-qgauss-psf.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/imfit-qgauss-psf.c	(revision 12840)
+++ /trunk/Ohana/src/opihi/cmd.astro/imfit-qgauss-psf.c	(revision 12840)
@@ -0,0 +1,68 @@
+# include "imfit.h"
+
+float qgauss_psfTD (float, float, float *, int, float *);
+void  qgauss_psfCL ();
+
+void qgauss_psf_setup (char *name) {
+
+  if (strcmp(name, "qgauss_psf")) return;
+
+  fitfunc = qgauss_psfTD;
+  imfit_cleanup = qgauss_psfCL;
+  Npar = 4;
+  Nfpar = 5;
+
+  /* allocate free and fixed parameters */
+  ALLOCATE (par, float, MAX (Npar, 1));
+  bzero (par, Npar*sizeof(float));
+  ALLOCATE (fpar, float, MAX (Nfpar, 1));
+  bzero (fpar, Nfpar*sizeof(float));
+
+  par[0]  = get_variable_default ("Xg", 0);
+  par[1]  = get_variable_default ("Yg", 0);
+  par[2]  = get_variable_default ("Zpk", 10000);
+  par[3]  = get_variable_default ("Sg", 0.0);
+
+  fpar[0] = 2.35 / get_variable_default ("SXg", 15.0);
+  fpar[1] = 2.35 / get_variable_default ("SYg", 15.0);
+  fpar[2] = get_variable_default ("SXYg", 0.0);
+  fpar[3] = get_variable_default ("Sr", 1.0);
+  fpar[4] = get_variable_default ("Npow", 2.25);
+
+  sky = &par[3];
+}
+
+void qgauss_psfCL () {
+  set_variable ("Xg",  par[0]);
+  set_variable ("Yg",  par[1]);
+  set_variable ("Zpk", par[2]);
+  set_variable ("Sg",  par[3]);
+}
+
+/* one component, two slopes: (1 + z^M + z^N)^(-1) -- x, y, sx, sy, sxy, I, sky, sr */
+float qgauss_psfTD (float x, float y, float *par, int Npar, float *dpar) {
+
+  float X, Y, px, py;
+  float z, r, q, f;
+
+  X = x - par[0];
+  Y = y - par[1];
+  
+  px = fpar[0]*X;
+  py = fpar[1]*Y;
+
+  z = 0.5*SQ(px) + 0.5*SQ(py) + fpar[2]*X*Y;
+
+  r = 1.0 / (1 + fpar[3]*z + pow(z,fpar[4]));
+  f = par[2]*r + par[3];
+  q = par[2]*SQ(r)*(fpar[3] + fpar[4]*pow(z,(fpar[4]-1)));
+
+  if (dpar != NULL) {
+    dpar[0] = q*(2*px*fpar[0] + fpar[2]*Y);
+    dpar[1] = q*(2*py*fpar[1] + fpar[2]*X);
+    dpar[2] = +r;
+    dpar[3] = +1;
+  }
+  return (f);
+}
+
Index: /trunk/Ohana/src/opihi/cmd.astro/imfit-sgauss-psf.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/imfit-sgauss-psf.c	(revision 12840)
+++ /trunk/Ohana/src/opihi/cmd.astro/imfit-sgauss-psf.c	(revision 12840)
@@ -0,0 +1,74 @@
+# include "imfit.h"
+
+float sgauss_psfTD (float, float, float *, int, float *);
+void  sgauss_psfCL ();
+
+void sgauss_psf_setup (char *name) {
+
+  if (strcmp(name, "sgauss_psf")) return;
+
+  fitfunc = sgauss_psfTD;
+  imfit_cleanup = sgauss_psfCL;
+  Npar = 4;
+  Nfpar = 7;
+
+  /* allocate free and fixed parameters */
+  ALLOCATE (par, float, MAX (Npar, 1));
+  bzero (par, Npar*sizeof(float));
+  ALLOCATE (fpar, float, MAX (Nfpar, 1));
+  bzero (fpar, Nfpar*sizeof(float));
+
+  par[0] = get_variable_default ("Xg", 0);
+  par[1] = get_variable_default ("Yg", 0);
+  par[2] = get_variable_default ("Zpk", 10000);
+  par[3] = get_variable_default ("Sg", 0.0);
+
+  fpar[0] = 2.35 / get_variable_default ("SXg", 15.0);
+  fpar[1] = 2.35 / get_variable_default ("SYg", 15.0);
+  fpar[2] = get_variable_default ("SXYg", 0.0);
+  fpar[3] = 2.35 / get_variable_default ("SXf", 15.0);
+  fpar[4] = 2.35 / get_variable_default ("SYf", 15.0);
+  fpar[5] = get_variable_default ("SXYf", 0.0);
+  fpar[6] = get_variable_default ("Npow", 2.25);
+
+  sky = &par[3];
+}
+
+void sgauss_psfCL () {
+  set_variable ("Xg",   par[0]);
+  set_variable ("Yg",   par[1]);
+  set_variable ("Zpk",  par[2]);
+  set_variable ("Sg",   par[3]);
+}
+
+/* two components: (1 + z_1 + z_2^N)^(-1) -- x, y, sx1, sy1, sxy1, I, sky, sx2, sy2, sxy2 */
+float sgauss_psfTD (float x, float y, float *par, int Npar, float *dpar) {
+
+  float X, Y, px1, py1, px2, py2;
+  float z1, z2, r, q1, q2, f;
+
+  X = x - par[0];
+  Y = y - par[1];
+  
+  px1 = fpar[0]*X;
+  py1 = fpar[1]*Y;
+  px2 = fpar[3]*X;
+  py2 = fpar[4]*Y;
+
+  z1 = 0.5*SQ(px1) + 0.5*SQ(py1) + fpar[2]*X*Y;
+  z2 = 0.5*SQ(px2) + 0.5*SQ(py2) + fpar[5]*X*Y;
+
+  r = 1.0 / (1 + z1 + pow(z2,fpar[6]));
+  f = par[2]*r + par[3];
+
+  q1 = par[2]*SQ(r);
+  q2 = par[2]*SQ(r)*fpar[6]*pow(z2,(fpar[6]-1));
+
+  if (dpar != NULL) {
+    dpar[0] = q1*(2*px1*fpar[0] + fpar[2]*Y) + q2*(2*px2*fpar[3] + fpar[5]*Y);
+    dpar[1] = q1*(2*py1*fpar[1] + fpar[2]*X) + q2*(2*py2*fpar[4] + fpar[5]*X);
+    dpar[2] = +r;
+    dpar[3] = +1;
+  }
+  return (f);
+}
Index: /trunk/Ohana/src/opihi/cmd.astro/imfit-test.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/imfit-test.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/cmd.astro/imfit-test.c	(revision 12840)
@@ -31,5 +31,5 @@
       par[3] = tp1;
     }
-    if (fitfunc == SgaussTD) {
+    if (fitfunc == sgauss_psfTD) {
       tp1 = par[0];
       tp2 = par[3];
@@ -48,5 +48,5 @@
       par[4] = tp2;
     }
-    if (fitfunc == PgaussTD) {
+    if (fitfunc == pgauss_psfTD) {
       tp1 = par[0];
       par[0] = par[0]*1.05;
Index: /trunk/Ohana/src/opihi/cmd.astro/imfit.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/imfit.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/cmd.astro/imfit.c	(revision 12840)
@@ -57,9 +57,9 @@
     fgauss_setup (argv[N]);
     pgauss_setup (argv[N]);
-    Pgauss_setup (argv[N]);
+    pgauss_psf_setup (argv[N]);
     sgauss_setup (argv[N]);
-    Sgauss_setup (argv[N]);
+    sgauss_psf_setup (argv[N]);
     qgauss_setup (argv[N]);
-    Qgauss_setup (argv[N]);
+    qgauss_psf_setup (argv[N]);
     qfgauss_setup (argv[N]);
     qrgauss_setup (argv[N]);
Index: /trunk/Ohana/src/opihi/cmd.astro/imsub.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/imsub.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/cmd.astro/imsub.c	(revision 12840)
@@ -22,9 +22,9 @@
     fgauss_setup (argv[N]);
     pgauss_setup (argv[N]);
-    Pgauss_setup (argv[N]);
+    pgauss_psf_setup (argv[N]);
     sgauss_setup (argv[N]);
-    Sgauss_setup (argv[N]);
+    sgauss_psf_setup (argv[N]);
     qgauss_setup (argv[N]);
-    Qgauss_setup (argv[N]);
+    qgauss_psf_setup (argv[N]);
     qfgauss_setup (argv[N]);
     qrgauss_setup (argv[N]);
Index: /trunk/Ohana/src/opihi/dvo/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/dvo/Makefile	(revision 12839)
+++ /trunk/Ohana/src/opihi/dvo/Makefile	(revision 12840)
@@ -23,5 +23,5 @@
 $(SRC)/ImageSelection.$(ARCH).o	\
 $(SRC)/LoadImages.$(ARCH).o		\
-$(SRC)/cmpRead.$(ARCH).o		\
+$(SRC)/cmpReadFile.$(ARCH).o		\
 $(SRC)/compare.$(ARCH).o               \
 $(SRC)/match_image.$(ARCH).o		\
Index: unk/Ohana/src/opihi/dvo/cmpRead.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/cmpRead.c	(revision 12839)
+++ 	(revision )
@@ -1,125 +1,0 @@
-# include "dvoshell.h"
-# define D_NSTARS 1000
-# define BYTES_STAR 66
-# define BLOCK 1000
-
-CMPstars *cmpReadFits (FILE *f, int *nstars) {
-
-  int i, Nstars;
-  Header theader;
-  FTable table;
-  CMPstars *stars;
-  SMPData *smpdata;
-
-  /* if no stars, no table */
-  if (*nstars == 0) return (NULL);
-
-  /* init & load in table data */
-  table.header   = &theader;
-  if (!gfits_fread_ftable (f, &table, "SMPFILE")) goto escape;
-
-  smpdata = gfits_table_get_SMPData (&table, &Nstars, NULL);
-
-  ALLOCATE (stars, CMPstars, Nstars);
-  for (i = 0; i < Nstars; i++) {
-    stars[i].X      = smpdata[i].X;
-    stars[i].Y      = smpdata[i].Y;
-    stars[i].M      = smpdata[i].M;
-    stars[i].dM     = smpdata[i].dM;
-    stars[i].dophot = smpdata[i].dophot;
-
-    stars[i].Mgal   = smpdata[i].M;
-    stars[i].Map    = smpdata[i].dM;
-    stars[i].fx     = smpdata[i].fx;
-    stars[i].fy     = smpdata[i].fy;
-    stars[i].df     = smpdata[i].df;
-  }    
-  *nstars = Nstars;
-  return (stars);
-
-escape:
-  gprint (GP_ERR, "error reading file\n");
-  *nstars = 0;
-  return (NULL);
-}
-
-CMPstars *cmpReadText (FILE *f, int *nstars) {
-
-  int j, N, Nextra, Ninstar, Nskip, Nbytes, nbytes;
-  int done;
-  char *buffer, *c, *c2;
-  double tmp;
-  CMPstars *stars;
-  
-  /* load in stars by blocks of 1000 */
-  N = 0;
-  ALLOCATE (buffer, char, (BLOCK*BYTES_STAR) + 1);
-  buffer[BLOCK*BYTES_STAR] = 0;
-  Nextra = 0;
-
-  ALLOCATE (stars, CMPstars, *nstars);
-
-  while (N < *nstars) {
-    /* load next data block */
-    Nbytes = BYTES_STAR * BLOCK - Nextra;
-    nbytes = fread (&buffer[Nextra], 1, Nbytes, f);
-    if (nbytes == 0) {
-      *nstars = N;
-      return (stars);
-    }
-    nbytes += Nextra;
-
-    /* check line-by-line integrity */
-    c = buffer;
-    done = FALSE;
-    while ((c < buffer + nbytes) && (!done)) { 
-      for (c2 = c; *c2 == '\n'; c2++);
-      if (c2 > c) { /* extra return chars */
-	memmove (c, c2, (int)(buffer + nbytes - c2));
-	Nskip = c2 - c;
-	nbytes -= Nskip;
-	bzero (buffer + nbytes, Nskip);
-	/* if (VERBOSE) gprint (GP_ERR, "deleted %d extra return chars\n", Nskip); */
-      }
-      c2 = strchr (c, '\n');
-      if (c2 == (char *) NULL) {
-	done = TRUE;	
-	continue;
-      }
-      c2++;
-      if ((c2 - c) != BYTES_STAR) { /* bad line, delete it */
-	memmove (c, c2, (int)(buffer + nbytes - c2));
-	Nskip = c2 - c;
-	nbytes -= Nskip;
-	bzero (buffer + nbytes, Nskip);
-	/* if (VERBOSE) gprint (GP_ERR, "deleted line, %d extra chars\n", Nskip); */
-      } else {
-	c = c2;
-      }
-    }
-
-    /* extract data for stars */
-    Ninstar = nbytes / BYTES_STAR;
-    Nextra = nbytes % BYTES_STAR;
-    for (j = 0; (j < Ninstar) && (N < *nstars); j++, N++) {
-      dparse (&stars[N].X,  1, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].Y,  2, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].M,  3, &buffer[j*BYTES_STAR]);
-
-      /* cmp files carry dM in millimags */
-      dparse (&tmp, 4, &buffer[j*BYTES_STAR]);
-      stars[N].dM = 0.001*tmp;
-
-      dparse (&tmp,         5, &buffer[j*BYTES_STAR]);
-      stars[N].dophot = tmp;
-
-      dparse (&stars[N].Mgal, 7, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].Map,  8, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].fx,   9, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].fy,  10, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].df,  11, &buffer[j*BYTES_STAR]);
-    }
-  }
-  *nstars = N;
-  return (stars);
-}
Index: /trunk/Ohana/src/opihi/dvo/cmpReadFile.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/cmpReadFile.c	(revision 12840)
+++ /trunk/Ohana/src/opihi/dvo/cmpReadFile.c	(revision 12840)
@@ -0,0 +1,125 @@
+# include "dvoshell.h"
+# define D_NSTARS 1000
+# define BYTES_STAR 66
+# define BLOCK 1000
+
+CMPstars *cmpReadFits (FILE *f, int *nstars) {
+
+  int i, Nstars;
+  Header theader;
+  FTable table;
+  CMPstars *stars;
+  SMPData *smpdata;
+
+  /* if no stars, no table */
+  if (*nstars == 0) return (NULL);
+
+  /* init & load in table data */
+  table.header   = &theader;
+  if (!gfits_fread_ftable (f, &table, "SMPFILE")) goto escape;
+
+  smpdata = gfits_table_get_SMPData (&table, &Nstars, NULL);
+
+  ALLOCATE (stars, CMPstars, Nstars);
+  for (i = 0; i < Nstars; i++) {
+    stars[i].X      = smpdata[i].X;
+    stars[i].Y      = smpdata[i].Y;
+    stars[i].M      = smpdata[i].M;
+    stars[i].dM     = smpdata[i].dM;
+    stars[i].dophot = smpdata[i].dophot;
+
+    stars[i].Mgal   = smpdata[i].M;
+    stars[i].Map    = smpdata[i].dM;
+    stars[i].fx     = smpdata[i].fx;
+    stars[i].fy     = smpdata[i].fy;
+    stars[i].df     = smpdata[i].df;
+  }    
+  *nstars = Nstars;
+  return (stars);
+
+escape:
+  gprint (GP_ERR, "error reading file\n");
+  *nstars = 0;
+  return (NULL);
+}
+
+CMPstars *cmpReadText (FILE *f, int *nstars) {
+
+  int j, N, Nextra, Ninstar, Nskip, Nbytes, nbytes;
+  int done;
+  char *buffer, *c, *c2;
+  double tmp;
+  CMPstars *stars;
+  
+  /* load in stars by blocks of 1000 */
+  N = 0;
+  ALLOCATE (buffer, char, (BLOCK*BYTES_STAR) + 1);
+  buffer[BLOCK*BYTES_STAR] = 0;
+  Nextra = 0;
+
+  ALLOCATE (stars, CMPstars, *nstars);
+
+  while (N < *nstars) {
+    /* load next data block */
+    Nbytes = BYTES_STAR * BLOCK - Nextra;
+    nbytes = fread (&buffer[Nextra], 1, Nbytes, f);
+    if (nbytes == 0) {
+      *nstars = N;
+      return (stars);
+    }
+    nbytes += Nextra;
+
+    /* check line-by-line integrity */
+    c = buffer;
+    done = FALSE;
+    while ((c < buffer + nbytes) && (!done)) { 
+      for (c2 = c; *c2 == '\n'; c2++);
+      if (c2 > c) { /* extra return chars */
+	memmove (c, c2, (int)(buffer + nbytes - c2));
+	Nskip = c2 - c;
+	nbytes -= Nskip;
+	bzero (buffer + nbytes, Nskip);
+	/* if (VERBOSE) gprint (GP_ERR, "deleted %d extra return chars\n", Nskip); */
+      }
+      c2 = strchr (c, '\n');
+      if (c2 == (char *) NULL) {
+	done = TRUE;	
+	continue;
+      }
+      c2++;
+      if ((c2 - c) != BYTES_STAR) { /* bad line, delete it */
+	memmove (c, c2, (int)(buffer + nbytes - c2));
+	Nskip = c2 - c;
+	nbytes -= Nskip;
+	bzero (buffer + nbytes, Nskip);
+	/* if (VERBOSE) gprint (GP_ERR, "deleted line, %d extra chars\n", Nskip); */
+      } else {
+	c = c2;
+      }
+    }
+
+    /* extract data for stars */
+    Ninstar = nbytes / BYTES_STAR;
+    Nextra = nbytes % BYTES_STAR;
+    for (j = 0; (j < Ninstar) && (N < *nstars); j++, N++) {
+      dparse (&stars[N].X,  1, &buffer[j*BYTES_STAR]);
+      dparse (&stars[N].Y,  2, &buffer[j*BYTES_STAR]);
+      dparse (&stars[N].M,  3, &buffer[j*BYTES_STAR]);
+
+      /* cmp files carry dM in millimags */
+      dparse (&tmp, 4, &buffer[j*BYTES_STAR]);
+      stars[N].dM = 0.001*tmp;
+
+      dparse (&tmp,         5, &buffer[j*BYTES_STAR]);
+      stars[N].dophot = tmp;
+
+      dparse (&stars[N].Mgal, 7, &buffer[j*BYTES_STAR]);
+      dparse (&stars[N].Map,  8, &buffer[j*BYTES_STAR]);
+      dparse (&stars[N].fx,   9, &buffer[j*BYTES_STAR]);
+      dparse (&stars[N].fy,  10, &buffer[j*BYTES_STAR]);
+      dparse (&stars[N].df,  11, &buffer[j*BYTES_STAR]);
+    }
+  }
+  *nstars = N;
+  return (stars);
+}
Index: /trunk/Ohana/src/opihi/include/pantasks.h
===================================================================
--- /trunk/Ohana/src/opihi/include/pantasks.h	(revision 12839)
+++ /trunk/Ohana/src/opihi/include/pantasks.h	(revision 12840)
@@ -138,16 +138,17 @@
   Task   *task;
 
-  IOBuffer    stdout;			/* stdout storage buffer */
-  IOBuffer    stderr;			/* stderr storage buffer */
+  /* this cries out for another structure... */
+  IOBuffer    stdout_buff;    /* stdout storage buffer */
+  char       *stdout_dump;    // output target file for stdout
+  int         stdout_size;    /* size of pending stdout buffer (controller) */
+  int         stdout_fd;      /* stdout pipe (local only) */
+
+  IOBuffer    stderr_buff;    /* stderr storage buffer */
+  char       *stderr_dump;    // output target file for stderr
+  int         stderr_size;    /* size of pending stderr buffer (controller) */
+  int         stderr_fd;      /* stderr pipe (local only) */
+
   JobMode     mode;			/* local or controller? */
-
-  char   *stdout_dump;
-  char   *stderr_dump;
   char   *realhost;
-
-  int         stdout_size;		/* size of pending stdout buffer (controller) */
-  int         stderr_size;		/* size of pending stderr buffer (controller) */
-  int         stdout_fd;		/* stdout pipe (local only) */
-  int         stderr_fd;		/* stderr pipe (local only) */
 
   double dtime;
Index: /trunk/Ohana/src/opihi/include/pcontrol.h
===================================================================
--- /trunk/Ohana/src/opihi/include/pcontrol.h	(revision 12839)
+++ /trunk/Ohana/src/opihi/include/pcontrol.h	(revision 12840)
@@ -75,6 +75,6 @@
   JobStat      state;
   JobStat      stack;
-  IOBuffer     stdout;
-  IOBuffer     stderr;
+  IOBuffer     stdout_buff;
+  IOBuffer     stderr_buff;
   Ptime        start;
   Ptime        stop;
@@ -88,7 +88,7 @@
 typedef struct {
   char       *hostname;
-  int         stdin;
-  int         stdout;
-  int         stderr;
+  int         stdin_fd;
+  int         stdout_fd;
+  int         stderr_fd;
   int         markoff;
   int         pid;
Index: /trunk/Ohana/src/opihi/pantasks/CheckJobs.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/CheckJobs.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pantasks/CheckJobs.c	(revision 12840)
@@ -48,6 +48,6 @@
 	/* push output buffer data to the stdout and stderr queues */
 	/* XXX this will break on 0 values in output streams */
-	PushNamedQueue ("stdout", job[0].stdout.buffer);
-	PushNamedQueue ("stderr", job[0].stderr.buffer);
+	PushNamedQueue ("stdout", job[0].stdout_buff.buffer);
+	PushNamedQueue ("stderr", job[0].stderr_buff.buffer);
 
 	/* save the stdout and stderr if desired */
@@ -57,5 +57,5 @@
 	    gprint (GP_ERR, "unable to open stdout dump file %s\n", job[0].stdout_dump);
 	  } else {
-	    fwrite (job[0].stdout.buffer, 1, job[0].stdout.Nbuffer, f);
+	    fwrite (job[0].stdout_buff.buffer, 1, job[0].stdout_buff.Nbuffer, f);
 	    fclose (f);
 	  }
@@ -66,5 +66,5 @@
 	    gprint (GP_ERR, "unable to open stderr dump file %s\n", job[0].stderr_dump);
 	  } else {
-	    fwrite (job[0].stderr.buffer, 1, job[0].stderr.Nbuffer, f);
+	    fwrite (job[0].stderr_buff.buffer, 1, job[0].stderr_buff.Nbuffer, f);
 	    fclose (f);
 	  }
Index: /trunk/Ohana/src/opihi/pantasks/ControllerOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 12840)
@@ -29,5 +29,5 @@
   if ((job[0].state == JOB_EXIT) || (job[0].state == JOB_CRASH)) {
     gettimeofday (&start, (void *) NULL);
-    GetJobOutput ("stdout", job[0].pid, &job[0].stdout, job[0].stdout_size);
+    GetJobOutput ("stdout", job[0].pid, &job[0].stdout_buff, job[0].stdout_size);
     gettimeofday (&stop, (void *) NULL);
     dtime = DTIME (stop, start);
@@ -35,5 +35,5 @@
 
     gettimeofday (&start, (void *) NULL);
-    GetJobOutput ("stderr", job[0].pid, &job[0].stderr, job[0].stderr_size);
+    GetJobOutput ("stderr", job[0].pid, &job[0].stderr_buff, job[0].stderr_size);
     gettimeofday (&stop, (void *) NULL);
     dtime = DTIME (stop, start);
Index: /trunk/Ohana/src/opihi/pantasks/JobOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/JobOps.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pantasks/JobOps.c	(revision 12840)
@@ -143,6 +143,6 @@
      need to have matched entries to these quantites in the job structure */
 
-  InitIOBuffer (&job[0].stdout, 0x100);
-  InitIOBuffer (&job[0].stderr, 0x100);
+  InitIOBuffer (&job[0].stdout_buff, 0x100);
+  InitIOBuffer (&job[0].stderr_buff, 0x100);
 
   job[0].stdout_dump = NULL;
@@ -181,6 +181,6 @@
   if (job[0].stderr_dump != NULL) free (job[0].stderr_dump);
 
-  FreeIOBuffer (&job[0].stdout);
-  FreeIOBuffer (&job[0].stderr);
+  FreeIOBuffer (&job[0].stdout_buff);
+  FreeIOBuffer (&job[0].stderr_buff);
   free (job);
   return;
Index: /trunk/Ohana/src/opihi/pantasks/LocalJob.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/LocalJob.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pantasks/LocalJob.c	(revision 12840)
@@ -15,11 +15,11 @@
 
   if ((job[0].state == JOB_EXIT) || (job[0].state == JOB_CRASH)) {
-    EmptyIOBuffer (&job[0].stdout, 10, job[0].stdout_fd);
-    EmptyIOBuffer (&job[0].stderr, 10, job[0].stderr_fd);
+    EmptyIOBuffer (&job[0].stdout_buff, 10, job[0].stdout_fd);
+    EmptyIOBuffer (&job[0].stderr_buff, 10, job[0].stderr_fd);
     close (job[0].stdout_fd);
     close (job[0].stderr_fd);
   } else {
     /* read stdout buffer */
-    Nread = ReadtoIOBuffer (&job[0].stdout, job[0].stdout_fd);
+    Nread = ReadtoIOBuffer (&job[0].stdout_buff, job[0].stdout_fd);
     switch (Nread) {
       case -2:  /* error in read (programming error?  system level error?) */
@@ -34,5 +34,5 @@
   
     /* read stderr buffer */
-    Nread = ReadtoIOBuffer (&job[0].stderr, job[0].stderr_fd);
+    Nread = ReadtoIOBuffer (&job[0].stderr_buff, job[0].stderr_fd);
     switch (Nread) {
       case -2:  /* error in read (programming error?  system level error?) */
Index: /trunk/Ohana/src/opihi/pclient/ChildOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pclient/ChildOps.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pclient/ChildOps.c	(revision 12840)
@@ -3,5 +3,5 @@
 #include <sys/types.h>
 #include <unistd.h>
-#include <stropts.h>
+// #include <stropts.h>
 
 static int Nbad = 0;
Index: /trunk/Ohana/src/opihi/pcontrol/CheckDoneJob.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/CheckDoneJob.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pcontrol/CheckDoneJob.c	(revision 12840)
@@ -12,6 +12,6 @@
 
   success = TRUE;
-  success &= GetJobOutput ("stdout", host, &job[0].stdout, job[0].stdout_size);
-  success &= GetJobOutput ("stderr", host, &job[0].stderr, job[0].stderr_size);
+  success &= GetJobOutput ("stdout", host, &job[0].stdout_buff, job[0].stdout_size);
+  success &= GetJobOutput ("stderr", host, &job[0].stderr_buff, job[0].stderr_size);
 
   if (!success) {
Index: /trunk/Ohana/src/opihi/pcontrol/GetJobOutput.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/GetJobOutput.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pcontrol/GetJobOutput.c	(revision 12840)
@@ -14,5 +14,5 @@
 
   /* flush any earlier messages */
-  ReadtoIOBuffer (buffer, host[0].stdout);
+  ReadtoIOBuffer (buffer, host[0].stdout_fd);
   FlushIOBuffer (buffer);
   Nstart = buffer[0].Nbuffer;
@@ -23,5 +23,5 @@
 
   /* send cmd (stdout / stderr) */
-  status = write_fmt (host[0].stdin, "%s\n", cmd);
+  status = write_fmt (host[0].stdin_fd, "%s\n", cmd);
 
   /* is pipe still open? */
@@ -32,5 +32,5 @@
   status = -1;
   for (i = 0; (i < PCLIENT_TIMEOUT) && (status != 0) && (line == NULL); i++) {
-    status = ReadtoIOBuffer (buffer, host[0].stdout);
+    status = ReadtoIOBuffer (buffer, host[0].stdout_fd);
     if ((buffer[0].Nbuffer - Nstart) >= Nbytes) {
       line = memstr (buffer[0].buffer, PCLIENT_PROMPT, buffer[0].Nbuffer);
Index: /trunk/Ohana/src/opihi/pcontrol/HostOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/HostOps.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pcontrol/HostOps.c	(revision 12840)
@@ -151,9 +151,9 @@
   ALLOCATE (host, Host, 1);
 
-  host[0].hostname = strcreate (hostname);
-  host[0].stdin    = 0;
-  host[0].stdout   = 0;
-  host[0].stderr   = 0;
-  host[0].HostID   = NextHostID();
+  host[0].hostname  = strcreate (hostname);
+  host[0].stdin_fd  = 0;
+  host[0].stdout_fd = 0;
+  host[0].stderr_fd = 0;
+  host[0].HostID    = NextHostID();
 
   host[0].lasttry.tv_sec = 0;
Index: /trunk/Ohana/src/opihi/pcontrol/JobOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/JobOps.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pcontrol/JobOps.c	(revision 12840)
@@ -148,6 +148,6 @@
 
   /* do this step on start? */
-  InitIOBuffer (&job[0].stdout, 0x1000);
-  InitIOBuffer (&job[0].stderr, 0x1000);
+  InitIOBuffer (&job[0].stdout_buff, 0x1000);
+  InitIOBuffer (&job[0].stderr_buff, 0x1000);
 
   JobID = job[0].JobID;
@@ -167,6 +167,6 @@
   FREE (job[0].argv);
 
-  FreeIOBuffer (&job[0].stdout);
-  FreeIOBuffer (&job[0].stderr);
+  FreeIOBuffer (&job[0].stdout_buff);
+  FreeIOBuffer (&job[0].stderr_buff);
 
   FREE (job);
Index: /trunk/Ohana/src/opihi/pcontrol/PclientCommand.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/PclientCommand.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pcontrol/PclientCommand.c	(revision 12840)
@@ -19,11 +19,11 @@
 
   // flush the stdout and stderr buffers here
-  ReadtoIOBuffer (buffer, host[0].stdout);
+  ReadtoIOBuffer (buffer, host[0].stdout_fd);
   FlushIOBuffer (buffer);
-  ReadtoIOBuffer (buffer, host[0].stderr);
+  ReadtoIOBuffer (buffer, host[0].stderr_fd);
   FlushIOBuffer (buffer);
 
   /* send command to client (adding on \n) */
-  status = write_fmt (host[0].stdin, "%s\n", command);
+  status = write_fmt (host[0].stdin_fd, "%s\n", command);
 
   /* is pipe still open? */
@@ -37,5 +37,5 @@
   status = -1;
   for (i = 0; (i < PCLIENT_TIMEOUT) && (status != 0) && (line == NULL); i++) {
-    status = ReadtoIOBuffer (buffer, host[0].stdout);
+    status = ReadtoIOBuffer (buffer, host[0].stdout_fd);
     line = memstr (buffer[0].buffer, response, buffer[0].Nbuffer);
     if (status == -1) nanosleep (&request, &remain);
Index: /trunk/Ohana/src/opihi/pcontrol/StartHost.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/StartHost.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pcontrol/StartHost.c	(revision 12840)
@@ -39,8 +39,8 @@
   host[0].lasttry.tv_usec = 0;
 
-  host[0].stdin  = stdio[0];
-  host[0].stdout = stdio[1];
-  host[0].stderr = stdio[2];
-  host[0].pid    = pid;
+  host[0].stdin_fd  = stdio[0];
+  host[0].stdout_fd = stdio[1];
+  host[0].stderr_fd = stdio[2];
+  host[0].pid       = pid;
   PutHost (host, PCONTROL_HOST_IDLE, STACK_BOTTOM);
   return (TRUE);
Index: /trunk/Ohana/src/opihi/pcontrol/StopHosts.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/StopHosts.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pcontrol/StopHosts.c	(revision 12840)
@@ -2,7 +2,7 @@
 
 void DownHost (Host *host) {
-  CLOSE (host[0].stdin);
-  CLOSE (host[0].stdout);
-  CLOSE (host[0].stderr);
+  CLOSE (host[0].stdin_fd);
+  CLOSE (host[0].stdout_fd);
+  CLOSE (host[0].stderr_fd);
   host[0].job = NULL;
   PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
@@ -10,7 +10,7 @@
 
 void OffHost (Host *host) {
-  CLOSE (host[0].stdin);
-  CLOSE (host[0].stdout);
-  CLOSE (host[0].stderr);
+  CLOSE (host[0].stdin_fd);
+  CLOSE (host[0].stdout_fd);
+  CLOSE (host[0].stderr_fd);
   host[0].job = NULL;
   PutHost (host, PCONTROL_HOST_OFF, STACK_BOTTOM);
Index: /trunk/Ohana/src/opihi/pcontrol/stdout.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/stdout.c	(revision 12839)
+++ /trunk/Ohana/src/opihi/pcontrol/stdout.c	(revision 12840)
@@ -29,5 +29,5 @@
 
 found_stdout:
-  buffer = &job[0].stdout;
+  buffer = &job[0].stdout_buff;
   fwrite (buffer[0].buffer, 1, buffer[0].Nbuffer, stdout);
   gprint (GP_LOG, "STATUS %d\n", 0);
@@ -64,5 +64,5 @@
 
 found_stderr:
-  buffer = &job[0].stderr;
+  buffer = &job[0].stderr_buff;
   fwrite (buffer[0].buffer, 1, buffer[0].Nbuffer, stdout);
   gprint (GP_LOG, "STATUS %d\n", 0);
