mirror of
https://github.com/bdnugget/kcgi.git
synced 2026-11-07 05:47:27 +00:00
Improve the documentation as suggested by Jan Schreiber--thanks!
This commit is contained in:
1 parent
fdebab25fa
commit
8d8ad02a75
6 files changed
+45
-10
No files matched your search
@@ -19,7 +19,8 @@ VERSIONS = version_0_4_2.xml \
|
||||
version_0_5_4.xml \
|
||||
version_0_5_5.xml \
|
||||
version_0_5_6.xml \
|
||||
version_0_5_7.xml
|
||||
version_0_5_7.xml \
|
||||
version_0_5_8.xml
|
||||
MANDIR = $(PREFIX)/man/man3
|
||||
LIBDIR = $(PREFIX)/lib
|
||||
INCLUDEDIR = $(PREFIX)/include
|
||||
|
||||
@@ -42,6 +42,10 @@ figure { margin: 0;
|
||||
figcaption { padding: 0 1% 0.5ex 1%; }
|
||||
figcaption span { font-weight: bolder; }
|
||||
#intro { padding: 0 2%; }
|
||||
#intro figure { width: 100%;
|
||||
text-align: center; }
|
||||
#intro img { max-width: 480px;
|
||||
width: 100%; }
|
||||
#sample { padding: 1ex 1%; }
|
||||
#sample nav i { font-size: 16pt; }
|
||||
#sample nav { padding: 0.5ex 1em; }
|
||||
|
||||
@@ -99,10 +99,18 @@ int main(void) {
|
||||
* Parse the HTTP environment.
|
||||
* We only know a single page, "index", which is also
|
||||
* the default page if none is supplied.
|
||||
* (We don't validate any input fields.)
|
||||
*/
|
||||
if (KCGI_OK != <a href="khttp_parse.3.html">khttp_parse</a>(&r, NULL, 0, &page, 1, 0))
|
||||
return(EXIT_FAILURE);
|
||||
|
||||
/*
|
||||
* Ordinarily, here I'd switch on the method (OPTIONS, etc.,
|
||||
* defined in the <q>method</q> variable) then switch on which
|
||||
* page was requested (<q>page</q> variable).
|
||||
* But for the same of example, just output a response.
|
||||
*/
|
||||
|
||||
/* Emit the HTTP status 200 header: everything's ok. */
|
||||
<a href="khttp_head.3.html">khttp_head</a>(&r, kresps[KRESP_STATUS], "%s", khttps[KHTTP_200]);
|
||||
/* Echo our content-type, defaulting to HTML if none was specified. */
|
||||
|
||||
+11
-1
@@ -84,12 +84,22 @@ and
|
||||
For example,
|
||||
.Bd -literal
|
||||
% cc -I/usr/local/include -c -o sample.o sample.c
|
||||
% cc -L/usr/local/lib -o sample -lkcgi -lz
|
||||
% cc -L/usr/local/lib -o sample sample.o -lkcgi -lz
|
||||
.Ed
|
||||
.Pp
|
||||
If the library will be statically linked (e.g., for running within a
|
||||
.Xr chroot 2 ) ,
|
||||
and assuming you'll use the
|
||||
.Xr kcgihtml 3
|
||||
library, link as follows:
|
||||
.Bd -literal
|
||||
% cc -o sample -static sample.o -lkcgihtml -lkcgi -lz
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr kcgi 3 ,
|
||||
.Xr kcgihtml 3 ,
|
||||
.Xr kcgijson 3 ,
|
||||
.Xr kcgixml 3 ,
|
||||
.Xr khttp_body 3 ,
|
||||
.Xr khttp_free 3 ,
|
||||
.Xr khttp_head 3 ,
|
||||
|
||||
@@ -181,18 +181,16 @@ sendindex(struct kreq *req)
|
||||
struct khtmlreq r;
|
||||
const char *cp;
|
||||
|
||||
memset(&r, 0, sizeof(struct khtmlreq));
|
||||
r.req = req;
|
||||
|
||||
(void)kasprintf(&page, "%s/%s",
|
||||
req->pname, pages[PAGE_INDEX]);
|
||||
resp_open(req, KHTTP_200);
|
||||
khtml_open(&r, req);
|
||||
khtml_elem(&r, KELEM_DOCTYPE);
|
||||
khtml_elem(&r, KELEM_HTML);
|
||||
khtml_elem(&r, KELEM_HEAD);
|
||||
khtml_elem(&r, KELEM_TITLE);
|
||||
khtml_puts(&r, "Welcome!");
|
||||
khtml_close(&r, 2);
|
||||
khtml_closeelem(&r, 2);
|
||||
khtml_elem(&r, KELEM_BODY);
|
||||
khtml_puts(&r, "Welcome!");
|
||||
khtml_attr(&r, KELEM_FORM,
|
||||
@@ -203,7 +201,7 @@ sendindex(struct kreq *req)
|
||||
khtml_elem(&r, KELEM_FIELDSET);
|
||||
khtml_elem(&r, KELEM_LEGEND);
|
||||
khtml_puts(&r, "Post (multipart)");
|
||||
khtml_close(&r, 1);
|
||||
khtml_closeelem(&r, 1);
|
||||
khtml_elem(&r, KELEM_P);
|
||||
cp = NULL == req->fieldmap[KEY_INTEGER] ?
|
||||
"" : req->fieldmap[KEY_INTEGER]->val;
|
||||
@@ -211,7 +209,7 @@ sendindex(struct kreq *req)
|
||||
KATTR_TYPE, "number",
|
||||
KATTR_NAME, keys[KEY_INTEGER].name,
|
||||
KATTR_VALUE, cp, KATTR__MAX);
|
||||
khtml_close(&r, 1);
|
||||
khtml_closeelem(&r, 1);
|
||||
khtml_elem(&r, KELEM_P);
|
||||
khtml_attr(&r, KELEM_INPUT,
|
||||
KATTR_TYPE, "file",
|
||||
@@ -229,12 +227,13 @@ sendindex(struct kreq *req)
|
||||
khtml_puts(&r, req->fieldmap[KEY_FILE]->ctype);
|
||||
}
|
||||
}
|
||||
khtml_close(&r, 1);
|
||||
khtml_closeelem(&r, 1);
|
||||
khtml_elem(&r, KELEM_P);
|
||||
khtml_attr(&r, KELEM_INPUT,
|
||||
KATTR_TYPE, "submit",
|
||||
KATTR__MAX);
|
||||
khtml_close(&r, 0);
|
||||
khtml_closeelem(&r, 0);
|
||||
khtml_close(&r);
|
||||
free(page);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<article data-sblg-article="1" data-sblg-tags="version">
|
||||
<header>
|
||||
<h1>0.5.8</h1>
|
||||
<address>Kristaps Dzonsons</address>
|
||||
<time datetime="2015-05-11">2015-05-11</time>
|
||||
</header>
|
||||
<aside>
|
||||
Update the included sample file and correct the documentation regarding its compilation.
|
||||
Fix noted by Jan Schreiber — thanks!
|
||||
While doing so, add some documentation bits to the manpages.
|
||||
No functional changes.
|
||||
</aside>
|
||||
</article>
|
||||
Reference in new issue
Block a user