KJSON_CLOSE(3)

πŸ“¦ version 1.0.1, in alpine 3.24

πŸ’– KJSON_CLOSE(3) β€” like, the manual page, bestie πŸ’–

okay so this is a page from the Library Functions Manual (the KJSON_CLOSE(3) corner of it), and we're gonna get you fluent in it, no cap ✨


🌸 NAME 🌸

kjson_close β€” closes the kcgijson context, that's the whole vibe πŸŽ€


πŸ¦‹ LIBRARY πŸ¦‹

library β€œlibkcgijson” β€” that's where this lil function lives, iykyk πŸ’…


✨ SYNOPSIS ✨

like, include these first or nothing works, periodt:

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

enum kcgi_err
kjson_close(struct kjsonreq *req);

πŸ’œ DESCRIPTION πŸ’œ

So kjson_close closes req, which you opened with kjson_open(3) β€” yes, they're a matching set, iconic behavior 🫢

And here's the slay part: every single scope you opened with kjson_obj_open(3), kjson_objp_open(3), kjson_array_open(3), kjson_arrayp_open(3), kjson_string_open(3), and kjson_stringp_open(3) gets closed automatically for you. Not me doing all the cleanup πŸ’…βœ¨

🚨 bestie, listen: after this, req may no longer be used. Like, it's done. It's retired. Do not touch it again, fr fr 😭

πŸ”₯ RETURN VALUES πŸ”₯

It returns an enum kcgi_err telling you the error state β€” vibe check time:

  • KCGI_OK β€” Success. Not an error. We love a happy ending 🌈
  • KCGI_ENOMEM β€” Internal memory allocation failure 😭 the memory said no
  • 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 means khttp_body(3) didn't return with success, or it was never invoked πŸ™ˆ For FastCGI connections, the current connection should be released with khttp_free(3) and the parse loop reentered.
  • KCGI_SYSTEM β€” Internal system error while writing to the output stream. Rough πŸ₯²

πŸŽ€ EXAMPLES πŸŽ€

Here's a whole little JSON page being served β€” look at her go πŸ‘‘

It assumes r is a struct kreq pointer. And for brevity (we're being efficient besties), it does not do any error checking 😌

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_putstringp(&req, "foo", "bar");
kjson_close(&req);

⭐ SEE ALSO ⭐

  • kcgijson(3) β€” go read that one next, it's the main character 🧚

πŸ‘‘ AUTHORS πŸ‘‘

Written by Kristaps Dzonsons <kristaps@bsd.lv>. Respect the icon who wrote it πŸ’–


aaaand that's the page! it's from Debian, version $Mdocdate$, and it goes by KJSON_CLOSE(3) β€” mwah, go close some contexts responsibly, 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