ehandle.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * libdpkg - Debian packaging suite library routines
  3. * ehandle.h - error handling
  4. *
  5. * Copyright © 1994,1995 Ian Jackson <ian@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 <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef LIBDPKG_EHANDLE_H
  22. #define LIBDPKG_EHANDLE_H
  23. #include <setjmp.h>
  24. #include <stddef.h>
  25. #include <stdarg.h>
  26. #include <dpkg/macros.h>
  27. DPKG_BEGIN_DECLS
  28. /* Defined separately in each program. */
  29. extern const char thisname[];
  30. extern volatile int onerr_abort;
  31. enum {
  32. ehflag_normaltidy = 01,
  33. ehflag_bombout = 02,
  34. ehflag_recursiveerror = 04
  35. };
  36. typedef void error_handler(void);
  37. typedef void error_printer(const char *emsg, const char *contextstring);
  38. void print_fatal_error(const char *emsg, const char *contextstring);
  39. void catch_fatal_error(void);
  40. void push_error_context_jump(jmp_buf *jbufp, error_printer *printerror,
  41. const char *contextstring);
  42. void push_error_context_func(error_handler *func, error_printer *printerror,
  43. const char *contextstring);
  44. void push_error_context(void);
  45. void pop_error_context(int flagset);
  46. void push_cleanup(void (*f1)(int argc, void **argv), int flagmask1,
  47. void (*f2)(int argc, void **argv), int flagmask2,
  48. unsigned int nargs, ...);
  49. void push_checkpoint(int mask, int value);
  50. void pop_cleanup(int flagset);
  51. void warningv(const char *fmt, va_list args) DPKG_ATTR_VPRINTF(1);
  52. void warning(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
  53. void ohshitv(const char *fmt, va_list args)
  54. DPKG_ATTR_NORET DPKG_ATTR_VPRINTF(1);
  55. void ohshit(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
  56. void ohshite(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
  57. void werr(const char *what) DPKG_ATTR_NORET;
  58. void do_internerr(const char *file, int line, const char *fmt, ...)
  59. DPKG_ATTR_NORET DPKG_ATTR_PRINTF(3);
  60. #define internerr(...) do_internerr(__FILE__, __LINE__, __VA_ARGS__)
  61. DPKG_END_DECLS
  62. #endif /* LIBDPKG_EHANDLE_H */