#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

# include "psphot.h"

static void usage (void) {
    fprintf (stderr, "USAGE: ppImage [-file INPUT.fits] [-list INPUT.txt] OUTPUT\n");
    exit (2);
}

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

    psTimerStart ("complete");

    psphotErrorRegister();              // register our error codes/messages

    // basic pslib options
    psLogSetFormat ("M");

    // load implementation-specific models
    psphotModelGroupInit ();

    // load command-line arguments, options, and system config data
    pmConfig *config = psphotArguments (argc, argv);
    if (config == NULL) usage ();

    // load input data (config and images (signal, noise, mask)
    if (!psphotParseCamera (config)) {
        psErrorStackPrint(stderr, " ");
        exit(1);
    }

    // call psphot for each readout
    psphotImageLoop (config);

    psLogMsg ("psphot", 3, "complete psphot run: %f sec\n", psTimerMark ("complete"));

    psphotCleanup (config);
    exit (EXIT_SUCCESS);
}
