# include "dvomerge.h"

int LoadCatalog (Catalog *catalog, SkyRegion *region, char *filename, char *mode) {

    // set the parameters which guide catalog open/load/create
    catalog[0].filename  = filename;
    catalog[0].Nsecfilt  = GetPhotcodeNsecfilt ();

    if (!strcmp (mode, "w")) {
	catalog[0].catflags = LOAD_NONE;
    } else {
	catalog[0].catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
    }

    catalog[0].catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
    catalog[0].catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data

    if (!dvo_catalog_open (catalog, region, VERBOSE, mode)) {
	fprintf (stderr, "ERROR: failure to open catalog file %s\n", filename);
	exit (2);
    }
    return (TRUE);
}
