Commit | Line | Data |
---|---|---|
8ce86de8 GS |
1 | #include "EXTERN.h" |
2 | #include "perl.h" | |
3 | #include "XSUB.h" | |
1307ca85 JH |
4 | #ifdef USE_PPPORT_H |
5 | # include "ppport.h" | |
6 | #endif | |
8ce86de8 | 7 | |
a650b841 AT |
8 | #ifndef HAVE_SYSLOG |
9 | #define HAVE_SYSLOG 1 | |
10 | #endif | |
11 | ||
a650b841 | 12 | #if defined(_WIN32) && !defined(__CYGWIN__) |
f93f88eb AT |
13 | # undef HAVE_SYSLOG |
14 | # include "fallback/syslog.h" | |
15 | #else | |
16 | # if defined(I_SYSLOG) || PATCHLEVEL < 6 | |
17 | # include <syslog.h> | |
18 | # endif | |
a650b841 AT |
19 | #endif |
20 | ||
89c3c464 AT |
21 | static SV *ident_svptr; |
22 | ||
1cb0fb50 | 23 | #include "const-c.inc" |
8ce86de8 | 24 | |
8ce86de8 GS |
25 | MODULE = Sys::Syslog PACKAGE = Sys::Syslog |
26 | ||
1cb0fb50 | 27 | INCLUDE: const-xs.inc |
8ce86de8 GS |
28 | |
29 | int | |
30 | LOG_FAC(p) | |
31 | INPUT: | |
32 | int p | |
33 | CODE: | |
34 | #ifdef LOG_FAC | |
35 | RETVAL = LOG_FAC(p); | |
36 | #else | |
37 | croak("Your vendor has not defined the Sys::Syslog macro LOG_FAC"); | |
b621ec8a | 38 | RETVAL = -1; |
8ce86de8 GS |
39 | #endif |
40 | OUTPUT: | |
41 | RETVAL | |
42 | ||
43 | int | |
44 | LOG_PRI(p) | |
45 | INPUT: | |
46 | int p | |
47 | CODE: | |
48 | #ifdef LOG_PRI | |
49 | RETVAL = LOG_PRI(p); | |
50 | #else | |
51 | croak("Your vendor has not defined the Sys::Syslog macro LOG_PRI"); | |
b621ec8a | 52 | RETVAL = -1; |
8ce86de8 GS |
53 | #endif |
54 | OUTPUT: | |
55 | RETVAL | |
56 | ||
57 | int | |
58 | LOG_MAKEPRI(fac,pri) | |
59 | INPUT: | |
60 | int fac | |
61 | int pri | |
62 | CODE: | |
63 | #ifdef LOG_MAKEPRI | |
64 | RETVAL = LOG_MAKEPRI(fac,pri); | |
65 | #else | |
66 | croak("Your vendor has not defined the Sys::Syslog macro LOG_MAKEPRI"); | |
b621ec8a | 67 | RETVAL = -1; |
8ce86de8 GS |
68 | #endif |
69 | OUTPUT: | |
70 | RETVAL | |
71 | ||
72 | int | |
73 | LOG_MASK(pri) | |
74 | INPUT: | |
75 | int pri | |
76 | CODE: | |
77 | #ifdef LOG_MASK | |
78 | RETVAL = LOG_MASK(pri); | |
79 | #else | |
80 | croak("Your vendor has not defined the Sys::Syslog macro LOG_MASK"); | |
b621ec8a | 81 | RETVAL = -1; |
8ce86de8 GS |
82 | #endif |
83 | OUTPUT: | |
84 | RETVAL | |
85 | ||
86 | int | |
87 | LOG_UPTO(pri) | |
88 | INPUT: | |
89 | int pri | |
90 | CODE: | |
91 | #ifdef LOG_UPTO | |
92 | RETVAL = LOG_UPTO(pri); | |
93 | #else | |
94 | croak("Your vendor has not defined the Sys::Syslog macro LOG_UPTO"); | |
b621ec8a | 95 | RETVAL = -1; |
8ce86de8 GS |
96 | #endif |
97 | OUTPUT: | |
98 | RETVAL | |
89c3c464 | 99 | |
a650b841 | 100 | #ifdef HAVE_SYSLOG |
89c3c464 AT |
101 | |
102 | void | |
103 | openlog_xs(ident, option, facility) | |
104 | INPUT: | |
105 | SV* ident | |
106 | int option | |
107 | int facility | |
108 | PREINIT: | |
109 | STRLEN len; | |
110 | char* ident_pv; | |
111 | CODE: | |
112 | ident_svptr = newSVsv(ident); | |
113 | ident_pv = SvPV(ident_svptr, len); | |
114 | openlog(ident_pv, option, facility); | |
115 | ||
116 | void | |
117 | syslog_xs(priority, message) | |
118 | INPUT: | |
119 | int priority | |
120 | const char * message | |
121 | CODE: | |
122 | syslog(priority, "%s", message); | |
123 | ||
124 | int | |
125 | setlogmask_xs(mask) | |
126 | INPUT: | |
127 | int mask | |
128 | CODE: | |
f93f88eb AT |
129 | RETVAL = setlogmask(mask); |
130 | OUTPUT: | |
131 | RETVAL | |
89c3c464 AT |
132 | |
133 | void | |
134 | closelog_xs() | |
135 | CODE: | |
136 | closelog(); | |
137 | if (SvREFCNT(ident_svptr)) | |
138 | SvREFCNT_dec(ident_svptr); | |
139 | ||
a650b841 | 140 | #endif /* HAVE_SYSLOG */ |