# include "psphotStandAlone.h"

void psphotCleanup (pmConfig *config) {

    psFree (config);

    psTimerStop ();
    psMemCheckCorruption (stderr, true);
    pmModelClassCleanup ();
    psTimeFinalize ();
    pmConceptsDone ();
    pmConfigDone ();
    // fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "psphot");
    fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "psphot");
    return;
}

psExit psphotGetExitStatus () {

    psErrorCode err = psErrorCodeLast ();
    switch (err) {
      case PS_ERR_NONE:
	return PS_EXIT_SUCCESS;
      case PSPHOT_ERR_SYS:
        return PS_EXIT_SYS_ERROR;
      case PSPHOT_ERR_CONFIG:
        return PS_EXIT_CONFIG_ERROR;
      case PSPHOT_ERR_PROG:
        return PS_EXIT_PROG_ERROR;
      case PSPHOT_ERR_DATA:
        return PS_EXIT_DATA_ERROR;
      default:
        return PS_EXIT_UNKNOWN_ERROR;
    }
    return PS_EXIT_UNKNOWN_ERROR;
}
