KCGIHTML(3)

πŸ“¦
version 1.0.1 Β· 2 versions
, in alpine 3.24

πŸ’– 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 πŸ‘€

🌈 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms