jfclere 2002/10/31 03:32:05 Modified: daemon/src/native/nt/executables/vdmoniadm resource.h daemon/src/native/nt/executables/vdmonisvc resource.h daemon/src/native/nt/moni vdmoniadm.c vdmonisvc.c daemon/src/native/nt/service instmain.c daemon/src/native/nt/signals kills.c daemon/src/native/nt/supcalls_nt vdenv.c daemon/src/native/unix/native signals.c Log: Arrange licence stuff and C++ comments. Revision Changes Path 1.2 +61 -6 jakarta-commons-sandbox/daemon/src/native/nt/executables/vdmoniadm/resource.h Index: resource.h =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/executables/vdmoniadm/resource.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- resource.h 18 Feb 2002 21:15:40 -0000 1.1 +++ resource.h 31 Oct 2002 11:32:04 -0000 1.2 @@ -1,7 +1,62 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by vdmoniadm.rc -// +/* ========================================================================= * + * * + * The Apache Software License, Version 1.1 * + * * + * Copyright (c) 1999-2002 The Apache Software Foundation. * + * All rights reserved. * + * * + * ========================================================================= * + * * + * Redistribution and use in source and binary forms, with or without modi- * + * fication, are permitted provided that the following conditions are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice * + * notice, this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. The end-user documentation included with the redistribution, if any, * + * must include the following acknowlegement: * + * * + * "This product includes software developed by the Apache Software * + * Foundation <http://www.apache.org/>." * + * * + * Alternately, this acknowlegement may appear in the software itself, if * + * and wherever such third-party acknowlegements normally appear. * + * * + * 4. The names "The Jakarta Project", "WebApp", and "Apache Software * + * Foundation" must not be used to endorse or promote products derived * + * from this software without prior written permission. For written * + * permission, please contact <[EMAIL PROTECTED]>. * + * * + * 5. Products derived from this software may not be called "Apache" nor may * + * "Apache" appear in their names without prior written permission of the * + * Apache Software Foundation. * + * * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES * + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * + * THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY * + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * + * POSSIBILITY OF SUCH DAMAGE. * + * * + * ========================================================================= * + * * + * This software consists of voluntary contributions made by many indivi- * + * duals on behalf of the Apache Software Foundation. For more information * + * on the Apache Software Foundation, please see <http://www.apache.org/>. * + * * + * ========================================================================= */ + +/* @version $Id$ */ +/* Used by vdmoniadm.rc */ #define NO_ACCESS 1 #define NO_ACCESS_MONI 2 #define ALREADY_STOP 3 @@ -15,8 +70,8 @@ #define ID_PROPRETY 40003 #define ID_START_VDCOM 40008 -// Next default values for new objects -// +/* Next default values for new objects */ + #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 103 1.2 +60 -6 jakarta-commons-sandbox/daemon/src/native/nt/executables/vdmonisvc/resource.h Index: resource.h =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/executables/vdmonisvc/resource.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- resource.h 18 Feb 2002 21:15:39 -0000 1.1 +++ resource.h 31 Oct 2002 11:32:04 -0000 1.2 @@ -1,10 +1,64 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by vdmonisvc.rc -// +/* ========================================================================= * + * * + * The Apache Software License, Version 1.1 * + * * + * Copyright (c) 1999-2001 The Apache Software Foundation. * + * All rights reserved. * + * * + * ========================================================================= * + * * + * Redistribution and use in source and binary forms, with or without modi- * + * fication, are permitted provided that the following conditions are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice * + * notice, this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. The end-user documentation included with the redistribution, if any, * + * must include the following acknowlegement: * + * * + * "This product includes software developed by the Apache Software * + * Foundation <http://www.apache.org/>." * + * * + * Alternately, this acknowlegement may appear in the software itself, if * + * and wherever such third-party acknowlegements normally appear. * + * * + * 4. The names "The Jakarta Project", "WebApp", and "Apache Software * + * Foundation" must not be used to endorse or promote products derived * + * from this software without prior written permission. For written * + * permission, please contact <[EMAIL PROTECTED]>. * + * * + * 5. Products derived from this software may not be called "Apache" nor may * + * "Apache" appear in their names without prior written permission of the * + * Apache Software Foundation. * + * * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES * + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * + * THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY * + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * + * POSSIBILITY OF SUCH DAMAGE. * + * * + * ========================================================================= * + * * + * This software consists of voluntary contributions made by many indivi- * + * duals on behalf of the Apache Software Foundation. For more information * + * on the Apache Software Foundation, please see <http://www.apache.org/>. * + * * + * ========================================================================= */ -// Next default values for new objects -// +/* @version $Id$ */ +/* Used by vdmonisvc.rc */ + +/* Next default values for new objects */ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 105 1.2 +88 -39 jakarta-commons-sandbox/daemon/src/native/nt/moni/vdmoniadm.c Index: vdmoniadm.c =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/moni/vdmoniadm.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- vdmoniadm.c 18 Feb 2002 21:15:40 -0000 1.1 +++ vdmoniadm.c 31 Oct 2002 11:32:04 -0000 1.2 @@ -1,15 +1,61 @@ -#ident "%W% %E% ONSERVE V3.0" +/* ========================================================================= * + * * + * The Apache Software License, Version 1.1 * + * * + * Copyright (c) 1999-2001 The Apache Software Foundation. * + * All rights reserved. * + * * + * ========================================================================= * + * * + * Redistribution and use in source and binary forms, with or without modi- * + * fication, are permitted provided that the following conditions are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice * + * notice, this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. The end-user documentation included with the redistribution, if any, * + * must include the following acknowlegement: * + * * + * "This product includes software developed by the Apache Software * + * Foundation <http://www.apache.org/>." * + * * + * Alternately, this acknowlegement may appear in the software itself, if * + * and wherever such third-party acknowlegements normally appear. * + * * + * 4. The names "The Jakarta Project", "WebApp", and "Apache Software * + * Foundation" must not be used to endorse or promote products derived * + * from this software without prior written permission. For written * + * permission, please contact <[EMAIL PROTECTED]>. * + * * + * 5. Products derived from this software may not be called "Apache" nor may * + * "Apache" appear in their names without prior written permission of the * + * Apache Software Foundation. * + * * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES * + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * + * THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY * + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * + * POSSIBILITY OF SUCH DAMAGE. * + * * + * ========================================================================= * + * * + * This software consists of voluntary contributions made by many indivi- * + * duals on behalf of the Apache Software Foundation. For more information * + * on the Apache Software Foundation, please see <http://www.apache.org/>. * + * * + * ========================================================================= */ -/* ------------------------------------------------------------ * - * file: vdmonistop.c - * authors: Fujitsu-siemens - * modified: OEC BS DC22, Barcelona - * date: July 1997 - * compiler: ANSI C - * desc: stop the monitor service. - * note: - * bugs: 0 - * ------------------------------------------------------------ */ +/* @version $Id$ */ #include <windows.h> /* required for all Windows applications */ #include <stdio.h> /* for sprintf */ @@ -35,10 +81,10 @@ BOOL InitApplication(HANDLE hInstance); -HANDLE hInst; // current instance +HANDLE hInst; /* current instance */ SC_HANDLE hManager=NULL; SC_HANDLE hService=NULL; -int optmode; // start, stop or check. +int optmode; /* start, stop or check. */ int flagdown = 0; #define VDMONISTART 0 @@ -62,12 +108,14 @@ 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 +/* + * 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; @@ -91,12 +139,13 @@ 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 +/* + * 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; @@ -217,7 +266,7 @@ switch (message) { case WM_INITDIALOG: - SetTimer(hDlg,VM_ID_TIMER2,5000,NULL); // wait 5 seconds. + SetTimer(hDlg,VM_ID_TIMER2,5000,NULL); /* wait 5 seconds. */ case WM_COMMAND: /* message: received a command */ if (LOWORD(wParam) == IDCANCEL) EndDialog(hDlg, FALSE); @@ -226,7 +275,7 @@ if(IsStopped(hDlg)) EndDialog(hDlg, TRUE); else - SetTimer(hDlg,VM_ID_TIMER2,5000,NULL); // wait 5 seconds. + SetTimer(hDlg,VM_ID_TIMER2,5000,NULL); /* wait 5 seconds. */ return(TRUE); } /* End switch message */ return (FALSE); /* Didn't process a message */ @@ -250,14 +299,14 @@ if (IsRunning(hDlg)) EndDialog(hDlg, TRUE); else - SetTimer(hDlg,VM_ID_TIMER1,5000,NULL); // wait 5 seconds. + 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. + SetTimer(hDlg,VM_ID_TIMER1,5000,NULL); /* wait 5 seconds. */ return(TRUE); case WM_COMMAND: /* message: received a command */ @@ -287,10 +336,10 @@ GetCursorPos(&point); - SetForegroundWindow(hWnd); // MS bug. + 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. + PostMessage(hWnd, WM_USER, 0, 0); /* MS bug. */ DestroyMenu(hMenu); } @@ -370,23 +419,23 @@ switch (message) { case WM_CREATE: - // acces to service manager. + /* 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. + /* 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. + /* check if running. */ if (QueryServiceStatus(hService, &svcStatus)) { - // and see if the service is stopped + /* and see if the service is stopped */ if (SERVICE_STOPPED == svcStatus.dwCurrentState && optmode == VDMONISTOP) { DisplayMess(hWnd,ALREADY_STOP); @@ -438,7 +487,7 @@ case WM_RBUTTONUP: if (flagdown == 1) { flagdown = 2; - // show a menu. + /* show a menu. */ ShowMenu(hWnd); } break; @@ -449,7 +498,7 @@ case WM_TIMER: /* check if service is running */ if (QueryServiceStatus(hService, &svcStatus)) { - // and see if the service is stopped + /* and see if the service is stopped */ if (SERVICE_STOPPED == svcStatus.dwCurrentState) { MyTaskBarDeleteIcon(hWnd); PostQuitMessage(0); @@ -460,13 +509,13 @@ break; case VM_START_ICON: - // add the icon and timer. + /* add the icon and timer. */ MyTaskBarAddIcon(hWnd); SetTimer(hWnd,VM_ID_TIMER,5000,NULL); break; case WM_COMMAND: - // command for the popup menu. + /* command for the popup menu. */ switch (LOWORD(wParam)) { case ID_START_VDCOM: StartVdcom(hWnd); 1.3 +264 -207 jakarta-commons-sandbox/daemon/src/native/nt/moni/vdmonisvc.c Index: vdmonisvc.c =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/moni/vdmonisvc.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- vdmonisvc.c 20 Mar 2002 23:39:32 -0000 1.2 +++ vdmonisvc.c 31 Oct 2002 11:32:04 -0000 1.3 @@ -1,15 +1,66 @@ -// -// OnServe monitor service module. -// -// MODULE: vdmonisvc.c -// -// PURPOSE: Implements the body of the service. -// It reads the register entry and starts the jsvc. -// -// FUNCTIONS: -// ServiceStart(DWORD dwArgc, LPTSTR *lpszArgv); -// ServiceStop( ); - +/* ========================================================================= * + * * + * The Apache Software License, Version 1.1 * + * * + * Copyright (c) 1999-2001 The Apache Software Foundation. * + * All rights reserved. * + * * + * ========================================================================= * + * * + * Redistribution and use in source and binary forms, with or without modi- * + * fication, are permitted provided that the following conditions are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice * + * notice, this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. The end-user documentation included with the redistribution, if any, * + * must include the following acknowlegement: * + * * + * "This product includes software developed by the Apache Software * + * Foundation <http://www.apache.org/>." * + * * + * Alternately, this acknowlegement may appear in the software itself, if * + * and wherever such third-party acknowlegements normally appear. * + * * + * 4. The names "The Jakarta Project", "WebApp", and "Apache Software * + * Foundation" must not be used to endorse or promote products derived * + * from this software without prior written permission. For written * + * permission, please contact <[EMAIL PROTECTED]>. * + * * + * 5. Products derived from this software may not be called "Apache" nor may * + * "Apache" appear in their names without prior written permission of the * + * Apache Software Foundation. * + * * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES * + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * + * THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY * + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * + * POSSIBILITY OF SUCH DAMAGE. * + * * + * ========================================================================= * + * * + * This software consists of voluntary contributions made by many indivi- * + * duals on behalf of the Apache Software Foundation. For more information * + * on the Apache Software Foundation, please see <http://www.apache.org/>. * + * * + * ========================================================================= */ + +/* @version $Id$ */ + +/* 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> @@ -63,8 +114,8 @@ dwErr = GetLastError(); - // Use event logging to log the error. - // + /* Use event logging to log the error. */ + if (isWindowsNT()) hEventSource = RegisterEventSource(NULL, TEXT(SZSERVICENAME)); else @@ -79,15 +130,15 @@ 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 + 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 { @@ -110,25 +161,27 @@ } } -// -// 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. -// +/* + * + * 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 ) @@ -184,20 +237,20 @@ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc WM_DESTROY")); return 0; } else if (msg == WM_CLOSE) { - // Call StopService?. + /* Call StopService?. */ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc WM_CLOSE")); - return 0; // May return 1 if StopService failed. + 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. + /* Here we have nothing to our hidden windows should stay. */ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc LOGOFF")); - return(1); // Otherwise it cancels the logoff + return(1); /* Otherwise it cancels the logoff */ } else { - // Stop Service. + /* Stop Service. */ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc SHUTDOWN")); ServiceStop(); - // Wait until it stops. + /* Wait until it stops. */ qreturn = WaitForMonitor(3); if (msg == WM_QUERYENDSESSION) { @@ -210,7 +263,7 @@ } } else AddToMessageLog(TEXT("ttyConsoleCtrlWndProc SHUTDOWN")); - return(1); // Otherwise it cancels the shutdown. + return(1); /* Otherwise it cancels the shutdown. */ } } return (DefWindowProc(hwnd, msg, wParam, lParam)); @@ -310,24 +363,26 @@ 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: -// + +/* + * + * 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) @@ -352,8 +407,8 @@ ssStatus.dwCheckPoint = dwCheckPoint++; - // Report the status of the service to the service control manager. - // + /* Report the status of the service to the service control manager. */ + if (!(fResult = SetServiceStatus( sshStatusHandle, &ssStatus))) { AddToMessageLog(TEXT("SetServiceStatus")); } @@ -367,30 +422,32 @@ { if (isWindowsNT()) return(ReportStatusToSCMgr( - event, // service state - NO_ERROR, // exit code - 3000)); // wait hint + 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). -// +/* + * + * 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]; @@ -400,36 +457,34 @@ char *qptr; - /////////////////////////////////////////////////// - // - // Service initialization - // - ProcessInformation.hProcess = NULL; + /* Service initialization */ + ProcessInformation.hProcess = NULL; + + /* report the status to the service control manager. */ - // 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. - // + /* + * 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 + 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. - // + /* report the status to the service control manager. */ if (!ReportManager(SERVICE_START_PENDING)) goto cleanup; - // Read the registry and set environment. + /* Read the registry and set environment. */ if (OnServeSetEnv()) { AddToMessageLog(TEXT("ServiceStart: read environment failed")); goto cleanup; @@ -438,19 +493,19 @@ if (!ReportManager(SERVICE_START_PENDING)) goto cleanup; - // set the start path for jsvc.exe + /* 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. + /* Build the start jsvc command according to the registry information. */ strcpy(Data,qptr); BuildCommand(Data); AddToMessageLog(TEXT(Data)); - // create the jsvc process. + /* create the jsvc process. */ AddToMessageLog(TEXT("ServiceStart: start jsvc")); memset(&StartupInfo,'\0',sizeof(StartupInfo)); StartupInfo.cb = sizeof(STARTUPINFO); @@ -467,7 +522,7 @@ if (!ReportManager(SERVICE_START_PENDING)) goto cleanup; - // wait until the process is completly created. + /* 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")); @@ -475,31 +530,30 @@ } */ - // - // jsvc is now running. - // report the status to the service control manager. - // + /* + * 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. - // + /* 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. + qreturn = WaitForSingleObject(hServerStopEvent,60000); /* each minutes. */ - if (qreturn == WAIT_FAILED) break;// something have gone wrong. + if (qreturn == WAIT_FAILED) break;/* something have gone wrong. */ if (qreturn == WAIT_TIMEOUT) { - // timeout check the monitor. + /* timeout check the monitor. */ if (GetExitCodeProcess(ProcessInformation.hProcess, &qreturn)) { if (qreturn == STILL_ACTIVE) continue; } @@ -507,13 +561,14 @@ hMonitorProcess = NULL; CloseHandle(hServerStopEvent); CloseHandle(ProcessInformation.hProcess); - exit(0); // exit ungracefully so - // Service Control Manager - // will attempt a restart. - break; //failed. + exit(0); /* exit ungracefully so + * Service Control Manager + * will attempt a restart. */ + + break; /*failed. */ } - // stop the monitor by signal(event) + /* stop the monitor by signal(event) */ sprintf(Data,"ServiceStart: stopping jsvc: %d", ProcessInformation.dwProcessId); AddToMessageLog(Data); @@ -524,7 +579,7 @@ } WaitForMonitor(6); AddToMessageLog(TEXT("ServiceStart: jsvc stopped")); - break; // finished!!! + break; /* finished!!! */ } cleanup: @@ -538,46 +593,45 @@ } - -// -// 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: -// +/* + * + * 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. - // + /* 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. + /* 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. - // + /* Update the service status. */ case SERVICE_CONTROL_INTERROGATE: break; - // invalid control code - // + /* invalid control code */ default: break; @@ -586,44 +640,45 @@ 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. -// +/* + * + * 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); + + /* 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 - // + /* 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. - // + /* report the status to the service control manager. */ if (!ReportStatusToSCMgr(SERVICE_START_PENDING,NO_ERROR,3000)) { AddToMessageLog(TEXT("service_main:ReportStatusToSCMgr failed")); goto cleanup; @@ -633,9 +688,9 @@ ServiceStart( dwArgc, lpszArgv ); cleanup: - - // try to report the stopped status to the service control manager. - // + /* + * try to report the stopped status to the service control manager. + */ if (sshStatusHandle) (VOID)ReportStatusToSCMgr( SERVICE_STOPPED, @@ -646,24 +701,26 @@ 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. -// +/* + * + * 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 1.4 +89 -30 jakarta-commons-sandbox/daemon/src/native/nt/service/instmain.c Index: instmain.c =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/service/instmain.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- instmain.c 21 Mar 2002 23:17:25 -0000 1.3 +++ instmain.c 31 Oct 2002 11:32:04 -0000 1.4 @@ -1,8 +1,67 @@ +/* ========================================================================= * + * * + * The Apache Software License, Version 1.1 * + * * + * Copyright (c) 1999-2001 The Apache Software Foundation. * + * All rights reserved. * + * * + * ========================================================================= * + * * + * Redistribution and use in source and binary forms, with or without modi- * + * fication, are permitted provided that the following conditions are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice * + * notice, this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. The end-user documentation included with the redistribution, if any, * + * must include the following acknowlegement: * + * * + * "This product includes software developed by the Apache Software * + * Foundation <http://www.apache.org/>." * + * * + * Alternately, this acknowlegement may appear in the software itself, if * + * and wherever such third-party acknowlegements normally appear. * + * * + * 4. The names "The Jakarta Project", "WebApp", and "Apache Software * + * Foundation" must not be used to endorse or promote products derived * + * from this software without prior written permission. For written * + * permission, please contact <[EMAIL PROTECTED]>. * + * * + * 5. Products derived from this software may not be called "Apache" nor may * + * "Apache" appear in their names without prior written permission of the * + * Apache Software Foundation. * + * * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES * + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * + * THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY * + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * + * POSSIBILITY OF SUCH DAMAGE. * + * * + * ========================================================================= * + * * + * This software consists of voluntary contributions made by many indivi- * + * duals on behalf of the Apache Software Foundation. For more information * + * on the Apache Software Foundation, please see <http://www.apache.org/>. * + * * + * ========================================================================= */ + +/* @version $Id$ */ + /* * jsvc.exe install program, create the service JavaService */ -// includes +/* includes */ #include <windows.h> #include <string.h> #include <stdio.h> @@ -78,41 +137,41 @@ DWORD dwCount; removed = FALSE; - // open service control manager with full access right + /* open service control manager with full access right */ hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (NULL != hManager) { - // open existing service + /* open existing service */ hService = OpenService(hManager, SZSERVICENAME, SERVICE_ALL_ACCESS); if (NULL != hService) { - // get the status of the service + /* get the status of the service */ if (QueryServiceStatus(hService, &svcStatus)) { - // and see if the service is stopped + /* and see if the service is stopped */ if (SERVICE_STOPPED != svcStatus.dwCurrentState) { - // if not stop the service + /* if not stop the service */ ControlService(hService, SERVICE_CONTROL_STOP, &svcStatus); } dwCount = 0; do { if (SERVICE_STOPPED == svcStatus.dwCurrentState) { - // delete the service + /* delete the service */ if (DeleteService(hService)) { removed = TRUE; break; } } - // wait 10 seconds for the service to stop + /* wait 10 seconds for the service to stop */ Sleep(10000); if (!QueryServiceStatus(hService, &svcStatus)) { - // something went wrong + /* something went wrong */ break; } dwCount++; } while (10 > dwCount); } - // close service handle + /* close service handle */ CloseServiceHandle(hService); } - // close service control manager + /* close service control manager */ CloseServiceHandle(hManager); } return removed; @@ -161,25 +220,25 @@ SC_HANDLE hService; installed = FALSE; - // open the service control manager with full access right + /* open the service control manager with full access right */ hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (NULL != hManager) { - // create the service + /* create the service hService = CreateService(hManager, - SZSERVICENAME, // name of the service - SZSERVICEDISPLAYNAME, // description + SZSERVICENAME, /* name of the service */ + SZSERVICEDISPLAYNAME, /* description */ SERVICE_ALL_ACCESS, - SERVICE_WIN32_OWN_PROCESS, // type of service - SERVICE_DEMAND_START, // AUTO_START, // startmode - SERVICE_ERROR_NORMAL, // error treatment - svcExePath, // path_name - NULL, // no load order enty - NULL, // no tag identifier. - NULL, // dependencies. - NULL, // LocalSystem account - NULL); // dummy user password + SERVICE_WIN32_OWN_PROCESS, /* type of service */ + SERVICE_DEMAND_START, /* AUTO_START, startmode */ + SERVICE_ERROR_NORMAL, /* error treatment */ + svcExePath, /* path_name */ + NULL, /* no load order enty */ + NULL, /* no tag identifier. */ + NULL, /* dependencies. */ + NULL, /* LocalSystem account */ + NULL); /* dummy user password */ if (NULL != hService) { - // close service handle + /* close service handle */ CloseServiceHandle(hService); installed = TRUE; } @@ -252,12 +311,12 @@ HKEY hKey; installed = FALSE; - // create the parameters registry tree + /* create the parameters registry tree */ log_debug("InstallEnv: %s:%s",var,value); if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_LOCAL_MACHINE, SZKEY_ONSERVE, 0, NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL, &hKey, NULL)) { - // key is created or opened + /* key is created or opened */ RegSetValueEx(hKey,var,0,REG_SZ,(BYTE *)value,lstrlen(value)+1); RegCloseKey(hKey); installed = TRUE; @@ -278,12 +337,12 @@ log_debug("InstallEnvParm: %s:%s",var,value); installed = FALSE; - // create the parameters registry tree + /* create the parameters registry tree */ if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_LOCAL_MACHINE, SZKEY_ONSERVEARG, 0, NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL, &hKey, NULL)) { - // key is created or opened + /* key is created or opened */ RegSetValueEx(hKey,var,0,REG_SZ, (BYTE *)value,lstrlen(value)+1); RegCloseKey(hKey); @@ -399,7 +458,7 @@ } if (args->remove==true) { - // remove the service. removing the keys not yet done!!! + /* remove the service. removing the keys not yet done!!! */ printf( "\r\n - removing Java Service...\r\n\r\n"); if (isWindowsNT()) done = RemoveSvcNT(); 1.2 +61 -2 jakarta-commons-sandbox/daemon/src/native/nt/signals/kills.c Index: kills.c =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/signals/kills.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- kills.c 18 Feb 2002 21:15:40 -0000 1.1 +++ kills.c 31 Oct 2002 11:32:04 -0000 1.2 @@ -1,5 +1,64 @@ +/* ========================================================================= * + * * + * The Apache Software License, Version 1.1 * + * * + * Copyright (c) 1999-2001 The Apache Software Foundation. * + * All rights reserved. * + * * + * ========================================================================= * + * * + * Redistribution and use in source and binary forms, with or without modi- * + * fication, are permitted provided that the following conditions are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice * + * notice, this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. The end-user documentation included with the redistribution, if any, * + * must include the following acknowlegement: * + * * + * "This product includes software developed by the Apache Software * + * Foundation <http://www.apache.org/>." * + * * + * Alternately, this acknowlegement may appear in the software itself, if * + * and wherever such third-party acknowlegements normally appear. * + * * + * 4. The names "The Jakarta Project", "WebApp", and "Apache Software * + * Foundation" must not be used to endorse or promote products derived * + * from this software without prior written permission. For written * + * permission, please contact <[EMAIL PROTECTED]>. * + * * + * 5. Products derived from this software may not be called "Apache" nor may * + * "Apache" appear in their names without prior written permission of the * + * Apache Software Foundation. * + * * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES * + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * + * THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY * + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * + * POSSIBILITY OF SUCH DAMAGE. * + * * + * ========================================================================= * + * * + * This software consists of voluntary contributions made by many indivi- * + * duals on behalf of the Apache Software Foundation. For more information * + * on the Apache Software Foundation, please see <http://www.apache.org/>. * + * * + * ========================================================================= */ + +/* @version $Id$ */ + /* - * as Windows does not support signal, OnServe use event to emulate them. + * as Windows does not support signal, jsvc uses events to emulate them. * The supported signal is SIGTERM. * signals.c contains the signal handler logic. */ @@ -19,7 +78,7 @@ sprintf(Name,"TERM%ld",pid); hevint = OpenEvent(EVENT_MODIFY_STATE,FALSE,Name); - if (hevint == NULL) return(-1); // failed + if (hevint == NULL) return(-1); /* failed */ rc = SetEvent(hevint); CloseHandle(hevint); 1.3 +84 -34 jakarta-commons-sandbox/daemon/src/native/nt/supcalls_nt/vdenv.c Index: vdenv.c =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/supcalls_nt/vdenv.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- vdenv.c 20 Mar 2002 23:39:32 -0000 1.2 +++ vdenv.c 31 Oct 2002 11:32:04 -0000 1.3 @@ -1,16 +1,66 @@ -#ident "%W% %E% ONSERVE V3.0" +/* ========================================================================= * + * * + * The Apache Software License, Version 1.1 * + * * + * Copyright (c) 1999-2001 The Apache Software Foundation. * + * All rights reserved. * + * * + * ========================================================================= * + * * + * Redistribution and use in source and binary forms, with or without modi- * + * fication, are permitted provided that the following conditions are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice * + * notice, this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. The end-user documentation included with the redistribution, if any, * + * must include the following acknowlegement: * + * * + * "This product includes software developed by the Apache Software * + * Foundation <http://www.apache.org/>." * + * * + * Alternately, this acknowlegement may appear in the software itself, if * + * and wherever such third-party acknowlegements normally appear. * + * * + * 4. The names "The Jakarta Project", "WebApp", and "Apache Software * + * Foundation" must not be used to endorse or promote products derived * + * from this software without prior written permission. For written * + * permission, please contact <[EMAIL PROTECTED]>. * + * * + * 5. Products derived from this software may not be called "Apache" nor may * + * "Apache" appear in their names without prior written permission of the * + * Apache Software Foundation. * + * * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES * + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * + * THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY * + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * + * POSSIBILITY OF SUCH DAMAGE. * + * * + * ========================================================================= * + * * + * This software consists of voluntary contributions made by many indivi- * + * duals on behalf of the Apache Software Foundation. For more information * + * on the Apache Software Foundation, please see <http://www.apache.org/>. * + * * + * ========================================================================= */ -/* ------------------------------------------------------------ * - * file: vdenv.c - * authors: OEC BS DC22, Barcelona - * date: January 1998 - * compiler: ANSI C - * desc: Read the Win-NT register and set the OnServe environment - * variable. Set the PATH (for dynamic linking!). - * note: - * bugs: 0 - * ------------------------------------------------------------ */ +/* @version $Id$ */ +/* Read the Win-NT register and set the jsvc environment variable. */ +/* XXX We should use a property file instead registry */ + +/* XXX Set the PATH (for dynamic linking!) what about libapr*.so? */ #include <windows.h> #include "moni_inst.h" @@ -27,37 +77,37 @@ if (putenv(Variable)) return(-1); return(0); } -// -// FUNCTION: OnServeSetEnv() -// -// PURPOSE: Actual code of the routine that reads the registry and -// set the OnServe environment variables. -// The PATH is needed for the dynamic linking. -// -// RETURN VALUE: -// 0 : All OK. -// <0: Something Failed. (Registry cannot be read or one key cannot be read). -// -// +/* + * FUNCTION: OnServeSetEnv() + * + * PURPOSE: Actual code of the routine that reads the registry and + * set the OnServe environment variables. + * The PATH is needed for the dynamic linking. + * + * RETURN VALUE: + * 0 : All OK. + * <0: Something Failed. (Registry cannot be read or one key cannot be read). + * +*/ int OnServeSetEnv () { HKEY hKey=NULL; DWORD Type; -char jakarta_home[ENVSIZE]; // for the path -char cygwin[ENVSIZE]; // for the path +char jakarta_home[ENVSIZE]; /* for the path */ +char cygwin[ENVSIZE]; /* for the path */ char Data[ENVSIZE]; DWORD LData; int qreturn=0; - // Read the registry and set environment. + /* Read the registry and set environment. */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SZKEY_ONSERVE, 0, KEY_READ,&hKey) != ERROR_SUCCESS) return(-1); - // read key and set environment. + /* read key and set environment. */ - // JAKARTA_HOME + /* JAKARTA_HOME */ LData = sizeof(Data); if (RegQueryValueEx(hKey,"JAKARTA_HOME",NULL,&Type,Data,&LData)==ERROR_SUCCESS) { strcpy(jakarta_home,Data); @@ -66,7 +116,7 @@ else qreturn = -2; - // CYGWIN + /* CYGWIN */ LData = sizeof(Data); if (RegQueryValueEx(hKey,"CYGWIN",NULL,&Type,Data,&LData)==ERROR_SUCCESS) { strcpy(cygwin,Data); @@ -75,7 +125,7 @@ else qreturn = -3; - // JAVA_HOME + /* JAVA_HOME */ LData = sizeof(Data); if (RegQueryValueEx(hKey,"JAVA_HOME",NULL,&Type,Data,&LData) ==ERROR_SUCCESS) { @@ -87,7 +137,7 @@ RegCloseKey(hKey); hKey = NULL; - // set the PATH otherwise nothing works!!! + /* set the PATH otherwise nothing works!!! */ LData = sizeof(Data); if (!GetEnvironmentVariable("PATH",Data,LData)) { strcpy(Data,jakarta_home); @@ -126,7 +176,7 @@ strcat(data,"\\jsvc.exe -nodetach "); - // Read the registry and set environment. + /* Read the registry and set environment. */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SZKEY_ONSERVEARG, 0, KEY_READ,&hKey) != ERROR_SUCCESS) return(-1); @@ -134,7 +184,7 @@ &nvalue,NULL, NULL, NULL, NULL) != ERROR_SUCCESS) return(-2); - // Read the arguments + /* Read the arguments */ for (i=0;i<nvalue;i++) { lname = sizeof(name); lvalue = sizeof(value); @@ -151,7 +201,7 @@ } RegCloseKey(hKey); - // Read the start class. + /* Read the start class. */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SZKEY_ONSERVE, 0, KEY_READ,&hKey) != ERROR_SUCCESS) return(-4); 1.2 +71 -12 jakarta-commons-sandbox/daemon/src/native/unix/native/signals.c Index: signals.c =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/unix/native/signals.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- signals.c 18 Feb 2002 21:15:42 -0000 1.1 +++ signals.c 31 Oct 2002 11:32:04 -0000 1.2 @@ -1,12 +1,71 @@ +/* ========================================================================= * + * * + * The Apache Software License, Version 1.1 * + * * + * Copyright (c) 1999-2001 The Apache Software Foundation. * + * All rights reserved. * + * * + * ========================================================================= * + * * + * Redistribution and use in source and binary forms, with or without modi- * + * fication, are permitted provided that the following conditions are met: * + * * + * 1. Redistributions of source code must retain the above copyright notice * + * notice, this list of conditions and the following disclaimer. * + * * + * 2. Redistributions in binary form must reproduce the above copyright * + * notice, this list of conditions and the following disclaimer in the * + * documentation and/or other materials provided with the distribution. * + * * + * 3. The end-user documentation included with the redistribution, if any, * + * must include the following acknowlegement: * + * * + * "This product includes software developed by the Apache Software * + * Foundation <http://www.apache.org/>." * + * * + * Alternately, this acknowlegement may appear in the software itself, if * + * and wherever such third-party acknowlegements normally appear. * + * * + * 4. The names "The Jakarta Project", "WebApp", and "Apache Software * + * Foundation" must not be used to endorse or promote products derived * + * from this software without prior written permission. For written * + * permission, please contact <[EMAIL PROTECTED]>. * + * * + * 5. Products derived from this software may not be called "Apache" nor may * + * "Apache" appear in their names without prior written permission of the * + * Apache Software Foundation. * + * * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES * + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * + * THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY * + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * + * POSSIBILITY OF SUCH DAMAGE. * + * * + * ========================================================================= * + * * + * This software consists of voluntary contributions made by many indivi- * + * duals on behalf of the Apache Software Foundation. For more information * + * on the Apache Software Foundation, please see <http://www.apache.org/>. * + * * + * ========================================================================= */ + +/* @version $Id$ */ + /* - * as Windows does not support signal, OnServe use event to emulate them. + * as Windows does not support signal, jsvc use event to emulate them. * The supported signal is SIGTERM. * The kills.c contains the kill logic. */ #ifdef OS_CYGWIN #include <windows.h> #include <stdio.h> -static void (*HandleTerm)()=NULL; // address of the handler routine. +static void (*HandleTerm)()=NULL; /* address of the handler routine. */ /* * Event handling routine @@ -19,11 +78,11 @@ for (;;) { if (WaitForSingleObject(hevint,INFINITE) == WAIT_FAILED) { - // something have gone wrong. - return; // may be something more is needed. + /* something have gone wrong. */ + return; /* may be something more is needed. */ } - // call the interrupt handler. + /* call the interrupt handler. */ if (HandleTerm==NULL) return; HandleTerm(); } @@ -49,10 +108,10 @@ * the start state is resetted. */ - // Initialize the new security descriptor. + /* Initialize the new security descriptor. */ InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION); - // Add a NULL descriptor ACL to the security descriptor. + /* Add a NULL descriptor ACL to the security descriptor. */ SetSecurityDescriptorDacl (&sd, TRUE, (PACL)NULL, FALSE); sa.nLength = sizeof(sa); @@ -60,23 +119,23 @@ sa.bInheritHandle = TRUE; - // It works also with NULL instead &sa!! + /* It works also with NULL instead &sa!! */ hevint = CreateEvent(&sa,FALSE, FALSE,Name); HandleTerm = (int (*)()) func; - if (hevint == NULL) return(-1); // failed + if (hevint == NULL) return(-1); /* failed */ /* create the thread to wait for event */ hthread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE) v_difthf, (LPVOID) hevint, 0, &ThreadId); if (hthread == NULL) { - // failed remove the event - CloseHandle(hevint); // windows will remove it. + /* failed remove the event */ + CloseHandle(hevint); /* windows will remove it. */ return(-1); } - CloseHandle(hthread); // not needed + CloseHandle(hthread); /* not needed */ return(0); } #endif
-- To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>