KCGI_BUF_PRINTF(3)
π KCGI_BUF_PRINTF π
okay so this is a page from the Library Functions Manual, section 3, and yes bestie the title says KCGI_BUF_PRINTF β hold that thought, we'll get to the synopsis π
β¨ NAME β¨
kcgi_buf_printf β put variable content into a kcgi buffer π«Ά
π LIBRARY π
library βlibkcgiβ
π 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 *fmt, ...);
ngl, the function in the synopsis is literally spelled kcgi_buf_puts and not kcgi_buf_printf. That's what's on the page, so that's what you get β no editing the icon, periodt. π
πΈ DESCRIPTION πΈ
So what does it do? It appends output to a buffer buf, formatting it according to the given fmt. The format works like printf(3) β same energy, same vibes, you already know her. β¨
β οΈ real talk: buffers have to be initialised to zero with memset(3) before you use them the first time. Not optional, bestie. Zero it out or it's giving uninitialised chaos. π
π¦ RETURN VALUES π¦
It returns an enum kcgi_err telling you the error state. Here's the whole cast of characters, no cap:
KCGI_OKβ success! not an error, we love a happy ending πKCGI_ENOMEMβ internal memory allocation failure π the malloc said noKCGI_HUPβ the output connection has been terminated. For FastCGI connections, the current connection should be released withkhttp_free(3)and the parse loop reentered π₯KCGI_FORMβ the connection is still expecting headers withkhttp_head(3). This one indicates thatkhttp_body(3)did not return with success or was not invoked at all π. For FastCGI connections, the current connection should be released withkhttp_free(3)and the parse loop reentered.KCGI_SYSTEMβ internal system error writing to the output stream π
π EXAMPLES π
okay this example creates a simple NUL-terminated buffer and outputs its contents. It does not perform any error checking β main character energy, honestly, but don't be like this in prod π«Ά
struct kcgi_buf buf;
memset(&buf, 0, sizeof(struct kcgi_buf));
kcgi_buf_printf(&buf, "number %d", 1);
puts(buf.buf); /* Emits "number 1" */
free(buf.buf);
ate. β¨ (and then free(buf.buf), because we're responsible queens π)
π SEE ALSO π
kcgi_buf_putc(3), kcgi_buf_puts(3), kcgi_buf_write(3) β the whole squad, go say hi π
π§ AUTHORS π§
Written by Kristaps Dzonsons <kristaps@bsd.lv>.
that's the whole page bestie!! and for the sign-off β this one ships from Debian, stamped $Mdocdate$, and the footer names her right back: KCGI_BUF_PRINTF(3). slay π
ππ
π¦ 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