#ifndef _ERRORSTACK_H_
#define _ERRORSTACK_H_

/*-=-=-=-=-=-=-=-=-=-=-=- RCCL/RCI Notice of Copyright -=-=-=-=-=-=-=-=-=-=-*
 *									    *
 *	Copyright (C) 1991 by John E. Lloyd.				    *
 *									    *
 *	Information on copyright permissions, as well as a complete	    *
 *	disclaimer of warranty, is given in the file COPYRIGHT.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#include "../h/cdefs.h"

typedef struct {
	int code;
	char *msg;
	char *prevMsg;
} ERROR_DESC;

typedef struct {
	char overflow;
	int num;
	char *top;
	ERROR_DESC *desc;
	char *msgPtr;	
} ERROR_STACK_DESC;

/* Macro provided so that RCI task monitor can do this quickly */
#define CLEAR_ERRS(estk)		\
	if ((estk)->num)		\
	 { (estk)->msgPtr = (estk)->top;\
	   (estk)->num = 0; 		\
	   (estk)->overflow = 0; 	\
	 }

#ifndef PROTO
#ifndef NO_PROTOTYPES
#define PROTO(x) x
#else
#define PROTO(x) ()
#endif
#endif

/* extern errorMsg PROTO((int, char*, ...)); */
extern char *getErrorMsg PROTO((int));
extern getErrorCode PROTO((int));
extern setErrorCode PROTO((int, int));
extern numErrors PROTO(());
extern popError PROTO(());
extern clearErrors PROTO(());
extern char *dumpErrorMsgs PROTO((char*, int));
extern printErrors PROTO(()); 

extern ERROR_STACK_DESC *errStackInit PROTO((ERROR_STACK_DESC*,char*,int));
extern char* dumpErrMsgs PROTO((ERROR_STACK_DESC*,char*,int));

#endif
