Index: /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/Makefile
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/Makefile	(revision 33238)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/Makefile	(revision 33239)
@@ -95,5 +95,6 @@
 $(SRC)/match_image.$(ARCH).o		\
 $(SRC)/db_utils.$(ARCH).o		\
-$(SRC)/convert.$(ARCH).o
+$(SRC)/convert.$(ARCH).o                \
+$(SRC)/HostTable.$(ARCH).o
 
 
Index: /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/include/dvo.h
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/include/dvo.h	(revision 33238)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/include/dvo.h	(revision 33239)
@@ -219,4 +219,33 @@
 } FlatCorrectionTable;
 
+/* definitions for parallel dvo host information 
+   XXX : need better names (safer namespace)
+ */
+
+typedef enum {
+    MODE_NONE = 0,
+    MODE_OUT  = 1,
+    MODE_IN   = 2,
+} ModeType;
+
+typedef enum {
+  DATA_ON_TGT = 0x01,
+  DATA_COPY_FAILURE = 0x02,
+} SkyTableDataFlags;
+
+typedef struct {
+  char *hostname;	      // name of remote machine
+  char *pathname;	      // name of directory for this machine's data
+  int hostID;		      // remove machine ID in SkyTable
+  int stdio[3]; 	      // fd's for communication with the remote host
+  int pid;		      // remote process ID
+} HostInfo;
+
+typedef struct {
+  int Nhosts;
+  HostInfo *hosts;
+  unsigned short *index;
+} HostTable;
+
 // special-case function:
 CMF_PS1_V2 *gfits_table_get_CMF_PS1_V1_Alt (FTable *ftable, off_t *Ndata, char *swapped);
@@ -551,3 +580,6 @@
 #endif
 
+// functions for parallel DVO
+HostTable    *HostTableLoad (char *catdir, char *rootname);
+
 # endif
Index: /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/HostTable.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/HostTable.c	(revision 33239)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/HostTable.c	(revision 33239)
@@ -0,0 +1,115 @@
+# include "dvo.h"
+
+void InitHosts (HostInfo *hosts, int Nhosts, int NHOSTS) {
+
+  int i;
+  for (i = Nhosts; i < NHOSTS; i++) {
+    hosts[i].hostname = NULL;
+    hosts[i].pathname = NULL;
+    hosts[i].stdio[0] = -1;
+    hosts[i].stdio[1] = -1;
+    hosts[i].stdio[2] = -1;
+    hosts[i].pid = 0;
+  }
+  return;
+}
+
+void FreeHosts (HostInfo *hosts, int Nhosts) {
+
+  int i;
+  for (i = 0; i < Nhosts; i++) {
+    free (hosts[i].hostname);
+    free (hosts[i].pathname);
+  }
+  free (hosts);
+  return;
+}
+
+HostTable *HostTableLoad (char *catdir, char *rootname) {
+
+  int i, Nline;
+
+  char *filename = NULL;
+
+  ALLOCATE (filename, char, strlen(catdir) + strlen(rootname) + 2); // one slash and one EOL
+  sprintf (filename, "%s/%s", catdir, rootname);
+
+  FILE *f = fopen (filename, "r");
+  if (!f) {
+    fprintf (stderr, "failed to open host table %s\n", filename);
+    return NULL;
+  }
+
+  // simple format: ID hostname pathname
+  
+  int NHOSTS = 16;
+  int Nhosts = 0;
+  HostInfo *hosts = NULL;
+  ALLOCATE (hosts, HostInfo, NHOSTS);
+  InitHosts (hosts, Nhosts, NHOSTS);
+
+  int maxID = 0;
+
+  for (Nline = 0; TRUE; Nline ++) {
+    int ID;
+    char tmphost[1024];
+    char tmppath[1024];
+    char line[1024];
+
+    // XXXX use this for safety: int status = scan_line_maxlen (f, line, 1024);
+    int status = scan_line (f, line);
+    if (status == EOF) break;
+
+    // find first non-whitespace char & skip commented lines
+    for (i = 0; OHANA_WHITESPACE (line[i]); i++);
+    if (line[i] == '#') continue;
+
+    status = sscanf (line, "%d %1023s %1023s", &ID, tmphost, tmppath);
+    if (status != 3) {
+      fprintf (stderr, "error reading line %d of host table %s\n", Nline, filename);
+      FreeHosts (hosts, Nhosts);
+      return NULL;
+    }
+
+    // check the validity of ID (0 < ID < MAX_SHORT)
+
+    if (ID < 1) {
+      fprintf (stderr, "invalid host ID %d\n", ID);
+      exit (1);
+    }
+    if (ID > 255) {
+      fprintf (stderr, "invalid host ID %d\n", ID);
+      exit (1);
+    }
+    maxID = MAX(maxID, ID);
+
+    hosts[Nhosts].hostID = ID;
+    hosts[Nhosts].hostname = strcreate(tmphost);
+    hosts[Nhosts].pathname = strcreate(tmppath);
+    
+    Nhosts ++;
+    if (Nhosts >= NHOSTS) {
+      NHOSTS += 16;
+      REALLOCATE (hosts, HostInfo, NHOSTS);
+      InitHosts (hosts, Nhosts, NHOSTS);
+    }
+  }    
+
+  HostTable *table = NULL;
+  ALLOCATE (table, HostTable, 1);
+  table->Nhosts = Nhosts;
+  table->hosts = hosts;
+
+  ALLOCATE (table->index, unsigned short, maxID + 1);
+  for (i = 0; i <= maxID; i++) table->index[i] = -1;
+
+  for (i = 0; i < table->Nhosts; i++) {
+    if (table->index[table->hosts[i].hostID] == -1) {
+      fprintf (stderr, "error: duplicate hostID %d\n", table->hosts[i].hostID);
+      exit (1);
+    }
+    table->index[table->hosts[i].hostID] = i;
+  }
+
+  return table;
+}
