]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Implement --help parameter.
authorGunnar Beutner <redacted>
Thu, 25 Jul 2013 16:47:15 +0000 (18:47 +0200)
committerGunnar Beutner <redacted>
Thu, 25 Jul 2013 16:47:15 +0000 (18:47 +0200)
core/config.c
core/main.c

index 2a721056e232349b069f97a518475974a876e193..ba4099c8a6c4195e67e355e470c09dc186b85097 100644 (file)
@@ -80,7 +80,7 @@ void initconfig(char *filename) {
   array_init((&sections),sizeof(configsection));
   
   if ((fp=fopen(filename,"r"))==NULL) {
-    Error("core",ERR_STOP,"Couldn't load config file.");
+    Error("core",ERR_STOP,"Couldn't load config file '%s'.", filename);
     exit(1);
   }
   
index 7b4c33fb05eddc9fee0f9d188c45e93e415e3f54..3f4ad31064f37ec6f5138b6bf7956f921c6e9520 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 #include <time.h>
 #include <sys/time.h>
 #include <signal.h>
@@ -28,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();
@@ -38,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);