
/** @file  psAbort.c
 *
 *  @brief Contains the definition for abort function
 *
 *  The abort logging and handling shall be performed by psAbort function.
 *  This will allow for consistent handling of other software units
 *  needing to abort from program execution.
 *
 *  @author Eric Van Alst, MHPCC
 *  @author Joshua Hoblitt, University of Hawaii
 *   
 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2007-02-07 23:52:54 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdarg.h>
#include <stdlib.h>

#include "psAbort.h"
#include "psError.h"
#include "psLogMsg.h"

void p_psAbort(const char *file,
               unsigned int lineno,
               const char *func,
               const char *format,
               ...)
{
    psErrorStackPrint(stderr, "Aborting. Error stack:");

    va_list argPtr;             // variable list arguement pointer
    // Get the variable list parameters to pass to logging function
    va_start(argPtr, format);

    // Call logging function with PS_LOG_ABORT level
    psLogMsgV("psLib.sys", PS_LOG_ABORT, format, argPtr);

    // Clean up stack after variable arguement has been used
    va_end(argPtr);

    // Call system abort function to terminate program execution
    abort();
}
