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