summaryrefslogtreecommitdiff
path: root/src/fileserv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fileserv.c')
-rw-r--r--src/fileserv.c55
1 files changed, 38 insertions, 17 deletions
diff --git a/src/fileserv.c b/src/fileserv.c
index fb9811d..58262c3 100644
--- a/src/fileserv.c
+++ b/src/fileserv.c
@@ -35,7 +35,7 @@
#endif
char const *progname;
-int verbose; /* reserved for future use */
+int verbose; /* increase diagnostic verbosity */
char *address = DEFAULT_ADDRESS;
char *forwarded_header = "X-Forwarded-For";
char *index_css;
@@ -44,6 +44,39 @@ char *user;
char *group;
char *mime_types_file;
+void
+usage(void)
+{
+ printf("usage: %s [OPTIONS] [HOST:]URL:DIR...\n", progname);
+ printf("Simple HTTP server.\n");
+ printf("OPTIONS are:\n\n");
+ printf(" -a [IP]:PORT listen on this IP and PORT\n");
+ printf(" -c FILE read configuration from FILE\n");
+ printf(" -f remain in the foreground\n");
+ printf(" -g GROUP run with this group privileges\n");
+ printf(" -h show this help summary\n");
+ printf(" -s don't start sentinel process\n");
+ printf(" -u USER run with this user privileges\n");
+ printf(" -v increase verbosity\n");
+ printf(" -V show program version\n");
+ printf("\n");
+}
+
+const char version_copyright[] = "Copyright (C) 2017-2018 Sergey Poznyakoff";
+const char gplv3[] = "\
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\
+This is free software: you are free to change and redistribute it.\n\
+There is NO WARRANTY, to the extent permitted by law.\
+";
+
+static void
+show_version(void)
+{
+ printf("%s\n", PACKAGE_STRING);
+ printf("%s\n", version_copyright);
+ printf("\n%s\n\n", gplv3);
+}
+
static void
fileserv_panic(void *cls, const char *file, unsigned int line,
const char *reason)
@@ -85,21 +118,6 @@ errno_to_http_code(int ec)
}
}
-void
-usage(void)
-{
- printf("usage: %s [OPTIONS] [HOST:]URL:DIR...\n", progname);
- printf("OPTIONS are:\n\n");
- printf(" -a [IP]:PORT listen on this IP and PORT\n");
- printf(" -c FILE read configuration from FILE\n");
- printf(" -f remain in the foreground\n");
- printf(" -g GROUP run with this group privileges\n");
- printf(" -h show this help summary\n");
- printf(" -s don't start sentinel process\n");
- printf(" -u USER run with this user privileges\n");
- printf(" -v increase verbosity\n");
-}
-
int
open_node(char const *node, char const *serv, struct sockaddr **saddr)
{
@@ -781,7 +799,7 @@ main(int argc, char **argv)
if (!tmpdir)
tmpdir = "/tmp";
- while ((c = getopt(argc, argv, "a:c:fg:hsu:v")) != EOF) {
+ while ((c = getopt(argc, argv, "a:c:fg:hsu:vV")) != EOF) {
switch (c) {
case 'a':
opt_address = optarg;
@@ -807,6 +825,9 @@ main(int argc, char **argv)
case 'v':
verbose++;
break;
+ case 'V':
+ show_version();
+ exit(0);
default:
exit(1);
}

Return to:

Send suggestions and report system problems to the System administrator.