]> jfr.im git - irc/quakenet/newserv.git/blobdiff - core/main.c
Implement --help parameter.
[irc/quakenet/newserv.git] / core / main.c
index a2dbdd7afa8924fd2874b41e12780afa6ffebf55..3f4ad31064f37ec6f5138b6bf7956f921c6e9520 100644 (file)
@@ -9,12 +9,14 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 #include <time.h>
 #include <sys/time.h>
 #include <signal.h>
 
 void initseed();
 void init_logfile();
+void fini_logfile();
 void siginthandler(int sig);
 void sigusr1handler(int sig);
 void sigsegvhandler(int sig);
@@ -27,6 +29,8 @@ static int newserv_sigint_pending, newserv_sigusr1_pending, newserv_sighup_pendi
 static void (*oldsegv)(int);
 
 int main(int argc, char **argv) {
+  char *config = "newserv.conf";
+
   initseed();
   inithooks();
   inithandlers();
@@ -37,11 +41,19 @@ int main(int argc, char **argv) {
   initsstring();
   
   if (argc>1) {
-    initconfig(argv[1]);
-  } else {  
-    initconfig("newserv.conf");
+    if (strcmp(argv[1], "--help")==0) {
+      printf("Syntax: %s [config]\n", argv[0]);
+      puts("");
+      printf("Default configuration file unless specified: %s\n", config);
+
+      return 0;
+    }
+
+    config = argv[1];
   }
 
+  initconfig(config);
+
   /* Loading the modules will bring in the bulk of the code */
   initmodules();
   signal(SIGINT, siginthandler);
@@ -70,6 +82,8 @@ int main(int argc, char **argv) {
   finihandlers();
 
   nsexit();
+
+  return 0;
 }
 
 void handlesignals(void) {