syslog.c 964 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * <syslog.h> wrapper functions.
  3. *
  4. * Authors:
  5. * Jonathan Pryor ([email protected])
  6. *
  7. * Copyright (C) 2005 Jonathan Pryor
  8. */
  9. #include <stdarg.h>
  10. #include <syslog.h>
  11. #include <errno.h>
  12. #include "map.h"
  13. #include "mph.h"
  14. #include <glib.h>
  15. G_BEGIN_DECLS
  16. int
  17. Mono_Posix_Syscall_openlog (void* ident, int option, int facility)
  18. {
  19. errno = 0;
  20. openlog ((const char*) ident, option, facility);
  21. return errno == 0 ? 0 : -1;
  22. }
  23. int
  24. Mono_Posix_Syscall_closelog (void)
  25. {
  26. errno = 0;
  27. closelog ();
  28. return errno == 0 ? 0 : -1;
  29. }
  30. int
  31. Mono_Posix_Syscall_syslog (int priority, const char* message)
  32. {
  33. errno = 0;
  34. syslog (priority, message);
  35. return errno == 0 ? 0 : -1;
  36. }
  37. /* vararg version of syslog(3). */
  38. gint32
  39. Mono_Posix_Syscall_syslog2 (int priority, const char *format, ...)
  40. {
  41. va_list ap;
  42. errno = 0;
  43. va_start (ap, format);
  44. vsyslog (priority, format, ap);
  45. va_end (ap);
  46. if (errno != 0)
  47. return -1;
  48. return 0;
  49. }
  50. G_END_DECLS
  51. /*
  52. * vim: noexpandtab
  53. */