提交 befe1fbc 编写于 作者: A Andy Polyakov

Fix bss_log.c on Windows.

上级 5e4430e7
......@@ -70,7 +70,6 @@
#if defined(OPENSSL_SYS_WINCE)
#elif defined(OPENSSL_SYS_WIN32)
# include <process.h>
#elif defined(OPENSSL_SYS_VMS)
# include <opcdef.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 xsyslog(BIO* bp, int priority, const char* string);
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=
{
......@@ -249,35 +236,20 @@ static int MS_CALLBACK slg_puts(BIO *bp, const char *str)
static void xopenlog(BIO* bp, char* name, int level)
{
if ( !register_event_source )
{
HANDLE advapi;
if ( !(advapi = GetModuleHandle("advapi32")) )
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);
if (GetVersion() < 0x80000000)
bp->ptr = RegisterEventSourceA(NULL,name);
else
bp->ptr = NULL;
}
static void xsyslog(BIO *bp, int priority, const char *string)
{
LPCSTR lpszStrings[2];
WORD evtype= EVENTLOG_ERROR_TYPE;
int pid = _getpid();
char pidbuf[DECIMAL_SIZE(pid)+4];
char pidbuf[DECIMAL_SIZE(DWORD)+4];
if (bp->ptr == NULL)
return;
switch (priority)
{
......@@ -301,19 +273,18 @@ static void xsyslog(BIO *bp, int priority, const char *string)
break;
}
sprintf(pidbuf, "[%d] ", pid);
sprintf(pidbuf, "[%u] ", GetCurrentProcessId());
lpszStrings[0] = pidbuf;
lpszStrings[1] = string;
if(report_event && bp->ptr)
report_event(bp->ptr, evtype, 0, 1024, NULL, 2, 0,
ReportEventA(bp->ptr, evtype, 0, 1024, NULL, 2, 0,
lpszStrings, NULL);
}
static void xcloselog(BIO* bp)
{
if(deregister_event_source && bp->ptr)
deregister_event_source((HANDLE)(bp->ptr));
if(bp->ptr)
DeregisterEventSource((HANDLE)(bp->ptr));
bp->ptr= NULL;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册