2 * Copyright (c) 2017-2018, De Rais <derais@cock.li>
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
18 #define UNUSED(x) (void) (sizeof(x))
21 #define STR(x) STR2(x)
22 #define L(x) __FILE__ ":" STR(__LINE__) ": " x
24 #define NUM_OF(x) (sizeof(x) / sizeof((x)[0]))
26 #define UBSAFES(x) ((x) ? (x) : "[None]")
28 extern const char *program_name
;
30 #define PERROR_MESSAGE(x) perror(L(x))
31 #define ERROR_MESSAGE(...) \
33 fprintf(stderr, "%s", UBSAFES(program_name)); \
34 fprintf(stderr, ": ERROR: " __FILE__ ":" STR( \
35 __LINE__) ": " __VA_ARGS__); \
36 fprintf(stderr, "\n"); \
42 fprintf(stderr, "%s", UBSAFES(program_name)); \
43 fprintf(stderr, ": %-25s", \
44 "LOG: " __FILE__ ":" STR( \
46 fprintf(stderr, __VA_ARGS__); \
47 fprintf(stderr, "\n"); \