json.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef JSON_H
  3. #define JSON_H 1
  4. #include "jsmn.h"
  5. jsmntok_t *parse_json(const char *fn, char **map, size_t *size, int *len);
  6. void free_json(char *map, size_t size, jsmntok_t *tokens);
  7. int json_line(char *map, jsmntok_t *t);
  8. const char *json_name(jsmntok_t *t);
  9. int json_streq(char *map, jsmntok_t *t, const char *s);
  10. int json_len(jsmntok_t *t);
  11. extern int verbose;
  12. #include <stdbool.h>
  13. extern int eprintf(int level, int var, const char *fmt, ...);
  14. #define pr_fmt(fmt) fmt
  15. #define pr_err(fmt, ...) \
  16. eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
  17. #define pr_info(fmt, ...) \
  18. eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__)
  19. #define pr_debug(fmt, ...) \
  20. eprintf(2, verbose, pr_fmt(fmt), ##__VA_ARGS__)
  21. #ifndef roundup
  22. #define roundup(x, y) ( \
  23. { \
  24. const typeof(y) __y = y; \
  25. (((x) + (__y - 1)) / __y) * __y; \
  26. } \
  27. )
  28. #endif
  29. #endif