/*M*
//
//               INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in accordance with the terms of that agreement.
//        Copyright (c) 1995 Intel Corporation. All Rights Reserved.
//
//  RCS:
//      $Source: d:/rcs/nsp20/include/nsperror.h $
//      $Revision: 1.4 $
//      $Date: 1995/08/07 10:58:20 $
//
//  Purpose: NSP Error Handling Module
*M*/

/*===========================================================================*/

#if !defined _NSPERROR_H || defined _NSP_BLDPCS
# define _NSPERROR_H

/*--- NSPErrStatus Declaration ---------------------------------------------*/

#define NSP_StsOk             0         /* everithing is ok                  */
#define NSP_StsBackTrace     -1         /* pseudo error for back trace       */
#define NSP_StsError         -2         /* unknown /unspecified error        */
#define NSP_StsInternal      -3         /* internal error (bad state)        */
#define NSP_StsNoMem         -4         /* out of memory                     */
#define NSP_StsBadArg        -5         /* function arg/param is bad         */
#define NSP_StsBadFunc       -6         /* unsupported function              */
#define NSP_StsNoConv        -7         /* iter. didn't converge             */
#define NSP_StsAutoTrace     -8         /* Tracing through nsptrace.h        */

#ifndef _NSP_BLDPCS

typedef int                 NSPStatus;
typedef int (*NSPErrorCallBack)  (NSPStatus status,    const char *funcname,
                                  const char *context, const char *file,
                                        int   line);
#endif

NSPAPI(NSPStatus, nspGetErrStatus,(void));
NSPAPI(void,      nspSetErrStatus,(NSPStatus status));

/*--- NspStdErrMode Declaration ---------------------------------------------*/

#define NSP_ErrModeLeaf     0           /* Print error and exit program      */
#define NSP_ErrModeParent   1           /* Print error and continue          */
#define NSP_ErrModeSilent   2           /* Don't print and continue          */

NSPAPI(int,  nspGetErrMode,(void));
NSPAPI(void, nspSetErrMode,(int mode));

/*--- nspError,nspErrorStr Declaration --------------------------------------------------*/

NSPAPI(NSPStatus,   nspError,(NSPStatus status, const char *func,
                             const char *context, const char *file,int line));

NSPAPI(const char*, nspErrorStr,(NSPStatus status));

/*--- nspRedirectError Declaration ------------------------------------------*/

NSPAPI(NSPStatus, nspNulDevReport,(NSPStatus   status, const char *funcname,
                                  const char *context,const char *file,
                                        int   line));

NSPAPI(NSPStatus, nspStdErrReport,(NSPStatus   status, const char *funcname,
                                  const char *context,const char *file,
                                        int   line));

NSPAPI(NSPStatus, nspGuiBoxReport,(NSPStatus   status, const char *funcname,
                                  const char *context,const char *file,
                                        int   line));

NSPAPI(NSPErrorCallBack, nspRedirectError,(NSPErrorCallBack nspErrorFunc));

/*--- Macros ----------------------------------------------------------------*/

#define NSP_ERROR(status,func,context)\
                nspError((status),(func),(context),__FILE__,__LINE__)

#define NSP_ERRCHK(func,context)\
                ((nspGetErrStatus() >= 0) ? NSP_StsOk \
                : NSP_ERROR(NSP_StsBackTrace,(func),(context)))

#define NSP_ASSERT(expr,func,context)\
                ((expr) ? NSP_StsOk \
                : NSP_ERROR(NSP_StsInternal,(func),(context)))

#define NSP_RSTERR() (nspSetErrStatus(NSP_StsOk))

#endif                                  /* _NSPERROR_H                        */
