1.\" # 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 7.\" # LICENSE. 8.\" # Phil Shafer, July 2014 9.\" 10.Dd December 4, 2014 11.Dt LIBXO 3 12.Os 13.Sh NAME 14.Nm xo_emit 15.Nd emit formatted output based on format string and arguments 16.Sh LIBRARY 17.Lb libxo 18.Sh SYNOPSIS 19.In libxo/xo.h 20.Ft void 21.Fn xo_set_info "xo_handle_t *handle" "xo_info_t *info" "int count" 22.Sh DESCRIPTION 23HTML data can include additional information in attributes that 24begin with "data-". 25To enable this, three things must occur: 26.Pp 27First the application must build an array of 28.Dv xo_info_t 29structures, 30one per tag. 31The array must be sorted by name, since 32.Nm libxo 33uses a 34binary search to find the entry that matches names from format 35instructions. 36.Pp 37The 38.Dv xo_info_t 39structure is defined in 40.In libxo/xo.h : 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 */ 46 } xo_info_t; 47.Ed 48.Pp 49Second, the application must inform 50.Nm libxo 51about this information using the 52.Fn xo_set_info 53call. 54Like other 55.Nm libxo 56calls, passing 57.Dv NULL 58for the handle tells 59.Nm libxo 60to use the default handle. 61.Pp 62If the 63.Fa count 64is -1, 65.Nm libxo 66will count the elements of 67.Fa info , 68but there 69must be an empty element at the end. 70More typically, the number is 71known to the application: 72.Bd -literal -offset indent 73 xo_info_t info[] = { 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" }, 79 }; 80 int info_count = (sizeof(info) / sizeof(info[0])); 81 ... 82 xo_set_info(NULL, info, info_count); 83.Ed 84.Pp 85Third, the emission of info must be triggered with the 86.Dv XOF_INFO 87flag 88using either the 89.Fn xo_set_flags 90function or the 91.Dq --libxo=info 92command line argument. 93.Pp 94The type and help values, if present, are emitted as the "data-type" 95and "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> 99.Ed 100.Sh ADDITIONAL DOCUMENTATION 101Complete documentation can be found on github: 102.Bd -literal -offset indent 103http://juniper.github.io/libxo/libxo-manual.html 104.Ed 105.Pp 106.Nm libxo 107lives on github as: 108.Bd -literal -offset indent 109https://github.com/Juniper/libxo 110.Ed 111.Pp 112The latest release of 113.Nm libxo 114is available at: 115.Bd -literal -offset indent 116https://github.com/Juniper/libxo/releases 117.Ed 118.Sh SEE ALSO 119.Xr xo_emit 3 120.Sh HISTORY 121The 122.Nm libxo 123library was added in 124.Fx 11.0 . 125.Sh AUTHOR 126Phil Shafer 127