line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
2
|
|
|
|
|
|
|
#include "perl.h" |
3
|
|
|
|
|
|
|
#include "XSUB.h" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "ppport.h" |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#include "LogSyslogFast.h" |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#include "const-c.inc" |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
MODULE = Log::Syslog::Fast PACKAGE = Log::Syslog::Fast |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
INCLUDE: const-xs.inc |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
LogSyslogFast* |
18
|
|
|
|
|
|
|
new(class, proto, hostname, port, facility, severity, sender, name) |
19
|
|
|
|
|
|
|
char* class |
20
|
|
|
|
|
|
|
int proto |
21
|
|
|
|
|
|
|
char* hostname |
22
|
|
|
|
|
|
|
int port |
23
|
|
|
|
|
|
|
int facility |
24
|
|
|
|
|
|
|
int severity |
25
|
|
|
|
|
|
|
char* sender |
26
|
|
|
|
|
|
|
char* name |
27
|
|
|
|
|
|
|
CODE: |
28
|
40
|
100
|
|
|
|
|
if (!hostname) |
29
|
1
|
|
|
|
|
|
croak("hostname required"); |
30
|
39
|
100
|
|
|
|
|
if (!sender) |
31
|
1
|
|
|
|
|
|
croak("sender required"); |
32
|
38
|
100
|
|
|
|
|
if (!name) |
33
|
1
|
|
|
|
|
|
croak("name required"); |
34
|
37
|
|
|
|
|
|
RETVAL = LSF_alloc(); |
35
|
37
|
50
|
|
|
|
|
if (!RETVAL) |
36
|
0
|
|
|
|
|
|
croak("Error in ->new: malloc failed"); |
37
|
37
|
100
|
|
|
|
|
if (LSF_init(RETVAL, proto, hostname, port, facility, severity, sender, name) < 0) |
38
|
9
|
|
|
|
|
|
croak("Error in ->new: %s", RETVAL->err); |
39
|
|
|
|
|
|
|
OUTPUT: |
40
|
|
|
|
|
|
|
RETVAL |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
void |
43
|
|
|
|
|
|
|
DESTROY(logger) |
44
|
|
|
|
|
|
|
LogSyslogFast* logger |
45
|
|
|
|
|
|
|
CODE: |
46
|
28
|
50
|
|
|
|
|
if (LSF_destroy(logger)) |
47
|
0
|
|
|
|
|
|
croak("Error in close: %s", logger->err); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
int |
50
|
|
|
|
|
|
|
send(logger, logmsg, now = time(0)) |
51
|
|
|
|
|
|
|
LogSyslogFast* logger |
52
|
|
|
|
|
|
|
SV* logmsg |
53
|
|
|
|
|
|
|
time_t now |
54
|
|
|
|
|
|
|
ALIAS: |
55
|
|
|
|
|
|
|
emit = 1 |
56
|
|
|
|
|
|
|
INIT: |
57
|
|
|
|
|
|
|
STRLEN msglen; |
58
|
|
|
|
|
|
|
const char* msgstr; |
59
|
35
|
50
|
|
|
|
|
msgstr = SvPV(logmsg, msglen); |
60
|
|
|
|
|
|
|
CODE: |
61
|
35
|
|
|
|
|
|
RETVAL = LSF_send(logger, msgstr, msglen, now); |
62
|
35
|
100
|
|
|
|
|
if (RETVAL < 0) |
63
|
5
|
|
|
|
|
|
croak("Error while sending: %s", logger->err); |
64
|
|
|
|
|
|
|
OUTPUT: |
65
|
|
|
|
|
|
|
RETVAL |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
void |
68
|
|
|
|
|
|
|
set_receiver(logger, proto, hostname, port) |
69
|
|
|
|
|
|
|
LogSyslogFast* logger |
70
|
|
|
|
|
|
|
int proto |
71
|
|
|
|
|
|
|
char* hostname |
72
|
|
|
|
|
|
|
int port |
73
|
|
|
|
|
|
|
ALIAS: |
74
|
|
|
|
|
|
|
setReceiver = 1 |
75
|
|
|
|
|
|
|
CODE: |
76
|
108
|
50
|
|
|
|
|
if (!hostname) |
77
|
0
|
|
|
|
|
|
croak("hostname required"); |
78
|
108
|
|
|
|
|
|
int ret = LSF_set_receiver(logger, proto, hostname, port); |
79
|
108
|
50
|
|
|
|
|
if (ret < 0) |
80
|
0
|
|
|
|
|
|
croak("Error in set_receiver: %s", logger->err); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
void |
83
|
|
|
|
|
|
|
set_priority(logger, facility, severity) |
84
|
|
|
|
|
|
|
LogSyslogFast* logger |
85
|
|
|
|
|
|
|
int facility |
86
|
|
|
|
|
|
|
int severity |
87
|
|
|
|
|
|
|
ALIAS: |
88
|
|
|
|
|
|
|
setPriority = 1 |
89
|
|
|
|
|
|
|
CODE: |
90
|
9
|
|
|
|
|
|
LSF_set_priority(logger, facility, severity); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
void |
93
|
|
|
|
|
|
|
set_facility(logger, facility) |
94
|
|
|
|
|
|
|
LogSyslogFast* logger |
95
|
|
|
|
|
|
|
int facility |
96
|
|
|
|
|
|
|
CODE: |
97
|
1
|
|
|
|
|
|
LSF_set_facility(logger, facility); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
void |
100
|
|
|
|
|
|
|
set_severity(logger, severity) |
101
|
|
|
|
|
|
|
LogSyslogFast* logger |
102
|
|
|
|
|
|
|
int severity |
103
|
|
|
|
|
|
|
CODE: |
104
|
1
|
|
|
|
|
|
LSF_set_severity(logger, severity); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
void |
107
|
|
|
|
|
|
|
set_sender(logger, sender) |
108
|
|
|
|
|
|
|
LogSyslogFast* logger |
109
|
|
|
|
|
|
|
char* sender |
110
|
|
|
|
|
|
|
ALIAS: |
111
|
|
|
|
|
|
|
setSender = 1 |
112
|
|
|
|
|
|
|
CODE: |
113
|
10
|
100
|
|
|
|
|
if (!sender) |
114
|
1
|
|
|
|
|
|
croak("sender required"); |
115
|
9
|
|
|
|
|
|
int ret = LSF_set_sender(logger, sender); |
116
|
9
|
50
|
|
|
|
|
if (ret < 0) |
117
|
0
|
|
|
|
|
|
croak("Error in set_sender: %s", logger->err); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
void |
120
|
|
|
|
|
|
|
set_name(logger, name) |
121
|
|
|
|
|
|
|
LogSyslogFast* logger |
122
|
|
|
|
|
|
|
char* name |
123
|
|
|
|
|
|
|
ALIAS: |
124
|
|
|
|
|
|
|
setName = 1 |
125
|
|
|
|
|
|
|
CODE: |
126
|
10
|
100
|
|
|
|
|
if (!name) |
127
|
1
|
|
|
|
|
|
croak("name required"); |
128
|
9
|
|
|
|
|
|
int ret = LSF_set_name(logger, name); |
129
|
9
|
50
|
|
|
|
|
if (ret < 0) |
130
|
0
|
|
|
|
|
|
croak("Error in set_name: %s", logger->err); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
void |
133
|
|
|
|
|
|
|
set_pid(logger, pid) |
134
|
|
|
|
|
|
|
LogSyslogFast* logger |
135
|
|
|
|
|
|
|
int pid |
136
|
|
|
|
|
|
|
ALIAS: |
137
|
|
|
|
|
|
|
setPid = 1 |
138
|
|
|
|
|
|
|
CODE: |
139
|
9
|
|
|
|
|
|
LSF_set_pid(logger, pid); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
void |
142
|
|
|
|
|
|
|
set_format(logger, format) |
143
|
|
|
|
|
|
|
LogSyslogFast* logger |
144
|
|
|
|
|
|
|
int format |
145
|
|
|
|
|
|
|
ALIAS: |
146
|
|
|
|
|
|
|
setFormat = 1 |
147
|
|
|
|
|
|
|
CODE: |
148
|
14
|
|
|
|
|
|
int ret = LSF_set_format(logger, format); |
149
|
14
|
50
|
|
|
|
|
if (ret < 0) |
150
|
0
|
|
|
|
|
|
croak("Error in set_format: %s", logger->err); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
int |
153
|
|
|
|
|
|
|
get_priority(logger) |
154
|
|
|
|
|
|
|
LogSyslogFast* logger |
155
|
|
|
|
|
|
|
CODE: |
156
|
3
|
|
|
|
|
|
RETVAL = LSF_get_priority(logger); |
157
|
|
|
|
|
|
|
OUTPUT: |
158
|
|
|
|
|
|
|
RETVAL |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
int |
161
|
|
|
|
|
|
|
get_facility(logger) |
162
|
|
|
|
|
|
|
LogSyslogFast* logger |
163
|
|
|
|
|
|
|
CODE: |
164
|
2
|
|
|
|
|
|
RETVAL = LSF_get_facility(logger); |
165
|
|
|
|
|
|
|
OUTPUT: |
166
|
|
|
|
|
|
|
RETVAL |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
int |
169
|
|
|
|
|
|
|
get_severity(logger) |
170
|
|
|
|
|
|
|
LogSyslogFast* logger |
171
|
|
|
|
|
|
|
CODE: |
172
|
2
|
|
|
|
|
|
RETVAL = LSF_get_severity(logger); |
173
|
|
|
|
|
|
|
OUTPUT: |
174
|
|
|
|
|
|
|
RETVAL |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
const char* |
177
|
|
|
|
|
|
|
get_sender(logger) |
178
|
|
|
|
|
|
|
LogSyslogFast* logger |
179
|
|
|
|
|
|
|
CODE: |
180
|
2
|
|
|
|
|
|
RETVAL = LSF_get_sender(logger); |
181
|
|
|
|
|
|
|
OUTPUT: |
182
|
|
|
|
|
|
|
RETVAL |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
const char* |
185
|
|
|
|
|
|
|
get_name(logger) |
186
|
|
|
|
|
|
|
LogSyslogFast* logger |
187
|
|
|
|
|
|
|
CODE: |
188
|
2
|
|
|
|
|
|
RETVAL = LSF_get_name(logger); |
189
|
|
|
|
|
|
|
OUTPUT: |
190
|
|
|
|
|
|
|
RETVAL |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
int |
193
|
|
|
|
|
|
|
get_pid(logger) |
194
|
|
|
|
|
|
|
LogSyslogFast* logger |
195
|
|
|
|
|
|
|
CODE: |
196
|
2
|
|
|
|
|
|
RETVAL = LSF_get_pid(logger); |
197
|
|
|
|
|
|
|
OUTPUT: |
198
|
|
|
|
|
|
|
RETVAL |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
int |
201
|
|
|
|
|
|
|
get_format(logger) |
202
|
|
|
|
|
|
|
LogSyslogFast* logger |
203
|
|
|
|
|
|
|
CODE: |
204
|
0
|
|
|
|
|
|
RETVAL = LSF_get_format(logger); |
205
|
|
|
|
|
|
|
OUTPUT: |
206
|
|
|
|
|
|
|
RETVAL |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
int |
209
|
|
|
|
|
|
|
_get_sock(logger) |
210
|
|
|
|
|
|
|
LogSyslogFast* logger |
211
|
|
|
|
|
|
|
CODE: |
212
|
2
|
|
|
|
|
|
RETVAL = LSF_get_sock(logger); |
213
|
|
|
|
|
|
|
OUTPUT: |
214
|
|
|
|
|
|
|
RETVAL |