# include "imregister.h"
# include "spreg.h"
static char *version = "imsearch $Revision: 1.1.1.1 $";

int main (int argc, char **argv) {
 
  int status, Nmatch;
  int *match;

  get_version (argc, argv, version);
  args (argc, argv);

  set_db (SpectrumDB);

  status = load_db ();
  if (!status) {
    close_db ();
    exit (0);
  }
  if (!output.modify && !output.delete) close_db ();
  
  match = match_criteria (&Nmatch);
  match = unique_entries (match, &Nmatch);

  if (output.modify) ModifySubset (match, Nmatch);
  if (output.delete) DeleteSubset (match, Nmatch);

  OutputSubset (match, Nmatch);

  exit (0);
}

/* 

FITS table version:

   load_db - open, read in database, store as RegImage structure
   match   - return index 'match' to matched images
   modify  - change value of selected images
             write out subset of rows
   delete  - remove selected images from image structure
             write out entire table
   output  - write out subset in various formats

   get_images returns pointer to complete image structure


SQL version:

   load_db - set up connection
   match   - convert criteria to SQL where clause and do:
             'select from images [where clause]'
             images structure is filled with result from query
   modify  - change value of subset selection (identical)
             update selected rows
   delete  - user where clause and do 
             'delete from images where clause'
   output  - (identical)

   get_images returns pointer to image subset from query
   match[i] = i

*/
