# include "uniphot.h"

int gcatalog (Catalog *catalog) {

  int mode;

  mode = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;

  switch (lock_catalog (catalog, LCK_SOFT)) {
  case 0:
    fprintf (stderr, "ERROR: can't lock file %s\n", catalog[0].filename);
    exit (1);
  case 1:
    if (!load_catalog (catalog, mode, VERBOSE)) {
      fprintf (stderr, "ERROR: failure loading catalog %s\n", catalog[0].filename);
      exit (1);
    }
    if (VERBOSE) {
      fprintf (stderr, "read %d stars from catalog file %s (%d measurements)\n", 
	       catalog[0].Naverage, catalog[0].filename, catalog[0].Nmeasure);
    }
    return (TRUE);
  case 2:
    if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog[0].filename);
    return (FALSE);
  default:
    fprintf (stderr, "weird lock_catalog exit state\n");
    exit (1);
  }
  return (FALSE);
}
