KXML_POP(3)
π KXML_POP(3) β kxml_pop
okay so bestie, welcome to kxml_pop(3), part of the βlibkcgixmlβ library β¨ (yes that's LIBRARY, and yes she's an icon). This is the little function that closes out an element scope for kcgixml, and honestly? she's a closer. literally.
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
#include <kcgihxml.h>
enum kcgi_err
kxml_pop(struct kxmlreq *req);
like, that's the whole vibe. one function, one job, no cap π
πΈ DESCRIPTION πΈ
So kxml_pop closes exactly one element scope of req β the request you already set up with kxml_open(3). That's it. That's the whole function. main character energy in its purest form π
where do those scopes come from, you ask? they get opened by kxml_push(3) or kxml_pushattrs(3). so every push needs its pop, bestie. it's giving matching accessories. π
β οΈ ngl, it is literally an error to pop from an empty scope stack. no scopes open? no pop for you. don't do it. π«Ά
π¦ RETURN VALUES π¦
she returns an enum kcgi_err, which is just the error state. here's the whole cast of characters:
KCGI_OKβ success! not an error, just vibes πKCGI_ENOMEMβ internal memory allocation failure. the malloc said no πKCGI_HUPβ the output connection has been terminated. for FastCGI connections, you should release the current connection withkhttp_free(3)and reenter the parse loop. (yeah. do that. π«‘)KCGI_FORMβ the connection is still expecting headers viakhttp_head(3). this one's telling you thatkhttp_body(3)didn't return with success, or was never invoked at all. for FastCGI connections, release the current connection withkhttp_free(3)and reenter the parse loop. (same drill, different error π)KCGI_SYSTEMβ internal system error writing to the output stream. the stream is not having it πKCGI_WRITERβ there are no open scopes to pop. literally nothing to close. this is the empty-stack situation from up there β¬οΈ
π₯ EXAMPLES π₯
okay so this example outputs a simple XML page, and it assumes r is a struct kreq pointer. for brevity, it does not do any error checking (iconic of it, honestly, but don't copy that part into prod π).
const char *const elems[] =
{ "foo", "bar", "baz" };
khttp_head(r, kresps[KRESP_STATUS],
"%s", khttps[KHTTP_200]);
khttp_head(r, kresps[KRESP_CONTENT_TYPE],
"%s", kmimetypes[KMIME_TEXT_XML]);
khttp_body(r);
kxml_open(&req, r, elems, 3);
kxml_push(&req, 0); /* foo */
kxml_puts(&req, "Hello, world");
kxml_pop(&req);
kxml_push(&req, 1, "baz", "xyzzy"); /* bar */
kxml_puts(&req, "Hello, world");
kxml_pop(&req);
kxml_close(&req);
see how every kxml_push gets its matching kxml_pop? balance. harmony. friendship. π
π SEE ALSO π
like obviously go read the parent page, bestie, iykyk π
π AUTHORS π
Written by Kristaps Dzonsons <kristaps@bsd.lv>. we stan. π«Ά
okay and for the sign-off: this page came from the Debian fam, dated $Mdocdate$, and it's KXML_POP(3) through and through. periodt. π
β¨
π¦ 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