File: err.h

package info (click to toggle)
tworld 1.3.0-6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 6,636 kB
  • ctags: 1,407
  • sloc: ansic: 12,442; perl: 2,465; makefile: 194; sh: 18
file content (36 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* err.h: Error handling and reporting.
 *
 * Copyright (C) 2001-2006 by Brian Raiter, under the GNU General Public
 * License. No warranty. See COPYING for details.
 */

#ifndef	_err_h_
#define	_err_h_

/* Simple macros for dealing with memory allocation simply.
 */
#define	memerrexit()	(die("out of memory"))
#define	xalloc(p, n)	(((p) = realloc((p), (n))) || (memerrexit(), NULL))

/* Log an error message and continue.
 */
extern void _warn(char const *fmt, ...);

/* Display an error message.
 */
extern void _errmsg(char const *prefix, char const *fmt, ...);

/* Display an error message and abort.
 */
extern void _die(char const *fmt, ...);

/* A really ugly hack used to smuggle extra arguments into variadic
 * functions.
 */
extern char const      *_err_cfile;
extern unsigned long	_err_lineno;
#define	warn	(_err_cfile = __FILE__, _err_lineno = __LINE__, _warn)
#define	errmsg	(_err_cfile = __FILE__, _err_lineno = __LINE__, _errmsg)
#define	die	(_err_cfile = __FILE__, _err_lineno = __LINE__, _die)

#endif