3
.\" Copyright (c) 2014, 2017 Kristaps Dzonsons <kristaps@bsd.lv>
4
.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
6
.\" Permission to use, copy, modify, and distribute this software for any
7
.\" purpose with or without fee is hereby granted, provided that the above
8
.\" copyright notice and this permission notice appear in all copies.
10
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
.Nd URL formatting for kcgi
34
.Fa "enum kscheme scheme"
42
.Fa "enum kscheme scheme"
49
Format an absolute (full) URL.
52
is in some standards called the
55
.Dl Fa scheme Ns :// Ns Fa host : Ns Fa port Ns / Ns Fa path Ns ?key=val
56
.Dl Fa scheme Ns :// Ns Fa host : Ns Fa port Ns / Ns Fa path
57
.Dl Fa scheme : Ns Fa path
75
is also non-empty and not
79
is prepended with a mandatory slash.
83
is zero, it is omitted.
91
The variable arguments are arranged in pairs terminated by a single
93
The first of each pair is the query string key, the second is the value.
98
query string value is rendered as an empty string.
100
Only the query string pairs are URL-encoded, so the caller must make
101
sure that the characters in
107
The deprecated form of these functions,
109
should no longer be used.
111
Return newly-allocated strings that must be freed with
119
.Dl khttp_urlabs(KSCHEME_HTTPS, "foo.com", 80, "b", "c", "d", NULL);
122
.Li https://foo.com:80/b?c=d .
124
Setting the port to zero eliminates the port:
126
.Dl khttp_urlabs(KSCHEME_HTTPS, "foo.com", 0, "b", "c", "d", NULL);
129
.Li https://foo.com/b?c=d .
131
An empty path component ends with the domain (or query string).
133
.Dl khttp_urlabs(KSCHEME_HTTPS, "foo.com", 0, "", "c", "d", NULL);
136
.Li https://foo.com?c=d .
138
To use a host-less scheme, specify a
142
.Dl khttp_urlabs(KSCHEME_MAILTO, NULL, 0, "k@b.com", NULL);
148
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
150
These functions can currently be used to create semantically invalid
153
by omitting components required for the scheme.
154
Semantically-correct URLs are the responsibility of the caller.
155
This behaviour may be verified for correctness in later versions of the