forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/tools/bpf/bpftool/json_writer.h
....@@ -1,13 +1,9 @@
1
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
12 /*
23 * Simple streaming JSON writer
34 *
45 * This takes care of the annoying bits of JSON syntax like the commas
56 * after elements
6
- *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License
9
- * as published by the Free Software Foundation; either version
10
- * 2 of the License, or (at your option) any later version.
117 *
128 * Authors: Stephen Hemminger <stephen@networkplumber.org>
139 */
....@@ -18,6 +14,7 @@
1814 #include <stdbool.h>
1915 #include <stdint.h>
2016 #include <stdarg.h>
17
+#include <linux/compiler.h>
2118
2219 /* Opaque class structure */
2320 typedef struct json_writer json_writer_t;
....@@ -30,12 +27,16 @@
3027 /* Cause output to have pretty whitespace */
3128 void jsonw_pretty(json_writer_t *self, bool on);
3229
30
+/* Reset separator to create new JSON */
31
+void jsonw_reset(json_writer_t *self);
32
+
3333 /* Add property name */
3434 void jsonw_name(json_writer_t *self, const char *name);
3535
3636 /* Add value */
37
-void jsonw_vprintf_enquote(json_writer_t *self, const char *fmt, va_list ap);
38
-void jsonw_printf(json_writer_t *self, const char *fmt, ...);
37
+void __printf(2, 0) jsonw_vprintf_enquote(json_writer_t *self, const char *fmt,
38
+ va_list ap);
39
+void __printf(2, 3) jsonw_printf(json_writer_t *self, const char *fmt, ...);
3940 void jsonw_string(json_writer_t *self, const char *value);
4041 void jsonw_bool(json_writer_t *self, bool value);
4142 void jsonw_float(json_writer_t *self, double number);