diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-04-21 20:39:57 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-04-21 20:39:57 +0300 |
commit | 38e7700cc2472aa66591f255915bc85e5351cb7d (patch) | |
tree | f0ebeda6461526a7439e14711d18afecfb8933be | |
parent | 265d2886f8012e84860bbe66f299073ebefe7553 (diff) | |
download | fileserv-38e7700cc2472aa66591f255915bc85e5351cb7d.tar.gz fileserv-38e7700cc2472aa66591f255915bc85e5351cb7d.tar.bz2 |
Minor changes
* src/Makefile.am: Install fileserv to sbin.
* src/fileserv.8: Update.
* src/fileserv.c: New option -V
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/fileserv.8 | 5 | ||||
-rw-r--r-- | src/fileserv.c | 57 |
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 @@ | |||
1 | bin_PROGRAMS=fileserv | 1 | sbin_PROGRAMS=fileserv |
2 | fileserv_SOURCES=fileserv.c runas.c fileserv.h logger.c pidfile.c\ | 2 | fileserv_SOURCES=fileserv.c runas.c fileserv.h logger.c pidfile.c\ |
3 | wordsplit.c wordsplit.h catfile.c config.c idx.c defidx.h\ | 3 | wordsplit.c wordsplit.h catfile.c config.c idx.c defidx.h\ |
4 | mem.c remoteip.c icon.c dirls.c dirls.h lang.c httperr.c | 4 | 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 @@ | |||
13 | .\" | 13 | .\" |
14 | .\" You should have received a copy of the GNU General Public License | 14 | .\" You should have received a copy of the GNU General Public License |
15 | .\" along with fileserv. If not, see <http://www.gnu.org/licenses/>. | 15 | .\" along with fileserv. If not, see <http://www.gnu.org/licenses/>. |
16 | .TH FILESERV 8 "April 20, 2018" "FILESERV" "User Commands" | 16 | .TH FILESERV 8 "April 21, 2018" "FILESERV" "User Commands" |
17 | .SH NAME | 17 | .SH NAME |
18 | fileserv \- simple http server for static files | 18 | fileserv \- simple http server for static files |
19 | .SH SYNOPSIS | 19 | .SH SYNOPSIS |
@@ -84,6 +84,9 @@ This option overrides the \fBuser\fR configuration setting. | |||
84 | .TP | 84 | .TP |
85 | .B \-v | 85 | .B \-v |
86 | Increase verbosity level. Multiple options accumulate. | 86 | Increase verbosity level. Multiple options accumulate. |
87 | .TP | ||
88 | .B \-V | ||
89 | Show program version, license and copyright information. | ||
87 | .SH CONFIGURATION FILE | 90 | .SH CONFIGURATION FILE |
88 | The server reads most of its settings from the configuration file | 91 | The server reads most of its settings from the configuration file |
89 | \fB/etc/fileserv.conf\fR (the default location can be overridden using | 92 | \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 @@ | |||
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | char const *progname; | 37 | char const *progname; |
38 | int verbose; /* reserved for future use */ | 38 | int verbose; /* increase diagnostic verbosity */ |
39 | char *address = DEFAULT_ADDRESS; | 39 | char *address = DEFAULT_ADDRESS; |
40 | char *forwarded_header = "X-Forwarded-For"; | 40 | char *forwarded_header = "X-Forwarded-For"; |
41 | char *index_css; | 41 | char *index_css; |
@@ -43,7 +43,40 @@ char *tmpdir; | |||
43 | char *user; | 43 | char *user; |
44 | char *group; | 44 | char *group; |
45 | char *mime_types_file; | 45 | char *mime_types_file; |
46 | |||
47 | void | ||
48 | usage(void) | ||
49 | { | ||
50 | printf("usage: %s [OPTIONS] [HOST:]URL:DIR...\n", progname); | ||
51 | printf("Simple HTTP server.\n"); | ||
52 | printf("OPTIONS are:\n\n"); | ||
53 | printf(" -a [IP]:PORT listen on this IP and PORT\n"); | ||
54 | printf(" -c FILE read configuration from FILE\n"); | ||
55 | printf(" -f remain in the foreground\n"); | ||
56 | printf(" -g GROUP run with this group privileges\n"); | ||
57 | printf(" -h show this help summary\n"); | ||
58 | printf(" -s don't start sentinel process\n"); | ||
59 | printf(" -u USER run with this user privileges\n"); | ||
60 | printf(" -v increase verbosity\n"); | ||
61 | printf(" -V show program version\n"); | ||
62 | printf("\n"); | ||
63 | } | ||
46 | 64 | ||
65 | const char version_copyright[] = "Copyright (C) 2017-2018 Sergey Poznyakoff"; | ||
66 | const char gplv3[] = "\ | ||
67 | License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\ | ||
68 | This is free software: you are free to change and redistribute it.\n\ | ||
69 | There is NO WARRANTY, to the extent permitted by law.\ | ||
70 | "; | ||
71 | |||
72 | static void | ||
73 | show_version(void) | ||
74 | { | ||
75 | printf("%s\n", PACKAGE_STRING); | ||
76 | printf("%s\n", version_copyright); | ||
77 | printf("\n%s\n\n", gplv3); | ||
78 | } | ||
79 | |||
47 | static void | 80 | static void |
48 | fileserv_panic(void *cls, const char *file, unsigned int line, | 81 | fileserv_panic(void *cls, const char *file, unsigned int line, |
49 | const char *reason) | 82 | const char *reason) |
@@ -84,22 +117,7 @@ errno_to_http_code(int ec) | |||
84 | return MHD_HTTP_FORBIDDEN; | 117 | return MHD_HTTP_FORBIDDEN; |
85 | } | 118 | } |
86 | } | 119 | } |
87 | 120 | ||
88 | void | ||
89 | usage(void) | ||
90 | { | ||
91 | printf("usage: %s [OPTIONS] [HOST:]URL:DIR...\n", progname); | ||
92 | printf("OPTIONS are:\n\n"); | ||
93 | printf(" -a [IP]:PORT listen on this IP and PORT\n"); | ||
94 | printf(" -c FILE read configuration from FILE\n"); | ||
95 | printf(" -f remain in the foreground\n"); | ||
96 | printf(" -g GROUP run with this group privileges\n"); | ||
97 | printf(" -h show this help summary\n"); | ||
98 | printf(" -s don't start sentinel process\n"); | ||
99 | printf(" -u USER run with this user privileges\n"); | ||
100 | printf(" -v increase verbosity\n"); | ||
101 | } | ||
102 | |||
103 | int | 121 | int |
104 | open_node(char const *node, char const *serv, struct sockaddr **saddr) | 122 | open_node(char const *node, char const *serv, struct sockaddr **saddr) |
105 | { | 123 | { |
@@ -781,7 +799,7 @@ main(int argc, char **argv) | |||
781 | if (!tmpdir) | 799 | if (!tmpdir) |
782 | tmpdir = "/tmp"; | 800 | tmpdir = "/tmp"; |
783 | 801 | ||
784 | while ((c = getopt(argc, argv, "a:c:fg:hsu:v")) != EOF) { | 802 | while ((c = getopt(argc, argv, "a:c:fg:hsu:vV")) != EOF) { |
785 | switch (c) { | 803 | switch (c) { |
786 | case 'a': | 804 | case 'a': |
787 | opt_address = optarg; | 805 | opt_address = optarg; |
@@ -807,6 +825,9 @@ main(int argc, char **argv) | |||
807 | case 'v': | 825 | case 'v': |
808 | verbose++; | 826 | verbose++; |
809 | break; | 827 | break; |
828 | case 'V': | ||
829 | show_version(); | ||
830 | exit(0); | ||
810 | default: | 831 | default: |
811 | exit(1); | 832 | exit(1); |
812 | } | 833 | } |