KXML_PUSH(3)

πŸ“¦ version 1.0.1, in alpine 3.24

πŸ’… 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 for kcgixml πŸ’…

🫢 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 with khttp_free(3) and parse loop reentered.
  • 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.
  • KCGI_SYSTEM β€” Internal system error writing to the output stream.
  • KCGI_WRITER β€” The elem is 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms