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>


  71      value in the template and the fields requested.  In human-friendly (non
  72      machine-parsable) mode, NULL fields, or a value of "all" is treated as a
  73      request to print all allowable fields that fit other applicable
  74      constraints.
  75 
  76      template specifies the list of supported fields, along with formatting
  77      information (e.g., field width), and a pointer to a callback function
  78      that can provide a string representation of the value to be printed out.
  79      The set of supported fields must be a NULL terminated array of type
  80      ofmt_field_t, described in Data Structures, as follows:
  81 
  82            {<of_name>, <of_width>, <of_id>, <of_cb> },
  83            ...
  84            {<of_name>, <of_width>, <of_id>, <of_cb> },
  85            {NULL, 0, 0, NULL}
  86 
  87      of_cb is the application-specified callback function with the following
  88      prototype that provides a string representation of the value to be
  89      printed for the field:
  90 
  91            (*of_cb)(ofmt_arg_t *ofmt_arg, char *buf, uint_t bufsize)
  92 





  93      The interpretation of the of_id field is completely private to the
  94      caller, and can be optionally used by the callback function as a cookie
  95      to identify the field being printed when a single callback function is
  96      shared between multiple template entries.
  97 
  98      The flags can be any valid combination of the following:
  99 
 100      OFMT_PARSABLE   Machine-parsable mode.  Specifying a null or empty fields
 101                      in the machine-parsable mode will result in a returned
 102                      error value of OFMT_EPARSENONE.  An attempt to create a
 103                      handle in machine-parsable mode with the fields set to
 104                      "all" will result in a returned error value of
 105                      OFMT_EPARSEALL.
 106      OFMT_WRAP       Wrap output if field width is exceeded.  Currently output
 107                      is wrapped at whitespace or comma characters.
 108      OFMT_MULTILINE  Multiline mode.  Specifying both OFMT_MULTILINE and
 109                      OFMT_PARSABLE will result in OFMT_EPARSEMULTI.
 110      OFMT_RIGHTJUST  Right justified output.
 111 
 112      The non-zero maxcols limits the number of output columns.


 145      OFMT_ENOMEM       out of memory
 146      OFMT_EBADFIELDS   one or more bad fields with good fields
 147      OFMT_ENOFIELDS    no valid output fields
 148      OFMT_EPARSEALL    "all" is invalid in parsable mode
 149      OFMT_EPARSENONE   output fields missing in parsable mode
 150      OFMT_EPARSEWRAP   parsable mode incompatible with wrap mode
 151      OFMT_ENOTEMPLATE  no template provided for fields
 152      OFMT_EPARSEMULTI  parsable and multiline don't mix
 153 
 154      More information about the type of failure can be obtained by calling
 155      ofmt_strerror().
 156 
 157      The ofmt_strerror() function returns the buf.
 158 
 159 INTERFACE STABILITY
 160      Private.
 161 
 162 SEE ALSO
 163      ioctl(2), strerror(3C), attributes(5)
 164 
 165 illumos                          June 1, 2017                          illumos


  71      value in the template and the fields requested.  In human-friendly (non
  72      machine-parsable) mode, NULL fields, or a value of "all" is treated as a
  73      request to print all allowable fields that fit other applicable
  74      constraints.
  75 
  76      template specifies the list of supported fields, along with formatting
  77      information (e.g., field width), and a pointer to a callback function
  78      that can provide a string representation of the value to be printed out.
  79      The set of supported fields must be a NULL terminated array of type
  80      ofmt_field_t, described in Data Structures, as follows:
  81 
  82            {<of_name>, <of_width>, <of_id>, <of_cb> },
  83            ...
  84            {<of_name>, <of_width>, <of_id>, <of_cb> },
  85            {NULL, 0, 0, NULL}
  86 
  87      of_cb is the application-specified callback function with the following
  88      prototype that provides a string representation of the value to be
  89      printed for the field:
  90 
  91            boolean_t (*of_cb)(ofmt_arg_t *ofmt_arg, char *buf, uint_t bufsize)
  92 
  93      The callback must not write beyond bufsize bytes of the string form into
  94      buf.  If the function successfully translates the field into its string
  95      representation and places it into buf, then the callback function should
  96      return B_TRUE.  Otherwise, the callback function should return B_FALSE.
  97 
  98      The interpretation of the of_id field is completely private to the
  99      caller, and can be optionally used by the callback function as a cookie
 100      to identify the field being printed when a single callback function is
 101      shared between multiple template entries.
 102 
 103      The flags can be any valid combination of the following:
 104 
 105      OFMT_PARSABLE   Machine-parsable mode.  Specifying a null or empty fields
 106                      in the machine-parsable mode will result in a returned
 107                      error value of OFMT_EPARSENONE.  An attempt to create a
 108                      handle in machine-parsable mode with the fields set to
 109                      "all" will result in a returned error value of
 110                      OFMT_EPARSEALL.
 111      OFMT_WRAP       Wrap output if field width is exceeded.  Currently output
 112                      is wrapped at whitespace or comma characters.
 113      OFMT_MULTILINE  Multiline mode.  Specifying both OFMT_MULTILINE and
 114                      OFMT_PARSABLE will result in OFMT_EPARSEMULTI.
 115      OFMT_RIGHTJUST  Right justified output.
 116 
 117      The non-zero maxcols limits the number of output columns.


 150      OFMT_ENOMEM       out of memory
 151      OFMT_EBADFIELDS   one or more bad fields with good fields
 152      OFMT_ENOFIELDS    no valid output fields
 153      OFMT_EPARSEALL    "all" is invalid in parsable mode
 154      OFMT_EPARSENONE   output fields missing in parsable mode
 155      OFMT_EPARSEWRAP   parsable mode incompatible with wrap mode
 156      OFMT_ENOTEMPLATE  no template provided for fields
 157      OFMT_EPARSEMULTI  parsable and multiline don't mix
 158 
 159      More information about the type of failure can be obtained by calling
 160      ofmt_strerror().
 161 
 162      The ofmt_strerror() function returns the buf.
 163 
 164 INTERFACE STABILITY
 165      Private.
 166 
 167 SEE ALSO
 168      ioctl(2), strerror(3C), attributes(5)
 169 
 170 illumos                        December 20, 2018                       illumos