KCGI_WRITER_WRITE(3)
β¨ kcgi_writer_write β¨
okay so bestie, pull up a chair β this is kcgi_writer_write(3), straight out of the Library Functions Manual section, and honestly? it's giving "small function, big main character energy." π
π NAME π
kcgi_writer_write β write into a writer. that's it, that's the vibe. β¨
π LIBRARY π
you're gonna need library "libkcgi" β no cap, that's the whole library section, short and slay. π«Ά
π» SYNOPSIS π»
okay so here's the whole ritual, do the includes in this exact order, don't @ me:
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
enum kcgi_err
kcgi_writer_write(struct kcgi_writer *writer, const void *buf,
size_b bufsz);
πΈ DESCRIPTION πΈ
so kcgi_writer_write() writes bufsz bytes of buf into a writer channel that you opened earlier with kcgi_writer_get(3). literally just shoving your bytes into the channel, iconic behavior. π
the big deal here β the reason this function is a whole mood β is that it lets you write after kcgi_writer_disable(3), which is something khttp_write(3) absolutely will not do for you. iykyk. π₯
π RETURN VALUES π
it hands you back an enum kcgi_err telling you the error state. so like, a vibe check for your write. here's the whole menu, no skips:
KCGI_OKβ success, bestie! it worked. this one is not an error, it's the good ending. πKCGI_ENOMEMβ internal memory allocation failure. the malloc said no. πKCGI_HUPβ the output connection has been terminated. heads up for FastCGI connections in particular: the current connection should be released withkhttp_free(3)and you should reenter the parse loop. πKCGI_FORMβ the connection is still expecting headers withkhttp_head(3). this is the function going "girl, where are the headers." it means thatkhttp_body(3)either didn't return with success or was never invoked at all. and again, for FastCGI connections: release the current connection withkhttp_free(3)and reenter the parse loop. πKCGI_SYSTEMβ internal system error writing to the output stream. it's giving chaos, ngl. π
π¦ SEE ALSO π¦
go read these next, they're the friends in this little friend group:
π AUTHORS π
this function was written by Kristaps Dzonsons <kristaps@bsd.lv> β thank you king, we love a legend. π
and that's the page, bestie!! π§ tiny sign-off from the Debian build of this page, dated $Mdocdate$, and yeah β the source/version footer literally just repeats KCGI_WRITER_WRITE(3) back at you like a cute little echo. 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