KXML_OPEN(3)
π KXML_OPEN(3) β like, the kcgixml context opener, bestie
okay so this one lives in the Library Functions Manual and it's from the libkcgixml library β¨ (yes, that's the whole library name, no cap).
πΈ NAME πΈ
kxml_open β open a kcgixml context π«Ά
π LIBRARY π
library βlibkcgixmlβ
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
#include <kcgixml.h>
enum kcgi_err
kxml_open(struct kxmlreq *xml, struct kreq *req,
const char *const *elems, size_t elemsz);
π DESCRIPTION π
So what this does is it zeroes and initialises a brand-new context req, sitting on top of the underlying kcgi(3) context r β and r has to have been allocated with khttp_parse(3) or khttp_fcgi_parse(3), no exceptions bestie π₯
Lowkey important: you should only call this after khttp_body(3). Like, that's the vibe check and it has to pass.
The context gets initialised with elemsz possible elements, and their names are elems. And here's the thing β it's your job (the caller's responsibility, periodt π
) to make sure those are actually valid XML element names. This function is not gonna hold your hand on that one.
Also π¨ if kcgi_writer_disable(3) has been called, the process will be killed with an uncatchable signal. Not a vibe. Very much not a vibe. π
π¦ RETURN VALUES π¦
It returns an enum kcgi_err showing the error state, and here's the whole menu:
KCGI_OKβ success! not an error! we love to see it πKCGI_ENOMEMβ internal memory allocation failure πKCGI_HUPβ the output connection got terminated. For FastCGI connections, you should release the current connection withkhttp_free(3)and reenter the parse loop πKCGI_FORMβ the connection is still expecting headers withkhttp_head(3). This meanskhttp_body(3)either didn't return with success or just straight-up wasn't invoked π. For FastCGI connections, release the current connection withkhttp_free(3)and reenter the parse loop, same drill.KCGI_SYSTEMβ internal system error while writing to the output stream π
π EXAMPLES π
The following outputs a simple XML page π It assumes r is a struct kreq pointer. And for brevity β because we're keeping it cute and short β it does no error checking at all (iconic of it, honestly):
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_close(&req);
π§ SEE ALSO π§
π AUTHORS π
Written by Kristaps Dzonsons <kristaps@bsd.lv> β thank you king π«Ά
okay that's the whole page, mwah π this thing is Debian-flavoured, version $Mdocdate$, and it goes by KXML_OPEN(3) if you ever need to find it again. bye bestie, go open some contexts β¨π
π¦ 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