Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added source from local repo

  • Loading branch information...
commit 791609992436d0d0a893260355788fdcc1437182 1 parent c80060f
Zsolt Keszthelyi authored
Showing with 10,104 additions and 3 deletions.
  1. +6 −1 .gitignore
  2. +7 −0 Makefile
  3. +13 −2 README.md
  4. +7 −0 client
  5. +11 −0 ebin/rrpc.app
  6. +56 −0 include/amqp_client.hrl
  7. +34 −0 include/amqp_client_internal.hrl
  8. +42 −0 include/amqp_gen_consumer_spec.hrl
  9. +28 −0 include/gm_specs.hrl
  10. +110 −0 include/rabbit.hrl
  11. +163 −0 include/rabbit_framing.hrl
  12. +25 −0 include/rabbit_msg_store.hrl
  13. +24 −0 include/rabbit_routing_prefixes.hrl
  14. +28 −0 include/rrpc.hrl
  15. +5 −0 lib/erlang-rfc4627/.gitignore
  16. +75 −0 lib/erlang-rfc4627/Makefile
  17. +128 −0 lib/erlang-rfc4627/README.md
  18. +46 −0 lib/erlang-rfc4627/debian/changelog
  19. +1 −0  lib/erlang-rfc4627/debian/compat
  20. +11 −0 lib/erlang-rfc4627/debian/control
  21. +33 −0 lib/erlang-rfc4627/debian/copyright
  22. +1 −0  lib/erlang-rfc4627/debian/dirs
  23. +41 −0 lib/erlang-rfc4627/debian/postinst.ex
  24. +39 −0 lib/erlang-rfc4627/debian/postrm.ex
  25. +37 −0 lib/erlang-rfc4627/debian/preinst.ex
  26. +40 −0 lib/erlang-rfc4627/debian/prerm.ex
  27. +6 −0 lib/erlang-rfc4627/debian/rules
  28. +18 −0 lib/erlang-rfc4627/ebin/rfc4627_jsonrpc.app
  29. +36 −0 lib/erlang-rfc4627/include/rfc4627.hrl
  30. +31 −0 lib/erlang-rfc4627/include/rfc4627_jsonrpc.hrl
  31. +2 −0  lib/erlang-rfc4627/rebar.config
  32. +586 −0 lib/erlang-rfc4627/src/rfc4627.erl
  33. +563 −0 lib/erlang-rfc4627/src/rfc4627_jsonrpc.erl
  34. +36 −0 lib/erlang-rfc4627/src/rfc4627_jsonrpc_app.erl
  35. +113 −0 lib/erlang-rfc4627/src/rfc4627_jsonrpc_cowboy.erl
  36. +172 −0 lib/erlang-rfc4627/src/rfc4627_jsonrpc_http.erl
  37. +173 −0 lib/erlang-rfc4627/src/rfc4627_jsonrpc_inets.erl
  38. +117 −0 lib/erlang-rfc4627/src/rfc4627_jsonrpc_mochiweb.erl
  39. +92 −0 lib/erlang-rfc4627/src/rfc4627_jsonrpc_registry.erl
  40. +42 −0 lib/erlang-rfc4627/src/rfc4627_jsonrpc_sup.erl
  41. +15 −0 lib/erlang-rfc4627/test/server_root/conf/httpd.conf
  42. +465 −0 lib/erlang-rfc4627/test/server_root/conf/mime.types
  43. +21 −0 lib/erlang-rfc4627/test/server_root/htdocs/index.html
  44. +482 −0 lib/erlang-rfc4627/test/server_root/htdocs/json.js
  45. +129 −0 lib/erlang-rfc4627/test/server_root/htdocs/jsonrpc.js
  46. +1,781 −0 lib/erlang-rfc4627/test/server_root/htdocs/prototype-1.4.0.js
  47. +15 −0 lib/erlang-rfc4627/test/server_root/htdocs/test-client.js
  48. +2 −0  lib/erlang-rfc4627/test/server_root/logs/README
  49. +82 −0 lib/erlang-rfc4627/test/test_jsonrpc_inets.erl
  50. +203 −0 lib/erlang-rfc4627/test/test_rfc4627.erl
  51. +1 −0  lib/erlang-yaml
  52. +1 −0  lib/erlport
  53. +1 −0  lib/rabbitmq-codegen/.gitignore
  54. BIN  lib/rabbitmq-codegen/.hg/00changelog.i
  55. +1 −0  lib/rabbitmq-codegen/.hg/branch
  56. +50 −0 lib/rabbitmq-codegen/.hg/cache/branchheads
  57. +48 −0 lib/rabbitmq-codegen/.hg/cache/tags
  58. BIN  lib/rabbitmq-codegen/.hg/dirstate
  59. +2 −0  lib/rabbitmq-codegen/.hg/hgrc
  60. +4 −0 lib/rabbitmq-codegen/.hg/requires
  61. BIN  lib/rabbitmq-codegen/.hg/store/00changelog.i
  62. BIN  lib/rabbitmq-codegen/.hg/store/00manifest.i
  63. BIN  lib/rabbitmq-codegen/.hg/store/data/_l_i_c_e_n_s_e-_l_g_p_l21.i
  64. BIN  lib/rabbitmq-codegen/.hg/store/data/_l_i_c_e_n_s_e-_m_p_l-_rabbit_m_q.i
  65. BIN  lib/rabbitmq-codegen/.hg/store/data/_l_i_c_e_n_s_e.i
  66. BIN  lib/rabbitmq-codegen/.hg/store/data/_makefile.i
  67. BIN  lib/rabbitmq-codegen/.hg/store/data/_r_e_a_d_m_e.extensions.md.i
  68. BIN  lib/rabbitmq-codegen/.hg/store/data/amqp-0.8.json.i
  69. BIN  lib/rabbitmq-codegen/.hg/store/data/amqp-0.9.1.json.i
  70. BIN  lib/rabbitmq-codegen/.hg/store/data/amqp-rabbitmq-0.8.json.i
  71. BIN  lib/rabbitmq-codegen/.hg/store/data/amqp-rabbitmq-0.9.1.json.i
  72. BIN  lib/rabbitmq-codegen/.hg/store/data/amqp-rabbitmq.json.i
  73. BIN  lib/rabbitmq-codegen/.hg/store/data/amqp__codegen.py.i
  74. BIN  lib/rabbitmq-codegen/.hg/store/data/confirm-extension.json.i
  75. BIN  lib/rabbitmq-codegen/.hg/store/data/demo__extension.json.i
  76. BIN  lib/rabbitmq-codegen/.hg/store/data/json.py.i
  77. BIN  lib/rabbitmq-codegen/.hg/store/data/license__info.i
  78. BIN  lib/rabbitmq-codegen/.hg/store/data/puback-extension.json.i
  79. BIN  lib/rabbitmq-codegen/.hg/store/data/rabbitmq-0.8-extensions.json.i
  80. BIN  lib/rabbitmq-codegen/.hg/store/data/recover-0.8.json.i
  81. BIN  lib/rabbitmq-codegen/.hg/store/data/unbind-0.8.json.i
  82. BIN  lib/rabbitmq-codegen/.hg/store/data/~2egitignore.i
  83. BIN  lib/rabbitmq-codegen/.hg/store/data/~2ehgignore.i
  84. BIN  lib/rabbitmq-codegen/.hg/store/data/~2ehgtags.i
  85. +22 −0 lib/rabbitmq-codegen/.hg/store/fncache
  86. BIN  lib/rabbitmq-codegen/.hg/store/undo
  87. 0  lib/rabbitmq-codegen/.hg/undo.bookmarks
  88. +1 −0  lib/rabbitmq-codegen/.hg/undo.branch
  89. +3 −0  lib/rabbitmq-codegen/.hg/undo.desc
  90. 0  lib/rabbitmq-codegen/.hg/undo.dirstate
  91. +5 −0 lib/rabbitmq-codegen/.hgignore
  92. +31 −0 lib/rabbitmq-codegen/.hgtags
  93. +6 −0 lib/rabbitmq-codegen/LICENSE
  94. +455 −0 lib/rabbitmq-codegen/LICENSE-MPL-RabbitMQ
  95. +8 −0 lib/rabbitmq-codegen/Makefile
  96. +189 −0 lib/rabbitmq-codegen/README.extensions.md
  97. +659 −0 lib/rabbitmq-codegen/amqp-rabbitmq-0.8.json
  98. +467 −0 lib/rabbitmq-codegen/amqp-rabbitmq-0.9.1.json
  99. +286 −0 lib/rabbitmq-codegen/amqp_codegen.py
  100. +18 −0 lib/rabbitmq-codegen/demo_extension.json
  101. +4 −0 lib/rabbitmq-codegen/license_info
  102. BIN  lib/rabbitmq-erlang-client/.hg/00changelog.i
  103. +1 −0  lib/rabbitmq-erlang-client/.hg/branch
  104. +271 −0 lib/rabbitmq-erlang-client/.hg/cache/branchheads
  105. +45 −0 lib/rabbitmq-erlang-client/.hg/cache/tags
  106. BIN  lib/rabbitmq-erlang-client/.hg/dirstate
  107. +2 −0  lib/rabbitmq-erlang-client/.hg/hgrc
  108. +4 −0 lib/rabbitmq-erlang-client/.hg/requires
  109. BIN  lib/rabbitmq-erlang-client/.hg/store/00changelog.d
  110. BIN  lib/rabbitmq-erlang-client/.hg/store/00changelog.i
  111. BIN  lib/rabbitmq-erlang-client/.hg/store/00manifest.d
  112. BIN  lib/rabbitmq-erlang-client/.hg/store/00manifest.i
  113. BIN  lib/rabbitmq-erlang-client/.hg/store/data/_makefile.i
  114. BIN  lib/rabbitmq-erlang-client/.hg/store/data/_makefile.in.i
  115. BIN  lib/rabbitmq-erlang-client/.hg/store/data/_r_e_a_d_m_e.i
  116. BIN  lib/rabbitmq-erlang-client/.hg/store/data/_r_e_a_d_m_e.in.i
  117. BIN  lib/rabbitmq-erlang-client/.hg/store/data/certs/_makefile.i
  118. BIN  lib/rabbitmq-erlang-client/.hg/store/data/codegen.py.i
  119. BIN  lib/rabbitmq-erlang-client/.hg/store/data/common.mk.i
  120. BIN  lib/rabbitmq-erlang-client/.hg/store/data/ebin/amqp__client.app.i
  121. BIN  lib/rabbitmq-erlang-client/.hg/store/data/ebin/amqp__client.app.in.i
  122. BIN  lib/rabbitmq-erlang-client/.hg/store/data/examples/certs/_makefile.i
  123. BIN  lib/rabbitmq-erlang-client/.hg/store/data/examples/certs/ca/cacerts.cer.i
  124. BIN  lib/rabbitmq-erlang-client/.hg/store/data/examples/certs/ca/cacerts.pem.i
  125. BIN  lib/rabbitmq-erlang-client/.hg/store/data/examples/certs/client/cert.pem.i
  126. BIN  lib/rabbitmq-erlang-client/.hg/store/data/examples/certs/client/key.pem.i
  127. BIN  lib/rabbitmq-erlang-client/.hg/store/data/examples/certs/server/cert.pem.i
  128. BIN  lib/rabbitmq-erlang-client/.hg/store/data/examples/certs/server/key.pem.i
  129. BIN  lib/rabbitmq-erlang-client/.hg/store/data/include.mk.i
  130. BIN  lib/rabbitmq-erlang-client/.hg/store/data/include/amqp__client.hrl.i
  131. BIN  lib/rabbitmq-erlang-client/.hg/store/data/include/amqp__client__internal.hrl.i
  132. BIN  lib/rabbitmq-erlang-client/.hg/store/data/include/amqp__connection__util.hrl.i
  133. BIN  lib/rabbitmq-erlang-client/.hg/store/data/include/amqp__gen__consumer__spec.hrl.i
  134. BIN  lib/rabbitmq-erlang-client/.hg/store/data/include/rabbit.hrl.i
  135. BIN  lib/rabbitmq-erlang-client/.hg/store/data/include/rabbit__routing__prefixes.hrl.i
  136. BIN  lib/rabbitmq-erlang-client/.hg/store/data/include/routing__prefixes.hrl.i
  137. BIN  lib/rabbitmq-erlang-client/.hg/store/data/java/blocking__timeout.patch.i
  138. BIN  lib/rabbitmq-erlang-client/.hg/store/data/java/primitive__call.patch.i
  139. BIN  lib/rabbitmq-erlang-client/.hg/store/data/java/rabbit__management/pom.xml.i
  140. BIN  ...g-client/.hg/store/data/java/rabbit__management/src/main/java/com/rabbitmq/management/_proxy_factory.java.i
  141. BIN  .../.hg/store/data/java/rabbit__management/src/main/java/com/rabbitmq/management/_rabbit_access_control.java.i
  142. BIN  ...erlang-client/.hg/store/data/java/rabbit__management/src/main/java/com/rabbitmq/management/_resource.java.i
  143. BIN  ...q-erlang-client/.hg/store/data/java/rabbit__management/src/main/java/com/rabbitmq/management/_ticket.java.i
  144. BIN  ...tmq-erlang-client/.hg/store/data/java/rabbit__management/src/main/java/com/rabbitmq/management/_user.java.i
  145. BIN  lib/rabbitmq-erlang-client/.hg/store/data/java/rabbit__management/src/main/resources/log4j.properties.i
  146. BIN  ...store/data/java/rabbit__management/src/test/java/com/rabbitmq/management/_rabbit_access_control_test.java.i
  147. BIN  lib/rabbitmq-erlang-client/.hg/store/data/rabbit.patch.i
  148. BIN  lib/rabbitmq-erlang-client/.hg/store/data/rabbit__common.app.i
  149. BIN  lib/rabbitmq-erlang-client/.hg/store/data/rabbit__common.app.in.i
  150. BIN  lib/rabbitmq-erlang-client/.hg/store/data/rabbit__management.app.i
  151. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__auth__mechanisms.erl.i
  152. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__channel.erl.d
  153. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__channel.erl.i
  154. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__channel__sup.erl.i
  155. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__channel__sup__sup.erl.i
  156. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__channel__util.erl.i
  157. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__channels__manager.erl.i
  158. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__client.erl.i
  159. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__connection.erl.i
  160. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__connection__specific__sup.erl.i
  161. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__connection__sup.erl.i
  162. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__connection__type__sup.erl.i
  163. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__connection__util.erl.i
  164. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__consumer.erl.i
  165. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__direct__client__test.erl.i
  166. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__direct__connection.erl.i
  167. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__direct__consumer.erl.i
  168. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__direct__driver.erl.i
  169. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__gen__connection.erl.i
  170. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__gen__consumer.erl.i
  171. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__infra__sup.erl.i
  172. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__main__reader.erl.i
  173. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__method__util.erl.i
  174. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__network__client__test.erl.i
  175. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__network__connection.erl.i
  176. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__network__driver.erl.i
  177. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__rpc__client.erl.i
  178. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__rpc__handler.erl.i
  179. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__rpc__server.erl.i
  180. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__rpc__util.erl.i
  181. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__selective__consumer.erl.i
  182. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__sup.erl.i
  183. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__test__util.erl.i
  184. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__uri.erl.i
  185. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__url.erl.i
  186. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__util.erl.i
  187. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/amqp__writer__sup.erl.i
  188. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/direct__client__test.erl.i
  189. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/direct__integration__test.erl.i
  190. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/integration__test__util.erl.i
  191. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/lib__amqp.erl.i
  192. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/negative__test__util.erl.i
  193. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/network__client__test.erl.i
  194. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/network__integration__test.erl.i
  195. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/overview.edoc.in.i
  196. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit.erl.i
  197. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__access__control.erl.i
  198. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__amqqueue.erl.i
  199. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__amqqueue__process.erl.i
  200. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__binary__generator.erl.i
  201. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__binary__parser.erl.i
  202. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__channel.erl.i
  203. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__channel0.erl.i
  204. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__control.erl.i
  205. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__direct__channel.erl.i
  206. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__error__logger.erl.i
  207. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__exchange.erl.i
  208. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__framing__channel.erl.i
  209. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__gc__persist.erl.i
  210. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__gensym.erl.i
  211. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__load.erl.i
  212. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__log.erl.i
  213. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__management.erl.i
  214. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__management__application.erl.i
  215. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__management__supervisor.erl.i
  216. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__misc.erl.i
  217. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__mnesia.erl.i
  218. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__monitor.erl.i
  219. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__networking.erl.i
  220. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__node__monitor.erl.i
  221. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__persister.erl.i
  222. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__persister__sup.erl.i
  223. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__reader.erl.i
  224. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__realm.erl.i
  225. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__routing__util.erl.i
  226. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__sup.erl.i
  227. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__tests.erl.i
  228. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__ticket.erl.i
  229. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__tracer.erl.i
  230. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__transaction.erl.i
  231. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/rabbit__writer.erl.i
  232. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/routing__util.erl.i
  233. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/ssl__client__test.erl.i
  234. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/tcp__acceptor.erl.i
  235. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/tcp__acceptor__sup.erl.i
  236. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/tcp__client__sup.erl.i
  237. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/tcp__listener.erl.i
  238. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/tcp__listener__sup.erl.i
  239. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/test__util.erl.i
  240. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/transport__agnostic__server.erl.i
  241. BIN  lib/rabbitmq-erlang-client/.hg/store/data/src/uri__parser.erl.i
  242. BIN  lib/rabbitmq-erlang-client/.hg/store/data/tailor.conf.i
  243. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test.mk.i
  244. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/_makefile.i
  245. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/amqp__client___s_u_i_t_e.erl.i
  246. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/amqp__consumer.erl.i
  247. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/amqp__dbg.erl.i
  248. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/amqp__direct__client__test.erl.i
  249. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/amqp__network__client__test.erl.i
  250. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/amqp__rpc__handler.erl.i
  251. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/amqp__test__util.erl.i
  252. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/direct__client___s_u_i_t_e.erl.i
  253. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/negative__test__util.erl.i
  254. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/network__client___s_u_i_t_e.erl.i
  255. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/ssl__client___s_u_i_t_e.erl.i
  256. BIN  lib/rabbitmq-erlang-client/.hg/store/data/test/test__util.erl.i
  257. BIN  lib/rabbitmq-erlang-client/.hg/store/data/tests/_makefile.i
  258. BIN  lib/rabbitmq-erlang-client/.hg/store/data/tests/direct__client__test.erl.i
  259. BIN  lib/rabbitmq-erlang-client/.hg/store/data/tests/negative__test__util.erl.i
  260. BIN  lib/rabbitmq-erlang-client/.hg/store/data/tests/network__client__test.erl.i
  261. BIN  lib/rabbitmq-erlang-client/.hg/store/data/tests/src/direct__client__test.erl.i
  262. BIN  lib/rabbitmq-erlang-client/.hg/store/data/tests/src/negative__test__util.erl.i
  263. BIN  lib/rabbitmq-erlang-client/.hg/store/data/tests/src/network__client__test.erl.i
  264. BIN  lib/rabbitmq-erlang-client/.hg/store/data/tests/src/test__util.erl.i
  265. BIN  lib/rabbitmq-erlang-client/.hg/store/data/tests/test__util.erl.i
  266. BIN  lib/rabbitmq-erlang-client/.hg/store/data/~2ehgignore.i
  267. BIN  lib/rabbitmq-erlang-client/.hg/store/data/~2ehgtags.i
  268. +155 −0 lib/rabbitmq-erlang-client/.hg/store/fncache
  269. BIN  lib/rabbitmq-erlang-client/.hg/store/undo
  270. 0  lib/rabbitmq-erlang-client/.hg/undo.bookmarks
  271. +1 −0  lib/rabbitmq-erlang-client/.hg/undo.branch
  272. +3 −0  lib/rabbitmq-erlang-client/.hg/undo.desc
  273. 0  lib/rabbitmq-erlang-client/.hg/undo.dirstate
  274. +11 −0 lib/rabbitmq-erlang-client/.hgignore
  275. +23 −0 lib/rabbitmq-erlang-client/.hgtags
  276. +125 −0 lib/rabbitmq-erlang-client/Makefile
  277. +26 −0 lib/rabbitmq-erlang-client/Makefile.in
  278. +10 −0 lib/rabbitmq-erlang-client/README.in
  279. +200 −0 lib/rabbitmq-erlang-client/common.mk
  280. +23 −0 lib/rabbitmq-erlang-client/deps.mk
  281. BIN  lib/rabbitmq-erlang-client/dist/amqp_client-0.0.0.ez
  282. +16 −0 lib/rabbitmq-erlang-client/dist/amqp_client-0.0.0/ebin/amqp_client.app
  283. +56 −0 lib/rabbitmq-erlang-client/dist/amqp_client-0.0.0/include/amqp_client.hrl
  284. +34 −0 lib/rabbitmq-erlang-client/dist/amqp_client-0.0.0/include/amqp_client_internal.hrl
  285. +42 −0 lib/rabbitmq-erlang-client/dist/amqp_client-0.0.0/include/amqp_gen_consumer_spec.hrl
  286. +24 −0 lib/rabbitmq-erlang-client/dist/amqp_client-0.0.0/include/rabbit_routing_prefixes.hrl
  287. BIN  lib/rabbitmq-erlang-client/dist/rabbit_common-0.0.0.ez
  288. +17 −0 lib/rabbitmq-erlang-client/dist/rabbit_common-0.0.0/ebin/rabbit_common.app
  289. +28 −0 lib/rabbitmq-erlang-client/dist/rabbit_common-0.0.0/include/gm_specs.hrl
  290. +110 −0 lib/rabbitmq-erlang-client/dist/rabbit_common-0.0.0/include/rabbit.hrl
  291. +163 −0 lib/rabbitmq-erlang-client/dist/rabbit_common-0.0.0/include/rabbit_framing.hrl
  292. +25 −0 lib/rabbitmq-erlang-client/dist/rabbit_common-0.0.0/include/rabbit_msg_store.hrl
  293. +16 −0 lib/rabbitmq-erlang-client/ebin/amqp_client.app
  294. +8 −0 lib/rabbitmq-erlang-client/ebin/amqp_client.app.in
  295. +56 −0 lib/rabbitmq-erlang-client/include/amqp_client.hrl
  296. +34 −0 lib/rabbitmq-erlang-client/include/amqp_client_internal.hrl
  297. +42 −0 lib/rabbitmq-erlang-client/include/amqp_gen_consumer_spec.hrl
  298. +24 −0 lib/rabbitmq-erlang-client/include/rabbit_routing_prefixes.hrl
  299. +17 −0 lib/rabbitmq-erlang-client/rabbit_common.app
  300. +37 −0 lib/rabbitmq-erlang-client/rabbit_common.app.in
Sorry, we could not display the entire diff because too many files (1,004) changed.
View
7 .gitignore
@@ -1,5 +1,10 @@
.eunit
deps
*.o
+*.so
*.beam
-*.plt
+*.plt
+*~
+*.swp
+priv/logs/*
+erl_crash.dump
View
7 Makefile
@@ -0,0 +1,7 @@
+compile:
+ ./rebar compile
+
+clean:
+ ./rebar clean
+
+.PHONY: compile clean
View
15 README.md
@@ -1,4 +1,15 @@
-ansible_rpc_server
+Ansible RPC Server
==================
-JSON-RPC server with an Ansible Runner service
+JSON-RPC server with an Ansible Runner service. Accepts JSON-RPC 1.1 requests over RabbitMq .
+( not production ready )
+
+
+Needs a 'test' exchange declared.
+Requests need to be published to 'rpc\_queue/service\_name' queue.
+
+Based on: https://github.com/tonyg/erlang-rfc4627
+
+For request format see: rrpc\_test\_publisher:sample\_\request/0
+
+Playbooks can register a playbook\_out variable that will be returned as a response to the RPC request.
View
7 client
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+export ERL_LIBS=libs
+
+erl -pa ebin lib/*/ebin lib/*/priv -sname rrpc_client -setcookie aaa -boot start_sasl -config priv/rrpc -s reloader
+
+
View
11 ebin/rrpc.app
@@ -0,0 +1,11 @@
+{application,rrpc,
+ [{description,[]},
+ {vsn,"1"},
+ {registered,[]},
+ {applications,[kernel,stdlib]},
+ {mod,{rrpc_app,[]}},
+ {env,[]},
+ {modules,[reloader,rrpc,rrpc_amr,rrpc_app,rrpc_apr,
+ rrpc_consumer,rrpc_consumer_sup,rrpc_services_sup,
+ rrpc_sup,rrpc_test_publisher,rrpc_test_service,
+ rrpc_util,service_ansible,start]}]}.
View
56 include/amqp_client.hrl
@@ -0,0 +1,56 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License at
+%% http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+%% License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is VMware, Inc.
+%% Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
+%%
+
+-ifndef(AMQP_CLIENT_HRL).
+-define(AMQP_CLIENT_HRL, true).
+
+-include_lib("rabbit.hrl").
+-include_lib("rabbit_framing.hrl").
+
+-record(amqp_msg, {props = #'P_basic'{}, payload = <<>>}).
+
+-record(amqp_params_network, {username = <<"guest">>,
+ password = <<"guest">>,
+ virtual_host = <<"/">>,
+ host = "localhost",
+ port = undefined,
+ channel_max = 0,
+ frame_max = 0,
+ heartbeat = 0,
+ connection_timeout = infinity,
+ ssl_options = none,
+ auth_mechanisms =
+ [fun amqp_auth_mechanisms:plain/3,
+ fun amqp_auth_mechanisms:amqplain/3],
+ client_properties = [],
+ socket_options = []}).
+
+-record(amqp_params_direct, {username = <<"guest">>,
+ password = none,
+ virtual_host = <<"/">>,
+ node = node(),
+ adapter_info = none,
+ client_properties = []}).
+
+-record(amqp_adapter_info, {host = unknown,
+ port = unknown,
+ peer_host = unknown,
+ peer_port = unknown,
+ name = unknown,
+ protocol = unknown,
+ additional_info = []}).
+
+-endif.
View
34 include/amqp_client_internal.hrl
@@ -0,0 +1,34 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License at
+%% http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+%% License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is VMware, Inc.
+%% Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
+%%
+
+-include("amqp_client.hrl").
+
+-define(PROTOCOL_VERSION_MAJOR, 0).
+-define(PROTOCOL_VERSION_MINOR, 9).
+-define(PROTOCOL_HEADER, <<"AMQP", 0, 0, 9, 1>>).
+-define(PROTOCOL, rabbit_framing_amqp_0_9_1).
+
+-define(MAX_CHANNEL_NUMBER, 65535).
+
+-define(LOG_DEBUG(Format), error_logger:info_msg(Format)).
+-define(LOG_INFO(Format, Args), error_logger:info_msg(Format, Args)).
+-define(LOG_WARN(Format, Args), error_logger:warning_msg(Format, Args)).
+-define(LOG_ERR(Format, Args), error_logger:error_msg(Format, Args)).
+
+-define(CLIENT_CAPABILITIES, [{<<"publisher_confirms">>, bool, true},
+ {<<"exchange_exchange_bindings">>, bool, true},
+ {<<"basic.nack">>, bool, true},
+ {<<"consumer_cancel_notify">>, bool, true}]).
View
42 include/amqp_gen_consumer_spec.hrl
@@ -0,0 +1,42 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License at
+%% http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+%% License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is VMware, Inc.
+%% Copyright (c) 2011-2013 VMware, Inc. All rights reserved.
+%%
+
+-include("amqp_client.hrl").
+
+-ifndef(edoc).
+-type(state() :: any()).
+-type(consume() :: #'basic.consume'{}).
+-type(consume_ok() :: #'basic.consume_ok'{}).
+-type(cancel() :: #'basic.cancel'{}).
+-type(cancel_ok() :: #'basic.cancel_ok'{}).
+-type(deliver() :: #'basic.deliver'{}).
+-type(from() :: any()).
+-type(reason() :: any()).
+-type(ok_error() :: {ok, state()} | {error, reason(), state()}).
+
+-spec(init/1 :: ([any()]) -> {ok, state()}).
+-spec(handle_consume/3 :: (consume(), pid(), state()) -> ok_error()).
+-spec(handle_consume_ok/3 :: (consume_ok(), consume(), state()) ->
+ ok_error()).
+-spec(handle_cancel/2 :: (cancel(), state()) -> ok_error()).
+-spec(handle_cancel_ok/3 :: (cancel_ok(), cancel(), state()) -> ok_error()).
+-spec(handle_deliver/3 :: (deliver(), #amqp_msg{}, state()) -> ok_error()).
+-spec(handle_info/2 :: (any(), state()) -> ok_error()).
+-spec(handle_call/3 :: (any(), from(), state()) ->
+ {reply, any(), state()} | {noreply, state()} |
+ {error, reason(), state()}).
+-spec(terminate/2 :: (any(), state()) -> state()).
+-endif.
View
28 include/gm_specs.hrl
@@ -0,0 +1,28 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License at
+%% http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+%% License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is VMware, Inc.
+%% Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
+%%
+
+-ifdef(use_specs).
+
+-type(callback_result() :: 'ok' | {'stop', any()} | {'become', atom(), args()}).
+-type(args() :: any()).
+-type(members() :: [pid()]).
+
+-spec(joined/2 :: (args(), members()) -> callback_result()).
+-spec(members_changed/3 :: (args(), members(), members()) -> callback_result()).
+-spec(handle_msg/3 :: (args(), pid(), any()) -> callback_result()).
+-spec(terminate/2 :: (args(), term()) -> any()).
+
+-endif.
View
110 include/rabbit.hrl
@@ -0,0 +1,110 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License
+%% at http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and
+%% limitations under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is VMware, Inc.
+%% Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
+%%
+
+-record(user, {username,
+ tags,
+ auth_backend, %% Module this user came from
+ impl %% Scratch space for that module
+ }).
+
+-record(internal_user, {username, password_hash, tags}).
+-record(permission, {configure, write, read}).
+-record(user_vhost, {username, virtual_host}).
+-record(user_permission, {user_vhost, permission}).
+
+-record(vhost, {virtual_host, dummy}).
+
+-record(content,
+ {class_id,
+ properties, %% either 'none', or a decoded record/tuple
+ properties_bin, %% either 'none', or an encoded properties binary
+ %% Note: at most one of properties and properties_bin can be
+ %% 'none' at once.
+ protocol, %% The protocol under which properties_bin was encoded
+ payload_fragments_rev %% list of binaries, in reverse order (!)
+ }).
+
+-record(resource, {virtual_host, kind, name}).
+
+-record(exchange, {name, type, durable, auto_delete, internal, arguments,
+ scratches, policy}).
+-record(exchange_serial, {name, next}).
+
+-record(amqqueue, {name, durable, auto_delete, exclusive_owner = none,
+ arguments, pid, slave_pids, sync_slave_pids, policy,
+ gm_pids}).
+
+%% mnesia doesn't like unary records, so we add a dummy 'value' field
+-record(route, {binding, value = const}).
+-record(reverse_route, {reverse_binding, value = const}).
+
+-record(binding, {source, key, destination, args = []}).
+-record(reverse_binding, {destination, key, source, args = []}).
+
+-record(topic_trie_node, {trie_node, edge_count, binding_count}).
+-record(topic_trie_edge, {trie_edge, node_id}).
+-record(topic_trie_binding, {trie_binding, value = const}).
+
+-record(trie_node, {exchange_name, node_id}).
+-record(trie_edge, {exchange_name, node_id, word}).
+-record(trie_binding, {exchange_name, node_id, destination}).
+
+-record(listener, {node, protocol, host, ip_address, port}).
+
+-record(runtime_parameters, {key, value}).
+
+-record(basic_message, {exchange_name, routing_keys = [], content, id,
+ is_persistent}).
+
+-record(ssl_socket, {tcp, ssl}).
+-record(delivery, {mandatory, sender, message, msg_seq_no}).
+-record(amqp_error, {name, explanation = "", method = none}).
+
+-record(event, {type, props, timestamp}).
+
+-record(message_properties, {expiry, needs_confirming = false}).
+
+-record(plugin, {name, %% atom()
+ version, %% string()
+ description, %% string()
+ type, %% 'ez' or 'dir'
+ dependencies, %% [{atom(), string()}]
+ location}). %% string()
+
+%%----------------------------------------------------------------------------
+
+-define(COPYRIGHT_MESSAGE, "Copyright (C) 2007-2013 VMware, Inc.").
+-define(INFORMATION_MESSAGE, "Licensed under the MPL. See http://www.rabbitmq.com/").
+-define(ERTS_MINIMUM, "5.6.3").
+
+%% EMPTY_FRAME_SIZE, 8 = 1 + 2 + 4 + 1
+%% - 1 byte of frame type
+%% - 2 bytes of channel number
+%% - 4 bytes of frame payload length
+%% - 1 byte of payload trailer FRAME_END byte
+%% See rabbit_binary_generator:check_empty_frame_size/0, an assertion
+%% called at startup.
+-define(EMPTY_FRAME_SIZE, 8).
+
+-define(MAX_WAIT, 16#ffffffff).
+
+-define(HIBERNATE_AFTER_MIN, 1000).
+-define(DESIRED_HIBERNATE, 10000).
+-define(CREDIT_DISC_BOUND, {2000, 500}).
+
+-define(INVALID_HEADERS_KEY, <<"x-invalid-headers">>).
+-define(ROUTING_HEADERS, [<<"CC">>, <<"BCC">>]).
+-define(DELETED_HEADER, <<"BCC">>).
View
163 include/rabbit_framing.hrl
@@ -0,0 +1,163 @@
+%% Autogenerated code. Do not edit.
+%%
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License
+%% at http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and
+%% limitations under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is VMware, Inc.
+%% Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
+%%
+-define(PROTOCOL_PORT, 5672).
+-define(FRAME_METHOD, 1).
+-define(FRAME_HEADER, 2).
+-define(FRAME_BODY, 3).
+-define(FRAME_HEARTBEAT, 8).
+-define(FRAME_MIN_SIZE, 4096).
+-define(FRAME_END, 206).
+-define(REPLY_SUCCESS, 200).
+-define(CONTENT_TOO_LARGE, 311).
+-define(NO_ROUTE, 312).
+-define(NO_CONSUMERS, 313).
+-define(ACCESS_REFUSED, 403).
+-define(NOT_FOUND, 404).
+-define(RESOURCE_LOCKED, 405).
+-define(PRECONDITION_FAILED, 406).
+-define(CONNECTION_FORCED, 320).
+-define(INVALID_PATH, 402).
+-define(FRAME_ERROR, 501).
+-define(SYNTAX_ERROR, 502).
+-define(COMMAND_INVALID, 503).
+-define(CHANNEL_ERROR, 504).
+-define(UNEXPECTED_FRAME, 505).
+-define(RESOURCE_ERROR, 506).
+-define(NOT_ALLOWED, 530).
+-define(NOT_IMPLEMENTED, 540).
+-define(INTERNAL_ERROR, 541).
+-define(FRAME_OOB_METHOD, 4).
+-define(FRAME_OOB_HEADER, 5).
+-define(FRAME_OOB_BODY, 6).
+-define(FRAME_TRACE, 7).
+-define(NOT_DELIVERED, 310).
+%% Method field records.
+-record('connection.start', {version_major = 0, version_minor = 9, server_properties, mechanisms = <<"PLAIN">>, locales = <<"en_US">>}).
+-record('connection.start_ok', {client_properties, mechanism = <<"PLAIN">>, response, locale = <<"en_US">>}).
+-record('connection.secure', {challenge}).
+-record('connection.secure_ok', {response}).
+-record('connection.tune', {channel_max = 0, frame_max = 0, heartbeat = 0}).
+-record('connection.tune_ok', {channel_max = 0, frame_max = 0, heartbeat = 0}).
+-record('connection.open', {virtual_host = <<"/">>, capabilities = <<"">>, insist = false}).
+-record('connection.open_ok', {known_hosts = <<"">>}).
+-record('connection.close', {reply_code, reply_text = <<"">>, class_id, method_id}).
+-record('connection.close_ok', {}).
+-record('connection.redirect', {host, known_hosts = <<"">>}).
+-record('channel.open', {out_of_band = <<"">>}).
+-record('channel.open_ok', {channel_id = <<"">>}).
+-record('channel.flow', {active}).
+-record('channel.flow_ok', {active}).
+-record('channel.close', {reply_code, reply_text = <<"">>, class_id, method_id}).
+-record('channel.close_ok', {}).
+-record('channel.alert', {reply_code, reply_text = <<"">>, details = []}).
+-record('access.request', {realm = <<"/data">>, exclusive = false, passive = true, active = true, write = true, read = true}).
+-record('access.request_ok', {ticket = 1}).
+-record('exchange.declare', {ticket = 0, exchange, type = <<"direct">>, passive = false, durable = false, auto_delete = false, internal = false, nowait = false, arguments = []}).
+-record('exchange.declare_ok', {}).
+-record('exchange.delete', {ticket = 0, exchange, if_unused = false, nowait = false}).
+-record('exchange.delete_ok', {}).
+-record('exchange.bind', {ticket = 0, destination, source, routing_key = <<"">>, nowait = false, arguments = []}).
+-record('exchange.bind_ok', {}).
+-record('exchange.unbind', {ticket = 0, destination, source, routing_key = <<"">>, nowait = false, arguments = []}).
+-record('exchange.unbind_ok', {}).
+-record('queue.declare', {ticket = 0, queue = <<"">>, passive = false, durable = false, exclusive = false, auto_delete = false, nowait = false, arguments = []}).
+-record('queue.declare_ok', {queue, message_count, consumer_count}).
+-record('queue.bind', {ticket = 0, queue = <<"">>, exchange, routing_key = <<"">>, nowait = false, arguments = []}).
+-record('queue.bind_ok', {}).
+-record('queue.purge', {ticket = 0, queue = <<"">>, nowait = false}).
+-record('queue.purge_ok', {message_count}).
+-record('queue.delete', {ticket = 0, queue = <<"">>, if_unused = false, if_empty = false, nowait = false}).
+-record('queue.delete_ok', {message_count}).
+-record('queue.unbind', {ticket = 0, queue = <<"">>, exchange, routing_key = <<"">>, arguments = []}).
+-record('queue.unbind_ok', {}).
+-record('basic.qos', {prefetch_size = 0, prefetch_count = 0, global = false}).
+-record('basic.qos_ok', {}).
+-record('basic.consume', {ticket = 0, queue = <<"">>, consumer_tag = <<"">>, no_local = false, no_ack = false, exclusive = false, nowait = false, arguments = []}).
+-record('basic.consume_ok', {consumer_tag}).
+-record('basic.cancel', {consumer_tag, nowait = false}).
+-record('basic.cancel_ok', {consumer_tag}).
+-record('basic.publish', {ticket = 0, exchange = <<"">>, routing_key = <<"">>, mandatory = false, immediate = false}).
+-record('basic.return', {reply_code, reply_text = <<"">>, exchange, routing_key}).
+-record('basic.deliver', {consumer_tag, delivery_tag, redelivered = false, exchange, routing_key}).
+-record('basic.get', {ticket = 0, queue = <<"">>, no_ack = false}).
+-record('basic.get_ok', {delivery_tag, redelivered = false, exchange, routing_key, message_count}).
+-record('basic.get_empty', {cluster_id = <<"">>}).
+-record('basic.ack', {delivery_tag = 0, multiple = false}).
+-record('basic.reject', {delivery_tag, requeue = true}).
+-record('basic.recover_async', {requeue = false}).
+-record('basic.recover', {requeue = false}).
+-record('basic.recover_ok', {}).
+-record('basic.nack', {delivery_tag = 0, multiple = false, requeue = true}).
+-record('tx.select', {}).
+-record('tx.select_ok', {}).
+-record('tx.commit', {}).
+-record('tx.commit_ok', {}).
+-record('tx.rollback', {}).
+-record('tx.rollback_ok', {}).
+-record('confirm.select', {nowait = false}).
+-record('confirm.select_ok', {}).
+-record('file.qos', {prefetch_size = 0, prefetch_count = 0, global = false}).
+-record('file.qos_ok', {}).
+-record('file.consume', {ticket = 1, queue = <<"">>, consumer_tag = <<"">>, no_local = false, no_ack = false, exclusive = false, nowait = false}).
+-record('file.consume_ok', {consumer_tag}).
+-record('file.cancel', {consumer_tag, nowait = false}).
+-record('file.cancel_ok', {consumer_tag}).
+-record('file.open', {identifier, content_size}).
+-record('file.open_ok', {staged_size}).
+-record('file.stage', {}).
+-record('file.publish', {ticket = 1, exchange = <<"">>, routing_key = <<"">>, mandatory = false, immediate = false, identifier}).
+-record('file.return', {reply_code = 200, reply_text = <<"">>, exchange, routing_key}).
+-record('file.deliver', {consumer_tag, delivery_tag, redelivered = false, exchange, routing_key, identifier}).
+-record('file.ack', {delivery_tag = 0, multiple = false}).
+-record('file.reject', {delivery_tag, requeue = true}).
+-record('stream.qos', {prefetch_size = 0, prefetch_count = 0, consume_rate = 0, global = false}).
+-record('stream.qos_ok', {}).
+-record('stream.consume', {ticket = 1, queue = <<"">>, consumer_tag = <<"">>, no_local = false, exclusive = false, nowait = false}).
+-record('stream.consume_ok', {consumer_tag}).
+-record('stream.cancel', {consumer_tag, nowait = false}).
+-record('stream.cancel_ok', {consumer_tag}).
+-record('stream.publish', {ticket = 1, exchange = <<"">>, routing_key = <<"">>, mandatory = false, immediate = false}).
+-record('stream.return', {reply_code = 200, reply_text = <<"">>, exchange, routing_key}).
+-record('stream.deliver', {consumer_tag, delivery_tag, exchange, queue}).
+-record('dtx.select', {}).
+-record('dtx.select_ok', {}).
+-record('dtx.start', {dtx_identifier}).
+-record('dtx.start_ok', {}).
+-record('tunnel.request', {meta_data}).
+-record('test.integer', {integer_1, integer_2, integer_3, integer_4, operation}).
+-record('test.integer_ok', {result}).
+-record('test.string', {string_1, string_2, operation}).
+-record('test.string_ok', {result}).
+-record('test.table', {table, integer_op, string_op}).
+-record('test.table_ok', {integer_result, string_result}).
+-record('test.content', {}).
+-record('test.content_ok', {content_checksum}).
+%% Class property records.
+-record('P_connection', {}).
+-record('P_channel', {}).
+-record('P_access', {}).
+-record('P_exchange', {}).
+-record('P_queue', {}).
+-record('P_basic', {content_type, content_encoding, headers, delivery_mode, priority, correlation_id, reply_to, expiration, message_id, timestamp, type, user_id, app_id, cluster_id}).
+-record('P_tx', {}).
+-record('P_confirm', {}).
+-record('P_file', {content_type, content_encoding, headers, priority, reply_to, message_id, filename, timestamp, cluster_id}).
+-record('P_stream', {content_type, content_encoding, headers, priority, timestamp}).
+-record('P_dtx', {}).
+-record('P_tunnel', {headers, proxy_name, data_name, durable, broadcast}).
+-record('P_test', {}).
View
25 include/rabbit_msg_store.hrl
@@ -0,0 +1,25 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License
+%% at http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and
+%% limitations under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is VMware, Inc.
+%% Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
+%%
+
+-include("rabbit.hrl").
+
+-ifdef(use_specs).
+
+-type(msg() :: any()).
+
+-endif.
+
+-record(msg_location, {msg_id, ref_count, file, offset, total_size}).
View
24 include/rabbit_routing_prefixes.hrl
@@ -0,0 +1,24 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License
+%% at http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and
+%% limitations under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is VMware, Inc.
+%% Copyright (c) 2011-2013 VMware, Inc. All rights reserved.
+%%
+
+-define(QUEUE_PREFIX, "/queue").
+-define(TOPIC_PREFIX, "/topic").
+-define(EXCHANGE_PREFIX, "/exchange").
+-define(AMQQUEUE_PREFIX, "/amq/queue").
+-define(TEMP_QUEUE_PREFIX, "/temp-queue").
+%% reply queues names can have slashes in the content so no further
+%% parsing happens.
+-define(REPLY_QUEUE_PREFIX, "/reply-queue/").
View
28 include/rrpc.hrl
@@ -0,0 +1,28 @@
+-define(log(Msg), io:format("[~-20.20s] ~p~n", [?MODULE, Msg])).
+-define(log(Format, Args), io:format("[~-20.20s] "++Format++"~n", [?MODULE]++Args)).
+
+-define(gv(Key, List), proplists:get_value(Key, List)).
+
+
+-define( conf(Par),
+ fun()->
+ {ok, Val}=application:get_env(rrpc, Par),
+ Val
+ end()
+ ).
+
+-define(ld(Arg), lager:debug(Arg)).
+-define(ld(Arg1, Arg2), lager:debug(Arg1, Arg2)).
+
+-define(li(Arg), lager:info(Arg)).
+-define(li(Arg1, Arg2), lager:info(Arg1, Arg2)).
+
+-define(ln(Arg), lager:notice(Arg)).
+-define(ln(Arg1, Arg2), lager:notice(Arg1, Arg2)).
+
+-define(lw(Arg), lager:warning(Arg)).
+-define(lw(Arg1, Arg2), lager:warning(Arg1, Arg2)).
+
+-define(le(Arg), lager:error(Arg)).
+-define(le(Arg1, Arg2), lager:error(Arg1, Arg2)).
+
View
5 lib/erlang-rfc4627/.gitignore
@@ -0,0 +1,5 @@
+*.beam
+test/server_root/logs/*_log
+build
+dist
+doc
View
75 lib/erlang-rfc4627/Makefile
@@ -0,0 +1,75 @@
+SOURCE_DIR=src
+EBIN_DIR=ebin
+DOC_DIR=doc
+INCLUDE_DIR=include
+INCLUDES=$(wildcard $(INCLUDE_DIR)/*.hrl)
+SOURCES=$(wildcard $(SOURCE_DIR)/*.erl)
+TARGETS=$(patsubst $(SOURCE_DIR)/%.erl, $(EBIN_DIR)/%.beam,$(SOURCES))
+ERLC_OPTS=-I $(INCLUDE_DIR) -o $(EBIN_DIR) $(INETS_DEF) -Wall +debug_info # +native -v
+DIST_DIR=dist
+SIGNING_KEY_ID=F8D7D525
+VERSION=HEAD
+PACKAGE_NAME=rfc4627_jsonrpc
+
+## The path to httpd.hrl changed at R14A, and then changed again
+## between OTP R14B and R14B01. Detect the changes, and supply
+## compile-time macro definitions to allow rfc4627_jsonrpc_inets.erl
+## to adapt to the new paths.
+ERLANG_OTP_RELEASE:=$(shell erl -noshell -eval 'io:format(erlang:system_info(otp_release)), halt().')
+$(info Building for OTP release $(ERLANG_OTP_RELEASE).)
+ifeq ($(shell test R14A \> $(ERLANG_OTP_RELEASE) && echo yes),yes)
+$(info Using path to INETS httpd.hrl that existed before R14A.)
+INETS_DEF=-Dinets_pre_r14a
+else
+ifeq ($(shell test R14B01 \> $(ERLANG_OTP_RELEASE) && echo yes),yes)
+$(info Using path to INETS httpd.hrl that existed before R14B01.)
+INETS_DEF=-Dinets_pre_r14b01
+else
+$(info Using path to INETS httpd.hrl that exists in releases at and after R14B01.)
+INETS_DEF=
+endif
+endif
+
+all: $(TARGETS)
+
+$(EBIN_DIR)/%.beam: $(SOURCE_DIR)/%.erl $(INCLUDES)
+ erlc $(ERLC_OPTS) $<
+
+clean:
+ rm -f ebin/*.beam
+ rm -f $(TARGETS)
+ rm -rf $(DIST_DIR)
+ rm -rf $(DOC_DIR)
+
+dist: all doc/index.html
+ mkdir -p $(DIST_DIR)
+ cp -r doc ebin include src test Makefile $(DIST_DIR)
+
+distclean: clean
+ rm -rf $(DIST_DIR)
+ find . -name '*~' -exec rm {} \;
+
+debian-package: clean
+ @(cat debian/changelog | head -1 | fgrep -q 'rfc4627-erlang ($(VERSION))') || \
+ (echo "No changelog entry for version $(VERSION) exists. Aborting."; false)
+ tar -cf debian-package.tar `ls | grep -v _darcs`
+ mkdir build
+ cd build; tar -xf ../debian-package.tar
+ cd build; dpkg-buildpackage -rfakeroot -k$(SIGNING_KEY_ID)
+ rm -rf build debian-package.tar
+
+$(DOC_DIR)/index.html: $(DOC_DIR)/overview.edoc
+ erl -noshell \
+ -eval 'edoc:application(rfc4627, ".", [{overview, "$(DOC_DIR)/overview.edoc"}, {dir, "$(DOC_DIR)"}])' \
+ -run init stop
+ cp src/doc/JSON-RPC-1-1-WD-20060807.html $(DOC_DIR)
+
+$(DOC_DIR)/overview.edoc: src/doc/overview.edoc.in
+ mkdir -p $(DOC_DIR)
+ sed -e 's:%%VERSION%%:$(VERSION):g' < $< > $@
+
+test-compile:
+ erlc $(ERLC_OPTS) $(wildcard test/*.erl)
+
+test: all test-compile
+ erl -pa ebin -noshell -eval 'passed = test_rfc4627:test_all(), c:q().'
View
128 lib/erlang-rfc4627/README.md
@@ -0,0 +1,128 @@
+# RFC4627 (JSON) and JSON-RPC for Erlang
+
+An implementation of JSON and JSON-RPC for Erlang.
+
+See
+[rfc4627.erl](http://tonyg.github.com/erlang-rfc4627/doc/rfc4627.html),
+the JSON/RFC4627 codec itself, to learn how to encode and decode JSON
+objects from Erlang code.
+
+## Providing and calling JSON-RPC services
+
+See
+[rfc4627\_jsonrpc.erl](http://tonyg.github.com/erlang-rfc4627/doc/rfc4627_jsonrpc.html),
+a JSON-RPC service registry and transport-neutral service method
+invocation mechanism, to learn how to expose Erlang processes as
+remotely-callable JSON-RPC services, and to learn how to invoke local
+JSON-RPC services from Erlang without the overhead of HTTP.
+
+## Exposing JSON-RPC services over HTTP
+
+### Using Inets
+
+See
+[rfc4627\_jsonrpc\_inets.erl](http://tonyg.github.com/erlang-rfc4627/doc/rfc4627_jsonrpc_inets.html),
+an Inets HTTP transport binding for JSON-RPC, to learn how to
+configure the Inets HTTP server to respond to JSON-RPC requests.
+
+### Using Mochiweb
+
+See
+[rfc4627\_jsonrpc\_mochiweb.erl](http://tonyg.github.com/erlang-rfc4627/doc/rfc4627_jsonrpc_mochiweb.html)
+to learn how to delegate incoming Mochiweb HTTP requests to the
+JSON-RPC service dispatcher.
+
+### Using Cowboy
+
+See
+[rfc4627\_jsonrpc\_cowboy.erl](http://tonyg.github.com/erlang-rfc4627/doc/rfc4627_jsonrpc_cowboy.html)
+to learn how to delegate incoming Cowboy HTTP requests to the
+JSON-RPC service dispatcher.
+
+## Running the example test service that comes with the source code
+
+Included with the Erlang RFC4627 source code is a small Inets-based
+example that defines a "hello world"-style JSON-RPC service, and calls
+it from a Javascript program embedded in a web page.
+
+At your Erlang shell,
+
+ - after compiling the code with `make all test-compile`,
+ - when your current working directory contains the `test` directory
+ from the distribution, such that
+ `./test/server_root/conf/httpd.conf` exists,
+
+type `test_jsonrpc_inets:start_httpd().` (Don't forget the trailing
+"."!) This will
+
+ - start the inets httpd on port 5671 (from `./test/server_root/conf/httpd.conf`)
+ - allow HTTP access to JSON-RPC services via a url prefix of `/rpc` (again from `httpd.conf`)
+ - start the `rfc4627_jsonrpc` service registry
+ - register the test service
+
+Visiting <http://localhost:5671/> in your browser should load a page
+that uses javascript to invoke the Erlang-implemented JSON-RPC test
+service.
+
+## Invoking JSON-RPC procedures from Javascript
+
+See the [relevant
+section](http://tonyg.github.com/erlang-rfc4627/doc/overview-summary.html#Invoking_JSON-RPC_procedures_from_Javascript)
+of the `edoc` documentation included with the source code.
+
+## References
+
+ - the [JSON RFC](http://www.ietf.org/rfc/rfc4627.txt).
+
+ - the [JSON-RPC
+ specification](http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html)
+ 1.1 working draft ([mirrored
+ locally](http://tonyg.github.com/erlang-rfc4627/doc/JSON-RPC-1-1-WD-20060807.html)).
+
+ - Joe Armstrong's
+ [message](http://erlang.org/pipermail/erlang-questions/2005-November/017805.html)
+ describing the basis of the JSON data type mapping that the
+ `rfc4627.erl` module uses.
+
+## Contributors
+
+The codebase and documentation was originally written between 2007 and
+2010 by Tony Garnock-Jones while at LShift in London. Since then, it
+has been maintained by Tony and enhanced with a few generous
+contributions from others:
+
+ - András Veres-Szentkirályi
+ - Eugene Volchek
+ - Simon MacMullen
+ - Andrey Khozov
+ - Erik Timan
+
+## Copyright and Licence
+
+Copyrights:
+
+ - Copyright &copy; 2007-2010, 2011, 2012 Tony Garnock-Jones.
+ - Portions copyright 2007-2010 LShift Ltd.
+ - Portions copyright contributors to the project, listed above.
+
+License (MIT):
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use, copy,
+ modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
View
46 lib/erlang-rfc4627/debian/changelog
@@ -0,0 +1,46 @@
+rfc4627-erlang (1.1.1) unstable; urgency=low
+
+ * Fix \u escaping for surrogate pairs.
+
+ -- Tony Garnock-Jones <tonyg@shortstop.lshift.net> Thu, 01 May 2008 12:10:41 +0100
+
+rfc4627-erlang (1.1.0-1) unstable; urgency=low
+
+ * Unicode support per RFC.
+
+ -- Tony Garnock-Jones <tonyg@shortstop.lshift.net> Wed, 03 Oct 2007 15:58:39 +0100
+
+rfc4627-erlang (1.0.4-1) unstable; urgency=low
+
+ * Support X-JSON-RPC-Timeout header (value in milliseconds).
+
+ -- Tony Garnock-Jones <tonyg@shortstop.lshift.net> Thu, 21 Jun 2007 15:00:46 +0100
+
+rfc4627-erlang (1.0.3-1) unstable; urgency=low
+
+ * Add start_link for use in supervision hierarchies.
+
+ -- Tony Garnock-Jones <tonyg@shortstop.lshift.net> Wed, 20 Jun 2007 14:04:42 +0100
+
+rfc4627-erlang (1.0.2-1) unstable; urgency=low
+
+ * Documentation for release
+ * Minor API improvements
+ * MIT licensing
+
+ -- Tony Garnock-Jones <tonyg@lshift.net> Sat, 17 Feb 2007 14:44:57 +0000
+
+rfc4627-erlang (1.0.1-1) unstable; urgency=low
+
+ * JSON-RPC transport is factored out on the client
+ * Header file path correction
+ * No longer take any action synchronously in the JS client
+
+ -- Tony Garnock-Jones <tonyg@shortstop.lshift.net> Mon, 29 Jan 2007 15:28:06 +0000
+
+rfc4627-erlang (1.0-1) unstable; urgency=low
+
+ * Initial release
+
+ -- Tony Garnock-Jones <tonyg@lshift.net> Fri, 26 Jan 2007 14:17:16 +0000
+
View
1  lib/erlang-rfc4627/debian/compat
@@ -0,0 +1 @@
+5
View
11 lib/erlang-rfc4627/debian/control
@@ -0,0 +1,11 @@
+Source: rfc4627-erlang
+Section: libs
+Priority: extra
+Maintainer: Tony Garnock-Jones <tonyg@lshift.net>
+Build-Depends: cdbs, debhelper (>= 5), erlang-base | erlang-base-hipe, erlang-nox, erlang-dev, make
+Standards-Version: 3.7.2
+
+Package: rfc4627-erlang
+Architecture: all
+Depends: erlang-base | erlang-base-hipe
+Description: A JSON (RFC4627) codec and JSON-RPC server for Erlang
View
33 lib/erlang-rfc4627/debian/copyright
@@ -0,0 +1,33 @@
+This package was debianized by Tony Garnock-Jones <tonyg@rabbitmq.com> on
+Fri, 19 Jan 2007 20:08:56 +0000.
+
+Upstream Author: Tony Garnock-Jones <tonyg@lshift.net>
+
+Copyright: 2007 Tony Garnock-Jones, 2007 LShift Ltd.
+
+License:
+
+Copyright (c) 2007 Tony Garnock-Jones and LShift Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+The Debian packaging is (C) 2007, Tony Garnock-Jones <tonyg@lshift.net> and
+is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
View
1  lib/erlang-rfc4627/debian/dirs
@@ -0,0 +1 @@
+usr/lib/erlang/lib
View
41 lib/erlang-rfc4627/debian/postinst.ex
@@ -0,0 +1,41 @@
+#!/bin/sh
+# postinst script for rabbitmq
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <postinst> `configure' <most-recently-configured-version>
+# * <old-postinst> `abort-upgrade' <new version>
+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+# <new-version>
+# * <postinst> `abort-remove'
+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+# <failed-install-package> <version> `removing'
+# <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+ configure)
+ ;;
+
+ abort-upgrade|abort-remove|abort-deconfigure)
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
View
39 lib/erlang-rfc4627/debian/postrm.ex
@@ -0,0 +1,39 @@
+#!/bin/sh
+# postrm script for rabbitmq
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <postrm> `remove'
+# * <postrm> `purge'
+# * <old-postrm> `upgrade' <new-version>
+# * <new-postrm> `failed-upgrade' <old-version>
+# * <new-postrm> `abort-install'
+# * <new-postrm> `abort-install' <old-version>
+# * <new-postrm> `abort-upgrade' <old-version>
+# * <disappearer's-postrm> `disappear' <overwriter>
+# <overwriter-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+ purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+ ;;
+
+ *)
+ echo "postrm called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
View
37 lib/erlang-rfc4627/debian/preinst.ex
@@ -0,0 +1,37 @@
+#!/bin/sh
+# preinst script for rabbitmq
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <new-preinst> `install'
+# * <new-preinst> `install' <old-version>
+# * <new-preinst> `upgrade' <old-version>
+# * <old-preinst> `abort-upgrade' <new-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+ install|upgrade)
+ ;;
+
+ abort-upgrade)
+ ;;
+
+ *)
+ echo "preinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
View
40 lib/erlang-rfc4627/debian/prerm.ex
@@ -0,0 +1,40 @@
+#!/bin/sh
+# prerm script for rabbitmq
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <prerm> `remove'
+# * <old-prerm> `upgrade' <new-version>
+# * <new-prerm> `failed-upgrade' <old-version>
+# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+# * <deconfigured's-prerm> `deconfigure' `in-favour'
+# <package-being-installed> <version> `removing'
+# <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+ remove|upgrade|deconfigure)
+ ;;
+
+ failed-upgrade)
+ ;;
+
+ *)
+ echo "prerm called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
View
6 lib/erlang-rfc4627/debian/rules
@@ -0,0 +1,6 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/makefile.mk
+
+DEB_MAKE_INSTALL_TARGET := dist DIST_DIR=$(DEB_DESTDIR)usr/lib/erlang/lib/rfc4627-$(DEB_UPSTREAM_VERSION)/
View
18 lib/erlang-rfc4627/ebin/rfc4627_jsonrpc.app
@@ -0,0 +1,18 @@
+{application, rfc4627_jsonrpc,
+ [{description, "JSON RPC Service"},
+ {vsn, "0.01"},
+ {modules, [
+ rfc4627,
+ rfc4627_jsonrpc,
+ rfc4627_jsonrpc_app,
+ rfc4627_jsonrpc_sup,
+ rfc4627_jsonrpc_http,
+ rfc4627_jsonrpc_inets,
+ rfc4627_jsonrpc_mochiweb,
+ rfc4627_jsonrpc_cowboy,
+ rfc4627_jsonrpc_registry
+ ]},
+ {registered, []},
+ {mod, {rfc4627_jsonrpc_app, []}},
+ {env, []},
+ {applications, [kernel, stdlib]}]}.
View
36 lib/erlang-rfc4627/include/rfc4627.hrl
@@ -0,0 +1,36 @@
+%% JSON - RFC 4627 - for Erlang
+%%---------------------------------------------------------------------------
+%% Copyright (c) 2007-2010, 2011, 2012 Tony Garnock-Jones <tonygarnockjones@gmail.com>
+%% Copyright (c) 2007-2010 LShift Ltd. <query@lshift.net>
+%%
+%% Permission is hereby granted, free of charge, to any person
+%% obtaining a copy of this software and associated documentation
+%% files (the "Software"), to deal in the Software without
+%% restriction, including without limitation the rights to use, copy,
+%% modify, merge, publish, distribute, sublicense, and/or sell copies
+%% of the Software, and to permit persons to whom the Software is
+%% furnished to do so, subject to the following conditions:
+%%
+%% The above copyright notice and this permission notice shall be
+%% included in all copies or substantial portions of the Software.
+%%
+%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+%% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+%% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+%% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+%% BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+%% ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+%% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+%% SOFTWARE.
+%%---------------------------------------------------------------------------
+%%
+%% Convenience macros for encoding and decoding record structures.
+%%
+%% Erlang's compile-time-only notion of record definitions means we
+%% have to supply a constant record name in the source text.
+
+-define(RFC4627_FROM_RECORD(RName, R),
+ rfc4627:from_record(R, RName, record_info(fields, RName))).
+
+-define(RFC4627_TO_RECORD(RName, R),
+ rfc4627:to_record(R, #RName{}, record_info(fields, RName))).
View
31 lib/erlang-rfc4627/include/rfc4627_jsonrpc.hrl
@@ -0,0 +1,31 @@
+%% JSON-RPC for Erlang
+%%---------------------------------------------------------------------------
+%% Copyright (c) 2007-2010, 2011, 2012 Tony Garnock-Jones <tonygarnockjones@gmail.com>
+%% Copyright (c) 2007-2010 LShift Ltd. <query@lshift.net>
+%%
+%% Permission is hereby granted, free of charge, to any person
+%% obtaining a copy of this software and associated documentation
+%% files (the "Software"), to deal in the Software without
+%% restriction, including without limitation the rights to use, copy,
+%% modify, merge, publish, distribute, sublicense, and/or sell copies
+%% of the Software, and to permit persons to whom the Software is
+%% furnished to do so, subject to the following conditions:
+%%
+%% The above copyright notice and this permission notice shall be
+%% included in all copies or substantial portions of the Software.
+%%
+%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+%% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+%% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+%% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+%% BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+%% ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+%% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+%% SOFTWARE.
+%%---------------------------------------------------------------------------
+%%
+%% Records for JSON-RPC services using the rfc4627_jsonrpc module.
+
+-record(service, {handler, name, id, version, summary, help, procs}).
+-record(service_proc, {name, summary, help, idempotent = false, params, return}).
+-record(service_proc_param, {name, type}).
View
2  lib/erlang-rfc4627/rebar.config
@@ -0,0 +1,2 @@
+%-*-mode: erlang -*-
+
View
586 lib/erlang-rfc4627/src/rfc4627.erl
@@ -0,0 +1,586 @@
+%% JSON - RFC 4627 - for Erlang
+%%---------------------------------------------------------------------------
+%% @author Tony Garnock-Jones <tonygarnockjones@gmail.com>
+%% @author LShift Ltd. <query@lshift.net>
+%% @copyright 2007-2010, 2011, 2012 Tony Garnock-Jones and 2007-2010 LShift Ltd.
+%% @license
+%%
+%% Permission is hereby granted, free of charge, to any person
+%% obtaining a copy of this software and associated documentation
+%% files (the "Software"), to deal in the Software without
+%% restriction, including without limitation the rights to use, copy,
+%% modify, merge, publish, distribute, sublicense, and/or sell copies
+%% of the Software, and to permit persons to whom the Software is
+%% furnished to do so, subject to the following conditions:
+%%
+%% The above copyright notice and this permission notice shall be
+%% included in all copies or substantial portions of the Software.
+%%
+%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+%% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+%% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+%% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+%% BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+%% ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+%% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+%% SOFTWARE.
+%%---------------------------------------------------------------------------
+%%
+%% @reference <a href="http://www.ietf.org/rfc/rfc4627.txt">RFC
+%% 4627</a>, the JSON RFC
+%%
+%% @reference <a href="http://www.json.org/">JSON in general</a>
+%%
+%% @reference Joe Armstrong's <a
+%% href="http://erlang.org/pipermail/erlang-questions/2005-November/017805.html">
+%% message</a> describing the basis of the JSON data type mapping that
+%% this module uses
+%%
+%% @doc An implementation of RFC 4627 (JSON, the JavaScript Object Notation) for Erlang.
+%%
+%% The basic API is comprised of the {@link encode/1} and {@link decode/1} functions.
+%%
+%% == Data Type Mapping ==
+%%
+%% The data type mapping I've implemented is as per Joe Armstrong's
+%% message [http://www.erlang.org/ml-archive/erlang-questions/200511/msg00193.html] - see {@link json()}.
+%%
+%% == Unicode ==
+%%
+%% When serializing a string, if characters are found with codepoint
+%% >127, we rely on the unicode encoder to build the proper byte
+%% sequence for transmission. We still use the \uXXXX escape for
+%% control characters (other than the RFC-specified specially
+%% recognised ones).
+%%
+%% {@link decode/1} will autodetect the unicode encoding used, and any
+%% strings returned in the result as binaries will contain UTF-8
+%% encoded byte sequences for codepoints >127. Object keys containing
+%% codepoints >127 will be returned as lists of codepoints, rather
+%% than being UTF-8 encoded. If you have already transformed the text
+%% to parse into a list of unicode codepoints, perhaps by your own use
+%% of {@link unicode_decode/1}, then use {@link decode_noauto/1} to
+%% avoid redundant and erroneous double-unicode-decoding.
+%%
+%% Similarly, {@link encode/1} produces text that is already UTF-8
+%% encoded. To get raw codepoints, use {@link encode_noauto/1} and
+%% {@link encode_noauto/2}. You can use {@link unicode_encode/1} to
+%% UTF-encode the results, if that's appropriate for your application.
+%%
+%% == Differences to the specification ==
+%%
+%% I'm lenient in the following ways during parsing:
+%%
+%% <ul>
+%% <li>repeated commas in arrays and objects collapse to a single comma</li>
+%% <li>any character =&lt;32 is considered whitespace</li>
+%% <li>leading zeros for numbers are accepted</li>
+%% <li>we don't restrict the toplevel token to only object or array -
+%% any JSON value can be used at toplevel</li>
+%% </ul>
+
+%% @type json() = jsonobj() | jsonarray() | jsonnum() | jsonstr() | true | false | null. An Erlang representation of a general JSON value.
+%% @type jsonobj() = {obj, [{jsonkey(), json()}]}. A JSON "object" or "struct".
+%% @type jsonkey() = string(). A field-name within a JSON "object".
+%% @type jsonarray() = [json()]. A JSON array value.
+%% @type jsonnum() = integer() | float(). A JSON numeric value.
+%% @type jsonstr() = binary(). A JSON string value.
+%% @type byte() = integer(). An integer >=0 and =&lt;255.
+
+-module(rfc4627).
+
+-export([mime_type/0, encode/1, decode/1]).
+-export([encode_noauto/1, encode_noauto/2, decode_noauto/1]).
+-export([unicode_decode/1, unicode_encode/1]).
+-export([from_record/3, to_record/3]).
+-export([hex_digit/1, digit_hex/1]).
+-export([get_field/2, get_field/3, set_field/3, exclude_field/2]).
+-export([equiv/2]).
+
+%% @spec () -> string()
+%% @doc Returns the IANA-registered MIME type for JSON data.
+mime_type() ->
+ "application/json".
+
+%% @spec (json()) -> [byte()]
+%%
+%% @doc Encodes the JSON value supplied, first into Unicode
+%% codepoints, and then into UTF-8.
+%%
+%% The resulting string is a list of byte values that should be
+%% interpreted as UTF-8 encoded text.
+%%
+%% During encoding, atoms and binaries are accepted as keys of JSON
+%% objects (type {@link jsonkey()}) as well as the usual strings
+%% (lists of character codepoints).
+encode(X) ->
+ unicode_encode({'utf-8', encode_noauto(X)}).
+
+%% @spec (json()) -> string()
+%%
+%% @doc Encodes the JSON value supplied into raw Unicode codepoints.
+%%
+%% The resulting string may contain codepoints with value >=128. You
+%% can use {@link unicode_encode/1} to UTF-encode the results, if
+%% that's appropriate for your application.
+%%
+%% During encoding, atoms and binaries are accepted as keys of JSON
+%% objects (type {@link jsonkey()}) as well as the usual strings
+%% (lists of character codepoints).
+encode_noauto(X) ->
+ lists:reverse(encode_noauto(X, [])).
+
+%% @spec (json(), string()) -> string()
+%%
+%% @doc As {@link encode_noauto/1}, but prepends <i>reversed</i> text
+%% to the supplied accumulator string.
+encode_noauto(true, Acc) ->
+ "eurt" ++ Acc;
+encode_noauto(false, Acc) ->
+ "eslaf" ++ Acc;
+encode_noauto(null, Acc) ->
+ "llun" ++ Acc;
+encode_noauto(Str, Acc) when is_binary(Str) ->
+ Codepoints = xmerl_ucs:from_utf8(Str),
+ quote_and_encode_string(Codepoints, Acc);
+encode_noauto(Str, Acc) when is_atom(Str) ->
+ quote_and_encode_string(atom_to_list(Str), Acc);
+encode_noauto(Num, Acc) when is_number(Num) ->
+ encode_number(Num, Acc);
+encode_noauto({obj, Fields}, Acc) ->
+ "}" ++ encode_object(Fields, "{" ++ Acc);
+encode_noauto(Dict, Acc) when element(1, Dict) =:= dict ->
+ "}" ++ encode_object(dict:to_list(Dict), "{" ++ Acc);
+encode_noauto(Arr, Acc) when is_list(Arr) ->
+ "]" ++ encode_array(Arr, "[" ++ Acc).
+
+encode_object([], Acc) ->
+ Acc;
+encode_object([{Key, Value}], Acc) ->
+ encode_field(Key, Value, Acc);
+encode_object([{Key, Value} | Rest], Acc) ->
+ encode_object(Rest, "," ++ encode_field(Key, Value, Acc)).
+
+encode_field(Key, Value, Acc) when is_binary(Key) ->
+ Codepoints = xmerl_ucs:from_utf8(Key),
+ encode_noauto(Value, ":" ++ quote_and_encode_string(Codepoints, Acc));
+encode_field(Key, Value, Acc) when is_atom(Key) ->
+ encode_noauto(Value, ":" ++ quote_and_encode_string(atom_to_list(Key), Acc));
+encode_field(Key, Value, Acc) when is_list(Key) ->
+ encode_noauto(Value, ":" ++ quote_and_encode_string(Key, Acc)).
+
+encode_array([], Acc) ->
+ Acc;
+encode_array([X], Acc) ->
+ encode_noauto(X, Acc);
+encode_array([X | Rest], Acc) ->
+ encode_array(Rest, "," ++ encode_noauto(X, Acc)).
+
+quote_and_encode_string(Str, Acc) ->
+ "\"" ++ encode_string(Str, "\"" ++ Acc).
+
+encode_string([], Acc) ->
+ Acc;
+encode_string([$" | Rest], Acc) ->
+ encode_string(Rest, [$", $\\ | Acc]);
+encode_string([$\\ | Rest], Acc) ->
+ encode_string(Rest, [$\\, $\\ | Acc]);
+encode_string([X | Rest], Acc) when X < 32 orelse X > 127 ->
+ encode_string(Rest, encode_general_char(X, Acc));
+encode_string([X | Rest], Acc) ->
+ encode_string(Rest, [X | Acc]).
+
+encode_general_char(8, Acc) -> [$b, $\\ | Acc];
+encode_general_char(9, Acc) -> [$t, $\\ | Acc];
+encode_general_char(10, Acc) -> [$n, $\\ | Acc];
+encode_general_char(12, Acc) -> [$f, $\\ | Acc];
+encode_general_char(13, Acc) -> [$r, $\\ | Acc];
+encode_general_char(X, Acc) when X > 127 -> [X | Acc];
+encode_general_char(X, Acc) ->
+ %% FIXME currently this branch never runs.
+ %% We could make it configurable, maybe?
+ Utf16Bytes = xmerl_ucs:to_utf16be(X),
+ encode_utf16be_chars(Utf16Bytes, Acc).
+
+encode_utf16be_chars([], Acc) ->
+ Acc;
+encode_utf16be_chars([B1, B2 | Rest], Acc) ->
+ encode_utf16be_chars(Rest, [hex_digit((B2) band 16#F),
+ hex_digit((B2 bsr 4) band 16#F),
+ hex_digit((B1) band 16#F),
+ hex_digit((B1 bsr 4) band 16#F),
+ $u,
+ $\\ | Acc]).
+
+%% @spec (Nibble::integer()) -> char()
+%% @doc Returns the character code corresponding to Nibble.
+%%
+%% Nibble must be >=0 and =&lt;15.
+hex_digit(N) when is_integer(N), N >= 0, N =< 9 -> $0 + N;
+hex_digit(N) when is_integer(N), N >= 10, N =< 15 -> $A + N - 10.
+
+encode_number(Num, Acc) when is_integer(Num) ->
+ lists:reverse(integer_to_list(Num), Acc);
+encode_number(Num, Acc) when is_float(Num) ->
+ lists:reverse(float_to_list(Num), Acc).
+
+%% @spec (Input::(binary() | [byte()])) -> ({ok, json(), Remainder} | {error, Reason})
+%% where Remainder = string()
+%% Reason = any()
+%%
+%% @doc Decodes a JSON value from an input binary or string of
+%% Unicode-encoded text.
+%%
+%% Given a binary, converts it to a list of bytes. Given a
+%% list/string, interprets it as a list of bytes.
+%%
+%% Uses {@link unicode_decode/1} on its input, which results in a list
+%% of codepoints, and then decodes a JSON value from that list of
+%% codepoints.
+%%
+%% Returns either `{ok, Result, Remainder}', where Remainder is the
+%% remaining portion of the input that was not consumed in the process
+%% of decoding Result, or `{error, Reason}'.
+decode(Bin) when is_binary(Bin) ->
+ decode(binary_to_list(Bin));
+decode(Bytes) ->
+ {_Charset, Codepoints} = unicode_decode(Bytes),
+ decode_noauto(Codepoints).
+
+%% @spec (Input::string()) -> ({ok, json(), string()} | {error, any()})
+%%
+%% @doc As {@link decode/1}, but does not perform Unicode decoding on its input.
+%%
+%% Expects a list of codepoints - an ordinary Erlang string - rather
+%% than a list of Unicode-encoded bytes.
+decode_noauto(Bin) when is_binary(Bin) ->
+ decode_noauto(binary_to_list(Bin));
+decode_noauto(Chars) ->
+ case catch parse(skipws(Chars)) of
+ {'EXIT', Reason} ->
+ %% Reason is usually far too much information, but helps
+ %% if needing to debug this module.
+ {error, Reason};
+ {Value, Remaining} ->
+ {ok, Value, skipws(Remaining)}
+ end.
+
+%% @spec ([byte()]) -> [char()]
+%%
+%% @doc Autodetects and decodes using the Unicode encoding of its input.
+%%
+%% From RFC4627, section 3, "Encoding":
+%%
+%% <blockquote>
+%% JSON text SHALL be encoded in Unicode. The default encoding is
+%% UTF-8.
+%%
+%% Since the first two characters of a JSON text will always be ASCII
+%% characters [RFC0020], it is possible to determine whether an octet
+%% stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking
+%% at the pattern of nulls in the first four octets.
+%%
+%% 00 00 00 xx UTF-32BE
+%% 00 xx 00 xx UTF-16BE
+%% xx 00 00 00 UTF-32LE
+%% xx 00 xx 00 UTF-16LE
+%% xx xx xx xx UTF-8
+%% </blockquote>
+%%
+%% Interestingly, the BOM (byte-order mark) is not mentioned. We
+%% support it here by using it to detect our encoding, discarding it
+%% if present, even though RFC4627 explicitly notes that the first two
+%% characters of a JSON text will be ASCII.
+%%
+%% If a BOM ([http://unicode.org/faq/utf_bom.html]) is present, we use
+%% that; if not, we use RFC4627's rules (as above). Note that UTF-32
+%% is the same as UCS-4 for our purposes (but see also
+%% [http://unicode.org/reports/tr19/tr19-9.html]). Note that UTF-16 is
+%% not the same as UCS-2!
+%%
+%% Note that I'm using xmerl's UCS/UTF support here. There's another
+%% UTF-8 codec in asn1rt, which works on binaries instead of lists.
+%%
+unicode_decode([0,0,254,255|C]) -> {'utf-32', xmerl_ucs:from_ucs4be(C)};
+unicode_decode([255,254,0,0|C]) -> {'utf-32', xmerl_ucs:from_ucs4le(C)};
+unicode_decode([254,255|C]) -> {'utf-16', xmerl_ucs:from_utf16be(C)};
+unicode_decode([239,187,191|C]) -> {'utf-8', xmerl_ucs:from_utf8(C)};
+unicode_decode(C=[0,0,_,_|_]) -> {'utf-32be', xmerl_ucs:from_ucs4be(C)};
+unicode_decode(C=[_,_,0,0|_]) -> {'utf-32le', xmerl_ucs:from_ucs4le(C)};
+unicode_decode(C=[0,_|_]) -> {'utf-16be', xmerl_ucs:from_utf16be(C)};
+unicode_decode(C=[_,0|_]) -> {'utf-16le', xmerl_ucs:from_utf16le(C)};
+unicode_decode(C=_) -> {'utf-8', xmerl_ucs:from_utf8(C)}.
+
+%% @spec (EncodingAndCharacters::{Encoding, [char()]}) -> [byte()]
+%% where Encoding = 'utf-32' | 'utf-32be' | 'utf-32le' | 'utf-16' |
+%% 'utf-16be' | 'utf-16le' | 'utf-8'
+%%
+%% @doc Encodes the given characters to bytes, using the given Unicode encoding.
+%%
+%% For convenience, we supply a partial inverse of unicode_decode; If
+%% a BOM is requested, we more-or-less arbitrarily pick the big-endian
+%% variant of the encoding, since big-endian is network-order. We
+%% don't support UTF-8 with BOM here.
+unicode_encode({'utf-32', C}) -> [0,0,254,255|xmerl_ucs:to_ucs4be(C)];
+unicode_encode({'utf-32be', C}) -> xmerl_ucs:to_ucs4be(C);
+unicode_encode({'utf-32le', C}) -> xmerl_ucs:to_ucs4le(C);
+unicode_encode({'utf-16', C}) -> [254,255|xmerl_ucs:to_utf16be(C)];
+unicode_encode({'utf-16be', C}) -> xmerl_ucs:to_utf16be(C);
+unicode_encode({'utf-16le', C}) -> xmerl_ucs:to_utf16le(C);
+unicode_encode({'utf-8', C}) -> xmerl_ucs:to_utf8(C).
+
+parse([$" | Rest]) -> %% " emacs balancing
+ {Codepoints, Rest1} = parse_string(Rest, []),
+ {list_to_binary(xmerl_ucs:to_utf8(Codepoints)), Rest1};
+parse("true" ++ Rest) -> {true, Rest};
+parse("false" ++ Rest) -> {false, Rest};
+parse("null" ++ Rest) -> {null, Rest};
+parse([${ | Rest]) -> parse_object(skipws(Rest), []);
+parse([$[ | Rest]) -> parse_array(skipws(Rest), []);
+parse([]) -> exit(unexpected_end_of_input);
+parse(Chars) -> parse_number(Chars, []).
+
+skipws([X | Rest]) when X =< 32 ->
+ skipws(Rest);
+skipws(Chars) ->
+ Chars.
+
+parse_string(Chars, Acc) ->
+ case parse_codepoint(Chars) of
+ {done, Rest} ->
+ {lists:reverse(Acc), Rest};
+ {ok, Codepoint, Rest} ->
+ parse_string(Rest, [Codepoint | Acc])
+ end.
+
+parse_codepoint([$" | Rest]) -> %% " emacs balancing
+ {done, Rest};
+parse_codepoint([$\\, Key | Rest]) ->
+ parse_general_char(Key, Rest);
+parse_codepoint([X | Rest]) ->
+ {ok, X, Rest}.
+
+parse_general_char($b, Rest) -> {ok, 8, Rest};
+parse_general_char($t, Rest) -> {ok, 9, Rest};
+parse_general_char($n, Rest) -> {ok, 10, Rest};
+parse_general_char($f, Rest) -> {ok, 12, Rest};
+parse_general_char($r, Rest) -> {ok, 13, Rest};
+parse_general_char($/, Rest) -> {ok, $/, Rest};
+parse_general_char($\\, Rest) -> {ok, $\\, Rest};
+parse_general_char($", Rest) -> {ok, $", Rest};
+parse_general_char($u, [D0, D1, D2, D3 | Rest]) ->
+ Codepoint =
+ (digit_hex(D0) bsl 12) +
+ (digit_hex(D1) bsl 8) +
+ (digit_hex(D2) bsl 4) +
+ (digit_hex(D3)),
+ if
+ Codepoint >= 16#D800 andalso Codepoint < 16#DC00 ->
+ % High half of surrogate pair
+ case parse_codepoint(Rest) of
+ {low_surrogate_pair, Codepoint2, Rest1} ->
+ [FinalCodepoint] =
+ xmerl_ucs:from_utf16be(<<Codepoint:16/big-unsigned-integer,
+ Codepoint2:16/big-unsigned-integer>>),
+ {ok, FinalCodepoint, Rest1};
+ _ ->
+ exit(incorrect_usage_of_surrogate_pair)
+ end;
+ Codepoint >= 16#DC00 andalso Codepoint < 16#E000 ->
+ {low_surrogate_pair, Codepoint, Rest};
+ true ->
+ {ok, Codepoint, Rest}
+ end.
+
+%% @spec (Hexchar::char()) -> integer()
+%% @doc Returns the number corresponding to Hexchar.
+%%
+%% Hexchar must be one of the characters `$0' through `$9', `$A'
+%% through `$F' or `$a' through `$f'.
+digit_hex(C) when is_integer(C), C >= $0, C =< $9 -> C - $0;
+digit_hex(C) when is_integer(C), C >= $A, C =< $F -> C - $A + 10;
+digit_hex(C) when is_integer(C), C >= $a, C =< $f -> C - $a + 10.
+
+finish_number(Acc, Rest) ->
+ Str = lists:reverse(Acc),
+ {case catch list_to_integer(Str) of
+ {'EXIT', _} -> list_to_float(Str);
+ Value -> Value
+ end, Rest}.
+
+parse_number([$- | Rest], Acc) ->
+ parse_number1(Rest, [$- | Acc]);
+parse_number(Rest = [C | _], Acc) ->
+ case is_digit(C) of
+ true -> parse_number1(Rest, Acc);
+ false -> exit(syntax_error)
+ end.
+
+parse_number1(Rest, Acc) ->
+ {Acc1, Rest1} = parse_int_part(Rest, Acc),
+ case Rest1 of
+ [] -> finish_number(Acc1, []);
+ [$. | More] ->
+ {Acc2, Rest2} = parse_int_part(More, [$. | Acc1]),
+ parse_exp(Rest2, Acc2, false);
+ _ ->
+ parse_exp(Rest1, Acc1, true)
+ end.
+
+parse_int_part(Chars = [_Ch | _Rest], Acc) ->
+ parse_int_part0(Chars, Acc).
+
+parse_int_part0([], Acc) ->
+ {Acc, []};
+parse_int_part0([Ch | Rest], Acc) ->
+ case is_digit(Ch) of
+ true -> parse_int_part0(Rest, [Ch | Acc]);
+ false -> {Acc, [Ch | Rest]}
+ end.
+
+parse_exp([$e | Rest], Acc, NeedFrac) ->
+ parse_exp1(Rest, Acc, NeedFrac);
+parse_exp([$E | Rest], Acc, NeedFrac) ->
+ parse_exp1(Rest, Acc, NeedFrac);
+parse_exp(Rest, Acc, _NeedFrac) ->
+ finish_number(Acc, Rest).
+
+parse_exp1(Rest, Acc, NeedFrac) ->
+ {Acc1, Rest1} = parse_signed_int_part(Rest, if
+ NeedFrac -> [$e, $0, $. | Acc];
+ true -> [$e | Acc]
+ end),
+ finish_number(Acc1, Rest1).
+
+parse_signed_int_part([$+ | Rest], Acc) ->
+ parse_int_part(Rest, [$+ | Acc]);
+parse_signed_int_part([$- | Rest], Acc) ->
+ parse_int_part(Rest, [$- | Acc]);
+parse_signed_int_part(Rest, Acc) ->
+ parse_int_part(Rest, Acc).
+
+is_digit(N) when is_integer(N) -> N >= $0 andalso N =< $9;
+is_digit(_) -> false.
+
+parse_object([$} | Rest], Acc) ->
+ {{obj, lists:reverse(Acc)}, Rest};
+parse_object([$, | Rest], Acc) ->
+ parse_object(skipws(Rest), Acc);
+parse_object([$" | Rest], Acc) -> %% " emacs balancing
+ {KeyCodepoints, Rest1} = parse_string(Rest, []),
+ [$: | Rest2] = skipws(Rest1),
+ {Value, Rest3} = parse(skipws(Rest2)),
+ parse_object(skipws(Rest3), [{KeyCodepoints, Value} | Acc]).
+
+parse_array([$] | Rest], Acc) ->
+ {lists:reverse(Acc), Rest};
+parse_array([$, | Rest], Acc) ->
+ parse_array(skipws(Rest), Acc);
+parse_array(Chars, Acc) ->
+ {Value, Rest} = parse(Chars),
+ parse_array(skipws(Rest), [Value | Acc]).
+
+%% @spec (Record, atom(), [any()]) -> jsonobj()
+%% where Record = tuple()
+%%
+%% @doc Used by the `?RFC4627_FROM_RECORD' macro in `rfc4627.hrl'.
+%%
+%% Given a record type definiton of ``-record(myrecord, {field1,
+%% field})'', and a value ``V = #myrecord{}'', the code
+%% ``?RFC4627_FROM_RECORD(myrecord, V)'' will return a JSON "object"
+%% with fields corresponding to the fields of the record. The macro
+%% expands to a call to the `from_record' function.
+from_record(R, _RecordName, Fields) ->
+ {obj, encode_record_fields(R, 2, Fields)}.
+
+encode_record_fields(_R, _Index, []) ->
+ [];
+encode_record_fields(R, Index, [Field | Rest]) ->
+ case element(Index, R) of
+ undefined ->
+ encode_record_fields(R, Index + 1, Rest);
+ Value ->
+ [{atom_to_list(Field), Value} | encode_record_fields(R, Index + 1, Rest)]
+ end.
+
+%% @spec (JsonObject::jsonobj(), DefaultValue::Record, [atom()]) -> Record
+%% where Record = tuple()
+%%
+%% @doc Used by the `?RFC4627_TO_RECORD' macro in `rfc4627.hrl'.
+%%
+%% Given a record type definiton of ``-record(myrecord, {field1,
+%% field})'', and a JSON "object" ``J = {obj, [{"field1", 123},
+%% {"field2", 234}]}'', the code ``?RFC4627_TO_RECORD(myrecord, J)''
+%% will return a record ``#myrecord{field1 = 123, field2 = 234}''.
+%% The macro expands to a call to the `to_record' function.
+to_record({obj, Values}, Fallback, Fields) ->
+ list_to_tuple([element(1, Fallback) | decode_record_fields(Values, Fallback, 2, Fields)]).
+
+decode_record_fields(_Values, _Fallback, _Index, []) ->
+ [];
+decode_record_fields(Values, Fallback, Index, [Field | Rest]) ->
+ [case lists:keysearch(atom_to_list(Field), 1, Values) of
+ {value, {_, Value}} ->
+ Value;
+ false ->
+ element(Index, Fallback)
+ end | decode_record_fields(Values, Fallback, Index + 1, Rest)].
+
+%% @spec (JsonObject::jsonobj(), atom()) -> jsonobj()
+%% @doc Exclude a named field from a JSON "object".
+exclude_field({obj, Props}, Key) ->
+ {obj, lists:keydelete(Key, 1, Props)}.
+
+%% @spec (JsonObject::jsonobj(), atom()) -> {ok, json()} | not_found
+%% @doc Retrieves the value of a named field of a JSON "object".
+get_field({obj, Props}, Key) ->
+ case lists:keysearch(Key, 1, Props) of
+ {value, {_K, Val}} ->
+ {ok, Val};
+ false ->
+ not_found
+ end.
+
+%% @spec (jsonobj(), atom(), json()) -> json()
+%% @doc Retrieves the value of a named field of a JSON "object", or a
+%% default value if no such field is present.
+get_field(Obj, Key, DefaultValue) ->
+ case get_field(Obj, Key) of
+ {ok, Val} ->
+ Val;
+ not_found ->
+ DefaultValue
+ end.
+
+%% @spec (JsonObject::jsonobj(), atom(), json()) -> jsonobj()
+%% @doc Adds or replaces a named field with the given value.
+%%
+%% Returns a JSON "object" that contains the new field value as well
+%% as all the unmodified fields from the first argument.
+set_field({obj, Props}, Key, NewValue) ->
+ {obj, [{Key, NewValue} | lists:keydelete(Key, 1, Props)]}.
+
+%% @spec (A::json(), B::json()) -> bool()
+%% @doc Tests equivalence of JSON terms.
+%%
+%% After Bob Ippolito's `equiv' predicate in mochijson.
+equiv({obj, Props1}, {obj, Props2}) ->
+ L1 = lists:keysort(1, Props1),
+ L2 = lists:keysort(1, Props2),
+ equiv_sorted_plists(L1, L2);
+equiv(A, B) when is_list(A) andalso is_list(B) ->
+ equiv_arrays(A, B);
+equiv(A, B) ->
+ A == B.
+
+equiv_sorted_plists([], []) -> true;
+equiv_sorted_plists([], _) -> false;
+equiv_sorted_plists(_, []) -> false;
+equiv_sorted_plists([{K1, V1} | R1], [{K2, V2} | R2]) ->
+ K1 == K2 andalso equiv(V1, V2) andalso equiv_sorted_plists(R1, R2).
+
+equiv_arrays([], []) -> true;
+equiv_arrays([], _) -> false;
+equiv_arrays(_, []) -> false;
+equiv_arrays([V1 | R1], [V2 | R2]) ->
+ equiv(V1, V2) andalso equiv_arrays(R1, R2).
View
563 lib/erlang-rfc4627/src/rfc4627_jsonrpc.erl
@@ -0,0 +1,563 @@
+%% JSON-RPC, transport-neutral.
+%%---------------------------------------------------------------------------
+%% @author Tony Garnock-Jones <tonygarnockjones@gmail.com>
+%% @author LShift Ltd. <query@lshift.net>
+%% @copyright 2007-2010, 2011, 2012 Tony Garnock-Jones and 2007-2010 LShift Ltd.
+%% @license
+%%
+%% Permission is hereby granted, free of charge, to any person
+%% obtaining a copy of this software and associated documentation
+%% files (the "Software"), to deal in the Software without
+%% restriction, including without limitation the rights to use, copy,
+%% modify, merge, publish, distribute, sublicense, and/or sell copies
+%% of the Software, and to permit persons to whom the Software is
+%% furnished to do so, subject to the following conditions:
+%%
+%% The above copyright notice and this permission notice shall be
+%% included in all copies or substantial portions of the Software.
+%%
+%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+%% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+%% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+%% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+%% BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+%% ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+%% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+%% SOFTWARE.
+%%---------------------------------------------------------------------------
+%% @since 1.2.0
+%%
+%% @reference the <a href="http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html">JSON-RPC specification</a> (draft; <a href="JSON-RPC-1-1-WD-20060807.html">mirrored locally</a>)
+%%
+%% @doc Provides a registry of running JSON-RPC objects, and a
+%% transport-neutral means of invoking methods defined on such
+%% objects.
+%%
+%% Other modules provide interfaces to specific transports and
+%% transport implementations. See {@link rfc4627_jsonrpc_http} and
+%% {@link rfc4627_jsonrpc_inets}, for example.
+%%
+%% == JSON-RPC Objects are Erlang Processes ==
+%%
+%% In the normal case, each JSON-RPC object in a running system
+%% corresponds to one Erlang process. This makes object lifecycle
+%% control very natural.
+%%
+%% == Basic usage ==
+%%
+%% Ensure the registry process is running, using {@link start/0} or
+%% {@link start_link/0}. Once it's up and running, use {@link
+%% register_service/2} to expose a process as a JSON-RPC service.
+%%
+%% To register a service, you will need to describe the methods
+%% available on it. Use {@link service/4} to do so.
+%%
+%% == Implementing a service ==
+%%
+%% Your service should be implemented by a `gen_server'
+%% process. JSON-RPC requests will be sent to it as
+%% `gen_server:call/2' messages:
+%%
+%% ``{jsonrpc, ProcedureNameBin, RequestInfo, Args}''
+%%
+%% Your module's `handle_call' function should respond to these
+%% messages with a reply of type {@type jsonrpc_response()}.
+%%
+%% Here's the implementation of the "test_proc" example:
+%%
+%% ```
+%% handle_call({jsonrpc, <<"test_proc">>, _RequestInfo, [Value]}, _From, State) ->
+%% {reply, {result, <<"ErlangServer: ", Value/binary>>}, State}.
+%% '''
+%%
+%% See also the complete example Erlang module included with the
+%% source code, `test_jsonrpc_inets.erl'.
+%%
+%% == Registering a service with the Service Registry ==
+%%
+%% You will need to ``-include("rfc4627_jsonrpc.hrl").'' (Or, if
+%% you've installed the compiled `rfc4627_jsonrpc' code in your Erlang
+%% lib directory,
+%% ``-include_lib("rfc4627/include/rfc4627_jsonrpc.hrl").'')
+%%
+%% The service registry must be started before any registrations can
+%% be performed: simply call {@link start/0} or {@link
+%% start_link/0}. This will start the registry if it wasn't running,
+%% or if it was, it will inform you of the existing registry's Pid.
+%%
+%% Registering a service is as simple as starting a process to receive