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