You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

json_tokener.h 2.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * $Id: json_tokener.h,v 1.10 2006/07/25 03:24:50 mclark Exp $
  3. *
  4. * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  5. * Michael Clark <michael@metaparadigm.com>
  6. *
  7. * This library is free software; you can redistribute it and/or modify
  8. * it under the terms of the MIT license. See COPYING for details.
  9. *
  10. */
  11. #ifndef _json_tokener_h_
  12. #define _json_tokener_h_
  13. #include "json_object.h"
  14. enum json_tokener_error {
  15. json_tokener_success,
  16. json_tokener_continue,
  17. json_tokener_error_depth,
  18. json_tokener_error_parse_eof,
  19. json_tokener_error_parse_unexpected,
  20. json_tokener_error_parse_null,
  21. json_tokener_error_parse_boolean,
  22. json_tokener_error_parse_number,
  23. json_tokener_error_parse_array,
  24. json_tokener_error_parse_object_key_name,
  25. json_tokener_error_parse_object_key_sep,
  26. json_tokener_error_parse_object_value_sep,
  27. json_tokener_error_parse_string,
  28. json_tokener_error_parse_comment
  29. };
  30. enum json_tokener_state {
  31. json_tokener_state_eatws,
  32. json_tokener_state_start,
  33. json_tokener_state_finish,
  34. json_tokener_state_null,
  35. json_tokener_state_comment_start,
  36. json_tokener_state_comment,
  37. json_tokener_state_comment_eol,
  38. json_tokener_state_comment_end,
  39. json_tokener_state_string,
  40. json_tokener_state_string_escape,
  41. json_tokener_state_escape_unicode,
  42. json_tokener_state_boolean,
  43. json_tokener_state_number,
  44. json_tokener_state_array,
  45. json_tokener_state_array_add,
  46. json_tokener_state_array_sep,
  47. json_tokener_state_object_field_start,
  48. json_tokener_state_object_field,
  49. json_tokener_state_object_field_end,
  50. json_tokener_state_object_value,
  51. json_tokener_state_object_value_add,
  52. json_tokener_state_object_sep
  53. };
  54. struct json_tokener_srec
  55. {
  56. enum json_tokener_state state, saved_state;
  57. struct json_object *obj;
  58. struct json_object *current;
  59. char *obj_field_name;
  60. };
  61. #define JSON_TOKENER_MAX_DEPTH 32
  62. struct json_tokener
  63. {
  64. char *str;
  65. struct printbuf *pb;
  66. int depth, is_double, st_pos, char_offset;
  67. ptrdiff_t err;
  68. unsigned int ucs_char;
  69. char quote_char;
  70. struct json_tokener_srec stack[JSON_TOKENER_MAX_DEPTH];
  71. };
  72. extern const char* json_tokener_errors[];
  73. extern struct json_tokener* json_tokener_new();
  74. extern void json_tokener_free(struct json_tokener *tok);
  75. extern void json_tokener_reset(struct json_tokener *tok);
  76. extern struct json_object* json_tokener_parse(char *str);
  77. extern struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
  78. char *str, int len);
  79. #endif

No Description

Contributors (1)