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,38 @@
|
|
1
|
+
#!/usr/bin/env perl
|
2
|
+
use strict;
|
3
|
+
use warnings;
|
4
|
+
use Digest::MD5 qw(md5_hex);
|
5
|
+
|
6
|
+
my $HDR = "** $0:";
|
7
|
+
$\="\n";
|
8
|
+
|
9
|
+
my $DT_SRC = shift @ARGV;
|
10
|
+
my $CMD = shift @ARGV;
|
11
|
+
|
12
|
+
my @O_FILES = grep { $_ =~ /\.o$/ } @ARGV;
|
13
|
+
if (!scalar @O_FILES) {
|
14
|
+
# Assume this isn't an actual link command?
|
15
|
+
print"$HDR Assuming this isn't an LD/AR invocation. Continuing..";
|
16
|
+
exec($CMD,@ARGV);
|
17
|
+
}
|
18
|
+
|
19
|
+
my $ss = join('_', @O_FILES);
|
20
|
+
my $hexstr = md5_hex($ss);
|
21
|
+
|
22
|
+
my $INSTRUMENTED = "generated/probes_${hexstr}.o";
|
23
|
+
# Run DTrace instrumentation. Assuming running from build directory:
|
24
|
+
my @args = (
|
25
|
+
'dtrace', '-C', '-G',
|
26
|
+
'-s', $DT_SRC,
|
27
|
+
'-o', $INSTRUMENTED,
|
28
|
+
@O_FILES);
|
29
|
+
|
30
|
+
print "$HDR: Creating instrumented DTrace object: @args";
|
31
|
+
if (system(@args) != 0) {
|
32
|
+
exit(1);
|
33
|
+
}
|
34
|
+
|
35
|
+
unshift @ARGV, $CMD;
|
36
|
+
push @ARGV, $INSTRUMENTED;
|
37
|
+
print "$HDR: Linking with instrumented DTrace object: @ARGV";
|
38
|
+
exit(system(@ARGV));
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# These define the various source file listings of various modules
|
2
|
+
# within the library.
|
3
|
+
# This is included by the top-level CMakeLists.txt
|
4
|
+
|
5
|
+
# couchbase_utils
|
6
|
+
SET(LCB_UTILS_SRC
|
7
|
+
contrib/genhash/genhash.c
|
8
|
+
src/strcodecs/base64.c
|
9
|
+
src/gethrtime.c
|
10
|
+
src/hashtable.c
|
11
|
+
src/hashset.c
|
12
|
+
src/list.c
|
13
|
+
src/logging.c
|
14
|
+
src/packetutils.c
|
15
|
+
src/ringbuffer.c
|
16
|
+
src/simplestring.c)
|
17
|
+
|
18
|
+
# lcbio
|
19
|
+
FILE(GLOB LCB_IO_SRC src/lcbio/*.c)
|
20
|
+
|
21
|
+
# common memcached operations
|
22
|
+
FILE(GLOB LCB_OP_SRC src/operations/*.c)
|
23
|
+
|
24
|
+
# memcached packets
|
25
|
+
FILE(GLOB LCB_MC_SRC src/mc/*.c)
|
26
|
+
|
27
|
+
# read buffer management
|
28
|
+
FILE(GLOB LCB_RDB_SRC src/rdb/*.c)
|
29
|
+
|
30
|
+
# send buffer management
|
31
|
+
FILE(GLOB LCB_NETBUF_SRC src/netbuf/*.c)
|
32
|
+
|
33
|
+
# HTTP protocol management
|
34
|
+
FILE(GLOB LCB_HT_SRC src/lcbht/*.c)
|
35
|
+
LIST(APPEND LCB_HT_SRC "contrib/http_parser/http_parser.c")
|
36
|
+
|
37
|
+
# bucket config ("confmon")
|
38
|
+
FILE(GLOB LCB_BCONF_SRC src/bucketconfig/*.c)
|
39
|
+
|
40
|
+
SET(LCB_CORE_SRC
|
41
|
+
${LCB_OP_SRC}
|
42
|
+
${LCB_BCONF_SRC}
|
43
|
+
${LCB_N1QL_SRC}
|
44
|
+
src/bootstrap.c
|
45
|
+
src/callbacks.c
|
46
|
+
src/dump.c
|
47
|
+
src/handler.c
|
48
|
+
src/getconfig.c
|
49
|
+
src/legacy.c
|
50
|
+
src/mcserver/negotiate.c
|
51
|
+
src/mcserver/mcserver.c
|
52
|
+
src/newconfig.c
|
53
|
+
src/iofactory.c
|
54
|
+
src/retryq.c
|
55
|
+
src/retrychk.c
|
56
|
+
src/settings.c
|
57
|
+
src/utilities.c
|
58
|
+
src/wait.c)
|
59
|
+
|
60
|
+
SET(LCB_CORE_CXXSRC
|
61
|
+
src/instance.cc
|
62
|
+
src/auth.cc
|
63
|
+
src/connspec.cc
|
64
|
+
src/nodeinfo.cc
|
65
|
+
src/hostlist.cc
|
66
|
+
src/http/http.cc
|
67
|
+
src/http/http_io.cc
|
68
|
+
src/n1ql/params.cc
|
69
|
+
src/n1ql/n1ql.cc
|
70
|
+
src/n1ql/ixmgmt.cc
|
71
|
+
src/cbft.cc
|
72
|
+
src/operations/subdoc.cc
|
73
|
+
src/cntl.cc)
|
@@ -0,0 +1 @@
|
|
1
|
+
cmake/configure
|
@@ -0,0 +1,624 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2009 Dave Gamble
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
12
|
+
all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
THE SOFTWARE.
|
21
|
+
*/
|
22
|
+
|
23
|
+
/* cJSON */
|
24
|
+
/* JSON parser in C. */
|
25
|
+
|
26
|
+
#include <string.h>
|
27
|
+
#include <stdio.h>
|
28
|
+
#include <math.h>
|
29
|
+
#include <stdlib.h>
|
30
|
+
#include <float.h>
|
31
|
+
#include <limits.h>
|
32
|
+
#include <ctype.h>
|
33
|
+
#include <assert.h>
|
34
|
+
#include "cJSON.h"
|
35
|
+
|
36
|
+
static int cJSON_strcasecmp(const char *s1,const char *s2)
|
37
|
+
{
|
38
|
+
if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
|
39
|
+
for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
|
40
|
+
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
|
41
|
+
}
|
42
|
+
|
43
|
+
static void *(*cJSON_malloc)(size_t sz) = malloc;
|
44
|
+
static void (*cJSON_free)(void *ptr) = free;
|
45
|
+
|
46
|
+
static char* cJSON_strdup(const char* str)
|
47
|
+
{
|
48
|
+
size_t len;
|
49
|
+
char* copy;
|
50
|
+
|
51
|
+
len = strlen(str) + 1;
|
52
|
+
if (!(copy = (char*)cJSON_malloc(len))) return 0;
|
53
|
+
memcpy(copy,str,len);
|
54
|
+
return copy;
|
55
|
+
}
|
56
|
+
|
57
|
+
void cJSON_InitHooks(cJSON_Hooks* hooks)
|
58
|
+
{
|
59
|
+
if (!hooks) { /* Reset hooks */
|
60
|
+
cJSON_malloc = malloc;
|
61
|
+
cJSON_free = free;
|
62
|
+
return;
|
63
|
+
}
|
64
|
+
|
65
|
+
cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
|
66
|
+
cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
|
67
|
+
}
|
68
|
+
|
69
|
+
/* The size of pool allocation groups. Note that the allocation
|
70
|
+
pools are only used during parsing, and not generation.
|
71
|
+
Additionally, this default value is based on empirical
|
72
|
+
evidence of best performance with Couchbase configuration
|
73
|
+
data */
|
74
|
+
#ifndef CJSON_POOL_ALLOC_SIZE
|
75
|
+
#define CJSON_POOL_ALLOC_SIZE 1024
|
76
|
+
#endif
|
77
|
+
|
78
|
+
/* Creates a new allocation pool. */
|
79
|
+
static cJSON_PoolBlock *cJSON_New_PoolBlock(cJSON_Pool *pool)
|
80
|
+
{
|
81
|
+
int i;
|
82
|
+
cJSON *item, *new_alloc;
|
83
|
+
cJSON_PoolBlock *new_block;
|
84
|
+
|
85
|
+
if (CJSON_POOL_ALLOC_SIZE <= 0) {
|
86
|
+
return 0;
|
87
|
+
}
|
88
|
+
|
89
|
+
new_block = (cJSON_PoolBlock*)cJSON_malloc(
|
90
|
+
sizeof(cJSON_PoolBlock) + sizeof(cJSON)*CJSON_POOL_ALLOC_SIZE);
|
91
|
+
if (!new_block) {
|
92
|
+
return 0;
|
93
|
+
}
|
94
|
+
|
95
|
+
new_alloc = (cJSON*)(new_block+1);
|
96
|
+
|
97
|
+
memset(new_block, 0,
|
98
|
+
sizeof(cJSON_PoolBlock) + sizeof(cJSON)*CJSON_POOL_ALLOC_SIZE);
|
99
|
+
|
100
|
+
new_block->next = pool->blocks;
|
101
|
+
pool->blocks = new_block;
|
102
|
+
|
103
|
+
for (i=0, item=new_alloc; i<CJSON_POOL_ALLOC_SIZE; ++i, ++item) {
|
104
|
+
item->next = pool->free_items;
|
105
|
+
pool->free_items = item;
|
106
|
+
}
|
107
|
+
|
108
|
+
return new_block;
|
109
|
+
}
|
110
|
+
|
111
|
+
/* This will create an allocation pool */
|
112
|
+
static cJSON_Pool * cJSON_New_Pool(void)
|
113
|
+
{
|
114
|
+
if (CJSON_POOL_ALLOC_SIZE <= 0) {
|
115
|
+
return 0;
|
116
|
+
} else {
|
117
|
+
cJSON_Pool * pool = (cJSON_Pool*)cJSON_malloc(sizeof(cJSON_Pool));
|
118
|
+
if (!pool) {
|
119
|
+
return 0;
|
120
|
+
}
|
121
|
+
|
122
|
+
memset(pool, 0, sizeof(cJSON_Pool));
|
123
|
+
pool->free_items = 0;
|
124
|
+
pool->blocks = 0;
|
125
|
+
pool->refcount = 0;
|
126
|
+
|
127
|
+
return pool;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
/* This will destroy an allocation pool */
|
132
|
+
static void cJSON_Destroy_Pool(cJSON_Pool *pool)
|
133
|
+
{
|
134
|
+
cJSON_PoolBlock *cur = pool->blocks, *next;
|
135
|
+
while (cur) {
|
136
|
+
next = cur->next;
|
137
|
+
/* this frees all the allocations as well */
|
138
|
+
cJSON_free(cur);
|
139
|
+
cur = next;
|
140
|
+
}
|
141
|
+
cJSON_free(pool);
|
142
|
+
}
|
143
|
+
|
144
|
+
/* allocate new item from a pool */
|
145
|
+
static cJSON *cJSON_Pool_New_Item(cJSON_Pool *pool)
|
146
|
+
{
|
147
|
+
if (!pool->free_items) {
|
148
|
+
cJSON_New_PoolBlock(pool);
|
149
|
+
}
|
150
|
+
if (pool->free_items) {
|
151
|
+
cJSON *node = pool->free_items;
|
152
|
+
pool->free_items = node->next;
|
153
|
+
pool->refcount++;
|
154
|
+
node->next = 0;
|
155
|
+
node->alloc_pool = pool;
|
156
|
+
/* all items in the pool are already zeroed */
|
157
|
+
return node;
|
158
|
+
}
|
159
|
+
return 0;
|
160
|
+
}
|
161
|
+
static void cJSON_Pool_Free_Item(cJSON_Pool *pool, cJSON *node)
|
162
|
+
{
|
163
|
+
/* Note that this code intentially does not return the item
|
164
|
+
to the pool if we are destroying the pool anyways. */
|
165
|
+
assert(pool->refcount);
|
166
|
+
if (--pool->refcount == 0) {
|
167
|
+
cJSON_Destroy_Pool(pool);
|
168
|
+
} else {
|
169
|
+
memset(node, 0, sizeof(cJSON));
|
170
|
+
node->next = pool->free_items;
|
171
|
+
pool->free_items = node;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
/* Internal constructor. */
|
176
|
+
static cJSON *cJSON_New_Item(cJSON *parent)
|
177
|
+
{
|
178
|
+
cJSON* node = 0;
|
179
|
+
if (parent && parent->alloc_pool) {
|
180
|
+
node = cJSON_Pool_New_Item(parent->alloc_pool);
|
181
|
+
}
|
182
|
+
if (!node) {
|
183
|
+
node = (cJSON*)cJSON_malloc(sizeof(cJSON));
|
184
|
+
if (node) {
|
185
|
+
memset(node,0,sizeof(cJSON));
|
186
|
+
}
|
187
|
+
}
|
188
|
+
return node;
|
189
|
+
}
|
190
|
+
|
191
|
+
static void cJSON_Free_Item(cJSON *node)
|
192
|
+
{
|
193
|
+
cJSON_Pool *pool = node->alloc_pool;
|
194
|
+
if (pool) {
|
195
|
+
cJSON_Pool_Free_Item(pool, node);
|
196
|
+
} else {
|
197
|
+
cJSON_free(node);
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
/* Delete a cJSON structure. */
|
202
|
+
void cJSON_Delete(cJSON *c)
|
203
|
+
{
|
204
|
+
cJSON *next;
|
205
|
+
while (c)
|
206
|
+
{
|
207
|
+
next=c->next;
|
208
|
+
if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
|
209
|
+
if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring);
|
210
|
+
if (c->string) cJSON_free(c->string);
|
211
|
+
cJSON_Free_Item(c);
|
212
|
+
c=next;
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
/* Parse the input text to generate a number, and populate the result into item. */
|
217
|
+
static const char *parse_number(cJSON *item,const char *num)
|
218
|
+
{
|
219
|
+
double n=0,sign=1,scale=0;int subscale=0,signsubscale=1;
|
220
|
+
|
221
|
+
/* Could use sscanf for this? */
|
222
|
+
if (*num=='-') sign=-1,num++; /* Has sign? */
|
223
|
+
if (*num=='0') num++; /* is zero */
|
224
|
+
if (*num>='1' && *num<='9') do n=(n*10.0)+(*num++ -'0'); while (*num>='0' && *num<='9'); /* Number? */
|
225
|
+
if (*num=='.') {num++; do n=(n*10.0)+(*num++ -'0'),scale--; while (*num>='0' && *num<='9');} /* Fractional part? */
|
226
|
+
if (*num=='e' || *num=='E') /* Exponent? */
|
227
|
+
{ num++;if (*num=='+') num++; else if (*num=='-') signsubscale=-1,num++; /* With sign? */
|
228
|
+
while (*num>='0' && *num<='9') subscale=(subscale*10)+(*num++ - '0'); /* Number? */
|
229
|
+
}
|
230
|
+
|
231
|
+
n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */
|
232
|
+
|
233
|
+
item->valuedouble=n;
|
234
|
+
item->valueint=(int)n;
|
235
|
+
item->type=cJSON_Number;
|
236
|
+
return num;
|
237
|
+
}
|
238
|
+
|
239
|
+
/* Render the number nicely from the given item into a string. */
|
240
|
+
static char *print_number(cJSON *item)
|
241
|
+
{
|
242
|
+
char *str;
|
243
|
+
double d=item->valuedouble;
|
244
|
+
if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN)
|
245
|
+
{
|
246
|
+
str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */
|
247
|
+
sprintf(str,"%d",item->valueint);
|
248
|
+
}
|
249
|
+
else
|
250
|
+
{
|
251
|
+
str=(char*)cJSON_malloc(64); /* This is a nice tradeoff. */
|
252
|
+
if (fabs(floor(d)-d)<=DBL_EPSILON) sprintf(str,"%.0f",d);
|
253
|
+
else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d);
|
254
|
+
else sprintf(str,"%f",d);
|
255
|
+
}
|
256
|
+
return str;
|
257
|
+
}
|
258
|
+
|
259
|
+
/* Parse the input text into an unescaped cstring, and populate item. */
|
260
|
+
static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
261
|
+
static const char *parse_string(cJSON *item,const char *str)
|
262
|
+
{
|
263
|
+
const char *ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc;
|
264
|
+
if (*str!='\"') return 0; /* not a string! */
|
265
|
+
|
266
|
+
while (*ptr!='\"' && (unsigned char)*ptr>31 && ++len) if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */
|
267
|
+
|
268
|
+
out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */
|
269
|
+
if (!out) return 0;
|
270
|
+
|
271
|
+
ptr=str+1;ptr2=out;
|
272
|
+
while (*ptr!='\"' && (unsigned char)*ptr>31)
|
273
|
+
{
|
274
|
+
if (*ptr!='\\') *ptr2++=*ptr++;
|
275
|
+
else
|
276
|
+
{
|
277
|
+
ptr++;
|
278
|
+
switch (*ptr)
|
279
|
+
{
|
280
|
+
case 'b': *ptr2++='\b'; break;
|
281
|
+
case 'f': *ptr2++='\f'; break;
|
282
|
+
case 'n': *ptr2++='\n'; break;
|
283
|
+
case 'r': *ptr2++='\r'; break;
|
284
|
+
case 't': *ptr2++='\t'; break;
|
285
|
+
case 'u': /* transcode utf16 to utf8. DOES NOT SUPPORT SURROGATE PAIRS CORRECTLY. */
|
286
|
+
sscanf(ptr+1,"%4x",&uc); /* get the unicode char. */
|
287
|
+
len=3;if (uc<0x80) len=1;else if (uc<0x800) len=2;ptr2+=len;
|
288
|
+
|
289
|
+
switch (len) {
|
290
|
+
case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
291
|
+
case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
292
|
+
case 1: *--ptr2 =(uc | firstByteMark[len]);
|
293
|
+
}
|
294
|
+
ptr2+=len;ptr+=4;
|
295
|
+
break;
|
296
|
+
default: *ptr2++=*ptr; break;
|
297
|
+
}
|
298
|
+
ptr++;
|
299
|
+
}
|
300
|
+
}
|
301
|
+
*ptr2=0;
|
302
|
+
if (*ptr=='\"') ptr++;
|
303
|
+
item->valuestring=out;
|
304
|
+
item->type=cJSON_String;
|
305
|
+
return ptr;
|
306
|
+
}
|
307
|
+
|
308
|
+
/* Render the cstring provided to an escaped version that can be printed. */
|
309
|
+
static char *print_string_ptr(const char *str)
|
310
|
+
{
|
311
|
+
const char *ptr;char *ptr2,*out;int len=0;
|
312
|
+
|
313
|
+
if (!str) return cJSON_strdup("");
|
314
|
+
ptr=str;while (*ptr && ++len) {if ((unsigned char)*ptr<32 || *ptr=='\"' || *ptr=='\\') len++;ptr++;}
|
315
|
+
|
316
|
+
out=(char*)cJSON_malloc(len+3);
|
317
|
+
ptr2=out;ptr=str;
|
318
|
+
*ptr2++='\"';
|
319
|
+
while (*ptr)
|
320
|
+
{
|
321
|
+
if ((unsigned char)*ptr>31 && *ptr!='\"' && *ptr!='\\') *ptr2++=*ptr++;
|
322
|
+
else
|
323
|
+
{
|
324
|
+
*ptr2++='\\';
|
325
|
+
switch (*ptr++)
|
326
|
+
{
|
327
|
+
case '\\': *ptr2++='\\'; break;
|
328
|
+
case '\"': *ptr2++='\"'; break;
|
329
|
+
case '\b': *ptr2++='b'; break;
|
330
|
+
case '\f': *ptr2++='f'; break;
|
331
|
+
case '\n': *ptr2++='n'; break;
|
332
|
+
case '\r': *ptr2++='r'; break;
|
333
|
+
case '\t': *ptr2++='t'; break;
|
334
|
+
default: ptr2--; break; /* eviscerate with prejudice. */
|
335
|
+
}
|
336
|
+
}
|
337
|
+
}
|
338
|
+
*ptr2++='\"';*ptr2++=0;
|
339
|
+
return out;
|
340
|
+
}
|
341
|
+
/* Invote print_string_ptr (which is useful) on an item. */
|
342
|
+
static char *print_string(cJSON *item) {return print_string_ptr(item->valuestring);}
|
343
|
+
|
344
|
+
/* Predeclare these prototypes. */
|
345
|
+
static const char *parse_value(cJSON *item,const char *value);
|
346
|
+
static char *print_value(cJSON *item,int depth,int fmt);
|
347
|
+
static const char *parse_array(cJSON *item,const char *value);
|
348
|
+
static char *print_array(cJSON *item,int depth,int fmt);
|
349
|
+
static const char *parse_object(cJSON *item,const char *value);
|
350
|
+
static char *print_object(cJSON *item,int depth,int fmt);
|
351
|
+
|
352
|
+
/* Utility to jump whitespace and cr/lf */
|
353
|
+
static const char *skip(const char *in) {while (in && (unsigned char)*in<=32) in++; return in;}
|
354
|
+
|
355
|
+
/* Parse an object - create a new root, and populate. */
|
356
|
+
cJSON *cJSON_Parse(const char *value)
|
357
|
+
{
|
358
|
+
cJSON_Pool *pool = cJSON_New_Pool();
|
359
|
+
cJSON *c = 0;
|
360
|
+
if (pool) {
|
361
|
+
c = cJSON_Pool_New_Item(pool);
|
362
|
+
}
|
363
|
+
if (!c) {
|
364
|
+
c = cJSON_New_Item(0);
|
365
|
+
}
|
366
|
+
if (!c) return 0; /* memory fail */
|
367
|
+
|
368
|
+
c->alloc_pool = pool;
|
369
|
+
|
370
|
+
if (!parse_value(c,skip(value))) {cJSON_Delete(c);return 0;}
|
371
|
+
return c;
|
372
|
+
}
|
373
|
+
|
374
|
+
/* Render a cJSON item/entity/structure to text. */
|
375
|
+
char *cJSON_Print(cJSON *item) {return print_value(item,0,1);}
|
376
|
+
char *cJSON_PrintUnformatted(cJSON *item) {return print_value(item,0,0);}
|
377
|
+
|
378
|
+
/* Parser core - when encountering text, process appropriately. */
|
379
|
+
static const char *parse_value(cJSON *item,const char *value)
|
380
|
+
{
|
381
|
+
if (!value) return 0; /* Fail on null. */
|
382
|
+
if (!strncmp(value,"null",4)) { item->type=cJSON_NULL; return value+4; }
|
383
|
+
if (!strncmp(value,"false",5)) { item->type=cJSON_False; return value+5; }
|
384
|
+
if (!strncmp(value,"true",4)) { item->type=cJSON_True; item->valueint=1; return value+4; }
|
385
|
+
if (*value=='\"') { return parse_string(item,value); }
|
386
|
+
if (*value=='-' || (*value>='0' && *value<='9')) { return parse_number(item,value); }
|
387
|
+
if (*value=='[') { return parse_array(item,value); }
|
388
|
+
if (*value=='{') { return parse_object(item,value); }
|
389
|
+
|
390
|
+
return 0; /* failure. */
|
391
|
+
}
|
392
|
+
|
393
|
+
/* Render a value to text. */
|
394
|
+
static char *print_value(cJSON *item,int depth,int fmt)
|
395
|
+
{
|
396
|
+
char *out=0;
|
397
|
+
if (!item) return 0;
|
398
|
+
switch ((item->type)&255)
|
399
|
+
{
|
400
|
+
case cJSON_NULL: out=cJSON_strdup("null"); break;
|
401
|
+
case cJSON_False: out=cJSON_strdup("false");break;
|
402
|
+
case cJSON_True: out=cJSON_strdup("true"); break;
|
403
|
+
case cJSON_Number: out=print_number(item);break;
|
404
|
+
case cJSON_String: out=print_string(item);break;
|
405
|
+
case cJSON_Array: out=print_array(item,depth,fmt);break;
|
406
|
+
case cJSON_Object: out=print_object(item,depth,fmt);break;
|
407
|
+
}
|
408
|
+
return out;
|
409
|
+
}
|
410
|
+
|
411
|
+
/* Build an array from input text. */
|
412
|
+
static const char *parse_array(cJSON *item,const char *value)
|
413
|
+
{
|
414
|
+
cJSON *child;
|
415
|
+
if (*value!='[') return 0; /* not an array! */
|
416
|
+
|
417
|
+
item->type=cJSON_Array;
|
418
|
+
value=skip(value+1);
|
419
|
+
if (*value==']') return value+1; /* empty array. */
|
420
|
+
|
421
|
+
item->child=child=cJSON_New_Item(item);
|
422
|
+
if (!item->child) return 0; /* memory fail */
|
423
|
+
value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */
|
424
|
+
if (!value) return 0;
|
425
|
+
|
426
|
+
while (*value==',')
|
427
|
+
{
|
428
|
+
cJSON *new_item;
|
429
|
+
if (!(new_item=cJSON_New_Item(item))) return 0; /* memory fail */
|
430
|
+
child->next=new_item;new_item->prev=child;child=new_item;
|
431
|
+
value=skip(parse_value(child,skip(value+1)));
|
432
|
+
if (!value) return 0; /* memory fail */
|
433
|
+
}
|
434
|
+
|
435
|
+
if (*value==']') return value+1; /* end of array */
|
436
|
+
return 0; /* malformed. */
|
437
|
+
}
|
438
|
+
|
439
|
+
/* Render an array to text */
|
440
|
+
static char *print_array(cJSON *item,int depth,int fmt)
|
441
|
+
{
|
442
|
+
char **entries;
|
443
|
+
char *out=0,*ptr,*ret;size_t len=5;
|
444
|
+
cJSON *child=item->child;
|
445
|
+
int numentries=0,i=0,fail=0;
|
446
|
+
|
447
|
+
/* How many entries in the array? */
|
448
|
+
while (child) numentries++,child=child->next;
|
449
|
+
/* Allocate an array to hold the values for each */
|
450
|
+
entries=(char**)cJSON_malloc(numentries*sizeof(char*));
|
451
|
+
if (!entries) return 0;
|
452
|
+
memset(entries,0,numentries*sizeof(char*));
|
453
|
+
/* Retrieve all the results: */
|
454
|
+
child=item->child;
|
455
|
+
while (child && !fail)
|
456
|
+
{
|
457
|
+
ret=print_value(child,depth+1,fmt);
|
458
|
+
entries[i++]=ret;
|
459
|
+
if (ret) len+=strlen(ret)+2+(fmt?1:0); else fail=1;
|
460
|
+
child=child->next;
|
461
|
+
}
|
462
|
+
|
463
|
+
/* If we didn't fail, try to malloc the output string */
|
464
|
+
if (!fail) out=cJSON_malloc(len);
|
465
|
+
/* If that fails, we fail. */
|
466
|
+
if (!out) fail=1;
|
467
|
+
|
468
|
+
/* Handle failure. */
|
469
|
+
if (fail)
|
470
|
+
{
|
471
|
+
for (i=0;i<numentries;i++) if (entries[i]) cJSON_free(entries[i]);
|
472
|
+
cJSON_free(entries);
|
473
|
+
return 0;
|
474
|
+
}
|
475
|
+
|
476
|
+
/* Compose the output array. */
|
477
|
+
*out='[';
|
478
|
+
ptr=out+1;*ptr=0;
|
479
|
+
for (i=0;i<numentries;i++)
|
480
|
+
{
|
481
|
+
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
|
482
|
+
if (i!=numentries-1) {*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;}
|
483
|
+
cJSON_free(entries[i]);
|
484
|
+
}
|
485
|
+
cJSON_free(entries);
|
486
|
+
*ptr++=']';*ptr++=0;
|
487
|
+
return out;
|
488
|
+
}
|
489
|
+
|
490
|
+
/* Build an object from the text. */
|
491
|
+
static const char *parse_object(cJSON *item,const char *value)
|
492
|
+
{
|
493
|
+
cJSON *child;
|
494
|
+
if (*value!='{') return 0; /* not an object! */
|
495
|
+
|
496
|
+
item->type=cJSON_Object;
|
497
|
+
value=skip(value+1);
|
498
|
+
if (*value=='}') return value+1; /* empty array. */
|
499
|
+
|
500
|
+
item->child=child=cJSON_New_Item(item);
|
501
|
+
value=skip(parse_string(child,skip(value)));
|
502
|
+
if (!value) return 0;
|
503
|
+
child->string=child->valuestring;child->valuestring=0;
|
504
|
+
if (*value!=':') return 0; /* fail! */
|
505
|
+
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
|
506
|
+
if (!value) return 0;
|
507
|
+
|
508
|
+
while (*value==',')
|
509
|
+
{
|
510
|
+
cJSON *new_item;
|
511
|
+
if (!(new_item=cJSON_New_Item(item))) return 0; /* memory fail */
|
512
|
+
child->next=new_item;new_item->prev=child;child=new_item;
|
513
|
+
value=skip(parse_string(child,skip(value+1)));
|
514
|
+
if (!value) return 0;
|
515
|
+
child->string=child->valuestring;child->valuestring=0;
|
516
|
+
if (*value!=':') return 0; /* fail! */
|
517
|
+
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
|
518
|
+
if (!value) return 0;
|
519
|
+
}
|
520
|
+
|
521
|
+
if (*value=='}') return value+1; /* end of array */
|
522
|
+
return 0; /* malformed. */
|
523
|
+
}
|
524
|
+
|
525
|
+
/* Render an object to text. */
|
526
|
+
static char *print_object(cJSON *item,int depth,int fmt)
|
527
|
+
{
|
528
|
+
char **entries=0,**names=0;
|
529
|
+
char *out=0,*ptr,*ret,*str;size_t len=7; int i=0,j;
|
530
|
+
cJSON *child=item->child;
|
531
|
+
int numentries=0,fail=0;
|
532
|
+
/* Count the number of entries. */
|
533
|
+
while (child) numentries++,child=child->next;
|
534
|
+
/* Allocate space for the names and the objects */
|
535
|
+
entries=(char**)cJSON_malloc(numentries*sizeof(char*));
|
536
|
+
if (!entries) return 0;
|
537
|
+
names=(char**)cJSON_malloc(numentries*sizeof(char*));
|
538
|
+
if (!names) {cJSON_free(entries);return 0;}
|
539
|
+
memset(entries,0,sizeof(char*)*numentries);
|
540
|
+
memset(names,0,sizeof(char*)*numentries);
|
541
|
+
|
542
|
+
/* Collect all the results into our arrays: */
|
543
|
+
child=item->child;depth++;if (fmt) len+=depth;
|
544
|
+
while (child)
|
545
|
+
{
|
546
|
+
names[i]=str=print_string_ptr(child->string);
|
547
|
+
entries[i++]=ret=print_value(child,depth,fmt);
|
548
|
+
if (str && ret) len+=strlen(ret)+strlen(str)+2+(fmt?2+depth:0); else fail=1;
|
549
|
+
child=child->next;
|
550
|
+
}
|
551
|
+
|
552
|
+
/* Try to allocate the output string */
|
553
|
+
if (!fail) out=(char*)cJSON_malloc(len);
|
554
|
+
if (!out) fail=1;
|
555
|
+
|
556
|
+
/* Handle failure */
|
557
|
+
if (fail)
|
558
|
+
{
|
559
|
+
for (i=0;i<numentries;i++) {if (names[i]) free(names[i]);if (entries[i]) free(entries[i]);}
|
560
|
+
free(names);free(entries);
|
561
|
+
return 0;
|
562
|
+
}
|
563
|
+
|
564
|
+
/* Compose the output: */
|
565
|
+
*out='{';ptr=out+1;if (fmt)*ptr++='\n';*ptr=0;
|
566
|
+
for (i=0;i<numentries;i++)
|
567
|
+
{
|
568
|
+
if (fmt) for (j=0;j<depth;j++) *ptr++='\t';
|
569
|
+
strcpy(ptr,names[i]);ptr+=strlen(names[i]);
|
570
|
+
*ptr++=':';if (fmt) *ptr++='\t';
|
571
|
+
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
|
572
|
+
if (i!=numentries-1) *ptr++=',';
|
573
|
+
if (fmt) *ptr++='\n';*ptr=0;
|
574
|
+
cJSON_free(names[i]);cJSON_free(entries[i]);
|
575
|
+
}
|
576
|
+
|
577
|
+
cJSON_free(names);cJSON_free(entries);
|
578
|
+
if (fmt) for (i=0;i<depth-1;i++) *ptr++='\t';
|
579
|
+
*ptr++='}';*ptr++=0;
|
580
|
+
return out;
|
581
|
+
}
|
582
|
+
|
583
|
+
/* Get Array size/item / object item. */
|
584
|
+
int cJSON_GetArraySize(cJSON *array) {cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;}
|
585
|
+
cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c=array->child; while (c && item>0) item--,c=c->next; return c;}
|
586
|
+
cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;}
|
587
|
+
|
588
|
+
/* Utility for array list handling. */
|
589
|
+
static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}
|
590
|
+
/* Utility for handling references. */
|
591
|
+
static cJSON *create_reference(cJSON *item) {cJSON *ref=cJSON_New_Item(item);memcpy(ref,item,sizeof(cJSON));ref->string=0;ref->type|=cJSON_IsReference;ref->next=ref->prev=0;return ref;}
|
592
|
+
|
593
|
+
/* Add item to array/object. */
|
594
|
+
void cJSON_AddItemToArray(cJSON *array, cJSON *item) {cJSON *c=array->child;if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}}
|
595
|
+
void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);}
|
596
|
+
void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));}
|
597
|
+
void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
|
598
|
+
|
599
|
+
cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
|
600
|
+
if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;}
|
601
|
+
void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));}
|
602
|
+
cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}
|
603
|
+
void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}
|
604
|
+
|
605
|
+
/* Replace array/object items with new ones. */
|
606
|
+
void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
|
607
|
+
newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
|
608
|
+
if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);}
|
609
|
+
void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}}
|
610
|
+
|
611
|
+
/* Create basic types: */
|
612
|
+
cJSON *cJSON_CreateNull() {cJSON *item=cJSON_New_Item(0);item->type=cJSON_NULL;return item;}
|
613
|
+
cJSON *cJSON_CreateTrue() {cJSON *item=cJSON_New_Item(0);item->type=cJSON_True;return item;}
|
614
|
+
cJSON *cJSON_CreateFalse() {cJSON *item=cJSON_New_Item(0);item->type=cJSON_False;return item;}
|
615
|
+
cJSON *cJSON_CreateNumber(double num) {cJSON *item=cJSON_New_Item(0);item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int)num;return item;}
|
616
|
+
cJSON *cJSON_CreateString(const char *string) {cJSON *item=cJSON_New_Item(0);item->type=cJSON_String;item->valuestring=cJSON_strdup(string);return item;}
|
617
|
+
cJSON *cJSON_CreateArray() {cJSON *item=cJSON_New_Item(0);item->type=cJSON_Array;return item;}
|
618
|
+
cJSON *cJSON_CreateObject() {cJSON *item=cJSON_New_Item(0);item->type=cJSON_Object;return item;}
|
619
|
+
|
620
|
+
/* Create Arrays: */
|
621
|
+
cJSON *cJSON_CreateIntArray(int *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
622
|
+
cJSON *cJSON_CreateFloatArray(float *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
623
|
+
cJSON *cJSON_CreateDoubleArray(double *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
624
|
+
cJSON *cJSON_CreateStringArray(const char **strings,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|