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,192 @@
1
+ /*
2
+ * Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
3
+ *
4
+ * Jansson is free software; you can redistribute it and/or modify
5
+ * it under the terms of the MIT license. See LICENSE for details.
6
+ */
7
+
8
+ #include <stdlib.h>
9
+ #include <string.h>
10
+
11
+ #include <jansson.h>
12
+ #include <curl/curl.h>
13
+
14
+ #define BUFFER_SIZE (256 * 1024) /* 256 KB */
15
+
16
+ #define URL_FORMAT "https://api.github.com/repos/%s/%s/commits"
17
+ #define URL_SIZE 256
18
+
19
+ /* Return the offset of the first newline in text or the length of
20
+ text if there's no newline */
21
+ static int newline_offset(const char *text)
22
+ {
23
+ const char *newline = strchr(text, '\n');
24
+ if(!newline)
25
+ return strlen(text);
26
+ else
27
+ return (int)(newline - text);
28
+ }
29
+
30
+ struct write_result
31
+ {
32
+ char *data;
33
+ int pos;
34
+ };
35
+
36
+ static size_t write_response(void *ptr, size_t size, size_t nmemb, void *stream)
37
+ {
38
+ struct write_result *result = (struct write_result *)stream;
39
+
40
+ if(result->pos + size * nmemb >= BUFFER_SIZE - 1)
41
+ {
42
+ fprintf(stderr, "error: too small buffer\n");
43
+ return 0;
44
+ }
45
+
46
+ memcpy(result->data + result->pos, ptr, size * nmemb);
47
+ result->pos += size * nmemb;
48
+
49
+ return size * nmemb;
50
+ }
51
+
52
+ static char *request(const char *url)
53
+ {
54
+ CURL *curl = NULL;
55
+ CURLcode status;
56
+ char *data = NULL;
57
+ long code;
58
+
59
+ curl_global_init(CURL_GLOBAL_ALL);
60
+ curl = curl_easy_init();
61
+ if(!curl)
62
+ goto error;
63
+
64
+ data = malloc(BUFFER_SIZE);
65
+ if(!data)
66
+ goto error;
67
+
68
+ struct write_result write_result = {
69
+ .data = data,
70
+ .pos = 0
71
+ };
72
+
73
+ curl_easy_setopt(curl, CURLOPT_URL, url);
74
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_response);
75
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &write_result);
76
+
77
+ status = curl_easy_perform(curl);
78
+ if(status != 0)
79
+ {
80
+ fprintf(stderr, "error: unable to request data from %s:\n", url);
81
+ fprintf(stderr, "%s\n", curl_easy_strerror(status));
82
+ goto error;
83
+ }
84
+
85
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
86
+ if(code != 200)
87
+ {
88
+ fprintf(stderr, "error: server responded with code %ld\n", code);
89
+ goto error;
90
+ }
91
+
92
+ curl_easy_cleanup(curl);
93
+ curl_global_cleanup();
94
+
95
+ /* zero-terminate the result */
96
+ data[write_result.pos] = '\0';
97
+
98
+ return data;
99
+
100
+ error:
101
+ if(data)
102
+ free(data);
103
+ if(curl)
104
+ curl_easy_cleanup(curl);
105
+ curl_global_cleanup();
106
+ return NULL;
107
+ }
108
+
109
+ int main(int argc, char *argv[])
110
+ {
111
+ size_t i;
112
+ char *text;
113
+ char url[URL_SIZE];
114
+
115
+ json_t *root;
116
+ json_error_t error;
117
+
118
+ if(argc != 3)
119
+ {
120
+ fprintf(stderr, "usage: %s USER REPOSITORY\n\n", argv[0]);
121
+ fprintf(stderr, "List commits at USER's REPOSITORY.\n\n");
122
+ return 2;
123
+ }
124
+
125
+ snprintf(url, URL_SIZE, URL_FORMAT, argv[1], argv[2]);
126
+
127
+ text = request(url);
128
+ if(!text)
129
+ return 1;
130
+
131
+ root = json_loads(text, 0, &error);
132
+ free(text);
133
+
134
+ if(!root)
135
+ {
136
+ fprintf(stderr, "error: on line %d: %s\n", error.line, error.text);
137
+ return 1;
138
+ }
139
+
140
+ if(!json_is_array(root))
141
+ {
142
+ fprintf(stderr, "error: root is not an array\n");
143
+ json_decref(root);
144
+ return 1;
145
+ }
146
+
147
+ for(i = 0; i < json_array_size(root); i++)
148
+ {
149
+ json_t *data, *sha, *commit, *message;
150
+ const char *message_text;
151
+
152
+ data = json_array_get(root, i);
153
+ if(!json_is_object(data))
154
+ {
155
+ fprintf(stderr, "error: commit data %d is not an object\n", (int)(i + 1));
156
+ json_decref(root);
157
+ return 1;
158
+ }
159
+
160
+ sha = json_object_get(data, "sha");
161
+ if(!json_is_string(sha))
162
+ {
163
+ fprintf(stderr, "error: commit %d: sha is not a string\n", (int)(i + 1));
164
+ return 1;
165
+ }
166
+
167
+ commit = json_object_get(data, "commit");
168
+ if(!json_is_object(commit))
169
+ {
170
+ fprintf(stderr, "error: commit %d: commit is not an object\n", (int)(i + 1));
171
+ json_decref(root);
172
+ return 1;
173
+ }
174
+
175
+ message = json_object_get(commit, "message");
176
+ if(!json_is_string(message))
177
+ {
178
+ fprintf(stderr, "error: commit %d: message is not a string\n", (int)(i + 1));
179
+ json_decref(root);
180
+ return 1;
181
+ }
182
+
183
+ message_text = json_string_value(message);
184
+ printf("%.8s %.*s\n",
185
+ json_string_value(sha),
186
+ newline_offset(message_text),
187
+ message_text);
188
+ }
189
+
190
+ json_decref(root);
191
+ return 0;
192
+ }
@@ -0,0 +1,53 @@
1
+ Jansson Documentation
2
+ =====================
3
+
4
+ This is the documentation for Jansson_ |release|, last updated |today|.
5
+
6
+ Introduction
7
+ ------------
8
+
9
+ Jansson_ is a C library for encoding, decoding and manipulating JSON
10
+ data. Its main features and design principles are:
11
+
12
+ - Simple and intuitive API and data model
13
+
14
+ - Comprehensive documentation
15
+
16
+ - No dependencies on other libraries
17
+
18
+ - Full Unicode support (UTF-8)
19
+
20
+ - Extensive test suite
21
+
22
+ Jansson is licensed under the `MIT license`_; see LICENSE in the
23
+ source distribution for details.
24
+
25
+ Jansson is used in production and its API is stable. It works on
26
+ numerous platforms, including numerous Unix like systems and Windows.
27
+ It's suitable for use on any system, including desktop, server, and
28
+ small embedded systems.
29
+
30
+
31
+ .. _`MIT license`: http://www.opensource.org/licenses/mit-license.php
32
+ .. _Jansson: http://www.digip.org/jansson/
33
+
34
+ Contents
35
+ --------
36
+
37
+ .. toctree::
38
+ :maxdepth: 2
39
+
40
+ gettingstarted
41
+ upgrading
42
+ tutorial
43
+ conformance
44
+ portability
45
+ apiref
46
+ changes
47
+
48
+
49
+ Indices and Tables
50
+ ==================
51
+
52
+ * :ref:`genindex`
53
+ * :ref:`search`
@@ -0,0 +1,52 @@
1
+ ***********
2
+ Portability
3
+ ***********
4
+
5
+ Thread safety
6
+ -------------
7
+
8
+ Jansson is thread safe and has no mutable global state. The only
9
+ exception are the memory allocation functions, that should be set at
10
+ most once, and only on program startup. See
11
+ :ref:`apiref-custom-memory-allocation`.
12
+
13
+ There's no locking performed inside Jansson's code, so a multithreaded
14
+ program must perform its own locking if JSON values are shared by
15
+ multiple threads. Jansson's reference counting semantics may make this
16
+ a bit harder than it seems, as it's possible to have a reference to a
17
+ value that's also stored inside a list or object. Modifying the
18
+ container (adding or removing values) may trigger concurrent access to
19
+ such values, as containers manage the reference count of their
20
+ contained values. Bugs involving concurrent incrementing or
21
+ decrementing of deference counts may be hard to track.
22
+
23
+ The encoding functions (:func:`json_dumps()` and friends) track
24
+ reference loops by modifying the internal state of objects and arrays.
25
+ For this reason, encoding functions must not be run on the same JSON
26
+ values in two separate threads at the same time. As already noted
27
+ above, be especially careful if two arrays or objects share their
28
+ contained values with another array or object.
29
+
30
+ If you want to make sure that two JSON value hierarchies do not
31
+ contain shared values, use :func:`json_deep_copy()` to make copies.
32
+
33
+ Locale
34
+ ------
35
+
36
+ Jansson works fine under any locale.
37
+
38
+ However, if the host program is multithreaded and uses ``setlocale()``
39
+ to switch the locale in one thread while Jansson is currently encoding
40
+ or decoding JSON data in another thread, the result may be wrong or
41
+ the program may even crash.
42
+
43
+ Jansson uses locale specific functions for certain string conversions
44
+ in the encoder and decoder, and then converts the locale specific
45
+ values to/from the JSON representation. This fails if the locale
46
+ changes between the string conversion and the locale-to-JSON
47
+ conversion. This can only happen in multithreaded programs that use
48
+ ``setlocale()``, because ``setlocale()`` switches the locale for all
49
+ running threads, not only the thread that calls ``setlocale()``.
50
+
51
+ If your program uses ``setlocale()`` as described above, consider
52
+ using the thread-safe ``uselocale()`` instead.
@@ -0,0 +1,286 @@
1
+ .. _tutorial:
2
+
3
+ ********
4
+ Tutorial
5
+ ********
6
+
7
+ .. highlight:: c
8
+
9
+ In this tutorial, we create a program that fetches the latest commits
10
+ of a repository in GitHub_ over the web. `GitHub API`_ uses JSON, so
11
+ the result can be parsed using Jansson.
12
+
13
+ To stick to the the scope of this tutorial, we will only cover the the
14
+ parts of the program related to handling JSON data. For the best user
15
+ experience, the full source code is available:
16
+ :download:`github_commits.c`. To compile it (on Unix-like systems with
17
+ gcc), use the following command::
18
+
19
+ gcc -o github_commits github_commits.c -ljansson -lcurl
20
+
21
+ libcurl_ is used to communicate over the web, so it is required to
22
+ compile the program.
23
+
24
+ The command line syntax is::
25
+
26
+ github_commits USER REPOSITORY
27
+
28
+ ``USER`` is a GitHub user ID and ``REPOSITORY`` is the repository
29
+ name. Please note that the GitHub API is rate limited, so if you run
30
+ the program too many times within a short period of time, the sever
31
+ starts to respond with an error.
32
+
33
+ .. _GitHub: https://github.com/
34
+ .. _GitHub API: http://developer.github.com/
35
+ .. _libcurl: http://curl.haxx.se/
36
+
37
+
38
+ .. _tutorial-github-commits-api:
39
+
40
+ The GitHub Repo Commits API
41
+ ===========================
42
+
43
+ The `GitHub Repo Commits API`_ is used by sending HTTP requests to
44
+ URLs like ``https://api.github.com/repos/USER/REPOSITORY/commits``,
45
+ where ``USER`` and ``REPOSITORY`` are the GitHub user ID and the name
46
+ of the repository whose commits are to be listed, respectively.
47
+
48
+ GitHub responds with a JSON array of the following form:
49
+
50
+ .. code-block:: none
51
+
52
+ [
53
+ {
54
+ "sha": "<the commit ID>",
55
+ "commit": {
56
+ "message": "<the commit message>",
57
+ <more fields, not important to this tutorial...>
58
+ },
59
+ <more fields...>
60
+ },
61
+ {
62
+ "sha": "<the commit ID>",
63
+ "commit": {
64
+ "message": "<the commit message>",
65
+ <more fields...>
66
+ },
67
+ <more fields...>
68
+ },
69
+ <more commits...>
70
+ ]
71
+
72
+ In our program, the HTTP request is sent using the following
73
+ function::
74
+
75
+ static char *request(const char *url);
76
+
77
+ It takes the URL as a parameter, preforms a HTTP GET request, and
78
+ returns a newly allocated string that contains the response body. If
79
+ the request fails, an error message is printed to stderr and the
80
+ return value is *NULL*. For full details, refer to :download:`the code
81
+ <github_commits.c>`, as the actual implementation is not important
82
+ here.
83
+
84
+ .. _GitHub Repo Commits API: http://developer.github.com/v3/repos/commits/
85
+
86
+ .. _tutorial-the-program:
87
+
88
+ The Program
89
+ ===========
90
+
91
+ First the includes::
92
+
93
+ #include <string.h>
94
+ #include <jansson.h>
95
+
96
+ Like all the programs using Jansson, we need to include
97
+ :file:`jansson.h`.
98
+
99
+ The following definitions are used to build the GitHub API request
100
+ URL::
101
+
102
+ #define URL_FORMAT "https://api.github.com/repos/%s/%s/commits"
103
+ #define URL_SIZE 256
104
+
105
+ The following function is used when formatting the result to find the
106
+ first newline in the commit message::
107
+
108
+ /* Return the offset of the first newline in text or the length of
109
+ text if there's no newline */
110
+ static int newline_offset(const char *text)
111
+ {
112
+ const char *newline = strchr(text, '\n');
113
+ if(!newline)
114
+ return strlen(text);
115
+ else
116
+ return (int)(newline - text);
117
+ }
118
+
119
+ The main function follows. In the beginning, we first declare a bunch
120
+ of variables and check the command line parameters::
121
+
122
+ int main(int argc, char *argv[])
123
+ {
124
+ size_t i;
125
+ char *text;
126
+ char url[URL_SIZE];
127
+
128
+ json_t *root;
129
+ json_error_t error;
130
+
131
+ if(argc != 3)
132
+ {
133
+ fprintf(stderr, "usage: %s USER REPOSITORY\n\n", argv[0]);
134
+ fprintf(stderr, "List commits at USER's REPOSITORY.\n\n");
135
+ return 2;
136
+ }
137
+
138
+ Then we build the request URL using the user and repository names
139
+ given as command line parameters::
140
+
141
+ snprintf(url, URL_SIZE, URL_FORMAT, argv[1], argv[2]);
142
+
143
+ This uses the ``URL_SIZE`` and ``URL_FORMAT`` constants defined above.
144
+ Now we're ready to actually request the JSON data over the web::
145
+
146
+ text = request(url);
147
+ if(!text)
148
+ return 1;
149
+
150
+ If an error occurs, our function ``request`` prints the error and
151
+ returns *NULL*, so it's enough to just return 1 from the main
152
+ function.
153
+
154
+ Next we'll call :func:`json_loads()` to decode the JSON text we got
155
+ as a response::
156
+
157
+ root = json_loads(text, 0, &error);
158
+ free(text);
159
+
160
+ if(!root)
161
+ {
162
+ fprintf(stderr, "error: on line %d: %s\n", error.line, error.text);
163
+ return 1;
164
+ }
165
+
166
+ We don't need the JSON text anymore, so we can free the ``text``
167
+ variable right after decoding it. If :func:`json_loads()` fails, it
168
+ returns *NULL* and sets error information to the :type:`json_error_t`
169
+ structure given as the second parameter. In this case, our program
170
+ prints the error information out and returns 1 from the main function.
171
+
172
+ Now we're ready to extract the data out of the decoded JSON response.
173
+ The structure of the response JSON was explained in section
174
+ :ref:`tutorial-github-commits-api`.
175
+
176
+ We check that the returned value really is an array::
177
+
178
+ if(!json_is_array(root))
179
+ {
180
+ fprintf(stderr, "error: root is not an array\n");
181
+ json_decref(root);
182
+ return 1;
183
+ }
184
+
185
+ Then we proceed to loop over all the commits in the array::
186
+
187
+ for(i = 0; i < json_array_size(root); i++)
188
+ {
189
+ json_t *data, *sha, *commit, *message;
190
+ const char *message_text;
191
+
192
+ data = json_array_get(root, i);
193
+ if(!json_is_object(data))
194
+ {
195
+ fprintf(stderr, "error: commit data %d is not an object\n", i + 1);
196
+ json_decref(root);
197
+ return 1;
198
+ }
199
+ ...
200
+
201
+ The function :func:`json_array_size()` returns the size of a JSON
202
+ array. First, we again declare some variables and then extract the
203
+ i'th element of the ``root`` array using :func:`json_array_get()`.
204
+ We also check that the resulting value is a JSON object.
205
+
206
+ Next we'll extract the commit ID (a hexadecimal SHA-1 sum),
207
+ intermediate commit info object, and the commit message from that
208
+ object. We also do proper type checks::
209
+
210
+ sha = json_object_get(data, "sha");
211
+ if(!json_is_string(sha))
212
+ {
213
+ fprintf(stderr, "error: commit %d: sha is not a string\n", i + 1);
214
+ json_decref(root);
215
+ return 1;
216
+ }
217
+
218
+ commit = json_object_get(data, "commit");
219
+ if(!json_is_object(commit))
220
+ {
221
+ fprintf(stderr, "error: commit %d: commit is not an object\n", i + 1);
222
+ json_decref(root);
223
+ return 1;
224
+ }
225
+
226
+ message = json_object_get(commit, "message");
227
+ if(!json_is_string(message))
228
+ {
229
+ fprintf(stderr, "error: commit %d: message is not a string\n", i + 1);
230
+ json_decref(root);
231
+ return 1;
232
+ }
233
+ ...
234
+
235
+ And finally, we'll print the first 8 characters of the commit ID and
236
+ the first line of the commit message. A C-style string is extracted
237
+ from a JSON string using :func:`json_string_value()`::
238
+
239
+ message_text = json_string_value(message);
240
+ printf("%.8s %.*s\n",
241
+ json_string_value(id),
242
+ newline_offset(message_text),
243
+ message_text);
244
+ }
245
+
246
+ After sending the HTTP request, we decoded the JSON text using
247
+ :func:`json_loads()`, remember? It returns a *new reference* to the
248
+ JSON value it decodes. When we're finished with the value, we'll need
249
+ to decrease the reference count using :func:`json_decref()`. This way
250
+ Jansson can release the resources::
251
+
252
+ json_decref(root);
253
+ return 0;
254
+
255
+ For a detailed explanation of reference counting in Jansson, see
256
+ :ref:`apiref-reference-count` in :ref:`apiref`.
257
+
258
+ The program's ready, let's test it and view the latest commits in
259
+ Jansson's repository::
260
+
261
+ $ ./github_commits akheron jansson
262
+ 1581f26a Merge branch '2.3'
263
+ aabfd493 load: Change buffer_pos to be a size_t
264
+ bd72efbd load: Avoid unexpected behaviour in macro expansion
265
+ e8fd3e30 Document and tweak json_load_callback()
266
+ 873eddaf Merge pull request #60 from rogerz/contrib
267
+ bd2c0c73 Ignore the binary test_load_callback
268
+ 17a51a4b Merge branch '2.3'
269
+ 09c39adc Add json_load_callback to the list of exported symbols
270
+ cbb80baf Merge pull request #57 from rogerz/contrib
271
+ 040bd7b0 Add json_load_callback()
272
+ 2637faa4 Make test stripping locale independent
273
+ <...>
274
+
275
+
276
+ Conclusion
277
+ ==========
278
+
279
+ In this tutorial, we implemented a program that fetches the latest
280
+ commits of a GitHub repository using the GitHub Repo Commits API.
281
+ Jansson was used to decode the JSON response and to extract the commit
282
+ data.
283
+
284
+ This tutorial only covered a small part of Jansson. For example, we
285
+ did not create or manipulate JSON values at all. Proceed to
286
+ :ref:`apiref` to explore all features of Jansson.