X-Git-Url: http://git.arpa2.org/?a=blobdiff_plain;f=src%2Fconfig.c;h=ae281cb06956469c64d8ca373cd82cbc86bda81e;hb=2dc9dd49506580e9b99e43b4e7941a336618db5a;hp=ad17e3fbe63a3a01e97eae92a3c0217fbc134d2c;hpb=b8983f7664a279dc83a581265f7bbbc8ced758e1;p=krsd diff --git a/src/config.c b/src/config.c index ad17e3f..ae281cb 100644 --- a/src/config.c +++ b/src/config.c @@ -28,7 +28,9 @@ static void print_help(const char *progname) { " future output will be lost.\n" " --dir= - Name of the directory relative to the user's\n" " home directory to serve data from.\n" - " Defaults to: storage\n" + " Defaults to: remotestorage\n" + " --static= - Directory from which to serve static files.\n" + " Defaults to: /var/www/krsd\n" " --pid-file= - Write PID to given file.\n" " --stop - Stop a running rs-serve process. The process\n" " is identified by the PID file specified via\n" @@ -71,6 +73,8 @@ FILE *rs_pid_file = NULL; char *rs_pid_file_path = NULL; char *rs_home_serve_root = NULL; int rs_home_serve_root_len = 0; +char *rs_static_dir = NULL; +int rs_static_dir_len = 0; int rs_stop_other = 0; char *rs_auth_uri = NULL; int rs_auth_uri_len = 0; @@ -95,6 +99,7 @@ static struct option long_options[] = { { "detach", no_argument, 0, 'd' }, { "help", no_argument, 0, 'h' }, { "version", no_argument, 0, 'v' }, + { "static", required_argument, 0, 0 }, #if 0 { "auth-uri", required_argument, 0, 0 }, #endif @@ -186,6 +191,14 @@ void init_config(int argc, char **argv) { rs_home_serve_root[--len] = 0; } rs_home_serve_root_len = len; + } else if(strcmp(arg_name, "static") == 0) { // --static= + rs_static_dir = optarg; + int len = strlen(rs_static_dir); + if(rs_static_dir[len - 1] == '/') { + // strip trailing slash. + rs_static_dir[--len] = 0; + } + rs_static_dir = len; #if 0 } else if(strcmp(arg_name, "auth-uri") == 0) { // --auth-uri= rs_auth_uri = optarg; @@ -209,8 +222,13 @@ void init_config(int argc, char **argv) { } if(rs_home_serve_root == NULL) { - rs_home_serve_root = "storage"; - rs_home_serve_root_len = 7; + rs_home_serve_root = "remotestorage"; + rs_home_serve_root_len = 13; + } + + if(rs_static_dir == NULL) { + rs_static_dir = "/var/www/krsd"; + rs_static_dir_len = 13; } if(rs_stop_other) {