KCGI_WRITER_WRITE(3)

πŸ“¦ version 1.0.1, in alpine 3.24

✨ 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 with khttp_free(3) and you should reenter the parse loop. πŸ’€
  • KCGI_FORM β€” the connection is still expecting headers with khttp_head(3). this is the function going "girl, where are the headers." it means that khttp_body(3) either didn't return with success or was never invoked at all. and again, for FastCGI connections: release the current connection with khttp_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