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>

@@ -23,10 +23,11 @@
  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
 /*
+ * Copyright (c) 2015 by Delphix. All rights reserved.
  * Copyright 2017 Joyent, Inc.
  */
 
 #ifndef _OFMT_H
 #define _OFMT_H

@@ -125,16 +126,16 @@
  * handle is first created. If the caller wishes to adjust the window size
  * after the handle has been created (e.g., on the reception of SIGWINCH by the
  * caller), the function ofmt_update_winsize(handle) may be called.
  */
 
-#include <sys/types.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#include <sys/types.h>
+
 /*
  * Recommended buffer size for buffers passed, for example, to ofmt_strerror().
  */
 #define OFMT_BUFSIZE            256
 

@@ -185,23 +186,35 @@
 
 #define OFMT_PARSABLE   0x00000001 /* machine parsable mode */
 #define OFMT_WRAP       0x00000002 /* wrap output if field width is exceeded */
 #define OFMT_MULTILINE  0x00000004 /* "long" output: "name: value" lines */
 #define OFMT_RIGHTJUST  0x00000008 /* right justified output */
+#define OFMT_NOHEADER   0x00000010 /* do not automatically print header lines */
 
 /*
  * ofmt_close() must be called to free resources associated
  * with the ofmt_handle_t
  */
 extern void ofmt_close(ofmt_handle_t);
 
 /*
+ * Set the field separator used in parsable output (default is ':').
+ */
+extern void ofmt_set_fs(ofmt_handle_t, char);
+
+/*
  * ofmt_print() emits one row of output
  */
 extern void ofmt_print(ofmt_handle_t, void *);
 
 /*
+ * ofmt_print_header() prints the header line. It can be used with
+ * OFMT_NOHEADER to control exactly when the header gets printed.
+ */
+extern void ofmt_print_header(ofmt_handle_t);
+
+/*
  * ofmt_update_winsize() updates the window size information for ofmt_handle_t
  */
 extern void ofmt_update_winsize(ofmt_handle_t);
 
 /*