diff options
Diffstat (limited to 'src/lib/libcrypto/bio/bss_log.c')
-rw-r--r-- | src/lib/libcrypto/bio/bss_log.c | 55 |
1 files changed, 13 insertions, 42 deletions
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c index 6360dbc820..7ead044b37 100644 --- a/src/lib/libcrypto/bio/bss_log.c +++ b/src/lib/libcrypto/bio/bss_log.c | |||
@@ -70,7 +70,6 @@ | |||
70 | 70 | ||
71 | #if defined(OPENSSL_SYS_WINCE) | 71 | #if defined(OPENSSL_SYS_WINCE) |
72 | #elif defined(OPENSSL_SYS_WIN32) | 72 | #elif defined(OPENSSL_SYS_WIN32) |
73 | # include <process.h> | ||
74 | #elif defined(OPENSSL_SYS_VMS) | 73 | #elif defined(OPENSSL_SYS_VMS) |
75 | # include <opcdef.h> | 74 | # include <opcdef.h> |
76 | # include <descrip.h> | 75 | # include <descrip.h> |
@@ -122,18 +121,6 @@ static int MS_CALLBACK slg_free(BIO *data); | |||
122 | static void xopenlog(BIO* bp, char* name, int level); | 121 | static void xopenlog(BIO* bp, char* name, int level); |
123 | static void xsyslog(BIO* bp, int priority, const char* string); | 122 | static void xsyslog(BIO* bp, int priority, const char* string); |
124 | static void xcloselog(BIO* bp); | 123 | static void xcloselog(BIO* bp); |
125 | #ifdef OPENSSL_SYS_WIN32 | ||
126 | LONG (WINAPI *go_for_advapi)() = RegOpenKeyEx; | ||
127 | HANDLE (WINAPI *register_event_source)() = NULL; | ||
128 | BOOL (WINAPI *deregister_event_source)() = NULL; | ||
129 | BOOL (WINAPI *report_event)() = NULL; | ||
130 | #define DL_PROC(m,f) (GetProcAddress( m, f )) | ||
131 | #ifdef UNICODE | ||
132 | #define DL_PROC_X(m,f) DL_PROC( m, f "W" ) | ||
133 | #else | ||
134 | #define DL_PROC_X(m,f) DL_PROC( m, f "A" ) | ||
135 | #endif | ||
136 | #endif | ||
137 | 124 | ||
138 | static BIO_METHOD methods_slg= | 125 | static BIO_METHOD methods_slg= |
139 | { | 126 | { |
@@ -175,7 +162,7 @@ static int MS_CALLBACK slg_write(BIO *b, const char *in, int inl) | |||
175 | char* buf; | 162 | char* buf; |
176 | char* pp; | 163 | char* pp; |
177 | int priority, i; | 164 | int priority, i; |
178 | static struct | 165 | static const struct |
179 | { | 166 | { |
180 | int strl; | 167 | int strl; |
181 | char str[10]; | 168 | char str[10]; |
@@ -249,35 +236,20 @@ static int MS_CALLBACK slg_puts(BIO *bp, const char *str) | |||
249 | 236 | ||
250 | static void xopenlog(BIO* bp, char* name, int level) | 237 | static void xopenlog(BIO* bp, char* name, int level) |
251 | { | 238 | { |
252 | if ( !register_event_source ) | 239 | if (GetVersion() < 0x80000000) |
253 | { | 240 | bp->ptr = RegisterEventSourceA(NULL,name); |
254 | HANDLE advapi; | 241 | else |
255 | if ( !(advapi = GetModuleHandle("advapi32")) ) | 242 | bp->ptr = NULL; |
256 | return; | ||
257 | register_event_source = (HANDLE (WINAPI *)())DL_PROC_X(advapi, | ||
258 | "RegisterEventSource" ); | ||
259 | deregister_event_source = (BOOL (WINAPI *)())DL_PROC(advapi, | ||
260 | "DeregisterEventSource"); | ||
261 | report_event = (BOOL (WINAPI *)())DL_PROC_X(advapi, | ||
262 | "ReportEvent" ); | ||
263 | if ( !(register_event_source && deregister_event_source && | ||
264 | report_event) ) | ||
265 | { | ||
266 | register_event_source = NULL; | ||
267 | deregister_event_source = NULL; | ||
268 | report_event = NULL; | ||
269 | return; | ||
270 | } | ||
271 | } | ||
272 | bp->ptr= (char *)register_event_source(NULL, name); | ||
273 | } | 243 | } |
274 | 244 | ||
275 | static void xsyslog(BIO *bp, int priority, const char *string) | 245 | static void xsyslog(BIO *bp, int priority, const char *string) |
276 | { | 246 | { |
277 | LPCSTR lpszStrings[2]; | 247 | LPCSTR lpszStrings[2]; |
278 | WORD evtype= EVENTLOG_ERROR_TYPE; | 248 | WORD evtype= EVENTLOG_ERROR_TYPE; |
279 | int pid = _getpid(); | 249 | char pidbuf[DECIMAL_SIZE(DWORD)+4]; |
280 | char pidbuf[DECIMAL_SIZE(pid)+4]; | 250 | |
251 | if (bp->ptr == NULL) | ||
252 | return; | ||
281 | 253 | ||
282 | switch (priority) | 254 | switch (priority) |
283 | { | 255 | { |
@@ -301,19 +273,18 @@ static void xsyslog(BIO *bp, int priority, const char *string) | |||
301 | break; | 273 | break; |
302 | } | 274 | } |
303 | 275 | ||
304 | sprintf(pidbuf, "[%d] ", pid); | 276 | sprintf(pidbuf, "[%u] ", GetCurrentProcessId()); |
305 | lpszStrings[0] = pidbuf; | 277 | lpszStrings[0] = pidbuf; |
306 | lpszStrings[1] = string; | 278 | lpszStrings[1] = string; |
307 | 279 | ||
308 | if(report_event && bp->ptr) | 280 | ReportEventA(bp->ptr, evtype, 0, 1024, NULL, 2, 0, |
309 | report_event(bp->ptr, evtype, 0, 1024, NULL, 2, 0, | ||
310 | lpszStrings, NULL); | 281 | lpszStrings, NULL); |
311 | } | 282 | } |
312 | 283 | ||
313 | static void xcloselog(BIO* bp) | 284 | static void xcloselog(BIO* bp) |
314 | { | 285 | { |
315 | if(deregister_event_source && bp->ptr) | 286 | if(bp->ptr) |
316 | deregister_event_source((HANDLE)(bp->ptr)); | 287 | DeregisterEventSource((HANDLE)(bp->ptr)); |
317 | bp->ptr= NULL; | 288 | bp->ptr= NULL; |
318 | } | 289 | } |
319 | 290 | ||