KHTTP_PRINTF(3)

πŸ“¦ version 1.0.1, in alpine 3.24

✨ KHTTP_PRINTF(3) ✨

okay so this is the manual page for khttp_printf in the library functions manual β€” aka the lil formatting-queen of libkcgi πŸ’… she's the one who takes your variable content and makes it go out 🫢


πŸŽ€ LIBRARY πŸŽ€

we're in the library β€œlibkcgi” bestie, that's the house she lives in πŸ’–


🌸 SYNOPSIS 🌸

the receipts, verbatim, no cap:

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

enum kcgi_err
khttp_printf(struct kreq *req, const char *fmt, ...);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so what she does: she writes output according to whatever fmt you hand her, straight into a kcgi(3) context req β€” and that req has to be the one you already allocated with khttp_parse(3) or khttp_fcgi_parse(3), no substitutes pls πŸ™…β€β™€οΈ

the format works exactly like printf(3), like, the whole vibe is identical πŸ’–

⚠️ timing check bestie: she should only be called after khttp_body(3). if you call her before, that's a whole mess, don't do it 😭

and here's the little plot twist: if fmt is NULL, she literally does nothing at all and returns success. iconique. zero drama, maximum chill 🧚 no output, no problems, we love a low-maintenance queen.

πŸ’€ BUT β€” and this is the serious one β€” if kcgi_writer_disable(3) was invoked earlier? she will abort(3). like, full on abort. so yeah, do NOT be doing that combo, that's a one-way ticket to crash city πŸ™ˆ

πŸ”₯ RETURN VALUES πŸ”₯

she returns an enum kcgi_err telling you her whole emotional state (aka the error state) πŸ’œ

  • KCGI_OK β€” success!! not an error, everything slayed, we're so back πŸ‘‘
  • KCGI_ENOMEM β€” internal memory allocation failure 😭 the memory said no ❌
  • KCGI_HUP β€” the output connection has been terminated πŸ’€ for FastCGI connections you should release the current connection with khttp_free(3) and then reenter the parse loop, k? go, go, go πŸƒβ€β™€οΈ
  • KCGI_FORM β€” the connection is still expecting headers with khttp_head(3) 🫠 this means khttp_body(3) either didn't return with success or was just... never invoked. for FastCGI connections you should release the current connection with khttp_free(3) and reenter the parse loop. same drill as above bestie, no cap ✨
  • KCGI_SYSTEM β€” internal system error while writing to the output stream πŸ’₯ the system is having a moment, not her fault

🌈 SEE ALSO 🌈

go read these too, iykyk:


πŸ’– AUTHORS πŸ’–

written by Kristaps Dzonsons <kristaps@bsd.lv> β€” king behavior, honestly πŸ‘‘


okay that's the whole page, mwah 🫢 this came from the Debian build, dated $Mdocdate$, and it's the KHTTP_PRINTF(3) page β€” literally iconic, no notes, periodt πŸ’…βœ¨

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