KUTIL_URLENCODE(3)
π 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()andkutil_urlpartx()β these two format thepath/page.suffixpart of an HTTP URL, and they append a variable number of query string key-value pairs. IfpageisNULL, these returnNULL. IfpathisNULL, the URL will be relative topage; otherwise,pathwill be followed by a path separator. The last argument must beNULL. If thesuffixisNULL, it is omitted from the URL. Thepage, the keys, and the values are URL-encoded, but thepathand thesuffixare not πkutil_urlpart()β accepts a variable number of pairs ofchar *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 achar *giving the key. The second argument is anenum kattrxspecifying the type of the third argument:KATTRX_STRINGfollowed by achar *string,KATTRX_INTfollowed by anint64_tsigned integer, orKATTRX_DOUBLEfollowed by adoublefloating-point number. If all types areKATTRX_STRING, the invocation can be shortened tokutil_urlpart()πkutil_urlencode()β encodes a string for embedding in a URL πkutil_urlabs()β assembles the URLschema://host:portpath. Unless thepathis an empty string, it needs to begin with a slash. None of this is URL-encoded, so make sure to usekutil_urlpart(),kutil_urlpartx(), or justkutil_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 acceptsschemearguments that arenβt valid in URLs π - The
reqargument 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
- nixos 26.05: kcgi 0.10.8
- nixpkgs unstable: kcgi 0.10.8
- Copyright (c) 2014, 2017 Kristaps Dzonsons <kristaps@bsd.lv>
- Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms