# include "photdbc.h"

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

  SkyTable *sky;
  SkyList *skylist;

  /* get configuration info, args, lockfile */
  initialize (argc, argv);

  // the output catalog needs to inherit the SKY_DEPTH of the input catalog
  sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, 0, VERBOSE);
  SkyTableSetFilenames (sky, CATDIR, "cpt");
  skylist = SkyListByPatch (sky, -1, &REGION);

  // load and copy the image table
  copy_images (argv[1], skylist);

  // hostID is 0 for master program
  photdbc_catalogs (argv[1], skylist, 0);

  char *skyfile = SkyTableFilename (argv[1]);
  SkyTableSave (sky, skyfile);
  exit (0);
}
