diff options
author | Luke Bratch <luke@bratch.co.uk> | 2019-09-14 17:57:07 +0100 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2019-09-14 17:57:07 +0100 |
commit | e1f41810ac85a0d210062ed33f43938dc4b03be4 (patch) | |
tree | 24e100886b063dfe8aa49d6881070b9e238296c4 /blabouncer.c | |
parent | e546de81cbecac2b02d29a02d6c6fd7d0785d739 (diff) |
Implement arrays in the configuration file and start using them to allow for multiple connect commands.
Diffstat (limited to 'blabouncer.c')
-rw-r--r-- | blabouncer.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/blabouncer.c b/blabouncer.c index d94a165..e6a56c1 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -1025,9 +1025,21 @@ int main(int argc, char *argv[]) { settings.ircserverpassword[0] = '\0'; } - // What is the connect command, if any? - if (!getconfstr("connectcommand", settings.conffile, settings.connectcommand)) { - settings.connectcommand[0] = '\0'; + // What are the connect commands, if any? + int ret = getconfarr("connectcommands", settings.conffile, settings.connectcommands); + if (!ret) { + for (int i = 0; i < MAXCONFARR; i++) { + settings.connectcommands[i][0] = '\0'; + } + } else if (ret == -1) { + // Remove any newlines from the middle of the string so error printing works nicely + for (size_t i = 0; i < strlen(settings.connectcommands[0]) - 1; i++) { + if (settings.connectcommands[0][i] == '\n') { + settings.connectcommands[0][i] = ' '; + } + } + printf("main(): error getting 'commandcommands' from configuration file: %s", settings.connectcommands[0]); + exit(1); } // Is the base directory set? If not, use the default. |