librpc: Shorten dcerpc_binding_handle_call a bit
[Samba/gebeck_regimport.git] / lib / ccan / err / err.h
blob58ad91c728a65a36487bd4eda87d31dbf8c19957
1 #ifndef CCAN_ERR_H
2 #define CCAN_ERR_H
3 #include "config.h"
5 #if HAVE_ERR_H
6 #include <err.h>
8 /* This is unnecessary with a real err.h. See below */
9 #define err_set_progname(name) ((void)name)
11 #else
12 #include <ccan/compiler/compiler.h>
14 /**
15 * err_set_progname - set the program name
16 * @name: the name to use for err, errx, warn and warnx
18 * The BSD err.h calls know the program name, unfortunately there's no
19 * portable way for the CCAN replacements to do that on other systems.
21 * If you don't call this with argv[0], it will be "unknown program".
23 * Example:
24 * err_set_progname(argv[0]);
26 void err_set_progname(const char *name);
28 /**
29 * err - exit(eval) with message based on format and errno.
30 * @eval: the exit code
31 * @fmt: the printf-style format string
33 * The format string is printed to stderr like so:
34 * <executable name>: <format>: <strerror(errno)>\n
36 * Example:
37 * char *p = strdup("hello");
38 * if (!p)
39 * err(1, "Failed to strdup 'hello'");
41 void NORETURN err(int eval, const char *fmt, ...);
43 /**
44 * errx - exit(eval) with message based on format.
45 * @eval: the exit code
46 * @fmt: the printf-style format string
48 * The format string is printed to stderr like so:
49 * <executable name>: <format>\n
51 * Example:
52 * if (argc != 1)
53 * errx(1, "I don't expect any arguments");
55 void NORETURN errx(int eval, const char *fmt, ...);
57 /**
58 * warn - print a message to stderr based on format and errno.
59 * @eval: the exit code
60 * @fmt: the printf-style format string
62 * The format string is printed to stderr like so:
63 * <executable name>: <format>: <strerror(errno)>\n
65 * Example:
66 * char *p = strdup("hello");
67 * if (!p)
68 * warn("Failed to strdup 'hello'");
70 void warn(const char *fmt, ...);
72 /**
73 * warnx - print a message to stderr based on format.
74 * @eval: the exit code
75 * @fmt: the printf-style format string
77 * The format string is printed to stderr like so:
78 * <executable name>: <format>\n
80 * Example:
81 * if (argc != 1)
82 * warnx("I don't expect any arguments (ignoring)");
84 void warnx(const char *fmt, ...);
85 #endif
87 #endif /* CCAN_ERR_H */