2 .\" # Copyright (c) 2014, Juniper Networks, Inc.
3 .\" # All rights reserved.
4 .\" # This SOFTWARE is licensed under the LICENSE provided in the
5 .\" # ../Copyright file. By downloading, installing, copying, or
6 .\" # using the SOFTWARE, you agree to be bound by the terms of that
8 .\" # Phil Shafer, July 2014
15 .Nd set the field information data for libxo
21 .Fn xo_set_info "xo_handle_t *handle" "xo_info_t *info" "int count"
23 HTML data can include additional information in attributes that
25 To enable this, three things must occur:
27 First the application must build an array of
31 The array must be sorted by name, since
34 binary search to find the entry that matches names from format
39 structure is defined in
41 .Bd -literal -offset indent
42 typedef struct xo_info_s {
43 const char *xi_name; /* Name of the element */
44 const char *xi_type; /* Type of field */
45 const char *xi_help; /* Description of field */
49 Second, the application must inform
51 about this information using the
60 to use the default handle.
66 will count the elements of
69 must be an empty element at the end.
70 More typically, the number is
71 known to the application:
72 .Bd -literal -offset indent
74 { "in-stock", "number", "Number of items in stock" },
75 { "name", "string", "Name of the item" },
76 { "on-order", "number", "Number of items on order" },
77 { "sku", "string", "Stock Keeping Unit" },
78 { "sold", "number", "Number of items sold" },
80 int info_count = (sizeof(info) / sizeof(info[0]));
82 xo_set_info(NULL, info, info_count);
85 Third, the emission of info must be triggered with the
92 command line argument.
94 The type and help values, if present, are emitted as the "data-type"
95 and "data-help" attributes:
96 .Bd -literal -offset indent
97 <div class="data" data-tag="sku" data-type="string"
98 data-help="Stock Keeping Unit">GRO-000-533</div>
106 library first appeared in
111 .An Phil Shafer Aq Mt phil@freebsd.org .