KJSON_PUTBOOL(3)

πŸ“¦ version 1.0.1, in alpine 3.24

🌸 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 with khttp_free(3) and parse loop reentered. No cap, that's the move.
  • KCGI_FORM β€” the connection is still expecting headers with khttp_head(3). 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 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms