os2main.c revision 04bdb234571448ed6194e1d4048e6512f2446f1c
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley/*
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * os2main.c - mDNS Proxy, entry for OS2
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley *
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * For OS/2, there are no daemon, nor service. Simply
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * start server program with
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley *
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * RUN in config.sys
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * START in startup.cmd
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * put server program (object) into startup folder
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff */
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff/*
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff *
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * By using this file, you agree to the terms and conditions set forth bellow.
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff *
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * LICENSE TERMS AND CONDITIONS
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff *
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * The following License Terms and Conditions apply, unless a different
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * license is obtained from Japan Network Information Center ("JPNIC"),
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * a Japanese association, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * Tokyo, Japan.
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff *
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * 1. Use, Modification and Redistribution (including distribution of any
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * modified or derived work) in source and/or binary forms is permitted
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * under this License Terms and Conditions.
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff *
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * 2. Redistribution of source code must retain the copyright notices as they
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * appear in each source code file, this License Terms and Conditions.
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff *
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * 3. Redistribution in binary form must reproduce the Copyright Notice,
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * this License Terms and Conditions, in the documentation and/or other
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff * materials provided with the distribution. For the purposes of binary
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * distribution the "Copyright Notice" refers to the following language:
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * "Copyright (c) Japan Network Information Center. All rights reserved."
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley *
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * 4. Neither the name of JPNIC may be used to endorse or promote products
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * derived from this Software without specific prior written approval of
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * JPNIC.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley *
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
a2171e092382f8f8a72b1f73436ddf93918c7719Bob Halley * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
a2171e092382f8f8a72b1f73436ddf93918c7719Bob Halley * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
7c0876aa42e6abaa8779bcb83962ccf20a9f4da3Bob Halley * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
a2171e092382f8f8a72b1f73436ddf93918c7719Bob Halley * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
64ba6e4cc3a0ccf8c8c6349fa75b937ca9bad9a6Michael Graff *
64ba6e4cc3a0ccf8c8c6349fa75b937ca9bad9a6Michael Graff * 6. Indemnification by Licensee
64ba6e4cc3a0ccf8c8c6349fa75b937ca9bad9a6Michael Graff * Any person or entities using and/or redistributing this Software under
64ba6e4cc3a0ccf8c8c6349fa75b937ca9bad9a6Michael Graff * this License Terms and Conditions shall defend indemnify and hold
64ba6e4cc3a0ccf8c8c6349fa75b937ca9bad9a6Michael Graff * harmless JPNIC from and against any and all judgements damages,
64ba6e4cc3a0ccf8c8c6349fa75b937ca9bad9a6Michael Graff * expenses, settlement liabilities, cost and other liabilities of any
28ed3013196c373745dbde87b75a490148dab840Bob Halley * kind as a result of use and redistribution of this Software or any
28ed3013196c373745dbde87b75a490148dab840Bob Halley * claim, suite, action, litigation or proceeding by any third party
28ed3013196c373745dbde87b75a490148dab840Bob Halley * arising out of or relates to this License Terms and Conditions.
28ed3013196c373745dbde87b75a490148dab840Bob Halley *
28ed3013196c373745dbde87b75a490148dab840Bob Halley * 7. Governing Law, Jurisdiction and Venue
c810fcbf6c7d628e71aaaefafeccc74a3a443ca2Michael Graff * This License Terms and Conditions shall be governed by and and
c810fcbf6c7d628e71aaaefafeccc74a3a443ca2Michael Graff * construed in accordance with the law of Japan. Any person or entities
c810fcbf6c7d628e71aaaefafeccc74a3a443ca2Michael Graff * using and/or redistributing this Software under this License Terms and
c810fcbf6c7d628e71aaaefafeccc74a3a443ca2Michael Graff * Conditions hereby agrees and consent to the personal and exclusive
c810fcbf6c7d628e71aaaefafeccc74a3a443ca2Michael Graff * jurisdiction and venue of Tokyo District Court of Japan.
64ba6e4cc3a0ccf8c8c6349fa75b937ca9bad9a6Michael Graff */
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#ifndef lint
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleystatic char *rcsid = "$Id: os2main.c,v 1.12 2000/07/04 03:52:28 ishisone Exp $";
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#endif
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#ifdef OS2
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#include <stdio.h>
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#include <stdlib.h>
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#include <string.h>
4affa94a03c9f4e5839fcf4d65ffbad3e9572234Bob Halley#include <signal.h>
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley#include "dnsproxy.h" /* Common definitions for mDNS proxy */
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley/*
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley * signal handler to catch signal to terminate server
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley */
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleystatic void handler(int signo)
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley{
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley server_stop() ;
a2171e092382f8f8a72b1f73436ddf93918c7719Bob Halley signal(signo, SIG_DFL) ;
61ca07caec2c7d58e1da52055c1aa1e1fb8c67d9Bob Halley}
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley/*
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley * main - entry of os2 version
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley */
7c0876aa42e6abaa8779bcb83962ccf20a9f4da3Bob Halley
7c0876aa42e6abaa8779bcb83962ccf20a9f4da3Bob Halleyint main(int ac, char *av[])
7c0876aa42e6abaa8779bcb83962ccf20a9f4da3Bob Halley{
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley if (config_load(ac, av) != TRUE) {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley printf("cannot load configurations\n") ;
28ed3013196c373745dbde87b75a490148dab840Bob Halley return 1 ;
28ed3013196c373745dbde87b75a490148dab840Bob Halley }
28ed3013196c373745dbde87b75a490148dab840Bob Halley log_configure(ac, av) ;
28ed3013196c373745dbde87b75a490148dab840Bob Halley
7c0876aa42e6abaa8779bcb83962ccf20a9f4da3Bob Halley if (server_init(ac, av) != TRUE) {
7c0876aa42e6abaa8779bcb83962ccf20a9f4da3Bob Halley printf("cannot initialize server\n") ;
7c0876aa42e6abaa8779bcb83962ccf20a9f4da3Bob Halley log_terminate() ;
28ed3013196c373745dbde87b75a490148dab840Bob Halley return 1 ;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley }
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
e10232e34adad7b089e04292748f47d68875f987Bob Halley signal(SIGINT, handler) ;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley signal(SIGKILL, handler) ;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley signal(SIGTERM, handler) ;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley signal(SIGBREAK, handler) ;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#ifdef DEBUG
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley printf("Service Started\n") ;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#endif
9fbc1afb8b08432e3a1adda1f41d5575620e9785Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley server_loop() ;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#ifdef DEBUG
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley printf("Service Termiating...\n") ;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#endif
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley server_done() ;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley log_terminate() ;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#ifdef DEBUG
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley printf("Service Terminated\n") ;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#endif
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley return 0 ;
690a68b8112039e633e26f9216c0d463751e011aMichael Graff}
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
#endif /* OS2 */