/** @file  psConfigure.c
 *
 *  @brief Contains the declarations for initialization, memory finalization, and configuration.
 *
 *  These functions initalize psLib data before the beginning of a run and remove (finalize) the
 *  same data after the run is complete. A function is also provided to return the current
 *  psLib version.
 *
 *  @ingroup Configure
 *
 *  @author Ross Harman, MHPCC
 *  @author Robert DeSonia, MHPCC
 *
 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2005-02-17 19:26:24 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 */
#include "psString.h"
#include "psTime.h"
#include "psError.h"
#include "psConfigure.h"
#include "psSysUtilsErrors.h"
#include "config.h"

char* psLibVersion(void)
{
    char version[80];
    snprintf(version,80,"%s-v%s",PACKAGE,VERSION);

    return(psStringCopy(version));
}

void psLibInit(bool predictable, const char* timeConfig)
{
    // Still needs error codes to be set
    // Still needs random number generator initialization
    // Please code me, Robert and George.

    if(!p_psTimeInit(timeConfig)) {
        psError(PS_ERR_BAD_PARAMETER_VALUE, true, PS_ERRORTEXT_psConfigure_INITIALIZATION_FAILED, "psTime");
        return;
    }
}

void psLibFinalize(void)
{
    // Users of persistent memory should free them in this function

    if(!p_psTimeFinalize()) {
        psError(PS_ERR_BAD_PARAMETER_VALUE, true, PS_ERRORTEXT_psConfigure_FINALIZATION_FAILED, "psTime");
        return;
    }
}
