DragonFly On-Line Manual Pages

Search: Section:  


KUTIL_URLENCODE(3)    DragonFly Library Functions Manual    KUTIL_URLENCODE(3)

NAME

kutil_urlabs, kutil_urlpart, kutil_urlpartx, kutil_urlencode - URL functions for kcgi

LIBRARY

library "libkcgi"

SYNOPSIS

#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

The kutil_urlpart, and kutil_urlpartx functions format a partial HTTP URL from the path, suffix, page, and variable-length query string keys and values. If the suffix part is NULL, it is not formatted as part of the URL. The kutil_urlabs forms an absolute URL from a scheme, domain, and path component. The kutil_urlencode function encodes a string for embedding in a URL. All functions return newly-allocated string of the encoded contents. kutil_urlpart and kutil_urlpartx accept variable-length arguments terminated with a NULL value. kutil_urlpart accepts key-value string pairs. kutil_urlpartx accepts string keys, then a enum kattrx of the value type, then a pointer to the value corresponding to that type: KATTRX_STRING for strings, KATTRX_INT for int64_t 64-bit signed integers, and KATTRX_DOUBLE for double double-precision floating-point numbers. kutil_urlpart, thus, is as if kutil_urlpartx were invoked with KATTRX_STRING for all values. kutil_urlabs formats schema, host, port, and path component into a URL. This is not URL-encoded in any way, so make sure to use kutil_urlpart(), kutil_urlpartx(), or just kutil_urlencode() for the sensitive parts.

RETURN VALUES

kutil_urlabs, kutil_urlpart, kutil_urlpartx, and kutil_urlencode return a newly-allocated string that must be freed with free(3). kutil_urlencode will return NULL if its input argument is NULL or if allocation fails.

AUTHORS

The kutil_urlabs library was written by Kristaps Dzonsons <kristaps@bsd.lv>.

CAVEATS

The kutil_urlabs function accepts schemas via enum kscheme that aren't URLs. Also, the fact that kutil_urlencode will return NULL on allocation failure but kutil_urlabs, kutil_urlpart, and kutil_urlpartx will abort is wrong. DragonFly 6.5-DEVELOPMENT July 16, 2015 DragonFly 6.5-DEVELOPMENT

Search: Section: