ntservice.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 1999-2002, 2004, 2006, 2007, 2009, 2011, 2013-2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: ntservice.c,v 1.16 2011/01/13 08:50:29 tbox Exp $ */
#include <config.h>
#include <stdio.h>
#include <isc/commandline.h>
#include <named/ntservice.h>
/* Handle to SCM for updating service status */
static SERVICE_STATUS_HANDLE hServiceStatus = 0;
static char ConsoleTitle[128];
/*
* Forward declarations
*/
/*
* Initialize the Service by registering it.
*/
void
ntservice_init(void) {
if (!foreground) {
/* Register handler with the SCM */
if (!hServiceStatus) {
"could not register service control handler");
exit(1);
}
} else {
}
}
void
ntservice_shutdown(void) {
}
/*
* Routine to check if this is a service or a foreground program
*/
ntservice_isservice(void) {
return(!foreground);
}
/*
* ServiceControl(): Handles requests from the SCM and passes them on
* to named.
*/
void
/* Handle the requested control code */
switch(dwCtrlCode) {
UpdateSCM(0);
break;
case SERVICE_CONTROL_SHUTDOWN:
case SERVICE_CONTROL_STOP:
break;
default:
break;
}
}
/*
* Tell the Service Control Manager the state of the service.
*/
if (hServiceStatus) {
if (state)
ss.dwCheckPoint = 0;
}
}
}
/* unhook main */
/*
* This is the entry point for the executable
* We can now call bindmain() explicitly or via StartServiceCtrlDispatcher()
* as we need to.
*/
{
/* Command line users should put -f in the options. */
switch (ch) {
case 'f':
case 'g':
case 'v':
case 'V':
foreground = TRUE;
break;
default:
break;
}
}
if (foreground) {
/* run in console window */
} else {
/* Start up as service */
char *SERVICE_NAME = BIND_SERVICE_NAME;
{ TEXT(SERVICE_NAME),
};
if (!rc) {
"Use -f to run from the command line.\n");
/* will be 1063 when launched as a console app */
exit(GetLastError());
}
}
exit(0);
}