2 .\" This file and its contents are supplied under the terms of the
3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
4 .\" You may only use this file in accordance with the terms of version
7 .\" A full copy of the text of the CDDL should have accompanied this
8 .\" source. A copy of the CDDL is also available via the Internet at
9 .\" http://www.illumos.org/license/CDDL.
12 .\" Copyright 2010 Sun Microsystems, Inc. All rights reserved.
13 .\" Copyright 2017 Nexenta Systems, Inc.
21 .Nm ofmt_update_winsize ,
24 .Nd data structures and routines for printing output
31 .Fa "const char *fields"
32 .Fa "const ofmt_field_t *template"
35 .Fa "ofmt_handle_t *ofmt"
39 .Fa "ofmt_handle_t ofmt"
43 .Fo ofmt_update_winsize
44 .Fa "ofmt_handle_t ofmt"
48 .Fa "ofmt_handle_t ofmt"
49 .Fa "ofmt_status_t error"
55 .Fa "ofmt_handle_t ofmt"
60 library provides data structures and routines for printing output.
62 Currently this is an internal interface.
63 The interface can and will change without notice as the project needs, at any
66 All output is assumed to be in a columnar format, where each column represents
67 a field to be printed out.
68 Multiple fields in parsable output are separated by
72 character itself escaped by a
74 .Po e.g., IPv6 addresses may be printed as
77 single field output is printed as-is.
78 In multiline mode, every
80 pair is printed in a line of its own, thus:
85 data structure used in
87 is defined as follows:
89 typedef struct ofmt_field_s {
90 char *of_name; /* column name */
91 uint_t of_width; /* output column width */
92 uint_t of_id; /* implementation specific cookie */
93 ofmt_cb_t *of_cb; /* callback function defined by caller */
99 data structure which is passed to callback function is defined as follows:
101 typedef struct ofmt_arg_s {
102 uint_t ofmt_id; /* implementation specific cookie */
103 uint_t ofmt_width; /* output column width */
104 uint_t ofmt_index; /* unused */
105 void *ofmt_cbarg; /* argument passed to ofmt_print() */
111 function opens a handle returned in
113 for each set of fields to be printed.
116 is a comma-separated list of the fields that have been selected for output
117 .Po typically the string passed to
121 Columns selected for output are identified by a match between the
129 .Pq non machine-parsable
135 is treated as a request to print all allowable fields that fit other applicable
139 specifies the list of supported fields, along with formatting information
140 .Pq e.g., field width ,
141 and a pointer to a callback function that can provide a string representation of
142 the value to be printed out.
143 The set of supported fields must be a
145 terminated array of type
148 .Sx Data Structures ,
150 .Bd -literal -offset indent
151 {<of_name>, <of_width>, <of_id>, <of_cb> },
153 {<of_name>, <of_width>, <of_id>, <of_cb> },
158 is the application-specified callback function with the following prototype that
159 provides a string representation of the value to be printed for the field:
160 .Bd -literal -offset indent
161 (*of_cb)(ofmt_arg_t *ofmt_arg, char *buf, uint_t bufsize)
164 The interpretation of the
166 field is completely private to the caller, and can be optionally used by the
167 callback function as a cookie to identify the field being printed when a single
168 callback function is shared between multiple
174 can be any valid combination of the following:
176 .Bl -tag -width "OFMT_MULTILINE" -compact
178 Machine-parsable mode.
179 Specifying a null or empty
181 in the machine-parsable mode will result in a returned error value of
182 .Dv OFMT_EPARSENONE .
183 An attempt to create a handle in machine-parsable mode with the
187 will result in a returned error value of
190 Wrap output if field width is exceeded.
191 Currently output is wrapped at whitespace or comma characters.
192 .It Dv OFMT_MULTILINE
199 .Dv OFMT_EPARSEMULTI .
200 .It Dv OFMT_RIGHTJUST
201 Right justified output.
206 limits the number of output columns.
210 function prints a row of output.
213 points at the arguments to be passed to the callback function for each column in
217 will result in the callback function of each selected field invoked with
225 .Sx Data Structures .
227 The callback function should fill
229 with the string to be printed for the field using the data in
231 .Ss Fn ofmt_update_winsize
233 .Fn ofmt_update_winsize
234 function updates the window size information
235 .Pq which is initially computed when the handle is created
240 ioctl fails, the window size is set to 80x24.
244 function returns error diagnostics in
246 using the information in the
259 function frees any resources allocated for the handle after printing is
268 The function returns one of the failure codes
272 listed below otherwise:
274 .Bl -tag -width "OFMT_ENOTEMPLATE" -compact
277 .It Dv OFMT_EBADFIELDS
278 one or more bad fields with good fields
279 .It Dv OFMT_ENOFIELDS
280 no valid output fields
281 .It Dv OFMT_EPARSEALL
282 "all" is invalid in parsable mode
283 .It Dv OFMT_EPARSENONE
284 output fields missing in parsable mode
285 .It Dv OFMT_EPARSEWRAP
286 parsable mode incompatible with wrap mode
287 .It Dv OFMT_ENOTEMPLATE
288 no template provided for fields
289 .It Dv OFMT_EPARSEMULTI
290 parsable and multiline don't mix
293 More information about the type of failure can be obtained by calling
300 .Sh INTERFACE STABILITY