~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/json_writer.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
  2 /*
  3  * Simple streaming JSON writer
  4  *
  5  * This takes care of the annoying bits of JSON syntax like the commas
  6  * after elements
  7  *
  8  * Authors:     Stephen Hemminger <stephen@networkplumber.org>
  9  */
 10 
 11 #ifndef _JSON_WRITER_H_
 12 #define _JSON_WRITER_H_
 13 
 14 #include <stdbool.h>
 15 #include <stdint.h>
 16 #include <stdarg.h>
 17 #include <stdio.h>
 18 #include <linux/compiler.h>
 19 
 20 /* Opaque class structure */
 21 typedef struct json_writer json_writer_t;
 22 
 23 /* Create a new JSON stream */
 24 json_writer_t *jsonw_new(FILE *f);
 25 /* End output to JSON stream */
 26 void jsonw_destroy(json_writer_t **self_p);
 27 
 28 /* Cause output to have pretty whitespace */
 29 void jsonw_pretty(json_writer_t *self, bool on);
 30 
 31 /* Reset separator to create new JSON */
 32 void jsonw_reset(json_writer_t *self);
 33 
 34 /* Add property name */
 35 void jsonw_name(json_writer_t *self, const char *name);
 36 
 37 /* Add value  */
 38 void __printf(2, 0) jsonw_vprintf_enquote(json_writer_t *self, const char *fmt,
 39                                           va_list ap);
 40 void __printf(2, 3) jsonw_printf(json_writer_t *self, const char *fmt, ...);
 41 void jsonw_string(json_writer_t *self, const char *value);
 42 void jsonw_bool(json_writer_t *self, bool value);
 43 void jsonw_float(json_writer_t *self, double number);
 44 void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num);
 45 void jsonw_uint(json_writer_t *self, uint64_t number);
 46 void jsonw_hu(json_writer_t *self, unsigned short number);
 47 void jsonw_int(json_writer_t *self, int64_t number);
 48 void jsonw_null(json_writer_t *self);
 49 void jsonw_lluint(json_writer_t *self, unsigned long long int num);
 50 
 51 /* Useful Combinations of name and value */
 52 void jsonw_string_field(json_writer_t *self, const char *prop, const char *val);
 53 void jsonw_bool_field(json_writer_t *self, const char *prop, bool value);
 54 void jsonw_float_field(json_writer_t *self, const char *prop, double num);
 55 void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num);
 56 void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num);
 57 void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num);
 58 void jsonw_null_field(json_writer_t *self, const char *prop);
 59 void jsonw_lluint_field(json_writer_t *self, const char *prop,
 60                         unsigned long long int num);
 61 void jsonw_float_field_fmt(json_writer_t *self, const char *prop,
 62                            const char *fmt, double val);
 63 
 64 /* Collections */
 65 void jsonw_start_object(json_writer_t *self);
 66 void jsonw_end_object(json_writer_t *self);
 67 
 68 void jsonw_start_array(json_writer_t *self);
 69 void jsonw_end_array(json_writer_t *self);
 70 
 71 /* Override default exception handling */
 72 typedef void (jsonw_err_handler_fn)(const char *);
 73 
 74 #endif /* _JSON_WRITER_H_ */
 75 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php