ntservice.c revision c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840e
/*
* Copyright (C) 2004, 2006, 2007, 2009, 2011, 2013 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2002 Internet Software Consortium.
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $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() {
if (!foreground) {
/* Register handler with the SCM */
if (!hServiceStatus) {
"could not register service control handler");
exit(1);
}
} else {
}
}
void
}
/*
* Routine to check if this is a service or a foreground program
*/
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. */
"46c:C:d:D:E:fFgi:lm:n:N:p:P:"
"sS:t:T:U:u:vVx:")) != -1) {
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);
}