summaryrefslogtreecommitdiff
path: root/tests/service
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2009-03-23 18:07:50 +0100
committerAndreas Baumann <abaumann@yahoo.com>2009-03-23 18:07:50 +0100
commitbbbb86a7aeb2394e7c118ebe1edaa2be18350cda (patch)
tree0bf7001b0bcda0a801b2882422839a8ce7321d22 /tests/service
parent93e6d0bbbf09e1a91fb1a294ba478cdd327e0fd6 (diff)
downloadwolfbones-bbbb86a7aeb2394e7c118ebe1edaa2be18350cda.tar.gz
wolfbones-bbbb86a7aeb2394e7c118ebe1edaa2be18350cda.tar.bz2
started with the Win32 service
Diffstat (limited to 'tests/service')
-rw-r--r--tests/service/Makefile.W3245
-rw-r--r--tests/service/testservice.c45
-rw-r--r--tests/service/testservice.mc61
3 files changed, 151 insertions, 0 deletions
diff --git a/tests/service/Makefile.W32 b/tests/service/Makefile.W32
new file mode 100644
index 0000000..4dc3bf8
--- /dev/null
+++ b/tests/service/Makefile.W32
@@ -0,0 +1,45 @@
+TOPDIR = ..\..
+
+SUBDIRS =
+
+INCLUDE_DIRS = \
+ /I$(TOPDIR)\include\wolf /I. \
+ /D_WIN32_WINNT=0x400 /I"$(PLATFORM_SDK_DIR)\Include"
+
+INCLUDE_LDFLAGS = \
+ /LIBPATH:"$(PLATFORM_SDK_DIR)\lib"
+
+INCLUDE_LIBS = \
+ $(TOPDIR)\src\wolf.lib \
+ advapi32.lib kernel32.lib
+
+LIBRARIES = \
+ testservice.dll
+
+TEST_BINS = \
+ testservice.exe
+
+!INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk
+
+test_service.exe: test_service.obj $(TOPDIR)\src\wolf.lib
+
+testservice.dll: testservice.res
+ $(LINK) /dll /nologo /noentry /MACHINE:x86 /out:$@ $?
+
+testservice.rc: testservice.mc
+testservice.res: testservice.rc
+
+local_test: $(LIBRARIES)
+# @echo Testing log..
+# @copy testservice.dll C:\TEMP
+# @test_service 2>NUL
+
+local_all:
+
+local_clean:
+ @-erase testservice.log 2>NUL
+ @-erase $(LIBRARIES) testservice.h 2>NUL
+
+local_distclean:
+
+
diff --git a/tests/service/testservice.c b/tests/service/testservice.c
new file mode 100644
index 0000000..8675a97
--- /dev/null
+++ b/tests/service/testservice.c
@@ -0,0 +1,45 @@
+#include "log/log.h" /* for logging */
+#include "log/messages.h" /* for i18n */
+#include "port/string.h" /* for strcasecmp */
+#include "port/gettext.h" /* for i18n */
+
+#include <windows.h>
+#include <tchar.h>
+#include <WinSvc.h>
+
+#define WOLF_CATEGORY_TESTSERVICE WOLF_LAST_INTERNAL_CATEGORY+1
+
+#define WOLF_MSG_TESTSERVICE_BASE ( WOLF_CATEGORY_TESTSERVICE ) * 1000
+#define WOLF_MSG_TESTSERVICE_CANT_OPEN_SCM WOLF_MSG_TESTSERVICE_BASE+1
+
+static void wolf_service_register( void ) {
+ SC_HANDLE scm;
+
+ scm = (SC_HANDLE)OpenSCManager(
+ NULL, /* local computer */
+ SERVICES_ACTIVE_DATABASE,
+ SC_MANAGER_ALL_ACCESS );
+
+ if( scm != NULL ) {
+ DWORD last_error = GetLastError( );
+
+ wolf_log( WOLF_LOG_EMERG, WOLF_CATEGORY_TESTSERVICE, WOLF_MSG_TESTSERVICE_CANT_OPEN_SCM,
+ _( "Unable to open the service control manager: %s (%d)" ),
+ "", last_error );
+ }
+}
+
+void __cdecl _tmain( int argc, TCHAR *argv[] ) {
+ wolf_log_openlogtostderr( WOLF_LOG_NOTICE );
+ wolf_log_openlogtofile( "testservice.log", WOLF_LOG_NOTICE );
+ wolf_log_openlogtoeventlog( NULL, "Application", "testservice",
+ "C:\\Temp\\testsrevice.dll", 3, WOLF_LOG_NOTICE );
+
+ if( strcasecmp( argv[1], "install" ) == 0 ) {
+ wolf_service_register( );
+ }
+
+ wolf_log_closelogtoeventlog( );
+ wolf_log_closelogtofile( );
+ wolf_log_closelogtostderr( );
+}
diff --git a/tests/service/testservice.mc b/tests/service/testservice.mc
new file mode 100644
index 0000000..8b032be
--- /dev/null
+++ b/tests/service/testservice.mc
@@ -0,0 +1,61 @@
+;// messages file for wolf messages
+
+;// language codes for translated messages
+;// (409 ist the windows locale for en-US)
+LanguageNames = (
+ English = 0x409 : MSG00409
+)
+
+;// Category names come first, the 'CategoryCount' registry entry
+;// for the event source must match the number of entries here.
+;// Also the numbering must be strictly starting by one and increase
+;// by one. Careful: categories MUST be defined here, the message
+;// compiler is a little bit flag and context infected. Also make
+;// sure they are not longer than 10 characters, the event viewer
+;// field is quite small.
+
+MessageId = 0x1
+SymbolicName = WOLF_CATEGORY_1
+Language = English
+Category 1
+.
+
+MessageId = 0x2
+SymbolicName = WOLF_CATEGORY_2
+Language = English
+Category 2
+.
+
+MessageId = 0x3
+SymbolicName = WOLF_CATEGORY_TESTSERVICE
+Language = English
+Testservice
+.
+
+;// event log severity levels (severity bits)
+SeverityNames = (
+ Success = 0x0 : STATUS_SEVERITY_SUCCESS
+ Informational = 0x1 : STATUS_SEVERITY_INFORMATIONAL
+ Warning = 0x2 : STATUS_SEVERITY_WARNING
+ Error = 0x3 : STATUS_SEVERITY_ERROR
+)
+
+;// facility names
+FacilityNames = (
+ System = 0x0FF
+ Application = 0xFFF
+)
+
+
+
+;// event messages from here
+
+MessageIdTypedef = DWORD
+
+MessageId = 3001
+Severity = Error
+Facility = Application
+SymbolicName = WOLF_CATEGORY_TEST_LOG_MSG1
+Language = English
+This is error %1
+.