snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit 5b21c9546b40cc0c52d5f39273747c551926984c
parent e56e30f0c64f12ea12413aaf4229975543e1bdbf
Author: default <nobody@localhost>
Date:   Mon, 20 Jan 2025 10:40:43 +0100

Added support for the SNAC_BASEDIR environment variable.

If it's set, the basedir argument in command-line commands must not be given.

Diffstat:
Mmain.c | 29++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/main.c b/main.c @@ -96,19 +96,6 @@ int main(int argc, char *argv[]) return snac_init(basedir); } - if (strcmp(cmd, "upgrade") == 0) { /** **/ - int ret; - - /* upgrade */ - if ((basedir = GET_ARGV()) == NULL) - return usage(); - - if ((ret = srv_open(basedir, 1)) == 1) - srv_log(xs_dup("OK")); - - return ret; - } - if (strcmp(cmd, "markdown") == 0) { /** **/ /* undocumented, for testing only */ xs *c = xs_readall(stdin); @@ -118,8 +105,20 @@ int main(int argc, char *argv[]) return 0; } - if ((basedir = GET_ARGV()) == NULL) - return usage(); + if ((basedir = getenv("SNAC_BASEDIR")) == NULL) { + if ((basedir = GET_ARGV()) == NULL) + return usage(); + } + + if (strcmp(cmd, "upgrade") == 0) { /** **/ + int ret; + + /* upgrade */ + if ((ret = srv_open(basedir, 1)) == 1) + srv_log(xs_dup("OK")); + + return ret; + } if (!srv_open(basedir, 0)) { srv_log(xs_fmt("error opening data storage at %s", basedir));