/* * Copyright (c) 1997, 2001 Hellmuth Michaelis. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * *--------------------------------------------------------------------------- * * i4b daemon - main program entry * ------------------------------- * * $FreeBSD: src/usr.sbin/i4b/isdnd/main.c,v 1.8.2.5 2001/12/16 15:13:38 hm Exp $ * $DragonFly: src/usr.sbin/i4b/isdnd/main.c,v 1.3 2004/03/26 00:30:12 cpressey Exp $ * * last edit-date: [Tue Jun 5 17:06:20 2001] * *---------------------------------------------------------------------------*/ #include #include #ifdef I4B_EXTERNAL_MONITOR #include "monitor.h" #endif #define MAIN #include "isdnd.h" #undef MAIN #ifdef I4B_EXTERNAL_MONITOR #ifdef I4B_NOTCPIP_MONITOR /* monitor via local socket */ static void mloop(int sockfd); #else /* I4B_NOTCPIP_MONITOR */ /* monitor via local and tcp/ip socket */ static void mloop(int localsock, int remotesock); #endif /* I4B_NOTCPIP_MONITOR */ #else /* I4B_EXTERNAL_MONITOR */ /* no monitoring at all */ static void mloop(); #endif /* I4B_EXTERNAL_MONITOR */ #ifdef USE_CURSES static void kbdrdhdl(void); #endif static void isdnrdhdl(void); static void usage(void); #define MSG_BUF_SIZ 1024 /* message buffer size */ /*---------------------------------------------------------------------------* * usage display and exit *---------------------------------------------------------------------------*/ static void usage(void) { fprintf(stderr, "\n"); fprintf(stderr, "isdnd - i4b ISDN manager daemon, version %02d.%02d.%d, %s %s\n", VERSION, REL, STEP, __DATE__, __TIME__); #ifdef DEBUG fprintf(stderr, " usage: isdnd [-c file] [-d level] [-F] [-f [-r dev] [-t termtype]]\n"); #else fprintf(stderr, " usage: isdnd [-c file] [-F] [-f [-r dev] [-t termtype]]\n"); #endif fprintf(stderr, " [-l] [-L file] [-m] [-s facility] [-u time]\n"); fprintf(stderr, " -c configuration file name (def: %s)\n", CONFIG_FILE_DEF); #ifdef DEBUG fprintf(stderr, " -d set debug flag bits:\n"); fprintf(stderr, " general = 0x%04x, rates = 0x%04x, timing = 0x%04x\n", DL_MSG, DL_RATES, DL_TIME); fprintf(stderr, " state = 0x%04x, retry = 0x%04x, dial = 0x%04x\n", DL_STATE, DL_RCVRY, DL_DIAL); fprintf(stderr, " process = 0x%04x, kernio = 0x%04x, ctrlstat = 0x%04x\n", DL_PROC, DL_DRVR, DL_CNST); fprintf(stderr, " rc-file = 0x%04x, budget = 0x%04x, valid = 0x%04x\n", DL_RCCF, DL_BDGT, DL_VALID); fprintf(stderr, " -dn no debug output on fullscreen display\n"); #endif fprintf(stderr, " -f fullscreen status display\n"); fprintf(stderr, " -F do not become a daemon process\n"); fprintf(stderr, " -l use a logfile instead of syslog\n"); fprintf(stderr, " -L use file instead of %s for logging\n", LOG_FILE_DEF); fprintf(stderr, " -P pretty print real config to stdout and exit\n"); fprintf(stderr, " -r redirect output to other device (for -f)\n"); fprintf(stderr, " -s use facility instead of %d for syslog logging\n", LOG_LOCAL0 >> 3); fprintf(stderr, " -t terminal type of redirected screen (for -f)\n"); fprintf(stderr, " -u