LIBXO(3)
π LIBXO(3) β the libxo manual page, section 3 (Library Functions Manual) π
okay bestie, we're doing the libxo library pages and this one is about setting the field information data. it's giving "make your HTML data attributes slay" and honestly? iconic. let's get into it π«Ά
β¨ NAME β¨
xo_set_info β set the field information data for libxo
no cap, that's the whole job. one function, one mission. π
π LIBRARY π
library βlibxoβ
πΈ SYNOPSIS πΈ
#include <libxo/xo.h>
void
xo_set_info(xo_handle_t *handle, xo_info_t *info, int count);
three args, zero drama. okurrr. β¨
π¦ DESCRIPTION π¦
so here's the vibe: HTML data can carry extra info in attributes that start with "data-". literally the little metadata besties. to make that happen, three things must occur β and yes, all three, we're not skipping steps. π
First, the application has to build an array of xo_info_t structures, one per tag. and the array must be sorted by name, because libxo uses a binary search to find the entry that matches names from format instructions. like, it's not scrolling the whole list, it's binary searching, so if you hand it unsorted data it will simply not find your stuff. bestie. sort it. π
the xo_info_t structure is defined in <libxo/xo.h>:
typedef struct xo_info_s {
const char *xi_name; /* Name of the element */
const char *xi_type; /* Type of field */
const char *xi_help; /* Description of field */
} xo_info_t;
name, type, help. that's the trio. π
Second, the application must inform libxo about this information using the xo_set_info() call. and like other libxo calls, passing NULL for the handle tells libxo to use the default handle β so you don't gotta manage handles if you don't wanna.
now, about the count: if the count is -1, libxo will count the elements of info but there must be an empty element at the end. that's the deal, that's the rule. more typically tho, the number is known to the application:
xo_info_t info[] = {
{ "in-stock", "number", "Number of items in stock" },
{ "name", "string", "Name of the item" },
{ "on-order", "number", "Number of items on order" },
{ "sku", "string", "Stock Keeping Unit" },
{ "sold", "number", "Number of items sold" },
};
int info_count = (sizeof(info) / sizeof(info[0]));
...
xo_set_info(NULL, info, info_count);
look at that sizeof(info) / sizeof(info[0]) β the classic "how many things are in my array" move. we love a self-counting array. π
Third, the emission of info must be triggered with the XOF_INFO flag using either the xo_set_flags() function or the β--libxo=infoβ command line argument. no flag, no data attributes. the info just sits there. vibes only, no output. π
and the type and help values, if present, are emitted as the "data-type" and "data-help" attributes:
<div class="data" data-tag="sku" data-type="string"
data-help="Stock Keeping Unit">GRO-000-533</div>
see how sku got matched up with "string" and "Stock Keeping Unit"?? that's the whole point bestie, that's the glow-up. β¨
π₯ SEE ALSO π₯
go read those next, i'm literally begging. π₯Ί
π HISTORY π
The libxo library first appeared in FreeBSD 11.0. a whole era. π
π AUTHORS π
libxo was written by Phil Shafer <phil@freebsd.org>. king behavior, fr fr. π
π ADDITIONAL DOCUMENTATION π
FreeBSD uses libxo version 1.7.5. Complete documentation can be found on github:
https://juniper.github.io/libxo/1.7.5/html/index.html
libxo lives on github as:
https://github.com/Juniper/libxo
The latest release of libxo is available at:
https://github.com/Juniper/libxo/releases
three links, all the lore, go read. π§
π HISTORY π
The libxo library was added in FreeBSD 11.0.
yes bestie, this section really does show up twice in the original. i'm not merging them. we keep every detail in this house. π
π AUTHOR π
Phil Shafer
and that's the whole page, angel!! π this one shipped as part of Debian, dated December 4, 2014, in the LIBXO(3) manual. mwah. go forth and set your info arrays β sorted, obviously. πππ¦
π¦ where this page comes from
- epel 9: libxo-devel 1.7.5-1.el9 Β· LicenseRef-Callaway-BSD
- fedora 43: libxo-devel 1.7.5-2.fc43 Β· LicenseRef-Callaway-BSD
- fedora 43: libxo-devel 1.7.5-2.fc43 Β· LicenseRef-Callaway-BSD
- fedora 44: libxo-devel 1.7.5-3.fc44 Β· LicenseRef-Callaway-BSD
- fedora 44: libxo-devel 1.7.5-3.fc44 Β· LicenseRef-Callaway-BSD
- nixpkgs unstable: libxo 1.7.5
- Copyright (c) 2014, Juniper Networks, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms