aboutsummaryrefslogtreecommitdiffstats
path: root/asterisk.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>1999-11-15 04:57:28 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>1999-11-15 04:57:28 +0000
commit4d46eab32cac8254e44dce0bb0846d6b24c9f803 (patch)
tree7a13d1fe18cc2d9af1604118f685931a986a75c0 /asterisk.c
parent9e9d86bacf3c1da43f2e85e3576f520a75bdbe39 (diff)
Version 0.1.0 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@21 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'asterisk.c')
-rwxr-xr-xasterisk.c94
1 files changed, 94 insertions, 0 deletions
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 <markster@linux-support.net>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <asterisk/logger.h>
+#include <asterisk/options.h>
+#include <stdio.h>
+#include <signal.h>
+#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 <markster@linux-support.net>\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;
+}