KCGI_BUF_PUTS(3)

πŸ“¦ version 1.0.1, in alpine 3.24

πŸ’… KCGI_BUF_PUTS(3) β€” it's giving "library functions manual" ✨

okay so bestie, welcome to the manual page for kcgi_buf_puts β€” a function from the libkcgi library (that's "library "libkcgi"" to be formal about it πŸŽ€). this one's short, sweet, and honestly kind of iconic. let's get into it πŸ’–


🌸 NAME 🌸

kcgi_buf_puts β€” put string content into a kcgi buffer 🫢


πŸ“š LIBRARY πŸ“š

the library is literally libkcgi, no cap ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

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

enum kcgi_err
kcgi_buf_puts(struct kcgi_buf *buf, const char *cp);

πŸ’œ DESCRIPTION πŸ’œ

okay so what it does: it appends a NUL-terminated string cp to a buffer buf. that's the whole vibe, honestly 🌈

⭐ IMPORTANT, bestie: buffers must be initialised to zero with memset(3) prior to first use. like, before you touch them. no exceptions, periodt πŸ’…

the way this function handles things: it does nothing if cp is NULL (silent queen behavior, she just moves on πŸ™ˆ).

and heads up β€” it does not append a newline like puts(3) does. so don't come crying to me when your output is all crammed on one line, iykyk 😭


πŸ”₯ RETURN VALUES πŸ”₯

it returns an enum kcgi_err indicating the error state. here's the full lineup πŸ‘‘

  • KCGI_OK β€” success, we love to see it πŸ’– (not an error, bestie, she's fine)
  • KCGI_ENOMEM β€” internal memory allocation failure 😭
  • 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 indicates that khttp_body(3) did not return with success or was not invoked. 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 🚨

✨ EXAMPLES ✨

okay here's a cute little example πŸŽ€ β€” it creates a simple NUL-terminated buffer and outputs its contents. note: it does not perform any error checking, so this is very "living in the moment" of it ngl πŸ™ˆ

struct kcgi_buf buf;

memset(&buf, 0, sizeof(struct kcgi_buf));
kcgi_buf_puts(&buf, "Hello, world!");
puts(buf.buf); /* Emits "Hello, world!" */
free(buf.buf);

and yes, she emits "Hello, world!" β€” iconic behavior, honestly πŸŒπŸ’«


πŸ‘€ SEE ALSO πŸ‘€

go read those next, bestie, they're all part of the same friend group 🫢


🌟 AUTHORS 🌟

written by Kristaps Dzonsons <kristaps@bsd.lv> πŸ‘‘ β€” thank you for your service, king 🫑


and that's the page!! πŸ’– this version came from Debian, dated $Mdocdate$, and it's the KCGI_BUF_PUTS(3) manual page β€” mwah, slay, bye bestie πŸ’…βœ¨πŸŽ€

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