Print this page
11544 ofmt(3OFMT) should talk about the callback handler
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Jason King <jason.brian.king@gmail.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man3ofmt/ofmt.3ofmt
          +++ new/usr/src/man/man3ofmt/ofmt.3ofmt
↓ open down ↓ 3 lines elided ↑ open up ↑
   4    4  .\" You may only use this file in accordance with the terms of version
   5    5  .\" 1.0 of the CDDL.
   6    6  .\"
   7    7  .\" A full copy of the text of the CDDL should have accompanied this
   8    8  .\" source.  A copy of the CDDL is also available via the Internet at
   9    9  .\" http://www.illumos.org/license/CDDL.
  10   10  .\"
  11   11  .\"
  12   12  .\" Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  13   13  .\" Copyright 2017 Nexenta Systems, Inc.
       14 +.\" Copyright 2018 Joyent, Inc.
  14   15  .\"
  15      -.Dd June 1, 2017
       16 +.Dd December 20, 2018
  16   17  .Dt OFMT 3OFMT
  17   18  .Os
  18   19  .Sh NAME
  19   20  .Nm ofmt_open ,
  20   21  .Nm ofmt_print ,
  21   22  .Nm ofmt_update_winsize ,
  22   23  .Nm ofmt_strerror ,
  23   24  .Nm ofmt_close
  24   25  .Nd data structures and routines for printing output
  25   26  .Sh LIBRARY
↓ open down ↓ 125 lines elided ↑ open up ↑
 151  152  {<of_name>, <of_width>, <of_id>, <of_cb> },
 152  153  \&.\&.\&.
 153  154  {<of_name>, <of_width>, <of_id>, <of_cb> },
 154  155  {NULL, 0, 0, NULL}
 155  156  .Ed
 156  157  .Pp
 157  158  .Va of_cb
 158  159  is the application-specified callback function with the following prototype that
 159  160  provides a string representation of the value to be printed for the field:
 160  161  .Bd -literal -offset indent
 161      -(*of_cb)(ofmt_arg_t *ofmt_arg, char *buf, uint_t bufsize)
      162 +boolean_t (*of_cb)(ofmt_arg_t *ofmt_arg, char *buf, uint_t bufsize)
 162  163  .Ed
 163  164  .Pp
      165 +The callback must not write beyond
      166 +.Fa bufsize
      167 +bytes of the string form into
      168 +.Fa buf .
      169 +If the function successfully translates the field into its string
      170 +representation and places it into
      171 +.Fa buf ,
      172 +then the callback function should return
      173 +.Dv B_TRUE .
      174 +Otherwise, the callback function should return
      175 +.Dv B_FALSE .
      176 +.Pp
 164  177  The interpretation of the
 165  178  .Va of_id
 166  179  field is completely private to the caller, and can be optionally used by the
 167  180  callback function as a cookie to identify the field being printed when a single
 168  181  callback function is shared between multiple
 169  182  .Fa template
 170  183  entries.
 171  184  .Pp
 172  185  The
 173  186  .Fa flags
↓ open down ↓ 132 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX