/*  Header file for the error_message translation module	 error_message.h
**  ----------------------------------------------------
**
*/

/*  The following error codes returned by err_* do not have a facility number: 
**  this is because any attempt to look them up may fail recursively.
*/
#define	ERR_S_NORMAL		    1	/* Normal successful status  */
#define ERR_S_ALREADY_REGISTERED    9	/* Sucess (WAS SET )	     */
#define ERR_S_NOT_REGISTERED	    9	/* Sucess (WAS SET )	     */
#define ERR_S_NO_TRANSLATION	   0x14	/* Error: Unknown error code */
#define ERR_S_BUFFER_OVERFLOW	   0	/* Warning */


/*  The translation triplet gives, for a message number, the short name
**  and the message string. A zero pointer in place of the message string
**  indicates that this is the last triplet in an array.
*/
typedef struct {
    short int		code;
    char		*symbol;
    char		*message;    /* Zero pointer terminates array */
} err_translation;


/*  This is the format of the error block (possibly automatically generated)
**  which is passed to err_register and err_unregister.
*/
typedef struct err_block_struct *   err_pointer;
struct err_block_struct {
    err_pointer		next;
    short int		facility_number;    /* Eg 0x46	     */
    char *		prefix;		    /* Eg FE	     */
    char *		name;		    /* Eg FASTBUS    */
    err_translation	*array;		    /* Array of translations */
};

typedef long int err_code;	    /* A formatted error code */
typedef long int err_status;	    /* A formatted error code */


/*	External definitions of the routines
**	------------------------------------
*/

#ifndef IMPLEMENTATION
#ifdef __STDC__
extern err_status err_translate(
    err_code	error_code,
    char	*buffer,
    int		buffer_length);
#else
extern err_status err_translate();
#endif

#ifdef __STDC__
extern err_status err_register(err_pointer pblock);
#else
extern err_status err_register();
#endif

#ifdef __STDC__
extern err_status err_unregister(err_pointer pblock);
#else
extern err_status err_unregister();
#endif

#endif

