From 4d46eab32cac8254e44dce0bb0846d6b24c9f803 Mon Sep 17 00:00:00 2001 From: markster Date: Mon, 15 Nov 1999 04:57:28 +0000 Subject: Version 0.1.0 from FTP git-svn-id: http://svn.digium.com/svn/asterisk/trunk@21 f38db490-d61c-443f-a65b-d21fe96a405b --- asterisk.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 asterisk.c (limited to 'asterisk.c') diff --git a/asterisk.c b/asterisk.c new file mode 100755 index 000000000..1bc7be174 --- /dev/null +++ b/asterisk.c @@ -0,0 +1,94 @@ +/* + * Asterisk -- A telephony toolkit for Linux. + * + * Top level source file for asterisk + * + * Copyright (C) 1999, Adtran Inc. and Linux Support Services, LLC + * + * Mark Spencer + * + * This program is free software, distributed under the terms of + * the GNU General Public License + */ + +#include +#include +#include +#include +#include +#include +#include "asterisk.h" + +int option_verbose=0; +int option_debug=0; +int option_nofork=0; +int option_quiet=0; + +static void urg_handler(int num) +{ + /* Called by soft_hangup to interrupt the select, read, or other + system call. We don't actually need to do anything though. */ + if (option_debug) + ast_log(LOG_DEBUG, "Urgent handler\n"); + return; +} + +static void quit_handler(int num) +{ + /* Called on exit */ + if (option_verbose) + ast_verbose("Asterisk ending (%d).\n", num); + else if (option_debug) + ast_log(LOG_DEBUG, "Asterisk ending (%d).\n", num); + exit(0); +} + +int main(int argc, char *argv[]) +{ + char c; + /* Check if we're root */ + if (geteuid()) { + ast_log(LOG_ERROR, "Must be run as root\n"); + exit(1); + } + /* Check for options */ + while((c=getopt(argc, argv, "dvq")) != EOF) { + switch(c) { + case 'd': + option_debug++; + option_nofork++; + option_verbose++; + break; + case 'v': + option_verbose++; + break; + case 'q': + option_quiet++; + break; + case '?': + exit(1); + } + } + /* Print a welcome message if desired */ + if (option_verbose) { + ast_verbose( "Asterisk, Copyright (C) 1999 Adtran, Inc. and Linux Support Services, LLC\n"); + ast_verbose( "Written by Mark Spencer \n"); + ast_verbose( "=========================================================================\n"); + } + signal(SIGURG, urg_handler); + signal(SIGINT, quit_handler); + signal(SIGTERM, quit_handler); + signal(SIGHUP, quit_handler); + if (init_logger()) + exit(1); + if (load_pbx()) + exit(1); + if (load_modules()) + exit(1); + /* We might have the option of showing a console, but for now just + do nothing... */ + if (option_verbose) + ast_verbose( "Asterisk Ready.\n"); + select(0,NULL,NULL,NULL,NULL); + return 0; +} -- cgit v1.2.3