NAME
kcgihtml —
    HTML output for kcgi
LIBRARY
library “libkcgihtml”
SYNOPSIS
#include
    <sys/types.h>
  
  #include <stdarg.h>
  
  #include <stdint.h>
  
  #include <kcgi.h>
  
  #include <kcgihtml.h>
DESCRIPTION
Produce output of XML-formed HTML5 content in a kcgi(3) context allocated with khttp_parse(3).
To compile and link, use pkg-config(1) as follows:
% 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().
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.
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.
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.
AUTHORS
Written by Kristaps Dzonsons <kristaps@bsd.lv>.