Added:
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/lib/moni_inst.h
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/lib/moni_inst.h?rev=980662&view=auto
==============================================================================
---
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/lib/moni_inst.h
(added)
+++
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/lib/moni_inst.h
Fri Jul 30 06:50:12 2010
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * include for the service installation
+ */
+#define SZAPPNAME "JavaService"
+#define SZSERVICENAME "jsvc" // name of service
+#define SZDEPENDENCIES ""
+#define SZSERVICEDISPLAYNAME "Java Service" // name to display
+#define SZKEY_ONSERVE "SOFTWARE\\apache\\jakarta\\1.0"
+#define SZKEY_ONSERVEARG "SOFTWARE\\apache\\jakarta\\1.0\\arguments"
+#define SZKEY_F_DIR "F_DIR"
+#define SZDEFMONISVCPATH "\\vdmonisvc.exe"
+#define SZCYGWINPATH "c:\\gnu"
+#define SZJAKARTA_HOME "c:\\home\\jakarta"
+#define SZJAVA_HOME "c:\\jdk1.3.1"
Propchange:
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/lib/moni_inst.h
------------------------------------------------------------------------------
svn:eol-style = native
Added:
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/Makefile
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/Makefile?rev=980662&view=auto
==============================================================================
---
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/Makefile
(added)
+++
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/Makefile
Fri Jul 30 06:50:12 2010
@@ -0,0 +1,33 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+INCLUDE=-I../lib
+BIN=../../../../dist
+all: $(BIN)/vdmoniadm $(BIN)/vdmonisvc
+
+$(BIN)/vdmoniadm: vdmoniadm.c
+ gcc $(INCLUDE) -I../executables/vdmoniadm vdmoniadm.c \
+ -o $(BIN)/vdmoniadm -lgdi32
+$(BIN)/vdmonisvc: vdmonisvc.c vdenv.o kills.o
+ gcc -mno-cygwin -I/usr/include $(INCLUDE) -I../executables/vdmonisvc \
+ -DCYGWIN vdmonisvc.c \
+ -o $(BIN)/vdmonisvc vdenv.o kills.o
+vdenv.o: ../supcalls_nt/vdenv.c
+ gcc $(INCLUDE) -c ../supcalls_nt/vdenv.c
+kills.o: ../signals/kills.c
+ gcc $(INCLUDE) -c ../signals/kills.c
+clean:
+ rm -f vdenv.o kills.o
Propchange:
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/Makefile
------------------------------------------------------------------------------
svn:eol-style = native
Added:
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/vdmoniadm.c
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/vdmoniadm.c?rev=980662&view=auto
==============================================================================
---
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/vdmoniadm.c
(added)
+++
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/vdmoniadm.c
Fri Jul 30 06:50:12 2010
@@ -0,0 +1,595 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: vdmoniadm.c 909069 2010-02-11 16:43:36Z mturk $ */
+
+#include <windows.h> /* required for all Windows applications */
+#include <stdio.h> /* for sprintf */
+#include <io.h>
+#include <fcntl.h>
+#include <shellapi.h>
+#include <winuser.h>
+
+#include "resource.h"
+#include "moni_inst.h"
+
+
+
+#define WINWIDTH 680
+#define WINHEIGHT 460
+
+#define CLASSMAIN
+#define VM_ICON_MESS WM_USER+1
+#define VM_ID_TIMER WM_USER+2
+#define VM_START_ICON WM_USER+3
+#define VM_ID_TIMER1 WM_USER+4
+#define VM_ID_TIMER2 WM_USER+5
+
+BOOL InitApplication(HANDLE hInstance);
+
+HANDLE hInst; /* current instance */
+SC_HANDLE hManager=NULL;
+SC_HANDLE hService=NULL;
+int optmode; /* start, stop or check. */
+int flagdown = 0;
+
+#define VDMONISTART 0
+#define VDMONISTOP 1
+#define VDMONICHECK 2
+
+#define NORMALWINDOW WS_OVERLAPPED|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX
+#define ICONWINDOW WS_CAPTION|WS_POPUPWINDOW|WS_MINIMIZEBOX|WS_MAXIMIZEBOX
+
+
+/* display a message read from resources */
+
+static void DisplayMess(HWND hDlg,int item)
+{
+char MessBox[256];
+
+ if (LoadString(hInst,item,MessBox,sizeof(MessBox)))
+ MessageBox(hDlg, MessBox,"ERROR" , MB_OK);
+ else {
+ sprintf(MessBox,"ERROR %d",item);
+ MessageBox(hDlg, MessBox,"ERROR" , MB_OK);
+ }
+}
+/*
+ * MyTaskBarAddIcon - adds an icon to the taskbar status area.
+ * Returns TRUE if successful or FALSE otherwise.
+ * hwnd - handle of the window to receive callback messages
+ * uID - identifier of the icon
+ * hicon - handle of the icon to add
+ * lpszTip - ToolTip text
+ */
+BOOL MyTaskBarAddIcon(HWND hWnd)
+{
+ BOOL res;
+ NOTIFYICONDATA notifyicondata;
+ HICON hicon;
+
+ notifyicondata.cbSize=sizeof(notifyicondata);
+ notifyicondata.hWnd=hWnd;
+ notifyicondata.uID=ID_TASKICON;
+ notifyicondata.uFlags= NIF_ICON|NIF_MESSAGE|NIF_TIP;
+ notifyicondata.uCallbackMessage=VM_ICON_MESS;
+ hicon = LoadIcon(hInst,"OnServe");
+ notifyicondata.hIcon = hicon;
+ strcpy(notifyicondata.szTip,"Jakarta Service");
+
+
+ res = Shell_NotifyIcon(NIM_ADD,¬ifyicondata);
+
+ if (hicon)
+ DestroyIcon(hicon);
+
+ return res;
+}
+/*
+ * MyTaskBarDeleteIcon - deletes an icon from the taskbar
+ * status area.
+ * Returns TRUE if successful or FALSE otherwise.
+ * hwnd - handle of the window that added the icon
+ * uID - identifier of the icon to delete
+ */
+BOOL MyTaskBarDeleteIcon(HWND hwnd)
+{
+ BOOL res;
+ NOTIFYICONDATA tnid;
+
+ tnid.cbSize = sizeof(NOTIFYICONDATA);
+ tnid.hWnd = hwnd;
+ tnid.uID = ID_TASKICON;
+
+ res = Shell_NotifyIcon(NIM_DELETE, &tnid);
+ return res;
+}
+
+/* start the vdcom process */
+void StartVdcom(HWND hDlg)
+{
+STARTUPINFO StartupInfo;
+PROCESS_INFORMATION ProcessInformation;
+
+ memset(&StartupInfo,'\0',sizeof(StartupInfo));
+ StartupInfo.cb = sizeof(STARTUPINFO);
+
+ if (!CreateProcess(NULL,"vdcom.exe",NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,
+ NULL,NULL, &StartupInfo, &ProcessInformation)) {
+ DisplayMess(hDlg,CANNOT_START_VDCOM);
+ return;
+ }
+ /* the handle to the process */
+ CloseHandle(ProcessInformation.hProcess);
+ CloseHandle(ProcessInformation.hThread);
+}
+/* start the vdconf process */
+void StartVdconf(HWND hDlg)
+{
+STARTUPINFO StartupInfo;
+PROCESS_INFORMATION ProcessInformation;
+
+ memset(&StartupInfo,'\0',sizeof(StartupInfo));
+ StartupInfo.cb = sizeof(STARTUPINFO);
+
+ if (!CreateProcess(NULL,"vdconf.exe",NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,
+ NULL,NULL, &StartupInfo, &ProcessInformation)) {
+ DisplayMess(hDlg,CANNOT_START_VDCONF);
+ return;
+ }
+ /* the handle to the process */
+ CloseHandle(ProcessInformation.hProcess);
+ CloseHandle(ProcessInformation.hThread);
+}
+
+/* test if service is running */
+BOOL IsRunning(HWND hDlg)
+{
+ SERVICE_STATUS svcStatus;
+
+ if (!QueryServiceStatus(hService, &svcStatus)) {
+ DisplayMess(hDlg,ERROR_STATUS);
+ PostQuitMessage(0);
+ return(FALSE);
+ }
+ else {
+ if (SERVICE_RUNNING == svcStatus.dwCurrentState)
+ return(TRUE);
+ }
+ return(FALSE);
+
+}
+/* test if service is stoppped */
+BOOL IsStopped(HWND hDlg)
+{
+ SERVICE_STATUS svcStatus;
+
+ if (!QueryServiceStatus(hService, &svcStatus)) {
+ DisplayMess(hDlg,ERROR_STATUS);
+ PostQuitMessage(0);
+ return(FALSE);
+ }
+ else {
+ if (SERVICE_STOPPED == svcStatus.dwCurrentState)
+ return(TRUE);
+ }
+ return(FALSE);
+
+}
+/* Yes/No dialog box */
+BOOL CALLBACK StopYesNo(
+ HWND hDlg, /* window handle of the dialog box */
+ UINT message, /* type of message */
+ WPARAM wParam, /* message-specific information */
+ LPARAM lParam)
+{
+ SERVICE_STATUS svcStatus;
+
+ switch (message) {
+ case WM_COMMAND: /* message: received a command */
+ if (LOWORD(wParam) == IDOK) { /* "OK" box selected */
+ if (!IsStopped(hDlg)) {
+ ControlService(hService, SERVICE_CONTROL_STOP, &svcStatus);
+ EndDialog(hDlg, TRUE);
+ }
+ else
+ EndDialog(hDlg, FALSE);
+ }
+ if (LOWORD(wParam) == IDCANCEL)
+ EndDialog(hDlg, FALSE);
+ return(TRUE);
+ } /* End switch message */
+ return (FALSE); /* Didn't process a message
*/
+ UNREFERENCED_PARAMETER(lParam);
+}
+/* Please wait stopping dialog box */
+BOOL CALLBACK PleaseWait(
+ HWND hDlg, /* window handle of the dialog box */
+ UINT message, /* type of message */
+ WPARAM wParam, /* message-specific information */
+ LPARAM lParam)
+{
+
+ switch (message) {
+ case WM_INITDIALOG:
+ SetTimer(hDlg,VM_ID_TIMER2,5000,NULL); /* wait 5 seconds. */
+ case WM_COMMAND: /* message: received a command */
+ if (LOWORD(wParam) == IDCANCEL)
+ EndDialog(hDlg, FALSE);
+ return(TRUE);
+ case WM_TIMER:
+ if(IsStopped(hDlg))
+ EndDialog(hDlg, TRUE);
+ else
+ SetTimer(hDlg,VM_ID_TIMER2,5000,NULL); /* wait 5 seconds. */
+ return(TRUE);
+ } /* End switch message */
+ return (FALSE); /* Didn't process a message
*/
+ UNREFERENCED_PARAMETER(lParam);
+}
+BOOL CALLBACK StartYesNo(
+ HWND hDlg, /* window handle of the dialog box */
+ UINT message, /* type of message */
+ WPARAM wParam, /* message-specific information */
+ LPARAM lParam)
+{
+
+ switch (message) {
+ case WM_INITDIALOG:
+ if (!StartService(hService,0,NULL)) {
+ DisplayMess(hDlg,CANNOT_START);
+ PostQuitMessage(0);
+ }
+ /* test if running, if not set a timer. */
+ /* wait until service is start */
+ if (IsRunning(hDlg))
+ EndDialog(hDlg, TRUE);
+ else
+ SetTimer(hDlg,VM_ID_TIMER1,5000,NULL); /* wait 5 seconds. */
+ return(TRUE);
+
+ case WM_TIMER:
+ if(IsRunning(hDlg))
+ EndDialog(hDlg, TRUE);
+ else
+ SetTimer(hDlg,VM_ID_TIMER1,5000,NULL); /* wait 5 seconds. */
+ return(TRUE);
+
+ case WM_COMMAND: /* message: received a command */
+ if (LOWORD(wParam) == IDCANCEL) {
+ if (IsRunning(hDlg))
+ EndDialog(hDlg, TRUE);
+ else
+ PostQuitMessage(0);
+ }
+ return(TRUE);
+
+ } /* End switch message */
+ return (FALSE); /* Didn't process a message
*/
+ UNREFERENCED_PARAMETER(lParam);
+}
+
+/* Display the menu */
+
+void ShowMenu(HWND hWnd)
+{
+ HMENU hMenu,hMenu1;
+ POINT point;
+
+ hMenu = LoadMenu(hInst,"MENU");
+ SetMenu(hWnd,hMenu);
+ hMenu1 = GetSubMenu(hMenu,0);
+
+ GetCursorPos(&point);
+
+ SetForegroundWindow(hWnd); /* MS bug. */
+
TrackPopupMenuEx(hMenu1,TPM_RIGHTALIGN|TPM_BOTTOMALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,
+ point.x,point.y,hWnd,NULL);
+ PostMessage(hWnd, WM_USER, 0, 0); /* MS bug. */
+ DestroyMenu(hMenu);
+
+}
+/****************************************************************************\
+*
+* FUNCTION: InitInstance(HANDLE, int)
+*
+* PURPOSE: Saves instance handle and creates main window
+*
+*\***************************************************************************/
+
+BOOL InitInstance(
+ HANDLE hInstance, /* Current instance identifier.
*/
+ int nCmdShow) /* Param for first ShowWindow() call.
*/
+{
+ HWND hWnd; /* Main window handle.
*/
+ DWORD dwStyle,dwExStyle;
+
+
+ /* Save the instance handle in static variable, which will be used in */
+ /* many subsequence calls from this application to Windows. */
+
+ hInst = hInstance;
+
+ /* Create a main window for this application instance. */
+
+ if (optmode == VDMONISTART || optmode == VDMONICHECK) {
+ dwStyle = ICONWINDOW;
+ dwExStyle = WS_EX_APPWINDOW;
+ }
+ else {
+ dwStyle = NORMALWINDOW;
+ dwExStyle = 0;
+ }
+
+ hWnd = CreateWindowEx(
+ dwExStyle,
+ "OnServe", /* See RegisterClass() call.
*/
+ "OnServe Monitor Control", /* Text for window title bar. */
+ dwStyle, /* Window style.*/
+ CW_USEDEFAULT, /* Default horizontal position.
*/
+ CW_USEDEFAULT, /* Default vertical position.
*/
+ WINWIDTH, /* Windows width.
*/
+ WINHEIGHT, /* Windows height.
*/
+ NULL, /* Overlapped windows have no parent.
*/
+ NULL, /* Use the window class menu.
*/
+ hInstance, /* This instance owns this window.
*/
+ NULL /* Pointer not needed.
*/
+ );
+
+
+ /* If window could not be created, return "failure" */
+
+ if (!hWnd) {
+ return (FALSE);
+ }
+
+ return (TRUE); /* Returns the value from PostQuitMessage */
+
+}
+/****************************************************************************\
+*
+* FUNCTION: MainWndProc(HWND, unsigned, WORD, LONG)
+*
+* PURPOSE: Processes main window messages
+*
+*\***************************************************************************/
+
+LRESULT CALLBACK MainWndProc(
+ HWND hWnd, /* window handle */
+ UINT message, /* type of message */
+ WPARAM wParam, /* additional information */
+ LPARAM lParam) /* additional information */
+{
+ SERVICE_STATUS svcStatus;
+
+ switch (message) {
+ case WM_CREATE:
+
+ /* acces to service manager. */
+ hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if (hManager==NULL) {
+ DisplayMess(hWnd,NO_ACCESS);
+ PostQuitMessage(0);
+ break;
+ }
+ /* access to monitor service. */
+ hService = OpenService(hManager, SZSERVICENAME, SERVICE_ALL_ACCESS);
+ if (hService==NULL) {
+ DisplayMess(hWnd,NO_ACCESS_MONI);
+ PostQuitMessage(0);
+ break;
+ }
+ /* check if running. */
+ if (QueryServiceStatus(hService, &svcStatus)) {
+ /* and see if the service is stopped */
+ if (SERVICE_STOPPED == svcStatus.dwCurrentState &&
+ optmode == VDMONISTOP) {
+ DisplayMess(hWnd,ALREADY_STOP);
+ PostQuitMessage(0);
+ break;
+ }
+ else if (SERVICE_RUNNING == svcStatus.dwCurrentState &&
+ optmode == VDMONISTART) {
+ DisplayMess(hWnd,ALREADY_START);
+ PostQuitMessage(0);
+ break;
+ }
+
+ }
+ else {
+ DisplayMess(hWnd,ERROR_STATUS);
+ PostQuitMessage(0);
+ break;
+ }
+
+ /* DialogBoxes Yes/No */
+ if (optmode == VDMONISTART)
+ DialogBox(hInst, /* current instance */
+ "StartYesNo", /* resource to use */
+ hWnd, /* parent handle */
+ StartYesNo); /* instance address */
+ else if (optmode == VDMONISTOP)
+ if (DialogBox(hInst,"StopYesNo",hWnd,StopYesNo))
+ DialogBox(hInst,"PleaseWait",hWnd,PleaseWait);
+
+
+ if (optmode == VDMONISTOP)
+ PostQuitMessage(0);
+ else {
+ SetTimer(hWnd,VM_ID_TIMER,5000,NULL);
+ MyTaskBarAddIcon(hWnd);
+ }
+
+ break; /* WM_CREATE */
+
+ case VM_ICON_MESS:
+ switch ((UINT)lParam) {
+ case WM_LBUTTONDBLCLK:
+ StartVdcom(hWnd);
+ break;
+ case WM_RBUTTONDOWN:
+ flagdown = 1;
+ break;
+ case WM_RBUTTONUP:
+ if (flagdown == 1) {
+ flagdown = 2;
+ /* show a menu. */
+ ShowMenu(hWnd);
+ }
+ break;
+ }
+ break;
+
+
+ case WM_TIMER:
+ /* check if service is running */
+ if (QueryServiceStatus(hService, &svcStatus)) {
+ /* and see if the service is stopped */
+ if (SERVICE_STOPPED == svcStatus.dwCurrentState) {
+ MyTaskBarDeleteIcon(hWnd);
+ PostQuitMessage(0);
+ }
+ SetTimer(hWnd,VM_ID_TIMER,5000,NULL);
+ return(0);
+ }
+ break;
+
+ case VM_START_ICON:
+ /* add the icon and timer. */
+ MyTaskBarAddIcon(hWnd);
+ SetTimer(hWnd,VM_ID_TIMER,5000,NULL);
+ break;
+
+ case WM_COMMAND:
+ /* command for the popup menu. */
+ switch (LOWORD(wParam)) {
+ case ID_START_VDCOM:
+ StartVdcom(hWnd);
+ break;
+ case ID_STOP_VDMONI:
+ if (DialogBox(hInst,"StopYesNo",hWnd,StopYesNo))
+ DialogBox(hInst,"PleaseWait",hWnd,PleaseWait);
+ break;
+ case ID_PROPRETY:
+ StartVdconf(hWnd);
+ break;
+
+ }
+ break;
+
+ /*
+ * Clean up.
+ */
+ case WM_DESTROY:
+ if (hService!=NULL)
+ CloseServiceHandle(hService);
+ if (hManager!=NULL)
+ CloseServiceHandle(hManager);
+ PostQuitMessage(0);
+ break;
+
+ default: /* Passes it on if unproccessed */
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+
+ }
+ return (0);
+
+}
+
+/****************************************************************************
+*
+* FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
+*
+* PURPOSE: calls initialization function, processes message loop
+*
+*\***************************************************************************/
+
+WINAPI WinMain(
+ HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow
+ )
+{
+
+ MSG msg;
+
+ UNREFERENCED_PARAMETER( lpCmdLine );
+ if (strcmp(lpCmdLine,"start")==0)
+ optmode = VDMONISTART;
+ else if (strcmp(lpCmdLine,"stop")==0)
+ optmode = VDMONISTOP;
+ else
+ optmode = VDMONICHECK;
+
+ if (!hPrevInstance) /* Other instances of app running? */
+ if (!InitApplication(hInstance)) /* Initialize shared things */
+ return (FALSE); /* Exits if unable to initialize */
+
+ /*
+ * Perform initializations that apply to a specific instance
+ */
+ if (!InitInstance(hInstance, nCmdShow))
+ return (FALSE);
+
+ /*
+ * Acquire and dispatch messages until a WM_QUIT message is received.
+ */
+ while (GetMessage(&msg, /* message structure */
+ NULL, /* handle of window receiving the message */
+ 0, /* lowest message to examine */
+ 0)) /* highest message to examine */
+ {
+ TranslateMessage(&msg); /* Translates virtual key codes */
+ DispatchMessage(&msg); /* Dispatches message to window */
+ }
+ return (msg.wParam); /* Returns the value from PostQuitMessage */
+}
+
+/****************************************************************************
+*
+* FUNCTION: InitApplication(HANDLE)
+*
+* PURPOSE: Initializes window data and registers window class
+*
+*\***************************************************************************/
+
+BOOL InitApplication(HANDLE hInstance) /* current instance */
+{
+ WNDCLASS wc;
+
+ /* Fill in window class structure with parameters that describe the
*/
+ /* main window.
*/
+
+ wc.style = 0; /* Class style(s).
*/
+ wc.lpfnWndProc = MainWndProc; /* Function to retrieve messages for
*/
+ /* windows of this class.
*/
+ wc.cbClsExtra = 0; /* No per-class extra data.
*/
+ wc.cbWndExtra = 0; /* No per-window extra data.
*/
+ wc.hIcon = LoadIcon (hInstance, "onserve"); /* Icon name from .RC */
+ wc.hInstance = hInstance; /* Application that owns the class. */
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = GetStockObject(WHITE_BRUSH);
+ wc.lpszMenuName = "onservemenu"; /* Name of menu resource in .RC file.
*/
+ wc.lpszClassName = "OnServe"; /* Name used in call to CreateWindow. */
+
+ /* Register the window class and return success/failure code. */
+
+ return (RegisterClass(&wc));
+
+}
+
Propchange:
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/vdmoniadm.c
------------------------------------------------------------------------------
svn:eol-style = native
Added:
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/vdmonisvc.c
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/vdmonisvc.c?rev=980662&view=auto
==============================================================================
---
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/vdmonisvc.c
(added)
+++
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/vdmonisvc.c
Fri Jul 30 06:50:12 2010
@@ -0,0 +1,708 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: vdmonisvc.c 909069 2010-02-11 16:43:36Z mturk $ */
+
+/* jsvc monitor service module:
+ * Implements the body of the service.
+ * It reads the register entry and starts the jsvc.
+ */
+
+#include <windows.h>
+#include <winuser.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <process.h>
+#include <time.h>
+#ifdef CYGWIN
+#else
+#include <tchar.h>
+#endif
+#include "moni_inst.h"
+
+/* globals */
+SERVICE_STATUS ssStatus;
+SERVICE_STATUS_HANDLE sshStatusHandle;
+DWORD dwErr;
+HANDLE hServerStopEvent = NULL;
+HANDLE hMonitorProcess = NULL;
+
+/*
+ * NT/other detection
+ * from src/os/win32/service.c (httpd-1.3!).
+ */
+
+BOOL isWindowsNT(void)
+{
+ static BOOL once = FALSE;
+ static BOOL isNT = FALSE;
+
+ if (!once)
+ {
+ OSVERSIONINFO osver;
+ osver.dwOSVersionInfoSize = sizeof(osver);
+ if (GetVersionEx(&osver))
+ if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ isNT = TRUE;
+ once = TRUE;
+ }
+ return isNT;
+}
+
+/* Event logger routine */
+
+VOID AddToMessageLog(LPTSTR lpszMsg)
+{
+ TCHAR szMsg[256];
+ HANDLE hEventSource;
+ LPCTSTR lpszStrings[2];
+
+
+ dwErr = GetLastError();
+
+ /* Use event logging to log the error. */
+
+ if (isWindowsNT())
+ hEventSource = RegisterEventSource(NULL, TEXT(SZSERVICENAME));
+ else
+ hEventSource = NULL;
+
+#ifdef CYGWIN
+ sprintf(szMsg, TEXT("%s ERROR: %d"), TEXT(SZSERVICENAME), dwErr);
+#else
+ _stprintf(szMsg, TEXT("%s ERROR: %d"), TEXT(SZSERVICENAME), dwErr);
+#endif
+ lpszStrings[0] = szMsg;
+ lpszStrings[1] = lpszMsg;
+
+ if (hEventSource != NULL) {
+ ReportEvent(hEventSource, /* handle of event source */
+ EVENTLOG_ERROR_TYPE, /* event type */
+ 0, /* event category */
+ 0, /* event ID */
+ NULL, /* current user's SID */
+ 2, /* strings in lpszStrings */
+ 0, /* no bytes of raw data */
+ lpszStrings, /* array of error strings */
+ NULL); /* no raw data */
+
+ (VOID) DeregisterEventSource(hEventSource);
+ } else {
+ /* Default to a trace file */
+ FILE *log;
+ log = fopen("c:/jakarta-service.log","a+");
+ if (log != NULL) {
+ struct tm *newtime;
+ time_t long_time;
+
+ time( &long_time );
+ newtime = localtime( &long_time );
+
+ if (dwErr)
+ fprintf(log,"%.24s:%s: %s\n",asctime(newtime),szMsg, lpszMsg);
+ else
+ fprintf(log,"%.24s: %s\n",asctime(newtime), lpszMsg);
+ fclose(log);
+ }
+ }
+}
+
+/*
+ *
+ * FUNCTION: ServiceStop
+ *
+ * PURPOSE: Stops the service
+ *
+ * PARAMETERS:
+ * none
+ *
+ * RETURN VALUE:
+ * none
+ *
+ * COMMENTS:
+ * If a ServiceStop procedure is going to
+ * take longer than 3 seconds to execute,
+ * it should spawn a thread to execute the
+ * stop code, and return. Otherwise, the
+ * ServiceControlManager will believe that
+ * the service has stopped responding.
+ *
+ */
+VOID ServiceStop()
+{
+ if ( hServerStopEvent )
+ SetEvent(hServerStopEvent);
+}
+
+/*
+ * Wait for the monitor process to stop
+ */
+int WaitForMonitor(int num)
+{
+ DWORD qreturn;
+ int i;
+
+ for (i=0;i<num;i++) {
+ if (hMonitorProcess == NULL) break;
+ if (GetExitCodeProcess(hMonitorProcess, &qreturn)) {
+ if (qreturn == STILL_ACTIVE) {
+ Sleep(1000);
+ continue;
+ }
+ hMonitorProcess = NULL;
+ break;
+ }
+ break;
+ }
+ if (i==num)
+ return -1;
+ return 0;
+}
+/* This group of functions are provided for the service/console app
+ * to register itself a HandlerRoutine to accept tty or service messages
+ * adapted from src/os/win32/Win9xConHook.c (httpd-1.3!).
+ */
+
+/* This is the WndProc procedure for our invisible window.
+ * When our subclasssed tty window receives the WM_CLOSE, WM_ENDSESSION,
+ * or WM_QUERYENDSESSION messages, the message is dispatched to our hidden
+ * window (this message process), and we call the installed HandlerRoutine
+ * that was registered by the app.
+ */
+#ifndef ENDSESSION_LOGOFF
+#define ENDSESSION_LOGOFF 0x80000000
+#endif
+static LRESULT CALLBACK ttyConsoleCtrlWndProc(HWND hwnd, UINT msg,
+ WPARAM wParam, LPARAM lParam)
+{
+ int qreturn;
+ if (msg == WM_CREATE) {
+ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc WM_CREATE"));
+ return 0;
+ } else if (msg == WM_DESTROY) {
+ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc WM_DESTROY"));
+ return 0;
+ } else if (msg == WM_CLOSE) {
+ /* Call StopService?. */
+ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc WM_CLOSE"));
+ return 0; /* May return 1 if StopService failed. */
+ } else if ((msg == WM_QUERYENDSESSION) || (msg == WM_ENDSESSION)) {
+ if (lParam & ENDSESSION_LOGOFF) {
+ /* Here we have nothing to our hidden windows should stay. */
+ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc LOGOFF"));
+ return(1); /* Otherwise it cancels the logoff */
+ } else {
+ /* Stop Service. */
+ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc SHUTDOWN"));
+ ServiceStop();
+
+ /* Wait until it stops. */
+ qreturn = WaitForMonitor(3);
+
+ if (msg == WM_QUERYENDSESSION) {
+ AddToMessageLog(
+ TEXT("ttyConsoleCtrlWndProc SHUTDOWN (query)"));
+ if (qreturn) {
+ AddToMessageLog(
+ TEXT("Cancelling shutdown: cannot stop service"));
+ return(0);
+ }
+ } else
+ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc SHUTDOWN"));
+ return(1); /* Otherwise it cancels the shutdown. */
+ }
+ }
+ return (DefWindowProc(hwnd, msg, wParam, lParam));
+}
+/* ttyConsoleCreateThread is the process that runs within the user app's
+ * context. It creates and pumps the messages of a hidden monitor window,
+ * watching for messages from the system, or the associated subclassed tty
+ * window. Things can happen in our context that can't be done from the
+ * tty's context, and visa versa, so the subclass procedure and this hidden
+ * window work together to make it all happen.
+ */
+static DWORD WINAPI ttyConsoleCtrlThread()
+{
+ HWND monitor_hwnd;
+ WNDCLASS wc;
+ MSG msg;
+ wc.style = CS_GLOBALCLASS;
+ wc.lpfnWndProc = ttyConsoleCtrlWndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 8;
+ wc.hInstance = NULL;
+ wc.hIcon = NULL;
+ wc.hCursor = NULL;
+ wc.hbrBackground = NULL;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = "ApacheJakartaService";
+
+ if (!RegisterClass(&wc)) {
+ AddToMessageLog(TEXT("RegisterClass failed"));
+ return 0;
+ }
+
+ /* Create an invisible window */
+ monitor_hwnd = CreateWindow(wc.lpszClassName,
+ "ApacheJakartaService",
+ WS_OVERLAPPED & ~WS_VISIBLE,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ NULL, NULL,
+ GetModuleHandle(NULL), NULL);
+
+ if (!monitor_hwnd) {
+ AddToMessageLog(TEXT("RegisterClass failed"));
+ return 0;
+ }
+
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ return 0;
+}
+/*
+ * Register the process to resist logoff and start the thread that will receive
+ * the shutdown via a hidden window.
+ */
+BOOL Windows9xServiceCtrlHandler()
+{
+ HANDLE hThread;
+ DWORD tid;
+ HINSTANCE hkernel;
+ DWORD (WINAPI *register_service_process)(DWORD, DWORD) = NULL;
+
+ /* If we have not yet done so */
+ FreeConsole();
+
+ /* Make sure the process will resist logoff */
+ hkernel = LoadLibrary("KERNEL32.DLL");
+ if (!hkernel) {
+ AddToMessageLog(TEXT("LoadLibrary KERNEL32.DLL failed"));
+ return 0;
+ }
+ register_service_process = (DWORD (WINAPI *)(DWORD, DWORD))
+ GetProcAddress(hkernel, "RegisterServiceProcess");
+ if (register_service_process == NULL) {
+ AddToMessageLog(TEXT("dlsym RegisterServiceProcess failed"));
+ return 0;
+ }
+ if (!register_service_process(0,TRUE)) {
+ FreeLibrary(hkernel);
+ AddToMessageLog(TEXT("register_service_process failed"));
+ return 0;
+ }
+ AddToMessageLog(TEXT("jsvc registered as a service"));
+
+ /*
+ * To be handle notice the shutdown, we need a thread and window.
+ */
+ hThread = CreateThread(NULL, 0, ttyConsoleCtrlThread,
+ (LPVOID)NULL, 0, &tid);
+ if (hThread) {
+ CloseHandle(hThread);
+ return TRUE;
+ }
+ AddToMessageLog(TEXT("jsvc shutdown listener start failed"));
+ return TRUE;
+}
+
+/*
+ *
+ * FUNCTION: ReportStatusToSCMgr()
+ *
+ * PURPOSE: Sets the current status of the service and
+ * reports it to the Service Control Manager
+ *
+ * PARAMETERS:
+ * dwCurrentState - the state of the service
+ * dwWin32ExitCode - error code to report
+ * dwWaitHint - worst case estimate to next checkpoint
+ *
+ * RETURN VALUE:
+ * TRUE - success
+ * FALSE - failure
+ *
+ * COMMENTS:
+ *
+ */
+BOOL ReportStatusToSCMgr(DWORD dwCurrentState,
+ DWORD dwWin32ExitCode,
+ DWORD dwWaitHint)
+{
+ static DWORD dwCheckPoint = 1;
+ BOOL fResult = TRUE;
+
+
+ if (dwCurrentState == SERVICE_START_PENDING)
+ ssStatus.dwControlsAccepted = 0;
+ else
+ ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
+
+ ssStatus.dwCurrentState = dwCurrentState;
+ ssStatus.dwWin32ExitCode = dwWin32ExitCode;
+ ssStatus.dwWaitHint = dwWaitHint;
+
+ if ( ( dwCurrentState == SERVICE_RUNNING ) ||
+ ( dwCurrentState == SERVICE_STOPPED ) )
+ ssStatus.dwCheckPoint = 0;
+ else
+ ssStatus.dwCheckPoint = dwCheckPoint++;
+
+
+ /* Report the status of the service to the service control manager. */
+
+ if (!(fResult = SetServiceStatus( sshStatusHandle, &ssStatus))) {
+ AddToMessageLog(TEXT("SetServiceStatus"));
+ }
+ return fResult;
+}
+
+/*
+ * Report event to the Service Manager
+ */
+int ReportManager(int event)
+{
+ if (isWindowsNT())
+ return(ReportStatusToSCMgr(
+ event, /* service state */
+ NO_ERROR, /* exit code */
+ 3000)); /* wait hint */
+ return(1);
+}
+
+/*
+ *
+ * FUNCTION: ServiceStart
+ *
+ * PURPOSE: Actual code of the service
+ * that does the work.
+ *
+ * PARAMETERS:
+ * dwArgc - number of command line arguments
+ * lpszArgv - array of command line arguments
+ *
+ * RETURN VALUE:
+ * none
+ *
+ * COMMENTS:
+ * The default behavior is to read the registry and start jsvc.
+ * The service stops when hServerStopEvent is signalled, the jsvc
+ * is stopped via TermPid(pid) (see kills.c).
+ *
+ */
+VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv)
+{
+char Data[512];
+DWORD qreturn;
+STARTUPINFO StartupInfo;
+PROCESS_INFORMATION ProcessInformation;
+char *qptr;
+
+
+ /* Service initialization */
+ ProcessInformation.hProcess = NULL;
+
+ /* report the status to the service control manager. */
+
+ AddToMessageLog(TEXT("ServiceStart: starting"));
+ if (!ReportManager(SERVICE_START_PENDING))
+ goto cleanup;
+
+ /*
+ * create the event object. The control handler function signals
+ * this event when it receives the "stop" control code.
+ *
+ */
+ hServerStopEvent = CreateEvent(
+ NULL, /* no security attributes */
+ TRUE, /* manual reset event */
+ FALSE, /* not-signalled */
+ NULL); /* no name */
+
+ if ( hServerStopEvent == NULL)
+ goto cleanup;
+
+ /* report the status to the service control manager. */
+ if (!ReportManager(SERVICE_START_PENDING))
+ goto cleanup;
+
+ /* Read the registry and set environment. */
+ if (OnServeSetEnv()) {
+ AddToMessageLog(TEXT("ServiceStart: read environment failed"));
+ goto cleanup;
+ }
+
+ if (!ReportManager(SERVICE_START_PENDING))
+ goto cleanup;
+
+ /* set the start path for jsvc.exe */
+ qptr = getenv("JAKARTA_HOME");
+ if (qptr==NULL || strlen(qptr)==0) {
+ AddToMessageLog(TEXT("ServiceStart: read JAKARTA_HOME failed"));
+ goto cleanup;
+ }
+
+ /* Build the start jsvc command according to the registry information. */
+ strcpy(Data,qptr);
+ BuildCommand(Data);
+ AddToMessageLog(TEXT(Data));
+
+ /* create the jsvc process. */
+ AddToMessageLog(TEXT("ServiceStart: start jsvc"));
+ memset(&StartupInfo,'\0',sizeof(StartupInfo));
+ StartupInfo.cb = sizeof(STARTUPINFO);
+
+ if (!CreateProcess(NULL,Data,NULL,NULL,FALSE,
+ DETACHED_PROCESS|NORMAL_PRIORITY_CLASS,
+ NULL,NULL, &StartupInfo, &ProcessInformation))
+ goto cleanup;
+ AddToMessageLog(TEXT("ServiceStart: jsvc started"));
+ CloseHandle(ProcessInformation.hThread);
+ ProcessInformation.hThread = NULL;
+ hMonitorProcess = ProcessInformation.hProcess;
+
+ if (!ReportManager(SERVICE_START_PENDING))
+ goto cleanup;
+
+ /* wait until the process is completly created. */
+/* With the DETACHED_PROCESS it does not work...
+ if (WaitForInputIdle(ProcessInformation.hProcess , INFINITE)) {
+ AddToMessageLog(TEXT("ServiceStart: jsvc stopped after creation"));
+ goto cleanup;
+ }
+ */
+
+ /*
+ * jsvc is now running.
+ * report the status to the service control manager.
+ */
+
+ if (!ReportManager(SERVICE_RUNNING))
+ goto cleanup;
+
+ /* End of initialization */
+
+ /*
+ *
+ * Service is now running, perform work until shutdown:
+ * Check every 60 seconds if the monitor is up.
+ *
+ */
+
+ for (;;) {
+ qreturn = WaitForSingleObject(hServerStopEvent,60000); /* each minutes.
*/
+
+ if (qreturn == WAIT_FAILED) break;/* something have gone wrong. */
+
+ if (qreturn == WAIT_TIMEOUT) {
+ /* timeout check the monitor. */
+ if (GetExitCodeProcess(ProcessInformation.hProcess, &qreturn)) {
+ if (qreturn == STILL_ACTIVE) continue;
+ }
+ AddToMessageLog(TEXT("ServiceStart: jsvc crashed"));
+ hMonitorProcess = NULL;
+ CloseHandle(hServerStopEvent);
+ CloseHandle(ProcessInformation.hProcess);
+ exit(0); /* exit ungracefully so
+ * Service Control Manager
+ * will attempt a restart. */
+
+ break; /*failed. */
+ }
+
+ /* stop the monitor by signal(event) */
+ sprintf(Data,"ServiceStart: stopping jsvc: %d",
+ ProcessInformation.dwProcessId);
+ AddToMessageLog(Data);
+
+ if (TermPid(ProcessInformation.dwProcessId)) {
+ AddToMessageLog(TEXT("ServiceStart: jsvc stop failed"));
+ break;
+ }
+ WaitForMonitor(6);
+ AddToMessageLog(TEXT("ServiceStart: jsvc stopped"));
+ break; /* finished!!! */
+ }
+
+ cleanup:
+
+ AddToMessageLog(TEXT("ServiceStart: stopped"));
+ if (hServerStopEvent)
+ CloseHandle(hServerStopEvent);
+
+ if (ProcessInformation.hProcess)
+ CloseHandle(ProcessInformation.hProcess);
+
+}
+
+/*
+ *
+ * FUNCTION: service_ctrl
+ *
+ * PURPOSE: This function is called by the SCM whenever
+ * ControlService() is called on this service.
+ *
+ * PARAMETERS:
+ * dwCtrlCode - type of control requested
+ *
+ * RETURN VALUE:
+ * none
+ *
+ * COMMENTS:
+ *
+ */
+VOID WINAPI service_ctrl(DWORD dwCtrlCode)
+{
+ /* Handle the requested control code. */
+ switch(dwCtrlCode)
+ {
+ /* Stop the service.
+ *
+ * SERVICE_STOP_PENDING should be reported before
+ * setting the Stop Event - hServerStopEvent - in
+ * ServiceStop(). This avoids a race condition
+ * which may result in a 1053 - The Service did not respond...
+ * error.
+ */
+ case SERVICE_CONTROL_STOP:
+ ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, 0);
+ ServiceStop();
+ return;
+
+ /* Update the service status. */
+ case SERVICE_CONTROL_INTERROGATE:
+ break;
+
+ /* invalid control code */
+ default:
+ break;
+
+ }
+
+ ReportStatusToSCMgr(ssStatus.dwCurrentState, NO_ERROR, 0);
+}
+
+/*
+ *
+ * FUNCTION: service_main
+ *
+ * PURPOSE: To perform actual initialization of the service
+ *
+ * PARAMETERS:
+ * dwArgc - number of command line arguments
+ * lpszArgv - array of command line arguments
+ *
+ * RETURN VALUE:
+ * none
+ *
+ * COMMENTS:
+ * This routine performs the service initialization and then calls
+ * the user defined ServiceStart() routine to perform majority
+ * of the work.
+ *
+ */
+void WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv)
+{
+
+ AddToMessageLog(TEXT("service_main:starting"));
+
+ /* register our service control handler: */
+ sshStatusHandle = RegisterServiceCtrlHandler( TEXT(SZSERVICENAME),
+ service_ctrl);
+
+ if (!sshStatusHandle) {
+ AddToMessageLog(TEXT("service_main:RegisterServiceCtrlHandler failed"));
+ goto cleanup;
+ }
+
+ /* SERVICE_STATUS members that don't change in example */
+ ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ ssStatus.dwServiceSpecificExitCode = 0;
+
+
+ /* report the status to the service control manager. */
+ if (!ReportStatusToSCMgr(SERVICE_START_PENDING,NO_ERROR,3000)) {
+ AddToMessageLog(TEXT("service_main:ReportStatusToSCMgr failed"));
+ goto cleanup;
+ }
+
+
+ ServiceStart( dwArgc, lpszArgv );
+
+cleanup:
+ /*
+ * try to report the stopped status to the service control manager.
+ */
+ if (sshStatusHandle)
+ (VOID)ReportStatusToSCMgr(
+ SERVICE_STOPPED,
+ dwErr,
+ 0);
+
+ AddToMessageLog(TEXT("service_main:stopped"));
+ return;
+}
+
+/*
+ *
+ * FUNCTION: main
+ *
+ * PURPOSE: entrypoint for service
+ *
+ * PARAMETERS:
+ * argc - number of command line arguments
+ * argv - array of command line arguments
+ *
+ * RETURN VALUE:
+ * none
+ *
+ * COMMENTS:
+ * main() either performs the command line task, or
+ * call StartServiceCtrlDispatcher to register the
+ * main service thread. When the this call returns,
+ * the service has stopped, so exit.
+ *
+ */
+#ifdef CYGWIN
+int main(int argc, char **argv)
+#else
+void _CRTAPI1 main(int argc, char **argv)
+#endif
+{
+ SERVICE_TABLE_ENTRY dispatchTable[] =
+ {
+ { TEXT(SZSERVICENAME), (LPSERVICE_MAIN_FUNCTION)service_main },
+ { NULL, NULL }
+ };
+
+ AddToMessageLog(TEXT("StartService starting"));
+ if (isWindowsNT()) {
+ if (!StartServiceCtrlDispatcher(dispatchTable)) {
+ AddToMessageLog(TEXT("StartServiceCtrlDispatcher failed."));
+ return;
+ }
+ AddToMessageLog(TEXT("StartService started"));
+ } else {
+ Windows9xServiceCtrlHandler();
+ ServiceStart(argc,argv);
+ AddToMessageLog(TEXT("StartService stopped"));
+ }
+}
Propchange:
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/moni/vdmonisvc.c
------------------------------------------------------------------------------
svn:eol-style = native
Added:
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/README.dev
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/README.dev?rev=980662&view=auto
==============================================================================
---
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/README.dev
(added)
+++
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/README.dev
Fri Jul 30 06:50:12 2010
@@ -0,0 +1,25 @@
+Apache Commons Daemon
+=====================
+
+
+Configuring and Building Commons Daemon on Windows
+==================================================
+
+Using Visual Studio, you can build the Commons Daemon.
+The Makefile make file has a bunch of documentation about it's
+options, but a trivial build is simply;
+
+ nmake CPU=X86
+ nmake CPU=X86 PREFIX=c:\desired\path\of\daemon install
+
+
+Needed Tools
+============
+
+Commons Daemon needs the Microsoft Visual C 6/SP5 to
+build the x86 binaries. This is because this compiler
+doesn't create MSVCRTnn.DLL dependecies which will
+be loaded inside running JVM if used.
+For building AMD64/EMT64 binaries use the Platform SDK
+for Windows Server 2003R2.
+
Added:
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/apps/prunmgr/Makefile
URL:
http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/apps/prunmgr/Makefile?rev=980662&view=auto
==============================================================================
---
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/apps/prunmgr/Makefile
(added)
+++
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/apps/prunmgr/Makefile
Fri Jul 30 06:50:12 2010
@@ -0,0 +1,87 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# @author Mladen Turk
+#
+#
+TARGET = GUI
+PROJECT = prunmgr
+UNICODE = 1
+!include <..\..\include\Makefile.inc>
+
+!IF !DEFINED(PREFIX) || "$(PREFIX)" == ""
+PREFIX = .\..\..\dist
+!ENDIF
+!IF !DEFINED(SRCDIR) || "$(SRCDIR)" == ""
+SRCDIR = .\..\..
+!ENDIF
+
+LFLAGS = $(LFLAGS) /version:1.0
+LIBS = $(LIBS) user32.lib gdi32.lib winspool.lib comdlg32.lib comctl32.lib
shlwapi.lib netapi32.lib
+INCLUDES = -I$(SRCDIR)\include -I$(SRCDIR)\src $(JAVA_INCLUDES)
+
+PDBFLAGS = -Fo$(WORKDIR)\ -Fd$(WORKDIR)\$(PROJECT)-src
+OBJECTS = \
+ $(WORKDIR)\cmdline.obj \
+ $(WORKDIR)\console.obj \
+ $(WORKDIR)\gui.obj \
+ $(WORKDIR)\handles.obj \
+ $(WORKDIR)\javajni.obj \
+ $(WORKDIR)\log.obj \
+ $(WORKDIR)\mclib.obj \
+ $(WORKDIR)\registry.obj \
+ $(WORKDIR)\rprocess.obj \
+ $(WORKDIR)\service.obj \
+ $(WORKDIR)\utils.obj \
+ $(WORKDIR)\prunmgr.obj
+
+BUILDEXE = $(WORKDIR)\$(PROJECT).exe
+BUILDLOC = $(PREFIX)
+!IF "$(CPU)" == "X64"
+BUILDLOC = $(PREFIX)\amd64
+!ELSEIF "$(CPU)" == "I64"
+BUILDLOC = $(PREFIX)\ia64
+!ENDIF
+BUILDPDB = $(WORKDIR)\$(PROJECT).pdb
+BUILDRES = $(WORKDIR)\$(PROJECT).res
+BUILDMAN = $(BUILDEXE).manifest
+
+all : $(WORKDIR) $(BUILDEXE)
+
+$(BUILDLOC) :
+ @if not exist "$(BUILDLOC)\$(NULL)" mkdir "$(BUILDLOC)"
+
+$(WORKDIR) :
+ @$(MAKEWORKDIR)
+
+{$(SRCDIR)\src}.c{$(WORKDIR)}.obj:
+ $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
+
+{$(SRCDIR)\apps\prunmgr}.c{$(WORKDIR)}.obj:
+ $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
+
+$(BUILDRES): $(SRCDIR)/apps/prunmgr/prunmgr.rc
+ $(RC) $(RCFLAGS) /i "$(SRCDIR)\include" /fo $(BUILDRES)
$(SRCDIR)/apps/prunmgr/prunmgr.rc
+
+$(BUILDEXE): $(WORKDIR) $(OBJECTS) $(BUILDRES)
+ $(LINK) $(LFLAGS) $(OBJECTS) $(BUILDRES) $(LIBS) $(LDIRS)
/pdb:$(BUILDPDB) /out:$(BUILDEXE)
+ IF EXIST $(BUILDMAN) \
+ mt -nologo -manifest $(BUILDMAN) -outputresource:$(BUILDEXE);1
+
+clean:
+ @$(CLEANTARGET)
+
+install: $(BUILDLOC) $(WORKDIR) $(BUILDEXE)
+ @xcopy "$(WORKDIR)\*.exe" "$(BUILDLOC)" /Y /Q
Propchange:
commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/apps/prunmgr/Makefile
------------------------------------------------------------------------------
svn:eol-style = native