├── .clang-format ├── .gitignore ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── README.markdown ├── RELEASE_NOTES.markdown ├── cmake ├── Modules │ ├── ConfigureDtrace.cmake │ ├── DistScript.cmake │ ├── DownloadLcbDep.cmake │ ├── FindCouchbaseHdrHistogram.cmake │ ├── FindCouchbaseLibev.cmake │ ├── FindCouchbaseLibevent.cmake │ ├── FindCouchbaseLibuv.cmake │ ├── FindProfiler.cmake │ ├── GenerateConfigDotH.cmake │ ├── GetLibcouchbaseFlags.cmake │ ├── GetPlatformCCInfo.cmake │ └── GetVersionInfo.cmake ├── build-timestamp.h.in ├── config-cmake.h.in ├── configure ├── defs.mk.in ├── dtrace-instr-link.pl ├── libcouchbase.stp.in └── source_files.cmake ├── configure.pl ├── contrib ├── HdrHistogram_c │ ├── .gitignore │ ├── CMakeLists.txt │ ├── COPYING.txt │ ├── LICENSE.txt │ ├── README.md │ ├── config.cmake.in │ └── src │ │ ├── CMakeLists.txt │ │ ├── hdr_atomic.h │ │ ├── hdr_encoding.c │ │ ├── hdr_encoding.h │ │ ├── hdr_endian.h │ │ ├── hdr_histogram.c │ │ ├── hdr_histogram.h │ │ ├── hdr_histogram_log.c │ │ ├── hdr_histogram_log.h │ │ ├── hdr_histogram_log_no_op.c │ │ ├── hdr_interval_recorder.c │ │ ├── hdr_interval_recorder.h │ │ ├── hdr_tests.h │ │ ├── hdr_thread.c │ │ ├── hdr_thread.h │ │ ├── hdr_time.c │ │ ├── hdr_time.h │ │ ├── hdr_writer_reader_phaser.c │ │ └── hdr_writer_reader_phaser.h ├── cJSON │ ├── cJSON.c │ └── cJSON.h ├── cbsasl │ ├── CMakeLists.txt │ ├── COPYING │ ├── include │ │ └── cbsasl │ │ │ └── cbsasl.h │ └── src │ │ ├── client.c │ │ ├── common.c │ │ ├── cram-md5 │ │ ├── hmac.c │ │ ├── hmac.h │ │ ├── md5.c │ │ └── md5.h │ │ ├── hash.c │ │ ├── hash.h │ │ ├── scram-sha │ │ ├── scram_utils.cc │ │ └── scram_utils.h │ │ └── util.h ├── cliopts │ ├── CMakeLists.txt │ ├── cliopts.c │ └── cliopts.h ├── gtest-1.8.1 │ ├── CHANGES │ ├── CMakeLists.txt │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── MINIFY.sh │ ├── README.md │ ├── cmake │ │ ├── Config.cmake.in │ │ ├── gtest.pc.in │ │ ├── gtest_main.pc.in │ │ └── internal_utils.cmake │ ├── include │ │ └── gtest │ │ │ ├── gtest-death-test.h │ │ │ ├── gtest-message.h │ │ │ ├── gtest-param-test.h │ │ │ ├── gtest-param-test.h.pump │ │ │ ├── gtest-printers.h │ │ │ ├── gtest-spi.h │ │ │ ├── gtest-test-part.h │ │ │ ├── gtest-typed-test.h │ │ │ ├── gtest.h │ │ │ ├── gtest_pred_impl.h │ │ │ ├── gtest_prod.h │ │ │ └── internal │ │ │ ├── custom │ │ │ ├── README.md │ │ │ ├── gtest-port.h │ │ │ ├── gtest-printers.h │ │ │ └── gtest.h │ │ │ ├── gtest-death-test-internal.h │ │ │ ├── gtest-filepath.h │ │ │ ├── gtest-internal.h │ │ │ ├── gtest-linked_ptr.h │ │ │ ├── gtest-param-util-generated.h │ │ │ ├── gtest-param-util-generated.h.pump │ │ │ ├── gtest-param-util.h │ │ │ ├── gtest-port-arch.h │ │ │ ├── gtest-port.h │ │ │ ├── gtest-string.h │ │ │ ├── gtest-tuple.h │ │ │ ├── gtest-tuple.h.pump │ │ │ ├── gtest-type-util.h │ │ │ └── gtest-type-util.h.pump │ └── src │ │ ├── gtest-all.cc │ │ ├── gtest-death-test.cc │ │ ├── gtest-filepath.cc │ │ ├── gtest-internal-inl.h │ │ ├── gtest-port.cc │ │ ├── gtest-printers.cc │ │ ├── gtest-test-part.cc │ │ ├── gtest-typed-test.cc │ │ ├── gtest.cc │ │ └── gtest_main.cc ├── http_parser │ ├── LICENSE-MIT │ ├── README.md │ ├── http_parser.c │ └── http_parser.h ├── jsonsl │ ├── LICENSE │ ├── jsonsl.c │ └── jsonsl.h ├── lcb-jsoncpp │ ├── CMakeLists.txt │ ├── LICENSE │ ├── lcb-jsoncpp-forwards.h │ ├── lcb-jsoncpp.cpp │ └── lcb-jsoncpp.h ├── snappy │ ├── CMakeLists.txt │ ├── COPYING │ ├── snappy-c.cc │ ├── snappy-c.h │ ├── snappy-internal.h │ ├── snappy-lcb-msvc.h │ ├── snappy-sinksource.cc │ ├── snappy-sinksource.h │ ├── snappy-stubs-internal.cc │ ├── snappy-stubs-internal.h │ ├── snappy-stubs-public.h │ ├── snappy.cc │ └── snappy.h └── win32-defs │ ├── iocpdefs.h │ ├── mingwdefs.h │ └── win_stdint.h ├── doc ├── Doxyfile ├── DoxygenLayout.xml ├── Makefile ├── apiattr.h ├── cbc-n1qlback.markdown ├── cbc-pillowfight.markdown ├── cbc-subdoc.markdown ├── cbc.markdown ├── cbcrc.markdown ├── common-additional-options.markdown ├── common-options.markdown ├── environment.h ├── footer.html ├── genman.sh ├── header.html ├── intro.h ├── mainpage.h ├── man │ ├── cbc-admin.1 │ ├── cbc-bucket-create.1 │ ├── cbc-bucket-delete.1 │ ├── cbc-cat.1 │ ├── cbc-connstr.1 │ ├── cbc-cp.1 │ ├── cbc-create.1 │ ├── cbc-decr.1 │ ├── cbc-flush.1 │ ├── cbc-hash.1 │ ├── cbc-incr.1 │ ├── cbc-lock.1 │ ├── cbc-mcversion.1 │ ├── cbc-n1ql.1 │ ├── cbc-n1qlback.1 │ ├── cbc-observe.1 │ ├── cbc-pillowfight.1 │ ├── cbc-ping.1 │ ├── cbc-rm.1 │ ├── cbc-role-list.1 │ ├── cbc-stats.1 │ ├── cbc-subdoc.1 │ ├── cbc-unlock.1 │ ├── cbc-user-delete.1 │ ├── cbc-user-list.1 │ ├── cbc-user-upsert.1 │ ├── cbc-verbosity.1 │ ├── cbc-version.1 │ ├── cbc-view.1 │ ├── cbc-watch.1 │ ├── cbc.1 │ └── cbcrc.4 └── style.css ├── example ├── CMakeLists.txt ├── README.markdown ├── analytics-deferred │ ├── .gitignore │ ├── analytics-deferred.c │ ├── cJSON.c │ └── cJSON.h ├── analytics-ingest │ ├── .gitignore │ ├── analytics-ingest.c │ ├── cJSON.c │ └── cJSON.h ├── analytics │ ├── .gitignore │ ├── analytics.c │ ├── build-queries.rb │ ├── cJSON.c │ ├── cJSON.h │ ├── queries.h │ └── queries │ │ ├── 00-show-dataverse.json │ │ ├── 01-setup-dataset-breweries.json │ │ ├── 02-setup-dataset-beers.json │ │ ├── 03-initiate-shadow.json │ │ ├── 04-list-datasets.json │ │ ├── 05-count-breweries.json │ │ ├── 06-first-brewery.json │ │ ├── 07-key-based-lookup.json │ │ ├── 08-exact-match-lookup.json │ │ ├── 09-exact-match-lookup-different-shape.json │ │ ├── 10-other-query-filters.json │ │ ├── 11-equijoin.json │ │ ├── 12-equijoin-select-star.json │ │ ├── 13-ansi-join.json │ │ ├── 14-join-select-values.json │ │ ├── 15-nested-outer-join.json │ │ ├── 16-theta-join.json │ │ ├── 17-existential-quantification.json │ │ ├── 18-universal-quantification.json │ │ ├── 19-simple-aggregation.json │ │ ├── 20-simple-aggregation-unwrapped-value.json │ │ ├── 21-simple-aggregation-explicit.json │ │ ├── 22-grouping-and-aggregation.json │ │ ├── 23-grouping-and-aggregation-with-hint.json │ │ ├── 24-grouping-and-limits.json │ │ ├── 25-named-parameters.json │ │ └── 26-positional-parameters.json ├── crypto │ ├── .gitignore │ ├── Makefile │ ├── common_provider.c │ ├── common_provider.h │ ├── openssl_symmetric_decrypt.c │ ├── openssl_symmetric_encrypt.c │ ├── openssl_symmetric_provider.c │ └── openssl_symmetric_provider.h ├── db │ ├── db.c │ ├── dbx.cc │ └── vb.c ├── fts │ ├── .gitignore │ ├── build-queries.rb │ ├── fts.c │ ├── queries.h │ └── queries │ │ ├── 00-simple-text-query.json │ │ ├── 01-simple-text-query-on-non-default-index.json │ │ ├── 02-simple-text-query-on-stored-field.json │ │ ├── 03-match-query-with-facet.json │ │ ├── 04-docid-query.json │ │ ├── 05-unanalyzed-term-query-with-fuzziness-level-of-0.json │ │ ├── 06-unanalyzed-term-query-with-fuzziness-level-of-2.json │ │ ├── 07-match-phrase-query.json │ │ ├── 08-phrase-query.json │ │ ├── 09-query-string-query.json │ │ ├── 10-conjunction-query.json │ │ ├── 11-wild-card-query.json │ │ ├── 12-numeric-range-query.json │ │ └── 13-regexp-query.json ├── instancepool │ ├── main.cc │ ├── pool.cc │ └── pool.h ├── libeventdirect │ └── main.c ├── libuvdirect │ └── main.c ├── management │ └── eventing.cc ├── mcc │ └── mcc.cc ├── metrics │ └── otel_metrics.cc ├── minimal │ ├── .gitignore │ ├── cJSON.c │ ├── cJSON.h │ ├── durability.cc │ ├── g3cp-async.c │ ├── g3cp.c │ ├── logger.c │ ├── minimal.c │ └── query.c ├── subdoc │ ├── subdoc-multi.cc │ ├── subdoc-simple.cc │ ├── subdoc-tombstone.cc │ └── subdoc-xattrs.c ├── threads-private │ └── threads-private.c ├── threads-shared │ └── threads-shared.c ├── tick │ └── tick.c ├── tracing │ ├── .gitignore │ ├── Makefile │ ├── cJSON.c │ ├── cJSON.h │ ├── otel_tracing.cc │ ├── tracing.c │ └── views.c ├── users │ ├── README │ └── users.c └── views │ └── views-example.cc ├── include ├── libcouchbase │ ├── assert.h │ ├── auth.h │ ├── cntl-private.h │ ├── cntl.h │ ├── configuration.h.in │ ├── couchbase.h │ ├── crypto.h │ ├── error.h │ ├── iometrics.h │ ├── iops.h │ ├── ixmgmt.h │ ├── kvbuf.h │ ├── logger.h │ ├── metrics.h │ ├── pktfwd.h │ ├── plugins │ │ └── io │ │ │ ├── bsdio-inl.c │ │ │ ├── wsaerr-inl.c │ │ │ └── wsaerr.h │ ├── sysdefs.h │ ├── tracing.h │ ├── utils.h │ ├── vbucket.h │ └── visibility.h └── memcached │ ├── COPYING │ ├── README │ └── protocol_binary.h ├── packaging ├── README ├── abicheck │ ├── .gitignore │ ├── Makefile │ ├── README.md │ └── template.xml.erb ├── deb │ ├── compat │ ├── control │ ├── copyright │ ├── libcouchbase-dev.docs │ ├── package.mk │ ├── rules │ └── source │ │ └── format ├── distinfo │ ├── README │ └── distinfo.cmake.in ├── dllversion.rc.in ├── libcouchbase.pc.in ├── nuget │ └── libcouchbase.autopkg ├── parse-git-describe.pl └── rpm │ ├── libcouchbase.spec.in │ └── package.mk ├── plugins └── io │ ├── iocp │ ├── CMakeLists.txt │ ├── iocp_iops.c │ ├── iocp_iops.h │ ├── iocp_loop.c │ ├── iocp_timer.c │ └── iocp_util.c │ ├── libev │ ├── CMakeLists.txt │ ├── libev_io_opts.h │ └── plugin-libev.c │ ├── libevent │ ├── CMakeLists.txt │ ├── libevent_io_opts.h │ └── plugin-libevent.c │ ├── libuv │ ├── CMakeLists.txt │ ├── libuv_compat.h │ ├── libuv_io_opts.h │ ├── plugin-internal.h │ └── plugin-libuv.c │ └── select │ ├── CMakeLists.txt │ ├── plugin-select.c │ └── select_io_opts.h ├── src ├── README.md ├── analytics │ ├── analytics.cc │ ├── analytics_handle.cc │ └── analytics_handle.hh ├── aspend.h ├── auth-priv.h ├── auth.cc ├── bootstrap.cc ├── bootstrap.h ├── bucketconfig │ ├── bc_cccp.cc │ ├── bc_file.cc │ ├── bc_http.cc │ ├── bc_http.h │ ├── bc_static.cc │ ├── clconfig.h │ └── confmon.cc ├── callbacks.c ├── capi │ ├── cmd_analytics.cc │ ├── cmd_analytics.hh │ ├── cmd_counter.hh │ ├── cmd_diag.hh │ ├── cmd_endure.hh │ ├── cmd_exists.hh │ ├── cmd_get.hh │ ├── cmd_get_replica.hh │ ├── cmd_getcid.hh │ ├── cmd_getmanifest.hh │ ├── cmd_http.hh │ ├── cmd_noop.hh │ ├── cmd_observe.hh │ ├── cmd_observe_seqno.hh │ ├── cmd_ping.hh │ ├── cmd_query.cc │ ├── cmd_query.hh │ ├── cmd_remove.hh │ ├── cmd_search.cc │ ├── cmd_search.hh │ ├── cmd_stats.hh │ ├── cmd_store.hh │ ├── cmd_subdoc.hh │ ├── cmd_touch.hh │ ├── cmd_unlock.hh │ ├── cmd_view.cc │ ├── cmd_view.hh │ ├── collection_qualifier.hh │ ├── deferred_command_context.hh │ └── key_value_error_context.hh ├── cntl.cc ├── collections.cc ├── collections.h ├── config_static.h ├── connspec.cc ├── connspec.h ├── crypto.cc ├── ctx-log-inl.h ├── defer.cc ├── defer.h ├── dns-srv.cc ├── docreq │ ├── docreq.cc │ └── docreq.h ├── dump.cc ├── errmap.cc ├── errmap.h ├── getconfig.cc ├── gethrtime.c ├── handler.cc ├── hdr_timings.c ├── hostlist.cc ├── hostlist.h ├── http │ ├── http-priv.h │ ├── http.cc │ ├── http.h │ └── http_io.cc ├── instance.cc ├── internal.h ├── internalstructs.h ├── iofactory.c ├── iometrics.cc ├── jsparse │ ├── parser.cc │ └── parser.h ├── lcbht │ ├── lcbht.cc │ └── lcbht.h ├── lcbio │ ├── connect.cc │ ├── connect.h │ ├── ctx.cc │ ├── ctx.h │ ├── iotable.c │ ├── iotable.h │ ├── ioutils.cc │ ├── ioutils.h │ ├── lcbio.h │ ├── manager.cc │ ├── manager.h │ ├── protoctx.cc │ ├── rw-inl.h │ ├── ssl.h │ ├── timer-cxx.h │ ├── timer-ng.h │ └── timer.cc ├── list.c ├── list.h ├── logging.c ├── logging.h ├── mc │ ├── compress.cc │ ├── compress.h │ ├── forward.c │ ├── forward.h │ ├── iovcursor-inl.h │ ├── iovcursor.h │ ├── mcreq-flush-inl.h │ ├── mcreq.c │ └── mcreq.h ├── mcserver │ ├── mcserver.cc │ ├── mcserver.h │ ├── negotiate.cc │ └── negotiate.h ├── mctx-helper.h ├── metrics │ ├── caching_meter.cc │ ├── caching_meter.hh │ ├── logging_meter.cc │ ├── logging_meter.hh │ ├── metrics-internal.cc │ ├── metrics-internal.h │ └── metrics.cc ├── mutation_token.hh ├── n1ql │ ├── ixmgmt.cc │ ├── n1ql-internal.cc │ ├── n1ql-internal.h │ ├── n1ql.cc │ ├── query_cache.hh │ ├── query_handle.cc │ ├── query_handle.hh │ ├── query_utils.cc │ └── query_utils.hh ├── netbuf │ ├── netbuf-defs.h │ ├── netbuf-mblock.h │ ├── netbuf.c │ └── netbuf.h ├── newconfig.cc ├── nodeinfo.cc ├── operations │ ├── cbflush.cc │ ├── counter.cc │ ├── durability-seqno.cc │ ├── durability.cc │ ├── durability_internal.h │ ├── exists.cc │ ├── get.cc │ ├── get_replica.cc │ ├── observe-seqno.cc │ ├── observe.cc │ ├── ping.cc │ ├── pktfwd.cc │ ├── remove.cc │ ├── stats.cc │ ├── store.cc │ ├── subdoc.cc │ ├── touch.cc │ └── unlock.cc ├── packetutils.h ├── probes.d ├── rdb │ ├── bigalloc.c │ ├── bigalloc.h │ ├── chunkalloc.c │ ├── libcalloc.c │ ├── rope.c │ └── rope.h ├── retrychk.cc ├── retryq.cc ├── retryq.h ├── ringbuffer.c ├── ringbuffer.h ├── rnd.cc ├── rnd.h ├── search │ ├── search.cc │ ├── search_handle.cc │ └── search_handle.hh ├── settings.cc ├── settings.h ├── sllist-inl.h ├── sllist.h ├── ssl │ ├── CMakeLists.txt │ ├── ssl_c.c │ ├── ssl_common.c │ ├── ssl_e.c │ └── ssl_iot_common.h ├── strcodecs │ ├── base64.cc │ └── strcodecs.h ├── timings.c ├── trace.h ├── tracing │ ├── span.cc │ ├── threshold_logging_tracer.cc │ ├── tracer.cc │ └── tracing-internal.h ├── utilities.cc ├── utilities.h ├── vbucket │ ├── CMakeLists.txt │ ├── aliases.h │ ├── crc32.h │ ├── hash.h │ ├── json-inl.h │ ├── ketama.c │ ├── rfc1321 │ │ ├── global.h │ │ ├── md5.h │ │ └── md5c-inl.h │ └── vbucket.c ├── views │ ├── view.cc │ ├── view_handle.cc │ └── view_handle.hh └── wait.cc ├── tests ├── CMakeLists.txt ├── basic │ ├── t_analytics.cc │ ├── t_base64.cc │ ├── t_ccbc103.cc │ ├── t_connstr.cc │ ├── t_creds.cc │ ├── t_ctlcodes.cc │ ├── t_host.cc │ ├── t_jsparse.cc │ ├── t_jsparse.h │ ├── t_list.cc │ ├── t_logger.cc │ ├── t_misc.cc │ ├── t_n1qlstrings.cc │ ├── t_netbuf.cc │ ├── t_packet.cc │ ├── t_ringbuffer.cc │ ├── t_scram.cc │ ├── t_slist.cc │ └── t_urlencode.cc ├── check-all.cc ├── htparse │ └── t_basic.cc ├── ioserver │ ├── connection.cc │ ├── future.cc │ ├── ioserver.cc │ ├── ioserver.h │ ├── socket.cc │ ├── ssl_connection.cc │ ├── threads-pthreads.cc │ ├── threads-win32.cc │ └── threads.h ├── iotests │ ├── iotests.h │ ├── mock-environment.cc │ ├── mock-environment.h │ ├── mock-unit-test.cc │ ├── mock-unit-test.h │ ├── serverparams.h │ ├── t_arithmetic.cc │ ├── t_behavior.cc │ ├── t_collections.cc │ ├── t_configcache.cc │ ├── t_confmon.cc │ ├── t_durability.cc │ ├── t_eerrs.cc │ ├── t_errmap.cc │ ├── t_forward.cc │ ├── t_get.cc │ ├── t_http.cc │ ├── t_iops.cc │ ├── t_lock.cc │ ├── t_misc.cc │ ├── t_mutate.cc │ ├── t_n1ql.cc │ ├── t_netfail.cc │ ├── t_obseqno.cc │ ├── t_ratelimit.cc │ ├── t_regression.cc │ ├── t_sched.cc │ ├── t_serverops.cc │ ├── t_smoke.cc │ ├── t_snappy.cc │ ├── t_subdoc.cc │ ├── t_views.cc │ ├── testutil.cc │ └── testutil.h ├── mc │ ├── mctest.h │ ├── pktmaker.h │ ├── t_alloc.cc │ ├── t_context.cc │ ├── t_flush.cc │ ├── t_forward.cc │ ├── t_ioflush.cc │ └── t_iovcursor.cc ├── mocksupport │ ├── procutil.c │ ├── procutil.h │ ├── server.c │ ├── server.h │ └── timeout.c ├── nonio_tests.cc ├── rdb │ ├── rdbtest.h │ ├── t_basic.cc │ ├── t_bigalloc.cc │ └── t_refs.cc ├── socktests │ ├── socktest.cc │ ├── socktest.h │ ├── t_basic.cc │ ├── t_ctx.cc │ ├── t_manager.cc │ ├── t_putex.cc │ ├── t_read.cc │ ├── t_reentrant.cc │ ├── t_ssl.cc │ └── t_write.cc ├── start_mock.bat ├── start_mock.sh.in ├── unit_tests.cc └── vbucket │ ├── confdata │ ├── bad.json │ ├── full_25.json │ ├── ketama_expected.json │ ├── map_node_present_nodesext_missing_nodes.json │ ├── memd_25.json │ ├── memd_30.json │ ├── memd_45.json │ ├── memd_ketama_config.json │ ├── terse_25.json │ ├── terse_30.json │ └── terse_long_hostname.json │ └── t_config.cc └── tools ├── CMakeLists.txt ├── cbc-gen.cc ├── cbc-handlers.h ├── cbc-n1qlback.cc ├── cbc-pillowfight.cc ├── cbc-proxy.cc ├── cbc-subdoc.cc ├── cbc-timestamp.cc ├── cbc-timestamp.h ├── cbc.cc ├── check-clang-format ├── check-clang-static-analyzer ├── common ├── histogram.cc ├── histogram.h ├── options.cc └── options.h ├── docgen ├── docgen.h ├── loc.h ├── placeholders.h └── seqgen.h ├── extract-packets.rb ├── gen-script.txt ├── gen ├── lexer.c ├── lexer.h └── lexer.re ├── jenkins ├── check-clang-format ├── check-clang-static-analyzer └── scan-build-add-exclude-switch.patch └── linenoise ├── linenoise.c └── linenoise.h /.clang-format: -------------------------------------------------------------------------------- 1 | # -*- mode: yaml; -*- 2 | 3 | BasedOnStyle: LLVM 4 | IndentWidth: 4 5 | BreakBeforeBraces: Linux 6 | ColumnLimit: 120 7 | AllowShortFunctionsOnASingleLine: Empty 8 | SortIncludes: false 9 | IndentCaseLabels: true 10 | SpacesInAngles: false 11 | AlwaysBreakTemplateDeclarations: Yes 12 | -------------------------------------------------------------------------------- /cmake/Modules/ConfigureDtrace.cmake: -------------------------------------------------------------------------------- 1 | FIND_PROGRAM(DTRACE dtrace) 2 | IF(DTRACE) 3 | SET(LCB_DTRACE_HEADER "${LCB_GENSRCDIR}/probes.h") 4 | SET(LCB_DTRACE_SRC "${PROJECT_SOURCE_DIR}/src/probes.d") 5 | 6 | # Generate probes.h 7 | EXECUTE_PROCESS(COMMAND ${DTRACE} -C -h -s ${LCB_DTRACE_SRC} -o ${LCB_DTRACE_HEADER} 8 | RESULT_VARIABLE _rv) 9 | IF(NOT ${_rv} EQUAL 0) 10 | MESSAGE(WARNING "Could not execute DTrace. DTrace support will be disabled!") 11 | RETURN() 12 | ENDIF() 13 | 14 | # Fix probes.h on FreeBSD 15 | IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") 16 | FIND_PROGRAM(SED sed) 17 | EXECUTE_PROCESS(COMMAND ${SED} -i.tmp "s/, *char \\*/, const char \\*/g" ${LCB_DTRACE_HEADER} 18 | RESULT_VARIABLE _rv) 19 | IF(NOT ${_rv} EQUAL 0) 20 | MESSAGE(WARNING "Could not execute sed to update dtrace-generated header. DTrace support will be disabled!") 21 | RETURN() 22 | ENDIF() 23 | ENDIF() 24 | 25 | ADD_DEFINITIONS(-DHAVE_DTRACE) 26 | IF(NOT APPLE) 27 | SET(LCB_DTRACE_OBJECT "${LCB_GENSRCDIR}/probes.o") 28 | IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") 29 | SET(LCB_DTRACE_OPTIONS "-k") 30 | ENDIF() 31 | # Generate probes.o 32 | IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") 33 | SET(LCB_DTRACE_INSTRO ON) 34 | UNSET(LCB_DTRACE_OBJECT) 35 | ELSE() 36 | ADD_CUSTOM_COMMAND(OUTPUT ${LCB_DTRACE_OBJECT} 37 | DEPENDS ${LCB_DTRACE_SRC} 38 | COMMAND ${DTRACE} -C -G ${LCB_DTRACE_OPTIONS} -s ${LCB_DTRACE_SRC} -o ${LCB_DTRACE_OBJECT}) 39 | ENDIF() 40 | ENDIF() 41 | 42 | FIND_PROGRAM(STAP stap) 43 | IF(STAP) 44 | SET(LCB_TAPSET_ROOT ${CMAKE_INSTALL_PREFIX}/share/systemtap/tapset) 45 | CONFIGURE_FILE( 46 | ${PROJECT_SOURCE_DIR}/cmake/libcouchbase.stp.in 47 | ${LCB_GENSRCDIR}/libcouchbase.so.${LCB_SONAME_FULL}.stp) 48 | INSTALL( 49 | FILES ${LCB_GENSRCDIR}/libcouchbase.so.${LCB_SONAME_FULL}.stp 50 | DESTINATION ${LCB_TAPSET_ROOT}) 51 | ENDIF() 52 | ENDIF() 53 | -------------------------------------------------------------------------------- /cmake/Modules/DistScript.cmake: -------------------------------------------------------------------------------- 1 | EXECUTE_PROCESS( 2 | COMMAND ${CMAKE_COMMAND} --build . --config Debug) 3 | 4 | EXECUTE_PROCESS( 5 | COMMAND ${CMAKE_COMMAND} --build . --config RelWithDebInfo) 6 | 7 | EXECUTE_PROCESS( 8 | COMMAND ${CMAKE_COMMAND} 9 | -DCMAKE_INSTALL_CONFIG_NAME=Debug 10 | -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} 11 | -P cmake_install.cmake) 12 | 13 | EXECUTE_PROCESS( 14 | COMMAND ${CMAKE_COMMAND} 15 | -DCMAKE_INSTALL_CONFIG_NAME=RelWithDebInfo 16 | -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} 17 | -P cmake_install.cmake) 18 | -------------------------------------------------------------------------------- /cmake/Modules/DownloadLcbDep.cmake: -------------------------------------------------------------------------------- 1 | # DownloadLcbDeb(url location) 2 | MACRO(DOWNLOAD_LCB_DEP url dest) 3 | FIND_PROGRAM(WGET wget) 4 | FIND_PROGRAM(CURL curl) 5 | IF(CURL) 6 | EXECUTE_PROCESS(COMMAND "${CURL}" "${url}" -L -o "${dest}" RESULT_VARIABLE DLRC) 7 | ELSEIF(WGET) 8 | EXECUTE_PROCESS(COMMAND "${WGET}" "${url}" -O "${dest}" RESULT_VARIABLE DLRC) 9 | ENDIF() 10 | IF(NOT DLRC EQUAL 0) 11 | MESSAGE(WARNING "Using buggy built-in CMake downloader") 12 | FILE(DOWNLOAD ${url} ${dest} INACTIVITY_TIMEOUT 30 SHOW_PROGRESS STATUS RET) 13 | LIST(GET RET 0 DLRC) 14 | ENDIF() 15 | IF(NOT DLRC EQUAL 0) 16 | MESSAGE(FATAL_ERROR "Failed to download ${url}") 17 | ENDIF() 18 | ENDMACRO() 19 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseHdrHistogram.cmake: -------------------------------------------------------------------------------- 1 | FIND_PATH(HDR_HISTOGRAM_INCLUDES hdr_histogram.h 2 | HINTS ENV HDR_HISTOGRAM_DIR 3 | PATH_SUFFIXES include/hdr 4 | PATHS 5 | /usr/local) 6 | FIND_LIBRARY(HDR_HISTOGRAM_LIBRARIES NAMES hdr_histogram 7 | HINTS ENV HDR_HISTOGRAM_DIR 8 | PATH_SUFFIXES lib 9 | PATHS 10 | /usr/local) 11 | IF(HDR_HISTOGRAM_LIBRARIES AND HDR_HISTOGRAM_INCLUDES) 12 | SET(HDR_HISTOGRAM_FOUND TRUE) 13 | ELSE() 14 | SET(HDR_HISTOGRAM_FOUND FALSE) 15 | ENDIF() 16 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseLibev.cmake: -------------------------------------------------------------------------------- 1 | # Locate libev library 2 | # This module defines 3 | # HAVE_LIBEV, if false, do not try to link with libev 4 | # LIBEV_LIBRARIES, Library path and libs 5 | # LIBEV_INCLUDE_DIR, where to find the libev headers 6 | 7 | FIND_PATH(LIBEV_INCLUDE_DIR ev.h 8 | PATHS ${LIBEV_ROOT} 9 | PATH_SUFFIXES include libev 10 | NO_DEFAULT_PATH) 11 | 12 | FIND_LIBRARY(LIBEV_LIBRARIES 13 | NAMES ev libev 14 | PATHS ${LIBEV_ROOT} 15 | PATH_SUFFIXES lib libev 16 | NO_DEFAULT_PATH) 17 | 18 | FIND_PATH(LIBEV_INCLUDE_DIR ev.h 19 | HINTS 20 | ENV LIBEV_DIR 21 | PATH_SUFFIXES include include/libev 22 | PATHS 23 | ${DEPS_INCLUDE_DIR} 24 | ~/Library/Frameworks 25 | /Library/Frameworks 26 | /opt/local 27 | /opt/csw 28 | /opt/libev 29 | /opt) 30 | 31 | FIND_LIBRARY(LIBEV_LIBRARIES 32 | NAMES ev libev 33 | HINTS 34 | ENV LIBEV_DIR 35 | PATH_SUFFIXES lib libev 36 | PATHS 37 | ${DEPS_LIB_DIR} 38 | ~/Library/Frameworks 39 | /Library/Frameworks 40 | /opt/local 41 | /opt/csw 42 | /opt/libev 43 | /opt) 44 | 45 | IF (LIBEV_LIBRARIES AND LIBEV_INCLUDE_DIR) 46 | SET(HAVE_LIBEV true) 47 | MESSAGE(STATUS "Found libev in ${LIBEV_INCLUDE_DIR} : ${LIBEV_LIBRARIES}") 48 | ELSE (LIBEV_LIBRARIES) 49 | SET(HAVE_LIBEV false) 50 | ENDIF (LIBEV_LIBRARIES AND LIBEV_INCLUDE_DIR) 51 | 52 | INCLUDE(CMakePushCheckState) 53 | INCLUDE(CheckFunctionExists) 54 | IF(HAVE_LIBEV) 55 | CMAKE_PUSH_CHECK_STATE() 56 | SET(CMAKE_REQUIRED_FLAGS "-I${LIBEV_INCLUDE_DIR}") 57 | SET(CMAKE_REQUIRED_LIBRARIES ${LIBEV_LIBRARIES}) 58 | SET(CMAKE_REQUIRED_INCLUDES "ev.h") 59 | CHECK_FUNCTION_EXISTS(ev_loop HAVE_LIBEV3) 60 | IF(NOT HAVE_LIBEV3) 61 | CHECK_FUNCTION_EXISTS(ev_run HAVE_LIBEV4) 62 | ENDIF() 63 | CMAKE_POP_CHECK_STATE() 64 | IF(HAVE_LIBEV3) 65 | MESSAGE(STATUS "libev3 found") 66 | ELSEIF(HAVE_LIBEV4) 67 | MESSAGE(STATUS "libev4 found") 68 | ELSE() 69 | MESSAGE(STATUS "libev not found") 70 | ENDIF() 71 | ENDIF() 72 | 73 | MARK_AS_ADVANCED(HAVE_LIBEV LIBEV_INCLUDE_DIR LIBEV_LIBRARIES) 74 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseLibevent.cmake: -------------------------------------------------------------------------------- 1 | # Locate libevent library 2 | # This module defines 3 | # HAVE_LIBEVENT, if false, do not try to link with libevent 4 | # LIBEVENT_LIBRARIES, Library path and libs 5 | # LIBEVENT_INCLUDE_DIR, where to find the ICU headers 6 | # HAVE_LIBEVENT 7 | # HAVE_LIBEVENT2 8 | 9 | FIND_PATH(LIBEVENT_INCLUDE_DIR evutil.h 10 | HINTS 11 | ${LIBEVENT_ROOT} 12 | ENV LIBEVENT_DIR 13 | PATH_SUFFIXES include 14 | PATHS 15 | ${DEPS_INCLUDE_DIR} 16 | ~/Library/Frameworks 17 | /Library/Frameworks 18 | /opt/local 19 | /opt/csw 20 | /opt/libevent 21 | /opt) 22 | 23 | FIND_LIBRARY(LIBEVENT_LIBRARIES 24 | NAMES event_core libevent_core 25 | HINTS 26 | ${LIBEVENT_ROOT} 27 | ENV LIBEVENT_DIR 28 | PATHS 29 | ${DEPS_LIB_DIR} 30 | ~/Library/Frameworks 31 | /Library/Frameworks 32 | /opt/local 33 | /opt/csw 34 | /opt/libevent 35 | /opt) 36 | 37 | INCLUDE(CMakePushCheckState) 38 | INCLUDE(CheckFunctionExists) 39 | 40 | IF (LIBEVENT_LIBRARIES AND LIBEVENT_INCLUDE_DIR) 41 | SET(HAVE_LIBEVENT true) 42 | MESSAGE(STATUS "Found libevent in ${LIBEVENT_INCLUDE_DIR} : ${LIBEVENT_LIBRARIES}") 43 | CMAKE_PUSH_CHECK_STATE() 44 | SET(CMAKE_REQUIRED_FLAGS "-I${LIBEVENT_INCLUDE_DIR}") 45 | SET(CMAKE_REQUIRED_INCLUDES "event2/event.h") 46 | SET(CMAKE_REQUIRED_LIBRARIES ${LIBEVENT_LIBRARIES}) 47 | CHECK_FUNCTION_EXISTS(event_new HAVE_LIBEVENT2) 48 | CMAKE_POP_CHECK_STATE() 49 | 50 | ELSE (LIBEVENT_LIBRARIES) 51 | SET(HAVE_LIBEVENT false) 52 | ENDIF (LIBEVENT_LIBRARIES AND LIBEVENT_INCLUDE_DIR) 53 | 54 | MARK_AS_ADVANCED(HAVE_LIBEVENT LIBEVENT_INCLUDE_DIR LIBEVENT_LIBRARIES) 55 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseLibuv.cmake: -------------------------------------------------------------------------------- 1 | # Locate libuvent library 2 | # This module defines 3 | # HAVE_LIBUV, if false, do not try to link with libuvent 4 | # LIBUV_LIBRARIES, Library path and libs 5 | # LIBUV_INCLUDE_DIR, where to find the ICU headers 6 | 7 | FIND_PATH(LIBUV_INCLUDE_DIR uv.h 8 | HINTS 9 | ${LIBUV_ROOT} 10 | PATH_SUFFIXES include 11 | PATHS 12 | ~/Library/Frameworks 13 | /Library/Frameworks 14 | /opt/local 15 | /opt/csw 16 | /opt/libuv 17 | /opt) 18 | MESSAGE(STATUS "Found UV include dir: ${LIBUV_INCLUDE_DIR}") 19 | 20 | IF(WIN32) 21 | FIND_LIBRARY(LIBUV_LIBRARIES_DEBUG 22 | NAMES uv libuv 23 | HINTS ${LIBUV_ROOT} 24 | PATH_SUFFIXES Debug Debug/lib) 25 | 26 | FIND_LIBRARY(LIBUV_LIBRARIES_OPTIMIZED 27 | NAMES uv libuv 28 | HINTS ${LIBUV_ROOT} 29 | PATH_SUFFIXES Release Release/lib) 30 | 31 | SET(LIBUV_LIBRARIES 32 | OPTIMIZED ${LIBUV_LIBRARIES_OPTIMIZED} 33 | DEBUG ${LIBUV_LIBRARIES_DEBUG}) 34 | 35 | ELSE() 36 | FIND_LIBRARY(LIBUV_LIBRARIES 37 | NAMES uv 38 | HINTS ${LIBUV_ROOT} 39 | PATH_SUFFIXES lib 40 | PATHS 41 | ~/Library/Frameworks 42 | /Library/Frameworks 43 | /opt/local 44 | /opt/csw 45 | /opt/libuv 46 | /opt) 47 | ENDIF(WIN32) 48 | 49 | 50 | IF (LIBUV_LIBRARIES) 51 | SET(HAVE_LIBUV true) 52 | MESSAGE(STATUS "Found libuv in ${LIBUV_INCLUDE_DIR} : ${LIBUV_LIBRARIES}") 53 | ELSE (LIBUV_LIBRARIES) 54 | SET(HAVE_LIBUV false) 55 | ENDIF (LIBUV_LIBRARIES) 56 | 57 | MARK_AS_ADVANCED(HAVE_LIBUV LIBUV_INCLUDE_DIR LIBUV_LIBRARIES LIBUV_ROOT) 58 | -------------------------------------------------------------------------------- /cmake/Modules/FindProfiler.cmake: -------------------------------------------------------------------------------- 1 | FIND_LIBRARY(LIBPROFILER 2 | NAMES profiler 3 | HINTS 4 | ENV LIBPROFILER_DIR 5 | PATHS 6 | ${DEPS_LIB_DIR} 7 | ~/Library/Frameworks 8 | /Library/Frameworks 9 | /opt/local 10 | /opt) 11 | 12 | IF(LIBPROFILER) 13 | MESSAGE(STATUS "Found libprofiler: ${LIBPROFILER}") 14 | ELSE() 15 | MESSAGE(FATAL_ERROR "Unable to find gperftools libprofiler, Try disabling LCB_USE_PROFILER option of CMake.") 16 | ENDIF() 17 | -------------------------------------------------------------------------------- /cmake/Modules/GenerateConfigDotH.cmake: -------------------------------------------------------------------------------- 1 | # Writes the 'config.h' header.. 2 | INCLUDE(CheckFunctionExists) 3 | INCLUDE(CheckIncludeFiles) 4 | INCLUDE(CheckSymbolExists) 5 | 6 | IF(UNIX) 7 | CHECK_FUNCTION_EXISTS(gethrtime HAVE_GETHRTIME) 8 | CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY) 9 | CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) 10 | CHECK_FUNCTION_EXISTS(setitimer HAVE_SETITIMER) 11 | CHECK_SYMBOL_EXISTS(htonll arpa/inet.h HAVE_HTONLL) 12 | CHECK_SYMBOL_EXISTS(res_search "netinet/in.h;resolv.h" HAVE_RES_SEARCH) 13 | CHECK_INCLUDE_FILES(dlfcn.h HAVE_DLFCN_H) 14 | CHECK_INCLUDE_FILES(netdb.h HAVE_NETDB_H) 15 | CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H) 16 | CHECK_INCLUDE_FILES(stddef.h HAVE_STDDEF_H) 17 | CHECK_INCLUDE_FILES(strings.h HAVE_STRINGS_H) 18 | CHECK_INCLUDE_FILES(sys/socket.h HAVE_SYS_SOCKET_H) 19 | CHECK_INCLUDE_FILES(sys/stat.h HAVE_SYS_STAT_H) 20 | CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H) 21 | CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H) 22 | CHECK_INCLUDE_FILES(sys/uio.h HAVE_SYS_UIO_H) 23 | CHECK_INCLUDE_FILES(fcntl.h HAVE_FCNTL_H) 24 | CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H) 25 | CHECK_INCLUDE_FILES(arpa/inet.h HAVE_ARPA_INET_H) 26 | CHECK_INCLUDE_FILES(inttypes.h HAVE_INTTYPES_H) 27 | CHECK_INCLUDE_FILES(arpa/nameser.h HAVE_ARPA_NAMESER_H) 28 | ENDIF() 29 | 30 | IF (WIN32) 31 | CHECK_FUNCTION_EXISTS(_ftime64_s HAVE__FTIME64_S) 32 | ENDIF() 33 | 34 | CONFIGURE_FILE( 35 | ${PROJECT_SOURCE_DIR}/cmake/config-cmake.h.in 36 | ${LCB_GENSRCDIR}/config.h) 37 | CONFIGURE_FILE( 38 | ${PROJECT_SOURCE_DIR}/cmake/build-timestamp.h.in 39 | ${LCB_GENSRCDIR}/build-timestamp.h) 40 | -------------------------------------------------------------------------------- /cmake/Modules/GetPlatformCCInfo.cmake: -------------------------------------------------------------------------------- 1 | # Gets string/platform information about the specific compiler 2 | # Defines: 3 | # LCB_CC_STRING for the C compiler string (i.e. "msvc", "mingw") 4 | # LCB_ARCH_STRING for the target architecture, e.g. "x86" 5 | 6 | # Figure out how we're building! 7 | IF(MSVC) 8 | IF(CMAKE_CL_64) 9 | SET(LCB_ARCH_STRING "amd64") 10 | ELSE() 11 | SET(LCB_ARCH_STRING "x86") 12 | ENDIF(CMAKE_CL_64) 13 | 14 | IF(MSVC80) 15 | SET(LCB_CC_STRING "vs8") 16 | ELSEIF(MSVC90) 17 | SET(LCB_CC_STRING "vc9") 18 | ELSEIF(MSVC_VERSION EQUAL 1600) 19 | SET(LCB_CC_STRING "vc10") 20 | ELSEIF(MSVC_VERSION EQUAL 1700) 21 | SET(LCB_CC_STRING "vc11") 22 | ELSEIF(MSVC_VERSION EQUAL 1800) 23 | SET(LCB_CC_STRING "vc12") 24 | ELSEIF(MSVC_VERSION EQUAL 1900) 25 | SET(LCB_CC_STRING "vc14") 26 | ELSEIF(MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS_EQUAL 1919) 27 | SET(LCB_CC_STRING "vc15") 28 | ELSEIF(MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS_EQUAL 1929) 29 | SET(LCB_CC_STRING "vc16") 30 | ELSEIF(MSVC_VERSION GREATER_EQUAL 1930 AND MSVC_VERSION LESS_EQUAL 1949) 31 | SET(LCB_CC_STRING "vc17") 32 | ENDIF() 33 | ELSE() 34 | IF(UNIX) 35 | SET(LCB_CC_STRING "gcc") 36 | EXECUTE_PROCESS( 37 | COMMAND 38 | uname -m 39 | COMMAND 40 | tr -d '\n' 41 | OUTPUT_VARIABLE 42 | LCB_ARCH_STRING) 43 | ELSE() 44 | IF(CMAKE_SIZEOF_VOID_P EQUAL 8) 45 | SET(LCB_ARCH_STRING "amd64") 46 | ELSE() 47 | SET(LCB_ARCH_STRING "x86") 48 | ENDIF() 49 | SET(LCB_CC_STRING "mingw") 50 | ENDIF() 51 | ENDIF() 52 | -------------------------------------------------------------------------------- /cmake/build-timestamp.h.in: -------------------------------------------------------------------------------- 1 | #define LCB_BUILD_TIMESTAMP "${LCB_BUILD_TIMESTAMP}" 2 | -------------------------------------------------------------------------------- /cmake/defs.mk.in: -------------------------------------------------------------------------------- 1 | GITPARSE=${PROJECT_SOURCE_DIR}/packaging/parse-git-describe.pl 2 | BUILDROOT=${CMAKE_BINARY_DIR} 3 | SRCROOT=${PROJECT_SOURCE_DIR} 4 | REVDESCRIBE=${LCB_REVDESCRIBE} 5 | PACKAGE=libcouchbase 6 | VERSION=${LCB_VERSION} 7 | -------------------------------------------------------------------------------- /cmake/dtrace-instr-link.pl: -------------------------------------------------------------------------------- 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 | # Copy .o files to a temporary location before DTrace messes with them 20 | chomp(my $tmpdir = `mktemp -d -t $$`); 21 | if (system("tar cf - @O_FILES | tar xf - -C $tmpdir") != 0) { 22 | system("rm -r $tmpdir"); 23 | exit(1); 24 | } 25 | 26 | my $ss = join('_', @O_FILES); 27 | my $hexstr = md5_hex($ss); 28 | 29 | # From now, we work with files in the temporary location, update @ARGV 30 | map { $_ =~ s,.+\.o$,$tmpdir/$&, } @ARGV; 31 | 32 | my $INSTRUMENTED = "generated/probes_${hexstr}_$$.o"; 33 | # Run DTrace instrumentation. Assuming running from build directory: 34 | my @args = ( 35 | 'dtrace', '-C', '-G', 36 | '-s', $DT_SRC, 37 | '-o', $INSTRUMENTED, 38 | grep { $_ =~ /\.o$/ } @ARGV); 39 | 40 | print "$HDR: Creating instrumented DTrace object: @args"; 41 | if (system(@args) != 0) { 42 | system("rm -r $tmpdir"); 43 | exit(1); 44 | } 45 | 46 | unshift @ARGV, $CMD; 47 | push @ARGV, $INSTRUMENTED; 48 | print "$HDR: Linking with instrumented DTrace object: @ARGV"; 49 | my $rc = system(@ARGV); 50 | system("rm -r $tmpdir"); 51 | exit($rc); 52 | -------------------------------------------------------------------------------- /configure.pl: -------------------------------------------------------------------------------- 1 | cmake/configure -------------------------------------------------------------------------------- /contrib/HdrHistogram_c/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .idea 3 | out 4 | gh-pages 5 | HdrHistogram.iml 6 | .classpath 7 | .project 8 | .settings 9 | release.properties 10 | install_manifest.txt 11 | /bin 12 | alltests 13 | format_example 14 | *.a 15 | *.iml 16 | .sconsign.dblite 17 | *.o 18 | *.os 19 | .DS_Store 20 | build 21 | CMakeCache.txt 22 | CMakeFiles/ 23 | CPackConfig.cmake 24 | CPackSourceConfig.cmake 25 | CTestTestfile.cmake 26 | Makefile 27 | Testing/ 28 | cmake_install.cmake 29 | examples/CMakeFiles/ 30 | examples/CTestTestfile.cmake 31 | examples/Makefile 32 | examples/cmake_install.cmake 33 | examples/hdr_decoder 34 | examples/hiccup 35 | src/CMakeFiles/ 36 | src/CTestTestfile.cmake 37 | src/Makefile 38 | src/cmake_install.cmake 39 | src/libhdr_histogram.so 40 | src/libhdr_histogram.so.* 41 | test/CMakeFiles/ 42 | test/CTestTestfile.cmake 43 | test/Makefile 44 | test/cmake_install.cmake 45 | test/hdr_atomic_test 46 | test/hdr_dbl_histogram_test 47 | test/hdr_histogram_atomic_concurrency_test 48 | test/hdr_histogram_atomic_test 49 | test/hdr_histogram_log_test 50 | test/hdr_histogram_test 51 | test/perftest 52 | .gdb_history 53 | debug 54 | cmake-build-debug 55 | /build-afl 56 | -------------------------------------------------------------------------------- /contrib/HdrHistogram_c/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The code in this repository code was Written by Gil Tene, Michael Barker, 2 | and Matt Warren, and released to the public domain, as explained at 3 | http://creativecommons.org/publicdomain/zero/1.0/ 4 | 5 | For users of this code who wish to consume it under the "BSD" license 6 | rather than under the public domain or CC0 contribution text mentioned 7 | above, the code found under this directory is *also* provided under the 8 | following license (commonly referred to as the BSD 2-Clause License). This 9 | license does not detract from the above stated release of the code into 10 | the public domain, and simply represents an additional license granted by 11 | the Author. 12 | 13 | ----------------------------------------------------------------------------- 14 | ** Beginning of "BSD 2-Clause License" text. ** 15 | 16 | Copyright (c) 2012, 2013, 2014 Gil Tene 17 | Copyright (c) 2014 Michael Barker 18 | Copyright (c) 2014 Matt Warren 19 | All rights reserved. 20 | 21 | Redistribution and use in source and binary forms, with or without 22 | modification, are permitted provided that the following conditions are met: 23 | 24 | 1. Redistributions of source code must retain the above copyright notice, 25 | this list of conditions and the following disclaimer. 26 | 27 | 2. Redistributions in binary form must reproduce the above copyright notice, 28 | this list of conditions and the following disclaimer in the documentation 29 | and/or other materials provided with the distribution. 30 | 31 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 32 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 33 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 34 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 35 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 36 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 39 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 41 | THE POSSIBILITY OF SUCH DAMAGE. 42 | -------------------------------------------------------------------------------- /contrib/HdrHistogram_c/config.cmake.in: -------------------------------------------------------------------------------- 1 | include(CMakeFindDependencyMacro) 2 | 3 | find_dependency(ZLIB) 4 | find_dependency(Threads) 5 | 6 | include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake) 7 | -------------------------------------------------------------------------------- /contrib/HdrHistogram_c/src/hdr_tests.h: -------------------------------------------------------------------------------- 1 | #ifndef HDR_TESTS_H 2 | #define HDR_TESTS_H 3 | 4 | /* These are functions used in tests and are not intended for normal usage. */ 5 | 6 | #include "hdr_histogram.h" 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | int32_t counts_index_for(const struct hdr_histogram* h, int64_t value); 13 | int hdr_encode_compressed(struct hdr_histogram* h, uint8_t** compressed_histogram, size_t* compressed_len); 14 | int hdr_decode_compressed(uint8_t* buffer, size_t length, struct hdr_histogram** histogram); 15 | void hdr_base64_decode_block(const char* input, uint8_t* output); 16 | void hdr_base64_encode_block(const uint8_t* input, char* output); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /contrib/HdrHistogram_c/src/hdr_thread.h: -------------------------------------------------------------------------------- 1 | /** 2 | * hdr_thread.h 3 | * Written by Philip Orwig and released to the public domain, 4 | * as explained at http://creativecommons.org/publicdomain/zero/1.0/ 5 | */ 6 | 7 | #ifndef HDR_THREAD_H__ 8 | #define HDR_THREAD_H__ 9 | 10 | #include 11 | 12 | #if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) 13 | 14 | 15 | #define HDR_ALIGN_PREFIX(alignment) __declspec( align(alignment) ) 16 | #define HDR_ALIGN_SUFFIX(alignment) 17 | 18 | typedef struct hdr_mutex 19 | { 20 | uint8_t _critical_section[40]; 21 | } hdr_mutex; 22 | 23 | #else 24 | 25 | #include 26 | 27 | #define HDR_ALIGN_PREFIX(alignment) 28 | #define HDR_ALIGN_SUFFIX(alignment) __attribute__((aligned(alignment))) 29 | 30 | typedef struct hdr_mutex 31 | { 32 | pthread_mutex_t _mutex; 33 | } hdr_mutex; 34 | #endif 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | struct hdr_mutex* hdr_mutex_alloc(void); 41 | void hdr_mutex_free(struct hdr_mutex*); 42 | 43 | int hdr_mutex_init(struct hdr_mutex* mutex); 44 | void hdr_mutex_destroy(struct hdr_mutex* mutex); 45 | 46 | void hdr_mutex_lock(struct hdr_mutex* mutex); 47 | void hdr_mutex_unlock(struct hdr_mutex* mutex); 48 | 49 | void hdr_yield(void); 50 | int hdr_usleep(unsigned int useconds); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | #endif 56 | -------------------------------------------------------------------------------- /contrib/HdrHistogram_c/src/hdr_time.h: -------------------------------------------------------------------------------- 1 | /** 2 | * hdr_time.h 3 | * Written by Michael Barker and released to the public domain, 4 | * as explained at http://creativecommons.org/publicdomain/zero/1.0/ 5 | */ 6 | 7 | #ifndef HDR_TIME_H__ 8 | #define HDR_TIME_H__ 9 | 10 | #include 11 | #include 12 | 13 | #if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) 14 | 15 | typedef struct hdr_timespec 16 | { 17 | long tv_sec; 18 | long tv_nsec; 19 | } hdr_timespec; 20 | 21 | #else 22 | 23 | typedef struct timespec hdr_timespec; 24 | 25 | #endif 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #if defined(_MSC_VER) 32 | void hdr_gettime(hdr_timespec* t); 33 | #else 34 | void hdr_gettime(hdr_timespec* t); 35 | #endif 36 | 37 | void hdr_getnow(hdr_timespec* t); 38 | 39 | double hdr_timespec_as_double(const hdr_timespec* t); 40 | 41 | /* Assumes only millisecond accuracy. */ 42 | void hdr_timespec_from_double(hdr_timespec* t, double value); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /contrib/HdrHistogram_c/src/hdr_writer_reader_phaser.h: -------------------------------------------------------------------------------- 1 | /** 2 | * hdr_writer_reader_phaser.h 3 | * Written by Michael Barker and released to the public domain, 4 | * as explained at http://creativecommons.org/publicdomain/zero/1.0/ 5 | */ 6 | 7 | #ifndef HDR_WRITER_READER_PHASER_H 8 | #define HDR_WRITER_READER_PHASER_H 1 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "hdr_thread.h" 16 | 17 | HDR_ALIGN_PREFIX(8) 18 | struct hdr_writer_reader_phaser 19 | { 20 | int64_t start_epoch; 21 | int64_t even_end_epoch; 22 | int64_t odd_end_epoch; 23 | hdr_mutex* reader_mutex; 24 | } 25 | HDR_ALIGN_SUFFIX(8); 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | int hdr_writer_reader_phaser_init(struct hdr_writer_reader_phaser* p); 32 | 33 | void hdr_writer_reader_phaser_destroy(struct hdr_writer_reader_phaser* p); 34 | 35 | int64_t hdr_phaser_writer_enter(struct hdr_writer_reader_phaser* p); 36 | 37 | void hdr_phaser_writer_exit( 38 | struct hdr_writer_reader_phaser* p, int64_t critical_value_at_enter); 39 | 40 | void hdr_phaser_reader_lock(struct hdr_writer_reader_phaser* p); 41 | 42 | void hdr_phaser_reader_unlock(struct hdr_writer_reader_phaser* p); 43 | 44 | void hdr_phaser_flip_phase( 45 | struct hdr_writer_reader_phaser* p, int64_t sleep_time_ns); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /contrib/cbsasl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE (CheckCSourceCompiles) 2 | INCLUDE_DIRECTORIES(src) 3 | FILE(GLOB CBSASL_SRC src/*.c) 4 | FILE(GLOB CRAM_SRC src/cram-md5/*.c) 5 | FILE(GLOB SCRAM_SRC src/scram-sha/*.cc) 6 | 7 | ADD_LIBRARY(cbsasl-lcb OBJECT ${CBSASL_SRC} ${CRAM_SRC}) 8 | SET_TARGET_PROPERTIES(cbsasl-lcb 9 | PROPERTIES 10 | POSITION_INDEPENDENT_CODE TRUE 11 | COMPILE_FLAGS "${LCB_CORE_CFLAGS}") 12 | 13 | ADD_LIBRARY(cbsasl-lcb-cxx OBJECT ${SCRAM_SRC}) 14 | SET_TARGET_PROPERTIES(cbsasl-lcb-cxx 15 | PROPERTIES 16 | POSITION_INDEPENDENT_CODE TRUE 17 | COMPILE_FLAGS "${LCB_CORE_CXXFLAGS}") 18 | 19 | IF(OPENSSL_FOUND AND (NOT LCB_NO_SSL)) 20 | INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) 21 | ADD_DEFINITIONS(${OPENSSL_DEFINITIONS}) 22 | # Check if the system have a usable version of PKCS5_PBKDF2_HMAC 23 | CMAKE_PUSH_CHECK_STATE(RESET) 24 | SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OPENSSL_LIBRARIES}) 25 | SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${OPENSSL_INCLUDE_DIR}) 26 | CHECK_C_SOURCE_COMPILES(" 27 | #include 28 | int main() { 29 | PKCS5_PBKDF2_HMAC(NULL, 0, NULL, 0, 0, NULL, 0, NULL); 30 | }" HAVE_PKCS5_PBKDF2_HMAC) 31 | ENDIF() 32 | -------------------------------------------------------------------------------- /contrib/cbsasl/src/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2020 Couchbase, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "cbsasl/cbsasl.h" 18 | #include "util.h" 19 | #include 20 | 21 | CBSASL_PUBLIC_API 22 | void cbsasl_dispose(cbsasl_conn_t **conn) 23 | { 24 | if (*conn != NULL) { 25 | if ((*conn)->client) { 26 | free((*conn)->c.client.userdata); 27 | free((*conn)->c.client.nonce); 28 | free((*conn)->c.client.client_first_message_bare); 29 | free((*conn)->c.client.saltedpassword); 30 | free((*conn)->c.client.auth_message); 31 | } else { 32 | free((*conn)->c.server.username); 33 | free((*conn)->c.server.config); 34 | free((*conn)->c.server.sasl_data); 35 | } 36 | 37 | free(*conn); 38 | *conn = NULL; 39 | } 40 | } 41 | 42 | static const char *hexchar = "0123456789abcdef"; 43 | void cbsasl_hex_encode(char *dest, const char *src, size_t srclen) 44 | { 45 | size_t i; 46 | for (i = 0; i < srclen; i++) { 47 | dest[i * 2] = hexchar[(src[i] >> 4) & 0xF]; 48 | dest[i * 2 + 1] = hexchar[src[i] & 0xF]; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /contrib/cbsasl/src/cram-md5/hmac.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2020 Couchbase, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "hmac.h" 18 | #include "md5.h" 19 | #include 20 | 21 | /** 22 | * The code in this function is based on the code provided in rfc 2104. 23 | * http://www.ietf.org/rfc/rfc2104.txt 24 | */ 25 | void cbsasl_hmac_md5(unsigned char *text, 26 | int textlen, 27 | unsigned char *key, 28 | int keylen, 29 | unsigned char *digest) 30 | { 31 | MD5_CTX context; 32 | unsigned char k_ipad[65]; 33 | unsigned char k_opad[65]; 34 | unsigned char tk[16]; 35 | int i; 36 | 37 | if (keylen > 64) { 38 | MD5_CTX ctx; 39 | cbsasl_MD5_Init(&ctx); 40 | cbsasl_MD5_Update(&ctx, key, keylen); 41 | cbsasl_MD5_Final(tk, &ctx); 42 | key = tk; 43 | keylen = 16; 44 | } 45 | 46 | memset(k_ipad, 0, sizeof(k_ipad)); 47 | memset(k_opad, 0, sizeof(k_opad)); 48 | memcpy(k_ipad, key, keylen); 49 | memcpy(k_opad, key, keylen); 50 | 51 | for (i = 0; i < 64; i++) { 52 | k_ipad[i] ^= 0x36; 53 | k_opad[i] ^= 0x5c; 54 | } 55 | 56 | /* Perform inner md5 */ 57 | cbsasl_MD5_Init(&context); 58 | cbsasl_MD5_Update(&context, k_ipad, 64); 59 | cbsasl_MD5_Update(&context, text, textlen); 60 | cbsasl_MD5_Final(digest, &context); 61 | 62 | /* Perform outer md5 */ 63 | cbsasl_MD5_Init(&context); 64 | cbsasl_MD5_Update(&context, k_opad, 64); 65 | cbsasl_MD5_Update(&context, digest, 16); 66 | cbsasl_MD5_Final(digest, &context); 67 | } 68 | -------------------------------------------------------------------------------- /contrib/cbsasl/src/cram-md5/hmac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2020 Couchbase, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SRC_CRAM_MD5_HMAC_H_ 18 | #define SRC_CRAM_MD5_HMAC_H_ 1 19 | #define DIGEST_LENGTH 16 20 | 21 | /** 22 | * Perform hmac on md5 23 | * 24 | * The code in this function is based on the code provided in rfc 2104. 25 | * http://www.ietf.org/rfc/rfc2104.txt 26 | */ 27 | void cbsasl_hmac_md5(unsigned char *text, 28 | int text_len, 29 | unsigned char *key, 30 | int keylen, 31 | unsigned char *digest); 32 | 33 | #endif /* SRC_CRAM_MD5_HMAC_H_ */ 34 | -------------------------------------------------------------------------------- /contrib/cbsasl/src/cram-md5/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. 3 | * MD5 Message-Digest Algorithm (RFC 1321). 4 | * 5 | * Homepage: 6 | * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 7 | * 8 | * Author: 9 | * Alexander Peslyak, better known as Solar Designer 10 | * 11 | * This software was written by Alexander Peslyak in 2001. No copyright is 12 | * claimed, and the software is hereby placed in the public domain. 13 | * In case this attempt to disclaim copyright and place the software in the 14 | * public domain is deemed null and void, then the software is 15 | * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the 16 | * general public under the following terms: 17 | * 18 | * Redistribution and use in source and binary forms, with or without 19 | * modification, are permitted. 20 | * 21 | * There's ABSOLUTELY NO WARRANTY, express or implied. 22 | * 23 | * See md5.c for more information. 24 | */ 25 | 26 | #ifdef HAVE_OPENSSL 27 | #include 28 | #elif !defined(_MD5_H) 29 | #define _MD5_H 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /* Any 32-bit or wider unsigned integer data type will do */ 36 | typedef unsigned int MD5_u32plus; 37 | 38 | typedef struct { 39 | MD5_u32plus lo, hi; 40 | MD5_u32plus a, b, c, d; 41 | unsigned char buffer[64]; 42 | MD5_u32plus block[16]; 43 | } MD5_CTX; 44 | 45 | extern void cbsasl_MD5_Init(MD5_CTX *ctx); 46 | extern void cbsasl_MD5_Update(MD5_CTX *ctx, void *data, unsigned long size); 47 | extern void cbsasl_MD5_Final(unsigned char *result, MD5_CTX *ctx); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /contrib/cbsasl/src/hash.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2013-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef SRC_HASH_H_ 19 | #define SRC_HASH_H_ 1 20 | #include "config.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | uint32_t cbsasl_hash(const void *key, size_t length, const uint32_t initval); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* SRC_HASH_H_ */ 33 | -------------------------------------------------------------------------------- /contrib/cbsasl/src/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2020 Couchbase, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CBSASL_UTIL_H_ 18 | #define CBSASL_UTIL_H_ 1 19 | #include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /* Encode hexadecimal representation of bytes from src into dest. 26 | * Will write srclen * 2 bytes. */ 27 | void cbsasl_hex_encode(char *dest, const char *src, size_t srclen); 28 | 29 | /* Compare a and b without revealing their content by short-circuiting */ 30 | int cbsasl_secure_compare(const char *a, size_t alen, const char *b, size_t blen); 31 | 32 | cbsasl_error_t cbsasl_secure_random(char *dest, size_t len); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif /* CBSASL_UTIL_H_ */ 39 | -------------------------------------------------------------------------------- /contrib/cliopts/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_LIBRARY(cliopts OBJECT cliopts.c) 2 | SET_TARGET_PROPERTIES(cbsasl-lcb PROPERTIES COMPILE_FLAGS "${LCB_CORE_CFLAGS}") 3 | -------------------------------------------------------------------------------- /contrib/gtest-1.8.1/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Bharat Mediratta 9 | Chandler Carruth 10 | Chris Prince 11 | Chris Taylor 12 | Dan Egnor 13 | Eric Roman 14 | Hady Zalek 15 | Jeffrey Yasskin 16 | Jói Sigurðsson 17 | Keir Mierle 18 | Keith Ray 19 | Kenton Varda 20 | Manuel Klimek 21 | Markus Heule 22 | Mika Raento 23 | Miklós Fazekas 24 | Pasi Valminen 25 | Patrick Hanna 26 | Patrick Riley 27 | Peter Kaminski 28 | Preston Jackson 29 | Rainer Klaffenboeck 30 | Russ Cox 31 | Russ Rufer 32 | Sean Mcafee 33 | Sigurður Ásgeirsson 34 | Tracy Bialik 35 | Vadim Berman 36 | Vlad Losev 37 | Zhanyong Wan 38 | -------------------------------------------------------------------------------- /contrib/gtest-1.8.1/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /contrib/gtest-1.8.1/MINIFY.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | rm -f aclocal.m4 4 | rm -rf build-aux 5 | rm -rf msvc 6 | rm -rf fused-src 7 | rm -f configure configure.ac 8 | rm -f Makefile.in Makefile.am 9 | rm -rf xcode 10 | rm -rf test 11 | rm -rf m4 12 | rm -rf make 13 | rm -rf codegear 14 | rm -rf samples 15 | rm -rf scripts 16 | rm -rf docs 17 | -------------------------------------------------------------------------------- /contrib/gtest-1.8.1/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include(CMakeFindDependencyMacro) 3 | if (@GTEST_HAS_PTHREAD@) 4 | set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@) 5 | find_dependency(Threads) 6 | endif() 7 | 8 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 9 | check_required_components("@project_name@") 10 | -------------------------------------------------------------------------------- /contrib/gtest-1.8.1/cmake/gtest.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest 5 | Description: GoogleTest (without main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@ 9 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ 10 | -------------------------------------------------------------------------------- /contrib/gtest-1.8.1/cmake/gtest_main.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest_main 5 | Description: GoogleTest (with main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gtest 9 | Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ 11 | -------------------------------------------------------------------------------- /contrib/gtest-1.8.1/include/gtest/internal/custom/README.md: -------------------------------------------------------------------------------- 1 | # Customization Points 2 | 3 | The custom directory is an injection point for custom user configurations. 4 | 5 | ## Header `gtest.h` 6 | 7 | ### The following macros can be defined: 8 | 9 | * `GTEST_OS_STACK_TRACE_GETTER_` - The name of an implementation of 10 | `OsStackTraceGetterInterface`. 11 | * `GTEST_CUSTOM_TEMPDIR_FUNCTION_` - An override for `testing::TempDir()`. See 12 | `testing::TempDir` for semantics and signature. 13 | 14 | ## Header `gtest-port.h` 15 | 16 | The following macros can be defined: 17 | 18 | ### Flag related macros: 19 | 20 | * `GTEST_FLAG(flag_name)` 21 | * `GTEST_USE_OWN_FLAGFILE_FLAG_` - Define to 0 when the system provides its 22 | own flagfile flag parsing. 23 | * `GTEST_DECLARE_bool_(name)` 24 | * `GTEST_DECLARE_int32_(name)` 25 | * `GTEST_DECLARE_string_(name)` 26 | * `GTEST_DEFINE_bool_(name, default_val, doc)` 27 | * `GTEST_DEFINE_int32_(name, default_val, doc)` 28 | * `GTEST_DEFINE_string_(name, default_val, doc)` 29 | 30 | ### Logging: 31 | 32 | * `GTEST_LOG_(severity)` 33 | * `GTEST_CHECK_(condition)` 34 | * Functions `LogToStderr()` and `FlushInfoLog()` have to be provided too. 35 | 36 | ### Threading: 37 | 38 | * `GTEST_HAS_NOTIFICATION_` - Enabled if Notification is already provided. 39 | * `GTEST_HAS_MUTEX_AND_THREAD_LOCAL_` - Enabled if `Mutex` and `ThreadLocal` 40 | are already provided. Must also provide `GTEST_DECLARE_STATIC_MUTEX_(mutex)` 41 | and `GTEST_DEFINE_STATIC_MUTEX_(mutex)` 42 | * `GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)` 43 | * `GTEST_LOCK_EXCLUDED_(locks)` 44 | 45 | ### Underlying library support features 46 | 47 | * `GTEST_HAS_CXXABI_H_` 48 | 49 | ### Exporting API symbols: 50 | 51 | * `GTEST_API_` - Specifier for exported symbols. 52 | 53 | ## Header `gtest-printers.h` 54 | 55 | * See documentation at `gtest/gtest-printers.h` for details on how to define a 56 | custom printer. 57 | -------------------------------------------------------------------------------- /contrib/gtest-1.8.1/include/gtest/internal/custom/gtest-port.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 35 | #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 36 | 37 | #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 38 | -------------------------------------------------------------------------------- /contrib/gtest-1.8.1/include/gtest/internal/custom/gtest-printers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // This file provides an injection point for custom printers in a local 31 | // installation of gTest. 32 | // It will be included from gtest-printers.h and the overrides in this file 33 | // will be visible to everyone. 34 | // 35 | // Injection point for custom user configurations. See README for details 36 | // 37 | // ** Custom implementation starts here ** 38 | 39 | #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 40 | #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 41 | 42 | #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 43 | -------------------------------------------------------------------------------- /contrib/gtest-1.8.1/include/gtest/internal/custom/gtest.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 35 | #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 36 | 37 | #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 38 | -------------------------------------------------------------------------------- /contrib/gtest-1.8.1/src/gtest-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Google C++ Testing and Mocking Framework (Google Test) 32 | // 33 | // Sometimes it's desirable to build Google Test by compiling a single file. 34 | // This file serves this purpose. 35 | 36 | // This line ensures that gtest.h can be compiled on its own, even 37 | // when it's fused. 38 | #include "gtest/gtest.h" 39 | 40 | // The following lines pull in the real gtest *.cc files. 41 | #include "src/gtest.cc" 42 | #include "src/gtest-death-test.cc" 43 | #include "src/gtest-filepath.cc" 44 | #include "src/gtest-port.cc" 45 | #include "src/gtest-printers.cc" 46 | #include "src/gtest-test-part.cc" 47 | #include "src/gtest-typed-test.cc" 48 | -------------------------------------------------------------------------------- /contrib/gtest-1.8.1/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | #include "gtest/gtest.h" 32 | 33 | GTEST_API_ int main(int argc, char **argv) { 34 | printf("Running main() from %s\n", __FILE__); 35 | testing::InitGoogleTest(&argc, argv); 36 | return RUN_ALL_TESTS(); 37 | } 38 | -------------------------------------------------------------------------------- /contrib/http_parser/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | http_parser.c is based on src/http/ngx_http_parse.c from NGINX copyright 2 | Igor Sysoev. 3 | 4 | Additional changes are licensed under the same terms as NGINX and 5 | copyright Joyent, Inc. and other Node contributors. All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to 9 | deal in the Software without restriction, including without limitation the 10 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | sell copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /contrib/jsonsl/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 M. Nunberg, mnunberg@haskalah.org 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /contrib/lcb-jsoncpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_LIBRARY(lcb_jsoncpp OBJECT lcb-jsoncpp.cpp) 2 | ADD_DEFINITIONS(-DJSON_USE_EXCEPTIONS=0) 3 | SET_TARGET_PROPERTIES(lcb_jsoncpp 4 | PROPERTIES 5 | POSITION_INDEPENDENT_CODE TRUE 6 | COMPILE_FLAGS "${LCB_CORE_CXXFLAGS}") 7 | -------------------------------------------------------------------------------- /contrib/snappy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB SNAPPY_SRC *.cc) 2 | ADD_LIBRARY(lcb_snappy OBJECT ${SNAPPY_SRC}) 3 | 4 | SET_TARGET_PROPERTIES(lcb_snappy 5 | PROPERTIES 6 | POSITION_INDEPENDENT_CODE TRUE 7 | COMPILE_FLAGS "${LCB_CORE_CXXFLAGS}") 8 | -------------------------------------------------------------------------------- /contrib/snappy/COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2011, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /contrib/snappy/snappy-lcb-msvc.h: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | #define NOMINMAX 3 | #include 4 | typedef SSIZE_T ssize_t; 5 | #endif 6 | -------------------------------------------------------------------------------- /contrib/snappy/snappy-stubs-internal.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | #include 31 | 32 | #include "snappy-stubs-internal.h" 33 | 34 | namespace snappy { 35 | 36 | void Varint::Append32(std::string* s, uint32 value) { 37 | char buf[Varint::kMax32]; 38 | const char* p = Varint::Encode32(buf, value); 39 | s->append(buf, p - buf); 40 | } 41 | 42 | } // namespace snappy 43 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | SRCROOT=$(shell pwd) 2 | VERSINFO=$(shell $(SRCROOT)/packaging/parse-git-describe.pl --tar) 3 | ifneq ($(strip $(VERSINFO)),) 4 | VERLINE=PROJECT_NUMBER=$(VERSINFO) 5 | endif 6 | 7 | DOXYGEN?=doxygen 8 | DOXYFILE=doc/Doxyfile 9 | OUTDIR_PUB = doc/public 10 | OUTDIR_PRIV = doc/internal 11 | INTERNAL_SRC = \ 12 | src/rdb \ 13 | src/bootstrap.h \ 14 | src/lcbio \ 15 | src/netbuf \ 16 | src/mc \ 17 | src/retryq.h \ 18 | src/bucketconfig/clconfig.h \ 19 | src/mcserver \ 20 | src/list.h \ 21 | src/sllist.h \ 22 | src/sllist-inl.h \ 23 | src/hostlist.h \ 24 | include/memcached/protocol_binary.h 25 | 26 | all: public internal 27 | public: 28 | (cat $(DOXYFILE);\ 29 | echo $(VERLINE);\ 30 | echo OUTPUT_DIRECTORY=$(OUTDIR_PUB)) | $(DOXYGEN) - 31 | cp doc/style.css $(OUTDIR_PUB)/html/style.css 32 | 33 | 34 | 35 | internal: 36 | (cat $(DOXYFILE);\ 37 | echo $(VERLINE); \ 38 | echo OUTPUT_DIRECTORY=$(OUTDIR_PRIV); \ 39 | echo INTERNAL_DOCS=yes; \ 40 | echo INPUT += $(INTERNAL_SRC);) | $(DOXYGEN) - 41 | cp doc/style.css $(OUTDIR_PRIV)/html/style.css 42 | 43 | clean: 44 | rm -r -f $(OUTDIR_PRIV)/html $(OUTDIR_PUB)/html 45 | -------------------------------------------------------------------------------- /doc/cbcrc.markdown: -------------------------------------------------------------------------------- 1 | # cbcrc(4) - Configuration file for Couchbase command line tools 2 | 3 | ## SYNOPSIS 4 | 5 | `~/.cbcrc` 6 | 7 | ## DESCRIPTION 8 | 9 | cbcrc is an optional configuration file used to provide default values for the 10 | cbc(1) and cbc-pillowfight(1) utilities. It should be placed in 11 | 12 | Each entry in the cbcrc file is a line with a key-value pair in the following 13 | form: 14 | 15 | # optional comments 16 | key=value 17 | 18 | The keys may be specified in random order, and if you specify the same 19 | key multiple times the last value "wins". The following keys exists: 20 | 21 | * `connstr`: 22 | This is the URI-like string used to connect to the cluster. Its format 23 | consists of a _scheme_ followed by a list of hosts, an optional 24 | bucket for the path and an optional `?` followed by key-value options. 25 | 26 | Using custom REST API ports 27 | 28 | http://localhost:9000,localhost:9001,localhost:9002 29 | 30 | Using custom memcached ports: 31 | 32 | couchbase://localhost:9100,localhost:9200,localhost:9300 33 | 34 | * `user`: 35 | This is the user name used during authentication to your bucket 36 | 37 | * `password`: 38 | This is the password used during authentication to your bucket 39 | 40 | * `timeout`: 41 | The timeout value to use for the operations. 42 | 43 | ## NOTES 44 | 45 | * You can generate such a file from the cbc(1) itself using the `write-config` 46 | subcommand 47 | 48 | * Most other options can be specified within the connection string 49 | 50 | ## SEE ALSO 51 | 52 | cbc(1), cbc-pillowfight(1) 53 | -------------------------------------------------------------------------------- /doc/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 14 | 15 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /doc/genman.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | set -x 4 | 5 | # Run from the top level source directory 6 | OUTDIR=man 7 | SRCDIR=. 8 | 9 | MANPAGES="cbc cbc-pillowfight cbc-n1qlback cbc-subdoc" 10 | for page in $MANPAGES; do 11 | ronn --pipe --roff $SRCDIR/$page.markdown | sed 's/\\.\\.\\./\\[char46]\\[char46]\\[char46]/g' > $OUTDIR/$page.1 12 | done 13 | ronn --pipe --roff $SRCDIR/cbcrc.markdown | sed 's/\\.\\.\\./\\[char46]\\[char46]\\[char46]/g' > $OUTDIR/cbcrc.4 14 | 15 | MANLINKS="cat cp create observe flush hash lock unlock rm stats \ 16 | version verbosity view admin bucket-create bucket-delete connstr \ 17 | role-list user-list user-upsert user-delete ping n1ql \ 18 | decr incr watch mcversion" 19 | 20 | for link in $MANLINKS; do 21 | dest="$OUTDIR/cbc-${link}.1" 22 | echo ".so man1/cbc.1" > "$dest" 23 | done 24 | -------------------------------------------------------------------------------- /doc/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $projectname: $title 7 | $title 8 | 9 | 10 | 11 | $treeview 12 | $search 13 | $mathjax 14 | 15 | 16 | 17 |
18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 34 | 35 | 36 | 37 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
29 |
$projectname 30 |  $projectnumber 31 |
32 |
$projectbrief
33 |
38 |
$projectbrief
39 |
$searchbox
50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /doc/man/cbc-admin.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-bucket-create.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-bucket-delete.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-cat.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-connstr.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-cp.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-create.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-decr.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-flush.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-hash.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-incr.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-lock.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-mcversion.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-n1ql.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-observe.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-ping.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-rm.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-role-list.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-stats.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-unlock.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-user-delete.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-user-list.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-user-upsert.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-verbosity.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-version.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-view.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbc-watch.1: -------------------------------------------------------------------------------- 1 | .so man1/cbc.1 2 | -------------------------------------------------------------------------------- /doc/man/cbcrc.4: -------------------------------------------------------------------------------- 1 | .\" generated with Ronn-NG/v0.10.1 2 | .\" http://github.com/apjanke/ronn-ng/tree/0.10.1 3 | .TH "CBCRC" "4" "July 2024" "" 4 | .SH "NAME" 5 | \fBcbcrc\fR \- Configuration file for Couchbase command line tools 6 | .SH "SYNOPSIS" 7 | \fB~/\.cbcrc\fR 8 | .SH "DESCRIPTION" 9 | cbcrc is an optional configuration file used to provide default values for the cbc(1) and cbc\-pillowfight(1) utilities\. It should be placed in 10 | .P 11 | Each entry in the cbcrc file is a line with a key\-value pair in the following form: 12 | .IP "" 4 13 | .nf 14 | # optional comments 15 | key=value 16 | .fi 17 | .IP "" 0 18 | .P 19 | The keys may be specified in random order, and if you specify the same key multiple times the last value "wins"\. The following keys exists: 20 | .TP 21 | \fBconnstr\fR 22 | This is the URI\-like string used to connect to the cluster\. Its format consists of a \fIscheme\fR followed by a list of hosts, an optional bucket for the path and an optional \fB?\fR followed by key\-value options\. 23 | .IP 24 | Using custom REST API ports 25 | .IP 26 | http://localhost:9000,localhost:9001,localhost:9002 27 | .IP 28 | Using custom memcached ports: 29 | .IP 30 | couchbase://localhost:9100,localhost:9200,localhost:9300 31 | .TP 32 | \fBuser\fR 33 | This is the user name used during authentication to your bucket 34 | .TP 35 | \fBpassword\fR 36 | This is the password used during authentication to your bucket 37 | .TP 38 | \fBtimeout\fR 39 | The timeout value to use for the operations\. 40 | .SH "NOTES" 41 | .IP "\(bu" 4 42 | You can generate such a file from the cbc(1) itself using the \fBwrite\-config\fR subcommand 43 | .IP "\(bu" 4 44 | Most other options can be specified within the connection string 45 | .IP "" 0 46 | .SH "SEE ALSO" 47 | cbc(1), cbc\-pillowfight(1) 48 | -------------------------------------------------------------------------------- /example/README.markdown: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | An example says more than a 1000 words (and its way easier to write an 5 | example than trying to explain something). In this directory you'll 6 | find a varity of examples that will show you different use patterns of 7 | libcoucbase. 8 | 9 | libeventdirect 10 | -------------- 11 | 12 | This example programs shows you how you may integrate libcouchbase 13 | into your own event loop (in this example libevent). 14 | 15 | syncmode 16 | -------- 17 | 18 | This example shows you how you may use the synchronous interface of 19 | libcouchbase. 20 | 21 | yajl 22 | ---- 23 | 24 | This is an example that shows you how to work with views and json 25 | 26 | pillowfight 27 | ----------- 28 | 29 | This is an example that implements a small test program to show 30 | you some of the functionalities in libcouchbase. 31 | 32 | minimal 33 | ------- 34 | 35 | This is an minimal single-file example which works both unix-like and windows OS. 36 | It accepts three arguments: "host:port", "bucket" and "password". 37 | 38 | Build: 39 | 40 | gcc -lcouchbase -o minimal minimal.c 41 | cl /DWIN32 /Iinclude lib\libcouchbase.lib minimal.c 42 | 43 | Execute: 44 | 45 | valgrind -v --tool=memcheck --leak-check=full --show-reachable=yes ./minimal 46 | ./minimal 47 | mininal.exe 48 | -------------------------------------------------------------------------------- /example/analytics-deferred/.gitignore: -------------------------------------------------------------------------------- 1 | analytics-deferred 2 | -------------------------------------------------------------------------------- /example/analytics-deferred/cJSON.c: -------------------------------------------------------------------------------- 1 | ../../contrib/cJSON/cJSON.c -------------------------------------------------------------------------------- /example/analytics-deferred/cJSON.h: -------------------------------------------------------------------------------- 1 | ../../contrib/cJSON/cJSON.h -------------------------------------------------------------------------------- /example/analytics-ingest/.gitignore: -------------------------------------------------------------------------------- 1 | analytics-deferred 2 | -------------------------------------------------------------------------------- /example/analytics-ingest/cJSON.c: -------------------------------------------------------------------------------- 1 | ../../contrib/cJSON/cJSON.c -------------------------------------------------------------------------------- /example/analytics-ingest/cJSON.h: -------------------------------------------------------------------------------- 1 | ../../contrib/cJSON/cJSON.h -------------------------------------------------------------------------------- /example/analytics/.gitignore: -------------------------------------------------------------------------------- 1 | analytics 2 | -------------------------------------------------------------------------------- /example/analytics/build-queries.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | 3 | # Copyright 2018 Couchbase, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | require 'json' 18 | 19 | paths = Dir[File.join(__dir__, 'queries', '*.json')].sort 20 | File.open(File.join(__dir__, 'queries.h'), 'w+') do |out| 21 | out.puts("// This file was generated by queries.rb") 22 | out.puts("typedef struct analytics_query_str { const char *comment; size_t query_len; const char *query; } analytics_query_str;") 23 | out.puts("size_t num_queries = #{paths.size};") 24 | out.puts("analytics_query_str queries[#{paths.size + 1}] = {") 25 | paths.each do |path| 26 | lines = File.readlines(path) 27 | lines.delete_at(0) 28 | comment, query = lines.partition { |line| line.start_with?('//') } 29 | comment_str = comment.map { |line| line.sub(%r(^//\s*), '').strip }.join(' ') 30 | query_str = JSON.generate(JSON.parse(query.join.strip)) 31 | out.puts("{#{comment_str.inspect},\n #{query_str.size},\n #{query_str.inspect}},\n\n") 32 | end 33 | out.puts("{NULL, 0, NULL}};") 34 | end 35 | -------------------------------------------------------------------------------- /example/analytics/cJSON.c: -------------------------------------------------------------------------------- 1 | ../../contrib/cJSON/cJSON.c -------------------------------------------------------------------------------- /example/analytics/cJSON.h: -------------------------------------------------------------------------------- 1 | ../../contrib/cJSON/cJSON.h -------------------------------------------------------------------------------- /example/analytics/queries/00-show-dataverse.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Display dataverses defined by Analytics service 3 | { 4 | "statement": "SELECT * FROM Metadata.`Dataverse`" 5 | } 6 | -------------------------------------------------------------------------------- /example/analytics/queries/01-setup-dataset-breweries.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Tell analytics service to shadow the data from beer-sample bucket using 3 | // breweries dataset. 4 | { 5 | "statement": "CREATE DATASET breweries ON `beer-sample` WHERE `type` = \"brewery\"" 6 | } 7 | -------------------------------------------------------------------------------- /example/analytics/queries/02-setup-dataset-beers.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Tell analytics service to shadow the data from beer-sample bucket using 3 | // beers dataset. 4 | { 5 | "statement": "CREATE DATASET beers ON `beer-sample` WHERE `type` = \"beer\"" 6 | } 7 | -------------------------------------------------------------------------------- /example/analytics/queries/03-initiate-shadow.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Initiate the shadowing relationship of datasets to the data in Couchbase 3 | // Server 4 | { 5 | "statement": "CONNECT LINK Local" 6 | } 7 | -------------------------------------------------------------------------------- /example/analytics/queries/04-list-datasets.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // List populated datasets 3 | { 4 | "statement": "SELECT ds.BucketName, ds.DatasetName, ds.`Filter` FROM Metadata.`Dataset` ds WHERE ds.DataverseName = \"Default\"" 5 | } 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/analytics/queries/05-count-breweries.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Ask Analytics the number of breweries 3 | { 4 | "statement": "SELECT VALUE COUNT(*) FROM breweries" 5 | } 6 | -------------------------------------------------------------------------------- /example/analytics/queries/06-first-brewery.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Retrieve first brewery, ordered by name 3 | { 4 | "statement": "SELECT * FROM breweries ORDER BY name LIMIT 1", 5 | "pretty": true 6 | } 7 | -------------------------------------------------------------------------------- /example/analytics/queries/07-key-based-lookup.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Find a particular brewery based on its Couchbase Server key 3 | { 4 | "statement": "SELECT meta(bw) AS meta, bw AS data FROM breweries bw WHERE meta(bw).id = 'kona_brewing'", 5 | "pretty": true 6 | } 7 | -------------------------------------------------------------------------------- /example/analytics/queries/08-exact-match-lookup.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Find the same brewery information but in a slightly simpler or cleaner way 3 | // based only on the data 4 | { 5 | "statement": "SELECT VALUE bw FROM breweries bw WHERE bw.name = 'Kona Brewing'", 6 | "pretty": true 7 | } 8 | -------------------------------------------------------------------------------- /example/analytics/queries/09-exact-match-lookup-different-shape.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Find brewery by name, but return objects instead of values 3 | { 4 | "statement": "SELECT bw FROM breweries bw WHERE bw.name = 'Kona Brewing'", 5 | "pretty": true 6 | } 7 | -------------------------------------------------------------------------------- /example/analytics/queries/10-other-query-filters.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Apply a range condition together with a string condition to select breweries 3 | { 4 | "statement": "SELECT VALUE bw FROM breweries bw WHERE bw.geo.lat > 60.0 AND bw.name LIKE '%Brewing%' ORDER BY bw.name", 5 | "pretty": true 6 | } 7 | -------------------------------------------------------------------------------- /example/analytics/queries/11-equijoin.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Fetch list of all breweries paired with their associated beers, with the 3 | // list enumerating the brewery name and the beer name for each such pair, 4 | // while also limiting the answer set size to at most 3 results. 5 | { 6 | "statement": "SELECT bw.name AS brewer, br.name AS beer FROM breweries bw, beers br WHERE br.brewery_id = meta(bw).id ORDER BY bw.name, br.name LIMIT 3" 7 | } 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/analytics/queries/12-equijoin-select-star.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Fetch list of all breweries paired with their associated beers, including 3 | // all attributes, while also limiting the answer set size to at most 3 4 | // results. 5 | { 6 | "statement": "SELECT * FROM breweries bw, beers br WHERE br.brewery_id = meta(bw).id ORDER BY bw.name, br.name LIMIT 3", 7 | "pretty": true 8 | } 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/analytics/queries/13-ansi-join.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Fetch list of all breweries paired with their associated beers, including 3 | // all attributes, while also limiting the answer set size to at most 3 4 | // results. With ANSI JOINS! 5 | { 6 | "statement": "SELECT * FROM breweries bw JOIN beers br ON br.brewery_id = meta(bw).id ORDER BY bw.name, br.name LIMIT 3", 7 | "pretty": true 8 | } 9 | -------------------------------------------------------------------------------- /example/analytics/queries/14-join-select-values.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Fetch list of all breweries paired with their associated beers, including 3 | // all attributes, while also limiting the answer set size to at most 3 4 | // results. Select values explicitly. 5 | { 6 | "statement": "SELECT VALUE {\"bw\": bw, \"br\": br} FROM breweries bw, beers br WHERE br.brewery_id = meta(bw).id ORDER BY bw.name, br.name LIMIT 3", 7 | "pretty": true 8 | } 9 | -------------------------------------------------------------------------------- /example/analytics/queries/15-nested-outer-join.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // For each brewery produce an object that contains the brewery name along with 3 | // a list of all of the brewery’s offered beer names and alcohol percentages 4 | { 5 | "statement": "SELECT bw.name AS brewer, (SELECT br.name, br.abv FROM beers br WHERE br.brewery_id = meta(bw).id ORDER BY br.name) AS beers FROM breweries bw ORDER BY bw.name LIMIT 2", 6 | "pretty": true 7 | } 8 | -------------------------------------------------------------------------------- /example/analytics/queries/16-theta-join.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // For each Arizona brewery get the brewery's name, location, and a list of 3 | // competitors' names -- where competitors are other breweries that are 4 | // geographically close to their location 5 | { 6 | "statement": "SELECT bw1.name AS brewer, bw1.geo AS location, (SELECT VALUE bw2.name FROM breweries bw2 WHERE bw2.name != bw1.name AND abs(bw1.geo.lat - bw2.geo.lat) <= 0.1 AND abs(bw2.geo.lon - bw1.geo.lon) <= 0.1) AS competitors FROM breweries bw1 WHERE bw1.state = 'Arizona' ORDER BY bw1.name LIMIT 3", 7 | "pretty": true 8 | } 9 | -------------------------------------------------------------------------------- /example/analytics/queries/17-existential-quantification.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Find those breweries whose beers include at least one IPA and return the 3 | // brewery’s name, phone number, and complete list of beer names and associated 4 | // alcohol levels. 5 | { 6 | "statement": "WITH nested_breweries AS ( SELECT bw.name AS brewer, bw.phone, ( SELECT br.name, br.abv FROM beers br WHERE br.brewery_id = meta(bw).id ORDER BY br.name) AS beers FROM breweries bw) SELECT VALUE nb FROM nested_breweries nb WHERE (SOME b IN nb.beers SATISFIES b.name LIKE '%IPA%') ORDER BY nb.brewer LIMIT 2", 7 | "pretty": true 8 | } 9 | 10 | -------------------------------------------------------------------------------- /example/analytics/queries/18-universal-quantification.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Find those breweries that only have seriously strong beers 3 | { 4 | "statement": "WITH nested_breweries AS ( SELECT bw.name AS brewer, bw.phone, ( SELECT br.name, br.abv FROM beers br WHERE br.brewery_id = meta(bw).id ORDER BY br.name) AS beers FROM breweries bw) SELECT VALUE nb FROM nested_breweries nb WHERE (EVERY b IN nb.beers SATISFIES b.abv >= 10) AND ARRAY_COUNT(nb.beers) > 0 ORDER BY nb.brewer LIMIT 5", 5 | "pretty": true 6 | } 7 | 8 | -------------------------------------------------------------------------------- /example/analytics/queries/19-simple-aggregation.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Compute the total number of beers in a SQL-like way 3 | { 4 | "statement": "SELECT COUNT(*) AS num_beers FROM beers" 5 | } 6 | 7 | -------------------------------------------------------------------------------- /example/analytics/queries/20-simple-aggregation-unwrapped-value.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Compute the total number of beers and return unwrapped value 3 | { 4 | "statement": "SELECT VALUE COUNT(b) FROM beers b" 5 | } 6 | 7 | -------------------------------------------------------------------------------- /example/analytics/queries/21-simple-aggregation-explicit.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Compute the total number of beers with explicit aggregate function 3 | { 4 | "statement": "SELECT VALUE ARRAY_COUNT((SELECT b FROM beers b))" 5 | } 6 | 7 | -------------------------------------------------------------------------------- /example/analytics/queries/22-grouping-and-aggregation.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // For each brewery that offers more than 30 beers, the following group-by or 3 | // aggregate query reports the number of beers that it offers 4 | { 5 | "statement": "SELECT br.brewery_id, COUNT(*) AS num_beers FROM beers br GROUP BY br.brewery_id HAVING COUNT(*) > 30 ORDER BY COUNT(*) DESC" 6 | } 7 | -------------------------------------------------------------------------------- /example/analytics/queries/23-grouping-and-aggregation-with-hint.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // For each brewery that offers more than 30 beers, the following group-by or 3 | // aggregate query reports the number of beers that it offers. With a 4 | // hash-based aggregation hint. 5 | { 6 | "statement": "SELECT br.brewery_id, COUNT(*) AS num_beers FROM beers br /*+ hash */ GROUP BY br.brewery_id HAVING COUNT(*) > 30 ORDER BY COUNT(*) DESC" 7 | } 8 | -------------------------------------------------------------------------------- /example/analytics/queries/24-grouping-and-limits.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Return the top three breweries based on their numbers of offered beers. Also 3 | // illustrate the use of multiple aggregate functions to compute various 4 | // alcohol content statistics for their beers 5 | { 6 | "statement": "SELECT bw.name, COUNT(*) AS num_beers, AVG(br.abv) AS abv_avg, MIN(br.abv) AS abv_min, MAX(br.abv) AS abv_max FROM breweries bw, beers br WHERE br.brewery_id = meta(bw).id GROUP BY bw.name ORDER BY num_beers DESC LIMIT 3" 7 | } 8 | -------------------------------------------------------------------------------- /example/analytics/queries/25-named-parameters.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Find the same brewery information but specify name as parameter 3 | { 4 | "statement": "SELECT VALUE bw FROM breweries bw WHERE bw.name = $name", 5 | "$name": "Kona Brewing", 6 | "pretty": true 7 | } 8 | -------------------------------------------------------------------------------- /example/analytics/queries/26-positional-parameters.json: -------------------------------------------------------------------------------- 1 | // vim: ft=javascript 2 | // Find the same brewery information but specify name as parameter 3 | { 4 | "statement": "SELECT VALUE bw FROM breweries bw WHERE bw.name = ?", 5 | "args": ["Kona Brewing"], 6 | "pretty": true 7 | } 8 | -------------------------------------------------------------------------------- /example/crypto/.gitignore: -------------------------------------------------------------------------------- 1 | openssl_symmetric_decrypt 2 | openssl_symmetric_encrypt 3 | -------------------------------------------------------------------------------- /example/crypto/Makefile: -------------------------------------------------------------------------------- 1 | LDFLAGS=-lcouchbase -lm 2 | CFLAGS=-g 3 | 4 | OPENSSL_LDFLAGS=$(shell pkg-config --libs openssl) ${LDFLAGS} 5 | OPENSSL_CFLAGS=$(shell pkg-config --cflags openssl) ${CFLAGS} 6 | 7 | all: openssl_symmetric_encrypt openssl_symmetric_decrypt 8 | 9 | openssl_symmetric_encrypt: openssl_symmetric_encrypt.c openssl_symmetric_provider.c common_provider.c 10 | ${CC} ${OPENSSL_CFLAGS} ${OPENSSL_LDFLAGS} -o $@ $^ 11 | 12 | openssl_symmetric_decrypt: openssl_symmetric_decrypt.c openssl_symmetric_provider.c common_provider.c 13 | ${CC} ${OPENSSL_CFLAGS} ${OPENSSL_LDFLAGS} -o $@ $^ 14 | -------------------------------------------------------------------------------- /example/crypto/common_provider.c: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2018-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "common_provider.h" 19 | 20 | char *common_aes256_key_id = "mykeyid"; 21 | 22 | uint8_t *common_hmac_sha256_key = "myauthpassword"; 23 | 24 | uint8_t common_aes256_key[AES256_KEY_SIZE] = "!mysecretkey#9^5usdk39d&dlf)03sL"; 25 | uint8_t common_aes256_iv[AES256_IV_SIZE] = {0x65, 0xe7, 0x66, 0xbe, 0x35, 0xb2, 0xd2, 0x52, 26 | 0x2b, 0x2e, 0x7e, 0x8e, 0x99, 0x9, 0x8d, 0xa9}; 27 | -------------------------------------------------------------------------------- /example/crypto/common_provider.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2018-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef _COMMON_PROVIDER_H 19 | #define _COMMON_PROVIDER_H 20 | 21 | #include 22 | 23 | extern char *common_aes256_key_id; 24 | 25 | #define AES256_KEY_SIZE 32 26 | #define AES256_IV_SIZE 16 27 | 28 | extern uint8_t common_aes256_key[AES256_KEY_SIZE]; 29 | extern uint8_t common_aes256_iv[AES256_IV_SIZE]; 30 | 31 | extern uint8_t *common_hmac_sha256_key; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /example/crypto/openssl_symmetric_provider.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2018-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef _OPENSSL_SYMMETRIC_PROVIDER_H 19 | #define _OPENSSL_SYMMETRIC_PROVIDER_H 20 | 21 | #include 22 | #include 23 | 24 | #include "common_provider.h" 25 | 26 | void osp_initialize(); 27 | lcbcrypto_PROVIDER *osp_create(); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /example/fts/.gitignore: -------------------------------------------------------------------------------- 1 | fts 2 | -------------------------------------------------------------------------------- /example/fts/build-queries.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | 3 | # Copyright 2018 Couchbase, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | require 'json' 18 | 19 | paths = Dir[File.join(__dir__, 'queries', '*.json')].sort 20 | File.open(File.join(__dir__, 'queries.h'), 'w+') do |out| 21 | out.puts("// This file was generated by queries.rb") 22 | out.puts("typedef struct fts_query_str { const char *comment; size_t query_len; const char *query; } fts_query_str;") 23 | out.puts("size_t num_queries = #{paths.size};") 24 | out.puts("fts_query_str queries[#{paths.size + 1}] = {") 25 | paths.each do |path| 26 | lines = File.readlines(path) 27 | comment = lines[1].gsub(%r{^//\s*}, '').strip 28 | query = lines.reject { |line| line.start_with?('//') }.join 29 | query_str = JSON.generate(JSON.parse(query)) 30 | out.puts("{#{comment.inspect},\n #{query_str.size},\n #{query_str.inspect}},\n\n") 31 | end 32 | out.puts("{NULL, 0, NULL}};") 33 | end 34 | -------------------------------------------------------------------------------- /example/fts/queries/00-simple-text-query.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Simple Text Query on a single word, targeting an index with dynamic fields not stored. 3 | { 4 | "indexName": "travel-sample-index-unstored", 5 | "size": 10, 6 | "highlight": { 7 | "style": "html" 8 | }, 9 | "query": { 10 | "match": "swanky" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example/fts/queries/01-simple-text-query-on-non-default-index.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Simple Text Query on Non-Default Index, specifying an index that consists only of content derived from a specific field from a specific document-type. 3 | { 4 | "indexName": "travel-sample-index-hotel-description", 5 | "size": 10, 6 | "query": { 7 | "match": "swanky" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/fts/queries/02-simple-text-query-on-stored-field.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Simple Text Query on Stored Field, specifying the field to be searched; targeting an index with dynamic fields stored, to ensure that field-content is included in the return object. 3 | { 4 | "indexName": "travel-sample-index-stored", 5 | "size": 10, 6 | "highlight": { 7 | "style": "html" 8 | }, 9 | "query": { 10 | "field": "destinationairport", 11 | "match": "MDG" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/fts/queries/03-match-query-with-facet.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Match Query with Facet, showing how query-results can be displayed either by row or by hits; and demonstrating use of a facet, which provides aggregation-data. 3 | { 4 | "indexName": "travel-sample-index-stored", 5 | "highlight": { 6 | "style": "html" 7 | }, 8 | "size": 10, 9 | "query": { 10 | "field": "reviews.content", 11 | "match": "La Rue Saint Denis!!" 12 | }, 13 | "facets": { 14 | "Countries Referenced": { 15 | "size": 5, 16 | "field": "country" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /example/fts/queries/04-docid-query.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // DocId Query, showing results of a query on two document IDs. 3 | { 4 | "indexName": "travel-sample-index-unstored", 5 | "query": { 6 | "ids": [ 7 | "hotel_26223", 8 | "hotel_28960" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /example/fts/queries/05-unanalyzed-term-query-with-fuzziness-level-of-0.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Unanalyzed Term Query with Fuzziness Level of 0, demonstrating how to query on a term with no analysis. Zero fuzziness is specified, to ensure that matches are exact. 3 | { 4 | "indexName": "travel-sample-index-stored", 5 | "size": 50, 6 | "highlight": { 7 | "style": "html" 8 | }, 9 | "query": { 10 | "field": "reviews.content", 11 | "term": "sushi" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/fts/queries/06-unanalyzed-term-query-with-fuzziness-level-of-2.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Unanalyzed Term Query with Fuzziness Level of 2, which is almost identical to the immediately preceding query; but which this time specifies a fuzziness factor of 2, allowing partial matches to be made. The output from this query can be compared to that of the one immediately preceding. 3 | { 4 | "indexName": "travel-sample-index-stored", 5 | "size": 50, 6 | "highlight": { 7 | "style": "html" 8 | }, 9 | "query": { 10 | "field": "reviews.content", 11 | "fuzziness": 2, 12 | "term": "sushi" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /example/fts/queries/07-match-phrase-query.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Match Phrase Query, using Analysis, for searching on a phrase. 3 | { 4 | "indexName": "travel-sample-index-stored", 5 | "size": 10, 6 | "highlight": { 7 | "style": "html" 8 | }, 9 | "query": { 10 | "field": "description", 11 | "match_phrase": "Eiffel Tower" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/fts/queries/08-phrase-query.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Phrase Query, without Analysis, for searching on a phrase without analysis supported. 3 | { 4 | "indexName": "travel-sample-index-stored", 5 | "size": 10, 6 | "highlight": { 7 | "style": "html" 8 | }, 9 | "query": { 10 | "field": "description", 11 | "terms": [ 12 | "dorm", 13 | "rooms" 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /example/fts/queries/09-query-string-query.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Query String Query, showing how a query string is specified as search-input. 3 | { 4 | "indexName": "travel-sample-index-unstored", 5 | "size": 10, 6 | "query": { 7 | "query": "description: Imperial" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/fts/queries/10-conjunction-query.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Conjunction Query, whereby two separate queries are defined and then run as part of the search, with only the matches returned by both included in the result-object. 3 | { 4 | "indexName": "travel-sample-index-stored", 5 | "size": 10, 6 | "highlight": { 7 | "style": "html" 8 | }, 9 | "query": { 10 | "conjuncts": [ 11 | { 12 | "field": "reviews.content", 13 | "match": "La Rue Saint Denis!!" 14 | }, 15 | { 16 | "field": "description", 17 | "match": "boutique" 18 | } 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example/fts/queries/11-wild-card-query.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Wild Card Query, whereby a wildcard is used in the string submitted for the search. 3 | { 4 | "indexName": "travel-sample-index-stored", 5 | "size": 10, 6 | "highlight": { 7 | "style": "html" 8 | }, 9 | "query": { 10 | "field": "description", 11 | "wildcard": "bouti*ue" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/fts/queries/12-numeric-range-query.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Numeric Range Query, whereby minimum and maximum numbers are specified, and matches within the range returned. 3 | { 4 | "indexName": "travel-sample-index-unstored", 5 | "size": 10, 6 | "query": { 7 | "field": "id", 8 | "max": 10200.0, 9 | "min": 10100.0 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /example/fts/queries/13-regexp-query.json: -------------------------------------------------------------------------------- 1 | // -*- mode: js; -*- 2 | // Regexp Query, whereby a regular expression is submitted, to generate the conditions for successful matches. 3 | { 4 | "indexName": "travel-sample-index-stored", 5 | "size": 10, 6 | "highlight": { 7 | "style": "html" 8 | }, 9 | "query": { 10 | "field": "description", 11 | "regexp": "[a-z]" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/instancepool/pool.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2013-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef POOL_H 19 | #define POOL_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace lcb 27 | { 28 | 29 | class Pool 30 | { 31 | public: 32 | /** 33 | * Create a new pool to use across threads 34 | * @param options The options used to initialize the instance 35 | * @param items How many items should be in the pool 36 | */ 37 | Pool(const lcb_CREATEOPTS *options, size_t items = 10); 38 | virtual ~Pool(); 39 | 40 | /**Get an instance from the pool. You should call #push() when you are 41 | * done with the instance 42 | * @return an lcb_INSTANCE *instance */ 43 | lcb_INSTANCE *pop(); 44 | 45 | /**Release an instance back into the pool 46 | * @param instance The instance to release */ 47 | void push(lcb_INSTANCE *instance); 48 | 49 | // Connect all the instances in the pool. This should be called once the 50 | // pool has been constructed 51 | lcb_STATUS connect(); 52 | 53 | protected: 54 | /**Function called after the instance is created. You may 55 | * customize the instance here with e.g. lcb_set_cookie() 56 | * @param instance the newly created instance */ 57 | virtual void initialize(lcb_INSTANCE *instance) = 0; 58 | 59 | private: 60 | pthread_mutex_t mutex; 61 | pthread_cond_t cond; 62 | std::queue< lcb_INSTANCE * > instances; 63 | 64 | // List of all instances 65 | std::vector< lcb_INSTANCE * > all_instances; 66 | size_t initial_size; 67 | }; 68 | } // namespace lcb 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /example/minimal/.gitignore: -------------------------------------------------------------------------------- 1 | query 2 | -------------------------------------------------------------------------------- /example/minimal/cJSON.c: -------------------------------------------------------------------------------- 1 | ../../contrib/cJSON/cJSON.c -------------------------------------------------------------------------------- /example/minimal/cJSON.h: -------------------------------------------------------------------------------- 1 | ../../contrib/cJSON/cJSON.h -------------------------------------------------------------------------------- /example/tracing/.gitignore: -------------------------------------------------------------------------------- 1 | tracing 2 | views 3 | -------------------------------------------------------------------------------- /example/tracing/Makefile: -------------------------------------------------------------------------------- 1 | LDFLAGS=-lcouchbase -lm 2 | CFLAGS=-g 3 | 4 | all: tracing views 5 | 6 | tracing: tracing.c cJSON.c 7 | 8 | views: views.c cJSON.c 9 | -------------------------------------------------------------------------------- /example/tracing/cJSON.c: -------------------------------------------------------------------------------- 1 | ../../contrib/cJSON/cJSON.c -------------------------------------------------------------------------------- /example/tracing/cJSON.h: -------------------------------------------------------------------------------- 1 | ../../contrib/cJSON/cJSON.h -------------------------------------------------------------------------------- /example/users/README: -------------------------------------------------------------------------------- 1 | This sample demonstrates how to manage user accounts. 2 | 3 | $ cc -lcouchbase users.c 4 | 5 | $ ./a.out couchbase://192.168.1.194 Administrator password 6 | 1. Create account 'cbtestuser' with predefined set of roles 7 | HTTP status: 200 8 | Server: Couchbase Server 9 | Pragma: no-cache 10 | Date: Fri, 23 Jun 2017 12:39:52 GMT 11 | Content-Type: application/json 12 | Content-Length: 2 13 | Cache-Control: no-cache 14 | "" 15 | 2. Retrieve list of all accounts in the cluster 16 | HTTP status: 200 17 | Transfer-Encoding: chunked 18 | Server: Couchbase Server 19 | Pragma: no-cache 20 | Date: Fri, 23 Jun 2017 12:39:52 GMT 21 | Content-Type: application/json 22 | Cache-Control: no-cache 23 | [ 24 | { 25 | "name": "TestUser", 26 | "id": "cbtestuser", 27 | "domain": "local", 28 | "roles": [ 29 | { 30 | "role": "bucket_admin", 31 | "bucket_name": "default" 32 | }, 33 | { 34 | "role": "cluster_admin" 35 | } 36 | ] 37 | } 38 | ] 39 | 40 | 3. Remove account 'cbtestuser' 41 | HTTP status: 200 42 | Server: Couchbase Server 43 | Pragma: no-cache 44 | Date: Fri, 23 Jun 2017 12:39:52 GMT 45 | Content-Type: application/json 46 | Content-Length: 2 47 | Cache-Control: no-cache 48 | "" 49 | -------------------------------------------------------------------------------- /include/libcouchbase/assert.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2013-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | #ifndef LIBCOUCHBASE_ASSERT_H 18 | #define LIBCOUCHBASE_ASSERT_H 1 19 | 20 | #ifdef NDEBUG 21 | #include 22 | #include 23 | 24 | #define lcb_assert(a) \ 25 | if (!(a)) { \ 26 | fprintf(stderr, "FATAL ERROR:\n"); \ 27 | fprintf(stderr, " libcouchbase experienced an unrecoverable error and terminates the program\n"); \ 28 | fprintf(stderr, " to avoid undefined behavior.\n"); \ 29 | fprintf(stderr, " The program should have generated a \"corefile\" which may used\n"); \ 30 | fprintf(stderr, " to gather more information about the problem.\n"); \ 31 | fprintf(stderr, " If your system doesn't create \"corefiles\" I can tell you that the\n"); \ 32 | fprintf(stderr, " assertion failed in %s at line %d\n", __FILE__, __LINE__); \ 33 | abort(); \ 34 | } 35 | #else 36 | #include 37 | #define lcb_assert(a) assert(a) 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /include/libcouchbase/configuration.h.in: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2010-2012 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef LIBCOUCHBASE_CONFIGURATION_H 19 | #define LIBCOUCHBASE_CONFIGURATION_H 1 20 | #define LCB_VERSION_STRING "@LCB_VERSION@" 21 | #define LCB_VERSION @LCB_VERSION_HEX@ 22 | #define LCB_VERSION_CHANGESET "@LCB_VERSION_CHANGESET@" 23 | #endif 24 | -------------------------------------------------------------------------------- /include/libcouchbase/plugins/io/wsaerr-inl.c: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2014-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "wsaerr.h" 19 | 20 | static int 21 | wsaerr_map_impl(DWORD in) 22 | { 23 | switch (in) { 24 | case WSAECONNRESET: 25 | return ECONNRESET; 26 | 27 | case WSAECONNABORTED: 28 | case WSA_OPERATION_ABORTED: 29 | return ECONNABORTED; 30 | 31 | case WSA_NOT_ENOUGH_MEMORY: 32 | return ENOMEM; 33 | 34 | case WSAEWOULDBLOCK: 35 | case WSA_IO_PENDING: 36 | return EWOULDBLOCK; 37 | 38 | case WSAEINVAL: 39 | return EINVAL; 40 | 41 | case WSAEINPROGRESS: 42 | return EINPROGRESS; 43 | 44 | case WSAEALREADY: 45 | return EALREADY; 46 | 47 | case WSAEISCONN: 48 | return EISCONN; 49 | 50 | case WSAENOTCONN: 51 | case WSAESHUTDOWN: 52 | return ENOTCONN; 53 | 54 | case WSAECONNREFUSED: 55 | return ECONNREFUSED; 56 | 57 | case WSAEINTR: 58 | return EINTR; 59 | 60 | 61 | case WSAENETDOWN: 62 | case WSAENETUNREACH: 63 | case WSAEHOSTUNREACH: 64 | case WSAEHOSTDOWN: 65 | return ENETUNREACH; 66 | 67 | case WSAETIMEDOUT: 68 | return ETIMEDOUT; 69 | 70 | case WSAENOTSOCK: 71 | return ENOTSOCK; 72 | 73 | default: 74 | return EINVAL; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /include/libcouchbase/visibility.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright (C) 2011 Couchbase, Inc 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | #ifndef LIBCOUCHBASE_VISIBILITY_H 18 | #define LIBCOUCHBASE_VISIBILITY_H 19 | 20 | #ifdef LIBCOUCHBASE_STATIC 21 | #define LIBCOUCHBASE_API 22 | #define LCB_EXTERN_VAR extern 23 | #define LCB_CLASS_EXPORT 24 | #else 25 | 26 | #ifdef LIBCOUCHBASE_INTERNAL 27 | #ifdef __SUNPRO_C 28 | #define LIBCOUCHBASE_API __global 29 | #define LCB_CLASS_EXPORT LIBCOUCHBASE_API 30 | #elif defined(HAVE_VISIBILITY) && HAVE_VISIBILITY 31 | #define LIBCOUCHBASE_API __attribute__((visibility("default"))) 32 | #define LCB_CLASS_EXPORT LIBCOUCHBASE_API 33 | #elif defined(_MSC_VER) 34 | #define LIBCOUCHBASE_API extern __declspec(dllexport) 35 | #define LCB_CLASS_EXPORT __declspec(dllexport) 36 | #else 37 | #define LIBCOUCHBASE_API 38 | #define LCB_CLASS_EXPORT 39 | #endif /* compiler version */ 40 | 41 | #else /* !LIBCOUCHBASE_INTERNAL */ 42 | #ifdef _MSC_VER 43 | #define LIBCOUCHBASE_API extern __declspec(dllimport) 44 | #define LCB_CLASS_EXPORT __declspec(dllimport) 45 | #else 46 | #define LIBCOUCHBASE_API 47 | #define LCB_CLASS_EXPORT 48 | #endif 49 | #endif /* LIBCOUCHBASE_INTERNAL */ 50 | 51 | /* Define LCB_EXTERN_VAR only if !LIBCOUCHBASE_STATIC */ 52 | #ifdef _MSC_VER 53 | /* Already includes 'extern' in LIBCOUCHBASE_API def, don't use it twice! */ 54 | #define LCB_EXTERN_VAR 55 | #else 56 | #define LCB_EXTERN_VAR extern 57 | #endif /* _MSC_VER */ 58 | #endif /* !LIBCOUCHBASE_STATIC */ 59 | 60 | /** 61 | * This symbol declares internal APIs as accessible from other modules. 62 | * It should still not be used. 63 | */ 64 | #define LCB_INTERNAL_API LIBCOUCHBASE_API 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /include/memcached/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2003, Danga Interactive, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following disclaimer 13 | in the documentation and/or other materials provided with the 14 | distribution. 15 | 16 | * Neither the name of the Danga Interactive nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /include/memcached/README: -------------------------------------------------------------------------------- 1 | This directory contains headerfiles copied from 2 | git://github.com/memcached/memcached.git. They are only included to 3 | make it easier to build the software without having to download these 4 | headers separately. Please do not change the files in this directory, but 5 | rather copy a new set from the repository if you need to upgrade the 6 | content. 7 | 8 | Cheers, 9 | 10 | Trond Norbye -------------------------------------------------------------------------------- /packaging/README: -------------------------------------------------------------------------------- 1 | These files contain the underlying metadata templates for building deb and 2 | rpm packages. To build a local package, do `make dist-deb` or `make dist-rpm` 3 | from within the top level directory. 4 | 5 | To build public signed packages, inspect the 6 | [lcbpackage](https://github.com/couchbaselabs/lcbpackage) for the necessary 7 | tooling 8 | -------------------------------------------------------------------------------- /packaging/abicheck/.gitignore: -------------------------------------------------------------------------------- 1 | *.xml 2 | compat_reports/* 3 | logs/* 4 | -------------------------------------------------------------------------------- /packaging/abicheck/Makefile: -------------------------------------------------------------------------------- 1 | OLDVER ?= $(shell git tag --list --sort=-v:refname | head -1) 2 | NEWVER ?= $(shell git describe) 3 | NEWROOT ?= $(shell realpath ../../../libcouchbase-${NEWVER}) 4 | OLDROOT ?= $(shell realpath ../../../libcouchbase-${OLDVER}) 5 | 6 | all: report 7 | 8 | templates: 9 | PREFIX=${NEWROOT} VERSION=${NEWVER} erb -P -T 2 template.xml.erb > ${NEWVER}.xml 10 | PREFIX=${OLDROOT} VERSION=${OLDVER} erb -P -T 2 template.xml.erb > ${OLDVER}.xml 11 | 12 | report: 13 | abi-compliance-checker -lib libcouchbase -old ${OLDVER}.xml -new ${NEWVER}.xml 14 | -------------------------------------------------------------------------------- /packaging/abicheck/README.md: -------------------------------------------------------------------------------- 1 | # Checking ABI compliance 2 | 3 | This contains some utilities for running `abi-compliance-checker` (which 4 | you need to install). It will generate an HTML file in the `compat_reports` 5 | directory which compares the ABI between different libcouchbase versions 6 | 7 | ## Running 8 | 9 | Ensure you have the `abi-compliance-checker` package installed 10 | 11 | Run `make`, defining these `make` variables: 12 | 13 | * `OLDVER` - Name of the old version (for display purposes) 14 | * `NEWVER` - Name of the new version (for display purposes) 15 | * `OLDROOT` - Installation root of the old version, e.g. `/usr/local/libcouchbase-2.4.0` 16 | * `NEWROOT` - Installation root of the new version, e.g. `/usr/local/libcouchbase-master` 17 | 18 | e.g. 19 | 20 | ``` 21 | make \ 22 | OLDVER=2.3.0 NEWVER=2.4.3 \ 23 | OLDROOT=/sources/libcouchbase-2.3.0/inst NEWROOT=/sources/lcb-master/inst 24 | ``` 25 | 26 | Then open the generated HTML file in the `compat_reports` directory with your favorite 27 | browser. 28 | -------------------------------------------------------------------------------- /packaging/abicheck/template.xml.erb: -------------------------------------------------------------------------------- 1 | <%= ENV['VERSION'] %> 2 | 3 | 4 | <% Dir["#{ENV['PREFIX']}/include/**/*.h"].each do |hdr| %> 5 | <%= hdr %> 6 | <% end %> 7 | 8 | 9 | <%= ENV['PREFIX'] %>/lib/libcouchbase.so 10 | 11 | -------------------------------------------------------------------------------- /packaging/deb/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /packaging/deb/copyright: -------------------------------------------------------------------------------- 1 | Format-Specification: http://dep.debian.net/deps/dep5/ 2 | Name: libcouchbase 3 | Maintainer: Couchbase SDK Team 4 | Source: https://github.com/couchbase/libcouchbase 5 | Debianized-Date: Mon, 05 Dec 2011 13:34:18 +0300 6 | 7 | Files: * 8 | Copyright: 2011, Couchbase 9 | License: Apache-2.0 10 | /usr/share/common-licenses/Apache-2.0 11 | -------------------------------------------------------------------------------- /packaging/deb/libcouchbase-dev.docs: -------------------------------------------------------------------------------- 1 | LICENSE 2 | README.markdown 3 | RELEASE_NOTES.markdown 4 | -------------------------------------------------------------------------------- /packaging/deb/package.mk: -------------------------------------------------------------------------------- 1 | .PHONY: dist-deb 2 | 3 | # Defined by CMake. For autotools, these will just be the normal build tree 4 | BUILDROOT ?= $(shell pwd) 5 | SRCROOT ?= $(shell pwd) 6 | 7 | # Variables derived 8 | GITPARSE := $(SRCROOT)/packaging/parse-git-describe.pl 9 | DEB_WORKSPACE := $(BUILDROOT)/build-deb 10 | DEB_DIR := $(DEB_WORKSPACE)/$(PACKAGE)-$(VERSION) 11 | DEB_VERSION := $(shell $(GITPARSE) --deb --input $(REVDESCRIBE)) 12 | TAR_VERSION := $(shell $(GITPARSE) --tar --input $(REVDESCRIBE)) 13 | 14 | dist-deb: dist 15 | cd $(BUILDROOT) 16 | rm -rf $(DEB_WORKSPACE) 17 | mkdir -p $(DEB_DIR) 18 | cp -r $(SRCROOT)/packaging/deb $(DEB_DIR)/debian 19 | cp $(BUILDROOT)/$(PACKAGE)-$(TAR_VERSION).tar.gz $(DEB_WORKSPACE)/$(PACKAGE)_$(DEB_VERSION).orig.tar.gz 20 | (cd $(DEB_WORKSPACE); tar zxvf $(PACKAGE)_$(DEB_VERSION).orig.tar.gz) 21 | (\ 22 | cd $(DEB_DIR); \ 23 | dch \ 24 | --package=libcouchbase \ 25 | --create \ 26 | --newversion="$(DEB_VERSION)" \ 27 | "Release package for $(DEB_VERSION)" && \ 28 | dpkg-buildpackage -rfakeroot ${DEB_FLAGS}\ 29 | ) 30 | mv $(DEB_WORKSPACE)/*.{changes,deb,dsc,tar.gz} `pwd` 31 | rm -rf $(DEB_WORKSPACE) 32 | -------------------------------------------------------------------------------- /packaging/deb/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) 4 | 5 | DH_AC_FLAGS=--buildsystem=cmake -- -DLCB_NO_MOCK=1 -DLCB_BUILD_DTRACE=0 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLCB_USE_HDR_HISTOGRAM=OFF 6 | DH_AT_CMD = dh_auto_build --verbose --parallel -- alltests 7 | ifdef DEB_HOST_MULTIARCH 8 | DH_AC_FLAGS += -DCMAKE_INSTALL_LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) 9 | endif 10 | 11 | %: 12 | dh $@ --verbose --parallel 13 | 14 | override_dh_strip: 15 | dh_strip -plibcouchbase3-tools -plibcouchbase3 -plibcouchbase3-libevent -plibcouchbase3-libev --dbg-package=libcouchbase-dbg 16 | dh_strip --remaining-packages 17 | 18 | override_dh_auto_configure: 19 | # Generate the install files 20 | echo "usr/lib/$(DEB_HOST_MULTIARCH)/libcouchbase.so.*" \ 21 | > debian/libcouchbase3.install 22 | echo "usr/lib/$(DEB_HOST_MULTIARCH)/libcouchbase/libcouchbase_libevent.so" \ 23 | > debian/libcouchbase3-libevent.install 24 | echo "usr/lib/$(DEB_HOST_MULTIARCH)/libcouchbase/libcouchbase_libev.so" \ 25 | > debian/libcouchbase3-libev.install 26 | echo "usr/lib/$(DEB_HOST_MULTIARCH)/libcouchbase.so" \ 27 | > debian/libcouchbase-dev.install 28 | echo "usr/include/*" \ 29 | >> debian/libcouchbase-dev.install 30 | echo "usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/libcouchbase.pc" \ 31 | >> debian/libcouchbase-dev.install 32 | # Generate 'cbc' files 33 | echo "usr/bin/cbc*" \ 34 | > debian/libcouchbase3-tools.install 35 | echo "usr/share/man/man1/cbc*.1*" \ 36 | >> debian/libcouchbase3-tools.install 37 | echo "usr/share/man/man4/cbcrc*.4*" \ 38 | >> debian/libcouchbase3-tools.install 39 | dh_auto_configure $(DH_AC_FLAGS) 40 | 41 | override_dh_auto_test: 42 | $(DH_AT_CMD) 43 | dh_auto_test $@ 44 | 45 | override_dh_installchangelogs: 46 | dh_installchangelogs -plibcouchbase3 --keep RELEASE_NOTES.markdown 47 | -------------------------------------------------------------------------------- /packaging/deb/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /packaging/distinfo/README: -------------------------------------------------------------------------------- 1 | This contains generated version info for non-SCM builds. 2 | -------------------------------------------------------------------------------- /packaging/distinfo/distinfo.cmake.in: -------------------------------------------------------------------------------- 1 | SET(LCB_REVDESCRIBE @LCB_REVDESCRIBE@) 2 | SET(LCB_VERSION_CHANGESET @LCB_VERSION_CHANGESET@) 3 | SET(LCB_VERSION @LCB_VERSION@) 4 | SET(LCB_VERSION_HEX @LCB_VERSION_HEX@) 5 | -------------------------------------------------------------------------------- /packaging/dllversion.rc.in: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define LCB_MAJOR @LCB_VERSION_MAJOR@ 4 | #define LCB_MINOR @LCB_VERSION_MINOR@ 5 | #define LCB_PATCH @LCB_VERSION_PATCH@ 6 | 7 | #define VER_FILEVERSION LCB_MAJOR,LCB_MINOR,LCB_PATCH,0 8 | #define VER_PRODUCT VER_FILEVERSION 9 | 10 | VS_VERSION_INFO VERSIONINFO 11 | FILEVERSION VER_FILEVERSION 12 | PRODUCTVERSION VER_PRODUCT 13 | FILEOS VOS_NT_WINDOWS32 14 | FILETYPE VFT_DLL 15 | FILESUBTYPE VFT2_UNKNOWN 16 | BEGIN 17 | BLOCK "StringFileInfo" 18 | BEGIN 19 | BLOCK "040904B0" 20 | BEGIN 21 | VALUE "CompanyName", "Couchbase, Inc.\0" 22 | VALUE "FileDescription", "Platform/Client driver for Couchbase\0" 23 | 24 | VALUE "LegalCopyright", "Copyright (C) 2014 Couchbase, Inc. " 25 | "You may use this file in accordance with the " 26 | "Apache License 2.0\0" 27 | VALUE "ProductName", "libcouchbase\0" 28 | VALUE "ProductVersion", "@LCB_VERSION@\0" 29 | VALUE "InternalName", "LCB\0" 30 | VALUE "Revision", "@LCB_VERSION_CHANGESET@\0" 31 | END 32 | END 33 | BLOCK "VarFileInfo" 34 | BEGIN 35 | VALUE "Translation", 0x409, 1252 36 | END 37 | END 38 | -------------------------------------------------------------------------------- /packaging/libcouchbase.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=@CMAKE_INSTALL_PREFIX@ 3 | includedir=@CMAKE_INSTALL_PREFIX@/include 4 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 5 | 6 | Name: libcouchbase @LCB_VERSION@ 7 | Description: Couchbase client library 8 | Version: @LCB_VERSION@ 9 | Libs: -L${libdir} -lcouchbase 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /packaging/rpm/package.mk: -------------------------------------------------------------------------------- 1 | .PHONY: dist-rpm 2 | 3 | # Defined by CMake. For autotools, these will just be the normal build tree 4 | BUILDROOT ?= $(shell pwd) 5 | SRCROOT ?= $(shell pwd) 6 | 7 | # Variables derived 8 | GITPARSE := $(SRCROOT)/packaging/parse-git-describe.pl 9 | RPM_WORKSPACE := $(BUILDROOT)/build-rpm 10 | RPM_DIR := $(RPM_WORKSPACE)/ 11 | RPM_VER := $(shell $(GITPARSE) --rpm-ver --input $(REVDESCRIBE)) 12 | RPM_REL := $(shell $(GITPARSE) --rpm-rel --input $(REVDESCRIBE)) 13 | TAR_VERSION := $(shell $(GITPARSE) --tar --input $(REVDESCRIBE)) 14 | 15 | EXTRA_RPMDEFS := 16 | 17 | dist-rpm: dist 18 | rm -rf $(RPM_WORKSPACE) 19 | mkdir -p $(RPM_DIR) 20 | mkdir $(RPM_DIR)/SOURCES 21 | mkdir $(RPM_DIR)/BUILD 22 | mkdir $(RPM_DIR)/RPMS 23 | mkdir $(RPM_DIR)/SRPMS 24 | cp $(BUILDROOT)/$(PACKAGE)-$(TAR_VERSION).tar.gz $(RPM_DIR)/SOURCES 25 | sed \ 26 | 's/@VERSION@/$(RPM_VER)/g;s/@RELEASE@/$(RPM_REL)/g;s/@TARREDAS@/libcouchbase-$(TAR_VERSION)/g' \ 27 | < packaging/rpm/$(PACKAGE).spec.in > $(RPM_WORKSPACE)/$(PACKAGE).spec 28 | 29 | (cd $(RPM_WORKSPACE) && \ 30 | rpmbuild ${RPM_FLAGS} -ba \ 31 | --define "_topdir $(RPM_DIR)" \ 32 | --define "_source_filedigest_algorithm md5" \ 33 | --define "_binary_filedigest_algorithm md5" \ 34 | $(EXTRA_RPMDEFS) \ 35 | $(PACKAGE).spec \ 36 | ) 37 | 38 | mv $(RPM_DIR)/RPMS/*/*.rpm $(BUILDROOT) 39 | mv $(RPM_DIR)/SRPMS/*.rpm $(BUILDROOT) 40 | rm -rf $(RPM_WORKSPACE) 41 | -------------------------------------------------------------------------------- /plugins/io/iocp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF(WIN32) 2 | INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/contrib/win32-defs) 3 | ADD_LIBRARY(couchbase_iocp OBJECT 4 | iocp_iops.c 5 | iocp_loop.c 6 | iocp_timer.c 7 | iocp_util.c) 8 | ADD_DEFINITIONS(-DLIBCOUCHBASE_INTERNAL=1) 9 | ENDIF(WIN32) 10 | -------------------------------------------------------------------------------- /plugins/io/libev/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF(LCB_INSTALL_HEADERS) 2 | INSTALL( 3 | FILES 4 | libev_io_opts.h 5 | DESTINATION 6 | include/libcouchbase) 7 | ENDIF(LCB_INSTALL_HEADERS) 8 | 9 | IF(NOT (HAVE_LIBEV3 OR HAVE_LIBEV4)) 10 | RETURN() 11 | ENDIF() 12 | 13 | 14 | ADD_LIBRARY(couchbase_libev SHARED plugin-libev.c) 15 | SET_TARGET_PROPERTIES(couchbase_libev 16 | PROPERTIES 17 | PREFIX "lib" 18 | IMPORT_PREFIX "lib" 19 | COMPILE_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CORE_CFLAGS} -std=gnu99") 20 | TARGET_LINK_LIBRARIES(couchbase_libev ${LIBEV_LIBRARIES}) 21 | INCLUDE_DIRECTORIES(AFTER ${LIBEV_INCLUDE_DIR}) 22 | 23 | IF(HAVE_LIBEV4) 24 | ADD_DEFINITIONS(-DHAVE_LIBEV4) 25 | ELSE() 26 | ADD_DEFINITIONS(-DHAVE_LIBEV3) 27 | ENDIF() 28 | 29 | INSTALL(TARGETS 30 | couchbase_libev 31 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${LCB_PLUGINS_DIR}") 32 | -------------------------------------------------------------------------------- /plugins/io/libev/libev_io_opts.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2011-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @file 20 | * libev integration with libcouchbase 21 | * @author Sergey Avseyev 22 | */ 23 | 24 | /** 25 | * @ingroup lcb-io-plugin-api 26 | * @defgroup lcb-libev libev 27 | * @brief libev integration 28 | * 29 | * @details 30 | * libcouchbase_create_libev_io_opts() allows you to create an instance 31 | * of the ioopts that will utilize libev. You may either supply an event 32 | * loop (if you'd like to add your own events into the loop), or it will 33 | * create it's own. 34 | * 35 | * @addtogroup lcb-libev 36 | * @{ 37 | */ 38 | #ifndef LIBCOUCHBASE_LIBEV_IO_OPTS_H 39 | #define LIBCOUCHBASE_LIBEV_IO_OPTS_H 1 40 | 41 | #include 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /** 48 | * Create an instance of an event handler that utilize libev for 49 | * event notification. 50 | * 51 | * @param version Set this to 0. This may be used in the future to allow 52 | * variation on the third argument (`void*` currently). 53 | * @param[out] io a pointer to a newly created and initialized event handler 54 | * @param loop the event loop (struct ev_loop *) to hook use (please 55 | * note that you shouldn't reference the event loop from 56 | * multiple threads) 57 | * @return status of the operation 58 | */ 59 | LIBCOUCHBASE_API 60 | lcb_STATUS lcb_create_libev_io_opts(int version, lcb_io_opt_t *io, void *loop); 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | /**@}*/ 66 | #endif 67 | -------------------------------------------------------------------------------- /plugins/io/libevent/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF(LCB_INSTALL_HEADERS) 2 | INSTALL( 3 | FILES 4 | libevent_io_opts.h 5 | DESTINATION 6 | include/libcouchbase) 7 | ENDIF(LCB_INSTALL_HEADERS) 8 | 9 | 10 | IF(NOT (HAVE_LIBEVENT OR HAVE_LIBEVENT2)) 11 | RETURN() 12 | ENDIF() 13 | 14 | IF(HAVE_LIBEVENT2) 15 | ADD_DEFINITIONS(-DHAVE_LIBEVENT2) 16 | INCLUDE_DIRECTORIES(AFTER ${LIBEVENT_INCLUDE_DIR}) 17 | ELSE() 18 | INCLUDE_DIRECTORIES(AFTER ${LIBEVENT_INCLUDE_DIR}) 19 | ADD_DEFINITIONS(-DHAVE_LIBEVENT) 20 | ENDIF() 21 | 22 | IF(LCB_EMBED_PLUGIN_LIBEVENT) 23 | ADD_LIBRARY(couchbase_libevent OBJECT plugin-libevent.c) 24 | SET(LCB_LINK_SPEC "${LCB_LINKS_SPEC} ${LIBEVENT_LIBRARIES}") 25 | ELSE() 26 | ADD_LIBRARY(couchbase_libevent SHARED plugin-libevent.c) 27 | INSTALL(TARGETS couchbase_libevent LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${LCB_PLUGINS_DIR}") 28 | TARGET_LINK_LIBRARIES(couchbase_libevent ${LIBEVENT_LIBRARIES}) 29 | ENDIF() 30 | 31 | LCB_UTIL(couchbase_libevent) 32 | -------------------------------------------------------------------------------- /plugins/io/libevent/libevent_io_opts.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2011-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @file 20 | * libevent integration with libcouchbase 21 | * @author Trond Norbye 22 | */ 23 | 24 | /** 25 | * @ingroup lcb-io-plugin-api 26 | * @defgroup lcb-libevent libevent 27 | * @brief libev integration 28 | * 29 | * lcb_create_libevent_io_opts() allows you to create an instance 30 | * of the ioopts that will utilize libevent. You may either supply an event 31 | * base (if you'd like to add your own events into the loop), or it will 32 | * create its own. 33 | */ 34 | 35 | /** 36 | * @addtogroup lcb-libevent 37 | * @{ 38 | */ 39 | #ifndef LIBCOUCHBASE_LIBEVENT_IO_OPTS_H 40 | #define LIBCOUCHBASE_LIBEVENT_IO_OPTS_H 1 41 | 42 | #include 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /** 49 | * Create an instance of an event handler that utilize libevent for 50 | * event notification. 51 | * 52 | * @param version the API version to use 53 | * @param base the event base (struct event_base *) to hook use (please 54 | * note that you shouldn't reference the event base from 55 | * multiple threads) 56 | * @param io a pointer to a newly created and initialized event handler 57 | * @return status of the operation 58 | */ 59 | LIBCOUCHBASE_API 60 | lcb_STATUS lcb_create_libevent_io_opts(int version, lcb_io_opt_t *io, void *base); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | /**@}*/ 67 | #endif 68 | -------------------------------------------------------------------------------- /plugins/io/libuv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF(LCB_INSTALL_HEADERS) 2 | INSTALL( 3 | FILES 4 | plugin-libuv.c 5 | plugin-internal.h 6 | libuv_compat.h 7 | DESTINATION 8 | include/libcouchbase/plugins/io/libuv) 9 | 10 | INSTALL( 11 | FILES 12 | libuv_io_opts.h 13 | DESTINATION 14 | include/libcouchbase) 15 | ENDIF(LCB_INSTALL_HEADERS) 16 | 17 | IF(NOT HAVE_LIBUV OR LCB_NO_PLUGINS OR NOT LCB_BUILD_LIBUV) 18 | RETURN() 19 | ENDIF() 20 | 21 | ADD_LIBRARY(couchbase_libuv SHARED plugin-libuv.c) 22 | 23 | # The macros abstracting UV versions dynamically inject special signatures. We 24 | # can't have the compiler whine about that. 25 | 26 | # Unfortunately, Older GCC (EL5) barfs at this option. 27 | #IF(CMAKE_COMPILER_IS_GNUCC) 28 | # SET(_lcbuv_cflags "-Wno-unused-parameters") 29 | #ELSE() 30 | # SET(_lcbuv_cflags "") 31 | #ENDIF() 32 | SET_TARGET_PROPERTIES(couchbase_libuv 33 | PROPERTIES 34 | PREFIX "lib" 35 | IMPORT_PREFIX "lib" 36 | COMPILE_FLAGS "${CMAKE_C_FLAGS} ${LCB_CORE_FLAGS} ${_lcbuv_cflags}") 37 | 38 | TARGET_LINK_LIBRARIES(couchbase_libuv ${LIBUV_LIBRARIES} couchbase) 39 | INCLUDE_DIRECTORIES(AFTER ${LIBUV_INCLUDE_DIR}) 40 | ADD_DEFINITIONS(-DLIBCOUCHBASE_INTERNAL=1) 41 | INSTALL(TARGETS 42 | couchbase_libuv 43 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${LCB_PLUGINS_DIR}" 44 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 45 | -------------------------------------------------------------------------------- /plugins/io/select/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_LIBRARY(couchbase_select OBJECT plugin-select.c) 2 | ADD_DEFINITIONS(-DLIBCOUCHBASE_INTERNAL=1) 3 | SET_TARGET_PROPERTIES(couchbase_select 4 | PROPERTIES 5 | COMPILE_FLAGS "${CMAKE_C_FLAGS} ${LCB_CORE_CFLAGS}" 6 | POSITION_INDEPENDENT_CODE TRUE) 7 | IF(LCB_INSTALL_HEADERS) 8 | INSTALL( 9 | FILES 10 | select_io_opts.h 11 | DESTINATION 12 | include/libcouchbase/) 13 | ENDIF(LCB_INSTALL_HEADERS) 14 | -------------------------------------------------------------------------------- /plugins/io/select/select_io_opts.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2013-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef LIBCOUCHBASE_SELECT_IO_OPTS_H 19 | #define LIBCOUCHBASE_SELECT_IO_OPTS_H 1 20 | 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * Create an instance of an event handler that utilize libev for 29 | * event notification. 30 | * 31 | * @return status of the operation 32 | */ 33 | LIBCOUCHBASE_API 34 | lcb_STATUS lcb_create_select_io_opts(int version, lcb_io_opt_t *io, void *loop); 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/capi/key_value_error_context.hh: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2016-2021 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef LIBCOUCHBASE_CAPI_KEY_VALUE_ERROR_CONTEXT_HH 19 | #define LIBCOUCHBASE_CAPI_KEY_VALUE_ERROR_CONTEXT_HH 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | /** 26 | * @private 27 | */ 28 | struct lcb_KEY_VALUE_ERROR_CONTEXT_ { 29 | lcb_STATUS rc; 30 | std::uint16_t status_code; 31 | std::uint32_t opaque; 32 | std::uint64_t cas; 33 | std::string key{}; 34 | std::string bucket{}; 35 | std::string collection{}; 36 | std::string scope{}; 37 | std::string ref{}; 38 | std::string context{}; 39 | std::string endpoint{}; 40 | }; 41 | 42 | #endif // LIBCOUCHBASE_CAPI_KEY_VALUE_ERROR_CONTEXT_HH 43 | -------------------------------------------------------------------------------- /src/ctx-log-inl.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2014-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /* small utility for retrieving host/port information from the CTX */ 19 | static const lcb_host_t *get_ctx_host(const lcbio_CTX *ctx) 20 | { 21 | static lcb_host_t host = {"NOHOST", "NOPORT", 0}; 22 | if (!ctx) { 23 | return &host; 24 | } 25 | if (!ctx->sock) { 26 | return &host; 27 | } 28 | if (!ctx->sock->info) { 29 | return &host; 30 | } 31 | return &ctx->sock->info->ep_remote; 32 | } 33 | 34 | #define CTX_LOGFMT_PRE "<" LCB_LOG_SPEC("%s%s%s:%s") "> (CTX=%p,%s" 35 | #define CTX_LOGFMT CTX_LOGFMT_PRE ") " 36 | #define CTX_LOGID(ctx) \ 37 | (ctx && ctx->sock && ctx->sock->settings->log_redaction) ? LCB_LOG_SD_OTAG : "", \ 38 | (get_ctx_host(ctx)->ipv6 ? "[" : ""), get_ctx_host(ctx)->host, (get_ctx_host(ctx)->ipv6 ? "]" : ""), \ 39 | get_ctx_host(ctx)->port, (ctx && ctx->sock && ctx->sock->settings->log_redaction) ? LCB_LOG_SD_CTAG : "", \ 40 | (void *)ctx, ctx ? ctx->subsys : "" 41 | -------------------------------------------------------------------------------- /src/defer.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2021 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | #include "settings.h" 18 | #include "internal.h" 19 | #include "defer.h" 20 | 21 | namespace lcb 22 | { 23 | lcb_STATUS defer_operation(lcb_INSTANCE *instance, std::function operation) 24 | { 25 | if (instance == nullptr || instance->deferred_operations == nullptr) { 26 | return LCB_ERR_INVALID_ARGUMENT; 27 | } 28 | instance->deferred_operations->emplace_back(std::move(operation)); 29 | return LCB_SUCCESS; 30 | } 31 | 32 | void execute_deferred_operations(lcb_INSTANCE *instance) 33 | { 34 | if (instance == nullptr || instance->deferred_operations == nullptr) { 35 | return; 36 | } 37 | if (instance->settings->conntype != LCB_TYPE_BUCKET) { 38 | return; 39 | } 40 | 41 | while (instance->has_deferred_operations()) { 42 | auto operation = instance->deferred_operations->front(); 43 | instance->deferred_operations->pop_front(); 44 | operation(LCB_SUCCESS); 45 | } 46 | } 47 | 48 | void cancel_deferred_operations(lcb_INSTANCE *instance) 49 | { 50 | if (instance == nullptr || instance->deferred_operations == nullptr) { 51 | return; 52 | } 53 | while (instance->has_deferred_operations()) { 54 | auto operation = instance->deferred_operations->front(); 55 | instance->deferred_operations->pop_front(); 56 | operation(LCB_ERR_REQUEST_CANCELED); 57 | } 58 | } 59 | } // namespace lcb 60 | -------------------------------------------------------------------------------- /src/defer.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2019-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef LCB_DEFER_H 19 | #define LCB_DEFER_H 20 | 21 | #ifdef __cplusplus 22 | #include 23 | 24 | namespace lcb 25 | { 26 | lcb_STATUS defer_operation(lcb_INSTANCE *instance, std::function operation); 27 | void execute_deferred_operations(lcb_INSTANCE *instance); 28 | void cancel_deferred_operations(lcb_INSTANCE *instance); 29 | } // namespace lcb 30 | 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/http/http.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2014-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "http-priv.h" 19 | -------------------------------------------------------------------------------- /src/lcbio/lcbio.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2014-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef LCBIO_H 19 | #define LCBIO_H 20 | #include "connect.h" 21 | #include "manager.h" 22 | #include "ioutils.h" 23 | #include "ctx.h" 24 | #endif 25 | 26 | /** 27 | * @defgroup lcbio I/O 28 | * @brief IO Core 29 | * 30 | * @details 31 | * 32 | * This module represents the I/O core of libcouchbase. Effort has been made 33 | * so that this module in theory is usable outside of libcouchbase. 34 | * 35 | * # Architectural Overview 36 | * 37 | * The I/O core (_LCBIO_) has been designed to support different I/O models and 38 | * operating environments, with the goal of being able to integrate natively 39 | * into such environments with minimal performance loss. Integration is acheived 40 | * through several layers. The first layer is the _IOPS_ system defined in 41 | * and defines integration APIs for different I/O models. 42 | * 43 | * Afterwards, this is flattened and normalized into an _IO Table_ (`lcbio_TABLE`) 44 | * which serves as a context and abstraction layer for unifying those two APIs 45 | * where applicable. 46 | * 47 | * Finally the "End-user" APIs (in this case end-user means the application which 48 | * requests a TCP connection or I/O on a socket) employs the 49 | * `lcbio_connect` and `lcbio_CTX` systems to provide a uniform interface, the 50 | * end result being that the underlying I/O model is completely abstracted. 51 | */ 52 | -------------------------------------------------------------------------------- /src/mc/compress.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2014-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "mcreq.h" 19 | #include "settings.h" 20 | #ifndef LCB_MCCOMPRESS_H 21 | #define LCB_MCCOMPRESS_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * Stores a compressed payload into a packet 29 | * @param pl The pipeline which hosts the packet 30 | * @param pkt The packet which hosts the value 31 | * @param vbuf The user input to be compressed 32 | * @param settings The instance settings 33 | * @param should_compress The pointer, which stores zero if the value is not compressed 34 | * @return 0 if successful, nonzero on error. 35 | */ 36 | int mcreq_compress_value(mc_PIPELINE *pl, mc_PACKET *pkt, const lcb_VALBUF *vbuf, lcb_settings *settings, 37 | int *should_compress); 38 | 39 | /** 40 | * Inflate a compressed value 41 | * @param compressed The value to inflate 42 | * @param ncompressed Size of value to inflate 43 | * @param[out] bytes The inflated value 44 | * @param[out] nbytes The size of the inflated value 45 | * @param[in/out] freeptr Pointer initialized to NULL (or an malloc'd buffer) 46 | * which on output should point to a malloc'd buffer to be freed() when no 47 | * longer required. 48 | * @return 0 if successful, nonzero on error. 49 | */ 50 | int mcreq_inflate_value(const void *compressed, size_t ncompressed, const void **bytes, size_t *nbytes, void **freeptr); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | #endif 56 | -------------------------------------------------------------------------------- /src/metrics/caching_meter.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Couchbase, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LCB_CACHEINGETERS_HH 18 | #define LCB_CACHEINGETERS_HH 19 | 20 | #include "metrics/metrics-internal.h" 21 | #include 22 | #include 23 | 24 | namespace lcb 25 | { 26 | namespace metrics 27 | { 28 | 29 | class CachingMeter 30 | { 31 | public: 32 | explicit CachingMeter(const lcbmetrics_METER *base); 33 | ~CachingMeter(); 34 | 35 | const lcbmetrics_METER *wrap(); 36 | 37 | const lcbmetrics_VALUERECORDER *findValueRecorder(const char *name, const lcbmetrics_TAG *tags, size_t ntags); 38 | 39 | protected: 40 | lcbmetrics_METER *wrapper_{nullptr}; 41 | const lcbmetrics_METER *base_; 42 | std::unordered_map valueRecorders_; 43 | }; 44 | 45 | } // namespace metrics 46 | } // namespace lcb 47 | 48 | #endif // LCB_CACHEINGETERS_HH 49 | -------------------------------------------------------------------------------- /src/metrics/logging_meter.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Couchbase, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LCB_LOGGINGMETER_H 18 | #define LCB_LOGGINGMETER_H 19 | 20 | #include "metrics/metrics-internal.h" 21 | #include "settings.h" 22 | #include "lcbio/timer-cxx.h" 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace lcb 31 | { 32 | namespace metrics 33 | { 34 | 35 | class LoggingValueRecorder 36 | { 37 | public: 38 | LoggingValueRecorder(); 39 | ~LoggingValueRecorder(); 40 | 41 | const lcbmetrics_VALUERECORDER *wrap(); 42 | 43 | void recordValue(std::uint64_t value); 44 | 45 | Json::Value flush(); 46 | 47 | protected: 48 | lcbmetrics_VALUERECORDER *wrapper_; 49 | struct hdr_histogram *histogram_; 50 | }; 51 | 52 | class LoggingMeter 53 | { 54 | public: 55 | explicit LoggingMeter(lcb_INSTANCE *lcb); 56 | 57 | const lcbmetrics_METER *wrap(); 58 | 59 | const lcbmetrics_VALUERECORDER *findValueRecorder(const char *name, const lcbmetrics_TAG *tags, size_t ntags); 60 | 61 | void flush(); 62 | 63 | protected: 64 | LoggingValueRecorder &findValueRecorder(const char *svcName, const char *opName); 65 | 66 | lcbmetrics_METER *wrapper_{nullptr}; 67 | lcb_settings *settings_; 68 | lcb::io::Timer timer_; 69 | std::unordered_map> valueRecorders_; 70 | }; 71 | 72 | } // namespace metrics 73 | } // namespace lcb 74 | 75 | #endif // LCB_LOGGINGMETER_H 76 | -------------------------------------------------------------------------------- /src/metrics/metrics-internal.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2018-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef LCB_METRICS_INTERNAL_H 19 | #define LCB_METRICS_INTERNAL_H 20 | 21 | #include 22 | #include "mc/mcreq.h" 23 | 24 | #define METRICS_OPS_METER_NAME "db.couchbase.operations" 25 | #define METRICS_SVC_TAG_NAME "db.couchbase.service" 26 | #define METRICS_OP_TAG_NAME "db.operation" 27 | 28 | struct lcbmetrics_VALUERECORDER_ { 29 | void *cookie_; 30 | void (*destructor_)(const lcbmetrics_VALUERECORDER *recorder); 31 | lcbmetrics_RECORD_VALUE record_value_; 32 | }; 33 | 34 | struct lcbmetrics_METER_ { 35 | void *cookie_; 36 | void (*destructor_)(const lcbmetrics_METER *meter); 37 | lcbmetrics_VALUE_RECORDER_CALLBACK value_recorder_; 38 | }; 39 | 40 | void record_kv_op_latency(const char *op, lcb_INSTANCE *instance, mc_PACKET *request); 41 | void record_kv_op_latency_store(lcb_INSTANCE *instance, mc_PACKET *request, lcb_RESPSTORE *response); 42 | void record_http_op_latency(const char *op, const char *svc, lcb_INSTANCE *instance, hrtime_t start); 43 | 44 | #endif // LCB_METRICS_INTERNAL_H 45 | -------------------------------------------------------------------------------- /src/n1ql/n1ql-internal.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2016-2021 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "query_cache.hh" 19 | #include "n1ql-internal.h" 20 | 21 | lcb_QUERY_CACHE *lcb_n1qlcache_create(void) 22 | { 23 | return new lcb_QUERY_CACHE{}; 24 | } 25 | 26 | void lcb_n1qlcache_destroy(lcb_QUERY_CACHE *cache) 27 | { 28 | delete cache; 29 | } 30 | 31 | void lcb_n1qlcache_clear(lcb_QUERY_CACHE *cache) 32 | { 33 | cache->clear(); 34 | } 35 | -------------------------------------------------------------------------------- /src/n1ql/n1ql-internal.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2015-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * This C wrapper over Query Cache classes eventually will go away. 20 | */ 21 | 22 | #ifndef LCB_N1QL_INTERNAL_H 23 | #define LCB_N1QL_INTERNAL_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | typedef struct lcb_QUERY_CACHE_ lcb_QUERY_CACHE; 30 | 31 | lcb_QUERY_CACHE *lcb_n1qlcache_create(void); 32 | void lcb_n1qlcache_destroy(lcb_QUERY_CACHE *); 33 | void lcb_n1qlcache_clear(lcb_QUERY_CACHE *); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /src/n1ql/query_utils.hh: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2016-2021 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef LIBCOUCHBASE_N1QL_QUERY_UTILS_HH 19 | #define LIBCOUCHBASE_N1QL_QUERY_UTILS_HH 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | /** 28 | * @private 29 | */ 30 | class lcb_duration_parse_error : public std::runtime_error 31 | { 32 | public: 33 | explicit lcb_duration_parse_error(const std::string &msg) : std::runtime_error(msg) {} 34 | }; 35 | 36 | /** 37 | * @private 38 | */ 39 | std::chrono::nanoseconds lcb_parse_golang_duration(const std::string &text); 40 | 41 | #endif // LIBCOUCHBASE_N1QL_QUERY_UTILS_HH 42 | -------------------------------------------------------------------------------- /src/rnd.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2018-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "rnd.h" 19 | #include "internal.h" 20 | 21 | #include 22 | 23 | LCB_INTERNAL_API 24 | lcb_U32 lcb_next_rand32(void) 25 | { 26 | static thread_local std::mt19937 gen{std::random_device{}()}; 27 | std::uniform_int_distribution dis; 28 | return dis(gen); 29 | } 30 | 31 | LCB_INTERNAL_API 32 | lcb_U64 lcb_next_rand64(void) 33 | { 34 | static thread_local std::mt19937 gen{std::random_device{}()}; 35 | std::uniform_int_distribution dis; 36 | return dis(gen); 37 | } 38 | -------------------------------------------------------------------------------- /src/rnd.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2018-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef LIBCOUCHBASE_RND_H 19 | #define LIBCOUCHBASE_RND_H 1 20 | 21 | #include "config.h" 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | LCB_INTERNAL_API lcb_U32 lcb_next_rand32(void); 29 | LCB_INTERNAL_API lcb_U64 lcb_next_rand64(void); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/ssl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF(OPENSSL_FOUND AND (NOT LCB_NO_SSL)) 2 | INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) 3 | ADD_DEFINITIONS(${OPENSSL_DEFINITIONS}) 4 | ADD_LIBRARY(lcbssl OBJECT ssl_e.c ssl_c.c ssl_common.c) 5 | SET(lcb_ssl_libs ${OPENSSL_LIBRARIES} PARENT_SCOPE) 6 | SET(lcb_ssl_objs $ PARENT_SCOPE) 7 | LCB_UTIL(lcbssl) 8 | ELSE() 9 | SET(LCB_NO_SSL ON PARENT_SCOPE) 10 | SET(lcb_ssl_libs "" PARENT_SCOPE) 11 | ENDIF() 12 | -------------------------------------------------------------------------------- /src/utilities.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2018-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef LIBCOUCHBASE_UTILITIES_H 19 | #define LIBCOUCHBASE_UTILITIES_H 1 20 | 21 | #include "config.h" 22 | 23 | #ifdef __cplusplus 24 | #include 25 | #include 26 | #include 27 | 28 | namespace lcb 29 | { 30 | namespace flexible_framing_extras 31 | { 32 | lcb_STATUS encode_impersonate_user(const std::string &username, std::vector &flexible_framing_extras); 33 | 34 | lcb_STATUS encode_impersonate_users_extra_privilege(const std::string &privilege, 35 | std::vector &flexible_framing_extras); 36 | } // namespace flexible_framing_extras 37 | } // namespace lcb 38 | 39 | extern "C" { 40 | #endif 41 | 42 | /** 43 | * Added to avoid triggering unexpected behaviour of strdup from stdlib. 44 | * See https://stackoverflow.com/questions/8359966/strdup-returning-address-out-of-bounds 45 | * 46 | * All usages have to be replaced with std::string eventually. 47 | * 48 | * @private 49 | */ 50 | LCB_INTERNAL_API 51 | char *lcb_strdup(const char *); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/vbucket/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_LIBRARY(vbucket-lcb OBJECT vbucket.c ketama.c ${SOURCE_ROOT}/contrib/cJSON/cJSON.c) 2 | LCB_UTIL(vbucket-lcb) 3 | -------------------------------------------------------------------------------- /src/vbucket/aliases.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2014-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef VB_ALIASES_H 19 | #define VB_ALIASES_H 20 | 21 | #define VB_NODESTR(config, index) lcbvb_get_hostport(config, index, LCBVB_SVCTYPE_DATA, LCBVB_SVCMODE_PLAIN) 22 | #define VB_RESTURL(config, index) lcbvb_get_hostport(config, index, LCBVB_SVCTYPE_MGMT, LCBVB_SVCMODE_PLAIN) 23 | #define VB_VIEWSURL(config, index) lcbvb_get_capibase(config, index, LCBVB_SVCMODE_PLAIN) 24 | #define VB_SSLNODESTR(config, index) lcbvb_get_hostport(config, index, LCBVB_SVCTYPE_DATA, LCBVB_SVCMODE_SSL) 25 | #define VB_SSLRESTURL(config, index) lcbvb_get_hostport(config, index, LCBVB_SVCTYPE_MGMT, LCBVB_SVCMODE_SSL) 26 | #define VB_SSLVIEWSURL(config, index) lcbvb_get_capibase(config, index, LCBVB_SVCMODE_SSL) 27 | #define VB_MEMDSTR(config, index, mode) lcbvb_get_hostport(config, index, LCBVB_SVCTYPE_DATA, mode) 28 | #define VB_MGMTSTR(config, index, mode) lcbvb_get_hostport(config, index, LCBVB_SVCTYPE_MGMT, mode) 29 | #define VB_CAPIURL(config, index, mode) lcbvb_get_capibase(config, index, mode) 30 | 31 | #define VB_DISTTYPE(config) (config)->dtype 32 | #define VB_NREPLICAS(config) (config)->nrepl 33 | #define VB_NSERVERS(config) (config)->nsrv 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/vbucket/hash.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2010-2020 NorthScale, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef LIBVBUCKET_HASH_H 19 | #define LIBVBUCKET_HASH_H 1 20 | 21 | #include "config.h" 22 | #include 23 | #include 24 | 25 | uint32_t vb__hash_ketama(const char *key, size_t key_length); 26 | void vb__hash_md5(const char *key, size_t key_length, unsigned char *result); 27 | void *vb__hash_md5_update(void *ctx, const char *key, size_t key_length); 28 | void vb__hash_md5_final(void *ctx, unsigned char *result); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/vbucket/ketama.c: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2014-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #define PROTOTYPES 1 19 | 20 | #define MD5Final vb__MD5_final 21 | #define MD5Init vb__MD5Init 22 | #define MD5Update vb__MD5Update 23 | 24 | #include 25 | #include "rfc1321/md5c-inl.h" 26 | #include "hash.h" 27 | 28 | void vb__hash_md5(const char *key, size_t key_length, unsigned char *result) 29 | { 30 | MD5_CTX ctx; 31 | 32 | MD5Init(&ctx); 33 | MD5Update(&ctx, (unsigned char *)key, (unsigned int)key_length); 34 | MD5Final(result, &ctx); 35 | } 36 | 37 | void *vb__hash_md5_update(void *ctx, const char *key, size_t key_length) 38 | { 39 | if (ctx == NULL) { 40 | ctx = calloc(1, sizeof(MD5_CTX)); 41 | MD5Init(ctx); 42 | } 43 | MD5Update(ctx, (unsigned char *)key, (unsigned int)key_length); 44 | return ctx; 45 | } 46 | 47 | void vb__hash_md5_final(void *ctx, unsigned char *result) 48 | { 49 | if (ctx == NULL) { 50 | return; 51 | } 52 | MD5Final(result, ctx); 53 | free(ctx); 54 | } 55 | 56 | uint32_t vb__hash_ketama(const char *key, size_t key_length) 57 | { 58 | unsigned char digest[16]; 59 | 60 | vb__hash_md5(key, key_length, digest); 61 | 62 | return (uint32_t)((digest[3] << 24) | (digest[2] << 16) | (digest[1] << 8) | digest[0]); 63 | } 64 | -------------------------------------------------------------------------------- /src/vbucket/rfc1321/global.h: -------------------------------------------------------------------------------- 1 | /* GLOBAL.H - RSAREF types and constants 2 | */ 3 | 4 | /* PROTOTYPES should be set to one if and only if the compiler supports 5 | function argument prototyping. 6 | The following makes PROTOTYPES default to 0 if it has not already 7 | been defined with C compiler flags. 8 | */ 9 | #ifndef PROTOTYPES 10 | #define PROTOTYPES 0 11 | #endif 12 | 13 | #include "config.h" 14 | 15 | /* POINTER defines a generic pointer type */ 16 | typedef unsigned char *POINTER; 17 | 18 | /* UINT2 defines a two byte word */ 19 | typedef uint16_t UINT2; 20 | 21 | /* UINT4 defines a four byte word */ 22 | typedef uint32_t UINT4; 23 | 24 | /* PROTO_LIST is defined depending on how PROTOTYPES is defined above. 25 | If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it 26 | returns an empty list. 27 | */ 28 | #if PROTOTYPES 29 | #define PROTO_LIST(list) list 30 | #else 31 | #define PROTO_LIST(list) () 32 | #endif 33 | -------------------------------------------------------------------------------- /src/vbucket/rfc1321/md5.h: -------------------------------------------------------------------------------- 1 | /* MD5.H - header file for MD5C.C 2 | */ 3 | 4 | /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 5 | rights reserved. 6 | 7 | License to copy and use this software is granted provided that it 8 | is identified as the "RSA Data Security, Inc. MD5 Message-Digest 9 | Algorithm" in all material mentioning or referencing this software 10 | or this function. 11 | 12 | License is also granted to make and use derivative works provided 13 | that such works are identified as "derived from the RSA Data 14 | Security, Inc. MD5 Message-Digest Algorithm" in all material 15 | mentioning or referencing the derived work. 16 | 17 | RSA Data Security, Inc. makes no representations concerning either 18 | the merchantability of this software or the suitability of this 19 | software for any particular purpose. It is provided "as is" 20 | without express or implied warranty of any kind. 21 | 22 | These notices must be retained in any copies of any part of this 23 | documentation and/or software. 24 | */ 25 | 26 | /* MD5 context. */ 27 | typedef struct { 28 | UINT4 state[4]; /* state (ABCD) */ 29 | UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ 30 | unsigned char buffer[64]; /* input buffer */ 31 | } MD5_CTX; 32 | 33 | void MD5Init PROTO_LIST((MD5_CTX *)); 34 | void MD5Update PROTO_LIST((MD5_CTX *, unsigned char *, unsigned int)); 35 | void MD5Final PROTO_LIST((unsigned char[16], MD5_CTX *)); 36 | -------------------------------------------------------------------------------- /tests/basic/t_misc.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2011-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "config.h" 19 | #include "internal.h" 20 | #include 21 | #define LIBCOUCHBASE_INTERNAL 1 22 | #include 23 | 24 | class MiscTests : public ::testing::Test 25 | { 26 | }; 27 | 28 | TEST_F(MiscTests, testGetTmpdir) 29 | { 30 | const char *tmpdir = lcb_get_tmpdir(); 31 | ASSERT_FALSE(tmpdir == NULL); 32 | ASSERT_STRNE("", tmpdir); 33 | } 34 | TEST_F(MiscTests, testVersionG) 35 | { 36 | ASSERT_GT(lcb_version_g, (lcb_U32)0); 37 | } 38 | -------------------------------------------------------------------------------- /tests/ioserver/future.cc: -------------------------------------------------------------------------------- 1 | #include "ioserver.h" 2 | using namespace LCBTest; 3 | 4 | Future::Future() 5 | { 6 | failed = false; 7 | } 8 | 9 | void Future::wait() 10 | { 11 | mutex.lock(); 12 | while (!isDone() && !failed) { 13 | cond.wait(mutex); 14 | } 15 | mutex.unlock(); 16 | } 17 | 18 | Future::~Future() 19 | { 20 | mutex.close(); 21 | cond.close(); 22 | } 23 | 24 | void Future::startUpdate() 25 | { 26 | mutex.lock(); 27 | } 28 | 29 | void Future::endUpdate() 30 | { 31 | if (shouldEnd()) { 32 | cond.signal(); 33 | } 34 | mutex.unlock(); 35 | } 36 | 37 | bool Future::checkDone() 38 | { 39 | bool ret; 40 | if (!mutex.tryLock()) { 41 | return false; 42 | } 43 | ret = isDone(); 44 | mutex.unlock(); 45 | return ret; 46 | } 47 | -------------------------------------------------------------------------------- /tests/ioserver/socket.cc: -------------------------------------------------------------------------------- 1 | #include "ioserver.h" 2 | using namespace LCBTest; 3 | 4 | SockFD::SockFD(int sock) 5 | { 6 | assert(sock >= 0); 7 | fd = sock; 8 | naddr = sizeof(sa_local); 9 | int rv = getsockname(fd, (struct sockaddr *)&sa_local, &naddr); 10 | assert(rv == 0); 11 | } 12 | 13 | void SockFD::loadRemoteAddr() 14 | { 15 | socklen_t lentmp = sizeof(sa_remote); 16 | getpeername(*this, (struct sockaddr *)&sa_remote, &lentmp); 17 | } 18 | 19 | void SockFD::close() 20 | { 21 | if (fd != -1) { 22 | shutdown(fd, SHUT_RDWR); 23 | ::closesocket(fd); 24 | fd = -1; 25 | } 26 | } 27 | 28 | SockFD::~SockFD() 29 | { 30 | close(); 31 | } 32 | 33 | SockFD *SockFD::acceptClient() 34 | { 35 | struct sockaddr_storage newaddr; 36 | socklen_t newlen = sizeof(newaddr); 37 | int newsock = accept(*this, (struct sockaddr *)&newaddr, &newlen); 38 | return new SockFD(newsock); 39 | } 40 | 41 | SockFD *SockFD::newListener() 42 | { 43 | struct sockaddr_in addr; 44 | memset(&addr, 0, sizeof(addr)); 45 | 46 | int lsnfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 47 | addr.sin_family = AF_INET; 48 | addr.sin_addr.s_addr = inet_addr("127.0.0.1"); 49 | addr.sin_port = 0; 50 | bind(lsnfd, (struct sockaddr *)&addr, sizeof(addr)); 51 | listen(lsnfd, 5); 52 | return new SockFD(lsnfd); 53 | } 54 | 55 | SockFD *SockFD::newClient(SockFD *server) 56 | { 57 | int sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 58 | assert(sockfd >= 0); 59 | int rv = connect(sockfd, (struct sockaddr *)&server->localAddr4(), sizeof(struct sockaddr_in)); 60 | assert(rv == 0); 61 | return new SockFD(sockfd); 62 | } 63 | 64 | #ifndef _WIN32 65 | std::string SockFD::getHostCommon(sockaddr_storage *ss) 66 | { 67 | struct sockaddr_in *addr = (struct sockaddr_in *)ss; 68 | char buf[4096]; 69 | inet_ntop(AF_INET, &addr->sin_addr, buf, sizeof(*addr)); 70 | return std::string(buf); 71 | } 72 | #else 73 | std::string SockFD::getHostCommon(sockaddr_storage *ss) 74 | { 75 | struct sockaddr_in *inaddr = (struct sockaddr_in *)ss; 76 | char *buf = inet_ntoa(inaddr->sin_addr); 77 | return std::string(buf); 78 | } 79 | #endif 80 | -------------------------------------------------------------------------------- /tests/ioserver/threads-pthreads.cc: -------------------------------------------------------------------------------- 1 | #ifndef _WIN32 2 | #include "threads.h" 3 | #include 4 | #include 5 | #include 6 | 7 | extern "C" { 8 | static void *startfunc(void *arg) 9 | { 10 | Thread *thr = reinterpret_cast< Thread * >(arg); 11 | thr->doRun(); 12 | return NULL; 13 | } 14 | } 15 | 16 | Thread::Thread(StartFunc startfn, void *arg) 17 | { 18 | this->fn = startfn; 19 | this->fnparam = arg; 20 | initialized = true; 21 | pthread_create(&thr, NULL, startfunc, this); 22 | } 23 | 24 | void Thread::close() 25 | { 26 | if (!initialized) { 27 | return; 28 | } 29 | join(); 30 | initialized = false; 31 | } 32 | 33 | Thread::~Thread() 34 | { 35 | close(); 36 | } 37 | 38 | void Thread::join() 39 | { 40 | void *res; 41 | pthread_join(thr, &res); 42 | } 43 | 44 | // Mutex: 45 | Mutex::Mutex() 46 | { 47 | pthread_mutex_init(&mutex, NULL); 48 | initialized = true; 49 | } 50 | 51 | void Mutex::lock() 52 | { 53 | pthread_mutex_lock(&mutex); 54 | } 55 | 56 | bool Mutex::tryLock() 57 | { 58 | return pthread_mutex_trylock(&mutex) == 0; 59 | } 60 | 61 | void Mutex::unlock() 62 | { 63 | pthread_mutex_unlock(&mutex); 64 | } 65 | 66 | void Mutex::close() 67 | { 68 | if (initialized) { 69 | initialized = false; 70 | pthread_mutex_destroy(&mutex); 71 | } 72 | } 73 | 74 | Mutex::~Mutex() 75 | { 76 | close(); 77 | } 78 | 79 | // Condvar 80 | Condvar::Condvar() 81 | { 82 | pthread_cond_init(&cond, NULL); 83 | initialized = true; 84 | } 85 | 86 | void Condvar::wait(Mutex &mutex) 87 | { 88 | pthread_cond_wait(&cond, &mutex.mutex); 89 | } 90 | 91 | void Condvar::signal() 92 | { 93 | pthread_cond_signal(&cond); 94 | } 95 | 96 | void Condvar::close() 97 | { 98 | if (initialized) { 99 | pthread_cond_destroy(&cond); 100 | initialized = false; 101 | } 102 | } 103 | 104 | Condvar::~Condvar() 105 | { 106 | close(); 107 | } 108 | #endif 109 | -------------------------------------------------------------------------------- /tests/ioserver/threads-win32.cc: -------------------------------------------------------------------------------- 1 | #ifdef _WIN32 2 | #include 3 | #include 4 | #include 5 | #include "threads.h" 6 | 7 | extern "C" { 8 | unsigned int __stdcall startfunc(void *param) 9 | { 10 | Thread *thr = reinterpret_cast< Thread * >(param); 11 | thr->doRun(); 12 | return 0; 13 | } 14 | } 15 | 16 | Thread::Thread(StartFunc thrfn, void *param) 17 | { 18 | fn = thrfn; 19 | fnparam = param; 20 | uintptr_t rv; 21 | rv = _beginthreadex(NULL, 0, startfunc, this, 0, NULL); 22 | assert(rv); 23 | hThread = (HANDLE)rv; 24 | initialized = true; 25 | } 26 | 27 | void Thread::join() 28 | { 29 | WaitForSingleObject(hThread, INFINITE); 30 | } 31 | 32 | void Thread::close() 33 | { 34 | if (initialized) { 35 | join(); 36 | CloseHandle(hThread); 37 | initialized = false; 38 | } 39 | } 40 | 41 | Thread::~Thread() 42 | { 43 | close(); 44 | } 45 | 46 | Mutex::Mutex() 47 | { 48 | InitializeCriticalSection(&cs); 49 | initialized = true; 50 | } 51 | 52 | Mutex::~Mutex() 53 | { 54 | close(); 55 | } 56 | 57 | void Mutex::close() 58 | { 59 | if (initialized) { 60 | DeleteCriticalSection(&cs); 61 | initialized = false; 62 | } 63 | } 64 | 65 | void Mutex::lock() 66 | { 67 | EnterCriticalSection(&cs); 68 | } 69 | 70 | bool Mutex::tryLock() 71 | { 72 | return TryEnterCriticalSection(&cs) == TRUE; 73 | } 74 | 75 | void Mutex::unlock() 76 | { 77 | LeaveCriticalSection(&cs); 78 | } 79 | 80 | Condvar::Condvar() 81 | { 82 | InitializeConditionVariable(&cv); 83 | initialized = true; 84 | } 85 | 86 | void Condvar::close() 87 | { 88 | initialized = false; 89 | } 90 | 91 | Condvar::~Condvar() 92 | { 93 | close(); 94 | } 95 | 96 | void Condvar::signal() 97 | { 98 | WakeConditionVariable(&cv); 99 | } 100 | 101 | void Condvar::wait(Mutex &mutex) 102 | { 103 | SleepConditionVariableCS(&cv, &mutex.cs, INFINITE); 104 | } 105 | #endif 106 | -------------------------------------------------------------------------------- /tests/ioserver/threads.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Simple cross-platform thread abstraction 4 | */ 5 | #ifndef _WIN32 6 | #include 7 | #endif 8 | 9 | class Thread 10 | { 11 | public: 12 | typedef void (*StartFunc)(void *); 13 | Thread(StartFunc, void *); 14 | ~Thread(); 15 | void close(); 16 | void join(); 17 | void doRun() 18 | { 19 | fn(fnparam); 20 | } 21 | 22 | private: 23 | StartFunc fn; 24 | void *fnparam; 25 | bool initialized; 26 | #ifdef _WIN32 27 | HANDLE hThread; 28 | #else 29 | pthread_t thr; 30 | #endif 31 | }; 32 | 33 | class Condvar; 34 | class Mutex 35 | { 36 | public: 37 | Mutex(); 38 | ~Mutex(); 39 | void lock(); 40 | void unlock(); 41 | bool tryLock(); 42 | void close(); 43 | 44 | private: 45 | friend class Condvar; 46 | bool initialized; 47 | #ifdef _WIN32 48 | CRITICAL_SECTION cs; 49 | #else 50 | pthread_mutex_t mutex; 51 | #endif 52 | }; 53 | 54 | class Condvar 55 | { 56 | public: 57 | Condvar(); 58 | ~Condvar(); 59 | void signal(); 60 | void wait(Mutex &); 61 | void close(); 62 | 63 | private: 64 | bool initialized; 65 | #ifdef _WIN32 66 | CONDITION_VARIABLE cv; 67 | #else 68 | pthread_cond_t cond; 69 | #endif 70 | }; 71 | -------------------------------------------------------------------------------- /tests/iotests/iotests.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2011-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "testutil.h" 22 | #include "mock-unit-test.h" 23 | #include "mock-environment.h" 24 | 25 | static inline void doLcbCreate(lcb_INSTANCE **instance, const lcb_CREATEOPTS *options, MockEnvironment *env) 26 | { 27 | lcb_STATUS err = lcb_create(instance, options); 28 | ASSERT_EQ(LCB_SUCCESS, err); 29 | env->postCreate(*instance); 30 | } 31 | -------------------------------------------------------------------------------- /tests/mocksupport/server.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2010-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | #ifndef LIBCOUCHBASE_TEST_SERVER_H 18 | #define LIBCOUCHBASE_TEST_SERVER_H 1 19 | #define LCB_TEST_REALCLUSTER_ENV "LCB_TEST_CLUSTER_CONF" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #ifdef _WIN32 26 | #define in_port_t USHORT 27 | #ifndef usleep 28 | #define usleep(us) Sleep((us) / 1000) 29 | #endif 30 | #ifndef sleep 31 | #define sleep(s) Sleep((s)*1000) 32 | #endif 33 | 34 | #include 35 | #else 36 | #define closesocket close 37 | #include 38 | #include 39 | #include 40 | #endif 41 | #include 42 | #include "procutil.h" 43 | 44 | struct test_server_info { 45 | child_process_t process; 46 | char *http; 47 | char *bucket; 48 | char *username; 49 | char *password; 50 | in_port_t port; 51 | struct sockaddr_storage storage; 52 | int sock; 53 | int client; 54 | int is_mock; 55 | }; 56 | 57 | const void *start_test_server(char **cmdline); 58 | const char *get_mock_http_server(const void *); 59 | void get_mock_std_creds(const void *handle, const char **userp, const char **passp); 60 | int is_using_real_cluster(void); 61 | 62 | void shutdown_mock_server(const void *); 63 | 64 | struct lcb_io_opt_st *get_test_io_opts(void); 65 | void setup_test_timeout_handler(void); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /tests/mocksupport/timeout.c: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2012-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | #include "config.h" 18 | #include 19 | /* 20 | * The current test suite should not take more than 8 minutes to run. 21 | * If you're testing on a really slow system you may set the 22 | * environment variable LCB_MAX_TEST_DURATION to the maximum number of 23 | * seconds you'd like the tests to take. 24 | */ 25 | const int max_duration = 480; 26 | 27 | #ifdef _WIN32 28 | static HANDLE hTimer; 29 | void CALLBACK test_timed_out(PVOID lpUnused, BOOLEAN bUnused) 30 | { 31 | (void)lpUnused; 32 | (void)bUnused; 33 | fprintf(stderr, "Tests are taking too long to run. Aborting..\n"); 34 | abort(); 35 | } 36 | #endif 37 | 38 | void setup_test_timeout_handler(void) 39 | { 40 | char *ptr = getenv("LCB_MAX_TEST_DURATION"); 41 | int duration = 0; 42 | if (ptr != NULL) { 43 | duration = atoi(ptr); 44 | } 45 | if (duration == 0) { 46 | duration = max_duration; 47 | } 48 | 49 | #ifdef HAVE_SETITIMER 50 | struct itimerval timer = {.it_value = {.tv_sec = duration}}; 51 | setitimer(ITIMER_REAL, &timer, NULL); 52 | #elif defined(HAVE_ALARM) 53 | alarm(duration); 54 | #elif defined(_WIN32) 55 | CreateTimerQueueTimer(&hTimer, NULL, test_timed_out, NULL, duration * 1000, 0, 0); 56 | #else 57 | /* print an error message so that we're using the duration variable 58 | * and not generate a warning about unused variables ;) */ 59 | fprintf(stderr, "Tests may run longer than %d due to lack of an alarm\n", duration); 60 | #endif 61 | } 62 | -------------------------------------------------------------------------------- /tests/nonio_tests.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2010-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | #include 18 | 19 | int main(int argc, char **argv) 20 | { 21 | ::testing::InitGoogleTest(&argc, argv); 22 | return RUN_ALL_TESTS(); 23 | } 24 | -------------------------------------------------------------------------------- /tests/socktests/t_ctx.cc: -------------------------------------------------------------------------------- 1 | #include "socktest.h" 2 | using namespace LCBTest; 3 | using std::string; 4 | using std::vector; 5 | class SockCtxTest : public SockTest 6 | { 7 | }; 8 | 9 | /** 10 | * While some of the previous tests also used the 'Easy' context implicitly, 11 | * this will try to test some of the more advanced free/destroy functionality. 12 | * 13 | * This mainly relates to freeing the context and inspecting whether any 14 | * callbacks are invoked afterwards. 15 | */ 16 | 17 | TEST_F(SockCtxTest, testClose) 18 | { 19 | ESocket sock; 20 | 21 | loop->connect(&sock); 22 | for (unsigned ii = 0; ii < 100; ++ii) { 23 | sock.put("Hi"); 24 | sock.schedule(); 25 | } 26 | 27 | CtxCloseBreakCondition cbc(&sock); 28 | cbc.closeCtx(); 29 | loop->setBreakCondition(&cbc); 30 | loop->start(); 31 | } 32 | 33 | struct ReleaseInfo { 34 | lcbio_SOCKET *sock; 35 | bool reusable; 36 | ReleaseInfo() 37 | { 38 | sock = NULL; 39 | reusable = false; 40 | } 41 | void reset() 42 | { 43 | sock = NULL; 44 | reusable = false; 45 | } 46 | }; 47 | 48 | extern "C" { 49 | static void release_cb(lcbio_SOCKET *s, int reusable, void *arg) 50 | { 51 | ReleaseInfo *info = (ReleaseInfo *)arg; 52 | if (reusable) { 53 | info->sock = s; 54 | lcbio_ref(s); 55 | } 56 | info->reusable = !!reusable; 57 | } 58 | } 59 | 60 | TEST_F(SockCtxTest, testReleasable) 61 | { 62 | ESocket sock; 63 | loop->connect(&sock); 64 | ReleaseInfo ri; 65 | // Release the socket 66 | lcbio_ctx_close(sock.ctx, release_cb, &ri); 67 | sock.clear(); 68 | ASSERT_TRUE(ri.reusable); 69 | 70 | // Schedule some events on it. It should not be releaseable 71 | sock.assign(ri.sock, LCB_SUCCESS); 72 | sock.put("Hi!"); 73 | sock.schedule(); 74 | ri.reset(); 75 | lcbio_ctx_close(sock.ctx, release_cb, &ri); 76 | sock.clear(); 77 | ASSERT_FALSE(ri.reusable); 78 | } 79 | -------------------------------------------------------------------------------- /tests/start_mock.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | SET lcbdir=%srcdir% 3 | IF "%lcbdir%"=="" ( 4 | SET lcbdir=. 5 | ) 6 | 7 | SET MOCKPATH=%lcbdir%\tests\CouchbaseMock.jar 8 | 9 | java ^ 10 | -client^ 11 | -jar "%MOCKPATH%"^ 12 | --cccp^ 13 | --nodes=4^ 14 | --host=localhost^ 15 | --port=0^ 16 | %* 17 | -------------------------------------------------------------------------------- /tests/start_mock.sh.in: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Copyright 2011 Couchbase, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | # We don't want to run memory debugging on java ;) 19 | unset LD_PRELOAD 20 | unset MALLOC_DEBUG 21 | unset UMEM_DEBUG 22 | 23 | # This is a wrapper script to start the Couchbase Mock server. 24 | # We could have started it directly from the C code, but by using 25 | # a script it's a bit easier to test it manually ;) 26 | if [ -z "$srcdir" ]; then 27 | srcdir="${CMAKE_SOURCE_DIR}" 28 | fi 29 | 30 | for p in "$srcdir/tests" "$srcdir" "tests" "."; do 31 | if [ -f "$p/CouchbaseMock.jar" ]; then 32 | COUCHBASEMOCK="$p/CouchbaseMock.jar" 33 | fi 34 | done 35 | 36 | exec java \ 37 | -client \ 38 | -jar "$COUCHBASEMOCK" \ 39 | --cccp \ 40 | --nodes=4 \ 41 | --host=localhost \ 42 | --port=0 \ 43 | "$@" 44 | -------------------------------------------------------------------------------- /tests/unit_tests.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2010-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | #include "config.h" 18 | #include 19 | 20 | #ifdef NO_COUCHBASEMOCK 21 | class MockTestsAreDisabled : public ::testing::Test 22 | { 23 | }; 24 | TEST_F(MockTestsAreDisabled, MockTestsAreDisabled) 25 | { 26 | fprintf(stderr, "*** WARNING\n"); 27 | fprintf(stderr, "*** libcouchbase Java Mock tests are disabled\n"); 28 | fprintf(stderr, "*** Basic memcached functionality (get, set, etc.) \n"); 29 | fprintf(stderr, "*** will NOT be tested\n"); 30 | } 31 | #define SETUP_MOCK_ENV() 32 | #define setup_test_timeout_handler() 33 | #else 34 | #include "iotests/iotests.h" 35 | #define SETUP_MOCK_ENV() ::testing::AddGlobalTestEnvironment(MockEnvironment::getInstance()) 36 | #endif 37 | 38 | int main(int argc, char **argv) 39 | { 40 | setvbuf(stdout, NULL, _IOLBF, 2048); 41 | setvbuf(stderr, NULL, _IOLBF, 2048); 42 | SETUP_MOCK_ENV(); 43 | ::testing::InitGoogleTest(&argc, argv); 44 | setup_test_timeout_handler(); 45 | return RUN_ALL_TESTS(); 46 | } 47 | -------------------------------------------------------------------------------- /tests/vbucket/confdata/memd_30.json: -------------------------------------------------------------------------------- 1 | {"rev":17,"name":"memd","uri":"/pools/default/buckets/memd?bucket_uuid=15b8be38964d2acd7b2079988b505ac4","streamingUri":"/pools/default/bucketsStreaming/memd?bucket_uuid=15b8be38964d2acd7b2079988b505ac4","nodes":[{"couchApiBase":"http://$HOST:8092/memd","hostname":"$HOST:8091","ports":{"proxy":11211,"direct":11210}}],"nodesExt":[{"services":{"mgmt":8091,"capi":8092,"moxi":11211,"kv":11210,"kvSSL":11207,"capiSSL":18092,"mgmtSSL":18091}}],"nodeLocator":"ketama","uuid":"15b8be38964d2acd7b2079988b505ac4","bucketCapabilitiesVer":"","bucketCapabilities":["cbhello"]} -------------------------------------------------------------------------------- /tests/vbucket/confdata/memd_45.json: -------------------------------------------------------------------------------- 1 | {"rev":49,"name":"memd","uri":"/pools/default/buckets/memd?bucket_uuid=5f0bea1472aab794b613ff6f0b9fc936","streamingUri":"/pools/default/bucketsStreaming/memd?bucket_uuid=5f0bea1472aab794b613ff6f0b9fc936","nodes":[{"couchApiBase":"http://10.0.0.195:9500/memd%2B5f0bea1472aab794b613ff6f0b9fc936","hostname":"10.0.0.195:9000","ports":{"proxy":12001,"direct":12000}},{"couchApiBase":"http://$HOST:9501/memd%2B5f0bea1472aab794b613ff6f0b9fc936","hostname":"$HOST:9001","ports":{"proxy":12003,"direct":12002}},{"couchApiBase":"http://$HOST:9502/memd%2B5f0bea1472aab794b613ff6f0b9fc936","hostname":"$HOST:9002","ports":{"proxy":12005,"direct":12004}},{"couchApiBase":"http://$HOST:9503/memd%2B5f0bea1472aab794b613ff6f0b9fc936","hostname":"$HOST:9003","ports":{"proxy":12007,"direct":12006}}],"nodesExt":[{"services":{"mgmt":9000,"mgmtSSL":19000,"fts":9200,"indexAdmin":9100,"indexScan":9101,"indexHttp":9102,"indexStreamInit":9103,"indexStreamCatchup":9104,"indexStreamMaint":9105,"capiSSL":19500,"capi":9500,"kvSSL":11996,"projector":10000,"kv":12000,"moxi":12001,"n1ql":9499,"n1qlSSL":19499},"thisNode":true,"hostname":"10.0.0.195"},{"services":{"mgmt":9001,"mgmtSSL":19001,"fts":9201,"indexAdmin":9106,"indexScan":9107,"indexHttp":9108,"indexStreamInit":9109,"indexStreamCatchup":9110,"indexStreamMaint":9111,"capiSSL":19501,"capi":9501,"kvSSL":11992,"projector":10001,"kv":12002,"moxi":12003,"n1ql":9498,"n1qlSSL":19498}},{"services":{"mgmt":9002,"mgmtSSL":19002,"fts":9202,"indexAdmin":9112,"indexScan":9113,"indexHttp":9114,"indexStreamInit":9115,"indexStreamCatchup":9116,"indexStreamMaint":9117,"capiSSL":19502,"capi":9502,"kvSSL":11988,"projector":10002,"kv":12004,"moxi":12005,"n1ql":9497,"n1qlSSL":19497}},{"services":{"mgmt":9003,"mgmtSSL":19003,"fts":9203,"indexAdmin":9118,"indexScan":9119,"indexHttp":9120,"indexStreamInit":9121,"indexStreamCatchup":9122,"indexStreamMaint":9123,"capiSSL":19503,"capi":9503,"kvSSL":11984,"projector":10003,"kv":12006,"moxi":12007,"n1ql":9496,"n1qlSSL":19496}}],"nodeLocator":"ketama","uuid":"5f0bea1472aab794b613ff6f0b9fc936","bucketCapabilitiesVer":"","bucketCapabilities":["cbhello","nodesExt"]} -------------------------------------------------------------------------------- /tests/vbucket/confdata/memd_ketama_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "bucketCapabilitiesVer" : "", 3 | "name" : "memd", 4 | "nodeLocator" : "ketama", 5 | "nodes" : [ 6 | { 7 | "ports" : { 8 | "direct" : 11210 9 | }, 10 | "hostname" : "192.168.1.103:8091" 11 | }, 12 | { 13 | "hostname" : "192.168.1.101:8091", 14 | "ports" : { 15 | "direct" : 11210 16 | } 17 | }, 18 | { 19 | "hostname" : "192.168.1.102:8091", 20 | "ports" : { 21 | "direct" : 11210 22 | } 23 | }, 24 | { 25 | "hostname" : "$HOST:8091", 26 | "ports" : { 27 | "direct" : 11210 28 | } 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /tools/cbc-timestamp.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2011-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "cbc-timestamp.h" 19 | #include "build-timestamp.h" 20 | 21 | namespace cbc { 22 | 23 | const char *const lcb_build_timestamp = LCB_BUILD_TIMESTAMP; 24 | 25 | } // namespace cbc 26 | -------------------------------------------------------------------------------- /tools/cbc-timestamp.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2011-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef CBC_TIMESTAMP_H 19 | #define CBC_TIMESTAMP_H 20 | 21 | namespace cbc { 22 | 23 | extern const char *const lcb_build_timestamp; 24 | 25 | } // namespace cbc 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /tools/check-clang-format: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2020 Couchbase, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | PROJECT_ROOT="$( cd "$(dirname "$0"/..)" >/dev/null 2>&1 ; pwd -P )" 18 | 19 | CB_GIT_CLANG_FORMAT=${CB_GIT_CLANG_FORMAT:-git-clang-format} 20 | CB_CLANG_FORMAT=${CB_CLANG_FORMAT:-$(which clang-format)} 21 | 22 | set -euo pipefail 23 | IFS=$'\n\t' 24 | 25 | format_diff="$(${CB_GIT_CLANG_FORMAT} --binary ${CB_CLANG_FORMAT} --diff --commit HEAD^)" 26 | 27 | if [ "$format_diff" == "clang-format did not modify any files" ] || \ 28 | [ "$format_diff" == "no modified files to format" ] 29 | then 30 | echo "clang-format did not suggest any changes" 31 | exit 0 32 | else 33 | echo "clang-format suggested the following changes:" 34 | echo "" 35 | echo "$format_diff" 36 | exit 1 37 | fi 38 | -------------------------------------------------------------------------------- /tools/check-clang-static-analyzer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2020 Couchbase, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | PROJECT_ROOT="$( cd "$(dirname "$0"/..)" >/dev/null 2>&1 ; pwd -P )" 18 | 19 | CB_CMAKE=${CB_CMAKE:-$(which cmake)} 20 | CB_CC=${CB_CC:-$(which clang)} 21 | CB_CXX=${CB_CC:-$(which clang++)} 22 | CB_SCAN_BUILD=${CB_SCAN_BUILD:-$(which scan-build)} 23 | 24 | echo "CB_CC=${CB_CC}" 25 | echo "CB_CXX=${CB_CXX}" 26 | echo "CB_SCAN_BUILD=${CB_SCAN_BUILD}" 27 | echo "CB_CMAKE=${CB_CMAKE}" 28 | 29 | set -exuo pipefail 30 | 31 | BUILD_DIR="${PROJECT_ROOT}/cmake-build-clang-analyzer" 32 | REPORT_DIR="${PROJECT_ROOT}/cmake-build-report" 33 | 34 | rm -rf "${BUILD_DIR}" "${REPORT_DIR}" 35 | mkdir -p "${BUILD_DIR}" 36 | cd "${BUILD_DIR}" 37 | 38 | SCAN_BUILD_ARGS="--exclude contrib -o ${REPORT_DIR} --use-analyzer=${CB_CC} --use-c++=${CB_CXX} --use-cc=${CB_CC} --status-bugs" 39 | 40 | ${CB_SCAN_BUILD} ${SCAN_BUILD_ARGS} ${CB_CMAKE} -DLCB_NO_TOOLS=ON ${PROJECT_ROOT} 41 | set +e 42 | ${CB_SCAN_BUILD} ${SCAN_BUILD_ARGS} make -j8 43 | STATUS=$? 44 | set -e 45 | 46 | tar zcvf ${REPORT_DIR}.tar.gz -C ${REPORT_DIR} . 47 | exit ${STATUS} 48 | -------------------------------------------------------------------------------- /tools/common/histogram.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2012-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "histogram.h" 19 | #include 20 | using namespace cbc; 21 | using std::string; 22 | 23 | void Histogram::install(lcb_INSTANCE *inst, FILE *out) 24 | { 25 | lcb_STATUS rc; 26 | output = out; 27 | lcb_enable_timings(inst); 28 | rc = lcb_cntl(inst, LCB_CNTL_GET, LCB_CNTL_KVTIMINGS, &hg); 29 | lcb_assert(rc == LCB_SUCCESS); 30 | lcb_assert(hg != nullptr); 31 | (void)rc; 32 | } 33 | 34 | void Histogram::installStandalone(FILE *out) 35 | { 36 | if (hg != nullptr) { 37 | return; 38 | } 39 | hg = lcb_histogram_create(); 40 | output = out; 41 | } 42 | 43 | #ifdef _WIN32 44 | #define flockfile(x) (void)0 45 | #define funlockfile(x) (void)0 46 | #endif 47 | 48 | void Histogram::write() 49 | { 50 | if (hg == nullptr) { 51 | return; 52 | } 53 | flockfile(output); 54 | lcb_histogram_print(hg, output); 55 | funlockfile(output); 56 | } 57 | 58 | void Histogram::record(lcb_U64 duration) 59 | { 60 | if (hg == nullptr) { 61 | return; 62 | } 63 | lcb_histogram_record(hg, duration); 64 | } 65 | -------------------------------------------------------------------------------- /tools/common/histogram.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2012-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef CBC_HISTOGRAM_H 19 | #define CBC_HISTOGRAM_H 20 | #include 21 | #include 22 | #include 23 | 24 | namespace cbc 25 | { 26 | 27 | class Histogram 28 | { 29 | public: 30 | Histogram() 31 | { 32 | hg = nullptr; 33 | output = nullptr; 34 | } 35 | void install(lcb_INSTANCE *, FILE *out = stderr); 36 | void installStandalone(FILE *out = stderr); 37 | void record(lcb_U64 duration); 38 | void write(); 39 | FILE *getOutput() const 40 | { 41 | return output; 42 | } 43 | 44 | private: 45 | lcb_HISTOGRAM *hg; 46 | FILE *output; 47 | }; 48 | 49 | } // namespace cbc 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /tools/gen-script.txt: -------------------------------------------------------------------------------- 1 | # 2 | # use this script with cbc-gen like this 3 | # 4 | # $ cbc-gen -s tools/gen-script.txt 5 | # 6 | 7 | # change defaults 8 | value-size-max 512 9 | batch-size 600 10 | durability-level majority 11 | 12 | # create only one worker thread 13 | create 14 | 15 | # setup workload scheme 16 | workload --reads=10 --writes=70 --deletes=20 17 | 18 | # start all worker threads that created so far 19 | # and ask them to execute 1000 operations each (zero for unbounded) 20 | start --num-items=1000 21 | 22 | # wait for the workers 23 | wait 24 | -------------------------------------------------------------------------------- /tools/gen/lexer.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2018-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef GEN_LEXER_H_ 19 | #define GEN_LEXER_H_ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef enum bm_TOKTYPE_ { BM_TOKEN_WORD = 0x01, BM_TOKEN_OPTION = 0x02, BM_TOKEN__MAX } bm_TOKTYPE; 26 | 27 | typedef struct bm_TOKEN_ { 28 | bm_TOKTYPE type; 29 | union { 30 | struct { 31 | const char *ptr; 32 | int len; 33 | } word; 34 | struct { 35 | const char *key; 36 | int klen; 37 | const char *val; 38 | int vlen; 39 | } option; 40 | } t; 41 | } bm_TOKEN; 42 | 43 | const char *lex(const char *s, bm_TOKEN *tok); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif 49 | -------------------------------------------------------------------------------- /tools/gen/lexer.re: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 | /* 3 | * Copyright 2018-2020 Couchbase, Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include 19 | #include "lexer.h" 20 | 21 | const char *lex(const char *s, bm_TOKEN *tok) 22 | { 23 | const char *m, *k, *ke, *v, *ve; 24 | /*!stags:re2c format = 'const char *@@;'; */ 25 | loop: 26 | /*!re2c 27 | re2c:define:YYCTYPE = char; 28 | re2c:define:YYCURSOR = s; 29 | re2c:define:YYMARKER = m; 30 | re2c:yyfill:enable = 0; 31 | 32 | end = "\x00"; 33 | sp = [ \t\n\r]; 34 | eq = "="; 35 | wsp = sp*; 36 | char = [^=] \ end; 37 | ochar = char \ sp; 38 | pchar = ochar \ [/]; 39 | str = ["] (char \ ["] | [\]["])* ["]; 40 | opt = ochar+; 41 | word = ochar* | str; 42 | 43 | [-]{1,2} @k opt @ke wsp eq? wsp @v word @ve { 44 | tok->type = BM_TOKEN_OPTION; 45 | tok->t.option.key = k; 46 | tok->t.option.klen = (int)(ke - k); 47 | tok->t.option.val = v; 48 | tok->t.option.vlen = (int)(ve - v); 49 | return s; 50 | } 51 | @k word @ke { 52 | tok->type = BM_TOKEN_WORD; 53 | tok->t.word.ptr = k; 54 | tok->t.word.len = (int)(ke - k); 55 | return s; 56 | } 57 | end { return NULL; } 58 | wsp { goto loop; } 59 | */ 60 | return NULL; 61 | } 62 | -------------------------------------------------------------------------------- /tools/jenkins/check-clang-format: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2020 Couchbase, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | PROJECT_ROOT="$( cd "$(dirname "$0"/../..)" >/dev/null 2>&1 ; pwd -P )" 18 | 19 | echo "HOSTNAME=${HOSTNAME}" 20 | echo "NODE_NAME=${NODE_NAME}" 21 | echo "CONTAINER_TAG=${CONTAINER_TAG}" 22 | echo "JENKINS_SLAVE_LABELS=${JENKINS_SLAVE_LABELS}" 23 | echo "NODE_LABELS=${NODE_LABELS}" 24 | 25 | set -x 26 | set -e 27 | 28 | if [ "$(uname -s)" = "Linux" ] 29 | then 30 | sudo yum install -y llvm-toolset-7.0-git-clang-format 31 | fi 32 | 33 | scl enable llvm-toolset-7.0 tools/check-clang-format 34 | -------------------------------------------------------------------------------- /tools/jenkins/check-clang-static-analyzer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2020 Couchbase, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | PROJECT_ROOT="$( cd "$(dirname "$0"/../..)" >/dev/null 2>&1 ; pwd -P )" 18 | 19 | echo "HOSTNAME=${HOSTNAME}" 20 | echo "NODE_NAME=${NODE_NAME}" 21 | echo "CONTAINER_TAG=${CONTAINER_TAG}" 22 | echo "JENKINS_SLAVE_LABELS=${JENKINS_SLAVE_LABELS}" 23 | echo "NODE_LABELS=${NODE_LABELS}" 24 | 25 | set -xe 26 | 27 | sudo patch -d/ -Np0 < ${PROJECT_ROOT}/tools/jenkins/scan-build-add-exclude-switch.patch || true 28 | scl enable llvm-toolset-7.0 tools/check-clang-static-analyzer 29 | -------------------------------------------------------------------------------- /tools/jenkins/scan-build-add-exclude-switch.patch: -------------------------------------------------------------------------------- 1 | --- /opt/rh/llvm-toolset-7.0/root/bin/scan-build.orig 2020-10-07 18:21:21.035260832 +0000 2 | +++ /opt/rh/llvm-toolset-7.0/root/bin/scan-build 2020-10-07 18:23:27.503366066 +0000 3 | @@ -58,6 +58,7 @@ 4 | KeepEmpty => 0, # Don't remove output directory even with 0 results. 5 | EnableCheckers => {}, 6 | DisableCheckers => {}, 7 | + Excludes => [], 8 | UseCC => undef, # C compiler to use for compilation. 9 | UseCXX => undef, # C++ compiler to use for compilation. 10 | AnalyzerTarget => undef, 11 | @@ -420,6 +421,20 @@ 12 | # The file no longer exists: use the original path. 13 | $BugFile = $1; 14 | } 15 | + 16 | + # Get just the path 17 | + my $p = dirname($BugFile); 18 | + # Check if the path is found in the list of exclude 19 | + if (grep { $p =~ m/$_/ } @{$Options{Excludes}}) { 20 | + if ($Options{Verbose}) { 21 | + Diag("File '$BugFile' deleted: part of an ignored directory.\n"); 22 | + } 23 | + 24 | + # File in an ignored directory. Remove it 25 | + unlink("$Dir/$FName"); 26 | + return; 27 | + } 28 | + 29 | UpdatePrefix($BugFile); 30 | } 31 | elsif (/$/) { 32 | @@ -1698,6 +1713,15 @@ 33 | next; 34 | } 35 | 36 | + if ($arg eq "--exclude") { 37 | + shift @$Args; 38 | + my $arg = shift @$Args; 39 | + # Remove the trailing slash if any 40 | + $arg =~ s|/$||; 41 | + push @{$Options{Excludes}}, $arg; 42 | + next; 43 | + } 44 | + 45 | if ($arg eq "-load-plugin") { 46 | shift @$Args; 47 | push @{$Options{PluginsToLoad}}, shift @$Args; 48 | --------------------------------------------------------------------------------