json-streamer.h 984 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * JSON streaming support
  3. *
  4. * Copyright IBM, Corp. 2009
  5. *
  6. * Authors:
  7. * Anthony Liguori <aliguori@us.ibm.com>
  8. *
  9. * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
  10. * See the COPYING.LIB file in the top-level directory.
  11. *
  12. */
  13. #ifndef QEMU_JSON_STREAMER_H
  14. #define QEMU_JSON_STREAMER_H
  15. #include "qlist.h"
  16. #include "json-lexer.h"
  17. typedef struct JSONMessageParser
  18. {
  19. void (*emit)(struct JSONMessageParser *parser, QList *tokens);
  20. JSONLexer lexer;
  21. int brace_count;
  22. int bracket_count;
  23. QList *tokens;
  24. uint64_t token_size;
  25. } JSONMessageParser;
  26. void json_message_parser_init(JSONMessageParser *parser,
  27. void (*func)(JSONMessageParser *, QList *));
  28. int json_message_parser_feed(JSONMessageParser *parser,
  29. const char *buffer, size_t size);
  30. int json_message_parser_flush(JSONMessageParser *parser);
  31. void json_message_parser_destroy(JSONMessageParser *parser);
  32. #endif