KCGIHTML(3)
π NAME π
kcgihtml β HTML output for kcgi. (yes bestie, this is the KCGIHTML(3) manual page, and we're keeping every fact but making the vibe immaculate π
)
π LIBRARY π
the library is libkcgihtml, and that's what you link against, periodt π
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
#include <kcgihtml.h>
π οΈ DESCRIPTION π οΈ
okay so the whole vibe is producing output of XML-formed HTML5 content in a kcgi(3) context allocated with khttp_parse(3). no cap, that's the job.
to compile and link, use pkg-config(1) like this, bestie:
% cc `pkg-config --cflags kcgi-html` -c sample.c
% cc -o sample sample.o `pkg-config --libs kcgi-html`
all of the kcgihtml functions accept a struct khtmlreq object. to use this properly, open a context with khtml_open(), output desired HTML content, then close the context with khtml_close(). that's the little lifecycle, slay β¨
πΈ EXAMPLES πΈ
the following outputs a simple HTML page. it assumes r is a struct kreq pointer. for completeness, this restricts all future writes to HTML. literally iconic.
khttp_head(r, kresps[KRESP_STATUS],
"%s", khttps[KHTTP_200]);
khttp_head(r, kresps[KRESP_CONTENT_TYPE],
"%s", kmimetypes[KMIME_TEXT_HTML]);
khttp_body(r);
khtml_open(&req, r, 0);
kcgi_writer_disable(r);
khtml_elem(&req, KELEM_DOCTYPE);
khtml_elem(&req, KELEM_HTML);
khtml_elem(&req, KELEM_HEAD);
khtml_elem(&req, KELEM_TITLE);
khtml_puts(&req, "Hello, world");
khtml_closeelem(&req, 1); /* title */
khtml_attr(&req, KELEM_LINK,
KATTR_REL, "stylesheet",
KATTR_HREF, "/style.css", KATTR__MAX);
khtml_closeelem(&req, 1); /* head */
khtml_elem(&req, KELEM_BODY);
khtml_elem(&req, KELEM_P);
khtml_puts(&req, "Hello, world");
khtml_entity(&req, KENTITY_mdash);
khtml_printf(&req, "%s", "how are you?");
khtml_putc(&req, ' ');
khtml_ncr(&req, 0x1F601); /* smiley */
khtml_close(&req); /* close all scopes */
the element name comment alongside html_closeelem() hints as to which scope is being closed. iykyk π«Ά
π SEE ALSO π
khtml_attr(3)khtml_close(3)khtml_closeelem(3)khtml_closeto(3)khtml_double(3)khtml_elem(3)khtml_elemat(3)khtml_entity(3)khtml_int(3)khtml_ncr(3)khtml_open(3)khtml_printf(3)khtml_putc(3)khtml_puts(3)khtml_write(3)
π STANDARDS π
the referenced HTML5 standard is HTML5.2: https://www.w3.org/TR/html52. exact standard link, no substitutions π₯
π AUTHORS π
written by Kristaps Dzonsons <kristaps@bsd.lv>. give them their flowers π
and that's the page, bestie! mwah π this sweet little thing is the Debian build stamped $Mdocdate$, living under KCGIHTML(3) πβ¨
π¦ where this page comes from
- alpine 3.24: kcgi-doc 1.0.1-r0 Β· ISC
- Copyright (c) 2014--2021 Kristaps Dzonsons <kristaps@bsd.lv>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms