(root)/
util-linux-2.39/
include/
jsonwrt.h
       1  /*
       2   * No copyright is claimed.  This code is in the public domain; do with
       3   * it what you wish.
       4   */
       5  #ifndef UTIL_LINUX_JSONWRT_H
       6  #define UTIL_LINUX_JSONWRT_H
       7  
       8  enum {
       9  	UL_JSON_OBJECT,
      10  	UL_JSON_ARRAY,
      11  	UL_JSON_VALUE
      12  };
      13  
      14  struct ul_jsonwrt {
      15  	FILE *out;
      16  	int indent;
      17  
      18  	unsigned int after_close :1;
      19  };
      20  
      21  void ul_jsonwrt_init(struct ul_jsonwrt *fmt, FILE *out, int indent);
      22  int ul_jsonwrt_is_ready(struct ul_jsonwrt *fmt);
      23  void ul_jsonwrt_indent(struct ul_jsonwrt *fmt);
      24  void ul_jsonwrt_open(struct ul_jsonwrt *fmt, const char *name, int type);
      25  void ul_jsonwrt_close(struct ul_jsonwrt *fmt, int type);
      26  
      27  #define ul_jsonwrt_root_open(_f)	ul_jsonwrt_open(_f, NULL, UL_JSON_OBJECT)
      28  #define ul_jsonwrt_root_close(_f)	ul_jsonwrt_close(_f, UL_JSON_OBJECT)
      29  
      30  #define ul_jsonwrt_array_open(_f, _n)	ul_jsonwrt_open(_f, _n, UL_JSON_ARRAY)
      31  #define ul_jsonwrt_array_close(_f)	ul_jsonwrt_close(_f, UL_JSON_ARRAY)
      32  
      33  #define ul_jsonwrt_object_open(_f, _n)	ul_jsonwrt_open(_f, _n, UL_JSON_OBJECT)
      34  #define ul_jsonwrt_object_close(_f)	ul_jsonwrt_close(_f, UL_JSON_OBJECT)
      35  
      36  #define ul_jsonwrt_value_open(_f, _n)	ul_jsonwrt_open(_f, _n, UL_JSON_VALUE)
      37  #define ul_jsonwrt_value_close(_f)	ul_jsonwrt_close(_f, UL_JSON_VALUE)
      38  
      39  
      40  void ul_jsonwrt_value_raw(struct ul_jsonwrt *fmt,
      41  			const char *name, const char *data);
      42  void ul_jsonwrt_value_s(struct ul_jsonwrt *fmt,
      43  			const char *name, const char *data);
      44  void ul_jsonwrt_value_u64(struct ul_jsonwrt *fmt,
      45  			const char *name, uint64_t data);
      46  void ul_jsonwrt_value_boolean(struct ul_jsonwrt *fmt,
      47  			const char *name, int data);
      48  void ul_jsonwrt_value_null(struct ul_jsonwrt *fmt,
      49  			const char *name);
      50  
      51  #endif /* UTIL_LINUX_JSONWRT_H */