# include "dvomerge.h"

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

  SetSignals ();
  dvomerge_help (argc, argv);
  ConfigInit (&argc, argv);
  dvomerge_args (&argc, argv);

  if (argc == 6) {
    if (!strcasecmp (argv[2], "and")) {
      if (VERIFY) {
	fprintf (stderr, "WARNING / ERROR : dvomerge (input1) and (input2) into (output) : VERIFY mode not implemented\n");
	exit (3);
      }
      if (IMAGES_ONLY) {
	fprintf (stderr, "ERROR : dvomerge (input1) and (input2) into (output) : not compatible with '-images-only'\n");
	exit (5);
      }
      dvomergeCreate (argc, argv);
    } else {
      if (VERIFY) {
	fprintf (stderr, "WARNING / ERROR : dvomerge (input) into (output) from (list) : VERIFY mode not implemented\n");
	exit (3);
      }
      if (IMAGES_ONLY) {
	fprintf (stderr, "ERROR : dvomerge (input) input (output) from (list) : not compatible with '-images-only'\n");
	exit (5);
      }
      dvomergeFromList (argc, argv);
    }
  }
  if ((argc == 4) || (argc == 5)) {
    if (NTHREADS) {
      dvomergeUpdate_threaded (argc, argv);
    } else {
      dvomergeUpdate (argc, argv);
    }
  }
  dvomerge_usage();
  exit (2); // cannot reach here.
}

/* we have two major modes of operation:

   Create    : dvomerge (in1) and (in2) to (out) -- create a new db from two input dbs
   Update    : dvomerge (in) into (out)          -- merge a new db into an existing db

   we also have varients on Update:
   Continue  : dvomerge (in) into (out) continue -- merge only unmerged tables into the existing db
   From List : dvomerge (in) into (out) from (list) -- merge only specified tables into the existing db

   neither of the 2 above modes update the image table
*/
