Index: trunk/Ohana/src/opihi/dvo/calmextract.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/calmextract.c	(revision 5320)
+++ trunk/Ohana/src/opihi/dvo/calmextract.c	(revision 5451)
@@ -7,15 +7,14 @@
   
   int i, j, k, m, N, N1, Nr, mode[2];
-  int NSTAR, Nstar, Nsec, Nregions;
-  char filename[256], catdir[256], *RegionName, *RegionList;
+  int NSTAR, Nstar, Nsec;
+  char *RegionName, *RegionList;
   double *M1, M2, dM2, color;
 
   Catalog catalog;
-  RegionFile *regions;
   PhotCode *code[2];
+  SkyList *skylist;
   Vector **vec;
 
   /* these need to be freed in the end */
-  regions = NULL;
   catalog.average = NULL; 
   catalog.secfilt = NULL;
@@ -28,7 +27,4 @@
   if (!InitPhotcodes ()) goto escape;
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* command line arguments */
@@ -71,13 +67,12 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
-  if (!SetImageSelection (MEAS_XMOSAIC)) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
+  if (!SetImageSelection (MEAS_XMOSAIC, ((RegionName == NULL) && (RegionList == NULL)))) goto escape;
 
-  for (Nr = 0; Nr < Nregions; Nr++) {
+  for (Nr = 0; Nr < skylist[0].Nregions; Nr++) {
     if (Nr && !(Nr % 500)) { fprintf (stderr, "."); }
 
     /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[Nr].name);
-    catalog.filename = filename;
+    catalog.filename = (char *) skylist[0].regions[Nr][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
     case 2:
@@ -153,5 +148,6 @@
     catalog.measure = (Measure *) NULL;
   }
-  if (regions != NULL) free (regions);  
+
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   for (i = 0; i < NVEC; i++) {
     vec[i][0].Nelements = N;
@@ -167,5 +163,5 @@
   
   FreeImageSelection ();
-  if (regions != NULL) free (regions);  
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   for (i = 0; i < NVEC; i++) {
     DeleteVector (vec[i]);
