KJSON_PUTBOOL(3)
πΈ NAME πΈ
okay so bestie, this is the KJSON_PUTBOOL(3) page from the Library Functions Manual, and it's literally about kjson_putbool and kjson_putboolp β put Boolean content for kcgijson. That's the whole assignment, and it ate. π
π LIBRARY π
This function pairing lives in the library libkcgijson. The manual says library βlibkcgijsonβ, so that's the home base, no cap π«Ά.
β¨ SYNOPSIS β¨
Here's the exact summoning spell β copied character for character because we respect the code, periodt:
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
#include <kcgijson.h>
enum kcgi_err
kjson_putbool(struct kjsonreq *req, int v);
enum kcgi_err
kjson_putboolp(struct kjsonreq *req, const char *name, int v);
π DESCRIPTION π
So the tea is: you're writing a Boolean v to a context req that was initialised with khtml_open(3). The Boolean is represented as zero for false and non-zero for true β that's the encoding, bestie, no extra drama. π
kjson_putbool() is the form for array scopes, and kjson_putboolp() is for objects. It's giving array girl vs object girl, iykyk.
Passing a NULL value to name for kjson_putboolp() is equivalent to calling kjson_putbool(). Literally the same energy, so don't stress.
π₯ RETURN VALUES π₯
These return an enum kcgi_err indicating the error state. Here's the vibe check on every possible value:
KCGI_OKβ success (not an error), bestie. It ate. βKCGI_ENOMEMβ internal memory allocation failure. The malloc girlies are crying π.KCGI_HUPβ the output connection has been terminated. For FastCGI connections, the current connection should be released withkhttp_free(3)and parse loop reentered. No cap, that's the move.KCGI_FORMβ the connection is still expecting headers withkhttp_head(3). Indicates thatkhttp_body(3)did not return with success or was not invoked. For FastCGI connections, the current connection should be released withkhttp_free(3)and parse loop reentered. It's giving βheaders not done yetβ energy π.KCGI_SYSTEMβ internal system error writing to the output stream. The stream said no π.KCGI_WRITERβ the incorrect form was used for the current scope, for example, an array-type write within an object. That's a scope violation, and it is not iconic, it's just wrong π .
π EXAMPLES π
This snippet outputs a simple JSON document. It assumes r is a struct kreq pointer. For brevity, it does not do any error checking. Here's the exact code, bestie:
khttp_head(r, kresps[KRESP_STATUS],
"%s", khttps[KHTTP_200]);
khttp_head(r, kresps[KRESP_CONTENT_TYPE],
"%s", kmimetypes[KMIME_APP_JSON]);
khttp_body(r);
kjson_open(&req, r);
kjson_obj_open(&req);
kjson_putboolp(&req, "bar", 1); /* true */
kjson_arrayp_open(&req, "baz");
kjson_putbool(&req, 0)); /* false */
kjson_close(&req);
π¦ SEE ALSO π¦
kcgijson(3)β the bestie man page, go read it, iykyk π«Ά
π AUTHORS π
Written by Kristaps Dzonsons <kristaps@bsd.lv>. Iconic behavior, honestly.
mwah π this page is the KJSON_PUTBOOL(3) manual, Debian flavor, with date/version $Mdocdate$ β see u at the next man page, bestie! πΈ
π¦ 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