KXML_CLOSE(3)

πŸ“¦ version 1.0.1, in alpine 3.24

✨ NAME ✨

kxml_close β€” close kcgixml context. Hi bestie, welcome to the kxml_close(3) page! This is the function that wraps up your kcgixml context and says bye. πŸŽ€

πŸ¦‹ LIBRARY πŸ¦‹

This one lives in the library libkcgixml, and yes it's iconic for that. πŸ’…

🌸 SYNOPSIS 🌸

#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
#include <kcgixml.h>

enum kcgi_err
kxml_close(struct kxmlreq *req);

πŸ’– DESCRIPTION πŸ’–

Okay so kxml_close closes req β€” the context you initialised with kxml_open(3). Every scope you opened with kxml_push(3) and kxml_pushattrs(3) gets automatically closed too, no manual cleanup era needed. ✨

⚠️ After this, req may no longer be used. Like, do not touch it, do not text it back, do not reuse it. Periodt. πŸ’€

πŸ”₯ RETURN VALUES πŸ”₯

It returns an enum kcgi_err that tells you the error state. Here's the full lineup:

  • KCGI_OK β€” Success, aka not an error. Slay. πŸŽ‰
  • KCGI_ENOMEM β€” Internal memory allocation failure. 😭
  • KCGI_HUP β€” The output connection has been terminated. For FastCGI connections, the current connection should be released with khttp_free(3) and the parse loop reentered. 🫢
  • KCGI_FORM β€” The connection is still expecting headers with khttp_head(3). This 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 the parse loop reentered. πŸŒ€
  • KCGI_SYSTEM β€” Internal system error writing to the output stream. Big yikes. πŸ’€

🌈 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. Copy-paste responsibly, bestie. πŸ“

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 πŸ’œ

  • kcgixml(3) β€” the whole family, go explore. 🌈

πŸ‘‘ AUTHORS πŸ‘‘

Written by Kristaps Dzonsons <kristaps@bsd.lv>. Respect the icon. πŸ‘‘


πŸŽ€ That's the whole KXML_CLOSE(3) page β€” Debian source/version, date-stamped $Mdocdate$. Bye bestie, go close those contexts! πŸŽ€

πŸ“¦ 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