#endif
#undef _WINUSER_
#include <winuser.h>
+#include <time.h>
APLOG_USE_MODULE(mpm_winnt);
static int ReportStatusToSCMgr(int currentState, int waitHint,
nt_service_ctx_t *ctx);
-
-#define PRODREGKEY "SOFTWARE\\" AP_SERVER_BASEVENDOR "\\" \
- AP_SERVER_BASEPRODUCT "\\" AP_SERVER_BASEREVISION
-
-/*
- * Get the server root from the registry into 'dir' which is
- * size bytes long. Returns 0 if the server root was found
- * or if the serverroot key does not exist (in which case
- * dir will contain an empty string), or -1 if there was
- * an error getting the key.
- */
-apr_status_t ap_registry_get_server_root(apr_pool_t *p, char **buf)
-{
- apr_status_t rv;
- ap_regkey_t *key;
-
- if ((rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, PRODREGKEY,
- APR_READ, p)) == APR_SUCCESS) {
- rv = ap_regkey_value_get(buf, key, "ServerRoot", p);
- ap_regkey_close(key);
- if (rv == APR_SUCCESS)
- return rv;
- }
-
- if ((rv = ap_regkey_open(&key, AP_REGKEY_CURRENT_USER, PRODREGKEY,
- APR_READ, p)) == APR_SUCCESS) {
- rv = ap_regkey_value_get(buf, key, "ServerRoot", p);
- ap_regkey_close(key);
- if (rv == APR_SUCCESS)
- return rv;
- }
-
- *buf = NULL;
- return rv;
-}
-
-
/* exit() for Win32 is macro mapped (horrible, we agree) that allows us
* to catch the non-zero conditions and inform the console process that
* the application died, and hang on to the console a bit longer.
return;
}
remains = ((start + 30) - time(NULL));
- sprintf (count, "%d...", remains);
+ sprintf(count, "%d...",
+ (int)remains); /* 30 or less, so can't overflow int */
if (!SetConsoleCursorPosition(hConErr, coninfo.dwCursorPosition))
return;
if (!WriteConsole(hConErr, count, (DWORD)strlen(count), &result, NULL)
while ((remains > 0) && WaitForSingleObject(hConIn, 1000) != WAIT_FAILED);
}
-static BOOL die_on_logoff = FALSE;
-
static BOOL CALLBACK console_control_handler(DWORD ctrl_type)
{
switch (ctrl_type)
}
-/* Special situation - children of services need to mind their
- * P's & Q's and wait quietly, ignoring the mean OS signaling
- * shutdown and other horrors, to kill them gracefully...
- */
-
-static BOOL CALLBACK child_control_handler(DWORD ctrl_type)
-{
- switch (ctrl_type)
- {
- case CTRL_C_EVENT:
- case CTRL_BREAK_EVENT:
- /* for Interrupt signals, ignore them.
- * The system will also signal the parent process,
- * which will terminate Apache.
- */
- return TRUE;
-
- case CTRL_CLOSE_EVENT:
- case CTRL_LOGOFF_EVENT:
- case CTRL_SHUTDOWN_EVENT:
- /* for Shutdown signals, ignore them, but... .
- * The system will also signal the parent process,
- * which will terminate Apache, so we need to wait.
- */
- Sleep(30000);
- return TRUE;
- }
-
- /* We should never get here, but this is (mostly) harmless */
- return FALSE;
-}
-
-
void mpm_start_child_console_handler(void)
{
FreeConsole();
}
/* Note this works on Win2000 and later due to ChangeServiceConfig2
- * Continue to test it's existence, but at least drop the feature
+ * Continue to test its existence, but at least drop the feature
* of revising service description tags prior to Win2000.
*/
{
const char *full_description;
SC_HANDLE schSCManager;
- BOOL ret = 0;
/* Nothing to do if we are a console
*/
/* handle the SCM's ControlService() callbacks to our service */
-static DWORD WINAPI service_nt_ctrl(DWORD dwCtrlCode, DWORD dwEventType,
+static DWORD WINAPI service_nt_ctrl(DWORD dwCtrlCode, DWORD dwEventType,
LPVOID lpEventData, LPVOID lpContext)
{
nt_service_ctx_t *ctx = lpContext;
}
-DWORD WINAPI service_nt_dispatch_thread(LPVOID nada)
+static DWORD WINAPI service_nt_dispatch_thread(LPVOID nada)
{
apr_status_t rv = APR_SUCCESS;
}
-void service_stopped(void)
+static void service_stopped(void)
{
/* Still have a thread & window to clean up, so signal now */
if (globdat.service_thread)
* depend on it.
*/
/* ###: utf-ize */
- schService = CreateService(schSCManager, // SCManager database
- mpm_service_name, // name of service
- mpm_display_name, // name to display
- SERVICE_ALL_ACCESS, // access required
- SERVICE_WIN32_OWN_PROCESS, // service type
- SERVICE_AUTO_START, // start type
- SERVICE_ERROR_NORMAL, // error control type
- launch_cmd, // service's binary
- NULL, // no load svc group
- NULL, // no tag identifier
- "Tcpip\0Afd\0", // dependencies
- NULL, // use SYSTEM account
- NULL); // no password
+ schService = CreateService(schSCManager, /* SCManager database */
+ mpm_service_name, /* name of service */
+ mpm_display_name, /* name to display */
+ SERVICE_ALL_ACCESS, /* access required */
+ SERVICE_WIN32_OWN_PROCESS, /* service type */
+ SERVICE_AUTO_START, /* start type */
+ SERVICE_ERROR_NORMAL, /* error control type */
+ launch_cmd, /* service's binary */
+ NULL, /* no load svc group */
+ NULL, /* no tag identifier */
+ "Tcpip\0Afd\0", /* dependencies */
+ NULL, /* use SYSTEM account */
+ NULL); /* no password */
if (!schService)
{
const char * const * argv)
{
apr_status_t rv;
- char **start_argv;
+ CHAR **start_argv;
SC_HANDLE schService;
SC_HANDLE schSCManager;
SC_HANDLE schService;
SC_HANDLE schSCManager;
- schSCManager = OpenSCManager(NULL, NULL, // default machine & database
+ schSCManager = OpenSCManager(NULL, NULL, /* default machine & database */
SC_MANAGER_CONNECT);
if (!schSCManager) {