KHTTP_PRINTF(3)
β¨ 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 β ifkcgi_writer_disable(3)was invoked earlier? she willabort(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 withkhttp_free(3)and then reenter the parse loop, k? go, go, go πββοΈKCGI_FORMβ the connection is still expecting headers withkhttp_head(3)π« this meanskhttp_body(3)either didn't return with success or was just... never invoked. for FastCGI connections you should release the current connection withkhttp_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
- Copyright (c) 2020 Kristaps Dzonsons <kristaps@bsd.lv>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms