diff options
author | Luke Bratch <luke@bratch.co.uk> | 2019-06-01 19:22:13 +0100 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2019-06-01 19:22:13 +0100 |
commit | d38794635a763174d62790cf350ee5665737c6ef (patch) | |
tree | 77068c5eca225e658baea54ff2a833b05f7c9ece /blabouncer.c | |
parent | c3f421e4046faf8b5f39cd1ad36bc4869405fcc9 (diff) |
Use errno to handle getconfint() failing.
Diffstat (limited to 'blabouncer.c')
-rw-r--r-- | blabouncer.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/blabouncer.c b/blabouncer.c index 2410625..0347ec7 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -38,6 +38,7 @@ #define DEBUG_CRIT 0 #define DEBUG_SOME 1 #define DEBUG_FULL 2 +#define ECONFINT 1 // errno value if getconfint() failed #define STDIN 0 // stdin is fd 0 #define SIGINT 2 // SIGINT is signal 2 @@ -2688,6 +2689,11 @@ int main(int argc, char *argv[]) { // How many seconds of replay log should automatically be replayed - TODO - Can we do error checking on this? settings.replayseconds = getconfint("replayseconds", settings.conffile); + if (errno == ECONFINT) { + printf("main(): error getting 'replayseconds' from configuration file.\n"); + exit(1); + } + // What port should the bouncer listen on if (!getconfstr("clientport", settings.conffile, settings.clientport)) { printf("main(): error getting 'clientport' from configuration file.\n"); @@ -2752,9 +2758,17 @@ int main(int argc, char *argv[]) { // Should the bouncer use TLS for the IRC server? settings.servertls = getconfint("servertls", settings.conffile); + if (errno == ECONFINT) { + printf("main(): error getting 'servertls' from configuration file.\n"); + exit(1); + } // Should the bouncer use TLS for clients? settings.clienttls = getconfint("clienttls", settings.conffile); + if (errno == ECONFINT) { + printf("main(): error getting 'clienttls' from configuration file.\n"); + exit(1); + } // If so, load the certificates if (settings.clienttls) { @@ -2790,15 +2804,31 @@ int main(int argc, char *argv[]) { // Is logging enabled? settings.logging = getconfint("logging", settings.conffile); + if (errno == ECONFINT) { + printf("main(): error getting 'logging' from configuration file.\n"); + exit(1); + } // Is replay logging enabled? settings.replaylogging = getconfint("replaylogging", settings.conffile); + if (errno == ECONFINT) { + printf("main(): error getting 'replaylogging' from configuration file.\n"); + exit(1); + } // How many debug logs should we keep? settings.debugkeep = getconfint("debugkeep", settings.conffile); + if (errno == ECONFINT) { + printf("main(): error getting 'debugkeep' from configuration file.\n"); + exit(1); + } // Is debugging enabled? debug = getconfint("debug", settings.conffile); + if (errno == ECONFINT) { + printf("main(): error getting 'debug' from configuration file.\n"); + exit(1); + } if (!snprintf(debugpath, PATH_MAX, "%s/debug/debug.txt", settings.basedir)) { fprintf(stderr, "Error while preparing debug path location!\n"); exit(1); |