summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/Makefile.am2
-rw-r--r--src/fileserv.85
-rw-r--r--src/fileserv.c57
3 files changed, 44 insertions, 20 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index d871c86..e943d6c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-bin_PROGRAMS=fileserv
+sbin_PROGRAMS=fileserv
fileserv_SOURCES=fileserv.c runas.c fileserv.h logger.c pidfile.c\
wordsplit.c wordsplit.h catfile.c config.c idx.c defidx.h\
mem.c remoteip.c icon.c dirls.c dirls.h lang.c httperr.c
diff --git a/src/fileserv.8 b/src/fileserv.8
index a0204a3..11129f0 100644
--- a/src/fileserv.8
+++ b/src/fileserv.8
@@ -13,7 +13,7 @@
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with fileserv. If not, see <http://www.gnu.org/licenses/>.
-.TH FILESERV 8 "April 20, 2018" "FILESERV" "User Commands"
+.TH FILESERV 8 "April 21, 2018" "FILESERV" "User Commands"
.SH NAME
fileserv \- simple http server for static files
.SH SYNOPSIS
@@ -84,6 +84,9 @@ This option overrides the \fBuser\fR configuration setting.
.TP
.B \-v
Increase verbosity level. Multiple options accumulate.
+.TP
+.B \-V
+Show program version, license and copyright information.
.SH CONFIGURATION FILE
The server reads most of its settings from the configuration file
\fB/etc/fileserv.conf\fR (the default location can be overridden using
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;
@@ -43,7 +43,40 @@ char *tmpdir;
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)
@@ -84,22 +117,7 @@ errno_to_http_code(int ec)
return MHD_HTTP_FORBIDDEN;
}
}
-
-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.