You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2010/07/30 08:50:16 UTC
svn commit: r980662 [10/15] - in
/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3: ./ src/ src/assembly/
src/docs/ src/java/ src/java/org/ src/java/org/apache/
src/java/org/apache/commons/ src/java/org/apache/commons/daemon/
src/java/org/apache/com...
Added: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/src/service.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/src/service.c?rev=980662&view=auto
==============================================================================
--- commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/src/service.c (added)
+++ commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/src/service.c Fri Jul 30 06:50:12 2010
@@ -0,0 +1,669 @@
+/* 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 "apxwin.h"
+#include "private.h"
+
+#define SAFE_CLOSE_SCH(h) \
+ if ((h) != NULL && (h) != INVALID_HANDLE_VALUE) { \
+ CloseServiceHandle((h)); \
+ (h) = NULL; \
+ }
+
+#define CHANGE_SERVICE(h, b, u, p, d) \
+ ChangeServiceConfigW(h, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, \
+ SERVICE_NO_CHANGE,b,NULL,NULL,NULL, \
+ u,p,d)
+
+typedef struct APXSERVICE {
+ /* Are we a service manager or we are the service itself */
+ BOOL bManagerMode;
+ /* Handle to the current service */
+ SC_HANDLE hService;
+ /* Handle of the Service manager */
+ SC_HANDLE hManager;
+ APXSERVENTRY stServiceEntry;
+
+} APXSERVICE, *LPAPXSERVICE;
+
+static BOOL __apxIsValidServiceName(LPCWSTR szServiceName)
+{
+ do {
+ if (!IsCharAlphaNumericW(*szServiceName)) {
+ apxDisplayError(FALSE, NULL, 0, "NonAlpha %d", *szServiceName);
+ return FALSE;
+ }
+ } while( *(++szServiceName));
+ return TRUE;
+}
+
+static BOOL __apxServiceCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ LPAPXSERVICE lpService;
+
+ lpService = APXHANDLE_DATA(hObject);
+ switch (uMsg) {
+ case WM_CLOSE:
+ apxFree(lpService->stServiceEntry.lpConfig);
+ lpService->stServiceEntry.lpConfig = NULL;
+ SAFE_CLOSE_SCH(lpService->hService);
+ SAFE_CLOSE_SCH(lpService->hManager);
+ break;
+ default:
+ break;
+ }
+ return TRUE;
+}
+
+APXHANDLE
+apxCreateService(APXHANDLE hPool, DWORD dwOptions, BOOL bManagerMode)
+{
+ APXHANDLE hService;
+ LPAPXSERVICE lpService;
+ SC_HANDLE hManager;
+
+ if (!(hManager = OpenSCManager(NULL, NULL, dwOptions))) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return NULL;
+ }
+ hService = apxHandleCreate(hPool, 0,
+ NULL, sizeof(APXSERVICE),
+ __apxServiceCallback);
+ if (IS_INVALID_HANDLE(hService)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Failed to Create Handle for Service");
+ return NULL;
+ }
+ hService->dwType = APXHANDLE_TYPE_SERVICE;
+ lpService = APXHANDLE_DATA(hService);
+ lpService->hManager = hManager;
+ lpService->bManagerMode = bManagerMode;
+
+ return hService;
+}
+
+BOOL
+apxServiceOpen(APXHANDLE hService, LPCWSTR szServiceName, DWORD dwOptions)
+{
+ LPAPXSERVICE lpService;
+ DWORD dwNeeded;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return FALSE;
+
+ /* Close any previous instance
+ * Same handle can manage multiple services
+ */
+ SAFE_CLOSE_SCH(lpService->hService);
+ *lpService->stServiceEntry.szServiceDescription = L'\0';
+ *lpService->stServiceEntry.szObjectName = L'\0';
+ apxFree(lpService->stServiceEntry.lpConfig);
+ lpService->stServiceEntry.lpConfig = NULL;
+ /* Open the service */
+ lpService->hService = OpenServiceW(lpService->hManager,
+ szServiceName,
+ dwOptions);
+
+ if (IS_INVALID_HANDLE(lpService->hService)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return FALSE;
+ }
+ lstrlcpyW(lpService->stServiceEntry.szServiceName, SIZ_RESLEN, szServiceName);
+ if (!apxGetServiceDescriptionW(szServiceName,
+ lpService->stServiceEntry.szServiceDescription,
+ SIZ_DESLEN)) {
+ apxLogWrite(APXLOG_MARK_WARN "Failed to obtain service description");
+ lpService->stServiceEntry.szServiceDescription[0] = L'\0';
+ }
+ if (!apxGetServiceUserW(szServiceName,
+ lpService->stServiceEntry.szObjectName,
+ SIZ_RESLEN)) {
+ apxLogWrite(APXLOG_MARK_WARN "Failed to obtain service user name");
+ lpService->stServiceEntry.szObjectName[0] = L'\0';
+ }
+ if (!QueryServiceConfigW(lpService->hService, NULL, 0, &dwNeeded)) {
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ }
+ /* TODO: Check GetLastError ERROR_INSUFFICIENT_BUFFER */
+ lpService->stServiceEntry.lpConfig = (LPQUERY_SERVICE_CONFIGW)apxPoolAlloc(hService->hPool,
+ dwNeeded);
+ return QueryServiceConfigW(lpService->hService,
+ lpService->stServiceEntry.lpConfig,
+ dwNeeded, &dwNeeded);
+}
+
+LPAPXSERVENTRY
+apxServiceEntry(APXHANDLE hService, BOOL bRequeryStatus)
+{
+ LPAPXSERVICE lpService;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return NULL;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return NULL;
+
+ if (bRequeryStatus && !QueryServiceStatus(lpService->hService,
+ &(lpService->stServiceEntry.stServiceStatus))) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return NULL;
+ }
+
+ return &lpService->stServiceEntry;
+}
+
+/* Set the service names etc...
+ * If the ImagePath contains a space, it must be quoted
+ */
+BOOL
+apxServiceSetNames(APXHANDLE hService,
+ LPCWSTR szImagePath,
+ LPCWSTR szDisplayName,
+ LPCWSTR szDescription,
+ LPCWSTR szUsername,
+ LPCWSTR szPassword)
+{
+ LPAPXSERVICE lpService;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return FALSE;
+ /* Check if the ServiceOpen has been called */
+ if (IS_INVALID_HANDLE(lpService->hService))
+ return FALSE;
+ if (!CHANGE_SERVICE(lpService->hService,
+ szImagePath,
+ szUsername,
+ szPassword,
+ szDisplayName)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return FALSE;
+ }
+ if (szDescription) {
+ return apxSetServiceDescriptionW(lpService->stServiceEntry.szServiceName,
+ szDescription);
+ }
+ return TRUE;
+}
+
+BOOL
+apxServiceSetOptions(APXHANDLE hService,
+ DWORD dwServiceType,
+ DWORD dwStartType,
+ DWORD dwErrorControl)
+{
+ LPAPXSERVICE lpService;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return FALSE;
+ /* Check if the ServixeOpen has been called */
+ if (IS_INVALID_HANDLE(lpService->hService))
+ return FALSE;
+ return ChangeServiceConfig(lpService->hService, dwServiceType,
+ dwStartType, dwErrorControl,
+ NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL);
+}
+
+static BOOL
+__apxStopDependentServices(LPAPXSERVICE lpService)
+{
+ DWORD i;
+ DWORD dwBytesNeeded;
+ DWORD dwCount;
+
+ LPENUM_SERVICE_STATUS lpDependencies = NULL;
+ ENUM_SERVICE_STATUS ess;
+ SC_HANDLE hDepService;
+ SERVICE_STATUS_PROCESS ssp;
+
+ DWORD dwStartTime = GetTickCount();
+ /* Use the 30-second time-out */
+ DWORD dwTimeout = 30000;
+
+ /* Pass a zero-length buffer to get the required buffer size.
+ */
+ if (EnumDependentServices(lpService->hService,
+ SERVICE_ACTIVE,
+ lpDependencies, 0,
+ &dwBytesNeeded,
+ &dwCount)) {
+ /* If the Enum call succeeds, then there are no dependent
+ * services, so do nothing.
+ */
+ return TRUE;
+ }
+ else {
+ if (GetLastError() != ERROR_MORE_DATA)
+ return FALSE; // Unexpected error
+
+ /* Allocate a buffer for the dependencies.
+ */
+ lpDependencies = (LPENUM_SERVICE_STATUS) HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ dwBytesNeeded);
+ if (!lpDependencies)
+ return FALSE;
+
+ __try {
+ /* Enumerate the dependencies. */
+ if (!EnumDependentServices(lpService->hService,
+ SERVICE_ACTIVE,
+ lpDependencies,
+ dwBytesNeeded,
+ &dwBytesNeeded,
+ &dwCount))
+ return FALSE;
+
+ for (i = 0; i < dwCount; i++) {
+ ess = *(lpDependencies + i);
+ /* Open the service. */
+ hDepService = OpenService(lpService->hManager,
+ ess.lpServiceName,
+ SERVICE_STOP | SERVICE_QUERY_STATUS);
+
+ if (!hDepService)
+ return FALSE;
+
+ __try {
+ /* Send a stop code. */
+ if (!ControlService(hDepService,
+ SERVICE_CONTROL_STOP,
+ (LPSERVICE_STATUS) &ssp))
+ return FALSE;
+
+ /* Wait for the service to stop. */
+ while (ssp.dwCurrentState != SERVICE_STOPPED) {
+ Sleep(ssp.dwWaitHint);
+ if (!QueryServiceStatusEx(hDepService,
+ SC_STATUS_PROCESS_INFO,
+ (LPBYTE)&ssp,
+ sizeof(SERVICE_STATUS_PROCESS),
+ &dwBytesNeeded))
+ return FALSE;
+
+ if (ssp.dwCurrentState == SERVICE_STOPPED)
+ break;
+
+ if (GetTickCount() - dwStartTime > dwTimeout)
+ return FALSE;
+ }
+ }
+ __finally {
+ /* Always release the service handle. */
+ CloseServiceHandle(hDepService);
+ }
+ }
+ }
+ __finally {
+ /* Always free the enumeration buffer. */
+ HeapFree(GetProcessHeap(), 0, lpDependencies);
+ }
+ }
+ return TRUE;
+}
+
+BOOL
+apxServiceControl(APXHANDLE hService, DWORD dwControl, UINT uMsg,
+ LPAPXFNCALLBACK fnControlCallback,
+ LPVOID lpCbData)
+{
+ LPAPXSERVICE lpService;
+ SERVICE_STATUS stStatus;
+ DWORD dwPending = 0;
+ DWORD dwState = 0;
+ DWORD dwTick = 0;
+ DWORD dwWait, dwCheck, dwStart;
+ BOOL bStatus;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return FALSE;
+ /* Check if the ServiceOpen has been called */
+ if (IS_INVALID_HANDLE(lpService->hService))
+ return FALSE;
+ switch (dwControl) {
+ case SERVICE_CONTROL_CONTINUE:
+ dwPending = SERVICE_START_PENDING;
+ dwState = SERVICE_RUNNING;
+ break;
+ case SERVICE_CONTROL_STOP:
+ dwPending = SERVICE_STOP_PENDING;
+ dwState = SERVICE_STOPPED;
+ break;
+ case SERVICE_CONTROL_PAUSE:
+ dwPending = SERVICE_PAUSE_PENDING;
+ dwState = SERVICE_PAUSED;
+ break;
+ default:
+ break;
+ }
+ /* user defined controls */
+ if (dwControl > 127 && dwControl < 224) {
+ /* 128 ... 159 start signals
+ * 160 ... 191 stop signals
+ * 192 ... 223 pause signals
+ */
+ switch (dwControl & 0xE0) {
+ case 0x80:
+ case 0x90:
+ dwPending = SERVICE_START_PENDING;
+ dwState = SERVICE_RUNNING;
+ break;
+ case 0xA0:
+ case 0xB0:
+ dwPending = SERVICE_STOP_PENDING;
+ dwState = SERVICE_STOPPED;
+ break;
+ case 0xC0:
+ case 0xD0:
+ dwPending = SERVICE_PAUSE_PENDING;
+ dwState = SERVICE_PAUSED;
+ break;
+ default:
+ break;
+ }
+ }
+ if (!dwPending && !dwState)
+ return FALSE;
+ /* Now lets control */
+ if (!QueryServiceStatus(lpService->hService, &stStatus)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return FALSE;
+ }
+ /* signal that we are about to control the service */
+ if (fnControlCallback)
+ (*fnControlCallback)(lpCbData, uMsg, (WPARAM)1, (LPARAM)dwState);
+ if (dwControl == SERVICE_CONTROL_CONTINUE &&
+ stStatus.dwCurrentState != SERVICE_PAUSED)
+ bStatus = StartService(lpService->hService, 0, NULL);
+ else {
+ bStatus = TRUE;
+ if (dwControl == SERVICE_CONTROL_STOP) {
+ /* First stop dependent services
+ */
+ bStatus = __apxStopDependentServices(lpService);
+ }
+ if (bStatus)
+ bStatus = ControlService(lpService->hService, dwControl, &stStatus);
+ }
+ dwStart = GetTickCount();
+ dwCheck = stStatus.dwCheckPoint;
+ if (bStatus) {
+ Sleep(100); /* Initial Sleep period */
+ while (QueryServiceStatus(lpService->hService, &stStatus)) {
+ if (stStatus.dwCurrentState == dwPending) {
+ /* Do not wait longer than the wait hint. A good interval is
+ * one tenth the wait hint, but no less than 1 second and no
+ * more than 10 seconds.
+ */
+ dwWait = stStatus.dwWaitHint / 10;
+
+ if( dwWait < 1000 )
+ dwWait = 1000;
+ else if ( dwWait > 10000 )
+ dwWait = 10000;
+ /* Signal to the callback that we are pending
+ * break if callback returns false.
+ */
+ if (fnControlCallback) {
+ if (!(*fnControlCallback)(lpCbData, uMsg, (WPARAM)2,
+ (LPARAM)dwTick++))
+ break;
+ }
+ Sleep(dwWait);
+ if (stStatus.dwCheckPoint > dwCheck) {
+ /* The service is making progress. */
+ dwStart = GetTickCount();
+ dwCheck = stStatus.dwCheckPoint;
+ }
+ else {
+ if(GetTickCount() - dwStart > stStatus.dwWaitHint) {
+ /* No progress made within the wait hint */
+ break;
+ }
+ }
+ }
+ else
+ break;
+ }
+ }
+ /* signal that we are done with controling the service */
+ if (fnControlCallback)
+ (*fnControlCallback)(lpCbData, uMsg, (WPARAM)3, (LPARAM)0);
+ /* Check if we are in the desired state */
+ Sleep(1000);
+
+ if (QueryServiceStatus(lpService->hService, &stStatus)) {
+ if (fnControlCallback)
+ (*fnControlCallback)(lpCbData, uMsg, (WPARAM)4,
+ (LPARAM)&stStatus);
+ if (stStatus.dwCurrentState == dwState)
+ return TRUE;
+
+ }
+
+ return FALSE;
+}
+
+BOOL
+apxServiceInstall(APXHANDLE hService, LPCWSTR szServiceName,
+ LPCWSTR szDisplayName, LPCWSTR szImagePath,
+ LPCWSTR lpDependencies, DWORD dwServiceType,
+ DWORD dwStartType)
+{
+ LPAPXSERVICE lpService;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return FALSE;
+ if (IS_INVALID_HANDLE(lpService->hManager))
+ return FALSE;
+ if (!__apxIsValidServiceName(szServiceName))
+ return FALSE;
+ /* Close any previous instance
+ * Same handle can install multiple services
+ */
+ SAFE_CLOSE_SCH(lpService->hService);
+
+ apxFree(lpService->stServiceEntry.lpConfig);
+ lpService->stServiceEntry.lpConfig = NULL;
+ AplZeroMemory(&lpService->stServiceEntry, sizeof(APXSERVENTRY));
+
+ lpService->hService = CreateServiceW(lpService->hManager,
+ szServiceName,
+ szDisplayName,
+ SERVICE_ALL_ACCESS,
+ dwServiceType,
+ dwStartType,
+ SERVICE_ERROR_NORMAL,
+ szImagePath,
+ NULL,
+ NULL,
+ lpDependencies,
+ NULL,
+ NULL);
+
+ if (IS_INVALID_HANDLE(lpService->hService)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return FALSE;
+ }
+ else {
+ lstrlcpyW(lpService->stServiceEntry.szServiceName,
+ SIZ_RESLEN, szServiceName);
+ lpService->stServiceEntry.dwStart = dwStartType;
+ return TRUE;
+ }
+}
+
+BOOL
+apxServiceDelete(APXHANDLE hService)
+{
+ LPAPXSERVICE lpService;
+ SERVICE_STATUS stStatus;
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return FALSE;
+ /* Check if the ServiceOpen has been called */
+ if (IS_INVALID_HANDLE(lpService->hService))
+ return FALSE;
+ if (QueryServiceStatus(lpService->hService, &stStatus)) {
+ BOOL rv;
+ if (stStatus.dwCurrentState != SERVICE_STOPPED)
+ apxServiceControl(hService, SERVICE_CONTROL_STOP, 0, NULL, NULL);
+ rv = DeleteService(lpService->hService);
+ SAFE_CLOSE_SCH(lpService->hService);
+ SAFE_CLOSE_SCH(lpService->hManager);
+
+ return rv;
+ }
+ return FALSE;
+}
+
+/* Browse the services */
+DWORD
+apxServiceBrowse(APXHANDLE hService,
+ LPCWSTR szIncludeNamePattern,
+ LPCWSTR szIncludeImagePattern,
+ LPCWSTR szExcludeNamePattern,
+ LPCWSTR szExcludeImagePattern,
+ UINT uMsg,
+ LPAPXFNCALLBACK fnDisplayCallback,
+ LPVOID lpCbData)
+{
+ DWORD nFound = 0;
+ APXREGENUM stEnum;
+ LPAPXSERVICE lpService;
+ SC_LOCK hLock;
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE || !fnDisplayCallback)
+ return 0;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Only the manager mode can browse services */
+ if (!lpService->bManagerMode ||
+ IS_INVALID_HANDLE(lpService->hManager))
+ return 0;
+ hLock = LockServiceDatabase(lpService->hManager);
+ if (IS_INVALID_HANDLE(hLock)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+
+ return 0;
+ }
+ AplZeroMemory(&stEnum, sizeof(APXREGENUM));
+
+ while (TRUE) {
+ APXSERVENTRY stEntry;
+ BOOL rv;
+ AplZeroMemory(&stEntry, sizeof(APXSERVENTRY));
+ rv = apxRegistryEnumServices(&stEnum, &stEntry);
+
+ if (rv) {
+ INT fm = -1;
+ SC_HANDLE hSrv = NULL;
+ DWORD dwNeeded = 0;
+ hSrv = OpenServiceW(lpService->hManager,
+ stEntry.szServiceName,
+ GENERIC_READ);
+ if (!IS_INVALID_HANDLE(hSrv)) {
+ QueryServiceConfigW(hSrv, NULL, 0, &dwNeeded);
+ stEntry.lpConfig = (LPQUERY_SERVICE_CONFIGW)apxPoolAlloc(hService->hPool,
+ dwNeeded);
+ /* Call the QueryServiceConfig againg with allocated config */
+ if (QueryServiceConfigW(hSrv, stEntry.lpConfig, dwNeeded, &dwNeeded)) {
+ /* Make that customizable so that kernel mode drivers can be
+ * displayed and maintained. For now skip the
+ * filesystem and device drivers.
+ * XXX: Do we need that customizable after all?
+ */
+ if ((stEntry.lpConfig->dwServiceType &
+ ~SERVICE_INTERACTIVE_PROCESS) & SERVICE_WIN32)
+ fm = 0;
+
+ if (!fm && szIncludeNamePattern) {
+ fm = apxMultiStrMatchW(stEntry.szServiceName,
+ szIncludeNamePattern, L';', TRUE);
+ }
+ if (!fm && szExcludeNamePattern) {
+ fm = !apxMultiStrMatchW(stEntry.szServiceName,
+ szExcludeNamePattern, L';', TRUE);
+ }
+ if (!fm && szIncludeImagePattern) {
+ fm = apxMultiStrMatchW(stEntry.lpConfig->lpBinaryPathName,
+ szIncludeImagePattern, L';', TRUE);
+ }
+ if (!fm && szExcludeImagePattern) {
+ fm = !apxMultiStrMatchW(stEntry.szServiceName,
+ szExcludeImagePattern, L';', TRUE);
+ }
+ if (!fm) {
+ QueryServiceStatus(hSrv, &(stEntry.stServiceStatus));
+ /* WIN2K + extended service info */
+ if (_st_apx_oslevel >= 4) {
+ DWORD dwNeed;
+ QueryServiceStatusEx(hSrv, SC_STATUS_PROCESS_INFO,
+ (LPBYTE)(&(stEntry.stStatusProcess)),
+ sizeof(SERVICE_STATUS_PROCESS),
+ &dwNeed);
+ }
+ /* finaly call the provided callback */
+ rv = (*fnDisplayCallback)(lpCbData, uMsg,
+ (WPARAM)&stEntry,
+ (LPARAM)nFound++);
+ }
+ }
+ /* release the skipped service config */
+ if (fm) {
+ apxFree(stEntry.lpConfig);
+ }
+ }
+ SAFE_CLOSE_SCH(hSrv);
+ }
+ if (!rv)
+ break;
+ }
+
+ UnlockServiceDatabase(hLock);
+ return nFound;
+}
Propchange: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/src/service.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/src/utils.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/src/utils.c?rev=980662&view=auto
==============================================================================
--- commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/src/utils.c (added)
+++ commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/src/utils.c Fri Jul 30 06:50:12 2010
@@ -0,0 +1,1017 @@
+/* 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 "apxwin.h"
+#include "private.h"
+
+APX_OSLEVEL _st_apx_oslevel = APX_WINVER_UNK;
+
+/* Apache's APR stripped Os level detection */
+APX_OSLEVEL apxGetOsLevel()
+{
+ if (_st_apx_oslevel == APX_WINVER_UNK) {
+ static OSVERSIONINFO oslev;
+ oslev.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&oslev);
+
+ if (oslev.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+ if (oslev.dwMajorVersion < 4)
+ _st_apx_oslevel = APX_WINVER_UNSUP;
+ else if (oslev.dwMajorVersion == 4)
+ _st_apx_oslevel = APX_WINVER_NT_4;
+ else if (oslev.dwMajorVersion == 5) {
+ if (oslev.dwMinorVersion == 0)
+ _st_apx_oslevel = APX_WINVER_2000;
+ else
+ _st_apx_oslevel = APX_WINVER_XP;
+ }
+ else
+ _st_apx_oslevel = APX_WINVER_XP;
+ }
+#ifndef WINNT
+ else if (oslev.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+ if (oslev.dwMinorVersion < 10)
+ _st_apx_oslevel = APX_WINVER_95;
+ else if (oslev.dwMinorVersion < 90)
+ _st_apx_oslevel = APX_WINVER_98;
+ else
+ _st_apx_oslevel = APX_WINVER_ME;
+ }
+#endif
+#ifdef _WIN32_WCE
+ else if (oslev.dwPlatformId == VER_PLATFORM_WIN32_CE) {
+ if (oslev.dwMajorVersion < 3)
+ _st_apx_oslevel = APX_WINVER_UNSUP;
+ else
+ _st_apx_oslevel = APX_WINVER_CE_3;
+ }
+#endif
+ else
+ _st_apx_oslevel = APX_WINVER_UNSUP;
+ }
+
+ if (_st_apx_oslevel < APX_WINVER_UNSUP)
+ return APX_WINVER_UNK;
+ else
+ return _st_apx_oslevel;
+}
+
+LPWSTR __apxGetEnvironmentVariableW(APXHANDLE hPool, LPCWSTR wsName)
+{
+ LPWSTR wsRet;
+ DWORD rc;
+
+ rc = GetEnvironmentVariableW(wsName, NULL, 0);
+ if (rc == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
+ return NULL;
+
+ if (!(wsRet = apxPoolAlloc(hPool, (rc + 1) * sizeof(WCHAR))))
+ return NULL;
+ if (!GetEnvironmentVariableW(wsName, wsRet, rc)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ apxFree(wsRet);
+ return NULL;
+ }
+ return wsRet;
+}
+
+LPSTR __apxGetEnvironmentVariableA(APXHANDLE hPool, LPCSTR szName)
+{
+ LPSTR szRet;
+ DWORD rc;
+
+ rc = GetEnvironmentVariableA(szName, NULL, 0);
+ if (rc == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
+ return NULL;
+
+ if (!(szRet = apxPoolAlloc(hPool, rc + 1)))
+ return NULL;
+ if (!GetEnvironmentVariableA(szName, szRet, rc)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ apxFree(szRet);
+ return NULL;
+ }
+ return szRet;
+}
+
+
+LPWSTR AsciiToWide(LPCSTR s, LPWSTR ws)
+{
+ LPWSTR pszSave = ws;
+
+ if (!s) {
+ *ws = L'\0';
+ return pszSave;
+ }
+ do {
+ *ws++ = (WCHAR)*s;
+ } while (*s++);
+ return pszSave;
+}
+
+LPSTR WideToAscii(LPCWSTR ws, LPSTR s)
+{
+ LPSTR pszSave = s;
+
+ if (!ws) {
+ *s = '\0';
+ return pszSave;
+ }
+ do {
+ *s++ = (CHAR)*ws;
+ } while( *ws++);
+ return pszSave;
+}
+
+LPSTR WideToUTF8(LPCWSTR ws)
+{
+
+ LPSTR s;
+ int cch = WideCharToMultiByte(CP_UTF8, 0, ws, -1, NULL, 0, NULL, NULL);
+ s = (LPSTR)apxAlloc(cch);
+ if (!WideCharToMultiByte(CP_UTF8, 0, ws, -1, s, cch, NULL, NULL)) {
+ apxFree(s);
+ return NULL;
+ }
+ return s;
+}
+
+LPWSTR UTF8ToWide(LPCSTR cs)
+{
+
+ LPWSTR s;
+ int cch = MultiByteToWideChar(CP_UTF8, 0, cs, -1, NULL, 0);
+ s = (LPWSTR)apxAlloc(cch * sizeof(WCHAR));
+ if (!MultiByteToWideChar(CP_UTF8, 0, cs, -1, s, cch)) {
+ apxFree(s);
+ return NULL;
+ }
+ return s;
+}
+
+LPSTR MzWideToAscii(LPCWSTR ws, LPSTR s)
+{
+ LPSTR pszSave = s;
+
+ if (ws) {
+ do {
+ *s++ = (CHAR)*ws;
+ ws++;
+ } while( *ws || *(ws + 1));
+ }
+ /* double terminate */
+ *s++ = '\0';
+ *s = '\0';
+ return pszSave;
+}
+
+LPSTR MzWideToUTF8(LPCWSTR ws)
+{
+ LPSTR str;
+ LPSTR s;
+ LPCWSTR p = ws;
+ int cch = 0;
+
+ for ( ; p && *p; p++) {
+ int len = WideCharToMultiByte(CP_UTF8, 0, p, -1, NULL, 0, NULL, NULL);
+ if (len > 0)
+ cch += len;
+ while (*p)
+ p++;
+ }
+ cch ++;
+ str = s = (LPSTR)apxAlloc(cch + 1);
+
+ p = ws;
+ for ( ; p && *p; p++) {
+ int len = WideCharToMultiByte(CP_UTF8, 0, p, -1, s, cch, NULL, NULL);
+ if (len > 0) {
+ s = s + len;
+ cch -= len;
+ }
+ while (*p)
+ p++;
+ }
+ /* double terminate */
+ *s = '\0';
+ return str;
+}
+
+DWORD __apxGetMultiSzLengthA(LPCSTR lpStr, LPDWORD lpdwCount)
+{
+ LPCSTR p = lpStr;
+ if (lpdwCount)
+ *lpdwCount = 0;
+ for ( ; p && *p; p++) {
+ if (lpdwCount)
+ *lpdwCount += 1;
+ while (*p)
+ p++;
+ }
+ return (DWORD)(p - lpStr);
+}
+
+DWORD __apxGetMultiSzLengthW(LPCWSTR lpStr, LPDWORD lpdwCount)
+{
+ LPCWSTR p = lpStr;
+ if (lpdwCount)
+ *lpdwCount = 0;
+ for ( ; p && *p; p++) {
+ if (lpdwCount)
+ *lpdwCount += 1;
+ while (*p)
+ p++;
+ }
+ return (DWORD)((p - lpStr));
+}
+
+LPWSTR apxMultiSzCombine(APXHANDLE hPool, LPCWSTR lpStrA, LPCWSTR lpStrB,
+ LPDWORD lpdwLength)
+{
+ LPWSTR rv;
+ DWORD la = 0, lb = 0;
+ if (!lpStrA && !lpStrB)
+ return NULL; /* Nothing to do if both are NULL */
+
+ la = __apxGetMultiSzLengthW(lpStrA, NULL);
+ lb = __apxGetMultiSzLengthW(lpStrB, NULL);
+
+ rv = apxPoolCalloc(hPool, (la + lb + 1) * sizeof(WCHAR));
+ if (la) {
+ AplMoveMemory(rv, lpStrA, la * sizeof(WCHAR));
+ }
+ if (lb) {
+ AplMoveMemory(&rv[la], lpStrB, lb * sizeof(WCHAR));
+ }
+ if (*lpdwLength)
+ *lpdwLength = (la + lb + 1) * sizeof(WCHAR);
+ return rv;
+}
+
+BOOL
+apxSetEnvironmentVariable(APXHANDLE hPool, LPCTSTR szName, LPCTSTR szValue,
+ BOOL bAppend)
+{
+ LPTSTR szNew = (LPTSTR)szValue;
+
+ if (bAppend) {
+ DWORD l = GetEnvironmentVariable(szName, NULL, 0);
+ if (l > 0) {
+ BOOL rv;
+ if (IS_INVALID_HANDLE(hPool))
+ szNew = apxAlloc(l + lstrlen(szValue) + 3);
+ else
+ szNew = apxPoolAlloc(hPool, l + lstrlen(szValue) + 3);
+ GetEnvironmentVariable(szName, szNew, l + 1);
+ lstrcat(szNew, TEXT(";"));
+ lstrcat(szNew, szValue);
+ rv = SetEnvironmentVariable(szName, szNew);
+ apxFree(szNew);
+ return rv;
+ }
+ }
+ return SetEnvironmentVariable(szName, szNew);
+}
+
+
+/** Convert null separated double null terimated string to LPTSTR array)
+ * returns array size
+ */
+DWORD
+apxMultiSzToArrayW(APXHANDLE hPool, LPCWSTR lpString, LPWSTR **lppArray)
+{
+ DWORD i, n, l;
+ char *buff;
+ LPWSTR p;
+
+ l = __apxGetMultiSzLengthW(lpString, &n);
+ if (!n || !l)
+ return 0;
+ if (IS_INVALID_HANDLE(hPool))
+ buff = apxPoolAlloc(hPool, (n + 2) * sizeof(LPWSTR) + (l + 1) * sizeof(WCHAR));
+ else
+ buff = apxAlloc((n + 2) * sizeof(LPWSTR) + (l + 1) * sizeof(WCHAR));
+
+ *lppArray = (LPWSTR *)buff;
+ p = (LPWSTR)(buff + (n + 2) * sizeof(LPWSTR));
+ AplCopyMemory(p, lpString, (l + 1) * sizeof(WCHAR) + sizeof(WCHAR));
+ for (i = 0; i < n; i++) {
+ (*lppArray)[i] = p;
+ while (*p)
+ p++;
+ p++;
+ }
+ (*lppArray)[++i] = NULL;
+
+ return n;
+}
+
+DWORD
+apxMultiSzToArrayA(APXHANDLE hPool, LPCSTR lpString, LPSTR **lppArray)
+{
+ DWORD i, n, l;
+ char *buff;
+ LPSTR p;
+
+ l = __apxGetMultiSzLengthA(lpString, &n);
+ if (!n || !l)
+ return 0;
+ if (IS_INVALID_HANDLE(hPool))
+ buff = apxPoolAlloc(hPool, (n + 2) * sizeof(LPTSTR) + (l + 1));
+ else
+ buff = apxAlloc((n + 2) * sizeof(LPSTR) + (l + 1) * sizeof(CHAR));
+
+ *lppArray = (LPSTR *)buff;
+ p = (LPSTR)(buff + (n + 2) * sizeof(LPSTR));
+ AplCopyMemory(p, lpString, (l + 1) * sizeof(CHAR) + sizeof(CHAR));
+ for (i = 0; i < n; i++) {
+ (*lppArray)[i] = p;
+ while (*p)
+ p++;
+ p++;
+ }
+ (*lppArray)[++i] = NULL;
+
+ return n;
+}
+
+#define QSTR_BOUNDARY 127
+#define QSTR_ALIGN(size) \
+ (((size) + QSTR_BOUNDARY + sizeof(APXMULTISZ) + 2) & ~(QSTR_BOUNDARY))
+
+#define QSTR_SIZE(size) \
+ ((QSTR_ALIGN(size)) - sizeof(APXMULTISZ))
+
+#define QSTR_DATA(q) ((char *)(q) + sizeof(APXMULTISZ))
+
+#if 0
+LPAPXMULTISZ apxMultiSzStrdup(LPCTSTR szSrc)
+{
+ LPAPXMULTISZ q;
+
+ if (szSrc) {
+ DWORD l = lstrlen(szSrc);
+ q = (LPAPXMULTISZ)apxAlloc(QSTR_ALIGN(l));
+ q->dwAllocated = QSTR_SIZE(l);
+ q->dwInsert = l + 1;
+ AplMoveMemory(QSTR_DATA(q), szSrc, l);
+ RtlZeroMemory(QSTR_DATA(q) + l, q->dwAllocated - l);
+ }
+ else {
+ q = (LPAPXMULTISZ)apxCalloc(QSTR_ALIGN(0));
+ q->dwAllocated = QSTR_SIZE(0);
+ }
+
+ return q;
+}
+
+LPTSTR apxMultiSzStrcat(LPAPXMULTISZ lpmSz, LPCTSTR szSrc)
+{
+ DWORD l = lstrlen(szSrc);
+ LPTSTR p;
+
+ if (lpmSz->dwInsert + l + 2 > lpmSz->dwAllocated) {
+ if ((lpmSz = (LPAPXMULTISZ )apxRealloc(lpmSz, QSTR_ALIGN(lpmSz->dwInsert + l))) == NULL)
+ return NULL;
+
+ lpmSz->dwAllocated = QSTR_SIZE(lpmSz->dwInsert + l);
+ AplZeroMemory(QSTR_DATA(lpmSz) + lpmSz->dwInsert + l,
+ lpmSz->dwAllocated - (lpmSz->dwInsert + l));
+ }
+ p = (LPTSTR)QSTR_DATA(lpmSz) + lpmSz->dwInsert;
+ AplMoveMemory(p, szSrc, l);
+
+ lpmSz->dwInsert += (l + 1);
+ return p;
+}
+
+DWORD apxMultiSzLen(LPAPXMULTISZ lpmSz)
+{
+ if (lpmSz->dwInsert)
+ return lpmSz->dwInsert - 1;
+ else
+ return 0;
+}
+
+LPCTSTR apxMultiSzGet(LPAPXMULTISZ lpmSz)
+{
+ return (LPCTSTR)QSTR_DATA(lpmSz);
+}
+#endif
+
+LPTSTR apxStrCharRemove(LPTSTR szString, TCHAR chSkip)
+{
+ LPTSTR p = szString;
+ LPTSTR q = szString;
+ while (*p) {
+ if(*p != chSkip)
+ *q++ = *p;
+ ++p;
+ }
+ *q = TEXT('\0');
+
+ return szString;
+}
+
+DWORD apxStrCharRemoveA(LPSTR szString, CHAR chSkip)
+{
+ LPSTR p = szString;
+ LPSTR q = szString;
+ DWORD c = 0;
+ while (*p) {
+ if(*p != chSkip)
+ *q++ = *p;
+ else
+ ++c;
+ ++p;
+ }
+ *q = '\0';
+
+ return c;
+}
+
+DWORD apxStrCharRemoveW(LPWSTR szString, WCHAR chSkip)
+{
+ LPWSTR p = szString;
+ LPWSTR q = szString;
+ DWORD c = 0;
+ while (*p) {
+ if(*p != chSkip)
+ *q++ = *p;
+ else
+ ++c;
+ ++p;
+ }
+ *q = L'\0';
+
+ return c;
+}
+
+void
+apxStrCharReplaceA(LPSTR szString, CHAR chReplace, CHAR chReplaceWith)
+{
+ LPSTR p = szString;
+ LPSTR q = szString;
+ while (*p) {
+ if(*p == chReplace)
+ *q++ = chReplaceWith;
+ else
+ *q++ = *p;
+ ++p;
+ }
+ *q = '\0';
+}
+
+void
+apxStrCharReplaceW(LPWSTR szString, WCHAR chReplace, WCHAR chReplaceWith)
+{
+ LPWSTR p = szString;
+ LPWSTR q = szString;
+ while (*p) {
+ if(*p == chReplace)
+ *q++ = chReplaceWith;
+ else
+ *q++ = *p;
+ ++p;
+ }
+ *q = L'\0';
+}
+
+static const LPCTSTR _st_hex = TEXT("0123456789abcdef");
+#define XTOABUFFER_SIZE (sizeof(ULONG) * 2 + 2)
+#define UTOABUFFER_SIZE (sizeof(ULONG_PTR) * 2 + 2)
+#define LO_NIBLE(x) ((BYTE)((x) & 0x0000000F))
+
+BOOL apxUltohex(ULONG n, LPTSTR lpBuff, DWORD dwBuffLength)
+{
+ LPTSTR p;
+ DWORD i;
+ *lpBuff = 0;
+ if (dwBuffLength < XTOABUFFER_SIZE)
+ return FALSE;
+ p = lpBuff + XTOABUFFER_SIZE;
+ *p-- = 0;
+ for (i = 0; i < sizeof(ULONG) * 2; i++) {
+ *p-- = _st_hex[LO_NIBLE(n)];
+ n = n >> 4;
+ }
+ *p-- = TEXT('x');
+ *p = TEXT('0');
+ return TRUE;
+}
+
+BOOL apxUptohex(ULONG_PTR n, LPTSTR lpBuff, DWORD dwBuffLength)
+{
+ LPTSTR p;
+ DWORD i;
+ *lpBuff = 0;
+ if (dwBuffLength < UTOABUFFER_SIZE)
+ return FALSE;
+ p = lpBuff + UTOABUFFER_SIZE;
+ *p-- = 0;
+ for (i = 0; i < sizeof(ULONG_PTR) * 2; i++) {
+ *p-- = _st_hex[LO_NIBLE(n)];
+ n = n >> 4;
+ }
+ *p-- = TEXT('x');
+ *p = TEXT('0');
+ return TRUE;
+}
+
+ULONG apxStrToul(LPCTSTR szNum)
+{
+ ULONG rv = 0;
+ DWORD sh = 0;
+ LPCTSTR p = szNum;
+ ++p;
+ while (*p && (*p != TEXT('x')) && (*(p - 1) != TEXT('0')))
+ p++;
+ if (*p != 'x')
+ return 0;
+ /* go to the last digit */
+ while (*(p + 1)) p++;
+
+ /* go back to 'x' */
+ while (*p != TEXT('x')) {
+ ULONG v = 0;
+ switch (*p--) {
+ case TEXT('0'): v = 0UL; break;
+ case TEXT('1'): v = 1UL; break;
+ case TEXT('2'): v = 2UL; break;
+ case TEXT('3'): v = 3UL; break;
+ case TEXT('4'): v = 4UL; break;
+ case TEXT('5'): v = 5UL; break;
+ case TEXT('6'): v = 6UL; break;
+ case TEXT('7'): v = 7UL; break;
+ case TEXT('8'): v = 8UL; break;
+ case TEXT('9'): v = 9UL; break;
+ case TEXT('a'): case TEXT('A'): v = 10UL; break;
+ case TEXT('b'): case TEXT('B'): v = 11UL; break;
+ case TEXT('c'): case TEXT('C'): v = 12UL; break;
+ case TEXT('d'): case TEXT('D'): v = 13UL; break;
+ case TEXT('e'): case TEXT('E'): v = 14UL; break;
+ case TEXT('f'): case TEXT('F'): v = 15UL; break;
+ default:
+ return 0;
+ break;
+ }
+ rv |= rv + (v << sh);
+ sh += 4;
+ }
+ return rv;
+}
+
+ULONG apxStrToulW(LPCWSTR szNum)
+{
+ ULONG rv = 0;
+ DWORD sh = 0;
+ LPCWSTR p = szNum;
+ ++p;
+ while (*p && (*p != L'x') && (*(p - 1) != L'0'))
+ p++;
+ if (*p != L'x')
+ return 0;
+ /* go to the last digit */
+ while (*(p + 1)) p++;
+
+ /* go back to 'x' */
+ while (*p != L'x') {
+ ULONG v = 0;
+ switch (*p--) {
+ case L'0': v = 0UL; break;
+ case L'1': v = 1UL; break;
+ case L'2': v = 2UL; break;
+ case L'3': v = 3UL; break;
+ case L'4': v = 4UL; break;
+ case L'5': v = 5UL; break;
+ case L'6': v = 6UL; break;
+ case L'7': v = 7UL; break;
+ case L'8': v = 8UL; break;
+ case L'9': v = 9UL; break;
+ case L'a': case L'A': v = 10UL; break;
+ case L'b': case L'B': v = 11UL; break;
+ case L'c': case L'C': v = 12UL; break;
+ case L'd': case L'D': v = 13UL; break;
+ case L'e': case L'E': v = 14UL; break;
+ case L'f': case L'F': v = 15UL; break;
+ default:
+ return 0;
+ break;
+ }
+ rv |= rv + (v << sh);
+ sh += 4;
+ }
+ return rv;
+}
+
+ULONG apxAtoulW(LPCWSTR szNum)
+{
+ ULONG rv = 0;
+ DWORD sh = 1;
+ int s = 1;
+ LPCWSTR p = szNum;
+
+ /* go to the last digit */
+ if (!p || !*p)
+ return 0;
+ if (*p == L'-') {
+ s = -1;
+ ++p;
+ }
+ while (*(p + 1)) p++;
+
+ /* go back */
+ while (p >= szNum) {
+ ULONG v = 0;
+ switch (*p--) {
+ case L'0': v = 0UL; break;
+ case L'1': v = 1UL; break;
+ case L'2': v = 2UL; break;
+ case L'3': v = 3UL; break;
+ case L'4': v = 4UL; break;
+ case L'5': v = 5UL; break;
+ case L'6': v = 6UL; break;
+ case L'7': v = 7UL; break;
+ case L'8': v = 8UL; break;
+ case L'9': v = 9UL; break;
+ default:
+ return rv * s;
+ break;
+ }
+ rv = rv + (v * sh);
+ sh = sh * 10;
+ }
+ return rv * s;
+}
+
+/* Make the unique system resource name from prefix and process id
+ *
+ */
+BOOL
+apxMakeResourceName(LPCTSTR szPrefix, LPTSTR lpBuff, DWORD dwBuffLength)
+{
+ DWORD pl = lstrlen(szPrefix);
+ if (dwBuffLength < (pl + 11))
+ return FALSE;
+ lstrcpy(lpBuff, szPrefix);
+ return apxUltohex(GetCurrentProcessId(), lpBuff + pl, dwBuffLength - pl);
+}
+/** apxStrMatchA ANSI string pattern matching
+ * Match = 0, NoMatch = 1, Abort = -1
+ * Based loosely on sections of wildmat.c by Rich Salz
+ */
+INT apxStrMatchA(LPCSTR szString, LPCSTR szPattern, BOOL bIgnoreCase)
+{
+ int x, y;
+
+ for (x = 0, y = 0; szPattern[y]; ++y, ++x) {
+ if (!szPattern[x] && (szPattern[y] != '*' || szPattern[y] != '?'))
+ return -1;
+ if (szPattern[y] == '*') {
+ while (szPattern[++y] == '*');
+ if (!szPattern[y])
+ return 0;
+ while (szString[x]) {
+ INT rc;
+ if ((rc = apxStrMatchA(&szString[x++], &szPattern[y],
+ bIgnoreCase)) != 1)
+ return rc;
+ }
+ return -1;
+ }
+ else if (szPattern[y] != '?') {
+ if (bIgnoreCase) {
+ if (CharLowerA((LPSTR)((SIZE_T)szString[x])) !=
+ CharLowerA((LPSTR)((SIZE_T)szPattern[y])))
+ return 1;
+ }
+ else {
+ if (szString[x] != szPattern[y])
+ return 1;
+ }
+ }
+ }
+ return (szString[x] != '\0');
+}
+
+INT apxStrMatchW(LPCWSTR szString, LPCWSTR szPattern, BOOL bIgnoreCase)
+{
+ int x, y;
+
+ for (x = 0, y = 0; szPattern[y]; ++y, ++x) {
+ if (!szPattern[x] && (szPattern[y] != L'*' || szPattern[y] != L'?'))
+ return -1;
+ if (szPattern[y] == L'*') {
+ while (szPattern[++y] == L'*');
+ if (!szPattern[y])
+ return 0;
+ while (szString[x]) {
+ INT rc;
+ if ((rc = apxStrMatchW(&szString[x++], &szPattern[y],
+ bIgnoreCase)) != 1)
+ return rc;
+ }
+ return -1;
+ }
+ else if (szPattern[y] != L'?') {
+ if (bIgnoreCase) {
+ if (CharLowerW((LPWSTR)((SIZE_T)szString[x])) !=
+ CharLowerW((LPWSTR)((SIZE_T)szPattern[y])))
+ return 1;
+ }
+ else {
+ if (szString[x] != szPattern[y])
+ return 1;
+ }
+ }
+ }
+ return (szString[x] != L'\0');
+}
+
+INT apxMultiStrMatchW(LPCWSTR szString, LPCWSTR szPattern,
+ WCHAR chSeparator, BOOL bIgnoreCase)
+{
+ WCHAR szM[SIZ_HUGLEN];
+ DWORD i = 0;
+ LPCWSTR p = szPattern;
+ INT m = -1;
+
+ if (chSeparator == 0)
+ return apxStrMatchW(szString, szPattern, bIgnoreCase);
+ while (*p != L'\0') {
+ if (*p == chSeparator) {
+ m = apxStrMatchW(szString, szM, bIgnoreCase);
+ if (m == 0)
+ return 0;
+ p++;
+ i = 0;
+ szM[0] = L'\0';
+ }
+ else {
+ if (i < SIZ_HUGMAX)
+ szM[i++] = *p++;
+ else
+ return -1;
+ }
+ }
+ szM[i] = L'\0';
+ if (szM[0])
+ return apxStrMatchW(szString, szM, bIgnoreCase);
+ else
+ return m;
+}
+
+LPSTR apxArrayToMultiSzA(APXHANDLE hPool, DWORD nArgs, LPCSTR *lpArgs)
+{
+ DWORD i, l = 0;
+ LPSTR lpSz, p;
+ if (!nArgs)
+ return NULL;
+ for (i = 0; i < nArgs; i++)
+ l += lstrlenA(lpArgs[i]);
+ l += (nArgs + 2);
+
+ p = lpSz = (LPSTR)apxPoolAlloc(hPool, l);
+ for (i = 0; i < nArgs; i++) {
+ lstrcpyA(p, lpArgs[i]);
+ p += lstrlenA(lpArgs[i]);
+ *p++ = '\0';
+ }
+ *p++ = '\0';
+ *p++ = '\0';
+ return lpSz;
+}
+
+void apxStrQuoteInplaceW(LPWSTR szString)
+{
+ LPWSTR p = szString;
+ BOOL needsQuote = FALSE;
+ while (*p) {
+ if (*p++ == L' ') {
+ needsQuote = TRUE;
+ break;
+ }
+ }
+ if (needsQuote) {
+ DWORD l = lstrlenW(szString);
+ AplMoveMemory(&szString[1], szString, l * sizeof(WCHAR));
+ szString[0] = L'"';
+ szString[++l] = L'"';
+ szString[++l] = L'\0';
+ }
+}
+
+DWORD apxStrUnQuoteInplaceA(LPSTR szString)
+{
+ LPSTR p = szString;
+ BOOL needsQuote = FALSE;
+ BOOL inQuote = FALSE;
+ while (*p) {
+ if (*p == '"') {
+ if (inQuote)
+ break;
+ else
+ inQuote = TRUE;
+ }
+ else if (*p == ' ') {
+ if (inQuote) {
+ needsQuote = TRUE;
+ break;
+ }
+ }
+ ++p;
+ }
+ if (!needsQuote)
+ return apxStrCharRemoveA(szString, '"');
+ else
+ return 0;
+}
+
+DWORD apxStrUnQuoteInplaceW(LPWSTR szString)
+{
+ LPWSTR p = szString;
+ BOOL needsQuote = FALSE;
+ BOOL inQuote = FALSE;
+ while (*p) {
+ if (*p == L'"') {
+ if (inQuote)
+ break;
+ else
+ inQuote = TRUE;
+ }
+ else if (*p == L' ') {
+ if (inQuote) {
+ needsQuote = TRUE;
+ break;
+ }
+ }
+ ++p;
+ }
+ if (!needsQuote)
+ return apxStrCharRemoveW(szString, L'"');
+ else
+ return 0;
+}
+
+LPWSTR
+apxMszToCRLFW(APXHANDLE hPool, LPCWSTR szStr)
+{
+ DWORD l, c;
+ LPWSTR rv, b;
+ LPCWSTR p = szStr;
+
+ l = __apxGetMultiSzLengthW(szStr, &c);
+ b = rv = apxPoolCalloc(hPool, (l + c + 2) * sizeof(WCHAR));
+
+ while (c > 0) {
+ if (*p)
+ *b++ = *p;
+ else {
+ *b++ = L'\r';
+ *b++ = L'\n';
+ c--;
+ }
+ p++;
+ }
+ return rv;
+}
+
+LPWSTR
+apxCRLFToMszW(APXHANDLE hPool, LPCWSTR szStr, LPDWORD lpdwBytes)
+{
+ DWORD l, c, n = 0;
+ LPWSTR rv, b;
+
+ l = lstrlenW(szStr);
+ b = rv = apxPoolCalloc(hPool, (l + 2) * sizeof(WCHAR));
+ for (c = 0; c < l; c++) {
+ if (szStr[c] == L'\r') {
+ *b++ = '\0';
+ n++;
+ }
+ else if (szStr[c] != L'\n') {
+ *b++ = szStr[c];
+ n++;
+ }
+ }
+ if (lpdwBytes)
+ *lpdwBytes = (n + 2) * sizeof(WCHAR);
+ return rv;
+}
+
+LPSTR
+apxExpandStrA(APXHANDLE hPool, LPCSTR szString)
+{
+ LPCSTR p = szString;
+ while (*p) {
+ if (*p == '%') {
+ p = szString;
+ break;
+ }
+ ++p;
+ }
+ if (p != szString)
+ return apxPoolStrdupA(hPool, szString);
+ else {
+ DWORD l = ExpandEnvironmentStringsA(szString, NULL, 0);
+ if (l) {
+ LPSTR rv = apxPoolAlloc(hPool, l);
+ l = ExpandEnvironmentStringsA(szString, rv, l);
+ if (l)
+ return rv;
+ else {
+ apxFree(rv);
+ return NULL;
+ }
+ }
+ else
+ return NULL;
+ }
+}
+
+LPWSTR
+apxExpandStrW(APXHANDLE hPool, LPCWSTR szString)
+{
+ LPCWSTR p = szString;
+ while (*p) {
+ if (*p == L'%') {
+ p = szString;
+ break;
+ }
+ ++p;
+ }
+ if (p != szString)
+ return apxPoolStrdupW(hPool, szString);
+ else {
+ DWORD l = ExpandEnvironmentStringsW(szString, NULL, 0);
+ if (l) {
+ LPWSTR rv = apxPoolAlloc(hPool, l * sizeof(WCHAR));
+ l = ExpandEnvironmentStringsW(szString, rv, l);
+ if (l)
+ return rv;
+ else {
+ apxFree(rv);
+ return NULL;
+ }
+ }
+ else
+ return NULL;
+ }
+}
+
+/* To share the semaphores with other processes, we need a NULL ACL
+ * Code from MS KB Q106387
+ */
+PSECURITY_ATTRIBUTES GetNullACL()
+{
+ PSECURITY_DESCRIPTOR pSD;
+ PSECURITY_ATTRIBUTES sa;
+
+ sa = (PSECURITY_ATTRIBUTES) LocalAlloc(LPTR, sizeof(SECURITY_ATTRIBUTES));
+ sa->nLength = sizeof(sizeof(SECURITY_ATTRIBUTES));
+
+ pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
+ sa->lpSecurityDescriptor = pSD;
+
+ if (pSD == NULL || sa == NULL) {
+ return NULL;
+ }
+ SetLastError(0);
+ if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)
+ || GetLastError()) {
+ LocalFree( pSD );
+ LocalFree( sa );
+ return NULL;
+ }
+ if (!SetSecurityDescriptorDacl(pSD, TRUE, (PACL) NULL, FALSE)
+ || GetLastError()) {
+ LocalFree( pSD );
+ LocalFree( sa );
+ return NULL;
+ }
+
+ sa->bInheritHandle = FALSE;
+ return sa;
+}
+
+
+void CleanNullACL(void *sa)
+{
+ if (sa) {
+ LocalFree(((PSECURITY_ATTRIBUTES)sa)->lpSecurityDescriptor);
+ LocalFree(sa);
+ }
+}
Propchange: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/src/utils.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/xdocs/index.xml
URL: http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/xdocs/index.xml?rev=980662&view=auto
==============================================================================
--- commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/xdocs/index.xml (added)
+++ commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/xdocs/index.xml Fri Jul 30 06:50:12 2010
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<document>
+ <properties>
+ <title>Daemon : Procrun</title>
+ <author email="mturk@apache.org">Mladen Turk</author>
+ </properties>
+
+<body>
+<section name="Introduction">
+<p>
+ Procrun is a set of libraries and applications for making Java
+ applications to run on WIN32 much easier.
+</p>
+</section>
+
+</body>
+</document>
Propchange: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/procrun/xdocs/index.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/Makefile
URL: http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/Makefile?rev=980662&view=auto
==============================================================================
--- commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/Makefile (added)
+++ commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/Makefile Fri Jul 30 06:50:12 2010
@@ -0,0 +1,25 @@
+#
+# 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 -I ../../unix/native
+../../../../dist/INSTSVC: instmain.c arguments.o debug.o
+ gcc $(INCLUDE) instmain.c -o ../../../../dist/INSTSVC arguments.o debug.o
+arguments.o: ../../unix/native/arguments.c
+ gcc -c $(INCLUDE) ../../unix/native/arguments.c
+debug.o: ../../unix/native/debug.c
+ gcc -c $(INCLUDE) ../../unix/native/debug.c
+clean:
+ rm -f arguments.o debug.o
Propchange: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/Makefile
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instmain.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instmain.c?rev=980662&view=auto
==============================================================================
--- commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instmain.c (added)
+++ commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instmain.c Fri Jul 30 06:50:12 2010
@@ -0,0 +1,437 @@
+/*
+ * 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: instmain.c 480469 2006-11-29 08:22:04Z bayard $ */
+
+/*
+ * jsvc.exe install program, create the service JavaService
+ */
+
+/* includes */
+#include <windows.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "moni_inst.h"
+
+/* Definitions for booleans */
+typedef enum {
+ false,
+ true
+} bool;
+#include "arguments.h"
+
+VOID Usage()
+{
+ printf( "\r\n - Java service installer\r\n\r\n");
+ printf( " - Usage :\r\n");
+
+ printf( " To install Java service : InstSvc -install ");
+ printf( " [-home JAVA_HOME] [-Dproperty=value]\r\n");
+ printf( " [-cp CLASSPATH] startclass\r\n");
+ printf( " Like:\r\n");
+
+ printf( " InstSvc -install -home c:\\jdk1.3.1_02");
+ printf( " -Dcatalina.home=/home1/jakarta/jakarta-tomcat-4.1/build");
+ printf( " -Djava.io.tmpdir=/var/tmp ");
+ printf( " -cp \"c:\\jdk1.3.1_02\\lib\\tools.jar;");
+ printf( "c:\\home1\\jakarta\\jakarta-tomcat-4.1\\build\\bin\\commons-daemon.jar;");
+ printf( "c:\\home1\\jakarta\\jakarta-tomcat-4.1\\build\\bin\\bootstrap.jar\"");
+ printf( " org.apache.catalina.startup.BootstrapService\r\n");
+
+ printf( " To remove Java service : InstSvc -remove\r\n\r\n");
+ printf( " Use regedit if you want to change something\r\n\r\n");
+ printf( " Note that the service keys are stored under:\r\n");
+ printf( " HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\");
+ printf( "%s",SZSERVICENAME);
+ printf( "\r\n");
+ printf( " The environment keys in:\r\n");
+ printf( " ");
+ printf( "%s",SZKEY_ONSERVE);
+ printf( "\r\n");
+ return;
+}
+
+/* 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;
+}
+
+
+/* remove the service (first stop it!) NT version */
+
+BOOL RemoveSvcNT (VOID)
+{
+ BOOL removed;
+ SC_HANDLE hManager;
+ SC_HANDLE hService;
+ SERVICE_STATUS svcStatus;
+ DWORD dwCount;
+
+ removed = FALSE;
+ /* open service control manager with full access right */
+ hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if (NULL != hManager) {
+ /* open existing service */
+ hService = OpenService(hManager, SZSERVICENAME, SERVICE_ALL_ACCESS);
+ if (NULL != hService) {
+ /* get the status of the service */
+ if (QueryServiceStatus(hService, &svcStatus)) {
+ /* and see if the service is stopped */
+ if (SERVICE_STOPPED != svcStatus.dwCurrentState) {
+ /* if not stop the service */
+ ControlService(hService, SERVICE_CONTROL_STOP, &svcStatus);
+ }
+ dwCount = 0;
+ do {
+ if (SERVICE_STOPPED == svcStatus.dwCurrentState) {
+ /* delete the service */
+ if (DeleteService(hService)) {
+ removed = TRUE;
+ break;
+ }
+ }
+ /* wait 10 seconds for the service to stop */
+ Sleep(10000);
+ if (!QueryServiceStatus(hService, &svcStatus)) {
+ /* something went wrong */
+ break;
+ }
+ dwCount++;
+ } while (10 > dwCount);
+ }
+ /* close service handle */
+ CloseServiceHandle(hService);
+ }
+ /* close service control manager */
+ CloseServiceHandle(hManager);
+ }
+ return removed;
+} /* RemoveSvc */
+
+/* remove service (non NT) stopping it looks ugly!!! */
+BOOL RemoveSvc (VOID)
+{
+ HKEY hkey;
+ DWORD rv;
+
+ rv = RegOpenKey(HKEY_LOCAL_MACHINE,
+ "Software\\Microsoft\\Windows\\CurrentVersion\\RunServices",
+ &hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not open the RunServices registry key.\r\n");
+ return FALSE;
+ }
+ rv = RegDeleteValue(hkey, SZSERVICENAME);
+ RegCloseKey(hkey);
+ if (rv != ERROR_SUCCESS)
+ printf( "Could not delete the RunServices entry.\r\n");
+
+ rv = RegOpenKey(HKEY_LOCAL_MACHINE,
+ "SYSTEM\\CurrentControlSet\\Services", &hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not open the Services registry key.\r\n");
+ return FALSE;
+ }
+ rv = RegDeleteKey(hkey, SZSERVICENAME);
+ RegCloseKey(hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not delete the Services registry key.\r\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/* Install service (NT version) */
+
+BOOL InstallSvcNT (CHAR *svcExePath)
+{
+ BOOL installed;
+ SC_HANDLE hManager;
+ SC_HANDLE hService;
+
+ installed = FALSE;
+ /* open the service control manager with full access right */
+ hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if (NULL != hManager) {
+ /* create the service */
+ hService = CreateService(hManager,
+ 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 */
+ if (NULL != hService) {
+ /* close service handle */
+ CloseServiceHandle(hService);
+ installed = TRUE;
+ }
+ } else {
+ printf( "OpenSCManager failed\r\n");
+ }
+ return installed;
+}
+
+/* Install service */
+
+BOOL InstallSvc (CHAR *svcExePath)
+{
+ HKEY hkey;
+ DWORD rv;
+ char szPath[MAX_PATH];
+
+ printf( "InstallSvc for non-NT\r\n");
+
+ rv = RegCreateKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows"
+ "\\CurrentVersion\\RunServices", &hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not open the RunServices registry key\r\n");
+ return FALSE;
+ }
+ rv = RegSetValueEx(hkey, SZSERVICENAME, 0, REG_SZ,
+ (unsigned char *) svcExePath,
+ strlen(svcExePath) + 1);
+ RegCloseKey(hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not add %s:%s ",SZSERVICENAME, svcExePath);
+ printf( "to RunServices Registry Key\r\n");
+ return FALSE;
+ }
+
+ strcpy(szPath,
+ "SYSTEM\\CurrentControlSet\\Services\\");
+ strcat(szPath,SZSERVICENAME);
+ rv = RegCreateKey(HKEY_LOCAL_MACHINE, szPath, &hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not create/open the %s registry key\r\n",
+ szPath);
+ return FALSE;
+ }
+ rv = RegSetValueEx(hkey, "ImagePath", 0, REG_SZ,
+ (unsigned char *) svcExePath,
+ strlen(svcExePath) + 1);
+ if (rv != ERROR_SUCCESS) {
+ RegCloseKey(hkey);
+ printf( "Could not add ImagePath to our Registry Key\r\n");
+ return FALSE;
+ }
+ rv = RegSetValueEx(hkey, "DisplayName", 0, REG_SZ,
+ (unsigned char *) SZSERVICEDISPLAYNAME,
+ strlen(SZSERVICEDISPLAYNAME) + 1);
+ RegCloseKey(hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not add DisplayName to our Registry Key\r\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * Fill the registry with the environment variables
+ */
+BOOL InstallEnv (char *var, char *value)
+{
+ BOOL installed;
+ HKEY hKey;
+
+ installed = FALSE;
+ /* 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 */
+ RegSetValueEx(hKey,var,0,REG_SZ,(BYTE *)value,lstrlen(value)+1);
+ RegCloseKey(hKey);
+ installed = TRUE;
+ }
+ return installed;
+} /* InstallEnv */
+
+/*
+ * Add the arguments to start jsvc like -Dcatalina.home=/home/jakarta/tomcat.
+ */
+BOOL InstallEnvParm(int i,char *value)
+{
+ BOOL installed;
+ HKEY hKey;
+ char var[64];
+
+ sprintf(var,"arg%d",i);
+ log_debug("InstallEnvParm: %s:%s",var,value);
+
+ installed = FALSE;
+ /* 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 */
+ RegSetValueEx(hKey,var,0,REG_SZ,
+ (BYTE *)value,lstrlen(value)+1);
+ RegCloseKey(hKey);
+ installed = TRUE;
+ }
+ return installed;
+}
+
+/*
+ * Remove the created keys
+ */
+BOOL RemoveEnv()
+{
+ HKEY hkey;
+ DWORD rv;
+
+ log_debug("RemoveEnv");
+
+ rv = RegOpenKey(HKEY_LOCAL_MACHINE,
+ NULL,
+ &hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not open the jsvc registry key.\r\n");
+ return FALSE;
+ }
+ rv = RegDeleteKey(hkey, SZKEY_ONSERVE);
+ RegCloseKey(hkey);
+ if (rv != ERROR_SUCCESS)
+ printf( "Could not delete the jsvc entry.\r\n");
+
+ /* remove the key tree if empty */
+
+ return TRUE;
+}
+
+
+/*
+ * Install or remove the OnServe service and Key in the registry.
+ * no parameter install the OnServe.
+ * -REMOVE: desinstall the OnServe service and Keys.
+ */
+
+INT main (INT argc, CHAR *argv[])
+{
+ BOOL done;
+ arg_data *args=NULL;
+ char szPath[512];
+ char szExePath[512];
+ int i;
+
+ printf( "\r\n - Copyright (c) 2001 The Apache Software Foundation. \r\n");
+ printf( "\r\n");
+ if (GetModuleFileName(NULL, szPath, sizeof(szPath))) {
+ printf( "%s\r\n",szPath);
+ }
+
+ args=arguments(argc,argv);
+ if (args==NULL) {
+ Usage();
+ return(1);
+ }
+
+
+ if (args->install==true) {
+ if (args->home==NULL) {
+ printf( "home empty or not defined...\r\n\r\n");
+ Usage();
+ return(1);
+ }
+ if (args->clas==NULL) {
+ printf( "startclass empty or not defined...\r\n\r\n");
+ Usage();
+ return(1);
+ }
+ printf( "\r\ninstalling...\r\n\r\n");
+
+ /* get the patch from the executable name */
+ for(i=strlen(szPath);i>0;i--)
+ if (szPath[i]=='\\') {
+ szPath[i]='\0';
+ break;
+ }
+ strcpy(szExePath,szPath);
+ strcat(szExePath,SZDEFMONISVCPATH);
+ /* install jsvcservice.exe as a service */
+ if (isWindowsNT())
+ done = InstallSvcNT(szExePath);
+ else
+ done = InstallSvc(szExePath);
+
+ if (done)
+ printf( "InstallSvc done\r\n");
+ else
+ printf( "InstallSvc failed\r\n");
+
+ /* install the environment variable in registry */
+
+ /* should get it from szPath */
+ InstallEnv("JAKARTA_HOME",szPath);
+
+ InstallEnv("CYGWIN",SZCYGWINPATH); /* need APR to get ride of it */
+
+ InstallEnv("JAVA_HOME",args->home);
+
+ InstallEnv("STARTCLASS",args->clas);
+
+ if (args->onum==0) return(0);
+
+ for(i=0;i<args->onum;i++)
+ InstallEnvParm(i,args->opts[i]);
+
+ return(0);
+ }
+
+ if (args->remove==true) {
+ /* remove the service. removing the keys not yet done!!! */
+ printf( "\r\n - removing Java Service...\r\n\r\n");
+ if (isWindowsNT())
+ done = RemoveSvcNT();
+ else
+ done = RemoveSvc();
+ if (!done) {
+ printf( "\r\n - REMOVE FAILED....\r\n\r\n");
+ return(2);
+ }
+ RemoveEnv();
+ return(0);
+ }
+ printf( "\r\nonly -install or -remove supported...\r\n\r\n");
+ Usage();
+ return(1);
+}
Propchange: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instmain.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instsvc.dsp
URL: http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instsvc.dsp?rev=980662&view=auto
==============================================================================
--- commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instsvc.dsp (added)
+++ commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instsvc.dsp Fri Jul 30 06:50:12 2010
@@ -0,0 +1,104 @@
+# Microsoft Developer Studio Project File - Name="InstSvc" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=InstSvc - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "INSTSVC.MAK".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "INSTSVC.MAK" CFG="InstSvc - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "InstSvc - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "InstSvc - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "InstSvc - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir ".\Release"
+# PROP BASE Intermediate_Dir ".\Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir ".\InstSvc.Release"
+# PROP Intermediate_Dir ".\InstSvc.Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /W3 /GX /O2 /I "../lib" /D "WIN32" /D "_CONSOLE" /YX /FD /D "NDEBUG" /c
+# ADD BASE RSC /l 0x407 /d "NDEBUG"
+# ADD RSC /l 0x407 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../bin/INSTSVC.exe"
+
+!ELSEIF "$(CFG)" == "InstSvc - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir ".\Debug"
+# PROP BASE Intermediate_Dir ".\Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ".\InstSvc.Debug"
+# PROP Intermediate_Dir ".\InstSvc.Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /YX /FD /c
+# ADD BASE RSC /l 0x407 /d "_DEBUG"
+# ADD RSC /l 0x407 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
+
+!ENDIF
+
+# Begin Target
+
+# Name "InstSvc - Win32 Release"
+# Name "InstSvc - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
+# Begin Source File
+
+SOURCE=.\instmain.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
+# Begin Source File
+
+SOURCE=..\lib\moni_inst.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
Propchange: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instsvc.dsp
------------------------------------------------------------------------------
svn:eol-style = CRLF
Added: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instsvc.dsw
URL: http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instsvc.dsw?rev=980662&view=auto
==============================================================================
--- commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instsvc.dsw (added)
+++ commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instsvc.dsw Fri Jul 30 06:50:12 2010
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 5.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "InstSvc"=.\INSTSVC.DSP - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
Propchange: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/service/instsvc.dsw
------------------------------------------------------------------------------
svn:eol-style = CRLF
Added: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/signals/kills.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/signals/kills.c?rev=980662&view=auto
==============================================================================
--- commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/signals/kills.c (added)
+++ commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/signals/kills.c Fri Jul 30 06:50:12 2010
@@ -0,0 +1,48 @@
+/*
+ * 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: kills.c 480469 2006-11-29 08:22:04Z bayard $ */
+
+/*
+ * as Windows does not support signal, jsvc uses events to emulate them.
+ * The supported signal is SIGTERM.
+ * signals.c contains the signal handler logic.
+ */
+#include <windows.h>
+#include <stdio.h>
+
+/*
+ * Send a clean termination signal to a process
+ * it is like kill(pid,SIGTERM);
+ */
+int TermPid(long pid)
+{
+char Name[256];
+HANDLE hevint;
+BOOL rc;
+
+ sprintf(Name,"TERM%ld",pid);
+
+ hevint = OpenEvent(EVENT_MODIFY_STATE,FALSE,Name);
+ if (hevint == NULL) return(-1); /* failed */
+
+ rc = SetEvent(hevint);
+ CloseHandle(hevint);
+
+ if (rc) return(0);
+ return(-1);
+}
Propchange: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/signals/kills.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/supcalls_nt/vdenv.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/supcalls_nt/vdenv.c?rev=980662&view=auto
==============================================================================
--- commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/supcalls_nt/vdenv.c (added)
+++ commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/supcalls_nt/vdenv.c Fri Jul 30 06:50:12 2010
@@ -0,0 +1,179 @@
+/*
+ * 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: vdenv.c 897078 2010-01-08 01:52:47Z sebb $ */
+
+/* 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"
+
+#define ENVSIZE 1024
+
+int MySetEnvironmentVariable(char *name, char *data)
+{
+char Variable[ENVSIZE];
+
+ strcpy(Variable,name);
+ strcat(Variable,"=");
+ strcat(Variable,data);
+ 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).
+ *
+*/
+int OnServeSetEnv ()
+{
+HKEY hKey=NULL;
+DWORD Type;
+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. */
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SZKEY_ONSERVE,
+ 0, KEY_READ,&hKey) != ERROR_SUCCESS)
+ return(-1);
+
+ /* read key and set environment. */
+
+ /* JAKARTA_HOME */
+ LData = sizeof(Data);
+ if (RegQueryValueEx(hKey,"JAKARTA_HOME",NULL,&Type,Data,&LData)==ERROR_SUCCESS) {
+ strcpy(jakarta_home,Data);
+ MySetEnvironmentVariable("JAKARTA_HOME",Data);
+ }
+ else
+ qreturn = -2;
+
+ /* CYGWIN */
+ LData = sizeof(Data);
+ if (RegQueryValueEx(hKey,"CYGWIN",NULL,&Type,Data,&LData)==ERROR_SUCCESS) {
+ strcpy(cygwin,Data);
+ MySetEnvironmentVariable("CYGWIN",Data);
+ }
+ else
+ qreturn = -3;
+
+ /* JAVA_HOME */
+ LData = sizeof(Data);
+ if (RegQueryValueEx(hKey,"JAVA_HOME",NULL,&Type,Data,&LData)
+ ==ERROR_SUCCESS) {
+ MySetEnvironmentVariable("JAVA_HOME",Data);
+ }
+ else
+ qreturn = -4;
+
+ RegCloseKey(hKey);
+ hKey = NULL;
+
+ /* set the PATH otherwise nothing works!!! */
+ LData = sizeof(Data);
+ if (!GetEnvironmentVariable("PATH",Data,LData)) {
+ strcpy(Data,jakarta_home);
+ }
+ else {
+ strcat(Data,";");
+ strcat(Data,jakarta_home);
+ }
+ strcat(Data,"\\bin");
+
+ strcat(Data,";");
+ strcat(Data,cygwin);
+ strcat(Data,"\\bin");
+
+ MySetEnvironmentVariable("PATH",Data);
+
+ return(qreturn);
+}
+
+/*
+ * Build the jsvc.exe command using the registry information.
+ */
+int BuildCommand(char *data)
+{
+ int i;
+ LONG lRet;
+ DWORD dwIndex;
+ char name[128];
+ DWORD lname;
+ char value[256];
+ DWORD lvalue;
+ DWORD nvalue;
+ DWORD Type;
+ HKEY hKey=NULL;
+
+
+ strcat(data,"\\jsvc.exe -nodetach ");
+
+ /* Read the registry and set environment. */
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SZKEY_ONSERVEARG,
+ 0, KEY_READ,&hKey) != ERROR_SUCCESS)
+ return(-1);
+ if (RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL,
+ &nvalue,NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
+ return(-2);
+
+ /* Read the arguments */
+ for (i=0;i<nvalue;i++) {
+ lname = sizeof(name);
+ lvalue = sizeof(value);
+
+ lRet = RegEnumValue (hKey, i, name, &lname, NULL, NULL,
+ value, &lvalue);
+ if (lRet != ERROR_SUCCESS) {
+ RegCloseKey(hKey);
+ return(-3);
+ }
+
+ strncat(data,value,lvalue);
+ strcat(data," ");
+ }
+ RegCloseKey(hKey);
+
+ /* Read the start class. */
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SZKEY_ONSERVE,
+ 0, KEY_READ,&hKey) != ERROR_SUCCESS)
+ return(-4);
+ lvalue = sizeof(value);
+ if (RegQueryValueEx(hKey,"STARTCLASS",NULL,&Type,value,&lvalue)
+ !=ERROR_SUCCESS) {
+ RegCloseKey(hKey);
+ return(-5);
+ }
+ RegCloseKey(hKey);
+
+ strncat(data,value,lvalue);
+
+ return(0);
+}
Propchange: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/nt/supcalls_nt/vdenv.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/unix/CHANGES.txt
URL: http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/unix/CHANGES.txt?rev=980662&view=auto
==============================================================================
--- commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/unix/CHANGES.txt (added)
+++ commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/unix/CHANGES.txt Fri Jul 30 06:50:12 2010
@@ -0,0 +1,34 @@
+APACHE COMMONS DAEMON (UNIX) CHANGELOG:
+Last modified at [$Date: 2010-03-15 10:50:28 +0100 (Mon, 15 Mar 2010) $]
+
+Changes with 1.0.3
+ * Implement fail() method (DAEMON-128)
+ * Add missing Java6 parameters (DAEMON-140)
+
+Changes with 1.0.2
+ * Allow support for OS/X 10.6 (DAEMON-129)
+ * Prunmgr shows wrong default logging level (DAEMON-132)
+ * Allon non ASCII characters in classpath (DAEMON-130)
+ * Log on tab of Prunmgr ignores current settings (DAEMON-126)
+ * Unable to open directory /proc/self/fd (DAEMON-120)
+ * Read Java parameters for Java mode in the same way as JVM mode (DAEMON-119)
+ * Allow running jsvc should as non root (DAEMON-93)
+ * Support all the standard Java 5 launcher options (DAEMON-84)
+ * Support compilation on Cygwin (DAEMON-40)
+ * Add Support for AIX (DAEMON-123)
+ * Fix default log path (DAEMON-116)
+ * Wait for JVM clean exit (DAEMON-97)
+
+Changes with 1.0.1
+ * Allow enableassertions -ea (PR 304310).
+ * Add -lpthread to LDFLAGS on Linux (PR 30177).
+ * Add support for x86_64 (PR 27523).
+ * Add support for Tru64 (PR 29465).
+ * Remove the pid file when son exits correctly (PR 31614).
+ * Add support for JVM-4.1.x on MAC OS X (part of PR 31613).
+ * Prevent starting jsvc several times with the same pidfile (PR 33580).
+ * Finish fixing 31613, automatic detection of JAVA_HOME and headers locations.
+ * -wait and -stop parameters.
+ * fix 34851.
+ * Don't break when set_caps() failed and the user is unchanged (linux).
+
Propchange: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/unix/CHANGES.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/unix/INSTALL.txt
URL: http://svn.apache.org/viewvc/commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/unix/INSTALL.txt?rev=980662&view=auto
==============================================================================
--- commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/unix/INSTALL.txt (added)
+++ commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/unix/INSTALL.txt Fri Jul 30 06:50:12 2010
@@ -0,0 +1,69 @@
+To build the service libraries and binary under an UNIX operating
+system you will need:
+
+ An ANSI-C compliant compiler (GCC is good)
+ A Java Platform 2 compliant SDK
+ GNU AutoConf (when building for SVN).
+
+When building from SVN sources you need to build the "configure" program with:
+
+ sh support/buildconf.sh
+(Note it is possible to replace sh by any compatible shell like bash, ksh).
+
+Once the configure script is generated, run it (remember to specify
+either the --with-java=<dir> parameter or set the JAVA_HOME environment
+to point to your JDK installation. For example:
+
+ ./configure --with-java=/usr/java
+
+or
+
+ JAVA_HOME=/usr/java
+ export JAVA_HOME
+ ./configure
+
+or (when using gcj (use fastjar for jar))
+ JAVAC=gcj; export JAVAC
+ JAVACFLAGS=-c; export JAVACFLAGS
+ ./configure
+
+Note: On Mac OS X <dir> is /System/Library/Frameworks/JavaVM.framework/Home.
+
+If your operating system is supported, configure will go thru cleanly,
+otherwise it will report an error (please send us the details of your
+OS/JDK, or a patch against the sources). To build the binaries and
+libraries simply do:
+
+ make
+
+This will generate the file: ./jsvc.
+It should be straightforward from here on. To check the allowed parameters
+for the jsvc binary simply do
+
+ ./native/jsvc -help
+
+Note: On Linux the module capabilities should be loaded, when using -user root
+make sure you REALLY understand what capabilities does (for example for
+files access: the downgraded root may not be able to read some files!).
+
+Making 64-bit binaries
+
+To be able to build the 64-binaries for supported platforms enter the
+specific parameters before calling configure
+
+ export CFLAGS=-m64
+ export LDFLAGS=-m64
+ ./configure
+ make
+
+Making Universal binaries
+
+Some platforms like Mac OSX allow universal or fat binaries that allow
+both 32 and 64 binaries inside the same executable. To be able to build
+the fat binaries enter the specific parameters before calling configure
+
+ export CFLAGS="-arch i386 -arch x86_64"
+ export LDFLAGS="-arch i386 -arch x86_64"
+ ./configure
+ make
+
Propchange: commons/proper/daemon/tags/COMMONS_DAEMON_1_0_3_RC3/src/native/unix/INSTALL.txt
------------------------------------------------------------------------------
svn:eol-style = native