Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/CopyToHostLocation.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/CopyToHostLocation.c	(revision 33204)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/CopyToHostLocation.c	(revision 33205)
@@ -18,66 +18,71 @@
   for (i = 0; i < skylist->Nregions; i++) {
     
-    // assign or re-assign? if a region is already assigned, do we keep it?
+    // move each table from CATDIR/name to table->hosts[].pathname/name
 
-    // unassigned
+    // XXX assign or re-assign? if a region is already assigned, do we keep it?
+
+    // skip unassigned tables
     if (!skylist->regions[i]->hostID) continue;
-    if (skylist->regions[i]->hostID < 0) continue;
 
+    // find the host for the table
     short index = table->index[skylist->regions[i]->hostID];
     HostInfo *host = &table->hosts[index];
 
-    // move from CATDIR/name to table->hosts[].pathname/name
-    sprintf (srcname, "%s/%s", CATDIR, skylist->regions[i]->name);
-    sprintf (tgtname, "%s/%s", host->pathname, skylist->regions[i]->name);
+    char extname[4][16] = {"cpm", "cpt", "cps", "cpn"};
+    for (j = 0; j < 4; j++) {
 
-    // does srcname exist & can it be read?
+	// set the in and out table names
+	sprintf (srcname, "%s/%s.%s", CATDIR, skylist->regions[i]->name, extname);
+	sprintf (tgtname, "%s/%s.%s", host->pathname, skylist->regions[i]->name, extname);
 
-    // check permission to read file 
-    int status = stat (srcname, &filestat);
-    if (!status) continue;  // file does not exist (check error stats for other issues?)
+	// does srcname exist & can it be read?
+
+	// check permission to read file 
+	int status = stat (srcname, &filestat);
+	if (!status) continue;  // file does not exist (check error stats for other issues?)
     
-    // can we read the file
-    if (uid == filestat.st_uid) {
-      if (filestat.st_mode & S_IRUSR) goto valid;
-    }
-    if (gid == filestat.st_gid) {
-      if (filestat.st_mode & S_IRGRP) goto valid;
-    }
-    if (filestat.st_mode & S_IROTH) goto valid;
+	// can we read the file
+	if (uid == filestat.st_uid) {
+	    if (filestat.st_mode & S_IRUSR) goto valid;
+	}
+	if (gid == filestat.st_gid) {
+	    if (filestat.st_mode & S_IRGRP) goto valid;
+	}
+	if (filestat.st_mode & S_IROTH) goto valid;
     
-    fprintf (stderr, "cannot read file %s, skipping\n", srcname);
-    continue;
+	fprintf (stderr, "cannot read file %s, skipping\n", srcname);
+	continue;
 
-  valid:
-    // since we have to open and read the whole file anyway, 
-    // perhaps we should just write the output file?
+    valid:
+	// XXX since we have to open and read the whole file anyway, 
+	// XXX perhaps we should just write the output file?
+	
+	// read srcname, write to tgtname, get MD5 sum for srcname as we go:
+	
+	// open the src file
+	FILE *fInput = fopen (srcname, "r");
+	int fdInput = fileno (fInput);
+	
+	// open the tgt file
+	FILE *fOutput = fopen (tgtname, "w");
+	int fdOutput = fileno (fOutput);
 
-    // read srcname, write to tgtname, get MD5 sum for srcname as we go:
+	int n;
+	MD5_CTX c;
+	char buf[512];
+	ssize_t nbytes;
 
-    // open the src file
-    FILE *fInput = fopen (srcname, "r");
-    int fdInput = fileno (fInput);
+	MD5_Init(&c);
+	while ((nbytes = read (fd, buf, 512)) > 0) {
+	    MD5_Update(&c, buf, nbytes);
+	    nbytes = write (fd, buf, 512);
+	}
+	MD5_Final(out, &c);
 
-    // open the tgt file
-    FILE *fOutput = fopen (srcname, "w");
-    int fdOutput = fileno (fInput);
-
-    int n;
-    MD5_CTX c;
-    char buf[512];
-    ssize_t nbytes;
-
-    MD5_Init(&c);
-    for (; (nbytes = read (fd, buf, 512)) > 0;) {
-      MD5_Update(&c, buf, nbytes);
-      nbytes = write (fd, buf, 512);
-    }
-    MD5_Final(out, &c);
-
-    for (n = 0; n < MD5_DIGEST_LENGTH; n++) {
-      fprintf (stderr, "%02x", out[n]);
-    }
-    fclose (f);
-    flush (f);
+	for (n = 0; n < MD5_DIGEST_LENGTH; n++) {
+	    fprintf (stderr, "%02x", out[n]);
+	}
+	fclose (f);
+	flush (f);
 
     // need to re-open and re-read tgtname to check md5sum
