mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Add pgevent, with docs explaining out to install it on Win32.
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.202 2004/05/23 15:13:43 tgl Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.203 2004/06/20 01:32:46 momjian Exp $ -->
|
||||||
|
|
||||||
<chapter id="installation">
|
<chapter id="installation">
|
||||||
<title><![%standalone-include[<productname>PostgreSQL</>]]>
|
<title><![%standalone-include[<productname>PostgreSQL</>]]>
|
||||||
@ -1072,6 +1072,19 @@ All of PostgreSQL is successfully made. Ready to install.
|
|||||||
</step>
|
</step>
|
||||||
</procedure>
|
</procedure>
|
||||||
|
|
||||||
|
<formalpara>
|
||||||
|
<title>Registering <application>eventlog</> on <systemitem
|
||||||
|
class="osname">Windows</>:</title>
|
||||||
|
<para>
|
||||||
|
To register a <systemitem class="osname">Windows</> <application>eventlog</>
|
||||||
|
library with the operating system, issue this command after installation:
|
||||||
|
<screen>
|
||||||
|
<userinput>regsvr32 <replaceable>pgsql_library_directory</>/pgevent.dll</>
|
||||||
|
</screen>
|
||||||
|
This creates registry entries used by the event viewer.
|
||||||
|
</para>
|
||||||
|
</formalpara>
|
||||||
|
|
||||||
<formalpara>
|
<formalpara>
|
||||||
<title>Uninstallation:</title>
|
<title>Uninstallation:</title>
|
||||||
<para>
|
<para>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
# Portions Copyright (c) 1994, Regents of the University of California
|
# Portions Copyright (c) 1994, Regents of the University of California
|
||||||
#
|
#
|
||||||
# $PostgreSQL: pgsql/src/bin/Makefile,v 1.44 2004/06/18 21:24:05 tgl Exp $
|
# $PostgreSQL: pgsql/src/bin/Makefile,v 1.45 2004/06/20 01:32:47 momjian Exp $
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -15,6 +15,9 @@ include $(top_builddir)/src/Makefile.global
|
|||||||
|
|
||||||
DIRS := initdb ipcclean pg_ctl pg_dump \
|
DIRS := initdb ipcclean pg_ctl pg_dump \
|
||||||
psql scripts pg_config pg_controldata pg_resetxlog
|
psql scripts pg_config pg_controldata pg_resetxlog
|
||||||
|
ifeq ($(PORTNAME), win32)
|
||||||
|
DIRS+=pgevent
|
||||||
|
endif
|
||||||
|
|
||||||
all install installdirs uninstall depend distprep:
|
all install installdirs uninstall depend distprep:
|
||||||
@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
|
@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
|
||||||
|
BIN
src/bin/pgevent/MSG00001.bin
Normal file
BIN
src/bin/pgevent/MSG00001.bin
Normal file
Binary file not shown.
38
src/bin/pgevent/Makefile
Normal file
38
src/bin/pgevent/Makefile
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Makefile for src/bin/pgevent
|
||||||
|
#
|
||||||
|
# Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
subdir = src/bin/pgevent
|
||||||
|
top_builddir = ../../..
|
||||||
|
include $(top_builddir)/src/Makefile.global
|
||||||
|
|
||||||
|
OBJS=pgevent.o pgmsgevent.o
|
||||||
|
NAME=pgevent.dll
|
||||||
|
|
||||||
|
all: $(NAME)
|
||||||
|
|
||||||
|
install: all install-lib
|
||||||
|
|
||||||
|
pgevent.dll: $(OBJS) pgevent.def
|
||||||
|
dllwrap --def pgevent.def -o $(NAME) $(OBJS)
|
||||||
|
|
||||||
|
pgmsgevent.o: pgmsgevent.rc
|
||||||
|
windres pgmsgevent.rc -o pgmsgevent.o
|
||||||
|
|
||||||
|
all-lib: $(NAME)
|
||||||
|
|
||||||
|
install-lib: $(NAME)
|
||||||
|
$(INSTALL_STLIB) $< $(DESTDIR)$(libdir)/$<
|
||||||
|
|
||||||
|
uninstall-lib:
|
||||||
|
rm -f $(DESTDIR)$(libdir)/$(NAME)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(OBJS) $(NAME)
|
||||||
|
|
||||||
|
clean-lib:
|
||||||
|
rm -f $(NAME)
|
18
src/bin/pgevent/README
Normal file
18
src/bin/pgevent/README
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
The files attached with this mail have to be stored in pgevent directory.
|
||||||
|
MSG000001.bin is a bin files, result of Microsoft MC compiler. MC compiler
|
||||||
|
can be downloaded for free with MS Core SDK but it is not included with MSYS
|
||||||
|
tools and I didn't find a alternative way to compile MC file.
|
||||||
|
|
||||||
|
To summarize MC pgmsgevent.mc command generates pgmsgevent.h
|
||||||
|
pgmsgevent.rc and MSG00001.bin files. In MC file, we declare a string
|
||||||
|
with %s format, so we can write anything we want in the future without
|
||||||
|
need to change the definition of this string.
|
||||||
|
|
||||||
|
To finish, because DllUnregisterServer and DllRegisterServer are system
|
||||||
|
defined entry point, we need to export these two functions with their names
|
||||||
|
without "decoration", so we cannot uses auto generated .def files without
|
||||||
|
handy modifications.
|
||||||
|
|
||||||
|
Laurent Ballester
|
||||||
|
|
||||||
|
|
114
src/bin/pgevent/pgevent.c
Normal file
114
src/bin/pgevent/pgevent.c
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* pgevent.c
|
||||||
|
* Defines the entry point for pgevent dll.
|
||||||
|
* The DLL defines event source for backend
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* IDENTIFICATION
|
||||||
|
* $PostgreSQL: pgsql/src/bin/pgevent/pgevent.c,v 1.1 2004/06/20 01:32:49 momjian Exp $
|
||||||
|
*
|
||||||
|
*-------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "windows.h"
|
||||||
|
#include "olectl.h"
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
|
/* Global variables */
|
||||||
|
HANDLE g_module = NULL; /* hModule of DLL */
|
||||||
|
|
||||||
|
/* Prototypes */
|
||||||
|
STDAPI DllRegisterServer(void) ;
|
||||||
|
STDAPI DllUnregisterServer(void);
|
||||||
|
BOOL WINAPI DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DllRegisterServer --- Instructs DLL to create its registry entries
|
||||||
|
*/
|
||||||
|
|
||||||
|
STDAPI DllRegisterServer(void)
|
||||||
|
{
|
||||||
|
HKEY key;
|
||||||
|
DWORD data;
|
||||||
|
char buffer[_MAX_PATH];
|
||||||
|
|
||||||
|
/* Set the name of DLL full path name. */
|
||||||
|
if (!GetModuleFileName((HMODULE)g_module, buffer, sizeof(buffer)))
|
||||||
|
{
|
||||||
|
MessageBox(NULL, "Could not retrieve DLL filename", "PostgreSQL error", MB_OK|MB_ICONSTOP);
|
||||||
|
return SELFREG_E_TYPELIB;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add PostgreSQL source name as a subkey under the Application
|
||||||
|
key in the EventLog registry key. */
|
||||||
|
if ( RegCreateKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL", &key) )
|
||||||
|
{
|
||||||
|
MessageBox(NULL, "Could not create the registry key.", "PostgreSQL error", MB_OK|MB_ICONSTOP);
|
||||||
|
return SELFREG_E_TYPELIB;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add the name to the EventMessageFile subkey. */
|
||||||
|
if (RegSetValueEx(key,
|
||||||
|
"EventMessageFile",
|
||||||
|
0,
|
||||||
|
REG_EXPAND_SZ,
|
||||||
|
(LPBYTE) buffer,
|
||||||
|
strlen(buffer) + 1))
|
||||||
|
{
|
||||||
|
MessageBox(NULL, "Could not set the event message file.", "PostgreSQL error", MB_OK|MB_ICONSTOP);
|
||||||
|
return SELFREG_E_TYPELIB;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the supported event types in the TypesSupported subkey. */
|
||||||
|
data = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
|
||||||
|
|
||||||
|
if (RegSetValueEx(key,
|
||||||
|
"TypesSupported",
|
||||||
|
0,
|
||||||
|
REG_DWORD,
|
||||||
|
(LPBYTE) &data,
|
||||||
|
sizeof(DWORD)))
|
||||||
|
{
|
||||||
|
MessageBox(NULL, "Could not set the supported types.", "PostgreSQL error", MB_OK|MB_ICONSTOP);
|
||||||
|
return SELFREG_E_TYPELIB;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(key);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DllUnregisterServer --- Instructs DLL to remove only those entries created through DllRegisterServer
|
||||||
|
*/
|
||||||
|
|
||||||
|
STDAPI DllUnregisterServer(void)
|
||||||
|
{
|
||||||
|
/* Remove PostgreSQL source name as a subkey under the Application
|
||||||
|
key in the EventLog registry key. */
|
||||||
|
|
||||||
|
if ( RegDeleteKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL") )
|
||||||
|
{
|
||||||
|
MessageBox(NULL, "Could not delete the registry key.", "PostgreSQL error", MB_OK|MB_ICONSTOP);
|
||||||
|
return SELFREG_E_TYPELIB;
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DllMain --- is an optional entry point into a DLL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
BOOL WINAPI DllMain( HANDLE hModule,
|
||||||
|
DWORD ul_reason_for_call,
|
||||||
|
LPVOID lpReserved
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( ul_reason_for_call == DLL_PROCESS_ATTACH )
|
||||||
|
{
|
||||||
|
g_module = hModule;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
4
src/bin/pgevent/pgevent.def
Normal file
4
src/bin/pgevent/pgevent.def
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
; dlltool --output-def pgevent.def pgevent.o pgmsgevent.o
|
||||||
|
EXPORTS
|
||||||
|
DllUnregisterServer=DllUnregisterServer@0 @ 1;
|
||||||
|
DllRegisterServer=DllRegisterServer@0 @ 2;
|
45
src/bin/pgevent/pgmsgevent.h
Normal file
45
src/bin/pgevent/pgmsgevent.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
//
|
||||||
|
// Values are 32 bit values layed out as follows:
|
||||||
|
//
|
||||||
|
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
|
||||||
|
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
||||||
|
// +---+-+-+-----------------------+-------------------------------+
|
||||||
|
// |Sev|C|R| Facility | Code |
|
||||||
|
// +---+-+-+-----------------------+-------------------------------+
|
||||||
|
//
|
||||||
|
// where
|
||||||
|
//
|
||||||
|
// Sev - is the severity code
|
||||||
|
//
|
||||||
|
// 00 - Success
|
||||||
|
// 01 - Informational
|
||||||
|
// 10 - Warning
|
||||||
|
// 11 - Error
|
||||||
|
//
|
||||||
|
// C - is the Customer code flag
|
||||||
|
//
|
||||||
|
// R - is a reserved bit
|
||||||
|
//
|
||||||
|
// Facility - is the facility code
|
||||||
|
//
|
||||||
|
// Code - is the facility's status code
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Define the facility codes
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Define the severity codes
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// MessageId: PGWIN32_EVENTLOG_MSG
|
||||||
|
//
|
||||||
|
// MessageText:
|
||||||
|
//
|
||||||
|
// %1.
|
||||||
|
//
|
||||||
|
#define PGWIN32_EVENTLOG_MSG 0x00000000L
|
||||||
|
|
5
src/bin/pgevent/pgmsgevent.mc
Normal file
5
src/bin/pgevent/pgmsgevent.mc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
MessageId=0
|
||||||
|
SymbolicName=PGWIN32_EVENTLOG_MSG
|
||||||
|
Language=English
|
||||||
|
%1.
|
||||||
|
.
|
2
src/bin/pgevent/pgmsgevent.rc
Normal file
2
src/bin/pgevent/pgmsgevent.rc
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
LANGUAGE 0x9,0x1
|
||||||
|
1 11 MSG00001.bin
|
Reference in New Issue
Block a user