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