dpkg (1.18.25) stretch; urgency=medium
[dpkg] / lib / dpkg / ehandle.h
CommitLineData
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
31DPKG_BEGIN_DECLS
32
33/**
34 * @defgroup ehandle Error context handling
35 * @ingroup dpkg-public
36 * @{
37 */
38
39extern volatile int onerr_abort;
40
41enum {
42 ehflag_normaltidy = DPKG_BIT(0),
43 ehflag_bombout = DPKG_BIT(1),
44 ehflag_recursiveerror = DPKG_BIT(2),
45};
46
47typedef void error_handler_func(void);
48typedef void error_printer_func(const char *emsg, const void *data);
49
50void print_fatal_error(const char *emsg, const void *data);
51void catch_fatal_error(void);
52
53void push_error_context_jump(jmp_buf *jumper,
54 error_printer_func *printer,
55 const void *printer_data);
56void push_error_context_func(error_handler_func *handler,
57 error_printer_func *printer,
58 const void *printer_data);
59void push_error_context(void);
60void pop_error_context(int flagset);
61
62void push_cleanup(void (*f1)(int argc, void **argv), int flagmask1,
63 void (*f2)(int argc, void **argv), int flagmask2,
64 unsigned int nargs, ...);
65void push_checkpoint(int mask, int value);
66void pop_cleanup(int flagset);
67
68void ohshitv(const char *fmt, va_list args)
69 DPKG_ATTR_NORET DPKG_ATTR_VPRINTF(1);
70void ohshit(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
71void ohshite(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
72
73void 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
80DPKG_END_DECLS
81
82#endif /* LIBDPKG_EHANDLE_H */