Index: trunk/Ohana/src/opihi/dvo/mextract.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/mextract.c	(revision 5320)
+++ trunk/Ohana/src/opihi/dvo/mextract.c	(revision 5451)
@@ -4,15 +4,14 @@
   
   int i, j, k, m, N, N1, NPTS;
-  int param, mode, Nregions, Nsec;
-  char filename[128], catdir[256], *RegionName, *RegionList, *p;
+  int param, mode, Nsec;
+  char *RegionName, *RegionList, *p;
   double *M1;
 
   PhotCode *code;
   Catalog catalog;
-  RegionFile *regions;
+  SkyList *skylist;
   Vector *vec;
 
   /* defaults */
-  regions = NULL;
   catalog.average = (Average *) NULL; 
   catalog.secfilt = (SecFilt *) NULL;
@@ -26,7 +25,4 @@
   if (!InitPhotcodes ()) goto escape;
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* interpret command-line options */
@@ -51,6 +47,6 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
-  if (!SetImageSelection (param)) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
+  if (!SetImageSelection (param, ((RegionName == NULL) && (RegionList == NULL)))) goto escape;
 
   /* create storage vector */
@@ -59,8 +55,6 @@
   if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto escape;
 
-  for (i = 0; i < Nregions; i++) {
-    /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[i].name);
-    catalog.filename = filename;
+  for (i = 0; i < skylist[0].Nregions; i++) {
+    catalog.filename = (char *) skylist[0].regions[i][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
     case 2:
@@ -97,6 +91,8 @@
   REALLOCATE (vec[0].elements, float, MAX(1,N));
 
-  if (regions != NULL) free (regions);
   FreeImageSelection ();
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
+  if (RegionName != NULL) free (RegionName);
+  if (RegionList != NULL) free (RegionList);
   return (TRUE);
 
@@ -108,5 +104,5 @@
 escape:
   FreeImageSelection ();
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   if (catalog.average != NULL) free (catalog.average);
   if (catalog.secfilt != NULL) free (catalog.secfilt);
