KXML_PUSH(3)
π KXML_PUSH(3) β from the Library Functions Manual π
okay so bestie, welcome to the absolute cutest corner of libkcgixml β this page is all about opening element scopes, and itβs lowkey iconic. letβs get into it π
β¨ NAME β¨
kxml_push,kxml_pushattrsβ open an element scope forkcgixmlπ
π«Ά LIBRARY π«Ά
library βlibkcgixmlβ β yes bestie, thatβs the one π
π SYNOPSIS π
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
#include <kcgixml.h>
enum kcgi_err
kxml_push(struct kxmlreq *req, size_t elem);
enum kcgi_err
kxml_pushattrs(struct kxmlreq *req, size_t elem, ...);
π¦ DESCRIPTION π¦
okay so kxml_push() opens a brand-new scope of element index elem on the current element stack of req β and that req is the one that got initialised with kxml_open(3). the element must be in the element array you passed to kxml_open(3), no cap.
scopes get closed with kxml_popall(3), kxml_pop(3), or kxml_close(3). periodt π
the kxml_pushattrs() form is the fancy one: it accepts pairs of character string arguments, where the first is an attribute name and the second is its value. this list must be terminated by a NULL pointer β donβt forget, bestie π
attribute names are left as-is: the caller must make sure that keys are valid XML. attribute values are XML escaped to prevent content from breaking out of the attribute string. so like, the escaping is handled, but the key validity is your main character moment π«Ά
π₯ RETURN VALUES π₯
returns an enum kcgi_err indicating the error state. vibe check on the possible values:
KCGI_OKβ Success (not an error). slay β¨KCGI_ENOMEMβ Internal memory allocation failure, including reaching the maximum number of possible JSON scopes.KCGI_HUPβ The output connection has been terminated. For FastCGI connections, the current connection should be released withkhttp_free(3)and parse loop reentered.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.KCGI_SYSTEMβ Internal system error writing to the output stream.KCGI_WRITERβ Theelemis not a valid element index.
π EXAMPLES π
the following outputs a simple XML page. it assumes r is a struct kreq pointer. for brevity, it does not do any error checking β yes, weβre being brave today π
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_pushattrs(&req, 1, "baz", "xyzzy", NULL); /* bar */
kxml_puts(&req, "Hello, world");
kxml_pop(&req);
kxml_close(&req);
π SEE ALSO π
kcgixml(3)β go read it, bestie, itβs giving essential lore πΈ
π AUTHORS π
Written by Kristaps Dzonsons <kristaps@bsd.lv>.
β¨ mwah π this page is from Debian, date tag $Mdocdate$, and itβs filed under KXML_PUSH(3) β love u bestie, go slay those XML scopes π«Άπ
π¦ 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