Fix bss_log.c on Windows.
This commit is contained in:
parent
5e4430e70d
commit
befe1fbc29
1 changed files with 12 additions and 41 deletions
|
@ -70,7 +70,6 @@
|
||||||
|
|
||||||
#if defined(OPENSSL_SYS_WINCE)
|
#if defined(OPENSSL_SYS_WINCE)
|
||||||
#elif defined(OPENSSL_SYS_WIN32)
|
#elif defined(OPENSSL_SYS_WIN32)
|
||||||
# include <process.h>
|
|
||||||
#elif defined(OPENSSL_SYS_VMS)
|
#elif defined(OPENSSL_SYS_VMS)
|
||||||
# include <opcdef.h>
|
# include <opcdef.h>
|
||||||
# include <descrip.h>
|
# include <descrip.h>
|
||||||
|
@ -122,18 +121,6 @@ static int MS_CALLBACK slg_free(BIO *data);
|
||||||
static void xopenlog(BIO* bp, char* name, int level);
|
static void xopenlog(BIO* bp, char* name, int level);
|
||||||
static void xsyslog(BIO* bp, int priority, const char* string);
|
static void xsyslog(BIO* bp, int priority, const char* string);
|
||||||
static void xcloselog(BIO* bp);
|
static void xcloselog(BIO* bp);
|
||||||
#ifdef OPENSSL_SYS_WIN32
|
|
||||||
LONG (WINAPI *go_for_advapi)() = RegOpenKeyEx;
|
|
||||||
HANDLE (WINAPI *register_event_source)() = NULL;
|
|
||||||
BOOL (WINAPI *deregister_event_source)() = NULL;
|
|
||||||
BOOL (WINAPI *report_event)() = NULL;
|
|
||||||
#define DL_PROC(m,f) (GetProcAddress( m, f ))
|
|
||||||
#ifdef UNICODE
|
|
||||||
#define DL_PROC_X(m,f) DL_PROC( m, f "W" )
|
|
||||||
#else
|
|
||||||
#define DL_PROC_X(m,f) DL_PROC( m, f "A" )
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static BIO_METHOD methods_slg=
|
static BIO_METHOD methods_slg=
|
||||||
{
|
{
|
||||||
|
@ -249,35 +236,20 @@ static int MS_CALLBACK slg_puts(BIO *bp, const char *str)
|
||||||
|
|
||||||
static void xopenlog(BIO* bp, char* name, int level)
|
static void xopenlog(BIO* bp, char* name, int level)
|
||||||
{
|
{
|
||||||
if ( !register_event_source )
|
if (GetVersion() < 0x80000000)
|
||||||
{
|
bp->ptr = RegisterEventSourceA(NULL,name);
|
||||||
HANDLE advapi;
|
else
|
||||||
if ( !(advapi = GetModuleHandle("advapi32")) )
|
bp->ptr = NULL;
|
||||||
return;
|
|
||||||
register_event_source = (HANDLE (WINAPI *)())DL_PROC_X(advapi,
|
|
||||||
"RegisterEventSource" );
|
|
||||||
deregister_event_source = (BOOL (WINAPI *)())DL_PROC(advapi,
|
|
||||||
"DeregisterEventSource");
|
|
||||||
report_event = (BOOL (WINAPI *)())DL_PROC_X(advapi,
|
|
||||||
"ReportEvent" );
|
|
||||||
if ( !(register_event_source && deregister_event_source &&
|
|
||||||
report_event) )
|
|
||||||
{
|
|
||||||
register_event_source = NULL;
|
|
||||||
deregister_event_source = NULL;
|
|
||||||
report_event = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bp->ptr= (char *)register_event_source(NULL, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xsyslog(BIO *bp, int priority, const char *string)
|
static void xsyslog(BIO *bp, int priority, const char *string)
|
||||||
{
|
{
|
||||||
LPCSTR lpszStrings[2];
|
LPCSTR lpszStrings[2];
|
||||||
WORD evtype= EVENTLOG_ERROR_TYPE;
|
WORD evtype= EVENTLOG_ERROR_TYPE;
|
||||||
int pid = _getpid();
|
char pidbuf[DECIMAL_SIZE(DWORD)+4];
|
||||||
char pidbuf[DECIMAL_SIZE(pid)+4];
|
|
||||||
|
if (bp->ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (priority)
|
switch (priority)
|
||||||
{
|
{
|
||||||
|
@ -301,19 +273,18 @@ static void xsyslog(BIO *bp, int priority, const char *string)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(pidbuf, "[%d] ", pid);
|
sprintf(pidbuf, "[%u] ", GetCurrentProcessId());
|
||||||
lpszStrings[0] = pidbuf;
|
lpszStrings[0] = pidbuf;
|
||||||
lpszStrings[1] = string;
|
lpszStrings[1] = string;
|
||||||
|
|
||||||
if(report_event && bp->ptr)
|
ReportEventA(bp->ptr, evtype, 0, 1024, NULL, 2, 0,
|
||||||
report_event(bp->ptr, evtype, 0, 1024, NULL, 2, 0,
|
|
||||||
lpszStrings, NULL);
|
lpszStrings, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xcloselog(BIO* bp)
|
static void xcloselog(BIO* bp)
|
||||||
{
|
{
|
||||||
if(deregister_event_source && bp->ptr)
|
if(bp->ptr)
|
||||||
deregister_event_source((HANDLE)(bp->ptr));
|
DeregisterEventSource((HANDLE)(bp->ptr));
|
||||||
bp->ptr= NULL;
|
bp->ptr= NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue