libcouchbase 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/.travis.yml +35 -0
- data/Gemfile +4 -0
- data/LICENSE +24 -0
- data/README.md +389 -0
- data/Rakefile +75 -0
- data/ext/README.md +6 -0
- data/ext/Rakefile +20 -0
- data/ext/libcouchbase/.gitignore +130 -0
- data/ext/libcouchbase/.travis.yml +19 -0
- data/ext/libcouchbase/CMakeLists.txt +429 -0
- data/ext/libcouchbase/CONTRIBUTING.md +124 -0
- data/ext/libcouchbase/LICENSE +202 -0
- data/ext/libcouchbase/README.markdown +163 -0
- data/ext/libcouchbase/RELEASE_NOTES.markdown +2691 -0
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +27 -0
- data/ext/libcouchbase/cmake/Modules/CopyPDB.cmake +42 -0
- data/ext/libcouchbase/cmake/Modules/DistScript.cmake +17 -0
- data/ext/libcouchbase/cmake/Modules/DownloadLcbDep.cmake +20 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseHdrHistogram.cmake +15 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibev.cmake +73 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +52 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +56 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +11 -0
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +29 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +133 -0
- data/ext/libcouchbase/cmake/Modules/GetPlatformCCInfo.cmake +45 -0
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +70 -0
- data/ext/libcouchbase/cmake/config-cmake.h.in +60 -0
- data/ext/libcouchbase/cmake/configure +357 -0
- data/ext/libcouchbase/cmake/defs.mk.in +8 -0
- data/ext/libcouchbase/cmake/dtrace-instr-link.pl +38 -0
- data/ext/libcouchbase/cmake/source_files.cmake +73 -0
- data/ext/libcouchbase/configure.pl +1 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.c +624 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.h +158 -0
- data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +9 -0
- data/ext/libcouchbase/contrib/cbsasl/COPYING +202 -0
- data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +217 -0
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +205 -0
- data/ext/libcouchbase/contrib/cbsasl/src/common.c +46 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.c +67 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.h +33 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.c +296 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.h +45 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.c +573 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.h +15 -0
- data/ext/libcouchbase/contrib/cbsasl/src/util.h +31 -0
- data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +2 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.c +747 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.h +493 -0
- data/ext/libcouchbase/contrib/genhash/genhash.c +372 -0
- data/ext/libcouchbase/contrib/genhash/genhash.h +235 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CHANGES +157 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CMakeLists.txt +252 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CONTRIBUTORS +37 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/LICENSE +28 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/MINIFY.sh +15 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/README +435 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/cmake/internal_utils.cmake +227 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-death-test.h +294 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-message.h +250 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h +1421 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h.pump +487 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-printers.h +855 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-spi.h +232 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-test-part.h +179 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-typed-test.h +259 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest.h +2291 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_pred_impl.h +358 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_prod.h +58 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-death-test-internal.h +319 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-filepath.h +206 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-internal.h +1158 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-linked_ptr.h +233 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h +5143 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h.pump +301 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util.h +619 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-port.h +1947 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-string.h +167 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h +1012 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h.pump +339 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h +3331 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h.pump +297 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-all.cc +48 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-death-test.cc +1344 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-filepath.cc +382 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-internal-inl.h +1218 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-port.cc +805 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-printers.cc +363 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-test-part.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-typed-test.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest.cc +5015 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest_main.cc +38 -0
- data/ext/libcouchbase/contrib/http_parser/LICENSE-MIT +23 -0
- data/ext/libcouchbase/contrib/http_parser/README.md +178 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.c +2060 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.h +321 -0
- data/ext/libcouchbase/contrib/jsonsl/LICENSE +20 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.c +1452 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.h +971 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/CMakeLists.txt +6 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/LICENSE +55 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp-forwards.h +255 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +4892 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.h +1961 -0
- data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +8 -0
- data/ext/libcouchbase/contrib/snappy/COPYING +28 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.cc +90 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.h +138 -0
- data/ext/libcouchbase/contrib/snappy/snappy-internal.h +150 -0
- data/ext/libcouchbase/contrib/snappy/snappy-lcb-msvc.h +5 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +71 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.h +137 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.cc +42 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.h +491 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +98 -0
- data/ext/libcouchbase/contrib/snappy/snappy.cc +1307 -0
- data/ext/libcouchbase/contrib/snappy/snappy.h +184 -0
- data/ext/libcouchbase/contrib/win32-defs/iocpdefs.h +133 -0
- data/ext/libcouchbase/contrib/win32-defs/mingwdefs.h +4396 -0
- data/ext/libcouchbase/contrib/win32-defs/win_stdint.h +258 -0
- data/ext/libcouchbase/example/CMakeLists.txt +37 -0
- data/ext/libcouchbase/example/README.markdown +47 -0
- data/ext/libcouchbase/example/db/db.c +167 -0
- data/ext/libcouchbase/example/db/vb.c +227 -0
- data/ext/libcouchbase/example/instancepool/main.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.h +69 -0
- data/ext/libcouchbase/example/libeventdirect/main.c +148 -0
- data/ext/libcouchbase/example/mcc/mcc.cc +246 -0
- data/ext/libcouchbase/example/minimal/minimal.c +130 -0
- data/ext/libcouchbase/example/observe/observe.c +146 -0
- data/ext/libcouchbase/example/subdoc/subdoc-multi.cc +132 -0
- data/ext/libcouchbase/example/subdoc/subdoc-simple.cc +191 -0
- data/ext/libcouchbase/example/tick/tick.c +119 -0
- data/ext/libcouchbase/example/views/views-example.cc +83 -0
- data/ext/libcouchbase/include/libcouchbase/_cxxwrap.h +150 -0
- data/ext/libcouchbase/include/libcouchbase/api-legacy.h +1689 -0
- data/ext/libcouchbase/include/libcouchbase/api3.h +2 -0
- data/ext/libcouchbase/include/libcouchbase/assert.h +44 -0
- data/ext/libcouchbase/include/libcouchbase/cbft.h +109 -0
- data/ext/libcouchbase/include/libcouchbase/cntl-private.h +356 -0
- data/ext/libcouchbase/include/libcouchbase/cntl.h +937 -0
- data/ext/libcouchbase/include/libcouchbase/configuration.h.in +23 -0
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +3677 -0
- data/ext/libcouchbase/include/libcouchbase/deprecated.h +300 -0
- data/ext/libcouchbase/include/libcouchbase/error.h +595 -0
- data/ext/libcouchbase/include/libcouchbase/http.h +1 -0
- data/ext/libcouchbase/include/libcouchbase/iops.h +1050 -0
- data/ext/libcouchbase/include/libcouchbase/ixmgmt.h +263 -0
- data/ext/libcouchbase/include/libcouchbase/kvbuf.h +132 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +364 -0
- data/ext/libcouchbase/include/libcouchbase/pktfwd.h +270 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +367 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr-inl.c +76 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr.h +199 -0
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +312 -0
- data/ext/libcouchbase/include/libcouchbase/sysdefs.h +98 -0
- data/ext/libcouchbase/include/libcouchbase/vbucket.h +643 -0
- data/ext/libcouchbase/include/libcouchbase/views.h +298 -0
- data/ext/libcouchbase/include/libcouchbase/visibility.h +65 -0
- data/ext/libcouchbase/include/memcached/COPYING +30 -0
- data/ext/libcouchbase/include/memcached/README +10 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +1916 -0
- data/ext/libcouchbase/include/memcached/vbucket.h +42 -0
- data/ext/libcouchbase/packaging/README +7 -0
- data/ext/libcouchbase/packaging/abicheck/.gitignore +4 -0
- data/ext/libcouchbase/packaging/abicheck/Makefile +17 -0
- data/ext/libcouchbase/packaging/abicheck/README.md +27 -0
- data/ext/libcouchbase/packaging/abicheck/template.xml +3 -0
- data/ext/libcouchbase/packaging/deb/compat +1 -0
- data/ext/libcouchbase/packaging/deb/control +73 -0
- data/ext/libcouchbase/packaging/deb/copyright +10 -0
- data/ext/libcouchbase/packaging/deb/libcouchbase-dev.docs +3 -0
- data/ext/libcouchbase/packaging/deb/package.mk +31 -0
- data/ext/libcouchbase/packaging/deb/rules +46 -0
- data/ext/libcouchbase/packaging/deb/source/format +1 -0
- data/ext/libcouchbase/packaging/distinfo/README +1 -0
- data/ext/libcouchbase/packaging/distinfo/distinfo.cmake.in +4 -0
- data/ext/libcouchbase/packaging/dllversion.rc.in +39 -0
- data/ext/libcouchbase/packaging/libcouchbase.pc.in +10 -0
- data/ext/libcouchbase/packaging/nuget/libcouchbase.autopkg +76 -0
- data/ext/libcouchbase/packaging/parse-git-describe.pl +166 -0
- data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +108 -0
- data/ext/libcouchbase/packaging/rpm/package.mk +40 -0
- data/ext/libcouchbase/plugins/io/iocp/CMakeLists.txt +9 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.c +466 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.h +217 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_loop.c +295 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_timer.c +79 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_util.c +229 -0
- data/ext/libcouchbase/plugins/io/libev/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +65 -0
- data/ext/libcouchbase/plugins/io/libev/plugin-libev.c +289 -0
- data/ext/libcouchbase/plugins/io/libevent/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libevent/libevent_io_opts.h +67 -0
- data/ext/libcouchbase/plugins/io/libevent/plugin-libevent.c +292 -0
- data/ext/libcouchbase/plugins/io/libuv/CMakeLists.txt +42 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_compat.h +212 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_io_opts.h +118 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +148 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +648 -0
- data/ext/libcouchbase/plugins/io/select/CMakeLists.txt +11 -0
- data/ext/libcouchbase/plugins/io/select/plugin-select.c +448 -0
- data/ext/libcouchbase/plugins/io/select/select_io_opts.h +39 -0
- data/ext/libcouchbase/src/README.md +103 -0
- data/ext/libcouchbase/src/aspend.h +106 -0
- data/ext/libcouchbase/src/auth.cc +74 -0
- data/ext/libcouchbase/src/auth.h +54 -0
- data/ext/libcouchbase/src/bootstrap.c +269 -0
- data/ext/libcouchbase/src/bootstrap.h +129 -0
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.c +495 -0
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +347 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +630 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +82 -0
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +150 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +681 -0
- data/ext/libcouchbase/src/bucketconfig/confmon.c +474 -0
- data/ext/libcouchbase/src/callbacks.c +378 -0
- data/ext/libcouchbase/src/cbft.cc +210 -0
- data/ext/libcouchbase/src/cntl.cc +847 -0
- data/ext/libcouchbase/src/config_static.h +159 -0
- data/ext/libcouchbase/src/connspec.cc +462 -0
- data/ext/libcouchbase/src/connspec.h +105 -0
- data/ext/libcouchbase/src/ctx-log-inl.h +27 -0
- data/ext/libcouchbase/src/dump.c +98 -0
- data/ext/libcouchbase/src/getconfig.c +100 -0
- data/ext/libcouchbase/src/gethrtime.c +109 -0
- data/ext/libcouchbase/src/handler.c +922 -0
- data/ext/libcouchbase/src/hashset.c +164 -0
- data/ext/libcouchbase/src/hashset.h +86 -0
- data/ext/libcouchbase/src/hashtable.c +75 -0
- data/ext/libcouchbase/src/hdr_timings.c +92 -0
- data/ext/libcouchbase/src/hostlist.cc +301 -0
- data/ext/libcouchbase/src/hostlist.h +171 -0
- data/ext/libcouchbase/src/http/http-priv.h +307 -0
- data/ext/libcouchbase/src/http/http.cc +633 -0
- data/ext/libcouchbase/src/http/http.h +34 -0
- data/ext/libcouchbase/src/http/http_io.cc +307 -0
- data/ext/libcouchbase/src/instance.cc +722 -0
- data/ext/libcouchbase/src/internal.h +244 -0
- data/ext/libcouchbase/src/iofactory.c +575 -0
- data/ext/libcouchbase/src/jsparse/parser.cc +519 -0
- data/ext/libcouchbase/src/jsparse/parser.h +173 -0
- data/ext/libcouchbase/src/lcbht/lcbht.c +282 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +199 -0
- data/ext/libcouchbase/src/lcbio/connect.c +557 -0
- data/ext/libcouchbase/src/lcbio/connect.h +364 -0
- data/ext/libcouchbase/src/lcbio/ctx.c +611 -0
- data/ext/libcouchbase/src/lcbio/ctx.h +405 -0
- data/ext/libcouchbase/src/lcbio/iotable.c +290 -0
- data/ext/libcouchbase/src/lcbio/iotable.h +84 -0
- data/ext/libcouchbase/src/lcbio/ioutils.c +350 -0
- data/ext/libcouchbase/src/lcbio/ioutils.h +203 -0
- data/ext/libcouchbase/src/lcbio/lcbio.h +51 -0
- data/ext/libcouchbase/src/lcbio/manager.c +584 -0
- data/ext/libcouchbase/src/lcbio/manager.h +156 -0
- data/ext/libcouchbase/src/lcbio/protoctx.c +84 -0
- data/ext/libcouchbase/src/lcbio/rw-inl.h +115 -0
- data/ext/libcouchbase/src/lcbio/ssl.h +149 -0
- data/ext/libcouchbase/src/lcbio/timer-ng.h +179 -0
- data/ext/libcouchbase/src/lcbio/timer.c +132 -0
- data/ext/libcouchbase/src/legacy.c +430 -0
- data/ext/libcouchbase/src/list.c +144 -0
- data/ext/libcouchbase/src/list.h +127 -0
- data/ext/libcouchbase/src/logging.c +244 -0
- data/ext/libcouchbase/src/logging.h +86 -0
- data/ext/libcouchbase/src/mc/compress.c +90 -0
- data/ext/libcouchbase/src/mc/compress.h +61 -0
- data/ext/libcouchbase/src/mc/forward.c +186 -0
- data/ext/libcouchbase/src/mc/forward.h +90 -0
- data/ext/libcouchbase/src/mc/iovcursor-inl.h +279 -0
- data/ext/libcouchbase/src/mc/iovcursor.h +66 -0
- data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +111 -0
- data/ext/libcouchbase/src/mc/mcreq.c +954 -0
- data/ext/libcouchbase/src/mc/mcreq.h +977 -0
- data/ext/libcouchbase/src/mcserver/mcserver.c +784 -0
- data/ext/libcouchbase/src/mcserver/mcserver.h +121 -0
- data/ext/libcouchbase/src/mcserver/negotiate.c +656 -0
- data/ext/libcouchbase/src/mcserver/negotiate.h +119 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +860 -0
- data/ext/libcouchbase/src/n1ql/n1ql-internal.h +22 -0
- data/ext/libcouchbase/src/n1ql/n1ql.cc +729 -0
- data/ext/libcouchbase/src/n1ql/params.cc +215 -0
- data/ext/libcouchbase/src/netbuf/netbuf-defs.h +89 -0
- data/ext/libcouchbase/src/netbuf/netbuf-mblock.h +235 -0
- data/ext/libcouchbase/src/netbuf/netbuf.c +929 -0
- data/ext/libcouchbase/src/netbuf/netbuf.h +452 -0
- data/ext/libcouchbase/src/newconfig.c +385 -0
- data/ext/libcouchbase/src/nodeinfo.cc +194 -0
- data/ext/libcouchbase/src/operations/cbflush.c +71 -0
- data/ext/libcouchbase/src/operations/counter.c +116 -0
- data/ext/libcouchbase/src/operations/durability-cas.c +224 -0
- data/ext/libcouchbase/src/operations/durability-seqno.c +157 -0
- data/ext/libcouchbase/src/operations/durability.c +668 -0
- data/ext/libcouchbase/src/operations/durability_internal.h +199 -0
- data/ext/libcouchbase/src/operations/get.c +409 -0
- data/ext/libcouchbase/src/operations/observe-seqno.c +96 -0
- data/ext/libcouchbase/src/operations/observe.c +340 -0
- data/ext/libcouchbase/src/operations/pktfwd.c +86 -0
- data/ext/libcouchbase/src/operations/remove.c +83 -0
- data/ext/libcouchbase/src/operations/stats.c +461 -0
- data/ext/libcouchbase/src/operations/store.c +360 -0
- data/ext/libcouchbase/src/operations/subdoc.cc +510 -0
- data/ext/libcouchbase/src/operations/touch.c +81 -0
- data/ext/libcouchbase/src/packetutils.c +60 -0
- data/ext/libcouchbase/src/packetutils.h +147 -0
- data/ext/libcouchbase/src/probes.d +211 -0
- data/ext/libcouchbase/src/rdb/bigalloc.c +225 -0
- data/ext/libcouchbase/src/rdb/bigalloc.h +73 -0
- data/ext/libcouchbase/src/rdb/chunkalloc.c +174 -0
- data/ext/libcouchbase/src/rdb/libcalloc.c +94 -0
- data/ext/libcouchbase/src/rdb/rope.c +419 -0
- data/ext/libcouchbase/src/rdb/rope.h +488 -0
- data/ext/libcouchbase/src/retrychk.c +113 -0
- data/ext/libcouchbase/src/retryq.c +424 -0
- data/ext/libcouchbase/src/retryq.h +157 -0
- data/ext/libcouchbase/src/ringbuffer.c +442 -0
- data/ext/libcouchbase/src/ringbuffer.h +100 -0
- data/ext/libcouchbase/src/settings.c +95 -0
- data/ext/libcouchbase/src/settings.h +188 -0
- data/ext/libcouchbase/src/simplestring.c +211 -0
- data/ext/libcouchbase/src/simplestring.h +228 -0
- data/ext/libcouchbase/src/sllist-inl.h +197 -0
- data/ext/libcouchbase/src/sllist.h +76 -0
- data/ext/libcouchbase/src/ssl/CMakeLists.txt +23 -0
- data/ext/libcouchbase/src/ssl/ssl_c.c +415 -0
- data/ext/libcouchbase/src/ssl/ssl_common.c +454 -0
- data/ext/libcouchbase/src/ssl/ssl_e.c +408 -0
- data/ext/libcouchbase/src/ssl/ssl_iot_common.h +180 -0
- data/ext/libcouchbase/src/ssobuf.h +82 -0
- data/ext/libcouchbase/src/strcodecs/base64.c +123 -0
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +285 -0
- data/ext/libcouchbase/src/timings.c +208 -0
- data/ext/libcouchbase/src/trace.h +105 -0
- data/ext/libcouchbase/src/utilities.c +171 -0
- data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -0
- data/ext/libcouchbase/src/vbucket/aliases.h +35 -0
- data/ext/libcouchbase/src/vbucket/crc32.h +83 -0
- data/ext/libcouchbase/src/vbucket/hash.h +30 -0
- data/ext/libcouchbase/src/vbucket/json-inl.h +112 -0
- data/ext/libcouchbase/src/vbucket/ketama.c +66 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/global.h +32 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5.h +35 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5c-inl.h +335 -0
- data/ext/libcouchbase/src/vbucket/vbucket.c +1543 -0
- data/ext/libcouchbase/src/views/docreq.c +194 -0
- data/ext/libcouchbase/src/views/docreq.h +83 -0
- data/ext/libcouchbase/src/views/viewreq.c +358 -0
- data/ext/libcouchbase/src/views/viewreq.h +36 -0
- data/ext/libcouchbase/src/wait.c +161 -0
- data/ext/libcouchbase/tests/CMakeLists.txt +140 -0
- data/ext/libcouchbase/tests/basic/t_base64.cc +81 -0
- data/ext/libcouchbase/tests/basic/t_ccbc103.cc +95 -0
- data/ext/libcouchbase/tests/basic/t_connstr.cc +404 -0
- data/ext/libcouchbase/tests/basic/t_creds.cc +32 -0
- data/ext/libcouchbase/tests/basic/t_ctlcodes.cc +92 -0
- data/ext/libcouchbase/tests/basic/t_hashset.cc +262 -0
- data/ext/libcouchbase/tests/basic/t_host.cc +198 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +137 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.h +589 -0
- data/ext/libcouchbase/tests/basic/t_list.cc +155 -0
- data/ext/libcouchbase/tests/basic/t_logger.cc +65 -0
- data/ext/libcouchbase/tests/basic/t_misc.cc +24 -0
- data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +18 -0
- data/ext/libcouchbase/tests/basic/t_netbuf.cc +446 -0
- data/ext/libcouchbase/tests/basic/t_packet.cc +222 -0
- data/ext/libcouchbase/tests/basic/t_ringbuffer.cc +278 -0
- data/ext/libcouchbase/tests/basic/t_slist.cc +429 -0
- data/ext/libcouchbase/tests/basic/t_strerror.cc +64 -0
- data/ext/libcouchbase/tests/basic/t_string.cc +112 -0
- data/ext/libcouchbase/tests/basic/t_urlencode.cc +132 -0
- data/ext/libcouchbase/tests/check-all.cc +608 -0
- data/ext/libcouchbase/tests/htparse/t_basic.cc +193 -0
- data/ext/libcouchbase/tests/ioserver/connection.cc +166 -0
- data/ext/libcouchbase/tests/ioserver/future.cc +50 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.cc +104 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.h +478 -0
- data/ext/libcouchbase/tests/ioserver/socket.cc +88 -0
- data/ext/libcouchbase/tests/ioserver/ssl_connection.cc +145 -0
- data/ext/libcouchbase/tests/ioserver/threads-pthreads.cc +119 -0
- data/ext/libcouchbase/tests/ioserver/threads-win32.cc +117 -0
- data/ext/libcouchbase/tests/ioserver/threads.h +66 -0
- data/ext/libcouchbase/tests/iotests/iotests.h +15 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +524 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.h +385 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.cc +67 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.h +61 -0
- data/ext/libcouchbase/tests/iotests/serverparams.h +76 -0
- data/ext/libcouchbase/tests/iotests/t_arithmetic.cc +143 -0
- data/ext/libcouchbase/tests/iotests/t_behavior.cc +226 -0
- data/ext/libcouchbase/tests/iotests/t_configcache.cc +117 -0
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +241 -0
- data/ext/libcouchbase/tests/iotests/t_durability.cc +1059 -0
- data/ext/libcouchbase/tests/iotests/t_forward.cc +110 -0
- data/ext/libcouchbase/tests/iotests/t_get.cc +512 -0
- data/ext/libcouchbase/tests/iotests/t_http.cc +438 -0
- data/ext/libcouchbase/tests/iotests/t_iops.cc +175 -0
- data/ext/libcouchbase/tests/iotests/t_lock.cc +275 -0
- data/ext/libcouchbase/tests/iotests/t_misc.cc +713 -0
- data/ext/libcouchbase/tests/iotests/t_mutate.cc +609 -0
- data/ext/libcouchbase/tests/iotests/t_n1ql.cc +270 -0
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +654 -0
- data/ext/libcouchbase/tests/iotests/t_obseqno.cc +157 -0
- data/ext/libcouchbase/tests/iotests/t_regression.cc +321 -0
- data/ext/libcouchbase/tests/iotests/t_sched.cc +88 -0
- data/ext/libcouchbase/tests/iotests/t_serverops.cc +230 -0
- data/ext/libcouchbase/tests/iotests/t_smoke.cc +528 -0
- data/ext/libcouchbase/tests/iotests/t_subdoc.cc +822 -0
- data/ext/libcouchbase/tests/iotests/t_syncmode.cc +64 -0
- data/ext/libcouchbase/tests/iotests/t_views.cc +405 -0
- data/ext/libcouchbase/tests/iotests/testutil.cc +250 -0
- data/ext/libcouchbase/tests/iotests/testutil.h +163 -0
- data/ext/libcouchbase/tests/mc/mctest.h +119 -0
- data/ext/libcouchbase/tests/mc/pktmaker.h +101 -0
- data/ext/libcouchbase/tests/mc/t_alloc.cc +269 -0
- data/ext/libcouchbase/tests/mc/t_context.cc +100 -0
- data/ext/libcouchbase/tests/mc/t_flush.cc +185 -0
- data/ext/libcouchbase/tests/mc/t_forward.cc +239 -0
- data/ext/libcouchbase/tests/mc/t_ioflush.cc +102 -0
- data/ext/libcouchbase/tests/mc/t_iovcursor.cc +173 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.c +305 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.h +89 -0
- data/ext/libcouchbase/tests/mocksupport/server.c +391 -0
- data/ext/libcouchbase/tests/mocksupport/server.h +72 -0
- data/ext/libcouchbase/tests/mocksupport/timeout.c +69 -0
- data/ext/libcouchbase/tests/nonio_tests.cc +23 -0
- data/ext/libcouchbase/tests/rdb/rdbtest.h +133 -0
- data/ext/libcouchbase/tests/rdb/t_basic.cc +128 -0
- data/ext/libcouchbase/tests/rdb/t_bigalloc.cc +93 -0
- data/ext/libcouchbase/tests/rdb/t_refs.cc +112 -0
- data/ext/libcouchbase/tests/socktests/socktest.cc +347 -0
- data/ext/libcouchbase/tests/socktests/socktest.h +448 -0
- data/ext/libcouchbase/tests/socktests/t_basic.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ctx.cc +73 -0
- data/ext/libcouchbase/tests/socktests/t_manager.cc +179 -0
- data/ext/libcouchbase/tests/socktests/t_putex.cc +256 -0
- data/ext/libcouchbase/tests/socktests/t_read.cc +187 -0
- data/ext/libcouchbase/tests/socktests/t_reentrant.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +80 -0
- data/ext/libcouchbase/tests/socktests/t_write.cc +95 -0
- data/ext/libcouchbase/tests/start_mock.bat +15 -0
- data/ext/libcouchbase/tests/start_mock.sh +42 -0
- data/ext/libcouchbase/tests/unit_tests.cc +43 -0
- data/ext/libcouchbase/tests/vbucket/confdata/bad.json +101 -0
- data/ext/libcouchbase/tests/vbucket/confdata/full_25.json +363 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_25.json +90 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_45.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_25.json +291 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +341 -0
- data/ext/libcouchbase/tools/CMakeLists.txt +51 -0
- data/ext/libcouchbase/tools/cbc-handlers.h +462 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +439 -0
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +822 -0
- data/ext/libcouchbase/tools/cbc.cc +1541 -0
- data/ext/libcouchbase/tools/common/histogram.cc +43 -0
- data/ext/libcouchbase/tools/common/histogram.h +23 -0
- data/ext/libcouchbase/tools/common/my_inttypes.h +22 -0
- data/ext/libcouchbase/tools/common/options.cc +420 -0
- data/ext/libcouchbase/tools/common/options.h +81 -0
- data/ext/libcouchbase/tools/docgen/docgen.h +469 -0
- data/ext/libcouchbase/tools/docgen/loc.h +210 -0
- data/ext/libcouchbase/tools/docgen/placeholders.h +211 -0
- data/ext/libcouchbase/tools/docgen/seqgen.h +94 -0
- data/lib/libcouchbase.rb +36 -0
- data/lib/libcouchbase/bucket.rb +819 -0
- data/lib/libcouchbase/callbacks.rb +72 -0
- data/lib/libcouchbase/connection.rb +790 -0
- data/lib/libcouchbase/design_docs.rb +86 -0
- data/lib/libcouchbase/error.rb +68 -0
- data/lib/libcouchbase/ext/libcouchbase.rb +1135 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdbase.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdcounter.rb +36 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdendure.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdfts.rb +24 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdget.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdgetreplica.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdhttp.rb +58 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdn1ql.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobseqno.rb +33 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobserve.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstore.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstoredur.rb +45 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdsubdoc.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdverbosity.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdviewquery.rb +61 -0
- data/lib/libcouchbase/ext/libcouchbase/contigbuf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st.rb +15 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st0.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st1.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st2.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st3.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/crst_u.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_st_v.rb +11 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_t.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/durabilityopt_sv0.rb +63 -0
- data/lib/libcouchbase/ext/libcouchbase/enums.rb +991 -0
- data/lib/libcouchbase/ext/libcouchbase/fragbuf.rb +18 -0
- data/lib/libcouchbase/ext/libcouchbase/ftshandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/histogram.rb +34 -0
- data/lib/libcouchbase/ext/libcouchbase/http_request_t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/keybuf.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/multicmd_ctx.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/mutation_token.rb +17 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlparams.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/respbase.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/respcounter.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respendure.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/respfts.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/respget.rb +44 -0
- data/lib/libcouchbase/ext/libcouchbase/resphttp.rb +48 -0
- data/lib/libcouchbase/ext/libcouchbase/respmcversion.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respn1ql.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respobseqno.rb +52 -0
- data/lib/libcouchbase/ext/libcouchbase/respobserve.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respserverbase.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstats.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respstore.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstoredur.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respsubdoc.rb +35 -0
- data/lib/libcouchbase/ext/libcouchbase/respviewquery.rb +67 -0
- data/lib/libcouchbase/ext/libcouchbase/sdentry.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/sdspec.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf_u_buf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/viewhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase_iocp.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase_libuv.rb +18 -0
- data/lib/libcouchbase/ext/tasks.rb +87 -0
- data/lib/libcouchbase/n1ql.rb +73 -0
- data/lib/libcouchbase/query_full_text.rb +147 -0
- data/lib/libcouchbase/query_n1ql.rb +121 -0
- data/lib/libcouchbase/query_view.rb +129 -0
- data/lib/libcouchbase/results_fiber.rb +262 -0
- data/lib/libcouchbase/results_native.rb +211 -0
- data/lib/libcouchbase/version.rb +5 -0
- data/libcouchbase.gemspec +61 -0
- data/spec/bucket_spec.rb +270 -0
- data/spec/connection_spec.rb +277 -0
- data/spec/design_docs_spec.rb +23 -0
- data/spec/error_spec.rb +26 -0
- data/spec/fts_spec.rb +129 -0
- data/spec/n1ql_spec.rb +201 -0
- data/spec/results_libuv_spec.rb +229 -0
- data/spec/results_native_spec.rb +259 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/design.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/data-0000.cbb +0 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/failover.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/meta.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/seqno.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/snapshot_markers.json +1 -0
- data/spec/view_spec.rb +195 -0
- metadata +775 -0
@@ -0,0 +1,971 @@
|
|
1
|
+
/**
|
2
|
+
* JSON Simple/Stacked/Stateful Lexer.
|
3
|
+
* - Does not buffer data
|
4
|
+
* - Maintains state
|
5
|
+
* - Callback oriented
|
6
|
+
* - Lightweight and fast. One source file and one header file
|
7
|
+
*
|
8
|
+
* Copyright (C) 2012-2015 Mark Nunberg
|
9
|
+
* See included LICENSE file for license details.
|
10
|
+
*/
|
11
|
+
|
12
|
+
#ifndef JSONSL_H_
|
13
|
+
#define JSONSL_H_
|
14
|
+
|
15
|
+
#include <stdio.h>
|
16
|
+
#include <stdlib.h>
|
17
|
+
#include <stddef.h>
|
18
|
+
#include <string.h>
|
19
|
+
#include <sys/types.h>
|
20
|
+
#include <wchar.h>
|
21
|
+
|
22
|
+
#ifdef __cplusplus
|
23
|
+
extern "C" {
|
24
|
+
#endif /* __cplusplus */
|
25
|
+
|
26
|
+
#ifdef JSONSL_USE_WCHAR
|
27
|
+
typedef jsonsl_char_t wchar_t;
|
28
|
+
typedef jsonsl_uchar_t unsigned wchar_t;
|
29
|
+
#else
|
30
|
+
typedef char jsonsl_char_t;
|
31
|
+
typedef unsigned char jsonsl_uchar_t;
|
32
|
+
#endif /* JSONSL_USE_WCHAR */
|
33
|
+
|
34
|
+
/* Stolen from http-parser.h, and possibly others */
|
35
|
+
#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600)
|
36
|
+
typedef __int8 int8_t;
|
37
|
+
typedef unsigned __int8 uint8_t;
|
38
|
+
typedef __int16 int16_t;
|
39
|
+
typedef unsigned __int16 uint16_t;
|
40
|
+
typedef __int32 int32_t;
|
41
|
+
typedef unsigned __int32 uint32_t;
|
42
|
+
typedef __int64 int64_t;
|
43
|
+
typedef unsigned __int64 uint64_t;
|
44
|
+
#if !defined(_MSC_VER) || _MSC_VER<1400
|
45
|
+
typedef unsigned int size_t;
|
46
|
+
typedef int ssize_t;
|
47
|
+
#endif
|
48
|
+
#else
|
49
|
+
#include <stdint.h>
|
50
|
+
#endif
|
51
|
+
|
52
|
+
|
53
|
+
#if (!defined(JSONSL_STATE_GENERIC)) && (!defined(JSONSL_STATE_USER_FIELDS))
|
54
|
+
#define JSONSL_STATE_GENERIC
|
55
|
+
#endif /* !defined JSONSL_STATE_GENERIC */
|
56
|
+
|
57
|
+
#ifdef JSONSL_STATE_GENERIC
|
58
|
+
#define JSONSL_STATE_USER_FIELDS
|
59
|
+
#endif /* JSONSL_STATE_GENERIC */
|
60
|
+
|
61
|
+
/* Additional fields for component object */
|
62
|
+
#ifndef JSONSL_JPR_COMPONENT_USER_FIELDS
|
63
|
+
#define JSONSL_JPR_COMPONENT_USER_FIELDS
|
64
|
+
#endif
|
65
|
+
|
66
|
+
#ifndef JSONSL_API
|
67
|
+
/**
|
68
|
+
* We require a /DJSONSL_DLL so that users already using this as a static
|
69
|
+
* or embedded library don't get confused
|
70
|
+
*/
|
71
|
+
#if defined(_WIN32) && defined(JSONSL_DLL)
|
72
|
+
#define JSONSL_API __declspec(dllexport)
|
73
|
+
#else
|
74
|
+
#define JSONSL_API
|
75
|
+
#endif /* _WIN32 */
|
76
|
+
|
77
|
+
#endif /* !JSONSL_API */
|
78
|
+
|
79
|
+
#ifndef JSONSL_INLINE
|
80
|
+
#if defined(_MSC_VER)
|
81
|
+
#define JSONSL_INLINE __inline
|
82
|
+
#elif defined(__GNUC__)
|
83
|
+
#define JSONSL_INLINE __inline__
|
84
|
+
#else
|
85
|
+
#define JSONSL_INLINE inline
|
86
|
+
#endif /* _MSC_VER or __GNUC__ */
|
87
|
+
#endif /* JSONSL_INLINE */
|
88
|
+
|
89
|
+
#define JSONSL_MAX_LEVELS 512
|
90
|
+
|
91
|
+
struct jsonsl_st;
|
92
|
+
typedef struct jsonsl_st *jsonsl_t;
|
93
|
+
|
94
|
+
typedef struct jsonsl_jpr_st* jsonsl_jpr_t;
|
95
|
+
|
96
|
+
/**
|
97
|
+
* This flag is true when AND'd against a type whose value
|
98
|
+
* must be in "quoutes" i.e. T_HKEY and T_STRING
|
99
|
+
*/
|
100
|
+
#define JSONSL_Tf_STRINGY 0xffff00
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Constant representing the special JSON types.
|
104
|
+
* The values are special and aid in speed (the OBJECT and LIST
|
105
|
+
* values are the char literals of their openings).
|
106
|
+
*
|
107
|
+
* Their actual value is a character which attempts to resemble
|
108
|
+
* some mnemonic reference to the actual type.
|
109
|
+
*
|
110
|
+
* If new types are added, they must fit into the ASCII printable
|
111
|
+
* range (so they should be AND'd with 0x7f and yield something
|
112
|
+
* meaningful)
|
113
|
+
*/
|
114
|
+
#define JSONSL_XTYPE \
|
115
|
+
X(STRING, '"'|JSONSL_Tf_STRINGY) \
|
116
|
+
X(HKEY, '#'|JSONSL_Tf_STRINGY) \
|
117
|
+
X(OBJECT, '{') \
|
118
|
+
X(LIST, '[') \
|
119
|
+
X(SPECIAL, '^') \
|
120
|
+
X(UESCAPE, 'u')
|
121
|
+
typedef enum {
|
122
|
+
#define X(o, c) \
|
123
|
+
JSONSL_T_##o = c,
|
124
|
+
JSONSL_XTYPE
|
125
|
+
JSONSL_T_UNKNOWN = '?',
|
126
|
+
/* Abstract 'root' object */
|
127
|
+
JSONSL_T_ROOT = 0
|
128
|
+
#undef X
|
129
|
+
} jsonsl_type_t;
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Subtypes for T_SPECIAL. We define them as flags
|
133
|
+
* because more than one type can be applied to a
|
134
|
+
* given object.
|
135
|
+
*/
|
136
|
+
|
137
|
+
#define JSONSL_XSPECIAL \
|
138
|
+
X(NONE, 0) \
|
139
|
+
X(SIGNED, 1<<0) \
|
140
|
+
X(UNSIGNED, 1<<1) \
|
141
|
+
X(TRUE, 1<<2) \
|
142
|
+
X(FALSE, 1<<3) \
|
143
|
+
X(NULL, 1<<4) \
|
144
|
+
X(FLOAT, 1<<5) \
|
145
|
+
X(EXPONENT, 1<<6) \
|
146
|
+
X(NONASCII, 1<<7)
|
147
|
+
typedef enum {
|
148
|
+
#define X(o,b) \
|
149
|
+
JSONSL_SPECIALf_##o = b,
|
150
|
+
JSONSL_XSPECIAL
|
151
|
+
#undef X
|
152
|
+
/* Handy flags for checking */
|
153
|
+
|
154
|
+
JSONSL_SPECIALf_UNKNOWN = 1 << 8,
|
155
|
+
|
156
|
+
/** @private Private */
|
157
|
+
JSONSL_SPECIALf_ZERO = 1 << 9 | JSONSL_SPECIALf_UNSIGNED,
|
158
|
+
/** @private */
|
159
|
+
JSONSL_SPECIALf_DASH = 1 << 10,
|
160
|
+
|
161
|
+
/** Type is numeric */
|
162
|
+
JSONSL_SPECIALf_NUMERIC = (JSONSL_SPECIALf_SIGNED| JSONSL_SPECIALf_UNSIGNED),
|
163
|
+
|
164
|
+
/** Type is a boolean */
|
165
|
+
JSONSL_SPECIALf_BOOLEAN = (JSONSL_SPECIALf_TRUE|JSONSL_SPECIALf_FALSE),
|
166
|
+
|
167
|
+
/** Type is an "extended", not integral type (but numeric) */
|
168
|
+
JSONSL_SPECIALf_NUMNOINT = (JSONSL_SPECIALf_FLOAT|JSONSL_SPECIALf_EXPONENT)
|
169
|
+
} jsonsl_special_t;
|
170
|
+
|
171
|
+
|
172
|
+
/**
|
173
|
+
* These are the various types of stack (or other) events
|
174
|
+
* which will trigger a callback.
|
175
|
+
* Like the type constants, this are also mnemonic
|
176
|
+
*/
|
177
|
+
#define JSONSL_XACTION \
|
178
|
+
X(PUSH, '+') \
|
179
|
+
X(POP, '-') \
|
180
|
+
X(UESCAPE, 'U') \
|
181
|
+
X(ERROR, '!')
|
182
|
+
typedef enum {
|
183
|
+
#define X(a,c) \
|
184
|
+
JSONSL_ACTION_##a = c,
|
185
|
+
JSONSL_XACTION
|
186
|
+
JSONSL_ACTION_UNKNOWN = '?'
|
187
|
+
#undef X
|
188
|
+
} jsonsl_action_t;
|
189
|
+
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Various errors which may be thrown while parsing JSON
|
193
|
+
*/
|
194
|
+
#define JSONSL_XERR \
|
195
|
+
/* Trailing garbage characters */ \
|
196
|
+
X(GARBAGE_TRAILING) \
|
197
|
+
/* We were expecting a 'special' (numeric, true, false, null) */ \
|
198
|
+
X(SPECIAL_EXPECTED) \
|
199
|
+
/* The 'special' value was incomplete */ \
|
200
|
+
X(SPECIAL_INCOMPLETE) \
|
201
|
+
/* Found a stray token */ \
|
202
|
+
X(STRAY_TOKEN) \
|
203
|
+
/* We were expecting a token before this one */ \
|
204
|
+
X(MISSING_TOKEN) \
|
205
|
+
/* Cannot insert because the container is not ready */ \
|
206
|
+
X(CANT_INSERT) \
|
207
|
+
/* Found a '\' outside a string */ \
|
208
|
+
X(ESCAPE_OUTSIDE_STRING) \
|
209
|
+
/* Found a ':' outside of a hash */ \
|
210
|
+
X(KEY_OUTSIDE_OBJECT) \
|
211
|
+
/* found a string outside of a container */ \
|
212
|
+
X(STRING_OUTSIDE_CONTAINER) \
|
213
|
+
/* Found a null byte in middle of string */ \
|
214
|
+
X(FOUND_NULL_BYTE) \
|
215
|
+
/* Current level exceeds limit specified in constructor */ \
|
216
|
+
X(LEVELS_EXCEEDED) \
|
217
|
+
/* Got a } as a result of an opening [ or vice versa */ \
|
218
|
+
X(BRACKET_MISMATCH) \
|
219
|
+
/* We expected a key, but got something else instead */ \
|
220
|
+
X(HKEY_EXPECTED) \
|
221
|
+
/* We got an illegal control character (bad whitespace or something) */ \
|
222
|
+
X(WEIRD_WHITESPACE) \
|
223
|
+
/* Found a \u-escape, but there were less than 4 following hex digits */ \
|
224
|
+
X(UESCAPE_TOOSHORT) \
|
225
|
+
/* Invalid two-character escape */ \
|
226
|
+
X(ESCAPE_INVALID) \
|
227
|
+
/* Trailing comma */ \
|
228
|
+
X(TRAILING_COMMA) \
|
229
|
+
/* An invalid number was passed in a numeric field */ \
|
230
|
+
X(INVALID_NUMBER) \
|
231
|
+
/* Value is missing for object */ \
|
232
|
+
X(VALUE_EXPECTED) \
|
233
|
+
/* The following are for JPR Stuff */ \
|
234
|
+
\
|
235
|
+
/* Found a literal '%' but it was only followed by a single valid hex digit */ \
|
236
|
+
X(PERCENT_BADHEX) \
|
237
|
+
/* jsonpointer URI is malformed '/' */ \
|
238
|
+
X(JPR_BADPATH) \
|
239
|
+
/* Duplicate slash */ \
|
240
|
+
X(JPR_DUPSLASH) \
|
241
|
+
/* No leading root */ \
|
242
|
+
X(JPR_NOROOT) \
|
243
|
+
/* Allocation failure */ \
|
244
|
+
X(ENOMEM)
|
245
|
+
|
246
|
+
typedef enum {
|
247
|
+
JSONSL_ERROR_SUCCESS = 0,
|
248
|
+
#define X(e) \
|
249
|
+
JSONSL_ERROR_##e,
|
250
|
+
JSONSL_XERR
|
251
|
+
#undef X
|
252
|
+
JSONSL_ERROR_GENERIC
|
253
|
+
} jsonsl_error_t;
|
254
|
+
|
255
|
+
|
256
|
+
/**
|
257
|
+
* A state is a single level of the stack.
|
258
|
+
* Non-private data (i.e. the 'data' field, see the STATE_GENERIC section)
|
259
|
+
* will remain in tact until the item is popped.
|
260
|
+
*
|
261
|
+
* As a result, it means a parent state object may be accessed from a child
|
262
|
+
* object, (the parents fields will all be valid). This allows a user to create
|
263
|
+
* an ad-hoc hierarchy on top of the JSON one.
|
264
|
+
*
|
265
|
+
*/
|
266
|
+
struct jsonsl_state_st {
|
267
|
+
/**
|
268
|
+
* The JSON object type
|
269
|
+
*/
|
270
|
+
unsigned type;
|
271
|
+
|
272
|
+
/** If this element is special, then its extended type is here */
|
273
|
+
unsigned special_flags;
|
274
|
+
|
275
|
+
/**
|
276
|
+
* The position (in terms of number of bytes since the first call to
|
277
|
+
* jsonsl_feed()) at which the state was first pushed. This includes
|
278
|
+
* opening tokens, if applicable.
|
279
|
+
*
|
280
|
+
* @note For strings (i.e. type & JSONSL_Tf_STRINGY is nonzero) this will
|
281
|
+
* be the position of the first quote.
|
282
|
+
*
|
283
|
+
* @see jsonsl_st::pos which contains the _current_ position and can be
|
284
|
+
* used during a POP callback to get the length of the element.
|
285
|
+
*/
|
286
|
+
size_t pos_begin;
|
287
|
+
|
288
|
+
/**FIXME: This is redundant as the same information can be derived from
|
289
|
+
* jsonsl_st::pos at pop-time */
|
290
|
+
size_t pos_cur;
|
291
|
+
|
292
|
+
/**
|
293
|
+
* Level of recursion into nesting. This is mainly a convenience
|
294
|
+
* variable, as this can technically be deduced from the lexer's
|
295
|
+
* level parameter (though the logic is not that simple)
|
296
|
+
*/
|
297
|
+
unsigned int level;
|
298
|
+
|
299
|
+
|
300
|
+
/**
|
301
|
+
* how many elements in the object/list.
|
302
|
+
* For objects (hashes), an element is either
|
303
|
+
* a key or a value. Thus for one complete pair,
|
304
|
+
* nelem will be 2.
|
305
|
+
*
|
306
|
+
* For special types, this will hold the sum of the digits.
|
307
|
+
* This only holds true for values which are simple signed/unsigned
|
308
|
+
* numbers. Otherwise a special flag is set, and extra handling is not
|
309
|
+
* performed.
|
310
|
+
*/
|
311
|
+
uint64_t nelem;
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
/*TODO: merge this and special_flags into a union */
|
316
|
+
|
317
|
+
|
318
|
+
/**
|
319
|
+
* Useful for an opening nest, this will prevent a callback from being
|
320
|
+
* invoked on this item or any of its children
|
321
|
+
*/
|
322
|
+
int ignore_callback;
|
323
|
+
|
324
|
+
/**
|
325
|
+
* Counter which is incremented each time an escape ('\') is encountered.
|
326
|
+
* This is used internally for non-string types and should only be
|
327
|
+
* inspected by the user if the state actually represents a string
|
328
|
+
* type.
|
329
|
+
*/
|
330
|
+
unsigned int nescapes;
|
331
|
+
|
332
|
+
/**
|
333
|
+
* Put anything you want here. if JSONSL_STATE_USER_FIELDS is here, then
|
334
|
+
* the macro expansion happens here.
|
335
|
+
*
|
336
|
+
* You can use these fields to store hierarchical or 'tagging' information
|
337
|
+
* for specific objects.
|
338
|
+
*
|
339
|
+
* See the documentation above for the lifetime of the state object (i.e.
|
340
|
+
* if the private data points to allocated memory, it should be freed
|
341
|
+
* when the object is popped, as the state object will be re-used)
|
342
|
+
*/
|
343
|
+
#ifndef JSONSL_STATE_GENERIC
|
344
|
+
JSONSL_STATE_USER_FIELDS
|
345
|
+
#else
|
346
|
+
|
347
|
+
/**
|
348
|
+
* Otherwise, this is a simple void * pointer for anything you want
|
349
|
+
*/
|
350
|
+
void *data;
|
351
|
+
#endif /* JSONSL_STATE_USER_FIELDS */
|
352
|
+
};
|
353
|
+
|
354
|
+
/**Gets the number of elements in the list.
|
355
|
+
* @param st The state. Must be of type JSONSL_T_LIST
|
356
|
+
* @return number of elements in the list
|
357
|
+
*/
|
358
|
+
#define JSONSL_LIST_SIZE(st) ((st)->nelem)
|
359
|
+
|
360
|
+
/**Gets the number of key-value pairs in an object
|
361
|
+
* @param st The state. Must be of type JSONSL_T_OBJECT
|
362
|
+
* @return the number of key-value pairs in the object
|
363
|
+
*/
|
364
|
+
#define JSONSL_OBJECT_SIZE(st) ((st)->nelem / 2)
|
365
|
+
|
366
|
+
/**Gets the numeric value.
|
367
|
+
* @param st The state. Must be of type JSONSL_T_SPECIAL and
|
368
|
+
* special_flags must have the JSONSL_SPECIALf_NUMERIC flag
|
369
|
+
* set.
|
370
|
+
* @return the numeric value of the state.
|
371
|
+
*/
|
372
|
+
#define JSONSL_NUMERIC_VALUE(st) ((st)->nelem)
|
373
|
+
|
374
|
+
/*
|
375
|
+
* So now we need some special structure for keeping the
|
376
|
+
* JPR info in sync. Preferrably all in a single block
|
377
|
+
* of memory (there's no need for separate allocations.
|
378
|
+
* So we will define a 'table' with the following layout
|
379
|
+
*
|
380
|
+
* Level nPosbl JPR1_last JPR2_last JPR3_last
|
381
|
+
*
|
382
|
+
* 0 1 NOMATCH POSSIBLE POSSIBLE
|
383
|
+
* 1 0 NOMATCH NOMATCH COMPLETE
|
384
|
+
* [ table ends here because no further path is possible]
|
385
|
+
*
|
386
|
+
* Where the JPR..n corresponds to the number of JPRs
|
387
|
+
* requested, and nPosble is a quick flag to determine
|
388
|
+
*
|
389
|
+
* the number of possibilities. In the future this might
|
390
|
+
* be made into a proper 'jump' table,
|
391
|
+
*
|
392
|
+
* Since we always mark JPRs from the higher levels descending
|
393
|
+
* into the lower ones, a prospective child match would first
|
394
|
+
* look at the parent table to check the possibilities, and then
|
395
|
+
* see which ones were possible..
|
396
|
+
*
|
397
|
+
* Thus, the size of this blob would be (and these are all ints here)
|
398
|
+
* nLevels * nJPR * 2.
|
399
|
+
*
|
400
|
+
* the 'Width' of the table would be nJPR*2, and the 'height' would be
|
401
|
+
* nlevels
|
402
|
+
*/
|
403
|
+
|
404
|
+
/**
|
405
|
+
* This is called when a stack change ocurs.
|
406
|
+
*
|
407
|
+
* @param jsn The lexer
|
408
|
+
* @param action The type of action, this can be PUSH or POP
|
409
|
+
* @param state A pointer to the stack currently affected by the action
|
410
|
+
* @param at A pointer to the position of the input buffer which triggered
|
411
|
+
* this action.
|
412
|
+
*/
|
413
|
+
typedef void (*jsonsl_stack_callback)(
|
414
|
+
jsonsl_t jsn,
|
415
|
+
jsonsl_action_t action,
|
416
|
+
struct jsonsl_state_st* state,
|
417
|
+
const jsonsl_char_t *at);
|
418
|
+
|
419
|
+
|
420
|
+
/**
|
421
|
+
* This is called when an error is encountered.
|
422
|
+
* Sometimes it's possible to 'erase' characters (by replacing them
|
423
|
+
* with whitespace). If you think you have corrected the error, you
|
424
|
+
* can return a true value, in which case the parser will backtrack
|
425
|
+
* and try again.
|
426
|
+
*
|
427
|
+
* @param jsn The lexer
|
428
|
+
* @param error The error which was thrown
|
429
|
+
* @param state the current state
|
430
|
+
* @param a pointer to the position of the input buffer which triggered
|
431
|
+
* the error. Note that this is not const, this is because you have the
|
432
|
+
* possibility of modifying the character in an attempt to correct the
|
433
|
+
* error
|
434
|
+
*
|
435
|
+
* @return zero to bail, nonzero to try again (this only makes sense if
|
436
|
+
* the input buffer has been modified by this callback)
|
437
|
+
*/
|
438
|
+
typedef int (*jsonsl_error_callback)(
|
439
|
+
jsonsl_t jsn,
|
440
|
+
jsonsl_error_t error,
|
441
|
+
struct jsonsl_state_st* state,
|
442
|
+
jsonsl_char_t *at);
|
443
|
+
|
444
|
+
struct jsonsl_st {
|
445
|
+
/** Public, read-only */
|
446
|
+
|
447
|
+
/** This is the current level of the stack */
|
448
|
+
unsigned int level;
|
449
|
+
|
450
|
+
/** Flag set to indicate we should stop processing */
|
451
|
+
unsigned int stopfl;
|
452
|
+
|
453
|
+
/**
|
454
|
+
* This is the current position, relative to the beginning
|
455
|
+
* of the stream.
|
456
|
+
*/
|
457
|
+
size_t pos;
|
458
|
+
|
459
|
+
/** This is the 'bytes' variable passed to feed() */
|
460
|
+
const jsonsl_char_t *base;
|
461
|
+
|
462
|
+
/** Callback invoked for PUSH actions */
|
463
|
+
jsonsl_stack_callback action_callback_PUSH;
|
464
|
+
|
465
|
+
/** Callback invoked for POP actions */
|
466
|
+
jsonsl_stack_callback action_callback_POP;
|
467
|
+
|
468
|
+
/** Default callback for any action, if neither PUSH or POP callbacks are defined */
|
469
|
+
jsonsl_stack_callback action_callback;
|
470
|
+
|
471
|
+
/**
|
472
|
+
* Do not invoke callbacks for objects deeper than this level.
|
473
|
+
* NOTE: This field establishes the lower bound for ignored callbacks,
|
474
|
+
* and is thus misnamed. `min_ignore_level` would actually make more
|
475
|
+
* sense, but we don't want to break API.
|
476
|
+
*/
|
477
|
+
unsigned int max_callback_level;
|
478
|
+
|
479
|
+
/** The error callback. Invoked when an error happens. Should not be NULL */
|
480
|
+
jsonsl_error_callback error_callback;
|
481
|
+
|
482
|
+
/* these are boolean flags you can modify. You will be called
|
483
|
+
* about notification for each of these types if the corresponding
|
484
|
+
* variable is true.
|
485
|
+
*/
|
486
|
+
|
487
|
+
/**
|
488
|
+
* @name Callback Booleans.
|
489
|
+
* These determine whether a callback is to be invoked for certain types of objects
|
490
|
+
* @{*/
|
491
|
+
|
492
|
+
/** Boolean flag to enable or disable the invokcation for events on this type*/
|
493
|
+
int call_SPECIAL;
|
494
|
+
int call_OBJECT;
|
495
|
+
int call_LIST;
|
496
|
+
int call_STRING;
|
497
|
+
int call_HKEY;
|
498
|
+
/*@}*/
|
499
|
+
|
500
|
+
/**
|
501
|
+
* @name u-Escape handling
|
502
|
+
* Special handling for the \\u-f00d type sequences. These are meant
|
503
|
+
* to be translated back into the corresponding octet(s).
|
504
|
+
* A special callback (if set) is invoked with *at=='u'. An application
|
505
|
+
* may wish to temporarily suspend parsing and handle the 'u-' sequence
|
506
|
+
* internally (or not).
|
507
|
+
*/
|
508
|
+
|
509
|
+
/*@{*/
|
510
|
+
|
511
|
+
/** Callback to be invoked for a u-escape */
|
512
|
+
jsonsl_stack_callback action_callback_UESCAPE;
|
513
|
+
|
514
|
+
/** Boolean flag, whether to invoke the callback */
|
515
|
+
int call_UESCAPE;
|
516
|
+
|
517
|
+
/** Boolean flag, whether we should return after encountering a u-escape:
|
518
|
+
* the callback is invoked and then we return if this is true
|
519
|
+
*/
|
520
|
+
int return_UESCAPE;
|
521
|
+
/*@}*/
|
522
|
+
|
523
|
+
struct {
|
524
|
+
int allow_trailing_comma;
|
525
|
+
} options;
|
526
|
+
|
527
|
+
/** Put anything here */
|
528
|
+
void *data;
|
529
|
+
|
530
|
+
/*@{*/
|
531
|
+
/** Private */
|
532
|
+
int in_escape;
|
533
|
+
char expecting;
|
534
|
+
char tok_last;
|
535
|
+
int can_insert;
|
536
|
+
unsigned int levels_max;
|
537
|
+
|
538
|
+
#ifndef JSONSL_NO_JPR
|
539
|
+
size_t jpr_count;
|
540
|
+
jsonsl_jpr_t *jprs;
|
541
|
+
|
542
|
+
/* Root pointer for JPR matching information */
|
543
|
+
size_t *jpr_root;
|
544
|
+
#endif /* JSONSL_NO_JPR */
|
545
|
+
/*@}*/
|
546
|
+
|
547
|
+
/**
|
548
|
+
* This is the stack. Its upper bound is levels_max, or the
|
549
|
+
* nlevels argument passed to jsonsl_new. If you modify this structure,
|
550
|
+
* make sure that this member is last.
|
551
|
+
*/
|
552
|
+
struct jsonsl_state_st stack[1];
|
553
|
+
};
|
554
|
+
|
555
|
+
|
556
|
+
/**
|
557
|
+
* Creates a new lexer object, with capacity for recursion up to nlevels
|
558
|
+
*
|
559
|
+
* @param nlevels maximum recursion depth
|
560
|
+
*/
|
561
|
+
JSONSL_API
|
562
|
+
jsonsl_t jsonsl_new(int nlevels);
|
563
|
+
|
564
|
+
/**
|
565
|
+
* Feeds data into the lexer.
|
566
|
+
*
|
567
|
+
* @param jsn the lexer object
|
568
|
+
* @param bytes new data to be fed
|
569
|
+
* @param nbytes size of new data
|
570
|
+
*/
|
571
|
+
JSONSL_API
|
572
|
+
void jsonsl_feed(jsonsl_t jsn, const jsonsl_char_t *bytes, size_t nbytes);
|
573
|
+
|
574
|
+
/**
|
575
|
+
* Resets the internal parser state. This does not free the parser
|
576
|
+
* but does clean it internally, so that the next time feed() is called,
|
577
|
+
* it will be treated as a new stream
|
578
|
+
*
|
579
|
+
* @param jsn the lexer
|
580
|
+
*/
|
581
|
+
JSONSL_API
|
582
|
+
void jsonsl_reset(jsonsl_t jsn);
|
583
|
+
|
584
|
+
/**
|
585
|
+
* Frees the lexer, cleaning any allocated memory taken
|
586
|
+
*
|
587
|
+
* @param jsn the lexer
|
588
|
+
*/
|
589
|
+
JSONSL_API
|
590
|
+
void jsonsl_destroy(jsonsl_t jsn);
|
591
|
+
|
592
|
+
/**
|
593
|
+
* Gets the 'parent' element, given the current one
|
594
|
+
*
|
595
|
+
* @param jsn the lexer
|
596
|
+
* @param cur the current nest, which should be a struct jsonsl_nest_st
|
597
|
+
*/
|
598
|
+
static JSONSL_INLINE
|
599
|
+
struct jsonsl_state_st *jsonsl_last_state(const jsonsl_t jsn,
|
600
|
+
const struct jsonsl_state_st *state)
|
601
|
+
{
|
602
|
+
/* Don't complain about overriding array bounds */
|
603
|
+
if (state->level > 1) {
|
604
|
+
return jsn->stack + state->level - 1;
|
605
|
+
} else {
|
606
|
+
return NULL;
|
607
|
+
}
|
608
|
+
}
|
609
|
+
|
610
|
+
/**
|
611
|
+
* Gets the state of the last fully consumed child of this parent. This is
|
612
|
+
* only valid in the parent's POP callback.
|
613
|
+
*
|
614
|
+
* @param the lexer
|
615
|
+
* @return A pointer to the child.
|
616
|
+
*/
|
617
|
+
static JSONSL_INLINE
|
618
|
+
struct jsonsl_state_st *jsonsl_last_child(const jsonsl_t jsn,
|
619
|
+
const struct jsonsl_state_st *parent)
|
620
|
+
{
|
621
|
+
return jsn->stack + (parent->level + 1);
|
622
|
+
}
|
623
|
+
|
624
|
+
/**Call to instruct the parser to stop parsing and return. This is valid
|
625
|
+
* only from within a callback */
|
626
|
+
static JSONSL_INLINE
|
627
|
+
void jsonsl_stop(jsonsl_t jsn)
|
628
|
+
{
|
629
|
+
jsn->stopfl = 1;
|
630
|
+
}
|
631
|
+
|
632
|
+
/**
|
633
|
+
* This enables receiving callbacks on all events. Doesn't do
|
634
|
+
* anything special but helps avoid some boilerplate.
|
635
|
+
* This does not touch the UESCAPE callbacks or flags.
|
636
|
+
*/
|
637
|
+
static JSONSL_INLINE
|
638
|
+
void jsonsl_enable_all_callbacks(jsonsl_t jsn)
|
639
|
+
{
|
640
|
+
jsn->call_HKEY = 1;
|
641
|
+
jsn->call_STRING = 1;
|
642
|
+
jsn->call_OBJECT = 1;
|
643
|
+
jsn->call_SPECIAL = 1;
|
644
|
+
jsn->call_LIST = 1;
|
645
|
+
}
|
646
|
+
|
647
|
+
/**
|
648
|
+
* A macro which returns true if the current state object can
|
649
|
+
* have children. This means a list type or an object type.
|
650
|
+
*/
|
651
|
+
#define JSONSL_STATE_IS_CONTAINER(state) \
|
652
|
+
(state->type == JSONSL_T_OBJECT || state->type == JSONSL_T_LIST)
|
653
|
+
|
654
|
+
/**
|
655
|
+
* These two functions, dump a string representation
|
656
|
+
* of the error or type, respectively. They will never
|
657
|
+
* return NULL
|
658
|
+
*/
|
659
|
+
JSONSL_API
|
660
|
+
const char* jsonsl_strerror(jsonsl_error_t err);
|
661
|
+
JSONSL_API
|
662
|
+
const char* jsonsl_strtype(jsonsl_type_t jt);
|
663
|
+
|
664
|
+
/**
|
665
|
+
* Dumps global metrics to the screen. This is a noop unless
|
666
|
+
* jsonsl was compiled with JSONSL_USE_METRICS
|
667
|
+
*/
|
668
|
+
JSONSL_API
|
669
|
+
void jsonsl_dump_global_metrics(void);
|
670
|
+
|
671
|
+
/* This macro just here for editors to do code folding */
|
672
|
+
#ifndef JSONSL_NO_JPR
|
673
|
+
|
674
|
+
/**
|
675
|
+
* @name JSON Pointer API
|
676
|
+
*
|
677
|
+
* JSONPointer API. This isn't really related to the lexer (at least not yet)
|
678
|
+
* JSONPointer provides an extremely simple specification for providing
|
679
|
+
* locations within JSON objects. We will extend it a bit and allow for
|
680
|
+
* providing 'wildcard' characters by which to be able to 'query' the stream.
|
681
|
+
*
|
682
|
+
* See http://tools.ietf.org/html/draft-pbryan-zyp-json-pointer-00
|
683
|
+
*
|
684
|
+
* Currently I'm implementing the 'single query' API which can only use a single
|
685
|
+
* query component. In the future I will integrate my yet-to-be-published
|
686
|
+
* Boyer-Moore-esque prefix searching implementation, in order to allow
|
687
|
+
* multiple paths to be merged into one for quick and efficient searching.
|
688
|
+
*
|
689
|
+
*
|
690
|
+
* JPR (as we'll refer to it within the source) can be used by splitting
|
691
|
+
* the components into mutliple sections, and incrementally 'track' each
|
692
|
+
* component. When JSONSL delivers a 'pop' callback for a string, or a 'push'
|
693
|
+
* callback for an object, we will check to see whether the index matching
|
694
|
+
* the component corresponding to the current level contains a match
|
695
|
+
* for our path.
|
696
|
+
*
|
697
|
+
* In order to do this properly, a structure must be maintained within the
|
698
|
+
* parent indicating whether its children are possible matches. This flag
|
699
|
+
* will be 'inherited' by call children which may conform to the match
|
700
|
+
* specification, and discarded by all which do not (thereby eliminating
|
701
|
+
* their children from inheriting it).
|
702
|
+
*
|
703
|
+
* A successful match is a complete one. One can provide multiple paths with
|
704
|
+
* multiple levels of matches e.g.
|
705
|
+
* /foo/bar/baz/^/blah
|
706
|
+
*
|
707
|
+
* @{
|
708
|
+
*/
|
709
|
+
|
710
|
+
/** The wildcard character */
|
711
|
+
#ifndef JSONSL_PATH_WILDCARD_CHAR
|
712
|
+
#define JSONSL_PATH_WILDCARD_CHAR '^'
|
713
|
+
#endif /* WILDCARD_CHAR */
|
714
|
+
|
715
|
+
#define JSONSL_XMATCH \
|
716
|
+
X(COMPLETE,1) \
|
717
|
+
X(POSSIBLE,0) \
|
718
|
+
X(NOMATCH,-1) \
|
719
|
+
X(TYPE_MISMATCH, -2)
|
720
|
+
|
721
|
+
typedef enum {
|
722
|
+
|
723
|
+
#define X(T,v) \
|
724
|
+
JSONSL_MATCH_##T = v,
|
725
|
+
JSONSL_XMATCH
|
726
|
+
|
727
|
+
#undef X
|
728
|
+
JSONSL_MATCH_UNKNOWN
|
729
|
+
} jsonsl_jpr_match_t;
|
730
|
+
|
731
|
+
typedef enum {
|
732
|
+
JSONSL_PATH_STRING = 1,
|
733
|
+
JSONSL_PATH_WILDCARD,
|
734
|
+
JSONSL_PATH_NUMERIC,
|
735
|
+
JSONSL_PATH_ROOT,
|
736
|
+
|
737
|
+
/* Special */
|
738
|
+
JSONSL_PATH_INVALID = -1,
|
739
|
+
JSONSL_PATH_NONE = 0
|
740
|
+
} jsonsl_jpr_type_t;
|
741
|
+
|
742
|
+
struct jsonsl_jpr_component_st {
|
743
|
+
/** The string the component points to */
|
744
|
+
char *pstr;
|
745
|
+
/** if this is a numeric type, the number is 'cached' here */
|
746
|
+
unsigned long idx;
|
747
|
+
/** The length of the string */
|
748
|
+
size_t len;
|
749
|
+
/** The type of component (NUMERIC or STRING) */
|
750
|
+
jsonsl_jpr_type_t ptype;
|
751
|
+
|
752
|
+
/** Set this to true to enforce type checking between dict keys and array
|
753
|
+
* indices. jsonsl_jpr_match() will return TYPE_MISMATCH if it detects
|
754
|
+
* that an array index is actually a child of a dictionary. */
|
755
|
+
short is_arridx;
|
756
|
+
|
757
|
+
/* Extra fields (for more advanced searches. Default is empty) */
|
758
|
+
JSONSL_JPR_COMPONENT_USER_FIELDS
|
759
|
+
};
|
760
|
+
|
761
|
+
struct jsonsl_jpr_st {
|
762
|
+
/** Path components */
|
763
|
+
struct jsonsl_jpr_component_st *components;
|
764
|
+
size_t ncomponents;
|
765
|
+
|
766
|
+
/** Base of allocated string for components */
|
767
|
+
char *basestr;
|
768
|
+
|
769
|
+
/** The original match string. Useful for returning to the user */
|
770
|
+
char *orig;
|
771
|
+
size_t norig;
|
772
|
+
};
|
773
|
+
|
774
|
+
|
775
|
+
|
776
|
+
/**
|
777
|
+
* Create a new JPR object.
|
778
|
+
*
|
779
|
+
* @param path the JSONPointer path specification.
|
780
|
+
* @param errp a pointer to a jsonsl_error_t. If this function returns NULL,
|
781
|
+
* then more details will be in this variable.
|
782
|
+
*
|
783
|
+
* @return a new jsonsl_jpr_t object, or NULL on error.
|
784
|
+
*/
|
785
|
+
JSONSL_API
|
786
|
+
jsonsl_jpr_t jsonsl_jpr_new(const char *path, jsonsl_error_t *errp);
|
787
|
+
|
788
|
+
/**
|
789
|
+
* Destroy a JPR object
|
790
|
+
*/
|
791
|
+
JSONSL_API
|
792
|
+
void jsonsl_jpr_destroy(jsonsl_jpr_t jpr);
|
793
|
+
|
794
|
+
/**
|
795
|
+
* Match a JSON object against a type and specific level
|
796
|
+
*
|
797
|
+
* @param jpr the JPR object
|
798
|
+
* @param parent_type the type of the parent (should be T_LIST or T_OBJECT)
|
799
|
+
* @param parent_level the level of the parent
|
800
|
+
* @param key the 'key' of the child. If the parent is an array, this should be
|
801
|
+
* empty.
|
802
|
+
* @param nkey - the length of the key. If the parent is an array (T_LIST), then
|
803
|
+
* this should be the current index.
|
804
|
+
*
|
805
|
+
* NOTE: The key of the child means any kind of associative data related to the
|
806
|
+
* element. Thus: <<< { "foo" : [ >>,
|
807
|
+
* the opening array's key is "foo".
|
808
|
+
*
|
809
|
+
* @return a status constant. This indicates whether a match was excluded, possible,
|
810
|
+
* or successful.
|
811
|
+
*/
|
812
|
+
JSONSL_API
|
813
|
+
jsonsl_jpr_match_t jsonsl_jpr_match(jsonsl_jpr_t jpr,
|
814
|
+
unsigned int parent_type,
|
815
|
+
unsigned int parent_level,
|
816
|
+
const char *key, size_t nkey);
|
817
|
+
|
818
|
+
|
819
|
+
/**
|
820
|
+
* Associate a set of JPR objects with a lexer instance.
|
821
|
+
* This should be called before the lexer has been fed any data (and
|
822
|
+
* behavior is undefined if you don't adhere to this).
|
823
|
+
*
|
824
|
+
* After using this function, you may subsequently call match_state() on
|
825
|
+
* given states (presumably from within the callbacks).
|
826
|
+
*
|
827
|
+
* Note that currently the first JPR is the quickest and comes
|
828
|
+
* pre-allocated with the state structure. Further JPR objects
|
829
|
+
* are chained.
|
830
|
+
*
|
831
|
+
* @param jsn The lexer
|
832
|
+
* @param jprs An array of jsonsl_jpr_t objects
|
833
|
+
* @param njprs How many elements in the jprs array.
|
834
|
+
*/
|
835
|
+
JSONSL_API
|
836
|
+
void jsonsl_jpr_match_state_init(jsonsl_t jsn,
|
837
|
+
jsonsl_jpr_t *jprs,
|
838
|
+
size_t njprs);
|
839
|
+
|
840
|
+
/**
|
841
|
+
* This follows the same semantics as the normal match,
|
842
|
+
* except we infer parent and type information from the relevant state objects.
|
843
|
+
* The match status (for all possible JPR objects) is set in the *out parameter.
|
844
|
+
*
|
845
|
+
* If a match has succeeded, then its JPR object will be returned. In all other
|
846
|
+
* instances, NULL is returned;
|
847
|
+
*
|
848
|
+
* @param jpr The jsonsl_jpr_t handle
|
849
|
+
* @param state The jsonsl_state_st which is a candidate
|
850
|
+
* @param key The hash key (if applicable, can be NULL if parent is list)
|
851
|
+
* @param nkey Length of hash key (if applicable, can be zero if parent is list)
|
852
|
+
* @param out A pointer to a jsonsl_jpr_match_t. This will be populated with
|
853
|
+
* the match result
|
854
|
+
*
|
855
|
+
* @return If a match was completed in full, then the JPR object containing
|
856
|
+
* the matching path will be returned. Otherwise, the return is NULL (note, this
|
857
|
+
* does not mean matching has failed, it can still be part of the match: check
|
858
|
+
* the out parameter).
|
859
|
+
*/
|
860
|
+
JSONSL_API
|
861
|
+
jsonsl_jpr_t jsonsl_jpr_match_state(jsonsl_t jsn,
|
862
|
+
struct jsonsl_state_st *state,
|
863
|
+
const char *key,
|
864
|
+
size_t nkey,
|
865
|
+
jsonsl_jpr_match_t *out);
|
866
|
+
|
867
|
+
|
868
|
+
/**
|
869
|
+
* Cleanup any memory allocated and any states set by
|
870
|
+
* match_state_init() and match_state()
|
871
|
+
* @param jsn The lexer
|
872
|
+
*/
|
873
|
+
JSONSL_API
|
874
|
+
void jsonsl_jpr_match_state_cleanup(jsonsl_t jsn);
|
875
|
+
|
876
|
+
/**
|
877
|
+
* Return a string representation of the match result returned by match()
|
878
|
+
*/
|
879
|
+
JSONSL_API
|
880
|
+
const char *jsonsl_strmatchtype(jsonsl_jpr_match_t match);
|
881
|
+
|
882
|
+
/* @}*/
|
883
|
+
|
884
|
+
/**
|
885
|
+
* Utility function to convert escape sequences into their original form.
|
886
|
+
*
|
887
|
+
* The decoders I've sampled do not seem to specify a standard behavior of what
|
888
|
+
* to escape/unescape.
|
889
|
+
*
|
890
|
+
* RFC 4627 Mandates only that the quoute, backslash, and ASCII control
|
891
|
+
* characters (0x00-0x1f) be escaped. It is often common for applications
|
892
|
+
* to escape a '/' - however this may also be desired behavior. the JSON
|
893
|
+
* spec is not clear on this, and therefore jsonsl leaves it up to you.
|
894
|
+
*
|
895
|
+
* @param in The input string.
|
896
|
+
* @param out An allocated output (should be the same size as in)
|
897
|
+
* @param len the size of the buffer
|
898
|
+
* @param toEscape - A sparse array of characters to unescape. Characters
|
899
|
+
* which are not present in this array, e.g. toEscape['c'] == 0 will be
|
900
|
+
* ignored and passed to the output in their original form.
|
901
|
+
* @param oflags If not null, and a \uXXXX escape expands to a non-ascii byte,
|
902
|
+
* then this variable will have the SPECIALf_NONASCII flag on.
|
903
|
+
*
|
904
|
+
* @param err A pointer to an error variable. If an error ocurrs, it will be
|
905
|
+
* set in this variable
|
906
|
+
* @param errat If not null and an error occurs, this will be set to point
|
907
|
+
* to the position within the string at which the offending character was
|
908
|
+
* encountered.
|
909
|
+
*
|
910
|
+
* @return The effective size of the output buffer.
|
911
|
+
*/
|
912
|
+
JSONSL_API
|
913
|
+
size_t jsonsl_util_unescape_ex(const char *in,
|
914
|
+
char *out,
|
915
|
+
size_t len,
|
916
|
+
const int toEscape[128],
|
917
|
+
unsigned *oflags,
|
918
|
+
jsonsl_error_t *err,
|
919
|
+
const char **errat);
|
920
|
+
|
921
|
+
/**
|
922
|
+
* Convenience macro to avoid passing too many parameters
|
923
|
+
*/
|
924
|
+
#define jsonsl_util_unescape(in, out, len, toEscape, err) \
|
925
|
+
jsonsl_util_unescape_ex(in, out, len, toEscape, NULL, err, NULL)
|
926
|
+
|
927
|
+
#endif /* JSONSL_NO_JPR */
|
928
|
+
|
929
|
+
/**
|
930
|
+
* HERE BE CHARACTER TABLES!
|
931
|
+
*/
|
932
|
+
#define JSONSL_CHARTABLE_string_nopass \
|
933
|
+
/* 0x00 */ 1 /* <NUL> */, /* 0x00 */ \
|
934
|
+
/* 0x01 */ 1 /* <SOH> */, /* 0x01 */ \
|
935
|
+
/* 0x02 */ 1 /* <STX> */, /* 0x02 */ \
|
936
|
+
/* 0x03 */ 1 /* <ETX> */, /* 0x03 */ \
|
937
|
+
/* 0x04 */ 1 /* <EOT> */, /* 0x04 */ \
|
938
|
+
/* 0x05 */ 1 /* <ENQ> */, /* 0x05 */ \
|
939
|
+
/* 0x06 */ 1 /* <ACK> */, /* 0x06 */ \
|
940
|
+
/* 0x07 */ 1 /* <BEL> */, /* 0x07 */ \
|
941
|
+
/* 0x08 */ 1 /* <BS> */, /* 0x08 */ \
|
942
|
+
/* 0x09 */ 1 /* <HT> */, /* 0x09 */ \
|
943
|
+
/* 0x0a */ 1 /* <LF> */, /* 0x0a */ \
|
944
|
+
/* 0x0b */ 1 /* <VT> */, /* 0x0b */ \
|
945
|
+
/* 0x0c */ 1 /* <FF> */, /* 0x0c */ \
|
946
|
+
/* 0x0d */ 1 /* <CR> */, /* 0x0d */ \
|
947
|
+
/* 0x0e */ 1 /* <SO> */, /* 0x0e */ \
|
948
|
+
/* 0x0f */ 1 /* <SI> */, /* 0x0f */ \
|
949
|
+
/* 0x10 */ 1 /* <DLE> */, /* 0x10 */ \
|
950
|
+
/* 0x11 */ 1 /* <DC1> */, /* 0x11 */ \
|
951
|
+
/* 0x12 */ 1 /* <DC2> */, /* 0x12 */ \
|
952
|
+
/* 0x13 */ 1 /* <DC3> */, /* 0x13 */ \
|
953
|
+
/* 0x14 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x21 */ \
|
954
|
+
/* 0x22 */ 1 /* <"> */, /* 0x22 */ \
|
955
|
+
/* 0x23 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x42 */ \
|
956
|
+
/* 0x43 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x5b */ \
|
957
|
+
/* 0x5c */ 1 /* <\> */, /* 0x5c */ \
|
958
|
+
/* 0x5d */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x7c */ \
|
959
|
+
/* 0x7d */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x9c */ \
|
960
|
+
/* 0x9d */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xbc */ \
|
961
|
+
/* 0xbd */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xdc */ \
|
962
|
+
/* 0xdd */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xfc */ \
|
963
|
+
/* 0xfd */ 0,0 /* 0xfe */ \
|
964
|
+
|
965
|
+
|
966
|
+
|
967
|
+
#ifdef __cplusplus
|
968
|
+
}
|
969
|
+
#endif /* __cplusplus */
|
970
|
+
|
971
|
+
#endif /* JSONSL_H_ */
|