Debian Codegraph @

lib/usual/err.h

raw symbols SCIP
1 /*
2 * Cmdline error reporting.
3 *
4 * Copyright (c) 2009 Marko Kreen
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 /**
20 * @file
21 *
22 * Error printing for command-line utilities.
23 */
24 #ifndef _USUAL_ERR_H_
25 #define _USUAL_ERR_H_
26
27 #include <usual/base.h>
28
29 #ifdef HAVE_ERR_H
30 #include <err.h>
31 #endif
32
33 #ifndef HAVE_ERR
34 /** Print formatted message and strerror(errno) to stderr and exit with given error code */
35 void err(int e, const char *fmt, ...) _PRINTF(2, 3);
36 #endif
37 #ifndef HAVE_ERRX
38 /** Print formatted message to stderr and exit with given error code */
39 void errx(int e, const char *fmt, ...) _PRINTF(2, 3);
40 #endif
41 #ifndef HAVE_WARN
42 /** Print formatted message and strerror(errno) to stderr */
43 void warn(const char *fmt, ...) _PRINTF(1, 2);
44 #endif
45 #ifndef HAVE_WARNX
46 /** Print formatted message to stderr */
47 void warnx(const char *fmt, ...) _PRINTF(1, 2);
48 #endif
49 #ifndef HAVE_SETPROGNAME
50 /** Set program name to that will printed as prefix to error messages */
51 void setprogname(const char *s);
52 #endif
53 #ifndef HAVE_GETPROGNAME
54 /** Return program name set with @ref setprogname */
55 const char *getprogname(void);
56 #endif
57
58 /** Malloc that exits on failure */
59 void *xmalloc(size_t len);
60
61 /** Realloc that exits on failure */
62 void *xrealloc(void *p, size_t len);
63
64 /** strdup that exits on failure */
65 char *xstrdup(const char *s);
66
67 #endif