/** @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.5 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2005-01-03 23:35:07 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
 */
#include "psString.h"
#include "psTime.h"
#include "psError.h"
#include "psConfigure.h"
#include "psSysUtilsErrors.h"


#ifndef PS_LIB_VERSION
#define PS_LIB_VERSION "psLib version unknown"
#pragma warning PS_LIB_VERSION was not defined in the makefile.
#endif

char* psLibVersion(void)
{
    // PS_LIB_VERSION comes from Makefile.Globals
    return(psStringCopy(PS_LIB_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;
    }
}
