/* vi: set tabstop=4 shiftwidth=4 */ #include #include "config.h" /* * $Id: error.h,v 2.1 2005/06/17 20:48:15 schweikh Exp $ */ #include /* FILE */ void /*@unused@*/ err_ret (const char *, ...) /*@globals stderr,fileSystem,internalState@*/ /*@modifies *stderr,fileSystem@*/; /*@exits@*/ /*@unused@*/ void err_sys (const char *, ...) /*@globals stderr,fileSystem,internalState@*/ /*@modifies *stderr,fileSystem@*/; /*@exits@*/ /*@unused@*/ void err_dump (const char *, ...) /*@globals stderr,fileSystem,internalState@*/ /*@modifies *stderr,fileSystem@*/; void /*@unused@*/ err_msg (const char *, ...) /*@globals stderr,fileSystem,internalState@*/ /*@modifies *stderr,fileSystem@*/; /*@exits@*/ /*@unused@*/ void err_quit (const char *, ...) /*@globals stderr,fileSystem,internalState@*/ /*@modifies *stderr,fileSystem@*/; void /*@unused@*/ set_progname (char *, char *) /*@globals internalState@*/ /*@modifies internalState@*/; char * err_progname (FILE *fp) /*@globals stderr,fileSystem,internalState@*/ /*@modifies *fp,fileSystem@*/; void /*@unused@*/ /*@printflike@*/ cfprintf (FILE *fp, const char *, ...) /*@globals stderr,fileSystem,internalState@*/ /*@modifies *fp,*stderr,fileSystem@*/; /*@observer@*/ char /*@unused@*/ * program_name (void) /*@globals internalState@*/; /* If MALLOC_DEBUG, write debug info to this file. */ #define DEBUG_FILE "debug.out" /* first arg for error() and warn() */ #define E_MSG 0 /* just warn, without perror */ #define E_PERROR 1 /* with perror */ #define E_ABORT 2 /* inconsistency: abort */ #if MALLOC_DEBUG #define xmalloc(s) \ xxmalloc ((size_t)(s), __FILE__, __LINE__) #define xcalloc(n, s) \ xxcalloc ((size_t)(n), (size_t)(s), __FILE__, __LINE__) #define xrealloc(p, s) \ xxrealloc ((p), (size_t)(s), __FILE__, __LINE__) #define xfree(p) \ xxfree ((p), __FILE__, __LINE__) #else #define xmalloc(s) xxmalloc ((size_t)(s)) #define xcalloc(n, s) xxcalloc ((size_t)(n), (size_t)(s)) #define xrealloc(p, s) xxrealloc ((p), (size_t)(s)) #define xfree(p) xxfree (p) #endif extern long alloc_free; /*@out@*//*@only@*/ void * #if MALLOC_DEBUG xxmalloc (size_t, char *, int); #else xxmalloc (size_t); #endif /*@out@*//*@only@*/ void * #if MALLOC_DEBUG xxcalloc (size_t, size_t, char *, int); #else xxcalloc (size_t, size_t); #endif /*@only@*/ void * #if MALLOC_DEBUG xxrealloc (/*@null@*//*@only@*//*@out@*//*@returned@*/ void *, size_t, char *, int); #else xxrealloc (/*@null@*//*@only@*//*@out@*//*@returned@*/ void *, size_t); #endif void #if MALLOC_DEBUG xxfree (/*@null@*//*@out@*//*@only@*/ void *, char *, int); #else xxfree (/*@null@*//*@out@*//*@only@*/ void *); #endif /*@falseexit@*/ void check (int); /*@falseexit@*/ void check_sys (int); #define check(x) \ do { \ if ((x) == 0) { \ warn (0, "check in '" __FILE__ \ "', line %d:", __LINE__); \ error (0, " '%s' is false", #x); \ } \ } while (0) #define check_sys(x) \ do { \ if ((x) == 0) { \ warn (0, "check in '" __FILE__ \ "', line %d:", __LINE__); \ error (E_PERROR, " '%s' is false", #x); \ } \ } while (0) void /*@exits@*/ /*@printflike@*/ error (int, const char *,...); void /*@printflike@*/ warn (int, const char *,...);