From: Gunnar Beutner Date: Thu, 25 Jul 2013 16:47:15 +0000 (+0200) Subject: Implement --help parameter. X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/commitdiff_plain/e29554df03ce86e29787dc9d9e059ae5c526f457?hp=cccb8a767c727a361769b5207e0c5c50c50b8787 Implement --help parameter. --- diff --git a/core/config.c b/core/config.c index 2a721056..ba4099c8 100644 --- a/core/config.c +++ b/core/config.c @@ -80,7 +80,7 @@ void initconfig(char *filename) { array_init((§ions),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); } diff --git a/core/main.c b/core/main.c index 7b4c33fb..3f4ad310 100644 --- a/core/main.c +++ b/core/main.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -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);