1LIBXO(3)                 BSD Library Functions Manual                 LIBXO(3)
2

NAME

4     xo_emit, xo_emit_h, xo_emit_hv — emit formatted output based on format
5     string and arguments
6

LIBRARY

8     library “libxo”
9

SYNOPSIS

11     #include <libxo/xo.h>
12
13     xo_ssize_t
14     xo_emit(const char *fmt, ...);
15
16     xo_ssize_t
17     xo_emit_h(xo_handle_t *xop, const char *fmt, ...);
18
19     xo_ssize_t
20     xo_emit_hv(xo_handle_t *xop, const char *fmt, va_list vap);
21

DESCRIPTION

23     The xo_emit() function emits formatted output using the description in a
24     format string along with a set of zero or more arguments, in a style sim‐
25     ilar to printf(3) but using a more complex format description string, as
26     described in xo_format(5).
27
28     xo_emit() uses the default output handle, as described in libxo(3), where
29     xo_emit_h() uses an explicit handle.  xo_emit_hv() accepts a va_list for
30     additional flexibility.
31

EXAMPLES

33     In this example, a set of four values is emitted using the following
34     source code:
35
36               xo_emit(" {:lines/%7ju} {:words/%7ju} "
37                       "{:characters/%7ju} {d:filename/%s}\n",
38                       linect, wordct, charct, file);
39     Output can then be generated in various style, using the "--libxo" op‐
40     tion:
41
42               % wc /etc/motd
43                     25     165    1140 /etc/motd
44               % wc --libxo xml,pretty,warn /etc/motd
45               <wc>
46                 <file>
47                   <lines>25</lines>
48                   <words>165</words>
49                   <characters>1140</characters>
50                   <filename>/etc/motd</filename>
51                 </file>
52               </wc>
53               % wc --libxo json,pretty,warn /etc/motd
54               {
55                 "wc": {
56                   "file": [
57                     {
58                       "lines": 25,
59                       "words": 165,
60                       "characters": 1140,
61                       "filename": "/etc/motd"
62                     }
63                   ]
64                 }
65               }
66               % wc --libxo html,pretty,warn /etc/motd
67               <div class="line">
68                 <div class="text"> </div>
69                 <div class="data" data-tag="lines">     25</div>
70                 <div class="text"> </div>
71                 <div class="data" data-tag="words">    165</div>
72                 <div class="text"> </div>
73                 <div class="data" data-tag="characters">   1140</div>
74                 <div class="text"> </div>
75                 <div class="data" data-tag="filename">/etc/motd</div>
76               </div>
77

RETURN CODE

79     xo_emit returns a negative value on error.  If the XOF_COLUMNS flag has
80     been turned on for the specific handle using xo_set_flags(3), then the
81     number of display columns consumed by the output will be returned.
82

SEE ALSO



        
Impressum