ctags.rb 1.0.0 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (323) hide show
  1. checksums.yaml +15 -0
  2. data/Gemfile +2 -1
  3. data/README.md +49 -0
  4. data/Rakefile +19 -0
  5. data/bench.rb +28 -0
  6. data/ctags.rb.gemspec +1 -1
  7. data/ext/.gitignore +1 -1
  8. data/ext/extconf.rb +30 -6
  9. data/ext/vendor/exuberant-ctags/entry.c +70 -1
  10. data/ext/vendor/exuberant-ctags/main.c +68 -7
  11. data/ext/vendor/exuberant-ctags/options.c +12 -12
  12. data/ext/vendor/exuberant-ctags/options.h +1 -1
  13. data/ext/vendor/exuberant-ctags/parse.c +2 -2
  14. data/ext/vendor/exuberant-ctags/read.c +8 -3
  15. data/ext/vendor/exuberant-ctags/read.h +4 -1
  16. data/ext/vendor/exuberant-ctags/routines.c +31 -8
  17. data/ext/vendor/exuberant-ctags/ruby.c +62 -7
  18. data/ext/vendor/fmemopen/README.md +49 -0
  19. data/ext/vendor/fmemopen/fmemopen.c +92 -0
  20. data/ext/vendor/fmemopen/fmemopen.h +52 -0
  21. data/ext/vendor/jansson-2.5/CHANGES +554 -0
  22. data/ext/vendor/jansson-2.5/LICENSE +19 -0
  23. data/ext/vendor/jansson-2.5/Makefile.am +15 -0
  24. data/ext/vendor/jansson-2.5/Makefile.in +825 -0
  25. data/ext/vendor/jansson-2.5/README.rst +63 -0
  26. data/ext/vendor/jansson-2.5/aclocal.m4 +9674 -0
  27. data/ext/vendor/jansson-2.5/config.guess +1530 -0
  28. data/ext/vendor/jansson-2.5/config.h.in +84 -0
  29. data/ext/vendor/jansson-2.5/config.sub +1782 -0
  30. data/ext/vendor/jansson-2.5/configure +13931 -0
  31. data/ext/vendor/jansson-2.5/configure.ac +57 -0
  32. data/ext/vendor/jansson-2.5/depcomp +708 -0
  33. data/ext/vendor/jansson-2.5/doc/Makefile.am +20 -0
  34. data/ext/vendor/jansson-2.5/doc/Makefile.in +401 -0
  35. data/ext/vendor/jansson-2.5/doc/README +5 -0
  36. data/ext/vendor/jansson-2.5/doc/apiref.rst +1487 -0
  37. data/ext/vendor/jansson-2.5/doc/changes.rst +5 -0
  38. data/ext/vendor/jansson-2.5/doc/conf.py +217 -0
  39. data/ext/vendor/jansson-2.5/doc/conformance.rst +114 -0
  40. data/ext/vendor/jansson-2.5/doc/ext/refcounting.py +59 -0
  41. data/ext/vendor/jansson-2.5/doc/gettingstarted.rst +237 -0
  42. data/ext/vendor/jansson-2.5/doc/github_commits.c +192 -0
  43. data/ext/vendor/jansson-2.5/doc/index.rst +53 -0
  44. data/ext/vendor/jansson-2.5/doc/portability.rst +52 -0
  45. data/ext/vendor/jansson-2.5/doc/tutorial.rst +286 -0
  46. data/ext/vendor/jansson-2.5/doc/upgrading.rst +76 -0
  47. data/ext/vendor/jansson-2.5/install-sh +527 -0
  48. data/ext/vendor/jansson-2.5/jansson.pc.in +10 -0
  49. data/ext/vendor/jansson-2.5/ltmain.sh +9661 -0
  50. data/ext/vendor/jansson-2.5/missing +331 -0
  51. data/ext/vendor/jansson-2.5/src/Makefile.am +24 -0
  52. data/ext/vendor/jansson-2.5/src/Makefile.in +613 -0
  53. data/ext/vendor/jansson-2.5/src/dump.c +456 -0
  54. data/ext/vendor/jansson-2.5/src/error.c +63 -0
  55. data/ext/vendor/jansson-2.5/src/hashtable.c +360 -0
  56. data/ext/vendor/jansson-2.5/src/hashtable.h +180 -0
  57. data/ext/vendor/jansson-2.5/src/jansson.def +63 -0
  58. data/ext/vendor/jansson-2.5/src/jansson.h +281 -0
  59. data/ext/vendor/jansson-2.5/src/jansson_config.h +39 -0
  60. data/ext/vendor/jansson-2.5/src/jansson_config.h.in +39 -0
  61. data/ext/vendor/jansson-2.5/src/jansson_private.h +93 -0
  62. data/ext/vendor/jansson-2.5/src/load.c +1077 -0
  63. data/ext/vendor/jansson-2.5/src/memory.c +56 -0
  64. data/ext/vendor/jansson-2.5/src/pack_unpack.c +762 -0
  65. data/ext/vendor/jansson-2.5/src/strbuffer.c +116 -0
  66. data/ext/vendor/jansson-2.5/src/strbuffer.h +33 -0
  67. data/ext/vendor/jansson-2.5/src/strconv.c +134 -0
  68. data/ext/vendor/jansson-2.5/src/utf.c +190 -0
  69. data/ext/vendor/jansson-2.5/src/utf.h +39 -0
  70. data/ext/vendor/jansson-2.5/src/value.c +950 -0
  71. data/ext/vendor/jansson-2.5/test/Makefile.am +10 -0
  72. data/ext/vendor/jansson-2.5/test/Makefile.in +684 -0
  73. data/ext/vendor/jansson-2.5/test/bin/Makefile.am +5 -0
  74. data/ext/vendor/jansson-2.5/test/bin/Makefile.in +498 -0
  75. data/ext/vendor/jansson-2.5/test/bin/json_process.c +349 -0
  76. data/ext/vendor/jansson-2.5/test/run-suites +50 -0
  77. data/ext/vendor/jansson-2.5/test/scripts/run-tests.sh +100 -0
  78. data/ext/vendor/jansson-2.5/test/scripts/valgrind.sh +35 -0
  79. data/ext/vendor/jansson-2.5/test/suites/Makefile.am +2 -0
  80. data/ext/vendor/jansson-2.5/test/suites/Makefile.in +580 -0
  81. data/ext/vendor/jansson-2.5/test/suites/api/Makefile.am +34 -0
  82. data/ext/vendor/jansson-2.5/test/suites/api/Makefile.in +632 -0
  83. data/ext/vendor/jansson-2.5/test/suites/api/check-exports +23 -0
  84. data/ext/vendor/jansson-2.5/test/suites/api/run +36 -0
  85. data/ext/vendor/jansson-2.5/test/suites/api/test_array.c +432 -0
  86. data/ext/vendor/jansson-2.5/test/suites/api/test_copy.c +318 -0
  87. data/ext/vendor/jansson-2.5/test/suites/api/test_dump.c +190 -0
  88. data/ext/vendor/jansson-2.5/test/suites/api/test_dump_callback.c +81 -0
  89. data/ext/vendor/jansson-2.5/test/suites/api/test_equal.c +189 -0
  90. data/ext/vendor/jansson-2.5/test/suites/api/test_load.c +166 -0
  91. data/ext/vendor/jansson-2.5/test/suites/api/test_load_callback.c +75 -0
  92. data/ext/vendor/jansson-2.5/test/suites/api/test_loadb.c +36 -0
  93. data/ext/vendor/jansson-2.5/test/suites/api/test_memory_funcs.c +82 -0
  94. data/ext/vendor/jansson-2.5/test/suites/api/test_number.c +73 -0
  95. data/ext/vendor/jansson-2.5/test/suites/api/test_object.c +511 -0
  96. data/ext/vendor/jansson-2.5/test/suites/api/test_pack.c +283 -0
  97. data/ext/vendor/jansson-2.5/test/suites/api/test_simple.c +199 -0
  98. data/ext/vendor/jansson-2.5/test/suites/api/test_unpack.c +373 -0
  99. data/ext/vendor/jansson-2.5/test/suites/api/util.h +74 -0
  100. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/encoded-surrogate-half/error +2 -0
  101. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/encoded-surrogate-half/input +1 -0
  102. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-after-backslash/error +2 -0
  103. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-after-backslash/input +1 -0
  104. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-array/error +2 -0
  105. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-array/input +1 -0
  106. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/error +2 -0
  107. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/input +1 -0
  108. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-escape/error +2 -0
  109. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-escape/input +1 -0
  110. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-exponent/error +2 -0
  111. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-exponent/input +1 -0
  112. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-identifier/error +2 -0
  113. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-identifier/input +1 -0
  114. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-int/error +2 -0
  115. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-int/input +1 -0
  116. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/error +2 -0
  117. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/input +1 -0
  118. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-string/error +2 -0
  119. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-string/input +1 -0
  120. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/lone-invalid-utf-8/error +2 -0
  121. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/lone-invalid-utf-8/input +1 -0
  122. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/lone-utf-8-continuation-byte/error +2 -0
  123. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/lone-utf-8-continuation-byte/input +1 -0
  124. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/not-in-unicode-range/error +2 -0
  125. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/not-in-unicode-range/input +1 -0
  126. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/overlong-3-byte-encoding/error +2 -0
  127. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/overlong-3-byte-encoding/input +1 -0
  128. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/overlong-4-byte-encoding/error +2 -0
  129. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/overlong-4-byte-encoding/input +1 -0
  130. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/overlong-ascii-encoding/error +2 -0
  131. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/overlong-ascii-encoding/input +1 -0
  132. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/restricted-utf-8/error +2 -0
  133. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/restricted-utf-8/input +1 -0
  134. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/run +27 -0
  135. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/truncated-utf-8/error +2 -0
  136. data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/truncated-utf-8/input +1 -0
  137. data/ext/vendor/jansson-2.5/test/suites/invalid/apostrophe/error +2 -0
  138. data/ext/vendor/jansson-2.5/test/suites/invalid/apostrophe/input +1 -0
  139. data/ext/vendor/jansson-2.5/test/suites/invalid/ascii-unicode-identifier/error +2 -0
  140. data/ext/vendor/jansson-2.5/test/suites/invalid/ascii-unicode-identifier/input +1 -0
  141. data/ext/vendor/jansson-2.5/test/suites/invalid/brace-comma/error +2 -0
  142. data/ext/vendor/jansson-2.5/test/suites/invalid/brace-comma/input +1 -0
  143. data/ext/vendor/jansson-2.5/test/suites/invalid/bracket-comma/error +2 -0
  144. data/ext/vendor/jansson-2.5/test/suites/invalid/bracket-comma/input +1 -0
  145. data/ext/vendor/jansson-2.5/test/suites/invalid/bracket-one-comma/error.normal +2 -0
  146. data/ext/vendor/jansson-2.5/test/suites/invalid/bracket-one-comma/error.strip +2 -0
  147. data/ext/vendor/jansson-2.5/test/suites/invalid/bracket-one-comma/input +1 -0
  148. data/ext/vendor/jansson-2.5/test/suites/invalid/empty/error +2 -0
  149. data/ext/vendor/jansson-2.5/test/suites/invalid/empty/input +0 -0
  150. data/ext/vendor/jansson-2.5/test/suites/invalid/escaped-null-byte-in-string/error +2 -0
  151. data/ext/vendor/jansson-2.5/test/suites/invalid/escaped-null-byte-in-string/input +1 -0
  152. data/ext/vendor/jansson-2.5/test/suites/invalid/extra-comma-in-array/error +2 -0
  153. data/ext/vendor/jansson-2.5/test/suites/invalid/extra-comma-in-array/input +1 -0
  154. data/ext/vendor/jansson-2.5/test/suites/invalid/extra-comma-in-multiline-array/error +2 -0
  155. data/ext/vendor/jansson-2.5/test/suites/invalid/extra-comma-in-multiline-array/input +6 -0
  156. data/ext/vendor/jansson-2.5/test/suites/invalid/garbage-after-newline/error +2 -0
  157. data/ext/vendor/jansson-2.5/test/suites/invalid/garbage-after-newline/input +2 -0
  158. data/ext/vendor/jansson-2.5/test/suites/invalid/garbage-at-the-end/error +2 -0
  159. data/ext/vendor/jansson-2.5/test/suites/invalid/garbage-at-the-end/input +1 -0
  160. data/ext/vendor/jansson-2.5/test/suites/invalid/integer-starting-with-zero/error +2 -0
  161. data/ext/vendor/jansson-2.5/test/suites/invalid/integer-starting-with-zero/input +1 -0
  162. data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-escape/error +2 -0
  163. data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-escape/input +1 -0
  164. data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-identifier/error +2 -0
  165. data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-identifier/input +1 -0
  166. data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-negative-integer/error +2 -0
  167. data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-negative-integer/input +1 -0
  168. data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-negative-real/error +2 -0
  169. data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-negative-real/input +1 -0
  170. data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-second-surrogate/error +2 -0
  171. data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-second-surrogate/input +1 -0
  172. data/ext/vendor/jansson-2.5/test/suites/invalid/lone-open-brace/error.normal +2 -0
  173. data/ext/vendor/jansson-2.5/test/suites/invalid/lone-open-brace/error.strip +2 -0
  174. data/ext/vendor/jansson-2.5/test/suites/invalid/lone-open-brace/input +1 -0
  175. data/ext/vendor/jansson-2.5/test/suites/invalid/lone-open-bracket/error.normal +2 -0
  176. data/ext/vendor/jansson-2.5/test/suites/invalid/lone-open-bracket/error.strip +2 -0
  177. data/ext/vendor/jansson-2.5/test/suites/invalid/lone-open-bracket/input +1 -0
  178. data/ext/vendor/jansson-2.5/test/suites/invalid/lone-second-surrogate/error +2 -0
  179. data/ext/vendor/jansson-2.5/test/suites/invalid/lone-second-surrogate/input +1 -0
  180. data/ext/vendor/jansson-2.5/test/suites/invalid/minus-sign-without-number/error +2 -0
  181. data/ext/vendor/jansson-2.5/test/suites/invalid/minus-sign-without-number/input +1 -0
  182. data/ext/vendor/jansson-2.5/test/suites/invalid/negative-integer-starting-with-zero/error +2 -0
  183. data/ext/vendor/jansson-2.5/test/suites/invalid/negative-integer-starting-with-zero/input +1 -0
  184. data/ext/vendor/jansson-2.5/test/suites/invalid/null-byte-in-string/error +2 -0
  185. data/ext/vendor/jansson-2.5/test/suites/invalid/null-byte-in-string/input +0 -0
  186. data/ext/vendor/jansson-2.5/test/suites/invalid/null-byte-in-string/nostrip +2 -0
  187. data/ext/vendor/jansson-2.5/test/suites/invalid/null-byte-outside-string/error +2 -0
  188. data/ext/vendor/jansson-2.5/test/suites/invalid/null-byte-outside-string/input +0 -0
  189. data/ext/vendor/jansson-2.5/test/suites/invalid/null-byte-outside-string/nostrip +2 -0
  190. data/ext/vendor/jansson-2.5/test/suites/invalid/null/error +2 -0
  191. data/ext/vendor/jansson-2.5/test/suites/invalid/null/input +1 -0
  192. data/ext/vendor/jansson-2.5/test/suites/invalid/object-apostrophes/error +2 -0
  193. data/ext/vendor/jansson-2.5/test/suites/invalid/object-apostrophes/input +1 -0
  194. data/ext/vendor/jansson-2.5/test/suites/invalid/object-garbage-at-end/error +2 -0
  195. data/ext/vendor/jansson-2.5/test/suites/invalid/object-garbage-at-end/input +1 -0
  196. data/ext/vendor/jansson-2.5/test/suites/invalid/object-in-unterminated-array/error.normal +2 -0
  197. data/ext/vendor/jansson-2.5/test/suites/invalid/object-in-unterminated-array/error.strip +2 -0
  198. data/ext/vendor/jansson-2.5/test/suites/invalid/object-in-unterminated-array/input +1 -0
  199. data/ext/vendor/jansson-2.5/test/suites/invalid/object-no-colon/error.normal +2 -0
  200. data/ext/vendor/jansson-2.5/test/suites/invalid/object-no-colon/error.strip +2 -0
  201. data/ext/vendor/jansson-2.5/test/suites/invalid/object-no-colon/input +1 -0
  202. data/ext/vendor/jansson-2.5/test/suites/invalid/object-no-value/error.normal +2 -0
  203. data/ext/vendor/jansson-2.5/test/suites/invalid/object-no-value/error.strip +2 -0
  204. data/ext/vendor/jansson-2.5/test/suites/invalid/object-no-value/input +1 -0
  205. data/ext/vendor/jansson-2.5/test/suites/invalid/object-unterminated-value/error.normal +2 -0
  206. data/ext/vendor/jansson-2.5/test/suites/invalid/object-unterminated-value/error.strip +2 -0
  207. data/ext/vendor/jansson-2.5/test/suites/invalid/object-unterminated-value/input +1 -0
  208. data/ext/vendor/jansson-2.5/test/suites/invalid/real-garbage-after-e/error +2 -0
  209. data/ext/vendor/jansson-2.5/test/suites/invalid/real-garbage-after-e/input +1 -0
  210. data/ext/vendor/jansson-2.5/test/suites/invalid/real-negative-overflow/error +2 -0
  211. data/ext/vendor/jansson-2.5/test/suites/invalid/real-negative-overflow/input +1 -0
  212. data/ext/vendor/jansson-2.5/test/suites/invalid/real-positive-overflow/error +2 -0
  213. data/ext/vendor/jansson-2.5/test/suites/invalid/real-positive-overflow/input +1 -0
  214. data/ext/vendor/jansson-2.5/test/suites/invalid/real-truncated-at-e/error +2 -0
  215. data/ext/vendor/jansson-2.5/test/suites/invalid/real-truncated-at-e/input +1 -0
  216. data/ext/vendor/jansson-2.5/test/suites/invalid/real-truncated-at-point/error +2 -0
  217. data/ext/vendor/jansson-2.5/test/suites/invalid/real-truncated-at-point/input +1 -0
  218. data/ext/vendor/jansson-2.5/test/suites/invalid/run +57 -0
  219. data/ext/vendor/jansson-2.5/test/suites/invalid/tab-character-in-string/error +2 -0
  220. data/ext/vendor/jansson-2.5/test/suites/invalid/tab-character-in-string/input +1 -0
  221. data/ext/vendor/jansson-2.5/test/suites/invalid/too-big-negative-integer/error +2 -0
  222. data/ext/vendor/jansson-2.5/test/suites/invalid/too-big-negative-integer/input +1 -0
  223. data/ext/vendor/jansson-2.5/test/suites/invalid/too-big-positive-integer/error +2 -0
  224. data/ext/vendor/jansson-2.5/test/suites/invalid/too-big-positive-integer/input +1 -0
  225. data/ext/vendor/jansson-2.5/test/suites/invalid/truncated-unicode-surrogate/error +2 -0
  226. data/ext/vendor/jansson-2.5/test/suites/invalid/truncated-unicode-surrogate/input +1 -0
  227. data/ext/vendor/jansson-2.5/test/suites/invalid/unicode-identifier/error +2 -0
  228. data/ext/vendor/jansson-2.5/test/suites/invalid/unicode-identifier/input +1 -0
  229. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-array-and-object/error.normal +2 -0
  230. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-array-and-object/error.strip +2 -0
  231. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-array-and-object/input +1 -0
  232. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-array/error.normal +2 -0
  233. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-array/error.strip +2 -0
  234. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-array/input +1 -0
  235. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-empty-key/error.normal +2 -0
  236. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-empty-key/error.strip +2 -0
  237. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-empty-key/input +1 -0
  238. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-key/error.normal +2 -0
  239. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-key/error.strip +2 -0
  240. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-key/input +1 -0
  241. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-object-and-array/error +2 -0
  242. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-object-and-array/input +1 -0
  243. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-string/error.normal +2 -0
  244. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-string/error.strip +2 -0
  245. data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-string/input +1 -0
  246. data/ext/vendor/jansson-2.5/test/suites/valid/complex-array/env +1 -0
  247. data/ext/vendor/jansson-2.5/test/suites/valid/complex-array/input +5 -0
  248. data/ext/vendor/jansson-2.5/test/suites/valid/complex-array/output +1 -0
  249. data/ext/vendor/jansson-2.5/test/suites/valid/empty-array/input +1 -0
  250. data/ext/vendor/jansson-2.5/test/suites/valid/empty-array/output +1 -0
  251. data/ext/vendor/jansson-2.5/test/suites/valid/empty-object-in-array/input +1 -0
  252. data/ext/vendor/jansson-2.5/test/suites/valid/empty-object-in-array/output +1 -0
  253. data/ext/vendor/jansson-2.5/test/suites/valid/empty-object/input +1 -0
  254. data/ext/vendor/jansson-2.5/test/suites/valid/empty-object/output +1 -0
  255. data/ext/vendor/jansson-2.5/test/suites/valid/empty-string/input +1 -0
  256. data/ext/vendor/jansson-2.5/test/suites/valid/empty-string/output +1 -0
  257. data/ext/vendor/jansson-2.5/test/suites/valid/escaped-utf-control-char/input +1 -0
  258. data/ext/vendor/jansson-2.5/test/suites/valid/escaped-utf-control-char/output +1 -0
  259. data/ext/vendor/jansson-2.5/test/suites/valid/false/input +1 -0
  260. data/ext/vendor/jansson-2.5/test/suites/valid/false/output +1 -0
  261. data/ext/vendor/jansson-2.5/test/suites/valid/negative-int/input +1 -0
  262. data/ext/vendor/jansson-2.5/test/suites/valid/negative-int/output +1 -0
  263. data/ext/vendor/jansson-2.5/test/suites/valid/negative-one/input +1 -0
  264. data/ext/vendor/jansson-2.5/test/suites/valid/negative-one/output +1 -0
  265. data/ext/vendor/jansson-2.5/test/suites/valid/negative-zero/input +1 -0
  266. data/ext/vendor/jansson-2.5/test/suites/valid/negative-zero/output +1 -0
  267. data/ext/vendor/jansson-2.5/test/suites/valid/null/input +1 -0
  268. data/ext/vendor/jansson-2.5/test/suites/valid/null/output +1 -0
  269. data/ext/vendor/jansson-2.5/test/suites/valid/one-byte-utf-8/input +1 -0
  270. data/ext/vendor/jansson-2.5/test/suites/valid/one-byte-utf-8/output +1 -0
  271. data/ext/vendor/jansson-2.5/test/suites/valid/real-capital-e-negative-exponent/input +1 -0
  272. data/ext/vendor/jansson-2.5/test/suites/valid/real-capital-e-negative-exponent/output +1 -0
  273. data/ext/vendor/jansson-2.5/test/suites/valid/real-capital-e-positive-exponent/input +1 -0
  274. data/ext/vendor/jansson-2.5/test/suites/valid/real-capital-e-positive-exponent/output +1 -0
  275. data/ext/vendor/jansson-2.5/test/suites/valid/real-capital-e/input +1 -0
  276. data/ext/vendor/jansson-2.5/test/suites/valid/real-capital-e/output +1 -0
  277. data/ext/vendor/jansson-2.5/test/suites/valid/real-exponent/input +1 -0
  278. data/ext/vendor/jansson-2.5/test/suites/valid/real-exponent/output +1 -0
  279. data/ext/vendor/jansson-2.5/test/suites/valid/real-fraction-exponent/input +1 -0
  280. data/ext/vendor/jansson-2.5/test/suites/valid/real-fraction-exponent/output +1 -0
  281. data/ext/vendor/jansson-2.5/test/suites/valid/real-negative-exponent/input +1 -0
  282. data/ext/vendor/jansson-2.5/test/suites/valid/real-negative-exponent/output +1 -0
  283. data/ext/vendor/jansson-2.5/test/suites/valid/real-positive-exponent/input +1 -0
  284. data/ext/vendor/jansson-2.5/test/suites/valid/real-positive-exponent/output +1 -0
  285. data/ext/vendor/jansson-2.5/test/suites/valid/real-underflow/input +1 -0
  286. data/ext/vendor/jansson-2.5/test/suites/valid/real-underflow/output +1 -0
  287. data/ext/vendor/jansson-2.5/test/suites/valid/run +56 -0
  288. data/ext/vendor/jansson-2.5/test/suites/valid/short-string/input +1 -0
  289. data/ext/vendor/jansson-2.5/test/suites/valid/short-string/output +1 -0
  290. data/ext/vendor/jansson-2.5/test/suites/valid/simple-ascii-string/input +1 -0
  291. data/ext/vendor/jansson-2.5/test/suites/valid/simple-ascii-string/output +1 -0
  292. data/ext/vendor/jansson-2.5/test/suites/valid/simple-int-0/input +1 -0
  293. data/ext/vendor/jansson-2.5/test/suites/valid/simple-int-0/output +1 -0
  294. data/ext/vendor/jansson-2.5/test/suites/valid/simple-int-1/input +1 -0
  295. data/ext/vendor/jansson-2.5/test/suites/valid/simple-int-1/output +1 -0
  296. data/ext/vendor/jansson-2.5/test/suites/valid/simple-int-123/input +1 -0
  297. data/ext/vendor/jansson-2.5/test/suites/valid/simple-int-123/output +1 -0
  298. data/ext/vendor/jansson-2.5/test/suites/valid/simple-object/input +1 -0
  299. data/ext/vendor/jansson-2.5/test/suites/valid/simple-object/output +1 -0
  300. data/ext/vendor/jansson-2.5/test/suites/valid/simple-real/input +1 -0
  301. data/ext/vendor/jansson-2.5/test/suites/valid/simple-real/output +1 -0
  302. data/ext/vendor/jansson-2.5/test/suites/valid/string-escapes/input +1 -0
  303. data/ext/vendor/jansson-2.5/test/suites/valid/string-escapes/output +1 -0
  304. data/ext/vendor/jansson-2.5/test/suites/valid/three-byte-utf-8/input +1 -0
  305. data/ext/vendor/jansson-2.5/test/suites/valid/three-byte-utf-8/output +1 -0
  306. data/ext/vendor/jansson-2.5/test/suites/valid/true/input +1 -0
  307. data/ext/vendor/jansson-2.5/test/suites/valid/true/output +1 -0
  308. data/ext/vendor/jansson-2.5/test/suites/valid/two-byte-utf-8/input +1 -0
  309. data/ext/vendor/jansson-2.5/test/suites/valid/two-byte-utf-8/output +1 -0
  310. data/ext/vendor/jansson-2.5/test/suites/valid/utf-8-string/input +1 -0
  311. data/ext/vendor/jansson-2.5/test/suites/valid/utf-8-string/output +1 -0
  312. data/ext/vendor/jansson-2.5/test/suites/valid/utf-surrogate-four-byte-encoding/input +1 -0
  313. data/ext/vendor/jansson-2.5/test/suites/valid/utf-surrogate-four-byte-encoding/output +1 -0
  314. data/ext/vendor/jansson-2.5/win32/jansson_config.h +39 -0
  315. data/ext/vendor/jansson-2.5/win32/vs2010/jansson.sln +20 -0
  316. data/ext/vendor/jansson-2.5/win32/vs2010/jansson.vcxproj +108 -0
  317. data/ext/vendor/jansson-2.5/win32/vs2010/jansson.vcxproj.filters +69 -0
  318. data/ext/vendor/jansson-2.5/win32/vs2010/jansson.vcxproj.user +3 -0
  319. data/lib/ctags.cnf +2 -0
  320. data/lib/ctags/exuberant.rb +129 -17
  321. data/lib/ctags/version.rb +1 -1
  322. data/test/test_ctags.rb +14 -7
  323. metadata +350 -69
@@ -0,0 +1,20 @@
1
+ EXTRA_DIST = conf.py apiref.rst changes.rst conformance.rst \
2
+ gettingstarted.rst github_commits.c index.rst portability.rst \
3
+ tutorial.rst upgrading.rst ext/refcounting.py
4
+
5
+ SPHINXBUILD = sphinx-build
6
+ SPHINXOPTS = -d _build/doctrees $(SPHINXOPTS_EXTRA)
7
+
8
+ html-local:
9
+ $(SPHINXBUILD) -b html $(SPHINXOPTS) $(srcdir) _build/html
10
+
11
+ install-html-local: html
12
+ mkdir -p $(DESTDIR)$(htmldir)
13
+ cp -r _build/html $(DESTDIR)$(htmldir)
14
+
15
+ uninstall-local:
16
+ rm -rf $(DESTDIR)$(htmldir)
17
+
18
+ clean-local:
19
+ rm -rf _build
20
+ rm -f ext/refcounting.pyc
@@ -0,0 +1,401 @@
1
+ # Makefile.in generated by automake 1.11.6 from Makefile.am.
2
+ # @configure_input@
3
+
4
+ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
+ # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
6
+ # Foundation, Inc.
7
+ # This Makefile.in is free software; the Free Software Foundation
8
+ # gives unlimited permission to copy and/or distribute it,
9
+ # with or without modifications, as long as this notice is preserved.
10
+
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13
+ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14
+ # PARTICULAR PURPOSE.
15
+
16
+ @SET_MAKE@
17
+ VPATH = @srcdir@
18
+ am__make_dryrun = \
19
+ { \
20
+ am__dry=no; \
21
+ case $$MAKEFLAGS in \
22
+ *\\[\ \ ]*) \
23
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
24
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
25
+ *) \
26
+ for am__flg in $$MAKEFLAGS; do \
27
+ case $$am__flg in \
28
+ *=*|--*) ;; \
29
+ *n*) am__dry=yes; break;; \
30
+ esac; \
31
+ done;; \
32
+ esac; \
33
+ test $$am__dry = yes; \
34
+ }
35
+ pkgdatadir = $(datadir)/@PACKAGE@
36
+ pkgincludedir = $(includedir)/@PACKAGE@
37
+ pkglibdir = $(libdir)/@PACKAGE@
38
+ pkglibexecdir = $(libexecdir)/@PACKAGE@
39
+ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
40
+ install_sh_DATA = $(install_sh) -c -m 644
41
+ install_sh_PROGRAM = $(install_sh) -c
42
+ install_sh_SCRIPT = $(install_sh) -c
43
+ INSTALL_HEADER = $(INSTALL_DATA)
44
+ transform = $(program_transform_name)
45
+ NORMAL_INSTALL = :
46
+ PRE_INSTALL = :
47
+ POST_INSTALL = :
48
+ NORMAL_UNINSTALL = :
49
+ PRE_UNINSTALL = :
50
+ POST_UNINSTALL = :
51
+ build_triplet = @build@
52
+ host_triplet = @host@
53
+ subdir = doc
54
+ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
55
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
56
+ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
57
+ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
58
+ $(ACLOCAL_M4)
59
+ mkinstalldirs = $(install_sh) -d
60
+ CONFIG_HEADER = $(top_builddir)/config.h
61
+ CONFIG_CLEAN_FILES =
62
+ CONFIG_CLEAN_VPATH_FILES =
63
+ SOURCES =
64
+ DIST_SOURCES =
65
+ am__can_run_installinfo = \
66
+ case $$AM_UPDATE_INFO_DIR in \
67
+ n|no|NO) false;; \
68
+ *) (install-info --version) >/dev/null 2>&1;; \
69
+ esac
70
+ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
71
+ ACLOCAL = @ACLOCAL@
72
+ AMTAR = @AMTAR@
73
+ AR = @AR@
74
+ AUTOCONF = @AUTOCONF@
75
+ AUTOHEADER = @AUTOHEADER@
76
+ AUTOMAKE = @AUTOMAKE@
77
+ AWK = @AWK@
78
+ CC = @CC@
79
+ CCDEPMODE = @CCDEPMODE@
80
+ CFLAGS = @CFLAGS@
81
+ CPP = @CPP@
82
+ CPPFLAGS = @CPPFLAGS@
83
+ CYGPATH_W = @CYGPATH_W@
84
+ DEFS = @DEFS@
85
+ DEPDIR = @DEPDIR@
86
+ DLLTOOL = @DLLTOOL@
87
+ DSYMUTIL = @DSYMUTIL@
88
+ DUMPBIN = @DUMPBIN@
89
+ ECHO_C = @ECHO_C@
90
+ ECHO_N = @ECHO_N@
91
+ ECHO_T = @ECHO_T@
92
+ EGREP = @EGREP@
93
+ EXEEXT = @EXEEXT@
94
+ FGREP = @FGREP@
95
+ GREP = @GREP@
96
+ INSTALL = @INSTALL@
97
+ INSTALL_DATA = @INSTALL_DATA@
98
+ INSTALL_PROGRAM = @INSTALL_PROGRAM@
99
+ INSTALL_SCRIPT = @INSTALL_SCRIPT@
100
+ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
101
+ LD = @LD@
102
+ LDFLAGS = @LDFLAGS@
103
+ LIBOBJS = @LIBOBJS@
104
+ LIBS = @LIBS@
105
+ LIBTOOL = @LIBTOOL@
106
+ LIPO = @LIPO@
107
+ LN_S = @LN_S@
108
+ LTLIBOBJS = @LTLIBOBJS@
109
+ MAKEINFO = @MAKEINFO@
110
+ MANIFEST_TOOL = @MANIFEST_TOOL@
111
+ MKDIR_P = @MKDIR_P@
112
+ NM = @NM@
113
+ NMEDIT = @NMEDIT@
114
+ OBJDUMP = @OBJDUMP@
115
+ OBJEXT = @OBJEXT@
116
+ OTOOL = @OTOOL@
117
+ OTOOL64 = @OTOOL64@
118
+ PACKAGE = @PACKAGE@
119
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
120
+ PACKAGE_NAME = @PACKAGE_NAME@
121
+ PACKAGE_STRING = @PACKAGE_STRING@
122
+ PACKAGE_TARNAME = @PACKAGE_TARNAME@
123
+ PACKAGE_URL = @PACKAGE_URL@
124
+ PACKAGE_VERSION = @PACKAGE_VERSION@
125
+ PATH_SEPARATOR = @PATH_SEPARATOR@
126
+ RANLIB = @RANLIB@
127
+ SED = @SED@
128
+ SET_MAKE = @SET_MAKE@
129
+ SHELL = @SHELL@
130
+ STRIP = @STRIP@
131
+ VERSION = @VERSION@
132
+ abs_builddir = @abs_builddir@
133
+ abs_srcdir = @abs_srcdir@
134
+ abs_top_builddir = @abs_top_builddir@
135
+ abs_top_srcdir = @abs_top_srcdir@
136
+ ac_ct_AR = @ac_ct_AR@
137
+ ac_ct_CC = @ac_ct_CC@
138
+ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
139
+ am__include = @am__include@
140
+ am__leading_dot = @am__leading_dot@
141
+ am__quote = @am__quote@
142
+ am__tar = @am__tar@
143
+ am__untar = @am__untar@
144
+ bindir = @bindir@
145
+ build = @build@
146
+ build_alias = @build_alias@
147
+ build_cpu = @build_cpu@
148
+ build_os = @build_os@
149
+ build_vendor = @build_vendor@
150
+ builddir = @builddir@
151
+ datadir = @datadir@
152
+ datarootdir = @datarootdir@
153
+ docdir = @docdir@
154
+ dvidir = @dvidir@
155
+ exec_prefix = @exec_prefix@
156
+ host = @host@
157
+ host_alias = @host_alias@
158
+ host_cpu = @host_cpu@
159
+ host_os = @host_os@
160
+ host_vendor = @host_vendor@
161
+ htmldir = @htmldir@
162
+ includedir = @includedir@
163
+ infodir = @infodir@
164
+ install_sh = @install_sh@
165
+ json_have_localeconv = @json_have_localeconv@
166
+ json_have_long_long = @json_have_long_long@
167
+ json_inline = @json_inline@
168
+ libdir = @libdir@
169
+ libexecdir = @libexecdir@
170
+ localedir = @localedir@
171
+ localstatedir = @localstatedir@
172
+ mandir = @mandir@
173
+ mkdir_p = @mkdir_p@
174
+ oldincludedir = @oldincludedir@
175
+ pdfdir = @pdfdir@
176
+ prefix = @prefix@
177
+ program_transform_name = @program_transform_name@
178
+ psdir = @psdir@
179
+ sbindir = @sbindir@
180
+ sharedstatedir = @sharedstatedir@
181
+ srcdir = @srcdir@
182
+ sysconfdir = @sysconfdir@
183
+ target_alias = @target_alias@
184
+ top_build_prefix = @top_build_prefix@
185
+ top_builddir = @top_builddir@
186
+ top_srcdir = @top_srcdir@
187
+ EXTRA_DIST = conf.py apiref.rst changes.rst conformance.rst \
188
+ gettingstarted.rst github_commits.c index.rst portability.rst \
189
+ tutorial.rst upgrading.rst ext/refcounting.py
190
+
191
+ SPHINXBUILD = sphinx-build
192
+ SPHINXOPTS = -d _build/doctrees $(SPHINXOPTS_EXTRA)
193
+ all: all-am
194
+
195
+ .SUFFIXES:
196
+ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
197
+ @for dep in $?; do \
198
+ case '$(am__configure_deps)' in \
199
+ *$$dep*) \
200
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
201
+ && { if test -f $@; then exit 0; else break; fi; }; \
202
+ exit 1;; \
203
+ esac; \
204
+ done; \
205
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \
206
+ $(am__cd) $(top_srcdir) && \
207
+ $(AUTOMAKE) --foreign doc/Makefile
208
+ .PRECIOUS: Makefile
209
+ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
210
+ @case '$?' in \
211
+ *config.status*) \
212
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
213
+ *) \
214
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
215
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
216
+ esac;
217
+
218
+ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
219
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
220
+
221
+ $(top_srcdir)/configure: $(am__configure_deps)
222
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
223
+ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
224
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
225
+ $(am__aclocal_m4_deps):
226
+
227
+ mostlyclean-libtool:
228
+ -rm -f *.lo
229
+
230
+ clean-libtool:
231
+ -rm -rf .libs _libs
232
+ tags: TAGS
233
+ TAGS:
234
+
235
+ ctags: CTAGS
236
+ CTAGS:
237
+
238
+
239
+ distdir: $(DISTFILES)
240
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
241
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
242
+ list='$(DISTFILES)'; \
243
+ dist_files=`for file in $$list; do echo $$file; done | \
244
+ sed -e "s|^$$srcdirstrip/||;t" \
245
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
246
+ case $$dist_files in \
247
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
248
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
249
+ sort -u` ;; \
250
+ esac; \
251
+ for file in $$dist_files; do \
252
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
253
+ if test -d $$d/$$file; then \
254
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
255
+ if test -d "$(distdir)/$$file"; then \
256
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
257
+ fi; \
258
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
259
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
260
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
261
+ fi; \
262
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
263
+ else \
264
+ test -f "$(distdir)/$$file" \
265
+ || cp -p $$d/$$file "$(distdir)/$$file" \
266
+ || exit 1; \
267
+ fi; \
268
+ done
269
+ check-am: all-am
270
+ check: check-am
271
+ all-am: Makefile
272
+ installdirs:
273
+ install: install-am
274
+ install-exec: install-exec-am
275
+ install-data: install-data-am
276
+ uninstall: uninstall-am
277
+
278
+ install-am: all-am
279
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
280
+
281
+ installcheck: installcheck-am
282
+ install-strip:
283
+ if test -z '$(STRIP)'; then \
284
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
285
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
286
+ install; \
287
+ else \
288
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
289
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
290
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
291
+ fi
292
+ mostlyclean-generic:
293
+
294
+ clean-generic:
295
+
296
+ distclean-generic:
297
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
298
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
299
+
300
+ maintainer-clean-generic:
301
+ @echo "This command is intended for maintainers to use"
302
+ @echo "it deletes files that may require special tools to rebuild."
303
+ clean: clean-am
304
+
305
+ clean-am: clean-generic clean-libtool clean-local mostlyclean-am
306
+
307
+ distclean: distclean-am
308
+ -rm -f Makefile
309
+ distclean-am: clean-am distclean-generic
310
+
311
+ dvi: dvi-am
312
+
313
+ dvi-am:
314
+
315
+ html: html-am
316
+
317
+ html-am: html-local
318
+
319
+ info: info-am
320
+
321
+ info-am:
322
+
323
+ install-data-am:
324
+
325
+ install-dvi: install-dvi-am
326
+
327
+ install-dvi-am:
328
+
329
+ install-exec-am:
330
+
331
+ install-html: install-html-am
332
+
333
+ install-html-am: install-html-local
334
+
335
+ install-info: install-info-am
336
+
337
+ install-info-am:
338
+
339
+ install-man:
340
+
341
+ install-pdf: install-pdf-am
342
+
343
+ install-pdf-am:
344
+
345
+ install-ps: install-ps-am
346
+
347
+ install-ps-am:
348
+
349
+ installcheck-am:
350
+
351
+ maintainer-clean: maintainer-clean-am
352
+ -rm -f Makefile
353
+ maintainer-clean-am: distclean-am maintainer-clean-generic
354
+
355
+ mostlyclean: mostlyclean-am
356
+
357
+ mostlyclean-am: mostlyclean-generic mostlyclean-libtool
358
+
359
+ pdf: pdf-am
360
+
361
+ pdf-am:
362
+
363
+ ps: ps-am
364
+
365
+ ps-am:
366
+
367
+ uninstall-am: uninstall-local
368
+
369
+ .MAKE: install-am install-strip
370
+
371
+ .PHONY: all all-am check check-am clean clean-generic clean-libtool \
372
+ clean-local distclean distclean-generic distclean-libtool \
373
+ distdir dvi dvi-am html html-am html-local info info-am \
374
+ install install-am install-data install-data-am install-dvi \
375
+ install-dvi-am install-exec install-exec-am install-html \
376
+ install-html-am install-html-local install-info \
377
+ install-info-am install-man install-pdf install-pdf-am \
378
+ install-ps install-ps-am install-strip installcheck \
379
+ installcheck-am installdirs maintainer-clean \
380
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
381
+ mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
382
+ uninstall-local
383
+
384
+
385
+ html-local:
386
+ $(SPHINXBUILD) -b html $(SPHINXOPTS) $(srcdir) _build/html
387
+
388
+ install-html-local: html
389
+ mkdir -p $(DESTDIR)$(htmldir)
390
+ cp -r _build/html $(DESTDIR)$(htmldir)
391
+
392
+ uninstall-local:
393
+ rm -rf $(DESTDIR)$(htmldir)
394
+
395
+ clean-local:
396
+ rm -rf _build
397
+ rm -f ext/refcounting.pyc
398
+
399
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
400
+ # Otherwise a system limit (for SysV at least) may be exceeded.
401
+ .NOEXPORT:
@@ -0,0 +1,5 @@
1
+ To build the documentation, invoke
2
+
3
+ make html
4
+
5
+ Then point your browser to _build/html/index.html.
@@ -0,0 +1,1487 @@
1
+ .. _apiref:
2
+
3
+ *************
4
+ API Reference
5
+ *************
6
+
7
+ .. highlight:: c
8
+
9
+ Preliminaries
10
+ =============
11
+
12
+ All declarations are in :file:`jansson.h`, so it's enough to
13
+
14
+ ::
15
+
16
+ #include <jansson.h>
17
+
18
+ in each source file.
19
+
20
+ All constants are prefixed with ``JSON_`` (except for those describing
21
+ the library version, prefixed with ``JANSSON_``). Other identifiers
22
+ are prefixed with ``json_``. Type names are suffixed with ``_t`` and
23
+ ``typedef``\ 'd so that the ``struct`` keyword need not be used.
24
+
25
+
26
+ Library Version
27
+ ===============
28
+
29
+ The Jansson version is of the form *A.B.C*, where *A* is the major
30
+ version, *B* is the minor version and *C* is the micro version. If the
31
+ micro version is zero, it's omitted from the version string, i.e. the
32
+ version string is just *A.B*.
33
+
34
+ When a new release only fixes bugs and doesn't add new features or
35
+ functionality, the micro version is incremented. When new features are
36
+ added in a backwards compatible way, the minor version is incremented
37
+ and the micro version is set to zero. When there are backwards
38
+ incompatible changes, the major version is incremented and others are
39
+ set to zero.
40
+
41
+ The following preprocessor constants specify the current version of
42
+ the library:
43
+
44
+ ``JANSSON_MAJOR_VERSION``, ``JANSSON_MINOR_VERSION``, ``JANSSON_MICRO_VERSION``
45
+ Integers specifying the major, minor and micro versions,
46
+ respectively.
47
+
48
+ ``JANSSON_VERSION``
49
+ A string representation of the current version, e.g. ``"1.2.1"`` or
50
+ ``"1.3"``.
51
+
52
+ ``JANSSON_VERSION_HEX``
53
+ A 3-byte hexadecimal representation of the version, e.g.
54
+ ``0x010201`` for version 1.2.1 and ``0x010300`` for version 1.3.
55
+ This is useful in numeric comparisions, e.g.::
56
+
57
+ #if JANSSON_VERSION_HEX >= 0x010300
58
+ /* Code specific to version 1.3 and above */
59
+ #endif
60
+
61
+
62
+ Value Representation
63
+ ====================
64
+
65
+ The JSON specification (:rfc:`4627`) defines the following data types:
66
+ *object*, *array*, *string*, *number*, *boolean*, and *null*. JSON
67
+ types are used dynamically; arrays and objects can hold any other data
68
+ type, including themselves. For this reason, Jansson's type system is
69
+ also dynamic in nature. There's one C type to represent all JSON
70
+ values, and this structure knows the type of the JSON value it holds.
71
+
72
+ .. type:: json_t
73
+
74
+ This data structure is used throughout the library to represent all
75
+ JSON values. It always contains the type of the JSON value it holds
76
+ and the value's reference count. The rest depends on the type of the
77
+ value.
78
+
79
+ Objects of :type:`json_t` are always used through a pointer. There
80
+ are APIs for querying the type, manipulating the reference count, and
81
+ for constructing and manipulating values of different types.
82
+
83
+ Unless noted otherwise, all API functions return an error value if an
84
+ error occurs. Depending on the function's signature, the error value
85
+ is either *NULL* or -1. Invalid arguments or invalid input are
86
+ apparent sources for errors. Memory allocation and I/O operations may
87
+ also cause errors.
88
+
89
+
90
+ Type
91
+ ----
92
+
93
+ The type of a JSON value is queried and tested using the following
94
+ functions:
95
+
96
+ .. type:: enum json_type
97
+
98
+ The type of a JSON value. The following members are defined:
99
+
100
+ +--------------------+
101
+ | ``JSON_OBJECT`` |
102
+ +--------------------+
103
+ | ``JSON_ARRAY`` |
104
+ +--------------------+
105
+ | ``JSON_STRING`` |
106
+ +--------------------+
107
+ | ``JSON_INTEGER`` |
108
+ +--------------------+
109
+ | ``JSON_REAL`` |
110
+ +--------------------+
111
+ | ``JSON_TRUE`` |
112
+ +--------------------+
113
+ | ``JSON_FALSE`` |
114
+ +--------------------+
115
+ | ``JSON_NULL`` |
116
+ +--------------------+
117
+
118
+ These correspond to JSON object, array, string, number, boolean and
119
+ null. A number is represented by either a value of the type
120
+ ``JSON_INTEGER`` or of the type ``JSON_REAL``. A true boolean value
121
+ is represented by a value of the type ``JSON_TRUE`` and false by a
122
+ value of the type ``JSON_FALSE``.
123
+
124
+ .. function:: int json_typeof(const json_t *json)
125
+
126
+ Return the type of the JSON value (a :type:`json_type` cast to
127
+ :type:`int`). *json* MUST NOT be *NULL*. This function is actually
128
+ implemented as a macro for speed.
129
+
130
+ .. function:: json_is_object(const json_t *json)
131
+ json_is_array(const json_t *json)
132
+ json_is_string(const json_t *json)
133
+ json_is_integer(const json_t *json)
134
+ json_is_real(const json_t *json)
135
+ json_is_true(const json_t *json)
136
+ json_is_false(const json_t *json)
137
+ json_is_null(const json_t *json)
138
+
139
+ These functions (actually macros) return true (non-zero) for values
140
+ of the given type, and false (zero) for values of other types and
141
+ for *NULL*.
142
+
143
+ .. function:: json_is_number(const json_t *json)
144
+
145
+ Returns true for values of types ``JSON_INTEGER`` and
146
+ ``JSON_REAL``, and false for other types and for *NULL*.
147
+
148
+ .. function:: json_is_boolean(const json_t *json)
149
+
150
+ Returns true for types ``JSON_TRUE`` and ``JSON_FALSE``, and false
151
+ for values of other types and for *NULL*.
152
+
153
+
154
+ .. _apiref-reference-count:
155
+
156
+ Reference Count
157
+ ---------------
158
+
159
+ The reference count is used to track whether a value is still in use
160
+ or not. When a value is created, it's reference count is set to 1. If
161
+ a reference to a value is kept (e.g. a value is stored somewhere for
162
+ later use), its reference count is incremented, and when the value is
163
+ no longer needed, the reference count is decremented. When the
164
+ reference count drops to zero, there are no references left, and the
165
+ value can be destroyed.
166
+
167
+ The following functions are used to manipulate the reference count.
168
+
169
+ .. function:: json_t *json_incref(json_t *json)
170
+
171
+ Increment the reference count of *json* if it's not *NULL*.
172
+ Returns *json*.
173
+
174
+ .. function:: void json_decref(json_t *json)
175
+
176
+ Decrement the reference count of *json*. As soon as a call to
177
+ :func:`json_decref()` drops the reference count to zero, the value
178
+ is destroyed and it can no longer be used.
179
+
180
+ Functions creating new JSON values set the reference count to 1. These
181
+ functions are said to return a **new reference**. Other functions
182
+ returning (existing) JSON values do not normally increase the
183
+ reference count. These functions are said to return a **borrowed
184
+ reference**. So, if the user will hold a reference to a value returned
185
+ as a borrowed reference, he must call :func:`json_incref`. As soon as
186
+ the value is no longer needed, :func:`json_decref` should be called
187
+ to release the reference.
188
+
189
+ Normally, all functions accepting a JSON value as an argument will
190
+ manage the reference, i.e. increase and decrease the reference count
191
+ as needed. However, some functions **steal** the reference, i.e. they
192
+ have the same result as if the user called :func:`json_decref()` on
193
+ the argument right after calling the function. These functions are
194
+ suffixed with ``_new`` or have ``_new_`` somewhere in their name.
195
+
196
+ For example, the following code creates a new JSON array and appends
197
+ an integer to it::
198
+
199
+ json_t *array, *integer;
200
+
201
+ array = json_array();
202
+ integer = json_integer(42);
203
+
204
+ json_array_append(array, integer);
205
+ json_decref(integer);
206
+
207
+ Note how the caller has to release the reference to the integer value
208
+ by calling :func:`json_decref()`. By using a reference stealing
209
+ function :func:`json_array_append_new()` instead of
210
+ :func:`json_array_append()`, the code becomes much simpler::
211
+
212
+ json_t *array = json_array();
213
+ json_array_append_new(array, json_integer(42));
214
+
215
+ In this case, the user doesn't have to explicitly release the
216
+ reference to the integer value, as :func:`json_array_append_new()`
217
+ steals the reference when appending the value to the array.
218
+
219
+ In the following sections it is clearly documented whether a function
220
+ will return a new or borrowed reference or steal a reference to its
221
+ argument.
222
+
223
+
224
+ Circular References
225
+ -------------------
226
+
227
+ A circular reference is created when an object or an array is,
228
+ directly or indirectly, inserted inside itself. The direct case is
229
+ simple::
230
+
231
+ json_t *obj = json_object();
232
+ json_object_set(obj, "foo", obj);
233
+
234
+ Jansson will refuse to do this, and :func:`json_object_set()` (and
235
+ all the other such functions for objects and arrays) will return with
236
+ an error status. The indirect case is the dangerous one::
237
+
238
+ json_t *arr1 = json_array(), *arr2 = json_array();
239
+ json_array_append(arr1, arr2);
240
+ json_array_append(arr2, arr1);
241
+
242
+ In this example, the array ``arr2`` is contained in the array
243
+ ``arr1``, and vice versa. Jansson cannot check for this kind of
244
+ indirect circular references without a performance hit, so it's up to
245
+ the user to avoid them.
246
+
247
+ If a circular reference is created, the memory consumed by the values
248
+ cannot be freed by :func:`json_decref()`. The reference counts never
249
+ drops to zero because the values are keeping the references to each
250
+ other. Moreover, trying to encode the values with any of the encoding
251
+ functions will fail. The encoder detects circular references and
252
+ returns an error status.
253
+
254
+
255
+ True, False and Null
256
+ ====================
257
+
258
+ These three values are implemented as singletons, so the returned
259
+ pointers won't change between invocations of these functions.
260
+
261
+ .. function:: json_t *json_true(void)
262
+
263
+ .. refcounting:: new
264
+
265
+ Returns the JSON true value.
266
+
267
+ .. function:: json_t *json_false(void)
268
+
269
+ .. refcounting:: new
270
+
271
+ Returns the JSON false value.
272
+
273
+ .. function:: json_t *json_boolean(val)
274
+
275
+ .. refcounting:: new
276
+
277
+ Returns JSON false if ``val`` is zero, and JSON true otherwise.
278
+ This is a macro, and equivalent to ``val ? json_true() :
279
+ json_false()``.
280
+
281
+ .. versionadded:: 2.4
282
+
283
+
284
+ .. function:: json_t *json_null(void)
285
+
286
+ .. refcounting:: new
287
+
288
+ Returns the JSON null value.
289
+
290
+
291
+ String
292
+ ======
293
+
294
+ Jansson uses UTF-8 as the character encoding. All JSON strings must be
295
+ valid UTF-8 (or ASCII, as it's a subset of UTF-8). Normal null
296
+ terminated C strings are used, so JSON strings may not contain
297
+ embedded null characters. All other Unicode codepoints U+0001 through
298
+ U+10FFFF are allowed.
299
+
300
+ .. function:: json_t *json_string(const char *value)
301
+
302
+ .. refcounting:: new
303
+
304
+ Returns a new JSON string, or *NULL* on error. *value* must be a
305
+ valid UTF-8 encoded Unicode string.
306
+
307
+ .. function:: json_t *json_string_nocheck(const char *value)
308
+
309
+ .. refcounting:: new
310
+
311
+ Like :func:`json_string`, but doesn't check that *value* is valid
312
+ UTF-8. Use this function only if you are certain that this really
313
+ is the case (e.g. you have already checked it by other means).
314
+
315
+ .. function:: const char *json_string_value(const json_t *string)
316
+
317
+ Returns the associated value of *string* as a null terminated UTF-8
318
+ encoded string, or *NULL* if *string* is not a JSON string.
319
+
320
+ The retuned value is read-only and must not be modified or freed by
321
+ the user. It is valid as long as *string* exists, i.e. as long as
322
+ its reference count has not dropped to zero.
323
+
324
+ .. function:: int json_string_set(const json_t *string, const char *value)
325
+
326
+ Sets the associated value of *string* to *value*. *value* must be a
327
+ valid UTF-8 encoded Unicode string. Returns 0 on success and -1 on
328
+ error.
329
+
330
+ .. function:: int json_string_set_nocheck(const json_t *string, const char *value)
331
+
332
+ Like :func:`json_string_set`, but doesn't check that *value* is
333
+ valid UTF-8. Use this function only if you are certain that this
334
+ really is the case (e.g. you have already checked it by other
335
+ means).
336
+
337
+
338
+ Number
339
+ ======
340
+
341
+ The JSON specification only contains one numeric type, "number". The C
342
+ programming language has distinct types for integer and floating-point
343
+ numbers, so for practical reasons Jansson also has distinct types for
344
+ the two. They are called "integer" and "real", respectively. For more
345
+ information, see :ref:`rfc-conformance`.
346
+
347
+ .. type:: json_int_t
348
+
349
+ This is the C type that is used to store JSON integer values. It
350
+ represents the widest integer type available on your system. In
351
+ practice it's just a typedef of ``long long`` if your compiler
352
+ supports it, otherwise ``long``.
353
+
354
+ Usually, you can safely use plain ``int`` in place of
355
+ ``json_int_t``, and the implicit C integer conversion handles the
356
+ rest. Only when you know that you need the full 64-bit range, you
357
+ should use ``json_int_t`` explicitly.
358
+
359
+ ``JSON_INTEGER_IS_LONG_LONG``
360
+ This is a preprocessor variable that holds the value 1 if
361
+ :type:`json_int_t` is ``long long``, and 0 if it's ``long``. It
362
+ can be used as follows::
363
+
364
+ #if JSON_INTEGER_IS_LONG_LONG
365
+ /* Code specific for long long */
366
+ #else
367
+ /* Code specific for long */
368
+ #endif
369
+
370
+ ``JSON_INTEGER_FORMAT``
371
+ This is a macro that expands to a :func:`printf()` conversion
372
+ specifier that corresponds to :type:`json_int_t`, without the
373
+ leading ``%`` sign, i.e. either ``"lld"`` or ``"ld"``. This macro
374
+ is required because the actual type of :type:`json_int_t` can be
375
+ either ``long`` or ``long long``, and :func:`printf()` reuiqres
376
+ different length modifiers for the two.
377
+
378
+ Example::
379
+
380
+ json_int_t x = 123123123;
381
+ printf("x is %" JSON_INTEGER_FORMAT "\n", x);
382
+
383
+
384
+ .. function:: json_t *json_integer(json_int_t value)
385
+
386
+ .. refcounting:: new
387
+
388
+ Returns a new JSON integer, or *NULL* on error.
389
+
390
+ .. function:: json_int_t json_integer_value(const json_t *integer)
391
+
392
+ Returns the associated value of *integer*, or 0 if *json* is not a
393
+ JSON integer.
394
+
395
+ .. function:: int json_integer_set(const json_t *integer, json_int_t value)
396
+
397
+ Sets the associated value of *integer* to *value*. Returns 0 on
398
+ success and -1 if *integer* is not a JSON integer.
399
+
400
+ .. function:: json_t *json_real(double value)
401
+
402
+ .. refcounting:: new
403
+
404
+ Returns a new JSON real, or *NULL* on error.
405
+
406
+ .. function:: double json_real_value(const json_t *real)
407
+
408
+ Returns the associated value of *real*, or 0.0 if *real* is not a
409
+ JSON real.
410
+
411
+ .. function:: int json_real_set(const json_t *real, double value)
412
+
413
+ Sets the associated value of *real* to *value*. Returns 0 on
414
+ success and -1 if *real* is not a JSON real.
415
+
416
+ In addition to the functions above, there's a common query function
417
+ for integers and reals:
418
+
419
+ .. function:: double json_number_value(const json_t *json)
420
+
421
+ Returns the associated value of the JSON integer or JSON real
422
+ *json*, cast to double regardless of the actual type. If *json* is
423
+ neither JSON real nor JSON integer, 0.0 is returned.
424
+
425
+
426
+ Array
427
+ =====
428
+
429
+ A JSON array is an ordered collection of other JSON values.
430
+
431
+ .. function:: json_t *json_array(void)
432
+
433
+ .. refcounting:: new
434
+
435
+ Returns a new JSON array, or *NULL* on error. Initially, the array
436
+ is empty.
437
+
438
+ .. function:: size_t json_array_size(const json_t *array)
439
+
440
+ Returns the number of elements in *array*, or 0 if *array* is NULL
441
+ or not a JSON array.
442
+
443
+ .. function:: json_t *json_array_get(const json_t *array, size_t index)
444
+
445
+ .. refcounting:: borrow
446
+
447
+ Returns the element in *array* at position *index*. The valid range
448
+ for *index* is from 0 to the return value of
449
+ :func:`json_array_size()` minus 1. If *array* is not a JSON array,
450
+ if *array* is *NULL*, or if *index* is out of range, *NULL* is
451
+ returned.
452
+
453
+ .. function:: int json_array_set(json_t *array, size_t index, json_t *value)
454
+
455
+ Replaces the element in *array* at position *index* with *value*.
456
+ The valid range for *index* is from 0 to the return value of
457
+ :func:`json_array_size()` minus 1. Returns 0 on success and -1 on
458
+ error.
459
+
460
+ .. function:: int json_array_set_new(json_t *array, size_t index, json_t *value)
461
+
462
+ Like :func:`json_array_set()` but steals the reference to *value*.
463
+ This is useful when *value* is newly created and not used after
464
+ the call.
465
+
466
+ .. function:: int json_array_append(json_t *array, json_t *value)
467
+
468
+ Appends *value* to the end of *array*, growing the size of *array*
469
+ by 1. Returns 0 on success and -1 on error.
470
+
471
+ .. function:: int json_array_append_new(json_t *array, json_t *value)
472
+
473
+ Like :func:`json_array_append()` but steals the reference to
474
+ *value*. This is useful when *value* is newly created and not used
475
+ after the call.
476
+
477
+ .. function:: int json_array_insert(json_t *array, size_t index, json_t *value)
478
+
479
+ Inserts *value* to *array* at position *index*, shifting the
480
+ elements at *index* and after it one position towards the end of
481
+ the array. Returns 0 on success and -1 on error.
482
+
483
+ .. function:: int json_array_insert_new(json_t *array, size_t index, json_t *value)
484
+
485
+ Like :func:`json_array_insert()` but steals the reference to
486
+ *value*. This is useful when *value* is newly created and not used
487
+ after the call.
488
+
489
+ .. function:: int json_array_remove(json_t *array, size_t index)
490
+
491
+ Removes the element in *array* at position *index*, shifting the
492
+ elements after *index* one position towards the start of the array.
493
+ Returns 0 on success and -1 on error. The reference count of the
494
+ removed value is decremented.
495
+
496
+ .. function:: int json_array_clear(json_t *array)
497
+
498
+ Removes all elements from *array*. Returns 0 on sucess and -1 on
499
+ error. The reference count of all removed values are decremented.
500
+
501
+ .. function:: int json_array_extend(json_t *array, json_t *other_array)
502
+
503
+ Appends all elements in *other_array* to the end of *array*.
504
+ Returns 0 on success and -1 on error.
505
+
506
+ The following macro can be used to iterate through all elements
507
+ in an array.
508
+
509
+ .. function:: json_array_foreach(array, index, value)
510
+
511
+ Iterate over every element of ``array``, running the block
512
+ of code that follows each time with the proper values set to
513
+ variables ``index`` and ``value``, of types :type:`size_t` and
514
+ :type:`json_t *` respectively. Example::
515
+
516
+ /* array is a JSON array */
517
+ size_t index;
518
+ json_t *value;
519
+
520
+ json_array_foreach(array, index, value) {
521
+ /* block of code that uses index and value */
522
+ }
523
+
524
+ The items are returned in increasing index order.
525
+
526
+ This macro expands to an ordinary ``for`` statement upon
527
+ preprocessing, so its performance is equivalent to that of
528
+ hand-written code using the array access functions.
529
+ The main advantage of this macro is that it abstracts
530
+ away the complexity, and makes for shorter, more
531
+ concise code.
532
+
533
+ .. versionadded:: 2.5
534
+
535
+
536
+ Object
537
+ ======
538
+
539
+ A JSON object is a dictionary of key-value pairs, where the key is a
540
+ Unicode string and the value is any JSON value.
541
+
542
+ .. function:: json_t *json_object(void)
543
+
544
+ .. refcounting:: new
545
+
546
+ Returns a new JSON object, or *NULL* on error. Initially, the
547
+ object is empty.
548
+
549
+ .. function:: size_t json_object_size(const json_t *object)
550
+
551
+ Returns the number of elements in *object*, or 0 if *object* is not
552
+ a JSON object.
553
+
554
+ .. function:: json_t *json_object_get(const json_t *object, const char *key)
555
+
556
+ .. refcounting:: borrow
557
+
558
+ Get a value corresponding to *key* from *object*. Returns *NULL* if
559
+ *key* is not found and on error.
560
+
561
+ .. function:: int json_object_set(json_t *object, const char *key, json_t *value)
562
+
563
+ Set the value of *key* to *value* in *object*. *key* must be a
564
+ valid null terminated UTF-8 encoded Unicode string. If there
565
+ already is a value for *key*, it is replaced by the new value.
566
+ Returns 0 on success and -1 on error.
567
+
568
+ .. function:: int json_object_set_nocheck(json_t *object, const char *key, json_t *value)
569
+
570
+ Like :func:`json_object_set`, but doesn't check that *key* is
571
+ valid UTF-8. Use this function only if you are certain that this
572
+ really is the case (e.g. you have already checked it by other
573
+ means).
574
+
575
+ .. function:: int json_object_set_new(json_t *object, const char *key, json_t *value)
576
+
577
+ Like :func:`json_object_set()` but steals the reference to
578
+ *value*. This is useful when *value* is newly created and not used
579
+ after the call.
580
+
581
+ .. function:: int json_object_set_new_nocheck(json_t *object, const char *key, json_t *value)
582
+
583
+ Like :func:`json_object_set_new`, but doesn't check that *key* is
584
+ valid UTF-8. Use this function only if you are certain that this
585
+ really is the case (e.g. you have already checked it by other
586
+ means).
587
+
588
+ .. function:: int json_object_del(json_t *object, const char *key)
589
+
590
+ Delete *key* from *object* if it exists. Returns 0 on success, or
591
+ -1 if *key* was not found. The reference count of the removed value
592
+ is decremented.
593
+
594
+ .. function:: int json_object_clear(json_t *object)
595
+
596
+ Remove all elements from *object*. Returns 0 on success and -1 if
597
+ *object* is not a JSON object. The reference count of all removed
598
+ values are decremented.
599
+
600
+ .. function:: int json_object_update(json_t *object, json_t *other)
601
+
602
+ Update *object* with the key-value pairs from *other*, overwriting
603
+ existing keys. Returns 0 on success or -1 on error.
604
+
605
+ .. function:: int json_object_update_existing(json_t *object, json_t *other)
606
+
607
+ Like :func:`json_object_update()`, but only the values of existing
608
+ keys are updated. No new keys are created. Returns 0 on success or
609
+ -1 on error.
610
+
611
+ .. versionadded:: 2.3
612
+
613
+ .. function:: int json_object_update_missing(json_t *object, json_t *other)
614
+
615
+ Like :func:`json_object_update()`, but only new keys are created.
616
+ The value of any existing key is not changed. Returns 0 on success
617
+ or -1 on error.
618
+
619
+ .. versionadded:: 2.3
620
+
621
+ The following macro can be used to iterate through all key-value pairs
622
+ in an object.
623
+
624
+ .. function:: json_object_foreach(object, key, value)
625
+
626
+ Iterate over every key-value pair of ``object``, running the block
627
+ of code that follows each time with the proper values set to
628
+ variables ``key`` and ``value``, of types :type:`const char *` and
629
+ :type:`json_t *` respectively. Example::
630
+
631
+ /* obj is a JSON object */
632
+ const char *key;
633
+ json_t *value;
634
+
635
+ json_object_foreach(obj, key, value) {
636
+ /* block of code that uses key and value */
637
+ }
638
+
639
+ The items are not returned in any particular order.
640
+
641
+ This macro expands to an ordinary ``for`` statement upon
642
+ preprocessing, so its performance is equivalent to that of
643
+ hand-written iteration code using the object iteration protocol
644
+ (see below). The main advantage of this macro is that it abstracts
645
+ away the complexity behind iteration, and makes for shorter, more
646
+ concise code.
647
+
648
+ .. versionadded:: 2.3
649
+
650
+
651
+ The following functions implement an iteration protocol for objects,
652
+ allowing to iterate through all key-value pairs in an object. The
653
+ items are not returned in any particular order, as this would require
654
+ sorting due to the internal hashtable implementation.
655
+
656
+ .. function:: void *json_object_iter(json_t *object)
657
+
658
+ Returns an opaque iterator which can be used to iterate over all
659
+ key-value pairs in *object*, or *NULL* if *object* is empty.
660
+
661
+ .. function:: void *json_object_iter_at(json_t *object, const char *key)
662
+
663
+ Like :func:`json_object_iter()`, but returns an iterator to the
664
+ key-value pair in *object* whose key is equal to *key*, or NULL if
665
+ *key* is not found in *object*. Iterating forward to the end of
666
+ *object* only yields all key-value pairs of the object if *key*
667
+ happens to be the first key in the underlying hash table.
668
+
669
+ .. function:: void *json_object_iter_next(json_t *object, void *iter)
670
+
671
+ Returns an iterator pointing to the next key-value pair in *object*
672
+ after *iter*, or *NULL* if the whole object has been iterated
673
+ through.
674
+
675
+ .. function:: const char *json_object_iter_key(void *iter)
676
+
677
+ Extract the associated key from *iter*.
678
+
679
+ .. function:: json_t *json_object_iter_value(void *iter)
680
+
681
+ .. refcounting:: borrow
682
+
683
+ Extract the associated value from *iter*.
684
+
685
+ .. function:: int json_object_iter_set(json_t *object, void *iter, json_t *value)
686
+
687
+ Set the value of the key-value pair in *object*, that is pointed to
688
+ by *iter*, to *value*.
689
+
690
+ .. function:: int json_object_iter_set_new(json_t *object, void *iter, json_t *value)
691
+
692
+ Like :func:`json_object_iter_set()`, but steals the reference to
693
+ *value*. This is useful when *value* is newly created and not used
694
+ after the call.
695
+
696
+ .. function:: void *json_object_key_to_iter(const char *key)
697
+
698
+ Like :func:`json_object_iter_at()`, but much faster. Only works for
699
+ values returned by :func:`json_object_iter_key()`. Using other keys
700
+ will lead to segfaults. This function is used internally to
701
+ implement :func:`json_object_foreach`.
702
+
703
+ .. versionadded:: 2.3
704
+
705
+ The iteration protocol can be used for example as follows::
706
+
707
+ /* obj is a JSON object */
708
+ const char *key;
709
+ json_t *value;
710
+
711
+ void *iter = json_object_iter(obj);
712
+ while(iter)
713
+ {
714
+ key = json_object_iter_key(iter);
715
+ value = json_object_iter_value(iter);
716
+ /* use key and value ... */
717
+ iter = json_object_iter_next(obj, iter);
718
+ }
719
+
720
+
721
+ Error reporting
722
+ ===============
723
+
724
+ Jansson uses a single struct type to pass error information to the
725
+ user. See sections :ref:`apiref-decoding`, :ref:`apiref-pack` and
726
+ :ref:`apiref-unpack` for functions that pass error information using
727
+ this struct.
728
+
729
+ .. type:: json_error_t
730
+
731
+ .. member:: char text[]
732
+
733
+ The error message (in UTF-8), or an empty string if a message is
734
+ not available.
735
+
736
+ .. member:: char source[]
737
+
738
+ Source of the error. This can be (a part of) the file name or a
739
+ special identifier in angle brackers (e.g. ``<string>``).
740
+
741
+ .. member:: int line
742
+
743
+ The line number on which the error occurred.
744
+
745
+ .. member:: int column
746
+
747
+ The column on which the error occurred. Note that this is the
748
+ *character column*, not the byte column, i.e. a multibyte UTF-8
749
+ character counts as one column.
750
+
751
+ .. member:: size_t position
752
+
753
+ The position in bytes from the start of the input. This is
754
+ useful for debugging Unicode encoding problems.
755
+
756
+ The normal use of :type:`json_error_t` is to allocate it on the stack,
757
+ and pass a pointer to a function. Example::
758
+
759
+ int main() {
760
+ json_t *json;
761
+ json_error_t error;
762
+
763
+ json = json_load_file("/path/to/file.json", 0, &error);
764
+ if(!json) {
765
+ /* the error variable contains error information */
766
+ }
767
+ ...
768
+ }
769
+
770
+ Also note that if the call succeeded (``json != NULL`` in the above
771
+ example), the contents of ``error`` are generally left unspecified.
772
+ The decoding functions write to the ``position`` member also on
773
+ success. See :ref:`apiref-decoding` for more info.
774
+
775
+ All functions also accept *NULL* as the :type:`json_error_t` pointer,
776
+ in which case no error information is returned to the caller.
777
+
778
+
779
+ Encoding
780
+ ========
781
+
782
+ This sections describes the functions that can be used to encode
783
+ values to JSON. By default, only objects and arrays can be encoded
784
+ directly, since they are the only valid *root* values of a JSON text.
785
+ To encode any JSON value, use the ``JSON_ENCODE_ANY`` flag (see
786
+ below).
787
+
788
+ By default, the output has no newlines, and spaces are used between
789
+ array and object elements for a readable output. This behavior can be
790
+ altered by using the ``JSON_INDENT`` and ``JSON_COMPACT`` flags
791
+ described below. A newline is never appended to the end of the encoded
792
+ JSON data.
793
+
794
+ Each function takes a *flags* parameter that controls some aspects of
795
+ how the data is encoded. Its default value is 0. The following macros
796
+ can be ORed together to obtain *flags*.
797
+
798
+ ``JSON_INDENT(n)``
799
+ Pretty-print the result, using newlines between array and object
800
+ items, and indenting with *n* spaces. The valid range for *n* is
801
+ between 0 and 31 (inclusive), other values result in an undefined
802
+ output. If ``JSON_INDENT`` is not used or *n* is 0, no newlines are
803
+ inserted between array and object items.
804
+
805
+ ``JSON_COMPACT``
806
+ This flag enables a compact representation, i.e. sets the separator
807
+ between array and object items to ``","`` and between object keys
808
+ and values to ``":"``. Without this flag, the corresponding
809
+ separators are ``", "`` and ``": "`` for more readable output.
810
+
811
+ ``JSON_ENSURE_ASCII``
812
+ If this flag is used, the output is guaranteed to consist only of
813
+ ASCII characters. This is achived by escaping all Unicode
814
+ characters outside the ASCII range.
815
+
816
+ ``JSON_SORT_KEYS``
817
+ If this flag is used, all the objects in output are sorted by key.
818
+ This is useful e.g. if two JSON texts are diffed or visually
819
+ compared.
820
+
821
+ ``JSON_PRESERVE_ORDER``
822
+ If this flag is used, object keys in the output are sorted into the
823
+ same order in which they were first inserted to the object. For
824
+ example, decoding a JSON text and then encoding with this flag
825
+ preserves the order of object keys.
826
+
827
+ ``JSON_ENCODE_ANY``
828
+ Specifying this flag makes it possible to encode any JSON value on
829
+ its own. Without it, only objects and arrays can be passed as the
830
+ *root* value to the encoding functions.
831
+
832
+ **Note:** Encoding any value may be useful in some scenarios, but
833
+ it's generally discouraged as it violates strict compatiblity with
834
+ :rfc:`4627`. If you use this flag, don't expect interoperatibility
835
+ with other JSON systems.
836
+
837
+ .. versionadded:: 2.1
838
+
839
+ ``JSON_ESCAPE_SLASH``
840
+ Escape the ``/`` characters in strings with ``\/``.
841
+
842
+ .. versionadded:: 2.4
843
+
844
+ The following functions perform the actual JSON encoding. The result
845
+ is in UTF-8.
846
+
847
+ .. function:: char *json_dumps(const json_t *root, size_t flags)
848
+
849
+ Returns the JSON representation of *root* as a string, or *NULL* on
850
+ error. *flags* is described above. The return value must be freed
851
+ by the caller using :func:`free()`.
852
+
853
+ .. function:: int json_dumpf(const json_t *root, FILE *output, size_t flags)
854
+
855
+ Write the JSON representation of *root* to the stream *output*.
856
+ *flags* is described above. Returns 0 on success and -1 on error.
857
+ If an error occurs, something may have already been written to
858
+ *output*. In this case, the output is undefined and most likely not
859
+ valid JSON.
860
+
861
+ .. function:: int json_dump_file(const json_t *json, const char *path, size_t flags)
862
+
863
+ Write the JSON representation of *root* to the file *path*. If
864
+ *path* already exists, it is overwritten. *flags* is described
865
+ above. Returns 0 on success and -1 on error.
866
+
867
+ .. type:: json_dump_callback_t
868
+
869
+ A typedef for a function that's called by
870
+ :func:`json_dump_callback()`::
871
+
872
+ typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data);
873
+
874
+ *buffer* points to a buffer containing a chunk of output, *size* is
875
+ the length of the buffer, and *data* is the corresponding
876
+ :func:`json_dump_callback()` argument passed through.
877
+
878
+ On error, the function should return -1 to stop the encoding
879
+ process. On success, it should return 0.
880
+
881
+ .. versionadded:: 2.2
882
+
883
+ .. function:: int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags)
884
+
885
+ Call *callback* repeatedly, passing a chunk of the JSON
886
+ representation of *root* each time. *flags* is described above.
887
+ Returns 0 on success and -1 on error.
888
+
889
+ .. versionadded:: 2.2
890
+
891
+
892
+ .. _apiref-decoding:
893
+
894
+ Decoding
895
+ ========
896
+
897
+ This sections describes the functions that can be used to decode JSON
898
+ text to the Jansson representation of JSON data. The JSON
899
+ specification requires that a JSON text is either a serialized array
900
+ or object, and this requirement is also enforced with the following
901
+ functions. In other words, the top level value in the JSON text being
902
+ decoded must be either array or object. To decode any JSON value, use
903
+ the ``JSON_DECODE_ANY`` flag (see below).
904
+
905
+ See :ref:`rfc-conformance` for a discussion on Jansson's conformance
906
+ to the JSON specification. It explains many design decisions that
907
+ affect especially the behavior of the decoder.
908
+
909
+ Each function takes a *flags* parameter that can be used to control
910
+ the behavior of the decoder. Its default value is 0. The following
911
+ macros can be ORed together to obtain *flags*.
912
+
913
+ ``JSON_REJECT_DUPLICATES``
914
+ Issue a decoding error if any JSON object in the input text
915
+ contains duplicate keys. Without this flag, the value of the last
916
+ occurence of each key ends up in the result. Key equivalence is
917
+ checked byte-by-byte, without special Unicode comparison
918
+ algorithms.
919
+
920
+ .. versionadded:: 2.1
921
+
922
+ ``JSON_DECODE_ANY``
923
+ By default, the decoder expects an array or object as the input.
924
+ With this flag enabled, the decoder accepts any valid JSON value.
925
+
926
+ **Note:** Decoding any value may be useful in some scenarios, but
927
+ it's generally discouraged as it violates strict compatiblity with
928
+ :rfc:`4627`. If you use this flag, don't expect interoperatibility
929
+ with other JSON systems.
930
+
931
+ .. versionadded:: 2.3
932
+
933
+ ``JSON_DISABLE_EOF_CHECK``
934
+ By default, the decoder expects that its whole input constitutes a
935
+ valid JSON text, and issues an error if there's extra data after
936
+ the otherwise valid JSON input. With this flag enabled, the decoder
937
+ stops after decoding a valid JSON array or object, and thus allows
938
+ extra data after the JSON text.
939
+
940
+ Normally, reading will stop when the last ``]`` or ``}`` in the
941
+ JSON input is encountered. If both ``JSON_DISABLE_EOF_CHECK`` and
942
+ ``JSON_DECODE_ANY`` flags are used, the decoder may read one extra
943
+ UTF-8 code unit (up to 4 bytes of input). For example, decoding
944
+ ``4true`` correctly decodes the integer 4, but also reads the
945
+ ``t``. For this reason, if reading multiple consecutive values that
946
+ are not arrays or objects, they should be separated by at least one
947
+ whitespace character.
948
+
949
+ .. versionadded:: 2.1
950
+
951
+ ``JSON_DECODE_INT_AS_REAL``
952
+ JSON defines only one number type. Jansson distinguishes between
953
+ ints and reals. For more information see :ref:`real-vs-integer`.
954
+ With this flag enabled the decoder interprets all numbers as real
955
+ values. Integers that do not have an exact double representation
956
+ will silently result in a loss of precision. Integers that cause
957
+ a double overflow will cause an error.
958
+
959
+ .. versionadded:: 2.5
960
+
961
+ Each function also takes an optional :type:`json_error_t` parameter
962
+ that is filled with error information if decoding fails. It's also
963
+ updated on success; the number of bytes of input read is written to
964
+ its ``position`` field. This is especially useful when using
965
+ ``JSON_DISABLE_EOF_CHECK`` to read multiple consecutive JSON texts.
966
+
967
+ .. versionadded:: 2.3
968
+ Number of bytes of input read is written to the ``position`` field
969
+ of the :type:`json_error_t` structure.
970
+
971
+ If no error or position information is needed, you can pass *NULL*.
972
+
973
+ The following functions perform the actual JSON decoding.
974
+
975
+ .. function:: json_t *json_loads(const char *input, size_t flags, json_error_t *error)
976
+
977
+ .. refcounting:: new
978
+
979
+ Decodes the JSON string *input* and returns the array or object it
980
+ contains, or *NULL* on error, in which case *error* is filled with
981
+ information about the error. *flags* is described above.
982
+
983
+ .. function:: json_t *json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error)
984
+
985
+ .. refcounting:: new
986
+
987
+ Decodes the JSON string *buffer*, whose length is *buflen*, and
988
+ returns the array or object it contains, or *NULL* on error, in
989
+ which case *error* is filled with information about the error. This
990
+ is similar to :func:`json_loads()` except that the string doesn't
991
+ need to be null-terminated. *flags* is described above.
992
+
993
+ .. versionadded:: 2.1
994
+
995
+ .. function:: json_t *json_loadf(FILE *input, size_t flags, json_error_t *error)
996
+
997
+ .. refcounting:: new
998
+
999
+ Decodes the JSON text in stream *input* and returns the array or
1000
+ object it contains, or *NULL* on error, in which case *error* is
1001
+ filled with information about the error. *flags* is described
1002
+ above.
1003
+
1004
+ This function will start reading the input from whatever position
1005
+ the input file was, without attempting to seek first. If an error
1006
+ occurs, the file position will be left indeterminate. On success,
1007
+ the file position will be at EOF, unless ``JSON_DISABLE_EOF_CHECK``
1008
+ flag was used. In this case, the file position will be at the first
1009
+ character after the last ``]`` or ``}`` in the JSON input. This
1010
+ allows calling :func:`json_loadf()` on the same ``FILE`` object
1011
+ multiple times, if the input consists of consecutive JSON texts,
1012
+ possibly separated by whitespace.
1013
+
1014
+ .. function:: json_t *json_load_file(const char *path, size_t flags, json_error_t *error)
1015
+
1016
+ .. refcounting:: new
1017
+
1018
+ Decodes the JSON text in file *path* and returns the array or
1019
+ object it contains, or *NULL* on error, in which case *error* is
1020
+ filled with information about the error. *flags* is described
1021
+ above.
1022
+
1023
+ .. type:: json_load_callback_t
1024
+
1025
+ A typedef for a function that's called by
1026
+ :func:`json_load_callback()` to read a chunk of input data::
1027
+
1028
+ typedef size_t (*json_load_callback_t)(void *buffer, size_t buflen, void *data);
1029
+
1030
+ *buffer* points to a buffer of *buflen* bytes, and *data* is the
1031
+ corresponding :func:`json_load_callback()` argument passed through.
1032
+
1033
+ On success, the function should return the number of bytes read; a
1034
+ returned value of 0 indicates that no data was read and that the
1035
+ end of file has been reached. On error, the function should return
1036
+ ``(size_t)-1`` to abort the decoding process.
1037
+
1038
+ .. versionadded:: 2.4
1039
+
1040
+ .. function:: json_t *json_load_callback(json_load_callback_t callback, void *data, size_t flags, json_error_t *error)
1041
+
1042
+ .. refcounting:: new
1043
+
1044
+ Decodes the JSON text produced by repeated calls to *callback*, and
1045
+ returns the array or object it contains, or *NULL* on error, in
1046
+ which case *error* is filled with information about the error.
1047
+ *data* is passed through to *callback* on each call. *flags* is
1048
+ described above.
1049
+
1050
+ .. versionadded:: 2.4
1051
+
1052
+
1053
+ .. _apiref-pack:
1054
+
1055
+ Building Values
1056
+ ===============
1057
+
1058
+ This section describes functions that help to create, or *pack*,
1059
+ complex JSON values, especially nested objects and arrays. Value
1060
+ building is based on a *format string* that is used to tell the
1061
+ functions about the expected arguments.
1062
+
1063
+ For example, the format string ``"i"`` specifies a single integer
1064
+ value, while the format string ``"[ssb]"`` or the equivalent ``"[s, s,
1065
+ b]"`` specifies an array value with two strings and a boolean as its
1066
+ items::
1067
+
1068
+ /* Create the JSON integer 42 */
1069
+ json_pack("i", 42);
1070
+
1071
+ /* Create the JSON array ["foo", "bar", true] */
1072
+ json_pack("[ssb]", "foo", "bar", 1);
1073
+
1074
+ Here's the full list of format specifiers. The type in parentheses
1075
+ denotes the resulting JSON type, and the type in brackets (if any)
1076
+ denotes the C type that is expected as the corresponding argument or
1077
+ arguments.
1078
+
1079
+ ``s`` (string) [const char \*]
1080
+ Convert a NULL terminated UTF-8 string to a JSON string.
1081
+
1082
+ ``s#`` (string) [const char \*, int]
1083
+ Convert a UTF-8 buffer of a given length to a JSON string.
1084
+
1085
+ ``+`` [const char \*]
1086
+ Like ``s``, but concatenate to the previous string. Only valid
1087
+ after ``s``, ``s#``, ``+`` or ``+#``.
1088
+
1089
+ ``+#`` [const char \*, int]
1090
+ Like ``s#``, but concatenate to the previous string. Only valid
1091
+ after ``s``, ``s#``, ``+`` or ``+#``.
1092
+
1093
+ ``n`` (null)
1094
+ Output a JSON null value. No argument is consumed.
1095
+
1096
+ ``b`` (boolean) [int]
1097
+ Convert a C :type:`int` to JSON boolean value. Zero is converted
1098
+ to ``false`` and non-zero to ``true``.
1099
+
1100
+ ``i`` (integer) [int]
1101
+ Convert a C :type:`int` to JSON integer.
1102
+
1103
+ ``I`` (integer) [json_int_t]
1104
+ Convert a C :type:`json_int_t` to JSON integer.
1105
+
1106
+ ``f`` (real) [double]
1107
+ Convert a C :type:`double` to JSON real.
1108
+
1109
+ ``o`` (any value) [json_t \*]
1110
+ Output any given JSON value as-is. If the value is added to an
1111
+ array or object, the reference to the value passed to ``o`` is
1112
+ stolen by the container.
1113
+
1114
+ ``O`` (any value) [json_t \*]
1115
+ Like ``o``, but the argument's reference count is incremented.
1116
+ This is useful if you pack into an array or object and want to
1117
+ keep the reference for the JSON value consumed by ``O`` to
1118
+ yourself.
1119
+
1120
+ ``[fmt]`` (array)
1121
+ Build an array with contents from the inner format string. ``fmt``
1122
+ may contain objects and arrays, i.e. recursive value building is
1123
+ supported.
1124
+
1125
+ ``{fmt}`` (object)
1126
+ Build an object with contents from the inner format string
1127
+ ``fmt``. The first, third, etc. format specifier represent a key,
1128
+ and must be a string (see ``s``, ``s#``, ``+`` and ``+#`` above),
1129
+ as object keys are always strings. The second, fourth, etc. format
1130
+ specifier represent a value. Any value may be an object or array,
1131
+ i.e. recursive value building is supported.
1132
+
1133
+ Whitespace, ``:`` and ``,`` are ignored.
1134
+
1135
+ The following functions compose the value building API:
1136
+
1137
+ .. function:: json_t *json_pack(const char *fmt, ...)
1138
+
1139
+ .. refcounting:: new
1140
+
1141
+ Build a new JSON value according to the format string *fmt*. For
1142
+ each format specifier (except for ``{}[]n``), one or more arguments
1143
+ are consumed and used to build the corresponding value. Returns
1144
+ *NULL* on error.
1145
+
1146
+ .. function:: json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...)
1147
+ json_t *json_vpack_ex(json_error_t *error, size_t flags, const char *fmt, va_list ap)
1148
+
1149
+ .. refcounting:: new
1150
+
1151
+ Like :func:`json_pack()`, but an in the case of an error, an error
1152
+ message is written to *error*, if it's not *NULL*. The *flags*
1153
+ parameter is currently unused and should be set to 0.
1154
+
1155
+ As only the errors in format string (and out-of-memory errors) can
1156
+ be caught by the packer, these two functions are most likely only
1157
+ useful for debugging format strings.
1158
+
1159
+ More examples::
1160
+
1161
+ /* Build an empty JSON object */
1162
+ json_pack("{}");
1163
+
1164
+ /* Build the JSON object {"foo": 42, "bar": 7} */
1165
+ json_pack("{sisi}", "foo", 42, "bar", 7);
1166
+
1167
+ /* Like above, ':', ',' and whitespace are ignored */
1168
+ json_pack("{s:i, s:i}", "foo", 42, "bar", 7);
1169
+
1170
+ /* Build the JSON array [[1, 2], {"cool": true}] */
1171
+ json_pack("[[i,i],{s:b}]", 1, 2, "cool", 1);
1172
+
1173
+ /* Build a string from a non-NUL terminated buffer */
1174
+ char buffer[4] = {'t', 'e', 's', 't'};
1175
+ json_pack("s#", buffer, 4);
1176
+
1177
+ /* Concatentate strings together to build the JSON string "foobarbaz" */
1178
+ json_pack("s++", "foo", "bar", "baz");
1179
+
1180
+
1181
+ .. _apiref-unpack:
1182
+
1183
+ Parsing and Validating Values
1184
+ =============================
1185
+
1186
+ This section describes functions that help to validate complex values
1187
+ and extract, or *unpack*, data from them. Like :ref:`building values
1188
+ <apiref-pack>`, this is also based on format strings.
1189
+
1190
+ While a JSON value is unpacked, the type specified in the format
1191
+ string is checked to match that of the JSON value. This is the
1192
+ validation part of the process. In addition to this, the unpacking
1193
+ functions can also check that all items of arrays and objects are
1194
+ unpacked. This check be enabled with the format specifier ``!`` or by
1195
+ using the flag ``JSON_STRICT``. See below for details.
1196
+
1197
+ Here's the full list of format specifiers. The type in parentheses
1198
+ denotes the JSON type, and the type in brackets (if any) denotes the C
1199
+ type whose address should be passed.
1200
+
1201
+ ``s`` (string) [const char \*]
1202
+ Convert a JSON string to a pointer to a NULL terminated UTF-8
1203
+ string. The resulting string is extracted by using
1204
+ :func:`json_string_value()` internally, so it exists as long as
1205
+ there are still references to the corresponding JSON string.
1206
+
1207
+ ``n`` (null)
1208
+ Expect a JSON null value. Nothing is extracted.
1209
+
1210
+ ``b`` (boolean) [int]
1211
+ Convert a JSON boolean value to a C :type:`int`, so that ``true``
1212
+ is converted to 1 and ``false`` to 0.
1213
+
1214
+ ``i`` (integer) [int]
1215
+ Convert a JSON integer to C :type:`int`.
1216
+
1217
+ ``I`` (integer) [json_int_t]
1218
+ Convert a JSON integer to C :type:`json_int_t`.
1219
+
1220
+ ``f`` (real) [double]
1221
+ Convert a JSON real to C :type:`double`.
1222
+
1223
+ ``F`` (integer or real) [double]
1224
+ Convert a JSON number (integer or real) to C :type:`double`.
1225
+
1226
+ ``o`` (any value) [json_t \*]
1227
+ Store a JSON value with no conversion to a :type:`json_t` pointer.
1228
+
1229
+ ``O`` (any value) [json_t \*]
1230
+ Like ``O``, but the JSON value's reference count is incremented.
1231
+
1232
+ ``[fmt]`` (array)
1233
+ Convert each item in the JSON array according to the inner format
1234
+ string. ``fmt`` may contain objects and arrays, i.e. recursive
1235
+ value extraction is supporetd.
1236
+
1237
+ ``{fmt}`` (object)
1238
+ Convert each item in the JSON object according to the inner format
1239
+ string ``fmt``. The first, third, etc. format specifier represent
1240
+ a key, and must be ``s``. The corresponding argument to unpack
1241
+ functions is read as the object key. The second fourth, etc.
1242
+ format specifier represent a value and is written to the address
1243
+ given as the corresponding argument. **Note** that every other
1244
+ argument is read from and every other is written to.
1245
+
1246
+ ``fmt`` may contain objects and arrays as values, i.e. recursive
1247
+ value extraction is supporetd.
1248
+
1249
+ .. versionadded:: 2.3
1250
+ Any ``s`` representing a key may be suffixed with a ``?`` to
1251
+ make the key optional. If the key is not found, nothing is
1252
+ extracted. See below for an example.
1253
+
1254
+ ``!``
1255
+ This special format specifier is used to enable the check that
1256
+ all object and array items are accessed, on a per-value basis. It
1257
+ must appear inside an array or object as the last format specifier
1258
+ before the closing bracket or brace. To enable the check globally,
1259
+ use the ``JSON_STRICT`` unpacking flag.
1260
+
1261
+ ``*``
1262
+ This special format specifier is the opposite of ``!``. If the
1263
+ ``JSON_STRICT`` flag is used, ``*`` can be used to disable the
1264
+ strict check on a per-value basis. It must appear inside an array
1265
+ or object as the last format specifier before the closing bracket
1266
+ or brace.
1267
+
1268
+ Whitespace, ``:`` and ``,`` are ignored.
1269
+
1270
+ The following functions compose the parsing and validation API:
1271
+
1272
+ .. function:: int json_unpack(json_t *root, const char *fmt, ...)
1273
+
1274
+ Validate and unpack the JSON value *root* according to the format
1275
+ string *fmt*. Returns 0 on success and -1 on failure.
1276
+
1277
+ .. function:: int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...)
1278
+ int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, va_list ap)
1279
+
1280
+ Validate and unpack the JSON value *root* according to the format
1281
+ string *fmt*. If an error occurs and *error* is not *NULL*, write
1282
+ error information to *error*. *flags* can be used to control the
1283
+ behaviour of the unpacker, see below for the flags. Returns 0 on
1284
+ success and -1 on failure.
1285
+
1286
+ .. note::
1287
+
1288
+ The first argument of all unpack functions is ``json_t *root``
1289
+ instead of ``const json_t *root``, because the use of ``O`` format
1290
+ specifier causes the reference count of ``root``, or some value
1291
+ reachable from ``root``, to be increased. Furthermore, the ``o``
1292
+ format specifier may be used to extract a value as-is, which allows
1293
+ modifying the structure or contents of a value reachable from
1294
+ ``root``.
1295
+
1296
+ If the ``O`` and ``o`` format specifiers are not used, it's
1297
+ perfectly safe to cast a ``const json_t *`` variable to plain
1298
+ ``json_t *`` when used with these functions.
1299
+
1300
+ The following unpacking flags are available:
1301
+
1302
+ ``JSON_STRICT``
1303
+ Enable the extra validation step checking that all object and
1304
+ array items are unpacked. This is equivalent to appending the
1305
+ format specifier ``!`` to the end of every array and object in the
1306
+ format string.
1307
+
1308
+ ``JSON_VALIDATE_ONLY``
1309
+ Don't extract any data, just validate the JSON value against the
1310
+ given format string. Note that object keys must still be specified
1311
+ after the format string.
1312
+
1313
+ Examples::
1314
+
1315
+ /* root is the JSON integer 42 */
1316
+ int myint;
1317
+ json_unpack(root, "i", &myint);
1318
+ assert(myint == 42);
1319
+
1320
+ /* root is the JSON object {"foo": "bar", "quux": true} */
1321
+ const char *str;
1322
+ int boolean;
1323
+ json_unpack(root, "{s:s, s:b}", "foo", &str, "quux", &boolean);
1324
+ assert(strcmp(str, "bar") == 0 && boolean == 1);
1325
+
1326
+ /* root is the JSON array [[1, 2], {"baz": null} */
1327
+ json_error_t error;
1328
+ json_unpack_ex(root, &error, JSON_VALIDATE_ONLY, "[[i,i], {s:n}]", "baz");
1329
+ /* returns 0 for validation success, nothing is extracted */
1330
+
1331
+ /* root is the JSON array [1, 2, 3, 4, 5] */
1332
+ int myint1, myint2;
1333
+ json_unpack(root, "[ii!]", &myint1, &myint2);
1334
+ /* returns -1 for failed validation */
1335
+
1336
+ /* root is an empty JSON object */
1337
+ int myint = 0, myint2 = 0;
1338
+ json_unpack(root, "{s?i, s?[ii]}",
1339
+ "foo", &myint1,
1340
+ "bar", &myint2, &myint3);
1341
+ /* myint1, myint2 or myint3 is no touched as "foo" and "bar" don't exist */
1342
+
1343
+
1344
+ Equality
1345
+ ========
1346
+
1347
+ Testing for equality of two JSON values cannot, in general, be
1348
+ achieved using the ``==`` operator. Equality in the terms of the
1349
+ ``==`` operator states that the two :type:`json_t` pointers point to
1350
+ exactly the same JSON value. However, two JSON values can be equal not
1351
+ only if they are exactly the same value, but also if they have equal
1352
+ "contents":
1353
+
1354
+ * Two integer or real values are equal if their contained numeric
1355
+ values are equal. An integer value is never equal to a real value,
1356
+ though.
1357
+
1358
+ * Two strings are equal if their contained UTF-8 strings are equal,
1359
+ byte by byte. Unicode comparison algorithms are not implemented.
1360
+
1361
+ * Two arrays are equal if they have the same number of elements and
1362
+ each element in the first array is equal to the corresponding
1363
+ element in the second array.
1364
+
1365
+ * Two objects are equal if they have exactly the same keys and the
1366
+ value for each key in the first object is equal to the value of the
1367
+ corresponding key in the second object.
1368
+
1369
+ * Two true, false or null values have no "contents", so they are equal
1370
+ if their types are equal. (Because these values are singletons,
1371
+ their equality can actually be tested with ``==``.)
1372
+
1373
+ The following function can be used to test whether two JSON values are
1374
+ equal.
1375
+
1376
+ .. function:: int json_equal(json_t *value1, json_t *value2)
1377
+
1378
+ Returns 1 if *value1* and *value2* are equal, as defined above.
1379
+ Returns 0 if they are inequal or one or both of the pointers are
1380
+ *NULL*.
1381
+
1382
+
1383
+ Copying
1384
+ =======
1385
+
1386
+ Because of reference counting, passing JSON values around doesn't
1387
+ require copying them. But sometimes a fresh copy of a JSON value is
1388
+ needed. For example, if you need to modify an array, but still want to
1389
+ use the original afterwards, you should take a copy of it first.
1390
+
1391
+ Jansson supports two kinds of copying: shallow and deep. There is a
1392
+ difference between these methods only for arrays and objects. Shallow
1393
+ copying only copies the first level value (array or object) and uses
1394
+ the same child values in the copied value. Deep copying makes a fresh
1395
+ copy of the child values, too. Moreover, all the child values are deep
1396
+ copied in a recursive fashion.
1397
+
1398
+ .. function:: json_t *json_copy(json_t *value)
1399
+
1400
+ .. refcounting:: new
1401
+
1402
+ Returns a shallow copy of *value*, or *NULL* on error.
1403
+
1404
+ .. function:: json_t *json_deep_copy(const json_t *value)
1405
+
1406
+ .. refcounting:: new
1407
+
1408
+ Returns a deep copy of *value*, or *NULL* on error.
1409
+
1410
+
1411
+ .. _apiref-custom-memory-allocation:
1412
+
1413
+ Custom Memory Allocation
1414
+ ========================
1415
+
1416
+ By default, Jansson uses :func:`malloc()` and :func:`free()` for
1417
+ memory allocation. These functions can be overridden if custom
1418
+ behavior is needed.
1419
+
1420
+ .. type:: json_malloc_t
1421
+
1422
+ A typedef for a function pointer with :func:`malloc()`'s
1423
+ signature::
1424
+
1425
+ typedef void *(*json_malloc_t)(size_t);
1426
+
1427
+ .. type:: json_free_t
1428
+
1429
+ A typedef for a function pointer with :func:`free()`'s
1430
+ signature::
1431
+
1432
+ typedef void (*json_free_t)(void *);
1433
+
1434
+ .. function:: void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn)
1435
+
1436
+ Use *malloc_fn* instead of :func:`malloc()` and *free_fn* instead
1437
+ of :func:`free()`. This function has to be called before any other
1438
+ Jansson's API functions to ensure that all memory operations use
1439
+ the same functions.
1440
+
1441
+ **Examples:**
1442
+
1443
+ Circumvent problems with different CRT heaps on Windows by using
1444
+ application's :func:`malloc()` and :func:`free()`::
1445
+
1446
+ json_set_alloc_funcs(malloc, free);
1447
+
1448
+ Use the `Boehm's conservative garbage collector`_ for memory
1449
+ operations::
1450
+
1451
+ json_set_alloc_funcs(GC_malloc, GC_free);
1452
+
1453
+ .. _Boehm's conservative garbage collector: http://www.hpl.hp.com/personal/Hans_Boehm/gc/
1454
+
1455
+ Allow storing sensitive data (e.g. passwords or encryption keys) in
1456
+ JSON structures by zeroing all memory when freed::
1457
+
1458
+ static void *secure_malloc(size_t size)
1459
+ {
1460
+ /* Store the memory area size in the beginning of the block */
1461
+ void *ptr = malloc(size + 8);
1462
+ *((size_t *)ptr) = size;
1463
+ return ptr + 8;
1464
+ }
1465
+
1466
+ static void secure_free(void *ptr)
1467
+ {
1468
+ size_t size;
1469
+
1470
+ ptr -= 8;
1471
+ size = *((size_t *)ptr);
1472
+
1473
+ guaranteed_memset(ptr, 0, size);
1474
+ free(ptr);
1475
+ }
1476
+
1477
+ int main()
1478
+ {
1479
+ json_set_alloc_funcs(secure_malloc, secure_free);
1480
+ /* ... */
1481
+ }
1482
+
1483
+ For more information about the issues of storing sensitive data in
1484
+ memory, see
1485
+ http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/protect-secrets.html.
1486
+ The page also explains the :func:`guaranteed_memset()` function used
1487
+ in the example and gives a sample implementation for it.