1*eaad808eSchristos /*
2*eaad808eSchristos  * winrc/unbound-service-remove.c - windows services installation util
3*eaad808eSchristos  *
4*eaad808eSchristos  * Copyright (c) 2009, NLnet Labs. All rights reserved.
5*eaad808eSchristos  *
6*eaad808eSchristos  * This software is open source.
7*eaad808eSchristos  *
8*eaad808eSchristos  * Redistribution and use in source and binary forms, with or without
9*eaad808eSchristos  * modification, are permitted provided that the following conditions
10*eaad808eSchristos  * are met:
11*eaad808eSchristos  *
12*eaad808eSchristos  * Redistributions of source code must retain the above copyright notice,
13*eaad808eSchristos  * this list of conditions and the following disclaimer.
14*eaad808eSchristos  *
15*eaad808eSchristos  * Redistributions in binary form must reproduce the above copyright notice,
16*eaad808eSchristos  * this list of conditions and the following disclaimer in the documentation
17*eaad808eSchristos  * and/or other materials provided with the distribution.
18*eaad808eSchristos  *
19*eaad808eSchristos  * Neither the name of the NLNET LABS nor the names of its contributors may
20*eaad808eSchristos  * be used to endorse or promote products derived from this software without
21*eaad808eSchristos  * specific prior written permission.
22*eaad808eSchristos  *
23*eaad808eSchristos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24*eaad808eSchristos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25*eaad808eSchristos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26*eaad808eSchristos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27*eaad808eSchristos  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28*eaad808eSchristos  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29*eaad808eSchristos  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30*eaad808eSchristos  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31*eaad808eSchristos  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32*eaad808eSchristos  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33*eaad808eSchristos  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34*eaad808eSchristos  */
35*eaad808eSchristos 
36*eaad808eSchristos /**
37*eaad808eSchristos  * \file
38*eaad808eSchristos  *
39*eaad808eSchristos  * This file contains functions to integrate with the windows services API.
40*eaad808eSchristos  * This means it handles the commandline switches to install and remove
41*eaad808eSchristos  * the service (via CreateService and DeleteService), it handles
42*eaad808eSchristos  * the ServiceMain() main service entry point when started as a service,
43*eaad808eSchristos  * and it handles the Handler[_ex]() to process requests to the service
44*eaad808eSchristos  * (such as start and stop and status).
45*eaad808eSchristos  */
46*eaad808eSchristos #include "config.h"
47*eaad808eSchristos #include "winrc/w_inst.h"
48*eaad808eSchristos 
49*eaad808eSchristos /** Remove service main */
main(int argc,char ** argv)50*eaad808eSchristos int main(int argc, char** argv)
51*eaad808eSchristos {
52*eaad808eSchristos 	FILE* out = stdout;
53*eaad808eSchristos 	/* out = fopen("unbound-service-remove.log", "w");*/
54*eaad808eSchristos 	if(argc == 2 && strcmp(argv[1], "stop")==0) {
55*eaad808eSchristos 		wsvc_rc_stop(out);
56*eaad808eSchristos 		return 0;
57*eaad808eSchristos 	}
58*eaad808eSchristos 	if(argc != 1) {
59*eaad808eSchristos 		if(out) fprintf(out, "Usage: %s [stop]\n", argv[0]);
60*eaad808eSchristos 		else	printf("Usage: %s [stop]\n", argv[0]);
61*eaad808eSchristos 		return 1;
62*eaad808eSchristos 	}
63*eaad808eSchristos 	wsvc_remove(NULL);
64*eaad808eSchristos 	return 0;
65*eaad808eSchristos }
66