# include "markrock.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 (0);
  }
  if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);

  /* used in other pipeline functions */
  ScanConfig (config, "CATDIR",                 "%s",  0, CATDIR);

  /* unique to markrock */
  ScanConfig (config, "ROCK_NEIGHBOR_RADIUS",   "%lf", 0, &ROCK_NEIGHBOR_RADIUS);
  ScanConfig (config, "ROCK_NEIGHBOR_NMAX",     "%d",  0, &ROCK_NEIGHBOR_NMAX);

  ScanConfig (config, "ROCK_RADIUS",            "%lf", 0, &RADIUS);
  ScanConfig (config, "ROCK_MAX_RADIUS",        "%lf", 0, &MAX_RADIUS);
  ScanConfig (config, "ROCK_MAX_SPEED",         "%lf", 0, &MAX_SPEED);
  ScanConfig (config, "ROCK_MAX_DELAY",         "%lf", 0, &MAX_DELAY);
  ScanConfig (config, "ROCK_CATALOG",           "%s",  0, RockCat);
  ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, PhotCodeFile);

  ScanConfig (config, "BRIGHT_HALO_MAG",        "%lf", 0, &BRIGHT_HALO_MAG);
  ScanConfig (config, "BRIGHT_HALO_SLOPE",      "%lf", 0, &BRIGHT_HALO_SLOPE);
  ScanConfig (config, "GSCFILE",                "%s",  0, GSCFILE);
  ScanConfig (config, "GSCDIR",                 "%s",  0, GSCDIR);
  ScanConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);

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

  free (config);
  free (file);

}
