# include "delstar.h"

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

  char *config, *file;
  char PhotCodeFile[256];

  /*** load configuration info ***/
  file = SelectConfigFile (argc, argv, "ptolemy");
  config = LoadConfigFile (file);
  if (config == (char *) NULL) {
    fprintf (stderr, "ERROR: can't find configuration file %s\n", file);
    if (file != (char *) NULL) free (file);
    exit (1);
  }
  if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);

  ScanConfig (config, "NSIGMA",                 "%lf", 0, &NSIGMA);
  ScanConfig (config, "ALPHA",                  "%lf", 0, &ALPHA);
  ScanConfig (config, "IMAGE_CATALOG",          "%s", 0, ImageCat);
  ScanConfig (config, "IMAGE_CATALOG_TEMPLATE", "%s", 0, ImageTemplate);
  ScanConfig (config, "CATALOG_TEMPLATE",       "%s", 0, CatTemplate);
  ScanConfig (config, "GSCFILE",                "%s", 0, GSCFILE);
  ScanConfig (config, "CATDIR",                 "%s", 0, CATDIR);
  ScanConfig (config, "PHOTCODE_FILE",          "%s", 0, PhotCodeFile);

  ScanConfig (config, "DATE-KEYWORD",           "%s", 0, DateKeyword);
  ScanConfig (config, "DATE-MODE",              "%s", 0, DateMode);
  ScanConfig (config, "UT-KEYWORD",             "%s", 0, UTKeyword);
  ScanConfig (config, "MJD-KEYWORD",            "%s", 0, MJDKeyword);
  ScanConfig (config, "JD-KEYWORD",             "%s", 0, JDKeyword);

  if (!LoadPhotcodes (PhotCodeFile)) {
    fprintf (stderr, "error loading photcodes\n");
    exit (1);
  }

  free (config);
  free (file);
}
