error.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * libdpkg - Debian packaging suite library routines
  3. * error.h - error message reporting
  4. *
  5. * Copyright © 2011-2015 Guillem Jover <guillem@debian.org>
  6. *
  7. * This is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. #ifndef LIBDPKG_ERROR_H
  21. #define LIBDPKG_ERROR_H
  22. #include <dpkg/macros.h>
  23. DPKG_BEGIN_DECLS
  24. /**
  25. * @defgroup dpkg_error Error message reporting
  26. * @ingroup dpkg-public
  27. * @{
  28. */
  29. enum dpkg_msg_type {
  30. DPKG_MSG_NONE,
  31. DPKG_MSG_WARN,
  32. DPKG_MSG_ERROR,
  33. };
  34. struct dpkg_error {
  35. enum dpkg_msg_type type;
  36. char *str;
  37. };
  38. #define DPKG_ERROR_INIT { DPKG_MSG_NONE, NULL }
  39. int dpkg_put_warn(struct dpkg_error *err, const char *fmt, ...)
  40. DPKG_ATTR_PRINTF(2);
  41. int dpkg_put_error(struct dpkg_error *err, const char *fmt, ...)
  42. DPKG_ATTR_PRINTF(2);
  43. int dpkg_put_errno(struct dpkg_error *err, const char *fmt, ...)
  44. DPKG_ATTR_PRINTF(2);
  45. void dpkg_error_print(struct dpkg_error *err, const char *fmt, ...)
  46. DPKG_ATTR_PRINTF(2);
  47. void dpkg_error_destroy(struct dpkg_error *err);
  48. /** @} */
  49. DPKG_END_DECLS
  50. #endif /* LIBDPKG_ERROR_H */