Print this page
11545 Want configurable output field separator for libofmt
Portions contributed by: Cody Peter Mello <cody.mello@joyent.com>
Reviewed by: Jason King <jason.king@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man3ofmt/ofmt.3ofmt
          +++ new/usr/src/man/man3ofmt/ofmt.3ofmt
↓ open down ↓ 5 lines elided ↑ open up ↑
   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   14  .\" Copyright 2018 Joyent, Inc.
  15   15  .\"
  16      -.Dd December 20, 2018
       16 +.Dd February 13, 2019
  17   17  .Dt OFMT 3OFMT
  18   18  .Os
  19   19  .Sh NAME
  20   20  .Nm ofmt_open ,
  21   21  .Nm ofmt_print ,
       22 +.Nm ofmt_print_header ,
  22   23  .Nm ofmt_update_winsize ,
       24 +.Nm ofmt_set_fs ,
  23   25  .Nm ofmt_strerror ,
  24   26  .Nm ofmt_close
  25   27  .Nd data structures and routines for printing output
  26   28  .Sh LIBRARY
  27   29  .Lb libofmt
  28   30  .Sh SYNOPSIS
  29   31  .In ofmt.h
  30   32  .Ft ofmt_status_t
  31   33  .Fo ofmt_open
  32   34  .Fa "const char *fields"
↓ open down ↓ 1 lines elided ↑ open up ↑
  34   36  .Fa "uint_t flags"
  35   37  .Fa "uint_t maxcols"
  36   38  .Fa "ofmt_handle_t *ofmt"
  37   39  .Fc
  38   40  .Ft void
  39   41  .Fo ofmt_print
  40   42  .Fa "ofmt_handle_t ofmt"
  41   43  .Fa "void *cbarg"
  42   44  .Fc
  43   45  .Ft void
       46 +.Fo ofmt_print_header
       47 +.Fa "ofmt_handle_t ofmt"
       48 +.Fc
       49 +.Ft void
  44   50  .Fo ofmt_update_winsize
  45   51  .Fa "ofmt_handle_t ofmt"
  46   52  .Fc
       53 +.Ft void
       54 +.Fo ofmt_set_fs
       55 +.Fa "ofmt_handle_t ofmt"
       56 +.Fa "char fs"
       57 +.Fc
  47   58  .Ft "char *"
  48   59  .Fo ofmt_strerror
  49   60  .Fa "ofmt_handle_t ofmt"
  50   61  .Fa "ofmt_status_t error"
  51   62  .Fa "char *buf"
  52   63  .Fa "uint_t bufsize"
  53   64  .Fc
  54   65  .Ft void
  55   66  .Fo ofmt_close
  56   67  .Fa "ofmt_handle_t ofmt"
↓ open down ↓ 148 lines elided ↑ open up ↑
 205  216  .It Dv OFMT_MULTILINE
 206  217  Multiline mode.
 207  218  Specifying both
 208  219  .Dv OFMT_MULTILINE
 209  220  and
 210  221  .Dv OFMT_PARSABLE
 211  222  will result in
 212  223  .Dv OFMT_EPARSEMULTI .
 213  224  .It Dv OFMT_RIGHTJUST
 214  225  Right justified output.
      226 +.It Dv OFMT_NOHEADER
      227 +Skip printing the header when calling
      228 +.Fn ofmt_print .
 215  229  .El
 216  230  .Pp
 217  231  The non-zero
 218  232  .Fa maxcols
 219  233  limits the number of output columns.
 220  234  .Ss Fn ofmt_print
 221  235  The
 222  236  .Fn ofmt_print
 223  237  function prints a row of output.
 224  238  .Pp
↓ open down ↓ 9 lines elided ↑ open up ↑
 234  248  .Fa cbarg
 235  249  embedded in
 236  250  .Fa ofmt_arg ,
 237  251  described in
 238  252  .Sx Data Structures .
 239  253  .Pp
 240  254  The callback function should fill
 241  255  .Fa buf
 242  256  with the string to be printed for the field using the data in
 243  257  .Fa cbarg .
      258 +.Ss Fn ofmt_print_header
      259 +The
      260 +.Fn ofmt_print_header
      261 +function prints the output header.
      262 +This is usually done as part of calling
      263 +.Fn ofmt_print ,
      264 +but is skipped when using
      265 +.Dv OFMT_NOHEADER .
      266 +This function allows you to insert it when and where desired.
 244  267  .Ss Fn ofmt_update_winsize
 245  268  The
 246  269  .Fn ofmt_update_winsize
 247  270  function updates the window size information
 248  271  .Pq which is initially computed when the handle is created
 249  272  in the
 250  273  .Fa ofmt .
 251  274  If the
 252  275  .Dv TIOCGWINSZ
 253  276  ioctl fails, the window size is set to 80x24.
      277 +.Ss Fn ofmt_set_fs
      278 +The
      279 +.Fn ofmt_set_fs
      280 +function sets the output field separator for parsable output.
 254  281  .Ss Fn ofmt_strerror
 255  282  The
 256  283  .Fn ofmt_strerror
 257  284  function returns error diagnostics in
 258  285  .Fa buf
 259  286  using the information in the
 260  287  .Fa ofmt
 261  288  and
 262  289  .Fa error .
 263  290  .Pp
↓ open down ↓ 55 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX