Skip to content

Commit

Permalink
add example and return code sections
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Shafer committed Aug 21, 2015
1 parent 54c2c00 commit a556a96
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions libxo/xo_emit.3
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,60 @@ uses an explicit handle.
accepts a
.Fa va_list
for additional flexibility.
.Sh EXAMPLES
In this example, a set of four values is emitted using the following
source code:
.Bd -literal -offset indent
xo_emit(" {:lines/%7ju} {:words/%7ju} "
"{:characters/%7ju} {d:filename/%s}\n",
linect, wordct, charct, file);
.Ed
Output can then be generated in various style, using
the "--libxo" option:
.Bd -literal -offset indent
% wc /etc/motd
25 165 1140 /etc/motd
% wc --libxo xml,pretty,warn /etc/motd
<wc>
<file>
<lines>25</lines>
<words>165</words>
<characters>1140</characters>
<filename>/etc/motd</filename>
</file>
</wc>
% wc --libxo json,pretty,warn /etc/motd
{
"wc": {
"file": [
{
"lines": 25,
"words": 165,
"characters": 1140,
"filename": "/etc/motd"
}
]
}
}
% wc --libxo html,pretty,warn /etc/motd
<div class="line">
<div class="text"> </div>
<div class="data" data-tag="lines"> 25</div>
<div class="text"> </div>
<div class="data" data-tag="words"> 165</div>
<div class="text"> </div>
<div class="data" data-tag="characters"> 1140</div>
<div class="text"> </div>
<div class="data" data-tag="filename">/etc/motd</div>
</div>
.Ed
.Sh RETURN CODE
.Nm
returns a negative value on error. If the
.Nm XOF_COLUMNS
flag has been turned on for the specific handle using
.Xr xo_set_flags 3 ,
then the number of display columns consumed by the output will be returned.
.Sh SEE ALSO
.Xr xo_open_container 3 ,
.Xr xo_open_list 3 ,
Expand Down

0 comments on commit a556a96

Please sign in to comment.