xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/ext/Sys/Syslog/Syslog.xs (revision 8243:601214671c81)
1*8243SVladimir.Marek@Sun.COM #if defined(_WIN32)
2*8243SVladimir.Marek@Sun.COM #  include <windows.h>
3*8243SVladimir.Marek@Sun.COM #endif
4*8243SVladimir.Marek@Sun.COM 
50Sstevel@tonic-gate #include "EXTERN.h"
60Sstevel@tonic-gate #include "perl.h"
70Sstevel@tonic-gate #include "XSUB.h"
8*8243SVladimir.Marek@Sun.COM #ifdef USE_PPPORT_H
9*8243SVladimir.Marek@Sun.COM #  include "ppport.h"
10*8243SVladimir.Marek@Sun.COM #endif
110Sstevel@tonic-gate 
12*8243SVladimir.Marek@Sun.COM #ifndef HAVE_SYSLOG
13*8243SVladimir.Marek@Sun.COM #define HAVE_SYSLOG 1
140Sstevel@tonic-gate #endif
150Sstevel@tonic-gate 
16*8243SVladimir.Marek@Sun.COM #if defined(_WIN32) && !defined(__CYGWIN__)
17*8243SVladimir.Marek@Sun.COM #  undef HAVE_SYSLOG
18*8243SVladimir.Marek@Sun.COM #  include "fallback/syslog.h"
19*8243SVladimir.Marek@Sun.COM #else
20*8243SVladimir.Marek@Sun.COM #  if defined(I_SYSLOG) || PATCHLEVEL < 6
21*8243SVladimir.Marek@Sun.COM #    include <syslog.h>
22*8243SVladimir.Marek@Sun.COM #  endif
23*8243SVladimir.Marek@Sun.COM #endif
24*8243SVladimir.Marek@Sun.COM 
25*8243SVladimir.Marek@Sun.COM static SV *ident_svptr;
26*8243SVladimir.Marek@Sun.COM 
270Sstevel@tonic-gate #include "const-c.inc"
280Sstevel@tonic-gate 
290Sstevel@tonic-gate MODULE = Sys::Syslog		PACKAGE = Sys::Syslog
300Sstevel@tonic-gate 
310Sstevel@tonic-gate INCLUDE: const-xs.inc
320Sstevel@tonic-gate 
330Sstevel@tonic-gate int
340Sstevel@tonic-gate LOG_FAC(p)
350Sstevel@tonic-gate     INPUT:
360Sstevel@tonic-gate 	int		p
370Sstevel@tonic-gate     CODE:
380Sstevel@tonic-gate #ifdef LOG_FAC
390Sstevel@tonic-gate 	RETVAL = LOG_FAC(p);
400Sstevel@tonic-gate #else
410Sstevel@tonic-gate 	croak("Your vendor has not defined the Sys::Syslog macro LOG_FAC");
420Sstevel@tonic-gate 	RETVAL = -1;
430Sstevel@tonic-gate #endif
440Sstevel@tonic-gate     OUTPUT:
450Sstevel@tonic-gate 	RETVAL
460Sstevel@tonic-gate 
470Sstevel@tonic-gate int
480Sstevel@tonic-gate LOG_PRI(p)
490Sstevel@tonic-gate     INPUT:
500Sstevel@tonic-gate 	int		p
510Sstevel@tonic-gate     CODE:
520Sstevel@tonic-gate #ifdef LOG_PRI
530Sstevel@tonic-gate 	RETVAL = LOG_PRI(p);
540Sstevel@tonic-gate #else
550Sstevel@tonic-gate 	croak("Your vendor has not defined the Sys::Syslog macro LOG_PRI");
560Sstevel@tonic-gate 	RETVAL = -1;
570Sstevel@tonic-gate #endif
580Sstevel@tonic-gate     OUTPUT:
590Sstevel@tonic-gate 	RETVAL
600Sstevel@tonic-gate 
610Sstevel@tonic-gate int
620Sstevel@tonic-gate LOG_MAKEPRI(fac,pri)
630Sstevel@tonic-gate     INPUT:
640Sstevel@tonic-gate 	int		fac
650Sstevel@tonic-gate 	int		pri
660Sstevel@tonic-gate     CODE:
670Sstevel@tonic-gate #ifdef LOG_MAKEPRI
680Sstevel@tonic-gate 	RETVAL = LOG_MAKEPRI(fac,pri);
690Sstevel@tonic-gate #else
700Sstevel@tonic-gate 	croak("Your vendor has not defined the Sys::Syslog macro LOG_MAKEPRI");
710Sstevel@tonic-gate 	RETVAL = -1;
720Sstevel@tonic-gate #endif
730Sstevel@tonic-gate     OUTPUT:
740Sstevel@tonic-gate 	RETVAL
750Sstevel@tonic-gate 
760Sstevel@tonic-gate int
770Sstevel@tonic-gate LOG_MASK(pri)
780Sstevel@tonic-gate     INPUT:
790Sstevel@tonic-gate 	int		pri
800Sstevel@tonic-gate     CODE:
810Sstevel@tonic-gate #ifdef LOG_MASK
820Sstevel@tonic-gate 	RETVAL = LOG_MASK(pri);
830Sstevel@tonic-gate #else
840Sstevel@tonic-gate 	croak("Your vendor has not defined the Sys::Syslog macro LOG_MASK");
850Sstevel@tonic-gate 	RETVAL = -1;
860Sstevel@tonic-gate #endif
870Sstevel@tonic-gate     OUTPUT:
880Sstevel@tonic-gate 	RETVAL
890Sstevel@tonic-gate 
900Sstevel@tonic-gate int
910Sstevel@tonic-gate LOG_UPTO(pri)
920Sstevel@tonic-gate     INPUT:
930Sstevel@tonic-gate 	int		pri
940Sstevel@tonic-gate     CODE:
950Sstevel@tonic-gate #ifdef LOG_UPTO
960Sstevel@tonic-gate 	RETVAL = LOG_UPTO(pri);
970Sstevel@tonic-gate #else
980Sstevel@tonic-gate 	croak("Your vendor has not defined the Sys::Syslog macro LOG_UPTO");
990Sstevel@tonic-gate 	RETVAL = -1;
1000Sstevel@tonic-gate #endif
1010Sstevel@tonic-gate     OUTPUT:
1020Sstevel@tonic-gate 	RETVAL
103*8243SVladimir.Marek@Sun.COM 
104*8243SVladimir.Marek@Sun.COM #ifdef HAVE_SYSLOG
105*8243SVladimir.Marek@Sun.COM 
106*8243SVladimir.Marek@Sun.COM void
107*8243SVladimir.Marek@Sun.COM openlog_xs(ident, option, facility)
108*8243SVladimir.Marek@Sun.COM     INPUT:
109*8243SVladimir.Marek@Sun.COM         SV*   ident
110*8243SVladimir.Marek@Sun.COM         int   option
111*8243SVladimir.Marek@Sun.COM         int   facility
112*8243SVladimir.Marek@Sun.COM     PREINIT:
113*8243SVladimir.Marek@Sun.COM         STRLEN len;
114*8243SVladimir.Marek@Sun.COM         char*  ident_pv;
115*8243SVladimir.Marek@Sun.COM     CODE:
116*8243SVladimir.Marek@Sun.COM         ident_svptr = newSVsv(ident);
117*8243SVladimir.Marek@Sun.COM         ident_pv    = SvPV(ident_svptr, len);
118*8243SVladimir.Marek@Sun.COM         openlog(ident_pv, option, facility);
119*8243SVladimir.Marek@Sun.COM 
120*8243SVladimir.Marek@Sun.COM void
121*8243SVladimir.Marek@Sun.COM syslog_xs(priority, message)
122*8243SVladimir.Marek@Sun.COM     INPUT:
123*8243SVladimir.Marek@Sun.COM         int   priority
124*8243SVladimir.Marek@Sun.COM         const char * message
125*8243SVladimir.Marek@Sun.COM     CODE:
126*8243SVladimir.Marek@Sun.COM         syslog(priority, "%s", message);
127*8243SVladimir.Marek@Sun.COM 
128*8243SVladimir.Marek@Sun.COM int
129*8243SVladimir.Marek@Sun.COM setlogmask_xs(mask)
130*8243SVladimir.Marek@Sun.COM     INPUT:
131*8243SVladimir.Marek@Sun.COM         int mask
132*8243SVladimir.Marek@Sun.COM     CODE:
133*8243SVladimir.Marek@Sun.COM         RETVAL = setlogmask(mask);
134*8243SVladimir.Marek@Sun.COM     OUTPUT:
135*8243SVladimir.Marek@Sun.COM         RETVAL
136*8243SVladimir.Marek@Sun.COM 
137*8243SVladimir.Marek@Sun.COM void
138*8243SVladimir.Marek@Sun.COM closelog_xs()
139*8243SVladimir.Marek@Sun.COM     CODE:
140*8243SVladimir.Marek@Sun.COM         closelog();
141*8243SVladimir.Marek@Sun.COM         if (SvREFCNT(ident_svptr))
142*8243SVladimir.Marek@Sun.COM             SvREFCNT_dec(ident_svptr);
143*8243SVladimir.Marek@Sun.COM 
144*8243SVladimir.Marek@Sun.COM #else  /* HAVE_SYSLOG */
145*8243SVladimir.Marek@Sun.COM 
146*8243SVladimir.Marek@Sun.COM void
147*8243SVladimir.Marek@Sun.COM openlog_xs(ident, option, facility)
148*8243SVladimir.Marek@Sun.COM     INPUT:
149*8243SVladimir.Marek@Sun.COM         SV*   ident
150*8243SVladimir.Marek@Sun.COM         int   option
151*8243SVladimir.Marek@Sun.COM         int   facility
152*8243SVladimir.Marek@Sun.COM     CODE:
153*8243SVladimir.Marek@Sun.COM 
154*8243SVladimir.Marek@Sun.COM void
155*8243SVladimir.Marek@Sun.COM syslog_xs(priority, message)
156*8243SVladimir.Marek@Sun.COM     INPUT:
157*8243SVladimir.Marek@Sun.COM         int   priority
158*8243SVladimir.Marek@Sun.COM         const char * message
159*8243SVladimir.Marek@Sun.COM     CODE:
160*8243SVladimir.Marek@Sun.COM 
161*8243SVladimir.Marek@Sun.COM int
162*8243SVladimir.Marek@Sun.COM setlogmask_xs(mask)
163*8243SVladimir.Marek@Sun.COM     INPUT:
164*8243SVladimir.Marek@Sun.COM         int mask
165*8243SVladimir.Marek@Sun.COM     CODE:
166*8243SVladimir.Marek@Sun.COM 
167*8243SVladimir.Marek@Sun.COM void
168*8243SVladimir.Marek@Sun.COM closelog_xs()
169*8243SVladimir.Marek@Sun.COM     CODE:
170*8243SVladimir.Marek@Sun.COM 
171*8243SVladimir.Marek@Sun.COM #endif /* HAVE_SYSLOG */
172