diff options
Diffstat (limited to 'src/lib/libcrypto/bio/bss_log.c')
-rw-r--r-- | src/lib/libcrypto/bio/bss_log.c | 199 |
1 files changed, 1 insertions, 198 deletions
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c index 9225af4df2..5a79f72673 100644 --- a/src/lib/libcrypto/bio/bss_log.c +++ b/src/lib/libcrypto/bio/bss_log.c | |||
@@ -68,59 +68,13 @@ | |||
68 | 68 | ||
69 | #include "cryptlib.h" | 69 | #include "cryptlib.h" |
70 | 70 | ||
71 | #if defined(OPENSSL_SYS_WINCE) | 71 | #include <syslog.h> |
72 | #elif defined(OPENSSL_SYS_WIN32) | ||
73 | #elif defined(OPENSSL_SYS_VMS) | ||
74 | # include <opcdef.h> | ||
75 | # include <descrip.h> | ||
76 | # include <lib$routines.h> | ||
77 | # include <starlet.h> | ||
78 | /* Some compiler options may mask the declaration of "_malloc32". */ | ||
79 | # if __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE | ||
80 | # if __INITIAL_POINTER_SIZE == 64 | ||
81 | # pragma pointer_size save | ||
82 | # pragma pointer_size 32 | ||
83 | void * _malloc32 (__size_t); | ||
84 | # pragma pointer_size restore | ||
85 | # endif /* __INITIAL_POINTER_SIZE == 64 */ | ||
86 | # endif /* __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE */ | ||
87 | #elif defined(__ultrix) | ||
88 | # include <sys/syslog.h> | ||
89 | #elif defined(OPENSSL_SYS_NETWARE) | ||
90 | # define NO_SYSLOG | ||
91 | #elif (!defined(MSDOS) || defined(WATT32)) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG) | ||
92 | # include <syslog.h> | ||
93 | #endif | ||
94 | 72 | ||
95 | #include <openssl/buffer.h> | 73 | #include <openssl/buffer.h> |
96 | #include <openssl/err.h> | 74 | #include <openssl/err.h> |
97 | 75 | ||
98 | #ifndef NO_SYSLOG | 76 | #ifndef NO_SYSLOG |
99 | 77 | ||
100 | #if defined(OPENSSL_SYS_WIN32) | ||
101 | #define LOG_EMERG 0 | ||
102 | #define LOG_ALERT 1 | ||
103 | #define LOG_CRIT 2 | ||
104 | #define LOG_ERR 3 | ||
105 | #define LOG_WARNING 4 | ||
106 | #define LOG_NOTICE 5 | ||
107 | #define LOG_INFO 6 | ||
108 | #define LOG_DEBUG 7 | ||
109 | |||
110 | #define LOG_DAEMON (3<<3) | ||
111 | #elif defined(OPENSSL_SYS_VMS) | ||
112 | /* On VMS, we don't really care about these, but we need them to compile */ | ||
113 | #define LOG_EMERG 0 | ||
114 | #define LOG_ALERT 1 | ||
115 | #define LOG_CRIT 2 | ||
116 | #define LOG_ERR 3 | ||
117 | #define LOG_WARNING 4 | ||
118 | #define LOG_NOTICE 5 | ||
119 | #define LOG_INFO 6 | ||
120 | #define LOG_DEBUG 7 | ||
121 | |||
122 | #define LOG_DAEMON OPC$M_NM_NTWORK | ||
123 | #endif | ||
124 | 78 | ||
125 | static int slg_write(BIO *h, const char *buf, int num); | 79 | static int slg_write(BIO *h, const char *buf, int num); |
126 | static int slg_puts(BIO *h, const char *str); | 80 | static int slg_puts(BIO *h, const char *str); |
@@ -245,161 +199,11 @@ slg_puts(BIO *bp, const char *str) | |||
245 | return (ret); | 199 | return (ret); |
246 | } | 200 | } |
247 | 201 | ||
248 | #if defined(OPENSSL_SYS_WIN32) | ||
249 | |||
250 | static void | ||
251 | xopenlog(BIO* bp, char* name, int level) | ||
252 | { | ||
253 | if (check_winnt()) | ||
254 | bp->ptr = RegisterEventSourceA(NULL, name); | ||
255 | else | ||
256 | bp->ptr = NULL; | ||
257 | } | ||
258 | |||
259 | static void | ||
260 | xsyslog(BIO *bp, int priority, const char *string) | ||
261 | { | ||
262 | LPCSTR lpszStrings[2]; | ||
263 | WORD evtype = EVENTLOG_ERROR_TYPE; | ||
264 | char pidbuf[DECIMAL_SIZE(DWORD) + 4]; | ||
265 | |||
266 | if (bp->ptr == NULL) | ||
267 | return; | ||
268 | |||
269 | switch (priority) { | ||
270 | case LOG_EMERG: | ||
271 | case LOG_ALERT: | ||
272 | case LOG_CRIT: | ||
273 | case LOG_ERR: | ||
274 | evtype = EVENTLOG_ERROR_TYPE; | ||
275 | break; | ||
276 | case LOG_WARNING: | ||
277 | evtype = EVENTLOG_WARNING_TYPE; | ||
278 | break; | ||
279 | case LOG_NOTICE: | ||
280 | case LOG_INFO: | ||
281 | case LOG_DEBUG: | ||
282 | evtype = EVENTLOG_INFORMATION_TYPE; | ||
283 | break; | ||
284 | default: /* Should never happen, but set it | ||
285 | as error anyway. */ | ||
286 | evtype = EVENTLOG_ERROR_TYPE; | ||
287 | break; | ||
288 | } | ||
289 | |||
290 | sprintf(pidbuf, "[%u] ", GetCurrentProcessId()); | ||
291 | lpszStrings[0] = pidbuf; | ||
292 | lpszStrings[1] = string; | ||
293 | |||
294 | ReportEventA(bp->ptr, evtype, 0, 1024, NULL, 2, 0, | ||
295 | lpszStrings, NULL); | ||
296 | } | ||
297 | |||
298 | static void | ||
299 | xcloselog(BIO* bp) | ||
300 | { | ||
301 | if (bp->ptr) | ||
302 | DeregisterEventSource((HANDLE)(bp->ptr)); | ||
303 | bp->ptr = NULL; | ||
304 | } | ||
305 | |||
306 | #elif defined(OPENSSL_SYS_VMS) | ||
307 | |||
308 | static int VMS_OPC_target = LOG_DAEMON; | ||
309 | |||
310 | static void | ||
311 | xopenlog(BIO* bp, char* name, int level) | ||
312 | { | ||
313 | VMS_OPC_target = level; | ||
314 | |||
315 | } | ||
316 | |||
317 | static void | ||
318 | xsyslog(BIO *bp, int priority, const char *string) | ||
319 | { | ||
320 | struct dsc$descriptor_s opc_dsc; | ||
321 | |||
322 | /* Arrange 32-bit pointer to opcdef buffer and malloc(), if needed. */ | ||
323 | #if __INITIAL_POINTER_SIZE == 64 | ||
324 | # pragma pointer_size save | ||
325 | # pragma pointer_size 32 | ||
326 | # define OPCDEF_TYPE __char_ptr32 | ||
327 | # define OPCDEF_MALLOC _malloc32 | ||
328 | #else /* __INITIAL_POINTER_SIZE == 64 */ | ||
329 | # define OPCDEF_TYPE char * | ||
330 | # define OPCDEF_MALLOC OPENSSL_malloc | ||
331 | #endif /* __INITIAL_POINTER_SIZE == 64 [else] */ | ||
332 | |||
333 | struct opcdef *opcdef_p; | ||
334 | |||
335 | #if __INITIAL_POINTER_SIZE == 64 | ||
336 | # pragma pointer_size restore | ||
337 | #endif /* __INITIAL_POINTER_SIZE == 64 */ | ||
338 | |||
339 | char buf[10240]; | ||
340 | unsigned int len; | ||
341 | struct dsc$descriptor_s buf_dsc; | ||
342 | $DESCRIPTOR(fao_cmd, "!AZ: !AZ"); | ||
343 | char *priority_tag; | ||
344 | |||
345 | switch (priority) { | ||
346 | case LOG_EMERG: | ||
347 | priority_tag = "Emergency"; break; | ||
348 | case LOG_ALERT: | ||
349 | priority_tag = "Alert"; break; | ||
350 | case LOG_CRIT: | ||
351 | priority_tag = "Critical"; break; | ||
352 | case LOG_ERR: | ||
353 | priority_tag = "Error"; break; | ||
354 | case LOG_WARNING: | ||
355 | priority_tag = "Warning"; break; | ||
356 | case LOG_NOTICE: | ||
357 | priority_tag = "Notice"; break; | ||
358 | case LOG_INFO: | ||
359 | priority_tag = "Info"; break; | ||
360 | case LOG_DEBUG: | ||
361 | priority_tag = "DEBUG"; break; | ||
362 | } | ||
363 | |||
364 | buf_dsc.dsc$b_dtype = DSC$K_DTYPE_T; | ||
365 | buf_dsc.dsc$b_class = DSC$K_CLASS_S; | ||
366 | buf_dsc.dsc$a_pointer = buf; | ||
367 | buf_dsc.dsc$w_length = sizeof(buf) - 1; | ||
368 | |||
369 | lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string); | ||
370 | |||
371 | /* We know there's an 8-byte header. That's documented. */ | ||
372 | opcdef_p = OPCDEF_MALLOC( 8 + len); | ||
373 | opcdef_p->opc$b_ms_type = OPC$_RQ_RQST; | ||
374 | memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3); | ||
375 | opcdef_p->opc$l_ms_rqstid = 0; | ||
376 | memcpy(&opcdef_p->opc$l_ms_text, buf, len); | ||
377 | |||
378 | opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T; | ||
379 | opc_dsc.dsc$b_class = DSC$K_CLASS_S; | ||
380 | opc_dsc.dsc$a_pointer = (OPCDEF_TYPE) opcdef_p; | ||
381 | opc_dsc.dsc$w_length = len + 8; | ||
382 | |||
383 | sys$sndopr(opc_dsc, 0); | ||
384 | |||
385 | OPENSSL_free(opcdef_p); | ||
386 | } | ||
387 | |||
388 | static void | ||
389 | xcloselog(BIO* bp) | ||
390 | { | ||
391 | } | ||
392 | |||
393 | #else /* Unix/Watt32 */ | ||
394 | 202 | ||
395 | static void | 203 | static void |
396 | xopenlog(BIO* bp, char* name, int level) | 204 | xopenlog(BIO* bp, char* name, int level) |
397 | { | 205 | { |
398 | #ifdef WATT32 /* djgpp/DOS */ | ||
399 | openlog(name, LOG_PID|LOG_CONS|LOG_NDELAY, level); | ||
400 | #else | ||
401 | openlog(name, LOG_PID|LOG_CONS, level); | 206 | openlog(name, LOG_PID|LOG_CONS, level); |
402 | #endif | ||
403 | } | 207 | } |
404 | 208 | ||
405 | static void | 209 | static void |
@@ -414,6 +218,5 @@ xcloselog(BIO* bp) | |||
414 | closelog(); | 218 | closelog(); |
415 | } | 219 | } |
416 | 220 | ||
417 | #endif /* Unix */ | ||
418 | 221 | ||
419 | #endif /* NO_SYSLOG */ | 222 | #endif /* NO_SYSLOG */ |