Commit | Line | Data |
---|---|---|
1479465f GJ |
1 | /* |
2 | * libdpkg - Debian packaging suite library routines | |
3 | * ehandle.h - error handling | |
4 | * | |
5 | * Copyright © 1994,1995 Ian Jackson <ijackson@chiark.greenend.org.uk> | |
6 | * Copyright © 2000,2001 Wichert Akkerman <wichert@debian.org> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | |
20 | */ | |
21 | ||
22 | #ifndef LIBDPKG_EHANDLE_H | |
23 | #define LIBDPKG_EHANDLE_H | |
24 | ||
25 | #include <setjmp.h> | |
26 | #include <stddef.h> | |
27 | #include <stdarg.h> | |
28 | ||
29 | #include <dpkg/macros.h> | |
30 | ||
31 | DPKG_BEGIN_DECLS | |
32 | ||
33 | /** | |
34 | * @defgroup ehandle Error context handling | |
35 | * @ingroup dpkg-public | |
36 | * @{ | |
37 | */ | |
38 | ||
39 | extern volatile int onerr_abort; | |
40 | ||
41 | enum { | |
42 | ehflag_normaltidy = DPKG_BIT(0), | |
43 | ehflag_bombout = DPKG_BIT(1), | |
44 | ehflag_recursiveerror = DPKG_BIT(2), | |
45 | }; | |
46 | ||
47 | typedef void error_handler_func(void); | |
48 | typedef void error_printer_func(const char *emsg, const void *data); | |
49 | ||
50 | void print_fatal_error(const char *emsg, const void *data); | |
51 | void catch_fatal_error(void); | |
52 | ||
53 | void push_error_context_jump(jmp_buf *jumper, | |
54 | error_printer_func *printer, | |
55 | const void *printer_data); | |
56 | void push_error_context_func(error_handler_func *handler, | |
57 | error_printer_func *printer, | |
58 | const void *printer_data); | |
59 | void push_error_context(void); | |
60 | void pop_error_context(int flagset); | |
61 | ||
62 | void push_cleanup(void (*f1)(int argc, void **argv), int flagmask1, | |
63 | void (*f2)(int argc, void **argv), int flagmask2, | |
64 | unsigned int nargs, ...); | |
65 | void push_checkpoint(int mask, int value); | |
66 | void pop_cleanup(int flagset); | |
67 | ||
68 | void ohshitv(const char *fmt, va_list args) | |
69 | DPKG_ATTR_NORET DPKG_ATTR_VPRINTF(1); | |
70 | void ohshit(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1); | |
71 | void ohshite(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1); | |
72 | ||
73 | void do_internerr(const char *file, int line, const char *func, | |
74 | const char *fmt, ...) | |
75 | DPKG_ATTR_NORET DPKG_ATTR_PRINTF(4); | |
76 | #define internerr(...) do_internerr(__FILE__, __LINE__, __func__, __VA_ARGS__) | |
77 | ||
78 | /** @} */ | |
79 | ||
80 | DPKG_END_DECLS | |
81 | ||
82 | #endif /* LIBDPKG_EHANDLE_H */ |