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

#include <stdio.h>
#include <pslib.h>
#include <psmodules.h>

#include "ppSim.h"

int main(int argc, char *argv[])
{
    psLibInit(NULL);
    pmConfig *config = pmConfigRead(&argc, argv, NULL); // Configuration
    if (!config) {
        psErrorStackPrint(stderr, "Unable to read configurations.");
        exit(PS_EXIT_CONFIG_ERROR);
    }

    ppSimArguments(argc, argv, config);

    if (!ppSimCreate(config)) {
        psErrorStackPrint(stderr, "Unable to create output file.");
        psFree(config);
        exit(PS_EXIT_CONFIG_ERROR);
    }

    psExit loopError;
    if ((loopError = ppSimLoop(config))) {
        psErrorStackPrint(stderr, "Unable to generate data.");
        psFree(config);
        exit(loopError);
    }

    psFree(config);
    pmConfigDone();
    pmConceptsDone();
    psLibFinalize();

    return PS_EXIT_SUCCESS;
}
