Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7864e0a

Browse files
committed
Add pgevent, with docs explaining out to install it on Win32.
1 parent 1098677 commit 7864e0a

File tree

10 files changed

+244
-2
lines changed

10 files changed

+244
-2
lines changed

doc/src/sgml/installation.sgml

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.202 2004/05/23 15:13:43 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.203 2004/06/20 01:32:46 momjian Exp $ -->
22

33
<chapter id="installation">
44
<title><![%standalone-include[<productname>PostgreSQL</>]]>
@@ -1072,6 +1072,19 @@ All of PostgreSQL is successfully made. Ready to install.
10721072
</step>
10731073
</procedure>
10741074

1075+
<formalpara>
1076+
<title>Registering <application>eventlog</> on <systemitem
1077+
class="osname">Windows</>:</title>
1078+
<para>
1079+
To register a <systemitem class="osname">Windows</> <application>eventlog</>
1080+
library with the operating system, issue this command after installation:
1081+
<screen>
1082+
<userinput>regsvr32 <replaceable>pgsql_library_directory</>/pgevent.dll</>
1083+
</screen>
1084+
This creates registry entries used by the event viewer.
1085+
</para>
1086+
</formalpara>
1087+
10751088
<formalpara>
10761089
<title>Uninstallation:</title>
10771090
<para>

src/bin/Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/bin/Makefile,v 1.44 2004/06/18 21:24:05 tgl Exp $
8+
# $PostgreSQL: pgsql/src/bin/Makefile,v 1.45 2004/06/20 01:32:47 momjian Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -15,6 +15,9 @@ include $(top_builddir)/src/Makefile.global
1515

1616
DIRS := initdb ipcclean pg_ctl pg_dump \
1717
psql scripts pg_config pg_controldata pg_resetxlog
18+
ifeq ($(PORTNAME), win32)
19+
DIRS+=pgevent
20+
endif
1821

1922
all install installdirs uninstall depend distprep:
2023
@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done

src/bin/pgevent/MSG00001.bin

32 Bytes
Binary file not shown.

src/bin/pgevent/Makefile

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile for src/bin/pgevent
4+
#
5+
# Copyright (c) 1996-2004, PostgreSQL Global Development Group
6+
#
7+
#-------------------------------------------------------------------------
8+
9+
subdir = src/bin/pgevent
10+
top_builddir = ../../..
11+
include $(top_builddir)/src/Makefile.global
12+
13+
OBJS=pgevent.o pgmsgevent.o
14+
NAME=pgevent.dll
15+
16+
all: $(NAME)
17+
18+
install: all install-lib
19+
20+
pgevent.dll: $(OBJS) pgevent.def
21+
dllwrap --def pgevent.def -o $(NAME) $(OBJS)
22+
23+
pgmsgevent.o: pgmsgevent.rc
24+
windres pgmsgevent.rc -o pgmsgevent.o
25+
26+
all-lib: $(NAME)
27+
28+
install-lib: $(NAME)
29+
$(INSTALL_STLIB) $< $(DESTDIR)$(libdir)/$<
30+
31+
uninstall-lib:
32+
rm -f $(DESTDIR)$(libdir)/$(NAME)
33+
34+
clean:
35+
rm -f $(OBJS) $(NAME)
36+
37+
clean-lib:
38+
rm -f $(NAME)

src/bin/pgevent/README

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
The files attached with this mail have to be stored in pgevent directory.
2+
MSG000001.bin is a bin files, result of Microsoft MC compiler. MC compiler
3+
can be downloaded for free with MS Core SDK but it is not included with MSYS
4+
tools and I didn't find a alternative way to compile MC file.
5+
6+
To summarize MC pgmsgevent.mc command generates pgmsgevent.h
7+
pgmsgevent.rc and MSG00001.bin files. In MC file, we declare a string
8+
with %s format, so we can write anything we want in the future without
9+
need to change the definition of this string.
10+
11+
To finish, because DllUnregisterServer and DllRegisterServer are system
12+
defined entry point, we need to export these two functions with their names
13+
without "decoration", so we cannot uses auto generated .def files without
14+
handy modifications.
15+
16+
Laurent Ballester
17+
18+

src/bin/pgevent/pgevent.c

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* pgevent.c
4+
* Defines the entry point for pgevent dll.
5+
* The DLL defines event source for backend
6+
*
7+
*
8+
* IDENTIFICATION
9+
* $PostgreSQL: pgsql/src/bin/pgevent/pgevent.c,v 1.1 2004/06/20 01:32:49 momjian Exp $
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
14+
15+
#include "windows.h"
16+
#include "olectl.h"
17+
#include "string.h"
18+
19+
/* Global variables */
20+
HANDLE g_module = NULL; /* hModule of DLL */
21+
22+
/* Prototypes */
23+
STDAPI DllRegisterServer(void) ;
24+
STDAPI DllUnregisterServer(void);
25+
BOOL WINAPI DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved );
26+
27+
/*
28+
* DllRegisterServer --- Instructs DLL to create its registry entries
29+
*/
30+
31+
STDAPI DllRegisterServer(void)
32+
{
33+
HKEY key;
34+
DWORD data;
35+
char buffer[_MAX_PATH];
36+
37+
/* Set the name of DLL full path name. */
38+
if (!GetModuleFileName((HMODULE)g_module, buffer, sizeof(buffer)))
39+
{
40+
MessageBox(NULL, "Could not retrieve DLL filename", "PostgreSQL error", MB_OK|MB_ICONSTOP);
41+
return SELFREG_E_TYPELIB;
42+
}
43+
44+
/* Add PostgreSQL source name as a subkey under the Application
45+
key in the EventLog registry key. */
46+
if ( RegCreateKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL", &key) )
47+
{
48+
MessageBox(NULL, "Could not create the registry key.", "PostgreSQL error", MB_OK|MB_ICONSTOP);
49+
return SELFREG_E_TYPELIB;
50+
}
51+
52+
/* Add the name to the EventMessageFile subkey. */
53+
if (RegSetValueEx(key,
54+
"EventMessageFile",
55+
0,
56+
REG_EXPAND_SZ,
57+
(LPBYTE) buffer,
58+
strlen(buffer) + 1))
59+
{
60+
MessageBox(NULL, "Could not set the event message file.", "PostgreSQL error", MB_OK|MB_ICONSTOP);
61+
return SELFREG_E_TYPELIB;
62+
}
63+
64+
/* Set the supported event types in the TypesSupported subkey. */
65+
data = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
66+
67+
if (RegSetValueEx(key,
68+
"TypesSupported",
69+
0,
70+
REG_DWORD,
71+
(LPBYTE) &data,
72+
sizeof(DWORD)))
73+
{
74+
MessageBox(NULL, "Could not set the supported types.", "PostgreSQL error", MB_OK|MB_ICONSTOP);
75+
return SELFREG_E_TYPELIB;
76+
}
77+
78+
RegCloseKey(key);
79+
return S_OK;
80+
}
81+
82+
/*
83+
* DllUnregisterServer --- Instructs DLL to remove only those entries created through DllRegisterServer
84+
*/
85+
86+
STDAPI DllUnregisterServer(void)
87+
{
88+
/* Remove PostgreSQL source name as a subkey under the Application
89+
key in the EventLog registry key. */
90+
91+
if ( RegDeleteKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL") )
92+
{
93+
MessageBox(NULL, "Could not delete the registry key.", "PostgreSQL error", MB_OK|MB_ICONSTOP);
94+
return SELFREG_E_TYPELIB;
95+
}
96+
return S_OK;
97+
}
98+
99+
/*
100+
* DllMain --- is an optional entry point into a DLL.
101+
*/
102+
103+
BOOL WINAPI DllMain( HANDLE hModule,
104+
DWORD ul_reason_for_call,
105+
LPVOID lpReserved
106+
)
107+
{
108+
if ( ul_reason_for_call == DLL_PROCESS_ATTACH )
109+
{
110+
g_module = hModule;
111+
}
112+
return TRUE;
113+
}
114+

src/bin/pgevent/pgevent.def

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
; dlltool --output-def pgevent.def pgevent.o pgmsgevent.o
2+
EXPORTS
3+
DllUnregisterServer=DllUnregisterServer@0 @ 1;
4+
DllRegisterServer=DllRegisterServer@0 @ 2;

src/bin/pgevent/pgmsgevent.h

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Values are 32 bit values layed out as follows:
3+
//
4+
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
5+
// 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
6+
// +---+-+-+-----------------------+-------------------------------+
7+
// |Sev|C|R| Facility | Code |
8+
// +---+-+-+-----------------------+-------------------------------+
9+
//
10+
// where
11+
//
12+
// Sev - is the severity code
13+
//
14+
// 00 - Success
15+
// 01 - Informational
16+
// 10 - Warning
17+
// 11 - Error
18+
//
19+
// C - is the Customer code flag
20+
//
21+
// R - is a reserved bit
22+
//
23+
// Facility - is the facility code
24+
//
25+
// Code - is the facility's status code
26+
//
27+
//
28+
// Define the facility codes
29+
//
30+
31+
32+
//
33+
// Define the severity codes
34+
//
35+
36+
37+
//
38+
// MessageId: PGWIN32_EVENTLOG_MSG
39+
//
40+
// MessageText:
41+
//
42+
// %1.
43+
//
44+
#define PGWIN32_EVENTLOG_MSG 0x00000000L
45+

src/bin/pgevent/pgmsgevent.mc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
MessageId=0
2+
SymbolicName=PGWIN32_EVENTLOG_MSG
3+
Language=English
4+
%1.
5+
.

src/bin/pgevent/pgmsgevent.rc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
LANGUAGE 0x9,0x1
2+
1 11 MSG00001.bin

0 commit comments

Comments
 (0)