#pragma prototyped
#ifndef _ERROR_H
#define _ERROR_H
#include <ast.h>
#include <option.h>
#include <errno.h>
#define ERROR_VERSION 20070319L
#if !defined(errno) && defined(__DYNAMIC__)
#define errno __DYNAMIC__(errno)
#endif
#define ERROR_debug(n) (-(n))
#define ERROR_exit(n) ((n)+ERROR_ERROR)
#define ERROR_system(n) (((n)+ERROR_ERROR)|ERROR_SYSTEM)
#define ERROR_usage(n) ((((n)?2:0)+ERROR_ERROR)|ERROR_USAGE)
#define ERROR_warn(n) (ERROR_WARNING)
#ifndef ERROR_catalog
#define ERROR_catalog(t) t
#endif
#ifndef ERROR_dictionary
#define ERROR_dictionary(t) t
#endif
#ifndef ERROR_translate
#define ERROR_translating() (error_info.translate&&(ast.locale.set&(1<<AST_LC_MESSAGES)))
#define ERROR_translate(l,i,d,m) (ERROR_translating()?errorx((const char*)l,(const char*)i,(const char*)d,(const char*)m):(m))
#endif
#define ERROR_INFO 0
#define ERROR_WARNING 1
#define ERROR_ERROR 2
#define ERROR_FATAL 3
#define ERROR_NOEXEC EXIT_NOEXEC
#define ERROR_NOENT EXIT_NOTFOUND
#define ERROR_PANIC ERROR_LEVEL
#define ERROR_LEVEL 0x00ff
#define ERROR_SYSTEM 0x0100
#define ERROR_OUTPUT 0x0200
#define ERROR_SOURCE 0x0400
#define ERROR_USAGE 0x0800
#define ERROR_PROMPT 0x1000
#define ERROR_NOID 0x2000
#define ERROR_LIBRARY 0x4000
#define ERROR_INTERACTIVE 0x0001
#define ERROR_SILENT 0x0002
#define ERROR_NOTIFY 0x0004
#define ERROR_FREE 0x0010
#define ERROR_POP 0x0020
#define ERROR_PUSH 0x0040
#define ERROR_SET 0x0080
#ifndef ERROR_CONTEXT_T
#define ERROR_CONTEXT_T Error_info_t
#endif
#define ERROR_CONTEXT_BASE ((Error_context_t*)&error_info.context)
#define errorpush(p,f) (*(p)=*ERROR_CONTEXT_BASE,*ERROR_CONTEXT_BASE=error_info.empty,error_info.context=(Error_context_t*)(p),error_info.flags=(f))
#define errorpop(p) (*ERROR_CONTEXT_BASE=*(p))
typedef struct Error_info_s Error_info_t;
typedef struct Error_context_s Error_context_t;
#define ERROR_CONTEXT \
ERROR_CONTEXT_T* context; \
int errors; \
int flags; \
int line; \
int warnings; \
char* file; \
char* id;
struct Error_context_s
{
ERROR_CONTEXT
};
struct Error_info_s
{
int fd;
void (*exit)(int);
ssize_t (*write)(int, const void*, size_t);
int clear;
int core;
int indent;
int init;
int last_errno;
int mask;
int set;
int trace;
char* version;
int (*auxilliary)(Sfio_t*, int, int);
ERROR_CONTEXT
Error_context_t empty;
unsigned long time;
char* (*translate)(const char*, const char*, const char*, const char*);
const char* catalog;
};
#ifndef errno
extern int errno;
#endif
#if _BLD_ast && defined(__EXPORT__)
#define extern extern __EXPORT__
#endif
#if !_BLD_ast && defined(__IMPORT__)
#define extern extern __IMPORT__
#endif
extern Error_info_t* _error_infop_;
#define error_info (*_error_infop_)
#undef extern
#if _BLD_ast && defined(__EXPORT__)
#define extern __EXPORT__
#endif
extern void error(int, ...);
extern int errormsg(const char*, int, ...);
extern int errorf(void*, void*, int, ...);
extern void errorv(const char*, int, va_list);
#ifndef errorx
extern char* errorx(const char*, const char*, const char*, const char*);
#endif
extern Error_info_t* errorctx(Error_info_t*, int, int);
#undef extern
#endif