[hackers] [quark] Change target prefix mapping argument order || Laslo Hunhold
commit 065394cb64395ed9a6e7cc57e2519ee8f754ce3e
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Sun Feb 24 00:40:46 2019 +0100
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Sun Feb 24 00:53:03 2019 +0100
Change target prefix mapping argument order
Put the chost-specification at the end and make it optional. This makes
more sense than having to give an arbitrary useless name in case you
weren't using virtual hosts in the first place.
While at it, clear up the wording in the manpage.
Signed-off-by: Laslo Hunhold <dev_AT_frign.de>
diff --git a/http.c b/http.c
index 673e6eb..efc4136 100644
--- a/http.c
+++ b/http.c
_AT_@ -394,8 +394,10 @@ http_send_response(int fd, struct request *r)
for (i = 0; i < s.map_len; i++) {
len = strlen(s.map[i].from);
if (!strncmp(realtarget, s.map[i].from, len)) {
- /* match canonical host if vhosts are enabled */
- if (s.vhost && strcmp(s.map[i].chost, vhostmatch)) {
+ /* match canonical host if vhosts are enabled and
+ * the mapping specifies a canonical host */
+ if (s.vhost && s.map[i].chost &&
+ strcmp(s.map[i].chost, vhostmatch)) {
continue;
}
diff --git a/main.c b/main.c
index 9d193a5..46cf424 100644
--- a/main.c
+++ b/main.c
_AT_@ -155,10 +155,12 @@ main(int argc, char *argv[])
sizeof(struct map)))) {
die("reallocarray:");
}
- if (!(s.map[s.map_len - 1].chost = strtok(tok, " ")) ||
- !(s.map[s.map_len - 1].from = strtok(NULL, " ")) ||
- !(s.map[s.map_len - 1].to = strtok(NULL, " ")) ||
- strtok(NULL, "")) {
+ if (!(s.map[s.map_len - 1].from = strtok(tok, " ")) ||
+ !(s.map[s.map_len - 1].to = strtok(NULL, " "))) {
+ usage();
+ }
+ s.map[s.map_len - 1].chost = strtok(NULL, " ");
+ if (strtok(NULL, "")) {
usage();
}
break;
diff --git a/quark.1 b/quark.1
index d9a76d8..67d120a 100644
--- a/quark.1
+++ b/quark.1
_AT_@ -1,4 +1,4 @@
-.Dd 2019-02-18
+.Dd 2019-02-24
.Dt QUARK 1
.Os suckless.org
.Sh NAME
_AT_@ -57,16 +57,15 @@ Enable directory listing.
Add the target prefix mapping rule specified by
.Ar map ,
which has the form
-.Qq Pa chost from to ,
+.Qq Pa from to [chost] ,
where each element is separated with whitespace.
.Pp
The prefix
.Pa from
-of all matching targets, especially only of those requests for the canonical
-virtual host
-.Pa chost
-when virtual hosts are specified, is then replaced with
-.Pa to .
+of all matching targets is replaced with
+.Pa to ,
+optionally limited to the canonical virtual host
+.Pa chost .
If no virtual hosts are given,
.Pa chost
is ignored.
Received on Sun Feb 24 2019 - 00:53:32 CET
This archive was generated by hypermail 2.3.0
: Sun Feb 24 2019 - 01:00:26 CET