KHTML_ENTITY(3)

πŸ“¦ version 1.0.1, in alpine 3.24

πŸ’– KHTML_ENTITY(3) β€” the khtml_entity glow-up πŸŽ€

okay bestie, so this one lives in the Library Functions Manual and it's from libkcgihtml β€” and no, you're not tripping, the function is literally called khttp_entity. yes the page is khtml_entity and the function is khttp_entity. that's just how it is. iykyk πŸ’…


✨ NAME ✨

khtml_entity β€” drop the content of a named character entity, for kcgihtml πŸ¦‹


🌸 LIBRARY 🌸

library β€œlibkcgihtml” πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
#include <kcgihtml.h>

enum kcgi_err
khttp_entity(struct kreq *req, enum entity v);

πŸ‘‘ DESCRIPTION πŸ‘‘

so what it does is: it writes a named character entity v into a context req that was already initialised with khtml_open(3). and it formats that value as "&#xNNNN;" β€” literally. that's the whole vibe check. ✨


πŸ’€ RETURN VALUES πŸ’€

it hands you back an enum kcgi_err that tells you the error state. so like, the mood ring of the call:

  • KCGI_OK β€” success, which is lowkey not an error at all 🫢
  • KCGI_ENOMEM β€” internal memory allocation failure. the malloc said no 😭
  • KCGI_HUP β€” the output connection has been terminated. for FastCGI connections, you should release the current connection with khttp_free(3) and reenter the parse loop. (yes, reenter. go back in. πŸ”)
  • KCGI_FORM β€” the connection is still expecting headers with khttp_head(3). this means khttp_body(3) didn't return with success, or it just wasn't invoked at all πŸ™ˆ. for FastCGI connections, release the current connection with khttp_free(3) and reenter the parse loop. same drill, bestie.
  • KCGI_SYSTEM β€” internal system error writing to the output stream. the write said nope πŸ’€

🌈 EXAMPLES 🌈

this one outputs a simple HTML page, main character energy. it assumes r is a struct kreq pointer. and for brevity it does no error checking whatsoever β€” iconic, reckless, we love it:

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);
khtml_elem(&req, KELEM_DOCTYPE);
khtml_elem(&req, KELEM_HTML);
khtml_elem(&req, KELEM_BODY);
khtml_elem(&req, KELEM_P);
khtml_puts(&req, "Hello");
khtml_ncr(&req, KENTITY_hellip); /* ... */
khtml_close(&req);

(that /* ... */ is the actual entity doing its thing, not me being mysterious 🧚)


πŸ¦‹ SEE ALSO πŸ¦‹


⭐ STANDARDS ⭐

the referenced HTML5 standard is HTML5.2: https://www.w3.org/TR/html52 β€” go read it if you're feeling studious, bestie πŸ“š


πŸ’œ AUTHORS πŸ’œ

written by Kristaps Dzonsons <kristaps@bsd.lv> πŸ’–


ngl, this page is giving "short and sweet and does exactly one thing". obsessed. periodt. πŸ’…

Debian Β· $Mdocdate$ Β· KHTML_ENTITY(3) β€” okay that's the whole page, love u, go write some HTML πŸŽ€πŸŒΈπŸ’–

πŸ“¦ 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