# include "delstar.h"

int main (int argc, char **argv) {

  FITS_DB db;

  int status;
  SetSignals ();
  ConfigInit (&argc, argv);
  args (&argc, argv);

  set_db (&db);
  status = dvo_image_lock (&db, ImageCat, 60.0, LCK_XCLD); /* XCLD */
  if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
  if (db.dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db.filename);

  status = dvo_image_load (&db, VERBOSE, FALSE);
  if (!status) Shutdown ("can't read image catalog %s", db.filename);

  switch (MODE) {
    case MODE_IMAGEFILE:
      delete_imagefile (&db, argv[1]);
      break;
    case MODE_IMAGENAME:
      delete_imagename (&db, argv[1]);
      break;
    case MODE_TIME:
      delete_times (&db);
      break;
    case MODE_ORPHAN:
      fprintf (stderr, "delete orphans not available\n");
      // delete_orphans (argv[1]);
      break;
    case MODE_MISSED:
      fprintf (stderr, "delete missed not available\n");
      // delete_missed (argv[1]);
      break;
    default:
      usage ();
  }
  exit (1);
}
