summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-16 21:35:16 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-16 21:35:16 +0100
commit61a369b85e51e0d54e1651e4ff8c11fe4815a0c0 (patch)
tree37273e4881e917b7402b66d563acc2f1359b7a08 /blabouncer.c
parent968cee422ab1d61b4234127892d75f0497d8d8c2 (diff)
Move default configuration file location to $HOME/.blabouncer/ and create a default file automatically if it doesn't exist.
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/blabouncer.c b/blabouncer.c
index 59cf8c1..8ed8d72 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -1375,7 +1375,14 @@ int main(int argc, char *argv[]) {
exit(1);
} else {
// If none provided, set to default
- strcpy(settings.conffile, "blabouncer.conf");
+ snprintf(settings.conffile, PATH_MAX, "%s/.blabouncer/blabouncer.conf", getenv("HOME"));
+ // Since this is the default, it might not exist yet, so let's check...
+ struct stat st = {0};
+ if (stat(settings.conffile, &st) == -1) {
+ // ...it doesn't exist, so let's create it
+ printf("Creating default configuration file '%s'.\n", settings.conffile);
+ createconfigfile(settings.conffile);
+ }
}
printf("Using configuration file '%s'.\n", settings.conffile);