KJSON_CLOSE(3)
π 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 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 meanskhttp_body(3)didn't return with success, or it was never invoked π For FastCGI connections, the current connection should be released withkhttp_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
- 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