libut(3)

πŸ“¦ version 2.11.0, in opensuse-leap 16.0

Okay bestie, this is libut(3) from the Library Functions Manual, and it's giving pure URI-template utility energy ✨. It's a whole little lifecycle: init a handle, register key-values, generate a URI, destroy the handle. Iconic.

πŸŽ€ NAME πŸŽ€

ut_init(), ut_destroy(), ut_keyvalue(), ut_generate() β€” URI template facility πŸ’…

🌸 SYNOPSIS 🌸

#include <ut.h>

URITEMP * ut_init (void);

void ut_destroy (URITEMP *ut);

int ut_keyvalue (URITEMP *ut, int type, const char *name, void *value);

size_t ut_generate (URITEMP *ut, const char *template, char *buf, size_t buflen);

πŸ’– DESCRIPTION πŸ’–

These functions are the mechanism for generating Universal Resource Identifiers (URIs) based on a template you provide. No cap.

First, an application initializes a template using ut_init(), which returns a handle. Then, through multiple calls to ut_keyvalue(), values get assigned to symbolic names and registered with that handle. A name may reference a string, a list of strings, or a set of key-value pairs. Once registration is complete, ut_generate() is used to generate a URI based on the provided template. When the handle is no longer needed, ut_destroy() deallocates the resources associated with it. Periodt.

The type parameter to ut_keyvalue() must be one of UT_KEYTYPE_STRING, UT_KEYTYPE_LIST or UT_KEYTYPE_KEYVALUE. If it is UT_KEYTYPE_LIST, the value parameter should be a NULL-terminated array of terminated strings that comprise the list; if it is UT_KEYTYPE_KEYVALUE, the value parameter should be a NULL-terminated array of terminated strings where the even-numbered entries are keys and the odd-numbered entries are their corresponding values. It returns 0 on success or non-zero on error. If the name was already in use, its value(s) are replaced. Slay.

The template parameter to ut_generate() is expected to conform to the URI templates draft (see below). The buf parameter points to a buffer where the result will be written, up to buflen bytes. The buffer will always remain properly terminated β€” yes, always. The function returns the number of bytes that would be needed to expand the template completely, or a negative number on error. So if the return value exceeds buflen, the string produced was truncated. That's the truncation vibe check πŸ’….

Copyright (c) 2011, 2012, The Trusted Domain Project.  All rights reserved.

πŸ¦‹ SEE ALSO πŸ¦‹

  • draft-gregorio-uritemplate β€” the URI templates draft ✨

That's the whole libut(3) situation, bestie πŸ’–. Sign-off time πŸŽ€: the source/version footer is literally just libut(3), and there is no date listed on this page, so this is your cute little end-of-manual moment. Mwah, go generate some iconic URIs πŸ’‹πŸ’…

πŸ“¦ where this page comes from