opkg_message.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* opkg_message.h - the opkg package management system
  2. Copyright (C) 2009 Ubiq Technologies <graham.gower@gmail.com>
  3. Copyright (C) 2003 Daniele Nicolodi <daniele@grinta.net>
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License as
  6. published by the Free Software Foundation; either version 2, or (at
  7. your option) any later version.
  8. This program is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. */
  13. #ifndef _OPKG_MESSAGE_H_
  14. #define _OPKG_MESSAGE_H_
  15. #include <string.h>
  16. #include <errno.h>
  17. typedef enum {
  18. ERROR, /* error conditions */
  19. NOTICE, /* normal but significant condition */
  20. INFO, /* informational message */
  21. DEBUG, /* debug level message */
  22. DEBUG2, /* more debug level message */
  23. } message_level_t;
  24. void free_error_list(void);
  25. void print_error_list(void);
  26. void opkg_message(message_level_t level, const char *fmt, ...)
  27. __attribute__ ((format(printf, 2, 3)));
  28. #define opkg_msg(l, fmt, args...) \
  29. do { \
  30. if (l == NOTICE) \
  31. opkg_message(l, fmt, ##args); \
  32. else \
  33. opkg_message(l, "%s: "fmt, __FUNCTION__, ##args); \
  34. } while (0)
  35. #define opkg_perror(l, fmt, args...) \
  36. opkg_msg(l, fmt": %s.\n", ##args, strerror(errno))
  37. #endif /* _OPKG_MESSAGE_H_ */