KHTML_PRINTF(3)

πŸ“¦ version 1.0.1, in alpine 3.24

πŸ’… KHTML_PRINTF(3) β€” the manual page, bestie edition πŸ’…

okay so real talk, this is KHTML_PRINTF(3) straight out of the Library Functions Manual, and it's literally the glow-up your HTML output needed. sit down, grab a strawberry drink πŸ“, and let's get into it.

✨ NAME ✨

khtml_printf β€” put variable content for kcgihtml

like, it prints stuff. with variables. into your HTML. that's the whole vibe πŸ’–

πŸ“š LIBRARY πŸ“š

library β€œlibkcgihtml”

πŸ› οΈ SYNOPSIS πŸ› οΈ

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

enum kcgi_err
khtml_printf(struct khtmlreq *req, const char *fmt, ...);

🌸 DESCRIPTION 🌸

So khtml_printf() writes output according to whatever fmt you hand it, into a context req that you already initialised with khtml_open(3). and the format? it's exactly as for printf(3). no cap, same energy πŸ‘‘

and here's the cute part: if fmt is NULL, it literally does nothing and returns success. icon behaviour. main character energy. we love a function that respects the "never mind" moment πŸ™ˆ

all of the content is HTML escaped β€” like, for example, the left-angle bracket "<" gets rendered as "&lt;". so nobody can sneak anything past it, periodt πŸ’…

πŸ”₯ RETURN VALUES πŸ”₯

Returns an enum kcgi_err indicating the error state. so yeah, check it, bestie, don't just ignore it 😭

  • KCGI_OK β€” Success (not an error). the slay outcome ✨
  • KCGI_ENOMEM β€” Internal memory allocation failure. the memory said no πŸ’€
  • KCGI_HUP β€” The output connection has been terminated. and for FastCGI connections, the current connection should be released with khttp_free(3) and the parse loop reentered. important!! 🫢
  • KCGI_FORM β€” The connection is still expecting headers with khttp_head(3). this one indicates that khttp_body(3) did not return with success or was not invoked. for FastCGI connections, the current connection should be released with khttp_free(3) and the parse loop reentered. same drill πŸŒ€
  • KCGI_SYSTEM β€” Internal system error writing to the output stream. the system is being a hater πŸ™„

πŸ’– EXAMPLES πŸ’–

The following outputs a simple HTML page. it assumes r is a struct kreq pointer. and for brevity, it does not do any error checking β€” which, ngl, for real code you should probably do, but here we're keeping it cute and short πŸŽ€

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_printf(&req, "%s", "Hello, world.");
khtml_close(&req);

look at that. a whole page. we ate 🍽️✨

πŸ‘€ SEE ALSO πŸ‘€

that's your bestie right there, go say hi πŸ¦‹

πŸ“ STANDARDS πŸ“

The referenced HTML5 standard is HTML5.2: https://www.w3.org/TR/html52

iykyk πŸ’œ

πŸ‘‘ AUTHORS πŸ‘‘

Written by Kristaps Dzonsons <kristaps@bsd.lv>. thank you for your service, king πŸ«‘πŸ‘‘


and that's the whole page, bestie!! this lil drop came to you from Debian, dated $Mdocdate$, and it's KHTML_PRINTF(3) forever and always. go forth and escape your 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