KUTIL_URLENCODE(3)

πŸ“¦ version 0.10.8, in nixos 26.05, nixpkgs unstable

πŸ’– KUTIL_URLENCODE(3) β€” URL formatting for kcgi, from the β€œlibkcgi” manual πŸ’–

✨ NAME ✨

kutil_urlabs, kutil_urlpart, kutil_urlpartx, kutil_urlencode β€” URL formatting for kcgi, bestie 🫢

πŸ“š LIBRARY πŸ“š

The library is literally called β€œlibkcgi” πŸ’…

🧚 SYNOPSIS 🧚

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

char *
kutil_urlabs(enum kscheme scheme, const char *host, uint16_t port,
    const char *path);

char *
kutil_urlpart(struct kreq *req, const char *path, const char *suffix,
    const char *page, ...);

char *
kutil_urlpartx(struct kreq *req, const char *path, const char *suffix,
    const char *page, ...);

char *
kutil_urlencode(const char *cp);

🌸 DESCRIPTION 🌸

These functions format various parts of a URL. They’re your little URL-gluing besties, no cap ✨

  • kutil_urlpart() and kutil_urlpartx() β€” these two format the path/page.suffix part of an HTTP URL, and they append a variable number of query string key-value pairs. If page is NULL, these return NULL. If path is NULL, the URL will be relative to page; otherwise, path will be followed by a path separator. The last argument must be NULL. If the suffix is NULL, it is omitted from the URL. The page, the keys, and the values are URL-encoded, but the path and the suffix are not πŸ‘‘
  • kutil_urlpart() β€” accepts a variable number of pairs of char * arguments. In each pair, the first argument is the key and the second one the corresponding value πŸ”‘
  • kutil_urlpartx() β€” accepts a variable number of groups of three arguments each. In each group, the first argument is a char * giving the key. The second argument is an enum kattrx specifying the type of the third argument: KATTRX_STRING followed by a char * string, KATTRX_INT followed by an int64_t signed integer, or KATTRX_DOUBLE followed by a double floating-point number. If all types are KATTRX_STRING, the invocation can be shortened to kutil_urlpart() 🌈
  • kutil_urlencode() β€” encodes a string for embedding in a URL πŸŽ€
  • kutil_urlabs() β€” assembles the URL schema://host:portpath. Unless the path is an empty string, it needs to begin with a slash. None of this is URL-encoded, so make sure to use kutil_urlpart(), kutil_urlpartx(), or just kutil_urlencode() for the sensitive parts.
⚠️ Bestie, seriously: kutil_urlabs() does not URL-encode any of that. Use the other functions for the sensitive bits, okay? πŸ’€

πŸ¦‹ RETURN VALUES πŸ¦‹

These functions return newly-allocated strings that must be freed with free(3). They return NULL if allocation fails. The kutil_urlencode() function also returns NULL if cp is NULL 😭

πŸ‘‘ AUTHORS πŸ‘‘

These functions were written by Kristaps Dzonsons <kristaps@bsd.lv> πŸ’œ

πŸ’€ BUGS πŸ’€

  • The kutil_urlabs() function accepts scheme arguments that aren’t valid in URLs πŸ™ˆ
  • The req argument is not used and should be removed. Yes, it’s just kinda vibing there 🫠

This page says it’s from Debian, carries the $Mdocdate$ version marker, and is filed under KUTIL_URLENCODE(3). Byeee bestie πŸ’–πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from