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