KHTML_CLOSE(3)

πŸ“¦ version 1.0.1, in alpine 3.24

πŸ’… KHTML_CLOSE β€” close kcgihtml context πŸ’…

okay so this is a page from Library Functions Manual (section 3, the library-call girly section) and it's all about khtml_close, bestie. it's short, it's sweet, it's the closing credits of your HTML era. let's get into it πŸŽ€


✨ LIBRARY ✨

library β€œlibkcgihtml” β€” that's the one, that's the squad 🫢


✨ SYNOPSIS ✨

like, here's the whole vibe up front:

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

enum kcgi_err
khtml_close(struct khtmlreq *req);

✨ DESCRIPTION ✨

so khtml_close closes req β€” the context you already opened with khtml_open(3). and the way that every single scope you opened with khtml_attr(3), khtml_attrx(3), or khtml_elem(3) gets automatically closed for you?? we love a function that cleans up after itself. main character energy fr fr 🧚

⚠️ but listen β€” after this, req may no longer be used. like, at all. it's done. it's retired. don't call it, don't text it, don't try to sneak one more element out of it. periodt πŸ’€

✨ RETURN VALUES ✨

returns an enum kcgi_err telling you the error state. the possibilities:

  • KCGI_OK β€” Success. not an error. slay πŸ’–
  • KCGI_ENOMEM β€” internal memory allocation failure. the computer ran out of room 😭
  • KCGI_HUP β€” the output connection has been terminated. for FastCGI connections, the current connection should be released with khttp_free(3) and the parse loop reentered.
  • KCGI_FORM β€” the connection is still expecting headers with khttp_head(3). this means khttp_body(3) did not return with success, or was not invoked at all. for FastCGI connections, the current connection should be released with khttp_free(3) and the parse loop reentered.
  • KCGI_SYSTEM β€” internal system error writing to the output stream. rough. 🫠

✨ EXAMPLES ✨

here's a whole lil' HTML page being born πŸ’– it assumes r is a struct kreq pointer. and for brevity it does not do any error checking β€” iconic but chaotic, ngl:

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_puts(&req, "Hello, world");
khtml_close(&req);

look at that β€” Hello, world and then khtml_close(&req) and we're out. no cap, that's the whole flex 🌈


✨ SEE ALSO ✨

  • kcgihtml(3) β€” go read the parent page, iykyk 🌸

✨ STANDARDS ✨

the referenced HTML5 standard is HTML5.2: https://www.w3.org/TR/html52. β€” yes bestie, the link is literally right there πŸ’…


✨ AUTHORS ✨

Written by Kristaps Dzonsons <kristaps@bsd.lv>. 🫢 thank you king


πŸŽ€ and that's the whole page, bestie. this particular rendering came from Debian, with the date placeholder $Mdocdate$ sitting in the footer spot, and the page answers to the name KHTML_CLOSE(3) β€” ok bye, close your scopes, hydrate, and go touch grass πŸ’œπŸ¦‹
πŸ“¦ 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