Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
1 MB
Referenced Files
None
Subscribers
None
This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/mongodb-1.2.0/phongo_compat.c b/mongodb-1.2.0/phongo_compat.c
deleted file mode 100644
index 2e6d18fa..00000000
--- a/mongodb-1.2.0/phongo_compat.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-void phongo_add_exception_prop(const char *prop, int prop_len, zval *value TSRMLS_DC)
-{
- if (EG(exception)) {
-#if PHP_VERSION_ID >= 70000
- zval ex;
- EXCEPTION_P(EG(exception), ex);
- zend_update_property(Z_OBJCE(ex), &ex, prop, prop_len, value);
-#else
- zval *ex = NULL;
- EXCEPTION_P(EG(exception), ex);
- zend_update_property(Z_OBJCE_P(ex), ex, prop, prop_len, value TSRMLS_CC);
-#endif
- }
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/BSON/Persistable.c b/mongodb-1.2.0/src/BSON/Persistable.c
deleted file mode 100644
index ac5629aa..00000000
--- a/mongodb-1.2.0/src/BSON/Persistable.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-
-
-PHONGO_API zend_class_entry *php_phongo_persistable_ce;
-
-
-
-/* {{{ BSON\Persistable */
-
-
-static zend_function_entry php_phongo_persistable_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(Persistable)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Persistable", php_phongo_persistable_me);
- php_phongo_persistable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
- zend_class_implements(php_phongo_persistable_ce TSRMLS_CC, 2, php_phongo_unserializable_ce, php_phongo_serializable_ce);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/BSON/Serializable.c b/mongodb-1.2.0/src/BSON/Serializable.c
deleted file mode 100644
index 55d7177d..00000000
--- a/mongodb-1.2.0/src/BSON/Serializable.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-
-
-PHONGO_API zend_class_entry *php_phongo_serializable_ce;
-
-
-
-/* {{{ BSON\Serializable */
-
-ZEND_BEGIN_ARG_INFO_EX(ai_Serializable_void, 0, 0, 0)
-ZEND_END_ARG_INFO()
-
-static zend_function_entry php_phongo_serializable_me[] = {
- ZEND_ABSTRACT_ME(Serializable, bsonSerialize, ai_Serializable_void)
- PHP_FE_END
-};
-
-/* }}} */
-
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(Serializable)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Serializable", php_phongo_serializable_me);
- php_phongo_serializable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
- zend_class_implements(php_phongo_serializable_ce TSRMLS_CC, 1, php_phongo_type_ce);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/BSON/Type.c b/mongodb-1.2.0/src/BSON/Type.c
deleted file mode 100644
index f7a00fb2..00000000
--- a/mongodb-1.2.0/src/BSON/Type.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-
-
-PHONGO_API zend_class_entry *php_phongo_type_ce;
-
-
-
-/* {{{ BSON\Type */
-
-
-static zend_function_entry php_phongo_type_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(Type)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Type", php_phongo_type_me);
- php_phongo_type_ce = zend_register_internal_interface(&ce TSRMLS_CC);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/BSON/Unserializable.c b/mongodb-1.2.0/src/BSON/Unserializable.c
deleted file mode 100644
index 4d5473fb..00000000
--- a/mongodb-1.2.0/src/BSON/Unserializable.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-
-
-PHONGO_API zend_class_entry *php_phongo_unserializable_ce;
-
-
-
-/* {{{ BSON\Unserializable */
-
-ZEND_BEGIN_ARG_INFO_EX(ai_Unserializable_bsonUnserialize, 0, 0, 1)
- ZEND_ARG_ARRAY_INFO(0, data, 0)
-ZEND_END_ARG_INFO()
-
-static zend_function_entry php_phongo_unserializable_me[] = {
- ZEND_ABSTRACT_ME(Unserializable, bsonUnserialize, ai_Unserializable_bsonUnserialize)
- PHP_FE_END
-};
-
-/* }}} */
-
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(Unserializable)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Unserializable", php_phongo_unserializable_me);
- php_phongo_unserializable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/MongoDB/Exception/AuthenticationException.c b/mongodb-1.2.0/src/MongoDB/Exception/AuthenticationException.c
deleted file mode 100644
index f5c461ae..00000000
--- a/mongodb-1.2.0/src/MongoDB/Exception/AuthenticationException.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-#include <ext/spl/spl_exceptions.h>
-
-
-PHONGO_API zend_class_entry *php_phongo_authenticationexception_ce;
-
-/* {{{ MongoDB\Driver\AuthenticationException */
-
-static zend_function_entry php_phongo_authenticationexception_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(AuthenticationException)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "AuthenticationException", php_phongo_authenticationexception_me);
-#if PHP_VERSION_ID >= 70000
- php_phongo_authenticationexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce);
-#else
- php_phongo_authenticationexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce, NULL TSRMLS_CC);
-#endif
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/MongoDB/Exception/BulkWriteException.c b/mongodb-1.2.0/src/MongoDB/Exception/BulkWriteException.c
deleted file mode 100644
index 8b238e98..00000000
--- a/mongodb-1.2.0/src/MongoDB/Exception/BulkWriteException.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-#include <ext/spl/spl_exceptions.h>
-
-
-PHONGO_API zend_class_entry *php_phongo_bulkwriteexception_ce;
-
-/* {{{ MongoDB\Driver\BulkWriteException */
-
-static zend_function_entry php_phongo_bulkwriteexception_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(BulkWriteException)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "BulkWriteException", php_phongo_bulkwriteexception_me);
-#if PHP_VERSION_ID >= 70000
- php_phongo_bulkwriteexception_ce = zend_register_internal_class_ex(&ce, php_phongo_writeexception_ce);
-#else
- php_phongo_bulkwriteexception_ce = zend_register_internal_class_ex(&ce, php_phongo_writeexception_ce, NULL TSRMLS_CC);
-#endif
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/MongoDB/Exception/ConnectionException.c b/mongodb-1.2.0/src/MongoDB/Exception/ConnectionException.c
deleted file mode 100644
index 14eb6e63..00000000
--- a/mongodb-1.2.0/src/MongoDB/Exception/ConnectionException.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-#include <ext/spl/spl_exceptions.h>
-
-
-PHONGO_API zend_class_entry *php_phongo_connectionexception_ce;
-
-/* {{{ MongoDB\Driver\ConnectionException */
-
-static zend_function_entry php_phongo_connectionexception_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(ConnectionException)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ConnectionException", php_phongo_connectionexception_me);
-#if PHP_VERSION_ID >= 70000
- php_phongo_connectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce);
-#else
- php_phongo_connectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce, NULL TSRMLS_CC);
-#endif
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/MongoDB/Exception/ConnectionTimeoutException.c b/mongodb-1.2.0/src/MongoDB/Exception/ConnectionTimeoutException.c
deleted file mode 100644
index 74224d74..00000000
--- a/mongodb-1.2.0/src/MongoDB/Exception/ConnectionTimeoutException.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-#include <ext/spl/spl_exceptions.h>
-
-
-PHONGO_API zend_class_entry *php_phongo_connectiontimeoutexception_ce;
-
-/* {{{ MongoDB\Driver\ConnectionTimeoutException */
-
-static zend_function_entry php_phongo_connectiontimeoutexception_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(ConnectionTimeoutException)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ConnectionTimeoutException", php_phongo_connectiontimeoutexception_me);
-#if PHP_VERSION_ID >= 70000
- php_phongo_connectiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce);
-#else
- php_phongo_connectiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce, NULL TSRMLS_CC);
-#endif
- PHONGO_CE_FINAL(php_phongo_connectiontimeoutexception_ce);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/MongoDB/Exception/Exception.c b/mongodb-1.2.0/src/MongoDB/Exception/Exception.c
deleted file mode 100644
index 2d14b35a..00000000
--- a/mongodb-1.2.0/src/MongoDB/Exception/Exception.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-#include <ext/spl/spl_exceptions.h>
-
-
-PHONGO_API zend_class_entry *php_phongo_exception_ce;
-
-/* {{{ MongoDB\Driver\Exception */
-
-static zend_function_entry php_phongo_exception_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(Exception)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "Exception", php_phongo_exception_me);
- php_phongo_exception_ce = zend_register_internal_interface(&ce TSRMLS_CC);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/MongoDB/Exception/ExecutionTimeoutException.c b/mongodb-1.2.0/src/MongoDB/Exception/ExecutionTimeoutException.c
deleted file mode 100644
index 94282730..00000000
--- a/mongodb-1.2.0/src/MongoDB/Exception/ExecutionTimeoutException.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-#include <ext/spl/spl_exceptions.h>
-
-
-PHONGO_API zend_class_entry *php_phongo_executiontimeoutexception_ce;
-
-/* {{{ MongoDB\Driver\ExecutionTimeoutException */
-
-static zend_function_entry php_phongo_executiontimeoutexception_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(ExecutionTimeoutException)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ExecutionTimeoutException", php_phongo_executiontimeoutexception_me);
-#if PHP_VERSION_ID >= 70000
- php_phongo_executiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce);
-#else
- php_phongo_executiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce, NULL TSRMLS_CC);
-#endif
- PHONGO_CE_FINAL(php_phongo_executiontimeoutexception_ce);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/MongoDB/Exception/InvalidArgumentException.c b/mongodb-1.2.0/src/MongoDB/Exception/InvalidArgumentException.c
deleted file mode 100644
index 46257aca..00000000
--- a/mongodb-1.2.0/src/MongoDB/Exception/InvalidArgumentException.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-#include <ext/spl/spl_exceptions.h>
-
-
-PHONGO_API zend_class_entry *php_phongo_invalidargumentexception_ce;
-
-/* {{{ MongoDB\Driver\InvalidArgumentException */
-
-static zend_function_entry php_phongo_invalidargumentexception_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(InvalidArgumentException)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "InvalidArgumentException", php_phongo_invalidargumentexception_me);
-#if PHP_VERSION_ID >= 70000
- php_phongo_invalidargumentexception_ce = zend_register_internal_class_ex(&ce, spl_ce_InvalidArgumentException);
-#else
- php_phongo_invalidargumentexception_ce = zend_register_internal_class_ex(&ce, spl_ce_InvalidArgumentException, NULL TSRMLS_CC);
-#endif
- zend_class_implements(php_phongo_invalidargumentexception_ce TSRMLS_CC, 1, php_phongo_exception_ce);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/MongoDB/Exception/LogicException.c b/mongodb-1.2.0/src/MongoDB/Exception/LogicException.c
deleted file mode 100644
index 05d2abbc..00000000
--- a/mongodb-1.2.0/src/MongoDB/Exception/LogicException.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-#include <ext/spl/spl_exceptions.h>
-
-
-PHONGO_API zend_class_entry *php_phongo_logicexception_ce;
-
-/* {{{ MongoDB\Driver\LogicException */
-
-static zend_function_entry php_phongo_logicexception_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(LogicException)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "LogicException", php_phongo_logicexception_me);
-#if PHP_VERSION_ID >= 70000
- php_phongo_logicexception_ce = zend_register_internal_class_ex(&ce, spl_ce_LogicException);
-#else
- php_phongo_logicexception_ce = zend_register_internal_class_ex(&ce, spl_ce_LogicException, NULL TSRMLS_CC);
-#endif
- zend_class_implements(php_phongo_logicexception_ce TSRMLS_CC, 1, php_phongo_exception_ce);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/MongoDB/Exception/RuntimeException.c b/mongodb-1.2.0/src/MongoDB/Exception/RuntimeException.c
deleted file mode 100644
index a2cab0db..00000000
--- a/mongodb-1.2.0/src/MongoDB/Exception/RuntimeException.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-#include <ext/spl/spl_exceptions.h>
-
-
-PHONGO_API zend_class_entry *php_phongo_runtimeexception_ce;
-
-/* {{{ MongoDB\Driver\RuntimeException */
-
-static zend_function_entry php_phongo_runtimeexception_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(RuntimeException)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "RuntimeException", php_phongo_runtimeexception_me);
-#if PHP_VERSION_ID >= 70000
- php_phongo_runtimeexception_ce = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException);
-#else
- php_phongo_runtimeexception_ce = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException, NULL TSRMLS_CC);
-#endif
- zend_class_implements(php_phongo_runtimeexception_ce TSRMLS_CC, 1, php_phongo_exception_ce);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/MongoDB/Exception/SSLConnectionException.c b/mongodb-1.2.0/src/MongoDB/Exception/SSLConnectionException.c
deleted file mode 100644
index 59ff1692..00000000
--- a/mongodb-1.2.0/src/MongoDB/Exception/SSLConnectionException.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-#include <ext/spl/spl_exceptions.h>
-
-
-PHONGO_API zend_class_entry *php_phongo_sslconnectionexception_ce;
-
-/* {{{ MongoDB\Driver\SSLConnectionException */
-
-static zend_function_entry php_phongo_sslconnectionexception_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(SSLConnectionException)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "SSLConnectionException", php_phongo_sslconnectionexception_me);
-#if PHP_VERSION_ID >= 70000
- php_phongo_sslconnectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce);
-#else
- php_phongo_sslconnectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce, NULL TSRMLS_CC);
-#endif
- PHONGO_CE_FINAL(php_phongo_sslconnectionexception_ce);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/MongoDB/Exception/UnexpectedValueException.c b/mongodb-1.2.0/src/MongoDB/Exception/UnexpectedValueException.c
deleted file mode 100644
index 699fe752..00000000
--- a/mongodb-1.2.0/src/MongoDB/Exception/UnexpectedValueException.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* External libs */
-#include <bson.h>
-#include <mongoc.h>
-
-/* PHP Core stuff */
-#include <php.h>
-#include <php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_interfaces.h>
-#include <ext/spl/spl_iterators.h>
-/* Our Compatability header */
-#include "phongo_compat.h"
-
-/* Our stuffz */
-#include "php_phongo.h"
-#include "php_bson.h"
-#include <ext/spl/spl_exceptions.h>
-
-
-PHONGO_API zend_class_entry *php_phongo_unexpectedvalueexception_ce;
-
-/* {{{ MongoDB\Driver\UnexpectedValueException */
-
-static zend_function_entry php_phongo_unexpectedvalueexception_me[] = {
- PHP_FE_END
-};
-
-/* }}} */
-
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(UnexpectedValueException)
-{
- zend_class_entry ce;
- (void)type;(void)module_number;
-
- INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "UnexpectedValueException", php_phongo_unexpectedvalueexception_me);
-#if PHP_VERSION_ID >= 70000
- php_phongo_unexpectedvalueexception_ce = zend_register_internal_class_ex(&ce, spl_ce_UnexpectedValueException);
-#else
- php_phongo_unexpectedvalueexception_ce = zend_register_internal_class_ex(&ce, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
-#endif
- zend_class_implements(php_phongo_unexpectedvalueexception_ce TSRMLS_CC, 1, php_phongo_exception_ce);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/mongodb-1.2.0/src/libbson/VERSION_CURRENT b/mongodb-1.2.0/src/libbson/VERSION_CURRENT
deleted file mode 100644
index 3e1ad720..00000000
--- a/mongodb-1.2.0/src/libbson/VERSION_CURRENT
+++ /dev/null
@@ -1 +0,0 @@
-1.5.0
\ No newline at end of file
diff --git a/mongodb-1.2.0/src/libbson/VERSION_RELEASED b/mongodb-1.2.0/src/libbson/VERSION_RELEASED
deleted file mode 100644
index 3e1ad720..00000000
--- a/mongodb-1.2.0/src/libbson/VERSION_RELEASED
+++ /dev/null
@@ -1 +0,0 @@
-1.5.0
\ No newline at end of file
diff --git a/mongodb-1.2.0/src/libmongoc/VERSION_CURRENT b/mongodb-1.2.0/src/libmongoc/VERSION_CURRENT
deleted file mode 100644
index 3e1ad720..00000000
--- a/mongodb-1.2.0/src/libmongoc/VERSION_CURRENT
+++ /dev/null
@@ -1 +0,0 @@
-1.5.0
\ No newline at end of file
diff --git a/mongodb-1.2.0/src/libmongoc/VERSION_RELEASED b/mongodb-1.2.0/src/libmongoc/VERSION_RELEASED
deleted file mode 100644
index 3e1ad720..00000000
--- a/mongodb-1.2.0/src/libmongoc/VERSION_RELEASED
+++ /dev/null
@@ -1 +0,0 @@
-1.5.0
\ No newline at end of file
diff --git a/mongodb-1.2.0/CREDITS b/mongodb-1.2.3/CREDITS
similarity index 100%
rename from mongodb-1.2.0/CREDITS
rename to mongodb-1.2.3/CREDITS
diff --git a/mongodb-1.2.0/LICENSE b/mongodb-1.2.3/LICENSE
similarity index 100%
rename from mongodb-1.2.0/LICENSE
rename to mongodb-1.2.3/LICENSE
diff --git a/mongodb-1.2.0/Makefile.frag b/mongodb-1.2.3/Makefile.frag
similarity index 100%
rename from mongodb-1.2.0/Makefile.frag
rename to mongodb-1.2.3/Makefile.frag
diff --git a/mongodb-1.2.0/README.md b/mongodb-1.2.3/README.md
similarity index 100%
rename from mongodb-1.2.0/README.md
rename to mongodb-1.2.3/README.md
diff --git a/mongodb-1.2.0/Vagrantfile b/mongodb-1.2.3/Vagrantfile
similarity index 100%
rename from mongodb-1.2.0/Vagrantfile
rename to mongodb-1.2.3/Vagrantfile
diff --git a/mongodb-1.2.0/config.m4 b/mongodb-1.2.3/config.m4
similarity index 91%
rename from mongodb-1.2.0/config.m4
rename to mongodb-1.2.3/config.m4
index d14ea40a..f6b2c808 100644
--- a/mongodb-1.2.0/config.m4
+++ b/mongodb-1.2.3/config.m4
@@ -1,641 +1,618 @@
dnl config.m4 for extension mongodb
PHP_ARG_ENABLE(mongodb, whether to enable mongodb support,
[ --enable-mongodb Enable mongodb support])
PHP_ARG_WITH(openssl-dir, OpenSSL dir for mongodb,
[ --with-openssl-dir[=DIR] openssl install prefix], yes, no)
PHP_ARG_WITH(system-ciphers, whether to use system default cipher list instead of hardcoded value,
[ --with-system-ciphers OPENSSL: Use system default cipher list instead of hardcoded value], no, no)
dnl borrowed from libmongoc configure.ac
# AS_VAR_COPY is available in AC 2.64 and on, but we only require 2.60.
# If we're on an older version, we define it ourselves:
m4_ifndef([AS_VAR_COPY],
[m4_define([AS_VAR_COPY],
[AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])])
# Get "user-set cflags" here, before we've added the flags we use by default
AS_VAR_COPY(MONGOC_USER_SET_CFLAGS, [CFLAGS])
AC_SUBST(MONGOC_USER_SET_CFLAGS)
AS_VAR_COPY(MONGOC_USER_SET_LDFLAGS, [LDFLAGS])
AC_SUBST(MONGOC_USER_SET_LDFLAGS)
AS_VAR_COPY(MONGOC_CC, [CC])
AC_SUBST(MONGOC_CC)
dnl borrowed from PHP acinclude.m4
AC_DEFUN([PHP_BSON_BIGENDIAN],
[AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php,
[
ac_cv_c_bigendian_php=unknown
AC_TRY_RUN(
[
int main(void)
{
short one = 1;
char *cp = (char *)&one;
if (*cp == 0) {
return(0);
} else {
return(1);
}
}
], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown])
])
if test $ac_cv_c_bigendian_php = yes; then
AC_SUBST(BSON_BYTE_ORDER, 4321)
else
AC_SUBST(BSON_BYTE_ORDER, 1234)
fi
])
dnl Borrowed from sapi/fpm/config.m4
AC_DEFUN([PHP_BSON_CLOCK],
[
have_clock_gettime=no
AC_MSG_CHECKING([for clock_gettime])
AC_TRY_LINK([ #include <time.h> ], [struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);], [
have_clock_gettime=yes
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
])
if test "$have_clock_gettime" = "no"; then
AC_MSG_CHECKING([for clock_gettime in -lrt])
SAVED_LIBS="$LIBS"
LIBS="$LIBS -lrt"
AC_TRY_LINK([ #include <time.h> ], [struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);], [
have_clock_gettime=yes
AC_MSG_RESULT([yes])
], [
LIBS="$SAVED_LIBS"
AC_MSG_RESULT([no])
])
fi
if test "$have_clock_gettime" = "yes"; then
AC_SUBST(BSON_HAVE_CLOCK_GETTIME, 1)
fi
])
MONGOC_SYMBOL_SUFFIX="priv"
AC_MSG_CHECKING(PHP version)
PHP_FOUND_VERSION=`${PHP_CONFIG} --version`
PHP_FOUND_VERNUM=`echo "${PHP_FOUND_VERSION}" | $AWK 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 100 + [$]2) * 100 + [$]3;}'`
AC_MSG_RESULT($PHP_FOUND_VERNUM)
if test "$MONGODB" != "no"; then
PHP_ARG_ENABLE(developer-flags, whether to enable developer build flags,
[ --enable-developer-flags Enable developer flags],, no)
if test "$PHP_DEVELOPER_FLAGS" = "yes"; then
dnl Warn about functions which might be candidates for format attributes
PHP_CHECK_GCC_ARG(-Wmissing-format-attribute, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wmissing-format-attribute")
dnl Avoid duplicating values for an enum
PHP_CHECK_GCC_ARG(-Wduplicate-enum, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wduplicate-enum")
dnl Warns on mismatches between #ifndef and #define header guards
PHP_CHECK_GCC_ARG(-Wheader-guard, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wheader-guard")
dnl logical not of a non-boolean expression
PHP_CHECK_GCC_ARG(-Wlogical-not-parentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wlogical-not-parentheses")
dnl Warn about suspicious uses of logical operators in expressions
PHP_CHECK_GCC_ARG(-Wlogical-op, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wlogical-op")
dnl memory error detector.
dnl FIXME: -fsanitize=address,undefined for clang. The PHP_CHECK_GCC_ARG macro isn't happy about that string :(
PHP_CHECK_GCC_ARG(-fsanitize-address, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fsanitize-address")
dnl Enable frame debugging
PHP_CHECK_GCC_ARG(-fno-omit-frame-pointer, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-omit-frame-pointer")
dnl Make sure we don't optimize calls
PHP_CHECK_GCC_ARG(-fno-optimize-sibling-calls, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-optimize-sibling-calls")
PHP_CHECK_GCC_ARG(-Wlogical-op-parentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wlogical-op-parentheses")
PHP_CHECK_GCC_ARG(-Wbool-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wbool-conversion")
PHP_CHECK_GCC_ARG(-Wloop-analysis, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wloop-analysis")
PHP_CHECK_GCC_ARG(-Wsizeof-array-argument, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wsizeof-array-argument")
PHP_CHECK_GCC_ARG(-Wstring-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wstring-conversion")
PHP_CHECK_GCC_ARG(-Wno-variadic-macros, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-variadic-macros")
PHP_CHECK_GCC_ARG(-Wno-sign-compare, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wno-sign-compare")
PHP_CHECK_GCC_ARG(-fstack-protector, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fstack-protector")
PHP_CHECK_GCC_ARG(-fno-exceptions, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-exceptions")
PHP_CHECK_GCC_ARG(-Wformat-security, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wformat-security")
PHP_CHECK_GCC_ARG(-Wformat-nonliteral, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wformat-nonliteral")
PHP_CHECK_GCC_ARG(-Winit-self, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Winit-self")
PHP_CHECK_GCC_ARG(-Wwrite-strings, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wwrite-strings")
PHP_CHECK_GCC_ARG(-Wenum-compare, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wenum-compare")
PHP_CHECK_GCC_ARG(-Wempty-body, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wempty-body")
PHP_CHECK_GCC_ARG(-Wparentheses, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wparentheses")
PHP_CHECK_GCC_ARG(-Wdeclaration-after-statement, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wdeclaration-after-statement")
if test "$PHP_FOUND_VERNUM" -ge "50400"; then
PHP_CHECK_GCC_ARG(-Werror, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Werror")
fi
MAINTAINER_CFLAGS="-Wextra $_MAINTAINER_CFLAGS -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-missing-field-initializers"
STD_CFLAGS="-g -O0 -Wall"
- dnl EXTRA_LDFLAGS="-Wl,--no-undefined"
fi
PHP_ARG_ENABLE(coverage, whether to enable code coverage,
[ --enable-coverage Enable developer code coverage information],, no)
if test "$PHP_COVERAGE" = "yes"; then
PHP_CHECK_GCC_ARG(-fprofile-arcs, COVERAGE_CFLAGS="$COVERAGE_CFLAGS -fprofile-arcs")
PHP_CHECK_GCC_ARG(-ftest-coverage, COVERAGE_CFLAGS="$COVERAGE_CFLAGS -ftest-coverage")
EXTRA_LDFLAGS="$COVERAGE_CFLAGS"
fi
MONGODB_BSON="\
src/bson.c \
";
MONGODB_BSON_CLASSES="\
src/BSON/Type.c \
src/BSON/Unserializable.c \
src/BSON/Serializable.c \
src/BSON/Persistable.c \
src/BSON/Binary.c \
src/BSON/Decimal128.c \
src/BSON/Javascript.c \
src/BSON/MaxKey.c \
src/BSON/MinKey.c \
src/BSON/ObjectID.c \
src/BSON/Regex.c \
src/BSON/Timestamp.c \
src/BSON/UTCDateTime.c \
";
MONGODB_ROOT="\
php_phongo.c \
phongo_compat.c \
";
MONGODB_MONGODB_CLASSES="\
src/MongoDB/Command.c \
src/MongoDB/Cursor.c \
src/MongoDB/CursorId.c \
src/MongoDB/Manager.c \
src/MongoDB/Query.c \
src/MongoDB/ReadConcern.c \
src/MongoDB/ReadPreference.c \
src/MongoDB/Server.c \
src/MongoDB/BulkWrite.c \
src/MongoDB/WriteConcern.c \
src/MongoDB/WriteConcernError.c \
src/MongoDB/WriteError.c \
src/MongoDB/WriteResult.c \
";
MONGODB_MONGODB_EXCEPTIONS="\
src/MongoDB/Exception/Exception.c \
src/MongoDB/Exception/LogicException.c \
src/MongoDB/Exception/RuntimeException.c \
src/MongoDB/Exception/UnexpectedValueException.c \
src/MongoDB/Exception/InvalidArgumentException.c \
src/MongoDB/Exception/ConnectionException.c \
src/MongoDB/Exception/AuthenticationException.c \
src/MongoDB/Exception/SSLConnectionException.c \
src/MongoDB/Exception/ExecutionTimeoutException.c \
src/MongoDB/Exception/ConnectionTimeoutException.c \
src/MongoDB/Exception/WriteException.c \
src/MongoDB/Exception/BulkWriteException.c \
";
YAJL_SOURCES="\
yajl_version.c \
yajl.c \
yajl_encode.c \
yajl_lex.c \
yajl_parser.c \
yajl_buf.c \
yajl_tree.c \
yajl_alloc.c \
yajl_gen.c
";
BSON_SOURCES="\
bcon.c \
bson.c \
bson-atomic.c \
bson-clock.c \
bson-context.c \
bson-decimal128.c \
bson-error.c \
bson-iter.c \
bson-iso8601.c \
bson-json.c \
bson-keys.c \
bson-md5.c \
bson-memory.c \
bson-oid.c \
bson-reader.c \
bson-string.c \
bson-timegm.c \
bson-utf8.c \
bson-value.c \
bson-version-functions.c \
bson-writer.c
";
MONGOC_SOURCES="\
mongoc-apm.c \
mongoc-array.c \
mongoc-async.c \
mongoc-async-cmd.c \
mongoc-buffer.c \
mongoc-bulk-operation.c \
mongoc-b64.c \
mongoc-client.c \
mongoc-client-pool.c \
mongoc-cluster.c \
mongoc-collection.c \
mongoc-counters.c \
mongoc-cursor.c \
mongoc-cursor-array.c \
mongoc-cursor-cursorid.c \
mongoc-cursor-transform.c \
mongoc-database.c \
mongoc-find-and-modify.c \
mongoc-host-list.c \
mongoc-init.c \
mongoc-gridfs.c \
mongoc-gridfs-file.c \
mongoc-gridfs-file-page.c \
mongoc-gridfs-file-list.c \
mongoc-handshake.c \
mongoc-index.c \
mongoc-linux-distro-scanner.c \
mongoc-list.c \
mongoc-log.c \
mongoc-matcher-op.c \
mongoc-matcher.c \
mongoc-memcmp.c \
mongoc-opcode.c \
mongoc-queue.c \
mongoc-read-concern.c \
mongoc-read-prefs.c \
mongoc-rpc.c \
mongoc-server-description.c \
mongoc-server-stream.c \
mongoc-set.c \
mongoc-socket.c \
mongoc-stream.c \
mongoc-stream-buffered.c \
mongoc-stream-file.c \
mongoc-stream-gridfs.c \
mongoc-stream-socket.c \
mongoc-topology.c \
mongoc-topology-description.c \
mongoc-topology-description-apm.c \
mongoc-topology-scanner.c \
mongoc-uri.c \
mongoc-util.c \
mongoc-version-functions.c \
mongoc-write-command.c \
mongoc-write-concern.c
";
MONGOC_SOURCES_CRYPTO="\
mongoc-crypto.c \
mongoc-scram.c
";
MONGOC_SOURCES_SSL="\
mongoc-stream-tls.c \
mongoc-ssl.c
";
MONGOC_SOURCES_OPENSSL="\
mongoc-crypto-openssl.c \
mongoc-openssl.c \
mongoc-rand-openssl.c \
mongoc-stream-tls-openssl.c \
mongoc-stream-tls-openssl-bio.c
";
MONGOC_SOURCES_SECURE_TRANSPORT="\
mongoc-crypto-common-crypto.c \
mongoc-rand-common-crypto.c \
mongoc-secure-transport.c \
mongoc-stream-tls-secure-transport.c
";
MONGOC_SOURCES_SECURE_CHANNEL="\
mongoc-crypto-cng.c \
mongoc-rand-cng.c \
mongoc-secure-channel.c \
mongoc-stream-tls-secure-channel.c
";
MONGOC_SOURCES_SASL=mongoc-sasl.c
if test "$ext_shared" = "no"; then
PHP_ADD_SOURCES(PHP_EXT_DIR(mongodb), $MONGODB_BSON)
PHP_ADD_SOURCES(PHP_EXT_DIR(mongodb), $MONGODB_BSON_CLASSES)
PHP_ADD_SOURCES(PHP_EXT_DIR(mongodb), $MONGODB_MONGODB_CLASSES)
PHP_ADD_SOURCES(PHP_EXT_DIR(mongodb), $MONGODB_MONGODB_EXCEPTIONS)
else
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb), $MONGODB_BSON, [$STD_CFLAGS $MAINTAINER_CFLAGS $COVERAGE_CFLAGS], shared_objects_mongodb, yes)
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb), $MONGODB_BSON_CLASSES, [$STD_CFLAGS $MAINTAINER_CFLAGS $COVERAGE_CFLAGS], shared_objects_mongodb, yes)
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb), $MONGODB_MONGODB_CLASSES, [$STD_CFLAGS $MAINTAINER_CFLAGS $COVERAGE_CFLAGS], shared_objects_mongodb, yes)
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb), $MONGODB_MONGODB_EXCEPTIONS, [$STD_CFLAGS $MAINTAINER_CFLAGS $COVERAGE_CFLAGS], shared_objects_mongodb, yes)
fi
-PHP_ARG_WITH(libbson, whether to use system libbson,
-[ --with-libbson Use system libbson], no, no)
+ PHP_ARG_WITH(libbson, whether to use system libbson,
+ [ --with-libbson Use system libbson], no, no)
+ PHP_ARG_WITH(libmongoc, whether to use system libmongoc,
+ [ --with-libmongoc Use system libmongoc], no, no)
if test "$PHP_LIBBSON" != "no"; then
+ if test "$PHP_LIBMONGOC" == "no"; then
+ AC_MSG_ERROR(Cannot use system libbson and bundled libmongoc)
+ fi
+
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
AC_MSG_CHECKING(for libbson)
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libbson-1.0; then
if $PKG_CONFIG libbson-1.0 --atleast-version 1.5.0; then
LIBBSON_INC=`$PKG_CONFIG libbson-1.0 --cflags`
LIBBSON_LIB=`$PKG_CONFIG libbson-1.0 --libs`
LIBBSON_VER=`$PKG_CONFIG libbson-1.0 --modversion`
AC_MSG_RESULT(version $LIBBSON_VER found)
else
AC_MSG_ERROR(system libbson must be upgraded to version >= 1.5.0)
fi
else
AC_MSG_ERROR(pkgconfig and libbson must be installed)
fi
PHP_EVAL_INCLINE($LIBBSON_INC)
PHP_EVAL_LIBLINE($LIBBSON_LIB, MONGODB_SHARED_LIBADD)
AC_DEFINE(HAVE_SYSTEM_LIBBSON, 1, [Use system libbson])
else
- PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libbson/src/yajl], $YAJL_SOURCES, [$STD_CFLAGS], shared_objects_mongodb, yes)
- PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libbson/src/bson], $BSON_SOURCES, [$STD_CFLAGS], shared_objects_mongodb, yes)
+ LIBBSON_CFLAGS="-DBSON_COMPILATION"
+
+ PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libbson/src/yajl], $YAJL_SOURCES, [$STD_CFLAGS $LIBBSON_CFLAGS], shared_objects_mongodb, yes)
+ PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libbson/src/bson], $BSON_SOURCES, [$STD_CFLAGS $LIBBSON_CFLAGS], shared_objects_mongodb, yes)
fi
-dnl libmongoc stuff {{{
AC_MSG_CHECKING(configuring libmongoc)
AC_MSG_RESULT(...)
-PHP_ARG_WITH(libmongoc, whether to use system libmongoc,
-[ --with-libmongoc Use system libmongoc], no, no)
-
- AC_DEFINE(HAVE_MONGOC, 1, [Kinda useless extension without it..])
-
if test "$PHP_LIBMONGOC" != "no"; then
+ if test "$PHP_LIBBSON" == "no"; then
+ AC_MSG_ERROR(Cannot use system libmongoc and bundled libbson)
+ fi
+
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
AC_MSG_CHECKING(for libmongoc)
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libmongoc-1.0; then
if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.5.0; then
LIBMONGOC_INC=`$PKG_CONFIG libmongoc-1.0 --cflags`
LIBMONGOC_LIB=`$PKG_CONFIG libmongoc-1.0 --libs`
LIBMONGOC_VER=`$PKG_CONFIG libmongoc-1.0 --modversion`
AC_MSG_RESULT(version $LIBMONGOC_VER found)
else
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.5.0)
fi
else
AC_MSG_ERROR(pkgconfig and mongoc must be installed)
fi
PHP_EVAL_INCLINE($LIBMONGOC_INC)
PHP_EVAL_LIBLINE($LIBMONGOC_LIB, MONGODB_SHARED_LIBADD)
AC_DEFINE(HAVE_SYSTEM_LIBMONGOC, 1, [Use system libmongoc])
else
- CPPFLAGS="$CPPFLAGS -DBSON_COMPILATION -DMONGOC_COMPILATION -DMONGOC_TRACE"
+ LIBMONGOC_CFLAGS="-DMONGOC_COMPILATION -DMONGOC_TRACE"
- PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES, [$STD_CFLAGS], shared_objects_mongodb, yes)
- PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES_CRYPTO, [$STD_CFLAGS], shared_objects_mongodb, yes)
- PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES_SSL, [$STD_CFLAGS], shared_objects_mongodb, yes)
- PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES_OPENSSL, [$STD_CFLAGS], shared_objects_mongodb, yes)
- PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES_SECURE_TRANSPORT, [$STD_CFLAGS], shared_objects_mongodb, yes)
- PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES_SECURE_CHANNEL, [$STD_CFLAGS], shared_objects_mongodb, yes)
- PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES_SASL, [$STD_CFLAGS], shared_objects_mongodb, yes)
+ PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES, [$STD_CFLAGS $LIBMONGOC_CFLAGS], shared_objects_mongodb, yes)
+ PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES_CRYPTO, [$STD_CFLAGS $LIBMONGOC_CFLAGS], shared_objects_mongodb, yes)
+ PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES_SSL, [$STD_CFLAGS $LIBMONGOC_CFLAGS], shared_objects_mongodb, yes)
+ PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES_OPENSSL, [$STD_CFLAGS $LIBMONGOC_CFLAGS], shared_objects_mongodb, yes)
+ PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES_SECURE_TRANSPORT, [$STD_CFLAGS $LIBMONGOC_CFLAGS], shared_objects_mongodb, yes)
+ PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES_SECURE_CHANNEL, [$STD_CFLAGS $LIBMONGOC_CFLAGS], shared_objects_mongodb, yes)
+ PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $MONGOC_SOURCES_SASL, [$STD_CFLAGS $LIBMONGOC_CFLAGS], shared_objects_mongodb, yes)
PHP_SETUP_OPENSSL(MONGODB_SHARED_LIBADD)
AC_SUBST(MONGOC_ENABLE_CRYPTO, 1)
AC_SUBST(MONGOC_ENABLE_SSL, 1)
AC_SUBST(MONGOC_ENABLE_CRYPTO_LIBCRYPTO, 1)
AC_SUBST(MONGOC_ENABLE_SSL_OPENSSL, 1)
if test "$PHP_SYSTEM_CIPHERS" != "no"; then
AC_SUBST(MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE, 1)
else
AC_SUBST(MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE, 0)
fi
dnl TODO: Support building with Secure Transport on OSX
AC_SUBST(MONGOC_ENABLE_SSL_SECURE_TRANSPORT, 0)
AC_SUBST(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO, 0)
dnl Secure Channel only applies to Windows
AC_SUBST(MONGOC_ENABLE_SSL_SECURE_CHANNEL, 0)
AC_SUBST(MONGOC_ENABLE_CRYPTO_CNG, 0)
AC_SUBST(MONGOC_ENABLE_SSL_LIBRESSL, 0)
AC_SUBST(MONGOC_NO_AUTOMATIC_GLOBALS, 1)
fi
-PHP_ARG_WITH(pcre-dir, for pcre-dir install prefix,
-[ --with-pcre-dir[=DIR] mongodb: pcre install prefix], auto, yes)
-
-if test "$PHP_PCRE_DIR" != "no"; then
- AC_MSG_CHECKING(for pcre)
- for i in $PHP_PCRE_DIR /usr /usr/local; do
- if test -f $i/include/pcre.h; then
- MONGODB_PCRE_DIR=$i/include
- AC_MSG_RESULT(found in $i)
- break
- fi
- done
-
- if test -z "$MONGODB_PCRE_DIR"; then
- AC_MSG_RESULT(not found)
- else
- PHP_ADD_INCLUDE($MONGODB_PCRE_DIR)
- fi
-fi
-
PHP_ARG_WITH(mongodb-sasl, for Cyrus SASL support,
[ --with-mongodb-sasl[=DIR] mongodb: Include Cyrus SASL support], auto, no)
if test "$PHP_MONGODB_SASL" != "no"; then
AC_MSG_CHECKING(for SASL)
for i in $PHP_MONGODB_SASL /usr /usr/local; do
if test -f $i/include/sasl/sasl.h; then
MONGODB_SASL_DIR=$i
AC_MSG_RESULT(found in $i)
break
fi
done
if test -z "$MONGODB_SASL_DIR"; then
AC_MSG_RESULT(not found)
if test "$PHP_MONGODB_SASL" != "auto"; then
AC_MSG_ERROR([sasl.h not found!])
else
AC_SUBST(MONGOC_ENABLE_SASL, 0)
AC_SUBST(MONGOC_HAVE_SASL_CLIENT_DONE, 0)
fi
else
PHP_CHECK_LIBRARY(sasl2, sasl_version,
[
PHP_ADD_INCLUDE($MONGODB_SASL_DIR)
PHP_ADD_LIBRARY_WITH_PATH(sasl2, $MONGODB_SASL_DIR/$PHP_LIBDIR, MONGODB_SHARED_LIBADD)
AC_SUBST(MONGOC_ENABLE_SASL, 1)
], [
if test "$MONGODB_SASL" != "auto"; then
AC_MSG_ERROR([MongoDB SASL check failed. Please check config.log for more information.])
fi
AC_SUBST(MONGOC_ENABLE_SASL, 0)
], [
-L$MONGODB_SASL_DIR/$PHP_LIBDIR
])
PHP_CHECK_LIBRARY(sasl2, sasl_client_done,
[
AC_SUBST(MONGOC_HAVE_SASL_CLIENT_DONE, 1)
], [
AC_SUBST(MONGOC_HAVE_SASL_CLIENT_DONE, 0)
])
fi
else
AC_SUBST(MONGOC_ENABLE_SASL, 0)
AC_SUBST(MONGOC_HAVE_SASL_CLIENT_DONE, 0)
fi
m4_include(src/libmongoc/build/autotools/WeakSymbols.m4)
m4_include(src/libmongoc/build/autotools/m4/ax_pthread.m4)
AX_PTHREAD
AC_CHECK_FUNCS([shm_open], [SHM_LIB=], [AC_CHECK_LIB([rt], [shm_open], [SHM_LIB=-lrt], [SHM_LIB=])])
MONGODB_SHARED_LIBADD="$MONGODB_SHARED_LIBADD $SHM_LIB"
-
- dnl PHP_ADD_LIBRARY_WITH_PATH(bson-1.0, src/libbson/.libs, MONGODB_SHARED_LIBADD)
- dnl PHP_ADD_LIBRARY_WITH_PATH(mongoc-priv, src/libmongoc/.libs, MONGODB_SHARED_LIBADD)
EXTRA_CFLAGS="$PTHREAD_CFLAGS $SASL_CFLAGS"
PHP_SUBST(EXTRA_CFLAGS)
PHP_SUBST(EXTRA_LDFLAGS)
MONGODB_SHARED_LIBADD="$MONGODB_SHARED_LIBADD $PTHREAD_LIBS $SASL_LIBS"
PHP_SUBST(MONGODB_SHARED_LIBADD)
-dnl }}}
-
PHP_NEW_EXTENSION(mongodb, $MONGODB_ROOT, $ext_shared,, [$STD_CFLAGS $MAINTAINER_CFLAGS $COVERAGE_CFLAGS])
PHP_ADD_EXTENSION_DEP(mongodb, date)
PHP_ADD_EXTENSION_DEP(mongodb, json)
PHP_ADD_EXTENSION_DEP(mongodb, spl)
PHP_ADD_EXTENSION_DEP(mongodb, standard)
PHP_ADD_INCLUDE([$ext_srcdir/src/BSON/])
PHP_ADD_INCLUDE([$ext_srcdir/src/MongoDB/])
PHP_ADD_INCLUDE([$ext_srcdir/src/MongoDB/Exception/])
PHP_ADD_INCLUDE([$ext_srcdir/src/contrib/])
PHP_ADD_BUILD_DIR([$ext_builddir/src/BSON/])
PHP_ADD_BUILD_DIR([$ext_builddir/src/MongoDB/])
PHP_ADD_BUILD_DIR([$ext_builddir/src/MongoDB/Exception/])
PHP_ADD_BUILD_DIR([$ext_builddir/src/contrib/])
if test "$PHP_LIBMONGOC" == "no"; then
PHP_ADD_INCLUDE([$ext_srcdir/src/libmongoc/src/mongoc/])
PHP_ADD_BUILD_DIR([$ext_builddir/src/libmongoc/src/mongoc/])
fi
if test "$PHP_LIBBSON" == "no"; then
m4_include(src/libbson/build/autotools/CheckAtomics.m4)
m4_include(src/libbson/build/autotools/FindDependencies.m4)
m4_include(src/libbson/build/autotools/m4/ac_compile_check_sizeof.m4)
m4_include(src/libbson/build/autotools/m4/ac_create_stdint_h.m4)
AC_CREATE_STDINT_H([$srcdir/src/libbson/src/bson/bson-stdint.h])
PHP_ADD_INCLUDE([$ext_srcdir/src/libbson/src/])
PHP_ADD_INCLUDE([$ext_srcdir/src/libbson/src/yajl/])
PHP_ADD_INCLUDE([$ext_srcdir/src/libbson/src/bson/])
PHP_ADD_BUILD_DIR([$ext_builddir/src/libbson/src/])
PHP_ADD_BUILD_DIR([$ext_builddir/src/libbson/src/yajl/])
PHP_ADD_BUILD_DIR([$ext_builddir/src/libbson/src/bson/])
fi
- dnl MONGODB_SHARED_DEPENDENCIES="mongodbdep"
- dnl PHP_SUBST(MONGODB_SHARED_DEPENDENCIES)
-
PHP_BSON_BIGENDIAN
AC_HEADER_STDBOOL
AC_SUBST(BSON_EXTRA_ALIGN, 0)
AC_SUBST(BSON_HAVE_DECIMAL128, 0)
if test "$ac_cv_header_stdbool_h" = "yes"; then
AC_SUBST(BSON_HAVE_STDBOOL_H, 1)
else
AC_SUBST(BSON_HAVE_STDBOOL_H, 0)
fi
AC_SUBST(BSON_OS, 1)
PHP_BSON_CLOCK
AC_CHECK_FUNC(strnlen,ac_cv_func_strnlen=yes,ac_cv_func_strnlen=no)
if test "$ac_cv_func_strnlen" = "yes"; then
AC_SUBST(BSON_HAVE_STRNLEN, 1)
else
AC_SUBST(BSON_HAVE_STRNLEN, 0)
fi
AC_CHECK_FUNC(snprintf,ac_cv_func_snprintf=yes,ac_cv_func_snprintf=no)
if test "$ac_cv_func_snprintf" = "yes"; then
AC_SUBST(BSON_HAVE_SNPRINTF, 1)
else
AC_SUBST(BSON_HAVE_SNPRINTF, 0)
fi
if test "$PHP_LIBMONGOC" == "no"; then
backup_srcdir=${srcdir}
srcdir=${srcdir}/src/libmongoc/
m4_include(src/libmongoc/build/autotools/Versions.m4)
srcdir=${backup_srcdir}
MONGOC_API_VERSION=1.0
AC_SUBST(MONGOC_MAJOR_VERSION)
AC_SUBST(MONGOC_MINOR_VERSION)
AC_SUBST(MONGOC_MICRO_VERSION)
AC_SUBST(MONGOC_API_VERSION)
AC_SUBST(MONGOC_VERSION)
AC_OUTPUT($srcdir/src/libmongoc/src/mongoc/mongoc-config.h)
AC_OUTPUT($srcdir/src/libmongoc/src/mongoc/mongoc-version.h)
fi
if test "$PHP_LIBBSON" == "no"; then
backup_srcdir=${srcdir}
srcdir=${srcdir}/src/libbson/
m4_include(src/libbson/build/autotools/Versions.m4)
srcdir=${backup_srcdir}
BSON_API_VERSION=1.0
AC_SUBST(BSON_MAJOR_VERSION)
AC_SUBST(BSON_MINOR_VERSION)
AC_SUBST(BSON_MICRO_VERSION)
AC_SUBST(BSON_API_VERSION)
AC_SUBST(BSON_VERSION)
AC_OUTPUT($srcdir/src/libbson/src/bson/bson-config.h)
AC_OUTPUT($srcdir/src/libbson/src/bson/bson-version.h)
fi
dnl This must come after PHP_NEW_EXTENSION, otherwise the srcdir won't be set
PHP_ADD_MAKEFILE_FRAGMENT
AC_CONFIG_COMMANDS_POST([echo "
mongodb was configured with the following options:
Build configuration:
CFLAGS : $CFLAGS
Extra CFLAGS : $STD_CFLAGS $EXTRA_CFLAGS
Developers flags (slow) : $MAINTAINER_CFLAGS
Code Coverage flags (extra slow) : $COVERAGE_CFLAGS
System mongoc : $PHP_LIBMONGOC
System libbson : $PHP_LIBBSON
LDFLAGS : $LDFLAGS
EXTRA_LDFLAGS : $EXTRA_LDFLAGS
MONGODB_SHARED_LIBADD : $MONGODB_SHARED_LIBADD
Please submit bugreports at:
https://jira.mongodb.org/browse/PHPC
"])
fi
dnl: vim: et sw=2
diff --git a/mongodb-1.2.0/config.w32 b/mongodb-1.2.3/config.w32
similarity index 96%
rename from mongodb-1.2.0/config.w32
rename to mongodb-1.2.3/config.w32
index 212d94f5..65c4065a 100644
--- a/mongodb-1.2.0/config.w32
+++ b/mongodb-1.2.3/config.w32
@@ -1,188 +1,186 @@
// vim:ft=javascript
function mongodb_generate_header(inpath, outpath, replacements)
{
STDOUT.WriteLine("Generating " + outpath);
var infile = FSO.OpenTextFile(inpath, 1);
var outdata = infile.ReadAll();
infile.Close();
for (var key in replacements) {
var replacement = replacements[key];
if (typeof replacement === 'string') {
replacement = replacement.replace(/"/g, '\\"');
}
- outdata = outdata.replace("@" + key + "@", replacement);
+ outdata = outdata.replace(new RegExp('@' + key + '@', 'g'), replacement);
}
var outfile = FSO.CreateTextFile(outpath, true);
outfile.Write(outdata);
outfile.Close();
}
function mongodb_parse_version_file(inpath, prefix)
{
var infile = FSO.OpenTextFile(inpath, 1);
var version = infile.ReadLine();
infile.Close();
var xyz_pre = version.split("-");
var xyz = xyz_pre[0].split(".");
+ var pre = xyz_pre.length > 1 ? xyz_pre[1] : "";
var replacements = {};
replacements[prefix + "VERSION"] = version;
replacements[prefix + "MAJOR_VERSION"] = xyz[0];
replacements[prefix + "MINOR_VERSION"] = xyz[1];
replacements[prefix + "MICRO_VERSION"] = xyz[2];
- replacements[prefix + "PRERELEASE_VERSION"] = xyz_pre[1];
+ replacements[prefix + "PRERELEASE_VERSION"] = pre;
return replacements;
}
ARG_ENABLE("mongodb", "MongoDB support", "no");
ARG_WITH("mongodb-sasl", "MongoDB: Build against Cyrus-SASL", "yes");
if (PHP_MONGODB != "no") {
- ADD_EXTENSION_DEP("mongodb", "date", false);
+ /* Note: ADD_EXTENSION_DEP() cannot be used to declare that we depend on the
+ * date and standard extensions. Assume that they're always enabled. */
ADD_EXTENSION_DEP("mongodb", "json", false);
ADD_EXTENSION_DEP("mongodb", "spl", false);
- ADD_EXTENSION_DEP("mongodb", "standard", false);
/* MongoDB does not actually depend on PHP's OpenSSL extension, but this is in
* place to ensure that later SSL library checks succeed. This can be removed
* once we support building with Secure Channel. */
ADD_EXTENSION_DEP("mongodb", "openssl", false);
ADD_FLAG("CFLAGS_MONGODB", " /D BSON_COMPILATION /D MONGOC_COMPILATION /D MONGOC_TRACE /I" + configure_module_dirname + " /I" + configure_module_dirname + "/src/libmongoc/src/mongoc" + " /I" + configure_module_dirname + "/src/libbson/src/bson/ /I" + configure_module_dirname + "/src/libbson/src /I" + configure_module_dirname + "/src/contrib");
EXTENSION("mongodb", "php_phongo.c");
ADD_SOURCES(configure_module_dirname + "/", "phongo_compat.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src", "bson.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/BSON", "Type.c Unserializable.c Serializable.c Persistable.c Binary.c Decimal128.c Javascript.c MaxKey.c MinKey.c ObjectID.c Regex.c Timestamp.c UTCDateTime.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/MongoDB", "Command.c Cursor.c CursorId.c Manager.c Query.c ReadConcern.c ReadPreference.c Server.c BulkWrite.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Exception", "Exception.c LogicException.c RuntimeException.c UnexpectedValueException.c InvalidArgumentException.c ConnectionException.c AuthenticationException.c SSLConnectionException.c ExecutionTimeoutException.c ConnectionTimeoutException.c WriteException.c BulkWriteException.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/yajl", "yajl_version.c yajl.c yajl_encode.c yajl_lex.c yajl_parser.c yajl_buf.c yajl_tree.c yajl_alloc.c yajl_gen.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/bson", "bcon.c bson.c bson-atomic.c bson-clock.c bson-context.c bson-decimal128.c bson-error.c bson-iter.c bson-iso8601.c bson-json.c bson-keys.c bson-md5.c bson-memory.c bson-oid.c bson-reader.c bson-string.c bson-timegm.c bson-utf8.c bson-value.c bson-version-functions.c bson-writer.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-b64.c mongoc-client.c mongoc-client-pool.c mongoc-cluster.c mongoc-collection.c mongoc-counters.c mongoc-cursor.c mongoc-cursor-array.c mongoc-cursor-cursorid.c mongoc-cursor-transform.c mongoc-database.c mongoc-find-and-modify.c mongoc-host-list.c mongoc-init.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-page.c mongoc-gridfs-file-list.c mongoc-handshake.c mongoc-index.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher-op.c mongoc-matcher.c mongoc-memcmp.c mongoc-opcode.c mongoc-queue.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-server-description.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-stream.c mongoc-stream-buffered.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-socket.c mongoc-topology.c mongoc-topology-description.c mongoc-topology-description-apm.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-concern.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-crypto.c mongoc-scram.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-stream-tls.c mongoc-ssl.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-crypto-openssl.c mongoc-rand-openssl.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-openssl.c mongoc-stream-tls-openssl.c mongoc-stream-tls-openssl-bio.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-crypto-common-crypto.c mongoc-rand-common-crypto.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-secure-transport.c mongoc-stream-tls-secure-transport.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-crypto-cng.c mongoc-rand-cng.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-secure-channel.c mongoc-stream-tls-secure-channel.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-sasl.c", "mongodb");
- AC_DEFINE("HAVE_MONGOC", 1);
-
var bson_opts = {
BSON_BYTE_ORDER: 1234,
BSON_OS: 2,
BSON_HAVE_STDBOOL_H: 0,
BSON_HAVE_ATOMIC_32_ADD_AND_FETCH: 0,
BSON_HAVE_ATOMIC_64_ADD_AND_FETCH: 0,
BSON_PTHREAD_ONCE_INIT_NEEDS_BRACES: 0,
BSON_HAVE_CLOCK_GETTIME: 0,
BSON_HAVE_STRNLEN: 0,
BSON_HAVE_SNPRINTF: 0,
BSON_HAVE_REALLOCF: 0,
BSON_NEEDS_SET_OUTPUT_FORMAT: 0,
BSON_HAVE_TIMESPEC: 0,
BSON_EXTRA_ALIGN: 0,
BSON_HAVE_SYSCALL_TID: 0,
BSON_HAVE_DECIMAL128: 0
};
if (CHECK_FUNC_IN_HEADER("stdio.h", "_set_output_format")) {
bson_opts.BSON_NEEDS_SET_OUTPUT_FORMAT = 1;
}
mongodb_generate_header(
configure_module_dirname + "/src/libbson/src/bson/bson-config.h.in",
configure_module_dirname + "/src/libbson/src/bson/bson-config.h",
bson_opts
);
mongodb_generate_header(
configure_module_dirname + "/src/libbson/src/bson/bson-version.h.in",
configure_module_dirname + "/src/libbson/src/bson/bson-version.h",
mongodb_parse_version_file(configure_module_dirname + "/src/libbson/VERSION_CURRENT", "BSON_")
);
var mongoc_opts = {
// TODO: Support building with Secure Channel on Windows
MONGOC_ENABLE_SSL_SECURE_CHANNEL: 0,
MONGOC_ENABLE_CRYPTO_CNG: 0,
// Secure Transport does not apply to Windows
MONGOC_ENABLE_SSL_SECURE_TRANSPORT: 0,
MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO: 0,
MONGOC_ENABLE_SSL_LIBRESSL: 0,
MONGOC_ENABLE_SSL_OPENSSL: 0,
MONGOC_ENABLE_CRYPTO_LIBCRYPTO: 0,
MONGOC_ENABLE_SSL: 0,
MONGOC_ENABLE_CRYPTO: 0,
MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE: 0,
MONGOC_ENABLE_SASL: 0,
MONGOC_HAVE_SASL_CLIENT_DONE: 0,
MONGOC_HAVE_WEAK_SYMBOLS: 0,
MONGOC_NO_AUTOMATIC_GLOBALS: 1,
MONGOC_CC: "",
MONGOC_USER_SET_CFLAGS: "",
MONGOC_USER_SET_LDFLAGS: ""
};
var mongoc_ssl_path_to_check = PHP_MONGODB;
if (typeof PHP_OPENSSL === 'string') {
mongoc_ssl_path_to_check += ";" + PHP_OPENSSL;
}
if (CHECK_LIB("ssleay32.lib", "mongodb", mongoc_ssl_path_to_check) &&
CHECK_LIB("libeay32.lib", "mongodb", mongoc_ssl_path_to_check) &&
CHECK_LIB("crypt32.lib", "mongodb") &&
CHECK_HEADER_ADD_INCLUDE("openssl/ssl.h", "CFLAGS_MONGODB")) {
mongoc_opts.MONGOC_ENABLE_SSL_OPENSSL = 1;
mongoc_opts.MONGOC_ENABLE_CRYPTO_LIBCRYPTO = 1;
mongoc_opts.MONGOC_ENABLE_SSL = 1;
mongoc_opts.MONGOC_ENABLE_CRYPTO = 1;
- mongoc_opts.MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE = 1;
} else {
WARNING("mongodb libopenssl support not enabled, libs not found");
}
if (PHP_MONGODB_SASL != "no" &&
CHECK_LIB("libsasl.lib", "mongodb", PHP_MONGODB) &&
CHECK_HEADER_ADD_INCLUDE("sasl/sasl.h", "CFLAGS_MONGODB")) {
mongoc_opts.MONGOC_ENABLE_SASL = 1;
if (CHECK_FUNC_IN_HEADER("sasl/sasl.h", "sasl_client_done")) {
mongoc_opts.MONGOC_HAVE_SASL_CLIENT_DONE = 1;
}
} else {
WARNING("mongodb libsasl support not enabled, libs not found");
}
if (typeof COMPILER_NAME === 'string') {
mongoc_opts.MONGOC_CC = COMPILER_NAME;
} else if (typeof VC_VERSIONS[VCVERS] === 'string') {
mongoc_opts.MONGOC_CC = VC_VERSIONS[VCVERS];
}
/* MONGOC_USER_SET_CFLAGS and MONGOC_USER_SET_LDFLAGS can be left blank, as we
* do not expect CFLAGS or LDFLAGS to be customized at build time. */
mongodb_generate_header(
configure_module_dirname + "/src/libmongoc/src/mongoc/mongoc-config.h.in",
configure_module_dirname + "/src/libmongoc/src/mongoc/mongoc-config.h",
mongoc_opts
);
mongodb_generate_header(
configure_module_dirname + "/src/libmongoc/src/mongoc/mongoc-version.h.in",
configure_module_dirname + "/src/libmongoc/src/mongoc/mongoc-version.h",
mongodb_parse_version_file(configure_module_dirname + "/src/libmongoc/VERSION_CURRENT", "MONGOC_")
);
}
diff --git a/mongodb-1.2.3/phongo_compat.c b/mongodb-1.2.3/phongo_compat.c
new file mode 100644
index 00000000..dade13e2
--- /dev/null
+++ b/mongodb-1.2.3/phongo_compat.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2015-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+void phongo_add_exception_prop(const char *prop, int prop_len, zval *value TSRMLS_DC)
+{
+ if (EG(exception)) {
+#if PHP_VERSION_ID >= 70000
+ zval ex;
+ EXCEPTION_P(EG(exception), ex);
+ zend_update_property(Z_OBJCE(ex), &ex, prop, prop_len, value);
+#else
+ zval *ex = NULL;
+ EXCEPTION_P(EG(exception), ex);
+ zend_update_property(Z_OBJCE_P(ex), ex, prop, prop_len, value TSRMLS_CC);
+#endif
+ }
+}
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.0/phongo_compat.h b/mongodb-1.2.3/phongo_compat.h
similarity index 77%
rename from mongodb-1.2.0/phongo_compat.h
rename to mongodb-1.2.3/phongo_compat.h
index 9a6e263e..a0635c3c 100644
--- a/mongodb-1.2.0/phongo_compat.h
+++ b/mongodb-1.2.3/phongo_compat.h
@@ -1,180 +1,184 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2015-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef PHONGO_COMPAT_H
#define PHONGO_COMPAT_H
#include <php.h>
#include <Zend/zend_string.h>
#if PHP_VERSION_ID >= 70000
#include <Zend/zend_portability.h>
#endif
#ifdef PHP_WIN32
# include "config.w32.h"
#else
# include <php_config.h>
#endif
#ifndef PHP_FE_END
# define PHP_FE_END { NULL, NULL, NULL }
#endif
#ifndef HASH_KEY_NON_EXISTENT
# define HASH_KEY_NON_EXISTENT HASH_KEY_NON_EXISTANT
#endif
#if PHP_VERSION_ID >= 70000
# define str_efree(s) efree((char*)s)
#else
# include <Zend/zend_string.h>
#endif
#if PHP_VERSION_ID >= 50500
#define ITERATOR_GET_CURRENT_KEY(it, z) \
(it).funcs->get_current_key(&(it), z TSRMLS_CC);
#else
#define ITERATOR_GET_CURRENT_KEY(it, z) \
{ \
char *str_key; \
uint str_key_len; \
ulong int_key; \
switch ((it).funcs->get_current_key(&(it), &str_key, &str_key_len, &int_key TSRMLS_CC)) { \
case HASH_KEY_IS_LONG: \
ZVAL_LONG(z, int_key); \
break; \
case HASH_KEY_IS_STRING: \
ZVAL_STRINGL(z, str_key, str_key_len-1, 0); \
break; \
default: \
RETURN_NULL(); \
} \
}
#endif
#if defined(__GNUC__)
# define ARG_UNUSED __attribute__ ((unused))
#else
# define ARG_UNUSED
#endif
#if PHP_VERSION_ID >= 70000
# define phongo_char zend_string
# define phongo_long zend_long
#if SIZEOF_ZEND_LONG == 8
# define PHONGO_LONG_FORMAT PRId64
#elif SIZEOF_ZEND_LONG == 4
# define PHONGO_LONG_FORMAT PRId32
#else
# error Unsupported architecture (integers are neither 32-bit nor 64-bit)
#endif
# define SIZEOF_PHONGO_LONG SIZEOF_ZEND_LONG
# define phongo_create_object_retval zend_object*
# define PHONGO_ALLOC_OBJECT_T(_obj_t, _class_type) (_obj_t *)ecalloc(1, sizeof(_obj_t)+zend_object_properties_size(_class_type))
# define PHONGO_TSRMLS_FETCH_FROM_CTX(user_data)
# define SUPPRESS_UNUSED_WARNING(x)
# define DECLARE_RETURN_VALUE_USED int return_value_used = 1;
# define EXCEPTION_P(_ex, _zp) ZVAL_OBJ(&_zp, _ex)
# define ADD_ASSOC_STRING(_zv, _key, _value) add_assoc_string_ex(_zv, ZEND_STRL(_key), (char *)(_value));
# define ADD_ASSOC_STRINGL(_zv, _key, _value, _len) add_assoc_stringl_ex(_zv, ZEND_STRL(_key), (char *)(_value), _len);
# define ADD_ASSOC_STRING_EX(_zv, _key, _key_len, _value, _value_len) add_assoc_stringl_ex(_zv, _key, _key_len, (char *)(_value), _value_len);
# define ADD_ASSOC_LONG_EX(_zv, _key, _value) add_assoc_long_ex(_zv, ZEND_STRL(_key), _value);
# define ADD_ASSOC_ZVAL_EX(_zv, _key, _value) add_assoc_zval_ex(_zv, ZEND_STRL(_key), _value);
# define ADD_ASSOC_ZVAL(_zv, _key, _value) add_assoc_zval(_zv, _key, _value);
# define ADD_ASSOC_NULL_EX(_zv, _key) add_assoc_null_ex(_zv, ZEND_STRL(_key));
# define ADD_ASSOC_BOOL_EX(_zv, _key, _value) add_assoc_bool_ex(_zv, ZEND_STRL(_key), _value);
-# define ADD_INDEX_STRINGL(_zv, _ind, _value, _len) add_index_stringl(_zv, _ind, _value, _len);
+# define ADD_NEXT_INDEX_STRINGL(_zv, _value, _len) add_next_index_stringl(_zv, _value, _len);
# define phongo_free_object_arg zend_object
# define phongo_zpp_char_len size_t
# define ZEND_HASH_APPLY_COUNT(ht) (ht)->u.v.nApplyCount
# define PHONGO_RETVAL_STRINGL(s, slen) RETVAL_STRINGL(s, slen)
# define PHONGO_RETURN_STRINGL(s, slen) RETURN_STRINGL(s, slen)
# define PHONGO_RETVAL_STRING(s) RETVAL_STRING(s)
# define PHONGO_RETURN_STRING(s) RETURN_STRING(s)
# define PHONGO_RETVAL_SMART_STR(val) PHONGO_RETVAL_STRINGL(ZSTR_VAL((val).s), ZSTR_LEN((val).s));
#else
# define phongo_char char
# define phongo_long long
# define PHONGO_LONG_FORMAT "ld"
# define SIZEOF_PHONGO_LONG SIZEOF_LONG
# define ZSTR_VAL(str) str
# define phongo_create_object_retval zend_object_value
# define PHONGO_ALLOC_OBJECT_T(_obj_t, _class_type) (_obj_t *)ecalloc(1, sizeof(_obj_t))
# define PHONGO_TSRMLS_FETCH_FROM_CTX(user_data) TSRMLS_FETCH_FROM_CTX(user_data)
# define SUPPRESS_UNUSED_WARNING(x) (void)x;
# define DECLARE_RETURN_VALUE_USED
# define EXCEPTION_P(_ex, _zp) _zp = _ex
# define ADD_ASSOC_STRING(_zv, _key, _value) add_assoc_string_ex(_zv, ZEND_STRS(_key), (char *)(_value), 1);
# define ADD_ASSOC_STRINGL(_zv, _key, _value, _len) add_assoc_stringl_ex(_zv, ZEND_STRS(_key), (char *)(_value), _len, 1);
# define ADD_ASSOC_STRING_EX(_zv, _key, _key_len, _value, _value_len) add_assoc_stringl_ex(_zv, _key, _key_len+1, (char *)(_value), _value_len, 1);
# define ADD_ASSOC_LONG_EX(_zv, _key, _value) add_assoc_long_ex(_zv, ZEND_STRS(_key), _value);
# define ADD_ASSOC_ZVAL_EX(_zv, _key, _value) add_assoc_zval_ex(_zv, ZEND_STRS(_key), _value);
# define ADD_ASSOC_ZVAL(_zv, _key, _value) add_assoc_zval(_zv, _key, _value);
# define ADD_ASSOC_NULL_EX(_zv, _key) add_assoc_null_ex(_zv, ZEND_STRS(_key));
# define ADD_ASSOC_BOOL_EX(_zv, _key, _value) add_assoc_bool_ex(_zv, ZEND_STRS(_key), _value);
-# define ADD_INDEX_STRINGL(_zv, _ind, _value, _len) add_index_stringl(_zv, _ind, _value, _len, 0);
+# define ADD_NEXT_INDEX_STRINGL(_zv, _value, _len) add_next_index_stringl(_zv, _value, _len, 1);
# define Z_PHPDATE_P(object) ((php_date_obj*)zend_object_store_get_object(object TSRMLS_CC))
# define Z_ISUNDEF(x) !x
# define phongo_free_object_arg void
# define phongo_zpp_char_len int
-# define ZEND_HASH_APPLY_COUNT(ht) (ht)->nApplyCount
+# define ZEND_HASH_APPLY_PROTECTION(ht) true
+# define ZEND_HASH_GET_APPLY_COUNT(ht) ((ht)->nApplyCount)
+# define ZEND_HASH_DEC_APPLY_COUNT(ht) ((ht)->nApplyCount -= 1)
+# define ZEND_HASH_INC_APPLY_COUNT(ht) ((ht)->nApplyCount += 1)
# define PHONGO_RETVAL_STRINGL(s, slen) RETVAL_STRINGL(s, slen, 1)
# define PHONGO_RETURN_STRINGL(s, slen) RETURN_STRINGL(s, slen, 1)
# define PHONGO_RETVAL_STRING(s) RETVAL_STRING(s, 1)
# define PHONGO_RETURN_STRING(s) RETURN_STRING(s, 1)
# define PHONGO_RETVAL_SMART_STR(val) PHONGO_RETVAL_STRINGL((val).c, (val).len);
#endif
#if SIZEOF_PHONGO_LONG == 8
# define ADD_INDEX_INT64(zval, index, value) add_index_long(zval, index, value)
+# define ADD_NEXT_INDEX_INT64(zval, value) add_next_index_long(zval, value)
# define ADD_ASSOC_INT64(zval, key, value) add_assoc_long(zval, key, value)
#elif SIZEOF_PHONGO_LONG == 4
# define ADD_INDEX_INT64(zval, index, value) \
if (value > INT32_MAX || value < INT32_MIN) { \
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Integer overflow detected on your platform: %lld", value); \
} else { \
- add_index_long(zval, index, val); \
+ add_index_long(zval, index, value); \
+ }
+# define ADD_NEXT_INDEX_INT64(zval, value) \
+ if (value > INT32_MAX || value < INT32_MIN) { \
+ phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Integer overflow detected on your platform: %lld", value); \
+ } else { \
+ add_next_index_long(zval, value); \
}
# define ADD_ASSOC_INT64(zval, key, value) \
if (value > INT32_MAX || value < INT32_MIN) { \
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Integer overflow detected on your platform: %lld", value); \
} else { \
add_assoc_long(zval, key, value); \
}
#else
# error Unsupported architecture (integers are neither 32-bit nor 64-bit)
#endif
void phongo_add_exception_prop(const char *prop, int prop_len, zval *value TSRMLS_DC);
#endif /* PHONGO_COMPAT_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/php_bson.h b/mongodb-1.2.3/php_bson.h
similarity index 64%
rename from mongodb-1.2.0/php_bson.h
rename to mongodb-1.2.3/php_bson.h
index cbc392f0..ecee8618 100644
--- a/mongodb-1.2.0/php_bson.h
+++ b/mongodb-1.2.3/php_bson.h
@@ -1,94 +1,91 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 20142015 Hannes Magnusson |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Hannes Magnusson <bjori@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef PHONGO_BSON_H
#define PHONGO_BSON_H
#include <bson.h>
/* PHP Core stuff */
#include <php.h>
#define BSON_UNSERIALIZE_FUNC_NAME "bsonUnserialize"
#define BSON_SERIALIZE_FUNC_NAME "bsonSerialize"
typedef enum {
PHONGO_BSON_NONE = 0x00,
PHONGO_BSON_ADD_ID = 0x01,
PHONGO_BSON_RETURN_ID = 0x02
} php_phongo_bson_flags_t;
typedef enum {
PHONGO_TYPEMAP_NONE,
PHONGO_TYPEMAP_NATIVE_ARRAY,
PHONGO_TYPEMAP_NATIVE_OBJECT,
PHONGO_TYPEMAP_CLASS
} php_phongo_bson_typemap_types;
typedef struct {
php_phongo_bson_typemap_types document_type;
zend_class_entry *document;
php_phongo_bson_typemap_types array_type;
zend_class_entry *array;
php_phongo_bson_typemap_types root_type;
zend_class_entry *root;
} php_phongo_bson_typemap;
typedef struct {
#if PHP_VERSION_ID >= 70000
zval zchild;
#else
zval *zchild;
#endif
php_phongo_bson_typemap map;
zend_class_entry *odm;
+ bool is_visiting_array;
} php_phongo_bson_state;
#if PHP_VERSION_ID >= 70000
-#define PHONGO_BSON_STATE_INITIALIZER { {{ 0 }}, { PHONGO_TYPEMAP_NONE, NULL, PHONGO_TYPEMAP_NONE, NULL, PHONGO_TYPEMAP_NONE, NULL}, NULL}
+#define PHONGO_BSON_STATE_INITIALIZER { {{ 0 }}, { PHONGO_TYPEMAP_NONE, NULL, PHONGO_TYPEMAP_NONE, NULL, PHONGO_TYPEMAP_NONE, NULL}, NULL, 0 }
#else
-#define PHONGO_BSON_STATE_INITIALIZER { NULL, { PHONGO_TYPEMAP_NONE, NULL, PHONGO_TYPEMAP_NONE, NULL, PHONGO_TYPEMAP_NONE, NULL}, NULL}
+#define PHONGO_BSON_STATE_INITIALIZER { NULL, { PHONGO_TYPEMAP_NONE, NULL, PHONGO_TYPEMAP_NONE, NULL, PHONGO_TYPEMAP_NONE, NULL}, NULL, 0 }
#endif
void phongo_zval_to_bson(zval *data, php_phongo_bson_flags_t flags, bson_t *bson, bson_t **bson_out TSRMLS_DC);
int phongo_bson_to_zval_ex(const unsigned char *data, int data_len, php_phongo_bson_state *state);
#if PHP_VERSION_ID >= 70000
int phongo_bson_to_zval(const unsigned char *data, int data_len, zval *out);
#else
int phongo_bson_to_zval(const unsigned char *data, int data_len, zval **out);
#endif
void phongo_bson_typemap_to_state(zval *typemap, php_phongo_bson_typemap *map TSRMLS_DC);
PHP_FUNCTION(toPHP);
PHP_FUNCTION(fromPHP);
PHP_FUNCTION(toJSON);
PHP_FUNCTION(fromJSON);
#endif /* PHONGO_BSON_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/php_phongo.c b/mongodb-1.2.3/php_phongo.c
similarity index 87%
rename from mongodb-1.2.0/php_phongo.c
rename to mongodb-1.2.3/php_phongo.c
index 157a9d3b..46714bf8 100644
--- a/mongodb-1.2.0/php_phongo.c
+++ b/mongodb-1.2.3/php_phongo.c
@@ -1,2230 +1,2153 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include "bson.h"
#include "mongoc.h"
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <ext/standard/file.h>
#include <Zend/zend_hash.h>
#include <Zend/zend_interfaces.h>
#include <Zend/zend_exceptions.h>
#include <ext/spl/spl_iterators.h>
#include <ext/spl/spl_exceptions.h>
#include <ext/standard/php_var.h>
#if PHP_VERSION_ID >= 70000
# include <Zend/zend_smart_str.h>
#else
# include <ext/standard/php_smart_str.h>
#endif
/* Stream wrapper */
#include <main/php_streams.h>
#include <main/php_network.h>
/* Debug log writing */
#include <main/php_open_temporary_file.h>
/* For formating timestamp in the log */
#include <ext/date/php_date.h>
/* String manipulation */
#include <Zend/zend_string.h>
/* PHP array helpers */
#include "php_array_api.h"
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#undef MONGOC_LOG_DOMAIN
#define MONGOC_LOG_DOMAIN "PHONGO"
#define PHONGO_DEBUG_INI "mongodb.debug"
#define PHONGO_DEBUG_INI_DEFAULT ""
ZEND_DECLARE_MODULE_GLOBALS(mongodb)
#if PHP_VERSION_ID >= 70000
#if defined(ZTS) && defined(COMPILE_DL_MONGODB)
ZEND_TSRMLS_CACHE_DEFINE();
#endif
#endif
+/* Declare zend_class_entry dependencies, which are initialized in MINIT */
+zend_class_entry *php_phongo_date_immutable_ce;
+zend_class_entry *php_phongo_json_serializable_ce;
+
php_phongo_server_description_type_map_t
php_phongo_server_description_type_map[PHONGO_SERVER_DESCRIPTION_TYPES] = {
{ PHONGO_SERVER_UNKNOWN, "Unknown" },
{ PHONGO_SERVER_STANDALONE, "Standalone" },
{ PHONGO_SERVER_MONGOS, "Mongos" },
{ PHONGO_SERVER_POSSIBLE_PRIMARY, "PossiblePrimary" },
{ PHONGO_SERVER_RS_PRIMARY, "RSPrimary" },
{ PHONGO_SERVER_RS_SECONDARY, "RSSecondary" },
{ PHONGO_SERVER_RS_ARBITER, "RSArbiter" },
{ PHONGO_SERVER_RS_OTHER, "RSOther" },
{ PHONGO_SERVER_RS_GHOST, "RSGhost" },
};
/* {{{ phongo_std_object_handlers */
zend_object_handlers phongo_std_object_handlers;
zend_object_handlers *phongo_get_std_object_handlers(void)
{
return &phongo_std_object_handlers;
}
/* }}} */
/* Forward declarations */
static bool phongo_split_namespace(const char *namespace, char **dbname, char **cname);
/* {{{ Error reporting and logging */
zend_class_entry* phongo_exception_from_phongo_domain(php_phongo_error_domain_t domain)
{
switch (domain) {
case PHONGO_ERROR_INVALID_ARGUMENT:
return php_phongo_invalidargumentexception_ce;
case PHONGO_ERROR_LOGIC:
return php_phongo_logicexception_ce;
case PHONGO_ERROR_RUNTIME:
return php_phongo_runtimeexception_ce;
case PHONGO_ERROR_UNEXPECTED_VALUE:
return php_phongo_unexpectedvalueexception_ce;
case PHONGO_ERROR_MONGOC_FAILED:
return php_phongo_runtimeexception_ce;
case PHONGO_ERROR_WRITE_FAILED:
return php_phongo_bulkwriteexception_ce;
case PHONGO_ERROR_CONNECTION_FAILED:
return php_phongo_connectionexception_ce;
}
MONGOC_ERROR("Resolving unknown phongo error domain: %d", domain);
return php_phongo_runtimeexception_ce;
}
zend_class_entry* phongo_exception_from_mongoc_domain(uint32_t /* mongoc_error_domain_t */ domain, uint32_t /* mongoc_error_code_t */ code)
{
switch(code) {
case 50: /* ExceededTimeLimit */
return php_phongo_executiontimeoutexception_ce;
case MONGOC_ERROR_STREAM_SOCKET:
case MONGOC_ERROR_SERVER_SELECTION_FAILURE:
return php_phongo_connectiontimeoutexception_ce;
case MONGOC_ERROR_CLIENT_AUTHENTICATE:
return php_phongo_authenticationexception_ce;
case MONGOC_ERROR_STREAM_INVALID_TYPE:
case MONGOC_ERROR_STREAM_INVALID_STATE:
case MONGOC_ERROR_STREAM_NAME_RESOLUTION:
case MONGOC_ERROR_STREAM_CONNECT:
case MONGOC_ERROR_STREAM_NOT_ESTABLISHED:
return php_phongo_connectionexception_ce;
case MONGOC_ERROR_CLIENT_NOT_READY:
case MONGOC_ERROR_CLIENT_TOO_BIG:
case MONGOC_ERROR_CLIENT_TOO_SMALL:
case MONGOC_ERROR_CLIENT_GETNONCE:
case MONGOC_ERROR_CLIENT_NO_ACCEPTABLE_PEER:
case MONGOC_ERROR_CLIENT_IN_EXHAUST:
case MONGOC_ERROR_PROTOCOL_INVALID_REPLY:
case MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION:
case MONGOC_ERROR_CURSOR_INVALID_CURSOR:
case MONGOC_ERROR_QUERY_FAILURE:
/*case MONGOC_ERROR_PROTOCOL_ERROR:*/
case MONGOC_ERROR_BSON_INVALID:
case MONGOC_ERROR_MATCHER_INVALID:
case MONGOC_ERROR_NAMESPACE_INVALID:
case MONGOC_ERROR_COMMAND_INVALID_ARG:
case MONGOC_ERROR_COLLECTION_INSERT_FAILED:
case MONGOC_ERROR_GRIDFS_INVALID_FILENAME:
case MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND:
case MONGOC_ERROR_QUERY_NOT_TAILABLE:
return php_phongo_runtimeexception_ce;
}
switch (domain) {
case MONGOC_ERROR_CLIENT:
case MONGOC_ERROR_STREAM:
case MONGOC_ERROR_PROTOCOL:
case MONGOC_ERROR_CURSOR:
case MONGOC_ERROR_QUERY:
case MONGOC_ERROR_INSERT:
case MONGOC_ERROR_SASL:
case MONGOC_ERROR_BSON:
case MONGOC_ERROR_MATCHER:
case MONGOC_ERROR_NAMESPACE:
case MONGOC_ERROR_COMMAND:
case MONGOC_ERROR_COLLECTION:
case MONGOC_ERROR_GRIDFS:
/* FIXME: We don't have the Exceptions mocked yet.. */
#if 0
return phongo_ce_mongo_connection_exception;
#endif
default:
return php_phongo_runtimeexception_ce;
}
}
void phongo_throw_exception(php_phongo_error_domain_t domain TSRMLS_DC, const char *format, ...)
{
va_list args;
char *message;
int message_len;
va_start(args, format);
message_len = vspprintf(&message, 0, format, args);
zend_throw_exception(phongo_exception_from_phongo_domain(domain), message, 0 TSRMLS_CC);
efree(message);
va_end(args);
}
void phongo_throw_exception_from_bson_error_t(bson_error_t *error TSRMLS_DC)
{
zend_throw_exception(phongo_exception_from_mongoc_domain(error->domain, error->code), error->message, error->code TSRMLS_CC);
}
static void php_phongo_log(mongoc_log_level_t log_level, const char *log_domain, const char *message, void *user_data)
{
PHONGO_TSRMLS_FETCH_FROM_CTX(user_data);
(void)user_data;
switch(log_level) {
case MONGOC_LOG_LEVEL_ERROR:
case MONGOC_LOG_LEVEL_CRITICAL:
phongo_throw_exception(PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC, "%s", message);
return;
case MONGOC_LOG_LEVEL_WARNING:
case MONGOC_LOG_LEVEL_MESSAGE:
case MONGOC_LOG_LEVEL_INFO:
case MONGOC_LOG_LEVEL_DEBUG:
case MONGOC_LOG_LEVEL_TRACE:
{
time_t t;
phongo_char *dt;
time(&t);
dt = php_format_date((char *)"Y-m-d\\TH:i:sP", strlen("Y-m-d\\TH:i:sP"), t, 0 TSRMLS_CC);
fprintf(MONGODB_G(debug_fd), "[%s] %10s: %-8s> %s\n", ZSTR_VAL(dt), log_domain, mongoc_log_level_str(log_level), message);
fflush(MONGODB_G(debug_fd));
efree(dt);
} break;
}
}
/* }}} */
/* {{{ Init objects */
static void phongo_cursor_init(zval *return_value, zval *manager, mongoc_cursor_t *cursor, zval *readPreference TSRMLS_DC) /* {{{ */
{
php_phongo_cursor_t *intern;
object_init_ex(return_value, php_phongo_cursor_ce);
intern = Z_CURSOR_OBJ_P(return_value);
intern->cursor = cursor;
intern->server_id = mongoc_cursor_get_hint(cursor);
intern->client = Z_MANAGER_OBJ_P(manager)->client;
#if PHP_VERSION_ID >= 70000
ZVAL_COPY(&intern->manager, manager);
#else
Z_ADDREF_P(manager);
intern->manager = manager;
#endif
if (readPreference) {
#if PHP_VERSION_ID >= 70000
ZVAL_ZVAL(&intern->read_preference, readPreference, 1, 0);
#else
Z_ADDREF_P(readPreference);
intern->read_preference = readPreference;
#endif
}
} /* }}} */
static void phongo_cursor_init_for_command(zval *return_value, zval *manager, mongoc_cursor_t *cursor, const char *db, zval *command, zval *readPreference TSRMLS_DC) /* {{{ */
{
php_phongo_cursor_t *intern;
phongo_cursor_init(return_value, manager, cursor, readPreference TSRMLS_CC);
intern = Z_CURSOR_OBJ_P(return_value);
intern->database = estrdup(db);
#if PHP_VERSION_ID >= 70000
ZVAL_ZVAL(&intern->command, command, 1, 0);
#else
Z_ADDREF_P(command);
intern->command = command;
#endif
} /* }}} */
static void phongo_cursor_init_for_query(zval *return_value, zval *manager, mongoc_cursor_t *cursor, const char *namespace, zval *query, zval *readPreference TSRMLS_DC) /* {{{ */
{
php_phongo_cursor_t *intern;
phongo_cursor_init(return_value, manager, cursor, readPreference TSRMLS_CC);
intern = Z_CURSOR_OBJ_P(return_value);
/* namespace has already been validated by phongo_execute_query() */
phongo_split_namespace(namespace, &intern->database, &intern->collection);
#if PHP_VERSION_ID >= 70000
ZVAL_ZVAL(&intern->query, query, 1, 0);
#else
Z_ADDREF_P(query);
intern->query = query;
#endif
} /* }}} */
void phongo_server_init(zval *return_value, zval *manager, int server_id TSRMLS_DC) /* {{{ */
{
php_phongo_server_t *server;
object_init_ex(return_value, php_phongo_server_ce);
server = Z_SERVER_OBJ_P(return_value);
server->server_id = server_id;
server->client = Z_MANAGER_OBJ_P(manager)->client;
#if PHP_VERSION_ID >= 70000
ZVAL_COPY(&server->manager, manager);
#else
Z_ADDREF_P(manager);
server->manager = manager;
#endif
}
/* }}} */
void phongo_readconcern_init(zval *return_value, const mongoc_read_concern_t *read_concern TSRMLS_DC) /* {{{ */
{
php_phongo_readconcern_t *intern;
object_init_ex(return_value, php_phongo_readconcern_ce);
intern = Z_READCONCERN_OBJ_P(return_value);
intern->read_concern = mongoc_read_concern_copy(read_concern);
}
/* }}} */
void phongo_readpreference_init(zval *return_value, const mongoc_read_prefs_t *read_prefs TSRMLS_DC) /* {{{ */
{
php_phongo_readpreference_t *intern;
object_init_ex(return_value, php_phongo_readpreference_ce);
intern = Z_READPREFERENCE_OBJ_P(return_value);
intern->read_preference = mongoc_read_prefs_copy(read_prefs);
}
/* }}} */
void phongo_writeconcern_init(zval *return_value, const mongoc_write_concern_t *write_concern TSRMLS_DC) /* {{{ */
{
php_phongo_writeconcern_t *intern;
object_init_ex(return_value, php_phongo_writeconcern_ce);
intern = Z_WRITECONCERN_OBJ_P(return_value);
intern->write_concern = mongoc_write_concern_copy(write_concern);
}
/* }}} */
zend_bool phongo_writeconcernerror_init(zval *return_value, bson_t *bson TSRMLS_DC) /* {{{ */
{
bson_iter_t iter;
- php_phongo_writeconcernerror_t *writeconcernerror;
+ php_phongo_writeconcernerror_t *intern;
- writeconcernerror = Z_WRITECONCERNERROR_OBJ_P(return_value);
+ object_init_ex(return_value, php_phongo_writeconcernerror_ce);
+
+ intern = Z_WRITECONCERNERROR_OBJ_P(return_value);
if (bson_iter_init_find(&iter, bson, "code") && BSON_ITER_HOLDS_INT32(&iter)) {
- writeconcernerror->code = bson_iter_int32(&iter);
+ intern->code = bson_iter_int32(&iter);
}
+
if (bson_iter_init_find(&iter, bson, "errmsg") && BSON_ITER_HOLDS_UTF8(&iter)) {
uint32_t errmsg_len;
const char *err_msg = bson_iter_utf8(&iter, &errmsg_len);
- writeconcernerror->message = estrndup(err_msg, errmsg_len);
+ intern->message = estrndup(err_msg, errmsg_len);
}
+
if (bson_iter_init_find(&iter, bson, "errInfo") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
- uint32_t len;
- const uint8_t *data;
+ uint32_t len;
+ const uint8_t *data = NULL;
bson_iter_document(&iter, &len, &data);
- if (!data) {
- return false;
- }
-
- if (!phongo_bson_to_zval(data, len, &writeconcernerror->info)) {
- zval_ptr_dtor(&writeconcernerror->info);
+ if (!phongo_bson_to_zval(data, len, &intern->info)) {
+ zval_ptr_dtor(&intern->info);
#if PHP_VERSION_ID >= 70000
- ZVAL_UNDEF(&writeconcernerror->info);
+ ZVAL_UNDEF(&intern->info);
#else
- writeconcernerror->info = NULL;
+ intern->info = NULL;
#endif
return false;
}
}
return true;
} /* }}} */
zend_bool phongo_writeerror_init(zval *return_value, bson_t *bson TSRMLS_DC) /* {{{ */
{
bson_iter_t iter;
- php_phongo_writeerror_t *writeerror;
+ php_phongo_writeerror_t *intern;
+
+ object_init_ex(return_value, php_phongo_writeerror_ce);
- writeerror = Z_WRITEERROR_OBJ_P(return_value);
+ intern = Z_WRITEERROR_OBJ_P(return_value);
if (bson_iter_init_find(&iter, bson, "code") && BSON_ITER_HOLDS_INT32(&iter)) {
- writeerror->code = bson_iter_int32(&iter);
+ intern->code = bson_iter_int32(&iter);
}
+
if (bson_iter_init_find(&iter, bson, "errmsg") && BSON_ITER_HOLDS_UTF8(&iter)) {
uint32_t errmsg_len;
const char *err_msg = bson_iter_utf8(&iter, &errmsg_len);
- writeerror->message = estrndup(err_msg, errmsg_len);
+ intern->message = estrndup(err_msg, errmsg_len);
}
- if (bson_iter_init_find(&iter, bson, "errInfo")) {
- bson_t info;
- bson_init(&info);
- bson_append_iter(&info, NULL, 0, &iter);
+ if (bson_iter_init_find(&iter, bson, "errInfo") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
+ uint32_t len;
+ const uint8_t *data = NULL;
+
+ bson_iter_document(&iter, &len, &data);
- if (!phongo_bson_to_zval(bson_get_data(&info), info.len, &writeerror->info)) {
- zval_ptr_dtor(&writeerror->info);
+ if (!phongo_bson_to_zval(data, len, &intern->info)) {
+ zval_ptr_dtor(&intern->info);
#if PHP_VERSION_ID >= 70000
- ZVAL_UNDEF(&writeerror->info);
+ ZVAL_UNDEF(&intern->info);
#else
- writeerror->info = NULL;
+ intern->info = NULL;
#endif
return false;
}
}
+
if (bson_iter_init_find(&iter, bson, "index") && BSON_ITER_HOLDS_INT32(&iter)) {
- writeerror->index = bson_iter_int32(&iter);
+ intern->index = bson_iter_int32(&iter);
}
return true;
} /* }}} */
php_phongo_writeresult_t *phongo_writeresult_init(zval *return_value, bson_t *reply, zval *manager, int server_id TSRMLS_DC) /* {{{ */
{
php_phongo_writeresult_t *writeresult;
object_init_ex(return_value, php_phongo_writeresult_ce);
writeresult = Z_WRITERESULT_OBJ_P(return_value);
writeresult->reply = bson_copy(reply);
writeresult->server_id = server_id;
writeresult->client = Z_MANAGER_OBJ_P(manager)->client;
#if PHP_VERSION_ID >= 70000
ZVAL_COPY(&writeresult->manager, manager);
#else
Z_ADDREF_P(manager);
writeresult->manager = manager;
#endif
return writeresult;
} /* }}} */
/* }}} */
/* {{{ CRUD */
/* Splits a namespace name into the database and collection names, allocated with estrdup. */
static bool phongo_split_namespace(const char *namespace, char **dbname, char **cname) /* {{{ */
{
char *dot = strchr(namespace, '.');
if (!dot) {
return false;
}
if (cname) {
*cname = estrdup(namespace + (dot - namespace) + 1);
}
if (dbname) {
*dbname = estrndup(namespace, dot - namespace);
}
return true;
} /* }}} */
mongoc_bulk_operation_t *phongo_bulkwrite_init(zend_bool ordered) { /* {{{ */
return mongoc_bulk_operation_new(ordered);
} /* }}} */
bool phongo_execute_write(zval *manager, const char *namespace, php_phongo_bulkwrite_t *bulk_write, const mongoc_write_concern_t *write_concern, int server_id, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */
{
mongoc_client_t *client;
bson_error_t error;
int success;
bson_t reply = BSON_INITIALIZER;
mongoc_bulk_operation_t *bulk = bulk_write->bulk;
php_phongo_writeresult_t *writeresult;
client = Z_MANAGER_OBJ_P(manager)->client;
if (bulk_write->executed) {
phongo_throw_exception(PHONGO_ERROR_WRITE_FAILED TSRMLS_CC, "BulkWrite objects may only be executed once and this instance has already been executed");
return false;
}
if (!phongo_split_namespace(namespace, &bulk_write->database, &bulk_write->collection)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "%s: %s", "Invalid namespace provided", namespace);
return false;
}
mongoc_bulk_operation_set_database(bulk, bulk_write->database);
mongoc_bulk_operation_set_collection(bulk, bulk_write->collection);
mongoc_bulk_operation_set_client(bulk, client);
/* If a write concern was not specified, libmongoc will use the client's
* write concern; however, we should still fetch it for the write result. */
if (write_concern) {
mongoc_bulk_operation_set_write_concern(bulk, write_concern);
} else {
write_concern = mongoc_client_get_write_concern(client);
}
if (server_id > 0) {
mongoc_bulk_operation_set_hint(bulk, server_id);
}
success = mongoc_bulk_operation_execute(bulk, &reply, &error);
bulk_write->executed = true;
/* Write succeeded and the user doesn't care for the results */
if (success && !return_value_used) {
bson_destroy(&reply);
return true;
}
/* Check for connection related exceptions */
if (EG(exception)) {
bson_destroy(&reply);
return false;
}
writeresult = phongo_writeresult_init(return_value, &reply, manager, mongoc_bulk_operation_get_hint(bulk) TSRMLS_CC);
writeresult->write_concern = mongoc_write_concern_copy(write_concern);
/* The Write failed */
if (!success) {
if (error.domain == MONGOC_ERROR_COMMAND || error.domain == MONGOC_ERROR_WRITE_CONCERN) {
phongo_throw_exception(PHONGO_ERROR_WRITE_FAILED TSRMLS_CC, "%s", error.message);
phongo_add_exception_prop(ZEND_STRL("writeResult"), return_value TSRMLS_CC);
} else {
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
}
}
bson_destroy(&reply);
return success;
} /* }}} */
/* Advance the cursor and return whether there is an error. On error, the cursor
* will be destroyed and an exception will be thrown. */
static bool phongo_advance_cursor_and_check_for_error(mongoc_cursor_t *cursor TSRMLS_DC)
{
const bson_t *doc;
if (!mongoc_cursor_next(cursor, &doc)) {
bson_error_t error;
/* Check for connection related exceptions */
if (EG(exception)) {
mongoc_cursor_destroy(cursor);
return false;
}
/* Could simply be no docs, which is not an error */
if (mongoc_cursor_error(cursor, &error)) {
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
mongoc_cursor_destroy(cursor);
return false;
}
}
return true;
}
int phongo_execute_query(zval *manager, const char *namespace, zval *zquery, zval *zreadPreference, int server_id, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */
{
mongoc_client_t *client;
const php_phongo_query_t *query;
mongoc_cursor_t *cursor;
char *dbname;
char *collname;
mongoc_collection_t *collection;
client = Z_MANAGER_OBJ_P(manager)->client;
if (!phongo_split_namespace(namespace, &dbname, &collname)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "%s: %s", "Invalid namespace provided", namespace);
return false;
}
collection = mongoc_client_get_collection(client, dbname, collname);
efree(dbname);
efree(collname);
query = Z_QUERY_OBJ_P(zquery);
if (query->read_concern) {
mongoc_collection_set_read_concern(collection, query->read_concern);
}
cursor = mongoc_collection_find_with_opts(collection, query->filter, query->opts, phongo_read_preference_from_zval(zreadPreference TSRMLS_CC));
mongoc_collection_destroy(collection);
/* mongoc issues a warning we need to catch somehow */
if (!cursor) {
phongo_throw_exception(PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC, "%s", "FIXME: Couldn't create cursor...");
return false;
}
if (server_id > 0 && !mongoc_cursor_set_hint(cursor, server_id)) {
phongo_throw_exception(PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC, "%s", "Could not set cursor server_id");
return false;
}
if (!phongo_advance_cursor_and_check_for_error(cursor TSRMLS_CC)) {
return false;
}
if (!return_value_used) {
mongoc_cursor_destroy(cursor);
return true;
}
phongo_cursor_init_for_query(return_value, manager, cursor, namespace, zquery, zreadPreference TSRMLS_CC);
return true;
} /* }}} */
int phongo_execute_command(zval *manager, const char *db, zval *zcommand, zval *zreadPreference, int server_id, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */
{
mongoc_client_t *client;
const php_phongo_command_t *command;
mongoc_cursor_t *cursor;
bson_iter_t iter;
client = Z_MANAGER_OBJ_P(manager)->client;
command = Z_COMMAND_OBJ_P(zcommand);
cursor = mongoc_client_command(client, db, MONGOC_QUERY_NONE, 0, 1, 0, command->bson, NULL, phongo_read_preference_from_zval(zreadPreference TSRMLS_CC));
if (server_id > 0 && !mongoc_cursor_set_hint(cursor, server_id)) {
phongo_throw_exception(PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC, "%s", "Could not set cursor server_id");
return false;
}
if (!phongo_advance_cursor_and_check_for_error(cursor TSRMLS_CC)) {
return false;
}
if (!return_value_used) {
mongoc_cursor_destroy(cursor);
return true;
}
if (bson_iter_init_find(&iter, mongoc_cursor_current(cursor), "cursor") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
mongoc_cursor_t *cmd_cursor;
/* According to mongoc_cursor_new_from_command_reply(), the reply bson_t
* is ultimately destroyed on both success and failure. Use bson_copy()
* to create a writable copy of the const bson_t we fetched above. */
cmd_cursor = mongoc_cursor_new_from_command_reply(client, bson_copy(mongoc_cursor_current(cursor)), mongoc_cursor_get_hint(cursor));
mongoc_cursor_destroy(cursor);
if (!phongo_advance_cursor_and_check_for_error(cmd_cursor TSRMLS_CC)) {
return false;
}
phongo_cursor_init_for_command(return_value, manager, cmd_cursor, db, zcommand, zreadPreference TSRMLS_CC);
return true;
}
phongo_cursor_init_for_command(return_value, manager, cursor, db, zcommand, zreadPreference TSRMLS_CC);
return true;
} /* }}} */
/* }}} */
/* {{{ mongoc types from from_zval */
const mongoc_write_concern_t* phongo_write_concern_from_zval(zval *zwrite_concern TSRMLS_DC) /* {{{ */
{
if (zwrite_concern) {
php_phongo_writeconcern_t *intern = Z_WRITECONCERN_OBJ_P(zwrite_concern);
if (intern) {
return intern->write_concern;
}
}
return NULL;
} /* }}} */
const mongoc_read_concern_t* phongo_read_concern_from_zval(zval *zread_concern TSRMLS_DC) /* {{{ */
{
if (zread_concern) {
php_phongo_readconcern_t *intern = Z_READCONCERN_OBJ_P(zread_concern);
if (intern) {
return intern->read_concern;
}
}
return NULL;
} /* }}} */
const mongoc_read_prefs_t* phongo_read_preference_from_zval(zval *zread_preference TSRMLS_DC) /* {{{ */
{
if (zread_preference) {
php_phongo_readpreference_t *intern = Z_READPREFERENCE_OBJ_P(zread_preference);
if (intern) {
return intern->read_preference;
}
}
return NULL;
} /* }}} */
/* }}} */
/* {{{ phongo zval from mongoc types */
void php_phongo_cursor_id_new_from_id(zval *object, int64_t cursorid TSRMLS_DC) /* {{{ */
{
php_phongo_cursorid_t *intern;
object_init_ex(object, php_phongo_cursorid_ce);
intern = Z_CURSORID_OBJ_P(object);
intern->id = cursorid;
} /* }}} */
void php_phongo_objectid_new_from_oid(zval *object, const bson_oid_t *oid TSRMLS_DC) /* {{{ */
{
php_phongo_objectid_t *intern;
object_init_ex(object, php_phongo_objectid_ce);
intern = Z_OBJECTID_OBJ_P(object);
bson_oid_to_string(oid, intern->oid);
intern->initialized = true;
} /* }}} */
php_phongo_server_description_type_t php_phongo_server_description_type(mongoc_server_description_t *sd)
{
const char* name = mongoc_server_description_type(sd);
int i;
for (i = 0; i < PHONGO_SERVER_DESCRIPTION_TYPES; i++) {
if (!strcmp(name, php_phongo_server_description_type_map[i].name)) {
return php_phongo_server_description_type_map[i].type;
}
}
return PHONGO_SERVER_UNKNOWN;
}
void php_phongo_server_to_zval(zval *retval, mongoc_server_description_t *sd) /* {{{ */
{
mongoc_host_list_t *host = mongoc_server_description_host(sd);
const bson_t *is_master = mongoc_server_description_ismaster(sd);
bson_iter_t iter;
array_init(retval);
ADD_ASSOC_STRING(retval, "host", host->host);
ADD_ASSOC_LONG_EX(retval, "port", host->port);
ADD_ASSOC_LONG_EX(retval, "type", php_phongo_server_description_type(sd));
ADD_ASSOC_BOOL_EX(retval, "is_primary", !strcmp(mongoc_server_description_type(sd), php_phongo_server_description_type_map[PHONGO_SERVER_RS_PRIMARY].name));
ADD_ASSOC_BOOL_EX(retval, "is_secondary", !strcmp(mongoc_server_description_type(sd), php_phongo_server_description_type_map[PHONGO_SERVER_RS_SECONDARY].name));
ADD_ASSOC_BOOL_EX(retval, "is_arbiter", !strcmp(mongoc_server_description_type(sd), php_phongo_server_description_type_map[PHONGO_SERVER_RS_ARBITER].name));
ADD_ASSOC_BOOL_EX(retval, "is_hidden", bson_iter_init_find_case(&iter, is_master, "hidden") && bson_iter_as_bool(&iter));
ADD_ASSOC_BOOL_EX(retval, "is_passive", bson_iter_init_find_case(&iter, is_master, "passive") && bson_iter_as_bool(&iter));
if (bson_iter_init_find(&iter, is_master, "tags") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
const uint8_t *bytes;
uint32_t len;
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
/* Use native arrays for debugging output */
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
bson_iter_document(&iter, &len, &bytes);
phongo_bson_to_zval_ex(bytes, len, &state);
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(retval, "tags", &state.zchild);
#else
ADD_ASSOC_ZVAL_EX(retval, "tags", state.zchild);
#endif
}
{
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
/* Use native arrays for debugging output */
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
phongo_bson_to_zval_ex(bson_get_data(is_master), is_master->len, &state);
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(retval, "last_is_master", &state.zchild);
#else
ADD_ASSOC_ZVAL_EX(retval, "last_is_master", state.zchild);
#endif
}
ADD_ASSOC_LONG_EX(retval, "round_trip_time", (phongo_long) mongoc_server_description_round_trip_time(sd));
} /* }}} */
void php_phongo_read_concern_to_zval(zval *retval, const mongoc_read_concern_t *read_concern) /* {{{ */
{
const char *level = mongoc_read_concern_get_level(read_concern);
array_init_size(retval, 1);
if (level) {
ADD_ASSOC_STRING(retval, "level", level);
}
} /* }}} */
/* Prepare tagSets for BSON encoding by converting each array in the set to an
* object. This ensures that empty arrays will serialize as empty documents.
*
* php_phongo_read_preference_tags_are_valid() handles actual validation of the
* tag set structure. */
void php_phongo_read_preference_prep_tagsets(zval *tagSets TSRMLS_DC) /* {{{ */
{
HashTable *ht_data;
if (Z_TYPE_P(tagSets) != IS_ARRAY) {
return;
}
ht_data = HASH_OF(tagSets);
#if PHP_VERSION_ID >= 70000
{
zval *tagSet;
ZEND_HASH_FOREACH_VAL(ht_data, tagSet) {
+ ZVAL_DEREF(tagSet);
if (Z_TYPE_P(tagSet) == IS_ARRAY) {
+ SEPARATE_ZVAL_NOREF(tagSet);
convert_to_object(tagSet);
}
} ZEND_HASH_FOREACH_END();
}
#else
{
HashPosition pos;
zval **tagSet;
for (zend_hash_internal_pointer_reset_ex(ht_data, &pos);
zend_hash_get_current_data_ex(ht_data, (void **) &tagSet, &pos) == SUCCESS;
zend_hash_move_forward_ex(ht_data, &pos)) {
if (Z_TYPE_PP(tagSet) == IS_ARRAY) {
+ SEPARATE_ZVAL_IF_NOT_REF(tagSet);
convert_to_object(*tagSet);
}
}
}
#endif
return;
} /* }}} */
/* Checks if tags is valid to set on a mongoc_read_prefs_t. It may be null or an
* array of one or more documents. */
bool php_phongo_read_preference_tags_are_valid(const bson_t *tags) /* {{{ */
{
bson_iter_t iter;
if (bson_empty0(tags)) {
return true;
}
if (!bson_iter_init(&iter, tags)) {
return false;
}
while (bson_iter_next(&iter)) {
- if (!BSON_ITER_HOLDS_DOCUMENT(&iter) && !BSON_ITER_HOLDS_ARRAY(&iter)) {
+ if (!BSON_ITER_HOLDS_DOCUMENT(&iter)) {
return false;
}
}
return true;
} /* }}} */
void php_phongo_read_preference_to_zval(zval *retval, const mongoc_read_prefs_t *read_prefs) /* {{{ */
{
const bson_t *tags = mongoc_read_prefs_get_tags(read_prefs);
mongoc_read_mode_t mode = mongoc_read_prefs_get_mode(read_prefs);
array_init_size(retval, 3);
switch (mode) {
case MONGOC_READ_PRIMARY: ADD_ASSOC_STRING(retval, "mode", "primary"); break;
case MONGOC_READ_PRIMARY_PREFERRED: ADD_ASSOC_STRING(retval, "mode", "primaryPreferred"); break;
case MONGOC_READ_SECONDARY: ADD_ASSOC_STRING(retval, "mode", "secondary"); break;
case MONGOC_READ_SECONDARY_PREFERRED: ADD_ASSOC_STRING(retval, "mode", "secondaryPreferred"); break;
case MONGOC_READ_NEAREST: ADD_ASSOC_STRING(retval, "mode", "nearest"); break;
default: /* Do nothing */
break;
}
if (!bson_empty0(tags)) {
/* Use PHONGO_TYPEMAP_NATIVE_ARRAY for the root type since tags is an
* array; however, inner documents and arrays can use the default. */
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
phongo_bson_to_zval_ex(bson_get_data(tags), tags->len, &state);
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(retval, "tags", &state.zchild);
#else
ADD_ASSOC_ZVAL_EX(retval, "tags", state.zchild);
#endif
}
if (mongoc_read_prefs_get_max_staleness_seconds(read_prefs) != MONGOC_NO_MAX_STALENESS) {
ADD_ASSOC_LONG_EX(retval, "maxStalenessSeconds", mongoc_read_prefs_get_max_staleness_seconds(read_prefs));
}
} /* }}} */
void php_phongo_write_concern_to_zval(zval *retval, const mongoc_write_concern_t *write_concern) /* {{{ */
{
const char *wtag = mongoc_write_concern_get_wtag(write_concern);
const int32_t w = mongoc_write_concern_get_w(write_concern);
const int32_t wtimeout = mongoc_write_concern_get_wtimeout(write_concern);
array_init_size(retval, 4);
if (wtag) {
ADD_ASSOC_STRING(retval, "w", wtag);
} else if (mongoc_write_concern_get_wmajority(write_concern)) {
ADD_ASSOC_STRING(retval, "w", PHONGO_WRITE_CONCERN_W_MAJORITY);
} else if (w != MONGOC_WRITE_CONCERN_W_DEFAULT) {
ADD_ASSOC_LONG_EX(retval, "w", w);
}
if (mongoc_write_concern_journal_is_set(write_concern)) {
ADD_ASSOC_BOOL_EX(retval, "j", mongoc_write_concern_get_journal(write_concern));
}
if (wtimeout != 0) {
ADD_ASSOC_LONG_EX(retval, "wtimeout", wtimeout);
}
} /* }}} */
/* }}} */
static mongoc_uri_t *php_phongo_make_uri(const char *uri_string, bson_t *options) /* {{{ */
{
bson_iter_t iter;
mongoc_uri_t *uri;
uri = mongoc_uri_new(uri_string);
MONGOC_DEBUG("Connection string: '%s'", uri_string);
if (!uri) {
return NULL;
}
if (options && bson_iter_init(&iter, options)) {
while (bson_iter_next (&iter)) {
const char *key = bson_iter_key(&iter);
/* Skip read preference and write concern options, as those must be
* processed after the mongoc_client_t is constructed. */
if (!strcasecmp(key, "journal") ||
!strcasecmp(key, "readpreference") ||
!strcasecmp(key, "readpreferencetags") ||
!strcasecmp(key, "safe") ||
!strcasecmp(key, "slaveok") ||
!strcasecmp(key, "w") ||
!strcasecmp(key, "wtimeoutms") ||
!strcasecmp(key, "maxstalenessseconds") ||
!strcasecmp(key, "appname")
) {
continue;
}
if (mongoc_uri_option_is_bool(key)) {
mongoc_uri_set_option_as_bool (uri, key, bson_iter_as_bool(&iter));
}
else if (mongoc_uri_option_is_int32(key) && BSON_ITER_HOLDS_INT32(&iter)) {
mongoc_uri_set_option_as_int32 (uri, key, bson_iter_int32 (&iter));
}
else if (mongoc_uri_option_is_utf8(key) && BSON_ITER_HOLDS_UTF8(&iter)) {
mongoc_uri_set_option_as_utf8(uri, key, bson_iter_utf8 (&iter, NULL));
}
else if (BSON_ITER_HOLDS_UTF8(&iter)) {
const char *value = bson_iter_utf8 (&iter, NULL);
if (!strcasecmp(key, "username")) {
mongoc_uri_set_username(uri, value);
} else if (!strcasecmp(key, "password")) {
mongoc_uri_set_password(uri, value);
} else if (!strcasecmp(key, "database")) {
mongoc_uri_set_database(uri, value);
} else if (!strcasecmp(key, "authsource")) {
mongoc_uri_set_auth_source(uri, value);
}
}
}
}
return uri;
} /* }}} */
static bool php_phongo_apply_rc_options_to_uri(mongoc_uri_t *uri, bson_t *options TSRMLS_DC) /* {{{ */
{
bson_iter_t iter;
mongoc_read_concern_t *new_rc;
const mongoc_read_concern_t *old_rc;
if (!(old_rc = mongoc_uri_get_read_concern(uri))) {
phongo_throw_exception(PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC, "mongoc_uri_t does not have a read concern");
return false;
}
/* Return early if there are no options to apply */
if (bson_empty0(options)) {
return true;
}
if (!bson_iter_init_find_case(&iter, options, "readconcernlevel")) {
return true;
}
new_rc = mongoc_read_concern_copy(old_rc);
if (bson_iter_init_find_case(&iter, options, "readconcernlevel") && BSON_ITER_HOLDS_UTF8(&iter)) {
const char *str = bson_iter_utf8(&iter, NULL);
mongoc_read_concern_set_level(new_rc, str);
}
mongoc_uri_set_read_concern(uri, new_rc);
mongoc_read_concern_destroy(new_rc);
return true;
} /* }}} */
static bool php_phongo_apply_rp_options_to_uri(mongoc_uri_t *uri, bson_t *options TSRMLS_DC) /* {{{ */
{
bson_iter_t iter;
mongoc_read_prefs_t *new_rp;
const mongoc_read_prefs_t *old_rp;
if (!(old_rp = mongoc_uri_get_read_prefs_t(uri))) {
phongo_throw_exception(PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC, "mongoc_uri_t does not have a read preference");
return false;
}
/* Return early if there are no options to apply */
if (bson_empty0(options)) {
return true;
}
if (!bson_iter_init_find_case(&iter, options, "slaveok") &&
!bson_iter_init_find_case(&iter, options, "readpreference") &&
!bson_iter_init_find_case(&iter, options, "readpreferencetags") &&
!bson_iter_init_find_case(&iter, options, "maxstalenessseconds")
) {
return true;
}
new_rp = mongoc_read_prefs_copy(old_rp);
if (bson_iter_init_find_case(&iter, options, "slaveok") && BSON_ITER_HOLDS_BOOL(&iter)) {
mongoc_read_prefs_set_mode(new_rp, MONGOC_READ_SECONDARY_PREFERRED);
}
if (bson_iter_init_find_case(&iter, options, "readpreference") && BSON_ITER_HOLDS_UTF8(&iter)) {
const char *str = bson_iter_utf8(&iter, NULL);
if (0 == strcasecmp("primary", str)) {
mongoc_read_prefs_set_mode(new_rp, MONGOC_READ_PRIMARY);
} else if (0 == strcasecmp("primarypreferred", str)) {
mongoc_read_prefs_set_mode(new_rp, MONGOC_READ_PRIMARY_PREFERRED);
} else if (0 == strcasecmp("secondary", str)) {
mongoc_read_prefs_set_mode(new_rp, MONGOC_READ_SECONDARY);
} else if (0 == strcasecmp("secondarypreferred", str)) {
mongoc_read_prefs_set_mode(new_rp, MONGOC_READ_SECONDARY_PREFERRED);
} else if (0 == strcasecmp("nearest", str)) {
mongoc_read_prefs_set_mode(new_rp, MONGOC_READ_NEAREST);
} else {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Unsupported readPreference value: '%s'", str);
mongoc_read_prefs_destroy(new_rp);
return false;
}
}
if (bson_iter_init_find_case(&iter, options, "readpreferencetags") && BSON_ITER_HOLDS_ARRAY(&iter)) {
bson_t tags;
uint32_t len;
const uint8_t *data;
bson_iter_array(&iter, &len, &data);
if (!bson_init_static(&tags, data, len)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Could not initialize BSON structure for read preference tags");
mongoc_read_prefs_destroy(new_rp);
return false;
}
if (!php_phongo_read_preference_tags_are_valid(&tags)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Read preference tags must be an array of zero or more documents");
mongoc_read_prefs_destroy(new_rp);
return false;
}
mongoc_read_prefs_set_tags(new_rp, &tags);
}
if (mongoc_read_prefs_get_mode(new_rp) == MONGOC_READ_PRIMARY &&
!bson_empty(mongoc_read_prefs_get_tags(new_rp))) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Primary read preference mode conflicts with tags");
mongoc_read_prefs_destroy(new_rp);
return false;
}
/* Handle maxStalenessSeconds, and make sure it is not combined with primary
* readPreference */
if (bson_iter_init_find_case(&iter, options, "maxstalenessseconds") && BSON_ITER_HOLDS_INT32(&iter)) {
int32_t max_staleness_seconds = bson_iter_int32(&iter);
if (max_staleness_seconds != MONGOC_NO_MAX_STALENESS) {
if (max_staleness_seconds < MONGOC_SMALLEST_MAX_STALENESS_SECONDS) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected maxStalenessSeconds to be >= %d, %" PRId32 " given", MONGOC_SMALLEST_MAX_STALENESS_SECONDS, max_staleness_seconds);
mongoc_read_prefs_destroy(new_rp);
return false;
}
/* max_staleness_seconds is fetched as an INT32, so there is no need to check
* if it exists INT32_MAX as we do in the ReadPreference constructor. */
if (mongoc_read_prefs_get_mode(new_rp) == MONGOC_READ_PRIMARY) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Primary read preference mode conflicts with maxStalenessSeconds");
mongoc_read_prefs_destroy(new_rp);
return false;
}
}
mongoc_read_prefs_set_max_staleness_seconds(new_rp, max_staleness_seconds);
}
/* This may be redundant in light of the last check (primary with tags), but
* we'll check anyway in case additional validation is implemented. */
if (!mongoc_read_prefs_is_valid(new_rp)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Read preference is not valid");
mongoc_read_prefs_destroy(new_rp);
return false;
}
mongoc_uri_set_read_prefs_t(uri, new_rp);
mongoc_read_prefs_destroy(new_rp);
return true;
} /* }}} */
static bool php_phongo_apply_wc_options_to_uri(mongoc_uri_t *uri, bson_t *options TSRMLS_DC) /* {{{ */
{
bson_iter_t iter;
int32_t wtimeoutms;
mongoc_write_concern_t *new_wc;
const mongoc_write_concern_t *old_wc;
if (!(old_wc = mongoc_uri_get_write_concern(uri))) {
phongo_throw_exception(PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC, "mongoc_uri_t does not have a write concern");
return false;
}
/* Return early if there are no options to apply */
if (bson_empty0(options)) {
return true;
}
if (!bson_iter_init_find_case(&iter, options, "journal") &&
!bson_iter_init_find_case(&iter, options, "safe") &&
!bson_iter_init_find_case(&iter, options, "w") &&
!bson_iter_init_find_case(&iter, options, "wtimeoutms")) {
return true;
}
wtimeoutms = mongoc_write_concern_get_wtimeout(old_wc);
new_wc = mongoc_write_concern_copy(old_wc);
if (bson_iter_init_find_case(&iter, options, "safe") && BSON_ITER_HOLDS_BOOL(&iter)) {
mongoc_write_concern_set_w(new_wc, bson_iter_bool(&iter) ? 1 : MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED);
}
if (bson_iter_init_find_case(&iter, options, "wtimeoutms") && BSON_ITER_HOLDS_INT32(&iter)) {
wtimeoutms = bson_iter_int32(&iter);
}
if (bson_iter_init_find_case(&iter, options, "journal") && BSON_ITER_HOLDS_BOOL(&iter)) {
mongoc_write_concern_set_journal(new_wc, bson_iter_bool(&iter));
}
if (bson_iter_init_find_case(&iter, options, "w")) {
if (BSON_ITER_HOLDS_INT32(&iter)) {
int32_t value = bson_iter_int32(&iter);
switch (value) {
case MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED:
case MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED:
mongoc_write_concern_set_w(new_wc, value);
break;
default:
if (value > 0) {
mongoc_write_concern_set_w(new_wc, value);
break;
}
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Unsupported w value: %d", value);
mongoc_write_concern_destroy(new_wc);
return false;
}
} else if (BSON_ITER_HOLDS_UTF8(&iter)) {
const char *str = bson_iter_utf8(&iter, NULL);
if (0 == strcasecmp(PHONGO_WRITE_CONCERN_W_MAJORITY, str)) {
mongoc_write_concern_set_wmajority(new_wc, wtimeoutms);
} else {
mongoc_write_concern_set_wtag(new_wc, str);
}
}
}
/* Only set wtimeout if it's still applicable; otherwise, clear it. */
if (mongoc_write_concern_get_w(new_wc) > 1 ||
mongoc_write_concern_get_wmajority(new_wc) ||
mongoc_write_concern_get_wtag(new_wc)) {
mongoc_write_concern_set_wtimeout(new_wc, wtimeoutms);
} else {
mongoc_write_concern_set_wtimeout(new_wc, 0);
}
if (mongoc_write_concern_get_journal(new_wc)) {
int32_t w = mongoc_write_concern_get_w(new_wc);
if (w == MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED || w == MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Journal conflicts with w value: %d", w);
mongoc_write_concern_destroy(new_wc);
return false;
}
}
/* This may be redundant in light of the last check (unacknowledged w with
journal), but we'll check anyway in case additional validation is
implemented. */
if (!mongoc_write_concern_is_valid(new_wc)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Write concern is not valid");
mongoc_write_concern_destroy(new_wc);
return false;
}
mongoc_uri_set_write_concern(uri, new_wc);
mongoc_write_concern_destroy(new_wc);
return true;
} /* }}} */
static inline char *php_phongo_fetch_ssl_opt_string(zval *zoptions, const char *key, int key_len)
{
int plen;
zend_bool pfree;
char *pval, *value;
pval = php_array_fetchl_string(zoptions, key, key_len, &plen, &pfree);
value = pfree ? pval : estrndup(pval, plen);
return value;
}
static mongoc_ssl_opt_t *php_phongo_make_ssl_opt(zval *zoptions TSRMLS_DC)
{
mongoc_ssl_opt_t *ssl_opt;
if (!zoptions) {
return NULL;
}
#if defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) || defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT)
if (php_array_existsc(zoptions, "ca_dir")) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "\"ca_dir\" option is not supported by Secure Channel and Secure Transport");
return NULL;
}
if (php_array_existsc(zoptions, "capath")) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "\"capath\" option is not supported by Secure Channel and Secure Transport");
return NULL;
}
#endif
#if defined(MONGOC_ENABLE_SSL_LIBRESSL) || defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT)
if (php_array_existsc(zoptions, "crl_file")) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "\"crl_file\" option is not supported by LibreSSL and Secure Transport");
return NULL;
}
#endif
ssl_opt = ecalloc(1, sizeof(mongoc_ssl_opt_t));
/* Check canonical option names first and fall back to SSL context options
* for backwards compatibility. */
if (php_array_existsc(zoptions, "allow_invalid_hostname")) {
ssl_opt->allow_invalid_hostname = php_array_fetchc_bool(zoptions, "allow_invalid_hostname");
}
if (php_array_existsc(zoptions, "weak_cert_validation")) {
ssl_opt->weak_cert_validation = php_array_fetchc_bool(zoptions, "weak_cert_validation");
} else if (php_array_existsc(zoptions, "allow_self_signed")) {
ssl_opt->weak_cert_validation = php_array_fetchc_bool(zoptions, "allow_self_signed");
}
if (php_array_existsc(zoptions, "pem_file")) {
ssl_opt->pem_file = php_phongo_fetch_ssl_opt_string(zoptions, ZEND_STRL("pem_file"));
} else if (php_array_existsc(zoptions, "local_cert")) {
ssl_opt->pem_file = php_phongo_fetch_ssl_opt_string(zoptions, ZEND_STRL("local_cert"));
}
if (php_array_existsc(zoptions, "pem_pwd")) {
ssl_opt->pem_pwd = php_phongo_fetch_ssl_opt_string(zoptions, ZEND_STRL("pem_pwd"));
} else if (php_array_existsc(zoptions, "passphrase")) {
ssl_opt->pem_pwd = php_phongo_fetch_ssl_opt_string(zoptions, ZEND_STRL("passphrase"));
}
if (php_array_existsc(zoptions, "ca_file")) {
ssl_opt->ca_file = php_phongo_fetch_ssl_opt_string(zoptions, ZEND_STRL("ca_file"));
} else if (php_array_existsc(zoptions, "cafile")) {
ssl_opt->ca_file = php_phongo_fetch_ssl_opt_string(zoptions, ZEND_STRL("cafile"));
}
if (php_array_existsc(zoptions, "ca_dir")) {
ssl_opt->ca_dir = php_phongo_fetch_ssl_opt_string(zoptions, ZEND_STRL("ca_dir"));
} else if (php_array_existsc(zoptions, "capath")) {
ssl_opt->ca_dir = php_phongo_fetch_ssl_opt_string(zoptions, ZEND_STRL("capath"));
}
if (php_array_existsc(zoptions, "crl_file")) {
ssl_opt->crl_file = php_phongo_fetch_ssl_opt_string(zoptions, ZEND_STRL("crl_file"));
}
return ssl_opt;
}
static void php_phongo_free_ssl_opt(mongoc_ssl_opt_t *ssl_opt)
{
if (ssl_opt->pem_file) {
str_efree(ssl_opt->pem_file);
}
if (ssl_opt->pem_pwd) {
str_efree(ssl_opt->pem_pwd);
}
if (ssl_opt->ca_file) {
str_efree(ssl_opt->ca_file);
}
if (ssl_opt->ca_dir) {
str_efree(ssl_opt->ca_dir);
}
if (ssl_opt->crl_file) {
str_efree(ssl_opt->crl_file);
}
efree(ssl_opt);
}
/* Creates a hash for a client by concatenating the URI string with serialized
* options arrays. On success, a persistent string is returned (i.e. pefree()
* should be used to free it) and hash_len will be set to the string's length.
* On error, an exception will have been thrown and NULL will be returned. */
static char *php_phongo_manager_make_client_hash(const char *uri_string, zval *options, zval *driverOptions, size_t *hash_len TSRMLS_DC)
{
char *hash = NULL;
smart_str var_buf = {0};
php_serialize_data_t var_hash;
#if PHP_VERSION_ID >= 70000
zval args;
array_init_size(&args, 3);
ADD_ASSOC_STRING(&args, "uri", uri_string);
if (options) {
ADD_ASSOC_ZVAL_EX(&args, "options", options);
Z_ADDREF_P(options);
} else {
ADD_ASSOC_NULL_EX(&args, "options");
}
if (driverOptions) {
ADD_ASSOC_ZVAL_EX(&args, "driverOptions", driverOptions);
Z_ADDREF_P(driverOptions);
} else {
ADD_ASSOC_NULL_EX(&args, "driverOptions");
}
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&var_buf, &args, &var_hash);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
if (!EG(exception)) {
*hash_len = ZSTR_LEN(var_buf.s);
hash = pestrndup(ZSTR_VAL(var_buf.s), *hash_len, 1);
}
zval_ptr_dtor(&args);
#else
zval *args;
MAKE_STD_ZVAL(args);
array_init_size(args, 3);
ADD_ASSOC_STRING(args, "uri", uri_string);
if (options) {
ADD_ASSOC_ZVAL_EX(args, "options", options);
Z_ADDREF_P(options);
} else {
ADD_ASSOC_NULL_EX(args, "options");
}
if (driverOptions) {
ADD_ASSOC_ZVAL_EX(args, "driverOptions", driverOptions);
Z_ADDREF_P(driverOptions);
} else {
ADD_ASSOC_NULL_EX(args, "driverOptions");
}
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&var_buf, &args, &var_hash TSRMLS_CC);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
if (!EG(exception)) {
*hash_len = var_buf.len;
hash = pestrndup(var_buf.c, *hash_len, 1);
}
zval_ptr_dtor(&args);
#endif
smart_str_free(&var_buf);
return hash;
}
static mongoc_client_t *php_phongo_make_mongo_client(const mongoc_uri_t *uri, mongoc_ssl_opt_t *ssl_opt TSRMLS_DC) /* {{{ */
{
const char *mongoc_version, *bson_version;
mongoc_client_t *client;
#ifdef HAVE_SYSTEM_LIBMONGOC
mongoc_version = mongoc_get_version();
#else
mongoc_version = "bundled";
#endif
#ifdef HAVE_SYSTEM_LIBBSON
bson_version = bson_get_version();
#else
bson_version = "bundled";
#endif
MONGOC_DEBUG("Creating Manager, phongo-%s[%s] - mongoc-%s(%s), libbson-%s(%s), php-%s",
MONGODB_VERSION_S,
MONGODB_STABILITY_S,
MONGOC_VERSION_S,
mongoc_version,
BSON_VERSION_S,
bson_version,
PHP_VERSION
);
client = mongoc_client_new_from_uri(uri);
if (!client) {
return NULL;
}
if (mongoc_uri_get_ssl(uri) && ssl_opt) {
mongoc_client_set_ssl_opts(client, ssl_opt);
}
return client;
} /* }}} */
void phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string, zval *options, zval *driverOptions TSRMLS_DC) /* {{{ */
{
char *hash = NULL;
size_t hash_len = 0;
bson_t bson_options = BSON_INITIALIZER;
mongoc_uri_t *uri = NULL;
mongoc_ssl_opt_t *ssl_opt = NULL;
bson_iter_t iter;
#if PHP_VERSION_ID >= 70000
- zval *client_ptr;
- zval new_client_ptr;
+ mongoc_client_t *client_ptr;
#else
mongoc_client_t **client_ptr;
#endif
if (!(hash = php_phongo_manager_make_client_hash(uri_string, options, driverOptions, &hash_len TSRMLS_CC))) {
/* Exception should already have been thrown and there is nothing to free */
return;
}
#if PHP_VERSION_ID >= 70000
- if ((client_ptr = zend_hash_str_find(&MONGODB_G(clients), hash, hash_len)) && Z_TYPE_P(client_ptr) == IS_PTR) {
+ if ((client_ptr = zend_hash_str_find_ptr(&MONGODB_G(clients), hash, hash_len)) != NULL) {
MONGOC_DEBUG("Found client for hash: %s\n", hash);
- manager->client = (mongoc_client_t *)Z_PTR_P(client_ptr);
+ manager->client = client_ptr;
goto cleanup;
}
#else
if (zend_hash_find(&MONGODB_G(clients), hash, hash_len + 1, (void**) &client_ptr) == SUCCESS) {
MONGOC_DEBUG("Found client for hash: %s\n", hash);
manager->client = *client_ptr;
goto cleanup;
}
#endif
if (options) {
phongo_zval_to_bson(options, PHONGO_BSON_NONE, &bson_options, NULL TSRMLS_CC);
}
/* An exception may be thrown during BSON conversion */
if (EG(exception)) {
goto cleanup;
}
if (!(uri = php_phongo_make_uri(uri_string, &bson_options))) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Failed to parse MongoDB URI: '%s'", uri_string);
goto cleanup;
}
if (!php_phongo_apply_rc_options_to_uri(uri, &bson_options TSRMLS_CC) ||
!php_phongo_apply_rp_options_to_uri(uri, &bson_options TSRMLS_CC) ||
!php_phongo_apply_wc_options_to_uri(uri, &bson_options TSRMLS_CC)) {
/* Exception should already have been thrown */
goto cleanup;
}
if (bson_iter_init_find_case(&iter, &bson_options, "appname") && BSON_ITER_HOLDS_UTF8(&iter)) {
const char *str = bson_iter_utf8(&iter, NULL);
if (!mongoc_uri_set_appname(uri, str)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Invalid appname value: '%s'", str);
goto cleanup;
}
}
ssl_opt = php_phongo_make_ssl_opt(driverOptions TSRMLS_CC);
/* An exception may be thrown during SSL option creation */
if (EG(exception)) {
goto cleanup;
}
manager->client = php_phongo_make_mongo_client(uri, ssl_opt TSRMLS_CC);
if (!manager->client) {
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to create Manager from URI: '%s'", uri_string);
goto cleanup;
}
MONGOC_DEBUG("Created client hash: %s\n", hash);
#if PHP_VERSION_ID >= 70000
- ZVAL_PTR(&new_client_ptr, manager->client);
- zend_hash_str_update(&MONGODB_G(clients), hash, hash_len, &new_client_ptr);
+ zend_hash_str_update_ptr(&MONGODB_G(clients), hash, hash_len, manager->client);
#else
zend_hash_update(&MONGODB_G(clients), hash, hash_len + 1, &manager->client, sizeof(mongoc_client_t *), NULL);
#endif
cleanup:
if (hash) {
pefree(hash, 1);
}
bson_destroy(&bson_options);
if (uri) {
mongoc_uri_destroy(uri);
}
if (ssl_opt) {
php_phongo_free_ssl_opt(ssl_opt);
}
} /* }}} */
void php_phongo_new_utcdatetime_from_epoch(zval *object, int64_t msec_since_epoch TSRMLS_DC) /* {{{ */
{
php_phongo_utcdatetime_t *intern;
object_init_ex(object, php_phongo_utcdatetime_ce);
intern = Z_UTCDATETIME_OBJ_P(object);
intern->milliseconds = msec_since_epoch;
intern->initialized = true;
} /* }}} */
void php_phongo_new_timestamp_from_increment_and_timestamp(zval *object, uint32_t increment, uint32_t timestamp TSRMLS_DC) /* {{{ */
{
php_phongo_timestamp_t *intern;
object_init_ex(object, php_phongo_timestamp_ce);
intern = Z_TIMESTAMP_OBJ_P(object);
intern->increment = increment;
intern->timestamp = timestamp;
intern->initialized = true;
} /* }}} */
void php_phongo_new_javascript_from_javascript(int init, zval *object, const char *code, size_t code_len TSRMLS_DC) /* {{{ */
{
php_phongo_new_javascript_from_javascript_and_scope(init, object, code, code_len, NULL TSRMLS_CC);
} /* }}} */
void php_phongo_new_javascript_from_javascript_and_scope(int init, zval *object, const char *code, size_t code_len, const bson_t *scope TSRMLS_DC) /* {{{ */
{
php_phongo_javascript_t *intern;
if (init) {
object_init_ex(object, php_phongo_javascript_ce);
}
intern = Z_JAVASCRIPT_OBJ_P(object);
intern->code = estrndup(code, code_len);
intern->code_len = code_len;
intern->scope = scope ? bson_copy(scope) : NULL;
} /* }}} */
void php_phongo_new_binary_from_binary_and_type(zval *object, const char *data, size_t data_len, bson_subtype_t type TSRMLS_DC) /* {{{ */
{
php_phongo_binary_t *intern;
object_init_ex(object, php_phongo_binary_ce);
intern = Z_BINARY_OBJ_P(object);
intern->data = estrndup(data, data_len);
intern->data_len = data_len;
intern->type = (uint8_t) type;
} /* }}} */
void php_phongo_new_decimal128(zval *object, const bson_decimal128_t *decimal TSRMLS_DC) /* {{{ */
{
php_phongo_decimal128_t *intern;
object_init_ex(object, php_phongo_decimal128_ce);
intern = Z_DECIMAL128_OBJ_P(object);
memcpy(&intern->decimal, decimal, sizeof(bson_decimal128_t));
intern->initialized = true;
} /* }}} */
+/* qsort() compare callback for alphabetizing regex flags upon initialization */
+static int php_phongo_regex_compare_flags(const void *f1, const void *f2) {
+ if (* (const char *) f1 == * (const char *) f2) {
+ return 0;
+ }
+
+ return (* (const char *) f1 > * (const char *) f2) ? 1 : -1;
+}
+
void php_phongo_new_regex_from_regex_and_options(zval *object, const char *pattern, const char *flags TSRMLS_DC) /* {{{ */
{
php_phongo_regex_t *intern;
object_init_ex(object, php_phongo_regex_ce);
intern = Z_REGEX_OBJ_P(object);
intern->pattern_len = strlen(pattern);
intern->pattern = estrndup(pattern, intern->pattern_len);
intern->flags_len = strlen(flags);
intern->flags = estrndup(flags, intern->flags_len);
-} /* }}} */
-
-static void php_phongo_cursor_free_current(php_phongo_cursor_t *cursor) /* {{{ */
-{
- if (!Z_ISUNDEF(cursor->visitor_data.zchild)) {
- zval_ptr_dtor(&cursor->visitor_data.zchild);
-#if PHP_VERSION_ID >= 70000
- ZVAL_UNDEF(&cursor->visitor_data.zchild);
-#else
- cursor->visitor_data.zchild = NULL;
-#endif
- }
-} /* }}} */
-
-void php_phongo_cursor_free(php_phongo_cursor_t *cursor) /* {{{ */
-{
- if (cursor->cursor) {
- mongoc_cursor_destroy(cursor->cursor);
- cursor->cursor = NULL;
- }
-
- php_phongo_cursor_free_current(cursor);
-} /* }}} */
-
-/* {{{ Iterator */
-static void php_phongo_cursor_iterator_dtor(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
-{
- php_phongo_cursor_iterator *cursor_it = (php_phongo_cursor_iterator *)iter;
-
- if (!Z_ISUNDEF(cursor_it->intern.data)) {
-#if PHP_VERSION_ID >= 70000
- zval_ptr_dtor(&cursor_it->intern.data);
-#else
- zval_ptr_dtor((zval**)&cursor_it->intern.data);
- cursor_it->intern.data = NULL;
-#endif
- }
-
-#if PHP_VERSION_ID < 70000
- efree(cursor_it);
-#endif
-} /* }}} */
-
-static int php_phongo_cursor_iterator_valid(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
-{
- php_phongo_cursor_t *cursor = ((php_phongo_cursor_iterator *)iter)->cursor;
-
- if (!Z_ISUNDEF(cursor->visitor_data.zchild)) {
- return SUCCESS;
- }
-
- return FAILURE;
-} /* }}} */
-
-#if PHP_VERSION_ID < 50500
-static int php_phongo_cursor_iterator_get_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC) /* {{{ */
-{
- php_phongo_cursor_t *cursor = ((php_phongo_cursor_iterator *)iter)->cursor;
-
- *int_key = (ulong) cursor->current;
- return HASH_KEY_IS_LONG;
-} /* }}} */
-#else
-static void php_phongo_cursor_iterator_get_current_key(zend_object_iterator *iter, zval *key TSRMLS_DC) /* {{{ */
-{
- php_phongo_cursor_t *cursor = ((php_phongo_cursor_iterator *)iter)->cursor;
-
- ZVAL_LONG(key, cursor->current);
-} /* }}} */
-#endif
-
-#if PHP_VERSION_ID < 70000
-static void php_phongo_cursor_iterator_get_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC) /* {{{ */
-{
- php_phongo_cursor_t *cursor = ((php_phongo_cursor_iterator *)iter)->cursor;
-
- *data = &cursor->visitor_data.zchild;
-} /* }}} */
-#else
-static zval* php_phongo_cursor_iterator_get_current_data(zend_object_iterator *iter) /* {{{ */
-{
- php_phongo_cursor_t *cursor = ((php_phongo_cursor_iterator *)iter)->cursor;
-
- return &cursor->visitor_data.zchild;
-} /* }}} */
-#endif
-
-static void php_phongo_cursor_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
-{
- php_phongo_cursor_iterator *cursor_it = (php_phongo_cursor_iterator *)iter;
- php_phongo_cursor_t *cursor = cursor_it->cursor;
- const bson_t *doc;
-
- php_phongo_cursor_free_current(cursor);
- cursor->current++;
-
- if (mongoc_cursor_next(cursor->cursor, &doc)) {
- phongo_bson_to_zval_ex(bson_get_data(doc), doc->len, &cursor->visitor_data);
- } else {
- bson_error_t error;
-
- if (mongoc_cursor_error(cursor->cursor, &error)) {
- /* Intentionally not destroying the cursor as it will happen
- * naturally now that there are no more results */
- phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
- }
- }
-} /* }}} */
-
-static void php_phongo_cursor_iterator_rewind(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
-{
- php_phongo_cursor_iterator *cursor_it = (php_phongo_cursor_iterator *)iter;
- php_phongo_cursor_t *cursor = cursor_it->cursor;
- const bson_t *doc;
-
- if (cursor->current > 0) {
- phongo_throw_exception(PHONGO_ERROR_LOGIC TSRMLS_CC, "Cursors cannot rewind after starting iteration");
- return;
- }
-
- php_phongo_cursor_free_current(cursor);
-
- doc = mongoc_cursor_current(cursor->cursor);
- if (doc) {
- phongo_bson_to_zval_ex(bson_get_data(doc), doc->len, &cursor->visitor_data);
- }
+ /* Ensure flags are alphabetized upon initialization. This may be removed
+ * once CDRIVER-1883 is implemented. */
+ qsort((void *) intern->flags, intern->flags_len, 1, php_phongo_regex_compare_flags);
} /* }}} */
-/* iterator handler table */
-zend_object_iterator_funcs php_phongo_cursor_iterator_funcs = {
- php_phongo_cursor_iterator_dtor,
- php_phongo_cursor_iterator_valid,
- php_phongo_cursor_iterator_get_current_data,
- php_phongo_cursor_iterator_get_current_key,
- php_phongo_cursor_iterator_move_forward,
- php_phongo_cursor_iterator_rewind,
- NULL /* invalidate_current is not used */
-};
-
-zend_object_iterator *php_phongo_cursor_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) /* {{{ */
-{
- php_phongo_cursor_iterator *cursor_it = NULL;
- php_phongo_cursor_t *cursor = Z_CURSOR_OBJ_P(object);
-
- if (by_ref) {
- zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
- }
-
- if (cursor->got_iterator) {
- phongo_throw_exception(PHONGO_ERROR_LOGIC TSRMLS_CC, "Cursors cannot yield multiple iterators");
- return NULL;
- }
-
- cursor->got_iterator = 1;
-
- cursor_it = ecalloc(1, sizeof(php_phongo_cursor_iterator));
-#if PHP_VERSION_ID >= 70000
- zend_iterator_init(&cursor_it->intern);
-#endif
-
-#if PHP_VERSION_ID >= 70000
- ZVAL_COPY(&cursor_it->intern.data, object);
-#else
- Z_ADDREF_P(object);
- cursor_it->intern.data = (void*)object;
-#endif
- cursor_it->intern.funcs = &php_phongo_cursor_iterator_funcs;
- cursor_it->cursor = cursor;
- /* cursor_it->current should already be allocated to zero */
-
- php_phongo_cursor_free_current(cursor_it->cursor);
-
- return &cursor_it->intern;
-} /* }}} */
-/* }}} */
-
-
/* {{{ Memory allocation wrappers */
static void* php_phongo_malloc(size_t num_bytes) /* {{{ */
{
return pemalloc(num_bytes, 1);
} /* }}} */
static void* php_phongo_calloc(size_t num_members, size_t num_bytes) /* {{{ */
{
return pecalloc(num_members, num_bytes, 1);
} /* }}} */
static void* php_phongo_realloc(void *mem, size_t num_bytes) { /* {{{ */
return perealloc(mem, num_bytes, 1);
} /* }}} */
static void php_phongo_free(void *mem) /* {{{ */
{
if (mem) {
pefree(mem, 1);
}
} /* }}} */
/* }}} */
#ifdef PHP_DEBUG
/* LCOV_EXCL_START */
void _phongo_debug_bson(bson_t *bson)
{
char *str;
size_t str_len;
str = bson_as_json(bson, &str_len);
php_printf("JSON: %s\n", str);
bson_free(str);
}
/* LCOV_EXCL_STOP */
#endif
/* {{{ M[INIT|SHUTDOWN] R[INIT|SHUTDOWN] G[INIT|SHUTDOWN] MINFO INI */
ZEND_INI_MH(OnUpdateDebug)
{
void ***ctx = NULL;
char *tmp_dir = NULL;
TSRMLS_SET_CTX(ctx);
/* Close any previously open log files */
if (MONGODB_G(debug_fd)) {
if (MONGODB_G(debug_fd) != stderr && MONGODB_G(debug_fd) != stdout) {
fclose(MONGODB_G(debug_fd));
}
MONGODB_G(debug_fd) = NULL;
}
if (!new_value || (new_value && !ZSTR_VAL(new_value)[0])
|| strcasecmp("0", ZSTR_VAL(new_value)) == 0
|| strcasecmp("off", ZSTR_VAL(new_value)) == 0
|| strcasecmp("no", ZSTR_VAL(new_value)) == 0
|| strcasecmp("false", ZSTR_VAL(new_value)) == 0
) {
mongoc_log_trace_disable();
mongoc_log_set_handler(NULL, NULL);
#if PHP_VERSION_ID >= 70000
return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
#else
return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
#endif
}
if (strcasecmp(ZSTR_VAL(new_value), "stderr") == 0) {
MONGODB_G(debug_fd) = stderr;
} else if (strcasecmp(ZSTR_VAL(new_value), "stdout") == 0) {
MONGODB_G(debug_fd) = stdout;
} else if (
strcasecmp("1", ZSTR_VAL(new_value)) == 0
|| strcasecmp("on", ZSTR_VAL(new_value)) == 0
|| strcasecmp("yes", ZSTR_VAL(new_value)) == 0
|| strcasecmp("true", ZSTR_VAL(new_value)) == 0
) {
tmp_dir = NULL;
} else {
tmp_dir = ZSTR_VAL(new_value);
}
if (!MONGODB_G(debug_fd)) {
time_t t;
int fd = -1;
char *prefix;
int len;
phongo_char *filename;
time(&t);
len = spprintf(&prefix, 0, "PHONGO-%ld", t);
fd = php_open_temporary_fd(tmp_dir, prefix, &filename TSRMLS_CC);
if (fd != -1) {
const char *path = ZSTR_VAL(filename);
MONGODB_G(debug_fd) = VCWD_FOPEN(path, "a");
}
efree(filename);
efree(prefix);
close(fd);
}
mongoc_log_trace_enable();
mongoc_log_set_handler(php_phongo_log, ctx);
#if PHP_VERSION_ID >= 70000
return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
#else
return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
#endif
}
/* {{{ INI entries */
PHP_INI_BEGIN()
#if PHP_VERSION_ID >= 70000
STD_PHP_INI_ENTRY(PHONGO_DEBUG_INI, PHONGO_DEBUG_INI_DEFAULT, PHP_INI_ALL, OnUpdateDebug, debug, zend_mongodb_globals, mongodb_globals)
#else
{ 0, PHP_INI_ALL, (char *)PHONGO_DEBUG_INI, sizeof(PHONGO_DEBUG_INI), OnUpdateDebug, (void *) XtOffsetOf(zend_mongodb_globals, debug), (void *) &mglo, NULL, (char *)PHONGO_DEBUG_INI_DEFAULT, sizeof(PHONGO_DEBUG_INI_DEFAULT)-1, NULL, 0, 0, 0, NULL },
#endif
PHP_INI_END()
/* }}} */
+#if PHP_VERSION_ID >= 70000
+static void php_phongo_client_dtor(zval *zv)
+{
+ mongoc_client_destroy((mongoc_client_t *) Z_PTR_P(zv));
+}
+#else
+static void php_phongo_client_dtor(void *client)
+{
+ mongoc_client_destroy(*((mongoc_client_t **) client));
+}
+#endif
+
/* {{{ PHP_GINIT_FUNCTION */
PHP_GINIT_FUNCTION(mongodb)
{
bson_mem_vtable_t bsonMemVTable = {
php_phongo_malloc,
php_phongo_calloc,
php_phongo_realloc,
php_phongo_free,
};
#if PHP_VERSION_ID >= 70000
#if defined(COMPILE_DL_MONGODB) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
#endif
- mongodb_globals->debug_fd = NULL;
+ memset(mongodb_globals, 0, sizeof(zend_mongodb_globals));
mongodb_globals->bsonMemVTable = bsonMemVTable;
-
+ /* Initialize HashTable for persistent clients */
+ zend_hash_init_ex(&mongodb_globals->clients, 0, NULL, php_phongo_client_dtor, 1, 0);
}
/* }}} */
-#if PHP_VERSION_ID >= 70000
-static void php_phongo_client_dtor(zval *zv)
+static zend_class_entry *php_phongo_fetch_internal_class(const char *class_name, size_t class_name_len TSRMLS_DC)
{
- mongoc_client_destroy((mongoc_client_t *) Z_PTR_P(zv));
-}
+#if PHP_VERSION_ID >= 70000
+ zend_class_entry *pce;
+
+ if ((pce = zend_hash_str_find_ptr(CG(class_table), class_name, class_name_len))) {
+ return pce;
+ }
#else
-static void php_phongo_client_dtor(void *client)
-{
- mongoc_client_destroy(*((mongoc_client_t **) client));
-}
+ zend_class_entry **pce;
+
+ if (zend_hash_find(CG(class_table), class_name, class_name_len + 1, (void **) &pce) == SUCCESS) {
+ return *pce;
+ }
#endif
+ return NULL;
+}
+
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(mongodb)
{
char *php_version_string;
(void)type; /* We don't care if we are loaded via dl() or extension= */
REGISTER_INI_ENTRIES();
/* Initialize libmongoc */
mongoc_init();
/* Set handshake options */
php_version_string = malloc(4 + sizeof(PHP_VERSION) + 1);
snprintf(php_version_string, 4 + sizeof(PHP_VERSION) + 1, "PHP %s", PHP_VERSION);
mongoc_handshake_data_append("ext-mongodb:PHP", MONGODB_VERSION_S, php_version_string);
free(php_version_string);
/* Initialize libbson */
bson_mem_set_vtable(&MONGODB_G(bsonMemVTable));
- /* Initialize HashTable for persistent clients */
- zend_hash_init(&MONGODB_G(clients), 0, NULL, php_phongo_client_dtor, 1);
-
/* Prep default object handlers to be used when we register the classes */
memcpy(&phongo_std_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
phongo_std_object_handlers.clone_obj = NULL;
/*
phongo_std_object_handlers.get_debug_info = NULL;
phongo_std_object_handlers.compare_objects = NULL;
phongo_std_object_handlers.cast_object = NULL;
phongo_std_object_handlers.count_elements = NULL;
phongo_std_object_handlers.get_closure = NULL;
*/
+ /* Initialize zend_class_entry dependencies.
+ *
+ * Although DateTimeImmutable was introduced in PHP 5.5.0,
+ * php_date_get_immutable_ce() is not available in PHP versions before
+ * 5.5.24 and 5.6.8.
+ *
+ * Although JsonSerializable was introduced in PHP 5.4.0,
+ * php_json_serializable_ce is not exported in PHP versions before 5.4.26
+ * and 5.5.10. For later PHP versions, looking up the class manually also
+ * helps with distros that disable LTDL_LAZY for dlopen() (e.g. Fedora).
+ */
+ php_phongo_date_immutable_ce = php_phongo_fetch_internal_class(ZEND_STRL("datetimeimmutable") TSRMLS_CC);
+ php_phongo_json_serializable_ce = php_phongo_fetch_internal_class(ZEND_STRL("jsonserializable") TSRMLS_CC);
+
+ if (php_phongo_json_serializable_ce == NULL) {
+ zend_error(E_ERROR, "JsonSerializable class is not defined. Please ensure that the 'json' module is loaded before the 'mongodb' module.");
+ return FAILURE;
+ }
+
PHP_MINIT(bson)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Type)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Serializable)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Unserializable)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Persistable)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Binary)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Decimal128)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Javascript)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(MaxKey)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(MinKey)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(ObjectID)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Regex)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Timestamp)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(UTCDateTime)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Command)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Cursor)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(CursorId)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Manager)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Query)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(ReadConcern)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(ReadPreference)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Server)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(BulkWrite)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(WriteConcern)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(WriteConcernError)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(WriteError)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(WriteResult)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(Exception)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(LogicException)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(RuntimeException)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(UnexpectedValueException)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(InvalidArgumentException)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(ConnectionException)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(AuthenticationException)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(SSLConnectionException)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(WriteException)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(BulkWriteException)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(ExecutionTimeoutException)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(ConnectionTimeoutException)(INIT_FUNC_ARGS_PASSTHRU);
REGISTER_STRING_CONSTANT("MONGODB_VERSION", (char *)MONGODB_VERSION_S, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("MONGODB_STABILITY", (char *)MONGODB_STABILITY_S, CONST_CS | CONST_PERSISTENT);
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION */
PHP_MSHUTDOWN_FUNCTION(mongodb)
{
(void)type; /* We don't care if we are loaded via dl() or extension= */
/* Destroy HashTable for persistent clients. The HashTable destructor will
* destroy any mongoc_client_t objects contained within. */
zend_hash_destroy(&MONGODB_G(clients));
bson_mem_restore_vtable();
/* Cleanup after libmongoc */
mongoc_cleanup();
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
/* }}} */
/* {{{ PHP_GSHUTDOWN_FUNCTION */
PHP_GSHUTDOWN_FUNCTION(mongodb)
{
mongodb_globals->debug = NULL;
if (mongodb_globals->debug_fd) {
fclose(mongodb_globals->debug_fd);
mongodb_globals->debug_fd = NULL;
}
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION */
PHP_MINFO_FUNCTION(mongodb)
{
php_info_print_table_start();
- php_info_print_table_header(2, "mongodb support", "enabled");
- php_info_print_table_row(2, "mongodb version", MONGODB_VERSION_S);
- php_info_print_table_row(2, "mongodb stability", MONGODB_STABILITY_S);
+ php_info_print_table_header(2, "MongoDB support", "enabled");
+ php_info_print_table_row(2, "MongoDB extension version", MONGODB_VERSION_S);
+ php_info_print_table_row(2, "MongoDB extension stability", MONGODB_STABILITY_S);
+
+#ifdef HAVE_SYSTEM_LIBBSON
+ php_info_print_table_row(2, "libbson headers version", BSON_VERSION_S);
+ php_info_print_table_row(2, "libbson library version", bson_get_version());
+#else
+ php_info_print_table_row(2, "libbson bundled version", BSON_VERSION_S);
+#endif
+
#ifdef HAVE_SYSTEM_LIBMONGOC
php_info_print_table_row(2, "libmongoc headers version", MONGOC_VERSION_S);
php_info_print_table_row(2, "libmongoc library version", mongoc_get_version());
#else
/* Bundled libraries, buildtime = runtime */
- php_info_print_table_row(2, "libmongoc version", MONGOC_VERSION_S);
+ php_info_print_table_row(2, "libmongoc bundled version", MONGOC_VERSION_S);
#endif
-#ifdef HAVE_SYSTEM_LIBBSON
- php_info_print_table_row(2, "libbson headers version", BSON_VERSION_S);
- php_info_print_table_row(2, "libbson library version", bson_get_version());
+
+#ifdef MONGOC_ENABLE_SSL
+ php_info_print_table_row(2, "libmongoc SSL", "enabled");
+# if defined(MONGOC_ENABLE_SSL_OPENSSL)
+ php_info_print_table_row(2, "libmongoc SSL library", "OpenSSL");
+# elif defined(MONGOC_ENABLE_SSL_LIBRESSL)
+ php_info_print_table_row(2, "libmongoc SSL library", "LibreSSL");
+# elif defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT)
+ php_info_print_table_row(2, "libmongoc SSL library", "Secure Transport");
+# elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL)
+ php_info_print_table_row(2, "libmongoc SSL library", "Secure Channel");
+# else
+ php_info_print_table_row(2, "libmongoc SSL library", "unknown");
+# endif
+#else
+ php_info_print_table_row(2, "libmongoc SSL", "disabled");
+#endif
+
+#ifdef MONGOC_ENABLE_CRYPTO
+ php_info_print_table_row(2, "libmongoc crypto", "enabled");
+# if defined(MONGOC_ENABLE_CRYPTO_LIBCRYPTO)
+ php_info_print_table_row(2, "libmongoc crypto library", "libcrypto");
+# elif defined(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO)
+ php_info_print_table_row(2, "libmongoc crypto library", "Common Crypto");
+# elif defined(MONGOC_ENABLE_CRYPTO_CNG)
+ php_info_print_table_row(2, "libmongoc crypto library", "CNG");
+# else
+ php_info_print_table_row(2, "libmongoc crypto library", "unknown");
+# endif
+# ifdef MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE
+ php_info_print_table_row(2, "libmongoc crypto system profile", "enabled");
+# else
+ php_info_print_table_row(2, "libmongoc crypto system profile", "disabled");
+# endif
#else
- php_info_print_table_row(2, "libbson version", BSON_VERSION_S);
+ php_info_print_table_row(2, "libmongoc crypto", "disabled");
#endif
+
+#ifdef MONGOC_ENABLE_SASL
+ php_info_print_table_row(2, "libmongoc SASL", "enabled");
+#else
+ php_info_print_table_row(2, "libmongoc SASL", "disabled");
+#endif
+
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
}
/* }}} */
/* }}} */
/* {{{ mongodb_functions[]
*/
ZEND_BEGIN_ARG_INFO_EX(ai_bson_fromPHP, 0, 0, 1)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_bson_toPHP, 0, 0, 1)
ZEND_ARG_INFO(0, bson)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_bson_toJSON, 0, 0, 1)
ZEND_ARG_INFO(0, bson)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_bson_fromJSON, 0, 0, 1)
ZEND_ARG_INFO(0, json)
ZEND_END_ARG_INFO();
const zend_function_entry mongodb_functions[] = {
ZEND_NS_FE("MongoDB\\BSON", fromPHP, ai_bson_fromPHP)
ZEND_NS_FE("MongoDB\\BSON", toPHP, ai_bson_toPHP)
ZEND_NS_FE("MongoDB\\BSON", toJSON, ai_bson_toJSON)
ZEND_NS_FE("MongoDB\\BSON", fromJSON, ai_bson_fromJSON)
PHP_FE_END
};
/* }}} */
static const zend_module_dep mongodb_deps[] = {
ZEND_MOD_REQUIRED("date")
ZEND_MOD_REQUIRED("json")
ZEND_MOD_REQUIRED("spl")
ZEND_MOD_REQUIRED("standard")
ZEND_MOD_END
};
/* {{{ mongodb_module_entry
*/
zend_module_entry mongodb_module_entry = {
STANDARD_MODULE_HEADER_EX,
NULL,
mongodb_deps,
"mongodb",
mongodb_functions,
PHP_MINIT(mongodb),
PHP_MSHUTDOWN(mongodb),
NULL /* PHP_RINIT(mongodb)*/,
NULL /* PHP_RSHUTDOWN(mongodb)*/,
PHP_MINFO(mongodb),
MONGODB_VERSION,
PHP_MODULE_GLOBALS(mongodb),
PHP_GINIT(mongodb),
PHP_GSHUTDOWN(mongodb),
NULL,
STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */
#ifdef COMPILE_DL_MONGODB
ZEND_GET_MODULE(mongodb)
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/php_phongo.h b/mongodb-1.2.3/php_phongo.h
similarity index 80%
rename from mongodb-1.2.0/php_phongo.h
rename to mongodb-1.2.3/php_phongo.h
index ad34c785..63d17672 100644
--- a/mongodb-1.2.0/php_phongo.h
+++ b/mongodb-1.2.3/php_phongo.h
@@ -1,190 +1,188 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 2014-2015 Hannes Magnusson |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Hannes Magnusson <bjori@php.net> |
- +----------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef PHONGO_H
#define PHONGO_H
/* External libs */
#include "bson.h"
#include "mongoc.h"
#define phpext_mongodb_ptr &mongodb_module_entry
extern zend_module_entry mongodb_module_entry;
/* FIXME: Its annoying to bump version. Move into phongo_version.h.in */
-#define MONGODB_VERSION_S "1.2.0"
+#define MONGODB_VERSION_S "1.2.3"
#define MONGODB_STABILITY_S "stable"
#define MONGODB_VERSION MONGODB_VERSION_S
#ifdef PHP_WIN32
# define PHONGO_API __declspec(dllexport)
# include "ext/standard/flock_compat.h"
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHONGO_API __attribute__ ((visibility("default")))
#else
# define PHONGO_API
#endif
ZEND_BEGIN_MODULE_GLOBALS(mongodb)
char *debug;
FILE *debug_fd;
bson_mem_vtable_t bsonMemVTable;
HashTable clients;
ZEND_END_MODULE_GLOBALS(mongodb)
#if PHP_VERSION_ID >= 70000
-# define MONGODB_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(mongodb, v)
+# define MONGODB_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(mongodb, v)
+# if defined(ZTS) && defined(COMPILE_DL_MONGODB)
+ZEND_TSRMLS_CACHE_EXTERN()
+# endif
#else
-# ifdef ZTS
-# define MONGODB_G(v) TSRMG(mongodb_globals_id, zend_mongodb_globals *, v)
-# define mglo mongodb_globals_id
-# else
-# define MONGODB_G(v) (mongodb_globals.v)
-# define mglo mongodb_globals
-# endif
+# ifdef ZTS
+# define MONGODB_G(v) TSRMG(mongodb_globals_id, zend_mongodb_globals *, v)
+# define mglo mongodb_globals_id
+# else
+# define MONGODB_G(v) (mongodb_globals.v)
+# define mglo mongodb_globals
+# endif
#endif
#define PHONGO_WRITE_CONCERN_W_MAJORITY "majority"
#include "php_phongo_classes.h"
/* This enum is necessary since mongoc_server_description_type_t is private and
* we need to translate strings returned by mongoc_server_description_type() to
* Server integer constants. */
typedef enum {
PHONGO_SERVER_UNKNOWN = 0,
PHONGO_SERVER_STANDALONE = 1,
PHONGO_SERVER_MONGOS = 2,
PHONGO_SERVER_POSSIBLE_PRIMARY = 3,
PHONGO_SERVER_RS_PRIMARY = 4,
PHONGO_SERVER_RS_SECONDARY = 5,
PHONGO_SERVER_RS_ARBITER = 6,
PHONGO_SERVER_RS_OTHER = 7,
PHONGO_SERVER_RS_GHOST = 8,
PHONGO_SERVER_DESCRIPTION_TYPES = 9,
} php_phongo_server_description_type_t;
typedef struct {
php_phongo_server_description_type_t type;
const char *name;
} php_phongo_server_description_type_map_t;
extern php_phongo_server_description_type_map_t php_phongo_server_description_type_map[];
typedef enum {
PHONGO_ERROR_INVALID_ARGUMENT = 1,
PHONGO_ERROR_RUNTIME = 2,
PHONGO_ERROR_UNEXPECTED_VALUE = 8,
PHONGO_ERROR_MONGOC_FAILED = 3,
PHONGO_ERROR_WRITE_FAILED = 5,
PHONGO_ERROR_CONNECTION_FAILED = 7,
PHONGO_ERROR_LOGIC = 9
} php_phongo_error_domain_t;
zend_class_entry* phongo_exception_from_mongoc_domain(uint32_t /* mongoc_error_domain_t */ domain, uint32_t /* mongoc_error_code_t */ code);
zend_class_entry* phongo_exception_from_phongo_domain(php_phongo_error_domain_t domain);
void phongo_throw_exception(php_phongo_error_domain_t domain TSRMLS_DC, const char *format, ...)
#if PHP_VERSION_ID < 70000
# ifndef PHP_WIN32
# ifdef ZTS
__attribute__ ((format(printf, 3, 4)))
# else
__attribute__ ((format(printf, 2, 3)))
# endif
# endif
#endif
;
void phongo_throw_exception_from_bson_error_t(bson_error_t *error TSRMLS_DC);
zend_object_handlers *phongo_get_std_object_handlers(void);
void phongo_server_init (zval *return_value, zval *manager, int server_id TSRMLS_DC);
void phongo_readconcern_init (zval *return_value, const mongoc_read_concern_t *read_concern TSRMLS_DC);
void phongo_readpreference_init (zval *return_value, const mongoc_read_prefs_t *read_prefs TSRMLS_DC);
void phongo_writeconcern_init (zval *return_value, const mongoc_write_concern_t *write_concern TSRMLS_DC);
mongoc_bulk_operation_t* phongo_bulkwrite_init (zend_bool ordered);
bool phongo_execute_write (zval *manager, const char *namespace, php_phongo_bulkwrite_t *bulk_write, const mongoc_write_concern_t *write_concern, int server_id, zval *return_value, int return_value_used TSRMLS_DC);
int phongo_execute_command (zval *manager, const char *db, zval *zcommand, zval *zreadPreference, int server_id, zval *return_value, int return_value_used TSRMLS_DC);
int phongo_execute_query (zval *manager, const char *namespace, zval *zquery, zval *zreadPreference, int server_id, zval *return_value, int return_value_used TSRMLS_DC);
const mongoc_read_concern_t* phongo_read_concern_from_zval (zval *zread_concern TSRMLS_DC);
const mongoc_read_prefs_t* phongo_read_preference_from_zval(zval *zread_preference TSRMLS_DC);
const mongoc_write_concern_t* phongo_write_concern_from_zval (zval *zwrite_concern TSRMLS_DC);
php_phongo_server_description_type_t php_phongo_server_description_type(mongoc_server_description_t *sd);
void php_phongo_read_preference_prep_tagsets(zval *tagSets TSRMLS_DC);
bool php_phongo_read_preference_tags_are_valid(const bson_t *tags);
void php_phongo_server_to_zval(zval *retval, mongoc_server_description_t *sd);
void php_phongo_read_concern_to_zval(zval *retval, const mongoc_read_concern_t *read_concern);
void php_phongo_read_preference_to_zval(zval *retval, const mongoc_read_prefs_t *read_prefs);
void php_phongo_write_concern_to_zval(zval *retval, const mongoc_write_concern_t *write_concern);
void php_phongo_cursor_to_zval(zval *retval, const mongoc_cursor_t *cursor);
void phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string, zval *options, zval *driverOptions TSRMLS_DC);
void php_phongo_objectid_new_from_oid(zval *object, const bson_oid_t *oid TSRMLS_DC);
void php_phongo_cursor_id_new_from_id(zval *object, int64_t cursorid TSRMLS_DC);
void php_phongo_new_utcdatetime_from_epoch(zval *object, int64_t msec_since_epoch TSRMLS_DC);
void php_phongo_new_timestamp_from_increment_and_timestamp(zval *object, uint32_t increment, uint32_t timestamp TSRMLS_DC);
void php_phongo_new_javascript_from_javascript(int init, zval *object, const char *code, size_t code_len TSRMLS_DC);
void php_phongo_new_javascript_from_javascript_and_scope(int init, zval *object, const char *code, size_t code_len, const bson_t *scope TSRMLS_DC);
void php_phongo_new_binary_from_binary_and_type(zval *object, const char *data, size_t data_len, bson_subtype_t type TSRMLS_DC);
void php_phongo_new_decimal128(zval *object, const bson_decimal128_t *decimal TSRMLS_DC);
void php_phongo_new_regex_from_regex_and_options(zval *object, const char *pattern, const char *flags TSRMLS_DC);
zend_bool phongo_writeerror_init(zval *return_value, bson_t *bson TSRMLS_DC);
zend_bool phongo_writeconcernerror_init(zval *return_value, bson_t *bson TSRMLS_DC);
-void php_phongo_cursor_free(php_phongo_cursor_t *cursor);
-zend_object_iterator* php_phongo_cursor_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
-
#if PHP_VERSION_ID >= 70000
#define PHONGO_CE_FINAL(ce) do { \
ce->ce_flags |= ZEND_ACC_FINAL; \
} while(0);
#else
#define PHONGO_CE_FINAL(ce) do { \
ce->ce_flags |= ZEND_ACC_FINAL_CLASS; \
} while(0);
#endif
#define PHONGO_CE_DISABLE_SERIALIZATION(ce) do { \
ce->serialize = zend_class_serialize_deny; \
ce->unserialize = zend_class_unserialize_deny; \
} while(0);
#ifdef PHP_DEBUG
void _phongo_debug_bson(bson_t *bson);
#else
#define _phongo_debug_bson(bson)
#endif
PHP_MINIT_FUNCTION(bson);
#endif /* PHONGO_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/php_phongo_classes.h b/mongodb-1.2.3/php_phongo_classes.h
similarity index 93%
rename from mongodb-1.2.0/php_phongo_classes.h
rename to mongodb-1.2.3/php_phongo_classes.h
index 4cff3cde..488a4c25 100644
--- a/mongodb-1.2.0/php_phongo_classes.h
+++ b/mongodb-1.2.3/php_phongo_classes.h
@@ -1,294 +1,296 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 2014-2015 Hannes Magnusson |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Hannes Magnusson <bjori@php.net> |
- +----------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef PHONGO_CLASSES_H
#define PHONGO_CLASSES_H
#include "php_phongo_structs.h"
+/* Export zend_class_entry dependencies, which are initialized in MINIT */
+extern zend_class_entry *php_phongo_date_immutable_ce;
+extern zend_class_entry *php_phongo_json_serializable_ce;
+
#if PHP_VERSION_ID >= 70000
static inline php_phongo_bulkwrite_t* php_bulkwrite_fetch_object(zend_object *obj) {
return (php_phongo_bulkwrite_t *)((char *)obj - XtOffsetOf(php_phongo_bulkwrite_t, std));
}
static inline php_phongo_command_t* php_command_fetch_object(zend_object *obj) {
return (php_phongo_command_t *)((char *)obj - XtOffsetOf(php_phongo_command_t, std));
}
static inline php_phongo_cursor_t* php_cursor_fetch_object(zend_object *obj) {
return (php_phongo_cursor_t *)((char *)obj - XtOffsetOf(php_phongo_cursor_t, std));
}
static inline php_phongo_cursorid_t* php_cursorid_fetch_object(zend_object *obj) {
return (php_phongo_cursorid_t *)((char *)obj - XtOffsetOf(php_phongo_cursorid_t, std));
}
static inline php_phongo_manager_t* php_manager_fetch_object(zend_object *obj) {
return (php_phongo_manager_t *)((char *)obj - XtOffsetOf(php_phongo_manager_t, std));
}
static inline php_phongo_query_t* php_query_fetch_object(zend_object *obj) {
return (php_phongo_query_t *)((char *)obj - XtOffsetOf(php_phongo_query_t, std));
}
static inline php_phongo_readconcern_t* php_readconcern_fetch_object(zend_object *obj) {
return (php_phongo_readconcern_t *)((char *)obj - XtOffsetOf(php_phongo_readconcern_t, std));
}
static inline php_phongo_readpreference_t* php_readpreference_fetch_object(zend_object *obj) {
return (php_phongo_readpreference_t *)((char *)obj - XtOffsetOf(php_phongo_readpreference_t, std));
}
static inline php_phongo_server_t* php_server_fetch_object(zend_object *obj) {
return (php_phongo_server_t *)((char *)obj - XtOffsetOf(php_phongo_server_t, std));
}
static inline php_phongo_writeconcern_t* php_writeconcern_fetch_object(zend_object *obj) {
return (php_phongo_writeconcern_t *)((char *)obj - XtOffsetOf(php_phongo_writeconcern_t, std));
}
static inline php_phongo_writeconcernerror_t* php_writeconcernerror_fetch_object(zend_object *obj) {
return (php_phongo_writeconcernerror_t *)((char *)obj - XtOffsetOf(php_phongo_writeconcernerror_t, std));
}
static inline php_phongo_writeerror_t* php_writeerror_fetch_object(zend_object *obj) {
return (php_phongo_writeerror_t *)((char *)obj - XtOffsetOf(php_phongo_writeerror_t, std));
}
static inline php_phongo_writeresult_t* php_writeresult_fetch_object(zend_object *obj) {
return (php_phongo_writeresult_t *)((char *)obj - XtOffsetOf(php_phongo_writeresult_t, std));
}
static inline php_phongo_binary_t* php_binary_fetch_object(zend_object *obj) {
return (php_phongo_binary_t *)((char *)obj - XtOffsetOf(php_phongo_binary_t, std));
}
static inline php_phongo_decimal128_t* php_decimal128_fetch_object(zend_object *obj) {
return (php_phongo_decimal128_t *)((char *)obj - XtOffsetOf(php_phongo_decimal128_t, std));
}
static inline php_phongo_javascript_t* php_javascript_fetch_object(zend_object *obj) {
return (php_phongo_javascript_t *)((char *)obj - XtOffsetOf(php_phongo_javascript_t, std));
}
static inline php_phongo_maxkey_t* php_maxkey_fetch_object(zend_object *obj) {
return (php_phongo_maxkey_t *)((char *)obj - XtOffsetOf(php_phongo_maxkey_t, std));
}
static inline php_phongo_minkey_t* php_minkey_fetch_object(zend_object *obj) {
return (php_phongo_minkey_t *)((char *)obj - XtOffsetOf(php_phongo_minkey_t, std));
}
static inline php_phongo_objectid_t* php_objectid_fetch_object(zend_object *obj) {
return (php_phongo_objectid_t *)((char *)obj - XtOffsetOf(php_phongo_objectid_t, std));
}
static inline php_phongo_regex_t* php_regex_fetch_object(zend_object *obj) {
return (php_phongo_regex_t *)((char *)obj - XtOffsetOf(php_phongo_regex_t, std));
}
static inline php_phongo_timestamp_t* php_timestamp_fetch_object(zend_object *obj) {
return (php_phongo_timestamp_t *)((char *)obj - XtOffsetOf(php_phongo_timestamp_t, std));
}
static inline php_phongo_utcdatetime_t* php_utcdatetime_fetch_object(zend_object *obj) {
return (php_phongo_utcdatetime_t *)((char *)obj - XtOffsetOf(php_phongo_utcdatetime_t, std));
}
# define Z_COMMAND_OBJ_P(zv) (php_command_fetch_object(Z_OBJ_P(zv)))
# define Z_CURSOR_OBJ_P(zv) (php_cursor_fetch_object(Z_OBJ_P(zv)))
# define Z_CURSORID_OBJ_P(zv) (php_cursorid_fetch_object(Z_OBJ_P(zv)))
# define Z_MANAGER_OBJ_P(zv) (php_manager_fetch_object(Z_OBJ_P(zv)))
# define Z_QUERY_OBJ_P(zv) (php_query_fetch_object(Z_OBJ_P(zv)))
# define Z_READCONCERN_OBJ_P(zv) (php_readconcern_fetch_object(Z_OBJ_P(zv)))
# define Z_READPREFERENCE_OBJ_P(zv) (php_readpreference_fetch_object(Z_OBJ_P(zv)))
# define Z_SERVER_OBJ_P(zv) (php_server_fetch_object(Z_OBJ_P(zv)))
# define Z_BULKWRITE_OBJ_P(zv) (php_bulkwrite_fetch_object(Z_OBJ_P(zv)))
# define Z_WRITECONCERN_OBJ_P(zv) (php_writeconcern_fetch_object(Z_OBJ_P(zv)))
# define Z_WRITECONCERNERROR_OBJ_P(zv) (php_writeconcernerror_fetch_object(Z_OBJ_P(zv)))
# define Z_WRITEERROR_OBJ_P(zv) (php_writeerror_fetch_object(Z_OBJ_P(zv)))
# define Z_WRITERESULT_OBJ_P(zv) (php_writeresult_fetch_object(Z_OBJ_P(zv)))
# define Z_BINARY_OBJ_P(zv) (php_binary_fetch_object(Z_OBJ_P(zv)))
# define Z_DECIMAL128_OBJ_P(zv) (php_decimal128_fetch_object(Z_OBJ_P(zv)))
# define Z_JAVASCRIPT_OBJ_P(zv) (php_javascript_fetch_object(Z_OBJ_P(zv)))
# define Z_MAXKEY_OBJ_P(zv) (php_maxkey_fetch_object(Z_OBJ_P(zv)))
# define Z_MINKEY_OBJ_P(zv) (php_minkey_fetch_object(Z_OBJ_P(zv)))
# define Z_OBJECTID_OBJ_P(zv) (php_objectid_fetch_object(Z_OBJ_P(zv)))
# define Z_REGEX_OBJ_P(zv) (php_regex_fetch_object(Z_OBJ_P(zv)))
# define Z_TIMESTAMP_OBJ_P(zv) (php_timestamp_fetch_object(Z_OBJ_P(zv)))
# define Z_UTCDATETIME_OBJ_P(zv) (php_utcdatetime_fetch_object(Z_OBJ_P(zv)))
# define Z_OBJ_COMMAND(zo) (php_command_fetch_object(zo))
# define Z_OBJ_CURSOR(zo) (php_cursor_fetch_object(zo))
# define Z_OBJ_CURSORID(zo) (php_cursorid_fetch_object(zo))
# define Z_OBJ_MANAGER(zo) (php_manager_fetch_object(zo))
# define Z_OBJ_QUERY(zo) (php_query_fetch_object(zo))
# define Z_OBJ_READCONCERN(zo) (php_readconcern_fetch_object(zo))
# define Z_OBJ_READPREFERENCE(zo) (php_readpreference_fetch_object(zo))
# define Z_OBJ_SERVER(zo) (php_server_fetch_object(zo))
# define Z_OBJ_BULKWRITE(zo) (php_bulkwrite_fetch_object(zo))
# define Z_OBJ_WRITECONCERN(zo) (php_writeconcern_fetch_object(zo))
# define Z_OBJ_WRITECONCERNERROR(zo) (php_writeconcernerror_fetch_object(zo))
# define Z_OBJ_WRITEERROR(zo) (php_writeerror_fetch_object(zo))
# define Z_OBJ_WRITERESULT(zo) (php_writeresult_fetch_object(zo))
# define Z_OBJ_BINARY(zo) (php_binary_fetch_object(zo))
# define Z_OBJ_DECIMAL128(zo) (php_decimal128_fetch_object(zo))
# define Z_OBJ_JAVASCRIPT(zo) (php_javascript_fetch_object(zo))
# define Z_OBJ_MAXKEY(zo) (php_maxkey_fetch_object(zo))
# define Z_OBJ_MINKEY(zo) (php_minkey_fetch_object(zo))
# define Z_OBJ_OBJECTID(zo) (php_objectid_fetch_object(zo))
# define Z_OBJ_REGEX(zo) (php_regex_fetch_object(zo))
# define Z_OBJ_TIMESTAMP(zo) (php_timestamp_fetch_object(zo))
# define Z_OBJ_UTCDATETIME(zo) (php_utcdatetime_fetch_object(zo))
#else
# define Z_COMMAND_OBJ_P(zv) ((php_phongo_command_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_CURSOR_OBJ_P(zv) ((php_phongo_cursor_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_CURSORID_OBJ_P(zv) ((php_phongo_cursorid_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_MANAGER_OBJ_P(zv) ((php_phongo_manager_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_QUERY_OBJ_P(zv) ((php_phongo_query_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_READCONCERN_OBJ_P(zv) ((php_phongo_readconcern_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_READPREFERENCE_OBJ_P(zv) ((php_phongo_readpreference_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_SERVER_OBJ_P(zv) ((php_phongo_server_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_BULKWRITE_OBJ_P(zv) ((php_phongo_bulkwrite_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_WRITECONCERN_OBJ_P(zv) ((php_phongo_writeconcern_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_WRITECONCERNERROR_OBJ_P(zv) ((php_phongo_writeconcernerror_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_WRITEERROR_OBJ_P(zv) ((php_phongo_writeerror_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_WRITERESULT_OBJ_P(zv) ((php_phongo_writeresult_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_BINARY_OBJ_P(zv) ((php_phongo_binary_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_DECIMAL128_OBJ_P(zv) ((php_phongo_decimal128_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_JAVASCRIPT_OBJ_P(zv) ((php_phongo_javascript_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_MAXKEY_OBJ_P(zv) ((php_phongo_maxkey_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_MINKEY_OBJ_P(zv) ((php_phongo_minkey_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_OBJECTID_OBJ_P(zv) ((php_phongo_objectid_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_REGEX_OBJ_P(zv) ((php_phongo_regex_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_TIMESTAMP_OBJ_P(zv) ((php_phongo_timestamp_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_UTCDATETIME_OBJ_P(zv) ((php_phongo_utcdatetime_t *)zend_object_store_get_object(zv TSRMLS_CC))
# define Z_OBJ_COMMAND(zo) ((php_phongo_command_t *)zo)
# define Z_OBJ_CURSOR(zo) ((php_phongo_cursor_t *)zo)
# define Z_OBJ_CURSORID(zo) ((php_phongo_cursorid_t *)zo)
# define Z_OBJ_MANAGER(zo) ((php_phongo_manager_t *)zo)
# define Z_OBJ_QUERY(zo) ((php_phongo_query_t *)zo)
# define Z_OBJ_READCONCERN(zo) ((php_phongo_readconcern_t *)zo)
# define Z_OBJ_READPREFERENCE(zo) ((php_phongo_readpreference_t *)zo)
# define Z_OBJ_SERVER(zo) ((php_phongo_server_t *)zo)
# define Z_OBJ_BULKWRITE(zo) ((php_phongo_bulkwrite_t *)zo)
# define Z_OBJ_WRITECONCERN(zo) ((php_phongo_writeconcern_t *)zo)
# define Z_OBJ_WRITECONCERNERROR(zo) ((php_phongo_writeconcernerror_t *)zo)
# define Z_OBJ_WRITEERROR(zo) ((php_phongo_writeerror_t *)zo)
# define Z_OBJ_WRITERESULT(zo) ((php_phongo_writeresult_t *)zo)
# define Z_OBJ_BINARY(zo) ((php_phongo_binary_t *)zo)
# define Z_OBJ_DECIMAL128(zo) ((php_phongo_decimal128_t *)zo)
# define Z_OBJ_JAVASCRIPT(zo) ((php_phongo_javascript_t *)zo)
# define Z_OBJ_MAXKEY(zo) ((php_phongo_maxkey_t *)zo)
# define Z_OBJ_MINKEY(zo) ((php_phongo_minkey_t *)zo)
# define Z_OBJ_OBJECTID(zo) ((php_phongo_objectid_t *)zo)
# define Z_OBJ_REGEX(zo) ((php_phongo_regex_t *)zo)
# define Z_OBJ_TIMESTAMP(zo) ((php_phongo_timestamp_t *)zo)
# define Z_OBJ_UTCDATETIME(zo) ((php_phongo_utcdatetime_t *)zo)
#endif
typedef struct {
zend_object_iterator intern;
php_phongo_cursor_t *cursor;
} php_phongo_cursor_iterator;
extern PHONGO_API zend_class_entry *php_phongo_command_ce;
extern PHONGO_API zend_class_entry *php_phongo_cursor_ce;
extern PHONGO_API zend_class_entry *php_phongo_cursorid_ce;
extern PHONGO_API zend_class_entry *php_phongo_manager_ce;
extern PHONGO_API zend_class_entry *php_phongo_query_ce;
extern PHONGO_API zend_class_entry *php_phongo_readconcern_ce;
extern PHONGO_API zend_class_entry *php_phongo_readpreference_ce;
extern PHONGO_API zend_class_entry *php_phongo_result_ce;
extern PHONGO_API zend_class_entry *php_phongo_server_ce;
extern PHONGO_API zend_class_entry *php_phongo_bulkwrite_ce;
extern PHONGO_API zend_class_entry *php_phongo_writeconcern_ce;
extern PHONGO_API zend_class_entry *php_phongo_writeconcernerror_ce;
extern PHONGO_API zend_class_entry *php_phongo_writeerror_ce;
extern PHONGO_API zend_class_entry *php_phongo_writeresult_ce;
extern PHONGO_API zend_class_entry *php_phongo_exception_ce;
extern PHONGO_API zend_class_entry *php_phongo_logicexception_ce;
extern PHONGO_API zend_class_entry *php_phongo_runtimeexception_ce;
extern PHONGO_API zend_class_entry *php_phongo_unexpectedvalueexception_ce;
extern PHONGO_API zend_class_entry *php_phongo_invalidargumentexception_ce;
extern PHONGO_API zend_class_entry *php_phongo_connectionexception_ce;
extern PHONGO_API zend_class_entry *php_phongo_authenticationexception_ce;
extern PHONGO_API zend_class_entry *php_phongo_sslconnectionexception_ce;
extern PHONGO_API zend_class_entry *php_phongo_executiontimeoutexception_ce;
extern PHONGO_API zend_class_entry *php_phongo_connectiontimeoutexception_ce;
extern PHONGO_API zend_class_entry *php_phongo_writeexception_ce;
extern PHONGO_API zend_class_entry *php_phongo_bulkwriteexception_ce;
extern PHONGO_API zend_class_entry *php_phongo_type_ce;
extern PHONGO_API zend_class_entry *php_phongo_persistable_ce;
extern PHONGO_API zend_class_entry *php_phongo_unserializable_ce;
extern PHONGO_API zend_class_entry *php_phongo_serializable_ce;
extern PHONGO_API zend_class_entry *php_phongo_binary_ce;
extern PHONGO_API zend_class_entry *php_phongo_decimal128_ce;
extern PHONGO_API zend_class_entry *php_phongo_javascript_ce;
extern PHONGO_API zend_class_entry *php_phongo_maxkey_ce;
extern PHONGO_API zend_class_entry *php_phongo_minkey_ce;
extern PHONGO_API zend_class_entry *php_phongo_objectid_ce;
extern PHONGO_API zend_class_entry *php_phongo_regex_ce;
extern PHONGO_API zend_class_entry *php_phongo_timestamp_ce;
extern PHONGO_API zend_class_entry *php_phongo_utcdatetime_ce;
/* Shared across all MongoDB\Driver objects to disable unserialize() */
PHP_METHOD(Manager, __wakeup);
/* Shared across all final MongoDB\Driver value objects, only possible to construct them internally */
PHP_METHOD(Server, __construct);
PHP_MINIT_FUNCTION(Command);
PHP_MINIT_FUNCTION(Cursor);
PHP_MINIT_FUNCTION(CursorId);
PHP_MINIT_FUNCTION(Manager);
PHP_MINIT_FUNCTION(Query);
PHP_MINIT_FUNCTION(ReadConcern);
PHP_MINIT_FUNCTION(ReadPreference);
PHP_MINIT_FUNCTION(Result);
PHP_MINIT_FUNCTION(Server);
PHP_MINIT_FUNCTION(BulkWrite);
PHP_MINIT_FUNCTION(WriteConcern);
PHP_MINIT_FUNCTION(WriteConcernError);
PHP_MINIT_FUNCTION(WriteError);
PHP_MINIT_FUNCTION(WriteResult);
PHP_MINIT_FUNCTION(Exception);
PHP_MINIT_FUNCTION(LogicException);
PHP_MINIT_FUNCTION(RuntimeException);
PHP_MINIT_FUNCTION(UnexpectedValueException);
PHP_MINIT_FUNCTION(InvalidArgumentException);
PHP_MINIT_FUNCTION(ConnectionException);
PHP_MINIT_FUNCTION(AuthenticationException);
PHP_MINIT_FUNCTION(SSLConnectionException);
PHP_MINIT_FUNCTION(ExecutionTimeoutException);
PHP_MINIT_FUNCTION(ConnectionTimeoutException);
PHP_MINIT_FUNCTION(WriteException);
PHP_MINIT_FUNCTION(BulkWriteException);
PHP_MINIT_FUNCTION(Type);
PHP_MINIT_FUNCTION(Unserializable);
PHP_MINIT_FUNCTION(Serializable);
PHP_MINIT_FUNCTION(Persistable);
PHP_MINIT_FUNCTION(Binary);
PHP_MINIT_FUNCTION(Decimal128);
PHP_MINIT_FUNCTION(Javascript);
PHP_MINIT_FUNCTION(MaxKey);
PHP_MINIT_FUNCTION(MinKey);
PHP_MINIT_FUNCTION(ObjectID);
PHP_MINIT_FUNCTION(Regex);
PHP_MINIT_FUNCTION(Timestamp);
PHP_MINIT_FUNCTION(UTCDateTime);
#endif /* PHONGO_CLASSES_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/php_phongo_structs.h b/mongodb-1.2.3/php_phongo_structs.h
similarity index 74%
rename from mongodb-1.2.0/php_phongo_structs.h
rename to mongodb-1.2.3/php_phongo_structs.h
index 0b74fd2f..5374ccbe 100644
--- a/mongodb-1.2.0/php_phongo_structs.h
+++ b/mongodb-1.2.3/php_phongo_structs.h
@@ -1,225 +1,219 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2016 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2016 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2015-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef PHONGO_STRUCTS_H
#define PHONGO_STRUCTS_H
#include <php.h>
#include "php_bson.h"
#if PHP_VERSION_ID >= 70000
# define PHONGO_ZEND_OBJECT_PRE
# define PHONGO_ZEND_OBJECT_POST zend_object std;
# define PHONGO_STRUCT_ZVAL zval
#else
# define PHONGO_ZEND_OBJECT_PRE zend_object std;
# define PHONGO_ZEND_OBJECT_POST
# define PHONGO_STRUCT_ZVAL zval*
#endif
typedef struct {
PHONGO_ZEND_OBJECT_PRE
mongoc_bulk_operation_t *bulk;
size_t num_ops;
bool ordered;
int bypass;
char *database;
char *collection;
bool executed;
PHONGO_ZEND_OBJECT_POST
} php_phongo_bulkwrite_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
bson_t *bson;
PHONGO_ZEND_OBJECT_POST
} php_phongo_command_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
mongoc_cursor_t *cursor;
PHONGO_STRUCT_ZVAL manager;
mongoc_client_t *client;
int server_id;
php_phongo_bson_state visitor_data;
int got_iterator;
long current;
char *database;
char *collection;
PHONGO_STRUCT_ZVAL query;
PHONGO_STRUCT_ZVAL command;
PHONGO_STRUCT_ZVAL read_preference;
PHONGO_ZEND_OBJECT_POST
} php_phongo_cursor_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
uint64_t id;
PHONGO_ZEND_OBJECT_POST
} php_phongo_cursorid_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
mongoc_client_t *client;
PHONGO_ZEND_OBJECT_POST
} php_phongo_manager_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
bson_t *filter;
bson_t *opts;
mongoc_read_concern_t *read_concern;
PHONGO_ZEND_OBJECT_POST
} php_phongo_query_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
mongoc_read_concern_t *read_concern;
PHONGO_ZEND_OBJECT_POST
} php_phongo_readconcern_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
mongoc_read_prefs_t *read_preference;
PHONGO_ZEND_OBJECT_POST
} php_phongo_readpreference_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
PHONGO_STRUCT_ZVAL manager;
mongoc_client_t *client;
int server_id;
PHONGO_ZEND_OBJECT_POST
} php_phongo_server_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
mongoc_write_concern_t *write_concern;
PHONGO_ZEND_OBJECT_POST
} php_phongo_writeconcern_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
int code;
char *message;
PHONGO_STRUCT_ZVAL info;
PHONGO_ZEND_OBJECT_POST
} php_phongo_writeconcernerror_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
int code;
char *message;
PHONGO_STRUCT_ZVAL info;
uint32_t index;
PHONGO_ZEND_OBJECT_POST
} php_phongo_writeerror_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
mongoc_write_concern_t *write_concern;
bson_t *reply;
PHONGO_STRUCT_ZVAL manager;
mongoc_client_t *client;
int server_id;
PHONGO_ZEND_OBJECT_POST
} php_phongo_writeresult_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
char *data;
int data_len;
uint8_t type;
PHONGO_ZEND_OBJECT_POST
} php_phongo_binary_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
bool initialized;
bson_decimal128_t decimal;
PHONGO_ZEND_OBJECT_POST
} php_phongo_decimal128_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
char *code;
size_t code_len;
bson_t *scope;
PHONGO_ZEND_OBJECT_POST
} php_phongo_javascript_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
PHONGO_ZEND_OBJECT_POST
} php_phongo_maxkey_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
PHONGO_ZEND_OBJECT_POST
} php_phongo_minkey_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
bool initialized;
char oid[25];
PHONGO_ZEND_OBJECT_POST
} php_phongo_objectid_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
char *pattern;
int pattern_len;
char *flags;
int flags_len;
PHONGO_ZEND_OBJECT_POST
} php_phongo_regex_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
bool initialized;
uint32_t increment;
uint32_t timestamp;
PHONGO_ZEND_OBJECT_POST
} php_phongo_timestamp_t;
typedef struct {
PHONGO_ZEND_OBJECT_PRE
bool initialized;
int64_t milliseconds;
PHONGO_ZEND_OBJECT_POST
} php_phongo_utcdatetime_t;
#undef PHONGO_ZEND_OBJECT_PRE
#undef PHONGO_ZEND_OBJECT_POST
#undef PHONGO_STRUCT_ZVAL
#endif /* PHONGO_STRUCTS */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/scripts/centos/essentials.sh b/mongodb-1.2.3/scripts/centos/essentials.sh
similarity index 100%
rename from mongodb-1.2.0/scripts/centos/essentials.sh
rename to mongodb-1.2.3/scripts/centos/essentials.sh
diff --git a/mongodb-1.2.0/scripts/centos/ldap/Domain.ldif b/mongodb-1.2.3/scripts/centos/ldap/Domain.ldif
similarity index 100%
rename from mongodb-1.2.0/scripts/centos/ldap/Domain.ldif
rename to mongodb-1.2.3/scripts/centos/ldap/Domain.ldif
diff --git a/mongodb-1.2.0/scripts/centos/ldap/Users.ldif b/mongodb-1.2.3/scripts/centos/ldap/Users.ldif
similarity index 100%
rename from mongodb-1.2.0/scripts/centos/ldap/Users.ldif
rename to mongodb-1.2.3/scripts/centos/ldap/Users.ldif
diff --git a/mongodb-1.2.0/scripts/centos/ldap/basics.ldif b/mongodb-1.2.3/scripts/centos/ldap/basics.ldif
similarity index 100%
rename from mongodb-1.2.0/scripts/centos/ldap/basics.ldif
rename to mongodb-1.2.3/scripts/centos/ldap/basics.ldif
diff --git a/mongodb-1.2.0/scripts/centos/ldap/install.sh b/mongodb-1.2.3/scripts/centos/ldap/install.sh
similarity index 100%
rename from mongodb-1.2.0/scripts/centos/ldap/install.sh
rename to mongodb-1.2.3/scripts/centos/ldap/install.sh
diff --git a/mongodb-1.2.0/scripts/centos/ldap/mongod.ldif b/mongodb-1.2.3/scripts/centos/ldap/mongod.ldif
similarity index 100%
rename from mongodb-1.2.0/scripts/centos/ldap/mongod.ldif
rename to mongodb-1.2.3/scripts/centos/ldap/mongod.ldif
diff --git a/mongodb-1.2.0/scripts/centos/ldap/pw.ldif b/mongodb-1.2.3/scripts/centos/ldap/pw.ldif
similarity index 100%
rename from mongodb-1.2.0/scripts/centos/ldap/pw.ldif
rename to mongodb-1.2.3/scripts/centos/ldap/pw.ldif
diff --git a/mongodb-1.2.0/scripts/centos/ldap/saslauthd.conf b/mongodb-1.2.3/scripts/centos/ldap/saslauthd.conf
similarity index 100%
rename from mongodb-1.2.0/scripts/centos/ldap/saslauthd.conf
rename to mongodb-1.2.3/scripts/centos/ldap/saslauthd.conf
diff --git a/mongodb-1.2.0/scripts/centos/ldap/users b/mongodb-1.2.3/scripts/centos/ldap/users
similarity index 100%
rename from mongodb-1.2.0/scripts/centos/ldap/users
rename to mongodb-1.2.3/scripts/centos/ldap/users
diff --git a/mongodb-1.2.3/scripts/convert-bson-corpus-tests.php b/mongodb-1.2.3/scripts/convert-bson-corpus-tests.php
new file mode 100644
index 00000000..c1ce6c24
--- /dev/null
+++ b/mongodb-1.2.3/scripts/convert-bson-corpus-tests.php
@@ -0,0 +1,211 @@
+<?php
+
+require_once __DIR__ . '/../tests/utils/tools.php';
+
+$outputPath = realpath(__DIR__ . '/../tests') . '/bson-corpus/';
+
+if ( ! is_dir($outputPath) && ! mkdir($outputPath, 0755, true)) {
+ printf("Error creating output path: %s\n", $outputPath);
+}
+
+foreach (array_slice($argv, 1) as $inputFile) {
+ if ( ! is_readable($inputFile) || ! is_file($inputFile)) {
+ printf("Error reading %s\n", $inputFile);
+ continue;
+ }
+
+ $test = json_decode(file_get_contents($inputFile), true);
+
+ if (json_last_error() !== JSON_ERROR_NONE) {
+ printf("Error decoding %s: %s\n", $inputFile, json_last_error_msg());
+ continue;
+ }
+
+ if ( ! empty($test['deprecated'])) {
+ printf("Skipping deprecated test file: %s\n", $inputFile);
+ continue;
+ }
+
+ if ( ! empty($test['valid'])) {
+ foreach ($test['valid'] as $i => $case) {
+ $outputFile = sprintf('%s-valid-%03d.phpt', pathinfo($inputFile, PATHINFO_FILENAME), $i + 1);
+ $output = renderPhpt(getParamsForValid($test, $case));
+
+ if (false === file_put_contents($outputPath . '/' . $outputFile, $output)) {
+ printf("Error writing valid[%d] in %s\n", $i, $inputFile);
+ continue;
+ }
+ }
+ }
+
+ if ( ! empty($test['decodeErrors'])) {
+ foreach ($test['decodeErrors'] as $i => $case) {
+ $outputFile = sprintf('%s-decodeError-%03d.phpt', pathinfo($inputFile, PATHINFO_FILENAME), $i + 1);
+ $output = renderPhpt(getParamsForDecodeError($test, $case));
+
+ if (false === file_put_contents($outputPath . '/' . $outputFile, $output)) {
+ printf("Error writing decodeErrors[%d] in %s\n", $i, $inputFile);
+ continue;
+ }
+ }
+ }
+
+ if ( ! empty($test['parseErrors'])) {
+ foreach ($test['parseErrors'] as $i => $case) {
+ $outputFile = sprintf('%s-parseError-%03d.phpt', pathinfo($inputFile, PATHINFO_FILENAME), $i + 1);
+ try {
+ $output = renderPhpt(getParamsForParseError($test, $case));
+ } catch (UnexpectedValueException $e) {
+ printf("Parse errors not supported for BSON type: %s\n", $test['bson_type']);
+ continue;
+ }
+
+ if (false === file_put_contents($outputPath . '/' . $outputFile, $output)) {
+ printf("Error writing parseErrors[%d] in %s\n", $i, $inputFile);
+ continue;
+ }
+ }
+ }
+}
+
+function getParamsForValid(array $test, array $case)
+{
+ $code = '';
+ $expect = '';
+
+ $bson = $case['bson'];
+ $canonicalBson = isset($case['canonical_bson']) ? $case['canonical_bson'] : $bson;
+ $expectedCanonicalBson = strtolower($canonicalBson);
+
+ $code .= sprintf('$bson = hex2bin(%s);', var_export($bson, true)) . "\n";
+
+ $code .= "\n// BSON to Canonical BSON\n";
+ $code .= 'echo bin2hex(fromPHP(toPHP($bson))), "\n";' . "\n";
+ $expect .= $expectedCanonicalBson . "\n";
+
+ if ($bson !== $canonicalBson) {
+ $code .= "\n" . sprintf('$canonicalBson = hex2bin(%s);', var_export($canonicalBson, true)) . "\n";
+ $code .= "\n// Canonical BSON to Canonical BSON\n";
+ $code .= 'echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";' . "\n";
+ $expect .= $expectedCanonicalBson . "\n";
+ }
+
+ if (isset($case['extjson'])) {
+ $json = $case['extjson'];
+ $canonicalJson = isset($case['canonical_extjson']) ? $case['canonical_extjson'] : $json;
+ $expectedCanonicalJson = json_canonicalize($canonicalJson);
+ $lossy = isset($case['lossy']) ? (boolean) $case['lossy'] : false;
+
+ $code .= "\n// BSON to Canonical extJSON\n";
+ $code .= 'echo json_canonicalize(toJSON($bson)), "\n";' . "\n";;
+ $expect .= $expectedCanonicalJson . "\n";
+
+ $code .= "\n" . sprintf('$json = %s;', var_export($json, true)) . "\n";
+ $code .= "\n// extJSON to Canonical extJSON\n";
+ $code .= 'echo json_canonicalize(toJSON(fromJSON($json))), "\n";' . "\n";;
+ $expect .= $expectedCanonicalJson . "\n";
+
+ if ($bson !== $canonicalBson) {
+ $code .= "\n// Canonical BSON to Canonical extJSON\n";
+ $code .= 'echo json_canonicalize(toJSON($canonicalBson)), "\n";' . "\n";;
+ $expect .= $expectedCanonicalJson . "\n";
+ }
+
+ if ($json !== $canonicalJson) {
+ $code .= "\n" . sprintf('$canonicalJson = %s;', var_export($canonicalJson, true)) . "\n";
+ $code .= "\n// Canonical extJSON to Canonical extJSON\n";
+ $code .= 'echo json_canonicalize(toJSON(fromJSON($canonicalJson))), "\n";' . "\n";;
+ $expect .= $expectedCanonicalJson . "\n";
+ }
+
+ if ( ! $lossy) {
+ $code .= "\n// extJSON to Canonical BSON\n";
+ $code .= 'echo bin2hex(fromJSON($json)), "\n";' . "\n";;
+ $expect .= $expectedCanonicalBson . "\n";
+
+ if ($json !== $canonicalJson) {
+ $code .= "\n// Canonical extJSON to Canonical BSON\n";
+ $code .= 'echo bin2hex(fromJSON($canonicalJson)), "\n";' . "\n";;
+ $expect .= $expectedCanonicalBson . "\n";
+ }
+ }
+ }
+
+ return [
+ '%NAME%' => sprintf('%s: %s', trim($test['description']), trim($case['description'])),
+ '%CODE%' => trim($code),
+ '%EXPECT%' => trim($expect),
+ ];
+}
+
+function getParamsForDecodeError(array $test, array $case)
+{
+ $code = sprintf('$bson = hex2bin(%s);', var_export($case['bson'], true)) . "\n\n";
+ $code .= "throws(function() use (\$bson) {\n";
+ $code .= " var_dump(toPHP(\$bson));\n";
+ $code .= "}, 'MongoDB\Driver\Exception\UnexpectedValueException');";
+
+ /* We do not test for the exception message, since that may differ based on
+ * the nature of the decoding error. */
+ $expect = "OK: Got MongoDB\Driver\Exception\UnexpectedValueException";
+
+ return [
+ '%NAME%' => sprintf('%s: %s', trim($test['description']), trim($case['description'])),
+ '%CODE%' => trim($code),
+ '%EXPECT%' => trim($expect),
+ ];
+}
+
+function getParamsForParseError(array $test, array $case)
+{
+ $code = '';
+ $expect = '';
+
+ switch ($test['bson_type']) {
+ case '0x13': // Decimal128
+ $code = "throws(function() {\n";
+ $code .= sprintf(" new MongoDB\BSON\Decimal128(%s);\n", var_export($case['string'], true));
+ $code .= "}, 'MongoDB\Driver\Exception\InvalidArgumentException');";
+
+ /* We do not test for the exception message, since that may differ
+ * based on the nature of the parse error. */
+ $expect = "OK: Got MongoDB\Driver\Exception\InvalidArgumentException";
+ break;
+
+ default:
+ throw new UnexpectedValueException;
+ }
+
+ return [
+ '%NAME%' => sprintf('%s: %s', trim($test['description']), trim($case['description'])),
+ '%CODE%' => trim($code),
+ '%EXPECT%' => trim($expect),
+ ];
+}
+
+function renderPhpt(array $params)
+{
+ $template = <<< 'TEMPLATE'
+--TEST--
+%NAME%
+--DESCRIPTION--
+Generated by scripts/convert-bson-corpus-tests.php
+
+DO NOT EDIT THIS FILE
+--FILE--
+<?php
+
+require_once __DIR__ . '/../utils/tools.php';
+
+%CODE%
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+%EXPECT%
+===DONE===
+TEMPLATE;
+
+ return str_replace(array_keys($params), array_values($params), $template);
+}
diff --git a/mongodb-1.2.0/scripts/convert-mo-tests.php b/mongodb-1.2.3/scripts/convert-mo-tests.php
similarity index 100%
rename from mongodb-1.2.0/scripts/convert-mo-tests.php
rename to mongodb-1.2.3/scripts/convert-mo-tests.php
diff --git a/mongodb-1.2.0/scripts/freebsd/essentials.sh b/mongodb-1.2.3/scripts/freebsd/essentials.sh
similarity index 100%
rename from mongodb-1.2.0/scripts/freebsd/essentials.sh
rename to mongodb-1.2.3/scripts/freebsd/essentials.sh
diff --git a/mongodb-1.2.0/scripts/freebsd/phongo.sh b/mongodb-1.2.3/scripts/freebsd/phongo.sh
similarity index 100%
rename from mongodb-1.2.0/scripts/freebsd/phongo.sh
rename to mongodb-1.2.3/scripts/freebsd/phongo.sh
diff --git a/mongodb-1.2.0/scripts/list-servers.php b/mongodb-1.2.3/scripts/list-servers.php
similarity index 100%
rename from mongodb-1.2.0/scripts/list-servers.php
rename to mongodb-1.2.3/scripts/list-servers.php
diff --git a/mongodb-1.2.0/scripts/presets/replicaset-30.json b/mongodb-1.2.3/scripts/presets/replicaset-30.json
similarity index 100%
rename from mongodb-1.2.0/scripts/presets/replicaset-30.json
rename to mongodb-1.2.3/scripts/presets/replicaset-30.json
diff --git a/mongodb-1.2.0/scripts/presets/replicaset.json b/mongodb-1.2.3/scripts/presets/replicaset.json
similarity index 100%
rename from mongodb-1.2.0/scripts/presets/replicaset.json
rename to mongodb-1.2.3/scripts/presets/replicaset.json
diff --git a/mongodb-1.2.0/scripts/presets/standalone-24.json b/mongodb-1.2.3/scripts/presets/standalone-24.json
similarity index 100%
rename from mongodb-1.2.0/scripts/presets/standalone-24.json
rename to mongodb-1.2.3/scripts/presets/standalone-24.json
diff --git a/mongodb-1.2.0/scripts/presets/standalone-26.json b/mongodb-1.2.3/scripts/presets/standalone-26.json
similarity index 100%
rename from mongodb-1.2.0/scripts/presets/standalone-26.json
rename to mongodb-1.2.3/scripts/presets/standalone-26.json
diff --git a/mongodb-1.2.0/scripts/presets/standalone-30.json b/mongodb-1.2.3/scripts/presets/standalone-30.json
similarity index 100%
rename from mongodb-1.2.0/scripts/presets/standalone-30.json
rename to mongodb-1.2.3/scripts/presets/standalone-30.json
diff --git a/mongodb-1.2.0/scripts/presets/standalone-auth.json b/mongodb-1.2.3/scripts/presets/standalone-auth.json
similarity index 100%
rename from mongodb-1.2.0/scripts/presets/standalone-auth.json
rename to mongodb-1.2.3/scripts/presets/standalone-auth.json
diff --git a/mongodb-1.2.0/scripts/presets/standalone-plain.json b/mongodb-1.2.3/scripts/presets/standalone-plain.json
similarity index 100%
rename from mongodb-1.2.0/scripts/presets/standalone-plain.json
rename to mongodb-1.2.3/scripts/presets/standalone-plain.json
diff --git a/mongodb-1.2.0/scripts/presets/standalone-ssl.json b/mongodb-1.2.3/scripts/presets/standalone-ssl.json
similarity index 100%
rename from mongodb-1.2.0/scripts/presets/standalone-ssl.json
rename to mongodb-1.2.3/scripts/presets/standalone-ssl.json
diff --git a/mongodb-1.2.0/scripts/presets/standalone-x509.json b/mongodb-1.2.3/scripts/presets/standalone-x509.json
similarity index 100%
rename from mongodb-1.2.0/scripts/presets/standalone-x509.json
rename to mongodb-1.2.3/scripts/presets/standalone-x509.json
diff --git a/mongodb-1.2.0/scripts/presets/standalone.json b/mongodb-1.2.3/scripts/presets/standalone.json
similarity index 100%
rename from mongodb-1.2.0/scripts/presets/standalone.json
rename to mongodb-1.2.3/scripts/presets/standalone.json
diff --git a/mongodb-1.2.0/scripts/ssl/ca.pem b/mongodb-1.2.3/scripts/ssl/ca.pem
similarity index 100%
rename from mongodb-1.2.0/scripts/ssl/ca.pem
rename to mongodb-1.2.3/scripts/ssl/ca.pem
diff --git a/mongodb-1.2.0/scripts/ssl/client.pem b/mongodb-1.2.3/scripts/ssl/client.pem
similarity index 100%
rename from mongodb-1.2.0/scripts/ssl/client.pem
rename to mongodb-1.2.3/scripts/ssl/client.pem
diff --git a/mongodb-1.2.0/scripts/ssl/crl.pem b/mongodb-1.2.3/scripts/ssl/crl.pem
similarity index 100%
rename from mongodb-1.2.0/scripts/ssl/crl.pem
rename to mongodb-1.2.3/scripts/ssl/crl.pem
diff --git a/mongodb-1.2.0/scripts/ssl/server.pem b/mongodb-1.2.3/scripts/ssl/server.pem
similarity index 100%
rename from mongodb-1.2.0/scripts/ssl/server.pem
rename to mongodb-1.2.3/scripts/ssl/server.pem
diff --git a/mongodb-1.2.0/scripts/start-servers.php b/mongodb-1.2.3/scripts/start-servers.php
similarity index 100%
rename from mongodb-1.2.0/scripts/start-servers.php
rename to mongodb-1.2.3/scripts/start-servers.php
diff --git a/mongodb-1.2.0/scripts/ubuntu/essentials.sh b/mongodb-1.2.3/scripts/ubuntu/essentials.sh
similarity index 100%
rename from mongodb-1.2.0/scripts/ubuntu/essentials.sh
rename to mongodb-1.2.3/scripts/ubuntu/essentials.sh
diff --git a/mongodb-1.2.0/scripts/ubuntu/ldap/install.sh b/mongodb-1.2.3/scripts/ubuntu/ldap/install.sh
similarity index 100%
rename from mongodb-1.2.0/scripts/ubuntu/ldap/install.sh
rename to mongodb-1.2.3/scripts/ubuntu/ldap/install.sh
diff --git a/mongodb-1.2.0/scripts/ubuntu/ldap/saslauthd.conf b/mongodb-1.2.3/scripts/ubuntu/ldap/saslauthd.conf
similarity index 100%
rename from mongodb-1.2.0/scripts/ubuntu/ldap/saslauthd.conf
rename to mongodb-1.2.3/scripts/ubuntu/ldap/saslauthd.conf
diff --git a/mongodb-1.2.0/scripts/ubuntu/mongo-orchestration.sh b/mongodb-1.2.3/scripts/ubuntu/mongo-orchestration.sh
similarity index 100%
rename from mongodb-1.2.0/scripts/ubuntu/mongo-orchestration.sh
rename to mongodb-1.2.3/scripts/ubuntu/mongo-orchestration.sh
diff --git a/mongodb-1.2.0/scripts/ubuntu/phongo.sh b/mongodb-1.2.3/scripts/ubuntu/phongo.sh
similarity index 100%
rename from mongodb-1.2.0/scripts/ubuntu/phongo.sh
rename to mongodb-1.2.3/scripts/ubuntu/phongo.sh
diff --git a/mongodb-1.2.0/scripts/vmware/kernel.sh b/mongodb-1.2.3/scripts/vmware/kernel.sh
similarity index 100%
rename from mongodb-1.2.0/scripts/vmware/kernel.sh
rename to mongodb-1.2.3/scripts/vmware/kernel.sh
diff --git a/mongodb-1.2.0/src/BSON/Binary.c b/mongodb-1.2.3/src/BSON/Binary.c
similarity index 89%
rename from mongodb-1.2.0/src/BSON/Binary.c
rename to mongodb-1.2.3/src/BSON/Binary.c
index e3571fda..5e5a34e9 100644
--- a/mongodb-1.2.0/src/BSON/Binary.c
+++ b/mongodb-1.2.3/src/BSON/Binary.c
@@ -1,495 +1,488 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
-#include <ext/json/php_json.h>
#include <ext/standard/base64.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <Zend/zend_operators.h>
#include <ext/spl/spl_iterators.h>
#include <ext/standard/php_var.h>
#if PHP_VERSION_ID >= 70000
# include <zend_smart_str.h>
#else
# include <ext/standard/php_smart_str.h>
#endif
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_binary_ce;
zend_object_handlers php_phongo_handler_binary;
/* Initialize the object and return whether it was successful. An exception will
* be thrown on error. */
static bool php_phongo_binary_init(php_phongo_binary_t *intern, const char *data, phongo_zpp_char_len data_len, phongo_long type TSRMLS_DC)
{
if (type < 0 || type > UINT8_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected type to be an unsigned 8-bit integer, %" PHONGO_LONG_FORMAT " given", type);
return false;
}
intern->data = estrndup(data, data_len);
intern->data_len = data_len;
intern->type = (uint8_t) type;
return true;
}
/* Initialize the object from a HashTable and return whether it was successful.
* An exception will be thrown on error. */
static bool php_phongo_binary_init_from_hash(php_phongo_binary_t *intern, HashTable *props TSRMLS_DC)
{
#if PHP_VERSION_ID >= 70000
zval *data, *type;
if ((data = zend_hash_str_find(props, "data", sizeof("data")-1)) && Z_TYPE_P(data) == IS_STRING &&
(type = zend_hash_str_find(props, "type", sizeof("type")-1)) && Z_TYPE_P(type) == IS_LONG) {
return php_phongo_binary_init(intern, Z_STRVAL_P(data), Z_STRLEN_P(data), Z_LVAL_P(type) TSRMLS_CC);
}
#else
zval **data, **type;
if (zend_hash_find(props, "data", sizeof("data"), (void**) &data) == SUCCESS && Z_TYPE_PP(data) == IS_STRING &&
zend_hash_find(props, "type", sizeof("type"), (void**) &type) == SUCCESS && Z_TYPE_PP(type) == IS_LONG) {
return php_phongo_binary_init(intern, Z_STRVAL_PP(data), Z_STRLEN_PP(data), Z_LVAL_PP(type) TSRMLS_CC);
}
#endif
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "%s initialization requires \"data\" string and \"type\" integer fields", ZSTR_VAL(php_phongo_binary_ce->name));
return false;
}
/* {{{ proto void Binary::__construct(string $data, int $type)
Construct a new BSON binary type */
PHP_METHOD(Binary, __construct)
{
php_phongo_binary_t *intern;
zend_error_handling error_handling;
char *data;
phongo_zpp_char_len data_len;
phongo_long type;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_BINARY_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &data, &data_len, &type) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
php_phongo_binary_init(intern, data, data_len, type TSRMLS_CC);
}
/* }}} */
/* {{{ proto void Binary::__set_state(array $properties)
*/
PHP_METHOD(Binary, __set_state)
{
php_phongo_binary_t *intern;
HashTable *props;
zval *array;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
RETURN_FALSE;
}
object_init_ex(return_value, php_phongo_binary_ce);
intern = Z_BINARY_OBJ_P(return_value);
props = Z_ARRVAL_P(array);
php_phongo_binary_init_from_hash(intern, props TSRMLS_CC);
}
/* }}} */
/* {{{ proto string Binary::__toString()
Return the Binary's data string. */
PHP_METHOD(Binary, __toString)
{
php_phongo_binary_t *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_BINARY_OBJ_P(getThis());
PHONGO_RETURN_STRINGL(intern->data, intern->data_len);
}
/* }}} */
/* {{{ proto string Binary::getData()
*/
PHP_METHOD(Binary, getData)
{
php_phongo_binary_t *intern;
intern = Z_BINARY_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
PHONGO_RETURN_STRINGL(intern->data, intern->data_len);
}
/* }}} */
/* {{{ proto integer Binary::getType()
*/
PHP_METHOD(Binary, getType)
{
php_phongo_binary_t *intern;
intern = Z_BINARY_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(intern->type);
}
/* }}} */
/* {{{ proto array Binary::jsonSerialize()
*/
PHP_METHOD(Binary, jsonSerialize)
{
php_phongo_binary_t *intern;
char type[3];
int type_len;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_BINARY_OBJ_P(getThis());
array_init_size(return_value, 2);
#if PHP_VERSION_ID >= 70000
{
zend_string *data = php_base64_encode((unsigned char *)intern->data, intern->data_len);
ADD_ASSOC_STRINGL(return_value, "$binary", ZSTR_VAL(data), ZSTR_LEN(data));
zend_string_free(data);
}
#else
{
int data_len = 0;
unsigned char *data = php_base64_encode((unsigned char *)intern->data, intern->data_len, &data_len);
ADD_ASSOC_STRINGL(return_value, "$binary", (char *)data, data_len);
efree(data);
}
#endif
type_len = snprintf(type, sizeof(type), "%02x", intern->type);
ADD_ASSOC_STRINGL(return_value, "$type", type, type_len);
}
/* }}} */
/* {{{ proto string Binary::serialize()
*/
PHP_METHOD(Binary, serialize)
{
php_phongo_binary_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval *retval;
#endif
php_serialize_data_t var_hash;
smart_str buf = { 0 };
intern = Z_BINARY_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
#if PHP_VERSION_ID >= 70000
array_init_size(&retval, 2);
ADD_ASSOC_STRINGL(&retval, "data", intern->data, intern->data_len);
ADD_ASSOC_LONG_EX(&retval, "type", intern->type);
#else
ALLOC_INIT_ZVAL(retval);
array_init_size(retval, 2);
ADD_ASSOC_STRINGL(retval, "data", intern->data, intern->data_len);
ADD_ASSOC_LONG_EX(retval, "type", intern->type);
#endif
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&buf, &retval, &var_hash TSRMLS_CC);
smart_str_0(&buf);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
PHONGO_RETVAL_SMART_STR(buf);
smart_str_free(&buf);
zval_ptr_dtor(&retval);
}
/* }}} */
/* {{{ proto string Binary::unserialize(string $serialized)
*/
PHP_METHOD(Binary, unserialize)
{
php_phongo_binary_t *intern;
zend_error_handling error_handling;
char *serialized;
phongo_zpp_char_len serialized_len;
#if PHP_VERSION_ID >= 70000
zval props;
#else
zval *props;
#endif
php_unserialize_data_t var_hash;
intern = Z_BINARY_OBJ_P(getThis());
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized, &serialized_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
#if PHP_VERSION_ID < 70000
ALLOC_INIT_ZVAL(props);
#endif
PHP_VAR_UNSERIALIZE_INIT(var_hash);
if (!php_var_unserialize(&props, (const unsigned char**) &serialized, (unsigned char *) serialized + serialized_len, &var_hash TSRMLS_CC)) {
zval_ptr_dtor(&props);
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "%s unserialization failed", ZSTR_VAL(php_phongo_binary_ce->name));
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return;
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
#if PHP_VERSION_ID >= 70000
php_phongo_binary_init_from_hash(intern, HASH_OF(&props) TSRMLS_CC);
#else
php_phongo_binary_init_from_hash(intern, HASH_OF(props) TSRMLS_CC);
#endif
zval_ptr_dtor(&props);
}
/* }}} */
/* {{{ BSON\Binary */
ZEND_BEGIN_ARG_INFO_EX(ai_Binary___construct, 0, 0, 2)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(0, type)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Binary___set_state, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, properties, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Binary_unserialize, 0, 0, 1)
ZEND_ARG_INFO(0, serialized)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Binary_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_binary_me[] = {
PHP_ME(Binary, __construct, ai_Binary___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Binary, __set_state, ai_Binary___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Binary, __toString, ai_Binary_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Binary, jsonSerialize, ai_Binary_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Binary, serialize, ai_Binary_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Binary, unserialize, ai_Binary_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Binary, getData, ai_Binary_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Binary, getType, ai_Binary_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_binary_t object handlers */
static void php_phongo_binary_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_binary_t *intern = Z_OBJ_BINARY(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->data) {
efree(intern->data);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_binary_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_binary_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_binary_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_binary;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_binary_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_binary;
return retval;
}
#endif
} /* }}} */
static int php_phongo_binary_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
{
php_phongo_binary_t *intern1, *intern2;
intern1 = Z_BINARY_OBJ_P(o1);
intern2 = Z_BINARY_OBJ_P(o2);
/* MongoDB compares binary types first by the data length, then by the type
* byte, and finally by the binary data itself. */
if (intern1->data_len != intern2->data_len) {
return intern1->data_len < intern2->data_len ? -1 : 1;
}
if (intern1->type != intern2->type) {
return intern1->type < intern2->type ? -1 : 1;
}
return zend_binary_strcmp(intern1->data, intern1->data_len, intern2->data, intern2->data_len);
} /* }}} */
HashTable *php_phongo_binary_get_properties(zval *object TSRMLS_DC) /* {{{ */
{
php_phongo_binary_t *intern;
HashTable *props;
intern = Z_BINARY_OBJ_P(object);
props = zend_std_get_properties(object TSRMLS_CC);
if (!intern->data) {
return props;
}
#if PHP_VERSION_ID >= 70000
{
zval data, type;
ZVAL_STRINGL(&data, intern->data, intern->data_len);
zend_hash_str_update(props, "data", sizeof("data")-1, &data);
ZVAL_LONG(&type, intern->type);
zend_hash_str_update(props, "type", sizeof("type")-1, &type);
}
#else
{
zval *data, *type;
MAKE_STD_ZVAL(data);
ZVAL_STRINGL(data, intern->data, intern->data_len, 1);
zend_hash_update(props, "data", sizeof("data"), &data, sizeof(data), NULL);
MAKE_STD_ZVAL(type);
ZVAL_LONG(type, intern->type);
zend_hash_update(props, "type", sizeof("type"), &type, sizeof(type), NULL);
}
#endif
return props;
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Binary)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Binary", php_phongo_binary_me);
php_phongo_binary_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_binary_ce->create_object = php_phongo_binary_create_object;
PHONGO_CE_FINAL(php_phongo_binary_ce);
- zend_class_implements(php_phongo_binary_ce TSRMLS_CC, 1, php_json_serializable_ce);
+ zend_class_implements(php_phongo_binary_ce TSRMLS_CC, 1, php_phongo_json_serializable_ce);
zend_class_implements(php_phongo_binary_ce TSRMLS_CC, 1, php_phongo_type_ce);
zend_class_implements(php_phongo_binary_ce TSRMLS_CC, 1, zend_ce_serializable);
memcpy(&php_phongo_handler_binary, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_binary.compare_objects = php_phongo_binary_compare_objects;
php_phongo_handler_binary.get_properties = php_phongo_binary_get_properties;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_binary.free_obj = php_phongo_binary_free_object;
php_phongo_handler_binary.offset = XtOffsetOf(php_phongo_binary_t, std);
#endif
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_GENERIC"), BSON_SUBTYPE_BINARY TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_FUNCTION"), BSON_SUBTYPE_FUNCTION TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_OLD_BINARY"), BSON_SUBTYPE_BINARY_DEPRECATED TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_OLD_UUID"), BSON_SUBTYPE_UUID_DEPRECATED TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_UUID"), BSON_SUBTYPE_UUID TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_MD5"), BSON_SUBTYPE_MD5 TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_USER_DEFINED"), BSON_SUBTYPE_USER TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/BSON/Decimal128.c b/mongodb-1.2.3/src/BSON/Decimal128.c
similarity index 87%
rename from mongodb-1.2.0/src/BSON/Decimal128.c
rename to mongodb-1.2.3/src/BSON/Decimal128.c
index 3da66371..d419a34e 100644
--- a/mongodb-1.2.0/src/BSON/Decimal128.c
+++ b/mongodb-1.2.3/src/BSON/Decimal128.c
@@ -1,399 +1,392 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2016 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2016 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2015-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
-#include <ext/json/php_json.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
#include <ext/standard/php_var.h>
#if PHP_VERSION_ID >= 70000
# include <zend_smart_str.h>
#else
# include <ext/standard/php_smart_str.h>
#endif
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_decimal128_ce;
zend_object_handlers php_phongo_handler_decimal128;
/* Initialize the object and return whether it was successful. An exception will
* be thrown on error. */
static bool php_phongo_decimal128_init(php_phongo_decimal128_t *intern, const char *value TSRMLS_DC)
{
if (!bson_decimal128_from_string(value, &intern->decimal)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error parsing Decimal128 string: %s", value);
return false;
}
intern->initialized = true;
return true;
}
/* Initialize the object from a HashTable and return whether it was successful.
* An exception will be thrown on error. */
static bool php_phongo_decimal128_init_from_hash(php_phongo_decimal128_t *intern, HashTable *props TSRMLS_DC)
{
#if PHP_VERSION_ID >= 70000
zval *dec;
if ((dec = zend_hash_str_find(props, "dec", sizeof("dec")-1)) && Z_TYPE_P(dec) == IS_STRING) {
return php_phongo_decimal128_init(intern, Z_STRVAL_P(dec) TSRMLS_CC);
}
#else
zval **dec;
if (zend_hash_find(props, "dec", sizeof("dec"), (void**) &dec) == SUCCESS && Z_TYPE_PP(dec) == IS_STRING) {
return php_phongo_decimal128_init(intern, Z_STRVAL_PP(dec) TSRMLS_CC);
}
#endif
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "%s initialization requires \"dec\" string field", ZSTR_VAL(php_phongo_decimal128_ce->name));
return false;
}
/* {{{ proto void Decimal128::__construct(string $value)
Construct a new BSON Decimal128 type */
PHP_METHOD(Decimal128, __construct)
{
php_phongo_decimal128_t *intern;
zend_error_handling error_handling;
char *value;
phongo_zpp_char_len value_len;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_DECIMAL128_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &value, &value_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
php_phongo_decimal128_init(intern, value TSRMLS_CC);
}
/* }}} */
/* {{{ proto void Decimal128::__set_state(array $properties)
*/
PHP_METHOD(Decimal128, __set_state)
{
php_phongo_decimal128_t *intern;
HashTable *props;
zval *array;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
RETURN_FALSE;
}
object_init_ex(return_value, php_phongo_decimal128_ce);
intern = Z_DECIMAL128_OBJ_P(return_value);
props = Z_ARRVAL_P(array);
php_phongo_decimal128_init_from_hash(intern, props TSRMLS_CC);
}
/* }}} */
/* {{{ proto string Decimal128::__toString()
*/
PHP_METHOD(Decimal128, __toString)
{
php_phongo_decimal128_t *intern;
char outbuf[BSON_DECIMAL128_STRING];
intern = Z_DECIMAL128_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
bson_decimal128_to_string(&intern->decimal, outbuf);
PHONGO_RETURN_STRING(outbuf);
}
/* }}} */
/* {{{ proto array Decimal128::jsonSerialize()
*/
PHP_METHOD(Decimal128, jsonSerialize)
{
php_phongo_decimal128_t *intern;
char outbuf[BSON_DECIMAL128_STRING] = "";
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_DECIMAL128_OBJ_P(getThis());
array_init_size(return_value, 1);
bson_decimal128_to_string(&intern->decimal, outbuf);
ADD_ASSOC_STRING(return_value, "$numberDecimal", outbuf);
}
/* }}} */
/* {{{ proto string Decimal128::serialize()
*/
PHP_METHOD(Decimal128, serialize)
{
php_phongo_decimal128_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval *retval;
#endif
php_serialize_data_t var_hash;
smart_str buf = { 0 };
char outbuf[BSON_DECIMAL128_STRING];
intern = Z_DECIMAL128_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
bson_decimal128_to_string(&intern->decimal, outbuf);
#if PHP_VERSION_ID >= 70000
array_init_size(&retval, 1);
ADD_ASSOC_STRING(&retval, "dec", outbuf);
#else
ALLOC_INIT_ZVAL(retval);
array_init_size(retval, 1);
ADD_ASSOC_STRING(retval, "dec", outbuf);
#endif
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&buf, &retval, &var_hash TSRMLS_CC);
smart_str_0(&buf);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
PHONGO_RETVAL_SMART_STR(buf);
smart_str_free(&buf);
zval_ptr_dtor(&retval);
}
/* }}} */
/* {{{ proto string Decimal128::unserialize(string $serialized)
*/
PHP_METHOD(Decimal128, unserialize)
{
php_phongo_decimal128_t *intern;
zend_error_handling error_handling;
char *serialized;
phongo_zpp_char_len serialized_len;
#if PHP_VERSION_ID >= 70000
zval props;
#else
zval *props;
#endif
php_unserialize_data_t var_hash;
intern = Z_DECIMAL128_OBJ_P(getThis());
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized, &serialized_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
#if PHP_VERSION_ID < 70000
ALLOC_INIT_ZVAL(props);
#endif
PHP_VAR_UNSERIALIZE_INIT(var_hash);
if (!php_var_unserialize(&props, (const unsigned char**) &serialized, (unsigned char *) serialized + serialized_len, &var_hash TSRMLS_CC)) {
zval_ptr_dtor(&props);
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "%s unserialization failed", ZSTR_VAL(php_phongo_decimal128_ce->name));
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return;
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
#if PHP_VERSION_ID >= 70000
php_phongo_decimal128_init_from_hash(intern, HASH_OF(&props) TSRMLS_CC);
#else
php_phongo_decimal128_init_from_hash(intern, HASH_OF(props) TSRMLS_CC);
#endif
zval_ptr_dtor(&props);
}
/* }}} */
/* {{{ BSON\Decimal128 */
ZEND_BEGIN_ARG_INFO_EX(ai_Decimal128___construct, 0, 0, 1)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Decimal128___set_state, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, properties, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Decimal128_unserialize, 0, 0, 1)
ZEND_ARG_INFO(0, serialized)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Decimal128_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_decimal128_me[] = {
PHP_ME(Decimal128, __construct, ai_Decimal128___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Decimal128, __set_state, ai_Decimal128___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Decimal128, __toString, ai_Decimal128_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Decimal128, jsonSerialize, ai_Decimal128_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Decimal128, serialize, ai_Decimal128_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Decimal128, unserialize, ai_Decimal128_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_decimal128_t object handlers */
static void php_phongo_decimal128_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_decimal128_t *intern = Z_OBJ_DECIMAL128(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_decimal128_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_decimal128_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_decimal128_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_decimal128;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_decimal128_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_decimal128;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_decimal128_get_properties(zval *object TSRMLS_DC) /* {{{ */
{
php_phongo_decimal128_t *intern;
HashTable *props;
char outbuf[BSON_DECIMAL128_STRING] = "";
intern = Z_DECIMAL128_OBJ_P(object);
props = zend_std_get_properties(object TSRMLS_CC);
if (!intern->initialized) {
return props;
}
bson_decimal128_to_string(&intern->decimal, outbuf);
#if PHP_VERSION_ID >= 70000
{
zval dec;
ZVAL_STRING(&dec, outbuf);
zend_hash_str_update(props, "dec", sizeof("dec")-1, &dec);
}
#else
{
zval *dec;
MAKE_STD_ZVAL(dec);
ZVAL_STRING(dec, outbuf, 1);
zend_hash_update(props, "dec", sizeof("dec"), &dec, sizeof(dec), NULL);
}
#endif
return props;
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Decimal128)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Decimal128", php_phongo_decimal128_me);
php_phongo_decimal128_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_decimal128_ce->create_object = php_phongo_decimal128_create_object;
PHONGO_CE_FINAL(php_phongo_decimal128_ce);
- zend_class_implements(php_phongo_decimal128_ce TSRMLS_CC, 1, php_json_serializable_ce);
+ zend_class_implements(php_phongo_decimal128_ce TSRMLS_CC, 1, php_phongo_json_serializable_ce);
zend_class_implements(php_phongo_decimal128_ce TSRMLS_CC, 1, php_phongo_type_ce);
zend_class_implements(php_phongo_decimal128_ce TSRMLS_CC, 1, zend_ce_serializable);
memcpy(&php_phongo_handler_decimal128, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_decimal128.get_properties = php_phongo_decimal128_get_properties;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_decimal128.free_obj = php_phongo_decimal128_free_object;
php_phongo_handler_decimal128.offset = XtOffsetOf(php_phongo_decimal128_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/BSON/Javascript.c b/mongodb-1.2.3/src/BSON/Javascript.c
similarity index 90%
rename from mongodb-1.2.0/src/BSON/Javascript.c
rename to mongodb-1.2.3/src/BSON/Javascript.c
index fe4e283d..07a97145 100644
--- a/mongodb-1.2.0/src/BSON/Javascript.c
+++ b/mongodb-1.2.3/src/BSON/Javascript.c
@@ -1,567 +1,560 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
-#include <ext/json/php_json.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
#include <ext/standard/php_var.h>
#if PHP_VERSION_ID >= 70000
# include <zend_smart_str.h>
#else
# include <ext/standard/php_smart_str.h>
#endif
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_javascript_ce;
zend_object_handlers php_phongo_handler_javascript;
/* Initialize the object and return whether it was successful. An exception will
* be thrown on error. */
static bool php_phongo_javascript_init(php_phongo_javascript_t *intern, const char *code, phongo_zpp_char_len code_len, zval *scope TSRMLS_DC)
{
if (scope && Z_TYPE_P(scope) != IS_OBJECT && Z_TYPE_P(scope) != IS_ARRAY && Z_TYPE_P(scope) != IS_NULL) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected scope to be array or object, %s given", zend_get_type_by_const(Z_TYPE_P(scope)));
return false;
}
if (strlen(code) != code_len) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Code cannot contain null bytes");
return false;
}
intern->code = estrndup(code, code_len);
intern->code_len = code_len;
if (scope && (Z_TYPE_P(scope) == IS_OBJECT || Z_TYPE_P(scope) == IS_ARRAY)) {
intern->scope = bson_new();
phongo_zval_to_bson(scope, PHONGO_BSON_NONE, intern->scope, NULL TSRMLS_CC);
} else {
intern->scope = NULL;
}
return true;
}
/* Initialize the object from a HashTable and return whether it was successful.
* An exception will be thrown on error. */
static bool php_phongo_javascript_init_from_hash(php_phongo_javascript_t *intern, HashTable *props TSRMLS_DC)
{
#if PHP_VERSION_ID >= 70000
zval *code, *scope;
if ((code = zend_hash_str_find(props, "code", sizeof("code")-1)) && Z_TYPE_P(code) == IS_STRING) {
scope = zend_hash_str_find(props, "scope", sizeof("scope")-1);
return php_phongo_javascript_init(intern, Z_STRVAL_P(code), Z_STRLEN_P(code), scope TSRMLS_CC);
}
#else
zval **code, **scope;
if (zend_hash_find(props, "code", sizeof("code"), (void**) &code) == SUCCESS && Z_TYPE_PP(code) == IS_STRING) {
zval *tmp = zend_hash_find(props, "scope", sizeof("scope"), (void**) &scope) == SUCCESS ? *scope : NULL;
return php_phongo_javascript_init(intern, Z_STRVAL_PP(code), Z_STRLEN_PP(code), tmp TSRMLS_CC);
}
#endif
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "%s initialization requires \"code\" string field", ZSTR_VAL(php_phongo_javascript_ce->name));
return false;
}
/* {{{ proto void Javascript::__construct(string $code[, array|object $scope])
Construct a new BSON Javascript type. The scope is a document mapping
identifiers and values, representing the scope in which the code string will
be evaluated. Note that this type cannot be represented as Extended JSON. */
PHP_METHOD(Javascript, __construct)
{
php_phongo_javascript_t *intern;
zend_error_handling error_handling;
char *code;
phongo_zpp_char_len code_len;
zval *scope = NULL;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_JAVASCRIPT_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|A!", &code, &code_len, &scope) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
php_phongo_javascript_init(intern, code, code_len, scope TSRMLS_CC);
}
/* }}} */
/* {{{ proto void Javascript::__set_state(array $properties)
*/
PHP_METHOD(Javascript, __set_state)
{
php_phongo_javascript_t *intern;
HashTable *props;
zval *array;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
RETURN_FALSE;
}
object_init_ex(return_value, php_phongo_javascript_ce);
intern = Z_JAVASCRIPT_OBJ_P(return_value);
props = Z_ARRVAL_P(array);
php_phongo_javascript_init_from_hash(intern, props TSRMLS_CC);
}
/* }}} */
/* {{{ proto string Javascript::__toString()
Return the Javascript's code string. */
PHP_METHOD(Javascript, __toString)
{
php_phongo_javascript_t *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_JAVASCRIPT_OBJ_P(getThis());
PHONGO_RETURN_STRINGL(intern->code, intern->code_len);
}
/* }}} */
/* {{{ proto string Javascript::getCode()
*/
PHP_METHOD(Javascript, getCode)
{
php_phongo_javascript_t *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_JAVASCRIPT_OBJ_P(getThis());
PHONGO_RETURN_STRINGL(intern->code, intern->code_len);
}
/* }}} */
/* {{{ proto object|null Javascript::getScope()
*/
PHP_METHOD(Javascript, getScope)
{
php_phongo_javascript_t *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_JAVASCRIPT_OBJ_P(getThis());
if (!intern->scope) {
RETURN_NULL();
}
if (intern->scope->len) {
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
phongo_bson_to_zval_ex(bson_get_data(intern->scope), intern->scope->len, &state);
#if PHP_VERSION_ID >= 70000
RETURN_ZVAL(&state.zchild, 0, 1);
#else
RETURN_ZVAL(state.zchild, 0, 1);
#endif
} else {
RETURN_NULL();
}
}
/* }}} */
/* {{{ proto array Javascript::jsonSerialize()
*/
PHP_METHOD(Javascript, jsonSerialize)
{
php_phongo_javascript_t *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_JAVASCRIPT_OBJ_P(getThis());
array_init_size(return_value, 2);
ADD_ASSOC_STRINGL(return_value, "$code", intern->code, intern->code_len);
if (intern->scope && intern->scope->len) {
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
if (phongo_bson_to_zval_ex(bson_get_data(intern->scope), intern->scope->len, &state)) {
#if PHP_VERSION_ID >= 70000
Z_ADDREF(state.zchild);
ADD_ASSOC_ZVAL_EX(return_value, "$scope", &state.zchild);
#else
Z_ADDREF_P(state.zchild);
ADD_ASSOC_ZVAL_EX(return_value, "$scope", state.zchild);
#endif
}
zval_ptr_dtor(&state.zchild);
}
}
/* }}} */
/* {{{ proto string Javascript::serialize()
*/
PHP_METHOD(Javascript, serialize)
{
php_phongo_javascript_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval *retval;
#endif
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
php_serialize_data_t var_hash;
smart_str buf = { 0 };
intern = Z_JAVASCRIPT_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
#if PHP_VERSION_ID >= 70000
if (intern->scope && intern->scope->len) {
if (!phongo_bson_to_zval_ex(bson_get_data(intern->scope), intern->scope->len, &state)) {
return;
}
Z_ADDREF(state.zchild);
} else {
ZVAL_NULL(&state.zchild);
}
#else
if (intern->scope && intern->scope->len) {
if (!phongo_bson_to_zval_ex(bson_get_data(intern->scope), intern->scope->len, &state)) {
return;
}
Z_ADDREF_P(state.zchild);
} else {
MAKE_STD_ZVAL(state.zchild);
ZVAL_NULL(state.zchild);
Z_ADDREF_P(state.zchild);
}
#endif
#if PHP_VERSION_ID >= 70000
array_init_size(&retval, 2);
ADD_ASSOC_STRINGL(&retval, "code", intern->code, intern->code_len);
ADD_ASSOC_ZVAL(&retval, "scope", &state.zchild);
#else
ALLOC_INIT_ZVAL(retval);
array_init_size(retval, 2);
ADD_ASSOC_STRINGL(retval, "code", intern->code, intern->code_len);
ADD_ASSOC_ZVAL(retval, "scope", state.zchild);
#endif
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&buf, &retval, &var_hash TSRMLS_CC);
smart_str_0(&buf);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
PHONGO_RETVAL_SMART_STR(buf);
smart_str_free(&buf);
zval_ptr_dtor(&retval);
zval_ptr_dtor(&state.zchild);
}
/* }}} */
/* {{{ proto string Javascript::unserialize(string $serialized)
*/
PHP_METHOD(Javascript, unserialize)
{
php_phongo_javascript_t *intern;
zend_error_handling error_handling;
char *serialized;
phongo_zpp_char_len serialized_len;
#if PHP_VERSION_ID >= 70000
zval props;
#else
zval *props;
#endif
php_unserialize_data_t var_hash;
intern = Z_JAVASCRIPT_OBJ_P(getThis());
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized, &serialized_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
#if PHP_VERSION_ID < 70000
ALLOC_INIT_ZVAL(props);
#endif
PHP_VAR_UNSERIALIZE_INIT(var_hash);
if (!php_var_unserialize(&props, (const unsigned char**) &serialized, (unsigned char *) serialized + serialized_len, &var_hash TSRMLS_CC)) {
zval_ptr_dtor(&props);
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "%s unserialization failed", ZSTR_VAL(php_phongo_javascript_ce->name));
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return;
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
#if PHP_VERSION_ID >= 70000
php_phongo_javascript_init_from_hash(intern, HASH_OF(&props) TSRMLS_CC);
#else
php_phongo_javascript_init_from_hash(intern, HASH_OF(props) TSRMLS_CC);
#endif
zval_ptr_dtor(&props);
}
/* }}} */
/* {{{ BSON\Javascript */
ZEND_BEGIN_ARG_INFO_EX(ai_Javascript___construct, 0, 0, 1)
ZEND_ARG_INFO(0, javascript)
ZEND_ARG_INFO(0, scope)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Javascript___set_state, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, properties, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Javascript_unserialize, 0, 0, 1)
ZEND_ARG_INFO(0, serialized)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Javascript_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_javascript_me[] = {
PHP_ME(Javascript, __construct, ai_Javascript___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Javascript, __set_state, ai_Javascript___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Javascript, __toString, ai_Javascript_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Javascript, jsonSerialize, ai_Javascript_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Javascript, serialize, ai_Javascript_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Javascript, unserialize, ai_Javascript_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Javascript, getCode, ai_Javascript_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Javascript, getScope, ai_Javascript_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_javascript_t object handlers */
static void php_phongo_javascript_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_javascript_t *intern = Z_OBJ_JAVASCRIPT(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->code) {
efree(intern->code);
}
if (intern->scope) {
bson_destroy(intern->scope);
intern->scope = NULL;
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_javascript_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_javascript_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_javascript_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_javascript;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_javascript_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_javascript;
return retval;
}
#endif
} /* }}} */
static int php_phongo_javascript_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
{
php_phongo_javascript_t *intern1, *intern2;
intern1 = Z_JAVASCRIPT_OBJ_P(o1);
intern2 = Z_JAVASCRIPT_OBJ_P(o2);
/* Do not consider the scope document for comparisons */
return strcmp(intern1->code, intern2->code);
} /* }}} */
HashTable *php_phongo_javascript_get_properties(zval *object TSRMLS_DC) /* {{{ */
{
php_phongo_javascript_t *intern;
HashTable *props;
intern = Z_JAVASCRIPT_OBJ_P(object);
props = zend_std_get_properties(object TSRMLS_CC);
if (!intern->code) {
return props;
}
#if PHP_VERSION_ID >= 70000
{
zval code;
ZVAL_STRING(&code, intern->code);
zend_hash_str_update(props, "code", sizeof("code")-1, &code);
if (intern->scope) {
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
if (phongo_bson_to_zval_ex(bson_get_data(intern->scope), intern->scope->len, &state)) {
Z_ADDREF(state.zchild);
zend_hash_str_update(props, "scope", sizeof("scope")-1, &state.zchild);
} else {
zval scope;
ZVAL_NULL(&scope);
zend_hash_str_update(props, "scope", sizeof("scope")-1, &scope);
}
zval_ptr_dtor(&state.zchild);
} else {
zval scope;
ZVAL_NULL(&scope);
zend_hash_str_update(props, "scope", sizeof("scope")-1, &scope);
}
}
#else
{
zval *code;
MAKE_STD_ZVAL(code);
ZVAL_STRING(code, intern->code, 1);
zend_hash_update(props, "code", sizeof("code"), &code, sizeof(code), NULL);
if (intern->scope) {
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
if (phongo_bson_to_zval_ex(bson_get_data(intern->scope), intern->scope->len, &state)) {
Z_ADDREF_P(state.zchild);
zend_hash_update(props, "scope", sizeof("scope"), &state.zchild, sizeof(state.zchild), NULL);
} else {
zval *scope;
MAKE_STD_ZVAL(scope);
ZVAL_NULL(scope);
zend_hash_update(props, "scope", sizeof("scope"), &scope, sizeof(scope), NULL);
}
zval_ptr_dtor(&state.zchild);
} else {
zval *scope;
MAKE_STD_ZVAL(scope);
ZVAL_NULL(scope);
zend_hash_update(props, "scope", sizeof("scope"), &scope, sizeof(scope), NULL);
}
}
#endif
return props;
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Javascript)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Javascript", php_phongo_javascript_me);
php_phongo_javascript_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_javascript_ce->create_object = php_phongo_javascript_create_object;
PHONGO_CE_FINAL(php_phongo_javascript_ce);
- zend_class_implements(php_phongo_javascript_ce TSRMLS_CC, 1, php_json_serializable_ce);
+ zend_class_implements(php_phongo_javascript_ce TSRMLS_CC, 1, php_phongo_json_serializable_ce);
zend_class_implements(php_phongo_javascript_ce TSRMLS_CC, 1, php_phongo_type_ce);
zend_class_implements(php_phongo_javascript_ce TSRMLS_CC, 1, zend_ce_serializable);
memcpy(&php_phongo_handler_javascript, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_javascript.compare_objects = php_phongo_javascript_compare_objects;
php_phongo_handler_javascript.get_properties = php_phongo_javascript_get_properties;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_javascript.free_obj = php_phongo_javascript_free_object;
php_phongo_handler_javascript.offset = XtOffsetOf(php_phongo_javascript_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/BSON/MaxKey.c b/mongodb-1.2.3/src/BSON/MaxKey.c
similarity index 73%
rename from mongodb-1.2.0/src/BSON/MaxKey.c
rename to mongodb-1.2.3/src/BSON/MaxKey.c
index ac2717b4..7a182914 100644
--- a/mongodb-1.2.0/src/BSON/MaxKey.c
+++ b/mongodb-1.2.3/src/BSON/MaxKey.c
@@ -1,198 +1,191 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
-#include <ext/json/php_json.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_maxkey_ce;
zend_object_handlers php_phongo_handler_maxkey;
/* {{{ proto MaxKey::__set_state(array $properties)
*/
PHP_METHOD(MaxKey, __set_state)
{
zval *array;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
RETURN_FALSE;
}
object_init_ex(return_value, php_phongo_maxkey_ce);
}
/* }}} */
/* {{{ proto array MaxKey::jsonSerialize()
*/
PHP_METHOD(MaxKey, jsonSerialize)
{
if (zend_parse_parameters_none() == FAILURE) {
return;
}
array_init_size(return_value, 1);
ADD_ASSOC_LONG_EX(return_value, "$maxKey", 1);
}
/* }}} */
/* {{{ proto string MaxKey::serialize()
*/
PHP_METHOD(MaxKey, serialize)
{
PHONGO_RETURN_STRING("");
}
/* }}} */
/* {{{ proto string MaxKey::unserialize(string $serialized)
*/
PHP_METHOD(MaxKey, unserialize)
{
zend_error_handling error_handling;
char *serialized;
phongo_zpp_char_len serialized_len;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized, &serialized_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
}
/* }}} */
/* {{{ BSON\MaxKey */
ZEND_BEGIN_ARG_INFO_EX(ai_MaxKey___set_state, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, properties, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_MaxKey_unserialize, 0, 0, 1)
ZEND_ARG_INFO(0, serialized)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_MaxKey_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_maxkey_me[] = {
PHP_ME(MaxKey, __set_state, ai_MaxKey___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(MaxKey, jsonSerialize, ai_MaxKey_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(MaxKey, serialize, ai_MaxKey_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(MaxKey, unserialize, ai_MaxKey_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_maxkey_t object handlers */
static void php_phongo_maxkey_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_maxkey_t *intern = Z_OBJ_MAXKEY(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_maxkey_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_maxkey_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_maxkey_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_maxkey;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_maxkey_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_maxkey;
return retval;
}
#endif
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(MaxKey)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "MaxKey", php_phongo_maxkey_me);
php_phongo_maxkey_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_maxkey_ce->create_object = php_phongo_maxkey_create_object;
PHONGO_CE_FINAL(php_phongo_maxkey_ce);
- zend_class_implements(php_phongo_maxkey_ce TSRMLS_CC, 1, php_json_serializable_ce);
+ zend_class_implements(php_phongo_maxkey_ce TSRMLS_CC, 1, php_phongo_json_serializable_ce);
zend_class_implements(php_phongo_maxkey_ce TSRMLS_CC, 1, php_phongo_type_ce);
zend_class_implements(php_phongo_maxkey_ce TSRMLS_CC, 1, zend_ce_serializable);
memcpy(&php_phongo_handler_maxkey, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
#if PHP_VERSION_ID >= 70000
php_phongo_handler_maxkey.free_obj = php_phongo_maxkey_free_object;
php_phongo_handler_maxkey.offset = XtOffsetOf(php_phongo_maxkey_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/BSON/MinKey.c b/mongodb-1.2.3/src/BSON/MinKey.c
similarity index 73%
rename from mongodb-1.2.0/src/BSON/MinKey.c
rename to mongodb-1.2.3/src/BSON/MinKey.c
index 4360c0bd..bf27e219 100644
--- a/mongodb-1.2.0/src/BSON/MinKey.c
+++ b/mongodb-1.2.3/src/BSON/MinKey.c
@@ -1,199 +1,192 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
-#include <ext/json/php_json.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_minkey_ce;
zend_object_handlers php_phongo_handler_minkey;
/* {{{ proto MinKey::__set_state(array $properties)
*/
PHP_METHOD(MinKey, __set_state)
{
zval *array;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
RETURN_FALSE;
}
object_init_ex(return_value, php_phongo_minkey_ce);
}
/* }}} */
/* {{{ proto array MinKey::jsonSerialize()
*/
PHP_METHOD(MinKey, jsonSerialize)
{
if (zend_parse_parameters_none() == FAILURE) {
return;
}
array_init_size(return_value, 1);
ADD_ASSOC_LONG_EX(return_value, "$minKey", 1);
}
/* }}} */
/* {{{ proto string MinKey::serialize()
*/
PHP_METHOD(MinKey, serialize)
{
PHONGO_RETURN_STRING("");
}
/* }}} */
/* {{{ proto string MinKey::unserialize(string $serialized)
*/
PHP_METHOD(MinKey, unserialize)
{
zend_error_handling error_handling;
char *serialized;
phongo_zpp_char_len serialized_len;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized, &serialized_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
}
/* }}} */
/* {{{ BSON\MinKey */
ZEND_BEGIN_ARG_INFO_EX(ai_MinKey___set_state, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, properties, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_MinKey_unserialize, 0, 0, 1)
ZEND_ARG_INFO(0, serialized)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_MinKey_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_minkey_me[] = {
PHP_ME(MinKey, __set_state, ai_MinKey___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(MinKey, jsonSerialize, ai_MinKey_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(MinKey, serialize, ai_MinKey_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(MinKey, unserialize, ai_MinKey_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_minkey_t object handlers */
static void php_phongo_minkey_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_minkey_t *intern = Z_OBJ_MINKEY(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_minkey_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_minkey_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_minkey_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_minkey;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_minkey_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_minkey;
return retval;
}
#endif
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(MinKey)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "MinKey", php_phongo_minkey_me);
php_phongo_minkey_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_minkey_ce->create_object = php_phongo_minkey_create_object;
PHONGO_CE_FINAL(php_phongo_minkey_ce);
- zend_class_implements(php_phongo_minkey_ce TSRMLS_CC, 1, php_json_serializable_ce);
+ zend_class_implements(php_phongo_minkey_ce TSRMLS_CC, 1, php_phongo_json_serializable_ce);
zend_class_implements(php_phongo_minkey_ce TSRMLS_CC, 1, php_phongo_type_ce);
zend_class_implements(php_phongo_minkey_ce TSRMLS_CC, 1, zend_ce_serializable);
memcpy(&php_phongo_handler_minkey, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
#if PHP_VERSION_ID >= 70000
php_phongo_handler_minkey.free_obj = php_phongo_minkey_free_object;
php_phongo_handler_minkey.offset = XtOffsetOf(php_phongo_minkey_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/BSON/ObjectID.c b/mongodb-1.2.3/src/BSON/ObjectID.c
similarity index 87%
rename from mongodb-1.2.0/src/BSON/ObjectID.c
rename to mongodb-1.2.3/src/BSON/ObjectID.c
index 0c9841e3..a79af9d5 100644
--- a/mongodb-1.2.0/src/BSON/ObjectID.c
+++ b/mongodb-1.2.3/src/BSON/ObjectID.c
@@ -1,452 +1,445 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
-#include <ext/json/php_json.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
#include <ext/standard/php_var.h>
#if PHP_VERSION_ID >= 70000
# include <zend_smart_str.h>
#else
# include <ext/standard/php_smart_str.h>
#endif
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_objectid_ce;
zend_object_handlers php_phongo_handler_objectid;
/* Initialize the object with a generated value and return whether it was
* successful. */
static bool php_phongo_objectid_init(php_phongo_objectid_t *intern)
{
bson_oid_t oid;
intern->initialized = true;
bson_oid_init(&oid, NULL);
bson_oid_to_string(&oid, intern->oid);
return true;
}
/* Initialize the object from a hex string and return whether it was successful.
* An exception will be thrown on error. */
static bool php_phongo_objectid_init_from_hex_string(php_phongo_objectid_t *intern, const char *oid, phongo_zpp_char_len oid_len TSRMLS_DC)
{
char *tid = zend_str_tolower_dup(oid, oid_len);
if (bson_oid_is_valid(tid, oid_len)) {
bson_oid_t oid;
bson_oid_init_from_string(&oid, tid);
bson_oid_to_string(&oid, intern->oid);
intern->initialized = true;
efree(tid);
return true;
}
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error parsing ObjectID string: %s", oid);
efree(tid);
return false;
}
/* Initialize the object from a HashTable and return whether it was successful.
* An exception will be thrown on error. */
static bool php_phongo_objectid_init_from_hash(php_phongo_objectid_t *intern, HashTable *props TSRMLS_DC)
{
#if PHP_VERSION_ID >= 70000
zval *z_oid;
z_oid = zend_hash_str_find(props, "oid", sizeof("oid")-1);
if (z_oid && Z_TYPE_P(z_oid) == IS_STRING) {
return php_phongo_objectid_init_from_hex_string(intern, Z_STRVAL_P(z_oid), Z_STRLEN_P(z_oid) TSRMLS_CC);
}
#else
zval **z_oid;
if (zend_hash_find(props, "oid", sizeof("oid"), (void**) &z_oid) == SUCCESS && Z_TYPE_PP(z_oid) == IS_STRING) {
return php_phongo_objectid_init_from_hex_string(intern, Z_STRVAL_PP(z_oid), Z_STRLEN_PP(z_oid) TSRMLS_CC);
}
#endif
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "%s initialization requires \"oid\" string field", ZSTR_VAL(php_phongo_objectid_ce->name));
return false;
}
/* {{{ proto void ObjectID::__construct([string $id])
Constructs a new BSON ObjectID type, optionally from a hex string. */
PHP_METHOD(ObjectID, __construct)
{
php_phongo_objectid_t *intern;
zend_error_handling error_handling;
char *id = NULL;
phongo_zpp_char_len id_len;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_OBJECTID_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &id, &id_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
if (id) {
php_phongo_objectid_init_from_hex_string(intern, id, id_len TSRMLS_CC);
} else {
php_phongo_objectid_init(intern);
}
}
/* }}} */
/* {{{ proto integer ObjectID::getTimestamp()
*/
PHP_METHOD(ObjectID, getTimestamp)
{
php_phongo_objectid_t *intern;
bson_oid_t tmp_oid;
intern = Z_OBJECTID_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
bson_oid_init_from_string(&tmp_oid, intern->oid);
RETVAL_LONG(bson_oid_get_time_t(&tmp_oid));
}
/* }}} */
/* {{{ proto ObjectID::__set_state(array $properties)
*/
PHP_METHOD(ObjectID, __set_state)
{
php_phongo_objectid_t *intern;
HashTable *props;
zval *array;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
RETURN_FALSE;
}
object_init_ex(return_value, php_phongo_objectid_ce);
intern = Z_OBJECTID_OBJ_P(return_value);
props = Z_ARRVAL_P(array);
php_phongo_objectid_init_from_hash(intern, props TSRMLS_CC);
}
/* }}} */
/* {{{ proto string ObjectID::__toString()
*/
PHP_METHOD(ObjectID, __toString)
{
php_phongo_objectid_t *intern;
intern = Z_OBJECTID_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
PHONGO_RETURN_STRINGL(intern->oid, 24);
}
/* }}} */
/* {{{ proto array ObjectID::jsonSerialize()
*/
PHP_METHOD(ObjectID, jsonSerialize)
{
php_phongo_objectid_t *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_OBJECTID_OBJ_P(getThis());
array_init_size(return_value, 1);
ADD_ASSOC_STRINGL(return_value, "$oid", intern->oid, 24);
}
/* }}} */
/* {{{ proto string ObjectID::serialize()
*/
PHP_METHOD(ObjectID, serialize)
{
php_phongo_objectid_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval *retval;
#endif
php_serialize_data_t var_hash;
smart_str buf = { 0 };
intern = Z_OBJECTID_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
#if PHP_VERSION_ID >= 70000
array_init_size(&retval, 2);
ADD_ASSOC_STRINGL(&retval, "oid", intern->oid, 24);
#else
ALLOC_INIT_ZVAL(retval);
array_init_size(retval, 2);
ADD_ASSOC_STRINGL(retval, "oid", intern->oid, 24);
#endif
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&buf, &retval, &var_hash TSRMLS_CC);
smart_str_0(&buf);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
PHONGO_RETVAL_SMART_STR(buf);
smart_str_free(&buf);
zval_ptr_dtor(&retval);
}
/* }}} */
/* {{{ proto string ObjectID::unserialize(string $serialized)
*/
PHP_METHOD(ObjectID, unserialize)
{
php_phongo_objectid_t *intern;
zend_error_handling error_handling;
char *serialized;
phongo_zpp_char_len serialized_len;
#if PHP_VERSION_ID >= 70000
zval props;
#else
zval *props;
#endif
php_unserialize_data_t var_hash;
intern = Z_OBJECTID_OBJ_P(getThis());
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized, &serialized_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
#if PHP_VERSION_ID < 70000
ALLOC_INIT_ZVAL(props);
#endif
PHP_VAR_UNSERIALIZE_INIT(var_hash);
if (!php_var_unserialize(&props, (const unsigned char**) &serialized, (unsigned char *) serialized + serialized_len, &var_hash TSRMLS_CC)) {
zval_ptr_dtor(&props);
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "%s unserialization failed", ZSTR_VAL(php_phongo_objectid_ce->name));
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return;
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
#if PHP_VERSION_ID >= 70000
php_phongo_objectid_init_from_hash(intern, HASH_OF(&props) TSRMLS_CC);
#else
php_phongo_objectid_init_from_hash(intern, HASH_OF(props) TSRMLS_CC);
#endif
zval_ptr_dtor(&props);
}
/* }}} */
/* {{{ BSON\ObjectID */
ZEND_BEGIN_ARG_INFO_EX(ai_ObjectID___construct, 0, 0, 0)
ZEND_ARG_INFO(0, id)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_ObjectID___set_state, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, properties, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_ObjectID_unserialize, 0, 0, 1)
ZEND_ARG_INFO(0, serialized)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_ObjectID_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_objectid_me[] = {
PHP_ME(ObjectID, __construct, ai_ObjectID___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ObjectID, getTimestamp, ai_ObjectID_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ObjectID, __set_state, ai_ObjectID___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(ObjectID, __toString, ai_ObjectID_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ObjectID, jsonSerialize, ai_ObjectID_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ObjectID, serialize, ai_ObjectID_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ObjectID, unserialize, ai_ObjectID_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_objectid_t object handlers */
static void php_phongo_objectid_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_objectid_t *intern = Z_OBJ_OBJECTID(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_objectid_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_objectid_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_objectid_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_objectid;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_objectid_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_objectid;
return retval;
}
#endif
} /* }}} */
static int php_phongo_objectid_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
{
php_phongo_objectid_t *intern1;
php_phongo_objectid_t *intern2;
intern1 = Z_OBJECTID_OBJ_P(o1);
intern2 = Z_OBJECTID_OBJ_P(o2);
return strcmp(intern1->oid, intern2->oid);
} /* }}} */
HashTable *php_phongo_objectid_get_properties(zval *object TSRMLS_DC) /* {{{ */
{
php_phongo_objectid_t *intern;
HashTable *props;
intern = Z_OBJECTID_OBJ_P(object);
props = zend_std_get_properties(object TSRMLS_CC);
if (!intern->oid) {
return props;
}
#if PHP_VERSION_ID >= 70000
{
zval zv;
ZVAL_STRING(&zv, intern->oid);
zend_hash_str_update(props, "oid", sizeof("oid")-1, &zv);
}
#else
{
zval *zv;
MAKE_STD_ZVAL(zv);
ZVAL_STRING(zv, intern->oid, 1);
zend_hash_update(props, "oid", sizeof("oid"), &zv, sizeof(zv), NULL);
}
#endif
return props;
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(ObjectID)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "ObjectID", php_phongo_objectid_me);
php_phongo_objectid_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_objectid_ce->create_object = php_phongo_objectid_create_object;
PHONGO_CE_FINAL(php_phongo_objectid_ce);
- zend_class_implements(php_phongo_objectid_ce TSRMLS_CC, 1, php_json_serializable_ce);
+ zend_class_implements(php_phongo_objectid_ce TSRMLS_CC, 1, php_phongo_json_serializable_ce);
zend_class_implements(php_phongo_objectid_ce TSRMLS_CC, 1, php_phongo_type_ce);
zend_class_implements(php_phongo_objectid_ce TSRMLS_CC, 1, zend_ce_serializable);
memcpy(&php_phongo_handler_objectid, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_objectid.compare_objects = php_phongo_objectid_compare_objects;
php_phongo_handler_objectid.get_properties = php_phongo_objectid_get_properties;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_objectid.free_obj = php_phongo_objectid_free_object;
php_phongo_handler_objectid.offset = XtOffsetOf(php_phongo_objectid_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.3/src/BSON/Persistable.c b/mongodb-1.2.3/src/BSON/Persistable.c
new file mode 100644
index 00000000..89f20fcf
--- /dev/null
+++ b/mongodb-1.2.3/src/BSON/Persistable.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+
+
+PHONGO_API zend_class_entry *php_phongo_persistable_ce;
+
+
+
+/* {{{ BSON\Persistable */
+
+
+static zend_function_entry php_phongo_persistable_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(Persistable)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Persistable", php_phongo_persistable_me);
+ php_phongo_persistable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
+ zend_class_implements(php_phongo_persistable_ce TSRMLS_CC, 2, php_phongo_unserializable_ce, php_phongo_serializable_ce);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.0/src/BSON/Regex.c b/mongodb-1.2.3/src/BSON/Regex.c
similarity index 89%
rename from mongodb-1.2.0/src/BSON/Regex.c
rename to mongodb-1.2.3/src/BSON/Regex.c
index 6c0c306f..0a64c666 100644
--- a/mongodb-1.2.0/src/BSON/Regex.c
+++ b/mongodb-1.2.3/src/BSON/Regex.c
@@ -1,499 +1,492 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
-#include <ext/json/php_json.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
#include <ext/standard/php_var.h>
#if PHP_VERSION_ID >= 70000
# include <zend_smart_str.h>
#else
# include <ext/standard/php_smart_str.h>
#endif
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_regex_ce;
zend_object_handlers php_phongo_handler_regex;
/* qsort() compare callback for alphabetizing regex flags upon initialization */
static int php_phongo_regex_compare_flags(const void *f1, const void *f2) {
if (* (const char *) f1 == * (const char *) f2) {
return 0;
}
return (* (const char *) f1 > * (const char *) f2) ? 1 : -1;
}
/* Initialize the object and return whether it was successful. An exception will
* be thrown on error. */
static bool php_phongo_regex_init(php_phongo_regex_t *intern, const char *pattern, phongo_zpp_char_len pattern_len, const char *flags, phongo_zpp_char_len flags_len TSRMLS_DC)
{
if (strlen(pattern) != pattern_len) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Pattern cannot contain null bytes");
return false;
}
intern->pattern = estrndup(pattern, pattern_len);
intern->pattern_len = pattern_len;
if (flags) {
if (strlen(flags) != flags_len) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Flags cannot contain null bytes");
return false;
}
intern->flags = estrndup(flags, flags_len);
intern->flags_len = flags_len;
/* Ensure flags are alphabetized upon initialization */
qsort((void *) intern->flags, flags_len, 1, php_phongo_regex_compare_flags);
} else {
intern->flags = estrdup("");
intern->flags_len = 0;
}
return true;
}
/* Initialize the object from a HashTable and return whether it was successful.
* An exception will be thrown on error. */
static bool php_phongo_regex_init_from_hash(php_phongo_regex_t *intern, HashTable *props TSRMLS_DC)
{
#if PHP_VERSION_ID >= 70000
zval *pattern, *flags;
if ((pattern = zend_hash_str_find(props, "pattern", sizeof("pattern")-1)) && Z_TYPE_P(pattern) == IS_STRING &&
(flags = zend_hash_str_find(props, "flags", sizeof("flags")-1)) && Z_TYPE_P(flags) == IS_STRING) {
return php_phongo_regex_init(intern, Z_STRVAL_P(pattern), Z_STRLEN_P(pattern), Z_STRVAL_P(flags), Z_STRLEN_P(flags) TSRMLS_CC);
}
#else
zval **pattern, **flags;
if (zend_hash_find(props, "pattern", sizeof("pattern"), (void**) &pattern) == SUCCESS && Z_TYPE_PP(pattern) == IS_STRING &&
zend_hash_find(props, "flags", sizeof("flags"), (void**) &flags) == SUCCESS && Z_TYPE_PP(flags) == IS_STRING) {
return php_phongo_regex_init(intern, Z_STRVAL_PP(pattern), Z_STRLEN_PP(pattern), Z_STRVAL_PP(flags), Z_STRLEN_PP(flags) TSRMLS_CC);
}
#endif
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "%s initialization requires \"pattern\" and \"flags\" string fields", ZSTR_VAL(php_phongo_regex_ce->name));
return false;
}
/* {{{ proto void Regex::__construct(string $pattern [, string $flags])
Constructs a new BSON regular expression type. */
PHP_METHOD(Regex, __construct)
{
php_phongo_regex_t *intern;
zend_error_handling error_handling;
char *pattern;
phongo_zpp_char_len pattern_len;
char *flags = NULL;
phongo_zpp_char_len flags_len = 0;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_REGEX_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &pattern, &pattern_len, &flags, &flags_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
php_phongo_regex_init(intern, pattern, pattern_len, flags, flags_len TSRMLS_CC);
}
/* }}} */
/* {{{ proto string Regex::getPattern()
*/
PHP_METHOD(Regex, getPattern)
{
php_phongo_regex_t *intern;
intern = Z_REGEX_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
PHONGO_RETURN_STRINGL(intern->pattern, intern->pattern_len);
}
/* }}} */
/* {{{ proto string Regex::getFlags()
*/
PHP_METHOD(Regex, getFlags)
{
php_phongo_regex_t *intern;
intern = Z_REGEX_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
PHONGO_RETURN_STRINGL(intern->flags, intern->flags_len);
}
/* }}} */
/* {{{ proto void Regex::__set_state(array $properties)
*/
PHP_METHOD(Regex, __set_state)
{
php_phongo_regex_t *intern;
HashTable *props;
zval *array;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
RETURN_FALSE;
}
object_init_ex(return_value, php_phongo_regex_ce);
intern = Z_REGEX_OBJ_P(return_value);
props = Z_ARRVAL_P(array);
php_phongo_regex_init_from_hash(intern, props TSRMLS_CC);
}
/* }}} */
/* {{{ proto string Regex::__toString()
Returns a string in the form: /pattern/flags */
PHP_METHOD(Regex, __toString)
{
php_phongo_regex_t *intern;
char *regex;
int regex_len;
intern = Z_REGEX_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
regex_len = spprintf(&regex, 0, "/%s/%s", intern->pattern, intern->flags);
PHONGO_RETVAL_STRINGL(regex, regex_len);
efree(regex);
}
/* }}} */
/* {{{ proto array Regex::jsonSerialize()
*/
PHP_METHOD(Regex, jsonSerialize)
{
php_phongo_regex_t *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_REGEX_OBJ_P(getThis());
array_init_size(return_value, 2);
ADD_ASSOC_STRINGL(return_value, "$regex", intern->pattern, intern->pattern_len);
ADD_ASSOC_STRINGL(return_value, "$options", intern->flags, intern->flags_len);
}
/* }}} */
/* {{{ proto string Regex::serialize()
*/
PHP_METHOD(Regex, serialize)
{
php_phongo_regex_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval *retval;
#endif
php_serialize_data_t var_hash;
smart_str buf = { 0 };
intern = Z_REGEX_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
#if PHP_VERSION_ID >= 70000
array_init_size(&retval, 2);
ADD_ASSOC_STRINGL(&retval, "pattern", intern->pattern, intern->pattern_len);
ADD_ASSOC_STRINGL(&retval, "flags", intern->flags, intern->flags_len);
#else
ALLOC_INIT_ZVAL(retval);
array_init_size(retval, 2);
ADD_ASSOC_STRINGL(retval, "pattern", intern->pattern, intern->pattern_len);
ADD_ASSOC_STRINGL(retval, "flags", intern->flags, intern->flags_len);
#endif
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&buf, &retval, &var_hash TSRMLS_CC);
smart_str_0(&buf);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
PHONGO_RETVAL_SMART_STR(buf);
smart_str_free(&buf);
zval_ptr_dtor(&retval);
}
/* }}} */
/* {{{ proto string Regex::unserialize(string $serialized)
*/
PHP_METHOD(Regex, unserialize)
{
php_phongo_regex_t *intern;
zend_error_handling error_handling;
char *serialized;
phongo_zpp_char_len serialized_len;
#if PHP_VERSION_ID >= 70000
zval props;
#else
zval *props;
#endif
php_unserialize_data_t var_hash;
intern = Z_REGEX_OBJ_P(getThis());
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized, &serialized_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
#if PHP_VERSION_ID < 70000
ALLOC_INIT_ZVAL(props);
#endif
PHP_VAR_UNSERIALIZE_INIT(var_hash);
if (!php_var_unserialize(&props, (const unsigned char**) &serialized, (unsigned char *) serialized + serialized_len, &var_hash TSRMLS_CC)) {
zval_ptr_dtor(&props);
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "%s unserialization failed", ZSTR_VAL(php_phongo_regex_ce->name));
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return;
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
#if PHP_VERSION_ID >= 70000
php_phongo_regex_init_from_hash(intern, HASH_OF(&props) TSRMLS_CC);
#else
php_phongo_regex_init_from_hash(intern, HASH_OF(props) TSRMLS_CC);
#endif
zval_ptr_dtor(&props);
}
/* }}} */
/* {{{ BSON\Regex */
ZEND_BEGIN_ARG_INFO_EX(ai_Regex___construct, 0, 0, 2)
ZEND_ARG_INFO(0, pattern)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Regex___set_state, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, properties, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Regex_unserialize, 0, 0, 1)
ZEND_ARG_INFO(0, serialized)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Regex_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_regex_me[] = {
PHP_ME(Regex, __construct, ai_Regex___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Regex, __set_state, ai_Regex___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Regex, __toString, ai_Regex_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Regex, jsonSerialize, ai_Regex_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Regex, serialize, ai_Regex_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Regex, unserialize, ai_Regex_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Regex, getPattern, ai_Regex_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Regex, getFlags, ai_Regex_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_regex_t object handlers */
static void php_phongo_regex_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_regex_t *intern = Z_OBJ_REGEX(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->pattern) {
efree(intern->pattern);
}
if (intern->flags) {
efree(intern->flags);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_regex_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_regex_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_regex_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_regex;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_regex_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_regex;
return retval;
}
#endif
} /* }}} */
static int php_phongo_regex_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
{
php_phongo_regex_t *intern1, *intern2;
int retval;
intern1 = Z_REGEX_OBJ_P(o1);
intern2 = Z_REGEX_OBJ_P(o2);
/* MongoDB compares the pattern string before the flags. */
retval = strcmp(intern1->pattern, intern2->pattern);
if (retval != 0) {
return retval;
}
return strcmp(intern1->flags, intern2->flags);
} /* }}} */
HashTable *php_phongo_regex_get_properties(zval *object TSRMLS_DC) /* {{{ */
{
php_phongo_regex_t *intern;
HashTable *props;
intern = Z_REGEX_OBJ_P(object);
props = zend_std_get_properties(object TSRMLS_CC);
if (!intern->pattern) {
return props;
}
#if PHP_VERSION_ID >= 70000
{
zval pattern, flags;
ZVAL_STRINGL(&pattern, intern->pattern, intern->pattern_len);
zend_hash_str_update(props, "pattern", sizeof("pattern")-1, &pattern);
ZVAL_STRINGL(&flags, intern->flags, intern->flags_len);
zend_hash_str_update(props, "flags", sizeof("flags")-1, &flags);
}
#else
{
zval *pattern, *flags;
MAKE_STD_ZVAL(pattern);
ZVAL_STRINGL(pattern, intern->pattern, intern->pattern_len, 1);
zend_hash_update(props, "pattern", sizeof("pattern"), &pattern, sizeof(pattern), NULL);
MAKE_STD_ZVAL(flags);
ZVAL_STRINGL(flags, intern->flags, intern->flags_len, 1);
zend_hash_update(props, "flags", sizeof("flags"), &flags, sizeof(flags), NULL);
}
#endif
return props;
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Regex)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Regex", php_phongo_regex_me);
php_phongo_regex_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_regex_ce->create_object = php_phongo_regex_create_object;
PHONGO_CE_FINAL(php_phongo_regex_ce);
zend_class_implements(php_phongo_regex_ce TSRMLS_CC, 1, php_phongo_type_ce);
zend_class_implements(php_phongo_regex_ce TSRMLS_CC, 1, zend_ce_serializable);
- zend_class_implements(php_phongo_regex_ce TSRMLS_CC, 1, php_json_serializable_ce);
+ zend_class_implements(php_phongo_regex_ce TSRMLS_CC, 1, php_phongo_json_serializable_ce);
memcpy(&php_phongo_handler_regex, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_regex.compare_objects = php_phongo_regex_compare_objects;
php_phongo_handler_regex.get_properties = php_phongo_regex_get_properties;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_regex.free_obj = php_phongo_regex_free_object;
php_phongo_handler_regex.offset = XtOffsetOf(php_phongo_regex_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.3/src/BSON/Serializable.c b/mongodb-1.2.3/src/BSON/Serializable.c
new file mode 100644
index 00000000..cc2f9e60
--- /dev/null
+++ b/mongodb-1.2.3/src/BSON/Serializable.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+
+
+PHONGO_API zend_class_entry *php_phongo_serializable_ce;
+
+
+
+/* {{{ BSON\Serializable */
+
+ZEND_BEGIN_ARG_INFO_EX(ai_Serializable_void, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+static zend_function_entry php_phongo_serializable_me[] = {
+ ZEND_ABSTRACT_ME(Serializable, bsonSerialize, ai_Serializable_void)
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(Serializable)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Serializable", php_phongo_serializable_me);
+ php_phongo_serializable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
+ zend_class_implements(php_phongo_serializable_ce TSRMLS_CC, 1, php_phongo_type_ce);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.0/src/BSON/Timestamp.c b/mongodb-1.2.3/src/BSON/Timestamp.c
similarity index 91%
rename from mongodb-1.2.0/src/BSON/Timestamp.c
rename to mongodb-1.2.3/src/BSON/Timestamp.c
index 5dc92f0c..878d8e20 100644
--- a/mongodb-1.2.0/src/BSON/Timestamp.c
+++ b/mongodb-1.2.3/src/BSON/Timestamp.c
@@ -1,532 +1,525 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
-#include <ext/json/php_json.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
#include <ext/standard/php_var.h>
#if PHP_VERSION_ID >= 70000
# include <zend_smart_str.h>
#else
# include <ext/standard/php_smart_str.h>
#endif
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_timestamp_ce;
zend_object_handlers php_phongo_handler_timestamp;
/* Initialize the object and return whether it was successful. An exception will
* be thrown on error. */
static bool php_phongo_timestamp_init(php_phongo_timestamp_t *intern, int64_t increment, int64_t timestamp TSRMLS_DC)
{
if (increment < 0 || increment > UINT32_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected increment to be an unsigned 32-bit integer, %" PHONGO_LONG_FORMAT " given", increment);
return false;
}
if (timestamp < 0 || timestamp > UINT32_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected timestamp to be an unsigned 32-bit integer, %" PHONGO_LONG_FORMAT " given", timestamp);
return false;
}
intern->increment = (uint32_t) increment;
intern->timestamp = (uint32_t) timestamp;
intern->initialized = true;
return true;
}
/* Initialize the object from numeric strings and return whether it was
* successful. An exception will be thrown on error. */
static bool php_phongo_timestamp_init_from_string(php_phongo_timestamp_t *intern, const char *s_increment, phongo_zpp_char_len s_increment_len, const char *s_timestamp, phongo_zpp_char_len s_timestamp_len TSRMLS_DC)
{
int64_t increment, timestamp;
char *endptr = NULL;
errno = 0;
/* errno will set errno if conversion fails; however, we do not need to
* specify the type of error.
*
* Note: bson_ascii_strtoll() does not properly detect out-of-range values
* (see: CDRIVER-1377). strtoll() would be preferable, but it is not
* available on all platforms (e.g. HP-UX), and atoll() provides no error
* reporting at all. */
increment = bson_ascii_strtoll(s_increment, &endptr, 10);
if (errno || (endptr && endptr != ((const char *)s_increment + s_increment_len))) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error parsing \"%s\" as 64-bit integer increment for %s initialization", s_increment, ZSTR_VAL(php_phongo_timestamp_ce->name));
return false;
}
timestamp = bson_ascii_strtoll(s_timestamp, &endptr, 10);
if (errno || (endptr && endptr != ((const char *)s_timestamp + s_timestamp_len))) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error parsing \"%s\" as 64-bit integer timestamp for %s initialization", s_timestamp, ZSTR_VAL(php_phongo_timestamp_ce->name));
return false;
}
return php_phongo_timestamp_init(intern, increment, timestamp TSRMLS_CC);
}
/* Initialize the object from a HashTable and return whether it was successful.
* An exception will be thrown on error. */
static bool php_phongo_timestamp_init_from_hash(php_phongo_timestamp_t *intern, HashTable *props TSRMLS_DC)
{
#if PHP_VERSION_ID >= 70000
zval *increment, *timestamp;
if ((increment = zend_hash_str_find(props, "increment", sizeof("increment")-1)) && Z_TYPE_P(increment) == IS_LONG &&
(timestamp = zend_hash_str_find(props, "timestamp", sizeof("timestamp")-1)) && Z_TYPE_P(timestamp) == IS_LONG) {
return php_phongo_timestamp_init(intern, Z_LVAL_P(increment), Z_LVAL_P(timestamp) TSRMLS_CC);
}
if ((increment = zend_hash_str_find(props, "increment", sizeof("increment")-1)) && Z_TYPE_P(increment) == IS_STRING &&
(timestamp = zend_hash_str_find(props, "timestamp", sizeof("timestamp")-1)) && Z_TYPE_P(timestamp) == IS_STRING) {
return php_phongo_timestamp_init_from_string(intern, Z_STRVAL_P(increment), Z_STRLEN_P(increment), Z_STRVAL_P(timestamp), Z_STRLEN_P(timestamp) TSRMLS_CC);
}
#else
zval **increment, **timestamp;
if (zend_hash_find(props, "increment", sizeof("increment"), (void**) &increment) == SUCCESS && Z_TYPE_PP(increment) == IS_LONG &&
zend_hash_find(props, "timestamp", sizeof("timestamp"), (void**) &timestamp) == SUCCESS && Z_TYPE_PP(timestamp) == IS_LONG) {
return php_phongo_timestamp_init(intern, Z_LVAL_PP(increment), Z_LVAL_PP(timestamp) TSRMLS_CC);
}
if (zend_hash_find(props, "increment", sizeof("increment"), (void**) &increment) == SUCCESS && Z_TYPE_PP(increment) == IS_STRING &&
zend_hash_find(props, "timestamp", sizeof("timestamp"), (void**) &timestamp) == SUCCESS && Z_TYPE_PP(timestamp) == IS_STRING) {
return php_phongo_timestamp_init_from_string(intern, Z_STRVAL_PP(increment), Z_STRLEN_PP(increment), Z_STRVAL_PP(timestamp), Z_STRLEN_PP(timestamp) TSRMLS_CC);
}
#endif
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "%s initialization requires \"increment\" and \"timestamp\" integer or numeric string fields", ZSTR_VAL(php_phongo_timestamp_ce->name));
return false;
}
/* {{{ proto void Timestamp::__construct(int|string $increment, int|string $timestamp)
Construct a new BSON timestamp type, which consists of a 4-byte increment and
4-byte timestamp. */
PHP_METHOD(Timestamp, __construct)
{
php_phongo_timestamp_t *intern;
zend_error_handling error_handling;
zval *increment = NULL, *timestamp = NULL;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_TIMESTAMP_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &increment, &timestamp) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
if (Z_TYPE_P(increment) == IS_LONG && Z_TYPE_P(timestamp) == IS_LONG) {
php_phongo_timestamp_init(intern, Z_LVAL_P(increment), Z_LVAL_P(timestamp) TSRMLS_CC);
return;
}
if (Z_TYPE_P(increment) == IS_LONG) {
convert_to_string(increment);
}
if (Z_TYPE_P(increment) != IS_STRING) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected increment to be an unsigned 32-bit integer or string, %s given", zend_get_type_by_const(Z_TYPE_P(increment)));
return;
}
if (Z_TYPE_P(timestamp) == IS_LONG) {
convert_to_string(timestamp);
}
if (Z_TYPE_P(timestamp) != IS_STRING) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected timestamp to be an unsigned 32-bit integer or string, %s given", zend_get_type_by_const(Z_TYPE_P(timestamp)));
return;
}
php_phongo_timestamp_init_from_string(intern, Z_STRVAL_P(increment), Z_STRLEN_P(increment), Z_STRVAL_P(timestamp), Z_STRLEN_P(timestamp) TSRMLS_CC);
}
/* }}} */
/* {{{ proto void Timestamp::__set_state(array $properties)
*/
PHP_METHOD(Timestamp, __set_state)
{
php_phongo_timestamp_t *intern;
HashTable *props;
zval *array;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
RETURN_FALSE;
}
object_init_ex(return_value, php_phongo_timestamp_ce);
intern = Z_TIMESTAMP_OBJ_P(return_value);
props = Z_ARRVAL_P(array);
php_phongo_timestamp_init_from_hash(intern, props TSRMLS_CC);
}
/* }}} */
/* {{{ proto string Timestamp::__toString()
Returns a string in the form: [increment:timestamp] */
PHP_METHOD(Timestamp, __toString)
{
php_phongo_timestamp_t *intern;
char *retval;
int retval_len;
intern = Z_TIMESTAMP_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
retval_len = spprintf(&retval, 0, "[%" PRIu32 ":%" PRIu32 "]", intern->increment, intern->timestamp);
PHONGO_RETVAL_STRINGL(retval, retval_len);
efree(retval);
}
/* }}} */
/* {{{ proto array Timestamp::jsonSerialize()
*/
PHP_METHOD(Timestamp, jsonSerialize)
{
php_phongo_timestamp_t *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_TIMESTAMP_OBJ_P(getThis());
array_init_size(return_value, 1);
#if PHP_VERSION_ID >= 70000
{
zval ts;
array_init_size(&ts, 2);
ADD_ASSOC_LONG_EX(&ts, "t", intern->timestamp);
ADD_ASSOC_LONG_EX(&ts, "i", intern->increment);
ADD_ASSOC_ZVAL_EX(return_value, "$timestamp", &ts);
}
#else
{
zval *ts;
MAKE_STD_ZVAL(ts);
array_init_size(ts, 2);
ADD_ASSOC_LONG_EX(ts, "t", intern->timestamp);
ADD_ASSOC_LONG_EX(ts, "i", intern->increment);
ADD_ASSOC_ZVAL_EX(return_value, "$timestamp", ts);
}
#endif
}
/* }}} */
/* {{{ proto string Timestamp::serialize()
*/
PHP_METHOD(Timestamp, serialize)
{
php_phongo_timestamp_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval *retval;
#endif
php_serialize_data_t var_hash;
smart_str buf = { 0 };
char s_increment[12];
char s_timestamp[12];
int s_increment_len;
int s_timestamp_len;
intern = Z_TIMESTAMP_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
s_increment_len = snprintf(s_increment, sizeof(s_increment), "%" PRIu32, intern->increment);
s_timestamp_len = snprintf(s_timestamp, sizeof(s_timestamp), "%" PRIu32, intern->timestamp);
#if PHP_VERSION_ID >= 70000
array_init_size(&retval, 2);
ADD_ASSOC_STRINGL(&retval, "increment", s_increment, s_increment_len);
ADD_ASSOC_STRINGL(&retval, "timestamp", s_timestamp, s_timestamp_len);
#else
ALLOC_INIT_ZVAL(retval);
array_init_size(retval, 2);
ADD_ASSOC_STRINGL(retval, "increment", s_increment, s_increment_len);
ADD_ASSOC_STRINGL(retval, "timestamp", s_timestamp, s_timestamp_len);
#endif
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&buf, &retval, &var_hash TSRMLS_CC);
smart_str_0(&buf);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
PHONGO_RETVAL_SMART_STR(buf);
smart_str_free(&buf);
zval_ptr_dtor(&retval);
}
/* }}} */
/* {{{ proto string Timestamp::unserialize(string $serialized)
*/
PHP_METHOD(Timestamp, unserialize)
{
php_phongo_timestamp_t *intern;
zend_error_handling error_handling;
char *serialized;
phongo_zpp_char_len serialized_len;
#if PHP_VERSION_ID >= 70000
zval props;
#else
zval *props;
#endif
php_unserialize_data_t var_hash;
intern = Z_TIMESTAMP_OBJ_P(getThis());
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized, &serialized_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
#if PHP_VERSION_ID < 70000
ALLOC_INIT_ZVAL(props);
#endif
PHP_VAR_UNSERIALIZE_INIT(var_hash);
if (!php_var_unserialize(&props, (const unsigned char**) &serialized, (unsigned char *) serialized + serialized_len, &var_hash TSRMLS_CC)) {
zval_ptr_dtor(&props);
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "%s unserialization failed", ZSTR_VAL(php_phongo_timestamp_ce->name));
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return;
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
#if PHP_VERSION_ID >= 70000
php_phongo_timestamp_init_from_hash(intern, HASH_OF(&props) TSRMLS_CC);
#else
php_phongo_timestamp_init_from_hash(intern, HASH_OF(props) TSRMLS_CC);
#endif
zval_ptr_dtor(&props);
}
/* }}} */
/* {{{ BSON\Timestamp */
ZEND_BEGIN_ARG_INFO_EX(ai_Timestamp___construct, 0, 0, 2)
ZEND_ARG_INFO(0, increment)
ZEND_ARG_INFO(0, timestamp)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Timestamp___set_state, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, properties, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Timestamp_unserialize, 0, 0, 1)
ZEND_ARG_INFO(0, serialized)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Timestamp_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_timestamp_me[] = {
PHP_ME(Timestamp, __construct, ai_Timestamp___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Timestamp, __set_state, ai_Timestamp___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Timestamp, __toString, ai_Timestamp_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Timestamp, jsonSerialize, ai_Timestamp_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Timestamp, serialize, ai_Timestamp_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Timestamp, unserialize, ai_Timestamp_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_timestamp_t object handlers */
static void php_phongo_timestamp_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_timestamp_t *intern = Z_OBJ_TIMESTAMP(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_timestamp_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_timestamp_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_timestamp_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_timestamp;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_timestamp_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_timestamp;
return retval;
}
#endif
} /* }}} */
static int php_phongo_timestamp_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
{
php_phongo_timestamp_t *intern1, *intern2;
intern1 = Z_TIMESTAMP_OBJ_P(o1);
intern2 = Z_TIMESTAMP_OBJ_P(o2);
/* MongoDB compares the timestamp before the increment. */
if (intern1->timestamp != intern2->timestamp) {
return intern1->timestamp < intern2->timestamp ? -1 : 1;
}
if (intern1->increment != intern2->increment) {
return intern1->increment < intern2->increment ? -1 : 1;
}
return 0;
} /* }}} */
HashTable *php_phongo_timestamp_get_properties(zval *object TSRMLS_DC) /* {{{ */
{
php_phongo_timestamp_t *intern;
HashTable *props;
char s_increment[24];
char s_timestamp[24];
int s_increment_len;
int s_timestamp_len;
intern = Z_TIMESTAMP_OBJ_P(object);
props = zend_std_get_properties(object TSRMLS_CC);
if (!intern->initialized) {
return props;
}
s_increment_len = snprintf(s_increment, sizeof(s_increment), "%" PRIu32, intern->increment);
s_timestamp_len = snprintf(s_timestamp, sizeof(s_timestamp), "%" PRIu32, intern->timestamp);
#if PHP_VERSION_ID >= 70000
{
zval increment, timestamp;
ZVAL_STRINGL(&increment, s_increment, s_increment_len);
zend_hash_str_update(props, "increment", sizeof("increment")-1, &increment);
ZVAL_STRINGL(&timestamp, s_timestamp, s_timestamp_len);
zend_hash_str_update(props, "timestamp", sizeof("timestamp")-1, &timestamp);
}
#else
{
zval *increment, *timestamp;
MAKE_STD_ZVAL(increment);
ZVAL_STRINGL(increment, s_increment, s_increment_len, 1);
zend_hash_update(props, "increment", sizeof("increment"), &increment, sizeof(increment), NULL);
MAKE_STD_ZVAL(timestamp);
ZVAL_STRINGL(timestamp, s_timestamp, s_timestamp_len, 1);
zend_hash_update(props, "timestamp", sizeof("timestamp"), &timestamp, sizeof(timestamp), NULL);
}
#endif
return props;
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Timestamp)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Timestamp", php_phongo_timestamp_me);
php_phongo_timestamp_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_timestamp_ce->create_object = php_phongo_timestamp_create_object;
PHONGO_CE_FINAL(php_phongo_timestamp_ce);
- zend_class_implements(php_phongo_timestamp_ce TSRMLS_CC, 1, php_json_serializable_ce);
+ zend_class_implements(php_phongo_timestamp_ce TSRMLS_CC, 1, php_phongo_json_serializable_ce);
zend_class_implements(php_phongo_timestamp_ce TSRMLS_CC, 1, php_phongo_type_ce);
zend_class_implements(php_phongo_timestamp_ce TSRMLS_CC, 1, zend_ce_serializable);
memcpy(&php_phongo_handler_timestamp, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_timestamp.compare_objects = php_phongo_timestamp_compare_objects;
php_phongo_handler_timestamp.get_properties = php_phongo_timestamp_get_properties;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_timestamp.free_obj = php_phongo_timestamp_free_object;
php_phongo_handler_timestamp.offset = XtOffsetOf(php_phongo_timestamp_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.3/src/BSON/Type.c b/mongodb-1.2.3/src/BSON/Type.c
new file mode 100644
index 00000000..2adf5299
--- /dev/null
+++ b/mongodb-1.2.3/src/BSON/Type.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+
+
+PHONGO_API zend_class_entry *php_phongo_type_ce;
+
+
+
+/* {{{ BSON\Type */
+
+
+static zend_function_entry php_phongo_type_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(Type)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Type", php_phongo_type_me);
+ php_phongo_type_ce = zend_register_internal_interface(&ce TSRMLS_CC);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.0/src/BSON/UTCDateTime.c b/mongodb-1.2.3/src/BSON/UTCDateTime.c
similarity index 90%
rename from mongodb-1.2.0/src/BSON/UTCDateTime.c
rename to mongodb-1.2.3/src/BSON/UTCDateTime.c
index ba3fe60c..1c6c6af0 100644
--- a/mongodb-1.2.0/src/BSON/UTCDateTime.c
+++ b/mongodb-1.2.3/src/BSON/UTCDateTime.c
@@ -1,577 +1,566 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
#include <math.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
-#include <ext/json/php_json.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/date/php_date.h>
#include <ext/spl/spl_iterators.h>
-#include <ext/date/php_date.h>
#include <ext/standard/php_var.h>
#if PHP_VERSION_ID >= 70000
# include <zend_smart_str.h>
#else
# include <ext/standard/php_smart_str.h>
#endif
/* Our Compatability header */
#include "phongo_compat.h"
#ifdef PHP_WIN32
#include "win32/time.h"
#endif
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_utcdatetime_ce;
zend_object_handlers php_phongo_handler_utcdatetime;
/* Initialize the object and return whether it was successful. */
static bool php_phongo_utcdatetime_init(php_phongo_utcdatetime_t *intern, int64_t milliseconds)
{
intern->milliseconds = milliseconds;
intern->initialized = true;
return true;
}
/* Initialize the object from a numeric string and return whether it was
* successful. An exception will be thrown on error. */
static bool php_phongo_utcdatetime_init_from_string(php_phongo_utcdatetime_t *intern, const char *s_milliseconds, phongo_zpp_char_len s_milliseconds_len TSRMLS_DC)
{
int64_t milliseconds;
char *endptr = NULL;
errno = 0;
milliseconds = bson_ascii_strtoll(s_milliseconds, &endptr, 10);
/* errno will set errno if conversion fails; however, we do not need to
* specify the type of error.
*
* Note: bson_ascii_strtoll() does not properly detect out-of-range values
* (see: CDRIVER-1377). strtoll() would be preferable, but it is not
* available on all platforms (e.g. HP-UX), and atoll() provides no error
* reporting at all. */
if (errno || (endptr && endptr != ((const char *)s_milliseconds + s_milliseconds_len))) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error parsing \"%s\" as 64-bit integer for %s initialization", s_milliseconds, ZSTR_VAL(php_phongo_utcdatetime_ce->name));
return false;
}
return php_phongo_utcdatetime_init(intern, milliseconds);
}
/* Initialize the object from a HashTable and return whether it was successful.
* An exception will be thrown on error. */
static bool php_phongo_utcdatetime_init_from_hash(php_phongo_utcdatetime_t *intern, HashTable *props TSRMLS_DC)
{
#if PHP_VERSION_ID >= 70000
zval *milliseconds;
if ((milliseconds = zend_hash_str_find(props, "milliseconds", sizeof("milliseconds")-1)) && Z_TYPE_P(milliseconds) == IS_LONG) {
return php_phongo_utcdatetime_init(intern, Z_LVAL_P(milliseconds));
}
if ((milliseconds = zend_hash_str_find(props, "milliseconds", sizeof("milliseconds")-1)) && Z_TYPE_P(milliseconds) == IS_STRING) {
return php_phongo_utcdatetime_init_from_string(intern, Z_STRVAL_P(milliseconds), Z_STRLEN_P(milliseconds) TSRMLS_CC);
}
#else
zval **milliseconds;
if (zend_hash_find(props, "milliseconds", sizeof("milliseconds"), (void**) &milliseconds) == SUCCESS && Z_TYPE_PP(milliseconds) == IS_LONG) {
return php_phongo_utcdatetime_init(intern, Z_LVAL_PP(milliseconds));
}
if (zend_hash_find(props, "milliseconds", sizeof("milliseconds"), (void**) &milliseconds) == SUCCESS && Z_TYPE_PP(milliseconds) == IS_STRING) {
return php_phongo_utcdatetime_init_from_string(intern, Z_STRVAL_PP(milliseconds), Z_STRLEN_PP(milliseconds) TSRMLS_CC);
}
#endif
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "%s initialization requires \"milliseconds\" integer or numeric string field", ZSTR_VAL(php_phongo_utcdatetime_ce->name));
return false;
}
/* Initialize the object from the current time and return whether it was
* successful. */
static bool php_phongo_utcdatetime_init_from_current_time(php_phongo_utcdatetime_t *intern)
{
int64_t sec, usec;
struct timeval cur_time;
gettimeofday(&cur_time, NULL);
sec = cur_time.tv_sec;
usec = cur_time.tv_usec;
intern->milliseconds = (sec * 1000) + (usec / 1000);
intern->initialized = true;
return true;
}
/* Initialize the object from a DateTime object and return whether it was
* successful. */
static bool php_phongo_utcdatetime_init_from_date(php_phongo_utcdatetime_t *intern, php_date_obj *datetime_obj)
{
int64_t sec, usec;
/* The following assignments use the same logic as date_format() in php_date.c */
sec = datetime_obj->time->sse;
usec = (int64_t) floor(datetime_obj->time->f * 1000000 + 0.5);
intern->milliseconds = (sec * 1000) + (usec / 1000);
intern->initialized = true;
return true;
}
/* {{{ proto void UTCDateTime::__construct([int|float|string|DateTimeInterface $milliseconds = null])
Construct a new BSON UTCDateTime type from either the current time,
milliseconds since the epoch, or a DateTimeInterface object. Defaults to the
current time. */
PHP_METHOD(UTCDateTime, __construct)
{
php_phongo_utcdatetime_t *intern;
zend_error_handling error_handling;
zval *milliseconds = NULL;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_UTCDATETIME_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z!", &milliseconds) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
if (milliseconds == NULL) {
php_phongo_utcdatetime_init_from_current_time(intern);
return;
}
if (Z_TYPE_P(milliseconds) == IS_OBJECT) {
- if (instanceof_function(Z_OBJCE_P(milliseconds), php_date_get_date_ce() TSRMLS_CC)) {
+ if (instanceof_function(Z_OBJCE_P(milliseconds), php_date_get_date_ce() TSRMLS_CC) ||
+ (php_phongo_date_immutable_ce && instanceof_function(Z_OBJCE_P(milliseconds), php_phongo_date_immutable_ce TSRMLS_CC))) {
php_phongo_utcdatetime_init_from_date(intern, Z_PHPDATE_P(milliseconds));
-#if PHP_VERSION_ID >= 50500
- } else if (instanceof_function(Z_OBJCE_P(milliseconds), php_date_get_immutable_ce() TSRMLS_CC)) {
- php_phongo_utcdatetime_init_from_date(intern, Z_PHPDATE_P(milliseconds));
-#endif
} else {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected instance of DateTimeInterface, %s given", ZSTR_VAL(Z_OBJCE_P(milliseconds)->name));
}
return;
}
if (Z_TYPE_P(milliseconds) == IS_LONG) {
php_phongo_utcdatetime_init(intern, Z_LVAL_P(milliseconds));
return;
}
if (Z_TYPE_P(milliseconds) == IS_DOUBLE) {
char tmp[24];
int tmp_len;
tmp_len = snprintf(tmp, sizeof(tmp), "%.0f", Z_DVAL_P(milliseconds) > 0 ? floor(Z_DVAL_P(milliseconds)) : ceil(Z_DVAL_P(milliseconds)));
php_phongo_utcdatetime_init_from_string(intern, tmp, tmp_len TSRMLS_CC);
return;
}
if (Z_TYPE_P(milliseconds) != IS_STRING) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected integer or string, %s given", zend_get_type_by_const(Z_TYPE_P(milliseconds)));
return;
}
php_phongo_utcdatetime_init_from_string(intern, Z_STRVAL_P(milliseconds), Z_STRLEN_P(milliseconds) TSRMLS_CC);
}
/* }}} */
/* {{{ proto void UTCDateTime::__set_state(array $properties)
*/
PHP_METHOD(UTCDateTime, __set_state)
{
php_phongo_utcdatetime_t *intern;
HashTable *props;
zval *array;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
RETURN_FALSE;
}
object_init_ex(return_value, php_phongo_utcdatetime_ce);
intern = Z_UTCDATETIME_OBJ_P(return_value);
props = Z_ARRVAL_P(array);
php_phongo_utcdatetime_init_from_hash(intern, props TSRMLS_CC);
}
/* }}} */
/* {{{ proto string UTCDateTime::__toString()
Returns the UTCDateTime's milliseconds as a string */
PHP_METHOD(UTCDateTime, __toString)
{
php_phongo_utcdatetime_t *intern;
char *tmp;
int tmp_len;
intern = Z_UTCDATETIME_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
tmp_len = spprintf(&tmp, 0, "%" PRId64, intern->milliseconds);
PHONGO_RETVAL_STRINGL(tmp, tmp_len);
efree(tmp);
}
/* }}} */
/* {{{ proto DateTime UTCDateTime::toDateTime()
Returns a DateTime object representing this UTCDateTime */
PHP_METHOD(UTCDateTime, toDateTime)
{
php_phongo_utcdatetime_t *intern;
php_date_obj *datetime_obj;
char *sec;
size_t sec_len;
intern = Z_UTCDATETIME_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
object_init_ex(return_value, php_date_get_date_ce());
datetime_obj = Z_PHPDATE_P(return_value);
sec_len = spprintf(&sec, 0, "@%" PRId64, intern->milliseconds / 1000);
php_date_initialize(datetime_obj, sec, sec_len, NULL, NULL, 0 TSRMLS_CC);
efree(sec);
datetime_obj->time->f = (double) (intern->milliseconds % 1000) / 1000;
}
/* }}} */
/* {{{ proto array UTCDateTime::jsonSerialize()
*/
PHP_METHOD(UTCDateTime, jsonSerialize)
{
php_phongo_utcdatetime_t *intern;
char s_milliseconds[24];
int s_milliseconds_len;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
intern = Z_UTCDATETIME_OBJ_P(getThis());
s_milliseconds_len = snprintf(s_milliseconds, sizeof(s_milliseconds), "%" PRId64, intern->milliseconds);
array_init_size(return_value, 1);
#if PHP_VERSION_ID >= 70000
{
zval udt;
array_init_size(&udt, 1);
ADD_ASSOC_STRINGL(&udt, "$numberLong", s_milliseconds, s_milliseconds_len);
ADD_ASSOC_ZVAL_EX(return_value, "$date", &udt);
}
#else
{
zval *udt;
MAKE_STD_ZVAL(udt);
array_init_size(udt, 1);
ADD_ASSOC_STRINGL(udt, "$numberLong", s_milliseconds, s_milliseconds_len);
ADD_ASSOC_ZVAL_EX(return_value, "$date", udt);
}
#endif
}
/* }}} */
/* {{{ proto string UTCDateTime::serialize()
*/
PHP_METHOD(UTCDateTime, serialize)
{
php_phongo_utcdatetime_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval *retval;
#endif
php_serialize_data_t var_hash;
smart_str buf = { 0 };
char s_milliseconds[24];
int s_milliseconds_len;
intern = Z_UTCDATETIME_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
s_milliseconds_len = snprintf(s_milliseconds, sizeof(s_milliseconds), "%" PRId64, intern->milliseconds);
#if PHP_VERSION_ID >= 70000
array_init_size(&retval, 2);
ADD_ASSOC_STRINGL(&retval, "milliseconds", s_milliseconds, s_milliseconds_len);
#else
ALLOC_INIT_ZVAL(retval);
array_init_size(retval, 2);
ADD_ASSOC_STRINGL(retval, "milliseconds", s_milliseconds, s_milliseconds_len);
#endif
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&buf, &retval, &var_hash TSRMLS_CC);
smart_str_0(&buf);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
PHONGO_RETVAL_SMART_STR(buf);
smart_str_free(&buf);
zval_ptr_dtor(&retval);
}
/* }}} */
/* {{{ proto string UTCDateTime::unserialize(string $serialized)
*/
PHP_METHOD(UTCDateTime, unserialize)
{
php_phongo_utcdatetime_t *intern;
zend_error_handling error_handling;
char *serialized;
phongo_zpp_char_len serialized_len;
#if PHP_VERSION_ID >= 70000
zval props;
#else
zval *props;
#endif
php_unserialize_data_t var_hash;
intern = Z_UTCDATETIME_OBJ_P(getThis());
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized, &serialized_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
#if PHP_VERSION_ID < 70000
ALLOC_INIT_ZVAL(props);
#endif
PHP_VAR_UNSERIALIZE_INIT(var_hash);
if (!php_var_unserialize(&props, (const unsigned char**) &serialized, (unsigned char *) serialized + serialized_len, &var_hash TSRMLS_CC)) {
zval_ptr_dtor(&props);
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "%s unserialization failed", ZSTR_VAL(php_phongo_utcdatetime_ce->name));
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return;
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
#if PHP_VERSION_ID >= 70000
php_phongo_utcdatetime_init_from_hash(intern, HASH_OF(&props) TSRMLS_CC);
#else
php_phongo_utcdatetime_init_from_hash(intern, HASH_OF(props) TSRMLS_CC);
#endif
zval_ptr_dtor(&props);
}
/* }}} */
/* {{{ BSON\UTCDateTime */
ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTime___construct, 0, 0, 1)
ZEND_ARG_INFO(0, milliseconds)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTime___set_state, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, properties, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTime_unserialize, 0, 0, 1)
ZEND_ARG_INFO(0, serialized)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTime_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_utcdatetime_me[] = {
PHP_ME(UTCDateTime, __construct, ai_UTCDateTime___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(UTCDateTime, __set_state, ai_UTCDateTime___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(UTCDateTime, __toString, ai_UTCDateTime_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(UTCDateTime, jsonSerialize, ai_UTCDateTime_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(UTCDateTime, serialize, ai_UTCDateTime_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(UTCDateTime, unserialize, ai_UTCDateTime_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(UTCDateTime, toDateTime, ai_UTCDateTime_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_utcdatetime_t object handlers */
static void php_phongo_utcdatetime_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_utcdatetime_t *intern = Z_OBJ_UTCDATETIME(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_utcdatetime_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_utcdatetime_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_utcdatetime_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_utcdatetime;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_utcdatetime_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_utcdatetime;
return retval;
}
#endif
} /* }}} */
static int php_phongo_utcdatetime_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
{
php_phongo_utcdatetime_t *intern1, *intern2;
intern1 = Z_UTCDATETIME_OBJ_P(o1);
intern2 = Z_UTCDATETIME_OBJ_P(o2);
if (intern1->milliseconds != intern2->milliseconds) {
return intern1->milliseconds < intern2->milliseconds ? -1 : 1;
}
return 0;
} /* }}} */
HashTable *php_phongo_utcdatetime_get_properties(zval *object TSRMLS_DC) /* {{{ */
{
php_phongo_utcdatetime_t *intern;
HashTable *props;
char s_milliseconds[24];
int s_milliseconds_len;
intern = Z_UTCDATETIME_OBJ_P(object);
props = zend_std_get_properties(object TSRMLS_CC);
if (!intern->initialized) {
return props;
}
s_milliseconds_len = snprintf(s_milliseconds, sizeof(s_milliseconds), "%" PRId64, intern->milliseconds);
#if PHP_VERSION_ID >= 70000
{
zval milliseconds;
ZVAL_STRINGL(&milliseconds, s_milliseconds, s_milliseconds_len);
zend_hash_str_update(props, "milliseconds", sizeof("milliseconds")-1, &milliseconds);
}
#else
{
zval *milliseconds;
MAKE_STD_ZVAL(milliseconds);
ZVAL_STRINGL(milliseconds, s_milliseconds, s_milliseconds_len, 1);
zend_hash_update(props, "milliseconds", sizeof("milliseconds"), &milliseconds, sizeof(milliseconds), NULL);
}
#endif
return props;
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(UTCDateTime)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "UTCDateTime", php_phongo_utcdatetime_me);
php_phongo_utcdatetime_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_utcdatetime_ce->create_object = php_phongo_utcdatetime_create_object;
PHONGO_CE_FINAL(php_phongo_utcdatetime_ce);
- zend_class_implements(php_phongo_utcdatetime_ce TSRMLS_CC, 1, php_json_serializable_ce);
+ zend_class_implements(php_phongo_utcdatetime_ce TSRMLS_CC, 1, php_phongo_json_serializable_ce);
zend_class_implements(php_phongo_utcdatetime_ce TSRMLS_CC, 1, php_phongo_type_ce);
zend_class_implements(php_phongo_utcdatetime_ce TSRMLS_CC, 1, zend_ce_serializable);
memcpy(&php_phongo_handler_utcdatetime, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_utcdatetime.compare_objects = php_phongo_utcdatetime_compare_objects;
php_phongo_handler_utcdatetime.get_properties = php_phongo_utcdatetime_get_properties;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_utcdatetime.free_obj = php_phongo_utcdatetime_free_object;
php_phongo_handler_utcdatetime.offset = XtOffsetOf(php_phongo_utcdatetime_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.3/src/BSON/Unserializable.c b/mongodb-1.2.3/src/BSON/Unserializable.c
new file mode 100644
index 00000000..c7a3d4a7
--- /dev/null
+++ b/mongodb-1.2.3/src/BSON/Unserializable.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+
+
+PHONGO_API zend_class_entry *php_phongo_unserializable_ce;
+
+
+
+/* {{{ BSON\Unserializable */
+
+ZEND_BEGIN_ARG_INFO_EX(ai_Unserializable_bsonUnserialize, 0, 0, 1)
+ ZEND_ARG_ARRAY_INFO(0, data, 0)
+ZEND_END_ARG_INFO()
+
+static zend_function_entry php_phongo_unserializable_me[] = {
+ ZEND_ABSTRACT_ME(Unserializable, bsonUnserialize, ai_Unserializable_bsonUnserialize)
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(Unserializable)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Unserializable", php_phongo_unserializable_me);
+ php_phongo_unserializable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.0/src/MongoDB/BulkWrite.c b/mongodb-1.2.3/src/MongoDB/BulkWrite.c
similarity index 91%
rename from mongodb-1.2.0/src/MongoDB/BulkWrite.c
rename to mongodb-1.2.3/src/MongoDB/BulkWrite.c
index 6b72e70a..6bddf3af 100644
--- a/mongodb-1.2.0/src/MongoDB/BulkWrite.c
+++ b/mongodb-1.2.3/src/MongoDB/BulkWrite.c
@@ -1,564 +1,558 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2015-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* PHP array helpers */
#include "php_array_api.h"
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#define BYPASS_UNSET -1
PHONGO_API zend_class_entry *php_phongo_bulkwrite_ce;
zend_object_handlers php_phongo_handler_bulkwrite;
/* Returns whether any top-level field names in the document contain a "$". */
static inline bool php_phongo_bulkwrite_update_has_operators(bson_t *bupdate) /* {{{ */
{
bson_iter_t iter;
if (bson_iter_init(&iter, bupdate)) {
while (bson_iter_next (&iter)) {
if (strchr(bson_iter_key(&iter), '$')) {
return true;
}
}
}
return false;
} /* }}} */
/* Appends a document field for the given opts document and key. Returns true on
* success; otherwise, false is returned and an exception is thrown. */
static bool php_phongo_bulkwrite_opts_append_document(bson_t *opts, const char *opts_key, zval *zarr, const char *zarr_key TSRMLS_DC)
{
zval *value = php_array_fetch(zarr, zarr_key);
bson_t b = BSON_INITIALIZER;
if (Z_TYPE_P(value) != IS_OBJECT && Z_TYPE_P(value) != IS_ARRAY) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"%s\" option to be array or object, %s given", zarr_key, zend_get_type_by_const(Z_TYPE_P(value)));
return false;
}
phongo_zval_to_bson(value, PHONGO_BSON_NONE, &b, NULL TSRMLS_CC);
if (EG(exception)) {
bson_destroy(&b);
return false;
}
if (!BSON_APPEND_DOCUMENT(opts, opts_key, &b)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"%s\" option", opts_key);
bson_destroy(&b);
return false;
}
bson_destroy(&b);
return true;
}
#define PHONGO_BULKWRITE_APPEND_BOOL(opt, value) \
if (!BSON_APPEND_BOOL(boptions, (opt), (value))) { \
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"%s\" option", (opt)); \
return false; \
}
#define PHONGO_BULKWRITE_APPEND_INT32(opt, value) \
if (!BSON_APPEND_INT32(boptions, (opt), (value))) { \
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"%s\" option", (opt)); \
return false; \
}
#define PHONGO_BULKWRITE_OPT_DOCUMENT(opt) \
if (zoptions && php_array_existsc(zoptions, (opt))) { \
if (!php_phongo_bulkwrite_opts_append_document(boptions, (opt), zoptions, (opt) TSRMLS_CC)) { \
return false; \
} \
}
/* Applies options (including defaults) for an update operation. */
static bool php_phongo_bulkwrite_update_apply_options(bson_t *boptions, zval *zoptions TSRMLS_DC)/* {{{ */
{
bool multi = false, upsert = false;
if (zoptions) {
if (php_array_existsc(zoptions, "multi")) {
multi = php_array_fetchc_bool(zoptions, "multi");
}
if (php_array_existsc(zoptions, "upsert")) {
upsert = php_array_fetchc_bool(zoptions, "upsert");
}
}
PHONGO_BULKWRITE_APPEND_BOOL("multi", multi);
PHONGO_BULKWRITE_APPEND_BOOL("upsert", upsert);
PHONGO_BULKWRITE_OPT_DOCUMENT("collation");
return true;
} /* }}} */
/* Applies options (including defaults) for an delete operation. */
static bool php_phongo_bulkwrite_delete_apply_options(bson_t *boptions, zval *zoptions TSRMLS_DC)/* {{{ */
{
int32_t limit = 0;
if (zoptions) {
if (php_array_existsc(zoptions, "limit")) {
limit = php_array_fetchc_bool(zoptions, "limit") ? 1 : 0;
}
}
PHONGO_BULKWRITE_APPEND_INT32("limit", limit);
PHONGO_BULKWRITE_OPT_DOCUMENT("collation");
return true;
} /* }}} */
#undef PHONGO_BULKWRITE_APPEND_BOOL
#undef PHONGO_BULKWRITE_APPEND_INT32
#undef PHONGO_BULKWRITE_OPT_DOCUMENT
/* {{{ proto void BulkWrite::__construct([array $options = array()])
Constructs a new BulkWrite */
PHP_METHOD(BulkWrite, __construct)
{
php_phongo_bulkwrite_t *intern;
zend_error_handling error_handling;
zval *options = NULL;
zend_bool ordered = 1;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_BULKWRITE_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!", &options) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
if (options && php_array_existsc(options, "ordered")) {
ordered = php_array_fetchc_bool(options, "ordered");
}
intern->bulk = phongo_bulkwrite_init(ordered);
intern->ordered = ordered;
intern->bypass = BYPASS_UNSET;
intern->num_ops = 0;
if (options && php_array_existsc(options, "bypassDocumentValidation")) {
zend_bool bypass = php_array_fetchc_bool(options, "bypassDocumentValidation");
mongoc_bulk_operation_set_bypass_document_validation(intern->bulk, bypass);
intern->bypass = bypass;
}
}
/* }}} */
/* {{{ proto mixed BulkWrite::insert(array|object $document)
Adds an insert operation to the BulkWrite */
PHP_METHOD(BulkWrite, insert)
{
php_phongo_bulkwrite_t *intern;
zval *document;
bson_t *bson;
bson_t *bson_out = NULL;
int bson_flags = PHONGO_BSON_ADD_ID;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_BULKWRITE_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "A", &document) == FAILURE) {
return;
}
if (return_value_used) {
bson_flags |= PHONGO_BSON_RETURN_ID;
}
bson = bson_new();
phongo_zval_to_bson(document, bson_flags, bson, &bson_out TSRMLS_CC);
mongoc_bulk_operation_insert(intern->bulk, bson);
bson_clear(&bson);
intern->num_ops++;
if (bson_out && return_value_used) {
bson_iter_t iter;
if (bson_iter_init_find(&iter, bson_out, "_id")) {
php_phongo_objectid_new_from_oid(return_value, bson_iter_oid(&iter) TSRMLS_CC);
bson_clear(&bson_out);
return;
}
bson_clear(&bson_out);
}
}
/* }}} */
/* {{{ proto void BulkWrite::update(array|object $query, array|object $newObj[, array $updateOptions = array()])
Adds an update operation to the BulkWrite */
PHP_METHOD(BulkWrite, update)
{
php_phongo_bulkwrite_t *intern;
zval *zquery, *zupdate, *zoptions = NULL;
bson_t *bquery, *bupdate, *boptions = NULL;
bson_error_t error = {0};
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_BULKWRITE_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "AA|a!", &zquery, &zupdate, &zoptions) == FAILURE) {
return;
}
bquery = bson_new();
bupdate = bson_new();
boptions = bson_new();
phongo_zval_to_bson(zquery, PHONGO_BSON_NONE, bquery, NULL TSRMLS_CC);
if (EG(exception)) {
goto cleanup;
}
phongo_zval_to_bson(zupdate, PHONGO_BSON_NONE, bupdate, NULL TSRMLS_CC);
if (EG(exception)) {
goto cleanup;
}
if (!php_phongo_bulkwrite_update_apply_options(boptions, zoptions TSRMLS_CC)) {
goto cleanup;
}
if (php_phongo_bulkwrite_update_has_operators(bupdate)) {
if (zoptions && php_array_existsc(zoptions, "multi") && php_array_fetchc_bool(zoptions, "multi")) {
if (!mongoc_bulk_operation_update_many_with_opts(intern->bulk, bquery, bupdate, boptions, &error)) {
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
goto cleanup;
}
} else {
if (!mongoc_bulk_operation_update_one_with_opts(intern->bulk, bquery, bupdate, boptions, &error)) {
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
goto cleanup;
}
}
} else {
if (!bson_validate(bupdate, BSON_VALIDATE_DOT_KEYS|BSON_VALIDATE_DOLLAR_KEYS, NULL)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Replacement document may not contain \"$\" or \".\" in keys");
goto cleanup;
}
if (zoptions && php_array_existsc(zoptions, "multi") && php_array_fetchc_bool(zoptions, "multi")) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Replacement document conflicts with true \"multi\" option");
goto cleanup;
}
if (!mongoc_bulk_operation_replace_one_with_opts(intern->bulk, bquery, bupdate, boptions, &error)) {
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
goto cleanup;
}
}
intern->num_ops++;
cleanup:
bson_clear(&bquery);
bson_clear(&bupdate);
bson_clear(&boptions);
}
/* }}} */
/* {{{ proto void BulkWrite::delete(array|object $query[, array $deleteOptions = array()])
Adds a delete operation to the BulkWrite */
PHP_METHOD(BulkWrite, delete)
{
php_phongo_bulkwrite_t *intern;
zval *zquery, *zoptions = NULL;
bson_t *bquery, *boptions = NULL;
bson_error_t error = {0};
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_BULKWRITE_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "A|a!", &zquery, &zoptions) == FAILURE) {
return;
}
bquery = bson_new();
boptions = bson_new();
phongo_zval_to_bson(zquery, PHONGO_BSON_NONE, bquery, NULL TSRMLS_CC);
if (EG(exception)) {
goto cleanup;
}
if (!php_phongo_bulkwrite_delete_apply_options(boptions, zoptions TSRMLS_CC)) {
goto cleanup;
}
if (zoptions && php_array_existsc(zoptions, "limit") && php_array_fetchc_bool(zoptions, "limit")) {
if (!mongoc_bulk_operation_remove_one_with_opts(intern->bulk, bquery, boptions, &error)) {
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
goto cleanup;
}
} else {
if (!mongoc_bulk_operation_remove_many_with_opts(intern->bulk, bquery, boptions, &error)) {
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
goto cleanup;
}
}
intern->num_ops++;
cleanup:
bson_clear(&bquery);
bson_clear(&boptions);
}
/* }}} */
/* {{{ proto integer BulkWrite::count()
Returns the number of operations that have been added to the BulkWrite */
PHP_METHOD(BulkWrite, count)
{
php_phongo_bulkwrite_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_BULKWRITE_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(intern->num_ops);
}
/* }}} */
/* {{{ MongoDB\Driver\BulkWrite */
ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite___construct, 0, 0, 0)
ZEND_ARG_ARRAY_INFO(0, options, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite_insert, 0, 0, 1)
ZEND_ARG_INFO(0, document)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite_update, 0, 0, 2)
ZEND_ARG_INFO(0, query)
ZEND_ARG_INFO(0, newObj)
ZEND_ARG_ARRAY_INFO(0, updateOptions, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite_delete, 0, 0, 1)
ZEND_ARG_INFO(0, query)
ZEND_ARG_ARRAY_INFO(0, deleteOptions, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_bulkwrite_me[] = {
PHP_ME(BulkWrite, __construct, ai_BulkWrite___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(BulkWrite, insert, ai_BulkWrite_insert, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(BulkWrite, update, ai_BulkWrite_update, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(BulkWrite, delete, ai_BulkWrite_delete, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(BulkWrite, count, ai_BulkWrite_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeup, ai_BulkWrite_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_bulkwrite_t object handlers */
static void php_phongo_bulkwrite_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_bulkwrite_t *intern = Z_OBJ_BULKWRITE(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->bulk) {
mongoc_bulk_operation_destroy(intern->bulk);
}
if (intern->database) {
efree(intern->database);
}
if (intern->collection) {
efree(intern->collection);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_bulkwrite_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_bulkwrite_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_bulkwrite_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_bulkwrite;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_bulkwrite_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_bulkwrite;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_bulkwrite_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
php_phongo_bulkwrite_t *intern = NULL;
*is_temp = 1;
intern = Z_BULKWRITE_OBJ_P(object);
array_init(&retval);
if (intern->database) {
ADD_ASSOC_STRING(&retval, "database", intern->database);
} else {
ADD_ASSOC_NULL_EX(&retval, "database");
}
if (intern->collection) {
ADD_ASSOC_STRING(&retval, "collection", intern->collection);
} else {
ADD_ASSOC_NULL_EX(&retval, "collection");
}
ADD_ASSOC_BOOL_EX(&retval, "ordered", intern->ordered);
if (intern->bypass != BYPASS_UNSET) {
ADD_ASSOC_BOOL_EX(&retval, "bypassDocumentValidation", intern->bypass);
} else {
ADD_ASSOC_NULL_EX(&retval, "bypassDocumentValidation");
}
ADD_ASSOC_BOOL_EX(&retval, "executed", intern->executed);
ADD_ASSOC_LONG_EX(&retval, "server_id", mongoc_bulk_operation_get_hint(intern->bulk));
if (mongoc_bulk_operation_get_write_concern(intern->bulk)) {
#if PHP_VERSION_ID >= 70000
zval write_concern;
php_phongo_write_concern_to_zval(&write_concern, mongoc_bulk_operation_get_write_concern(intern->bulk));
ADD_ASSOC_ZVAL_EX(&retval, "write_concern", &write_concern);
#else
zval *write_concern = NULL;
MAKE_STD_ZVAL(write_concern);
php_phongo_write_concern_to_zval(write_concern, mongoc_bulk_operation_get_write_concern(intern->bulk));
ADD_ASSOC_ZVAL_EX(&retval, "write_concern", write_concern);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "write_concern");
}
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(BulkWrite)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "BulkWrite", php_phongo_bulkwrite_me);
php_phongo_bulkwrite_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_bulkwrite_ce->create_object = php_phongo_bulkwrite_create_object;
PHONGO_CE_FINAL(php_phongo_bulkwrite_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_bulkwrite_ce);
memcpy(&php_phongo_handler_bulkwrite, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_bulkwrite.get_debug_info = php_phongo_bulkwrite_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_bulkwrite.free_obj = php_phongo_bulkwrite_free_object;
php_phongo_handler_bulkwrite.offset = XtOffsetOf(php_phongo_bulkwrite_t, std);
#endif
zend_class_implements(php_phongo_bulkwrite_ce TSRMLS_CC, 1, spl_ce_Countable);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/MongoDB/Command.c b/mongodb-1.2.3/src/MongoDB/Command.c
similarity index 75%
rename from mongodb-1.2.0/src/MongoDB/Command.c
rename to mongodb-1.2.3/src/MongoDB/Command.c
index e9065822..b086cb78 100644
--- a/mongodb-1.2.0/src/MongoDB/Command.c
+++ b/mongodb-1.2.3/src/MongoDB/Command.c
@@ -1,206 +1,200 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_command_ce;
zend_object_handlers php_phongo_handler_command;
/* {{{ proto void Command::__construct(array|object $document)
Constructs a new Command */
PHP_METHOD(Command, __construct)
{
php_phongo_command_t *intern;
zend_error_handling error_handling;
zval *document;
bson_t *bson = bson_new();
SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_COMMAND_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "A", &document) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
phongo_zval_to_bson(document, PHONGO_BSON_NONE, bson, NULL TSRMLS_CC);
intern->bson = bson;
}
/* }}} */
/**
* Value object for a database command document.
*/
/* {{{ MongoDB\Driver\Command */
ZEND_BEGIN_ARG_INFO_EX(ai_Command___construct, 0, 0, 1)
ZEND_ARG_INFO(0, document)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Command_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_command_me[] = {
PHP_ME(Command, __construct, ai_Command___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeup, ai_Command_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_command_t object handlers */
static void php_phongo_command_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_command_t *intern = Z_OBJ_COMMAND(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->bson) {
bson_clear(&intern->bson);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_command_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_command_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_command_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_command;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_command_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_command;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_command_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_command_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_COMMAND_OBJ_P(object);
array_init_size(&retval, 1);
if (intern->bson) {
#if PHP_VERSION_ID >= 70000
zval zv;
#else
zval *zv;
#endif
phongo_bson_to_zval(bson_get_data(intern->bson), intern->bson->len, &zv);
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(&retval, "command", &zv);
#else
ADD_ASSOC_ZVAL_EX(&retval, "command", zv);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "command");
}
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Command)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Command", php_phongo_command_me);
php_phongo_command_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_command_ce->create_object = php_phongo_command_create_object;
PHONGO_CE_FINAL(php_phongo_command_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_command_ce);
memcpy(&php_phongo_handler_command, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_command.get_debug_info = php_phongo_command_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_command.free_obj = php_phongo_command_free_object;
php_phongo_handler_command.offset = XtOffsetOf(php_phongo_command_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/MongoDB/Cursor.c b/mongodb-1.2.3/src/MongoDB/Cursor.c
similarity index 61%
rename from mongodb-1.2.0/src/MongoDB/Cursor.c
rename to mongodb-1.2.3/src/MongoDB/Cursor.c
index f599415b..d4b07446 100644
--- a/mongodb-1.2.0/src/MongoDB/Cursor.c
+++ b/mongodb-1.2.3/src/MongoDB/Cursor.c
@@ -1,402 +1,579 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_cursor_ce;
zend_object_handlers php_phongo_handler_cursor;
+static void php_phongo_cursor_free_current(php_phongo_cursor_t *cursor) /* {{{ */
+{
+ if (!Z_ISUNDEF(cursor->visitor_data.zchild)) {
+ zval_ptr_dtor(&cursor->visitor_data.zchild);
+#if PHP_VERSION_ID >= 70000
+ ZVAL_UNDEF(&cursor->visitor_data.zchild);
+#else
+ cursor->visitor_data.zchild = NULL;
+#endif
+ }
+} /* }}} */
+
+/* {{{ Iterator handlers */
+static void php_phongo_cursor_iterator_dtor(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
+{
+ php_phongo_cursor_iterator *cursor_it = (php_phongo_cursor_iterator *)iter;
+
+ if (!Z_ISUNDEF(cursor_it->intern.data)) {
+#if PHP_VERSION_ID >= 70000
+ zval_ptr_dtor(&cursor_it->intern.data);
+#else
+ zval_ptr_dtor((zval**)&cursor_it->intern.data);
+ cursor_it->intern.data = NULL;
+#endif
+ }
+
+#if PHP_VERSION_ID < 70000
+ efree(cursor_it);
+#endif
+} /* }}} */
+
+static int php_phongo_cursor_iterator_valid(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
+{
+ php_phongo_cursor_t *cursor = ((php_phongo_cursor_iterator *)iter)->cursor;
+
+ if (!Z_ISUNDEF(cursor->visitor_data.zchild)) {
+ return SUCCESS;
+ }
+
+ return FAILURE;
+} /* }}} */
+
+#if PHP_VERSION_ID < 50500
+static int php_phongo_cursor_iterator_get_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC) /* {{{ */
+{
+ php_phongo_cursor_t *cursor = ((php_phongo_cursor_iterator *)iter)->cursor;
+
+ *int_key = (ulong) cursor->current;
+ return HASH_KEY_IS_LONG;
+} /* }}} */
+#else
+static void php_phongo_cursor_iterator_get_current_key(zend_object_iterator *iter, zval *key TSRMLS_DC) /* {{{ */
+{
+ php_phongo_cursor_t *cursor = ((php_phongo_cursor_iterator *)iter)->cursor;
+
+ ZVAL_LONG(key, cursor->current);
+} /* }}} */
+#endif
+
+#if PHP_VERSION_ID < 70000
+static void php_phongo_cursor_iterator_get_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC) /* {{{ */
+{
+ php_phongo_cursor_t *cursor = ((php_phongo_cursor_iterator *)iter)->cursor;
+
+ *data = &cursor->visitor_data.zchild;
+} /* }}} */
+#else
+static zval* php_phongo_cursor_iterator_get_current_data(zend_object_iterator *iter) /* {{{ */
+{
+ php_phongo_cursor_t *cursor = ((php_phongo_cursor_iterator *)iter)->cursor;
+
+ return &cursor->visitor_data.zchild;
+} /* }}} */
+#endif
+
+static void php_phongo_cursor_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
+{
+ php_phongo_cursor_iterator *cursor_it = (php_phongo_cursor_iterator *)iter;
+ php_phongo_cursor_t *cursor = cursor_it->cursor;
+ const bson_t *doc;
+
+ php_phongo_cursor_free_current(cursor);
+ cursor->current++;
+
+ if (mongoc_cursor_next(cursor->cursor, &doc)) {
+ phongo_bson_to_zval_ex(bson_get_data(doc), doc->len, &cursor->visitor_data);
+ } else {
+ bson_error_t error;
+
+ if (mongoc_cursor_error(cursor->cursor, &error)) {
+ /* Intentionally not destroying the cursor as it will happen
+ * naturally now that there are no more results */
+ phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
+ }
+ }
+} /* }}} */
+
+static void php_phongo_cursor_iterator_rewind(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
+{
+ php_phongo_cursor_iterator *cursor_it = (php_phongo_cursor_iterator *)iter;
+ php_phongo_cursor_t *cursor = cursor_it->cursor;
+ const bson_t *doc;
+
+ if (cursor->current > 0) {
+ phongo_throw_exception(PHONGO_ERROR_LOGIC TSRMLS_CC, "Cursors cannot rewind after starting iteration");
+ return;
+ }
+
+ php_phongo_cursor_free_current(cursor);
+
+ doc = mongoc_cursor_current(cursor->cursor);
+
+ if (doc) {
+ phongo_bson_to_zval_ex(bson_get_data(doc), doc->len, &cursor->visitor_data);
+ }
+} /* }}} */
+
+/* iterator handler table */
+zend_object_iterator_funcs php_phongo_cursor_iterator_funcs = {
+ php_phongo_cursor_iterator_dtor,
+ php_phongo_cursor_iterator_valid,
+ php_phongo_cursor_iterator_get_current_data,
+ php_phongo_cursor_iterator_get_current_key,
+ php_phongo_cursor_iterator_move_forward,
+ php_phongo_cursor_iterator_rewind,
+ NULL /* invalidate_current is not used */
+};
+
+zend_object_iterator *php_phongo_cursor_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) /* {{{ */
+{
+ php_phongo_cursor_iterator *cursor_it = NULL;
+ php_phongo_cursor_t *cursor = Z_CURSOR_OBJ_P(object);
+
+ if (by_ref) {
+ zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
+ }
+
+ if (cursor->got_iterator) {
+ phongo_throw_exception(PHONGO_ERROR_LOGIC TSRMLS_CC, "Cursors cannot yield multiple iterators");
+ return NULL;
+ }
+
+ cursor->got_iterator = 1;
+
+ cursor_it = ecalloc(1, sizeof(php_phongo_cursor_iterator));
+#if PHP_VERSION_ID >= 70000
+ zend_iterator_init(&cursor_it->intern);
+#endif
+
+#if PHP_VERSION_ID >= 70000
+ ZVAL_COPY(&cursor_it->intern.data, object);
+#else
+ Z_ADDREF_P(object);
+ cursor_it->intern.data = (void*)object;
+#endif
+ cursor_it->intern.funcs = &php_phongo_cursor_iterator_funcs;
+ cursor_it->cursor = cursor;
+ /* cursor_it->current should already be allocated to zero */
+
+ php_phongo_cursor_free_current(cursor_it->cursor);
+
+ return &cursor_it->intern;
+} /* }}} */
+ /* }}} */
+
/* {{{ proto void Cursor::setTypeMap(array $typemap)
Sets a type map to use for BSON unserialization */
PHP_METHOD(Cursor, setTypeMap)
{
php_phongo_cursor_t *intern;
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
zval *typemap = NULL;
SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_CURSOR_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!", &typemap) == FAILURE) {
return;
}
+ /* Check if the existing element needs to be freed before we overwrite
+ * visitor_data, which contains the only reference to it. */
+ if (!Z_ISUNDEF(intern->visitor_data.zchild)) {
+ php_phongo_cursor_free_current(intern);
+ }
+
phongo_bson_typemap_to_state(typemap, &state.map TSRMLS_CC);
intern->visitor_data = state;
+
+ /* If the cursor has a current element, we just freed it and should restore
+ * it with a new type map applied. */
+ if (mongoc_cursor_current(intern->cursor)) {
+ const bson_t *doc = mongoc_cursor_current(intern->cursor);
+
+ phongo_bson_to_zval_ex(bson_get_data(doc), doc->len, &intern->visitor_data);
+ }
}
/* }}} */
static int php_phongo_cursor_to_array_apply(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *data;
zval *return_value = (zval*)puser;
data = iter->funcs->get_current_data(iter TSRMLS_CC);
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
}
if (Z_ISUNDEF_P(data)) {
return ZEND_HASH_APPLY_STOP;
}
Z_TRY_ADDREF_P(data);
add_next_index_zval(return_value, data);
#else
zval **data;
zval *return_value = (zval*)puser;
iter->funcs->get_current_data(iter, &data TSRMLS_CC);
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
}
if (data == NULL || *data == NULL) {
return ZEND_HASH_APPLY_STOP;
}
Z_ADDREF_PP(data);
add_next_index_zval(return_value, *data);
#endif
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
/* {{{ proto array Cursor::toArray()
Returns an array of all result documents for this cursor */
PHP_METHOD(Cursor, toArray)
{
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
array_init(return_value);
if (spl_iterator_apply(getThis(), php_phongo_cursor_to_array_apply, (void*)return_value TSRMLS_CC) != SUCCESS) {
zval_dtor(return_value);
RETURN_NULL();
}
}
/* }}} */
/* {{{ proto MongoDB\Driver\CursorId Cursor::getId()
Returns the CursorId for this cursor */
PHP_METHOD(Cursor, getId)
{
php_phongo_cursor_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_CURSOR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
php_phongo_cursor_id_new_from_id(return_value, mongoc_cursor_get_id(intern->cursor) TSRMLS_CC);
}
/* }}} */
/* {{{ proto MongoDB\Driver\Server Cursor::getServer()
Returns the Server object to which this cursor is attached */
PHP_METHOD(Cursor, getServer)
{
php_phongo_cursor_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_CURSOR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
#if PHP_VERSION_ID >= 70000
phongo_server_init(return_value, &intern->manager, intern->server_id TSRMLS_CC);
#else
phongo_server_init(return_value, intern->manager, intern->server_id TSRMLS_CC);
#endif
}
/* }}} */
/* {{{ proto boolean Cursor::isDead()
Checks if a cursor is still alive */
PHP_METHOD(Cursor, isDead)
{
php_phongo_cursor_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_CURSOR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(!mongoc_cursor_is_alive(intern->cursor));
}
/* }}} */
/* {{{ MongoDB\Driver\Cursor */
ZEND_BEGIN_ARG_INFO_EX(ai_Cursor_setTypeMap, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, typemap, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Cursor_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_cursor_me[] = {
PHP_ME(Server, __construct, ai_Cursor_void, ZEND_ACC_FINAL|ZEND_ACC_PRIVATE)
PHP_ME(Cursor, setTypeMap, ai_Cursor_setTypeMap, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Cursor, toArray, ai_Cursor_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Cursor, getId, ai_Cursor_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Cursor, getServer, ai_Cursor_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Cursor, isDead, ai_Cursor_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeup, ai_Cursor_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_cursor_t object handlers */
static void php_phongo_cursor_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_cursor_t *intern = Z_OBJ_CURSOR(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
+ if (intern->cursor) {
+ mongoc_cursor_destroy(intern->cursor);
+ }
+
if (intern->database) {
efree(intern->database);
}
if (intern->collection) {
efree(intern->collection);
}
if (!Z_ISUNDEF(intern->query)) {
zval_ptr_dtor(&intern->query);
}
if (!Z_ISUNDEF(intern->command)) {
zval_ptr_dtor(&intern->command);
}
if (!Z_ISUNDEF(intern->read_preference)) {
zval_ptr_dtor(&intern->read_preference);
}
- php_phongo_cursor_free(intern);
+ php_phongo_cursor_free_current(intern);
zval_ptr_dtor(&intern->manager);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_cursor_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_cursor_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_cursor_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_cursor;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_cursor_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_cursor;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_cursor_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_cursor_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_CURSOR_OBJ_P(object);
array_init_size(&retval, 9);
if (intern->database) {
ADD_ASSOC_STRING(&retval, "database", intern->database);
} else {
ADD_ASSOC_NULL_EX(&retval, "database");
}
if (intern->collection) {
ADD_ASSOC_STRING(&retval, "collection", intern->collection);
} else {
ADD_ASSOC_NULL_EX(&retval, "collection");
}
if (!Z_ISUNDEF(intern->query)) {
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(&retval, "query", &intern->query);
Z_ADDREF(intern->query);
#else
ADD_ASSOC_ZVAL_EX(&retval, "query", intern->query);
Z_ADDREF_P(intern->query);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "query");
}
if (!Z_ISUNDEF(intern->command)) {
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(&retval, "command", &intern->command);
Z_ADDREF(intern->command);
#else
ADD_ASSOC_ZVAL_EX(&retval, "command", intern->command);
Z_ADDREF_P(intern->command);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "command");
}
if (!Z_ISUNDEF(intern->read_preference)) {
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(&retval, "readPreference", &intern->read_preference);
Z_ADDREF(intern->read_preference);
#else
ADD_ASSOC_ZVAL_EX(&retval, "readPreference", intern->read_preference);
Z_ADDREF_P(intern->read_preference);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "readPreference");
}
ADD_ASSOC_BOOL_EX(&retval, "isDead", !mongoc_cursor_is_alive(intern->cursor));
ADD_ASSOC_LONG_EX(&retval, "currentIndex", intern->current);
if (!Z_ISUNDEF(intern->visitor_data.zchild)) {
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(&retval, "currentDocument", &intern->visitor_data.zchild);
/*Z_ADDREF(intern->visitor_data.zchild);*/
#else
ADD_ASSOC_ZVAL_EX(&retval, "currentDocument", intern->visitor_data.zchild);
Z_ADDREF_P(intern->visitor_data.zchild);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "currentDocument");
}
{
#if PHP_VERSION_ID >= 70000
zval server;
phongo_server_init(&server, &intern->manager, intern->server_id TSRMLS_CC);
ADD_ASSOC_ZVAL_EX(&retval, "server", &server);
#else
zval *server = NULL;
MAKE_STD_ZVAL(server);
phongo_server_init(server, intern->manager, intern->server_id TSRMLS_CC);
ADD_ASSOC_ZVAL_EX(&retval, "server", server);
#endif
}
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Cursor)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Cursor", php_phongo_cursor_me);
php_phongo_cursor_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_cursor_ce->create_object = php_phongo_cursor_create_object;
PHONGO_CE_FINAL(php_phongo_cursor_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_cursor_ce);
php_phongo_cursor_ce->get_iterator = php_phongo_cursor_get_iterator;
memcpy(&php_phongo_handler_cursor, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_cursor.get_debug_info = php_phongo_cursor_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_cursor.free_obj = php_phongo_cursor_free_object;
php_phongo_handler_cursor.offset = XtOffsetOf(php_phongo_cursor_t, std);
#endif
zend_class_implements(php_phongo_cursor_ce TSRMLS_CC, 1, zend_ce_traversable);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/MongoDB/CursorId.c b/mongodb-1.2.3/src/MongoDB/CursorId.c
similarity index 72%
rename from mongodb-1.2.0/src/MongoDB/CursorId.c
rename to mongodb-1.2.3/src/MongoDB/CursorId.c
index 5983262a..49c5cd83 100644
--- a/mongodb-1.2.0/src/MongoDB/CursorId.c
+++ b/mongodb-1.2.3/src/MongoDB/CursorId.c
@@ -1,184 +1,178 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_cursorid_ce;
zend_object_handlers php_phongo_handler_cursorid;
/* {{{ proto string CursorId::__toString()
Returns the string representation of the CursorId */
PHP_METHOD(CursorId, __toString)
{
php_phongo_cursorid_t *intern;
char *tmp;
int tmp_len;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_CURSORID_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
tmp_len = spprintf(&tmp, 0, "%" PRIu64, intern->id);
PHONGO_RETVAL_STRINGL(tmp, tmp_len);
efree(tmp);
}
/* }}} */
/* {{{ MongoDB\Driver\CursorId */
ZEND_BEGIN_ARG_INFO_EX(ai_CursorId_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_cursorid_me[] = {
PHP_ME(Server, __construct, ai_CursorId_void, ZEND_ACC_FINAL|ZEND_ACC_PRIVATE)
PHP_ME(CursorId, __toString, ai_CursorId_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeup, ai_CursorId_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_cursorid_t object handlers */
static void php_phongo_cursorid_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_cursorid_t *intern = Z_OBJ_CURSORID(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_cursorid_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_cursorid_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_cursorid_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_cursorid;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_cursorid_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_cursorid;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_cursorid_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_cursorid_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_CURSORID_OBJ_P(object);
array_init(&retval);
#if SIZEOF_LONG == 4
{
char tmp[24];
int tmp_len;
tmp_len = snprintf(tmp, sizeof(tmp), "%" PRIu64, intern->id);
ADD_ASSOC_STRINGL(&retval, "id", tmp, tmp_len);
}
#else
ADD_ASSOC_LONG_EX(&retval, "id", intern->id);
#endif
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(CursorId)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "CursorId", php_phongo_cursorid_me);
php_phongo_cursorid_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_cursorid_ce->create_object = php_phongo_cursorid_create_object;
PHONGO_CE_FINAL(php_phongo_cursorid_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_cursorid_ce);
memcpy(&php_phongo_handler_cursorid, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_cursorid.get_debug_info = php_phongo_cursorid_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_cursorid.free_obj = php_phongo_cursorid_free_object;
php_phongo_handler_cursorid.offset = XtOffsetOf(php_phongo_cursorid_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.3/src/MongoDB/Exception/AuthenticationException.c b/mongodb-1.2.3/src/MongoDB/Exception/AuthenticationException.c
new file mode 100644
index 00000000..dac85725
--- /dev/null
+++ b/mongodb-1.2.3/src/MongoDB/Exception/AuthenticationException.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+#include <ext/spl/spl_exceptions.h>
+
+
+PHONGO_API zend_class_entry *php_phongo_authenticationexception_ce;
+
+/* {{{ MongoDB\Driver\AuthenticationException */
+
+static zend_function_entry php_phongo_authenticationexception_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(AuthenticationException)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "AuthenticationException", php_phongo_authenticationexception_me);
+#if PHP_VERSION_ID >= 70000
+ php_phongo_authenticationexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce);
+#else
+ php_phongo_authenticationexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce, NULL TSRMLS_CC);
+#endif
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.3/src/MongoDB/Exception/BulkWriteException.c b/mongodb-1.2.3/src/MongoDB/Exception/BulkWriteException.c
new file mode 100644
index 00000000..96c766fb
--- /dev/null
+++ b/mongodb-1.2.3/src/MongoDB/Exception/BulkWriteException.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2015-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+#include <ext/spl/spl_exceptions.h>
+
+
+PHONGO_API zend_class_entry *php_phongo_bulkwriteexception_ce;
+
+/* {{{ MongoDB\Driver\BulkWriteException */
+
+static zend_function_entry php_phongo_bulkwriteexception_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(BulkWriteException)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "BulkWriteException", php_phongo_bulkwriteexception_me);
+#if PHP_VERSION_ID >= 70000
+ php_phongo_bulkwriteexception_ce = zend_register_internal_class_ex(&ce, php_phongo_writeexception_ce);
+#else
+ php_phongo_bulkwriteexception_ce = zend_register_internal_class_ex(&ce, php_phongo_writeexception_ce, NULL TSRMLS_CC);
+#endif
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.3/src/MongoDB/Exception/ConnectionException.c b/mongodb-1.2.3/src/MongoDB/Exception/ConnectionException.c
new file mode 100644
index 00000000..7b91969d
--- /dev/null
+++ b/mongodb-1.2.3/src/MongoDB/Exception/ConnectionException.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+#include <ext/spl/spl_exceptions.h>
+
+
+PHONGO_API zend_class_entry *php_phongo_connectionexception_ce;
+
+/* {{{ MongoDB\Driver\ConnectionException */
+
+static zend_function_entry php_phongo_connectionexception_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(ConnectionException)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ConnectionException", php_phongo_connectionexception_me);
+#if PHP_VERSION_ID >= 70000
+ php_phongo_connectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce);
+#else
+ php_phongo_connectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce, NULL TSRMLS_CC);
+#endif
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.3/src/MongoDB/Exception/ConnectionTimeoutException.c b/mongodb-1.2.3/src/MongoDB/Exception/ConnectionTimeoutException.c
new file mode 100644
index 00000000..2d52d645
--- /dev/null
+++ b/mongodb-1.2.3/src/MongoDB/Exception/ConnectionTimeoutException.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2015-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+#include <ext/spl/spl_exceptions.h>
+
+
+PHONGO_API zend_class_entry *php_phongo_connectiontimeoutexception_ce;
+
+/* {{{ MongoDB\Driver\ConnectionTimeoutException */
+
+static zend_function_entry php_phongo_connectiontimeoutexception_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(ConnectionTimeoutException)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ConnectionTimeoutException", php_phongo_connectiontimeoutexception_me);
+#if PHP_VERSION_ID >= 70000
+ php_phongo_connectiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce);
+#else
+ php_phongo_connectiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce, NULL TSRMLS_CC);
+#endif
+ PHONGO_CE_FINAL(php_phongo_connectiontimeoutexception_ce);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.3/src/MongoDB/Exception/Exception.c b/mongodb-1.2.3/src/MongoDB/Exception/Exception.c
new file mode 100644
index 00000000..6902aa14
--- /dev/null
+++ b/mongodb-1.2.3/src/MongoDB/Exception/Exception.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+#include <ext/spl/spl_exceptions.h>
+
+
+PHONGO_API zend_class_entry *php_phongo_exception_ce;
+
+/* {{{ MongoDB\Driver\Exception */
+
+static zend_function_entry php_phongo_exception_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(Exception)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "Exception", php_phongo_exception_me);
+ php_phongo_exception_ce = zend_register_internal_interface(&ce TSRMLS_CC);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.3/src/MongoDB/Exception/ExecutionTimeoutException.c b/mongodb-1.2.3/src/MongoDB/Exception/ExecutionTimeoutException.c
new file mode 100644
index 00000000..95eb2158
--- /dev/null
+++ b/mongodb-1.2.3/src/MongoDB/Exception/ExecutionTimeoutException.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2015-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+#include <ext/spl/spl_exceptions.h>
+
+
+PHONGO_API zend_class_entry *php_phongo_executiontimeoutexception_ce;
+
+/* {{{ MongoDB\Driver\ExecutionTimeoutException */
+
+static zend_function_entry php_phongo_executiontimeoutexception_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(ExecutionTimeoutException)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ExecutionTimeoutException", php_phongo_executiontimeoutexception_me);
+#if PHP_VERSION_ID >= 70000
+ php_phongo_executiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce);
+#else
+ php_phongo_executiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce, NULL TSRMLS_CC);
+#endif
+ PHONGO_CE_FINAL(php_phongo_executiontimeoutexception_ce);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.3/src/MongoDB/Exception/InvalidArgumentException.c b/mongodb-1.2.3/src/MongoDB/Exception/InvalidArgumentException.c
new file mode 100644
index 00000000..d8197aaa
--- /dev/null
+++ b/mongodb-1.2.3/src/MongoDB/Exception/InvalidArgumentException.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2015-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+#include <ext/spl/spl_exceptions.h>
+
+
+PHONGO_API zend_class_entry *php_phongo_invalidargumentexception_ce;
+
+/* {{{ MongoDB\Driver\InvalidArgumentException */
+
+static zend_function_entry php_phongo_invalidargumentexception_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(InvalidArgumentException)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "InvalidArgumentException", php_phongo_invalidargumentexception_me);
+#if PHP_VERSION_ID >= 70000
+ php_phongo_invalidargumentexception_ce = zend_register_internal_class_ex(&ce, spl_ce_InvalidArgumentException);
+#else
+ php_phongo_invalidargumentexception_ce = zend_register_internal_class_ex(&ce, spl_ce_InvalidArgumentException, NULL TSRMLS_CC);
+#endif
+ zend_class_implements(php_phongo_invalidargumentexception_ce TSRMLS_CC, 1, php_phongo_exception_ce);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.3/src/MongoDB/Exception/LogicException.c b/mongodb-1.2.3/src/MongoDB/Exception/LogicException.c
new file mode 100644
index 00000000..2ad41ccb
--- /dev/null
+++ b/mongodb-1.2.3/src/MongoDB/Exception/LogicException.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2015-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+#include <ext/spl/spl_exceptions.h>
+
+
+PHONGO_API zend_class_entry *php_phongo_logicexception_ce;
+
+/* {{{ MongoDB\Driver\LogicException */
+
+static zend_function_entry php_phongo_logicexception_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(LogicException)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "LogicException", php_phongo_logicexception_me);
+#if PHP_VERSION_ID >= 70000
+ php_phongo_logicexception_ce = zend_register_internal_class_ex(&ce, spl_ce_LogicException);
+#else
+ php_phongo_logicexception_ce = zend_register_internal_class_ex(&ce, spl_ce_LogicException, NULL TSRMLS_CC);
+#endif
+ zend_class_implements(php_phongo_logicexception_ce TSRMLS_CC, 1, php_phongo_exception_ce);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.3/src/MongoDB/Exception/RuntimeException.c b/mongodb-1.2.3/src/MongoDB/Exception/RuntimeException.c
new file mode 100644
index 00000000..a431f9fa
--- /dev/null
+++ b/mongodb-1.2.3/src/MongoDB/Exception/RuntimeException.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2015-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+#include <ext/spl/spl_exceptions.h>
+
+
+PHONGO_API zend_class_entry *php_phongo_runtimeexception_ce;
+
+/* {{{ MongoDB\Driver\RuntimeException */
+
+static zend_function_entry php_phongo_runtimeexception_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(RuntimeException)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "RuntimeException", php_phongo_runtimeexception_me);
+#if PHP_VERSION_ID >= 70000
+ php_phongo_runtimeexception_ce = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException);
+#else
+ php_phongo_runtimeexception_ce = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException, NULL TSRMLS_CC);
+#endif
+ zend_class_implements(php_phongo_runtimeexception_ce TSRMLS_CC, 1, php_phongo_exception_ce);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.3/src/MongoDB/Exception/SSLConnectionException.c b/mongodb-1.2.3/src/MongoDB/Exception/SSLConnectionException.c
new file mode 100644
index 00000000..b43f8b6a
--- /dev/null
+++ b/mongodb-1.2.3/src/MongoDB/Exception/SSLConnectionException.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+#include <ext/spl/spl_exceptions.h>
+
+
+PHONGO_API zend_class_entry *php_phongo_sslconnectionexception_ce;
+
+/* {{{ MongoDB\Driver\SSLConnectionException */
+
+static zend_function_entry php_phongo_sslconnectionexception_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(SSLConnectionException)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "SSLConnectionException", php_phongo_sslconnectionexception_me);
+#if PHP_VERSION_ID >= 70000
+ php_phongo_sslconnectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce);
+#else
+ php_phongo_sslconnectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce, NULL TSRMLS_CC);
+#endif
+ PHONGO_CE_FINAL(php_phongo_sslconnectionexception_ce);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.3/src/MongoDB/Exception/UnexpectedValueException.c b/mongodb-1.2.3/src/MongoDB/Exception/UnexpectedValueException.c
new file mode 100644
index 00000000..39961255
--- /dev/null
+++ b/mongodb-1.2.3/src/MongoDB/Exception/UnexpectedValueException.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* External libs */
+#include <bson.h>
+#include <mongoc.h>
+
+/* PHP Core stuff */
+#include <php.h>
+#include <php_ini.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_interfaces.h>
+#include <ext/spl/spl_iterators.h>
+/* Our Compatability header */
+#include "phongo_compat.h"
+
+/* Our stuffz */
+#include "php_phongo.h"
+#include "php_bson.h"
+#include <ext/spl/spl_exceptions.h>
+
+
+PHONGO_API zend_class_entry *php_phongo_unexpectedvalueexception_ce;
+
+/* {{{ MongoDB\Driver\UnexpectedValueException */
+
+static zend_function_entry php_phongo_unexpectedvalueexception_me[] = {
+ PHP_FE_END
+};
+
+/* }}} */
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(UnexpectedValueException)
+{
+ zend_class_entry ce;
+ (void)type;(void)module_number;
+
+ INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "UnexpectedValueException", php_phongo_unexpectedvalueexception_me);
+#if PHP_VERSION_ID >= 70000
+ php_phongo_unexpectedvalueexception_ce = zend_register_internal_class_ex(&ce, spl_ce_UnexpectedValueException);
+#else
+ php_phongo_unexpectedvalueexception_ce = zend_register_internal_class_ex(&ce, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
+#endif
+ zend_class_implements(php_phongo_unexpectedvalueexception_ce TSRMLS_CC, 1, php_phongo_exception_ce);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/mongodb-1.2.0/src/MongoDB/Exception/WriteException.c b/mongodb-1.2.3/src/MongoDB/Exception/WriteException.c
similarity index 60%
rename from mongodb-1.2.0/src/MongoDB/Exception/WriteException.c
rename to mongodb-1.2.3/src/MongoDB/Exception/WriteException.c
index 8692e6d0..faede47e 100644
--- a/mongodb-1.2.0/src/MongoDB/Exception/WriteException.c
+++ b/mongodb-1.2.3/src/MongoDB/Exception/WriteException.c
@@ -1,117 +1,111 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include <ext/spl/spl_exceptions.h>
PHONGO_API zend_class_entry *php_phongo_writeexception_ce;
/* {{{ proto MongoDB\Driver\WriteResult WriteException::getWriteResult()
Returns the WriteResult from the failed write operation. */
PHP_METHOD(WriteException, getWriteResult)
{
zval *writeresult;
#if PHP_VERSION_ID >= 70000
zval rv;
#endif
if (zend_parse_parameters_none() == FAILURE) {
return;
}
#if PHP_VERSION_ID >= 70000
writeresult = zend_read_property(php_phongo_writeexception_ce, getThis(), ZEND_STRL("writeResult"), 0, &rv TSRMLS_CC);
#else
writeresult = zend_read_property(php_phongo_writeexception_ce, getThis(), ZEND_STRL("writeResult"), 0 TSRMLS_CC);
#endif
RETURN_ZVAL(writeresult, 1, 0);
}
/* }}} */
/**
* Value object for write concern used in issuing write operations.
*/
/* {{{ MongoDB\Driver\WriteException */
ZEND_BEGIN_ARG_INFO_EX(ai_WriteException_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_writeexception_me[] = {
PHP_ME(WriteException, getWriteResult, ai_WriteException_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(WriteException)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "WriteException", php_phongo_writeexception_me);
#if PHP_VERSION_ID >= 70000
php_phongo_writeexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce);
#else
php_phongo_writeexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce, NULL TSRMLS_CC);
#endif
php_phongo_writeexception_ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
zend_declare_property_null(php_phongo_writeexception_ce, ZEND_STRL("writeResult"), ZEND_ACC_PROTECTED TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/MongoDB/Manager.c b/mongodb-1.2.3/src/MongoDB/Manager.c
similarity index 90%
rename from mongodb-1.2.0/src/MongoDB/Manager.c
rename to mongodb-1.2.3/src/MongoDB/Manager.c
index 1d9251d6..12d335a4 100644
--- a/mongodb-1.2.0/src/MongoDB/Manager.c
+++ b/mongodb-1.2.3/src/MongoDB/Manager.c
@@ -1,597 +1,595 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <ext/standard/file.h>
#include <Zend/zend_interfaces.h>
#include <Zend/zend_hash.h>
#include <ext/spl/spl_iterators.h>
/* PHP array helpers */
#include "php_array_api.h"
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#define PHONGO_MANAGER_URI_DEFAULT "mongodb://127.0.0.1/"
PHONGO_API zend_class_entry *php_phongo_manager_ce;
zend_object_handlers php_phongo_handler_manager;
/* Checks if driverOptions contains a stream context resource in the "context"
* key and incorporates any of its SSL options into the base array that did not
* already exist (i.e. array union). The "context" key is then unset from the
* base array.
*
* This handles the merging of any legacy SSL context options and also makes
* driverOptions suitable for serialization by removing the resource zval. */
static bool php_phongo_manager_merge_context_options(zval *zdriverOptions TSRMLS_DC)
{
php_stream_context *context;
zval *zcontext, *zcontextOptions;
if (!php_array_existsc(zdriverOptions, "context")) {
return true;
}
zcontext = php_array_fetchc(zdriverOptions, "context");
context = php_stream_context_from_zval(zcontext, 1);
if (!context) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "\"context\" driver option is not a valid Stream-Context resource");
return false;
}
#if PHP_VERSION_ID >= 70000
zcontextOptions = php_array_fetchc_array(&context->options, "ssl");
#else
zcontextOptions = php_array_fetchc_array(context->options, "ssl");
#endif
if (!zcontextOptions) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Stream-Context resource does not contain \"ssl\" options array");
return false;
}
/* Perform array union (see: add_function() in zend_operators.c) */
#if PHP_VERSION_ID >= 70000
- zend_hash_merge(Z_ARRVAL_P(zdriverOptions), Z_ARRVAL_P(zcontextOptions), zval_add_ref, 0);
+ zend_hash_merge(Z_ARRVAL_P(zdriverOptions), Z_ARRVAL_P(zcontextOptions), zval_add_ref, 0);
#else
{
zval *tmp;
zend_hash_merge(Z_ARRVAL_P(zdriverOptions), Z_ARRVAL_P(zcontextOptions), (void (*)(void *pData)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0);
}
#endif
php_array_unsetc(zdriverOptions, "context");
return true;
}
/* Prepare tagSets for BSON encoding by converting each array in the set to an
* object. This ensures that empty arrays will serialize as empty documents.
*
* php_phongo_read_preference_tags_are_valid() handles actual validation of the
* tag set structure. */
static void php_phongo_manager_prep_tagsets(zval *options TSRMLS_DC)
{
HashTable *ht_data;
if (Z_TYPE_P(options) != IS_ARRAY) {
return;
}
ht_data = HASH_OF(options);
#if PHP_VERSION_ID >= 70000
{
zend_string *string_key = NULL;
zend_ulong num_key = 0;
zval *tagSets;
ZEND_HASH_FOREACH_KEY_VAL(ht_data, num_key, string_key, tagSets) {
if (!string_key) {
continue;
}
/* php_phongo_make_uri() and php_phongo_apply_rp_options_to_uri()
* are both case-insensitive, so we need to be as well. */
if (!strcasecmp(ZSTR_VAL(string_key), "readpreferencetags")) {
+ ZVAL_DEREF(tagSets);
+ SEPARATE_ZVAL_NOREF(tagSets);
php_phongo_read_preference_prep_tagsets(tagSets TSRMLS_CC);
}
} ZEND_HASH_FOREACH_END();
}
#else
{
HashPosition pos;
zval **tagSets;
for (zend_hash_internal_pointer_reset_ex(ht_data, &pos);
zend_hash_get_current_data_ex(ht_data, (void **) &tagSets, &pos) == SUCCESS;
zend_hash_move_forward_ex(ht_data, &pos)) {
char *string_key = NULL;
uint string_key_len = 0;
ulong num_key = 0;
if (HASH_KEY_IS_STRING != zend_hash_get_current_key_ex(ht_data, &string_key, &string_key_len, &num_key, 0, &pos)) {
continue;
}
/* php_phongo_make_uri() and php_phongo_apply_rp_options_to_uri()
* are both case-insensitive, so we need to be as well. */
if (!strcasecmp(string_key, "readpreferencetags")) {
+ SEPARATE_ZVAL_IF_NOT_REF(tagSets);
php_phongo_read_preference_prep_tagsets(*tagSets TSRMLS_CC);
}
}
}
#endif
return;
} /* }}} */
/* {{{ proto void Manager::__construct([string $uri = "mongodb://127.0.0.1/"[, array $options = array()[, array $driverOptions = array()]]])
Constructs a new Manager */
PHP_METHOD(Manager, __construct)
{
php_phongo_manager_t *intern;
zend_error_handling error_handling;
char *uri_string = NULL;
phongo_zpp_char_len uri_string_len = 0;
zval *options = NULL;
zval *driverOptions = NULL;
SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_MANAGER_OBJ_P(getThis());
- /* Separate the driverOptions zval, since we may end up modifying it in
- * php_phongo_manager_merge_context_options() below. */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!a!a!", &uri_string, &uri_string_len, &options, &driverOptions) == FAILURE) {
+ /* Separate the options and driverOptions zvals, since we may end up
+ * modifying them in php_phongo_manager_prep_tagsets() and
+ * php_phongo_manager_merge_context_options() below, respectively. */
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!a/!a/!", &uri_string, &uri_string_len, &options, &driverOptions) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
if (options) {
php_phongo_manager_prep_tagsets(options TSRMLS_CC);
}
if (driverOptions && !php_phongo_manager_merge_context_options(driverOptions TSRMLS_CC)) {
/* Exception should already have been thrown */
return;
}
phongo_manager_init(intern, uri_string ? uri_string : PHONGO_MANAGER_URI_DEFAULT, options, driverOptions TSRMLS_CC);
}
/* }}} */
/* {{{ proto MongoDB\Driver\Cursor Manager::executeCommand(string $db, MongoDB\Driver\Command $command[, MongoDB\Driver\ReadPreference $readPreference = null])
Execute a Command */
PHP_METHOD(Manager, executeCommand)
{
char *db;
phongo_zpp_char_len db_len;
zval *command;
zval *readPreference = NULL;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sO|O!", &db, &db_len, &command, php_phongo_command_ce, &readPreference, php_phongo_readpreference_ce) == FAILURE) {
return;
}
phongo_execute_command(getThis(), db, command, readPreference, -1, return_value, return_value_used TSRMLS_CC);
}
/* }}} */
/* {{{ proto MongoDB\Driver\Cursor Manager::executeQuery(string $namespace, MongoDB\Driver\Query $query[, MongoDB\Driver\ReadPreference $readPreference = null])
Execute a Query */
PHP_METHOD(Manager, executeQuery)
{
char *namespace;
phongo_zpp_char_len namespace_len;
zval *query;
zval *readPreference = NULL;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sO|O!", &namespace, &namespace_len, &query, php_phongo_query_ce, &readPreference, php_phongo_readpreference_ce) == FAILURE) {
return;
}
phongo_execute_query(getThis(), namespace, query, readPreference, -1, return_value, return_value_used TSRMLS_CC);
}
/* }}} */
/* {{{ proto MongoDB\Driver\WriteResult Manager::executeBulkWrite(string $namespace, MongoDB\Driver\BulkWrite $zbulk[, MongoDB\Driver\WriteConcern $writeConcern = null])
Executes a BulkWrite (i.e. any number of insert, update, and delete ops) */
PHP_METHOD(Manager, executeBulkWrite)
{
char *namespace;
phongo_zpp_char_len namespace_len;
zval *zbulk;
zval *zwrite_concern = NULL;
php_phongo_bulkwrite_t *bulk;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sO|O!", &namespace, &namespace_len, &zbulk, php_phongo_bulkwrite_ce, &zwrite_concern, php_phongo_writeconcern_ce) == FAILURE) {
return;
}
bulk = Z_BULKWRITE_OBJ_P(zbulk);
phongo_execute_write(getThis(), namespace, bulk, phongo_write_concern_from_zval(zwrite_concern TSRMLS_CC), -1, return_value, return_value_used TSRMLS_CC);
}
/* }}} */
/* {{{ proto MongoDB\Driver\ReadConcern Manager::getReadConcern()
Returns the ReadConcern associated with this Manager */
PHP_METHOD(Manager, getReadConcern)
{
php_phongo_manager_t *intern;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (return_value_used) {
phongo_readconcern_init(return_value, mongoc_client_get_read_concern(intern->client) TSRMLS_CC);
}
}
/* }}} */
/* {{{ proto MongoDB\Driver\ReadPreference Manager::getReadPreference()
Returns the ReadPreference associated with this Manager */
PHP_METHOD(Manager, getReadPreference)
{
php_phongo_manager_t *intern;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (return_value_used) {
phongo_readpreference_init(return_value, mongoc_client_get_read_prefs(intern->client) TSRMLS_CC);
}
}
/* }}} */
/* {{{ proto MongoDB\Driver\Server[] Manager::getServers()
Returns the Servers associated with this Manager */
PHP_METHOD(Manager, getServers)
{
php_phongo_manager_t *intern;
mongoc_server_description_t **sds;
size_t i, n = 0;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
sds = mongoc_client_get_server_descriptions(intern->client, &n);
array_init_size(return_value, n);
for (i = 0; i < n; i++) {
#if PHP_VERSION_ID >= 70000
zval obj;
phongo_server_init(&obj, getThis(), mongoc_server_description_id(sds[i]) TSRMLS_CC);
add_next_index_zval(return_value, &obj);
#else
zval *obj = NULL;
MAKE_STD_ZVAL(obj);
phongo_server_init(obj, getThis(), mongoc_server_description_id(sds[i]) TSRMLS_CC);
add_next_index_zval(return_value, obj);
#endif
}
mongoc_server_descriptions_destroy_all(sds, n);
}
/* }}} */
/* {{{ proto MongoDB\Driver\WriteConcern Manager::getWriteConcern()
Returns the WriteConcern associated with this Manager */
PHP_METHOD(Manager, getWriteConcern)
{
php_phongo_manager_t *intern;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (return_value_used) {
phongo_writeconcern_init(return_value, mongoc_client_get_write_concern(intern->client) TSRMLS_CC);
}
}
/* }}} */
/* {{{ proto MongoDB\Driver\Server Manager::selectServers(MongoDB\Driver\ReadPreference $readPreference)
Returns a suitable Server for the given ReadPreference */
PHP_METHOD(Manager, selectServer)
{
php_phongo_manager_t *intern;
zval *zreadPreference = NULL;
const mongoc_read_prefs_t *readPreference;
bson_error_t error;
mongoc_server_description_t *selected_server = NULL;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zreadPreference, php_phongo_readpreference_ce) == FAILURE) {
return;
}
readPreference = phongo_read_preference_from_zval(zreadPreference TSRMLS_CC);
selected_server = mongoc_client_select_server(intern->client, false, readPreference, &error);
if (selected_server) {
phongo_server_init(return_value, getThis(), mongoc_server_description_id(selected_server) TSRMLS_CC);
mongoc_server_description_destroy(selected_server);
} else {
/* Check for connection related exceptions */
if (EG(exception)) {
return;
}
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
}
}
/* }}} */
/* {{{ proto void MongoDB\Driver\Manager::__wakeup()
Throws MongoDB\Driver\RuntimeException (serialization is not supported) */
PHP_METHOD(Manager, __wakeup)
{
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(this_ptr)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "%s", "MongoDB\\Driver objects cannot be serialized");
}
/* }}} */
/**
* Manager abstracts a cluster of Server objects (i.e. socket connections).
*
* Typically, users will connect to a cluster using a URI, and the Manager will
* perform tasks such as replica set discovery and create the necessary Server
* objects. That said, it is also possible to create a Manager with an arbitrary
* collection of Server objects using the static factory method (this can be
* useful for testing or administration).
*
* Operation methods do not take socket-level options (e.g. socketTimeoutMS).
* Those options should be specified during construction.
*/
/* {{{ MongoDB\Driver\Manager */
ZEND_BEGIN_ARG_INFO_EX(ai_Manager___construct, 0, 0, 0)
ZEND_ARG_INFO(0, uri)
ZEND_ARG_ARRAY_INFO(0, options, 0)
ZEND_ARG_ARRAY_INFO(0, driverOptions, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeCommand, 0, 0, 2)
ZEND_ARG_INFO(0, db)
ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0)
ZEND_ARG_OBJ_INFO(0, readPreference, MongoDB\\Driver\\ReadPreference, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeQuery, 0, 0, 2)
ZEND_ARG_INFO(0, namespace)
ZEND_ARG_OBJ_INFO(0, zquery, MongoDB\\Driver\\Query, 0)
ZEND_ARG_OBJ_INFO(0, readPreference, MongoDB\\Driver\\ReadPreference, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeBulkWrite, 0, 0, 2)
ZEND_ARG_INFO(0, namespace)
ZEND_ARG_OBJ_INFO(0, zbulk, MongoDB\\Driver\\BulkWrite, 0)
ZEND_ARG_OBJ_INFO(0, writeConcern, MongoDB\\Driver\\WriteConcern, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_selectServer, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, readPreference, MongoDB\\Driver\\ReadPreference, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_manager_me[] = {
PHP_ME(Manager, __construct, ai_Manager___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, executeCommand, ai_Manager_executeCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, executeQuery, ai_Manager_executeQuery, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, executeBulkWrite, ai_Manager_executeBulkWrite, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, getReadConcern, ai_Manager_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, getReadPreference, ai_Manager_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, getServers, ai_Manager_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, getWriteConcern, ai_Manager_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, selectServer, ai_Manager_selectServer, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeup, ai_Manager_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_manager_t object handlers */
static void php_phongo_manager_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_manager_t *intern = Z_OBJ_MANAGER(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->client) {
MONGOC_DEBUG("Not destroying persistent client for Manager");
intern->client = NULL;
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_manager_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_manager_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_manager_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_manager;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_manager_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_manager;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_manager_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_manager_t *intern;
mongoc_server_description_t **sds;
size_t i, n = 0;
#if PHP_VERSION_ID >= 70000
zval retval, cluster;
#else
zval retval = zval_used_for_init;
zval *cluster = NULL;
#endif
*is_temp = 1;
intern = Z_MANAGER_OBJ_P(object);
array_init_size(&retval, 2);
ADD_ASSOC_STRING(&retval, "uri", mongoc_uri_get_string(mongoc_client_get_uri(intern->client)));
sds = mongoc_client_get_server_descriptions(intern->client, &n);
#if PHP_VERSION_ID >= 70000
array_init_size(&cluster, n);
for (i = 0; i < n; i++) {
zval obj;
php_phongo_server_to_zval(&obj, sds[i]);
add_next_index_zval(&cluster, &obj);
}
ADD_ASSOC_ZVAL_EX(&retval, "cluster", &cluster);
#else
MAKE_STD_ZVAL(cluster);
array_init_size(cluster, n);
for (i = 0; i < n; i++) {
zval *obj = NULL;
MAKE_STD_ZVAL(obj);
php_phongo_server_to_zval(obj, sds[i]);
add_next_index_zval(cluster, obj);
}
ADD_ASSOC_ZVAL_EX(&retval, "cluster", cluster);
#endif
mongoc_server_descriptions_destroy_all(sds, n);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Manager)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Manager", php_phongo_manager_me);
php_phongo_manager_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_manager_ce->create_object = php_phongo_manager_create_object;
PHONGO_CE_FINAL(php_phongo_manager_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_manager_ce);
memcpy(&php_phongo_handler_manager, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_manager.get_debug_info = php_phongo_manager_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_manager.free_obj = php_phongo_manager_free_object;
php_phongo_handler_manager.offset = XtOffsetOf(php_phongo_manager_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/MongoDB/Query.c b/mongodb-1.2.3/src/MongoDB/Query.c
similarity index 91%
rename from mongodb-1.2.0/src/MongoDB/Query.c
rename to mongodb-1.2.3/src/MongoDB/Query.c
index 3e643032..d0fe0a51 100644
--- a/mongodb-1.2.0/src/MongoDB/Query.c
+++ b/mongodb-1.2.3/src/MongoDB/Query.c
@@ -1,506 +1,500 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* PHP array helpers */
#include "php_array_api.h"
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_query_ce;
zend_object_handlers php_phongo_handler_query;
/* Appends a string field into the BSON options. Returns true on
* success; otherwise, false is returned and an exception is thrown. */
static bool php_phongo_query_opts_append_string(bson_t *opts, const char *opts_key, zval *zarr, const char *zarr_key TSRMLS_DC)
{
zval *value = php_array_fetch(zarr, zarr_key);
if (Z_TYPE_P(value) != IS_STRING) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"%s\" %s to be string, %s given", zarr_key, zarr_key[0] == '$' ? "modifier" : "option", zend_get_type_by_const(Z_TYPE_P(value)));
return false;
}
if (!bson_append_utf8(opts, opts_key, strlen(opts_key), Z_STRVAL_P(value), Z_STRLEN_P(value))) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"%s\" option", opts_key);
return false;
}
return true;
}
/* Appends a document field for the given opts document and key. Returns true on
* success; otherwise, false is returned and an exception is thrown. */
static bool php_phongo_query_opts_append_document(bson_t *opts, const char *opts_key, zval *zarr, const char *zarr_key TSRMLS_DC)
{
zval *value = php_array_fetch(zarr, zarr_key);
bson_t b = BSON_INITIALIZER;
if (Z_TYPE_P(value) != IS_OBJECT && Z_TYPE_P(value) != IS_ARRAY) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"%s\" %s to be array or object, %s given", zarr_key, zarr_key[0] == '$' ? "modifier" : "option", zend_get_type_by_const(Z_TYPE_P(value)));
return false;
}
phongo_zval_to_bson(value, PHONGO_BSON_NONE, &b, NULL TSRMLS_CC);
if (EG(exception)) {
bson_destroy(&b);
return false;
}
if (!BSON_APPEND_DOCUMENT(opts, opts_key, &b)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"%s\" option", opts_key);
bson_destroy(&b);
return false;
}
bson_destroy(&b);
return true;
}
#define PHONGO_QUERY_OPT_BOOL(opt, zarr, key) \
if ((zarr) && php_array_existsc((zarr), (key))) { \
if (!BSON_APPEND_BOOL(intern->opts, (opt), php_array_fetchc_bool((zarr), (key)))) { \
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"%s\" option", (opt)); \
return false; \
} \
}
#define PHONGO_QUERY_OPT_DOCUMENT(opt, zarr, key) \
if ((zarr) && php_array_existsc((zarr), (key))) { \
if (!php_phongo_query_opts_append_document(intern->opts, (opt), (zarr), (key) TSRMLS_CC)) { \
return false; \
} \
}
/* Note: handling of integer options will depend on SIZEOF_ZEND_LONG and we
* are not converting strings to 64-bit integers for 32-bit platforms. */
#define PHONGO_QUERY_OPT_INT64(opt, zarr, key) \
if ((zarr) && php_array_existsc((zarr), (key))) { \
if (!BSON_APPEND_INT64(intern->opts, (opt), php_array_fetchc_long((zarr), (key)))) { \
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"%s\" option", (opt)); \
return false; \
} \
}
#define PHONGO_QUERY_OPT_STRING(opt, zarr, key) \
if ((zarr) && php_array_existsc((zarr), (key))) { \
if (!php_phongo_query_opts_append_string(intern->opts, (opt), (zarr), (key) TSRMLS_CC)) { \
return false; \
} \
}
/* Initialize the "hint" option. Returns true on success; otherwise, false is
* returned and an exception is thrown.
*
* The "hint" option (or "$hint" modifier) must be a string or document. Check
* for both types and merge into BSON options accordingly. */
static bool php_phongo_query_init_hint(php_phongo_query_t *intern, zval *options, zval *modifiers TSRMLS_DC) /* {{{ */
{
/* The "hint" option (or "$hint" modifier) must be a string or document.
* Check for both types and merge into BSON options accordingly. */
if (php_array_existsc(options, "hint")) {
zend_uchar type = Z_TYPE_P(php_array_fetchc(options, "hint"));
if (type == IS_STRING) {
PHONGO_QUERY_OPT_STRING("hint", options, "hint");
} else if (type == IS_OBJECT || type == IS_ARRAY) {
PHONGO_QUERY_OPT_DOCUMENT("hint", options, "hint");
} else {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"hint\" option to be string, array, or object, %s given", zend_get_type_by_const(type));
return false;
}
} else if (modifiers && php_array_existsc(modifiers, "$hint")) {
zend_uchar type = Z_TYPE_P(php_array_fetchc(modifiers, "$hint"));
if (type == IS_STRING) {
PHONGO_QUERY_OPT_STRING("hint", modifiers, "$hint");
} else if (type == IS_OBJECT || type == IS_ARRAY) {
PHONGO_QUERY_OPT_DOCUMENT("hint", modifiers, "$hint");
} else {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"$hint\" modifier to be string, array, or object, %s given", zend_get_type_by_const(type));
return false;
}
}
return true;
} /* }}} */
/* Initialize the "limit" and "singleBatch" options. Returns true on success;
* otherwise, false is returned and an exception is thrown.
*
* mongoc_collection_find_with_opts() requires a non-negative limit. For
* backwards compatibility, a negative limit should be set as a positive value
* and default singleBatch to true. */
static bool php_phongo_query_init_limit_and_singlebatch(php_phongo_query_t *intern, zval *options TSRMLS_DC) /* {{{ */
{
if (php_array_existsc(options, "limit") && php_array_fetchc_long(options, "limit") < 0) {
phongo_long limit = php_array_fetchc_long(options, "limit");
if (!BSON_APPEND_INT64(intern->opts, "limit", -limit)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"limit\" option");
return false;
}
if (php_array_existsc(options, "singleBatch") && !php_array_fetchc_bool(options, "singleBatch")) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Negative \"limit\" option conflicts with false \"singleBatch\" option");
return false;
} else {
if (!BSON_APPEND_BOOL(intern->opts, "singleBatch", true)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"singleBatch\" option");
return false;
}
}
} else {
PHONGO_QUERY_OPT_INT64("limit", options, "limit");
PHONGO_QUERY_OPT_BOOL("singleBatch", options, "singleBatch");
}
return true;
} /* }}} */
/* Initialize the "readConcern" option. Returns true on success; otherwise,
* false is returned and an exception is thrown.
*
* The "readConcern" option should be a MongoDB\Driver\ReadConcern instance,
* which must be converted to a mongoc_read_concern_t. */
static bool php_phongo_query_init_readconcern(php_phongo_query_t *intern, zval *options TSRMLS_DC) /* {{{ */
{
if (php_array_existsc(options, "readConcern")) {
zval *read_concern = php_array_fetchc(options, "readConcern");
if (Z_TYPE_P(read_concern) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(read_concern), php_phongo_readconcern_ce TSRMLS_CC)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"readConcern\" option to be %s, %s given", ZSTR_VAL(php_phongo_readconcern_ce->name), zend_get_type_by_const(Z_TYPE_P(read_concern)));
return false;
}
intern->read_concern = mongoc_read_concern_copy(phongo_read_concern_from_zval(read_concern TSRMLS_CC));
}
return true;
} /* }}} */
/* Initializes the php_phongo_query_t from filter and options arguments. This
* function will fall back to a modifier in the absence of a top-level option
* (where applicable). */
static bool php_phongo_query_init(php_phongo_query_t *intern, zval *filter, zval *options TSRMLS_DC) /* {{{ */
{
zval *modifiers = NULL;
intern->filter = bson_new();
intern->opts = bson_new();
phongo_zval_to_bson(filter, PHONGO_BSON_NONE, intern->filter, NULL TSRMLS_CC);
/* Note: if any exceptions are thrown, we can simply return as PHP will
* invoke php_phongo_query_free_object to destruct the object. */
if (EG(exception)) {
return false;
}
if (!options) {
return true;
}
if (php_array_existsc(options, "modifiers")) {
modifiers = php_array_fetchc(options, "modifiers");
if (Z_TYPE_P(modifiers) != IS_ARRAY) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"modifiers\" option to be array, %s given", zend_get_type_by_const(Z_TYPE_P(modifiers)));
return false;
}
}
PHONGO_QUERY_OPT_BOOL("allowPartialResults", options, "allowPartialResults")
else PHONGO_QUERY_OPT_BOOL("allowPartialResults", options, "partial");
PHONGO_QUERY_OPT_BOOL("awaitData", options, "awaitData");
PHONGO_QUERY_OPT_INT64("batchSize", options, "batchSize");
PHONGO_QUERY_OPT_DOCUMENT("collation", options, "collation");
PHONGO_QUERY_OPT_STRING("comment", options, "comment")
else PHONGO_QUERY_OPT_STRING("comment", modifiers, "$comment");
PHONGO_QUERY_OPT_BOOL("exhaust", options, "exhaust");
PHONGO_QUERY_OPT_DOCUMENT("max", options, "max")
else PHONGO_QUERY_OPT_DOCUMENT("max", modifiers, "$max");
PHONGO_QUERY_OPT_INT64("maxScan", options, "maxScan")
else PHONGO_QUERY_OPT_INT64("maxScan", modifiers, "$maxScan");
PHONGO_QUERY_OPT_INT64("maxTimeMS", options, "maxTimeMS")
else PHONGO_QUERY_OPT_INT64("maxTimeMS", modifiers, "$maxTimeMS");
PHONGO_QUERY_OPT_DOCUMENT("min", options, "min")
else PHONGO_QUERY_OPT_DOCUMENT("min", modifiers, "$min");
PHONGO_QUERY_OPT_BOOL("noCursorTimeout", options, "noCursorTimeout");
PHONGO_QUERY_OPT_BOOL("oplogReplay", options, "oplogReplay");
PHONGO_QUERY_OPT_DOCUMENT("projection", options, "projection");
PHONGO_QUERY_OPT_BOOL("returnKey", options, "returnKey")
else PHONGO_QUERY_OPT_BOOL("returnKey", modifiers, "$returnKey");
PHONGO_QUERY_OPT_BOOL("showRecordId", options, "showRecordId")
else PHONGO_QUERY_OPT_BOOL("showRecordId", modifiers, "$showDiskLoc");
PHONGO_QUERY_OPT_INT64("skip", options, "skip");
PHONGO_QUERY_OPT_DOCUMENT("sort", options, "sort")
else PHONGO_QUERY_OPT_DOCUMENT("sort", modifiers, "$orderby");
PHONGO_QUERY_OPT_BOOL("snapshot", options, "snapshot")
else PHONGO_QUERY_OPT_BOOL("snapshot", modifiers, "$snapshot");
PHONGO_QUERY_OPT_BOOL("tailable", options, "tailable");
/* The "$explain" modifier should be converted to an "explain" option, which
* libmongoc will later convert back to a modifier for the OP_QUERY code
* path. This modifier will be ignored for the find command code path. */
PHONGO_QUERY_OPT_BOOL("explain", modifiers, "$explain");
if (!php_phongo_query_init_hint(intern, options, modifiers TSRMLS_CC)) {
return false;
}
if (!php_phongo_query_init_limit_and_singlebatch(intern, options TSRMLS_CC)) {
return false;
}
if (!php_phongo_query_init_readconcern(intern, options TSRMLS_CC)) {
return false;
}
return true;
} /* }}} */
#undef PHONGO_QUERY_OPT_BOOL
#undef PHONGO_QUERY_OPT_DOCUMENT
#undef PHONGO_QUERY_OPT_INT64
#undef PHONGO_QUERY_OPT_STRING
/* {{{ proto void Query::__construct(array|object $filter[, array $options = array()])
Constructs a new Query */
PHP_METHOD(Query, __construct)
{
php_phongo_query_t *intern;
zend_error_handling error_handling;
zval *filter;
zval *options = NULL;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_QUERY_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "A|a!", &filter, &options) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
php_phongo_query_init(intern, filter, options TSRMLS_CC);
}
/* }}} */
/* {{{ MongoDB\Driver\Query */
ZEND_BEGIN_ARG_INFO_EX(ai_Query___construct, 0, 0, 1)
ZEND_ARG_INFO(0, filter)
ZEND_ARG_ARRAY_INFO(0, options, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Query_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_query_me[] = {
PHP_ME(Query, __construct, ai_Query___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeup, ai_Query_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_query_t object handlers */
static void php_phongo_query_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_query_t *intern = Z_OBJ_QUERY(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->filter) {
bson_clear(&intern->filter);
}
if (intern->opts) {
bson_clear(&intern->opts);
}
if (intern->read_concern) {
mongoc_read_concern_destroy(intern->read_concern);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_query_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_query_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_query_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_query;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_query_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_query;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_query_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_query_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_QUERY_OBJ_P(object);
array_init_size(&retval, 3);
/* Avoid using PHONGO_TYPEMAP_NATIVE_ARRAY for decoding filter and opts
* documents so that users can differentiate BSON arrays and documents. */
if (intern->filter) {
#if PHP_VERSION_ID >= 70000
zval zv;
#else
zval *zv;
#endif
phongo_bson_to_zval(bson_get_data(intern->filter), intern->filter->len, &zv);
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(&retval, "filter", &zv);
#else
ADD_ASSOC_ZVAL_EX(&retval, "filter", zv);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "filter");
}
if (intern->opts) {
#if PHP_VERSION_ID >= 70000
zval zv;
#else
zval *zv;
#endif
phongo_bson_to_zval(bson_get_data(intern->opts), intern->opts->len, &zv);
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(&retval, "options", &zv);
#else
ADD_ASSOC_ZVAL_EX(&retval, "options", zv);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "options");
}
if (intern->read_concern) {
#if PHP_VERSION_ID >= 70000
zval read_concern;
php_phongo_read_concern_to_zval(&read_concern, intern->read_concern);
ADD_ASSOC_ZVAL_EX(&retval, "readConcern", &read_concern);
#else
zval *read_concern = NULL;
MAKE_STD_ZVAL(read_concern);
php_phongo_read_concern_to_zval(read_concern, intern->read_concern);
ADD_ASSOC_ZVAL_EX(&retval, "readConcern", read_concern);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "readConcern");
}
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Query)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Query", php_phongo_query_me);
php_phongo_query_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_query_ce->create_object = php_phongo_query_create_object;
PHONGO_CE_FINAL(php_phongo_query_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_query_ce);
memcpy(&php_phongo_handler_query, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_query.get_debug_info = php_phongo_query_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_query.free_obj = php_phongo_query_free_object;
php_phongo_handler_query.offset = XtOffsetOf(php_phongo_query_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/MongoDB/ReadConcern.c b/mongodb-1.2.3/src/MongoDB/ReadConcern.c
similarity index 80%
rename from mongodb-1.2.0/src/MongoDB/ReadConcern.c
rename to mongodb-1.2.3/src/MongoDB/ReadConcern.c
index 72b6921d..2a7f9e2b 100644
--- a/mongodb-1.2.0/src/MongoDB/ReadConcern.c
+++ b/mongodb-1.2.3/src/MongoDB/ReadConcern.c
@@ -1,236 +1,230 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2015-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_readconcern_ce;
zend_object_handlers php_phongo_handler_readconcern;
/* {{{ proto void ReadConcern::__construct([string $level])
Constructs a new ReadConcern */
PHP_METHOD(ReadConcern, __construct)
{
php_phongo_readconcern_t *intern;
zend_error_handling error_handling;
char *level = NULL;
phongo_zpp_char_len level_len = 0;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_READCONCERN_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &level, &level_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
intern->read_concern = mongoc_read_concern_new();
if (level) {
mongoc_read_concern_set_level(intern->read_concern, level);
}
}
/* }}} */
/* {{{ proto string|null ReadConcern::getLevel()
Returns the ReadConcern "level" option */
PHP_METHOD(ReadConcern, getLevel)
{
php_phongo_readconcern_t *intern;
const char *level;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_READCONCERN_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
level = mongoc_read_concern_get_level(intern->read_concern);
if (level) {
PHONGO_RETURN_STRING(level);
}
RETURN_NULL();
}
/* }}} */
/* {{{ proto array ReadConcern::bsonSerialize()
*/
PHP_METHOD(ReadConcern, bsonSerialize)
{
const mongoc_read_concern_t *read_concern = phongo_read_concern_from_zval(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
php_phongo_read_concern_to_zval(return_value, read_concern);
convert_to_object(return_value);
}
/* }}} */
/**
* Value object for read concern used in issuing read operations.
*/
/* {{{ MongoDB\Driver\ReadConcern */
ZEND_BEGIN_ARG_INFO_EX(ai_ReadConcern___construct, 0, 0, 0)
ZEND_ARG_INFO(0, level)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_ReadConcern_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_readconcern_me[] = {
PHP_ME(ReadConcern, __construct, ai_ReadConcern___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ReadConcern, getLevel, ai_ReadConcern_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ReadConcern, bsonSerialize, ai_ReadConcern_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_readconcern_t object handlers */
static void php_phongo_readconcern_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_readconcern_t *intern = Z_OBJ_READCONCERN(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->read_concern) {
mongoc_read_concern_destroy(intern->read_concern);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_readconcern_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_readconcern_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_readconcern_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_readconcern;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_readconcern_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_readconcern;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_readconcern_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
const mongoc_read_concern_t *read_concern = phongo_read_concern_from_zval(object TSRMLS_CC);
*is_temp = 1;
php_phongo_read_concern_to_zval(&retval, read_concern);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(ReadConcern)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ReadConcern", php_phongo_readconcern_me);
php_phongo_readconcern_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_readconcern_ce->create_object = php_phongo_readconcern_create_object;
PHONGO_CE_FINAL(php_phongo_readconcern_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_readconcern_ce);
zend_class_implements(php_phongo_readconcern_ce TSRMLS_CC, 1, php_phongo_serializable_ce);
memcpy(&php_phongo_handler_readconcern, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_readconcern.get_debug_info = php_phongo_readconcern_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_readconcern.free_obj = php_phongo_readconcern_free_object;
php_phongo_handler_readconcern.offset = XtOffsetOf(php_phongo_readconcern_t, std);
#endif
zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("LOCAL"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_LOCAL) TSRMLS_CC);
zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("MAJORITY"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_MAJORITY) TSRMLS_CC);
zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("LINEARIZABLE"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_LINEARIZABLE) TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/MongoDB/ReadPreference.c b/mongodb-1.2.3/src/MongoDB/ReadPreference.c
similarity index 86%
rename from mongodb-1.2.0/src/MongoDB/ReadPreference.c
rename to mongodb-1.2.3/src/MongoDB/ReadPreference.c
index 419c2860..e09cfae2 100644
--- a/mongodb-1.2.0/src/MongoDB/ReadPreference.c
+++ b/mongodb-1.2.3/src/MongoDB/ReadPreference.c
@@ -1,347 +1,343 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* PHP array helpers */
#include "php_array_api.h"
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_readpreference_ce;
zend_object_handlers php_phongo_handler_readpreference;
/* {{{ proto void ReadPreference::__construct(integer $mode[, array $tagSets = array()[, array $options = array()]])
Constructs a new ReadPreference */
PHP_METHOD(ReadPreference, __construct)
{
php_phongo_readpreference_t *intern;
zend_error_handling error_handling;
phongo_long mode;
zval *tagSets = NULL;
zval *options = NULL;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_READPREFERENCE_OBJ_P(getThis());
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|a!a!", &mode, &tagSets, &options) == FAILURE) {
+ /* Separate the tagSets zval, since we may end up modifying it in
+ * php_phongo_read_preference_prep_tagsets() below. */
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|a/!a!", &mode, &tagSets, &options) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
switch(mode) {
case MONGOC_READ_PRIMARY:
case MONGOC_READ_SECONDARY:
case MONGOC_READ_PRIMARY_PREFERRED:
case MONGOC_READ_SECONDARY_PREFERRED:
case MONGOC_READ_NEAREST:
intern->read_preference = mongoc_read_prefs_new(mode);
break;
default:
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Invalid mode: %" PHONGO_LONG_FORMAT, mode);
return;
}
if (tagSets) {
bson_t *tags = bson_new();
php_phongo_read_preference_prep_tagsets(tagSets TSRMLS_CC);
phongo_zval_to_bson(tagSets, PHONGO_BSON_NONE, (bson_t *)tags, NULL TSRMLS_CC);
if (!php_phongo_read_preference_tags_are_valid(tags)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "tagSets must be an array of zero or more documents");
bson_destroy(tags);
return;
}
if (!bson_empty(tags) && mode == MONGOC_READ_PRIMARY) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "tagSets may not be used with primary mode");
bson_destroy(tags);
return;
}
mongoc_read_prefs_set_tags(intern->read_preference, tags);
bson_destroy(tags);
}
if (options && php_array_exists(options, "maxStalenessSeconds")) {
phongo_long maxStalenessSeconds = php_array_fetchc_long(options, "maxStalenessSeconds");
if (maxStalenessSeconds != MONGOC_NO_MAX_STALENESS) {
if (maxStalenessSeconds < MONGOC_SMALLEST_MAX_STALENESS_SECONDS) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected maxStalenessSeconds to be >= %d, %" PHONGO_LONG_FORMAT " given", MONGOC_SMALLEST_MAX_STALENESS_SECONDS, maxStalenessSeconds);
return;
}
if (maxStalenessSeconds > INT32_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected maxStalenessSeconds to be <= %" PRId32 ", %" PHONGO_LONG_FORMAT " given", INT32_MAX, maxStalenessSeconds);
return;
}
if (mode == MONGOC_READ_PRIMARY) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "maxStalenessSeconds may not be used with primary mode");
return;
}
}
mongoc_read_prefs_set_max_staleness_seconds(intern->read_preference, maxStalenessSeconds);
}
if (!mongoc_read_prefs_is_valid(intern->read_preference)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Read preference is not valid");
return;
}
}
/* }}} */
/* {{{ proto integer ReadPreference::getMaxStalenessSeconds()
Returns the ReadPreference maxStalenessSeconds value */
PHP_METHOD(ReadPreference, getMaxStalenessSeconds)
{
php_phongo_readpreference_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_READPREFERENCE_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(mongoc_read_prefs_get_max_staleness_seconds(intern->read_preference));
}
/* }}} */
/* {{{ proto integer ReadPreference::getMode()
Returns the ReadPreference mode */
PHP_METHOD(ReadPreference, getMode)
{
php_phongo_readpreference_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_READPREFERENCE_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(mongoc_read_prefs_get_mode(intern->read_preference));
}
/* }}} */
/* {{{ proto array ReadPreference::getTagSets()
Returns the ReadPreference tag sets */
PHP_METHOD(ReadPreference, getTagSets)
{
php_phongo_readpreference_t *intern;
const bson_t *tags;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_READPREFERENCE_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
tags = mongoc_read_prefs_get_tags(intern->read_preference);
if (tags->len) {
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
/* Use native arrays for debugging output */
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
phongo_bson_to_zval_ex(bson_get_data(tags), tags->len, &state);
#if PHP_VERSION_ID >= 70000
RETURN_ZVAL(&state.zchild, 0, 1);
#else
RETURN_ZVAL(state.zchild, 0, 1);
#endif
} else {
RETURN_NULL();
}
}
/* }}} */
/* {{{ proto array ReadPreference::bsonSerialize()
*/
PHP_METHOD(ReadPreference, bsonSerialize)
{
const mongoc_read_prefs_t *read_preference = phongo_read_preference_from_zval(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
php_phongo_read_preference_to_zval(return_value, read_preference);
convert_to_object(return_value);
}
/* }}} */
/**
* Value object for read preferences used in issuing commands and queries.
*/
/* {{{ MongoDB\Driver\ReadPreference */
ZEND_BEGIN_ARG_INFO_EX(ai_ReadPreference___construct, 0, 0, 1)
ZEND_ARG_INFO(0, mode)
ZEND_ARG_ARRAY_INFO(0, tagSets, 1)
ZEND_ARG_ARRAY_INFO(0, options, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_ReadPreference_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_readpreference_me[] = {
PHP_ME(ReadPreference, __construct, ai_ReadPreference___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ReadPreference, getMaxStalenessSeconds, ai_ReadPreference_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ReadPreference, getMode, ai_ReadPreference_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ReadPreference, getTagSets, ai_ReadPreference_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ReadPreference, bsonSerialize, ai_ReadPreference_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_readpreference_t object handlers */
static void php_phongo_readpreference_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_readpreference_t *intern = Z_OBJ_READPREFERENCE(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->read_preference) {
mongoc_read_prefs_destroy(intern->read_preference);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_readpreference_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_readpreference_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_readpreference_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_readpreference;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_readpreference_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_readpreference;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_readpreference_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
const mongoc_read_prefs_t *read_prefs = phongo_read_preference_from_zval(object TSRMLS_CC);
*is_temp = 1;
php_phongo_read_preference_to_zval(&retval, read_prefs);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(ReadPreference)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ReadPreference", php_phongo_readpreference_me);
php_phongo_readpreference_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_readpreference_ce->create_object = php_phongo_readpreference_create_object;
PHONGO_CE_FINAL(php_phongo_readpreference_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_readpreference_ce);
zend_class_implements(php_phongo_readpreference_ce TSRMLS_CC, 1, php_phongo_serializable_ce);
memcpy(&php_phongo_handler_readpreference, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_readpreference.get_debug_info = php_phongo_readpreference_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_readpreference.free_obj = php_phongo_readpreference_free_object;
php_phongo_handler_readpreference.offset = XtOffsetOf(php_phongo_readpreference_t, std);
#endif
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_PRIMARY"), MONGOC_READ_PRIMARY TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_PRIMARY_PREFERRED"), MONGOC_READ_PRIMARY_PREFERRED TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_SECONDARY"), MONGOC_READ_SECONDARY TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_SECONDARY_PREFERRED"), MONGOC_READ_SECONDARY_PREFERRED TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_NEAREST"), MONGOC_READ_NEAREST TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("NO_MAX_STALENESS"), MONGOC_NO_MAX_STALENESS TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("SMALLEST_MAX_STALENESS_SECONDS"), MONGOC_SMALLEST_MAX_STALENESS_SECONDS TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/MongoDB/Server.c b/mongodb-1.2.3/src/MongoDB/Server.c
similarity index 93%
rename from mongodb-1.2.0/src/MongoDB/Server.c
rename to mongodb-1.2.3/src/MongoDB/Server.c
index a8fa6b46..b30725c1 100644
--- a/mongodb-1.2.0/src/MongoDB/Server.c
+++ b/mongodb-1.2.3/src/MongoDB/Server.c
@@ -1,643 +1,637 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <ext/standard/file.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_server_ce;
zend_object_handlers php_phongo_handler_server;
/* {{{ proto void Server::__construct()
Throws MongoDB\Driver\RuntimeException (can only be created internally) */
PHP_METHOD(Server, __construct)
{
SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used) SUPPRESS_UNUSED_WARNING(return_value_ptr) (void)ZEND_NUM_ARGS(); (void)getThis();
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Accessing private constructor");
}
/* }}} */
/* {{{ proto MongoDB\Driver\Cursor Server::executeCommand(string $db, MongoDB\Driver\Command $command[, MongoDB\Driver\ReadPreference $readPreference = null]))
Executes a Command on this Server */
PHP_METHOD(Server, executeCommand)
{
php_phongo_server_t *intern;
char *db;
phongo_zpp_char_len db_len;
zval *command;
zval *readPreference = NULL;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sO|O!", &db, &db_len, &command, php_phongo_command_ce, &readPreference, php_phongo_readpreference_ce) == FAILURE) {
return;
}
#if PHP_VERSION_ID >= 70000
phongo_execute_command(&intern->manager, db, command, readPreference, intern->server_id, return_value, return_value_used TSRMLS_CC);
#else
phongo_execute_command(intern->manager, db, command, readPreference, intern->server_id, return_value, return_value_used TSRMLS_CC);
#endif
}
/* }}} */
/* {{{ proto MongoDB\Driver\Cursor Server::executeQuery(string $namespace, MongoDB\Driver\Query $query[, MongoDB\Driver\ReadPreference $readPreference = null]))
Executes a Query on this Server */
PHP_METHOD(Server, executeQuery)
{
php_phongo_server_t *intern;
char *namespace;
phongo_zpp_char_len namespace_len;
zval *query;
zval *readPreference = NULL;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sO|O!", &namespace, &namespace_len, &query, php_phongo_query_ce, &readPreference, php_phongo_readpreference_ce) == FAILURE) {
return;
}
#if PHP_VERSION_ID >= 70000
phongo_execute_query(&intern->manager, namespace, query, readPreference, intern->server_id, return_value, return_value_used TSRMLS_CC);
#else
phongo_execute_query(intern->manager, namespace, query, readPreference, intern->server_id, return_value, return_value_used TSRMLS_CC);
#endif
}
/* }}} */
/* {{{ proto MongoDB\Driver\WriteResult Server::executeBulkWrite(string $namespace, MongoDB\Driver\BulkWrite $zbulk[, MongoDB\Driver\WriteConcern $writeConcern = null])
Executes a BulkWrite (i.e. any number of insert, update, and delete ops) on
this Server */
PHP_METHOD(Server, executeBulkWrite)
{
php_phongo_server_t *intern;
char *namespace;
phongo_zpp_char_len namespace_len;
zval *zbulk;
zval *zwrite_concern = NULL;
php_phongo_bulkwrite_t *bulk;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sO|O!", &namespace, &namespace_len, &zbulk, php_phongo_bulkwrite_ce, &zwrite_concern, php_phongo_writeconcern_ce) == FAILURE) {
return;
}
bulk = Z_BULKWRITE_OBJ_P(zbulk);
#if PHP_VERSION_ID >= 70000
phongo_execute_write(&intern->manager, namespace, bulk, phongo_write_concern_from_zval(zwrite_concern TSRMLS_CC), intern->server_id, return_value, return_value_used TSRMLS_CC);
#else
phongo_execute_write(intern->manager, namespace, bulk, phongo_write_concern_from_zval(zwrite_concern TSRMLS_CC), intern->server_id, return_value, return_value_used TSRMLS_CC);
#endif
}
/* }}} */
/* {{{ proto string Server::getHost()
Returns the hostname for this Server */
PHP_METHOD(Server, getHost)
{
php_phongo_server_t *intern;
mongoc_server_description_t *sd;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
PHONGO_RETVAL_STRING(mongoc_server_description_host(sd)->host);
mongoc_server_description_destroy(sd);
return;
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description");
}
/* }}} */
/* {{{ proto array Server::getTags()
Returns the currently configured tags for this Server */
PHP_METHOD(Server, getTags)
{
php_phongo_server_t *intern;
mongoc_server_description_t *sd;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
const bson_t *is_master = mongoc_server_description_ismaster(sd);
bson_iter_t iter;
if (bson_iter_init_find(&iter, is_master, "tags") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
const uint8_t *bytes;
uint32_t len;
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
bson_iter_document(&iter, &len, &bytes);
phongo_bson_to_zval_ex(bytes, len, &state);
mongoc_server_description_destroy(sd);
#if PHP_VERSION_ID >= 70000
RETURN_ZVAL(&state.zchild, 0, 1);
#else
RETURN_ZVAL(state.zchild, 0, 1);
#endif
}
array_init(return_value);
mongoc_server_description_destroy(sd);
return;
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description");
}
/* }}} */
/* {{{ proto array Server::getInfo()
Returns the last isMaster result document for this Server */
PHP_METHOD(Server, getInfo)
{
php_phongo_server_t *intern;
mongoc_server_description_t *sd;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
const bson_t *is_master = mongoc_server_description_ismaster(sd);
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
phongo_bson_to_zval_ex(bson_get_data(is_master), is_master->len, &state);
mongoc_server_description_destroy(sd);
#if PHP_VERSION_ID >= 70000
RETURN_ZVAL(&state.zchild, 0, 1);
#else
RETURN_ZVAL(state.zchild, 0, 1);
#endif
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description");
}
/* }}} */
/* {{{ proto integer Server::getLatency()
Returns the last messured latency for this Server */
PHP_METHOD(Server, getLatency)
{
php_phongo_server_t *intern;
mongoc_server_description_t *sd;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
RETVAL_LONG((phongo_long) mongoc_server_description_round_trip_time(sd));
mongoc_server_description_destroy(sd);
return;
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description");
}
/* }}} */
/* {{{ proto integer Server::getPort()
Returns the port for this Server */
PHP_METHOD(Server, getPort)
{
php_phongo_server_t *intern;
mongoc_server_description_t *sd;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
RETVAL_LONG(mongoc_server_description_host(sd)->port);
mongoc_server_description_destroy(sd);
return;
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description");
}
/* }}} */
/* {{{ proto integer Server::getType()
Returns the node type of this Server */
PHP_METHOD(Server, getType)
{
php_phongo_server_t *intern;
mongoc_server_description_t *sd;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
RETVAL_LONG(php_phongo_server_description_type(sd));
mongoc_server_description_destroy(sd);
return;
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description");
}
/* }}} */
/* {{{ proto bool Server::isPrimary()
Returns whether this Server is a primary member of a replica set */
PHP_METHOD(Server, isPrimary)
{
php_phongo_server_t *intern;
mongoc_server_description_t *sd;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
RETVAL_BOOL(!strcmp(mongoc_server_description_type(sd), php_phongo_server_description_type_map[PHONGO_SERVER_RS_PRIMARY].name));
mongoc_server_description_destroy(sd);
return;
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description");
}
/* }}} */
/* {{{ proto bool Server::isSecondary()
Returns whether this Server is a secondary member of a replica set */
PHP_METHOD(Server, isSecondary)
{
php_phongo_server_t *intern;
mongoc_server_description_t *sd;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
RETVAL_BOOL(!strcmp(mongoc_server_description_type(sd), php_phongo_server_description_type_map[PHONGO_SERVER_RS_SECONDARY].name));
mongoc_server_description_destroy(sd);
return;
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description");
}
/* }}} */
/* {{{ proto bool Server::isArbiter()
Returns whether this Server is an arbiter member of a replica set */
PHP_METHOD(Server, isArbiter)
{
php_phongo_server_t *intern;
mongoc_server_description_t *sd;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
RETVAL_BOOL(!strcmp(mongoc_server_description_type(sd), php_phongo_server_description_type_map[PHONGO_SERVER_RS_ARBITER].name));
mongoc_server_description_destroy(sd);
return;
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description");
}
/* }}} */
/* {{{ proto bool Server::isHidden()
Returns whether this Server is a hidden member of a replica set */
PHP_METHOD(Server, isHidden)
{
php_phongo_server_t *intern;
mongoc_server_description_t *sd;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
bson_iter_t iter;
RETVAL_BOOL(bson_iter_init_find_case(&iter, mongoc_server_description_ismaster(sd), "hidden") && bson_iter_as_bool(&iter));
mongoc_server_description_destroy(sd);
return;
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description");
}
/* }}} */
/* {{{ proto bool Server::isPassive()
Returns whether this Server is a passive member of a replica set */
PHP_METHOD(Server, isPassive)
{
php_phongo_server_t *intern;
mongoc_server_description_t *sd;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_SERVER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
bson_iter_t iter;
RETVAL_BOOL(bson_iter_init_find_case(&iter, mongoc_server_description_ismaster(sd), "passive") && bson_iter_as_bool(&iter));
mongoc_server_description_destroy(sd);
return;
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description");
}
/* }}} */
/* {{{ MongoDB\Driver\Server */
ZEND_BEGIN_ARG_INFO_EX(ai_Server_executeCommand, 0, 0, 2)
ZEND_ARG_INFO(0, db)
ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0)
ZEND_ARG_OBJ_INFO(0, readPreference, MongoDB\\Driver\\ReadPreference, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Server_executeQuery, 0, 0, 2)
ZEND_ARG_INFO(0, namespace)
ZEND_ARG_OBJ_INFO(0, zquery, MongoDB\\Driver\\Query, 0)
ZEND_ARG_OBJ_INFO(0, readPreference, MongoDB\\Driver\\ReadPreference, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Server_executeBulkWrite, 0, 0, 2)
ZEND_ARG_INFO(0, namespace)
ZEND_ARG_OBJ_INFO(0, zbulk, MongoDB\\Driver\\BulkWrite, 0)
ZEND_ARG_OBJ_INFO(0, writeConcern, MongoDB\\Driver\\WriteConcern, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_Server_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_server_me[] = {
PHP_ME(Server, __construct, ai_Server_void, ZEND_ACC_FINAL|ZEND_ACC_PRIVATE)
PHP_ME(Server, executeCommand, ai_Server_executeCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, executeQuery, ai_Server_executeQuery, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, executeBulkWrite, ai_Server_executeBulkWrite, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, getHost, ai_Server_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, getTags, ai_Server_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, getInfo, ai_Server_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, getLatency, ai_Server_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, getPort, ai_Server_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, getType, ai_Server_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, isPrimary, ai_Server_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, isSecondary, ai_Server_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, isArbiter, ai_Server_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, isHidden, ai_Server_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Server, isPassive, ai_Server_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeup, ai_Server_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ Other functions */
static int php_phongo_server_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
{
php_phongo_server_t *intern1, *intern2;
mongoc_server_description_t *sd1, *sd2;
int retval = 0;
intern1 = Z_SERVER_OBJ_P(o1);
intern2 = Z_SERVER_OBJ_P(o2);
sd1 = mongoc_client_get_server_description(intern1->client, intern1->server_id);
sd2 = mongoc_client_get_server_description(intern2->client, intern2->server_id);
if (sd1 && sd2) {
retval = strcasecmp(mongoc_server_description_host(sd1)->host_and_port, mongoc_server_description_host(sd2)->host_and_port);
} else {
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description(s)");
}
if (sd1) {
mongoc_server_description_destroy(sd1);
}
if (sd2) {
mongoc_server_description_destroy(sd2);
}
return retval;
} /* }}} */
/* }}} */
/* {{{ php_phongo_server_t object handlers */
static void php_phongo_server_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_server_t *intern = Z_OBJ_SERVER(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
zval_ptr_dtor(&intern->manager);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_server_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_server_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_server_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_server;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_server_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_server;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_server_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_server_t *intern = NULL;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
mongoc_server_description_t *sd;
*is_temp = 1;
intern = Z_SERVER_OBJ_P(object);
if (!(sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Failed to get server description");
return NULL;
}
php_phongo_server_to_zval(&retval, sd);
mongoc_server_description_destroy(sd);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Server)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Server", php_phongo_server_me);
php_phongo_server_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_server_ce->create_object = php_phongo_server_create_object;
PHONGO_CE_FINAL(php_phongo_server_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_server_ce);
memcpy(&php_phongo_handler_server, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_server.compare_objects = php_phongo_server_compare_objects;
php_phongo_handler_server.get_debug_info = php_phongo_server_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_server.free_obj = php_phongo_server_free_object;
php_phongo_handler_server.offset = XtOffsetOf(php_phongo_server_t, std);
#endif
zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_UNKNOWN"), PHONGO_SERVER_UNKNOWN TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_STANDALONE"), PHONGO_SERVER_STANDALONE TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_MONGOS"), PHONGO_SERVER_MONGOS TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_POSSIBLE_PRIMARY"), PHONGO_SERVER_POSSIBLE_PRIMARY TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_RS_PRIMARY"), PHONGO_SERVER_RS_PRIMARY TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_RS_SECONDARY"), PHONGO_SERVER_RS_SECONDARY TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_RS_ARBITER"), PHONGO_SERVER_RS_ARBITER TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_RS_OTHER"), PHONGO_SERVER_RS_OTHER TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_server_ce, ZEND_STRL("TYPE_RS_GHOST"), PHONGO_SERVER_RS_GHOST TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/MongoDB/WriteConcern.c b/mongodb-1.2.3/src/MongoDB/WriteConcern.c
similarity index 85%
rename from mongodb-1.2.0/src/MongoDB/WriteConcern.c
rename to mongodb-1.2.3/src/MongoDB/WriteConcern.c
index afea0060..7712e9ac 100644
--- a/mongodb-1.2.0/src/MongoDB/WriteConcern.c
+++ b/mongodb-1.2.3/src/MongoDB/WriteConcern.c
@@ -1,319 +1,313 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_writeconcern_ce;
zend_object_handlers php_phongo_handler_writeconcern;
/* {{{ proto void WriteConcern::__construct(integer|string $w[, integer $wtimeout[, boolean $journal]])
Constructs a new WriteConcern */
PHP_METHOD(WriteConcern, __construct)
{
php_phongo_writeconcern_t *intern;
zend_error_handling error_handling;
zval *w, *journal;
phongo_long wtimeout = 0;
SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_WRITECONCERN_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|lz", &w, &wtimeout, &journal) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
intern->write_concern = mongoc_write_concern_new();
if (Z_TYPE_P(w) == IS_LONG) {
if (Z_LVAL_P(w) < -3) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected w to be >= -3, %ld given", Z_LVAL_P(w));
return;
}
mongoc_write_concern_set_w(intern->write_concern, Z_LVAL_P(w));
} else if (Z_TYPE_P(w) == IS_STRING) {
if (strcmp(Z_STRVAL_P(w), PHONGO_WRITE_CONCERN_W_MAJORITY) == 0) {
mongoc_write_concern_set_w(intern->write_concern, MONGOC_WRITE_CONCERN_W_MAJORITY);
} else {
mongoc_write_concern_set_wtag(intern->write_concern, Z_STRVAL_P(w));
}
} else {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected w to be integer or string, %s given", zend_get_type_by_const(Z_TYPE_P(w)));
return;
}
switch(ZEND_NUM_ARGS()) {
case 3:
if (Z_TYPE_P(journal) != IS_NULL) {
#ifdef ZEND_ENGINE_3
mongoc_write_concern_set_journal(intern->write_concern, zend_is_true(journal));
#else
mongoc_write_concern_set_journal(intern->write_concern, Z_BVAL_P(journal));
#endif
}
/* fallthrough */
case 2:
if (wtimeout < 0) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected wtimeout to be >= 0, %" PHONGO_LONG_FORMAT " given", wtimeout);
return;
}
if (wtimeout > INT32_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected wtimeout to be <= %" PRId32 ", %" PHONGO_LONG_FORMAT " given", INT32_MAX, wtimeout);
return;
}
mongoc_write_concern_set_wtimeout(intern->write_concern, wtimeout);
}
}
/* }}} */
/* {{{ proto string|integer|null WriteConcern::getW()
Returns the WriteConcern "w" option */
PHP_METHOD(WriteConcern, getW)
{
php_phongo_writeconcern_t *intern;
const char *wtag;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITECONCERN_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
wtag = mongoc_write_concern_get_wtag(intern->write_concern);
if (wtag) {
PHONGO_RETURN_STRING(wtag);
}
if (mongoc_write_concern_get_wmajority(intern->write_concern)) {
PHONGO_RETURN_STRING(PHONGO_WRITE_CONCERN_W_MAJORITY);
}
if (mongoc_write_concern_get_w(intern->write_concern) != MONGOC_WRITE_CONCERN_W_DEFAULT) {
RETURN_LONG(mongoc_write_concern_get_w(intern->write_concern));
}
RETURN_NULL();
}
/* }}} */
/* {{{ proto integer WriteConcern::getWtimeout()
Returns the WriteConcern "wtimeout" option */
PHP_METHOD(WriteConcern, getWtimeout)
{
php_phongo_writeconcern_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITECONCERN_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(mongoc_write_concern_get_wtimeout(intern->write_concern));
}
/* }}} */
/* {{{ proto null|boolean WriteConcern::getJournal()
Returns the WriteConcern "journal" option */
PHP_METHOD(WriteConcern, getJournal)
{
php_phongo_writeconcern_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITECONCERN_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (mongoc_write_concern_journal_is_set(intern->write_concern)) {
RETURN_BOOL(mongoc_write_concern_get_journal(intern->write_concern));
}
RETURN_NULL();
}
/* }}} */
/* {{{ proto array WriteConcern::bsonSerialize()
*/
PHP_METHOD(WriteConcern, bsonSerialize)
{
const mongoc_write_concern_t *write_concern = phongo_write_concern_from_zval(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
php_phongo_write_concern_to_zval(return_value, write_concern);
convert_to_object(return_value);
}
/* }}} */
/**
* Value object for write concern used in issuing write operations.
*/
/* {{{ MongoDB\Driver\WriteConcern */
ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern___construct, 0, 0, 1)
ZEND_ARG_INFO(0, w)
ZEND_ARG_INFO(0, wtimeout)
ZEND_ARG_INFO(0, journal)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_writeconcern_me[] = {
PHP_ME(WriteConcern, __construct, ai_WriteConcern___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteConcern, getW, ai_WriteConcern_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteConcern, getWtimeout, ai_WriteConcern_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteConcern, getJournal, ai_WriteConcern_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteConcern, bsonSerialize, ai_WriteConcern_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_writeconcern_t object handlers */
static void php_phongo_writeconcern_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_writeconcern_t *intern = Z_OBJ_WRITECONCERN(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->write_concern) {
mongoc_write_concern_destroy(intern->write_concern);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_writeconcern_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_writeconcern_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_writeconcern_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_writeconcern;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_writeconcern_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_writeconcern;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_writeconcern_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
const mongoc_write_concern_t *write_concern = phongo_write_concern_from_zval(object TSRMLS_CC);
*is_temp = 1;
php_phongo_write_concern_to_zval(&retval, write_concern);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(WriteConcern)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "WriteConcern", php_phongo_writeconcern_me);
php_phongo_writeconcern_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_writeconcern_ce->create_object = php_phongo_writeconcern_create_object;
PHONGO_CE_FINAL(php_phongo_writeconcern_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_writeconcern_ce);
zend_class_implements(php_phongo_writeconcern_ce TSRMLS_CC, 1, php_phongo_serializable_ce);
memcpy(&php_phongo_handler_writeconcern, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_writeconcern.get_debug_info = php_phongo_writeconcern_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_writeconcern.free_obj = php_phongo_writeconcern_free_object;
php_phongo_handler_writeconcern.offset = XtOffsetOf(php_phongo_writeconcern_t, std);
#endif
zend_declare_class_constant_stringl(php_phongo_writeconcern_ce, ZEND_STRL("MAJORITY"), ZEND_STRL(PHONGO_WRITE_CONCERN_W_MAJORITY) TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/MongoDB/WriteConcernError.c b/mongodb-1.2.3/src/MongoDB/WriteConcernError.c
similarity index 78%
rename from mongodb-1.2.0/src/MongoDB/WriteConcernError.c
rename to mongodb-1.2.3/src/MongoDB/WriteConcernError.c
index efffffc2..ba0b2669 100644
--- a/mongodb-1.2.0/src/MongoDB/WriteConcernError.c
+++ b/mongodb-1.2.3/src/MongoDB/WriteConcernError.c
@@ -1,236 +1,230 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_writeconcernerror_ce;
zend_object_handlers php_phongo_handler_writeconcernerror;
/* {{{ proto integer WriteConcernError::getCode()
Returns the MongoDB error code */
PHP_METHOD(WriteConcernError, getCode)
{
php_phongo_writeconcernerror_t *intern;
intern = Z_WRITECONCERNERROR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(intern->code);
}
/* }}} */
/* {{{ proto mixed WriteConcernError::getInfo()
Returns additional metadata for the error */
PHP_METHOD(WriteConcernError, getInfo)
{
php_phongo_writeconcernerror_t *intern;
intern = Z_WRITECONCERNERROR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (!Z_ISUNDEF(intern->info)) {
#if PHP_VERSION_ID >= 70000
RETURN_ZVAL(&intern->info, 1, 0);
#else
RETURN_ZVAL(intern->info, 1, 0);
#endif
}
}
/* }}} */
/* {{{ proto string WriteConcernError::getMessage()
Returns the actual error message from the server */
PHP_METHOD(WriteConcernError, getMessage)
{
php_phongo_writeconcernerror_t *intern;
intern = Z_WRITECONCERNERROR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
PHONGO_RETURN_STRING(intern->message);
}
/* }}} */
/**
* Value object for a write concern error.
*/
/* {{{ MongoDB\Driver\WriteConcernError */
ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcernError_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_writeconcernerror_me[] = {
PHP_ME(Server, __construct, ai_WriteConcernError_void, ZEND_ACC_FINAL|ZEND_ACC_PRIVATE)
PHP_ME(WriteConcernError, getCode, ai_WriteConcernError_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteConcernError, getInfo, ai_WriteConcernError_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteConcernError, getMessage, ai_WriteConcernError_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeup, ai_WriteConcernError_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_writeconcernerror_t object handlers */
static void php_phongo_writeconcernerror_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_writeconcernerror_t *intern = Z_OBJ_WRITECONCERNERROR(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->message) {
efree(intern->message);
}
if (!Z_ISUNDEF(intern->info)) {
zval_ptr_dtor(&intern->info);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_writeconcernerror_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_writeconcernerror_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_writeconcernerror_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_writeconcernerror;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_writeconcernerror_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_writeconcernerror;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_writeconcernerror_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_writeconcernerror_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_WRITECONCERNERROR_OBJ_P(object);
array_init_size(&retval, 3);
ADD_ASSOC_STRING(&retval, "message", intern->message);
ADD_ASSOC_LONG_EX(&retval, "code", intern->code);
if (!Z_ISUNDEF(intern->info)) {
#if PHP_VERSION_ID >= 70000
Z_ADDREF(intern->info);
ADD_ASSOC_ZVAL_EX(&retval, "info", &intern->info);
#else
Z_ADDREF_P(intern->info);
ADD_ASSOC_ZVAL_EX(&retval, "info", intern->info);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "info");
}
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(WriteConcernError)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "WriteConcernError", php_phongo_writeconcernerror_me);
php_phongo_writeconcernerror_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_writeconcernerror_ce->create_object = php_phongo_writeconcernerror_create_object;
PHONGO_CE_FINAL(php_phongo_writeconcernerror_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_writeconcernerror_ce);
memcpy(&php_phongo_handler_writeconcernerror, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_writeconcernerror.get_debug_info = php_phongo_writeconcernerror_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_writeconcernerror.free_obj = php_phongo_writeconcernerror_free_object;
php_phongo_handler_writeconcernerror.offset = XtOffsetOf(php_phongo_writeconcernerror_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/MongoDB/WriteError.c b/mongodb-1.2.3/src/MongoDB/WriteError.c
similarity index 78%
rename from mongodb-1.2.0/src/MongoDB/WriteError.c
rename to mongodb-1.2.3/src/MongoDB/WriteError.c
index 3a6a4503..32429095 100644
--- a/mongodb-1.2.0/src/MongoDB/WriteError.c
+++ b/mongodb-1.2.3/src/MongoDB/WriteError.c
@@ -1,258 +1,252 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_writeerror_ce;
zend_object_handlers php_phongo_handler_writeerror;
/* {{{ proto integer WriteError::getCode()
Returns the MongoDB error code */
PHP_METHOD(WriteError, getCode)
{
php_phongo_writeerror_t *intern;
intern = Z_WRITEERROR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(intern->code);
}
/* }}} */
/* {{{ proto integer WriteError::getIndex()
Returns the index of the operation in the BulkWrite to which this WriteError
corresponds. */
PHP_METHOD(WriteError, getIndex)
{
php_phongo_writeerror_t *intern;
intern = Z_WRITEERROR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(intern->index);
}
/* }}} */
/* {{{ proto string WriteError::getMessage()
Returns the actual error message from the server */
PHP_METHOD(WriteError, getMessage)
{
php_phongo_writeerror_t *intern;
intern = Z_WRITEERROR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
PHONGO_RETURN_STRING(intern->message);
}
/* }}} */
/* {{{ proto mixed WriteError::getInfo()
Returns additional metadata for the error */
PHP_METHOD(WriteError, getInfo)
{
php_phongo_writeerror_t *intern;
intern = Z_WRITEERROR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (!Z_ISUNDEF(intern->info)) {
#if PHP_VERSION_ID >= 70000
RETURN_ZVAL(&intern->info, 1, 0);
#else
RETURN_ZVAL(intern->info, 1, 0);
#endif
}
}
/* }}} */
/**
* Value object for a write error (e.g. duplicate key).
*/
/* {{{ MongoDB\Driver\WriteError */
ZEND_BEGIN_ARG_INFO_EX(ai_WriteError_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_writeerror_me[] = {
PHP_ME(Server, __construct, ai_WriteError_void, ZEND_ACC_FINAL|ZEND_ACC_PRIVATE)
PHP_ME(WriteError, getCode, ai_WriteError_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteError, getIndex, ai_WriteError_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteError, getMessage, ai_WriteError_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteError, getInfo, ai_WriteError_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeup, ai_WriteError_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_writeerror_t object handlers */
static void php_phongo_writeerror_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_writeerror_t *intern = Z_OBJ_WRITEERROR(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->message) {
efree(intern->message);
}
if (!Z_ISUNDEF(intern->info)) {
zval_ptr_dtor(&intern->info);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_writeerror_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_writeerror_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_writeerror_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_writeerror;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_writeerror_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_writeerror;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_writeerror_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_writeerror_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_WRITEERROR_OBJ_P(object);
array_init_size(&retval, 3);
ADD_ASSOC_STRING(&retval, "message", intern->message);
ADD_ASSOC_LONG_EX(&retval, "code", intern->code);
ADD_ASSOC_LONG_EX(&retval, "index", intern->index);
if (!Z_ISUNDEF(intern->info)) {
#if PHP_VERSION_ID >= 70000
Z_ADDREF(intern->info);
ADD_ASSOC_ZVAL_EX(&retval, "info", &intern->info);
#else
Z_ADDREF_P(intern->info);
ADD_ASSOC_ZVAL_EX(&retval, "info", intern->info);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "info");
}
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(WriteError)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "WriteError", php_phongo_writeerror_me);
php_phongo_writeerror_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_writeerror_ce->create_object = php_phongo_writeerror_create_object;
PHONGO_CE_FINAL(php_phongo_writeerror_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_writeerror_ce);
memcpy(&php_phongo_handler_writeerror, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_writeerror.get_debug_info = php_phongo_writeerror_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_writeerror.free_obj = php_phongo_writeerror_free_object;
php_phongo_handler_writeerror.offset = XtOffsetOf(php_phongo_writeerror_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/MongoDB/WriteResult.c b/mongodb-1.2.3/src/MongoDB/WriteResult.c
similarity index 79%
rename from mongodb-1.2.0/src/MongoDB/WriteResult.c
rename to mongodb-1.2.3/src/MongoDB/WriteResult.c
index f3ca23db..d432947b 100644
--- a/mongodb-1.2.0/src/MongoDB/WriteResult.c
+++ b/mongodb-1.2.3/src/MongoDB/WriteResult.c
@@ -1,600 +1,601 @@
/*
- +---------------------------------------------------------------------------+
- | PHP Driver for MongoDB |
- +---------------------------------------------------------------------------+
- | Copyright 2013-2015 MongoDB, Inc. |
- | |
- | Licensed under the Apache License, Version 2.0 (the "License"); |
- | you may not use this file except in compliance with the License. |
- | You may obtain a copy of the License at |
- | |
- | http://www.apache.org/licenses/LICENSE-2.0 |
- | |
- | Unless required by applicable law or agreed to in writing, software |
- | distributed under the License is distributed on an "AS IS" BASIS, |
- | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | See the License for the specific language governing permissions and |
- | limitations under the License. |
- +---------------------------------------------------------------------------+
- | Copyright (c) 2014-2015 MongoDB, Inc. |
- +---------------------------------------------------------------------------+
-*/
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
#include <mongoc.h>
/* PHP Core stuff */
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#define RETURN_LONG_FROM_BSON_INT32(iter, bson, key) \
if (bson_iter_init_find((iter), (bson), (key)) && BSON_ITER_HOLDS_INT32((iter))) { \
RETURN_LONG(bson_iter_int32((iter))); \
}
PHONGO_API zend_class_entry *php_phongo_writeresult_ce;
zend_object_handlers php_phongo_handler_writeresult;
+static bool php_phongo_writeresult_get_writeconcernerror(php_phongo_writeresult_t *intern, zval *return_value TSRMLS_DC)
+{
+ bson_iter_t iter, child;
+#if PHP_VERSION_ID >= 70000
+ zval writeconcernerror;
+#else
+ zval *writeconcernerror = NULL;
+#endif
+
+ ZVAL_NULL(return_value);
+
+ if (bson_iter_init_find(&iter, intern->reply, "writeConcernErrors") && BSON_ITER_HOLDS_ARRAY(&iter) && bson_iter_recurse(&iter, &child)) {
+ while (bson_iter_next(&child)) {
+ bson_t cbson;
+ uint32_t len;
+ const uint8_t *data;
+
+ if (!BSON_ITER_HOLDS_DOCUMENT(&child)) {
+ continue;
+ }
+
+ bson_iter_document(&child, &len, &data);
+
+ if (!bson_init_static(&cbson, data, len)) {
+ continue;
+ }
+
+#if PHP_VERSION_ID >= 70000
+ if (!phongo_writeconcernerror_init(&writeconcernerror, &cbson TSRMLS_CC)) {
+ zval_ptr_dtor(&writeconcernerror);
+ return false;
+ }
+
+ ZVAL_ZVAL(return_value, &writeconcernerror, 1, 1);
+#else
+ MAKE_STD_ZVAL(writeconcernerror);
+
+ if (!phongo_writeconcernerror_init(writeconcernerror, &cbson TSRMLS_CC)) {
+ zval_ptr_dtor(&writeconcernerror);
+ return false;
+ }
+
+ ZVAL_ZVAL(return_value, writeconcernerror, 1, 1);
+#endif
+
+ return true;
+ }
+ }
+
+ return true;
+}
+
+static bool php_phongo_writeresult_get_writeerrors(php_phongo_writeresult_t *intern, zval *return_value TSRMLS_DC)
+{
+ bson_iter_t iter, child;
+
+ array_init(return_value);
+
+ if (bson_iter_init_find(&iter, intern->reply, "writeErrors") && BSON_ITER_HOLDS_ARRAY(&iter) && bson_iter_recurse(&iter, &child)) {
+ while (bson_iter_next(&child)) {
+ bson_t cbson;
+ uint32_t len;
+ const uint8_t *data;
+#if PHP_VERSION_ID >= 70000
+ zval writeerror;
+#else
+ zval *writeerror = NULL;
+#endif
+
+ if (!BSON_ITER_HOLDS_DOCUMENT(&child)) {
+ continue;
+ }
+
+ bson_iter_document(&child, &len, &data);
+
+ if (!bson_init_static(&cbson, data, len)) {
+ continue;
+ }
+
+#if PHP_VERSION_ID >= 70000
+ if (!phongo_writeerror_init(&writeerror, &cbson TSRMLS_CC)) {
+ zval_ptr_dtor(&writeerror);
+ continue;
+ }
+
+ add_next_index_zval(return_value, &writeerror);
+#else
+ MAKE_STD_ZVAL(writeerror);
+
+ if (!phongo_writeerror_init(writeerror, &cbson TSRMLS_CC)) {
+ zval_ptr_dtor(&writeerror);
+ continue;
+ }
+
+ add_next_index_zval(return_value, writeerror);
+#endif
+ }
+ }
+
+ return true;
+}
+
/* {{{ proto integer|null WriteResult::getInsertedCount()
Returns the number of documents that were inserted */
PHP_METHOD(WriteResult, getInsertedCount)
{
bson_iter_t iter;
php_phongo_writeresult_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITERESULT_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG_FROM_BSON_INT32(&iter, intern->reply, "nInserted");
}
/* }}} */
/* {{{ proto integer|null WriteResult::getMatchedCount()
Returns the number of documents that matched the update criteria */
PHP_METHOD(WriteResult, getMatchedCount)
{
bson_iter_t iter;
php_phongo_writeresult_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITERESULT_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG_FROM_BSON_INT32(&iter, intern->reply, "nMatched");
}
/* }}} */
/* {{{ proto integer|null WriteResult::getModifiedCount()
Returns the number of documents that were actually modified by an update */
PHP_METHOD(WriteResult, getModifiedCount)
{
bson_iter_t iter;
php_phongo_writeresult_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITERESULT_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG_FROM_BSON_INT32(&iter, intern->reply, "nModified");
}
/* }}} */
/* {{{ proto integer|null WriteResult::getDeletedCount()
Returns the number of documents that were deleted */
PHP_METHOD(WriteResult, getDeletedCount)
{
bson_iter_t iter;
php_phongo_writeresult_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITERESULT_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG_FROM_BSON_INT32(&iter, intern->reply, "nRemoved");
}
/* }}} */
/* {{{ proto integer|null WriteResult::getUpsertedCount()
Returns the number of documents that were upserted */
PHP_METHOD(WriteResult, getUpsertedCount)
{
bson_iter_t iter;
php_phongo_writeresult_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITERESULT_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG_FROM_BSON_INT32(&iter, intern->reply, "nUpserted");
}
/* }}} */
/* {{{ proto MongoDB\Driver\Server WriteResult::getServer()
Returns the Server from which the result originated */
PHP_METHOD(WriteResult, getServer)
{
php_phongo_writeresult_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITERESULT_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
#if PHP_VERSION_ID >= 70000
phongo_server_init(return_value, &intern->manager, intern->server_id TSRMLS_CC);
#else
phongo_server_init(return_value, intern->manager, intern->server_id TSRMLS_CC);
#endif
}
/* }}} */
/* {{{ proto array WriteResult::getUpsertedIds()
Returns the identifiers generated by the server for upsert operations. */
PHP_METHOD(WriteResult, getUpsertedIds)
{
bson_iter_t iter, child;
php_phongo_writeresult_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITERESULT_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
array_init(return_value);
if (bson_iter_init_find(&iter, intern->reply, "upserted") && BSON_ITER_HOLDS_ARRAY(&iter) && bson_iter_recurse(&iter, &child)) {
while (bson_iter_next(&child)) {
int32_t index;
bson_iter_t outer;
if (!BSON_ITER_HOLDS_DOCUMENT(&child) || !bson_iter_recurse(&child, &outer)) {
continue;
}
if (!bson_iter_find(&outer, "index") || !BSON_ITER_HOLDS_INT32(&outer)) {
continue;
}
index = bson_iter_int32(&outer);
if (!bson_iter_find(&outer, "_id")) {
continue;
}
if (BSON_ITER_HOLDS_OID(&outer)) {
#if PHP_VERSION_ID >= 70000
zval zid;
php_phongo_objectid_new_from_oid(&zid, bson_iter_oid(&outer) TSRMLS_CC);
add_index_zval(return_value, index, &zid);
#else
zval *zid = NULL;
MAKE_STD_ZVAL(zid);
php_phongo_objectid_new_from_oid(zid, bson_iter_oid(&outer) TSRMLS_CC);
add_index_zval(return_value, index, zid);
#endif
} else if (BSON_ITER_HOLDS_INT32(&outer)) {
int32_t val = bson_iter_int32(&outer);
add_index_long(return_value, index, val);
} else if (BSON_ITER_HOLDS_INT64(&outer)) {
int64_t val = bson_iter_int64(&outer);
ADD_INDEX_INT64(return_value, index, val);
}
}
}
}
/* }}} */
/* {{{ proto WriteConcernError WriteResult::getWriteConcernError()
Return any write concern error that occurred */
PHP_METHOD(WriteResult, getWriteConcernError)
{
- bson_iter_t iter, child;
php_phongo_writeresult_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITERESULT_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- if (bson_iter_init_find(&iter, intern->reply, "writeConcernErrors") && BSON_ITER_HOLDS_ARRAY(&iter) && bson_iter_recurse(&iter, &child)) {
- while (bson_iter_next(&child)) {
- bson_t cbson;
- uint32_t len;
- const uint8_t *data;
-
- if (!BSON_ITER_HOLDS_DOCUMENT(&child)) {
- continue;
- }
-
- bson_iter_document(&child, &len, &data);
-
- if (!bson_init_static(&cbson, data, len)) {
- continue;
- }
-
- object_init_ex(return_value, php_phongo_writeconcernerror_ce);
-
- if (!phongo_writeconcernerror_init(return_value, &cbson TSRMLS_CC)) {
-#if PHP_VERSION_ID >= 70000
- zval_ptr_dtor(return_value);
-#else
- zval_ptr_dtor(&return_value);
-#endif
- }
-
- return;
- }
- }
+ php_phongo_writeresult_get_writeconcernerror(intern, return_value TSRMLS_CC);
}
/* }}} */
/* {{{ proto WriteError[] WriteResult::getWriteErrors()
Returns any write errors that occurred */
PHP_METHOD(WriteResult, getWriteErrors)
{
- bson_iter_t iter, child;
php_phongo_writeresult_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITERESULT_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
-
- array_init(return_value);
-
- if (bson_iter_init_find(&iter, intern->reply, "writeErrors") && BSON_ITER_HOLDS_ARRAY(&iter) && bson_iter_recurse(&iter, &child)) {
- while (bson_iter_next(&child)) {
- bson_t cbson;
- uint32_t len;
- const uint8_t *data;
-#if PHP_VERSION_ID >= 70000
- zval writeerror;
-#else
- zval *writeerror = NULL;
-#endif
-
- if (!BSON_ITER_HOLDS_DOCUMENT(&child)) {
- continue;
- }
-
- bson_iter_document(&child, &len, &data);
-
- if (!bson_init_static(&cbson, data, len)) {
- continue;
- }
-
-#if PHP_VERSION_ID >= 70000
- object_init_ex(&writeerror, php_phongo_writeerror_ce);
-
- if (!phongo_writeerror_init(&writeerror, &cbson TSRMLS_CC)) {
- zval_ptr_dtor(&writeerror);
- continue;
- }
-
- add_next_index_zval(return_value, &writeerror);
-#else
- MAKE_STD_ZVAL(writeerror);
- object_init_ex(writeerror, php_phongo_writeerror_ce);
-
- if (!phongo_writeerror_init(writeerror, &cbson TSRMLS_CC)) {
- zval_ptr_dtor(&writeerror);
- continue;
- }
-
- add_next_index_zval(return_value, writeerror);
-#endif
- }
- }
+ php_phongo_writeresult_get_writeerrors(intern, return_value TSRMLS_CC);
}
/* }}} */
/* {{{ proto boolean WriteResult::isAcknowledged()
Returns whether the write operation was acknowledged (based on the write
concern). */
PHP_METHOD(WriteResult, isAcknowledged)
{
php_phongo_writeresult_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_WRITERESULT_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(mongoc_write_concern_is_acknowledged(intern->write_concern));
}
/* }}} */
/**
* Result returned by Server and Manager executeBulkWrite() methods.
*
* This class may be constructed internally if it will encapsulate a libmongoc
* data structure.
*/
/* {{{ MongoDB\Driver\WriteResult */
ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_phongo_writeresult_me[] = {
PHP_ME(Server, __construct, ai_WriteResult_void, ZEND_ACC_FINAL|ZEND_ACC_PRIVATE)
PHP_ME(WriteResult, getInsertedCount, ai_WriteResult_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteResult, getMatchedCount, ai_WriteResult_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteResult, getModifiedCount, ai_WriteResult_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteResult, getDeletedCount, ai_WriteResult_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteResult, getUpsertedCount, ai_WriteResult_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteResult, getServer, ai_WriteResult_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteResult, getUpsertedIds, ai_WriteResult_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteResult, getWriteConcernError, ai_WriteResult_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteResult, getWriteErrors, ai_WriteResult_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(WriteResult, isAcknowledged, ai_WriteResult_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeup, ai_WriteResult_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_writeresult_t object handlers */
static void php_phongo_writeresult_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_writeresult_t *intern = Z_OBJ_WRITERESULT(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->reply) {
bson_destroy(intern->reply);
}
if (intern->write_concern) {
mongoc_write_concern_destroy(intern->write_concern);
}
zval_ptr_dtor(&intern->manager);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_writeresult_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_writeresult_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_writeresult_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_writeresult;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_writeresult_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_writeresult;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_writeresult_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_writeresult_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
- bson_iter_t iter, child;
+ bson_iter_t iter;
intern = Z_WRITERESULT_OBJ_P(object);
*is_temp = 1;
array_init_size(&retval, 9);
#define SCP(field) \
if (bson_iter_init_find(&iter, intern->reply, (field)) && BSON_ITER_HOLDS_INT32(&iter)) { \
ADD_ASSOC_LONG_EX(&retval, (field), bson_iter_int32(&iter)); \
} else { \
ADD_ASSOC_NULL_EX(&retval, (field)); \
}
SCP("nInserted");
SCP("nMatched");
SCP("nModified");
SCP("nRemoved");
SCP("nUpserted");
#undef SCP
if (bson_iter_init_find(&iter, intern->reply, "upserted") && BSON_ITER_HOLDS_ARRAY(&iter)) {
uint32_t len;
const uint8_t *data;
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
/* Use native arrays for debugging output */
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
bson_iter_array(&iter, &len, &data);
phongo_bson_to_zval_ex(data, len, &state);
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(&retval, "upsertedIds", &state.zchild);
#else
ADD_ASSOC_ZVAL_EX(&retval, "upsertedIds", state.zchild);
#endif
} else {
#if PHP_VERSION_ID >= 70000
zval upsertedIds;
array_init(&upsertedIds);
ADD_ASSOC_ZVAL_EX(&retval, "upsertedIds", &upsertedIds);
#else
zval *upsertedIds = NULL;
MAKE_STD_ZVAL(upsertedIds);
array_init(upsertedIds);
ADD_ASSOC_ZVAL_EX(&retval, "upsertedIds", upsertedIds);
#endif
}
- if (bson_iter_init_find(&iter, intern->reply, "writeErrors") && BSON_ITER_HOLDS_ARRAY(&iter)) {
- uint32_t len;
- const uint8_t *data;
- php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
-
- /* Use native arrays for debugging output */
- state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
- state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
-
- bson_iter_array(&iter, &len, &data);
- phongo_bson_to_zval_ex(data, len, &state);
-#if PHP_VERSION_ID >= 70000
- ADD_ASSOC_ZVAL_EX(&retval, "writeErrors", &state.zchild);
-#else
- ADD_ASSOC_ZVAL_EX(&retval, "writeErrors", state.zchild);
-#endif
- } else {
+ {
#if PHP_VERSION_ID >= 70000
- zval writeErrors;
- array_init(&writeErrors);
- ADD_ASSOC_ZVAL_EX(&retval, "writeErrors", &writeErrors);
+ zval writeerrors;
+
+ php_phongo_writeresult_get_writeerrors(intern, &writeerrors TSRMLS_CC);
+ ADD_ASSOC_ZVAL_EX(&retval, "writeErrors", &writeerrors);
#else
- zval *writeErrors = NULL;
- MAKE_STD_ZVAL(writeErrors);
- array_init(writeErrors);
- ADD_ASSOC_ZVAL_EX(&retval, "writeErrors", writeErrors);
+ zval *writeerrors = NULL;
+
+ MAKE_STD_ZVAL(writeerrors);
+ php_phongo_writeresult_get_writeerrors(intern, writeerrors TSRMLS_CC);
+ ADD_ASSOC_ZVAL_EX(&retval, "writeErrors", writeerrors);
#endif
}
- if (bson_iter_init_find(&iter, intern->reply, "writeConcernErrors") && BSON_ITER_HOLDS_ARRAY(&iter) &&
- bson_iter_recurse(&iter, &child) && bson_iter_next(&child) && BSON_ITER_HOLDS_DOCUMENT(&child)) {
- uint32_t len;
- const uint8_t *data;
- php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
-
- /* Use native arrays for debugging output */
- state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
- state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
-
- bson_iter_document(&child, &len, &data);
- phongo_bson_to_zval_ex(data, len, &state);
+ {
#if PHP_VERSION_ID >= 70000
- ADD_ASSOC_ZVAL_EX(&retval, "writeConcernError", &state.zchild);
+ zval writeconcernerror;
+
+ php_phongo_writeresult_get_writeconcernerror(intern, &writeconcernerror TSRMLS_CC);
+ ADD_ASSOC_ZVAL_EX(&retval, "writeConcernError", &writeconcernerror);
#else
- ADD_ASSOC_ZVAL_EX(&retval, "writeConcernError", state.zchild);
+ zval *writeconcernerror = NULL;
+
+ MAKE_STD_ZVAL(writeconcernerror);
+ php_phongo_writeresult_get_writeconcernerror(intern, writeconcernerror TSRMLS_CC);
+ ADD_ASSOC_ZVAL_EX(&retval, "writeConcernError", writeconcernerror);
#endif
- } else {
- ADD_ASSOC_NULL_EX(&retval, "writeConcernError");
}
if (intern->write_concern) {
#if PHP_VERSION_ID >= 70000
zval write_concern;
- php_phongo_write_concern_to_zval(&write_concern, intern->write_concern);
+ phongo_writeconcern_init(&write_concern, intern->write_concern);
ADD_ASSOC_ZVAL_EX(&retval, "writeConcern", &write_concern);
#else
zval *write_concern = NULL;
MAKE_STD_ZVAL(write_concern);
- php_phongo_write_concern_to_zval(write_concern, intern->write_concern);
+ phongo_writeconcern_init(write_concern, intern->write_concern TSRMLS_CC);
ADD_ASSOC_ZVAL_EX(&retval, "writeConcern", write_concern);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "writeConcern");
}
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(WriteResult)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "WriteResult", php_phongo_writeresult_me);
php_phongo_writeresult_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_writeresult_ce->create_object = php_phongo_writeresult_create_object;
PHONGO_CE_FINAL(php_phongo_writeresult_ce);
PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_writeresult_ce);
memcpy(&php_phongo_handler_writeresult, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_writeresult.get_debug_info = php_phongo_writeresult_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_writeresult.free_obj = php_phongo_writeresult_free_object;
php_phongo_handler_writeresult.offset = XtOffsetOf(php_phongo_writeresult_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/bson.c b/mongodb-1.2.3/src/bson.c
similarity index 83%
rename from mongodb-1.2.0/src/bson.c
rename to mongodb-1.2.3/src/bson.c
index e0542e2d..72796c79 100644
--- a/mongodb-1.2.0/src/bson.c
+++ b/mongodb-1.2.3/src/bson.c
@@ -1,1694 +1,1813 @@
/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 2014-2015 Hannes Magnusson |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Hannes Magnusson <bjori@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
+ * Copyright 2014-2017 MongoDB, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include <bson.h>
/* PHP Core stuff */
#include <php.h>
#include <ext/spl/spl_array.h>
#include <Zend/zend_hash.h>
#include <Zend/zend_interfaces.h>
/* PHP array helpers */
#include "php_array_api.h"
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#if SIZEOF_PHONGO_LONG == 8
# define BSON_APPEND_INT(b, key, keylen, val) \
if (val > INT32_MAX || val < INT32_MIN) { \
bson_append_int64(b, key, keylen, val); \
} else { \
bson_append_int32(b, key, keylen, val); \
}
#elif SIZEOF_PHONGO_LONG == 4
# define BSON_APPEND_INT(b, key, keylen, val) \
bson_append_int32(b, key, keylen, val)
#else
# error Unsupported architecture (integers are neither 32-bit nor 64-bit)
#endif
#undef MONGOC_LOG_DOMAIN
#define MONGOC_LOG_DOMAIN "PHONGO-BSON"
#define PHONGO_ODM_FIELD_NAME "__pclass"
#define PHONGO_IS_CLASS_INSTANTIATABLE(ce) \
(!(ce->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)))
PHP_MINIT_FUNCTION(bson)
{
(void)type; /* We don't care if we are loaded via dl() or extension= */
(void)module_number; /* Really doesn't matter which module number we are */
/* Register BSONable */
return SUCCESS;
}
/* Forward declarations */
bool php_phongo_bson_visit_document(const bson_iter_t *iter ARG_UNUSED, const char *key, const bson_t *v_document, void *data);
bool php_phongo_bson_visit_array(const bson_iter_t *iter ARG_UNUSED, const char *key, const bson_t *v_document, void *data);
/* {{{ Santa's Little Helper: Object getters */
void php_phongo_objectid_get_id(zval *object, bson_oid_t *oid TSRMLS_DC)
{
php_phongo_objectid_t *intern;
intern = Z_OBJECTID_OBJ_P(object);
bson_oid_init_from_string(oid, intern->oid);
}
int64_t php_phongo_utcdatetime_get_milliseconds(zval *object TSRMLS_DC)
{
php_phongo_utcdatetime_t *intern;
intern = Z_UTCDATETIME_OBJ_P(object);
return intern->milliseconds;
}
uint32_t php_phongo_timestamp_get_increment(zval *object TSRMLS_DC)
{
php_phongo_timestamp_t *intern;
intern = Z_TIMESTAMP_OBJ_P(object);
return intern->increment;
}
uint32_t php_phongo_timestamp_get_timestamp(zval *object TSRMLS_DC)
{
php_phongo_timestamp_t *intern;
intern = Z_TIMESTAMP_OBJ_P(object);
return intern->timestamp;
}
bool php_phongo_javascript_has_scope(zval *object TSRMLS_DC)
{
php_phongo_javascript_t *intern;
intern = Z_JAVASCRIPT_OBJ_P(object);
return !!intern->scope;
}
char *php_phongo_javascript_get_code(zval *object TSRMLS_DC)
{
php_phongo_javascript_t *intern;
intern = Z_JAVASCRIPT_OBJ_P(object);
return intern->code;
}
bson_t *php_phongo_javascript_get_scope(zval *object TSRMLS_DC)
{
php_phongo_javascript_t *intern;
intern = Z_JAVASCRIPT_OBJ_P(object);
return intern->scope;
}
int php_phongo_binary_get_data(zval *object, char **data TSRMLS_DC)
{
php_phongo_binary_t *intern;
intern = Z_BINARY_OBJ_P(object);
*data = intern->data;
return intern->data_len;
}
uint8_t php_phongo_binary_get_type(zval *object TSRMLS_DC)
{
php_phongo_binary_t *intern;
intern = Z_BINARY_OBJ_P(object);
return intern->type;
}
static bson_decimal128_t *php_phongo_decimal128_get_decimal128(zval *object TSRMLS_DC)
{
php_phongo_decimal128_t *intern;
intern = Z_DECIMAL128_OBJ_P(object);
return &intern->decimal;
}
char *php_phongo_regex_get_pattern(zval *object TSRMLS_DC)
{
php_phongo_regex_t *intern;
intern = Z_REGEX_OBJ_P(object);
return intern->pattern;
}
char *php_phongo_regex_get_flags(zval *object TSRMLS_DC)
{
php_phongo_regex_t *intern;
intern = Z_REGEX_OBJ_P(object);
return intern->flags;
}
/* }}} */
#if 0
bool php_phongo_bson_visit_before(const bson_iter_t *iter ARG_UNUSED, const char *key, void *data) /* {{{ */
{
return false;
}
/* }}} */
bool php_phongo_bson_visit_after(const bson_iter_t *iter ARG_UNUSED, const char *key, void *data) /* {{{ */
{
return false;
}
/* }}} */
#endif
void php_phongo_bson_visit_corrupt(const bson_iter_t *iter ARG_UNUSED, void *data ARG_UNUSED) /* {{{ */
{
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "Corrupt BSON data detected!");
}
void php_phongo_bson_visit_unsupported_type(const bson_iter_t *iter ARG_UNUSED, const char *key, uint32_t v_type_code, void *data ARG_UNUSED) /* {{{ */
{
TSRMLS_FETCH();
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Detected unknown BSON type 0x%02hhx for fieldname \"%s\". Are you using the latest driver?", v_type_code, key);
}
bool php_phongo_bson_visit_double(const bson_iter_t *iter ARG_UNUSED, const char *key, double v_double, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
- add_assoc_double(retval, key, v_double);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_double(retval, v_double);
+ } else {
+ add_assoc_double(retval, key, v_double);
+ }
return false;
}
/* }}} */
bool php_phongo_bson_visit_utf8(const bson_iter_t *iter ARG_UNUSED, const char *key, size_t v_utf8_len, const char *v_utf8, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
- ADD_ASSOC_STRING_EX(retval, key, strlen(key), v_utf8, v_utf8_len);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ ADD_NEXT_INDEX_STRINGL(retval, v_utf8, v_utf8_len);
+ } else {
+ ADD_ASSOC_STRING_EX(retval, key, strlen(key), v_utf8, v_utf8_len);
+ }
return false;
}
/* }}} */
bool php_phongo_bson_visit_binary(const bson_iter_t *iter ARG_UNUSED, const char *key, bson_subtype_t v_subtype, size_t v_binary_len, const uint8_t *v_binary, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
TSRMLS_FETCH();
if (v_subtype == 0x80 && strcmp(key, PHONGO_ODM_FIELD_NAME) == 0) {
#if PHP_VERSION_ID >= 70000
zend_string *zs_classname = zend_string_init((const char *)v_binary, v_binary_len, 0);
zend_class_entry *found_ce = zend_fetch_class(zs_classname, ZEND_FETCH_CLASS_AUTO|ZEND_FETCH_CLASS_SILENT TSRMLS_CC);
zend_string_free(zs_classname);
#else
zend_class_entry *found_ce = zend_fetch_class((const char *)v_binary, v_binary_len, ZEND_FETCH_CLASS_AUTO|ZEND_FETCH_CLASS_SILENT TSRMLS_CC);
#endif
if (found_ce && PHONGO_IS_CLASS_INSTANTIATABLE(found_ce) && instanceof_function(found_ce, php_phongo_persistable_ce TSRMLS_CC)) {
((php_phongo_bson_state *)data)->odm = found_ce;
}
}
{
#if PHP_VERSION_ID >= 70000
zval zchild;
php_phongo_new_binary_from_binary_and_type(&zchild, (const char *)v_binary, v_binary_len, v_subtype TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, &zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &zchild);
+ }
Z_SET_REFCOUNT(zchild, 1);
#else
zval *zchild = NULL;
MAKE_STD_ZVAL(zchild);
php_phongo_new_binary_from_binary_and_type(zchild, (const char *)v_binary, v_binary_len, v_subtype TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, zchild);
+ }
Z_SET_REFCOUNT_P(zchild, 1);
#endif
}
return false;
}
/* }}} */
#if 0
bool php_phongo_bson_visit_undefined(const bson_iter_t *iter ARG_UNUSED, const char *key, void *data) /* {{{ */
{
printf("Not Implemented\n");
return true;
}
/* }}} */
#endif
bool php_phongo_bson_visit_oid(const bson_iter_t *iter ARG_UNUSED, const char *key, const bson_oid_t *v_oid, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
#if PHP_VERSION_ID >= 70000
zval zchild;
php_phongo_objectid_new_from_oid(&zchild, v_oid TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, &zchild);
+
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &zchild);
+ }
#else
zval *zchild = NULL;
TSRMLS_FETCH();
MAKE_STD_ZVAL(zchild);
php_phongo_objectid_new_from_oid(zchild, v_oid TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, zchild);
+ }
Z_SET_REFCOUNT_P(zchild, 1);
#endif
return false;
}
/* }}} */
bool php_phongo_bson_visit_bool(const bson_iter_t *iter ARG_UNUSED, const char *key, bool v_bool, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
- add_assoc_bool(retval, key, v_bool);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_bool(retval, v_bool);
+ } else {
+ add_assoc_bool(retval, key, v_bool);
+ }
return false;
}
/* }}} */
bool php_phongo_bson_visit_date_time(const bson_iter_t *iter ARG_UNUSED, const char *key, int64_t msec_since_epoch, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
#if PHP_VERSION_ID >= 70000
zval zchild;
php_phongo_new_utcdatetime_from_epoch(&zchild, msec_since_epoch TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, &zchild);
+
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &zchild);
+ }
#else
zval *zchild = NULL;
TSRMLS_FETCH();
MAKE_STD_ZVAL(zchild);
php_phongo_new_utcdatetime_from_epoch(zchild, msec_since_epoch TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, zchild);
+ }
Z_SET_REFCOUNT_P(zchild, 1);
#endif
return false;
}
/* }}} */
bool php_phongo_bson_visit_decimal128(const bson_iter_t *iter ARG_UNUSED, const char *key, const bson_decimal128_t *decimal, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
zval zchild;
php_phongo_new_decimal128(&zchild, decimal TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, &zchild);
+
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &zchild);
+ }
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
zval *zchild = NULL;
TSRMLS_FETCH();
MAKE_STD_ZVAL(zchild);
php_phongo_new_decimal128(zchild, decimal TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, zchild);
+ }
Z_SET_REFCOUNT_P(zchild, 1);
#endif
return false;
}
/* }}} */
bool php_phongo_bson_visit_null(const bson_iter_t *iter ARG_UNUSED, const char *key, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
- add_assoc_null(retval, key);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_null(retval);
+ } else {
+ add_assoc_null(retval, key);
+ }
return false;
}
/* }}} */
bool php_phongo_bson_visit_regex(const bson_iter_t *iter ARG_UNUSED, const char *key, const char *v_regex, const char *v_options, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
#if PHP_VERSION_ID >= 70000
zval zchild;
php_phongo_new_regex_from_regex_and_options(&zchild, v_regex, v_options TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, &zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &zchild);
+ }
#else
zval *zchild = NULL;
TSRMLS_FETCH();
MAKE_STD_ZVAL(zchild);
php_phongo_new_regex_from_regex_and_options(zchild, v_regex, v_options TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, zchild);
+ }
Z_SET_REFCOUNT_P(zchild, 1);
#endif
return false;
}
/* }}} */
#if 0
bool php_phongo_bson_visit_dbpointer(const bson_iter_t *iter ARG_UNUSED, const char *key, size_t v_collection_len, const char *v_collection, const bson_oid_t *v_oid, void *data) /* {{{ */
{
printf("Not Implemented\n");
return true;
}
/* }}} */
#endif
bool php_phongo_bson_visit_code(const bson_iter_t *iter ARG_UNUSED, const char *key, size_t v_code_len, const char *v_code, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
#if PHP_VERSION_ID >= 70000
zval zchild;
php_phongo_new_javascript_from_javascript(1, &zchild, v_code, v_code_len TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, &zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &zchild);
+ }
#else
zval *zchild = NULL;
TSRMLS_FETCH();
MAKE_STD_ZVAL(zchild);
php_phongo_new_javascript_from_javascript(1, zchild, v_code, v_code_len TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, zchild);
+ }
Z_SET_REFCOUNT_P(zchild, 1);
#endif
return false;
}
/* }}} */
#if 0
bool php_phongo_bson_visit_symbol(const bson_iter_t *iter ARG_UNUSED, const char *key, size_t v_symbol_len, const char *v_symbol, void *data) /* {{{ */
{
printf("Not Implemented\n");
return true;
}
/* }}} */
#endif
bool php_phongo_bson_visit_codewscope(const bson_iter_t *iter ARG_UNUSED, const char *key, size_t v_code_len, const char *v_code, const bson_t *v_scope, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
#if PHP_VERSION_ID >= 70000
zval zchild;
php_phongo_new_javascript_from_javascript_and_scope(1, &zchild, v_code, v_code_len, v_scope TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, &zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &zchild);
+ }
#else
zval *zchild = NULL;
TSRMLS_FETCH();
MAKE_STD_ZVAL(zchild);
php_phongo_new_javascript_from_javascript_and_scope(1, zchild, v_code, v_code_len, v_scope TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, zchild);
+ }
Z_SET_REFCOUNT_P(zchild, 1);
#endif
return false;
}
/* }}} */
bool php_phongo_bson_visit_int32(const bson_iter_t *iter ARG_UNUSED, const char *key, int32_t v_int32, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
- add_assoc_long(retval, key, v_int32);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_long(retval, v_int32);
+ } else {
+ add_assoc_long(retval, key, v_int32);
+ }
return false;
}
/* }}} */
bool php_phongo_bson_visit_timestamp(const bson_iter_t *iter ARG_UNUSED, const char *key, uint32_t v_timestamp, uint32_t v_increment, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
#if PHP_VERSION_ID >= 70000
zval zchild;
php_phongo_new_timestamp_from_increment_and_timestamp(&zchild, v_increment, v_timestamp TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, &zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &zchild);
+ }
#else
zval *zchild = NULL;
TSRMLS_FETCH();
MAKE_STD_ZVAL(zchild);
php_phongo_new_timestamp_from_increment_and_timestamp(zchild, v_increment, v_timestamp TSRMLS_CC);
- ADD_ASSOC_ZVAL(retval, key, zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, zchild);
+ }
Z_SET_REFCOUNT_P(zchild, 1);
#endif
return false;
}
/* }}} */
bool php_phongo_bson_visit_int64(const bson_iter_t *iter ARG_UNUSED, const char *key, int64_t v_int64, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
+#if SIZEOF_PHONGO_LONG == 4
TSRMLS_FETCH();
+#endif
- ADD_ASSOC_INT64(retval, key, v_int64);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ ADD_NEXT_INDEX_INT64(retval, v_int64);
+ } else {
+ ADD_ASSOC_INT64(retval, key, v_int64);
+ }
return false;
}
/* }}} */
bool php_phongo_bson_visit_maxkey(const bson_iter_t *iter ARG_UNUSED, const char *key, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
#if PHP_VERSION_ID >= 70000
zval zchild;
object_init_ex(&zchild, php_phongo_maxkey_ce);
- ADD_ASSOC_ZVAL(retval, key, &zchild);
+
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &zchild);
+ }
#else
zval *zchild = NULL;
TSRMLS_FETCH();
MAKE_STD_ZVAL(zchild);
object_init_ex(zchild, php_phongo_maxkey_ce);
- ADD_ASSOC_ZVAL(retval, key, zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, zchild);
+ }
Z_SET_REFCOUNT_P(zchild, 1);
#endif
return false;
}
/* }}} */
bool php_phongo_bson_visit_minkey(const bson_iter_t *iter ARG_UNUSED, const char *key, void *data) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
#if PHP_VERSION_ID >= 70000
zval zchild;
object_init_ex(&zchild, php_phongo_minkey_ce);
- ADD_ASSOC_ZVAL(retval, key, &zchild);
+
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &zchild);
+ }
#else
zval *zchild = NULL;
TSRMLS_FETCH();
MAKE_STD_ZVAL(zchild);
object_init_ex(zchild, php_phongo_minkey_ce);
Z_SET_REFCOUNT_P(zchild, 1);
- ADD_ASSOC_ZVAL(retval, key, zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, zchild);
+ }
#endif
return false;
}
/* }}} */
static const bson_visitor_t php_bson_visitors = {
NULL /* php_phongo_bson_visit_before*/,
NULL /*php_phongo_bson_visit_after*/,
php_phongo_bson_visit_corrupt,
php_phongo_bson_visit_double,
php_phongo_bson_visit_utf8,
php_phongo_bson_visit_document,
php_phongo_bson_visit_array,
php_phongo_bson_visit_binary,
NULL /*php_phongo_bson_visit_undefined*/,
php_phongo_bson_visit_oid,
php_phongo_bson_visit_bool,
php_phongo_bson_visit_date_time,
php_phongo_bson_visit_null,
php_phongo_bson_visit_regex,
NULL /*php_phongo_bson_visit_dbpointer*/,
php_phongo_bson_visit_code,
NULL /*php_phongo_bson_visit_symbol*/,
php_phongo_bson_visit_codewscope,
php_phongo_bson_visit_int32,
php_phongo_bson_visit_timestamp,
php_phongo_bson_visit_int64,
php_phongo_bson_visit_maxkey,
php_phongo_bson_visit_minkey,
php_phongo_bson_visit_unsupported_type,
php_phongo_bson_visit_decimal128,
{ NULL }
};
bool php_phongo_bson_visit_document(const bson_iter_t *iter ARG_UNUSED, const char *key, const bson_t *v_document, void *data)
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
bson_iter_t child;
TSRMLS_FETCH();
if (bson_iter_init(&child, v_document)) {
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
state.map = ((php_phongo_bson_state *)data)->map;
#if PHP_VERSION_ID >= 70000
array_init(&state.zchild);
#else
MAKE_STD_ZVAL(state.zchild);
array_init(state.zchild);
#endif
if (!bson_iter_visit_all(&child, &php_bson_visitors, &state) && !child.err_off) {
/* If php_phongo_bson_visit_binary() finds an ODM class, it should
* supersede a default type map and named document class. */
if (state.odm && state.map.document_type == PHONGO_TYPEMAP_NONE) {
state.map.document_type = PHONGO_TYPEMAP_CLASS;
}
switch(state.map.document_type) {
case PHONGO_TYPEMAP_NATIVE_ARRAY:
#if PHP_VERSION_ID >= 70000
- ADD_ASSOC_ZVAL(retval, key, &state.zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &state.zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &state.zchild);
+ }
Z_SET_REFCOUNT(state.zchild, 1);
#else
- ADD_ASSOC_ZVAL(retval, key, state.zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, state.zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, state.zchild);
+ }
Z_SET_REFCOUNT_P(state.zchild, 1);
#endif
break;
case PHONGO_TYPEMAP_CLASS: {
#if PHP_VERSION_ID >= 70000
zval obj;
object_init_ex(&obj, state.odm ? state.odm : state.map.document);
zend_call_method_with_1_params(&obj, NULL, NULL, BSON_UNSERIALIZE_FUNC_NAME, NULL, &state.zchild);
- add_assoc_zval(retval, key, &obj);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &obj);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &obj);
+ }
zval_ptr_dtor(&state.zchild);
#else
zval *obj = NULL;
MAKE_STD_ZVAL(obj);
object_init_ex(obj, state.odm ? state.odm : state.map.document);
zend_call_method_with_1_params(&obj, NULL, NULL, BSON_UNSERIALIZE_FUNC_NAME, NULL, state.zchild);
- add_assoc_zval(retval, key, obj);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, obj);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, obj);
+ }
zval_ptr_dtor(&state.zchild);
#endif
break;
}
case PHONGO_TYPEMAP_NATIVE_OBJECT:
default:
#if PHP_VERSION_ID >= 70000
object_and_properties_init(&state.zchild, zend_standard_class_def, Z_ARRVAL(state.zchild));
- add_assoc_zval(retval, key, &state.zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &state.zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &state.zchild);
+ }
Z_SET_REFCOUNT(state.zchild, 1);
#else
object_and_properties_init(state.zchild, zend_standard_class_def, Z_ARRVAL_P(state.zchild));
- add_assoc_zval(retval, key, state.zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, state.zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, state.zchild);
+ }
Z_SET_REFCOUNT_P(state.zchild, 1);
#endif
}
} else {
/* Iteration stopped prematurely due to corruption or a failed
* visitor. Free state.zchild, which we just initialized, and return
* true to stop iteration for our parent context. */
zval_ptr_dtor(&state.zchild);
return true;
}
}
return false;
}
bool php_phongo_bson_visit_array(const bson_iter_t *iter ARG_UNUSED, const char *key, const bson_t *v_array, void *data)
{
#if PHP_VERSION_ID >= 70000
zval *retval = &((php_phongo_bson_state *)data)->zchild;
#else
zval *retval = ((php_phongo_bson_state *)data)->zchild;
#endif
bson_iter_t child;
TSRMLS_FETCH();
if (bson_iter_init(&child, v_array)) {
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
state.map = ((php_phongo_bson_state *)data)->map;
+ /* Note that we are visiting an array, so element visitors know to use
+ * add_next_index() (i.e. disregard BSON keys) instead of add_assoc()
+ * when building the PHP array.
+ */
+ state.is_visiting_array = true;
+
#if PHP_VERSION_ID >= 70000
array_init(&state.zchild);
#else
MAKE_STD_ZVAL(state.zchild);
array_init(state.zchild);
#endif
if (!bson_iter_visit_all(&child, &php_bson_visitors, &state) && !child.err_off) {
switch(state.map.array_type) {
case PHONGO_TYPEMAP_CLASS: {
#if PHP_VERSION_ID >= 70000
zval obj;
object_init_ex(&obj, state.map.array);
zend_call_method_with_1_params(&obj, NULL, NULL, BSON_UNSERIALIZE_FUNC_NAME, NULL, &state.zchild);
- add_assoc_zval(retval, key, &obj);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &obj);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &obj);
+ }
zval_ptr_dtor(&state.zchild);
#else
zval *obj = NULL;
MAKE_STD_ZVAL(obj);
object_init_ex(obj, state.map.array);
zend_call_method_with_1_params(&obj, NULL, NULL, BSON_UNSERIALIZE_FUNC_NAME, NULL, state.zchild);
- add_assoc_zval(retval, key, obj);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, obj);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, obj);
+ }
zval_ptr_dtor(&state.zchild);
#endif
break;
}
case PHONGO_TYPEMAP_NATIVE_OBJECT:
#if PHP_VERSION_ID >= 70000
object_and_properties_init(&state.zchild, zend_standard_class_def, Z_ARRVAL(state.zchild));
- add_assoc_zval(retval, key, &state.zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &state.zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &state.zchild);
+ }
Z_SET_REFCOUNT(state.zchild, 1);
#else
object_and_properties_init(state.zchild, zend_standard_class_def, Z_ARRVAL_P(state.zchild));
- add_assoc_zval(retval, key, state.zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, state.zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, state.zchild);
+ }
Z_SET_REFCOUNT_P(state.zchild, 1);
#endif
break;
case PHONGO_TYPEMAP_NATIVE_ARRAY:
default:
#if PHP_VERSION_ID >= 70000
- ADD_ASSOC_ZVAL(retval, key, &state.zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, &state.zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, &state.zchild);
+ }
Z_SET_REFCOUNT(state.zchild, 1);
#else
- ADD_ASSOC_ZVAL(retval, key, state.zchild);
+ if (((php_phongo_bson_state *)data)->is_visiting_array) {
+ add_next_index_zval(retval, state.zchild);
+ } else {
+ ADD_ASSOC_ZVAL(retval, key, state.zchild);
+ }
Z_SET_REFCOUNT_P(state.zchild, 1);
#endif
break;
}
} else {
/* Iteration stopped prematurely due to corruption or a failed
* visitor. Free state.zchild, which we just initialized, and return
* true to stop iteration for our parent context. */
zval_ptr_dtor(&state.zchild);
return true;
}
}
return false;
}
int php_phongo_is_array_or_document(zval *val TSRMLS_DC) /* {{{ */
{
HashTable *ht_data = HASH_OF(val);
int count;
if (Z_TYPE_P(val) != IS_ARRAY) {
return IS_OBJECT;
}
count = ht_data ? zend_hash_num_elements(ht_data) : 0;
if (count > 0) {
#if PHP_VERSION_ID >= 70000
zend_string *key;
zend_ulong index, idx;
idx = 0;
ZEND_HASH_FOREACH_KEY(ht_data, index, key) {
if (key) {
return IS_OBJECT;
} else {
if (index != idx) {
return IS_OBJECT;
}
}
idx++;
} ZEND_HASH_FOREACH_END();
#else
char *key;
unsigned int key_len;
unsigned long index = 0;
unsigned long idx = 0;
int hash_type = 0;
HashPosition pos;
zend_hash_internal_pointer_reset_ex(ht_data, &pos);
for (;; zend_hash_move_forward_ex(ht_data, &pos)) {
hash_type = zend_hash_get_current_key_ex(ht_data, &key, &key_len, &index, 0, &pos);
if (hash_type == HASH_KEY_NON_EXISTENT) {
break;
}
if (hash_type == HASH_KEY_IS_STRING) {
return IS_OBJECT;
} else {
if (index != idx) {
return IS_OBJECT;
}
}
idx++;
}
#endif
} else {
return Z_TYPE_P(val);
}
return IS_ARRAY;
}
/* }}} */
void object_to_bson(zval *object, php_phongo_bson_flags_t flags, const char *key, long key_len, bson_t *bson TSRMLS_DC)
{
bson_t child;
if (Z_TYPE_P(object) == IS_OBJECT && instanceof_function(Z_OBJCE_P(object), php_phongo_type_ce TSRMLS_CC)) {
if (instanceof_function(Z_OBJCE_P(object), php_phongo_serializable_ce TSRMLS_CC)) {
#if PHP_VERSION_ID >= 70000
zval obj_data;
#else
zval *obj_data = NULL;
#endif
bson_t child;
HashTable *tmp_ht;
#if PHP_VERSION_ID >= 70000
zend_call_method_with_0_params(object, NULL, NULL, BSON_SERIALIZE_FUNC_NAME, &obj_data);
#else
zend_call_method_with_0_params(&object, NULL, NULL, BSON_SERIALIZE_FUNC_NAME, &obj_data);
#endif
if (Z_ISUNDEF(obj_data)) {
/* zend_call_method() failed */
return;
}
#if PHP_VERSION_ID >= 70000
if (Z_TYPE(obj_data) != IS_ARRAY && !(Z_TYPE(obj_data) == IS_OBJECT && instanceof_function(Z_OBJCE(obj_data), zend_standard_class_def TSRMLS_CC))) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC,
"Expected %s::%s() to return an array or stdClass, %s given",
Z_OBJCE_P(object)->name->val,
BSON_SERIALIZE_FUNC_NAME,
(Z_TYPE(obj_data) == IS_OBJECT
? Z_OBJCE(obj_data)->name->val
: zend_get_type_by_const(Z_TYPE(obj_data))
)
);
zval_ptr_dtor(&obj_data);
#else
if (Z_TYPE_P(obj_data) != IS_ARRAY && !(Z_TYPE_P(obj_data) == IS_OBJECT && instanceof_function(Z_OBJCE_P(obj_data), zend_standard_class_def TSRMLS_CC))) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC,
"Expected %s::%s() to return an array or stdClass, %s given",
Z_OBJCE_P(object)->name,
BSON_SERIALIZE_FUNC_NAME,
(Z_TYPE_P(obj_data) == IS_OBJECT
? Z_OBJCE_P(obj_data)->name
: zend_get_type_by_const(Z_TYPE_P(obj_data))
)
);
zval_ptr_dtor(&obj_data);
#endif
return;
}
#if PHP_VERSION_ID >= 70000
tmp_ht = HASH_OF(&obj_data);
#else
tmp_ht = HASH_OF(obj_data);
#endif
- if (tmp_ht) {
- ZEND_HASH_APPLY_COUNT(tmp_ht)++;
+ if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
+ ZEND_HASH_INC_APPLY_COUNT(tmp_ht);
}
/* Persistable objects must always be serialized as BSON documents;
* otherwise, infer based on bsonSerialize()'s return value. */
#if PHP_VERSION_ID >= 70000
if (instanceof_function(Z_OBJCE_P(object), php_phongo_persistable_ce TSRMLS_CC) || php_phongo_is_array_or_document(&obj_data TSRMLS_CC) == IS_OBJECT) {
#else
if (instanceof_function(Z_OBJCE_P(object), php_phongo_persistable_ce TSRMLS_CC) || php_phongo_is_array_or_document(obj_data TSRMLS_CC) == IS_OBJECT) {
#endif
bson_append_document_begin(bson, key, key_len, &child);
if (instanceof_function(Z_OBJCE_P(object), php_phongo_persistable_ce TSRMLS_CC)) {
#if PHP_VERSION_ID >= 70000
bson_append_binary(&child, PHONGO_ODM_FIELD_NAME, -1, 0x80, (const uint8_t *)Z_OBJCE_P(object)->name->val, Z_OBJCE_P(object)->name->len);
#else
bson_append_binary(&child, PHONGO_ODM_FIELD_NAME, -1, 0x80, (const uint8_t *)Z_OBJCE_P(object)->name, strlen(Z_OBJCE_P(object)->name));
#endif
}
#if PHP_VERSION_ID >= 70000
phongo_zval_to_bson(&obj_data, flags, &child, NULL TSRMLS_CC);
#else
phongo_zval_to_bson(obj_data, flags, &child, NULL TSRMLS_CC);
#endif
bson_append_document_end(bson, &child);
} else {
bson_append_array_begin(bson, key, key_len, &child);
#if PHP_VERSION_ID >= 70000
phongo_zval_to_bson(&obj_data, flags, &child, NULL TSRMLS_CC);
#else
phongo_zval_to_bson(obj_data, flags, &child, NULL TSRMLS_CC);
#endif
bson_append_array_end(bson, &child);
}
- if (tmp_ht) {
- ZEND_HASH_APPLY_COUNT(tmp_ht)--;
+ if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
+ ZEND_HASH_DEC_APPLY_COUNT(tmp_ht);
}
zval_ptr_dtor(&obj_data);
return;
}
if (instanceof_function(Z_OBJCE_P(object), php_phongo_objectid_ce TSRMLS_CC)) {
bson_oid_t oid;
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding ObjectId");
php_phongo_objectid_get_id(object, &oid TSRMLS_CC);
bson_append_oid(bson, key, key_len, &oid);
return;
}
if (instanceof_function(Z_OBJCE_P(object), php_phongo_utcdatetime_ce TSRMLS_CC)) {
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding UTCDateTime");
bson_append_date_time(bson, key, key_len, php_phongo_utcdatetime_get_milliseconds(object TSRMLS_CC));
return;
}
if (instanceof_function(Z_OBJCE_P(object), php_phongo_binary_ce TSRMLS_CC)) {
const unsigned char *data;
size_t data_len;
data_len = php_phongo_binary_get_data(object, (char **)&data TSRMLS_CC);
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding Binary");
bson_append_binary(bson, key, key_len, php_phongo_binary_get_type(object TSRMLS_CC), data, data_len);
return;
}
if (instanceof_function(Z_OBJCE_P(object), php_phongo_decimal128_ce TSRMLS_CC)) {
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding Decimal128");
bson_append_decimal128(bson, key, key_len, php_phongo_decimal128_get_decimal128(object TSRMLS_CC));
return;
}
if (instanceof_function(Z_OBJCE_P(object), php_phongo_regex_ce TSRMLS_CC)) {
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding Regex");
bson_append_regex(bson, key, key_len, php_phongo_regex_get_pattern(object TSRMLS_CC), php_phongo_regex_get_flags(object TSRMLS_CC));
return;
}
if (instanceof_function(Z_OBJCE_P(object), php_phongo_javascript_ce TSRMLS_CC)) {
if (php_phongo_javascript_has_scope(object TSRMLS_CC)) {
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding Javascript with scope");
bson_append_code_with_scope(bson, key, key_len, php_phongo_javascript_get_code(object TSRMLS_CC), php_phongo_javascript_get_scope(object TSRMLS_CC));
} else {
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding Javascript without scope");
bson_append_code(bson, key, key_len, php_phongo_javascript_get_code(object TSRMLS_CC));
}
return;
}
if (instanceof_function(Z_OBJCE_P(object), php_phongo_timestamp_ce TSRMLS_CC)) {
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding Timestamp");
/*
* WHOOPS! libbson swaps the increment/timestamp compared to BSON
*
* "Timestamp - Special internal type used by MongoDB replication and sharding.
* First 4 bytes are an increment, second 4 are a timestamp."
*/
bson_append_timestamp(bson, key, key_len, php_phongo_timestamp_get_timestamp(object TSRMLS_CC), php_phongo_timestamp_get_increment(object TSRMLS_CC));
return;
}
if (instanceof_function(Z_OBJCE_P(object), php_phongo_maxkey_ce TSRMLS_CC)) {
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding MaxKey");
bson_append_maxkey(bson, key, key_len);
return;
}
if (instanceof_function(Z_OBJCE_P(object), php_phongo_minkey_ce TSRMLS_CC)) {
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding MinKey");
bson_append_minkey(bson, key, key_len);
return;
}
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Unexpected %s instance: %s", ZSTR_VAL(php_phongo_type_ce->name), ZSTR_VAL(Z_OBJCE_P(object)->name));
return;
- }
+ } else {
+ HashTable *tmp_ht = HASH_OF(object);
+
+ if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
+ ZEND_HASH_INC_APPLY_COUNT(tmp_ht);
+ }
- mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding document");
- bson_append_document_begin(bson, key, key_len, &child);
- phongo_zval_to_bson(object, flags, &child, NULL TSRMLS_CC);
- bson_append_document_end(bson, &child);
+ mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding document");
+ bson_append_document_begin(bson, key, key_len, &child);
+ phongo_zval_to_bson(object, flags, &child, NULL TSRMLS_CC);
+ bson_append_document_end(bson, &child);
+
+ if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
+ ZEND_HASH_DEC_APPLY_COUNT(tmp_ht);
+ }
+ }
}
static void phongo_bson_append(bson_t *bson, php_phongo_bson_flags_t flags, const char *key, long key_len, zval *entry TSRMLS_DC)
{
#if PHP_VERSION_ID >= 70000
try_again:
#endif
switch (Z_TYPE_P(entry))
{
case IS_NULL:
bson_append_null(bson, key, key_len);
break;
#if PHP_VERSION_ID >= 70000
case IS_TRUE:
bson_append_bool(bson, key, key_len, true);
break;
case IS_FALSE:
bson_append_bool(bson, key, key_len, false);
break;
#else
case IS_BOOL:
bson_append_bool(bson, key, key_len, Z_BVAL_P(entry));
break;
#endif
case IS_LONG:
BSON_APPEND_INT(bson, key, key_len, Z_LVAL_P(entry));
break;
case IS_DOUBLE:
bson_append_double(bson, key, key_len, Z_DVAL_P(entry));
break;
case IS_STRING:
if (bson_utf8_validate(Z_STRVAL_P(entry), Z_STRLEN_P(entry), true)) {
bson_append_utf8(bson, key, key_len, Z_STRVAL_P(entry), Z_STRLEN_P(entry));
} else {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Got invalid UTF-8 value serializing '%s'", Z_STRVAL_P(entry));
}
break;
case IS_ARRAY:
if (php_phongo_is_array_or_document(entry TSRMLS_CC) == IS_ARRAY) {
bson_t child;
HashTable *tmp_ht = HASH_OF(entry);
- if (tmp_ht) {
- ZEND_HASH_APPLY_COUNT(tmp_ht)++;
+ if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
+ ZEND_HASH_INC_APPLY_COUNT(tmp_ht);
}
bson_append_array_begin(bson, key, key_len, &child);
phongo_zval_to_bson(entry, flags, &child, NULL TSRMLS_CC);
bson_append_array_end(bson, &child);
- if (tmp_ht) {
- ZEND_HASH_APPLY_COUNT(tmp_ht)--;
+ if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
+ ZEND_HASH_DEC_APPLY_COUNT(tmp_ht);
}
break;
}
/* break intentionally omitted */
case IS_OBJECT:
object_to_bson(entry, flags, key, key_len, bson TSRMLS_CC);
break;
#if PHP_VERSION_ID >= 70000
case IS_INDIRECT:
phongo_bson_append(bson, flags, key, key_len, Z_INDIRECT_P(entry) TSRMLS_DC);
break;
case IS_REFERENCE:
ZVAL_DEREF(entry);
goto try_again;
#endif
default:
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Got unsupported type %d '%s'", Z_TYPE_P(entry), zend_get_type_by_const(Z_TYPE_P(entry)));
}
}
-#if PHP_VERSION_ID >= 70000
-static bool is_public_property(zend_class_entry *ce, zend_string *name, zend_string **member TSRMLS_DC) /* {{{ */
-#else
-static bool is_public_property(zend_class_entry *ce, const char *prop_name, int prop_name_len TSRMLS_DC) /* {{{ */
-#endif
-{
- zend_property_info *property_info = NULL;
-
-#if PHP_VERSION_ID >= 70000
- if (ZSTR_VAL(name)[0] == 0) {
- const char *prop_name,
- *class_name;
- size_t prop_name_len;
-
- zend_unmangle_property_name_ex(name,
- &class_name, &prop_name, &prop_name_len);
- (*member) = zend_string_init(prop_name, prop_name_len, 0);
- } else (*member) = zend_string_copy(name);
- property_info = zend_get_property_info(ce, (*member), 1 TSRMLS_CC);
-
- if (!property_info) /* undefined property */
- return true;
-
- if (property_info == ZEND_WRONG_PROPERTY_INFO) {
- return false;
- }
-
- return (property_info->flags & ZEND_ACC_PUBLIC);
-#else
- zval member;
- ZVAL_STRINGL(&member, prop_name, prop_name_len, 0);
- property_info = zend_get_property_info(ce, &member, 1 TSRMLS_CC);
-
- return (property_info && (property_info->flags & ZEND_ACC_PUBLIC));
-#endif
-}
-/* }}} */
-
void phongo_zval_to_bson(zval *data, php_phongo_bson_flags_t flags, bson_t *bson, bson_t **bson_out TSRMLS_DC) /* {{{ */
{
HashTable *ht_data = NULL;
#if PHP_VERSION_ID >= 70000
zval obj_data;
#else
HashPosition pos;
zval *obj_data = NULL;
#endif
/* If we will be encoding a class that may contain protected and private
* properties, we'll need to filter them out later. */
bool ht_data_from_properties = false;
switch(Z_TYPE_P(data)) {
case IS_OBJECT:
if (instanceof_function(Z_OBJCE_P(data), php_phongo_serializable_ce TSRMLS_CC)) {
#if PHP_VERSION_ID >= 70000
zend_call_method_with_0_params(data, NULL, NULL, BSON_SERIALIZE_FUNC_NAME, &obj_data);
#else
zend_call_method_with_0_params(&data, NULL, NULL, BSON_SERIALIZE_FUNC_NAME, &obj_data);
#endif
if (Z_ISUNDEF(obj_data)) {
/* zend_call_method() failed */
break;
}
#if PHP_VERSION_ID >= 70000
if (Z_TYPE(obj_data) != IS_ARRAY && !(Z_TYPE(obj_data) == IS_OBJECT && instanceof_function(Z_OBJCE(obj_data), zend_standard_class_def TSRMLS_CC))) {
#else
if (Z_TYPE_P(obj_data) != IS_ARRAY && !(Z_TYPE_P(obj_data) == IS_OBJECT && instanceof_function(Z_OBJCE_P(obj_data), zend_standard_class_def TSRMLS_CC))) {
#endif
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC,
"Expected %s::%s() to return an array or stdClass, %s given",
#if PHP_VERSION_ID >= 70000
Z_OBJCE_P(data)->name->val,
#else
Z_OBJCE_P(data)->name,
#endif
BSON_SERIALIZE_FUNC_NAME,
#if PHP_VERSION_ID >= 70000
(Z_TYPE(obj_data) == IS_OBJECT
? Z_OBJCE(obj_data)->name->val
: zend_get_type_by_const(Z_TYPE(obj_data))
#else
(Z_TYPE_P(obj_data) == IS_OBJECT
? Z_OBJCE_P(obj_data)->name
: zend_get_type_by_const(Z_TYPE_P(obj_data))
#endif
)
);
break;
}
#if PHP_VERSION_ID >= 70000
ht_data = HASH_OF(&obj_data);
#else
ht_data = HASH_OF(obj_data);
#endif
if (instanceof_function(Z_OBJCE_P(data), php_phongo_persistable_ce TSRMLS_CC)) {
#if PHP_VERSION_ID >= 70000
bson_append_binary(bson, PHONGO_ODM_FIELD_NAME, -1, 0x80, (const uint8_t *)Z_OBJCE_P(data)->name->val, Z_OBJCE_P(data)->name->len);
zend_hash_str_del(ht_data, PHONGO_ODM_FIELD_NAME, sizeof(PHONGO_ODM_FIELD_NAME)-1);
#else
bson_append_binary(bson, PHONGO_ODM_FIELD_NAME, -1, 0x80, (const uint8_t *)Z_OBJCE_P(data)->name, strlen(Z_OBJCE_P(data)->name));
zend_hash_del(ht_data, PHONGO_ODM_FIELD_NAME, sizeof(PHONGO_ODM_FIELD_NAME));
#endif
}
break;
}
if (instanceof_function(Z_OBJCE_P(data), php_phongo_type_ce TSRMLS_CC)) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "%s instance %s cannot be serialized as a root element", ZSTR_VAL(php_phongo_type_ce->name), ZSTR_VAL(Z_OBJCE_P(data)->name));
break;
}
ht_data = Z_OBJ_HT_P(data)->get_properties(data TSRMLS_CC);
ht_data_from_properties = true;
break;
case IS_ARRAY:
ht_data = HASH_OF(data);
break;
default:
return;
}
- if (!ht_data || ZEND_HASH_APPLY_COUNT(ht_data) > 1) {
+ if (!ht_data || ZEND_HASH_GET_APPLY_COUNT(ht_data) > 1) {
#if PHP_VERSION_ID >= 70000
if (Z_TYPE_P(data) == IS_OBJECT && instanceof_function(Z_OBJCE_P(data), php_phongo_serializable_ce TSRMLS_CC)) {
#endif
if (!Z_ISUNDEF(obj_data)) {
zval_ptr_dtor(&obj_data);
}
#if PHP_VERSION_ID >= 70000
}
#endif
return;
}
#if PHP_VERSION_ID >= 70000
{
zend_string *string_key = NULL;
zend_ulong num_key = 0;
zval *value;
ZEND_HASH_FOREACH_KEY_VAL(ht_data, num_key, string_key, value) {
- /* Ensure we're working with a string key */
- if (!string_key) {
- string_key = zend_long_to_str(num_key);
- } else {
- zend_string_addref(string_key);
- }
-
- if (Z_TYPE_P(data) == IS_OBJECT) {
- zend_string *member = NULL;
-
- /* Ignore non-public properties */
- if (!instanceof_function(Z_OBJCE_P(data), php_phongo_serializable_ce) &&
- !is_public_property(Z_OBJCE_P(data), string_key, &member TSRMLS_CC)) {
- if (member) {
- zend_string_release(member);
- }
- zend_string_release(string_key);
- continue;
- }
-
- if (flags & PHONGO_BSON_ADD_ID) {
- if (!strcmp(member ? ZSTR_VAL(member) : ZSTR_VAL(string_key), "_id")) {
- flags &= ~PHONGO_BSON_ADD_ID;
+ if (string_key) {
+ if (ht_data_from_properties) {
+ /* Skip protected and private properties */
+ if (ZSTR_VAL(string_key)[0] == '\0' && ZSTR_LEN(string_key) > 0) {
+ zend_string_release(string_key);
+ continue;
}
}
- phongo_bson_append(bson, flags & ~PHONGO_BSON_ADD_ID,
- member ? ZSTR_VAL(member) : ZSTR_VAL(string_key),
- member ? ZSTR_LEN(member) : ZSTR_LEN(string_key),
- value TSRMLS_CC);
+ if (strlen(ZSTR_VAL(string_key)) != ZSTR_LEN(string_key)) {
+ phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "BSON keys cannot contain null bytes. Unexpected null byte after \"%s\".", ZSTR_VAL(string_key));
- if (member) {
- zend_string_release(member);
+ return;
}
- } else {
+
if (flags & PHONGO_BSON_ADD_ID) {
if (!strcmp(ZSTR_VAL(string_key), "_id")) {
flags &= ~PHONGO_BSON_ADD_ID;
}
}
- phongo_bson_append(bson, flags & ~PHONGO_BSON_ADD_ID, ZSTR_VAL(string_key), ZSTR_LEN(string_key), value TSRMLS_CC);
}
+ /* Ensure we're working with a string key */
+ if (!string_key) {
+ string_key = zend_long_to_str(num_key);
+ } else {
+ zend_string_addref(string_key);
+ }
+
+ phongo_bson_append(bson, flags & ~PHONGO_BSON_ADD_ID, ZSTR_VAL(string_key), strlen(ZSTR_VAL(string_key)), value TSRMLS_CC);
+
zend_string_release(string_key);
} ZEND_HASH_FOREACH_END();
}
#else
zend_hash_internal_pointer_reset_ex(ht_data, &pos);
for (;; zend_hash_move_forward_ex(ht_data, &pos)) {
char *string_key = NULL;
uint string_key_len = 0;
ulong num_key = 0;
zval **value;
int hash_type;
hash_type = zend_hash_get_current_key_ex(ht_data, &string_key, &string_key_len, &num_key, 0, &pos);
if (hash_type == HASH_KEY_NON_EXISTENT) {
break;
}
if (zend_hash_get_current_data_ex(ht_data, (void **) &value, &pos) == FAILURE) {
break;
}
if (hash_type == HASH_KEY_IS_STRING) {
if (ht_data_from_properties) {
- const char *class_name;
- zend_unmangle_property_name(string_key, string_key_len-1, &class_name, (const char **)&string_key);
- string_key_len = strlen(string_key);
-
- /* Ignore non-public properties */
- if (!is_public_property(Z_OBJCE_P(data), string_key, string_key_len TSRMLS_CC)) {
+ /* Skip protected and private properties */
+ if (string_key[0] == '\0' && string_key_len > 1) {
continue;
}
- } else {
- /* Chop off the \0 from string lengths */
- string_key_len -= 1;
+ }
+
+ if (strlen(string_key) != string_key_len - 1) {
+ phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "BSON keys cannot contain null bytes. Unexpected null byte after \"%s\".", ZSTR_VAL(string_key));
+
+ return;
}
if (flags & PHONGO_BSON_ADD_ID) {
if (!strcmp(string_key, "_id")) {
flags &= ~PHONGO_BSON_ADD_ID;
}
}
}
/* Ensure we're working with a string key */
if (hash_type == HASH_KEY_IS_LONG) {
spprintf(&string_key, 0, "%ld", num_key);
- string_key_len = strlen(string_key);
}
- phongo_bson_append(bson, flags & ~PHONGO_BSON_ADD_ID, string_key, string_key_len, *value TSRMLS_CC);
+ phongo_bson_append(bson, flags & ~PHONGO_BSON_ADD_ID, string_key, strlen(string_key), *value TSRMLS_CC);
if (hash_type == HASH_KEY_IS_LONG) {
efree(string_key);
}
}
#endif
if (flags & PHONGO_BSON_ADD_ID) {
bson_oid_t oid;
bson_oid_init(&oid, NULL);
bson_append_oid(bson, "_id", strlen("_id"), &oid);
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "Added new _id");
if (flags & PHONGO_BSON_RETURN_ID) {
if (bson_out) {
*bson_out = bson_new();
bson_append_oid(*bson_out, "_id", strlen("_id"), &oid);
}
}
}
#if PHP_VERSION_ID >= 70000
if (Z_TYPE_P(data) == IS_OBJECT && instanceof_function(Z_OBJCE_P(data), php_phongo_serializable_ce TSRMLS_CC)) {
#endif
if (!Z_ISUNDEF(obj_data)) {
zval_ptr_dtor(&obj_data);
}
#if PHP_VERSION_ID >= 70000
}
#endif
}
/* }}} */
#if PHP_VERSION_ID >= 70000
int phongo_bson_to_zval(const unsigned char *data, int data_len, zval *zv)
#else
int phongo_bson_to_zval(const unsigned char *data, int data_len, zval **zv)
#endif
{
int retval = 0;
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
retval = phongo_bson_to_zval_ex(data, data_len, &state);
#if PHP_VERSION_ID >= 70000
ZVAL_ZVAL(zv, &state.zchild, 1, 1);
#else
*zv = state.zchild;
#endif
return retval;
}
int phongo_bson_to_zval_ex(const unsigned char *data, int data_len, php_phongo_bson_state *state)
{
bson_reader_t *reader;
bson_iter_t iter;
const bson_t *b;
bool eof = false;
TSRMLS_FETCH();
#if PHP_VERSION_ID < 70000
MAKE_STD_ZVAL(state->zchild);
/* Ensure that state->zchild has a type, since the calling code may want to
* zval_ptr_dtor() it if we throw an exception. */
ZVAL_NULL(state->zchild);
#endif
reader = bson_reader_new_from_data(data, data_len);
if (!(b = bson_reader_read(reader, NULL))) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Could not read document from BSON reader");
bson_reader_destroy(reader);
return 0;
}
if (!bson_iter_init(&iter, b)) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Could not initialize BSON iterator");
bson_reader_destroy(reader);
return 0;
}
/* We initialize an array because it will either be returned as-is (native
* array in type map), passed to bsonUnserialize() (ODM class), or used to
* initialize a stdClass object (native object in type map). */
#if PHP_VERSION_ID >= 70000
array_init(&state->zchild);
#else
array_init(state->zchild);
#endif
if (bson_iter_visit_all(&iter, &php_bson_visitors, state) || iter.err_off) {
/* Iteration stopped prematurely due to corruption or a failed visitor.
* While we free the reader, state->zchild should be left as-is, since
* the calling code may want to zval_ptr_dtor() it. If an exception has
* been thrown already (due to an unsupported BSON type for example,
* don't overwrite with a generic exception message. */
if (!EG(exception)) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Detected corrupt BSON data");
}
bson_reader_destroy(reader);
return 0;
}
/* If php_phongo_bson_visit_binary() finds an ODM class, it should supersede
* a default type map and named root class. */
if (state->odm && state->map.root_type == PHONGO_TYPEMAP_NONE) {
state->map.root_type = PHONGO_TYPEMAP_CLASS;
}
switch (state->map.root_type) {
case PHONGO_TYPEMAP_NATIVE_ARRAY:
/* Nothing to do here */
break;
case PHONGO_TYPEMAP_CLASS: {
#if PHP_VERSION_ID >= 70000
zval obj;
object_init_ex(&obj, state->odm ? state->odm : state->map.root);
zend_call_method_with_1_params(&obj, NULL, NULL, BSON_UNSERIALIZE_FUNC_NAME, NULL, &state->zchild);
zval_ptr_dtor(&state->zchild);
ZVAL_COPY_VALUE(&state->zchild, &obj);
#else
zval *obj = NULL;
MAKE_STD_ZVAL(obj);
object_init_ex(obj, state->odm ? state->odm : state->map.root);
zend_call_method_with_1_params(&obj, NULL, NULL, BSON_UNSERIALIZE_FUNC_NAME, NULL, state->zchild);
zval_ptr_dtor(&state->zchild);
state->zchild = obj;
#endif
break;
}
case PHONGO_TYPEMAP_NATIVE_OBJECT:
default:
#if PHP_VERSION_ID >= 70000
object_and_properties_init(&state->zchild, zend_standard_class_def, Z_ARRVAL(state->zchild));
#else
object_and_properties_init(state->zchild, zend_standard_class_def, Z_ARRVAL_P(state->zchild));
#endif
}
if (bson_reader_read(reader, &eof) || !eof) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Reading document did not exhaust input buffer");
bson_reader_destroy(reader);
return 0;
}
bson_reader_destroy(reader);
return 1;
}
/* {{{ proto string BSON\fromPHP(array|object $value)
Returns the BSON representation of a PHP value */
PHP_FUNCTION(fromPHP)
{
zval *data;
bson_t *bson;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(this_ptr) SUPPRESS_UNUSED_WARNING(return_value_used) /* We don't use these */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "A", &data) == FAILURE) {
return;
}
bson = bson_new();
phongo_zval_to_bson(data, PHONGO_BSON_NONE, bson, NULL TSRMLS_CC);
PHONGO_RETVAL_STRINGL((const char *) bson_get_data(bson), bson->len);
bson_destroy(bson);
}
/* }}} */
static void apply_classname_to_state(const char *classname, int classname_len, php_phongo_bson_typemap_types *type, zend_class_entry **type_ce TSRMLS_DC)
{
if (!strcasecmp(classname, "array")) {
*type = PHONGO_TYPEMAP_NATIVE_ARRAY;
*type_ce = NULL;
} else if (!strcasecmp(classname, "stdclass") || !strcasecmp(classname, "object")) {
*type = PHONGO_TYPEMAP_NATIVE_OBJECT;
*type_ce = NULL;
} else {
#if PHP_VERSION_ID >= 70000
zend_string* zs_classname = zend_string_init(classname, classname_len, 0);
zend_class_entry *found_ce = zend_fetch_class(zs_classname, ZEND_FETCH_CLASS_AUTO|ZEND_FETCH_CLASS_SILENT TSRMLS_CC);
zend_string_free(zs_classname);
#else
zend_class_entry *found_ce = zend_fetch_class(classname, classname_len, ZEND_FETCH_CLASS_AUTO|ZEND_FETCH_CLASS_SILENT TSRMLS_CC);
#endif
if (!found_ce) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Class %s does not exist", classname);
} else if (!PHONGO_IS_CLASS_INSTANTIATABLE(found_ce)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Class %s is not instantiatable", classname);
} else if (!instanceof_function(found_ce, php_phongo_unserializable_ce TSRMLS_CC)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Class %s does not implement %s", classname, ZSTR_VAL(php_phongo_unserializable_ce->name));
} else {
*type = PHONGO_TYPEMAP_CLASS;
*type_ce = found_ce;
}
}
}
void phongo_bson_typemap_to_state(zval *typemap, php_phongo_bson_typemap *map TSRMLS_DC)
{
if (typemap) {
char *classname;
int classname_len;
zend_bool classname_free = 0;
classname = php_array_fetchc_string(typemap, "array", &classname_len, &classname_free);
if (classname_len) {
apply_classname_to_state(classname, classname_len, &map->array_type, &map->array TSRMLS_CC);
}
if (classname_free) {
str_efree(classname);
}
classname = php_array_fetchc_string(typemap, "document", &classname_len, &classname_free);
if (classname_len) {
apply_classname_to_state(classname, classname_len, &map->document_type, &map->document TSRMLS_CC);
}
if (classname_free) {
str_efree(classname);
}
classname = php_array_fetchc_string(typemap, "root", &classname_len, &classname_free);
if (classname_len) {
apply_classname_to_state(classname, classname_len, &map->root_type, &map->root TSRMLS_CC);
}
if (classname_free) {
str_efree(classname);
}
}
}
/* {{{ proto array|object BSON\toPHP(string $bson [, array $typemap = array()])
Returns the PHP representation of a BSON value, optionally converting it into a custom class */
PHP_FUNCTION(toPHP)
{
char *data;
phongo_zpp_char_len data_len;
zval *typemap = NULL;
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(this_ptr) SUPPRESS_UNUSED_WARNING(return_value_used) /* We don't use these */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|a!", &data, &data_len, &typemap) == FAILURE) {
return;
}
phongo_bson_typemap_to_state(typemap, &state.map TSRMLS_CC);
if (!phongo_bson_to_zval_ex((const unsigned char *)data, data_len, &state)) {
zval_ptr_dtor(&state.zchild);
RETURN_NULL();
}
#if PHP_VERSION_ID >= 70000
RETURN_ZVAL(&state.zchild, 0, 1);
#else
RETURN_ZVAL(state.zchild, 0, 1);
#endif
}
/* }}} */
/* {{{ proto string BSON\toJSON(string $bson)
Returns the JSON representation of a BSON value */
PHP_FUNCTION(toJSON)
{
char *data;
phongo_zpp_char_len data_len;
const bson_t *b;
bool eof = false;
bson_reader_t *reader;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(this_ptr) SUPPRESS_UNUSED_WARNING(return_value_used) /* We don't use these */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) {
return;
}
reader = bson_reader_new_from_data((const unsigned char *)data, data_len);
b = bson_reader_read(reader, NULL);
if (b) {
char *str;
size_t str_len;
str = bson_as_json(b, &str_len);
if (!str) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Could not convert BSON document to a JSON string");
bson_reader_destroy(reader);
return;
}
PHONGO_RETVAL_STRINGL(str, str_len);
bson_free(str);
} else {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Could not read document from BSON reader");
bson_reader_destroy(reader);
return;
}
if (bson_reader_read(reader, &eof) || !eof) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Reading document did not exhaust input buffer");
}
bson_reader_destroy(reader);
}
/* }}} */
/* {{{ proto string BSON\fromJSON(string $json)
Returns the BSON representation of a JSON value */
PHP_FUNCTION(fromJSON)
{
char *data;
phongo_zpp_char_len data_len;
bson_t b = BSON_INITIALIZER;
bson_error_t error;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(this_ptr) SUPPRESS_UNUSED_WARNING(return_value_used) /* We don't use these */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) {
return;
}
if (bson_init_from_json(&b, (const char *)data, data_len, &error)) {
PHONGO_RETVAL_STRINGL((const char *) bson_get_data(&b), b.len);
bson_destroy(&b);
} else {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "%s", error.domain == BSON_ERROR_JSON ? error.message : "Error parsing JSON");
}
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
diff --git a/mongodb-1.2.0/src/contrib/php_array_api.h b/mongodb-1.2.3/src/contrib/php_array_api.h
similarity index 100%
rename from mongodb-1.2.0/src/contrib/php_array_api.h
rename to mongodb-1.2.3/src/contrib/php_array_api.h
diff --git a/mongodb-1.2.3/src/libbson/VERSION_CURRENT b/mongodb-1.2.3/src/libbson/VERSION_CURRENT
new file mode 100644
index 00000000..1d5e9e0b
--- /dev/null
+++ b/mongodb-1.2.3/src/libbson/VERSION_CURRENT
@@ -0,0 +1 @@
+1.5.3
\ No newline at end of file
diff --git a/mongodb-1.2.3/src/libbson/VERSION_RELEASED b/mongodb-1.2.3/src/libbson/VERSION_RELEASED
new file mode 100644
index 00000000..1d5e9e0b
--- /dev/null
+++ b/mongodb-1.2.3/src/libbson/VERSION_RELEASED
@@ -0,0 +1 @@
+1.5.3
\ No newline at end of file
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/CheckAtomics.m4 b/mongodb-1.2.3/src/libbson/build/autotools/CheckAtomics.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/CheckAtomics.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/CheckAtomics.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/CheckCompiler.m4 b/mongodb-1.2.3/src/libbson/build/autotools/CheckCompiler.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/CheckCompiler.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/CheckCompiler.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/CheckHeaders.m4 b/mongodb-1.2.3/src/libbson/build/autotools/CheckHeaders.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/CheckHeaders.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/CheckHeaders.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/CheckHost.m4 b/mongodb-1.2.3/src/libbson/build/autotools/CheckHost.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/CheckHost.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/CheckHost.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/CheckProgs.m4 b/mongodb-1.2.3/src/libbson/build/autotools/CheckProgs.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/CheckProgs.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/CheckProgs.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/CheckTarget.m4 b/mongodb-1.2.3/src/libbson/build/autotools/CheckTarget.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/CheckTarget.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/CheckTarget.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/Coverage.m4 b/mongodb-1.2.3/src/libbson/build/autotools/Coverage.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/Coverage.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/Coverage.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/Endian.m4 b/mongodb-1.2.3/src/libbson/build/autotools/Endian.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/Endian.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/Endian.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/FindDependencies.m4 b/mongodb-1.2.3/src/libbson/build/autotools/FindDependencies.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/FindDependencies.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/FindDependencies.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/MaintainerFlags.m4 b/mongodb-1.2.3/src/libbson/build/autotools/MaintainerFlags.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/MaintainerFlags.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/MaintainerFlags.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/Optimizations.m4 b/mongodb-1.2.3/src/libbson/build/autotools/Optimizations.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/Optimizations.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/Optimizations.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/PrintBuildConfiguration.m4 b/mongodb-1.2.3/src/libbson/build/autotools/PrintBuildConfiguration.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/PrintBuildConfiguration.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/PrintBuildConfiguration.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/ReadCommandLineArguments.m4 b/mongodb-1.2.3/src/libbson/build/autotools/ReadCommandLineArguments.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/ReadCommandLineArguments.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/ReadCommandLineArguments.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/SetupAutomake.m4 b/mongodb-1.2.3/src/libbson/build/autotools/SetupAutomake.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/SetupAutomake.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/SetupAutomake.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/SetupLibtool.m4 b/mongodb-1.2.3/src/libbson/build/autotools/SetupLibtool.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/SetupLibtool.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/SetupLibtool.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/Versions.m4 b/mongodb-1.2.3/src/libbson/build/autotools/Versions.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/Versions.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/Versions.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/m4/ac_check_typedef.m4 b/mongodb-1.2.3/src/libbson/build/autotools/m4/ac_check_typedef.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/m4/ac_check_typedef.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/m4/ac_check_typedef.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/m4/ac_compile_check_sizeof.m4 b/mongodb-1.2.3/src/libbson/build/autotools/m4/ac_compile_check_sizeof.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/m4/ac_compile_check_sizeof.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/m4/ac_compile_check_sizeof.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/m4/ac_create_stdint_h.m4 b/mongodb-1.2.3/src/libbson/build/autotools/m4/ac_create_stdint_h.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/m4/ac_create_stdint_h.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/m4/ac_create_stdint_h.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/m4/as-compiler-flag.m4 b/mongodb-1.2.3/src/libbson/build/autotools/m4/as-compiler-flag.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/m4/as-compiler-flag.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/m4/as-compiler-flag.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/m4/ax_check_compile_flag.m4 b/mongodb-1.2.3/src/libbson/build/autotools/m4/ax_check_compile_flag.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/m4/ax_check_compile_flag.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/m4/ax_check_compile_flag.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/m4/ax_check_link_flag.m4 b/mongodb-1.2.3/src/libbson/build/autotools/m4/ax_check_link_flag.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/m4/ax_check_link_flag.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/m4/ax_check_link_flag.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/m4/ax_pthread.m4 b/mongodb-1.2.3/src/libbson/build/autotools/m4/ax_pthread.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/m4/ax_pthread.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/m4/ax_pthread.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/m4/pkg.m4 b/mongodb-1.2.3/src/libbson/build/autotools/m4/pkg.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/m4/pkg.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/m4/pkg.m4
diff --git a/mongodb-1.2.0/src/libbson/build/autotools/m4/silent.m4 b/mongodb-1.2.3/src/libbson/build/autotools/m4/silent.m4
similarity index 100%
rename from mongodb-1.2.0/src/libbson/build/autotools/m4/silent.m4
rename to mongodb-1.2.3/src/libbson/build/autotools/m4/silent.m4
diff --git a/mongodb-1.2.0/src/libbson/src/bson/b64_ntop.h b/mongodb-1.2.3/src/libbson/src/bson/b64_ntop.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/b64_ntop.h
rename to mongodb-1.2.3/src/libbson/src/bson/b64_ntop.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/b64_pton.h b/mongodb-1.2.3/src/libbson/src/bson/b64_pton.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/b64_pton.h
rename to mongodb-1.2.3/src/libbson/src/bson/b64_pton.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bcon.c b/mongodb-1.2.3/src/libbson/src/bson/bcon.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bcon.c
rename to mongodb-1.2.3/src/libbson/src/bson/bcon.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bcon.h b/mongodb-1.2.3/src/libbson/src/bson/bcon.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bcon.h
rename to mongodb-1.2.3/src/libbson/src/bson/bcon.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-atomic.c b/mongodb-1.2.3/src/libbson/src/bson/bson-atomic.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-atomic.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-atomic.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-atomic.h b/mongodb-1.2.3/src/libbson/src/bson/bson-atomic.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-atomic.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-atomic.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-clock.c b/mongodb-1.2.3/src/libbson/src/bson/bson-clock.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-clock.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-clock.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-clock.h b/mongodb-1.2.3/src/libbson/src/bson/bson-clock.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-clock.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-clock.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-compat.h b/mongodb-1.2.3/src/libbson/src/bson/bson-compat.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-compat.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-compat.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-config.h b/mongodb-1.2.3/src/libbson/src/bson/bson-config.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-config.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-config.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-config.h.in b/mongodb-1.2.3/src/libbson/src/bson/bson-config.h.in
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-config.h.in
rename to mongodb-1.2.3/src/libbson/src/bson/bson-config.h.in
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-context-private.h b/mongodb-1.2.3/src/libbson/src/bson/bson-context-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-context-private.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-context-private.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-context.c b/mongodb-1.2.3/src/libbson/src/bson/bson-context.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-context.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-context.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-context.h b/mongodb-1.2.3/src/libbson/src/bson/bson-context.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-context.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-context.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-decimal128.c b/mongodb-1.2.3/src/libbson/src/bson/bson-decimal128.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-decimal128.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-decimal128.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-decimal128.h b/mongodb-1.2.3/src/libbson/src/bson/bson-decimal128.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-decimal128.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-decimal128.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-endian.h b/mongodb-1.2.3/src/libbson/src/bson/bson-endian.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-endian.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-endian.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-error.c b/mongodb-1.2.3/src/libbson/src/bson/bson-error.c
similarity index 97%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-error.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-error.c
index 697a3b7f..05dbb789 100644
--- a/mongodb-1.2.0/src/libbson/src/bson/bson-error.c
+++ b/mongodb-1.2.3/src/libbson/src/bson/bson-error.c
@@ -1,127 +1,127 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdarg.h>
#include "bson-compat.h"
#include "bson-config.h"
#include "bson-error.h"
#include "bson-memory.h"
#include "bson-string.h"
#include "bson-types.h"
/*
*--------------------------------------------------------------------------
*
* bson_set_error --
*
* Initializes @error using the parameters specified.
*
* @domain is an application specific error domain which should
* describe which module initiated the error. Think of this as the
* exception type.
*
* @code is the @domain specific error code.
*
* @format is used to generate the format string. It uses vsnprintf()
* internally so the format should match what you would use there.
*
* Parameters:
* @error: A #bson_error_t.
* @domain: The error domain.
* @code: The error code.
* @format: A printf style format string.
*
* Returns:
* None.
*
* Side effects:
* @error is initialized.
*
*--------------------------------------------------------------------------
*/
void
bson_set_error (bson_error_t *error, /* OUT */
uint32_t domain, /* IN */
uint32_t code, /* IN */
const char *format, /* IN */
...) /* IN */
{
va_list args;
if (error) {
error->domain = domain;
error->code = code;
va_start (args, format);
bson_vsnprintf (error->message, sizeof error->message, format, args);
va_end (args);
error->message[sizeof error->message - 1] = '\0';
}
}
/*
*--------------------------------------------------------------------------
*
* bson_strerror_r --
*
* This is a reentrant safe macro for strerror.
*
* The resulting string may be stored in @buf.
*
* Returns:
* A pointer to a static string or @buf.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
char *
bson_strerror_r (int err_code, /* IN */
char *buf, /* IN */
size_t buflen) /* IN */
{
static const char *unknown_msg = "Unknown error";
char *ret = NULL;
-#if defined(__GNUC__) && defined(_GNU_SOURCE)
- ret = strerror_r (err_code, buf, buflen);
-#elif defined(_WIN32)
+#if defined(_WIN32)
if (strerror_s (buf, buflen, err_code) != 0) {
ret = buf;
}
+#elif defined(__GNUC__) && defined(_GNU_SOURCE)
+ ret = strerror_r (err_code, buf, buflen);
#else /* XSI strerror_r */
if (strerror_r (err_code, buf, buflen) == 0) {
ret = buf;
}
#endif
if (!ret) {
bson_strncpy (buf, unknown_msg, buflen);
ret = buf;
}
return ret;
}
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-error.h b/mongodb-1.2.3/src/libbson/src/bson/bson-error.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-error.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-error.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-iso8601-private.h b/mongodb-1.2.3/src/libbson/src/bson/bson-iso8601-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-iso8601-private.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-iso8601-private.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-iso8601.c b/mongodb-1.2.3/src/libbson/src/bson/bson-iso8601.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-iso8601.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-iso8601.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-iter.c b/mongodb-1.2.3/src/libbson/src/bson/bson-iter.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-iter.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-iter.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-iter.h b/mongodb-1.2.3/src/libbson/src/bson/bson-iter.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-iter.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-iter.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-json.c b/mongodb-1.2.3/src/libbson/src/bson/bson-json.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-json.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-json.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-json.h b/mongodb-1.2.3/src/libbson/src/bson/bson-json.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-json.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-json.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-keys.c b/mongodb-1.2.3/src/libbson/src/bson/bson-keys.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-keys.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-keys.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-keys.h b/mongodb-1.2.3/src/libbson/src/bson/bson-keys.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-keys.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-keys.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-macros.h b/mongodb-1.2.3/src/libbson/src/bson/bson-macros.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-macros.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-macros.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-md5.c b/mongodb-1.2.3/src/libbson/src/bson/bson-md5.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-md5.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-md5.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-md5.h b/mongodb-1.2.3/src/libbson/src/bson/bson-md5.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-md5.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-md5.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-memory.c b/mongodb-1.2.3/src/libbson/src/bson/bson-memory.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-memory.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-memory.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-memory.h b/mongodb-1.2.3/src/libbson/src/bson/bson-memory.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-memory.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-memory.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-oid.c b/mongodb-1.2.3/src/libbson/src/bson/bson-oid.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-oid.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-oid.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-oid.h b/mongodb-1.2.3/src/libbson/src/bson/bson-oid.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-oid.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-oid.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-private.h b/mongodb-1.2.3/src/libbson/src/bson/bson-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-private.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-private.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-reader.c b/mongodb-1.2.3/src/libbson/src/bson/bson-reader.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-reader.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-reader.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-reader.h b/mongodb-1.2.3/src/libbson/src/bson/bson-reader.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-reader.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-reader.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-stdint-win32.h b/mongodb-1.2.3/src/libbson/src/bson/bson-stdint-win32.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-stdint-win32.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-stdint-win32.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-stdint.h b/mongodb-1.2.3/src/libbson/src/bson/bson-stdint.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-stdint.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-stdint.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-string.c b/mongodb-1.2.3/src/libbson/src/bson/bson-string.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-string.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-string.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-string.h b/mongodb-1.2.3/src/libbson/src/bson/bson-string.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-string.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-string.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-thread-private.h b/mongodb-1.2.3/src/libbson/src/bson/bson-thread-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-thread-private.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-thread-private.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-timegm-private.h b/mongodb-1.2.3/src/libbson/src/bson/bson-timegm-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-timegm-private.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-timegm-private.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-timegm.c b/mongodb-1.2.3/src/libbson/src/bson/bson-timegm.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-timegm.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-timegm.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-types.h b/mongodb-1.2.3/src/libbson/src/bson/bson-types.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-types.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-types.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-utf8.c b/mongodb-1.2.3/src/libbson/src/bson/bson-utf8.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-utf8.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-utf8.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-utf8.h b/mongodb-1.2.3/src/libbson/src/bson/bson-utf8.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-utf8.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-utf8.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-value.c b/mongodb-1.2.3/src/libbson/src/bson/bson-value.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-value.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-value.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-value.h b/mongodb-1.2.3/src/libbson/src/bson/bson-value.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-value.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-value.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-version-functions.c b/mongodb-1.2.3/src/libbson/src/bson/bson-version-functions.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-version-functions.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-version-functions.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-version-functions.h b/mongodb-1.2.3/src/libbson/src/bson/bson-version-functions.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-version-functions.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-version-functions.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-version.h b/mongodb-1.2.3/src/libbson/src/bson/bson-version.h
similarity index 96%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-version.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-version.h
index e0739d5f..c1d8e657 100644
--- a/mongodb-1.2.0/src/libbson/src/bson/bson-version.h
+++ b/mongodb-1.2.3/src/libbson/src/bson/bson-version.h
@@ -1,101 +1,101 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !defined (BSON_INSIDE) && !defined (BSON_COMPILATION)
#error "Only <bson.h> can be included directly."
#endif
#ifndef BSON_VERSION_H
#define BSON_VERSION_H
/**
* BSON_MAJOR_VERSION:
*
* BSON major version component (e.g. 1 if %BSON_VERSION is 1.2.3)
*/
#define BSON_MAJOR_VERSION (1)
/**
* BSON_MINOR_VERSION:
*
* BSON minor version component (e.g. 2 if %BSON_VERSION is 1.2.3)
*/
#define BSON_MINOR_VERSION (5)
/**
* BSON_MICRO_VERSION:
*
* BSON micro version component (e.g. 3 if %BSON_VERSION is 1.2.3)
*/
-#define BSON_MICRO_VERSION (0)
+#define BSON_MICRO_VERSION (3)
/**
* BSON_PRERELEASE_VERSION:
*
* BSON prerelease version component (e.g. rc0 if %BSON_VERSION is 1.2.3-rc0)
*/
#define BSON_PRERELEASE_VERSION ()
/**
* BSON_VERSION:
*
* BSON version.
*/
-#define BSON_VERSION (1.5.0)
+#define BSON_VERSION (1.5.3)
/**
* BSON_VERSION_S:
*
* BSON version, encoded as a string, useful for printing and
* concatenation.
*/
-#define BSON_VERSION_S "1.5.0"
+#define BSON_VERSION_S "1.5.3"
/**
* BSON_VERSION_HEX:
*
* BSON version, encoded as an hexadecimal number, useful for
* integer comparisons.
*/
#define BSON_VERSION_HEX (BSON_MAJOR_VERSION << 24 | \
BSON_MINOR_VERSION << 16 | \
BSON_MICRO_VERSION << 8)
/**
* BSON_CHECK_VERSION:
* @major: required major version
* @minor: required minor version
* @micro: required micro version
*
* Compile-time version checking. Evaluates to %TRUE if the version
* of BSON is greater than the required one.
*/
#define BSON_CHECK_VERSION(major,minor,micro) \
(BSON_MAJOR_VERSION > (major) || \
(BSON_MAJOR_VERSION == (major) && BSON_MINOR_VERSION > (minor)) || \
(BSON_MAJOR_VERSION == (major) && BSON_MINOR_VERSION == (minor) && \
BSON_MICRO_VERSION >= (micro)))
#endif /* BSON_VERSION_H */
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-version.h.in b/mongodb-1.2.3/src/libbson/src/bson/bson-version.h.in
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-version.h.in
rename to mongodb-1.2.3/src/libbson/src/bson/bson-version.h.in
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-writer.c b/mongodb-1.2.3/src/libbson/src/bson/bson-writer.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-writer.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson-writer.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson-writer.h b/mongodb-1.2.3/src/libbson/src/bson/bson-writer.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson-writer.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson-writer.h
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson.c b/mongodb-1.2.3/src/libbson/src/bson/bson.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson.c
rename to mongodb-1.2.3/src/libbson/src/bson/bson.c
diff --git a/mongodb-1.2.0/src/libbson/src/bson/bson.h b/mongodb-1.2.3/src/libbson/src/bson/bson.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/bson/bson.h
rename to mongodb-1.2.3/src/libbson/src/bson/bson.h
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl.c b/mongodb-1.2.3/src/libbson/src/yajl/yajl.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl.c
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl.c
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_alloc.c b/mongodb-1.2.3/src/libbson/src/yajl/yajl_alloc.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_alloc.c
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_alloc.c
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_alloc.h b/mongodb-1.2.3/src/libbson/src/yajl/yajl_alloc.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_alloc.h
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_alloc.h
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_buf.c b/mongodb-1.2.3/src/libbson/src/yajl/yajl_buf.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_buf.c
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_buf.c
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_buf.h b/mongodb-1.2.3/src/libbson/src/yajl/yajl_buf.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_buf.h
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_buf.h
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_bytestack.h b/mongodb-1.2.3/src/libbson/src/yajl/yajl_bytestack.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_bytestack.h
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_bytestack.h
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_common.h b/mongodb-1.2.3/src/libbson/src/yajl/yajl_common.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_common.h
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_common.h
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_encode.c b/mongodb-1.2.3/src/libbson/src/yajl/yajl_encode.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_encode.c
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_encode.c
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_encode.h b/mongodb-1.2.3/src/libbson/src/yajl/yajl_encode.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_encode.h
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_encode.h
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_gen.c b/mongodb-1.2.3/src/libbson/src/yajl/yajl_gen.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_gen.c
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_gen.c
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_gen.h b/mongodb-1.2.3/src/libbson/src/yajl/yajl_gen.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_gen.h
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_gen.h
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_lex.c b/mongodb-1.2.3/src/libbson/src/yajl/yajl_lex.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_lex.c
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_lex.c
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_lex.h b/mongodb-1.2.3/src/libbson/src/yajl/yajl_lex.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_lex.h
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_lex.h
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_parse.h b/mongodb-1.2.3/src/libbson/src/yajl/yajl_parse.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_parse.h
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_parse.h
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_parser.c b/mongodb-1.2.3/src/libbson/src/yajl/yajl_parser.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_parser.c
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_parser.c
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_parser.h b/mongodb-1.2.3/src/libbson/src/yajl/yajl_parser.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_parser.h
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_parser.h
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_tree.c b/mongodb-1.2.3/src/libbson/src/yajl/yajl_tree.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_tree.c
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_tree.c
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_tree.h b/mongodb-1.2.3/src/libbson/src/yajl/yajl_tree.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_tree.h
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_tree.h
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_version.c b/mongodb-1.2.3/src/libbson/src/yajl/yajl_version.c
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_version.c
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_version.c
diff --git a/mongodb-1.2.0/src/libbson/src/yajl/yajl_version.h b/mongodb-1.2.3/src/libbson/src/yajl/yajl_version.h
similarity index 100%
rename from mongodb-1.2.0/src/libbson/src/yajl/yajl_version.h
rename to mongodb-1.2.3/src/libbson/src/yajl/yajl_version.h
diff --git a/mongodb-1.2.3/src/libmongoc/VERSION_CURRENT b/mongodb-1.2.3/src/libmongoc/VERSION_CURRENT
new file mode 100644
index 00000000..1d5e9e0b
--- /dev/null
+++ b/mongodb-1.2.3/src/libmongoc/VERSION_CURRENT
@@ -0,0 +1 @@
+1.5.3
\ No newline at end of file
diff --git a/mongodb-1.2.3/src/libmongoc/VERSION_RELEASED b/mongodb-1.2.3/src/libmongoc/VERSION_RELEASED
new file mode 100644
index 00000000..1d5e9e0b
--- /dev/null
+++ b/mongodb-1.2.3/src/libmongoc/VERSION_RELEASED
@@ -0,0 +1 @@
+1.5.3
\ No newline at end of file
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/AutomaticInitAndCleanup.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/AutomaticInitAndCleanup.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/AutomaticInitAndCleanup.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/AutomaticInitAndCleanup.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/CheckCompiler.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/CheckCompiler.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/CheckCompiler.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/CheckCompiler.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/CheckHost.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/CheckHost.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/CheckHost.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/CheckHost.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/CheckProgs.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/CheckProgs.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/CheckProgs.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/CheckProgs.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/CheckSSL.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/CheckSSL.m4
similarity index 98%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/CheckSSL.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/CheckSSL.m4
index 0ababd46..bb87131f 100644
--- a/mongodb-1.2.0/src/libmongoc/build/autotools/CheckSSL.m4
+++ b/mongodb-1.2.3/src/libmongoc/build/autotools/CheckSSL.m4
@@ -1,131 +1,134 @@
AC_MSG_CHECKING([whether to enable crypto and TLS])
AC_ARG_ENABLE([ssl],
[AS_HELP_STRING([--enable-ssl=@<:@auto/no/openssl/darwin@:>@],
[Enable TLS connections and SCRAM-SHA-1 authentication.])],
[],
[enable_ssl=auto])
AC_MSG_RESULT([$enable_ssl])
AC_MSG_CHECKING([whether to use system crypto profile])
AC_ARG_ENABLE(crypto-system-profile,
AC_HELP_STRING([--enable-crypto-system-profile], [use system crypto profile (OpenSSL only) [default=no]]),
[],
[enable_crypto_system_profile="no"])
AC_MSG_RESULT([$enable_crypto_system_profile])
AS_IF([test "$enable_ssl" != "no"],[
AS_IF([test "$enable_ssl" != "darwin" -a "$enable_ssl" != "libressl"],[
PKG_CHECK_MODULES(SSL, [openssl], [enable_openssl=auto], [
AC_CHECK_LIB([ssl],[SSL_library_init],[have_ssl_lib=yes],[have_ssl_lib=no])
AC_CHECK_LIB([crypto],[EVP_DigestInit_ex],[have_crypto_lib=yes],[have_crypto_lib=no])
if test "$have_ssl_lib" = "no" -o "$have_crypto_lib" = "no" ; then
if test "$enable_ssl" = "openssl"; then
AC_MSG_ERROR([You must install the OpenSSL libraries and development headers to enable OpenSSL support.])
else
AC_MSG_WARN([You must install the OpenSSL libraries and development headers to enable OpenSSL support.])
fi
fi
if test "$have_ssl_lib" = "yes" -a "$have_crypto_lib" = "yes"; then
SSL_LIBS="-lssl -lcrypto"
enable_ssl=openssl
fi
])
])
AS_IF([test "$enable_ssl" = "libressl"],[
AC_CHECK_LIB([tls],[tls_init],[
SSL_LIBS="-ltls -lcrypto"
enable_ssl=libressl
])
])
dnl PKG_CHECK_MODULES() doesn't check for headers
dnl OSX for example has the lib, but not headers, so double confirm if OpenSSL works
AS_IF([test "$enable_ssl" = "openssl" -o "$enable_openssl" = "auto"], [
+ old_CFLAGS=$CFLAGS
+ CFLAGS=$SSL_CFLAGS
AC_CHECK_HEADERS([openssl/bio.h openssl/ssl.h openssl/err.h openssl/crypto.h],
[have_ssl_headers=yes],
[have_ssl_headers=no])
if test "$have_ssl_headers" = "yes"; then
enable_ssl=openssl
elif test "$enable_ssl" = "openssl"; then
AC_MSG_ERROR([You must install the OpenSSL development headers to enable OpenSSL support.])
else
SSL_LIBS=""
enable_ssl=auto
fi
+ CFLAGS=$old_CFLAGS
])
AS_IF([test "$enable_ssl" != "openssl" -a "$os_darwin" = "yes"],[
SSL_LIBS="-framework Security -framework CoreFoundation"
enable_ssl="darwin"
])
dnl If its still auto, its no.
AS_IF([test "$enable_ssl" = "auto"],[
enable_ssl="no"
])
AC_MSG_CHECKING([which TLS library to use])
AC_MSG_RESULT([$enable_ssl])
], [enable_ssl=no])
AC_SUBST(SSL_CFLAGS)
AC_SUBST(SSL_LIBS)
dnl Disable Windows SSL+Crypto
AC_SUBST(MONGOC_ENABLE_SSL_SECURE_CHANNEL, 0)
AC_SUBST(MONGOC_ENABLE_CRYPTO_CNG, 0)
if test "$enable_ssl" = "darwin" -o "$enable_ssl" = "openssl" -o "$enable_ssl" = "libressl"; then
AC_SUBST(MONGOC_ENABLE_SSL, 1)
AC_SUBST(MONGOC_ENABLE_CRYPTO, 1)
if test "$enable_ssl" = "darwin"; then
AC_SUBST(MONGOC_ENABLE_SSL_OPENSSL, 0)
AC_SUBST(MONGOC_ENABLE_SSL_LIBRESSL, 0)
AC_SUBST(MONGOC_ENABLE_SSL_SECURE_TRANSPORT, 1)
AC_SUBST(MONGOC_ENABLE_CRYPTO_LIBCRYPTO, 0)
AC_SUBST(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO, 1)
elif test "$enable_ssl" = "openssl"; then
AC_SUBST(MONGOC_ENABLE_SSL_OPENSSL, 1)
AC_SUBST(MONGOC_ENABLE_SSL_LIBRESSL, 0)
AC_SUBST(MONGOC_ENABLE_SSL_SECURE_TRANSPORT, 0)
AC_SUBST(MONGOC_ENABLE_CRYPTO_LIBCRYPTO, 1)
AC_SUBST(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO, 0)
elif test "$enable_ssl" = "libressl"; then
AC_SUBST(MONGOC_ENABLE_SSL_LIBRESSL, 1)
AC_SUBST(MONGOC_ENABLE_SSL_OPENSSL, 0)
AC_SUBST(MONGOC_ENABLE_SSL_SECURE_TRANSPORT, 0)
AC_SUBST(MONGOC_ENABLE_CRYPTO_LIBCRYPTO, 1)
AC_SUBST(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO, 0)
fi
else
AC_SUBST(MONGOC_ENABLE_SSL, 0)
AC_SUBST(MONGOC_ENABLE_SSL_LIBRESSL, 0)
AC_SUBST(MONGOC_ENABLE_SSL_OPENSSL, 0)
AC_SUBST(MONGOC_ENABLE_SSL_SECURE_TRANSPORT, 0)
AC_SUBST(MONGOC_ENABLE_CRYPTO, 0)
AC_SUBST(MONGOC_ENABLE_CRYPTO_LIBCRYPTO, 0)
AC_SUBST(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO, 0)
fi
if test "x$enable_crypto_system_profile" = xyes; then
if test "$enable_ssl" = "openssl"; then
AC_SUBST(MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE, 1)
else
AC_MSG_ERROR([--enable-crypto-system-profile only available with OpenSSL.])
fi
else
AC_SUBST(MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE, 0)
fi
AM_CONDITIONAL([ENABLE_SSL], [test "$enable_ssl" = "darwin" -o "$enable_ssl" = "openssl" -o "$enable_ssl" = "libressl"])
AM_CONDITIONAL([ENABLE_SSL_LIBRESSL], [test "$enable_ssl" = "libressl"])
AM_CONDITIONAL([ENABLE_SSL_OPENSSL], [test "$enable_ssl" = "openssl"])
AM_CONDITIONAL([ENABLE_SSL_SECURE_TRANSPORT], [test "$enable_ssl" = "darwin"])
AM_CONDITIONAL([ENABLE_SSL_SECURE_CHANNEL], false)
AM_CONDITIONAL([ENABLE_CRYPTO], [test "$enable_ssl" = "darwin" -o "$enable_ssl" = "openssl" -o "$enable_ssl" = "libressl"])
AM_CONDITIONAL([ENABLE_CRYPTO_LIBCRYPTO], [test "$enable_ssl" = "openssl" -o "$enable_ssl" = "libressl"])
AM_CONDITIONAL([ENABLE_CRYPTO_CNG], false)
AM_CONDITIONAL([ENABLE_CRYPTO_COMMON_CRYPTO], [test "$enable_ssl" = "darwin"])
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/CheckSasl.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/CheckSasl.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/CheckSasl.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/CheckSasl.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/CheckTarget.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/CheckTarget.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/CheckTarget.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/CheckTarget.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/Coverage.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/Coverage.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/Coverage.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/Coverage.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/FindDependencies.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/FindDependencies.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/FindDependencies.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/FindDependencies.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/Libbson.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/Libbson.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/Libbson.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/Libbson.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/MaintainerFlags.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/MaintainerFlags.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/MaintainerFlags.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/MaintainerFlags.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/Optimizations.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/Optimizations.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/Optimizations.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/Optimizations.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/PlatformFlags.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/PlatformFlags.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/PlatformFlags.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/PlatformFlags.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/PrintBuildConfiguration.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/PrintBuildConfiguration.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/PrintBuildConfiguration.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/PrintBuildConfiguration.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/ReadCommandLineArguments.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/ReadCommandLineArguments.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/ReadCommandLineArguments.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/ReadCommandLineArguments.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/SetupAutomake.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/SetupAutomake.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/SetupAutomake.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/SetupAutomake.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/SetupLibtool.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/SetupLibtool.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/SetupLibtool.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/SetupLibtool.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/Versions.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/Versions.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/Versions.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/Versions.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/WeakSymbols.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/WeakSymbols.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/WeakSymbols.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/WeakSymbols.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/m4/ac_check_typedef.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/m4/ac_check_typedef.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/m4/ac_check_typedef.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/m4/ac_check_typedef.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/m4/ac_compile_check_sizeof.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/m4/ac_compile_check_sizeof.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/m4/ac_compile_check_sizeof.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/m4/ac_compile_check_sizeof.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/m4/ac_create_stdint_h.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/m4/ac_create_stdint_h.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/m4/ac_create_stdint_h.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/m4/ac_create_stdint_h.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/m4/as-compiler-flag.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/m4/as-compiler-flag.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/m4/as-compiler-flag.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/m4/as-compiler-flag.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/m4/ax_check_compile_flag.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/m4/ax_check_compile_flag.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/m4/ax_check_compile_flag.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/m4/ax_check_compile_flag.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/m4/ax_check_link_flag.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/m4/ax_check_link_flag.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/m4/ax_check_link_flag.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/m4/ax_check_link_flag.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/m4/ax_pthread.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/m4/ax_pthread.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/m4/ax_pthread.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/m4/ax_pthread.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/m4/pkg.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/m4/pkg.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/m4/pkg.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/m4/pkg.m4
diff --git a/mongodb-1.2.0/src/libmongoc/build/autotools/m4/silent.m4 b/mongodb-1.2.3/src/libmongoc/build/autotools/m4/silent.m4
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/build/autotools/m4/silent.m4
rename to mongodb-1.2.3/src/libmongoc/build/autotools/m4/silent.m4
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-apm-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-apm-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-apm-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-apm-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-apm.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-apm.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-apm.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-apm.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-apm.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-apm.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-apm.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-apm.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-array-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-array-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-array-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-array-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-array.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-array.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-array.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-array.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-async-cmd-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-async-cmd-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-async-cmd-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-async-cmd-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-async-cmd.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-async-cmd.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-async-cmd.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-async-cmd.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-async-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-async-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-async-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-async-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-async.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-async.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-async.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-async.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-b64-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-b64-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-b64-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-b64-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-b64.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-b64.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-b64.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-b64.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-buffer-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-buffer-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-buffer-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-buffer-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-buffer.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-buffer.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-buffer.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-buffer.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-bulk-operation-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-bulk-operation-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-bulk-operation-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-bulk-operation-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-bulk-operation.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-bulk-operation.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-bulk-operation.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-bulk-operation.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-bulk-operation.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-bulk-operation.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-bulk-operation.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-bulk-operation.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client-pool-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client-pool-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client-pool-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client-pool-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client-pool.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client-pool.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client-pool.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client-pool.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client-pool.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client-pool.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client-pool.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client-pool.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client.c
similarity index 99%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client.c
index ab76e098..7d58df92 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client.c
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client.c
@@ -1,2183 +1,2184 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <bson.h>
#ifndef _WIN32
# include <netdb.h>
# include <netinet/tcp.h>
#endif
#include "mongoc-cursor-array-private.h"
#include "mongoc-client-private.h"
#include "mongoc-collection-private.h"
#include "mongoc-config.h"
#include "mongoc-counters-private.h"
#include "mongoc-database-private.h"
#include "mongoc-gridfs-private.h"
#include "mongoc-error.h"
#include "mongoc-log.h"
#include "mongoc-queue-private.h"
#include "mongoc-socket.h"
#include "mongoc-stream-buffered.h"
#include "mongoc-stream-socket.h"
#include "mongoc-thread-private.h"
#include "mongoc-trace-private.h"
#include "mongoc-uri-private.h"
#include "mongoc-util-private.h"
#include "mongoc-set-private.h"
#include "mongoc-log.h"
#include "mongoc-write-concern-private.h"
#include "mongoc-read-concern-private.h"
#ifdef MONGOC_ENABLE_SSL
#include "mongoc-stream-tls.h"
#include "mongoc-ssl-private.h"
#endif
#undef MONGOC_LOG_DOMAIN
#define MONGOC_LOG_DOMAIN "client"
static void
_mongoc_client_op_killcursors (mongoc_cluster_t *cluster,
mongoc_server_stream_t *server_stream,
int64_t cursor_id,
int64_t operation_id,
const char *db,
const char *collection);
static void
_mongoc_client_killcursors_command (mongoc_cluster_t *cluster,
mongoc_server_stream_t *server_stream,
int64_t cursor_id,
const char *db,
const char *collection);
/*
*--------------------------------------------------------------------------
*
* mongoc_client_connect_tcp --
*
* Connect to a host using a TCP socket.
*
* This will be performed synchronously and return a mongoc_stream_t
* that can be used to connect with the remote host.
*
* Returns:
* A newly allocated mongoc_stream_t if successful; otherwise
* NULL and @error is set.
*
* Side effects:
* @error is set if return value is NULL.
*
*--------------------------------------------------------------------------
*/
static mongoc_stream_t *
mongoc_client_connect_tcp (const mongoc_uri_t *uri,
const mongoc_host_list_t *host,
bson_error_t *error)
{
mongoc_socket_t *sock = NULL;
struct addrinfo hints;
struct addrinfo *result, *rp;
int32_t connecttimeoutms;
int64_t expire_at;
char portstr [8];
int s;
ENTRY;
BSON_ASSERT (uri);
BSON_ASSERT (host);
connecttimeoutms = mongoc_uri_get_option_as_int32 (
uri, "connecttimeoutms", MONGOC_DEFAULT_CONNECTTIMEOUTMS);
BSON_ASSERT (connecttimeoutms);
bson_snprintf (portstr, sizeof portstr, "%hu", host->port);
memset (&hints, 0, sizeof hints);
hints.ai_family = host->family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = 0;
hints.ai_protocol = 0;
s = getaddrinfo (host->host, portstr, &hints, &result);
if (s != 0) {
mongoc_counter_dns_failure_inc ();
bson_set_error(error,
MONGOC_ERROR_STREAM,
MONGOC_ERROR_STREAM_NAME_RESOLUTION,
"Failed to resolve %s",
host->host);
RETURN (NULL);
}
mongoc_counter_dns_success_inc ();
for (rp = result; rp; rp = rp->ai_next) {
/*
* Create a new non-blocking socket.
*/
if (!(sock = mongoc_socket_new (rp->ai_family,
rp->ai_socktype,
rp->ai_protocol))) {
continue;
}
/*
* Try to connect to the peer.
*/
expire_at = bson_get_monotonic_time () + (connecttimeoutms * 1000L);
if (0 != mongoc_socket_connect (sock,
rp->ai_addr,
(socklen_t)rp->ai_addrlen,
expire_at)) {
char *errmsg;
char errmsg_buf[BSON_ERROR_BUFFER_SIZE];
char ip[255];
mongoc_socket_inet_ntop (rp, ip, sizeof ip);
errmsg = bson_strerror_r (
mongoc_socket_errno (sock), errmsg_buf, sizeof errmsg_buf);
MONGOC_WARNING ("Failed to connect to: %s:%d, error: %d, %s\n",
ip,
host->port,
mongoc_socket_errno(sock),
errmsg);
mongoc_socket_destroy (sock);
sock = NULL;
continue;
}
break;
}
if (!sock) {
bson_set_error (error,
MONGOC_ERROR_STREAM,
MONGOC_ERROR_STREAM_CONNECT,
"Failed to connect to target host: %s",
host->host_and_port);
freeaddrinfo (result);
RETURN (NULL);
}
freeaddrinfo (result);
return mongoc_stream_socket_new (sock);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_connect_unix --
*
* Connect to a MongoDB server using a UNIX domain socket.
*
* Returns:
* A newly allocated mongoc_stream_t if successful; otherwise
* NULL and @error is set.
*
* Side effects:
* @error is set if return value is NULL.
*
*--------------------------------------------------------------------------
*/
static mongoc_stream_t *
mongoc_client_connect_unix (const mongoc_uri_t *uri,
const mongoc_host_list_t *host,
bson_error_t *error)
{
#ifdef _WIN32
ENTRY;
bson_set_error (error,
MONGOC_ERROR_STREAM,
MONGOC_ERROR_STREAM_CONNECT,
"UNIX domain sockets not supported on win32.");
RETURN (NULL);
#else
struct sockaddr_un saddr;
mongoc_socket_t *sock;
mongoc_stream_t *ret = NULL;
ENTRY;
BSON_ASSERT (uri);
BSON_ASSERT (host);
memset (&saddr, 0, sizeof saddr);
saddr.sun_family = AF_UNIX;
bson_snprintf (saddr.sun_path, sizeof saddr.sun_path - 1,
"%s", host->host);
sock = mongoc_socket_new (AF_UNIX, SOCK_STREAM, 0);
if (sock == NULL) {
bson_set_error (error,
MONGOC_ERROR_STREAM,
MONGOC_ERROR_STREAM_SOCKET,
"Failed to create socket.");
RETURN (NULL);
}
if (-1 == mongoc_socket_connect (sock,
(struct sockaddr *)&saddr,
sizeof saddr,
-1)) {
mongoc_socket_destroy (sock);
bson_set_error (error,
MONGOC_ERROR_STREAM,
MONGOC_ERROR_STREAM_CONNECT,
"Failed to connect to UNIX domain socket.");
RETURN (NULL);
}
ret = mongoc_stream_socket_new (sock);
RETURN (ret);
#endif
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_default_stream_initiator --
*
* A mongoc_stream_initiator_t that will handle the various type
* of supported sockets by MongoDB including TCP and UNIX.
*
* Language binding authors may want to implement an alternate
* version of this method to use their native stream format.
*
* Returns:
* A mongoc_stream_t if successful; otherwise NULL and @error is set.
*
* Side effects:
* @error is set if return value is NULL.
*
*--------------------------------------------------------------------------
*/
mongoc_stream_t *
mongoc_client_default_stream_initiator (const mongoc_uri_t *uri,
const mongoc_host_list_t *host,
void *user_data,
bson_error_t *error)
{
mongoc_stream_t *base_stream = NULL;
#ifdef MONGOC_ENABLE_SSL
mongoc_client_t *client = (mongoc_client_t *)user_data;
const char *mechanism;
int32_t connecttimeoutms;
#endif
BSON_ASSERT (uri);
BSON_ASSERT (host);
#ifndef MONGOC_ENABLE_SSL
if (mongoc_uri_get_ssl (uri)) {
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_NO_ACCEPTABLE_PEER,
"SSL is not enabled in this build of mongo-c-driver.");
return NULL;
}
#endif
switch (host->family) {
+ case AF_UNSPEC:
#if defined(AF_INET6)
case AF_INET6:
#endif
case AF_INET:
base_stream = mongoc_client_connect_tcp (uri, host, error);
break;
case AF_UNIX:
base_stream = mongoc_client_connect_unix (uri, host, error);
break;
default:
bson_set_error (error,
MONGOC_ERROR_STREAM,
MONGOC_ERROR_STREAM_INVALID_TYPE,
"Invalid address family: 0x%02x", host->family);
break;
}
#ifdef MONGOC_ENABLE_SSL
if (base_stream) {
mechanism = mongoc_uri_get_auth_mechanism (uri);
if (client->use_ssl ||
(mechanism && (0 == strcmp (mechanism, "MONGODB-X509")))) {
mongoc_stream_t *original = base_stream;
base_stream = mongoc_stream_tls_new_with_hostname (base_stream, host->host,
&client->ssl_opts, true);
if (!base_stream) {
mongoc_stream_destroy (original);
bson_set_error (error,
MONGOC_ERROR_STREAM,
MONGOC_ERROR_STREAM_SOCKET,
"Failed initialize TLS state.");
return NULL;
}
connecttimeoutms = mongoc_uri_get_option_as_int32 (
uri, "connecttimeoutms", MONGOC_DEFAULT_CONNECTTIMEOUTMS);
if (!mongoc_stream_tls_handshake_block (base_stream, host->host, connecttimeoutms, error)) {
mongoc_stream_destroy (base_stream);
return NULL;
}
}
}
#endif
return base_stream ? mongoc_stream_buffered_new (base_stream, 1024) : NULL;
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_client_create_stream --
*
* INTERNAL API
*
* This function is used by the mongoc_cluster_t to initiate a
* new stream. This is done because cluster is private API and
* those using mongoc_client_t may need to override this process.
*
* This function calls the default initiator for new streams.
*
* Returns:
* A newly allocated mongoc_stream_t if successful; otherwise
* NULL and @error is set.
*
* Side effects:
* @error is set if return value is NULL.
*
*--------------------------------------------------------------------------
*/
mongoc_stream_t *
_mongoc_client_create_stream (mongoc_client_t *client,
const mongoc_host_list_t *host,
bson_error_t *error)
{
BSON_ASSERT (client);
BSON_ASSERT (host);
return client->initiator (client->uri, host, client->initiator_data, error);
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_client_recv --
*
* Receives a RPC from a remote MongoDB cluster node.
*
* Returns:
* true if successful; otherwise false and @error is set.
*
* Side effects:
* @error is set if return value is false.
*
*--------------------------------------------------------------------------
*/
bool
_mongoc_client_recv (mongoc_client_t *client,
mongoc_rpc_t *rpc,
mongoc_buffer_t *buffer,
mongoc_server_stream_t *server_stream,
bson_error_t *error)
{
BSON_ASSERT (client);
BSON_ASSERT (rpc);
BSON_ASSERT (buffer);
BSON_ASSERT (server_stream);
if (!mongoc_cluster_try_recv (&client->cluster, rpc, buffer,
server_stream, error)) {
mongoc_topology_invalidate_server (client->topology,
server_stream->sd->id, error);
return false;
}
return true;
}
/*
*--------------------------------------------------------------------------
*
* _bson_to_error --
*
* A helper routine to convert a bson document to a bson_error_t.
*
* Returns:
* None.
*
* Side effects:
* @error is set if non-null.
*
*--------------------------------------------------------------------------
*/
static void
_bson_to_error (const bson_t *b,
int32_t error_api_version,
bson_error_t *error)
{
bson_iter_t iter;
uint32_t code = 0;
mongoc_error_domain_t domain =
error_api_version >= MONGOC_ERROR_API_VERSION_2
? MONGOC_ERROR_SERVER
: MONGOC_ERROR_QUERY;
BSON_ASSERT (b);
if (!error) {
return;
}
if (bson_iter_init_find(&iter, b, "code") && BSON_ITER_HOLDS_INT32(&iter)) {
code = (uint32_t) bson_iter_int32 (&iter);
}
if (bson_iter_init_find(&iter, b, "$err") && BSON_ITER_HOLDS_UTF8(&iter)) {
bson_set_error(error,
domain,
code,
"%s",
bson_iter_utf8(&iter, NULL));
return;
}
if (bson_iter_init_find(&iter, b, "errmsg") && BSON_ITER_HOLDS_UTF8(&iter)) {
bson_set_error(error,
domain,
code,
"%s",
bson_iter_utf8(&iter, NULL));
return;
}
bson_set_error(error,
MONGOC_ERROR_QUERY,
MONGOC_ERROR_QUERY_FAILURE,
"An unknown error occurred on the server.");
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_recv_gle --
*
* INTERNAL API
*
* This function is used to receive the next RPC from a cluster
* node, expecting it to be the response to a getlasterror command.
*
* The RPC is parsed into @error if it is an error and false is
* returned.
*
* If the operation was successful, true is returned.
*
* if @gle_doc is not NULL, then the actual response document for
* the gle command will be stored as an out parameter. The caller
* is responsible for freeing it in this case.
*
* Returns:
* true if getlasterror was success; otherwise false.
*
* Side effects:
* @gle_doc will be set if non NULL and a reply was received.
* @error if return value is false, and @gle_doc is set to NULL.
*
*--------------------------------------------------------------------------
*/
bool
_mongoc_client_recv_gle (mongoc_client_t *client,
mongoc_server_stream_t *server_stream,
bson_t **gle_doc,
bson_error_t *error)
{
mongoc_buffer_t buffer;
mongoc_rpc_t rpc;
bson_iter_t iter;
bool ret = false;
bson_t b;
ENTRY;
BSON_ASSERT (client);
BSON_ASSERT (server_stream);
if (gle_doc) {
*gle_doc = NULL;
}
_mongoc_buffer_init (&buffer, NULL, 0, NULL, NULL);
if (!mongoc_cluster_try_recv (&client->cluster, &rpc, &buffer,
server_stream, error)) {
mongoc_topology_invalidate_server (client->topology,
server_stream->sd->id, error);
GOTO (cleanup);
}
if (rpc.header.opcode != MONGOC_OPCODE_REPLY) {
bson_set_error (error,
MONGOC_ERROR_PROTOCOL,
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
"Received message other than OP_REPLY.");
GOTO (cleanup);
}
if (_mongoc_rpc_reply_get_first (&rpc.reply, &b)) {
if ((rpc.reply.flags & MONGOC_REPLY_QUERY_FAILURE)) {
_bson_to_error (&b, client->error_api_version, error);
bson_destroy (&b);
GOTO (cleanup);
}
if (gle_doc) {
*gle_doc = bson_copy (&b);
}
if (!bson_iter_init_find (&iter, &b, "ok") ||
BSON_ITER_HOLDS_DOUBLE (&iter)) {
if (bson_iter_double (&iter) == 0.0) {
_bson_to_error (&b, client->error_api_version, error);
}
}
bson_destroy (&b);
ret = true;
}
cleanup:
_mongoc_buffer_destroy (&buffer);
RETURN (ret);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_new --
*
* Create a new mongoc_client_t using the URI provided.
*
* @uri should be a MongoDB URI string such as "mongodb://localhost/"
* More information on the format can be found at
* http://docs.mongodb.org/manual/reference/connection-string/
*
* Returns:
* A newly allocated mongoc_client_t or NULL if @uri_string is
* invalid.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
mongoc_client_t *
mongoc_client_new(const char *uri_string)
{
mongoc_topology_t *topology;
mongoc_client_t *client;
mongoc_uri_t *uri;
if (!uri_string) {
uri_string = "mongodb://127.0.0.1/";
}
if (!(uri = mongoc_uri_new (uri_string))) {
return NULL;
}
topology = mongoc_topology_new(uri, true);
client = _mongoc_client_new_from_uri (uri, topology);
if (!client) {
mongoc_topology_destroy (topology);
}
mongoc_uri_destroy (uri);
return client;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_set_ssl_opts
*
* set ssl opts for a client
*
* Returns:
* Nothing
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
#ifdef MONGOC_ENABLE_SSL
void
mongoc_client_set_ssl_opts (mongoc_client_t *client,
const mongoc_ssl_opt_t *opts)
{
BSON_ASSERT (client);
BSON_ASSERT (opts);
_mongoc_ssl_opts_cleanup (&client->ssl_opts);
client->use_ssl = true;
_mongoc_ssl_opts_copy_to (opts, &client->ssl_opts);
if (client->topology->single_threaded) {
mongoc_topology_scanner_set_ssl_opts (client->topology->scanner,
&client->ssl_opts);
}
}
#endif
/*
*--------------------------------------------------------------------------
*
* mongoc_client_new_from_uri --
*
* Create a new mongoc_client_t for a mongoc_uri_t.
*
* Returns:
* A newly allocated mongoc_client_t.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
mongoc_client_t *
mongoc_client_new_from_uri (const mongoc_uri_t *uri)
{
mongoc_topology_t *topology;
topology = mongoc_topology_new (uri, true);
return _mongoc_client_new_from_uri (uri, topology);
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_client_new_from_uri --
*
* Create a new mongoc_client_t for a mongoc_uri_t and a given
* topology object.
*
* Returns:
* A newly allocated mongoc_client_t.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
mongoc_client_t *
_mongoc_client_new_from_uri (const mongoc_uri_t *uri, mongoc_topology_t *topology)
{
mongoc_client_t *client;
const mongoc_read_prefs_t *read_prefs;
const mongoc_read_concern_t *read_concern;
const mongoc_write_concern_t *write_concern;
const char *appname;
BSON_ASSERT (uri);
#ifndef MONGOC_ENABLE_SSL
if (mongoc_uri_get_ssl (uri)) {
MONGOC_ERROR ("Can't create SSL client, SSL not enabled in this build.");
return NULL;
}
#endif
client = (mongoc_client_t *)bson_malloc0(sizeof *client);
client->uri = mongoc_uri_copy (uri);
client->initiator = mongoc_client_default_stream_initiator;
client->initiator_data = client;
client->topology = topology;
client->error_api_version = MONGOC_ERROR_API_VERSION_LEGACY;
client->error_api_set = false;
write_concern = mongoc_uri_get_write_concern (client->uri);
client->write_concern = mongoc_write_concern_copy (write_concern);
read_concern = mongoc_uri_get_read_concern (client->uri);
client->read_concern = mongoc_read_concern_copy (read_concern);
read_prefs = mongoc_uri_get_read_prefs_t (client->uri);
client->read_prefs = mongoc_read_prefs_copy (read_prefs);
appname = mongoc_uri_get_option_as_utf8 (client->uri, "appname", NULL);
if (appname && client->topology->single_threaded) {
/* the appname should have already been validated */
BSON_ASSERT (mongoc_client_set_appname (client, appname));
}
mongoc_cluster_init (&client->cluster, client->uri, client);
#ifdef MONGOC_ENABLE_SSL
client->use_ssl = false;
if (mongoc_uri_get_ssl (client->uri)) {
/* sets use_ssl = true */
mongoc_client_set_ssl_opts (client, mongoc_ssl_opt_get_default ());
}
#endif
mongoc_counter_clients_active_inc ();
return client;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_destroy --
*
* Destroys a mongoc_client_t and cleans up all resources associated
* with the client instance.
*
* Returns:
* None.
*
* Side effects:
* @client is destroyed.
*
*--------------------------------------------------------------------------
*/
void
mongoc_client_destroy (mongoc_client_t *client)
{
if (client) {
if (client->topology->single_threaded) {
mongoc_topology_destroy(client->topology);
}
mongoc_write_concern_destroy (client->write_concern);
mongoc_read_concern_destroy (client->read_concern);
mongoc_read_prefs_destroy (client->read_prefs);
mongoc_cluster_destroy (&client->cluster);
mongoc_uri_destroy (client->uri);
#ifdef MONGOC_ENABLE_SSL
_mongoc_ssl_opts_cleanup (&client->ssl_opts);
#endif
bson_free (client);
mongoc_counter_clients_active_dec ();
mongoc_counter_clients_disposed_inc ();
}
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_get_uri --
*
* Fetch the URI used for @client.
*
* Returns:
* A mongoc_uri_t that should not be modified or freed.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
const mongoc_uri_t *
mongoc_client_get_uri (const mongoc_client_t *client)
{
BSON_ASSERT (client);
return client->uri;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_get_database --
*
* Fetches a newly allocated database structure to communicate with
* a database over @client.
*
* @database should be a db name such as "test".
*
* This structure should be freed when the caller is done with it
* using mongoc_database_destroy().
*
* Returns:
* A newly allocated mongoc_database_t.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
mongoc_database_t *
mongoc_client_get_database (mongoc_client_t *client,
const char *name)
{
BSON_ASSERT (client);
BSON_ASSERT (name);
return _mongoc_database_new(client, name, client->read_prefs,
client->read_concern, client->write_concern);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_get_default_database --
*
* Get the database named in the MongoDB connection URI, or NULL
* if none was specified in the URI.
*
* This structure should be freed when the caller is done with it
* using mongoc_database_destroy().
*
* Returns:
* A newly allocated mongoc_database_t or NULL.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
mongoc_database_t *
mongoc_client_get_default_database (mongoc_client_t *client)
{
const char *db;
BSON_ASSERT (client);
db = mongoc_uri_get_database (client->uri);
if (db) {
return mongoc_client_get_database (client, db);
}
return NULL;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_get_collection --
*
* This function returns a newly allocated collection structure.
*
* @db should be the name of the database, such as "test".
* @collection should be the name of the collection such as "test".
*
* The above would result in the namespace "test.test".
*
* You should free this structure when you are done with it using
* mongoc_collection_destroy().
*
* Returns:
* A newly allocated mongoc_collection_t that should be freed with
* mongoc_collection_destroy().
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
mongoc_collection_t *
mongoc_client_get_collection (mongoc_client_t *client,
const char *db,
const char *collection)
{
BSON_ASSERT (client);
BSON_ASSERT (db);
BSON_ASSERT (collection);
return _mongoc_collection_new(client, db, collection, client->read_prefs,
client->read_concern, client->write_concern);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_get_gridfs --
*
* This function returns a newly allocated collection structure.
*
* @db should be the name of the database, such as "test".
*
* @prefix optional prefix for GridFS collection names, or NULL. Default
* is "fs", thus the default collection names for GridFS are "fs.files"
* and "fs.chunks".
*
* Returns:
* A newly allocated mongoc_gridfs_t that should be freed with
* mongoc_gridfs_destroy().
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
mongoc_gridfs_t *
mongoc_client_get_gridfs (mongoc_client_t *client,
const char *db,
const char *prefix,
bson_error_t *error)
{
BSON_ASSERT (client);
BSON_ASSERT (db);
if (! prefix) {
prefix = "fs";
}
return _mongoc_gridfs_new(client, db, prefix, error);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_get_write_concern --
*
* Fetches the default write concern for @client.
*
* Returns:
* A mongoc_write_concern_t that should not be modified or freed.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
const mongoc_write_concern_t *
mongoc_client_get_write_concern (const mongoc_client_t *client)
{
BSON_ASSERT (client);
return client->write_concern;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_set_write_concern --
*
* Sets the default write concern for @client.
*
* Returns:
* None.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
void
mongoc_client_set_write_concern (mongoc_client_t *client,
const mongoc_write_concern_t *write_concern)
{
BSON_ASSERT (client);
if (write_concern != client->write_concern) {
if (client->write_concern) {
mongoc_write_concern_destroy(client->write_concern);
}
client->write_concern = write_concern ?
mongoc_write_concern_copy(write_concern) :
mongoc_write_concern_new();
}
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_get_read_concern --
*
* Fetches the default read concern for @client.
*
* Returns:
* A mongoc_read_concern_t that should not be modified or freed.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
const mongoc_read_concern_t *
mongoc_client_get_read_concern (const mongoc_client_t *client)
{
BSON_ASSERT (client);
return client->read_concern;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_set_read_concern --
*
* Sets the default read concern for @client.
*
* Returns:
* None.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
void
mongoc_client_set_read_concern (mongoc_client_t *client,
const mongoc_read_concern_t *read_concern)
{
BSON_ASSERT (client);
if (read_concern != client->read_concern) {
if (client->read_concern) {
mongoc_read_concern_destroy (client->read_concern);
}
client->read_concern = read_concern ?
mongoc_read_concern_copy (read_concern) :
mongoc_read_concern_new ();
}
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_get_read_prefs --
*
* Fetch the default read preferences for @client.
*
* Returns:
* None.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
const mongoc_read_prefs_t *
mongoc_client_get_read_prefs (const mongoc_client_t *client)
{
BSON_ASSERT (client);
return client->read_prefs;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_set_read_prefs --
*
* Set the default read preferences for @client.
*
* Returns:
* None.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
void
mongoc_client_set_read_prefs (mongoc_client_t *client,
const mongoc_read_prefs_t *read_prefs)
{
BSON_ASSERT (client);
if (read_prefs != client->read_prefs) {
if (client->read_prefs) {
mongoc_read_prefs_destroy(client->read_prefs);
}
client->read_prefs = read_prefs ?
mongoc_read_prefs_copy(read_prefs) :
mongoc_read_prefs_new(MONGOC_READ_PRIMARY);
}
}
mongoc_cursor_t *
mongoc_client_command (mongoc_client_t *client,
const char *db_name,
mongoc_query_flags_t flags,
uint32_t skip,
uint32_t limit,
uint32_t batch_size,
const bson_t *query,
const bson_t *fields,
const mongoc_read_prefs_t *read_prefs)
{
char ns[MONGOC_NAMESPACE_MAX];
mongoc_cursor_t *cursor;
BSON_ASSERT (client);
BSON_ASSERT (db_name);
BSON_ASSERT (query);
/*
* Allow a caller to provide a fully qualified namespace
*/
if (NULL == strstr (db_name, "$cmd")) {
bson_snprintf (ns, sizeof ns, "%s.$cmd", db_name);
db_name = ns;
}
/* flags, skip, limit, batch_size, fields are unused: CDRIVER-1543 */
/* ignore client read prefs if passed-in prefs are NULL */
cursor = _mongoc_cursor_new_with_opts (
client, db_name, true /* is_command */, query, NULL,
read_prefs, NULL);
return cursor;
}
static bool
_mongoc_client_command_with_stream (mongoc_client_t *client,
const char *db_name,
const bson_t *command,
mongoc_server_stream_t *server_stream,
const mongoc_query_flags_t flags,
const mongoc_read_prefs_t *read_prefs,
bson_t *reply,
bson_error_t *error)
{
mongoc_apply_read_prefs_result_t result = READ_PREFS_RESULT_INIT;
bool ret;
ENTRY;
apply_read_preferences (read_prefs, server_stream, command,
flags, &result);
ret = mongoc_cluster_run_command_monitored (
&client->cluster, server_stream, result.flags, db_name,
result.query_with_read_prefs, reply, error);
apply_read_prefs_result_cleanup (&result);
RETURN (ret);
}
bool
mongoc_client_command_simple (mongoc_client_t *client,
const char *db_name,
const bson_t *command,
const mongoc_read_prefs_t *read_prefs,
bson_t *reply,
bson_error_t *error)
{
mongoc_cluster_t *cluster;
mongoc_server_stream_t *server_stream = NULL;
bool ret;
ENTRY;
BSON_ASSERT (client);
BSON_ASSERT (db_name);
BSON_ASSERT (command);
if (!_mongoc_read_prefs_validate (read_prefs, error)) {
RETURN (false);
}
cluster = &client->cluster;
/* Server Selection Spec: "The generic command method has a default read
* preference of mode 'primary'. The generic command method MUST ignore any
* default read preference from client, database or collection
* configuration. The generic command method SHOULD allow an optional read
* preference argument."
*/
server_stream = mongoc_cluster_stream_for_reads (cluster, read_prefs, error);
if (server_stream) {
ret = _mongoc_client_command_with_stream (client, db_name, command,
server_stream, MONGOC_QUERY_NONE,
read_prefs, reply, error);
} else {
if (reply) {
bson_init (reply);
}
ret = false;
}
mongoc_server_stream_cleanup (server_stream);
RETURN (ret);
}
bool
_mongoc_client_command_append_iterator_opts_to_command (bson_iter_t *iter,
int max_wire_version,
bson_t *command,
bson_error_t *error)
{
ENTRY;
while (bson_iter_next (iter)) {
if (BSON_ITER_IS_KEY (iter, "collation")) {
if (max_wire_version < WIRE_VERSION_COLLATION) {
bson_set_error (error,
MONGOC_ERROR_COMMAND,
MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION,
"The selected server does not support collation");
RETURN (false);
}
}
else if (BSON_ITER_IS_KEY (iter, "writeConcern")) {
if (!_mongoc_write_concern_iter_is_valid (iter)) {
bson_set_error (error,
MONGOC_ERROR_COMMAND,
MONGOC_ERROR_COMMAND_INVALID_ARG,
"Invalid writeConcern");
RETURN (false);
}
if (max_wire_version < WIRE_VERSION_CMD_WRITE_CONCERN) {
continue;
}
}
else if (BSON_ITER_IS_KEY (iter, "readConcern")) {
if (max_wire_version < WIRE_VERSION_READ_CONCERN) {
bson_set_error (error,
MONGOC_ERROR_COMMAND,
MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION,
"The selected server does not support readConcern");
RETURN (false);
}
}
else if (BSON_ITER_IS_KEY (iter, "serverId")) {
continue;
}
bson_append_iter (command, bson_iter_key (iter), -1, iter);
}
RETURN (true);
}
static void
_ensure_copied (bson_t **dst,
const bson_t *src)
{
if (!*dst) {
*dst = bson_copy (src);
}
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_client_command_with_opts --
*
* Execute a command on the server. If mode is MONGOC_CMD_READ or
* MONGOC_CMD_RW, then read concern is applied from @opts, or else from
* @default_rc, and read preferences are applied from @default_prefs.
* If mode is MONGOC_CMD_WRITE or MONGOC_CMD_RW, then write concern is
* applied from @opts if present, or else from @default_wc.
*
* The mongoc_client_t's read preference, read concern, and write concern
* are *NOT* applied.
*
* Returns:
* Success or failure.
* A write concern timeout or write concern error is considered a failure.
*
* Side effects:
* @reply is always initialized.
* @error is filled out if the command fails.
*
*--------------------------------------------------------------------------
*/
bool
_mongoc_client_command_with_opts (mongoc_client_t *client,
const char *db_name,
const bson_t *command,
mongoc_command_mode_t mode,
const bson_t *opts,
mongoc_query_flags_t flags,
const mongoc_read_prefs_t *default_prefs,
mongoc_read_concern_t *default_rc,
mongoc_write_concern_t *default_wc,
bson_t *reply,
bson_error_t *error)
{
mongoc_server_stream_t *server_stream = NULL;
bson_t *command_with_opts = NULL;
mongoc_cluster_t *cluster;
bson_t reply_local;
bson_t *reply_ptr;
uint32_t server_id;
bool ret = false;
ENTRY;
BSON_ASSERT (client);
BSON_ASSERT (db_name);
BSON_ASSERT (command);
reply_ptr = reply ? reply : &reply_local;
if (mode & MONGOC_CMD_READ) {
/* NULL read pref is ok */
if (!_mongoc_read_prefs_validate (default_prefs, error)) {
GOTO (err);
}
} else {
/* this is a command that writes */
default_prefs = NULL;
}
cluster = &client->cluster;
if (!_mongoc_get_server_id_from_opts (opts, MONGOC_ERROR_COMMAND,
MONGOC_ERROR_COMMAND_INVALID_ARG,
&server_id, error)) {
GOTO (err);
}
if (server_id) {
/* "serverId" passed in opts */
server_stream = mongoc_cluster_stream_for_server (
cluster, server_id, true /* reconnect ok */, error);
if (server_stream && server_stream->sd->type != MONGOC_SERVER_MONGOS) {
flags |= MONGOC_QUERY_SLAVE_OK;
}
} else {
server_stream = mongoc_cluster_stream_for_reads (
cluster, default_prefs, error);
}
if (server_stream) {
bson_iter_t iter;
if (opts && bson_iter_init (&iter, opts)) {
bool ok = false;
_ensure_copied (&command_with_opts, command);
ok = _mongoc_client_command_append_iterator_opts_to_command (&iter,
server_stream->sd->max_wire_version,
command_with_opts,
error);
if (!ok) {
GOTO (err);
}
}
/* use default write concern unless it's in opts */
if ((mode & MONGOC_CMD_WRITE) &&
server_stream->sd->max_wire_version >= WIRE_VERSION_CMD_WRITE_CONCERN &&
!_mongoc_write_concern_is_default (default_wc) &&
(!command_with_opts || !bson_has_field (command_with_opts, "writeConcern"))) {
_ensure_copied (&command_with_opts, command);
bson_append_document (
command_with_opts, "writeConcern", 12,
_mongoc_write_concern_get_bson (default_wc));
}
/* use read prefs and read concern for read commands, unless in opts */
if ((mode & MONGOC_CMD_READ) &&
server_stream->sd->max_wire_version >= WIRE_VERSION_READ_CONCERN &&
!_mongoc_read_concern_is_default (default_rc) &&
(!command_with_opts || !bson_has_field (command_with_opts, "readConcern"))) {
_ensure_copied (&command_with_opts, command);
bson_append_document (
command_with_opts, "readConcern", 11,
_mongoc_read_concern_get_bson (default_rc));
}
ret = _mongoc_client_command_with_stream (
client,
db_name,
command_with_opts ? command_with_opts : command,
server_stream,
flags,
default_prefs,
reply_ptr,
error);
if (ret && (mode & MONGOC_CMD_WRITE)) {
ret = !_mongoc_parse_wc_err (reply_ptr, error);
}
if (reply_ptr == &reply_local) {
bson_destroy (reply_ptr);
}
GOTO (done);
}
err:
if (reply) {
bson_init (reply);
}
done:
if (command_with_opts) {
bson_destroy (command_with_opts);
}
if (server_stream) {
mongoc_server_stream_cleanup (server_stream);
}
RETURN (ret);
}
bool
mongoc_client_read_command_with_opts (mongoc_client_t *client,
const char *db_name,
const bson_t *command,
const mongoc_read_prefs_t *read_prefs,
const bson_t *opts,
bson_t *reply,
bson_error_t *error)
{
return _mongoc_client_command_with_opts (
client, db_name, command, MONGOC_CMD_READ, opts, MONGOC_QUERY_NONE,
COALESCE (read_prefs, client->read_prefs), client->read_concern,
client->write_concern, reply, error);
}
bool
mongoc_client_write_command_with_opts (mongoc_client_t *client,
const char *db_name,
const bson_t *command,
const bson_t *opts,
bson_t *reply,
bson_error_t *error)
{
return _mongoc_client_command_with_opts (
client, db_name, command, MONGOC_CMD_WRITE, opts, MONGOC_QUERY_NONE,
client->read_prefs, client->read_concern,
client->write_concern, reply, error);
}
bool
mongoc_client_read_write_command_with_opts (mongoc_client_t *client,
const char *db_name,
const bson_t *command,
const mongoc_read_prefs_t *read_prefs,
const bson_t *opts,
bson_t *reply,
bson_error_t *error)
{
return _mongoc_client_command_with_opts (
client, db_name, command, MONGOC_CMD_RW, opts, MONGOC_QUERY_NONE,
COALESCE (read_prefs, client->read_prefs), client->read_concern,
client->write_concern, reply, error);
}
bool
mongoc_client_command_simple_with_server_id (mongoc_client_t *client,
const char *db_name,
const bson_t *command,
const mongoc_read_prefs_t *read_prefs,
uint32_t server_id,
bson_t *reply,
bson_error_t *error)
{
mongoc_cluster_t *cluster;
mongoc_server_stream_t *server_stream;
bool ret;
ENTRY;
BSON_ASSERT (client);
BSON_ASSERT (db_name);
BSON_ASSERT (command);
if (!_mongoc_read_prefs_validate (read_prefs, error)) {
RETURN (false);
}
cluster = &client->cluster;
server_stream = mongoc_cluster_stream_for_server (
cluster, server_id, true /* reconnect ok */, error);
if (server_stream) {
ret = _mongoc_client_command_with_stream (client, db_name, command,
server_stream, MONGOC_QUERY_NONE, read_prefs,
reply, error);
mongoc_server_stream_cleanup (server_stream);
RETURN (ret);
} else {
if (reply) {
bson_init (reply);
}
RETURN (false);
}
}
static void
_mongoc_client_prepare_killcursors_command (int64_t cursor_id,
const char *collection,
bson_t *command)
{
bson_t child;
bson_append_utf8 (command, "killCursors", 11, collection, -1);
bson_append_array_begin (command, "cursors", 7, &child);
bson_append_int64 (&child, "0", 1, cursor_id);
bson_append_array_end (command, &child);
}
void
_mongoc_client_kill_cursor (mongoc_client_t *client,
uint32_t server_id,
int64_t cursor_id,
int64_t operation_id,
const char *db,
const char *collection)
{
mongoc_server_stream_t *server_stream;
ENTRY;
BSON_ASSERT (client);
BSON_ASSERT (cursor_id);
/* don't attempt reconnect if server unavailable, and ignore errors */
server_stream = mongoc_cluster_stream_for_server (&client->cluster,
server_id,
false /* reconnect_ok */,
NULL /* error */);
if (!server_stream) {
return;
}
if (db && collection &&
server_stream->sd->max_wire_version >=
WIRE_VERSION_KILLCURSORS_CMD) {
_mongoc_client_killcursors_command (&client->cluster, server_stream,
cursor_id, db, collection);
} else {
_mongoc_client_op_killcursors (&client->cluster,
server_stream,
cursor_id, operation_id,
db, collection);
}
mongoc_server_stream_cleanup (server_stream);
EXIT;
}
static void
_mongoc_client_monitor_op_killcursors (mongoc_cluster_t *cluster,
mongoc_server_stream_t *server_stream,
int64_t cursor_id,
int64_t operation_id,
const char *db,
const char *collection)
{
bson_t doc;
mongoc_client_t *client;
mongoc_apm_command_started_t event;
ENTRY;
client = cluster->client;
if (!client->apm_callbacks.started) {
return;
}
bson_init (&doc);
_mongoc_client_prepare_killcursors_command (cursor_id, collection, &doc);
mongoc_apm_command_started_init (&event,
&doc,
db,
"killCursors",
cluster->request_id,
operation_id,
&server_stream->sd->host,
server_stream->sd->id,
client->apm_context);
client->apm_callbacks.started (&event);
mongoc_apm_command_started_cleanup (&event);
bson_destroy (&doc);
EXIT;
}
static void
_mongoc_client_monitor_op_killcursors_succeeded (
mongoc_cluster_t *cluster,
int64_t duration,
mongoc_server_stream_t *server_stream,
int64_t cursor_id,
int64_t operation_id)
{
mongoc_client_t *client;
bson_t doc;
bson_t cursors_unknown;
mongoc_apm_command_succeeded_t event;
ENTRY;
client = cluster->client;
if (!client->apm_callbacks.succeeded) {
EXIT;
}
/* fake server reply to killCursors command: {ok: 1, cursorsUnknown: [42]} */
bson_init (&doc);
bson_append_int32 (&doc, "ok", 2, 1);
bson_append_array_begin (&doc, "cursorsUnknown", 14, &cursors_unknown);
bson_append_int64 (&cursors_unknown, "0", 1, cursor_id);
bson_append_array_end (&doc, &cursors_unknown);
mongoc_apm_command_succeeded_init (&event,
duration,
&doc,
"killCursors",
cluster->request_id,
operation_id,
&server_stream->sd->host,
server_stream->sd->id,
client->apm_context);
client->apm_callbacks.succeeded (&event);
mongoc_apm_command_succeeded_cleanup (&event);
bson_destroy (&doc);
}
static void
_mongoc_client_monitor_op_killcursors_failed (
mongoc_cluster_t *cluster,
int64_t duration,
mongoc_server_stream_t *server_stream,
const bson_error_t *error,
int64_t operation_id)
{
mongoc_client_t *client;
mongoc_apm_command_failed_t event;
ENTRY;
client = cluster->client;
if (!client->apm_callbacks.failed) {
EXIT;
}
mongoc_apm_command_failed_init (&event,
duration,
"killCursors",
error,
cluster->request_id,
operation_id,
&server_stream->sd->host,
server_stream->sd->id,
client->apm_context);
client->apm_callbacks.failed (&event);
mongoc_apm_command_failed_cleanup (&event);
}
static void
_mongoc_client_op_killcursors (mongoc_cluster_t *cluster,
mongoc_server_stream_t *server_stream,
int64_t cursor_id,
int64_t operation_id,
const char *db,
const char *collection)
{
int64_t started;
mongoc_rpc_t rpc = { { 0 } };
bson_error_t error;
bool has_ns;
bool r;
/* called by old mongoc_client_kill_cursor without db/collection? */
has_ns = (db && collection);
started = bson_get_monotonic_time ();
++cluster->request_id;
rpc.kill_cursors.msg_len = 0;
rpc.kill_cursors.request_id = cluster->request_id;
rpc.kill_cursors.response_to = 0;
rpc.kill_cursors.opcode = MONGOC_OPCODE_KILL_CURSORS;
rpc.kill_cursors.zero = 0;
rpc.kill_cursors.cursors = &cursor_id;
rpc.kill_cursors.n_cursors = 1;
if (has_ns) {
_mongoc_client_monitor_op_killcursors (cluster, server_stream, cursor_id,
operation_id, db, collection);
}
r = mongoc_cluster_sendv_to_server (cluster, &rpc, 1, server_stream,
NULL, &error);
if (has_ns) {
if (r) {
_mongoc_client_monitor_op_killcursors_succeeded (
cluster, bson_get_monotonic_time () - started, server_stream,
cursor_id, operation_id);
} else {
_mongoc_client_monitor_op_killcursors_failed (
cluster, bson_get_monotonic_time () - started, server_stream,
&error, operation_id);
}
}
}
static void
_mongoc_client_killcursors_command (mongoc_cluster_t *cluster,
mongoc_server_stream_t *server_stream,
int64_t cursor_id,
const char *db,
const char *collection)
{
bson_t command = BSON_INITIALIZER;
ENTRY;
_mongoc_client_prepare_killcursors_command (cursor_id,
collection,
&command);
/* Find, getMore And killCursors Commands Spec: "The result from the
* killCursors command MAY be safely ignored."
*/
mongoc_cluster_run_command_monitored (cluster, server_stream,
MONGOC_QUERY_SLAVE_OK, db, &command,
NULL, NULL);
bson_destroy (&command);
EXIT;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_client_kill_cursor --
*
* Destroy a cursor on the server.
*
* NOTE: this is only reliable when connected to a single mongod or
* mongos. If connected to a replica set, the driver attempts to
* kill the cursor on the primary. If connected to multiple mongoses
* the kill-cursors message is sent to a *random* mongos.
*
* If no primary, mongos, or standalone server is known, return
* without attempting to reconnect.
*
* Returns:
* None.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
void
mongoc_client_kill_cursor (mongoc_client_t *client,
int64_t cursor_id)
{
mongoc_topology_t *topology;
mongoc_server_description_t *selected_server;
mongoc_read_prefs_t *read_prefs;
uint32_t server_id = 0;
topology = client->topology;
read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY);
mongoc_mutex_lock (&topology->mutex);
/* see if there's a known writable server - do no I/O or retries */
selected_server = mongoc_topology_description_select(
&topology->description,
MONGOC_SS_WRITE,
read_prefs,
topology->local_threshold_msec);
if (selected_server) {
server_id = selected_server->id;
}
mongoc_mutex_unlock (&topology->mutex);
if (server_id) {
_mongoc_client_kill_cursor (client, selected_server->id, cursor_id,
0 /* operation_id */,
NULL /* db */,
NULL /* collection */);
} else {
MONGOC_INFO ("No server available for mongoc_client_kill_cursor");
}
mongoc_read_prefs_destroy (read_prefs);
}
char **
mongoc_client_get_database_names (mongoc_client_t *client,
bson_error_t *error)
{
bson_iter_t iter;
const char *name;
char **ret = NULL;
int i = 0;
mongoc_cursor_t *cursor;
const bson_t *doc;
BSON_ASSERT (client);
cursor = mongoc_client_find_databases (client, error);
while (mongoc_cursor_next (cursor, &doc)) {
if (bson_iter_init (&iter, doc) &&
bson_iter_find (&iter, "name") &&
BSON_ITER_HOLDS_UTF8 (&iter) &&
(name = bson_iter_utf8 (&iter, NULL))) {
ret = (char **)bson_realloc (ret, sizeof(char*) * (i + 2));
ret [i] = bson_strdup (name);
ret [++i] = NULL;
}
}
if (!ret && !mongoc_cursor_error (cursor, error)) {
ret = (char **)bson_malloc0 (sizeof (void*));
}
mongoc_cursor_destroy (cursor);
return ret;
}
mongoc_cursor_t *
mongoc_client_find_databases (mongoc_client_t *client,
bson_error_t *error)
{
bson_t cmd = BSON_INITIALIZER;
mongoc_cursor_t *cursor;
BSON_ASSERT (client);
BSON_APPEND_INT32 (&cmd, "listDatabases", 1);
/* ignore client read prefs */
cursor = _mongoc_cursor_new_with_opts (client, "admin",
true /* is_command */,
NULL, NULL, NULL, NULL);
_mongoc_cursor_array_init (cursor, &cmd, "databases");
bson_destroy (&cmd);
return cursor;
}
int32_t
mongoc_client_get_max_message_size (mongoc_client_t *client) /* IN */
{
BSON_ASSERT (client);
return mongoc_cluster_get_max_msg_size (&client->cluster);
}
int32_t
mongoc_client_get_max_bson_size (mongoc_client_t *client) /* IN */
{
BSON_ASSERT (client);
return mongoc_cluster_get_max_bson_obj_size (&client->cluster);
}
bool
mongoc_client_get_server_status (mongoc_client_t *client, /* IN */
mongoc_read_prefs_t *read_prefs, /* IN */
bson_t *reply, /* OUT */
bson_error_t *error) /* OUT */
{
bson_t cmd = BSON_INITIALIZER;
bool ret = false;
BSON_ASSERT (client);
BSON_APPEND_INT32 (&cmd, "serverStatus", 1);
ret = mongoc_client_command_simple (client, "admin", &cmd, read_prefs,
reply, error);
bson_destroy (&cmd);
return ret;
}
void
mongoc_client_set_stream_initiator (mongoc_client_t *client,
mongoc_stream_initiator_t initiator,
void *user_data)
{
BSON_ASSERT (client);
if (!initiator) {
initiator = mongoc_client_default_stream_initiator;
user_data = client;
} else {
MONGOC_DEBUG ("Using custom stream initiator.");
}
client->initiator = initiator;
client->initiator_data = user_data;
if (client->topology->single_threaded) {
mongoc_topology_scanner_set_stream_initiator (client->topology->scanner,
initiator, user_data);
}
}
bool
_mongoc_client_set_apm_callbacks_private (mongoc_client_t *client,
mongoc_apm_callbacks_t *callbacks,
void *context)
{
if (callbacks) {
memcpy (&client->apm_callbacks, callbacks, sizeof (mongoc_apm_callbacks_t));
} else {
memset (&client->apm_callbacks, 0, sizeof (mongoc_apm_callbacks_t));
}
client->apm_context = context;
mongoc_topology_set_apm_callbacks (client->topology, callbacks, context);
return true;
}
bool
mongoc_client_set_apm_callbacks (mongoc_client_t *client,
mongoc_apm_callbacks_t *callbacks,
void *context)
{
if (!client->topology->single_threaded) {
MONGOC_ERROR ("Cannot set callbacks on a pooled client, use "
"mongoc_client_pool_set_apm_callbacks");
return false;
}
return _mongoc_client_set_apm_callbacks_private (client, callbacks, context);
}
mongoc_server_description_t *
mongoc_client_get_server_description (mongoc_client_t *client,
uint32_t server_id)
{
/* the error info isn't useful */
return mongoc_topology_server_by_id (client->topology, server_id, NULL);
}
mongoc_server_description_t **
mongoc_client_get_server_descriptions (
const mongoc_client_t *client,
size_t *n /* OUT */)
{
mongoc_topology_t *topology;
mongoc_server_description_t **sds;
BSON_ASSERT (client);
BSON_ASSERT (n);
topology = (mongoc_topology_t *) client->topology;
/* in case the client is pooled */
mongoc_mutex_lock (&topology->mutex);
sds = mongoc_topology_description_get_servers (&topology->description, n);
mongoc_mutex_unlock (&topology->mutex);
return sds;
}
void
mongoc_server_descriptions_destroy_all (mongoc_server_description_t **sds,
size_t n)
{
size_t i;
for (i = 0; i < n; ++i) {
mongoc_server_description_destroy (sds[i]);
}
bson_free (sds);
}
mongoc_server_description_t *
mongoc_client_select_server (mongoc_client_t *client,
bool for_writes,
const mongoc_read_prefs_t *prefs,
bson_error_t *error)
{
if (for_writes && prefs) {
bson_set_error(error,
MONGOC_ERROR_SERVER_SELECTION,
MONGOC_ERROR_SERVER_SELECTION_FAILURE,
"Cannot use read preferences with for_writes = true");
return NULL;
}
if (!_mongoc_read_prefs_validate (prefs, error)) {
return NULL;
}
return mongoc_topology_select (client->topology,
for_writes ? MONGOC_SS_WRITE : MONGOC_SS_READ,
prefs,
error);
}
bool
mongoc_client_set_error_api (mongoc_client_t *client,
int32_t version)
{
if (!client->topology->single_threaded) {
MONGOC_ERROR ("Cannot set Error API Version on a pooled client, use "
"mongoc_client_pool_set_error_api");
return false;
}
if (version != MONGOC_ERROR_API_VERSION_LEGACY &&
version != MONGOC_ERROR_API_VERSION_2) {
MONGOC_ERROR ("Unsupported Error API Version: %" PRId32, version);
return false;
}
if (client->error_api_set) {
MONGOC_ERROR ("Can only set Error API Version once");
return false;
}
client->error_api_version = version;
client->error_api_set = true;
return true;
}
bool
mongoc_client_set_appname (mongoc_client_t *client,
const char *appname)
{
if (!client->topology->single_threaded) {
MONGOC_ERROR ("Cannot call set_appname on a client from a pool");
return false;
}
return _mongoc_topology_set_appname (client->topology,
appname);
}
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-client.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-client.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cluster-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cluster-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cluster-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cluster-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cluster.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cluster.c
similarity index 99%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cluster.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cluster.c
index 1c941a4c..88b28af1 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cluster.c
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cluster.c
@@ -1,2485 +1,2489 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mongoc-config.h"
#ifdef MONGOC_ENABLE_SASL
#include <sasl/sasl.h>
#include <sasl/saslutil.h>
#endif
#include <string.h>
#include "mongoc-cluster-private.h"
#include "mongoc-client-private.h"
#include "mongoc-counters-private.h"
#include "mongoc-config.h"
#include "mongoc-error.h"
#include "mongoc-host-list-private.h"
#include "mongoc-log.h"
#ifdef MONGOC_ENABLE_SASL
#include "mongoc-sasl-private.h"
#endif
#ifdef MONGOC_ENABLE_SSL
#include "mongoc-ssl.h"
#include "mongoc-ssl-private.h"
#include "mongoc-stream-tls.h"
#endif
#include "mongoc-b64-private.h"
#include "mongoc-scram-private.h"
#include "mongoc-set-private.h"
#include "mongoc-socket.h"
#include "mongoc-stream-private.h"
#include "mongoc-stream-socket.h"
#include "mongoc-stream-tls.h"
#include "mongoc-thread-private.h"
#include "mongoc-topology-private.h"
#include "mongoc-trace-private.h"
#include "mongoc-util-private.h"
#include "mongoc-write-concern-private.h"
#include "mongoc-uri-private.h"
#include "mongoc-rpc-private.h"
#undef MONGOC_LOG_DOMAIN
#define MONGOC_LOG_DOMAIN "cluster"
#define CHECK_CLOSED_DURATION_MSEC 1000
#define DB_AND_CMD_FROM_COLLECTION(outstr, name) \
do { \
const char *dot = strchr(name, '.'); \
if (!dot || ((dot - name) > (sizeof outstr - 6))) { \
bson_snprintf(outstr, sizeof outstr, "admin.$cmd"); \
} else { \
memcpy(outstr, name, dot - name); \
memcpy(outstr + (dot - name), ".$cmd", 6); \
} \
} while (0)
static mongoc_server_stream_t *
mongoc_cluster_fetch_stream_single (mongoc_cluster_t *cluster,
uint32_t server_id,
bool reconnect_ok,
bson_error_t *error);
static mongoc_server_stream_t *
mongoc_cluster_fetch_stream_pooled (mongoc_cluster_t *cluster,
uint32_t server_id,
bool reconnect_ok,
bson_error_t *error);
static void
_bson_error_message_printf (bson_error_t *error,
const char *format,
...) BSON_GNUC_PRINTF (2, 3);
/* Allows caller to safely overwrite error->message with a formatted string,
* even if the formatted string includes original error->message. */
static void
_bson_error_message_printf (bson_error_t *error,
const char *format,
...)
{
va_list args;
char error_message[sizeof error->message];
if (error) {
va_start (args, format);
bson_vsnprintf (error_message, sizeof error->message, format, args);
va_end (args);
bson_strncpy (error->message, error_message, sizeof error->message);
}
}
#define RUN_CMD_ERR(_domain, _code, _msg) \
do { \
bson_set_error (error, _domain, _code, _msg); \
_bson_error_message_printf ( \
error, \
"Failed to send \"%s\" command with database \"%s\": %s", \
command_name, db_name, error->message); \
} while (0)
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_run_command_internal --
*
* Internal function to run a command on a given stream.
* @error and @reply are optional out-pointers.
*
* Returns:
* true if successful; otherwise false and @error is set.
*
* Side effects:
* @reply is set and should ALWAYS be released with bson_destroy().
* On failure, @error is filled out. If this was a network error
* and server_id is nonzero, the cluster disconnects from the server.
*
*--------------------------------------------------------------------------
*/
bool
mongoc_cluster_run_command_internal (mongoc_cluster_t *cluster,
mongoc_stream_t *stream,
uint32_t server_id,
mongoc_query_flags_t flags,
const char *db_name,
const bson_t *command,
bool monitored,
const mongoc_host_list_t *host,
bson_t *reply,
bson_error_t *error)
{
int64_t started;
const char *command_name;
mongoc_apm_callbacks_t *callbacks;
mongoc_array_t ar; /* data to server */
const size_t reply_header_size = sizeof (mongoc_rpc_reply_header_t);
uint8_t reply_header_buf[sizeof (mongoc_rpc_reply_header_t)];
uint8_t *reply_buf; /* reply body */
mongoc_rpc_t rpc; /* sent to server */
bson_error_t err_local; /* in case the passed-in "error" is NULL */
bson_t reply_local;
bson_t *reply_ptr;
char cmd_ns[MONGOC_NAMESPACE_MAX];
uint32_t request_id;
int32_t msg_len;
size_t doc_len;
mongoc_apm_command_started_t started_event;
mongoc_apm_command_succeeded_t succeeded_event;
mongoc_apm_command_failed_t failed_event;
bool ret = false;
ENTRY;
BSON_ASSERT(cluster);
BSON_ASSERT(stream);
started = bson_get_monotonic_time ();
/*
* setup
*/
reply_ptr = reply ? reply : &reply_local;
bson_init (reply_ptr);
command_name = _mongoc_get_command_name (command);
BSON_ASSERT (command_name);
callbacks = &cluster->client->apm_callbacks;
_mongoc_array_init (&ar, sizeof (mongoc_iovec_t));
if (!error) {
error = &err_local;
}
error->code = 0;
/*
* prepare the request
*/
bson_snprintf (cmd_ns, sizeof cmd_ns, "%s.$cmd", db_name);
request_id = ++cluster->request_id;
_mongoc_rpc_prep_command (&rpc, cmd_ns, command, flags);
rpc.query.request_id = request_id;
_mongoc_rpc_gather (&rpc, &ar);
_mongoc_rpc_swab_to_le (&rpc);
if (monitored && callbacks->started) {
mongoc_apm_command_started_init (&started_event,
command,
db_name,
command_name,
request_id,
cluster->operation_id,
host,
server_id,
cluster->client->apm_context);
callbacks->started (&started_event);
mongoc_apm_command_started_cleanup (&started_event);
}
if (cluster->client->in_exhaust) {
bson_set_error(error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_IN_EXHAUST,
"A cursor derived from this client is in exhaust.");
GOTO (done);
}
/*
* send and receive
*/
if (!_mongoc_stream_writev_full (stream, (mongoc_iovec_t *)ar.data, ar.len,
cluster->sockettimeoutms, error)) {
mongoc_cluster_disconnect_node (cluster, server_id);
/* add info about the command to writev_full's error message */
_bson_error_message_printf (
error,
"Failed to send \"%s\" command with database \"%s\": %s",
command_name, db_name, error->message);
GOTO (done);
}
if (reply_header_size != mongoc_stream_read (stream, &reply_header_buf,
reply_header_size, reply_header_size,
cluster->sockettimeoutms)) {
mongoc_cluster_disconnect_node (cluster, server_id);
RUN_CMD_ERR (MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET,
"socket error or timeout");
GOTO (done);
}
memcpy (&msg_len, reply_header_buf, 4);
msg_len = BSON_UINT32_FROM_LE (msg_len);
if ((msg_len < reply_header_size) || (msg_len > MONGOC_DEFAULT_MAX_MSG_SIZE)) {
GOTO (done);
}
if (!_mongoc_rpc_scatter_reply_header_only (&rpc, reply_header_buf,
reply_header_size)) {
GOTO (done);
}
_mongoc_rpc_swab_from_le (&rpc);
if (rpc.header.opcode != MONGOC_OPCODE_REPLY ||
rpc.reply_header.n_returned != 1) {
GOTO (done);
}
doc_len = (size_t) msg_len - reply_header_size;
reply_buf = bson_reserve_buffer (reply_ptr, (uint32_t) doc_len);
BSON_ASSERT (reply_buf);
if (doc_len != mongoc_stream_read (stream, (void *) reply_buf, doc_len,
doc_len, cluster->sockettimeoutms)) {
RUN_CMD_ERR (MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET,
"socket error or timeout");
}
if (_mongoc_populate_cmd_error (reply_ptr,
cluster->client->error_api_version,
error)) {
GOTO (done);
}
ret = true;
if (monitored && callbacks->succeeded) {
mongoc_apm_command_succeeded_init (&succeeded_event,
bson_get_monotonic_time () - started,
reply_ptr,
command_name,
request_id,
cluster->operation_id,
host,
server_id,
cluster->client->apm_context);
callbacks->succeeded (&succeeded_event);
mongoc_apm_command_succeeded_cleanup (&succeeded_event);
}
done:
_mongoc_array_destroy (&ar);
if (!ret && error->code == 0) {
/* generic error */
RUN_CMD_ERR (MONGOC_ERROR_PROTOCOL,
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
"Invalid reply from server.");
}
if (!ret && monitored && callbacks->failed) {
mongoc_apm_command_failed_init (&failed_event,
bson_get_monotonic_time () - started,
command_name,
error,
request_id,
cluster->operation_id,
host,
server_id,
cluster->client->apm_context);
callbacks->failed (&failed_event);
mongoc_apm_command_failed_cleanup (&failed_event);
}
if (reply_ptr == &reply_local) {
bson_destroy (reply_ptr);
}
RETURN (ret);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_run_command_monitored --
*
* Internal function to run a command on a given stream.
* @error and @reply are optional out-pointers.
*
* Returns:
* true if successful; otherwise false and @error is set.
*
* Side effects:
* If the client's APM callbacks are set, they are executed.
* @reply is set and should ALWAYS be released with bson_destroy().
*
*--------------------------------------------------------------------------
*/
bool
mongoc_cluster_run_command_monitored (mongoc_cluster_t *cluster,
mongoc_server_stream_t *server_stream,
mongoc_query_flags_t flags,
const char *db_name,
const bson_t *command,
bson_t *reply,
bson_error_t *error)
{
return mongoc_cluster_run_command_internal (
cluster, server_stream->stream, server_stream->sd->id, flags, db_name,
command, true, &server_stream->sd->host, reply, error);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_run_command --
*
* Internal function to run a command on a given stream.
* @error and @reply are optional out-pointers.
* The client's APM callbacks are not executed.
*
* Returns:
* true if successful; otherwise false and @error is set.
*
* Side effects:
* @reply is set and should ALWAYS be released with bson_destroy().
*
*--------------------------------------------------------------------------
*/
bool
mongoc_cluster_run_command (mongoc_cluster_t *cluster,
mongoc_stream_t *stream,
uint32_t server_id,
mongoc_query_flags_t flags,
const char *db_name,
const bson_t *command,
bson_t *reply,
bson_error_t *error)
{
/* monitored = false */
return mongoc_cluster_run_command_internal (cluster,
stream,
server_id,
flags,
db_name,
command,
/* not monitored */
false, NULL,
reply, error);
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_stream_run_ismaster --
*
* Run an ismaster command on the given stream.
*
* Returns:
* A mongoc_server_description_t you must destroy. If the call failed
* its error is set and its type is MONGOC_SERVER_UNKNOWN.
*
*--------------------------------------------------------------------------
*/
static mongoc_server_description_t *
_mongoc_stream_run_ismaster (mongoc_cluster_t *cluster,
mongoc_stream_t *stream,
const char *address,
uint32_t server_id)
{
bson_t command = BSON_INITIALIZER;
bson_t reply;
bson_error_t error = { 0 };
int64_t start;
int64_t rtt_msec;
mongoc_server_description_t *sd;
bool r;
ENTRY;
BSON_ASSERT (cluster);
BSON_ASSERT (stream);
bson_append_int32 (&command, "ismaster", 8, 1);
start = bson_get_monotonic_time ();
mongoc_cluster_run_command (cluster, stream, 0, MONGOC_QUERY_SLAVE_OK,
"admin", &command, &reply, &error);
rtt_msec = (bson_get_monotonic_time () - start) / 1000;
sd = (mongoc_server_description_t *) bson_malloc0 (
sizeof (mongoc_server_description_t));
mongoc_server_description_init (sd, address, server_id);
/* send the error from run_command IN to handle_ismaster */
mongoc_server_description_handle_ismaster (sd, &reply, rtt_msec, &error);
bson_destroy (&command);
bson_destroy (&reply);
r = _mongoc_topology_update_from_handshake (cluster->client->topology, sd);
if (!r) {
mongoc_server_description_reset (sd);
bson_set_error (&sd->error, MONGOC_ERROR_STREAM,
MONGOC_ERROR_STREAM_NOT_ESTABLISHED,
"\"%s\" removed from topology", address);
}
RETURN (sd);
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_cluster_run_ismaster --
*
* Run an ismaster command for the given node and handle result.
*
* Returns:
* True if ismaster ran successfully, false otherwise.
*
* Side effects:
* Makes a blocking I/O call, updates cluster->topology->description
* with ismaster result.
*
*--------------------------------------------------------------------------
*/
static bool
_mongoc_cluster_run_ismaster (mongoc_cluster_t *cluster,
mongoc_cluster_node_t *node,
uint32_t server_id,
bson_error_t *error /* OUT */)
{
bool r;
mongoc_server_description_t *sd;
ENTRY;
BSON_ASSERT (cluster);
BSON_ASSERT (node);
BSON_ASSERT (node->stream);
sd = _mongoc_stream_run_ismaster (cluster, node->stream,
node->connection_address, server_id);
if (sd->type == MONGOC_SERVER_UNKNOWN) {
r = false;
memcpy (error, &sd->error, sizeof (bson_error_t));
} else {
r = true;
node->max_write_batch_size = sd->max_write_batch_size;
node->min_wire_version = sd->min_wire_version;
node->max_wire_version = sd->max_wire_version;
node->max_bson_obj_size = sd->max_bson_obj_size;
node->max_msg_size = sd->max_msg_size;
}
mongoc_server_description_destroy (sd);
return r;
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_cluster_build_basic_auth_digest --
*
* Computes the Basic Authentication digest using the credentials
* configured for @cluster and the @nonce provided.
*
* The result should be freed by the caller using bson_free() when
* they are finished with it.
*
* Returns:
* A newly allocated string containing the digest.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
static char *
_mongoc_cluster_build_basic_auth_digest (mongoc_cluster_t *cluster,
const char *nonce)
{
const char *username;
const char *password;
char *password_digest;
char *password_md5;
char *digest_in;
char *ret;
ENTRY;
/*
* The following generates the digest to be used for basic authentication
* with a MongoDB server. More information on the format can be found
* at the following location:
*
* http://docs.mongodb.org/meta-driver/latest/legacy/
* implement-authentication-in-driver/
*/
BSON_ASSERT(cluster);
BSON_ASSERT(cluster->uri);
username = mongoc_uri_get_username(cluster->uri);
password = mongoc_uri_get_password(cluster->uri);
password_digest = bson_strdup_printf("%s:mongo:%s", username, password);
password_md5 = _mongoc_hex_md5(password_digest);
digest_in = bson_strdup_printf("%s%s%s", nonce, username, password_md5);
ret = _mongoc_hex_md5(digest_in);
bson_free(digest_in);
bson_free(password_md5);
bson_free(password_digest);
RETURN(ret);
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_cluster_auth_node_cr --
*
* Performs authentication of @node using the credentials provided
* when configuring the @cluster instance.
*
* This is the Challenge-Response mode of authentication.
*
* Returns:
* true if authentication was successful; otherwise false and
* @error is set.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
static bool
_mongoc_cluster_auth_node_cr (mongoc_cluster_t *cluster,
mongoc_stream_t *stream,
bson_error_t *error)
{
bson_iter_t iter;
const char *auth_source;
bson_t command = { 0 };
bson_t reply = { 0 };
char *digest;
char *nonce;
bool ret;
ENTRY;
BSON_ASSERT(cluster);
BSON_ASSERT(stream);
if (!(auth_source = mongoc_uri_get_auth_source(cluster->uri)) ||
(*auth_source == '\0')) {
auth_source = "admin";
}
/*
* To authenticate a node using basic authentication, we need to first
* get the nonce from the server. We use that to hash our password which
* is sent as a reply to the server. If everything went good we get a
* success notification back from the server.
*/
/*
* Execute the getnonce command to fetch the nonce used for generating
* md5 digest of our password information.
*/
bson_init (&command);
bson_append_int32 (&command, "getnonce", 8, 1);
if (!mongoc_cluster_run_command (cluster, stream, 0, MONGOC_QUERY_SLAVE_OK,
auth_source, &command, &reply, error)) {
bson_destroy (&command);
bson_destroy (&reply);
RETURN (false);
}
bson_destroy (&command);
if (!bson_iter_init_find_case (&iter, &reply, "nonce")) {
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_GETNONCE,
"Invalid reply from getnonce");
bson_destroy (&reply);
RETURN (false);
}
/*
* Build our command to perform the authentication.
*/
nonce = bson_iter_dup_utf8(&iter, NULL);
digest = _mongoc_cluster_build_basic_auth_digest(cluster, nonce);
bson_init(&command);
bson_append_int32(&command, "authenticate", 12, 1);
bson_append_utf8(&command, "user", 4,
mongoc_uri_get_username(cluster->uri), -1);
bson_append_utf8(&command, "nonce", 5, nonce, -1);
bson_append_utf8(&command, "key", 3, digest, -1);
bson_destroy(&reply);
bson_free(nonce);
bson_free(digest);
/*
* Execute the authenticate command. mongoc_cluster_run_command
* checks for {ok: 1} in the response.
*/
ret = mongoc_cluster_run_command (cluster, stream, 0, MONGOC_QUERY_SLAVE_OK,
auth_source, &command, &reply, error);
if (!ret) {
/* error->message is already set */
error->domain = MONGOC_ERROR_CLIENT;
error->code = MONGOC_ERROR_CLIENT_AUTHENTICATE;
}
bson_destroy (&command);
bson_destroy (&reply);
RETURN (ret);
}
#ifdef MONGOC_ENABLE_SASL
/*
*--------------------------------------------------------------------------
*
* _mongoc_cluster_get_canonicalized_name --
*
* Query the node to get the canonicalized name. This may happen if
* the node has been accessed via an alias.
*
* The gssapi code will use this if canonicalizeHostname is true.
*
* Some underlying layers of krb might do this for us, but they can
* be disabled in krb.conf.
*
* Returns:
* None.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
static bool
_mongoc_cluster_get_canonicalized_name (mongoc_cluster_t *cluster, /* IN */
mongoc_stream_t *node_stream, /* IN */
char *name, /* OUT */
size_t namelen, /* IN */
bson_error_t *error) /* OUT */
{
mongoc_stream_t *stream;
mongoc_stream_t *tmp;
mongoc_socket_t *sock = NULL;
char *canonicalized;
ENTRY;
BSON_ASSERT (cluster);
BSON_ASSERT (node_stream);
BSON_ASSERT (name);
/*
* Find the underlying socket used in the stream chain.
*/
for (stream = node_stream; stream;) {
if ((tmp = mongoc_stream_get_base_stream (stream))) {
stream = tmp;
continue;
}
break;
}
BSON_ASSERT (stream);
if (stream->type == MONGOC_STREAM_SOCKET) {
sock = mongoc_stream_socket_get_socket ((mongoc_stream_socket_t *)stream);
if (sock) {
canonicalized = mongoc_socket_getnameinfo (sock);
if (canonicalized) {
bson_snprintf (name, namelen, "%s", canonicalized);
bson_free (canonicalized);
RETURN (true);
}
}
}
RETURN (false);
}
#endif
#ifdef MONGOC_ENABLE_SASL
/*
*--------------------------------------------------------------------------
*
* _mongoc_cluster_auth_node_sasl --
*
* Perform authentication for a cluster node using SASL. This is
* only supported for GSSAPI at the moment.
*
* Returns:
* true if successful; otherwise false and @error is set.
*
* Side effects:
* error may be set.
*
*--------------------------------------------------------------------------
*/
static bool
_mongoc_cluster_auth_node_sasl (mongoc_cluster_t *cluster,
mongoc_stream_t *stream,
const char *hostname,
bson_error_t *error)
{
uint32_t buflen = 0;
mongoc_sasl_t sasl;
bson_iter_t iter;
bool ret = false;
char real_name [BSON_HOST_NAME_MAX + 1];
const char *mechanism;
const char *tmpstr;
uint8_t buf[4096] = { 0 };
bson_t cmd;
bson_t reply;
int conv_id = 0;
BSON_ASSERT (cluster);
BSON_ASSERT (stream);
_mongoc_sasl_init (&sasl);
if ((mechanism = mongoc_uri_get_auth_mechanism (cluster->uri))) {
_mongoc_sasl_set_mechanism (&sasl, mechanism);
}
_mongoc_sasl_set_pass (&sasl, mongoc_uri_get_password (cluster->uri));
_mongoc_sasl_set_user (&sasl, mongoc_uri_get_username (cluster->uri));
_mongoc_sasl_set_properties (&sasl, cluster->uri);
/*
* If the URI requested canonicalizeHostname, we need to resolve the real
* hostname for the IP Address and pass that to the SASL layer. Some
* underlying GSSAPI layers will do this for us, but can be disabled in
* their config (krb.conf).
*
* This allows the consumer to specify canonicalizeHostname=true in the URI
* and have us do that for them.
*
* See CDRIVER-323 for more information.
*/
if (sasl.canonicalize_host_name &&
_mongoc_cluster_get_canonicalized_name (cluster, stream, real_name,
sizeof real_name, error))
{
_mongoc_sasl_set_service_host (&sasl, real_name);
} else {
_mongoc_sasl_set_service_host (&sasl, hostname);
}
for (;;) {
if (!_mongoc_sasl_step (&sasl, buf, buflen, buf, sizeof buf, &buflen, error)) {
goto failure;
}
bson_init (&cmd);
if (sasl.step == 1) {
BSON_APPEND_INT32 (&cmd, "saslStart", 1);
BSON_APPEND_UTF8 (&cmd, "mechanism", mechanism ? mechanism : "GSSAPI");
bson_append_utf8 (&cmd, "payload", 7, (const char *)buf, buflen);
BSON_APPEND_INT32 (&cmd, "autoAuthorize", 1);
} else {
BSON_APPEND_INT32 (&cmd, "saslContinue", 1);
BSON_APPEND_INT32 (&cmd, "conversationId", conv_id);
bson_append_utf8 (&cmd, "payload", 7, (const char *)buf, buflen);
}
TRACE ("SASL: authenticating (step %d)", sasl.step);
if (!mongoc_cluster_run_command (cluster, stream, 0, MONGOC_QUERY_SLAVE_OK,
"$external", &cmd, &reply, error)) {
bson_destroy (&cmd);
bson_destroy (&reply);
goto failure;
}
bson_destroy (&cmd);
if (bson_iter_init_find (&iter, &reply, "done") &&
bson_iter_as_bool (&iter)) {
bson_destroy (&reply);
break;
}
if (!bson_iter_init_find (&iter, &reply, "conversationId") ||
!BSON_ITER_HOLDS_INT32 (&iter) ||
!(conv_id = bson_iter_int32 (&iter)) ||
!bson_iter_init_find (&iter, &reply, "payload") ||
!BSON_ITER_HOLDS_UTF8 (&iter)) {
MONGOC_DEBUG ("SASL: authentication failed");
bson_destroy (&reply);
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_AUTHENTICATE,
"Received invalid SASL reply from MongoDB server.");
goto failure;
}
tmpstr = bson_iter_utf8 (&iter, &buflen);
if (buflen > sizeof buf) {
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_AUTHENTICATE,
"SASL reply from MongoDB is too large.");
bson_destroy (&reply);
goto failure;
}
memcpy (buf, tmpstr, buflen);
bson_destroy (&reply);
}
TRACE ("%s", "SASL: authenticated");
ret = true;
failure:
_mongoc_sasl_destroy (&sasl);
return ret;
}
#endif
/*
*--------------------------------------------------------------------------
*
* _mongoc_cluster_auth_node_plain --
*
* Perform SASL PLAIN authentication for @node. We do this manually
* instead of using the SASL module because its rather simplistic.
*
* Returns:
* true if successful; otherwise false and error is set.
*
* Side effects:
* error may be set.
*
*--------------------------------------------------------------------------
*/
static bool
_mongoc_cluster_auth_node_plain (mongoc_cluster_t *cluster,
mongoc_stream_t *stream,
bson_error_t *error)
{
char buf[4096];
int buflen = 0;
const char *username;
const char *password;
bson_t b = BSON_INITIALIZER;
bson_t reply;
size_t len;
char *str;
bool ret;
BSON_ASSERT (cluster);
BSON_ASSERT (stream);
username = mongoc_uri_get_username (cluster->uri);
if (!username) {
username = "";
}
password = mongoc_uri_get_password (cluster->uri);
if (!password) {
password = "";
}
str = bson_strdup_printf ("%c%s%c%s", '\0', username, '\0', password);
len = strlen (username) + strlen (password) + 2;
buflen = mongoc_b64_ntop ((const uint8_t *) str, len, buf, sizeof buf);
bson_free (str);
if (buflen == -1) {
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_AUTHENTICATE,
"failed base64 encoding message");
return false;
}
BSON_APPEND_INT32 (&b, "saslStart", 1);
BSON_APPEND_UTF8 (&b, "mechanism", "PLAIN");
bson_append_utf8 (&b, "payload", 7, (const char *)buf, buflen);
BSON_APPEND_INT32 (&b, "autoAuthorize", 1);
ret = mongoc_cluster_run_command (cluster, stream, 0, MONGOC_QUERY_SLAVE_OK,
"$external", &b, &reply, error);
if (!ret) {
/* error->message is already set */
error->domain = MONGOC_ERROR_CLIENT;
error->code = MONGOC_ERROR_CLIENT_AUTHENTICATE;
}
bson_destroy (&b);
bson_destroy (&reply);
return ret;
}
#ifdef MONGOC_ENABLE_SSL
static bool
_mongoc_cluster_auth_node_x509 (mongoc_cluster_t *cluster,
mongoc_stream_t *stream,
bson_error_t *error)
{
const char *username_from_uri = NULL;
char *username_from_subject = NULL;
bson_t cmd;
bson_t reply;
bool ret;
BSON_ASSERT (cluster);
BSON_ASSERT (stream);
username_from_uri = mongoc_uri_get_username (cluster->uri);
if (username_from_uri) {
TRACE ("%s", "X509: got username from URI");
} else {
if (!cluster->client->ssl_opts.pem_file) {
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_AUTHENTICATE,
"cannot determine username for "
"X-509 authentication.");
return false;
}
username_from_subject = mongoc_ssl_extract_subject (cluster->client->ssl_opts.pem_file,
cluster->client->ssl_opts.pem_pwd);
if (!username_from_subject) {
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_AUTHENTICATE,
"No username provided for X509 authentication.");
return false;
}
TRACE ("%s", "X509: got username from certificate");
}
bson_init (&cmd);
BSON_APPEND_INT32 (&cmd, "authenticate", 1);
BSON_APPEND_UTF8 (&cmd, "mechanism", "MONGODB-X509");
BSON_APPEND_UTF8 (&cmd, "user", username_from_uri ? username_from_uri : username_from_subject);
ret = mongoc_cluster_run_command (cluster, stream, 0, MONGOC_QUERY_SLAVE_OK,
"$external", &cmd, &reply, error);
if (!ret) {
/* error->message is already set */
error->domain = MONGOC_ERROR_CLIENT;
error->code = MONGOC_ERROR_CLIENT_AUTHENTICATE;
}
if (username_from_subject) {
bson_free (username_from_subject);
}
bson_destroy (&cmd);
bson_destroy (&reply);
return ret;
}
#endif
#ifdef MONGOC_ENABLE_CRYPTO
static bool
_mongoc_cluster_auth_node_scram (mongoc_cluster_t *cluster,
mongoc_stream_t *stream,
bson_error_t *error)
{
uint32_t buflen = 0;
mongoc_scram_t scram;
bson_iter_t iter;
bool ret = false;
const char *tmpstr;
const char *auth_source;
uint8_t buf[4096] = { 0 };
bson_t cmd;
bson_t reply;
int conv_id = 0;
bson_subtype_t btype;
BSON_ASSERT (cluster);
BSON_ASSERT (stream);
if (!(auth_source = mongoc_uri_get_auth_source(cluster->uri)) ||
(*auth_source == '\0')) {
auth_source = "admin";
}
_mongoc_scram_init(&scram);
_mongoc_scram_set_pass (&scram, mongoc_uri_get_password (cluster->uri));
_mongoc_scram_set_user (&scram, mongoc_uri_get_username (cluster->uri));
for (;;) {
if (!_mongoc_scram_step (&scram, buf, buflen, buf, sizeof buf, &buflen, error)) {
goto failure;
}
bson_init (&cmd);
if (scram.step == 1) {
BSON_APPEND_INT32 (&cmd, "saslStart", 1);
BSON_APPEND_UTF8 (&cmd, "mechanism", "SCRAM-SHA-1");
bson_append_binary (&cmd, "payload", 7, BSON_SUBTYPE_BINARY, buf, buflen);
BSON_APPEND_INT32 (&cmd, "autoAuthorize", 1);
} else {
BSON_APPEND_INT32 (&cmd, "saslContinue", 1);
BSON_APPEND_INT32 (&cmd, "conversationId", conv_id);
bson_append_binary (&cmd, "payload", 7, BSON_SUBTYPE_BINARY, buf, buflen);
}
TRACE ("SCRAM: authenticating (step %d)", scram.step);
if (!mongoc_cluster_run_command (cluster, stream, 0, MONGOC_QUERY_SLAVE_OK,
auth_source, &cmd, &reply, error)) {
bson_destroy (&cmd);
bson_destroy (&reply);
/* error->message is already set */
error->domain = MONGOC_ERROR_CLIENT;
error->code = MONGOC_ERROR_CLIENT_AUTHENTICATE;
goto failure;
}
bson_destroy (&cmd);
if (bson_iter_init_find (&iter, &reply, "done") &&
bson_iter_as_bool (&iter)) {
bson_destroy (&reply);
break;
}
if (!bson_iter_init_find (&iter, &reply, "conversationId") ||
!BSON_ITER_HOLDS_INT32 (&iter) ||
!(conv_id = bson_iter_int32 (&iter)) ||
!bson_iter_init_find (&iter, &reply, "payload") ||
!BSON_ITER_HOLDS_BINARY(&iter)) {
const char *errmsg = "Received invalid SCRAM reply from MongoDB server.";
MONGOC_DEBUG ("SCRAM: authentication failed");
if (bson_iter_init_find (&iter, &reply, "errmsg") &&
BSON_ITER_HOLDS_UTF8 (&iter)) {
errmsg = bson_iter_utf8 (&iter, NULL);
}
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_AUTHENTICATE,
"%s", errmsg);
bson_destroy (&reply);
goto failure;
}
bson_iter_binary (&iter, &btype, &buflen, (const uint8_t**)&tmpstr);
if (buflen > sizeof buf) {
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_AUTHENTICATE,
"SCRAM reply from MongoDB is too large.");
bson_destroy (&reply);
goto failure;
}
memcpy (buf, tmpstr, buflen);
bson_destroy (&reply);
}
TRACE ("%s", "SCRAM: authenticated");
ret = true;
failure:
_mongoc_scram_destroy (&scram);
return ret;
}
#endif
/*
*--------------------------------------------------------------------------
*
* _mongoc_cluster_auth_node --
*
* Authenticate a cluster node depending on the required mechanism.
*
* Returns:
* true if authenticated. false on failure and @error is set.
*
* Side effects:
* @error is set on failure.
*
*--------------------------------------------------------------------------
*/
static bool
_mongoc_cluster_auth_node (mongoc_cluster_t *cluster,
mongoc_stream_t *stream,
const char *hostname,
int32_t max_wire_version,
bson_error_t *error)
{
bool ret = false;
const char *mechanism;
ENTRY;
BSON_ASSERT (cluster);
BSON_ASSERT (stream);
mechanism = mongoc_uri_get_auth_mechanism (cluster->uri);
/* Use cached max_wire_version, not value from sd */
if (!mechanism) {
if (max_wire_version < WIRE_VERSION_SCRAM_DEFAULT) {
mechanism = "MONGODB-CR";
} else {
mechanism = "SCRAM-SHA-1";
}
}
if (0 == strcasecmp (mechanism, "MONGODB-CR")) {
ret = _mongoc_cluster_auth_node_cr (cluster, stream, error);
} else if (0 == strcasecmp (mechanism, "MONGODB-X509")) {
#ifdef MONGOC_ENABLE_SSL
ret = _mongoc_cluster_auth_node_x509 (cluster, stream, error);
#else
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_AUTHENTICATE,
"The \"%s\" authentication mechanism requires libmongoc built with --enable-ssl",
mechanism);
#endif
} else if (0 == strcasecmp (mechanism, "SCRAM-SHA-1")) {
#ifdef MONGOC_ENABLE_CRYPTO
ret = _mongoc_cluster_auth_node_scram (cluster, stream, error);
#else
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_AUTHENTICATE,
"The \"%s\" authentication mechanism requires libmongoc built with --enable-ssl",
mechanism);
#endif
} else if (0 == strcasecmp (mechanism, "GSSAPI")) {
#ifdef MONGOC_ENABLE_SASL
ret = _mongoc_cluster_auth_node_sasl (cluster, stream, hostname, error);
#else
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_AUTHENTICATE,
"The \"%s\" authentication mechanism requires libmongoc built with --enable-sasl",
mechanism);
#endif
} else if (0 == strcasecmp (mechanism, "PLAIN")) {
ret = _mongoc_cluster_auth_node_plain (cluster, stream, error);
} else {
bson_set_error (error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_AUTHENTICATE,
"Unknown authentication mechanism \"%s\".",
mechanism);
}
if (!ret) {
mongoc_counter_auth_failure_inc ();
MONGOC_DEBUG("Authentication failed: %s", error->message);
} else {
mongoc_counter_auth_success_inc ();
TRACE("%s", "Authentication succeeded");
}
RETURN(ret);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_disconnect_node --
*
* Remove a node from the set of nodes. This should be done if
* a stream in the set is found to be invalid.
*
* WARNING: pointers to a disconnected mongoc_cluster_node_t or
* its stream are now invalid, be careful of dangling pointers.
*
* Returns:
* None.
*
* Side effects:
* Removes node from cluster's set of nodes, and frees the
* mongoc_cluster_node_t if pooled.
*
*--------------------------------------------------------------------------
*/
void
mongoc_cluster_disconnect_node (mongoc_cluster_t *cluster, uint32_t server_id)
{
mongoc_topology_t *topology = cluster->client->topology;
ENTRY;
if (topology->single_threaded) {
mongoc_topology_scanner_node_t *scanner_node;
scanner_node = mongoc_topology_scanner_get_node (topology->scanner, server_id);
/* might never actually have connected */
if (scanner_node && scanner_node->stream) {
mongoc_topology_scanner_node_disconnect (scanner_node, true);
EXIT;
}
EXIT;
} else {
mongoc_set_rm(cluster->nodes, server_id);
}
EXIT;
}
static void
_mongoc_cluster_node_destroy (mongoc_cluster_node_t *node)
{
/* Failure, or Replica Set reconfigure without this node */
mongoc_stream_failed (node->stream);
bson_free (node->connection_address);
bson_free (node);
}
static void
_mongoc_cluster_node_dtor (void *data_,
void *ctx_)
{
mongoc_cluster_node_t *node = (mongoc_cluster_node_t *)data_;
_mongoc_cluster_node_destroy (node);
}
static mongoc_cluster_node_t *
_mongoc_cluster_node_new (mongoc_stream_t *stream,
const char *connection_address)
{
mongoc_cluster_node_t *node;
if (!stream) {
return NULL;
}
node = (mongoc_cluster_node_t *)bson_malloc0(sizeof *node);
node->stream = stream;
node->connection_address = bson_strdup (connection_address);
node->timestamp = bson_get_monotonic_time ();
node->max_wire_version = MONGOC_DEFAULT_WIRE_VERSION;
node->min_wire_version = MONGOC_DEFAULT_WIRE_VERSION;
node->max_write_batch_size = MONGOC_DEFAULT_WRITE_BATCH_SIZE;
node->max_bson_obj_size = MONGOC_DEFAULT_BSON_OBJ_SIZE;
node->max_msg_size = MONGOC_DEFAULT_MAX_MSG_SIZE;
return node;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_add_node --
*
* Add a new node to this cluster for the given server description.
*
* NOTE: does NOT check if this server is already in the cluster.
*
* Returns:
* A stream connected to the server, or NULL on failure.
*
* Side effects:
* Adds a cluster node, or sets error on failure.
*
*--------------------------------------------------------------------------
*/
static mongoc_stream_t *
_mongoc_cluster_add_node (mongoc_cluster_t *cluster,
uint32_t server_id,
bson_error_t *error /* OUT */)
{
mongoc_host_list_t *host = NULL;
mongoc_cluster_node_t *cluster_node = NULL;
mongoc_stream_t *stream;
ENTRY;
BSON_ASSERT (cluster);
BSON_ASSERT (!cluster->client->topology->single_threaded);
host = _mongoc_topology_host_by_id (cluster->client->topology, server_id,
error);
if (!host) {
GOTO (error);
}
TRACE ("Adding new server to cluster: %s", host->host_and_port);
stream = _mongoc_client_create_stream (cluster->client, host, error);
if (!stream) {
MONGOC_WARNING ("Failed connection to %s (%s)",
host->host_and_port, error->message);
GOTO (error);
}
/* take critical fields from a fresh ismaster */
cluster_node = _mongoc_cluster_node_new (stream, host->host_and_port);
if (!_mongoc_cluster_run_ismaster (cluster, cluster_node, server_id,
error)) {
GOTO (error);
}
if (cluster->requires_auth) {
if (!_mongoc_cluster_auth_node (cluster, cluster_node->stream, host->host,
cluster_node->max_wire_version, error)) {
MONGOC_WARNING ("Failed authentication to %s (%s)",
host->host_and_port, error->message);
GOTO (error);
}
}
mongoc_set_add (cluster->nodes, server_id, cluster_node);
_mongoc_host_list_destroy_all (host);
RETURN (stream);
error:
_mongoc_host_list_destroy_all (host); /* null ok */
if (cluster_node) {
_mongoc_cluster_node_destroy (cluster_node); /* also destroys stream */
}
RETURN (NULL);
}
static void
node_not_found (mongoc_topology_t *topology,
uint32_t server_id,
bson_error_t *error /* OUT */)
{
mongoc_server_description_t *sd;
if (!error) {
return;
}
sd = mongoc_topology_server_by_id (topology, server_id, error);
if (!sd) {
return;
}
if (sd->error.code) {
memcpy (error, &sd->error, sizeof *error);
} else {
bson_set_error (error,
MONGOC_ERROR_STREAM,
MONGOC_ERROR_STREAM_NOT_ESTABLISHED,
"Could not find node %s",
sd->host.host_and_port);
}
mongoc_server_description_destroy (sd);
}
static void
stream_not_found (mongoc_topology_t *topology,
uint32_t server_id,
const char *connection_address,
bson_error_t *error /* OUT */)
{
mongoc_server_description_t *sd;
sd = mongoc_topology_server_by_id (topology, server_id, error);
if (error) {
if (sd && sd->error.code) {
memcpy (error, &sd->error, sizeof *error);
} else {
bson_set_error (error, MONGOC_ERROR_STREAM,
MONGOC_ERROR_STREAM_NOT_ESTABLISHED,
"Could not find stream for node %s",
connection_address);
}
}
if (sd) {
mongoc_server_description_destroy (sd);
}
}
mongoc_server_stream_t *
_mongoc_cluster_stream_for_server (mongoc_cluster_t *cluster,
uint32_t server_id,
bool reconnect_ok,
- bson_error_t *error)
+ bson_error_t *error /* OUT */)
{
mongoc_topology_t *topology;
mongoc_server_stream_t *server_stream;
+ bson_error_t err_local;
+ /* if fetch_stream fails we need a place to receive error details and pass
+ * them to mongoc_topology_invalidate_server. */
+ bson_error_t *err_ptr = error ? error : &err_local;
ENTRY;
topology = cluster->client->topology;
/* in the single-threaded use case we share topology's streams */
if (topology->single_threaded) {
server_stream = mongoc_cluster_fetch_stream_single (cluster,
server_id,
reconnect_ok,
- error);
+ err_ptr);
} else {
server_stream = mongoc_cluster_fetch_stream_pooled (cluster,
server_id,
reconnect_ok,
- error);
+ err_ptr);
}
if (!server_stream) {
- /* Server Discovery And Monitoring Spec: When an application operation
+ /* Server Discovery And Monitoring Spec: "When an application operation
* fails because of any network error besides a socket timeout, the
* client MUST replace the server's description with a default
* ServerDescription of type Unknown, and fill the ServerDescription's
- * error field with useful information.
+ * error field with useful information."
*
* error was filled by fetch_stream_single/pooled, pass it to invalidate()
*/
mongoc_cluster_disconnect_node (cluster, server_id);
- mongoc_topology_invalidate_server (topology, server_id, error);
+ mongoc_topology_invalidate_server (topology, server_id, err_ptr);
}
RETURN (server_stream);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_stream_for_server --
*
* Fetch the stream for @server_id. If @reconnect_ok and there is no
* valid stream, attempts to reconnect; if not @reconnect_ok then only
* an existing stream can be returned, or NULL.
*
* Returns:
* A mongoc_server_stream_t, or NULL
*
* Side effects:
* May add a node or reconnect one, if @reconnect_ok.
* Authenticates the stream if needed.
* May set @error.
*
*--------------------------------------------------------------------------
*/
mongoc_server_stream_t *
mongoc_cluster_stream_for_server (mongoc_cluster_t *cluster,
uint32_t server_id,
bool reconnect_ok,
bson_error_t *error)
{
mongoc_server_stream_t *server_stream = NULL;
ENTRY;
BSON_ASSERT (cluster);
BSON_ASSERT (server_id);
server_stream = _mongoc_cluster_stream_for_server (cluster, server_id,
reconnect_ok, error);
if (!server_stream) {
/* failed */
mongoc_cluster_disconnect_node (cluster, server_id);
}
RETURN (server_stream);
}
static mongoc_server_stream_t *
mongoc_cluster_fetch_stream_single (mongoc_cluster_t *cluster,
uint32_t server_id,
bool reconnect_ok,
bson_error_t *error /* OUT */)
{
mongoc_topology_t *topology;
mongoc_server_description_t *sd;
mongoc_stream_t *stream;
mongoc_topology_scanner_node_t *scanner_node;
int64_t expire_at;
topology = cluster->client->topology;
scanner_node = mongoc_topology_scanner_get_node (topology->scanner,
server_id);
BSON_ASSERT (scanner_node && !scanner_node->retired);
stream = scanner_node->stream;
if (stream) {
sd = mongoc_topology_server_by_id (topology, server_id, error);
if (!sd) {
return NULL;
}
} else {
if (!reconnect_ok) {
stream_not_found (topology, server_id,
scanner_node->host.host_and_port, error);
return NULL;
}
if (!mongoc_topology_scanner_node_setup (scanner_node, error)) {
return NULL;
}
stream = scanner_node->stream;
expire_at = bson_get_monotonic_time() + topology->connect_timeout_msec * 1000;
if (!mongoc_stream_wait (stream, expire_at)) {
bson_set_error (error,
MONGOC_ERROR_STREAM,
MONGOC_ERROR_STREAM_CONNECT,
"Failed to connect to target host: '%s'",
scanner_node->host.host_and_port);
return NULL;
}
#ifdef MONGOC_ENABLE_SSL
if (cluster->client->use_ssl) {
bool r;
mongoc_stream_t *tls_stream;
for (tls_stream = stream; tls_stream->type != MONGOC_STREAM_TLS;
tls_stream = mongoc_stream_get_base_stream (tls_stream)) {
}
r = mongoc_stream_tls_handshake_block (
tls_stream, scanner_node->host.host,
(int32_t) topology->connect_timeout_msec * 1000, error);
if (!r) {
mongoc_topology_scanner_node_disconnect (scanner_node, true);
return NULL;
}
}
#endif
sd = _mongoc_stream_run_ismaster (cluster, stream,
scanner_node->host.host_and_port,
server_id);
}
if (sd->type == MONGOC_SERVER_UNKNOWN) {
memcpy (error, &sd->error, sizeof *error);
mongoc_server_description_destroy (sd);
return NULL;
}
/* stream open but not auth'ed: first use since connect or reconnect */
if (cluster->requires_auth && !scanner_node->has_auth) {
if (!_mongoc_cluster_auth_node (cluster, stream, sd->host.host,
sd->max_wire_version, &sd->error)) {
memcpy (error, &sd->error, sizeof *error);
mongoc_server_description_destroy (sd);
return NULL;
}
scanner_node->has_auth = true;
}
return mongoc_server_stream_new (topology->description.type, sd, stream);
}
static mongoc_server_stream_t *
_mongoc_cluster_create_server_stream (mongoc_topology_t *topology,
uint32_t server_id,
mongoc_stream_t *stream,
bson_error_t *error /* OUT */)
{
mongoc_server_description_t *sd;
sd = mongoc_topology_server_by_id (topology, server_id, error);
if (!sd) {
return NULL;
}
return mongoc_server_stream_new (_mongoc_topology_get_type (topology),
sd, stream);
}
static mongoc_server_stream_t *
mongoc_cluster_fetch_stream_pooled (mongoc_cluster_t *cluster,
uint32_t server_id,
bool reconnect_ok,
bson_error_t *error /* OUT */)
{
mongoc_topology_t *topology;
mongoc_stream_t *stream;
mongoc_cluster_node_t *cluster_node;
int64_t timestamp;
cluster_node = (mongoc_cluster_node_t *) mongoc_set_get (cluster->nodes,
server_id);
topology = cluster->client->topology;
if (cluster_node) {
BSON_ASSERT (cluster_node->stream);
timestamp = mongoc_topology_server_timestamp (topology, server_id);
if (timestamp == -1 || cluster_node->timestamp < timestamp) {
/* topology change or net error during background scan made us remove
* or replace server description since node's birth. destroy node. */
mongoc_cluster_disconnect_node (cluster, server_id);
} else {
return _mongoc_cluster_create_server_stream (topology, server_id,
cluster_node->stream,
error);
}
}
/* no node, or out of date */
if (!reconnect_ok) {
node_not_found (topology, server_id, error);
return NULL;
}
stream = _mongoc_cluster_add_node (cluster, server_id, error);
if (stream) {
return _mongoc_cluster_create_server_stream (topology, server_id,
stream, error);
} else {
return NULL;
}
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_init --
*
* Initializes @cluster using the @uri and @client provided. The
* @uri is used to determine the "mode" of the cluster. Based on the
* uri we can determine if we are connected to a single host, a
* replicaSet, or a shardedCluster.
*
* Returns:
* None.
*
* Side effects:
* @cluster is initialized.
*
*--------------------------------------------------------------------------
*/
void
mongoc_cluster_init (mongoc_cluster_t *cluster,
const mongoc_uri_t *uri,
void *client)
{
ENTRY;
BSON_ASSERT (cluster);
BSON_ASSERT (uri);
memset (cluster, 0, sizeof *cluster);
cluster->uri = mongoc_uri_copy(uri);
cluster->client = (mongoc_client_t *)client;
cluster->requires_auth = (mongoc_uri_get_username(uri) ||
mongoc_uri_get_auth_mechanism(uri));
cluster->sockettimeoutms = mongoc_uri_get_option_as_int32(
uri, "sockettimeoutms", MONGOC_DEFAULT_SOCKETTIMEOUTMS);
cluster->socketcheckintervalms = mongoc_uri_get_option_as_int32(
uri, "socketcheckintervalms", MONGOC_TOPOLOGY_SOCKET_CHECK_INTERVAL_MS);
/* TODO for single-threaded case we don't need this */
cluster->nodes = mongoc_set_new(8, _mongoc_cluster_node_dtor, NULL);
_mongoc_array_init (&cluster->iov, sizeof (mongoc_iovec_t));
cluster->operation_id = rand ();
EXIT;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_destroy --
*
* Clean up after @cluster and destroy all active connections.
* All resources for @cluster are released.
*
* Returns:
* None.
*
* Side effects:
* Everything.
*
*--------------------------------------------------------------------------
*/
void
mongoc_cluster_destroy (mongoc_cluster_t *cluster) /* INOUT */
{
ENTRY;
BSON_ASSERT (cluster);
mongoc_uri_destroy(cluster->uri);
mongoc_set_destroy(cluster->nodes);
_mongoc_array_destroy(&cluster->iov);
EXIT;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_stream_for_optype --
*
* Internal server selection.
*
* Returns:
* A mongoc_server_stream_t on which you must call
* mongoc_server_stream_cleanup, or NULL on failure (sets @error)
*
* Side effects:
* May set @error.
* May add new nodes to @cluster->nodes.
*
*--------------------------------------------------------------------------
*/
static mongoc_server_stream_t *
_mongoc_cluster_stream_for_optype (mongoc_cluster_t *cluster,
mongoc_ss_optype_t optype,
const mongoc_read_prefs_t *read_prefs,
bson_error_t *error)
{
mongoc_server_stream_t *server_stream;
uint32_t server_id;
mongoc_topology_t *topology = cluster->client->topology;
ENTRY;
BSON_ASSERT (cluster);
server_id = mongoc_topology_select_server_id (topology,
optype,
read_prefs,
error);
if (!server_id) {
RETURN(NULL);
}
/* connect or reconnect to server if necessary */
server_stream = _mongoc_cluster_stream_for_server (cluster,
server_id,
true /* reconnect_ok */,
error);
RETURN (server_stream);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_stream_for_reads --
*
* Internal server selection.
*
* Returns:
* A mongoc_server_stream_t on which you must call
* mongoc_server_stream_cleanup, or NULL on failure (sets @error)
*
* Side effects:
* May set @error.
* May add new nodes to @cluster->nodes.
*
*--------------------------------------------------------------------------
*/
mongoc_server_stream_t *
mongoc_cluster_stream_for_reads (mongoc_cluster_t *cluster,
const mongoc_read_prefs_t *read_prefs,
bson_error_t *error)
{
return _mongoc_cluster_stream_for_optype (cluster, MONGOC_SS_READ,
read_prefs, error);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_stream_for_writes --
*
* Get a stream for write operations.
*
* Returns:
* A mongoc_server_stream_t on which you must call
* mongoc_server_stream_cleanup, or NULL on failure (sets @error)
*
* Side effects:
* May set @error.
* May add new nodes to @cluster->nodes.
*
*--------------------------------------------------------------------------
*/
mongoc_server_stream_t *
mongoc_cluster_stream_for_writes (mongoc_cluster_t *cluster,
bson_error_t *error)
{
return _mongoc_cluster_stream_for_optype (cluster, MONGOC_SS_WRITE,
NULL, error);
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_cluster_inc_egress_rpc --
*
* Helper to increment the counter for a particular RPC based on
* it's opcode.
*
* Returns:
* None.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
static BSON_INLINE void
_mongoc_cluster_inc_egress_rpc (const mongoc_rpc_t *rpc)
{
mongoc_counter_op_egress_total_inc();
switch (rpc->header.opcode) {
case MONGOC_OPCODE_DELETE:
mongoc_counter_op_egress_delete_inc();
break;
case MONGOC_OPCODE_UPDATE:
mongoc_counter_op_egress_update_inc();
break;
case MONGOC_OPCODE_INSERT:
mongoc_counter_op_egress_insert_inc();
break;
case MONGOC_OPCODE_KILL_CURSORS:
mongoc_counter_op_egress_killcursors_inc();
break;
case MONGOC_OPCODE_GET_MORE:
mongoc_counter_op_egress_getmore_inc();
break;
case MONGOC_OPCODE_REPLY:
mongoc_counter_op_egress_reply_inc();
break;
case MONGOC_OPCODE_MSG:
mongoc_counter_op_egress_msg_inc();
break;
case MONGOC_OPCODE_QUERY:
mongoc_counter_op_egress_query_inc();
break;
default:
BSON_ASSERT(false);
break;
}
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_cluster_inc_ingress_rpc --
*
* Helper to increment the counter for a particular RPC based on
* it's opcode.
*
* Returns:
* None.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
static BSON_INLINE void
_mongoc_cluster_inc_ingress_rpc (const mongoc_rpc_t *rpc)
{
mongoc_counter_op_ingress_total_inc ();
switch (rpc->header.opcode) {
case MONGOC_OPCODE_DELETE:
mongoc_counter_op_ingress_delete_inc ();
break;
case MONGOC_OPCODE_UPDATE:
mongoc_counter_op_ingress_update_inc ();
break;
case MONGOC_OPCODE_INSERT:
mongoc_counter_op_ingress_insert_inc ();
break;
case MONGOC_OPCODE_KILL_CURSORS:
mongoc_counter_op_ingress_killcursors_inc ();
break;
case MONGOC_OPCODE_GET_MORE:
mongoc_counter_op_ingress_getmore_inc ();
break;
case MONGOC_OPCODE_REPLY:
mongoc_counter_op_ingress_reply_inc ();
break;
case MONGOC_OPCODE_MSG:
mongoc_counter_op_ingress_msg_inc ();
break;
case MONGOC_OPCODE_QUERY:
mongoc_counter_op_ingress_query_inc ();
break;
default:
BSON_ASSERT (false);
break;
}
}
static bool
_mongoc_cluster_min_of_max_obj_size_sds (void *item,
void *ctx)
{
mongoc_server_description_t *sd = (mongoc_server_description_t *)item;
int32_t *current_min = (int32_t *)ctx;
if (sd->max_bson_obj_size < *current_min) {
*current_min = sd->max_bson_obj_size;
}
return true;
}
static bool
_mongoc_cluster_min_of_max_obj_size_nodes (void *item,
void *ctx)
{
mongoc_cluster_node_t *node = (mongoc_cluster_node_t *)item;
int32_t *current_min = (int32_t *)ctx;
if (node->max_bson_obj_size < *current_min) {
*current_min = node->max_bson_obj_size;
}
return true;
}
static bool
_mongoc_cluster_min_of_max_msg_size_sds (void *item,
void *ctx)
{
mongoc_server_description_t *sd = (mongoc_server_description_t *)item;
int32_t *current_min = (int32_t *)ctx;
if (sd->max_msg_size < *current_min) {
*current_min = sd->max_msg_size;
}
return true;
}
static bool
_mongoc_cluster_min_of_max_msg_size_nodes (void *item,
void *ctx)
{
mongoc_cluster_node_t *node = (mongoc_cluster_node_t *)item;
int32_t *current_min = (int32_t *)ctx;
if (node->max_msg_size < *current_min) {
*current_min = node->max_msg_size;
}
return true;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_get_max_bson_obj_size --
*
* Return the minimum max_bson_obj_size across all servers in cluster.
*
* NOTE: this method uses the topology's mutex.
*
* Returns:
* The minimum max_bson_obj_size.
*
* Side effects:
* None
*
*--------------------------------------------------------------------------
*/
int32_t
mongoc_cluster_get_max_bson_obj_size (mongoc_cluster_t *cluster)
{
int32_t max_bson_obj_size = -1;
max_bson_obj_size = MONGOC_DEFAULT_BSON_OBJ_SIZE;
if (!cluster->client->topology->single_threaded) {
mongoc_set_for_each (cluster->nodes,
_mongoc_cluster_min_of_max_obj_size_nodes,
&max_bson_obj_size);
} else {
mongoc_set_for_each (cluster->client->topology->description.servers,
_mongoc_cluster_min_of_max_obj_size_sds,
&max_bson_obj_size);
}
return max_bson_obj_size;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_get_max_msg_size --
*
* Return the minimum max msg size across all servers in cluster.
*
* NOTE: this method uses the topology's mutex.
*
* Returns:
* The minimum max_msg_size
*
* Side effects:
* None
*
*--------------------------------------------------------------------------
*/
int32_t
mongoc_cluster_get_max_msg_size (mongoc_cluster_t *cluster)
{
int32_t max_msg_size = MONGOC_DEFAULT_MAX_MSG_SIZE;
if (!cluster->client->topology->single_threaded) {
mongoc_set_for_each (cluster->nodes,
_mongoc_cluster_min_of_max_msg_size_nodes,
&max_msg_size);
} else {
mongoc_set_for_each (cluster->client->topology->description.servers,
_mongoc_cluster_min_of_max_msg_size_sds,
&max_msg_size);
}
return max_msg_size;
}
static bool
_mongoc_cluster_check_interval (mongoc_cluster_t *cluster,
uint32_t server_id,
bson_error_t *error)
{
mongoc_topology_t *topology;
mongoc_topology_scanner_node_t *scanner_node;
mongoc_stream_t *stream;
int64_t now;
int64_t before_ismaster;
bson_t command;
bson_t reply;
bool r = true;
topology = cluster->client->topology;
if (!topology->single_threaded) {
return true;
}
scanner_node =
mongoc_topology_scanner_get_node (topology->scanner, server_id);
if (!scanner_node) {
return false;
}
BSON_ASSERT (!scanner_node->retired);
stream = scanner_node->stream;
if (!stream) {
return false;
}
now = bson_get_monotonic_time ();
if (scanner_node->last_used + (1000 * CHECK_CLOSED_DURATION_MSEC) < now) {
if (mongoc_stream_check_closed (stream)) {
mongoc_cluster_disconnect_node (cluster, server_id);
bson_set_error (error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET,
"Stream is closed");
return false;
}
}
if (scanner_node->last_used + (1000 * cluster->socketcheckintervalms) <
now) {
bson_init (&command);
BSON_APPEND_INT32 (&command, "ismaster", 1);
before_ismaster = now;
r = mongoc_cluster_run_command (cluster, stream, server_id,
MONGOC_QUERY_SLAVE_OK, "admin", &command,
&reply, error);
now = bson_get_monotonic_time ();
bson_destroy (&command);
mongoc_topology_description_handle_ismaster (
&topology->description, server_id, &reply,
(now - before_ismaster) / 1000, /* RTT_MS */
error);
bson_destroy (&reply);
}
return r;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_sendv_to_server --
*
* Sends the given RPCs to the given server.
*
* Returns:
* True if successful.
*
* Side effects:
* @rpcs may be mutated and should be considered invalid after calling
* this method.
*
* @error may be set.
*
*--------------------------------------------------------------------------
*/
bool
mongoc_cluster_sendv_to_server (mongoc_cluster_t *cluster,
mongoc_rpc_t *rpcs,
size_t rpcs_len,
mongoc_server_stream_t *server_stream,
const mongoc_write_concern_t *write_concern,
bson_error_t *error)
{
uint32_t server_id;
mongoc_iovec_t *iov;
mongoc_topology_scanner_node_t *scanner_node;
const bson_t *b;
mongoc_rpc_t gle;
size_t iovcnt;
size_t i;
bool need_gle;
char cmdname[140];
int32_t max_msg_size;
ENTRY;
BSON_ASSERT (cluster);
BSON_ASSERT (rpcs);
BSON_ASSERT (rpcs_len);
BSON_ASSERT (server_stream);
server_id = server_stream->sd->id;
if (cluster->client->in_exhaust) {
bson_set_error(error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_IN_EXHAUST,
"A cursor derived from this client is in exhaust.");
RETURN(false);
}
if (! write_concern) {
write_concern = cluster->client->write_concern;
}
if (!_mongoc_cluster_check_interval (cluster,
server_stream->sd->id,
error)) {
RETURN (false);
}
_mongoc_array_clear(&cluster->iov);
/*
* TODO: We can probably remove the need for sendv and just do send since
* we support write concerns now. Also, we clobber our getlasterror on
* each subsequent mutation. It's okay, since it comes out correct anyway,
* just useless work (and technically the request_id changes).
*/
for (i = 0; i < rpcs_len; i++) {
_mongoc_cluster_inc_egress_rpc (&rpcs[i]);
need_gle = _mongoc_rpc_needs_gle(&rpcs[i], write_concern);
_mongoc_rpc_gather (&rpcs[i], &cluster->iov);
max_msg_size = mongoc_server_stream_max_msg_size (server_stream);
if (rpcs[i].header.msg_len > max_msg_size) {
bson_set_error(error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_TOO_BIG,
"Attempted to send an RPC larger than the "
"max allowed message size. Was %u, allowed %u.",
rpcs[i].header.msg_len,
max_msg_size);
RETURN(false);
}
if (need_gle) {
gle.query.msg_len = 0;
gle.query.request_id = ++cluster->request_id;
gle.query.response_to = 0;
gle.query.opcode = MONGOC_OPCODE_QUERY;
gle.query.flags = MONGOC_QUERY_NONE;
switch (rpcs[i].header.opcode) {
case MONGOC_OPCODE_INSERT:
DB_AND_CMD_FROM_COLLECTION(cmdname, rpcs[i].insert.collection);
break;
case MONGOC_OPCODE_DELETE:
DB_AND_CMD_FROM_COLLECTION(cmdname, rpcs[i].delete_.collection);
break;
case MONGOC_OPCODE_UPDATE:
DB_AND_CMD_FROM_COLLECTION(cmdname, rpcs[i].update.collection);
break;
default:
BSON_ASSERT(false);
DB_AND_CMD_FROM_COLLECTION(cmdname, "admin.$cmd");
break;
}
gle.query.collection = cmdname;
gle.query.skip = 0;
gle.query.n_return = 1;
b = _mongoc_write_concern_get_gle((mongoc_write_concern_t *)write_concern);
gle.query.query = bson_get_data(b);
gle.query.fields = NULL;
_mongoc_rpc_gather(&gle, &cluster->iov);
_mongoc_rpc_swab_to_le(&gle);
}
_mongoc_rpc_swab_to_le(&rpcs[i]);
}
iov = (mongoc_iovec_t *)cluster->iov.data;
iovcnt = cluster->iov.len;
BSON_ASSERT (cluster->iov.len);
if (!_mongoc_stream_writev_full (server_stream->stream, iov, iovcnt,
cluster->sockettimeoutms, error)) {
RETURN (false);
}
if (cluster->client->topology->single_threaded) {
scanner_node =
mongoc_topology_scanner_get_node (cluster->client->topology->scanner,
server_id);
if (scanner_node) {
scanner_node->last_used = bson_get_monotonic_time ();
}
}
RETURN (true);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cluster_try_recv --
*
* Tries to receive the next event from the MongoDB server.
* The contents are loaded into @buffer and then
* scattered into the @rpc structure. @rpc is valid as long as
* @buffer contains the contents read into it.
*
* Callers that can optimize a reuse of @buffer should do so. It
* can save many memory allocations.
*
* Returns:
* True if successful.
*
* Side effects:
* @rpc is set on success, @error on failure.
* @buffer will be filled with the input data.
*
*--------------------------------------------------------------------------
*/
bool
mongoc_cluster_try_recv (mongoc_cluster_t *cluster,
mongoc_rpc_t *rpc,
mongoc_buffer_t *buffer,
mongoc_server_stream_t *server_stream,
bson_error_t *error)
{
uint32_t server_id;
int32_t msg_len;
int32_t max_msg_size;
off_t pos;
ENTRY;
BSON_ASSERT (cluster);
BSON_ASSERT (rpc);
BSON_ASSERT (buffer);
BSON_ASSERT (server_stream);
server_id = server_stream->sd->id;
TRACE ("Waiting for reply from server_id \"%u\"", server_id);
/*
* Buffer the message length to determine how much more to read.
*/
pos = buffer->len;
if (!_mongoc_buffer_append_from_stream (buffer, server_stream->stream, 4,
cluster->sockettimeoutms, error)) {
MONGOC_DEBUG("Could not read 4 bytes, stream probably closed or timed out");
mongoc_counter_protocol_ingress_error_inc ();
mongoc_cluster_disconnect_node(cluster, server_id);
RETURN (false);
}
/*
* Read the msg length from the buffer.
*/
memcpy (&msg_len, &buffer->data[buffer->off + pos], 4);
msg_len = BSON_UINT32_FROM_LE (msg_len);
max_msg_size = mongoc_server_stream_max_msg_size (server_stream);
if ((msg_len < 16) || (msg_len > max_msg_size)) {
bson_set_error (error,
MONGOC_ERROR_PROTOCOL,
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
"Corrupt or malicious reply received.");
mongoc_cluster_disconnect_node(cluster, server_id);
mongoc_counter_protocol_ingress_error_inc ();
RETURN (false);
}
/*
* Read the rest of the message from the stream.
*/
if (!_mongoc_buffer_append_from_stream (buffer, server_stream->stream,
msg_len - 4,
cluster->sockettimeoutms, error)) {
mongoc_cluster_disconnect_node (cluster, server_id);
mongoc_counter_protocol_ingress_error_inc ();
RETURN (false);
}
/*
* Scatter the buffer into the rpc structure.
*/
if (!_mongoc_rpc_scatter (rpc, &buffer->data[buffer->off + pos], msg_len)) {
bson_set_error (error,
MONGOC_ERROR_PROTOCOL,
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
"Failed to decode reply from server.");
mongoc_cluster_disconnect_node (cluster, server_id);
mongoc_counter_protocol_ingress_error_inc ();
RETURN (false);
}
_mongoc_rpc_swab_from_le (rpc);
_mongoc_cluster_inc_ingress_rpc (rpc);
RETURN(true);
}
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-collection-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-collection-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-collection-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-collection-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-collection.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-collection.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-collection.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-collection.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-collection.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-collection.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-collection.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-collection.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-config.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-config.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-config.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-config.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-config.h.in b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-config.h.in
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-config.h.in
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-config.h.in
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-counters-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-counters-private.h
similarity index 95%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-counters-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-counters-private.h
index 7a77d029..4b41aece 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-counters-private.h
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-counters-private.h
@@ -1,171 +1,174 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MONGOC_COUNTERS_PRIVATE_H
#define MONGOC_COUNTERS_PRIVATE_H
#if !defined (MONGOC_COMPILATION)
#error "Only <mongoc.h> can be included directly."
#endif
#include <bson.h>
#ifdef __linux__
# include <sched.h>
# include <sys/sysinfo.h>
#elif defined(__FreeBSD__) || \
defined(__NetBSD__) || \
defined(__DragonFly__) || \
defined(__OpenBSD__)
# include <sys/types.h>
# include <sys/sysctl.h>
# include <sys/param.h>
#endif
BSON_BEGIN_DECLS
void _mongoc_counters_init (void);
void _mongoc_counters_cleanup (void);
static BSON_INLINE unsigned
_mongoc_get_cpu_count (void)
{
#if defined(__linux__)
return get_nprocs ();
#elif defined(__FreeBSD__) || \
defined(__NetBSD__) || \
defined(__DragonFly__) || \
defined(__OpenBSD__)
int mib[2];
int maxproc;
size_t len;
mib[0] = CTL_HW;
mib[1] = HW_NCPU;
len = sizeof (maxproc);
if (-1 == sysctl (mib, 2, &maxproc, &len, NULL, 0)) {
return 1;
}
return len;
#elif defined(__APPLE__) || defined(__sun)
int ncpu;
ncpu = (int) sysconf (_SC_NPROCESSORS_ONLN);
return (ncpu > 0) ? ncpu : 1;
#elif defined(_MSC_VER) || defined(_WIN32)
SYSTEM_INFO si;
GetSystemInfo (&si);
return si.dwNumberOfProcessors;
#else
# warning "_mongoc_get_cpu_count() not supported, defaulting to 1."
return 1;
#endif
}
#define _mongoc_counter_add(v,count) \
bson_atomic_int64_add(&(v), (count))
#if defined(ENABLE_RDTSCP)
static BSON_INLINE unsigned
_mongoc_sched_getcpu (void)
{
- volatile uint32_t rax, rdx, aux;
- __asm__ volatile ("rdtscp\n" : "=a" (rax), "=d" (rdx), "=c" (aux) : : );
- return aux;
+ volatile uint32_t rax, rdx, rcx;
+ __asm__ volatile ("rdtscp\n" : "=a" (rax), "=d" (rdx), "=c" (rcx) : : );
+ unsigned node_id, core_id;
+ // node_id = (rcx & 0xFFF000)>>12; // node_id is unused
+ core_id = rcx & 0xFFF;
+ return core_id;
}
#elif defined(HAVE_SCHED_GETCPU)
# define _mongoc_sched_getcpu sched_getcpu
#else
# define _mongoc_sched_getcpu() (0)
#endif
#ifndef SLOTS_PER_CACHELINE
# define SLOTS_PER_CACHELINE 8
#endif
typedef struct
{
int64_t slots [SLOTS_PER_CACHELINE];
} mongoc_counter_slots_t;
typedef struct
{
mongoc_counter_slots_t *cpus;
} mongoc_counter_t;
#define COUNTER(ident, Category, Name, Description) \
extern mongoc_counter_t __mongoc_counter_##ident;
#include "mongoc-counters.defs"
#undef COUNTER
enum
{
#define COUNTER(ident, Category, Name, Description) \
COUNTER_##ident,
#include "mongoc-counters.defs"
#undef COUNTER
LAST_COUNTER
};
#define COUNTER(ident, Category, Name, Description) \
static BSON_INLINE void \
mongoc_counter_##ident##_add (int64_t val) \
{ \
_mongoc_counter_add(\
__mongoc_counter_##ident.cpus[_mongoc_sched_getcpu()].slots[ \
COUNTER_##ident%SLOTS_PER_CACHELINE], val); \
} \
static BSON_INLINE void \
mongoc_counter_##ident##_inc (void) \
{ \
mongoc_counter_##ident##_add (1); \
} \
static BSON_INLINE void \
mongoc_counter_##ident##_dec (void) \
{ \
mongoc_counter_##ident##_add (-1); \
} \
static BSON_INLINE void \
mongoc_counter_##ident##_reset (void) \
{ \
uint32_t i; \
for (i = 0; i < _mongoc_get_cpu_count(); i++) { \
__mongoc_counter_##ident.cpus [i].slots [\
COUNTER_##ident%SLOTS_PER_CACHELINE] = 0; \
} \
bson_memory_barrier (); \
}
#include "mongoc-counters.defs"
#undef COUNTER
BSON_END_DECLS
#endif /* MONGOC_COUNTERS_PRIVATE_H */
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-counters.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-counters.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-counters.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-counters.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-counters.defs b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-counters.defs
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-counters.defs
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-counters.defs
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-cng-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-cng-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-cng-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-cng-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-cng.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-cng.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-cng.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-cng.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-cng.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-cng.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-cng.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-cng.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-common-crypto.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-openssl-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-openssl-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-openssl-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-openssl-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-openssl.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-openssl.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-openssl.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-openssl.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-crypto.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-crypto.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-array-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-array-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-array-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-array-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-array.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-array.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-array.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-array.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-cursorid-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-cursorid-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-cursorid-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-cursorid-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-cursorid.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-cursorid.c
similarity index 96%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-cursorid.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-cursorid.c
index 3e2b8869..fbc0b80c 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-cursorid.c
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-cursorid.c
@@ -1,386 +1,386 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mongoc-cursor.h"
#include "mongoc-cursor-private.h"
#include "mongoc-cursor-cursorid-private.h"
#include "mongoc-log.h"
#include "mongoc-trace-private.h"
#include "mongoc-error.h"
#include "mongoc-util-private.h"
#include "mongoc-client-private.h"
#undef MONGOC_LOG_DOMAIN
#define MONGOC_LOG_DOMAIN "cursor-cursorid"
static void *
_mongoc_cursor_cursorid_new (void)
{
mongoc_cursor_cursorid_t *cid;
ENTRY;
cid = (mongoc_cursor_cursorid_t *) bson_malloc0 (sizeof *cid);
bson_init (&cid->array);
cid->in_batch = false;
cid->in_reader = false;
RETURN (cid);
}
static void
_mongoc_cursor_cursorid_destroy (mongoc_cursor_t *cursor)
{
mongoc_cursor_cursorid_t *cid;
ENTRY;
cid = (mongoc_cursor_cursorid_t *)cursor->iface_data;
BSON_ASSERT (cid);
bson_destroy (&cid->array);
bson_free (cid);
_mongoc_cursor_destroy (cursor);
EXIT;
}
/*
* Start iterating the reply to an "aggregate", "find", "getMore" etc. command:
*
* {cursor: {id: 1234, ns: "db.collection", firstBatch: [...]}}
*/
bool
_mongoc_cursor_cursorid_start_batch (mongoc_cursor_t *cursor)
{
mongoc_cursor_cursorid_t *cid;
bson_iter_t iter;
bson_iter_t child;
const char *ns;
uint32_t nslen;
cid = (mongoc_cursor_cursorid_t *)cursor->iface_data;
BSON_ASSERT (cid);
if (bson_iter_init_find (&iter, &cid->array, "cursor") &&
BSON_ITER_HOLDS_DOCUMENT (&iter) &&
bson_iter_recurse (&iter, &child)) {
while (bson_iter_next (&child)) {
if (BSON_ITER_IS_KEY (&child, "id")) {
cursor->rpc.reply.cursor_id = bson_iter_as_int64 (&child);
} else if (BSON_ITER_IS_KEY (&child, "ns")) {
ns = bson_iter_utf8 (&child, &nslen);
_mongoc_set_cursor_ns (cursor, ns, nslen);
} else if (BSON_ITER_IS_KEY (&child, "firstBatch") ||
BSON_ITER_IS_KEY (&child, "nextBatch")) {
if (BSON_ITER_HOLDS_ARRAY (&child) &&
bson_iter_recurse (&child, &cid->batch_iter)) {
cid->in_batch = true;
}
}
}
}
return cid->in_batch;
}
static bool
_mongoc_cursor_cursorid_refresh_from_command (mongoc_cursor_t *cursor,
const bson_t *command)
{
mongoc_cursor_cursorid_t *cid;
ENTRY;
cid = (mongoc_cursor_cursorid_t *)cursor->iface_data;
BSON_ASSERT (cid);
bson_destroy (&cid->array);
/* server replies to find / aggregate with {cursor: {id: N, firstBatch: []}},
* to getMore command with {cursor: {id: N, nextBatch: []}}. */
if (_mongoc_cursor_run_command (cursor, command, &cid->array) &&
_mongoc_cursor_cursorid_start_batch (cursor)) {
RETURN (true);
} else {
if (!cursor->error.domain) {
bson_set_error (&cursor->error,
MONGOC_ERROR_PROTOCOL,
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
"Invalid reply to %s command.",
_mongoc_get_command_name (command));
}
RETURN (false);
}
}
static void
_mongoc_cursor_cursorid_read_from_batch (mongoc_cursor_t *cursor,
const bson_t **bson)
{
mongoc_cursor_cursorid_t *cid;
const uint8_t *data = NULL;
uint32_t data_len = 0;
ENTRY;
cid = (mongoc_cursor_cursorid_t *)cursor->iface_data;
BSON_ASSERT (cid);
if (bson_iter_next (&cid->batch_iter) &&
BSON_ITER_HOLDS_DOCUMENT (&cid->batch_iter)) {
bson_iter_document (&cid->batch_iter, &data_len, &data);
if (bson_init_static (&cid->current_doc, data, data_len)) {
*bson = &cid->current_doc;
}
}
}
bool
_mongoc_cursor_cursorid_prime (mongoc_cursor_t *cursor)
{
cursor->sent = true;
cursor->operation_id = ++cursor->client->cluster.operation_id;
return _mongoc_cursor_cursorid_refresh_from_command (cursor,
&cursor->filter);
}
bool
_mongoc_cursor_prepare_getmore_command (mongoc_cursor_t *cursor,
bson_t *command)
{
const char *collection;
int collection_len;
int64_t batch_size;
bool await_data;
int32_t max_await_time_ms;
ENTRY;
_mongoc_cursor_collection (cursor, &collection, &collection_len);
bson_init (command);
bson_append_int64 (command, "getMore", 7, mongoc_cursor_get_id (cursor));
bson_append_utf8 (command, "collection", 10, collection, collection_len);
batch_size = mongoc_cursor_get_batch_size (cursor);
/* See find, getMore, and killCursors Spec for batchSize rules */
if (batch_size) {
- bson_append_int64 (command, BATCH_SIZE, BATCH_SIZE_LEN,
+ bson_append_int64 (command, MONGOC_CURSOR_BATCH_SIZE, MONGOC_CURSOR_BATCH_SIZE_LEN,
abs (_mongoc_n_return (cursor)));
}
/* Find, getMore And killCursors Commands Spec: "In the case of a tailable
cursor with awaitData == true the driver MUST provide a Cursor level
option named maxAwaitTimeMS (See CRUD specification for details). The
maxTimeMS option on the getMore command MUST be set to the value of the
option maxAwaitTimeMS. If no maxAwaitTimeMS is specified, the driver
SHOULD not set maxTimeMS on the getMore command."
*/
- await_data = _mongoc_cursor_get_opt_bool (cursor, TAILABLE) &&
- _mongoc_cursor_get_opt_bool (cursor, AWAIT_DATA);
+ await_data = _mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_TAILABLE) &&
+ _mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_AWAIT_DATA);
if (await_data) {
max_await_time_ms = (int32_t) mongoc_cursor_get_max_await_time_ms (cursor);
if (max_await_time_ms) {
- bson_append_int32 (command, MAX_TIME_MS, MAX_TIME_MS_LEN,
+ bson_append_int32 (command, MONGOC_CURSOR_MAX_TIME_MS, MONGOC_CURSOR_MAX_TIME_MS_LEN,
max_await_time_ms);
}
}
RETURN (true);
}
static bool
_mongoc_cursor_cursorid_get_more (mongoc_cursor_t *cursor)
{
mongoc_cursor_cursorid_t *cid;
mongoc_server_stream_t *server_stream;
bson_t command;
bool ret;
ENTRY;
cid = (mongoc_cursor_cursorid_t *)cursor->iface_data;
BSON_ASSERT (cid);
server_stream = _mongoc_cursor_fetch_stream (cursor);
if (!server_stream) {
RETURN (false);
}
if (_use_find_command (cursor, server_stream)) {
if (!_mongoc_cursor_prepare_getmore_command (cursor, &command)) {
mongoc_server_stream_cleanup (server_stream);
RETURN (false);
}
ret = _mongoc_cursor_cursorid_refresh_from_command (cursor, &command);
bson_destroy (&command);
} else {
ret = _mongoc_cursor_op_getmore (cursor, server_stream);
cid->in_reader = ret;
}
mongoc_server_stream_cleanup (server_stream);
RETURN (ret);
}
bool
_mongoc_cursor_cursorid_next (mongoc_cursor_t *cursor,
const bson_t **bson)
{
mongoc_cursor_cursorid_t *cid;
bool refreshed = false;
ENTRY;
*bson = NULL;
cid = (mongoc_cursor_cursorid_t *)cursor->iface_data;
BSON_ASSERT (cid);
if (!cursor->sent) {
if (!_mongoc_cursor_cursorid_prime (cursor)) {
GOTO (done);
}
}
again:
/* Two paths:
* - Mongo 3.2+, sent "getMore" cmd, we're reading reply's "nextBatch" array
* - Mongo 2.6 to 3, after "aggregate" or similar command we sent OP_GETMORE,
* we're reading the raw reply
*/
if (cid->in_batch) {
_mongoc_cursor_cursorid_read_from_batch (cursor, bson);
if (*bson) {
GOTO (done);
}
cid->in_batch = false;
} else if (cid->in_reader) {
_mongoc_read_from_buffer (cursor, bson);
if (*bson) {
GOTO (done);
}
cid->in_reader = false;
}
if (!refreshed && mongoc_cursor_get_id (cursor)) {
if (!_mongoc_cursor_cursorid_get_more (cursor)) {
GOTO (done);
}
refreshed = true;
GOTO (again);
}
done:
if (!*bson && mongoc_cursor_get_id (cursor) == 0) {
cursor->done = 1;
}
RETURN (*bson != NULL);
}
static mongoc_cursor_t *
_mongoc_cursor_cursorid_clone (const mongoc_cursor_t *cursor)
{
mongoc_cursor_t *clone_;
ENTRY;
clone_ = _mongoc_cursor_clone (cursor);
_mongoc_cursor_cursorid_init (clone_, &cursor->filter);
RETURN (clone_);
}
static mongoc_cursor_interface_t gMongocCursorCursorid = {
_mongoc_cursor_cursorid_clone,
_mongoc_cursor_cursorid_destroy,
NULL,
_mongoc_cursor_cursorid_next,
};
void
_mongoc_cursor_cursorid_init (mongoc_cursor_t *cursor,
const bson_t *command)
{
ENTRY;
bson_destroy (&cursor->filter);
bson_copy_to (command, &cursor->filter);
cursor->iface_data = _mongoc_cursor_cursorid_new ();
memcpy (&cursor->iface, &gMongocCursorCursorid,
sizeof (mongoc_cursor_interface_t));
EXIT;
}
void
_mongoc_cursor_cursorid_init_with_reply (mongoc_cursor_t *cursor,
bson_t *reply,
uint32_t server_id)
{
mongoc_cursor_cursorid_t *cid;
cursor->sent = true;
cursor->server_id = server_id;
cid = (mongoc_cursor_cursorid_t *)cursor->iface_data;
BSON_ASSERT (cid);
bson_destroy (&cid->array);
if (!bson_steal (&cid->array, reply)) {
bson_steal (&cid->array, bson_copy (reply));
}
if (!_mongoc_cursor_cursorid_start_batch (cursor)) {
bson_set_error (&cursor->error,
MONGOC_ERROR_CURSOR,
MONGOC_ERROR_CURSOR_INVALID_CURSOR,
"Couldn't parse cursor document");
}
}
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-private.h
similarity index 75%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-private.h
index 554ab7fa..6603902f 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-private.h
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-private.h
@@ -1,204 +1,204 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MONGOC_CURSOR_PRIVATE_H
#define MONGOC_CURSOR_PRIVATE_H
#if !defined (MONGOC_COMPILATION)
#error "Only <mongoc.h> can be included directly."
#endif
#include <bson.h>
#include "mongoc-client.h"
#include "mongoc-buffer-private.h"
#include "mongoc-rpc-private.h"
#include "mongoc-server-stream-private.h"
BSON_BEGIN_DECLS
typedef struct _mongoc_cursor_interface_t mongoc_cursor_interface_t;
struct _mongoc_cursor_interface_t
{
mongoc_cursor_t *(*clone) (const mongoc_cursor_t *cursor);
void (*destroy) (mongoc_cursor_t *cursor);
bool (*more) (mongoc_cursor_t *cursor);
bool (*next) (mongoc_cursor_t *cursor,
const bson_t **bson);
bool (*error) (mongoc_cursor_t *cursor,
bson_error_t *error);
void (*get_host) (mongoc_cursor_t *cursor,
mongoc_host_list_t *host);
};
-#define ALLOW_PARTIAL_RESULTS "allowPartialResults"
-#define ALLOW_PARTIAL_RESULTS_LEN 19
-#define AWAIT_DATA "awaitData"
-#define AWAIT_DATA_LEN 9
-#define BATCH_SIZE "batchSize"
-#define BATCH_SIZE_LEN 9
-#define COLLATION "collation"
-#define COLLATION_LEN 9
-#define COMMENT "comment"
-#define COMMENT_LEN 7
-#define EXHAUST "exhaust"
-#define EXHAUST_LEN 7
-#define FILTER "filter"
-#define FILTER_LEN 6
-#define FIND "find"
-#define FIND_LEN 4
-#define HINT "hint"
-#define HINT_LEN 4
-#define LIMIT "limit"
-#define LIMIT_LEN 5
-#define MAX "max"
-#define MAX_LEN 3
-#define MAX_AWAIT_TIME_MS "maxAwaitTimeMS"
-#define MAX_AWAIT_TIME_MS_LEN 14
-#define MAX_SCAN "maxScan"
-#define MAX_SCAN_LEN 7
-#define MAX_TIME_MS "maxTimeMS"
-#define MAX_TIME_MS_LEN 9
-#define MIN "min"
-#define MIN_LEN 3
-#define NO_CURSOR_TIMEOUT "noCursorTimeout"
-#define NO_CURSOR_TIMEOUT_LEN 15
-#define OPLOG_REPLAY "oplogReplay"
-#define OPLOG_REPLAY_LEN 11
-#define ORDERBY "orderby"
-#define ORDERBY_LEN 7
-#define PROJECTION "projection"
-#define PROJECTION_LEN 10
-#define QUERY "query"
-#define QUERY_LEN 5
-#define READ_CONCERN "readConcern"
-#define READ_CONCERN_LEN 11
-#define RETURN_KEY "returnKey"
-#define RETURN_KEY_LEN 9
-#define SHOW_DISK_LOC "showDiskLoc"
-#define SHOW_DISK_LOC_LEN 11
-#define SHOW_RECORD_ID "showRecordId"
-#define SHOW_RECORD_ID_LEN 12
-#define SINGLE_BATCH "singleBatch"
-#define SINGLE_BATCH_LEN 11
-#define SKIP "skip"
-#define SKIP_LEN 4
-#define SNAPSHOT "snapshot"
-#define SNAPSHOT_LEN 8
-#define SORT "sort"
-#define SORT_LEN 4
-#define TAILABLE "tailable"
-#define TAILABLE_LEN 8
+#define MONGOC_CURSOR_ALLOW_PARTIAL_RESULTS "allowPartialResults"
+#define MONGOC_CURSOR_ALLOW_PARTIAL_RESULTS_LEN 19
+#define MONGOC_CURSOR_AWAIT_DATA "awaitData"
+#define MONGOC_CURSOR_AWAIT_DATA_LEN 9
+#define MONGOC_CURSOR_BATCH_SIZE "batchSize"
+#define MONGOC_CURSOR_BATCH_SIZE_LEN 9
+#define MONGOC_CURSOR_COLLATION "collation"
+#define MONGOC_CURSOR_COLLATION_LEN 9
+#define MONGOC_CURSOR_COMMENT "comment"
+#define MONGOC_CURSOR_COMMENT_LEN 7
+#define MONGOC_CURSOR_EXHAUST "exhaust"
+#define MONGOC_CURSOR_EXHAUST_LEN 7
+#define MONGOC_CURSOR_FILTER "filter"
+#define MONGOC_CURSOR_FILTER_LEN 6
+#define MONGOC_CURSOR_FIND "find"
+#define MONGOC_CURSOR_FIND_LEN 4
+#define MONGOC_CURSOR_HINT "hint"
+#define MONGOC_CURSOR_HINT_LEN 4
+#define MONGOC_CURSOR_LIMIT "limit"
+#define MONGOC_CURSOR_LIMIT_LEN 5
+#define MONGOC_CURSOR_MAX "max"
+#define MONGOC_CURSOR_MAX_LEN 3
+#define MONGOC_CURSOR_MAX_AWAIT_TIME_MS "maxAwaitTimeMS"
+#define MONGOC_CURSOR_MAX_AWAIT_TIME_MS_LEN 14
+#define MONGOC_CURSOR_MAX_SCAN "maxScan"
+#define MONGOC_CURSOR_MAX_SCAN_LEN 7
+#define MONGOC_CURSOR_MAX_TIME_MS "maxTimeMS"
+#define MONGOC_CURSOR_MAX_TIME_MS_LEN 9
+#define MONGOC_CURSOR_MIN "min"
+#define MONGOC_CURSOR_MIN_LEN 3
+#define MONGOC_CURSOR_NO_CURSOR_TIMEOUT "noCursorTimeout"
+#define MONGOC_CURSOR_NO_CURSOR_TIMEOUT_LEN 15
+#define MONGOC_CURSOR_OPLOG_REPLAY "oplogReplay"
+#define MONGOC_CURSOR_OPLOG_REPLAY_LEN 11
+#define MONGOC_CURSOR_ORDERBY "orderby"
+#define MONGOC_CURSOR_ORDERBY_LEN 7
+#define MONGOC_CURSOR_PROJECTION "projection"
+#define MONGOC_CURSOR_PROJECTION_LEN 10
+#define MONGOC_CURSOR_QUERY "query"
+#define MONGOC_CURSOR_QUERY_LEN 5
+#define MONGOC_CURSOR_READ_CONCERN "readConcern"
+#define MONGOC_CURSOR_READ_CONCERN_LEN 11
+#define MONGOC_CURSOR_RETURN_KEY "returnKey"
+#define MONGOC_CURSOR_RETURN_KEY_LEN 9
+#define MONGOC_CURSOR_SHOW_DISK_LOC "showDiskLoc"
+#define MONGOC_CURSOR_SHOW_DISK_LOC_LEN 11
+#define MONGOC_CURSOR_SHOW_RECORD_ID "showRecordId"
+#define MONGOC_CURSOR_SHOW_RECORD_ID_LEN 12
+#define MONGOC_CURSOR_SINGLE_BATCH "singleBatch"
+#define MONGOC_CURSOR_SINGLE_BATCH_LEN 11
+#define MONGOC_CURSOR_SKIP "skip"
+#define MONGOC_CURSOR_SKIP_LEN 4
+#define MONGOC_CURSOR_SNAPSHOT "snapshot"
+#define MONGOC_CURSOR_SNAPSHOT_LEN 8
+#define MONGOC_CURSOR_SORT "sort"
+#define MONGOC_CURSOR_SORT_LEN 4
+#define MONGOC_CURSOR_TAILABLE "tailable"
+#define MONGOC_CURSOR_TAILABLE_LEN 8
struct _mongoc_cursor_t
{
mongoc_client_t *client;
uint32_t server_id;
bool server_id_set;
bool slave_ok;
unsigned is_command : 1;
unsigned sent : 1;
unsigned done : 1;
unsigned end_of_event : 1;
unsigned has_fields : 1;
unsigned in_exhaust : 1;
bson_t filter;
bson_t opts;
mongoc_read_concern_t *read_concern;
mongoc_read_prefs_t *read_prefs;
mongoc_write_concern_t *write_concern;
uint32_t count;
char ns [140];
uint32_t nslen;
uint32_t dblen;
bson_error_t error;
/* for OP_QUERY and OP_GETMORE replies*/
mongoc_rpc_t rpc;
mongoc_buffer_t buffer;
bson_reader_t *reader;
const bson_t *current;
mongoc_cursor_interface_t iface;
void *iface_data;
int64_t operation_id;
};
int32_t _mongoc_n_return (mongoc_cursor_t *cursor);
void _mongoc_set_cursor_ns (mongoc_cursor_t *cursor,
const char *ns,
uint32_t nslen);
bool _mongoc_cursor_get_opt_bool (const mongoc_cursor_t *cursor,
const char *option);
mongoc_cursor_t *_mongoc_cursor_new_with_opts (mongoc_client_t *client,
const char *db_and_collection,
bool is_command,
const bson_t *filter,
const bson_t *opts,
const mongoc_read_prefs_t *read_prefs,
const mongoc_read_concern_t *read_concern);
mongoc_cursor_t *_mongoc_cursor_new (mongoc_client_t *client,
const char *db_and_collection,
mongoc_query_flags_t flags,
uint32_t skip,
int32_t limit,
uint32_t batch_size,
bool is_command,
const bson_t *query,
const bson_t *fields,
const mongoc_read_prefs_t *read_prefs,
const mongoc_read_concern_t *read_concern);
mongoc_cursor_t *_mongoc_cursor_clone (const mongoc_cursor_t *cursor);
void _mongoc_cursor_destroy (mongoc_cursor_t *cursor);
bool _mongoc_read_from_buffer (mongoc_cursor_t *cursor,
const bson_t **bson);
bool _use_find_command (const mongoc_cursor_t *cursor,
const mongoc_server_stream_t *server_stream);
mongoc_server_stream_t * _mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor);
void _mongoc_cursor_collection (const mongoc_cursor_t *cursor,
const char **collection,
int *collection_len);
bool _mongoc_cursor_op_getmore (mongoc_cursor_t *cursor,
mongoc_server_stream_t *server_stream);
bool _mongoc_cursor_run_command (mongoc_cursor_t *cursor,
const bson_t *command,
bson_t *reply);
bool _mongoc_cursor_more (mongoc_cursor_t *cursor);
bool _mongoc_cursor_next (mongoc_cursor_t *cursor,
const bson_t **bson);
bool _mongoc_cursor_error (mongoc_cursor_t *cursor,
bson_error_t *error);
void _mongoc_cursor_get_host (mongoc_cursor_t *cursor,
mongoc_host_list_t *host);
BSON_END_DECLS
#endif /* MONGOC_CURSOR_PRIVATE_H */
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-transform-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-transform-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-transform-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-transform-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-transform.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-transform.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor-transform.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor-transform.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor.c
similarity index 90%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor.c
index 6c617089..700b60a0 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor.c
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor.c
@@ -1,2158 +1,2115 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mongoc-cursor.h"
#include "mongoc-cursor-private.h"
#include "mongoc-client-private.h"
#include "mongoc-counters-private.h"
#include "mongoc-error.h"
#include "mongoc-log.h"
#include "mongoc-trace-private.h"
#include "mongoc-cursor-cursorid-private.h"
#include "mongoc-read-concern-private.h"
#include "mongoc-util-private.h"
#include "mongoc-write-concern-private.h"
#undef MONGOC_LOG_DOMAIN
#define MONGOC_LOG_DOMAIN "cursor"
#define CURSOR_FAILED(cursor_) ((cursor_)->error.domain != 0)
static bool
_translate_query_opt (const char *query_field,
const char **cmd_field,
int *len);
static const bson_t *
_mongoc_cursor_op_query (mongoc_cursor_t *cursor,
mongoc_server_stream_t *server_stream);
static bool
_mongoc_cursor_prepare_find_command (mongoc_cursor_t *cursor,
bson_t *command,
mongoc_server_stream_t *server_stream);
static const bson_t *
_mongoc_cursor_find_command (mongoc_cursor_t *cursor,
mongoc_server_stream_t *server_stream);
static bool
_mongoc_cursor_set_opt_int64 (mongoc_cursor_t *cursor,
const char *option,
int64_t value)
{
bson_iter_t iter;
if (bson_iter_init_find (&iter, &cursor->opts, option)) {
if (!BSON_ITER_HOLDS_INT64 (&iter)) {
return false;
}
bson_iter_overwrite_int64 (&iter, value);
return true;
}
return BSON_APPEND_INT64 (&cursor->opts, option, value);
}
static int64_t
_mongoc_cursor_get_opt_int64 (const mongoc_cursor_t *cursor,
const char *option,
int64_t default_value)
{
bson_iter_t iter;
if (bson_iter_init_find (&iter, &cursor->opts, option)) {
return bson_iter_as_int64 (&iter);
}
return default_value;
}
static bool
_mongoc_cursor_set_opt_bool (mongoc_cursor_t *cursor,
const char *option,
bool value)
{
bson_iter_t iter;
if (bson_iter_init_find (&iter, &cursor->opts, option)) {
if (!BSON_ITER_HOLDS_BOOL (&iter)) {
return false;
}
bson_iter_overwrite_bool (&iter, value);
return true;
}
return BSON_APPEND_BOOL (&cursor->opts, option, value);
}
bool
_mongoc_cursor_get_opt_bool (const mongoc_cursor_t *cursor,
const char *option)
{
bson_iter_t iter;
if (bson_iter_init_find (&iter, &cursor->opts, option)) {
return bson_iter_as_bool (&iter);
}
return false;
}
int32_t
_mongoc_n_return (mongoc_cursor_t * cursor)
{
int64_t limit;
int64_t batch_size;
int64_t n_return;
if (cursor->is_command) {
/* commands always have n_return of 1 */
return 1;
}
limit = mongoc_cursor_get_limit (cursor);
batch_size = mongoc_cursor_get_batch_size (cursor);
if (limit < 0) {
n_return = limit;
} else if (limit) {
int64_t remaining = limit - cursor->count;
BSON_ASSERT (remaining > 0);
if (batch_size) {
n_return = BSON_MIN (batch_size, remaining);
} else {
/* batch_size 0 means accept the default */
n_return = remaining;
}
} else {
n_return = batch_size;
}
if (n_return < INT32_MIN) {
return INT32_MIN;
} else if (n_return > INT32_MAX) {
return INT32_MAX;
} else {
return (int32_t) n_return;
}
}
void
_mongoc_set_cursor_ns (mongoc_cursor_t *cursor,
const char *ns,
uint32_t nslen)
{
const char *dot;
bson_strncpy (cursor->ns, ns, sizeof cursor->ns);
cursor->nslen = BSON_MIN (nslen, sizeof cursor->ns);
dot = strstr (cursor->ns, ".");
if (dot) {
cursor->dblen = (uint32_t) (dot - cursor->ns);
} else {
/* a database name with no collection name */
cursor->dblen = cursor->nslen;
}
}
/* true if there are $-keys. precondition: bson must be valid. */
static bool
_has_dollar_fields (const bson_t *bson)
{
bson_iter_t iter;
const char *key;
BSON_ASSERT (bson_iter_init (&iter, bson));
while (bson_iter_next (&iter)) {
key = bson_iter_key (&iter);
if (key[0] == '$') {
return true;
}
}
return false;
}
-/* true if there are any non-$ keys. precondition: bson must be valid. */
-static bool
-_has_nondollar_fields (const bson_t *bson)
-{
- bson_iter_t iter;
- const char *key;
-
- BSON_ASSERT (bson_iter_init (&iter, bson));
- while (bson_iter_next (&iter)) {
- key = bson_iter_key (&iter);
-
- if (key[0] != '$') {
- return true;
- }
- }
-
- return false;
-}
-
-
-/* true if there are $ and non-$ keys. precondition: bson must be valid. */
-static bool
-_mixed_dollar_non_dollar (const bson_t *bson)
-{
- return _has_dollar_fields (bson) && _has_nondollar_fields (bson);
-}
-
-
#define MARK_FAILED(c) \
do { \
(c)->done = true; \
(c)->end_of_event = true; \
(c)->sent = true; \
} while (0)
mongoc_cursor_t *
_mongoc_cursor_new_with_opts (mongoc_client_t *client,
const char *db_and_collection,
bool is_command,
const bson_t *filter,
const bson_t *opts,
const mongoc_read_prefs_t *read_prefs,
const mongoc_read_concern_t *read_concern)
{
mongoc_cursor_t *cursor;
mongoc_topology_description_type_t td_type;
uint32_t server_id;
ENTRY;
BSON_ASSERT (client);
cursor = (mongoc_cursor_t *) bson_malloc0 (sizeof *cursor);
cursor->client = client;
cursor->is_command = is_command ? 1 : 0;
if (filter) {
if (!bson_validate (filter, BSON_VALIDATE_EMPTY_KEYS, NULL)) {
MARK_FAILED (cursor);
bson_set_error (&cursor->error, MONGOC_ERROR_CURSOR,
MONGOC_ERROR_CURSOR_INVALID_CURSOR,
"Empty keys are not allowed in 'filter'.");
GOTO (finish);
}
bson_copy_to (filter, &cursor->filter);
} else {
bson_init (&cursor->filter);
}
if (opts) {
if (!bson_validate (opts, BSON_VALIDATE_EMPTY_KEYS, NULL)) {
MARK_FAILED (cursor);
bson_set_error (&cursor->error, MONGOC_ERROR_CURSOR,
MONGOC_ERROR_CURSOR_INVALID_CURSOR,
"Cannot use empty keys in 'opts'.");
GOTO (finish);
}
if (_has_dollar_fields (opts)) {
MARK_FAILED (cursor);
bson_set_error (&cursor->error, MONGOC_ERROR_CURSOR,
MONGOC_ERROR_CURSOR_INVALID_CURSOR,
"Cannot use $-modifiers in 'opts'.");
GOTO (finish);
}
bson_init (&cursor->opts);
bson_copy_to_excluding_noinit (opts, &cursor->opts, "serverId", NULL);
/* true if there's a valid serverId or no serverId, false on err */
if (!_mongoc_get_server_id_from_opts (opts, MONGOC_ERROR_CURSOR,
MONGOC_ERROR_CURSOR_INVALID_CURSOR,
&server_id, &cursor->error)) {
MARK_FAILED (cursor);
GOTO (finish);
}
if (server_id) {
mongoc_cursor_set_hint (cursor, server_id);
}
} else {
bson_init (&cursor->opts);
}
cursor->read_prefs = read_prefs ?
mongoc_read_prefs_copy (read_prefs) :
mongoc_read_prefs_new (MONGOC_READ_PRIMARY);
cursor->read_concern = read_concern ?
mongoc_read_concern_copy (read_concern) :
mongoc_read_concern_new ();
if (db_and_collection) {
_mongoc_set_cursor_ns (cursor, db_and_collection,
(uint32_t) strlen (db_and_collection));
}
- if (_mongoc_cursor_get_opt_bool (cursor, EXHAUST)) {
- if (_mongoc_cursor_get_opt_int64 (cursor, LIMIT, 0)) {
+ if (_mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_EXHAUST)) {
+ if (_mongoc_cursor_get_opt_int64 (cursor, MONGOC_CURSOR_LIMIT, 0)) {
bson_set_error (&cursor->error,
MONGOC_ERROR_CURSOR,
MONGOC_ERROR_CURSOR_INVALID_CURSOR,
"Cannot specify both 'exhaust' and 'limit'.");
MARK_FAILED (cursor);
GOTO (finish);
}
td_type = _mongoc_topology_get_type (client->topology);
if (td_type == MONGOC_TOPOLOGY_SHARDED) {
bson_set_error (&cursor->error,
MONGOC_ERROR_CURSOR,
MONGOC_ERROR_CURSOR_INVALID_CURSOR,
"Cannot use exhaust cursor with sharded cluster.");
MARK_FAILED (cursor);
GOTO (finish);
}
}
_mongoc_buffer_init (&cursor->buffer, NULL, 0, NULL, NULL);
_mongoc_read_prefs_validate (read_prefs, &cursor->error);
finish:
mongoc_counter_cursors_active_inc ();
RETURN (cursor);
}
mongoc_cursor_t *
_mongoc_cursor_new (mongoc_client_t *client,
const char *db_and_collection,
mongoc_query_flags_t qflags,
uint32_t skip,
int32_t limit,
uint32_t batch_size,
bool is_command,
const bson_t *query,
const bson_t *fields,
const mongoc_read_prefs_t *read_prefs,
const mongoc_read_concern_t *read_concern)
{
bson_t filter;
bool has_filter = false;
bson_t opts = BSON_INITIALIZER;
bool slave_ok = false;
const char *key;
bson_iter_t iter;
const char *opt_key;
int len;
uint32_t data_len;
const uint8_t *data;
mongoc_cursor_t *cursor;
bson_error_t error = { 0 };
ENTRY;
BSON_ASSERT (client);
if (query) {
if (bson_has_field (query, "$query")) {
/* like "{$query: {a: 1}, $orderby: {b: 1}, $otherModifier: true}" */
bson_iter_init (&iter, query);
while (bson_iter_next (&iter)) {
key = bson_iter_key (&iter);
if (key[0] != '$') {
bson_set_error (&error, MONGOC_ERROR_CURSOR,
MONGOC_ERROR_CURSOR_INVALID_CURSOR,
"Cannot mix $query with non-dollar field '%s'",
key);
GOTO (done);
}
if (!strcmp (key, "$query")) {
/* set "filter" to the incoming document's "$query" */
bson_iter_document (&iter, &data_len, &data);
bson_init_static (&filter, data, (size_t) data_len);
has_filter = true;
} else if (_translate_query_opt (key, &opt_key, &len)) {
/* "$orderby" becomes "sort", etc., "$unknown" -> "unknown" */
bson_append_iter (&opts, opt_key, len, &iter);
} else {
/* strip leading "$" */
bson_append_iter (&opts, key + 1, -1, &iter);
}
}
- } else {
- /* whole document is query, like "{a: 1}" or "{$or: [...]}" */
- if (_mixed_dollar_non_dollar (query)) {
- bson_set_error (&error, MONGOC_ERROR_CURSOR,
- MONGOC_ERROR_CURSOR_INVALID_CURSOR,
- "Cannot mix top-level query with dollar keys such "
- "as $orderby. Use {$query: {},...} instead.");
- GOTO (done);
- }
}
}
if (!bson_empty0 (fields)) {
- bson_append_document (&opts, PROJECTION, PROJECTION_LEN, fields);
+ bson_append_document (&opts, MONGOC_CURSOR_PROJECTION, MONGOC_CURSOR_PROJECTION_LEN, fields);
}
if (skip) {
- bson_append_int64 (&opts, SKIP, SKIP_LEN, skip);
+ bson_append_int64 (&opts, MONGOC_CURSOR_SKIP, MONGOC_CURSOR_SKIP_LEN, skip);
}
if (limit) {
- bson_append_int64 (&opts, LIMIT, LIMIT_LEN, llabs (limit));
+ bson_append_int64 (&opts, MONGOC_CURSOR_LIMIT, MONGOC_CURSOR_LIMIT_LEN, llabs (limit));
if (limit < 0) {
- bson_append_bool (&opts, SINGLE_BATCH, SINGLE_BATCH_LEN, true);
+ bson_append_bool (&opts, MONGOC_CURSOR_SINGLE_BATCH, MONGOC_CURSOR_SINGLE_BATCH_LEN, true);
}
}
if (batch_size) {
- bson_append_int64 (&opts, BATCH_SIZE, BATCH_SIZE_LEN, batch_size);
+ bson_append_int64 (&opts, MONGOC_CURSOR_BATCH_SIZE, MONGOC_CURSOR_BATCH_SIZE_LEN, batch_size);
}
if (qflags & MONGOC_QUERY_SLAVE_OK) {
slave_ok = true;
}
if (qflags & MONGOC_QUERY_TAILABLE_CURSOR) {
- bson_append_bool (&opts, TAILABLE, TAILABLE_LEN, true);
+ bson_append_bool (&opts, MONGOC_CURSOR_TAILABLE, MONGOC_CURSOR_TAILABLE_LEN, true);
}
if (qflags & MONGOC_QUERY_OPLOG_REPLAY) {
- bson_append_bool (&opts, OPLOG_REPLAY, OPLOG_REPLAY_LEN, true);
+ bson_append_bool (&opts, MONGOC_CURSOR_OPLOG_REPLAY, MONGOC_CURSOR_OPLOG_REPLAY_LEN, true);
}
if (qflags & MONGOC_QUERY_NO_CURSOR_TIMEOUT) {
- bson_append_bool (&opts, NO_CURSOR_TIMEOUT, NO_CURSOR_TIMEOUT_LEN, true);
+ bson_append_bool (&opts, MONGOC_CURSOR_NO_CURSOR_TIMEOUT, MONGOC_CURSOR_NO_CURSOR_TIMEOUT_LEN, true);
}
if (qflags & MONGOC_QUERY_AWAIT_DATA) {
- bson_append_bool (&opts, AWAIT_DATA, AWAIT_DATA_LEN, true);
+ bson_append_bool (&opts, MONGOC_CURSOR_AWAIT_DATA, MONGOC_CURSOR_AWAIT_DATA_LEN, true);
}
if (qflags & MONGOC_QUERY_EXHAUST) {
- bson_append_bool (&opts, EXHAUST, EXHAUST_LEN, true);
+ bson_append_bool (&opts, MONGOC_CURSOR_EXHAUST, MONGOC_CURSOR_EXHAUST_LEN, true);
}
if (qflags & MONGOC_QUERY_PARTIAL) {
- bson_append_bool (&opts, ALLOW_PARTIAL_RESULTS, ALLOW_PARTIAL_RESULTS_LEN,
+ bson_append_bool (&opts, MONGOC_CURSOR_ALLOW_PARTIAL_RESULTS, MONGOC_CURSOR_ALLOW_PARTIAL_RESULTS_LEN,
true);
}
done:
if (error.domain != 0) {
cursor = _mongoc_cursor_new_with_opts (client, db_and_collection,
is_command, NULL, NULL, NULL,
NULL);
MARK_FAILED (cursor);
memcpy (&cursor->error, &error, sizeof (bson_error_t));
} else {
cursor = _mongoc_cursor_new_with_opts (client, db_and_collection,
is_command,
has_filter ? &filter : query,
&opts, read_prefs, read_concern);
if (slave_ok) {
cursor->slave_ok = true;
}
}
if (has_filter) {
bson_destroy (&filter);
}
bson_destroy (&opts);
RETURN (cursor);
}
void
mongoc_cursor_destroy (mongoc_cursor_t *cursor)
{
ENTRY;
BSON_ASSERT(cursor);
if (cursor->iface.destroy) {
cursor->iface.destroy(cursor);
} else {
_mongoc_cursor_destroy(cursor);
}
EXIT;
}
void
_mongoc_cursor_destroy (mongoc_cursor_t *cursor)
{
char db[MONGOC_NAMESPACE_MAX];
ENTRY;
BSON_ASSERT (cursor);
if (cursor->in_exhaust) {
cursor->client->in_exhaust = false;
if (!cursor->done) {
/* The only way to stop an exhaust cursor is to kill the connection */
mongoc_cluster_disconnect_node (&cursor->client->cluster,
cursor->server_id);
}
} else if (cursor->rpc.reply.cursor_id) {
bson_strncpy (db, cursor->ns, cursor->dblen + 1);
_mongoc_client_kill_cursor(cursor->client,
cursor->server_id,
cursor->rpc.reply.cursor_id,
cursor->operation_id,
db,
cursor->ns + cursor->dblen + 1);
}
if (cursor->reader) {
bson_reader_destroy(cursor->reader);
cursor->reader = NULL;
}
_mongoc_buffer_destroy(&cursor->buffer);
mongoc_read_prefs_destroy(cursor->read_prefs);
mongoc_read_concern_destroy(cursor->read_concern);
mongoc_write_concern_destroy (cursor->write_concern);
bson_destroy (&cursor->filter);
bson_destroy (&cursor->opts);
bson_free(cursor);
mongoc_counter_cursors_active_dec();
mongoc_counter_cursors_disposed_inc();
EXIT;
}
mongoc_server_stream_t *
_mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor)
{
mongoc_server_stream_t *server_stream;
ENTRY;
if (cursor->server_id) {
server_stream = mongoc_cluster_stream_for_server (&cursor->client->cluster,
cursor->server_id,
true /* reconnect_ok */,
&cursor->error);
} else {
server_stream = mongoc_cluster_stream_for_reads (&cursor->client->cluster,
cursor->read_prefs,
&cursor->error);
if (server_stream) {
cursor->server_id = server_stream->sd->id;
}
}
RETURN (server_stream);
}
bool
_use_find_command (const mongoc_cursor_t *cursor,
const mongoc_server_stream_t *server_stream)
{
/* Find, getMore And killCursors Commands Spec: "the find command cannot be
* used to execute other commands" and "the find command does not support the
* exhaust flag."
*/
return server_stream->sd->max_wire_version >= WIRE_VERSION_FIND_CMD &&
- !cursor->is_command &&
- !_mongoc_cursor_get_opt_bool (cursor, EXHAUST);
+ !cursor->is_command && !_mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_EXHAUST);
}
-
static const bson_t *
_mongoc_cursor_initial_query (mongoc_cursor_t *cursor)
{
mongoc_server_stream_t *server_stream;
const bson_t *b = NULL;
ENTRY;
BSON_ASSERT (cursor);
server_stream = _mongoc_cursor_fetch_stream (cursor);
if (!server_stream) {
GOTO (done);
}
if (_use_find_command (cursor, server_stream)) {
b = _mongoc_cursor_find_command (cursor, server_stream);
} else {
/* When the user explicitly provides a readConcern -- but the server
* doesn't support readConcern, we must error:
* https://github.com/mongodb/specifications/blob/master/source/read-write-concern/read-write-concern.rst#errors-1
*/
if (cursor->read_concern->level != NULL
&& server_stream->sd->max_wire_version < WIRE_VERSION_READ_CONCERN) {
bson_set_error (&cursor->error,
MONGOC_ERROR_COMMAND,
MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION,
"The selected server does not support readConcern");
} else {
b = _mongoc_cursor_op_query (cursor, server_stream);
}
}
done:
/* no-op if server_stream is NULL */
mongoc_server_stream_cleanup (server_stream);
if (!b) {
cursor->done = true;
}
RETURN (b);
}
static bool
_mongoc_cursor_monitor_legacy_query (mongoc_cursor_t *cursor,
mongoc_server_stream_t *server_stream,
const char *cmd_name)
{
bson_t doc;
mongoc_client_t *client;
mongoc_apm_command_started_t event;
char db[MONGOC_NAMESPACE_MAX];
ENTRY;
client = cursor->client;
if (!client->apm_callbacks.started) {
/* successful */
RETURN (true);
}
-
+
bson_init (&doc);
bson_strncpy (db, cursor->ns, cursor->dblen + 1);
if (!cursor->is_command) {
/* simulate a MongoDB 3.2+ "find" command */
if (!_mongoc_cursor_prepare_find_command (cursor, &doc, server_stream)) {
/* cursor->error is set */
bson_destroy (&doc);
RETURN (false);
}
}
mongoc_apm_command_started_init (&event,
cursor->is_command ? &cursor->filter : &doc,
db,
cmd_name,
client->cluster.request_id,
cursor->operation_id,
&server_stream->sd->host,
server_stream->sd->id,
client->apm_context);
client->apm_callbacks.started (&event);
mongoc_apm_command_started_cleanup (&event);
bson_destroy (&doc);
RETURN (true);
}
/* append array of docs from current cursor batch */
static void
_mongoc_cursor_append_docs_array (mongoc_cursor_t *cursor,
bson_t *docs)
{
bool eof = false;
char str[16];
const char *key;
uint32_t i = 0;
size_t keylen;
const bson_t *doc;
while ((doc = bson_reader_read (cursor->reader, &eof))) {
keylen = bson_uint32_to_string (i, &key, str, sizeof str);
bson_append_document (docs, key, (int) keylen, doc);
}
bson_reader_reset (cursor->reader);
}
static void
_mongoc_cursor_monitor_succeeded (mongoc_cursor_t *cursor,
int64_t duration,
bool first_batch,
mongoc_server_stream_t *stream,
const char *cmd_name)
{
mongoc_apm_command_succeeded_t event;
mongoc_client_t *client;
bson_t reply;
bson_t reply_cursor;
ENTRY;
client = cursor->client;
if (!client->apm_callbacks.succeeded) {
EXIT;
}
if (cursor->is_command) {
/* cursor is from mongoc_client_command. we're in mongoc_cursor_next. */
if (!_mongoc_rpc_reply_get_first(&cursor->rpc.reply, &reply)) {
MONGOC_ERROR ("_mongoc_cursor_monitor_succeeded can't parse reply");
EXIT;
}
} else {
bson_t docs_array;
/* fake reply to find/getMore command:
* {ok: 1, cursor: {id: 17, ns: "...", first/nextBatch: [ ... docs ... ]}}
*/
bson_init (&docs_array);
_mongoc_cursor_append_docs_array (cursor, &docs_array);
bson_init (&reply);
bson_append_int32 (&reply, "ok", 2, 1);
bson_append_document_begin (&reply, "cursor", 6, &reply_cursor);
bson_append_int64 (&reply_cursor, "id", 2, mongoc_cursor_get_id (cursor));
bson_append_utf8 (&reply_cursor, "ns", 2, cursor->ns, cursor->nslen);
bson_append_array (&reply_cursor,
first_batch ? "firstBatch" : "nextBatch",
first_batch ? 10 : 9,
&docs_array);
bson_append_document_end (&reply, &reply_cursor);
bson_destroy (&docs_array);
}
mongoc_apm_command_succeeded_init (&event,
duration,
&reply,
cmd_name,
client->cluster.request_id,
cursor->operation_id,
&stream->sd->host,
stream->sd->id,
client->apm_context);
client->apm_callbacks.succeeded (&event);
mongoc_apm_command_succeeded_cleanup (&event);
bson_destroy (&reply);
EXIT;
}
static void
_mongoc_cursor_monitor_failed (mongoc_cursor_t *cursor,
int64_t duration,
mongoc_server_stream_t *stream,
const char *cmd_name)
{
mongoc_apm_command_failed_t event;
mongoc_client_t *client;
ENTRY;
client = cursor->client;
if (!client->apm_callbacks.failed) {
EXIT;
}
mongoc_apm_command_failed_init (&event,
duration,
cmd_name,
&cursor->error,
client->cluster.request_id,
cursor->operation_id,
&stream->sd->host,
stream->sd->id,
client->apm_context);
client->apm_callbacks.failed (&event);
mongoc_apm_command_failed_cleanup (&event);
EXIT;
}
#define OPT_CHECK(_type) do { \
if (!BSON_ITER_HOLDS_##_type (&iter)) { \
bson_set_error (&cursor->error, \
MONGOC_ERROR_COMMAND, \
MONGOC_ERROR_COMMAND_INVALID_ARG, \
"invalid option %s, should be type %s", \
key, #_type); \
return NULL; \
} \
} while (false)
#define OPT_CHECK_INT() do { \
if (!BSON_ITER_HOLDS_INT64 (&iter) && \
!BSON_ITER_HOLDS_INT32 (&iter)) { \
bson_set_error (&cursor->error, \
MONGOC_ERROR_COMMAND, \
MONGOC_ERROR_COMMAND_INVALID_ARG, \
"invalid option %s, should be integer", key); \
return NULL; \
} \
} while (false)
#define OPT_ERR(_msg) do { \
bson_set_error (&cursor->error, MONGOC_ERROR_COMMAND, \
MONGOC_ERROR_COMMAND_INVALID_ARG, _msg); \
return NULL; \
} while (false)
#define OPT_BSON_ERR(_msg) do { \
bson_set_error (&cursor->error, MONGOC_ERROR_BSON, \
MONGOC_ERROR_BSON_INVALID, _msg); \
return NULL; \
} while (false)
#define OPT_FLAG(_flag) do { \
OPT_CHECK (BOOL); \
if (bson_iter_as_bool (&iter)) { \
*flags |= _flag; \
} \
} while (false)
#define PUSH_DOLLAR_QUERY() do { \
if (!pushed_dollar_query) { \
pushed_dollar_query = true; \
bson_append_document (query, "$query", 6, &cursor->filter); \
} \
} while (false)
#define OPT_SUBDOCUMENT(_opt_name, _legacy_name) do { \
OPT_CHECK (DOCUMENT); \
bson_iter_document (&iter, &len, &data); \
if (!bson_init_static (&subdocument, data, (size_t) len)) { \
OPT_BSON_ERR ("Invalid '" #_opt_name "' subdocument in 'opts'."); \
} \
BSON_APPEND_DOCUMENT (query, "$" #_legacy_name, &subdocument); \
} while (false)
#define ADD_FLAG(_flags, _value) do { \
if (!BSON_ITER_HOLDS_BOOL(&iter)) { \
bson_set_error (&cursor->error, \
MONGOC_ERROR_COMMAND, \
MONGOC_ERROR_COMMAND_INVALID_ARG, \
"invalid option %s, should be type bool", key); \
return false; \
} \
if (bson_iter_as_bool (&iter)) { \
*_flags |= _value; \
} \
} while (false);
static bool
_mongoc_cursor_flags (mongoc_cursor_t *cursor,
mongoc_server_stream_t *stream,
mongoc_query_flags_t *flags /* OUT */)
{
bson_iter_t iter;
const char *key;
*flags = MONGOC_QUERY_NONE;
if (!bson_iter_init (&iter, &cursor->opts)) {
bson_set_error (&cursor->error, MONGOC_ERROR_BSON,
MONGOC_ERROR_BSON_INVALID, "Invalid 'opts' parameter.");
return false;
}
while (bson_iter_next (&iter)) {
key = bson_iter_key (&iter);
- if (!strcmp (key, ALLOW_PARTIAL_RESULTS)) {
+ if (!strcmp (key, MONGOC_CURSOR_ALLOW_PARTIAL_RESULTS)) {
ADD_FLAG (flags, MONGOC_QUERY_PARTIAL);
- } else if (!strcmp (key, AWAIT_DATA)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_AWAIT_DATA)) {
ADD_FLAG (flags, MONGOC_QUERY_AWAIT_DATA);
- } else if (!strcmp (key, EXHAUST)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_EXHAUST)) {
ADD_FLAG (flags, MONGOC_QUERY_EXHAUST);
- } else if (!strcmp (key, NO_CURSOR_TIMEOUT)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_NO_CURSOR_TIMEOUT)) {
ADD_FLAG (flags, MONGOC_QUERY_NO_CURSOR_TIMEOUT);
- } else if (!strcmp (key, OPLOG_REPLAY)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_OPLOG_REPLAY)) {
ADD_FLAG (flags, MONGOC_QUERY_OPLOG_REPLAY);
- } else if (!strcmp (key, TAILABLE)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_TAILABLE)) {
ADD_FLAG (flags, MONGOC_QUERY_TAILABLE_CURSOR);
}
}
if (cursor->slave_ok) {
*flags |= MONGOC_QUERY_SLAVE_OK;
} else if (cursor->server_id_set &&
(stream->topology_type == MONGOC_TOPOLOGY_RS_WITH_PRIMARY ||
stream->topology_type == MONGOC_TOPOLOGY_RS_NO_PRIMARY) &&
stream->sd->type != MONGOC_SERVER_RS_PRIMARY) {
*flags |= MONGOC_QUERY_SLAVE_OK;
}
return true;
}
static bson_t *
_mongoc_cursor_parse_opts_for_op_query (mongoc_cursor_t *cursor,
mongoc_server_stream_t *stream,
bson_t *query /* OUT */,
bson_t *fields/* OUT */,
mongoc_query_flags_t *flags /* OUT */,
int32_t *skip /* OUT */)
{
bool pushed_dollar_query;
bson_iter_t iter;
uint32_t len;
const uint8_t *data;
bson_t subdocument;
const char *key;
char *dollar_modifier;
*flags = MONGOC_QUERY_NONE;
*skip = 0;
/* assume we'll send filter straight to server, like "{a: 1}". if we find an
* opt we must add, like "sort", we push the query like "$query: {a: 1}",
* then add a query modifier for the option, in this example "$orderby".
*/
pushed_dollar_query = false;
if (!bson_iter_init (&iter, &cursor->opts)) {
OPT_BSON_ERR ("Invalid 'opts' parameter.");
}
while (bson_iter_next (&iter)) {
key = bson_iter_key (&iter);
/* most common options first */
- if (!strcmp (key, PROJECTION)) {
+ if (!strcmp (key, MONGOC_CURSOR_PROJECTION)) {
OPT_CHECK (DOCUMENT);
bson_iter_document (&iter, &len, &data);
if (!bson_init_static (&subdocument, data, (size_t) len)) {
OPT_BSON_ERR ("Invalid 'projection' subdocument in 'opts'.");
}
bson_copy_to (&subdocument, fields);
- } else if (!strcmp (key, SORT)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_SORT)) {
PUSH_DOLLAR_QUERY ();
OPT_SUBDOCUMENT (sort, orderby);
- } else if (!strcmp (key, SKIP)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_SKIP)) {
OPT_CHECK_INT ();
*skip = (int32_t) bson_iter_as_int64 (&iter);
}
/* the rest of the options, alphabetically */
- else if (!strcmp (key, ALLOW_PARTIAL_RESULTS)) {
+ else if (!strcmp (key, MONGOC_CURSOR_ALLOW_PARTIAL_RESULTS)) {
OPT_FLAG (MONGOC_QUERY_PARTIAL);
- } else if (!strcmp (key, AWAIT_DATA)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_AWAIT_DATA)) {
OPT_FLAG (MONGOC_QUERY_AWAIT_DATA);
- } else if (!strcmp (key, COMMENT)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_COMMENT)) {
OPT_CHECK (UTF8);
PUSH_DOLLAR_QUERY ();
BSON_APPEND_UTF8 (query, "$comment", bson_iter_utf8 (&iter, NULL));
- } else if (!strcmp (key, HINT)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_HINT)) {
if (BSON_ITER_HOLDS_UTF8 (&iter)) {
PUSH_DOLLAR_QUERY ();
BSON_APPEND_UTF8 (query, "$hint", bson_iter_utf8 (&iter, NULL));
} else if (BSON_ITER_HOLDS_DOCUMENT (&iter)) {
PUSH_DOLLAR_QUERY ();
OPT_SUBDOCUMENT (hint, hint);
} else {
OPT_ERR ("Wrong type for 'hint' field in 'opts'.");
}
- } else if (!strcmp (key, MAX)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_MAX)) {
PUSH_DOLLAR_QUERY ();
OPT_SUBDOCUMENT (max, max);
- } else if (!strcmp (key, MAX_SCAN)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_MAX_SCAN)) {
OPT_CHECK_INT ();
PUSH_DOLLAR_QUERY ();
BSON_APPEND_INT64 (query, "$maxScan", bson_iter_as_int64 (&iter));
- } else if (!strcmp (key, MAX_TIME_MS)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_MAX_TIME_MS)) {
OPT_CHECK_INT ();
PUSH_DOLLAR_QUERY ();
BSON_APPEND_INT64 (query, "$maxTimeMS", bson_iter_as_int64 (&iter));
- } else if (!strcmp (key, MIN)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_MIN)) {
PUSH_DOLLAR_QUERY ();
OPT_SUBDOCUMENT (min, min);
- } else if (!strcmp (key, READ_CONCERN)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_READ_CONCERN)) {
OPT_ERR ("Set readConcern on client, database, or collection,"
" not in a query.");
- } else if (!strcmp (key, RETURN_KEY)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_RETURN_KEY)) {
OPT_CHECK (BOOL);
PUSH_DOLLAR_QUERY ();
BSON_APPEND_BOOL (query, "$returnKey", bson_iter_as_bool (&iter));
- } else if (!strcmp (key, SHOW_RECORD_ID)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_SHOW_RECORD_ID)) {
OPT_CHECK (BOOL);
PUSH_DOLLAR_QUERY ();
BSON_APPEND_BOOL (query, "$showDiskLoc", bson_iter_as_bool (&iter));
- } else if (!strcmp (key, SNAPSHOT)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_SNAPSHOT)) {
OPT_CHECK (BOOL);
PUSH_DOLLAR_QUERY ();
BSON_APPEND_BOOL (query, "$snapshot", bson_iter_as_bool (&iter));
- } else if (!strcmp (key, COLLATION)) {
+ } else if (!strcmp (key, MONGOC_CURSOR_COLLATION)) {
bson_set_error (&cursor->error,
MONGOC_ERROR_CURSOR,
MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION,
"Collation is not supported by this server");
return NULL;
}
/* singleBatch limit and batchSize are handled in _mongoc_n_return,
* exhaust noCursorTimeout oplogReplay tailable in _mongoc_cursor_flags
* maxAwaitTimeMS is handled in _mongoc_cursor_prepare_getmore_command
*/
- else if (strcmp (key, SINGLE_BATCH) &&
- strcmp (key, LIMIT) &&
- strcmp (key, BATCH_SIZE) &&
- strcmp (key, EXHAUST) &&
- strcmp (key, NO_CURSOR_TIMEOUT) &&
- strcmp (key, OPLOG_REPLAY) &&
- strcmp (key, TAILABLE) &&
- strcmp (key, MAX_AWAIT_TIME_MS)) {
+ else if (strcmp (key, MONGOC_CURSOR_SINGLE_BATCH) &&
+ strcmp (key, MONGOC_CURSOR_LIMIT) &&
+ strcmp (key, MONGOC_CURSOR_BATCH_SIZE) &&
+ strcmp (key, MONGOC_CURSOR_EXHAUST) &&
+ strcmp (key, MONGOC_CURSOR_NO_CURSOR_TIMEOUT) &&
+ strcmp (key, MONGOC_CURSOR_OPLOG_REPLAY) &&
+ strcmp (key, MONGOC_CURSOR_TAILABLE) &&
+ strcmp (key, MONGOC_CURSOR_MAX_AWAIT_TIME_MS)) {
/* pass unrecognized options to server, prefixed with $ */
PUSH_DOLLAR_QUERY ();
dollar_modifier = bson_strdup_printf ("$%s", key);
bson_append_iter (query, dollar_modifier, -1, &iter);
bson_free (dollar_modifier);
}
}
if (!_mongoc_cursor_flags (cursor, stream, flags)) {
/* cursor->error is set */
return NULL;
}
return pushed_dollar_query ? query : &cursor->filter;
}
#undef OPT_CHECK
#undef OPT_ERR
#undef OPT_BSON_ERR
#undef OPT_FLAG
#undef OPT_SUBDOCUMENT
static const bson_t *
_mongoc_cursor_op_query (mongoc_cursor_t *cursor,
mongoc_server_stream_t *server_stream)
{
int64_t started;
uint32_t request_id;
mongoc_rpc_t rpc;
const char *cmd_name; /* for command monitoring */
const bson_t *query_ptr;
bson_t query = BSON_INITIALIZER;
bson_t fields = BSON_INITIALIZER;
mongoc_query_flags_t flags;
mongoc_apply_read_prefs_result_t result = READ_PREFS_RESULT_INIT;
const bson_t *ret = NULL;
bool succeeded = false;
ENTRY;
started = bson_get_monotonic_time ();
cursor->sent = true;
cursor->operation_id = ++cursor->client->cluster.operation_id;
request_id = ++cursor->client->cluster.request_id;
rpc.query.msg_len = 0;
rpc.query.request_id = request_id;
rpc.query.response_to = 0;
rpc.query.opcode = MONGOC_OPCODE_QUERY;
rpc.query.flags = MONGOC_QUERY_NONE;
rpc.query.collection = cursor->ns;
rpc.query.skip = 0;
rpc.query.n_return = 0;
rpc.query.fields = NULL;
if (cursor->is_command) {
/* "filter" isn't a query, it's like {commandName: ... }*/
cmd_name = _mongoc_get_command_name (&cursor->filter);
BSON_ASSERT (cmd_name);
} else {
cmd_name = "find";
}
query_ptr = _mongoc_cursor_parse_opts_for_op_query (cursor,
server_stream,
&query,
&fields,
&flags,
&rpc.query.skip);
if (!query_ptr) {
/* invalid opts. cursor->error is set */
GOTO (done);
}
apply_read_preferences (cursor->read_prefs, server_stream,
query_ptr, flags, &result);
rpc.query.query = bson_get_data (result.query_with_read_prefs);
rpc.query.flags = result.flags;
rpc.query.n_return = _mongoc_n_return (cursor);
if (!bson_empty (&fields)) {
rpc.query.fields = bson_get_data (&fields);
}
if (!_mongoc_cursor_monitor_legacy_query (cursor, server_stream, cmd_name)) {
GOTO (done);
}
if (!mongoc_cluster_sendv_to_server (&cursor->client->cluster,
&rpc, 1, server_stream,
NULL, &cursor->error)) {
GOTO (done);
}
_mongoc_buffer_clear (&cursor->buffer, false);
if (!_mongoc_client_recv (cursor->client,
&cursor->rpc,
&cursor->buffer,
server_stream,
&cursor->error)) {
GOTO (done);
}
if (cursor->rpc.header.opcode != MONGOC_OPCODE_REPLY) {
bson_set_error (&cursor->error,
MONGOC_ERROR_PROTOCOL,
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
"Invalid opcode. Expected %d, got %d.",
MONGOC_OPCODE_REPLY, cursor->rpc.header.opcode);
GOTO (done);
}
if (cursor->rpc.header.response_to != request_id) {
bson_set_error (&cursor->error,
MONGOC_ERROR_PROTOCOL,
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
"Invalid response_to for query. Expected %d, got %d.",
request_id, cursor->rpc.header.response_to);
GOTO (done);
}
if (cursor->is_command) {
if (_mongoc_rpc_parse_command_error (&cursor->rpc,
cursor->client->error_api_version,
&cursor->error)) {
GOTO (done);
}
} else {
if (_mongoc_rpc_parse_query_error (&cursor->rpc,
cursor->client->error_api_version,
&cursor->error)) {
GOTO (done);
}
}
if (cursor->reader) {
bson_reader_destroy (cursor->reader);
}
cursor->reader = bson_reader_new_from_data (
cursor->rpc.reply.documents,
(size_t) cursor->rpc.reply.documents_len);
- if (_mongoc_cursor_get_opt_bool (cursor, EXHAUST)) {
+ if (_mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_EXHAUST)) {
cursor->in_exhaust = true;
cursor->client->in_exhaust = true;
}
_mongoc_cursor_monitor_succeeded (cursor,
bson_get_monotonic_time () - started,
true, /* first_batch */
server_stream,
cmd_name);
cursor->done = false;
cursor->end_of_event = false;
succeeded = true;
_mongoc_read_from_buffer (cursor, &ret);
done:
if (!succeeded) {
_mongoc_cursor_monitor_failed (cursor,
bson_get_monotonic_time () - started,
server_stream, cmd_name);
}
apply_read_prefs_result_cleanup (&result);
bson_destroy (&query);
bson_destroy (&fields);
if (!ret) {
cursor->done = true;
}
RETURN (ret);
}
bool
_mongoc_cursor_run_command (mongoc_cursor_t *cursor,
const bson_t *command,
bson_t *reply)
{
mongoc_cluster_t *cluster;
mongoc_server_stream_t *server_stream;
char db[MONGOC_NAMESPACE_MAX];
mongoc_query_flags_t flags;
mongoc_apply_read_prefs_result_t read_prefs_result = READ_PREFS_RESULT_INIT;
bool ret = false;
ENTRY;
cluster = &cursor->client->cluster;
server_stream = _mongoc_cursor_fetch_stream (cursor);
if (!server_stream) {
GOTO (done);
}
bson_strncpy (db, cursor->ns, cursor->dblen + 1);
if (!_mongoc_cursor_flags (cursor, server_stream, &flags)) {
GOTO (done);
}
apply_read_preferences (cursor->read_prefs, server_stream,
command, flags, &read_prefs_result);
if (cursor->write_concern &&
!_mongoc_write_concern_is_default (cursor->write_concern) &&
server_stream->sd->max_wire_version >= WIRE_VERSION_CMD_WRITE_CONCERN) {
mongoc_write_concern_append (cursor->write_concern,
read_prefs_result.query_with_read_prefs);
}
if (cursor->read_concern &&
server_stream->sd->max_wire_version >= WIRE_VERSION_READ_CONCERN) {
mongoc_read_concern_append (cursor->read_concern,
read_prefs_result.query_with_read_prefs);
}
ret = mongoc_cluster_run_command_monitored (
cluster,
server_stream,
read_prefs_result.flags,
db,
read_prefs_result.query_with_read_prefs,
reply,
&cursor->error);
/* Read and Write Concern Spec: "Drivers SHOULD parse server replies for a
* "writeConcernError" field and report the error only in command-specific
* helper methods that take a separate write concern parameter or an options
* parameter that may contain a write concern option.
*
* Only command helpers with names like "_with_write_concern" can create
* cursors with a non-NULL write_concern field.
*/
if (ret && cursor->write_concern) {
ret = !_mongoc_parse_wc_err (reply, &cursor->error);
}
done:
apply_read_prefs_result_cleanup (&read_prefs_result);
mongoc_server_stream_cleanup (server_stream);
return ret;
}
static bool
_translate_query_opt (const char *query_field,
const char **cmd_field,
int *len)
{
if (query_field[0] != '$') {
*cmd_field = query_field;
*len = -1;
return true;
}
/* strip the leading '$' */
query_field++;
- if (!strcmp (ORDERBY, query_field)) {
- *cmd_field = SORT;
- *len = SORT_LEN;
- } else if (!strcmp (SHOW_DISK_LOC, query_field)) { /* <= MongoDb 3.0 */
- *cmd_field = SHOW_RECORD_ID;
- *len = SHOW_RECORD_ID_LEN;
- } else if (!strcmp (HINT, query_field)) {
- *cmd_field = HINT;
- *len = HINT_LEN;
- } else if (!strcmp (COMMENT, query_field)) {
- *cmd_field = COMMENT;
- *len = COMMENT_LEN;
- } else if (!strcmp (MAX_SCAN, query_field)) {
- *cmd_field = MAX_SCAN;
- *len = MAX_SCAN_LEN;
- } else if (!strcmp (MAX_TIME_MS, query_field)) {
- *cmd_field = MAX_TIME_MS;
- *len = MAX_TIME_MS_LEN;
- } else if (!strcmp (MAX, query_field)) {
- *cmd_field = MAX;
- *len = MAX_LEN;
- } else if (!strcmp (MIN, query_field)) {
- *cmd_field = MIN;
- *len = MIN_LEN;
- } else if (!strcmp (RETURN_KEY, query_field)) {
- *cmd_field = RETURN_KEY;
- *len = RETURN_KEY_LEN;
- } else if (!strcmp (SNAPSHOT, query_field)) {
- *cmd_field = SNAPSHOT;
- *len = SNAPSHOT_LEN;
+ if (!strcmp (MONGOC_CURSOR_ORDERBY, query_field)) {
+ *cmd_field = MONGOC_CURSOR_SORT;
+ *len = MONGOC_CURSOR_SORT_LEN;
+ } else if (!strcmp (MONGOC_CURSOR_SHOW_DISK_LOC, query_field)) { /* <= MongoDb 3.0 */
+ *cmd_field = MONGOC_CURSOR_SHOW_RECORD_ID;
+ *len = MONGOC_CURSOR_SHOW_RECORD_ID_LEN;
+ } else if (!strcmp (MONGOC_CURSOR_HINT, query_field)) {
+ *cmd_field = MONGOC_CURSOR_HINT;
+ *len = MONGOC_CURSOR_HINT_LEN;
+ } else if (!strcmp (MONGOC_CURSOR_COMMENT, query_field)) {
+ *cmd_field = MONGOC_CURSOR_COMMENT;
+ *len = MONGOC_CURSOR_COMMENT_LEN;
+ } else if (!strcmp (MONGOC_CURSOR_MAX_SCAN, query_field)) {
+ *cmd_field = MONGOC_CURSOR_MAX_SCAN;
+ *len = MONGOC_CURSOR_MAX_SCAN_LEN;
+ } else if (!strcmp (MONGOC_CURSOR_MAX_TIME_MS, query_field)) {
+ *cmd_field = MONGOC_CURSOR_MAX_TIME_MS;
+ *len = MONGOC_CURSOR_MAX_TIME_MS_LEN;
+ } else if (!strcmp (MONGOC_CURSOR_MAX, query_field)) {
+ *cmd_field = MONGOC_CURSOR_MAX;
+ *len = MONGOC_CURSOR_MAX_LEN;
+ } else if (!strcmp (MONGOC_CURSOR_MIN, query_field)) {
+ *cmd_field = MONGOC_CURSOR_MIN;
+ *len = MONGOC_CURSOR_MIN_LEN;
+ } else if (!strcmp (MONGOC_CURSOR_RETURN_KEY, query_field)) {
+ *cmd_field = MONGOC_CURSOR_RETURN_KEY;
+ *len = MONGOC_CURSOR_RETURN_KEY_LEN;
+ } else if (!strcmp (MONGOC_CURSOR_SNAPSHOT, query_field)) {
+ *cmd_field = MONGOC_CURSOR_SNAPSHOT;
+ *len = MONGOC_CURSOR_SNAPSHOT_LEN;
} else {
/* not a special command field, must be a query operator like $or */
return false;
}
return true;
}
void
_mongoc_cursor_collection (const mongoc_cursor_t *cursor,
const char **collection,
int *collection_len)
{
/* ns is like "db.collection". Collection name is located past the ".". */
*collection = cursor->ns + (cursor->dblen + 1);
/* Collection name's length is ns length, minus length of db name and ".". */
*collection_len = cursor->nslen - cursor->dblen - 1;
BSON_ASSERT (*collection_len > 0);
}
static bool
_mongoc_cursor_prepare_find_command (mongoc_cursor_t *cursor,
bson_t *command,
mongoc_server_stream_t *server_stream)
{
const char *collection;
int collection_len;
bson_iter_t iter;
_mongoc_cursor_collection (cursor, &collection, &collection_len);
- bson_append_utf8 (command, FIND, FIND_LEN, collection, collection_len);
- bson_append_document (command, FILTER, FILTER_LEN, &cursor->filter);
+ bson_append_utf8 (command, MONGOC_CURSOR_FIND, MONGOC_CURSOR_FIND_LEN, collection, collection_len);
+ bson_append_document (command, MONGOC_CURSOR_FILTER, MONGOC_CURSOR_FILTER_LEN, &cursor->filter);
bson_iter_init (&iter, &cursor->opts);
while (bson_iter_next (&iter)) {
/* don't append "maxAwaitTimeMS" */
- if (!strcmp (bson_iter_key (&iter), COLLATION) &&
+ if (!strcmp (bson_iter_key (&iter), MONGOC_CURSOR_COLLATION) &&
server_stream->sd->max_wire_version < WIRE_VERSION_COLLATION) {
bson_set_error (&cursor->error,
MONGOC_ERROR_CURSOR,
MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION,
"Collation is not supported by this server");
MARK_FAILED (cursor);
return false;
- }
- else if (strcmp (bson_iter_key (&iter), MAX_AWAIT_TIME_MS)) {
+ } else if (strcmp (bson_iter_key (&iter), MONGOC_CURSOR_MAX_AWAIT_TIME_MS)) {
if (!bson_append_iter (command, bson_iter_key (&iter), -1, &iter)) {
bson_set_error (&cursor->error, MONGOC_ERROR_BSON,
MONGOC_ERROR_BSON_INVALID, "Cursor opts too large");
MARK_FAILED (cursor);
return false;
}
}
}
if (cursor->read_concern->level != NULL) {
const bson_t *read_concern_bson;
read_concern_bson = _mongoc_read_concern_get_bson (cursor->read_concern);
- bson_append_document (command, READ_CONCERN, READ_CONCERN_LEN,
- read_concern_bson);
+ bson_append_document (
+ command, MONGOC_CURSOR_READ_CONCERN, MONGOC_CURSOR_READ_CONCERN_LEN, read_concern_bson);
}
return true;
}
static const bson_t *
_mongoc_cursor_find_command (mongoc_cursor_t *cursor,
mongoc_server_stream_t *server_stream)
{
bson_t command = BSON_INITIALIZER;
const bson_t *bson = NULL;
ENTRY;
if (!_mongoc_cursor_prepare_find_command (cursor, &command, server_stream)) {
RETURN (NULL);
}
_mongoc_cursor_cursorid_init (cursor, &command);
bson_destroy (&command);
BSON_ASSERT (cursor->iface.next);
_mongoc_cursor_cursorid_next (cursor, &bson);
RETURN (bson);
}
static const bson_t *
_mongoc_cursor_get_more (mongoc_cursor_t *cursor)
{
mongoc_server_stream_t *server_stream;
const bson_t *b = NULL;
ENTRY;
BSON_ASSERT (cursor);
server_stream = _mongoc_cursor_fetch_stream (cursor);
if (!server_stream) {
GOTO (failure);
}
if (!cursor->in_exhaust && !cursor->rpc.reply.cursor_id) {
bson_set_error (&cursor->error,
MONGOC_ERROR_CURSOR,
MONGOC_ERROR_CURSOR_INVALID_CURSOR,
"No valid cursor was provided.");
GOTO (failure);
}
if (!_mongoc_cursor_op_getmore (cursor, server_stream)) {
GOTO (failure);
}
mongoc_server_stream_cleanup (server_stream);
if (cursor->reader) {
_mongoc_read_from_buffer (cursor, &b);
}
RETURN (b);
failure:
cursor->done = true;
mongoc_server_stream_cleanup (server_stream);
RETURN (NULL);
}
static bool
_mongoc_cursor_monitor_legacy_get_more (mongoc_cursor_t *cursor,
mongoc_server_stream_t *server_stream)
{
bson_t doc;
char db[MONGOC_NAMESPACE_MAX];
mongoc_client_t *client;
mongoc_apm_command_started_t event;
ENTRY;
client = cursor->client;
if (!client->apm_callbacks.started) {
/* successful */
RETURN (true);
}
bson_init (&doc);
if (!_mongoc_cursor_prepare_getmore_command (cursor, &doc)) {
bson_destroy (&doc);
RETURN (false);
}
bson_strncpy (db, cursor->ns, cursor->dblen + 1);
mongoc_apm_command_started_init (&event,
&doc,
db,
"getMore",
client->cluster.request_id,
cursor->operation_id,
&server_stream->sd->host,
server_stream->sd->id,
client->apm_context);
client->apm_callbacks.started (&event);
mongoc_apm_command_started_cleanup (&event);
bson_destroy (&doc);
RETURN (true);
}
bool
_mongoc_cursor_op_getmore (mongoc_cursor_t *cursor,
mongoc_server_stream_t *server_stream)
{
int64_t started;
mongoc_rpc_t rpc;
uint32_t request_id;
mongoc_cluster_t *cluster;
mongoc_query_flags_t flags;
ENTRY;
started = bson_get_monotonic_time ();
cluster = &cursor->client->cluster;
if (!_mongoc_cursor_flags (cursor, server_stream, &flags)) {
GOTO (fail);
}
if (cursor->in_exhaust) {
request_id = (uint32_t) cursor->rpc.header.request_id;
} else {
request_id = ++cluster->request_id;
rpc.get_more.cursor_id = cursor->rpc.reply.cursor_id;
rpc.get_more.msg_len = 0;
rpc.get_more.request_id = request_id;
rpc.get_more.response_to = 0;
rpc.get_more.opcode = MONGOC_OPCODE_GET_MORE;
rpc.get_more.zero = 0;
rpc.get_more.collection = cursor->ns;
if (flags & MONGOC_QUERY_TAILABLE_CURSOR) {
rpc.get_more.n_return = 0;
} else {
rpc.get_more.n_return = _mongoc_n_return(cursor);
}
if (!_mongoc_cursor_monitor_legacy_get_more (cursor, server_stream)) {
GOTO (fail);
}
if (!mongoc_cluster_sendv_to_server (cluster, &rpc, 1, server_stream,
NULL, &cursor->error)) {
GOTO (fail);
}
}
_mongoc_buffer_clear (&cursor->buffer, false);
if (!_mongoc_client_recv (cursor->client,
&cursor->rpc,
&cursor->buffer,
server_stream,
&cursor->error)) {
GOTO (fail);
}
if (cursor->rpc.header.opcode != MONGOC_OPCODE_REPLY) {
bson_set_error (&cursor->error,
MONGOC_ERROR_PROTOCOL,
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
"Invalid opcode. Expected %d, got %d.",
MONGOC_OPCODE_REPLY, cursor->rpc.header.opcode);
GOTO (fail);
}
if (cursor->rpc.header.response_to != request_id) {
bson_set_error (&cursor->error,
MONGOC_ERROR_PROTOCOL,
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
"Invalid response_to for getmore. Expected %d, got %d.",
request_id, cursor->rpc.header.response_to);
GOTO (fail);
}
if (_mongoc_rpc_parse_query_error (&cursor->rpc,
cursor->client->error_api_version,
&cursor->error)) {
GOTO (fail);
}
if (cursor->reader) {
bson_reader_destroy (cursor->reader);
}
cursor->reader = bson_reader_new_from_data (
cursor->rpc.reply.documents,
(size_t)cursor->rpc.reply.documents_len);
_mongoc_cursor_monitor_succeeded (cursor,
bson_get_monotonic_time () - started,
false, /* not first batch */
server_stream,
"getMore");
RETURN (true);
fail:
_mongoc_cursor_monitor_failed (cursor,
bson_get_monotonic_time () - started,
server_stream,
"getMore");
RETURN (false);
}
bool
mongoc_cursor_error (mongoc_cursor_t *cursor,
bson_error_t *error)
{
bool ret;
ENTRY;
BSON_ASSERT(cursor);
if (cursor->iface.error) {
ret = cursor->iface.error(cursor, error);
} else {
ret = _mongoc_cursor_error(cursor, error);
}
RETURN(ret);
}
bool
_mongoc_cursor_error (mongoc_cursor_t *cursor,
bson_error_t *error)
{
ENTRY;
BSON_ASSERT (cursor);
if (BSON_UNLIKELY(CURSOR_FAILED (cursor))) {
bson_set_error(error,
cursor->error.domain,
cursor->error.code,
"%s",
cursor->error.message);
RETURN(true);
}
RETURN(false);
}
bool
mongoc_cursor_next (mongoc_cursor_t *cursor,
const bson_t **bson)
{
bool ret;
ENTRY;
BSON_ASSERT(cursor);
BSON_ASSERT(bson);
TRACE ("cursor_id(%"PRId64")", cursor->rpc.reply.cursor_id);
if (bson) {
*bson = NULL;
}
if (CURSOR_FAILED (cursor)) {
return false;
}
if (cursor->done) {
bson_set_error (&cursor->error,
MONGOC_ERROR_CURSOR,
MONGOC_ERROR_CURSOR_INVALID_CURSOR,
"Cannot advance a completed or failed cursor.");
return false;
}
/*
* We cannot proceed if another cursor is receiving results in exhaust mode.
*/
if (cursor->client->in_exhaust && !cursor->in_exhaust) {
bson_set_error (&cursor->error,
MONGOC_ERROR_CLIENT,
MONGOC_ERROR_CLIENT_IN_EXHAUST,
"Another cursor derived from this client is in exhaust.");
RETURN (false);
}
if (cursor->iface.next) {
ret = cursor->iface.next(cursor, bson);
} else {
ret = _mongoc_cursor_next(cursor, bson);
}
cursor->current = *bson;
cursor->count++;
RETURN(ret);
}
bool
_mongoc_read_from_buffer (mongoc_cursor_t *cursor,
const bson_t **bson)
{
bool eof = false;
BSON_ASSERT (cursor->reader);
*bson = bson_reader_read (cursor->reader, &eof);
cursor->end_of_event = eof ? 1 : 0;
return *bson ? true : false;
}
bool
_mongoc_cursor_next (mongoc_cursor_t *cursor,
const bson_t **bson)
{
int64_t limit;
const bson_t *b = NULL;
bool tailable;
ENTRY;
BSON_ASSERT (cursor);
if (bson) {
*bson = NULL;
}
/*
* If we reached our limit, make sure we mark this as done and do not try to
* make further progress.
*/
limit = mongoc_cursor_get_limit (cursor);
if (limit && cursor->count >= llabs (limit)) {
cursor->done = true;
RETURN (false);
}
/*
* Try to read the next document from the reader if it exists, we might
* get NULL back and EOF, in which case we need to submit a getmore.
*/
if (cursor->reader) {
_mongoc_read_from_buffer (cursor, &b);
if (b) {
GOTO (complete);
}
}
/*
* Check to see if we need to send a GET_MORE for more results.
*/
if (!cursor->sent) {
b = _mongoc_cursor_initial_query (cursor);
} else if (BSON_UNLIKELY (cursor->end_of_event) && cursor->rpc.reply.cursor_id) {
b = _mongoc_cursor_get_more (cursor);
}
complete:
tailable = _mongoc_cursor_get_opt_bool (cursor, "tailable");
cursor->done = (cursor->end_of_event &&
((cursor->in_exhaust && !cursor->rpc.reply.cursor_id) ||
(!b && !tailable)));
if (bson) {
*bson = b;
}
RETURN (!!b);
}
bool
mongoc_cursor_more (mongoc_cursor_t *cursor)
{
bool ret;
ENTRY;
BSON_ASSERT(cursor);
if (cursor->iface.more) {
ret = cursor->iface.more(cursor);
} else {
ret = _mongoc_cursor_more(cursor);
}
RETURN(ret);
}
bool
_mongoc_cursor_more (mongoc_cursor_t *cursor)
{
BSON_ASSERT (cursor);
if (CURSOR_FAILED (cursor)) {
return false;
}
return (!cursor->sent ||
cursor->rpc.reply.cursor_id ||
!cursor->end_of_event);
}
void
mongoc_cursor_get_host (mongoc_cursor_t *cursor,
mongoc_host_list_t *host)
{
BSON_ASSERT(cursor);
BSON_ASSERT(host);
if (cursor->iface.get_host) {
cursor->iface.get_host(cursor, host);
} else {
_mongoc_cursor_get_host(cursor, host);
}
EXIT;
}
void
_mongoc_cursor_get_host (mongoc_cursor_t *cursor,
mongoc_host_list_t *host)
{
mongoc_server_description_t *description;
BSON_ASSERT (cursor);
BSON_ASSERT (host);
memset(host, 0, sizeof *host);
if (!cursor->server_id) {
MONGOC_WARNING("%s(): Must send query before fetching peer.",
BSON_FUNC);
return;
}
description = mongoc_topology_server_by_id(cursor->client->topology,
cursor->server_id,
&cursor->error);
if (!description) {
return;
}
*host = description->host;
mongoc_server_description_destroy (description);
return;
}
mongoc_cursor_t *
mongoc_cursor_clone (const mongoc_cursor_t *cursor)
{
mongoc_cursor_t *ret;
BSON_ASSERT(cursor);
if (cursor->iface.clone) {
ret = cursor->iface.clone(cursor);
} else {
ret = _mongoc_cursor_clone(cursor);
}
RETURN(ret);
}
mongoc_cursor_t *
_mongoc_cursor_clone (const mongoc_cursor_t *cursor)
{
mongoc_cursor_t *_clone;
ENTRY;
BSON_ASSERT (cursor);
_clone = (mongoc_cursor_t *)bson_malloc0 (sizeof *_clone);
_clone->client = cursor->client;
_clone->is_command = cursor->is_command;
_clone->nslen = cursor->nslen;
_clone->dblen = cursor->dblen;
_clone->has_fields = cursor->has_fields;
if (cursor->read_prefs) {
_clone->read_prefs = mongoc_read_prefs_copy (cursor->read_prefs);
}
if (cursor->read_concern) {
_clone->read_concern = mongoc_read_concern_copy (cursor->read_concern);
}
bson_copy_to (&cursor->filter, &_clone->filter);
bson_copy_to (&cursor->opts, &_clone->opts);
bson_strncpy (_clone->ns, cursor->ns, sizeof _clone->ns);
_mongoc_buffer_init (&_clone->buffer, NULL, 0, NULL, NULL);
mongoc_counter_cursors_active_inc ();
RETURN (_clone);
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cursor_is_alive --
*
* Checks to see if a cursor is alive.
*
* This is primarily useful with tailable cursors.
*
* Returns:
* true if the cursor is alive.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
bool
mongoc_cursor_is_alive (const mongoc_cursor_t *cursor) /* IN */
{
BSON_ASSERT (cursor);
return !cursor->done;
}
const bson_t *
mongoc_cursor_current (const mongoc_cursor_t *cursor) /* IN */
{
BSON_ASSERT (cursor);
return cursor->current;
}
void
mongoc_cursor_set_batch_size (mongoc_cursor_t *cursor,
uint32_t batch_size)
{
BSON_ASSERT (cursor);
- _mongoc_cursor_set_opt_int64 (cursor,
- BATCH_SIZE,
- (int64_t) batch_size);
+ _mongoc_cursor_set_opt_int64 (cursor, MONGOC_CURSOR_BATCH_SIZE, (int64_t) batch_size);
}
uint32_t
mongoc_cursor_get_batch_size (const mongoc_cursor_t *cursor)
{
BSON_ASSERT (cursor);
- return (uint32_t) _mongoc_cursor_get_opt_int64 (cursor, BATCH_SIZE, 0);
+ return (uint32_t) _mongoc_cursor_get_opt_int64 (cursor, MONGOC_CURSOR_BATCH_SIZE, 0);
}
bool
mongoc_cursor_set_limit (mongoc_cursor_t *cursor,
int64_t limit)
{
BSON_ASSERT (cursor);
if (!cursor->sent) {
if (limit < 0) {
- return _mongoc_cursor_set_opt_int64 (cursor, LIMIT, -limit) &&
- _mongoc_cursor_set_opt_bool (cursor, SINGLE_BATCH, true);
+ return _mongoc_cursor_set_opt_int64 (cursor, MONGOC_CURSOR_LIMIT, -limit) &&
+ _mongoc_cursor_set_opt_bool (cursor, MONGOC_CURSOR_SINGLE_BATCH, true);
} else {
- return _mongoc_cursor_set_opt_int64 (cursor, LIMIT, limit);
+ return _mongoc_cursor_set_opt_int64 (cursor, MONGOC_CURSOR_LIMIT, limit);
}
} else {
return false;
}
}
int64_t
mongoc_cursor_get_limit (const mongoc_cursor_t *cursor)
{
int64_t limit;
bool single_batch;
BSON_ASSERT (cursor);
- limit = _mongoc_cursor_get_opt_int64 (cursor, LIMIT, 0);
- single_batch = _mongoc_cursor_get_opt_bool (cursor, SINGLE_BATCH);
+ limit = _mongoc_cursor_get_opt_int64 (cursor, MONGOC_CURSOR_LIMIT, 0);
+ single_batch = _mongoc_cursor_get_opt_bool (cursor, MONGOC_CURSOR_SINGLE_BATCH);
if (limit > 0 && single_batch) {
limit = -limit;
}
return limit;
}
bool
mongoc_cursor_set_hint (mongoc_cursor_t *cursor,
uint32_t server_id)
{
BSON_ASSERT (cursor);
if (cursor->server_id) {
MONGOC_ERROR ("mongoc_cursor_set_hint: server_id already set");
return false;
}
if (!server_id) {
MONGOC_ERROR ("mongoc_cursor_set_hint: cannot set server_id to 0");
return false;
}
cursor->server_id = server_id;
cursor->server_id_set = true;
return true;
}
uint32_t
mongoc_cursor_get_hint (const mongoc_cursor_t *cursor)
{
BSON_ASSERT (cursor);
return cursor->server_id;
}
int64_t
mongoc_cursor_get_id (const mongoc_cursor_t *cursor)
{
BSON_ASSERT(cursor);
return cursor->rpc.reply.cursor_id;
}
void
mongoc_cursor_set_max_await_time_ms (mongoc_cursor_t *cursor,
uint32_t max_await_time_ms)
{
BSON_ASSERT (cursor);
if (!cursor->sent) {
- _mongoc_cursor_set_opt_int64 (cursor,
- MAX_AWAIT_TIME_MS,
- (int64_t) max_await_time_ms);
+ _mongoc_cursor_set_opt_int64 (
+ cursor, MONGOC_CURSOR_MAX_AWAIT_TIME_MS, (int64_t) max_await_time_ms);
}
}
uint32_t
mongoc_cursor_get_max_await_time_ms (const mongoc_cursor_t *cursor)
{
bson_iter_t iter;
BSON_ASSERT (cursor);
- if (bson_iter_init_find (&iter, &cursor->opts, MAX_AWAIT_TIME_MS)) {
+ if (bson_iter_init_find (&iter, &cursor->opts, MONGOC_CURSOR_MAX_AWAIT_TIME_MS)) {
return (uint32_t) bson_iter_as_int64 (&iter);
}
return 0;
}
/*
*--------------------------------------------------------------------------
*
* mongoc_cursor_new_from_command_reply --
*
* Low-level function to initialize a mongoc_cursor_t from the
* reply to a command like "aggregate", "find", or "listCollections".
*
* Useful in drivers that wrap the C driver; in applications, use
* high-level functions like mongoc_collection_aggregate instead.
*
* Returns:
* A cursor.
*
* Side effects:
* On failure, the cursor's error is set: retrieve it with
* mongoc_cursor_error. On success or failure, "reply" is
* destroyed.
*
*--------------------------------------------------------------------------
*/
mongoc_cursor_t *
mongoc_cursor_new_from_command_reply (mongoc_client_t *client,
bson_t *reply,
uint32_t server_id)
{
mongoc_cursor_t *cursor;
bson_t cmd = BSON_INITIALIZER;
BSON_ASSERT (client);
BSON_ASSERT (reply);
cursor = _mongoc_cursor_new_with_opts (client, NULL, false /* is_command */,
NULL, NULL, NULL, NULL);
_mongoc_cursor_cursorid_init (cursor, &cmd);
_mongoc_cursor_cursorid_init_with_reply (cursor, reply, server_id);
bson_destroy (&cmd);
return cursor;
}
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-cursor.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-cursor.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-database-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-database-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-database-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-database-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-database.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-database.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-database.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-database.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-database.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-database.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-database.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-database.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-errno-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-errno-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-errno-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-errno-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-error.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-error.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-error.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-error.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-find-and-modify-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-find-and-modify-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-find-and-modify-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-find-and-modify-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-find-and-modify.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-find-and-modify.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-find-and-modify.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-find-and-modify.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-find-and-modify.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-find-and-modify.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-find-and-modify.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-find-and-modify.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-flags.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-flags.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-flags.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-flags.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-list-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-list-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-list-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-list-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-list.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-page-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-page-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-page-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-page-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-page.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-page.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-page.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-page.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-page.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-page.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-page.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-page.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file.h
similarity index 77%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file.h
index cf58bb3d..b5c179eb 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-file.h
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-file.h
@@ -1,136 +1,133 @@
/*
* Copyright 2013 MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MONGOC_GRIDFS_FILE_H
#define MONGOC_GRIDFS_FILE_H
#if !defined (MONGOC_INSIDE) && !defined (MONGOC_COMPILATION)
#error "Only <mongoc.h> can be included directly."
#endif
#include <bson.h>
#include "mongoc-socket.h"
BSON_BEGIN_DECLS
-#define MONGOC_GRIDFS_FILE_STR_HEADER(name) \
- BSON_API \
- const char * \
- mongoc_gridfs_file_get_##name (mongoc_gridfs_file_t * file); \
- void \
- mongoc_gridfs_file_set_##name (mongoc_gridfs_file_t * file, \
- const char *str);
-
-
-#define MONGOC_GRIDFS_FILE_BSON_HEADER(name) \
- BSON_API \
- const bson_t * \
- mongoc_gridfs_file_get_##name (mongoc_gridfs_file_t * file); \
- void \
- mongoc_gridfs_file_set_##name (mongoc_gridfs_file_t * file, \
- const bson_t * bson);
-
+#define MONGOC_GRIDFS_FILE_STR_HEADER(name) \
+ BSON_API \
+ const char *mongoc_gridfs_file_get_##name (mongoc_gridfs_file_t *file); \
+ BSON_API \
+ void mongoc_gridfs_file_set_##name (mongoc_gridfs_file_t *file, \
+ const char *str);
+
+
+#define MONGOC_GRIDFS_FILE_BSON_HEADER(name) \
+ BSON_API \
+ const bson_t *mongoc_gridfs_file_get_##name (mongoc_gridfs_file_t *file); \
+ BSON_API \
+ void mongoc_gridfs_file_set_##name (mongoc_gridfs_file_t *file, \
+ const bson_t *bson);
typedef struct _mongoc_gridfs_file_t mongoc_gridfs_file_t;
typedef struct _mongoc_gridfs_file_opt_t mongoc_gridfs_file_opt_t;
struct _mongoc_gridfs_file_opt_t
{
const char *md5;
const char *filename;
const char *content_type;
const bson_t *aliases;
const bson_t *metadata;
uint32_t chunk_size;
};
MONGOC_GRIDFS_FILE_STR_HEADER (md5)
MONGOC_GRIDFS_FILE_STR_HEADER (filename)
MONGOC_GRIDFS_FILE_STR_HEADER (content_type)
MONGOC_GRIDFS_FILE_BSON_HEADER (aliases)
MONGOC_GRIDFS_FILE_BSON_HEADER (metadata)
BSON_API
const bson_value_t *
mongoc_gridfs_file_get_id (mongoc_gridfs_file_t * file);
BSON_API
int64_t
mongoc_gridfs_file_get_length (mongoc_gridfs_file_t *file);
BSON_API
int32_t
mongoc_gridfs_file_get_chunk_size (mongoc_gridfs_file_t *file);
BSON_API
int64_t
mongoc_gridfs_file_get_upload_date (mongoc_gridfs_file_t *file);
BSON_API
ssize_t
mongoc_gridfs_file_writev (mongoc_gridfs_file_t *file,
mongoc_iovec_t *iov,
size_t iovcnt,
uint32_t timeout_msec);
BSON_API
ssize_t
mongoc_gridfs_file_readv (mongoc_gridfs_file_t *file,
mongoc_iovec_t *iov,
size_t iovcnt,
size_t min_bytes,
uint32_t timeout_msec);
BSON_API
int
mongoc_gridfs_file_seek (mongoc_gridfs_file_t *file,
int64_t delta,
int whence);
BSON_API
uint64_t
mongoc_gridfs_file_tell (mongoc_gridfs_file_t *file);
BSON_API
bool
mongoc_gridfs_file_set_id (mongoc_gridfs_file_t *file,
const bson_value_t *id,
bson_error_t *error);
BSON_API
bool
mongoc_gridfs_file_save (mongoc_gridfs_file_t *file);
BSON_API
void
mongoc_gridfs_file_destroy (mongoc_gridfs_file_t *file);
BSON_API
bool
mongoc_gridfs_file_error (mongoc_gridfs_file_t *file,
bson_error_t *error);
BSON_API
bool
mongoc_gridfs_file_remove (mongoc_gridfs_file_t *file,
bson_error_t *error);
BSON_END_DECLS
#endif /* MONGOC_GRIDFS_FILE_H */
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-gridfs.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-gridfs.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-handshake-compiler-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-handshake-compiler-private.h
similarity index 93%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-handshake-compiler-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-handshake-compiler-private.h
index 602e1058..201a30c4 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-handshake-compiler-private.h
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-handshake-compiler-private.h
@@ -1,63 +1,60 @@
/*
* Copyright 2016 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MONGOC_HANDSHAKE_COMPILER_PRIVATE_H
#define MONGOC_HANDSHAKE_COMPILER_PRIVATE_H
#include "mongoc-config.h"
-
-/* Helper macros for stringifying things */
-#define MONGOC_STR(s) #s
-#define MONGOC_EVALUATE_STR(s) MONGOC_STR(s)
+#include "mongoc-util-private.h"
/*
* Thanks to:
* http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
*/
#if defined(__clang__)
#define MONGOC_COMPILER "clang"
#define MONGOC_COMPILER_VERSION __clang_version__
#elif defined(__ICC) || defined(__INTEL_COMPILER)
#define MONGOC_COMPILER "ICC"
#define MONGOC_COMPILER_VERSION __VERSION__
#elif defined(__GNUC__) || defined(__GNUG__)
#define MONGOC_COMPILER "GCC"
#define MONGOC_COMPILER_VERSION __VERSION__
#elif defined(__HP_cc) || defined(__HP_aCC)
#define MONGOC_COMPILER "aCC"
#define MONGOC_COMPILER_VERSION MONGOC_EVALUATE_STR (__HP_cc)
#elif defined(__IBMC__) || defined(__IBMCPP__)
#define MONGOC_COMPILER "xlc"
#define MONGOC_COMPILER_VERSION __xlc__
#elif defined(_MSC_VER)
#define MONGOC_COMPILER "MSVC"
#define MONGOC_COMPILER_VERSION MONGOC_EVALUATE_STR (_MSC_VER)
#elif defined(__PGI)
#define MONGOC_COMPILER "Portland PGCC"
#define MONGOC_COMPILER_VERSION MONGOC_EVALUATE_STR (__PGIC__) "." MONGOC_EVALUATE_STR (__PGIC_MINOR) "." MONGOC_EVALUATE_STR (__PGIC_PATCHLEVEL__)
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
#define MONGOC_COMPILER "Solaris Studio"
#define MONGOC_COMPILER_VERSION MONGOC_EVALUATE_STR (__SUNPRO_C)
#elif defined (__PCC__)
/* Portable C Compiler. Version may not be available */
#define MONGOC_COMPILER "PCC"
#else
- #define MONGOC_COMPILER MONGOC_CC
+ #define MONGOC_COMPILER MONGOC_EVALUATE_STR (MONGOC_CC)
/* Not defining COMPILER_VERSION. We'll fall back to values set at
* configure-time */
#endif
#endif
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-handshake-os-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-handshake-os-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-handshake-os-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-handshake-os-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-handshake-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-handshake-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-handshake-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-handshake-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-handshake.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-handshake.c
similarity index 97%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-handshake.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-handshake.c
index 884874b6..8673e2e8 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-handshake.c
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-handshake.c
@@ -1,514 +1,516 @@
/*
* Copyright 2016 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <bson.h>
#ifdef _POSIX_VERSION
#include <sys/utsname.h>
#endif
#ifdef _WIN32
#include <windows.h>
#endif
#include "mongoc-linux-distro-scanner-private.h"
#include "mongoc-handshake.h"
#include "mongoc-handshake-compiler-private.h"
#include "mongoc-handshake-os-private.h"
#include "mongoc-handshake-private.h"
#include "mongoc-client.h"
#include "mongoc-client-private.h"
#include "mongoc-error.h"
#include "mongoc-log.h"
#include "mongoc-version.h"
#include "mongoc-util-private.h"
/*
* Global handshake data instance. Initialized at startup from mongoc_init ()
*
* Can be modified by calls to mongoc_handshake_data_append ()
*/
static mongoc_handshake_t gMongocHandshake;
static uint32_t
_get_config_bitfield (void)
{
uint32_t bf = 0;
#ifdef MONGOC_ENABLE_SSL_SECURE_CHANNEL
bf |= MONGOC_MD_FLAG_ENABLE_SSL_SECURE_CHANNEL;
#endif
#ifdef MONGOC_ENABLE_CRYPTO_CNG
bf |= MONGOC_MD_FLAG_ENABLE_CRYPTO_CNG;
#endif
#ifdef MONGOC_ENABLE_SSL_SECURE_TRANSPORT
bf |= MONGOC_MD_FLAG_ENABLE_SSL_SECURE_TRANSPORT;
#endif
#ifdef MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO
bf |= MONGOC_MD_FLAG_ENABLE_CRYPTO_COMMON_CRYPTO;
#endif
#ifdef MONGOC_ENABLE_SSL_OPENSSL
bf |= MONGOC_MD_FLAG_ENABLE_SSL_OPENSSL;
#endif
#ifdef MONGOC_ENABLE_CRYPTO_LIBCRYPTO
bf |= MONGOC_MD_FLAG_ENABLE_CRYPTO_LIBCRYPTO;
#endif
#ifdef MONGOC_ENABLE_SSL
bf |= MONGOC_MD_FLAG_ENABLE_SSL;
#endif
#ifdef MONGOC_ENABLE_CRYPTO
bf |= MONGOC_MD_FLAG_ENABLE_CRYPTO;
#endif
#ifdef MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE
bf |= MONGOC_MD_FLAG_ENABLE_CRYPTO_SYSTEM_PROFILE;
#endif
#ifdef MONGOC_ENABLE_SASL
bf |= MONGOC_MD_FLAG_ENABLE_SASL;
#endif
#ifdef MONGOC_HAVE_SASL_CLIENT_DONE
bf |= MONGOC_MD_FLAG_HAVE_SASL_CLIENT_DONE;
#endif
#ifdef MONGOC_HAVE_WEAK_SYMBOLS
bf |= MONGOC_MD_FLAG_HAVE_WEAK_SYMBOLS;
#endif
#ifdef MONGOC_NO_AUTOMATIC_GLOBALS
bf |= MONGOC_MD_FLAG_NO_AUTOMATIC_GLOBALS;
#endif
#ifdef MONGOC_EXPERIMENTAL_FEATURES
bf |= MONGOC_MD_FLAG_EXPERIMENTAL_FEATURES;
#endif
#ifdef MONGOC_MD_FLAG_ENABLE_SSL_LIBRESSL
bf |= MONGOC_MD_FLAG_ENABLE_SSL_LIBRESSL;
#endif
return bf;
}
static char *
_get_os_type (void)
{
#ifdef MONGOC_OS_TYPE
return bson_strndup (MONGOC_OS_TYPE, HANDSHAKE_OS_TYPE_MAX);
#else
return bson_strndup ("unknown", HANDSHAKE_OS_TYPE_MAX);
#endif
}
static char *
_get_os_architecture (void)
{
const char *ret = NULL;
#ifdef _WIN32
SYSTEM_INFO system_info;
DWORD arch;
GetSystemInfo (&system_info);
arch = system_info.wProcessorArchitecture;
switch (arch) {
case PROCESSOR_ARCHITECTURE_AMD64:
ret = "x86_64";
break;
case PROCESSOR_ARCHITECTURE_ARM:
ret = "ARM";
break;
case PROCESSOR_ARCHITECTURE_IA64:
ret = "IA64";
break;
case PROCESSOR_ARCHITECTURE_INTEL:
ret = "x86";
break;
case PROCESSOR_ARCHITECTURE_UNKNOWN:
ret = "Unknown";
break;
default:
ret = "Other";
break;
}
#elif defined (_POSIX_VERSION)
struct utsname system_info;
if (uname (&system_info) >= 0) {
ret = system_info.machine;
}
#endif
if (ret) {
return bson_strndup (ret, HANDSHAKE_OS_ARCHITECTURE_MAX);
}
return NULL;
}
#ifndef MONGOC_OS_IS_LINUX
static char *
_get_os_name (void)
{
#ifdef MONGOC_OS_NAME
return bson_strndup (MONGOC_OS_NAME, HANDSHAKE_OS_NAME_MAX);
#elif defined (_POSIX_VERSION)
struct utsname system_info;
if (uname (&system_info) >= 0) {
return bson_strndup (system_info.sysname, HANDSHAKE_OS_NAME_MAX);
}
#endif
return NULL;
}
static char *
_get_os_version (void)
{
char *ret = bson_malloc (HANDSHAKE_OS_VERSION_MAX);
bool found = false;
#ifdef _WIN32
OSVERSIONINFO osvi;
ZeroMemory (&osvi, sizeof (OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (GetVersionEx (&osvi)) {
bson_snprintf (ret,
HANDSHAKE_OS_VERSION_MAX,
"%d.%d (%d)",
osvi.dwMajorVersion,
osvi.dwMinorVersion,
osvi.dwBuildNumber);
found = true;
} else {
MONGOC_WARNING ("Error with GetVersionEx(): %d",
GetLastError ());
}
#elif defined (_POSIX_VERSION)
struct utsname system_info;
if (uname (&system_info) >= 0) {
bson_strncpy (ret, system_info.release,
HANDSHAKE_OS_VERSION_MAX);
found = true;
} else {
MONGOC_WARNING ("Error with uname(): %d", errno);
}
#endif
if (!found) {
bson_free (ret);
ret = NULL;
}
return ret;
}
#endif
static void
_get_system_info (mongoc_handshake_t *handshake)
{
handshake->os_type = _get_os_type ();
#ifdef MONGOC_OS_IS_LINUX
_mongoc_linux_distro_scanner_get_distro (&handshake->os_name,
&handshake->os_version);
#else
handshake->os_name = _get_os_name ();
handshake->os_version = _get_os_version ();
#endif
handshake->os_architecture = _get_os_architecture ();
}
static void
_free_system_info (mongoc_handshake_t *handshake)
{
bson_free (handshake->os_type);
bson_free (handshake->os_name);
bson_free (handshake->os_version);
bson_free (handshake->os_architecture);
}
static void
_get_driver_info (mongoc_handshake_t *handshake)
{
handshake->driver_name = bson_strndup ("mongoc",
HANDSHAKE_DRIVER_NAME_MAX);
handshake->driver_version = bson_strndup (MONGOC_VERSION_S,
HANDSHAKE_DRIVER_VERSION_MAX);
}
static void
_free_driver_info (mongoc_handshake_t *handshake)
{
bson_free (handshake->driver_name);
bson_free (handshake->driver_version);
}
static void
_set_platform_string (mongoc_handshake_t *handshake)
{
bson_string_t *str;
str = bson_string_new ("");
bson_string_append_printf (str, "cfg=0x%x",
_get_config_bitfield ());
#ifdef _POSIX_VERSION
bson_string_append_printf (str, " posix=%ld", _POSIX_VERSION);
#endif
#ifdef __STDC_VERSION__
bson_string_append_printf (str, " stdc=%ld", __STDC_VERSION__);
#endif
bson_string_append_printf (str, " CC=%s", MONGOC_COMPILER);
#ifdef MONGOC_COMPILER_VERSION
bson_string_append_printf (str, " %s", MONGOC_COMPILER_VERSION);
#endif
- if (strlen (MONGOC_USER_SET_CFLAGS) > 0) {
- bson_string_append_printf (str, " CFLAGS=%s", MONGOC_USER_SET_CFLAGS);
+ if (strlen (MONGOC_EVALUATE_STR (MONGOC_USER_SET_CFLAGS)) > 0) {
+ bson_string_append_printf (
+ str, " CFLAGS=%s", MONGOC_EVALUATE_STR (MONGOC_USER_SET_CFLAGS));
}
- if (strlen (MONGOC_USER_SET_LDFLAGS) > 0) {
- bson_string_append_printf (str, " LDFLAGS=%s", MONGOC_USER_SET_LDFLAGS);
+ if (strlen (MONGOC_EVALUATE_STR (MONGOC_USER_SET_LDFLAGS)) > 0) {
+ bson_string_append_printf (
+ str, " LDFLAGS=%s", MONGOC_EVALUATE_STR (MONGOC_USER_SET_LDFLAGS));
}
handshake->platform = bson_string_free (str, false);
}
static void
_free_platform_string (mongoc_handshake_t *handshake)
{
bson_free (handshake->platform);
}
void
_mongoc_handshake_init (void)
{
_get_system_info (&gMongocHandshake);
_get_driver_info (&gMongocHandshake);
_set_platform_string (&gMongocHandshake);
gMongocHandshake.frozen = false;
}
void
_mongoc_handshake_cleanup (void)
{
_free_system_info (&gMongocHandshake);
_free_driver_info (&gMongocHandshake);
_free_platform_string (&gMongocHandshake);
}
static bool
_append_platform_field (bson_t *doc,
const char *platform)
{
int max_platform_str_size;
/* Compute space left for platform field */
max_platform_str_size = HANDSHAKE_MAX_SIZE -
(doc->len +
/* 1 byte for utf8 tag */
1 +
/* key size */
strlen (HANDSHAKE_PLATFORM_FIELD) + 1 +
/* 4 bytes for length of string */
4);
if (max_platform_str_size <= 0) {
return false;
}
max_platform_str_size = BSON_MIN (max_platform_str_size,
strlen (platform) + 1);
bson_append_utf8 (doc, HANDSHAKE_PLATFORM_FIELD, -1,
platform, max_platform_str_size - 1);
BSON_ASSERT (doc->len <= HANDSHAKE_MAX_SIZE);
return true;
}
/*
* Return true if we build the document, and it's not too big
* false if there's no way to prevent the doc from being too big. In this
* case, the caller shouldn't include it with isMaster
*/
bool
_mongoc_handshake_build_doc_with_application (bson_t *doc,
const char *appname)
{
const mongoc_handshake_t *md = &gMongocHandshake;
bson_t child;
if (appname) {
BSON_APPEND_DOCUMENT_BEGIN (doc, "application", &child);
BSON_APPEND_UTF8 (&child, "name", appname);
bson_append_document_end (doc, &child);
}
BSON_APPEND_DOCUMENT_BEGIN (doc, "driver", &child);
BSON_APPEND_UTF8 (&child, "name", md->driver_name);
BSON_APPEND_UTF8 (&child, "version", md->driver_version);
bson_append_document_end (doc, &child);
BSON_APPEND_DOCUMENT_BEGIN (doc, "os", &child);
BSON_ASSERT (md->os_type);
BSON_APPEND_UTF8 (&child, "type", md->os_type);
if (md->os_name) {
BSON_APPEND_UTF8 (&child, "name", md->os_name);
}
if (md->os_version) {
BSON_APPEND_UTF8 (&child, "version", md->os_version);
}
if (md->os_architecture) {
BSON_APPEND_UTF8 (&child, "architecture", md->os_architecture);
}
bson_append_document_end (doc, &child);
if (doc->len > HANDSHAKE_MAX_SIZE) {
/* We've done all we can possibly do to ensure the current
* document is below the maxsize, so if it overflows there is
* nothing else we can do, so we fail */
return false;
}
if (md->platform) {
_append_platform_field (doc, md->platform);
}
return true;
}
void
_mongoc_handshake_freeze (void)
{
gMongocHandshake.frozen = true;
}
/*
* free (*s) and make *s point to *s concated with suffix.
* If *s is NULL it's treated like it's an empty string.
* If suffix is NULL, nothing happens.
*/
static void
_append_and_truncate (char **s,
const char *suffix,
int max_len)
{
char *old_str = *s;
char *prefix;
const int delim_len = strlen (" / ");
int space_for_suffix;
BSON_ASSERT (s);
prefix = old_str ? old_str : "";
if (!suffix) {
return;
}
space_for_suffix = max_len - strlen (prefix) - delim_len;
BSON_ASSERT (space_for_suffix >= 0);
*s = bson_strdup_printf ("%s / %.*s", prefix, space_for_suffix, suffix);
BSON_ASSERT (strlen (*s) <= max_len);
bson_free (old_str);
}
/*
* Set some values in our global handshake struct. These values will be sent
* to the server as part of the initial connection handshake (isMaster).
* If this function is called more than once, or after we've connected to a
* mongod, then it will do nothing and return false. It will return true if it
* successfully sets the values.
*
* All arguments are optional.
*/
bool
mongoc_handshake_data_append (const char *driver_name,
const char *driver_version,
const char *platform)
{
int max_size = 0;
if (gMongocHandshake.frozen) {
MONGOC_ERROR ("Cannot set handshake more than once");
return false;
}
_append_and_truncate (&gMongocHandshake.driver_name, driver_name,
HANDSHAKE_DRIVER_NAME_MAX);
_append_and_truncate (&gMongocHandshake.driver_version, driver_version,
HANDSHAKE_DRIVER_VERSION_MAX);
max_size = HANDSHAKE_MAX_SIZE -
-_mongoc_strlen_or_zero (gMongocHandshake.os_type)
- _mongoc_strlen_or_zero (gMongocHandshake.os_name)
- _mongoc_strlen_or_zero (gMongocHandshake.os_version)
- _mongoc_strlen_or_zero (gMongocHandshake.os_architecture)
- _mongoc_strlen_or_zero (gMongocHandshake.driver_name)
- _mongoc_strlen_or_zero (gMongocHandshake.driver_version);
_append_and_truncate (&gMongocHandshake.platform, platform, max_size);
_mongoc_handshake_freeze ();
return true;
}
mongoc_handshake_t *
_mongoc_handshake_get (void)
{
return &gMongocHandshake;
}
bool
_mongoc_handshake_appname_is_valid (const char *appname)
{
return strlen (appname) <= MONGOC_HANDSHAKE_APPNAME_MAX;
}
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-handshake.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-handshake.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-handshake.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-handshake.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-host-list-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-host-list-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-host-list-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-host-list-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-host-list.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-host-list.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-host-list.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-host-list.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-host-list.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-host-list.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-host-list.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-host-list.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-index.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-index.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-index.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-index.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-index.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-index.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-index.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-index.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-init.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-init.c
similarity index 98%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-init.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-init.c
index d5343bbd..a20eda39 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-init.c
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-init.c
@@ -1,192 +1,194 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <bson.h>
#include "mongoc-config.h"
#include "mongoc-counters-private.h"
#include "mongoc-init.h"
#include "mongoc-handshake-private.h"
#ifdef MONGOC_ENABLE_SSL
# include "mongoc-scram-private.h"
# include "mongoc-ssl.h"
# ifdef MONGOC_ENABLE_SSL_OPENSSL
# include "mongoc-openssl-private.h"
+#elif defined(MONGOC_ENABLE_SSL_LIBRESSL)
+# include "tls.h"
# endif
#endif
#include "mongoc-thread-private.h"
#include "mongoc-trace-private.h"
#ifndef MONGOC_NO_AUTOMATIC_GLOBALS
#pragma message("Configure the driver with --disable-automatic-init-and-cleanup\
(if using ./configure) or ENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF (with cmake).\
Automatic cleanup is deprecated and will be removed in version 2.0.")
#endif
#ifdef MONGOC_ENABLE_SASL
#include <sasl/sasl.h>
static void *
mongoc_sasl_mutex_alloc (void)
{
mongoc_mutex_t *mutex;
mutex = (mongoc_mutex_t *)bson_malloc0 (sizeof (mongoc_mutex_t));
mongoc_mutex_init (mutex);
return (void *) mutex;
}
static int
mongoc_sasl_mutex_lock (void *mutex)
{
mongoc_mutex_lock ((mongoc_mutex_t *) mutex);
return SASL_OK;
}
static int
mongoc_sasl_mutex_unlock (void *mutex)
{
mongoc_mutex_unlock ((mongoc_mutex_t *) mutex);
return SASL_OK;
}
static void
mongoc_sasl_mutex_free (void *mutex)
{
mongoc_mutex_destroy ((mongoc_mutex_t *) mutex);
bson_free (mutex);
}
#endif /* MONGOC_ENABLE_SASL */
static MONGOC_ONCE_FUN( _mongoc_do_init)
{
#ifdef MONGOC_ENABLE_SSL_OPENSSL
_mongoc_openssl_init ();
#elif defined(MONGOC_ENABLE_SSL_LIBRESSL)
tls_init ();
#endif
#ifdef MONGOC_ENABLE_SSL
_mongoc_scram_startup ();
#endif
#ifdef MONGOC_ENABLE_SASL
/* The following functions should not use tracing, as they may be invoked
* before mongoc_log_set_handler() can complete. */
sasl_set_mutex (mongoc_sasl_mutex_alloc,
mongoc_sasl_mutex_lock,
mongoc_sasl_mutex_unlock,
mongoc_sasl_mutex_free);
/* TODO: logging callback? */
sasl_client_init (NULL);
#endif
_mongoc_counters_init ();
#ifdef _WIN32
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD (2, 2);
err = WSAStartup (wVersionRequested, &wsaData);
/* check the version perhaps? */
BSON_ASSERT (err == 0);
}
#endif
_mongoc_handshake_init ();
MONGOC_ONCE_RETURN;
}
void
mongoc_init (void)
{
static mongoc_once_t once = MONGOC_ONCE_INIT;
mongoc_once (&once, _mongoc_do_init);
}
static MONGOC_ONCE_FUN( _mongoc_do_cleanup)
{
#ifdef MONGOC_ENABLE_SSL_OPENSSL
_mongoc_openssl_cleanup ();
#endif
#ifdef MONGOC_ENABLE_SASL
#ifdef MONGOC_HAVE_SASL_CLIENT_DONE
sasl_client_done ();
#else
/* fall back to deprecated function */
sasl_done ();
#endif
#endif
#ifdef _WIN32
WSACleanup ();
#endif
_mongoc_counters_cleanup ();
_mongoc_handshake_cleanup ();
MONGOC_ONCE_RETURN;
}
void
mongoc_cleanup (void)
{
static mongoc_once_t once = MONGOC_ONCE_INIT;
mongoc_once (&once, _mongoc_do_cleanup);
}
/*
* On GCC, just use __attribute__((constructor)) to perform initialization
* automatically for the application.
*/
#if defined(__GNUC__) && ! defined(MONGOC_NO_AUTOMATIC_GLOBALS)
static void _mongoc_init_ctor (void) __attribute__((constructor));
static void
_mongoc_init_ctor (void)
{
mongoc_init ();
}
static void _mongoc_init_dtor (void) __attribute__((destructor));
static void
_mongoc_init_dtor (void)
{
bson_mem_restore_vtable ();
mongoc_cleanup ();
}
#endif
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-init.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-init.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-init.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-init.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-iovec.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-iovec.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-iovec.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-iovec.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-libressl-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-libressl-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-libressl-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-libressl-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-libressl.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-libressl.c
similarity index 96%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-libressl.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-libressl.c
index 2e8d379a..56bbd6f5 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-libressl.c
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-libressl.c
@@ -1,76 +1,76 @@
/*
* Copyright 2016 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mongoc-config.h"
#ifdef MONGOC_ENABLE_SSL_LIBRESSL
#include <bson.h>
#include "mongoc-log.h"
#include "mongoc-trace-private.h"
#include "mongoc-ssl.h"
#include "mongoc-stream-tls.h"
#include "mongoc-stream-tls-private.h"
#include "mongoc-libressl-private.h"
#include "mongoc-stream-tls-libressl-private.h"
#include <tls.h>
#undef MONGOC_LOG_DOMAIN
#define MONGOC_LOG_DOMAIN "stream-libressl"
bool
mongoc_libressl_setup_certificate (mongoc_stream_tls_libressl_t *libressl,
mongoc_ssl_opt_t *opt)
{
uint8_t *file;
size_t file_len;
if (!opt->pem_file) {
return false;
}
- file = tls_load_file (opt->pem_file, &file_len, opt->pem_pwd);
+ file = tls_load_file (opt->pem_file, &file_len, (char *)opt->pem_pwd);
if (!file) {
return false;
}
if (tls_config_set_keypair_mem (libressl->config, file, file_len, file, file_len) == -1) {
MONGOC_ERROR("%s", tls_config_error (libressl->config));
return false;
}
return true;
}
bool
mongoc_libressl_setup_ca (mongoc_stream_tls_libressl_t *libressl,
mongoc_ssl_opt_t *opt)
{
if (opt->ca_file) {
tls_config_set_ca_file (libressl->config, opt->ca_file);
}
if (opt->ca_dir) {
tls_config_set_ca_path (libressl->config, opt->ca_dir);
}
return true;
}
#endif
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-linux-distro-scanner-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-linux-distro-scanner-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-linux-distro-scanner-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-linux-distro-scanner-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-linux-distro-scanner.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-linux-distro-scanner.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-linux-distro-scanner.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-linux-distro-scanner.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-list-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-list-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-list-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-list-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-list.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-list.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-list.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-list.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-log-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-log-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-log-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-log-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-log.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-log.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-log.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-log.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-log.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-log.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-log.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-log.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-matcher-op-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-matcher-op-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-matcher-op-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-matcher-op-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-matcher-op.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-matcher-op.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-matcher-op.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-matcher-op.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-matcher-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-matcher-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-matcher-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-matcher-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-matcher.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-matcher.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-matcher.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-matcher.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-matcher.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-matcher.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-matcher.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-matcher.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-memcmp-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-memcmp-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-memcmp-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-memcmp-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-memcmp.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-memcmp.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-memcmp.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-memcmp.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-opcode-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-opcode-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-opcode-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-opcode-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-opcode.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-opcode.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-opcode.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-opcode.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-opcode.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-opcode.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-opcode.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-opcode.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-openssl-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-openssl-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-openssl-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-openssl-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-openssl.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-openssl.c
similarity index 96%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-openssl.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-openssl.c
index 8d2ea25e..71605543 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-openssl.c
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-openssl.c
@@ -1,641 +1,654 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mongoc-config.h"
#ifdef MONGOC_ENABLE_SSL_OPENSSL
#include <bson.h>
#include <limits.h>
#include <openssl/bio.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/x509v3.h>
#include <openssl/crypto.h>
#include <string.h>
#include "mongoc-init.h"
#include "mongoc-socket.h"
#include "mongoc-ssl.h"
#include "mongoc-openssl-private.h"
#include "mongoc-trace-private.h"
#include "mongoc-thread-private.h"
#include "mongoc-util-private.h"
#ifdef _WIN32
#include <wincrypt.h>
#endif
#if OPENSSL_VERSION_NUMBER < 0x10100000L
static mongoc_mutex_t * gMongocOpenSslThreadLocks;
static void _mongoc_openssl_thread_startup(void);
static void _mongoc_openssl_thread_cleanup(void);
#endif
/**
* _mongoc_openssl_init:
*
* initialization function for SSL
*
* This needs to get called early on and is not threadsafe. Called by
* mongoc_init.
*/
void
_mongoc_openssl_init (void)
{
SSL_CTX *ctx;
SSL_library_init ();
SSL_load_error_strings ();
ERR_load_BIO_strings ();
OpenSSL_add_all_algorithms ();
#if OPENSSL_VERSION_NUMBER < 0x10100000L
_mongoc_openssl_thread_startup ();
#endif
/*
* Ensure we also load the ciphers now from the primary thread
* or we can run into some weirdness on 64-bit Solaris 10 on
* SPARC with openssl 0.9.7.
*/
ctx = SSL_CTX_new (SSLv23_method ());
if (!ctx) {
MONGOC_ERROR ("Failed to initialize OpenSSL.");
}
SSL_CTX_free (ctx);
}
void
_mongoc_openssl_cleanup (void)
{
#if OPENSSL_VERSION_NUMBER < 0x10100000L
_mongoc_openssl_thread_cleanup ();
#endif
}
static int
_mongoc_openssl_password_cb (char *buf,
int num,
int rwflag,
void *user_data)
{
char *pass = (char *)user_data;
int pass_len = (int)strlen (pass);
if (num < pass_len + 1) {
return 0;
}
bson_strncpy (buf, pass, num);
return pass_len;
}
#ifdef _WIN32
bool
_mongoc_openssl_import_cert_store (LPWSTR store_name, DWORD dwFlags, X509_STORE* openssl_store)
{
PCCERT_CONTEXT cert = NULL;
HCERTSTORE cert_store;
cert_store = CertOpenStore (CERT_STORE_PROV_SYSTEM, /* provider */
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, /* certificate encoding */
0, /* unused */
dwFlags, /* dwFlags */
store_name); /* system store name. "My" or "Root" */
if (cert_store == NULL) {
- MONGOC_WARNING ("error opening system CA store");
+ LPTSTR msg = NULL;
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_ARGUMENT_ARRAY,
+ NULL,
+ GetLastError (),
+ LANG_NEUTRAL,
+ (LPTSTR) &msg,
+ 0,
+ NULL);
+ MONGOC_ERROR ("Can't open CA store: 0x%.8X: '%s'",
+ GetLastError (),
+ msg);
+ LocalFree (msg);
return false;
}
while ((cert = CertEnumCertificatesInStore (cert_store, cert)) != NULL) {
X509* x509Obj = d2i_X509 (NULL, (const unsigned char **)&cert->pbCertEncoded, cert->cbCertEncoded);
if (x509Obj == NULL) {
MONGOC_WARNING ("Error parsing X509 object from Windows certificate store");
continue;
}
X509_STORE_add_cert (openssl_store, x509Obj);
X509_free (x509Obj);
}
CertCloseStore(cert_store, 0);
return true;
}
bool
_mongoc_openssl_import_cert_stores (SSL_CTX *context)
{
bool retval;
X509_STORE *store = SSL_CTX_get_cert_store (context);
if (!store) {
MONGOC_WARNING ("no X509 store found for SSL context while loading system certificates");
return false;
}
- retval = _mongoc_openssl_import_cert_store (L"root", CERT_SYSTEM_STORE_CURRENT_USER, store);
+ retval = _mongoc_openssl_import_cert_store (L"root", CERT_SYSTEM_STORE_CURRENT_USER|CERT_STORE_READONLY_FLAG, store);
if (retval) {
return retval;
}
- return _mongoc_openssl_import_cert_store (L"CA", CERT_SYSTEM_STORE_CURRENT_USER, store);
+ return _mongoc_openssl_import_cert_store (L"CA", CERT_SYSTEM_STORE_CURRENT_USER|CERT_STORE_READONLY_FLAG, store);
}
#endif
/** mongoc_openssl_hostcheck
*
* rfc 6125 match a given hostname against a given pattern
*
* Patterns come from DNS common names or subjectAltNames.
*
* This code is meant to implement RFC 6125 6.4.[1-3]
*
*/
static bool
_mongoc_openssl_hostcheck (const char *pattern,
const char *hostname)
{
const char *pattern_label_end;
const char *pattern_wildcard;
const char *hostname_label_end;
size_t prefixlen;
size_t suffixlen;
TRACE("Comparing '%s' == '%s'", pattern, hostname);
pattern_wildcard = strchr (pattern, '*');
if (pattern_wildcard == NULL) {
return strcasecmp (pattern, hostname) == 0;
}
pattern_label_end = strchr (pattern, '.');
/* Bail out on wildcarding in a couple of situations:
* o we don't have 2 dots - we're not going to wildcard root tlds
* o the wildcard isn't in the left most group (separated by dots)
* o the pattern is embedded in an A-label or U-label
*/
if (pattern_label_end == NULL ||
strchr (pattern_label_end + 1, '.') == NULL ||
pattern_wildcard > pattern_label_end ||
strncasecmp (pattern, "xn--", 4) == 0) {
return strcasecmp (pattern, hostname) == 0;
}
hostname_label_end = strchr (hostname, '.');
/* we know we have a dot in the pattern, we need one in the hostname */
if (hostname_label_end == NULL ||
strcasecmp (pattern_label_end, hostname_label_end)) {
return 0;
}
/* The wildcard must match at least one character, so the left part of the
* hostname is at least as large as the left part of the pattern. */
if ((hostname_label_end - hostname) < (pattern_label_end - pattern)) {
return 0;
}
/* If the left prefix group before the star matches and right of the star
* matches... we have a wildcard match */
prefixlen = pattern_wildcard - pattern;
suffixlen = pattern_label_end - (pattern_wildcard + 1);
return strncasecmp (pattern, hostname, prefixlen) == 0 &&
strncasecmp (pattern_wildcard + 1, hostname_label_end - suffixlen,
suffixlen) == 0;
}
/** check if a provided cert matches a passed hostname
*/
bool
_mongoc_openssl_check_cert (SSL *ssl,
const char *host,
bool allow_invalid_hostname)
{
X509 *peer;
X509_NAME *subject_name;
X509_NAME_ENTRY *entry;
ASN1_STRING *entry_data;
char *check;
int length;
int idx;
int r = 0;
long verify_status;
size_t addrlen = 0;
unsigned char addr4[sizeof(struct in_addr)];
unsigned char addr6[sizeof(struct in6_addr)];
int i;
int n_sans = -1;
int target = GEN_DNS;
STACK_OF (GENERAL_NAME) * sans = NULL;
ENTRY;
BSON_ASSERT (ssl);
BSON_ASSERT (host);
if (allow_invalid_hostname) {
RETURN (true);
}
/** if the host looks like an IP address, match that, otherwise we assume we
* have a DNS name */
if (inet_pton (AF_INET, host, &addr4)) {
target = GEN_IPADD;
addrlen = sizeof addr4;
} else if (inet_pton (AF_INET6, host, &addr6)) {
target = GEN_IPADD;
addrlen = sizeof addr6;
}
peer = SSL_get_peer_certificate (ssl);
if (!peer) {
MONGOC_WARNING ("SSL Certification verification failed: %s", ERR_error_string(ERR_get_error(), NULL));
RETURN (false);
}
verify_status = SSL_get_verify_result (ssl);
if (verify_status == X509_V_OK) {
/* gets a stack of alt names that we can iterate through */
sans = (STACK_OF (GENERAL_NAME) *) X509_get_ext_d2i (
(X509 *)peer, NID_subject_alt_name, NULL, NULL);
if (sans) {
n_sans = sk_GENERAL_NAME_num (sans);
/* loop through the stack, or until we find a match */
for (i = 0; i < n_sans && !r; i++) {
const GENERAL_NAME *name = sk_GENERAL_NAME_value (sans, i);
/* skip entries that can't apply, I.e. IP entries if we've got a
* DNS host */
if (name->type == target) {
check = (char *)ASN1_STRING_data (name->d.ia5);
length = ASN1_STRING_length (name->d.ia5);
switch (target) {
case GEN_DNS:
/* check that we don't have an embedded null byte */
if ((length == bson_strnlen (check, length)) &&
_mongoc_openssl_hostcheck (check, host)) {
r = 1;
}
break;
case GEN_IPADD:
if (length == addrlen) {
if (length == sizeof addr6 && !memcmp (check, &addr6, length)) {
r = 1;
} else if (length == sizeof addr4 && !memcmp (check, &addr4, length)) {
r = 1;
}
}
break;
default:
BSON_ASSERT (0);
break;
}
}
}
GENERAL_NAMES_free (sans);
} else {
subject_name = X509_get_subject_name (peer);
if (subject_name) {
i = -1;
/* skip to the last common name */
while ((idx =
X509_NAME_get_index_by_NID (subject_name, NID_commonName, i)) >= 0) {
i = idx;
}
if (i >= 0) {
entry = X509_NAME_get_entry (subject_name, i);
entry_data = X509_NAME_ENTRY_get_data (entry);
if (entry_data) {
/* TODO: I've heard tell that old versions of SSL crap out
* when calling ASN1_STRING_to_UTF8 on already utf8 data.
* Check up on that */
length = ASN1_STRING_to_UTF8 ((unsigned char **)&check,
entry_data);
if (length >= 0) {
/* check for embedded nulls */
if ((length == bson_strnlen (check, length)) &&
_mongoc_openssl_hostcheck (check, host)) {
r = 1;
}
OPENSSL_free (check);
}
}
}
}
}
}
X509_free (peer);
RETURN (r);
}
static bool
_mongoc_openssl_setup_ca (SSL_CTX *ctx,
const char *cert,
const char *cert_dir)
{
BSON_ASSERT(ctx);
BSON_ASSERT(cert || cert_dir);
if (!SSL_CTX_load_verify_locations (ctx, cert, cert_dir)) {
MONGOC_ERROR ("Cannot load Certificate Authorities from '%s' and '%s'", cert, cert_dir);
return 0;
}
return 1;
}
static bool
_mongoc_openssl_setup_crl (SSL_CTX *ctx,
const char *crlfile)
{
X509_STORE *store;
X509_LOOKUP *lookup;
int status;
store = SSL_CTX_get_cert_store (ctx);
X509_STORE_set_flags (store, X509_V_FLAG_CRL_CHECK);
lookup = X509_STORE_add_lookup (store, X509_LOOKUP_file ());
status = X509_load_crl_file (lookup, crlfile, X509_FILETYPE_PEM);
return status != 0;
}
static bool
_mongoc_openssl_setup_pem_file (SSL_CTX *ctx,
const char *pem_file,
const char *password)
{
if (!SSL_CTX_use_certificate_chain_file (ctx, pem_file)) {
MONGOC_ERROR ("Cannot find certificate in '%s'", pem_file);
return 0;
}
if (password) {
SSL_CTX_set_default_passwd_cb_userdata (ctx, (void *)password);
SSL_CTX_set_default_passwd_cb (ctx, _mongoc_openssl_password_cb);
}
if (!(SSL_CTX_use_PrivateKey_file (ctx, pem_file, SSL_FILETYPE_PEM))) {
MONGOC_ERROR ("Cannot find private key in: '%s'", pem_file);
return 0;
}
if (!(SSL_CTX_check_private_key (ctx))) {
MONGOC_ERROR ("Cannot load private key: '%s'", pem_file);
return 0;
}
return 1;
}
/**
* _mongoc_openssl_ctx_new:
*
* Create a new ssl context declaratively
*
* The opt.pem_pwd parameter, if passed, must exist for the life of this
* context object (for storing and loading the associated pem file)
*/
SSL_CTX *
_mongoc_openssl_ctx_new (mongoc_ssl_opt_t *opt)
{
SSL_CTX *ctx = NULL;
int ssl_ctx_options = 0;
/*
* Ensure we are initialized. This is safe to call multiple times.
*/
mongoc_init ();
ctx = SSL_CTX_new (SSLv23_method ());
BSON_ASSERT (ctx);
/* SSL_OP_ALL - Activate all bug workaround options, to support buggy client SSL's. */
ssl_ctx_options |= SSL_OP_ALL;
/* SSL_OP_NO_SSLv2 - Disable SSL v2 support */
ssl_ctx_options |= SSL_OP_NO_SSLv2;
/* Disable compression, if we can.
* OpenSSL 0.9.x added compression support which was always enabled when built against zlib
* OpenSSL 1.0.0 added the ability to disable it, while keeping it enabled by default
* OpenSSL 1.1.0 disabled it by default.
*/
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
ssl_ctx_options |= SSL_OP_NO_COMPRESSION;
#endif
SSL_CTX_set_options (ctx, ssl_ctx_options);
/* only defined in special build, using:
* --enable-system-crypto-profile (autotools)
* -DENABLE_CRYPTO_SYSTEM_PROFILE:BOOL=ON (cmake) */
#ifndef MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE
/* HIGH - Enable strong ciphers
* !EXPORT - Disable export ciphers (40/56 bit)
* !aNULL - Disable anonymous auth ciphers
* @STRENGTH - Sort ciphers based on strength */
SSL_CTX_set_cipher_list (ctx, "HIGH:!EXPORT:!aNULL@STRENGTH");
#endif
/* If renegotiation is needed, don't return from recv() or send() until it's successful.
* Note: this is for blocking sockets only. */
SSL_CTX_set_mode (ctx, SSL_MODE_AUTO_RETRY);
/* Load my private keys to present to the server */
if (opt->pem_file &&
!_mongoc_openssl_setup_pem_file (ctx, opt->pem_file, opt->pem_pwd)) {
SSL_CTX_free (ctx);
return NULL;
}
/* Load in my Certificate Authority, to verify the server against
* If none provided, fallback to the distro defaults */
if (opt->ca_file || opt->ca_dir) {
if (!_mongoc_openssl_setup_ca (ctx, opt->ca_file, opt->ca_dir)) {
SSL_CTX_free (ctx);
return NULL;
}
} else {
/* If the server certificate is issued by known CA we trust it by default */
#ifdef _WIN32
_mongoc_openssl_import_cert_stores (ctx);
#else
SSL_CTX_set_default_verify_paths (ctx);
#endif
}
/* Load my revocation list, to verify the server against */
if (opt->crl_file && !_mongoc_openssl_setup_crl (ctx, opt->crl_file)) {
SSL_CTX_free (ctx);
return NULL;
}
return ctx;
}
char *
_mongoc_openssl_extract_subject (const char *filename, const char *passphrase)
{
X509_NAME *subject = NULL;
X509 *cert = NULL;
BIO *certbio = NULL;
BIO *strbio = NULL;
char *str = NULL;
int ret;
if (!filename) {
return NULL;
}
certbio = BIO_new (BIO_s_file ());
strbio = BIO_new (BIO_s_mem ());;
BSON_ASSERT (certbio);
BSON_ASSERT (strbio);
if (BIO_read_filename (certbio, filename) &&
(cert = PEM_read_bio_X509 (certbio, NULL, 0, NULL))) {
if ((subject = X509_get_subject_name (cert))) {
ret = X509_NAME_print_ex (strbio, subject, 0, XN_FLAG_RFC2253);
if ((ret > 0) && (ret < INT_MAX)) {
str = (char *)bson_malloc (ret + 2);
BIO_gets (strbio, str, ret + 1);
str [ret] = '\0';
}
}
}
if (cert) {
X509_free (cert);
}
if (certbio) {
BIO_free (certbio);
}
if (strbio) {
BIO_free (strbio);
}
return str;
}
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#ifdef _WIN32
static unsigned long
_mongoc_openssl_thread_id_callback (void)
{
unsigned long ret;
ret = (unsigned long)GetCurrentThreadId ();
return ret;
}
#else
static unsigned long
_mongoc_openssl_thread_id_callback (void)
{
unsigned long ret;
ret = (unsigned long)pthread_self ();
return ret;
}
#endif
static void
_mongoc_openssl_thread_locking_callback (int mode,
int type,
const char *file,
int line)
{
if (mode & CRYPTO_LOCK) {
mongoc_mutex_lock (&gMongocOpenSslThreadLocks[type]);
} else {
mongoc_mutex_unlock (&gMongocOpenSslThreadLocks[type]);
}
}
static void
_mongoc_openssl_thread_startup (void)
{
int i;
gMongocOpenSslThreadLocks = (mongoc_mutex_t *)OPENSSL_malloc (CRYPTO_num_locks () * sizeof (mongoc_mutex_t));
for (i = 0; i < CRYPTO_num_locks (); i++) {
mongoc_mutex_init(&gMongocOpenSslThreadLocks[i]);
}
if (!CRYPTO_get_locking_callback ()) {
CRYPTO_set_locking_callback (_mongoc_openssl_thread_locking_callback);
CRYPTO_set_id_callback (_mongoc_openssl_thread_id_callback);
}
}
static void
_mongoc_openssl_thread_cleanup (void)
{
int i;
if (CRYPTO_get_locking_callback () == _mongoc_openssl_thread_locking_callback) {
CRYPTO_set_locking_callback (NULL);
CRYPTO_set_id_callback (NULL);
}
for (i = 0; i < CRYPTO_num_locks (); i++) {
mongoc_mutex_destroy (&gMongocOpenSslThreadLocks[i]);
}
OPENSSL_free (gMongocOpenSslThreadLocks);
}
#endif
#endif
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-queue-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-queue-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-queue-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-queue-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-queue.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-queue.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-queue.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-queue.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rand-cng.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rand-cng.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rand-cng.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rand-cng.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rand-common-crypto.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rand-common-crypto.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rand-common-crypto.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rand-common-crypto.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rand-openssl.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rand-openssl.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rand-openssl.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rand-openssl.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rand-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rand-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rand-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rand-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rand.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rand.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rand.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rand.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-read-concern-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-read-concern-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-read-concern-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-read-concern-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-read-concern.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-read-concern.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-read-concern.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-read-concern.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-read-concern.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-read-concern.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-read-concern.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-read-concern.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-read-prefs-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-read-prefs-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-read-prefs-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-read-prefs-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-read-prefs.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-read-prefs.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-read-prefs.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-read-prefs.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-read-prefs.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-read-prefs.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-read-prefs.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-read-prefs.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rpc-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rpc-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rpc-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rpc-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rpc.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rpc.c
similarity index 99%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rpc.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rpc.c
index da331743..e0c0b866 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-rpc.c
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-rpc.c
@@ -1,941 +1,944 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <bson.h>
#include "mongoc.h"
#include "mongoc-rpc-private.h"
#include "mongoc-trace-private.h"
#define RPC(_name, _code) \
static void \
_mongoc_rpc_gather_##_name (mongoc_rpc_##_name##_t *rpc, \
mongoc_array_t *array) \
{ \
mongoc_iovec_t iov; \
assert (rpc); \
assert (array); \
rpc->msg_len = 0; \
_code \
}
#define INT32_FIELD(_name) \
iov.iov_base = (void *)&rpc->_name; \
iov.iov_len = 4; \
assert (iov.iov_len); \
rpc->msg_len += (int32_t)iov.iov_len; \
_mongoc_array_append_val(array, iov);
#define ENUM_FIELD INT32_FIELD
#define INT64_FIELD(_name) \
iov.iov_base = (void *)&rpc->_name; \
iov.iov_len = 8; \
assert (iov.iov_len); \
rpc->msg_len += (int32_t)iov.iov_len; \
_mongoc_array_append_val(array, iov);
#define CSTRING_FIELD(_name) \
assert (rpc->_name); \
iov.iov_base = (void *)rpc->_name; \
iov.iov_len = strlen(rpc->_name) + 1; \
assert (iov.iov_len); \
rpc->msg_len += (int32_t)iov.iov_len; \
_mongoc_array_append_val(array, iov);
#define BSON_FIELD(_name) \
do { \
int32_t __l; \
memcpy(&__l, rpc->_name, 4); \
__l = BSON_UINT32_FROM_LE(__l); \
iov.iov_base = (void *)rpc->_name; \
iov.iov_len = __l; \
assert (iov.iov_len); \
rpc->msg_len += (int32_t)iov.iov_len; \
_mongoc_array_append_val(array, iov); \
} while (0);
#define BSON_OPTIONAL(_check, _code) \
if (rpc->_check) { _code }
#define BSON_ARRAY_FIELD(_name) \
if (rpc->_name##_len) { \
iov.iov_base = (void *)rpc->_name; \
iov.iov_len = rpc->_name##_len; \
assert (iov.iov_len); \
rpc->msg_len += (int32_t)iov.iov_len; \
_mongoc_array_append_val(array, iov); \
}
#define IOVEC_ARRAY_FIELD(_name) \
do { \
ssize_t _i; \
assert (rpc->n_##_name); \
for (_i = 0; _i < rpc->n_##_name; _i++) { \
assert (rpc->_name[_i].iov_len); \
rpc->msg_len += (int32_t)rpc->_name[_i].iov_len; \
_mongoc_array_append_val(array, rpc->_name[_i]); \
} \
} while (0);
#define RAW_BUFFER_FIELD(_name) \
iov.iov_base = (void *)rpc->_name; \
iov.iov_len = rpc->_name##_len; \
assert (iov.iov_len); \
rpc->msg_len += (int32_t)iov.iov_len; \
_mongoc_array_append_val(array, iov);
#define INT64_ARRAY_FIELD(_len, _name) \
iov.iov_base = (void *)&rpc->_len; \
iov.iov_len = 4; \
assert (iov.iov_len); \
rpc->msg_len += (int32_t)iov.iov_len; \
_mongoc_array_append_val(array, iov); \
iov.iov_base = (void *)rpc->_name; \
iov.iov_len = rpc->_len * 8; \
assert (iov.iov_len); \
rpc->msg_len += (int32_t)iov.iov_len; \
_mongoc_array_append_val(array, iov);
#include "op-delete.def"
#include "op-get-more.def"
#include "op-insert.def"
#include "op-kill-cursors.def"
#include "op-msg.def"
#include "op-query.def"
#include "op-reply.def"
#include "op-update.def"
#undef RPC
#undef ENUM_FIELD
#undef INT32_FIELD
#undef INT64_FIELD
#undef INT64_ARRAY_FIELD
#undef CSTRING_FIELD
#undef BSON_FIELD
#undef BSON_ARRAY_FIELD
#undef IOVEC_ARRAY_FIELD
#undef RAW_BUFFER_FIELD
#undef BSON_OPTIONAL
#if BSON_BYTE_ORDER == BSON_BIG_ENDIAN
#define RPC(_name, _code) \
static void \
_mongoc_rpc_swab_to_le_##_name (mongoc_rpc_##_name##_t *rpc) \
{ \
assert (rpc); \
_code \
}
#define INT32_FIELD(_name) \
rpc->_name = BSON_UINT32_FROM_LE(rpc->_name);
#define ENUM_FIELD INT32_FIELD
#define INT64_FIELD(_name) \
rpc->_name = BSON_UINT64_FROM_LE(rpc->_name);
#define CSTRING_FIELD(_name)
#define BSON_FIELD(_name)
#define BSON_ARRAY_FIELD(_name)
#define IOVEC_ARRAY_FIELD(_name)
#define BSON_OPTIONAL(_check, _code) \
if (rpc->_check) { _code }
#define RAW_BUFFER_FIELD(_name)
#define INT64_ARRAY_FIELD(_len, _name) \
do { \
ssize_t i; \
for (i = 0; i < rpc->_len; i++) { \
rpc->_name[i] = BSON_UINT64_FROM_LE(rpc->_name[i]); \
} \
rpc->_len = BSON_UINT32_FROM_LE(rpc->_len); \
} while (0);
#include "op-delete.def"
#include "op-get-more.def"
#include "op-insert.def"
#include "op-kill-cursors.def"
#include "op-msg.def"
#include "op-query.def"
#include "op-reply.def"
/* Don't process generate _mongoc_rpc_swab_to_le_reply_header from op-reply-header.def */
#include "op-update.def"
#undef RPC
#undef INT64_ARRAY_FIELD
#define RPC(_name, _code) \
static void \
_mongoc_rpc_swab_from_le_##_name (mongoc_rpc_##_name##_t *rpc) \
{ \
assert (rpc); \
_code \
}
#define INT64_ARRAY_FIELD(_len, _name) \
do { \
ssize_t i; \
rpc->_len = BSON_UINT32_FROM_LE(rpc->_len); \
for (i = 0; i < rpc->_len; i++) { \
rpc->_name[i] = BSON_UINT64_FROM_LE(rpc->_name[i]); \
} \
} while (0);
#include "op-delete.def"
#include "op-get-more.def"
#include "op-insert.def"
#include "op-kill-cursors.def"
#include "op-msg.def"
#include "op-query.def"
#include "op-reply.def"
/* Don't process generate _mongoc_rpc_swab_from_le_reply_header from op-reply-header.def */
#include "op-update.def"
#undef RPC
#undef ENUM_FIELD
#undef INT32_FIELD
#undef INT64_FIELD
#undef INT64_ARRAY_FIELD
#undef CSTRING_FIELD
#undef BSON_FIELD
#undef BSON_ARRAY_FIELD
#undef IOVEC_ARRAY_FIELD
#undef BSON_OPTIONAL
#undef RAW_BUFFER_FIELD
#endif /* BSON_BYTE_ORDER == BSON_BIG_ENDIAN */
#define RPC(_name, _code) \
static void \
_mongoc_rpc_printf_##_name (mongoc_rpc_##_name##_t *rpc) \
{ \
assert (rpc); \
_code \
}
#define INT32_FIELD(_name) \
printf(" "#_name" : %d\n", rpc->_name);
#define ENUM_FIELD(_name) \
printf(" "#_name" : %u\n", rpc->_name);
#define INT64_FIELD(_name) \
printf(" "#_name" : %" PRIi64 "\n", (int64_t)rpc->_name);
#define CSTRING_FIELD(_name) \
printf(" "#_name" : %s\n", rpc->_name);
#define BSON_FIELD(_name) \
do { \
bson_t b; \
char *s; \
int32_t __l; \
memcpy(&__l, rpc->_name, 4); \
__l = BSON_UINT32_FROM_LE(__l); \
bson_init_static(&b, rpc->_name, __l); \
s = bson_as_json(&b, NULL); \
printf(" "#_name" : %s\n", s); \
bson_free(s); \
bson_destroy(&b); \
} while (0);
#define BSON_ARRAY_FIELD(_name) \
do { \
bson_reader_t *__r; \
bool __eof; \
const bson_t *__b; \
__r = bson_reader_new_from_data(rpc->_name, rpc->_name##_len); \
while ((__b = bson_reader_read(__r, &__eof))) { \
char *s = bson_as_json(__b, NULL); \
printf(" "#_name" : %s\n", s); \
bson_free(s); \
} \
bson_reader_destroy(__r); \
} while (0);
#define IOVEC_ARRAY_FIELD(_name) \
do { \
ssize_t _i; \
size_t _j; \
for (_i = 0; _i < rpc->n_##_name; _i++) { \
printf(" "#_name" : "); \
for (_j = 0; _j < rpc->_name[_i].iov_len; _j++) { \
uint8_t u; \
u = ((char *)rpc->_name[_i].iov_base)[_j]; \
printf(" %02x", u); \
} \
printf("\n"); \
} \
} while (0);
#define BSON_OPTIONAL(_check, _code) \
if (rpc->_check) { _code }
#define RAW_BUFFER_FIELD(_name) \
{ \
ssize_t __i; \
printf(" "#_name" :"); \
for (__i = 0; __i < rpc->_name##_len; __i++) { \
uint8_t u; \
u = ((char *)rpc->_name)[__i]; \
printf(" %02x", u); \
} \
printf("\n"); \
}
#define INT64_ARRAY_FIELD(_len, _name) \
do { \
ssize_t i; \
for (i = 0; i < rpc->_len; i++) { \
printf(" "#_name" : %" PRIi64 "\n", (int64_t)rpc->_name[i]); \
} \
rpc->_len = BSON_UINT32_FROM_LE(rpc->_len); \
} while (0);
#include "op-delete.def"
#include "op-get-more.def"
#include "op-insert.def"
#include "op-kill-cursors.def"
#include "op-msg.def"
#include "op-query.def"
#include "op-reply.def"
#include "op-update.def"
#undef RPC
#undef ENUM_FIELD
#undef INT32_FIELD
#undef INT64_FIELD
#undef INT64_ARRAY_FIELD
#undef CSTRING_FIELD
#undef BSON_FIELD
#undef BSON_ARRAY_FIELD
#undef IOVEC_ARRAY_FIELD
#undef BSON_OPTIONAL
#undef RAW_BUFFER_FIELD
#define RPC(_name, _code) \
static bool \
_mongoc_rpc_scatter_##_name (mongoc_rpc_##_name##_t *rpc, \
const uint8_t *buf, \
size_t buflen) \
{ \
assert (rpc); \
assert (buf); \
assert (buflen); \
_code \
return true; \
}
#define INT32_FIELD(_name) \
if (buflen < 4) { \
return false; \
} \
memcpy(&rpc->_name, buf, 4); \
buflen -= 4; \
buf += 4;
#define ENUM_FIELD INT32_FIELD
#define INT64_FIELD(_name) \
if (buflen < 8) { \
return false; \
} \
memcpy(&rpc->_name, buf, 8); \
buflen -= 8; \
buf += 8;
#define INT64_ARRAY_FIELD(_len, _name) \
do { \
size_t needed; \
if (buflen < 4) { \
return false; \
} \
memcpy(&rpc->_len, buf, 4); \
buflen -= 4; \
buf += 4; \
needed = BSON_UINT32_FROM_LE(rpc->_len) * 8; \
if (needed > buflen) { \
return false; \
} \
rpc->_name = (int64_t*)buf; \
buf += needed; \
buflen -= needed; \
} while (0);
#define CSTRING_FIELD(_name) \
do { \
size_t __i; \
bool found = false; \
for (__i = 0; __i < buflen; __i++) { \
if (!buf[__i]) { \
rpc->_name = (const char *)buf; \
buflen -= __i + 1; \
buf += __i + 1; \
found = true; \
break; \
} \
} \
if (!found) { \
return false; \
} \
} while (0);
#define BSON_FIELD(_name) \
do { \
uint32_t __l; \
if (buflen < 4) { \
return false; \
} \
memcpy(&__l, buf, 4); \
__l = BSON_UINT32_FROM_LE(__l); \
if (__l < 5 || __l > buflen) { \
return false; \
} \
rpc->_name = (uint8_t *)buf; \
buf += __l; \
buflen -= __l; \
} while (0);
#define BSON_ARRAY_FIELD(_name) \
rpc->_name = (uint8_t *)buf; \
rpc->_name##_len = (int32_t)buflen; \
buf = NULL; \
buflen = 0;
#define BSON_OPTIONAL(_check, _code) \
if (buflen) { \
_code \
}
#define IOVEC_ARRAY_FIELD(_name) \
rpc->_name##_recv.iov_base = (void *)buf; \
rpc->_name##_recv.iov_len = buflen; \
rpc->_name = &rpc->_name##_recv; \
rpc->n_##_name = 1; \
buf = NULL; \
buflen = 0;
#define RAW_BUFFER_FIELD(_name) \
rpc->_name = (void *)buf; \
rpc->_name##_len = (int32_t)buflen; \
buf = NULL; \
buflen = 0;
#include "op-delete.def"
#include "op-get-more.def"
#include "op-header.def"
#include "op-insert.def"
#include "op-kill-cursors.def"
#include "op-msg.def"
#include "op-query.def"
#include "op-reply.def"
#include "op-reply-header.def"
#include "op-update.def"
#undef RPC
#undef ENUM_FIELD
#undef INT32_FIELD
#undef INT64_FIELD
#undef INT64_ARRAY_FIELD
#undef CSTRING_FIELD
#undef BSON_FIELD
#undef BSON_ARRAY_FIELD
#undef IOVEC_ARRAY_FIELD
#undef BSON_OPTIONAL
#undef RAW_BUFFER_FIELD
void
_mongoc_rpc_gather (mongoc_rpc_t *rpc,
mongoc_array_t *array)
{
switch ((mongoc_opcode_t)rpc->header.opcode) {
case MONGOC_OPCODE_REPLY:
_mongoc_rpc_gather_reply(&rpc->reply, array);
return;
case MONGOC_OPCODE_MSG:
_mongoc_rpc_gather_msg(&rpc->msg, array);
return;
case MONGOC_OPCODE_UPDATE:
_mongoc_rpc_gather_update(&rpc->update, array);
return;
case MONGOC_OPCODE_INSERT:
_mongoc_rpc_gather_insert(&rpc->insert, array);
return;
case MONGOC_OPCODE_QUERY:
_mongoc_rpc_gather_query(&rpc->query, array);
return;
case MONGOC_OPCODE_GET_MORE:
_mongoc_rpc_gather_get_more(&rpc->get_more, array);
return;
case MONGOC_OPCODE_DELETE:
_mongoc_rpc_gather_delete(&rpc->delete_, array);
return;
case MONGOC_OPCODE_KILL_CURSORS:
_mongoc_rpc_gather_kill_cursors(&rpc->kill_cursors, array);
return;
default:
MONGOC_WARNING("Unknown rpc type: 0x%08x", rpc->header.opcode);
break;
}
}
void
_mongoc_rpc_swab_to_le (mongoc_rpc_t *rpc)
{
#if BSON_BYTE_ORDER != BSON_LITTLE_ENDIAN
mongoc_opcode_t opcode;
opcode = rpc->header.opcode;
switch (opcode) {
case MONGOC_OPCODE_REPLY:
_mongoc_rpc_swab_to_le_reply(&rpc->reply);
break;
case MONGOC_OPCODE_MSG:
_mongoc_rpc_swab_to_le_msg(&rpc->msg);
break;
case MONGOC_OPCODE_UPDATE:
_mongoc_rpc_swab_to_le_update(&rpc->update);
break;
case MONGOC_OPCODE_INSERT:
_mongoc_rpc_swab_to_le_insert(&rpc->insert);
break;
case MONGOC_OPCODE_QUERY:
_mongoc_rpc_swab_to_le_query(&rpc->query);
break;
case MONGOC_OPCODE_GET_MORE:
_mongoc_rpc_swab_to_le_get_more(&rpc->get_more);
break;
case MONGOC_OPCODE_DELETE:
_mongoc_rpc_swab_to_le_delete(&rpc->delete_);
break;
case MONGOC_OPCODE_KILL_CURSORS:
_mongoc_rpc_swab_to_le_kill_cursors(&rpc->kill_cursors);
break;
default:
MONGOC_WARNING("Unknown rpc type: 0x%08x", opcode);
break;
}
#endif
}
void
_mongoc_rpc_swab_from_le (mongoc_rpc_t *rpc)
{
#if BSON_BYTE_ORDER != BSON_LITTLE_ENDIAN
mongoc_opcode_t opcode;
opcode = BSON_UINT32_FROM_LE(rpc->header.opcode);
switch (opcode) {
case MONGOC_OPCODE_REPLY:
_mongoc_rpc_swab_from_le_reply(&rpc->reply);
break;
case MONGOC_OPCODE_MSG:
_mongoc_rpc_swab_from_le_msg(&rpc->msg);
break;
case MONGOC_OPCODE_UPDATE:
_mongoc_rpc_swab_from_le_update(&rpc->update);
break;
case MONGOC_OPCODE_INSERT:
_mongoc_rpc_swab_from_le_insert(&rpc->insert);
break;
case MONGOC_OPCODE_QUERY:
_mongoc_rpc_swab_from_le_query(&rpc->query);
break;
case MONGOC_OPCODE_GET_MORE:
_mongoc_rpc_swab_from_le_get_more(&rpc->get_more);
break;
case MONGOC_OPCODE_DELETE:
_mongoc_rpc_swab_from_le_delete(&rpc->delete_);
break;
case MONGOC_OPCODE_KILL_CURSORS:
_mongoc_rpc_swab_from_le_kill_cursors(&rpc->kill_cursors);
break;
default:
MONGOC_WARNING("Unknown rpc type: 0x%08x", rpc->header.opcode);
break;
}
#endif
}
void
_mongoc_rpc_printf (mongoc_rpc_t *rpc)
{
switch ((mongoc_opcode_t)rpc->header.opcode) {
case MONGOC_OPCODE_REPLY:
_mongoc_rpc_printf_reply(&rpc->reply);
break;
case MONGOC_OPCODE_MSG:
_mongoc_rpc_printf_msg(&rpc->msg);
break;
case MONGOC_OPCODE_UPDATE:
_mongoc_rpc_printf_update(&rpc->update);
break;
case MONGOC_OPCODE_INSERT:
_mongoc_rpc_printf_insert(&rpc->insert);
break;
case MONGOC_OPCODE_QUERY:
_mongoc_rpc_printf_query(&rpc->query);
break;
case MONGOC_OPCODE_GET_MORE:
_mongoc_rpc_printf_get_more(&rpc->get_more);
break;
case MONGOC_OPCODE_DELETE:
_mongoc_rpc_printf_delete(&rpc->delete_);
break;
case MONGOC_OPCODE_KILL_CURSORS:
_mongoc_rpc_printf_kill_cursors(&rpc->kill_cursors);
break;
default:
MONGOC_WARNING("Unknown rpc type: 0x%08x", rpc->header.opcode);
break;
}
}
bool
_mongoc_rpc_scatter (mongoc_rpc_t *rpc,
const uint8_t *buf,
size_t buflen)
{
mongoc_opcode_t opcode;
memset (rpc, 0, sizeof *rpc);
if (BSON_UNLIKELY(buflen < 16)) {
return false;
}
if (!_mongoc_rpc_scatter_header(&rpc->header, buf, 16)) {
return false;
}
opcode = (mongoc_opcode_t)BSON_UINT32_FROM_LE(rpc->header.opcode);
switch (opcode) {
case MONGOC_OPCODE_REPLY:
return _mongoc_rpc_scatter_reply(&rpc->reply, buf, buflen);
case MONGOC_OPCODE_MSG:
return _mongoc_rpc_scatter_msg(&rpc->msg, buf, buflen);
case MONGOC_OPCODE_UPDATE:
return _mongoc_rpc_scatter_update(&rpc->update, buf, buflen);
case MONGOC_OPCODE_INSERT:
return _mongoc_rpc_scatter_insert(&rpc->insert, buf, buflen);
case MONGOC_OPCODE_QUERY:
return _mongoc_rpc_scatter_query(&rpc->query, buf, buflen);
case MONGOC_OPCODE_GET_MORE:
return _mongoc_rpc_scatter_get_more(&rpc->get_more, buf, buflen);
case MONGOC_OPCODE_DELETE:
return _mongoc_rpc_scatter_delete(&rpc->delete_, buf, buflen);
case MONGOC_OPCODE_KILL_CURSORS:
return _mongoc_rpc_scatter_kill_cursors(&rpc->kill_cursors, buf, buflen);
default:
MONGOC_WARNING("Unknown rpc type: 0x%08x", opcode);
return false;
}
}
bool
_mongoc_rpc_scatter_reply_header_only (mongoc_rpc_t *rpc,
const uint8_t *buf,
size_t buflen)
{
if (BSON_UNLIKELY (buflen < sizeof (mongoc_rpc_reply_header_t))) {
return false;
}
return _mongoc_rpc_scatter_reply_header (&rpc->reply_header, buf, buflen);
}
bool
_mongoc_rpc_reply_get_first (mongoc_rpc_reply_t *reply,
bson_t *bson)
{
int32_t len;
if (!reply->documents || reply->documents_len < 4) {
return false;
}
memcpy(&len, reply->documents, 4);
len = BSON_UINT32_FROM_LE(len);
if (reply->documents_len < len) {
return false;
}
return bson_init_static(bson, reply->documents, len);
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_rpc_needs_gle --
*
* Checks to see if an rpc requires a getlasterror command to
* determine the success of the rpc.
*
* The write_concern is checked to ensure that the caller wants
* to know about a failure.
*
* Returns:
* true if a getlasterror should be delivered; otherwise false.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
bool
_mongoc_rpc_needs_gle (mongoc_rpc_t *rpc,
const mongoc_write_concern_t *write_concern)
{
switch (rpc->header.opcode) {
case MONGOC_OPCODE_REPLY:
case MONGOC_OPCODE_QUERY:
case MONGOC_OPCODE_MSG:
case MONGOC_OPCODE_GET_MORE:
case MONGOC_OPCODE_KILL_CURSORS:
return false;
case MONGOC_OPCODE_INSERT:
case MONGOC_OPCODE_UPDATE:
case MONGOC_OPCODE_DELETE:
default:
break;
}
if (!write_concern || !mongoc_write_concern_get_w(write_concern)) {
return false;
}
return true;
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_rpc_prep_command --
*
* Prepare an RPC for mongoc_cluster_run_command_rpc. @cmd_ns and
* @command must not be freed or modified while the RPC is in use.
*
* Side effects:
* Fills out the RPC, including pointers into @cmd_ns and @command.
*
*--------------------------------------------------------------------------
*/
void
_mongoc_rpc_prep_command (mongoc_rpc_t *rpc,
const char *cmd_ns,
const bson_t *command,
mongoc_query_flags_t flags)
{
rpc->query.msg_len = 0;
rpc->query.request_id = 0;
rpc->query.response_to = 0;
rpc->query.opcode = MONGOC_OPCODE_QUERY;
rpc->query.collection = cmd_ns;
rpc->query.skip = 0;
rpc->query.n_return = -1;
rpc->query.fields = NULL;
rpc->query.query = bson_get_data (command);
/* Find, getMore And killCursors Commands Spec: "When sending a find command
* rather than a legacy OP_QUERY find, only the slaveOk flag is honored."
* For other cursor-typed commands like aggregate, only slaveOk can be set.
* Clear bits except slaveOk; leave slaveOk set only if it is already.
*/
rpc->query.flags = flags & MONGOC_QUERY_SLAVE_OK;
}
bool
_mongoc_populate_cmd_error (const bson_t *doc,
int32_t error_api_version,
bson_error_t *error)
{
mongoc_error_domain_t domain =
error_api_version >= MONGOC_ERROR_API_VERSION_2
? MONGOC_ERROR_SERVER
: MONGOC_ERROR_QUERY;
uint32_t code = MONGOC_ERROR_QUERY_FAILURE;
bson_iter_t iter;
const char *msg = "Unknown command error";
ENTRY;
BSON_ASSERT (doc);
if (bson_iter_init_find (&iter, doc, "ok") && bson_iter_as_bool (&iter)) {
/* no error */
RETURN (false);
}
if (bson_iter_init_find (&iter, doc, "code") &&
BSON_ITER_HOLDS_INT32 (&iter)) {
code = (uint32_t) bson_iter_int32 (&iter);
}
if (code == MONGOC_ERROR_PROTOCOL_ERROR || code == 13390) {
code = MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND;
}
if (bson_iter_init_find (&iter, doc, "errmsg") &&
BSON_ITER_HOLDS_UTF8 (&iter)) {
msg = bson_iter_utf8 (&iter, NULL);
+ } else if (bson_iter_init_find (&iter, doc, "$err") &&
+ BSON_ITER_HOLDS_UTF8 (&iter)) {
+ msg = bson_iter_utf8 (&iter, NULL);
}
bson_set_error (error, domain, code, "%s", msg);
RETURN (true);
}
static void
_mongoc_populate_query_error (const bson_t *doc,
int32_t error_api_version,
bson_error_t *error)
{
mongoc_error_domain_t domain =
error_api_version >= MONGOC_ERROR_API_VERSION_2
? MONGOC_ERROR_SERVER
: MONGOC_ERROR_QUERY;
uint32_t code = MONGOC_ERROR_QUERY_FAILURE;
bson_iter_t iter;
const char *msg = "Unknown query failure";
ENTRY;
BSON_ASSERT (doc);
if (bson_iter_init_find (&iter, doc, "code") &&
BSON_ITER_HOLDS_INT32 (&iter)) {
code = (uint32_t) bson_iter_int32 (&iter);
}
if (bson_iter_init_find (&iter, doc, "$err") &&
BSON_ITER_HOLDS_UTF8 (&iter)) {
msg = bson_iter_utf8 (&iter, NULL);
}
bson_set_error (error, domain, code, "%s", msg);
EXIT;
}
/* returns true if the reply is a server error
*
* note we deliberately do *not* check for writeConcernError
*/
static bool
_mongoc_rpc_parse_error (mongoc_rpc_t *rpc,
bool is_command,
int32_t error_api_version,
bson_error_t *error /* OUT */)
{
bson_t b;
bool r;
ENTRY;
BSON_ASSERT (rpc);
if (rpc->header.opcode != MONGOC_OPCODE_REPLY) {
bson_set_error(error,
MONGOC_ERROR_PROTOCOL,
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
"Received rpc other than OP_REPLY.");
RETURN(true);
}
if (is_command) {
if (_mongoc_rpc_reply_get_first (&rpc->reply, &b)) {
r = _mongoc_populate_cmd_error (&b, error_api_version, error);
bson_destroy(&b);
RETURN (r);
} else {
bson_set_error (error,
MONGOC_ERROR_BSON,
MONGOC_ERROR_BSON_INVALID,
"Failed to decode document from the server.");
RETURN (true);
}
} else if ((rpc->reply.flags & MONGOC_REPLY_QUERY_FAILURE)) {
if (_mongoc_rpc_reply_get_first (&rpc->reply, &b)) {
_mongoc_populate_query_error (&b, error_api_version, error);
bson_destroy (&b);
} else {
bson_set_error (error,
MONGOC_ERROR_QUERY,
MONGOC_ERROR_QUERY_FAILURE,
"Unknown query failure.");
}
RETURN (true);
}
if ((rpc->reply.flags & MONGOC_REPLY_CURSOR_NOT_FOUND)) {
bson_set_error(error,
MONGOC_ERROR_CURSOR,
MONGOC_ERROR_CURSOR_INVALID_CURSOR,
"The cursor is invalid or has expired.");
RETURN(true);
}
RETURN(false);
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_rpc_parse_command_error --
*
* Check if a server OP_REPLY is a command error message.
* Optionally fill out a bson_error_t from the server error.
*
* Returns:
* true if the reply is an error message, false otherwise.
*
* Side effects:
* If rpc is an error reply and @error is not NULL, set its
* domain, code, and message.
*
*--------------------------------------------------------------------------
*/
bool _mongoc_rpc_parse_command_error (mongoc_rpc_t *rpc,
int32_t error_api_version,
bson_error_t *error)
{
return _mongoc_rpc_parse_error (rpc, true, error_api_version, error);
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_rpc_parse_query_error --
*
* Check if a server OP_REPLY is a query error message.
* Optionally fill out a bson_error_t from the server error.
*
* Returns:
* true if the reply is an error message, false otherwise.
*
* Side effects:
* If rpc is an error reply and @error is not NULL, set its
* domain, code, and message.
*
*--------------------------------------------------------------------------
*/
bool _mongoc_rpc_parse_query_error (mongoc_rpc_t *rpc,
int32_t error_api_version,
bson_error_t *error)
{
return _mongoc_rpc_parse_error (rpc, false, error_api_version, error);
}
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-sasl-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-sasl-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-sasl-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-sasl-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-sasl.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-sasl.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-sasl.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-sasl.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-scram-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-scram-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-scram-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-scram-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-scram.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-scram.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-scram.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-scram.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-secure-channel-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-secure-channel-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-secure-channel-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-secure-channel-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-secure-channel.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-secure-channel.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-secure-channel.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-secure-channel.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-secure-transport-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-secure-transport-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-secure-transport-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-secure-transport-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-secure-transport.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-secure-transport.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-secure-transport.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-secure-transport.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-server-description-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-server-description-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-server-description-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-server-description-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-server-description.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-server-description.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-server-description.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-server-description.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-server-description.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-server-description.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-server-description.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-server-description.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-server-stream-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-server-stream-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-server-stream-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-server-stream-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-server-stream.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-server-stream.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-server-stream.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-server-stream.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-set-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-set-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-set-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-set-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-set.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-set.c
similarity index 98%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-set.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-set.c
index 473f9704..9c1f18f8 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-set.c
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-set.c
@@ -1,232 +1,237 @@
/*
* Copyright 2014 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <bson.h>
#include "mongoc-set-private.h"
#undef MONGOC_LOG_DOMAIN
#define MONGOC_LOG_DOMAIN "set"
mongoc_set_t *
mongoc_set_new (size_t nitems,
mongoc_set_item_dtor dtor,
void *dtor_ctx)
{
mongoc_set_t *set = (mongoc_set_t *)bson_malloc (sizeof (*set));
set->items_allocated = nitems;
set->items = (mongoc_set_item_t *)bson_malloc (sizeof (*set->items) * set->items_allocated);
set->items_len = 0;
set->dtor = dtor;
set->dtor_ctx = dtor_ctx;
return set;
}
static int
mongoc_set_id_cmp (const void *a_,
const void *b_)
{
mongoc_set_item_t *a = (mongoc_set_item_t *)a_;
mongoc_set_item_t *b = (mongoc_set_item_t *)b_;
if (a->id == b->id) {
return 0;
}
return a->id < b->id ? -1 : 1;
}
void
mongoc_set_add (mongoc_set_t *set,
uint32_t id,
void *item)
{
if (set->items_len >= set->items_allocated) {
set->items_allocated *= 2;
set->items = (mongoc_set_item_t *)bson_realloc (set->items,
sizeof (*set->items) * set->items_allocated);
}
set->items[set->items_len].id = id;
set->items[set->items_len].item = item;
set->items_len++;
if (set->items_len > 1 && set->items[set->items_len - 2].id > id) {
qsort (set->items, set->items_len, sizeof (*set->items),
mongoc_set_id_cmp);
}
}
void
mongoc_set_rm (mongoc_set_t *set,
uint32_t id)
{
mongoc_set_item_t *ptr;
mongoc_set_item_t key;
int i;
key.id = id;
ptr = (mongoc_set_item_t *)bsearch (&key, set->items, set->items_len, sizeof (key),
mongoc_set_id_cmp);
if (ptr) {
set->dtor(ptr->item, set->dtor_ctx);
i = ptr - set->items;
if (i != set->items_len - 1) {
memmove (set->items + i, set->items + i + 1,
(set->items_len - (i + 1)) * sizeof (key));
}
set->items_len--;
}
}
void *
mongoc_set_get (mongoc_set_t *set,
uint32_t id)
{
mongoc_set_item_t *ptr;
mongoc_set_item_t key;
key.id = id;
ptr = (mongoc_set_item_t *)bsearch (&key, set->items, set->items_len, sizeof (key),
mongoc_set_id_cmp);
return ptr ? ptr->item : NULL;
}
void *
mongoc_set_get_item (mongoc_set_t *set,
int idx)
{
BSON_ASSERT (set);
BSON_ASSERT (idx < set->items_len);
return set->items[idx].item;
}
void *
mongoc_set_get_item_and_id (mongoc_set_t *set,
int idx,
uint32_t *id /* OUT */)
{
BSON_ASSERT (set);
BSON_ASSERT (id);
BSON_ASSERT (idx < set->items_len);
*id = set->items[idx].id;
return set->items[idx].item;
}
void
mongoc_set_destroy (mongoc_set_t *set)
{
int i;
for (i = 0; i < set->items_len; i++) {
set->dtor(set->items[i].item, set->dtor_ctx);
}
bson_free (set->items);
bson_free (set);
}
void
mongoc_set_for_each (mongoc_set_t *set,
mongoc_set_for_each_cb_t cb,
void *ctx)
{
size_t i;
mongoc_set_item_t *old_set;
size_t items_len;
items_len = set->items_len;
+ /* prevent undefined behavior of memcpy(NULL) */
+ if (items_len == 0) {
+ return;
+ }
+
old_set = (mongoc_set_item_t *)bson_malloc (sizeof (*old_set) * items_len);
memcpy (old_set, set->items, sizeof (*old_set) * items_len);
for (i = 0; i < items_len; i++) {
if (!cb (old_set[i].item, ctx)) {
break;
}
}
bson_free (old_set);
}
static mongoc_set_item_t *
_mongoc_set_find (mongoc_set_t *set,
mongoc_set_for_each_cb_t cb,
void *ctx)
{
size_t i;
size_t items_len;
mongoc_set_item_t *item;
items_len = set->items_len;
for (i = 0; i < items_len; i++) {
item = &set->items[i];
if (cb (item->item, ctx)) {
return item;
}
}
return NULL;
}
void *
mongoc_set_find_item (mongoc_set_t *set,
mongoc_set_for_each_cb_t cb,
void *ctx)
{
mongoc_set_item_t *item;
if ((item = _mongoc_set_find (set, cb, ctx))) {
return item->item;
}
return NULL;
}
uint32_t
mongoc_set_find_id (mongoc_set_t *set,
mongoc_set_for_each_cb_t cb,
void *ctx)
{
mongoc_set_item_t *item;
if ((item = _mongoc_set_find (set, cb, ctx))) {
return item->id;
}
return 0;
}
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-socket-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-socket-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-socket-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-socket-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-socket.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-socket.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-socket.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-socket.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-socket.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-socket.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-socket.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-socket.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-ssl-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-ssl-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-ssl-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-ssl-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-ssl.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-ssl.c
similarity index 99%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-ssl.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-ssl.c
index a4286ae8..45d6f3f3 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-ssl.c
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-ssl.c
@@ -1,121 +1,122 @@
/*
* Copyright 2016 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mongoc-config.h"
#ifdef MONGOC_ENABLE_SSL
#include <bson.h>
#include "mongoc-ssl.h"
#include "mongoc-ssl-private.h"
#include "mongoc-log.h"
#if defined(MONGOC_ENABLE_SSL_OPENSSL)
# include "mongoc-openssl-private.h"
#elif defined(MONGOC_ENABLE_SSL_LIBRESSL)
# include "mongoc-libressl-private.h"
#elif defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT)
# include "mongoc-secure-transport-private.h"
#elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL)
# include "mongoc-secure-channel-private.h"
#endif
/* TODO: we could populate these from a config or something further down the
* road for providing defaults */
#ifndef MONGOC_SSL_DEFAULT_TRUST_FILE
#define MONGOC_SSL_DEFAULT_TRUST_FILE NULL
#endif
#ifndef MONGOC_SSL_DEFAULT_TRUST_DIR
#define MONGOC_SSL_DEFAULT_TRUST_DIR NULL
#endif
static
mongoc_ssl_opt_t gMongocSslOptDefault = {
NULL,
NULL,
MONGOC_SSL_DEFAULT_TRUST_FILE,
MONGOC_SSL_DEFAULT_TRUST_DIR,
};
const mongoc_ssl_opt_t *
mongoc_ssl_opt_get_default (void)
{
return &gMongocSslOptDefault;
}
char *
mongoc_ssl_extract_subject (const char *filename, const char *passphrase)
{
char *retval;
if (!filename) {
MONGOC_ERROR ("No filename provided to extract subject from");
return NULL;
}
#ifdef _WIN32
if (_access (filename, 0) != 0) {
#else
if (access (filename, R_OK) != 0) {
#endif
MONGOC_ERROR ("Can't extract subject from unreadable file: '%s'", filename);
return NULL;
}
#if defined(MONGOC_ENABLE_SSL_OPENSSL)
retval = _mongoc_openssl_extract_subject (filename, passphrase);
#elif defined(MONGOC_ENABLE_SSL_LIBRESSL)
MONGOC_WARNING ("libtls doesn't support automatically extracting subject from "
"certificate to use with authentication");
+ retval = NULL;
#elif defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT)
retval = _mongoc_secure_transport_extract_subject (filename, passphrase);
#elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL)
retval = _mongoc_secure_channel_extract_subject (filename, passphrase);
#endif
if (!retval) {
MONGOC_ERROR ("Can't extract subject from file '%s'", filename);
}
return retval;
}
void _mongoc_ssl_opts_copy_to (const mongoc_ssl_opt_t* src,
mongoc_ssl_opt_t* dst)
{
BSON_ASSERT (src);
BSON_ASSERT (dst);
dst->pem_file = bson_strdup (src->pem_file);
dst->pem_pwd = bson_strdup (src->pem_pwd);
dst->ca_file = bson_strdup (src->ca_file);
dst->ca_dir = bson_strdup (src->ca_dir);
dst->crl_file = bson_strdup (src->crl_file);
dst->weak_cert_validation = src->weak_cert_validation;
dst->allow_invalid_hostname = src->allow_invalid_hostname;
}
void _mongoc_ssl_opts_cleanup (mongoc_ssl_opt_t* opt)
{
bson_free ((char*)opt->pem_file);
bson_free ((char*)opt->pem_pwd);
bson_free ((char*)opt->ca_file);
bson_free ((char*)opt->ca_dir);
bson_free ((char*)opt->crl_file);
}
#endif
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-ssl.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-ssl.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-ssl.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-ssl.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-buffered.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-buffered.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-buffered.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-buffered.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-buffered.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-buffered.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-buffered.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-buffered.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-file.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-file.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-file.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-file.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-file.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-file.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-file.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-file.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-gridfs.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-gridfs.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-gridfs.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-gridfs.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-gridfs.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-gridfs.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-gridfs.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-gridfs.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-socket.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-socket.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-socket.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-socket.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-socket.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-socket.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-socket.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-socket.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.c
similarity index 99%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.c
index 0f1e50ad..78111e10 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.c
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.c
@@ -1,509 +1,508 @@
/*
* Copyright 2016 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mongoc-config.h"
#ifdef MONGOC_ENABLE_SSL_LIBRESSL
#include <bson.h>
#include "mongoc-trace-private.h"
#include "mongoc-log.h"
#include "mongoc-stream-tls.h"
#include "mongoc-stream-tls-private.h"
#include "mongoc-stream-private.h"
#include "mongoc-stream-tls-libressl-private.h"
#include "mongoc-libressl-private.h"
#include "mongoc-ssl.h"
#include "mongoc-error.h"
#include "mongoc-counters-private.h"
#include "mongoc-stream-socket.h"
#include "mongoc-socket-private.h"
#include <tls.h>
#undef MONGOC_LOG_DOMAIN
#define MONGOC_LOG_DOMAIN "stream-tls-libressl"
static void
_mongoc_stream_tls_libressl_destroy (mongoc_stream_t *stream)
{
mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *)stream;
mongoc_stream_tls_libressl_t *libressl = (mongoc_stream_tls_libressl_t *) tls->ctx;
ENTRY;
BSON_ASSERT (libressl);
tls_close (libressl->ctx);
tls_free (libressl->ctx);
tls_config_free (libressl->config);
mongoc_stream_destroy (tls->base_stream);
bson_free (libressl);
bson_free (stream);
mongoc_counter_streams_active_dec();
mongoc_counter_streams_disposed_inc();
EXIT;
}
static void
_mongoc_stream_tls_libressl_failed (mongoc_stream_t *stream)
{
ENTRY;
_mongoc_stream_tls_libressl_destroy (stream);
EXIT;
}
static int
_mongoc_stream_tls_libressl_close (mongoc_stream_t *stream)
{
int ret = 0;
mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *)stream;
mongoc_stream_tls_libressl_t *libressl = (mongoc_stream_tls_libressl_t *) tls->ctx;
ENTRY;
BSON_ASSERT (libressl);
ret = mongoc_stream_close (tls->base_stream);
RETURN (ret);
}
static int
_mongoc_stream_tls_libressl_flush (mongoc_stream_t *stream)
{
mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *)stream;
mongoc_stream_tls_libressl_t *libressl = (mongoc_stream_tls_libressl_t *) tls->ctx;
ENTRY;
BSON_ASSERT (libressl);
RETURN (0);
}
static ssize_t
_mongoc_stream_tls_libressl_write (mongoc_stream_t *stream,
char *buf,
size_t buf_len)
{
mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *)stream;
mongoc_stream_tls_libressl_t *libressl = (mongoc_stream_tls_libressl_t *) tls->ctx;
mongoc_stream_poll_t poller;
ssize_t total_write = 0;
ssize_t ret;
int64_t now;
int64_t expire = 0;
ENTRY;
BSON_ASSERT (libressl);
if (tls->timeout_msec >= 0) {
expire = bson_get_monotonic_time () + (tls->timeout_msec * 1000UL);
}
do {
poller.stream = stream;
poller.revents = 0;
poller.events = POLLOUT;
ret = tls_write (libressl->ctx, buf, buf_len);
if (ret == TLS_WANT_POLLIN) {
poller.events = POLLIN;
mongoc_stream_poll (&poller, 1, tls->timeout_msec);
} else if (ret == TLS_WANT_POLLOUT) {
poller.events = POLLOUT;
mongoc_stream_poll (&poller, 1, tls->timeout_msec);
} else if (ret < 0) {
RETURN (total_write);
} else {
buf += ret;
buf_len -= ret;
total_write += ret;
}
if (expire) {
now = bson_get_monotonic_time ();
if ((expire - now) < 0) {
if (ret == 0) {
mongoc_counter_streams_timeout_inc();
break;
}
tls->timeout_msec = 0;
} else {
tls->timeout_msec = (expire - now) / 1000L;
}
}
} while (buf_len > 0);
RETURN (total_write);
}
/* This is copypasta from _mongoc_stream_tls_openssl_writev */
#define MONGOC_STREAM_TLS_BUFFER_SIZE 4096
static ssize_t
_mongoc_stream_tls_libressl_writev (mongoc_stream_t *stream,
mongoc_iovec_t *iov,
size_t iovcnt,
int32_t timeout_msec)
{
mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *)stream;
mongoc_stream_tls_libressl_t *libressl = (mongoc_stream_tls_libressl_t *) tls->ctx;
char buf[MONGOC_STREAM_TLS_BUFFER_SIZE];
ssize_t ret = 0;
ssize_t child_ret;
size_t i;
size_t iov_pos = 0;
/* There's a bit of a dance to coalesce vectorized writes into
* MONGOC_STREAM_TLS_BUFFER_SIZE'd writes to avoid lots of small tls
* packets.
*
* The basic idea is that we want to combine writes in the buffer if they're
* smaller than the buffer, flushing as it gets full. For larger writes, or
* the last write in the iovec array, we want to ignore the buffer and just
* write immediately. We take care of doing buffer writes by re-invoking
* ourself with a single iovec_t, pointing at our stack buffer.
*/
char *buf_head = buf;
char *buf_tail = buf;
char *buf_end = buf + MONGOC_STREAM_TLS_BUFFER_SIZE;
size_t bytes;
char *to_write = NULL;
size_t to_write_len;
BSON_ASSERT (iov);
BSON_ASSERT (iovcnt);
BSON_ASSERT (libressl);
ENTRY;
tls->timeout_msec = timeout_msec;
for (i = 0; i < iovcnt; i++) {
iov_pos = 0;
while (iov_pos < iov[i].iov_len) {
if (buf_head != buf_tail ||
((i + 1 < iovcnt) &&
((buf_end - buf_tail) > (iov[i].iov_len - iov_pos)))) {
/* If we have either of:
* - buffered bytes already
* - another iovec to send after this one and we don't have more
* bytes to send than the size of the buffer.
*
* copy into the buffer */
bytes = BSON_MIN (iov[i].iov_len - iov_pos, buf_end - buf_tail);
memcpy (buf_tail, (char *) iov[i].iov_base + iov_pos, bytes);
buf_tail += bytes;
iov_pos += bytes;
if (buf_tail == buf_end) {
/* If we're full, request send */
to_write = buf_head;
to_write_len = buf_tail - buf_head;
buf_tail = buf_head = buf;
}
} else {
/* Didn't buffer, so just write it through */
to_write = (char *)iov[i].iov_base + iov_pos;
to_write_len = iov[i].iov_len - iov_pos;
iov_pos += to_write_len;
}
if (to_write) {
/* We get here if we buffered some bytes and filled the buffer, or
* if we didn't buffer and have to send out of the iovec */
child_ret = _mongoc_stream_tls_libressl_write (stream, to_write, to_write_len);
if (child_ret < 0) {
RETURN (ret);
}
ret += child_ret;
if (child_ret < to_write_len) {
/* we timed out, so send back what we could send */
RETURN (ret);
}
to_write = NULL;
}
}
}
if (buf_head != buf_tail) {
/* If we have any bytes buffered, send */
child_ret = _mongoc_stream_tls_libressl_write (stream, buf_head, buf_tail - buf_head);
if (child_ret < 0) {
RETURN (child_ret);
}
ret += child_ret;
}
if (ret >= 0) {
mongoc_counter_streams_egress_add (ret);
}
TRACE("Returning %zu", ret);
RETURN (ret);
}
/* This function is copypasta of _mongoc_stream_tls_openssl_readv */
static ssize_t
_mongoc_stream_tls_libressl_readv (mongoc_stream_t *stream,
mongoc_iovec_t *iov,
size_t iovcnt,
size_t min_bytes,
int32_t timeout_msec)
{
mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *)stream;
mongoc_stream_tls_libressl_t *libressl = (mongoc_stream_tls_libressl_t *) tls->ctx;
ssize_t ret = 0;
ssize_t read_ret;
size_t i;
size_t iov_pos = 0;
int64_t now;
int64_t expire = 0;
mongoc_stream_poll_t poller;
BSON_ASSERT (iov);
BSON_ASSERT (iovcnt);
BSON_ASSERT (libressl);
ENTRY;
tls->timeout_msec = timeout_msec;
if (timeout_msec >= 0) {
expire = bson_get_monotonic_time () + (timeout_msec * 1000UL);
}
for (i = 0; i < iovcnt; i++) {
iov_pos = 0;
while (iov_pos < iov[i].iov_len) {
poller.stream = stream;
poller.revents = 0;
poller.events = POLLIN;
read_ret = tls_read (libressl->ctx, (char *)iov[i].iov_base + iov_pos, (int)(iov[i].iov_len - iov_pos));
if (read_ret == TLS_WANT_POLLIN) {
poller.events = POLLIN;
mongoc_stream_poll (&poller, 1, tls->timeout_msec);
} else if (read_ret == TLS_WANT_POLLOUT) {
poller.events = POLLOUT;
mongoc_stream_poll (&poller, 1, tls->timeout_msec);
} else if (read_ret < 0) {
RETURN (ret);
} else {
iov_pos += read_ret;
ret += read_ret;
}
if (expire) {
now = bson_get_monotonic_time ();
if ((expire - now) < 0) {
if (read_ret == 0) {
mongoc_counter_streams_timeout_inc();
errno = ETIMEDOUT;
RETURN (-1);
}
tls->timeout_msec = 0;
} else {
tls->timeout_msec = (expire - now) / 1000L;
}
}
if (ret > 0 && (size_t)ret >= min_bytes) {
mongoc_counter_streams_ingress_add(ret);
RETURN (ret);
}
}
}
if (ret >= 0) {
mongoc_counter_streams_ingress_add(ret);
}
RETURN (ret);
}
static int
_mongoc_stream_tls_libressl_setsockopt (mongoc_stream_t *stream,
int level,
int optname,
void *optval,
socklen_t optlen)
{
mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *)stream;
mongoc_stream_tls_libressl_t *libressl = (mongoc_stream_tls_libressl_t *) tls->ctx;
ENTRY;
BSON_ASSERT (libressl);
RETURN (mongoc_stream_setsockopt (tls->base_stream,
level,
optname,
optval,
optlen));
}
static mongoc_stream_t *
_mongoc_stream_tls_libressl_get_base_stream (mongoc_stream_t *stream)
{
mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *)stream;
mongoc_stream_tls_libressl_t *libressl = (mongoc_stream_tls_libressl_t *) tls->ctx;
ENTRY;
BSON_ASSERT (libressl);
RETURN (tls->base_stream);
}
static bool
_mongoc_stream_tls_libressl_check_closed (mongoc_stream_t *stream)
{
mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *)stream;
mongoc_stream_tls_libressl_t *libressl = (mongoc_stream_tls_libressl_t *) tls->ctx;
ENTRY;
BSON_ASSERT (libressl);
RETURN (mongoc_stream_check_closed (tls->base_stream));
}
bool
mongoc_stream_tls_libressl_handshake (mongoc_stream_t *stream,
const char *host,
int *events,
bson_error_t *error)
{
mongoc_stream_tls_t *tls = (mongoc_stream_tls_t *)stream;
mongoc_stream_tls_libressl_t *libressl = (mongoc_stream_tls_libressl_t *) tls->ctx;
int ret;
ENTRY;
BSON_ASSERT (libressl);
ret = tls_handshake (libressl->ctx);
if (ret == TLS_WANT_POLLIN) {
*events = POLLIN;
} else if (ret == TLS_WANT_POLLOUT) {
*events = POLLOUT;
} else if (ret < 0) {
*events = 0;
bson_set_error (error,
MONGOC_ERROR_STREAM,
MONGOC_ERROR_STREAM_SOCKET,
"TLS handshake failed: %s", tls_error (libressl->ctx));
RETURN (false);
} else {
RETURN (true);
}
RETURN (false);
}
mongoc_stream_t *
mongoc_stream_tls_libressl_new (mongoc_stream_t *base_stream,
const char *host,
mongoc_ssl_opt_t *opt,
int client)
{
mongoc_stream_tls_t *tls;
mongoc_stream_tls_libressl_t *libressl;
ENTRY;
BSON_ASSERT(base_stream);
BSON_ASSERT(opt);
if (opt->crl_file) {
MONGOC_ERROR("Setting mongoc_ssl_opt_t.crl_file has no effect when built "
"against libtls");
RETURN (false);
}
libressl = (mongoc_stream_tls_libressl_t *)bson_malloc0 (sizeof *libressl);
tls = (mongoc_stream_tls_t *)bson_malloc0 (sizeof *tls);
tls->parent.type = MONGOC_STREAM_TLS;
tls->parent.destroy = _mongoc_stream_tls_libressl_destroy;
tls->parent.failed = _mongoc_stream_tls_libressl_failed;
tls->parent.close = _mongoc_stream_tls_libressl_close;
tls->parent.flush = _mongoc_stream_tls_libressl_flush;
tls->parent.writev = _mongoc_stream_tls_libressl_writev;
tls->parent.readv = _mongoc_stream_tls_libressl_readv;
tls->parent.setsockopt = _mongoc_stream_tls_libressl_setsockopt;
tls->parent.get_base_stream = _mongoc_stream_tls_libressl_get_base_stream;
tls->parent.check_closed = _mongoc_stream_tls_libressl_check_closed;
memcpy (&tls->ssl_opts, opt, sizeof tls->ssl_opts);
tls->handshake = mongoc_stream_tls_libressl_handshake;
tls->ctx = (void *)libressl;
tls->timeout_msec = -1;
tls->base_stream = base_stream;
libressl->ctx = client ? tls_client() : tls_server();
libressl->config = tls_config_new();
if (opt->weak_cert_validation) {
tls_config_insecure_noverifycert (libressl->config);
tls_config_insecure_noverifytime (libressl->config);
}
if (opt->allow_invalid_hostname) {
tls_config_insecure_noverifyname (libressl->config);
}
tls_config_set_ciphers (libressl->config, "compat");
mongoc_libressl_setup_certificate (libressl, opt);
mongoc_libressl_setup_ca (libressl, opt);
{
mongoc_stream_t *stream = base_stream;
do {
if (stream->type == MONGOC_STREAM_SOCKET) {
int socket = mongoc_stream_socket_get_socket ((mongoc_stream_socket_t *)stream)->sd;
if (tls_configure (libressl->ctx, libressl->config) == -1) {
MONGOC_ERROR("%s", tls_config_error (libressl->config));
RETURN (false);
}
if (tls_connect_socket (libressl->ctx, socket, host) == -1) {
MONGOC_ERROR("%s", tls_error (libressl->ctx));
RETURN (false);
}
break;
}
} while ((stream = mongoc_stream_get_base_stream (stream)));
}
- libressl->n = streams++;
mongoc_counter_streams_active_inc();
RETURN((mongoc_stream_t *)tls);
}
#endif /* MONGOC_ENABLE_SSL_LIBRESSL */
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-bio-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-bio-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-bio-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-bio-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-bio.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-bio.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-bio.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-bio.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream-tls.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream-tls.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-stream.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-stream.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-thread-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-thread-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-thread-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-thread-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-description-apm-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-description-apm-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-description-apm-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-description-apm-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-description-apm.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-description-apm.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-description-apm.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-description-apm.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-description-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-description-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-description-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-description-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-description.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-description.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-description.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-description.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-description.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-description.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-description.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-description.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-scanner-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-scanner-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-scanner-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-scanner-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-scanner.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-scanner.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology-scanner.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology-scanner.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-topology.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-topology.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-trace-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-trace-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-trace-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-trace-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-uri-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-uri-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-uri-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-uri-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-uri.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-uri.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-uri.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-uri.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-uri.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-uri.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-uri.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-uri.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-util-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-util-private.h
similarity index 94%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-util-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-util-private.h
index aa14483b..1fa9a840 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-util-private.h
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-util-private.h
@@ -1,78 +1,82 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MONGOC_UTIL_PRIVATE_H
#define MONGOC_UTIL_PRIVATE_H
#if !defined (MONGOC_COMPILATION)
#error "Only <mongoc.h> can be included directly."
#endif
#include <bson.h>
#include "mongoc.h"
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
/* string comparison functions for Windows */
#ifdef _WIN32
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
#endif
/* Suppress CWE-252 ("Unchecked return value") warnings for things we can't deal with */
#if defined(__GNUC__) && __GNUC__ >= 4
# define _ignore_value(x) (({ __typeof__ (x) __x = (x); (void) __x; }))
#else
# define _ignore_value(x) ((void) (x))
#endif
#define COALESCE(x, y) ((x == 0) ? (y) : (x))
#ifdef _WIN32
# define MONGOC_RAND_R rand_s
#else
# define MONGOC_RAND_R rand_r
#endif
+/* Helper macros for stringifying things */
+#define MONGOC_STR(s) #s
+#define MONGOC_EVALUATE_STR(s) MONGOC_STR (s)
+
BSON_BEGIN_DECLS
char *_mongoc_hex_md5 (const char *input);
void _mongoc_usleep (int64_t usec);
const char *_mongoc_get_command_name (const bson_t *command);
void _mongoc_get_db_name (const char *ns,
char *db /* OUT */);
void _mongoc_bson_destroy_if_set (bson_t *bson);
size_t
_mongoc_strlen_or_zero (const char *s);
bool
_mongoc_get_server_id_from_opts (const bson_t *opts,
mongoc_error_domain_t domain,
mongoc_error_code_t code,
uint32_t *server_id,
bson_error_t *error);
BSON_END_DECLS
#endif /* MONGOC_UTIL_PRIVATE_H */
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-util.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-util.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-util.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-util.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-version-functions.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-version-functions.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-version-functions.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-version-functions.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-version-functions.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-version-functions.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-version-functions.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-version-functions.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-version.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-version.h
similarity index 96%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-version.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-version.h
index 131d8ffc..67b0e854 100644
--- a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-version.h
+++ b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-version.h
@@ -1,102 +1,102 @@
/*
* Copyright 2013 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !defined (MONGOC_INSIDE) && !defined (MONGOC_COMPILATION)
#error "Only <mongoc.h> can be included directly."
#endif
#ifndef MONGOC_VERSION_H
#define MONGOC_VERSION_H
/**
* MONGOC_MAJOR_VERSION:
*
* MONGOC major version component (e.g. 1 if %MONGOC_VERSION is 1.2.3)
*/
#define MONGOC_MAJOR_VERSION (1)
/**
* MONGOC_MINOR_VERSION:
*
* MONGOC minor version component (e.g. 2 if %MONGOC_VERSION is 1.2.3)
*/
#define MONGOC_MINOR_VERSION (5)
/**
* MONGOC_MICRO_VERSION:
*
* MONGOC micro version component (e.g. 3 if %MONGOC_VERSION is 1.2.3)
*/
-#define MONGOC_MICRO_VERSION (0)
+#define MONGOC_MICRO_VERSION (3)
/**
* MONGOC_PRERELEASE_VERSION:
*
* MONGOC prerelease version component (e.g. rc0 if %MONGOC_VERSION is 1.2.3-rc0)
*/
#define MONGOC_PRERELEASE_VERSION ()
/**
* MONGOC_VERSION:
*
* MONGOC version.
*/
-#define MONGOC_VERSION (1.5.0)
+#define MONGOC_VERSION (1.5.3)
/**
* MONGOC_VERSION_S:
*
* MONGOC version, encoded as a string, useful for printing and
* concatenation.
*/
-#define MONGOC_VERSION_S "1.5.0"
+#define MONGOC_VERSION_S "1.5.3"
/**
* MONGOC_VERSION_HEX:
*
* MONGOC version, encoded as an hexadecimal number, useful for
* integer comparisons.
*/
#define MONGOC_VERSION_HEX (MONGOC_MAJOR_VERSION << 24 | \
MONGOC_MINOR_VERSION << 16 | \
MONGOC_MICRO_VERSION << 8)
/**
* MONGOC_CHECK_VERSION:
* @major: required major version
* @minor: required minor version
* @micro: required micro version
*
* Compile-time version checking. Evaluates to %TRUE if the version
* of MONGOC is greater than the required one.
*/
#define MONGOC_CHECK_VERSION(major,minor,micro) \
(MONGOC_MAJOR_VERSION > (major) || \
(MONGOC_MAJOR_VERSION == (major) && MONGOC_MINOR_VERSION > (minor)) || \
(MONGOC_MAJOR_VERSION == (major) && MONGOC_MINOR_VERSION == (minor) && \
MONGOC_MICRO_VERSION >= (micro)))
#endif /* MONGOC_VERSION_H */
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-version.h.in b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-version.h.in
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-version.h.in
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-version.h.in
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-write-command-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-write-command-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-write-command-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-write-command-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-write-command.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-write-command.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-write-command.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-write-command.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-write-concern-private.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-write-concern-private.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-write-concern-private.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-write-concern-private.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-write-concern.c b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-write-concern.c
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-write-concern.c
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-write-concern.c
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-write-concern.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-write-concern.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc-write-concern.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc-write-concern.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/mongoc.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/mongoc.h
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/op-delete.def b/mongodb-1.2.3/src/libmongoc/src/mongoc/op-delete.def
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/op-delete.def
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/op-delete.def
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/op-get-more.def b/mongodb-1.2.3/src/libmongoc/src/mongoc/op-get-more.def
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/op-get-more.def
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/op-get-more.def
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/op-header.def b/mongodb-1.2.3/src/libmongoc/src/mongoc/op-header.def
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/op-header.def
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/op-header.def
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/op-insert.def b/mongodb-1.2.3/src/libmongoc/src/mongoc/op-insert.def
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/op-insert.def
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/op-insert.def
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/op-kill-cursors.def b/mongodb-1.2.3/src/libmongoc/src/mongoc/op-kill-cursors.def
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/op-kill-cursors.def
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/op-kill-cursors.def
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/op-msg.def b/mongodb-1.2.3/src/libmongoc/src/mongoc/op-msg.def
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/op-msg.def
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/op-msg.def
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/op-query.def b/mongodb-1.2.3/src/libmongoc/src/mongoc/op-query.def
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/op-query.def
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/op-query.def
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/op-reply-header.def b/mongodb-1.2.3/src/libmongoc/src/mongoc/op-reply-header.def
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/op-reply-header.def
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/op-reply-header.def
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/op-reply.def b/mongodb-1.2.3/src/libmongoc/src/mongoc/op-reply.def
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/op-reply.def
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/op-reply.def
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/op-update.def b/mongodb-1.2.3/src/libmongoc/src/mongoc/op-update.def
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/op-update.def
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/op-update.def
diff --git a/mongodb-1.2.0/src/libmongoc/src/mongoc/utlist.h b/mongodb-1.2.3/src/libmongoc/src/mongoc/utlist.h
similarity index 100%
rename from mongodb-1.2.0/src/libmongoc/src/mongoc/utlist.h
rename to mongodb-1.2.3/src/libmongoc/src/mongoc/utlist.h
diff --git a/mongodb-1.2.0/tests/bson/bson-binary-001.phpt b/mongodb-1.2.3/tests/bson/bson-binary-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary-compare-001.phpt b/mongodb-1.2.3/tests/bson/bson-binary-compare-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary-compare-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary-compare-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary-compare-002.phpt b/mongodb-1.2.3/tests/bson/bson-binary-compare-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary-compare-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary-compare-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary-jsonserialize-001.phpt b/mongodb-1.2.3/tests/bson/bson-binary-jsonserialize-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary-jsonserialize-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary-jsonserialize-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary-jsonserialize-002.phpt b/mongodb-1.2.3/tests/bson/bson-binary-jsonserialize-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary-jsonserialize-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary-jsonserialize-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary-serialization-001.phpt b/mongodb-1.2.3/tests/bson/bson-binary-serialization-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary-serialization-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary-serialization-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary-serialization_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-binary-serialization_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary-serialization_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary-serialization_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary-serialization_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-binary-serialization_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary-serialization_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary-serialization_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary-set_state-001.phpt b/mongodb-1.2.3/tests/bson/bson-binary-set_state-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary-set_state-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary-set_state-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary-set_state_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-binary-set_state_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary-set_state_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary-set_state_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary-set_state_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-binary-set_state_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary-set_state_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary-set_state_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary-tostring-001.phpt b/mongodb-1.2.3/tests/bson/bson-binary-tostring-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary-tostring-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary-tostring-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-binary_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-binary_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-binary_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-binary_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-binary_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-binary_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128-001.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128-002.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128-003.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128-004.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128-jsonserialize-001.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128-jsonserialize-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128-jsonserialize-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128-jsonserialize-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128-jsonserialize-002.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128-jsonserialize-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128-jsonserialize-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128-jsonserialize-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128-serialization-001.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128-serialization-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128-serialization-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128-serialization-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128-serialization_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128-serialization_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128-serialization_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128-serialization_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128-serialization_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128-serialization_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128-serialization_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128-serialization_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128-set_state-001.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128-set_state-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128-set_state-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128-set_state-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128-set_state_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128-set_state_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128-set_state_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128-set_state_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128-set_state_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128-set_state_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128-set_state_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128-set_state_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decimal128_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-decimal128_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decimal128_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-decimal128_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decode-001.phpt b/mongodb-1.2.3/tests/bson/bson-decode-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decode-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-decode-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-decode-002.phpt b/mongodb-1.2.3/tests/bson/bson-decode-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-decode-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-decode-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-encode-001.phpt b/mongodb-1.2.3/tests/bson/bson-encode-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-encode-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-encode-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-encode-002.phpt b/mongodb-1.2.3/tests/bson/bson-encode-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-encode-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-encode-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-encode-003.phpt b/mongodb-1.2.3/tests/bson/bson-encode-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-encode-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-encode-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-encode-004.phpt b/mongodb-1.2.3/tests/bson/bson-encode-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-encode-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-encode-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-encode-005.phpt b/mongodb-1.2.3/tests/bson/bson-encode-005.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-encode-005.phpt
rename to mongodb-1.2.3/tests/bson/bson-encode-005.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-fromJSON-001.phpt b/mongodb-1.2.3/tests/bson/bson-fromJSON-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-fromJSON-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-fromJSON-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-fromJSON-002.phpt b/mongodb-1.2.3/tests/bson/bson-fromJSON-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-fromJSON-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-fromJSON-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-fromJSON_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-fromJSON_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-fromJSON_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-fromJSON_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-fromPHP-001.phpt b/mongodb-1.2.3/tests/bson/bson-fromPHP-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-fromPHP-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-fromPHP-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-fromPHP-002.phpt b/mongodb-1.2.3/tests/bson/bson-fromPHP-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-fromPHP-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-fromPHP-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-fromPHP-003.phpt b/mongodb-1.2.3/tests/bson/bson-fromPHP-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-fromPHP-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-fromPHP-003.phpt
diff --git a/mongodb-1.2.3/tests/bson/bson-fromPHP-004.phpt b/mongodb-1.2.3/tests/bson/bson-fromPHP-004.phpt
new file mode 100644
index 00000000..bc9090b3
--- /dev/null
+++ b/mongodb-1.2.3/tests/bson/bson-fromPHP-004.phpt
@@ -0,0 +1,38 @@
+--TEST--
+BSON\fromPHP(): PHP documents with circular references
+--FILE--
+<?php
+
+require_once __DIR__ . '/../utils/tools.php';
+
+echo "\nTesting packed array with circular reference\n";
+
+$document = ['x' => 1, 'y' => []];
+$document['y'][] = &$document['y'];
+echo toJson(fromPHP($document)), "\n";
+
+echo "\nTesting associative array with circular reference\n";
+
+$document = ['x' => 1, 'y' => []];
+$document['y']['z'] = &$document['y'];
+echo toJson(fromPHP($document)), "\n";
+
+echo "\nTesting object with circular reference\n";
+
+$document = (object) ['x' => 1, 'y' => (object) []];
+$document->y->z = &$document->y;
+echo toJson(fromPHP($document)), "\n";
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Testing packed array with circular reference
+{ "x" : 1, "y" : [ [ ] ] }
+
+Testing associative array with circular reference
+{ "x" : 1, "y" : { "z" : { } } }
+
+Testing object with circular reference
+{ "x" : 1, "y" : { "z" : { } } }
+===DONE===
diff --git a/mongodb-1.2.3/tests/bson/bson-fromPHP-005.phpt b/mongodb-1.2.3/tests/bson/bson-fromPHP-005.phpt
new file mode 100644
index 00000000..3c83bc9d
--- /dev/null
+++ b/mongodb-1.2.3/tests/bson/bson-fromPHP-005.phpt
@@ -0,0 +1,27 @@
+--TEST--
+BSON\fromPHP(): PHP document with public property whose name is an empty string
+--FILE--
+<?php
+
+require_once __DIR__ . '/../utils/tools.php';
+
+$tests = [
+ ['' => 1],
+ (object) ['' => 1],
+];
+
+foreach ($tests as $document) {
+ $s = fromPHP($document);
+ echo "Test ", toJSON($s), "\n";
+ hex_dump($s);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+Test { "" : 1 }
+ 0 : 0b 00 00 00 10 00 01 00 00 00 00 [...........]
+Test { "" : 1 }
+ 0 : 0b 00 00 00 10 00 01 00 00 00 00 [...........]
+===DONE===
diff --git a/mongodb-1.2.3/tests/bson/bson-fromPHP-006.phpt b/mongodb-1.2.3/tests/bson/bson-fromPHP-006.phpt
new file mode 100644
index 00000000..b48a9c3c
--- /dev/null
+++ b/mongodb-1.2.3/tests/bson/bson-fromPHP-006.phpt
@@ -0,0 +1,62 @@
+--TEST--
+BSON\fromPHP(): PHP documents with null bytes in field name
+--FILE--
+<?php
+
+require_once __DIR__ . '/../utils/tools.php';
+
+echo "\nTesting array with one leading null byte in field name\n";
+echo throws(function() {
+ fromPHP(["\0" => 1]);
+}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n";
+
+echo "\nTesting array with one trailing null byte in field name\n";
+echo throws(function() {
+ fromPHP(["a\0" => 1]);
+}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n";
+
+echo "\nTesting array with multiple null bytes in field name\n";
+echo throws(function() {
+ fromPHP(["\0\0\0" => 1]);
+}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n";
+
+/* Per PHPC-884, field names with a leading null byte are ignored when encoding
+ * a document from an object's property hash table, since PHP uses leading bytes
+ * to denote protected and private properties. */
+echo "\nTesting object with one leading null byte in field name\n";
+hex_dump(fromPHP((object) ["\0" => 1]));
+
+echo "\nTesting object with one trailing null byte in field name\n";
+echo throws(function() {
+ fromPHP((object) ["a\0" => 1]);
+}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n";
+
+echo "\nTesting object with multiple null bytes in field name\n";
+hex_dump(fromPHP((object) ["\0\0\0" => 1]));
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+Testing array with one leading null byte in field name
+OK: Got MongoDB\Driver\Exception\UnexpectedValueException
+BSON keys cannot contain null bytes. Unexpected null byte after "".
+
+Testing array with one trailing null byte in field name
+OK: Got MongoDB\Driver\Exception\UnexpectedValueException
+BSON keys cannot contain null bytes. Unexpected null byte after "a".
+
+Testing array with multiple null bytes in field name
+OK: Got MongoDB\Driver\Exception\UnexpectedValueException
+BSON keys cannot contain null bytes. Unexpected null byte after "".
+
+Testing object with one leading null byte in field name
+ 0 : 05 00 00 00 00 [.....]
+
+Testing object with one trailing null byte in field name
+OK: Got MongoDB\Driver\Exception\UnexpectedValueException
+BSON keys cannot contain null bytes. Unexpected null byte after "a".
+
+Testing object with multiple null bytes in field name
+ 0 : 05 00 00 00 00 [.....]
+===DONE===
diff --git a/mongodb-1.2.0/tests/bson/bson-fromPHP_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-fromPHP_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-fromPHP_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-fromPHP_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-fromPHP_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-fromPHP_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-fromPHP_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-fromPHP_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-fromPHP_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-fromPHP_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-fromPHP_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-fromPHP_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-generate-document-id.phpt b/mongodb-1.2.3/tests/bson/bson-generate-document-id.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-generate-document-id.phpt
rename to mongodb-1.2.3/tests/bson/bson-generate-document-id.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-001.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-002.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-compare-001.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-compare-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-compare-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-compare-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-compare-002.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-compare-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-compare-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-compare-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-getCode-001.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-getCode-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-getCode-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-getCode-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-getScope-001.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-getScope-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-getScope-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-getScope-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-jsonserialize-001.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-jsonserialize-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-jsonserialize-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-jsonserialize-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-jsonserialize-002.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-jsonserialize-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-jsonserialize-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-jsonserialize-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-jsonserialize-003.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-jsonserialize-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-jsonserialize-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-jsonserialize-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-jsonserialize-004.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-jsonserialize-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-jsonserialize-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-jsonserialize-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-serialization-001.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-serialization-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-serialization-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-serialization-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-serialization_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-serialization_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-serialization_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-serialization_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-serialization_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-serialization_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-serialization_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-serialization_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-serialization_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-serialization_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-serialization_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-serialization_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-set_state-001.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-set_state-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-set_state-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-set_state-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-set_state_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-set_state_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-set_state_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-set_state_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-set_state_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-set_state_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-set_state_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-set_state_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-set_state_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-set_state_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-set_state_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-set_state_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript-tostring-001.phpt b/mongodb-1.2.3/tests/bson/bson-javascript-tostring-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript-tostring-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript-tostring-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-javascript_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-javascript_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-javascript_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-javascript_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-javascript_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-javascript_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-maxkey-001.phpt b/mongodb-1.2.3/tests/bson/bson-maxkey-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-maxkey-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-maxkey-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-maxkey-compare-001.phpt b/mongodb-1.2.3/tests/bson/bson-maxkey-compare-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-maxkey-compare-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-maxkey-compare-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-maxkey-jsonserialize-001.phpt b/mongodb-1.2.3/tests/bson/bson-maxkey-jsonserialize-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-maxkey-jsonserialize-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-maxkey-jsonserialize-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-maxkey-jsonserialize-002.phpt b/mongodb-1.2.3/tests/bson/bson-maxkey-jsonserialize-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-maxkey-jsonserialize-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-maxkey-jsonserialize-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-maxkey-serialization-001.phpt b/mongodb-1.2.3/tests/bson/bson-maxkey-serialization-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-maxkey-serialization-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-maxkey-serialization-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-maxkey-set_state-001.phpt b/mongodb-1.2.3/tests/bson/bson-maxkey-set_state-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-maxkey-set_state-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-maxkey-set_state-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-maxkey_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-maxkey_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-maxkey_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-maxkey_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-minkey-001.phpt b/mongodb-1.2.3/tests/bson/bson-minkey-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-minkey-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-minkey-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-minkey-compare-001.phpt b/mongodb-1.2.3/tests/bson/bson-minkey-compare-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-minkey-compare-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-minkey-compare-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-minkey-jsonserialize-001.phpt b/mongodb-1.2.3/tests/bson/bson-minkey-jsonserialize-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-minkey-jsonserialize-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-minkey-jsonserialize-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-minkey-jsonserialize-002.phpt b/mongodb-1.2.3/tests/bson/bson-minkey-jsonserialize-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-minkey-jsonserialize-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-minkey-jsonserialize-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-minkey-serialization-001.phpt b/mongodb-1.2.3/tests/bson/bson-minkey-serialization-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-minkey-serialization-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-minkey-serialization-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-minkey-set_state-001.phpt b/mongodb-1.2.3/tests/bson/bson-minkey-set_state-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-minkey-set_state-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-minkey-set_state-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-minkey_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-minkey_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-minkey_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-minkey_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-001.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-002.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-003.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-004.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-compare-001.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-compare-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-compare-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-compare-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-compare-002.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-compare-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-compare-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-compare-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-getTimestamp-001.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-getTimestamp-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-getTimestamp-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-getTimestamp-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-jsonserialize-001.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-jsonserialize-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-jsonserialize-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-jsonserialize-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-jsonserialize-002.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-jsonserialize-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-jsonserialize-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-jsonserialize-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-serialization-001.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-serialization-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-serialization-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-serialization-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-serialization_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-serialization_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-serialization_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-serialization_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-serialization_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-serialization_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-serialization_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-serialization_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-set_state-001.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-set_state-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-set_state-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-set_state-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-set_state_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-set_state_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-set_state_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-set_state_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid-set_state_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-objectid-set_state_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid-set_state_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid-set_state_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-objectid_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-objectid_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-objectid_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-objectid_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-objectid_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-objectid_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-001.phpt b/mongodb-1.2.3/tests/bson/bson-regex-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-002.phpt b/mongodb-1.2.3/tests/bson/bson-regex-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-003.phpt b/mongodb-1.2.3/tests/bson/bson-regex-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-004.phpt b/mongodb-1.2.3/tests/bson/bson-regex-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-005.phpt b/mongodb-1.2.3/tests/bson/bson-regex-005.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-005.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-005.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-compare-001.phpt b/mongodb-1.2.3/tests/bson/bson-regex-compare-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-compare-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-compare-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-compare-002.phpt b/mongodb-1.2.3/tests/bson/bson-regex-compare-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-compare-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-compare-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-jsonserialize-001.phpt b/mongodb-1.2.3/tests/bson/bson-regex-jsonserialize-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-jsonserialize-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-jsonserialize-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-jsonserialize-002.phpt b/mongodb-1.2.3/tests/bson/bson-regex-jsonserialize-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-jsonserialize-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-jsonserialize-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-jsonserialize-003.phpt b/mongodb-1.2.3/tests/bson/bson-regex-jsonserialize-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-jsonserialize-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-jsonserialize-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-jsonserialize-004.phpt b/mongodb-1.2.3/tests/bson/bson-regex-jsonserialize-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-jsonserialize-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-jsonserialize-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-serialization-001.phpt b/mongodb-1.2.3/tests/bson/bson-regex-serialization-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-serialization-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-serialization-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-serialization-002.phpt b/mongodb-1.2.3/tests/bson/bson-regex-serialization-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-serialization-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-serialization-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-serialization-003.phpt b/mongodb-1.2.3/tests/bson/bson-regex-serialization-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-serialization-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-serialization-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-serialization_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-regex-serialization_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-serialization_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-serialization_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-serialization_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-regex-serialization_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-serialization_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-serialization_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-set_state-001.phpt b/mongodb-1.2.3/tests/bson/bson-regex-set_state-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-set_state-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-set_state-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-set_state-002.phpt b/mongodb-1.2.3/tests/bson/bson-regex-set_state-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-set_state-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-set_state-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-set_state_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-regex-set_state_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-set_state_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-set_state_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex-set_state_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-regex-set_state_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex-set_state_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex-set_state_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-regex_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-regex_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-regex_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-regex_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-regex_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-regex_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-001.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-002.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-003.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-004.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-005.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-005.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-005.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-005.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-compare-001.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-compare-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-compare-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-compare-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-jsonserialize-001.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-jsonserialize-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-jsonserialize-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-jsonserialize-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-jsonserialize-002.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-jsonserialize-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-jsonserialize-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-jsonserialize-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-serialization-001.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-serialization-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-serialization-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-serialization-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-serialization-002.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-serialization-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-serialization-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-serialization-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-serialization_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-serialization_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-serialization_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-serialization_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-serialization_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-serialization_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-serialization_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-serialization_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-serialization_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-serialization_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-serialization_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-serialization_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-serialization_error-004.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-serialization_error-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-serialization_error-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-serialization_error-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-set_state-001.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-set_state-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-set_state-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-set_state-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-set_state-002.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-set_state-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-set_state-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-set_state-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-set_state_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-set_state_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-set_state_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-set_state_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-set_state_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-set_state_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-set_state_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-set_state_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-set_state_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-set_state_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-set_state_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-set_state_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp-set_state_error-004.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp-set_state_error-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp-set_state_error-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp-set_state_error-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp_error-004.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp_error-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp_error-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp_error-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp_error-005.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp_error-005.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp_error-005.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp_error-005.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-timestamp_error-006.phpt b/mongodb-1.2.3/tests/bson/bson-timestamp_error-006.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-timestamp_error-006.phpt
rename to mongodb-1.2.3/tests/bson/bson-timestamp_error-006.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-toJSON-001.phpt b/mongodb-1.2.3/tests/bson/bson-toJSON-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-toJSON-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-toJSON-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-toJSON-002.phpt b/mongodb-1.2.3/tests/bson/bson-toJSON-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-toJSON-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-toJSON-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-toJSON_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-toJSON_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-toJSON_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-toJSON_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-toJSON_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-toJSON_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-toJSON_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-toJSON_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-toJSON_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-toJSON_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-toJSON_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-toJSON_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-toPHP-001.phpt b/mongodb-1.2.3/tests/bson/bson-toPHP-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-toPHP-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-toPHP-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-toPHP-002.phpt b/mongodb-1.2.3/tests/bson/bson-toPHP-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-toPHP-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-toPHP-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-toPHP-003.phpt b/mongodb-1.2.3/tests/bson/bson-toPHP-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-toPHP-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-toPHP-003.phpt
diff --git a/mongodb-1.2.3/tests/bson/bson-toPHP-004.phpt b/mongodb-1.2.3/tests/bson/bson-toPHP-004.phpt
new file mode 100644
index 00000000..3d9de6b0
--- /dev/null
+++ b/mongodb-1.2.3/tests/bson/bson-toPHP-004.phpt
@@ -0,0 +1,577 @@
+--TEST--
+MongoDB\BSON\toPHP(): BSON array keys should be disregarded during visitation
+--FILE--
+<?php
+
+require_once __DIR__ . '/../utils/tools.php';
+
+class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable
+{
+ function bsonUnserialize(array $data)
+ {
+ parent::__construct($data);
+ }
+}
+
+$tests = [
+ null,
+ true,
+ 1,
+ 3.14,
+ 'foo',
+ [],
+ (object) [],
+ new MongoDB\BSON\Binary('foo', MongoDB\BSON\Binary::TYPE_GENERIC),
+ new MongoDB\BSON\Decimal128('3.14'),
+ new MongoDB\BSON\Javascript('function(){}'),
+ new MongoDB\BSON\MaxKey,
+ new MongoDB\BSON\MinKey,
+ new MongoDB\BSON\ObjectID('586c18d86118fd6c9012dec1'),
+ new MongoDB\BSON\Regex('foo'),
+ new MongoDB\BSON\Timestamp(1234, 5678),
+ new MongoDB\BSON\UTCDateTime('1483479256924'),
+];
+
+foreach ($tests as $value) {
+ printf("Testing %s visitor function\n", is_object($value) ? get_class($value) : gettype($value));
+ $bson = fromPHP(['x' => [$value]]);
+ // Alter the key of the BSON array's first element
+ $bson[12] = '1';
+
+ var_dump(toPHP($bson));
+
+ /* Note that numeric indexes within the HashTable are not accessible without
+ * casting the object to an array. This is because the entries are only
+ * stored with numeric indexes and do not also have string equivalents, as
+ * might be created with zend_symtable_update(). This behavior is not unique
+ * to the driver, as `(object) ['foo']` would demonstrate the same issue. */
+ var_dump(toPHP($bson, ['array' => 'object']));
+
+ var_dump(toPHP($bson, ['array' => 'MyArrayObject']));
+
+ echo "\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Testing NULL visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ NULL
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ }
+}
+
+Testing boolean visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ bool(true)
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ bool(true)
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ bool(true)
+ }
+ }
+}
+
+Testing integer visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ int(1)
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ int(1)
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ int(1)
+ }
+ }
+}
+
+Testing double visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ float(3.14)
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ float(3.14)
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ float(3.14)
+ }
+ }
+}
+
+Testing string visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ }
+}
+
+Testing array visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ array(0) {
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ object(stdClass)#%d (0) {
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(0) {
+ }
+ }
+ }
+ }
+}
+
+Testing stdClass visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ object(stdClass)#%d (0) {
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ object(stdClass)#%d (0) {
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ object(stdClass)#%d (0) {
+ }
+ }
+ }
+}
+
+Testing MongoDB\BSON\Binary visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\Binary)#%d (2) {
+ ["data"]=>
+ string(3) "foo"
+ ["type"]=>
+ int(0)
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ object(MongoDB\BSON\Binary)#%d (2) {
+ ["data"]=>
+ string(3) "foo"
+ ["type"]=>
+ int(0)
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\Binary)#%d (2) {
+ ["data"]=>
+ string(3) "foo"
+ ["type"]=>
+ int(0)
+ }
+ }
+ }
+}
+
+Testing MongoDB\BSON\Decimal128 visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\Decimal128)#%d (1) {
+ ["dec"]=>
+ string(4) "3.14"
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ object(MongoDB\BSON\Decimal128)#%d (1) {
+ ["dec"]=>
+ string(4) "3.14"
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\Decimal128)#%d (1) {
+ ["dec"]=>
+ string(4) "3.14"
+ }
+ }
+ }
+}
+
+Testing MongoDB\BSON\Javascript visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\Javascript)#%d (2) {
+ ["code"]=>
+ string(12) "function(){}"
+ ["scope"]=>
+ NULL
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ object(MongoDB\BSON\Javascript)#%d (2) {
+ ["code"]=>
+ string(12) "function(){}"
+ ["scope"]=>
+ NULL
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\Javascript)#%d (2) {
+ ["code"]=>
+ string(12) "function(){}"
+ ["scope"]=>
+ NULL
+ }
+ }
+ }
+}
+
+Testing MongoDB\BSON\MaxKey visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\MaxKey)#%d (0) {
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ object(MongoDB\BSON\MaxKey)#%d (0) {
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\MaxKey)#%d (0) {
+ }
+ }
+ }
+}
+
+Testing MongoDB\BSON\MinKey visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\MinKey)#%d (0) {
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ object(MongoDB\BSON\MinKey)#%d (0) {
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\MinKey)#%d (0) {
+ }
+ }
+ }
+}
+
+Testing MongoDB\BSON\ObjectID visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\ObjectID)#%d (1) {
+ ["oid"]=>
+ string(24) "586c18d86118fd6c9012dec1"
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ object(MongoDB\BSON\ObjectID)#%d (1) {
+ ["oid"]=>
+ string(24) "586c18d86118fd6c9012dec1"
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\ObjectID)#%d (1) {
+ ["oid"]=>
+ string(24) "586c18d86118fd6c9012dec1"
+ }
+ }
+ }
+}
+
+Testing MongoDB\BSON\Regex visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\Regex)#%d (2) {
+ ["pattern"]=>
+ string(3) "foo"
+ ["flags"]=>
+ string(0) ""
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ object(MongoDB\BSON\Regex)#%d (2) {
+ ["pattern"]=>
+ string(3) "foo"
+ ["flags"]=>
+ string(0) ""
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\Regex)#%d (2) {
+ ["pattern"]=>
+ string(3) "foo"
+ ["flags"]=>
+ string(0) ""
+ }
+ }
+ }
+}
+
+Testing MongoDB\BSON\Timestamp visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\Timestamp)#%d (2) {
+ ["increment"]=>
+ string(4) "1234"
+ ["timestamp"]=>
+ string(4) "5678"
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ object(MongoDB\BSON\Timestamp)#%d (2) {
+ ["increment"]=>
+ string(4) "1234"
+ ["timestamp"]=>
+ string(4) "5678"
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\Timestamp)#%d (2) {
+ ["increment"]=>
+ string(4) "1234"
+ ["timestamp"]=>
+ string(4) "5678"
+ }
+ }
+ }
+}
+
+Testing MongoDB\BSON\UTCDateTime visitor function
+object(stdClass)#%d (1) {
+ ["x"]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\UTCDateTime)#%d (1) {
+ ["milliseconds"]=>
+ string(13) "1483479256924"
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(stdClass)#%d (1) {
+ [0]=>
+ object(MongoDB\BSON\UTCDateTime)#%d (1) {
+ ["milliseconds"]=>
+ string(13) "1483479256924"
+ }
+ }
+}
+object(stdClass)#%d (1) {
+ ["x"]=>
+ object(MyArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ [0]=>
+ object(MongoDB\BSON\UTCDateTime)#%d (1) {
+ ["milliseconds"]=>
+ string(13) "1483479256924"
+ }
+ }
+ }
+}
+
+===DONE===
diff --git a/mongodb-1.2.0/tests/bson/bson-toPHP_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-toPHP_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-toPHP_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-toPHP_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-toPHP_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-toPHP_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-toPHP_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-toPHP_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-toPHP_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-toPHP_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-toPHP_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-toPHP_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-toPHP_error-004.phpt b/mongodb-1.2.3/tests/bson/bson-toPHP_error-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-toPHP_error-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-toPHP_error-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-unknown-001.phpt b/mongodb-1.2.3/tests/bson/bson-unknown-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-unknown-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-unknown-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-001.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-002.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-003.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-004.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-005.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-005.phpt
similarity index 97%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-005.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-005.phpt
index 60f237d4..40029b65 100644
--- a/mongodb-1.2.0/tests/bson/bson-utcdatetime-005.phpt
+++ b/mongodb-1.2.3/tests/bson/bson-utcdatetime-005.phpt
@@ -1,39 +1,39 @@
--TEST--
MongoDB\BSON\UTCDateTime construction from DateTime
--INI--
date.timezone=UTC
--FILE--
<?php
$tests = [
new DateTime(),
new DateTime('@1215282385'),
new DateTime('2011-01-01T15:03:01.012345Z'),
new DateTime('2050-11-12T13:14:15.999999Z'),
];
foreach ($tests as $test) {
var_dump(new MongoDB\BSON\UTCDateTime($test));
}
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
object(MongoDB\BSON\UTCDateTime)#%d (%d) {
["milliseconds"]=>
- string(13) "%d000"
+ string(13) "%d"
}
object(MongoDB\BSON\UTCDateTime)#%d (%d) {
["milliseconds"]=>
string(13) "1215282385000"
}
object(MongoDB\BSON\UTCDateTime)#%d (%d) {
["milliseconds"]=>
string(13) "1293894181012"
}
object(MongoDB\BSON\UTCDateTime)#%d (%d) {
["milliseconds"]=>
string(13) "2551871655999"
}
===DONE===
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-006.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-006.phpt
similarity index 97%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-006.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-006.phpt
index db8398a2..4b6a9e96 100644
--- a/mongodb-1.2.0/tests/bson/bson-utcdatetime-006.phpt
+++ b/mongodb-1.2.3/tests/bson/bson-utcdatetime-006.phpt
@@ -1,41 +1,41 @@
--TEST--
MongoDB\BSON\UTCDateTime construction from DateTimeImmutable
--SKIPIF--
<?php if (!version_compare(phpversion(), "5.5", '>=')) echo "skip >= PHP 5.5 needed\n"; ?>
--INI--
date.timezone=UTC
--FILE--
<?php
$tests = [
new DateTimeImmutable(),
new DateTimeImmutable('@1215282385'),
new DateTimeImmutable('2011-01-01T15:03:01.012345Z'),
new DateTimeImmutable('2050-11-12T13:14:15.999999Z'),
];
foreach ($tests as $test) {
var_dump(new MongoDB\BSON\UTCDateTime($test));
}
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
object(MongoDB\BSON\UTCDateTime)#%d (%d) {
["milliseconds"]=>
- string(13) "%d000"
+ string(13) "%d"
}
object(MongoDB\BSON\UTCDateTime)#%d (%d) {
["milliseconds"]=>
string(13) "1215282385000"
}
object(MongoDB\BSON\UTCDateTime)#%d (%d) {
["milliseconds"]=>
string(13) "1293894181012"
}
object(MongoDB\BSON\UTCDateTime)#%d (%d) {
["milliseconds"]=>
string(13) "2551871655999"
}
===DONE===
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-007.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-007.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-007.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-007.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-compare-001.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-compare-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-compare-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-compare-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-int-size-001.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-int-size-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-int-size-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-int-size-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-int-size-002.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-int-size-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-int-size-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-int-size-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-jsonserialize-001.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-jsonserialize-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-jsonserialize-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-jsonserialize-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-jsonserialize-002.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-jsonserialize-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-jsonserialize-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-jsonserialize-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-serialization-001.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-serialization-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-serialization-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-serialization-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-serialization-002.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-serialization-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-serialization-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-serialization-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-serialization_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-serialization_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-serialization_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-serialization_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-serialization_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-serialization_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-serialization_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-serialization_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-set_state-001.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-set_state-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-set_state-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-set_state-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-set_state-002.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-set_state-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-set_state-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-set_state-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-set_state_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-set_state_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-set_state_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-set_state_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-set_state_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-set_state_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-set_state_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-set_state_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-todatetime-001.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-todatetime-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-todatetime-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-todatetime-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-todatetime-002.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-todatetime-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-todatetime-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-todatetime-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime-tostring-001.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime-tostring-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime-tostring-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime-tostring-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime_error-001.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime_error-001.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime_error-002.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime_error-002.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime_error-003.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime_error-003.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime_error-003.phpt
diff --git a/mongodb-1.2.0/tests/bson/bson-utcdatetime_error-004.phpt b/mongodb-1.2.3/tests/bson/bson-utcdatetime_error-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bson-utcdatetime_error-004.phpt
rename to mongodb-1.2.3/tests/bson/bson-utcdatetime_error-004.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0274.phpt b/mongodb-1.2.3/tests/bson/bug0274.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0274.phpt
rename to mongodb-1.2.3/tests/bson/bug0274.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0313.phpt b/mongodb-1.2.3/tests/bson/bug0313.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0313.phpt
rename to mongodb-1.2.3/tests/bson/bug0313.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0325.phpt b/mongodb-1.2.3/tests/bson/bug0325.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0325.phpt
rename to mongodb-1.2.3/tests/bson/bug0325.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0334-001.phpt b/mongodb-1.2.3/tests/bson/bug0334-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0334-001.phpt
rename to mongodb-1.2.3/tests/bson/bug0334-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0334-002.phpt b/mongodb-1.2.3/tests/bson/bug0334-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0334-002.phpt
rename to mongodb-1.2.3/tests/bson/bug0334-002.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0341.phpt b/mongodb-1.2.3/tests/bson/bug0341.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0341.phpt
rename to mongodb-1.2.3/tests/bson/bug0341.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0347.phpt b/mongodb-1.2.3/tests/bson/bug0347.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0347.phpt
rename to mongodb-1.2.3/tests/bson/bug0347.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0528.phpt b/mongodb-1.2.3/tests/bson/bug0528.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0528.phpt
rename to mongodb-1.2.3/tests/bson/bug0528.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0531.phpt b/mongodb-1.2.3/tests/bson/bug0531.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0531.phpt
rename to mongodb-1.2.3/tests/bson/bug0531.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0544.phpt b/mongodb-1.2.3/tests/bson/bug0544.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0544.phpt
rename to mongodb-1.2.3/tests/bson/bug0544.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0592.phpt b/mongodb-1.2.3/tests/bson/bug0592.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0592.phpt
rename to mongodb-1.2.3/tests/bson/bug0592.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0623.phpt b/mongodb-1.2.3/tests/bson/bug0623.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0623.phpt
rename to mongodb-1.2.3/tests/bson/bug0623.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0631.phpt b/mongodb-1.2.3/tests/bson/bug0631.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0631.phpt
rename to mongodb-1.2.3/tests/bson/bug0631.phpt
diff --git a/mongodb-1.2.0/tests/bson/bug0672.phpt b/mongodb-1.2.3/tests/bson/bug0672.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/bug0672.phpt
rename to mongodb-1.2.3/tests/bson/bug0672.phpt
diff --git a/mongodb-1.2.0/tests/bson/typemap-001.phpt b/mongodb-1.2.3/tests/bson/typemap-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/typemap-001.phpt
rename to mongodb-1.2.3/tests/bson/typemap-001.phpt
diff --git a/mongodb-1.2.0/tests/bson/typemap-002.phpt b/mongodb-1.2.3/tests/bson/typemap-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bson/typemap-002.phpt
rename to mongodb-1.2.3/tests/bson/typemap-002.phpt
diff --git a/mongodb-1.2.0/tests/bulk/bug0667.phpt b/mongodb-1.2.3/tests/bulk/bug0667.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/bug0667.phpt
rename to mongodb-1.2.3/tests/bulk/bug0667.phpt
diff --git a/mongodb-1.2.0/tests/bulk/bulkwrite-count-001.phpt b/mongodb-1.2.3/tests/bulk/bulkwrite-count-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/bulkwrite-count-001.phpt
rename to mongodb-1.2.3/tests/bulk/bulkwrite-count-001.phpt
diff --git a/mongodb-1.2.0/tests/bulk/bulkwrite-countable-001.phpt b/mongodb-1.2.3/tests/bulk/bulkwrite-countable-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/bulkwrite-countable-001.phpt
rename to mongodb-1.2.3/tests/bulk/bulkwrite-countable-001.phpt
diff --git a/mongodb-1.2.0/tests/bulk/bulkwrite-debug-001.phpt b/mongodb-1.2.3/tests/bulk/bulkwrite-debug-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/bulkwrite-debug-001.phpt
rename to mongodb-1.2.3/tests/bulk/bulkwrite-debug-001.phpt
diff --git a/mongodb-1.2.0/tests/bulk/bulkwrite-delete-001.phpt b/mongodb-1.2.3/tests/bulk/bulkwrite-delete-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/bulkwrite-delete-001.phpt
rename to mongodb-1.2.3/tests/bulk/bulkwrite-delete-001.phpt
diff --git a/mongodb-1.2.0/tests/bulk/bulkwrite-delete_error-001.phpt b/mongodb-1.2.3/tests/bulk/bulkwrite-delete_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/bulkwrite-delete_error-001.phpt
rename to mongodb-1.2.3/tests/bulk/bulkwrite-delete_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bulk/bulkwrite-insert-001.phpt b/mongodb-1.2.3/tests/bulk/bulkwrite-insert-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/bulkwrite-insert-001.phpt
rename to mongodb-1.2.3/tests/bulk/bulkwrite-insert-001.phpt
diff --git a/mongodb-1.2.0/tests/bulk/bulkwrite-update-001.phpt b/mongodb-1.2.3/tests/bulk/bulkwrite-update-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/bulkwrite-update-001.phpt
rename to mongodb-1.2.3/tests/bulk/bulkwrite-update-001.phpt
diff --git a/mongodb-1.2.0/tests/bulk/bulkwrite-update_error-001.phpt b/mongodb-1.2.3/tests/bulk/bulkwrite-update_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/bulkwrite-update_error-001.phpt
rename to mongodb-1.2.3/tests/bulk/bulkwrite-update_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bulk/bulkwrite_error-001.phpt b/mongodb-1.2.3/tests/bulk/bulkwrite_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/bulkwrite_error-001.phpt
rename to mongodb-1.2.3/tests/bulk/bulkwrite_error-001.phpt
diff --git a/mongodb-1.2.0/tests/bulk/bulkwrite_error-002.phpt b/mongodb-1.2.3/tests/bulk/bulkwrite_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/bulkwrite_error-002.phpt
rename to mongodb-1.2.3/tests/bulk/bulkwrite_error-002.phpt
diff --git a/mongodb-1.2.0/tests/bulk/write-0001.phpt b/mongodb-1.2.3/tests/bulk/write-0001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/write-0001.phpt
rename to mongodb-1.2.3/tests/bulk/write-0001.phpt
diff --git a/mongodb-1.2.0/tests/bulk/write-0002.phpt b/mongodb-1.2.3/tests/bulk/write-0002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/bulk/write-0002.phpt
rename to mongodb-1.2.3/tests/bulk/write-0002.phpt
diff --git a/mongodb-1.2.0/tests/connect/bug0720.phpt b/mongodb-1.2.3/tests/connect/bug0720.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/bug0720.phpt
rename to mongodb-1.2.3/tests/connect/bug0720.phpt
diff --git a/mongodb-1.2.0/tests/connect/replicaset-seedlist-001.phpt b/mongodb-1.2.3/tests/connect/replicaset-seedlist-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/replicaset-seedlist-001.phpt
rename to mongodb-1.2.3/tests/connect/replicaset-seedlist-001.phpt
diff --git a/mongodb-1.2.0/tests/connect/replicaset-seedlist-002.phpt b/mongodb-1.2.3/tests/connect/replicaset-seedlist-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/replicaset-seedlist-002.phpt
rename to mongodb-1.2.3/tests/connect/replicaset-seedlist-002.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-auth-0001.phpt b/mongodb-1.2.3/tests/connect/standalone-auth-0001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-auth-0001.phpt
rename to mongodb-1.2.3/tests/connect/standalone-auth-0001.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-auth-0002.phpt b/mongodb-1.2.3/tests/connect/standalone-auth-0002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-auth-0002.phpt
rename to mongodb-1.2.3/tests/connect/standalone-auth-0002.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-plain-0001.phpt b/mongodb-1.2.3/tests/connect/standalone-plain-0001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-plain-0001.phpt
rename to mongodb-1.2.3/tests/connect/standalone-plain-0001.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-plain-0002.phpt b/mongodb-1.2.3/tests/connect/standalone-plain-0002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-plain-0002.phpt
rename to mongodb-1.2.3/tests/connect/standalone-plain-0002.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-ssl-no_verify-001.phpt b/mongodb-1.2.3/tests/connect/standalone-ssl-no_verify-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-ssl-no_verify-001.phpt
rename to mongodb-1.2.3/tests/connect/standalone-ssl-no_verify-001.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-ssl-no_verify-002.phpt b/mongodb-1.2.3/tests/connect/standalone-ssl-no_verify-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-ssl-no_verify-002.phpt
rename to mongodb-1.2.3/tests/connect/standalone-ssl-no_verify-002.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-ssl-verify_cert-001.phpt b/mongodb-1.2.3/tests/connect/standalone-ssl-verify_cert-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-ssl-verify_cert-001.phpt
rename to mongodb-1.2.3/tests/connect/standalone-ssl-verify_cert-001.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-ssl-verify_cert-002.phpt b/mongodb-1.2.3/tests/connect/standalone-ssl-verify_cert-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-ssl-verify_cert-002.phpt
rename to mongodb-1.2.3/tests/connect/standalone-ssl-verify_cert-002.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-ssl-verify_cert-error-001.phpt b/mongodb-1.2.3/tests/connect/standalone-ssl-verify_cert-error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-ssl-verify_cert-error-001.phpt
rename to mongodb-1.2.3/tests/connect/standalone-ssl-verify_cert-error-001.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-ssl-verify_cert-error-002.phpt b/mongodb-1.2.3/tests/connect/standalone-ssl-verify_cert-error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-ssl-verify_cert-error-002.phpt
rename to mongodb-1.2.3/tests/connect/standalone-ssl-verify_cert-error-002.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-x509-auth-001.phpt b/mongodb-1.2.3/tests/connect/standalone-x509-auth-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-x509-auth-001.phpt
rename to mongodb-1.2.3/tests/connect/standalone-x509-auth-001.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-x509-auth-002.phpt b/mongodb-1.2.3/tests/connect/standalone-x509-auth-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-x509-auth-002.phpt
rename to mongodb-1.2.3/tests/connect/standalone-x509-auth-002.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-x509-error-0001.phpt b/mongodb-1.2.3/tests/connect/standalone-x509-error-0001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-x509-error-0001.phpt
rename to mongodb-1.2.3/tests/connect/standalone-x509-error-0001.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-x509-extract_username-001.phpt b/mongodb-1.2.3/tests/connect/standalone-x509-extract_username-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-x509-extract_username-001.phpt
rename to mongodb-1.2.3/tests/connect/standalone-x509-extract_username-001.phpt
diff --git a/mongodb-1.2.0/tests/connect/standalone-x509-extract_username-002.phpt b/mongodb-1.2.3/tests/connect/standalone-x509-extract_username-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/connect/standalone-x509-extract_username-002.phpt
rename to mongodb-1.2.3/tests/connect/standalone-x509-extract_username-002.phpt
diff --git a/mongodb-1.2.0/tests/functional/cursor-001.phpt b/mongodb-1.2.3/tests/functional/cursor-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/functional/cursor-001.phpt
rename to mongodb-1.2.3/tests/functional/cursor-001.phpt
diff --git a/mongodb-1.2.0/tests/functional/cursorid-001.phpt b/mongodb-1.2.3/tests/functional/cursorid-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/functional/cursorid-001.phpt
rename to mongodb-1.2.3/tests/functional/cursorid-001.phpt
diff --git a/mongodb-1.2.0/tests/functional/phpinfo-1.phpt b/mongodb-1.2.3/tests/functional/phpinfo-1.phpt
similarity index 53%
rename from mongodb-1.2.0/tests/functional/phpinfo-1.phpt
rename to mongodb-1.2.3/tests/functional/phpinfo-1.phpt
index ab60843e..045c5404 100644
--- a/mongodb-1.2.0/tests/functional/phpinfo-1.phpt
+++ b/mongodb-1.2.3/tests/functional/phpinfo-1.phpt
@@ -1,29 +1,35 @@
--TEST--
phpinfo()
--SKIPIF--
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM does not do phpinfo() this way"); ?>
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
phpinfo();
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
%a
mongodb
-mongodb support => enabled
-mongodb version => 1.%d.%d%S
-mongodb stability => %s
-libmongoc version => 1.%s
-libbson version => 1.%s
+MongoDB support => enabled
+MongoDB extension version => 1.%d.%d%S
+MongoDB extension stability => %s
+libbson bundled version => 1.%d.%d%S
+libmongoc bundled version => 1.%d.%d%S
+libmongoc SSL => enabled
+libmongoc SSL library => %s
+libmongoc crypto => enabled
+libmongoc crypto library => %s
+libmongoc crypto system profile => %s
+libmongoc SASL => enabled
Directive => Local Value => Master Value
mongodb.debug => no value => no value
%a
===DONE===
diff --git a/mongodb-1.2.0/tests/functional/phpinfo-2.phpt b/mongodb-1.2.3/tests/functional/phpinfo-2.phpt
similarity index 56%
rename from mongodb-1.2.0/tests/functional/phpinfo-2.phpt
rename to mongodb-1.2.3/tests/functional/phpinfo-2.phpt
index af2a216c..91b32365 100644
--- a/mongodb-1.2.0/tests/functional/phpinfo-2.phpt
+++ b/mongodb-1.2.3/tests/functional/phpinfo-2.phpt
@@ -1,32 +1,38 @@
--TEST--
phpinfo()
--INI--
mongodb.debug=stderr
--SKIPIF--
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM does not do phpinfo() this way"); ?>
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
ini_set("mongodb.debug", "stdout");
phpinfo();
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
%a
mongodb
-mongodb support => enabled
-mongodb version => 1.%d.%d%S
-mongodb stability => %s
-libmongoc version => 1.%s
-libbson version => 1.%s
+MongoDB support => enabled
+MongoDB extension version => 1.%d.%d%S
+MongoDB extension stability => %s
+libbson bundled version => 1.%d.%d%S
+libmongoc bundled version => 1.%d.%d%S
+libmongoc SSL => enabled
+libmongoc SSL library => %s
+libmongoc crypto => enabled
+libmongoc crypto library => %s
+libmongoc crypto system profile => %s
+libmongoc SASL => enabled
Directive => Local Value => Master Value
mongodb.debug => stdout => stderr
%a
===DONE===
diff --git a/mongodb-1.2.0/tests/functional/query-sort-001.phpt b/mongodb-1.2.3/tests/functional/query-sort-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/functional/query-sort-001.phpt
rename to mongodb-1.2.3/tests/functional/query-sort-001.phpt
diff --git a/mongodb-1.2.0/tests/functional/query-sort-002.phpt b/mongodb-1.2.3/tests/functional/query-sort-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/functional/query-sort-002.phpt
rename to mongodb-1.2.3/tests/functional/query-sort-002.phpt
diff --git a/mongodb-1.2.0/tests/functional/query-sort-003.phpt b/mongodb-1.2.3/tests/functional/query-sort-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/functional/query-sort-003.phpt
rename to mongodb-1.2.3/tests/functional/query-sort-003.phpt
diff --git a/mongodb-1.2.0/tests/functional/query-sort-004.phpt b/mongodb-1.2.3/tests/functional/query-sort-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/functional/query-sort-004.phpt
rename to mongodb-1.2.3/tests/functional/query-sort-004.phpt
diff --git a/mongodb-1.2.0/tests/manager/bug0572.phpt b/mongodb-1.2.3/tests/manager/bug0572.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/bug0572.phpt
rename to mongodb-1.2.3/tests/manager/bug0572.phpt
diff --git a/mongodb-1.2.3/tests/manager/bug0851-001.phpt b/mongodb-1.2.3/tests/manager/bug0851-001.phpt
new file mode 100644
index 00000000..824e5ae4
--- /dev/null
+++ b/mongodb-1.2.3/tests/manager/bug0851-001.phpt
@@ -0,0 +1,55 @@
+--TEST--
+PHPC-851: Manager constructor should not modify options argument
+--FILE--
+<?php
+
+$options = [
+ 'readPreference' => 'secondaryPreferred',
+ 'readPreferenceTags' => [
+ ['dc' => 'ny'],
+ [],
+ ],
+];
+
+$manager = new MongoDB\Driver\Manager(null, $options);
+var_dump($options);
+
+/* Dump the Manager's ReadPreference to ensure that each element in the
+ * readPreferenceTags option was converted to an object. */
+var_dump($manager->getReadPreference());
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(2) {
+ ["readPreference"]=>
+ string(18) "secondaryPreferred"
+ ["readPreferenceTags"]=>
+ array(2) {
+ [0]=>
+ array(1) {
+ ["dc"]=>
+ string(2) "ny"
+ }
+ [1]=>
+ array(0) {
+ }
+ }
+}
+object(MongoDB\Driver\ReadPreference)#%d (%d) {
+ ["mode"]=>
+ string(18) "secondaryPreferred"
+ ["tags"]=>
+ array(2) {
+ [0]=>
+ object(stdClass)#%d (%d) {
+ ["dc"]=>
+ string(2) "ny"
+ }
+ [1]=>
+ object(stdClass)#%d (%d) {
+ }
+ }
+}
+===DONE===
diff --git a/mongodb-1.2.3/tests/manager/bug0851-002.phpt b/mongodb-1.2.3/tests/manager/bug0851-002.phpt
new file mode 100644
index 00000000..0f75090c
--- /dev/null
+++ b/mongodb-1.2.3/tests/manager/bug0851-002.phpt
@@ -0,0 +1,28 @@
+--TEST--
+PHPC-851: Manager constructor should not modify driverOptions argument
+--FILE--
+<?php
+
+$driverOptions = [
+ 'weak_cert_validation' => true,
+ 'context' => stream_context_create([
+ 'ssl' => [
+ 'allow_self_signed' => true,
+ ],
+ ]),
+];
+
+$manager = new MongoDB\Driver\Manager(null, [], $driverOptions);
+var_dump($driverOptions);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+array(2) {
+ ["weak_cert_validation"]=>
+ bool(true)
+ ["context"]=>
+ resource(4) of type (stream-context)
+}
+===DONE===
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor-001.phpt b/mongodb-1.2.3/tests/manager/manager-ctor-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor-002.phpt b/mongodb-1.2.3/tests/manager/manager-ctor-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor-002.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor-002.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor-003.phpt b/mongodb-1.2.3/tests/manager/manager-ctor-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor-003.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor-003.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor-appname-001.phpt b/mongodb-1.2.3/tests/manager/manager-ctor-appname-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor-appname-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor-appname-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor-appname_error-001.phpt b/mongodb-1.2.3/tests/manager/manager-ctor-appname_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor-appname_error-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor-appname_error-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor-read_preference-001.phpt b/mongodb-1.2.3/tests/manager/manager-ctor-read_preference-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor-read_preference-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor-read_preference-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor-read_preference-002.phpt b/mongodb-1.2.3/tests/manager/manager-ctor-read_preference-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor-read_preference-002.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor-read_preference-002.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor-read_preference-003.phpt b/mongodb-1.2.3/tests/manager/manager-ctor-read_preference-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor-read_preference-003.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor-read_preference-003.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor-read_preference-error-001.phpt b/mongodb-1.2.3/tests/manager/manager-ctor-read_preference-error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor-read_preference-error-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor-read_preference-error-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor-read_preference-error-002.phpt b/mongodb-1.2.3/tests/manager/manager-ctor-read_preference-error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor-read_preference-error-002.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor-read_preference-error-002.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor-write_concern-error-001.phpt b/mongodb-1.2.3/tests/manager/manager-ctor-write_concern-error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor-write_concern-error-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor-write_concern-error-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor_error-001.phpt b/mongodb-1.2.3/tests/manager/manager-ctor_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor_error-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor_error-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-ctor_error-002.phpt b/mongodb-1.2.3/tests/manager/manager-ctor_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-ctor_error-002.phpt
rename to mongodb-1.2.3/tests/manager/manager-ctor_error-002.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-debug-001.phpt b/mongodb-1.2.3/tests/manager/manager-debug-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-debug-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-debug-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-debug-002.phpt b/mongodb-1.2.3/tests/manager/manager-debug-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-debug-002.phpt
rename to mongodb-1.2.3/tests/manager/manager-debug-002.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-destruct-001.phpt b/mongodb-1.2.3/tests/manager/manager-destruct-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-destruct-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-destruct-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite-001.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite-002.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite-002.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite-002.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite-003.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite-003.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite-003.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite-004.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite-004.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite-004.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite-005.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite-005.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite-005.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite-005.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite-006.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite-006.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite-006.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite-006.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite-007.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite-007.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite-007.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite-007.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite-008.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite-008.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite-008.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite-008.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite-009.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite-009.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite-009.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite-009.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite-010.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite-010.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite-010.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite-010.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite-011.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite-011.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite-011.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite-011.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-001.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-002.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-002.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-002.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-003.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-003.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-003.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-004.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-004.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-004.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-005.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-005.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-005.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-005.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-006.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-006.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-006.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-006.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-007.phpt b/mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-007.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeBulkWrite_error-007.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeBulkWrite_error-007.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeCommand-001.phpt b/mongodb-1.2.3/tests/manager/manager-executeCommand-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeCommand-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeCommand-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeCommand_error-001.phpt b/mongodb-1.2.3/tests/manager/manager-executeCommand_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeCommand_error-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeCommand_error-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeQuery-001.phpt b/mongodb-1.2.3/tests/manager/manager-executeQuery-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeQuery-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeQuery-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeQuery-002.phpt b/mongodb-1.2.3/tests/manager/manager-executeQuery-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeQuery-002.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeQuery-002.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeQuery-005.phpt b/mongodb-1.2.3/tests/manager/manager-executeQuery-005.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeQuery-005.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeQuery-005.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executeQuery_error-001.phpt b/mongodb-1.2.3/tests/manager/manager-executeQuery_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executeQuery_error-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-executeQuery_error-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-executequery-without-assignment.phpt b/mongodb-1.2.3/tests/manager/manager-executequery-without-assignment.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-executequery-without-assignment.phpt
rename to mongodb-1.2.3/tests/manager/manager-executequery-without-assignment.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-getreadconcern-001.phpt b/mongodb-1.2.3/tests/manager/manager-getreadconcern-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-getreadconcern-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-getreadconcern-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-getreadpreference-001.phpt b/mongodb-1.2.3/tests/manager/manager-getreadpreference-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-getreadpreference-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-getreadpreference-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-getservers-001.phpt b/mongodb-1.2.3/tests/manager/manager-getservers-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-getservers-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-getservers-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-getservers-002.phpt b/mongodb-1.2.3/tests/manager/manager-getservers-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-getservers-002.phpt
rename to mongodb-1.2.3/tests/manager/manager-getservers-002.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-getwriteconcern-001.phpt b/mongodb-1.2.3/tests/manager/manager-getwriteconcern-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-getwriteconcern-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-getwriteconcern-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-invalidnamespace.phpt b/mongodb-1.2.3/tests/manager/manager-invalidnamespace.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-invalidnamespace.phpt
rename to mongodb-1.2.3/tests/manager/manager-invalidnamespace.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-selectserver-001.phpt b/mongodb-1.2.3/tests/manager/manager-selectserver-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-selectserver-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-selectserver-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-selectserver_error-001.phpt b/mongodb-1.2.3/tests/manager/manager-selectserver_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-selectserver_error-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-selectserver_error-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-set-uri-options-001.phpt b/mongodb-1.2.3/tests/manager/manager-set-uri-options-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-set-uri-options-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-set-uri-options-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-set-uri-options-002.phpt b/mongodb-1.2.3/tests/manager/manager-set-uri-options-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-set-uri-options-002.phpt
rename to mongodb-1.2.3/tests/manager/manager-set-uri-options-002.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-var-dump-001.phpt b/mongodb-1.2.3/tests/manager/manager-var-dump-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-var-dump-001.phpt
rename to mongodb-1.2.3/tests/manager/manager-var-dump-001.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager-wakeup.phpt b/mongodb-1.2.3/tests/manager/manager-wakeup.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager-wakeup.phpt
rename to mongodb-1.2.3/tests/manager/manager-wakeup.phpt
diff --git a/mongodb-1.2.0/tests/manager/manager_error-001.phpt b/mongodb-1.2.3/tests/manager/manager_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/manager/manager_error-001.phpt
rename to mongodb-1.2.3/tests/manager/manager_error-001.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/bug0146-001.phpt b/mongodb-1.2.3/tests/readPreference/bug0146-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/bug0146-001.phpt
rename to mongodb-1.2.3/tests/readPreference/bug0146-001.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/bug0146-002.phpt b/mongodb-1.2.3/tests/readPreference/bug0146-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/bug0146-002.phpt
rename to mongodb-1.2.3/tests/readPreference/bug0146-002.phpt
diff --git a/mongodb-1.2.3/tests/readPreference/bug0851-001.phpt b/mongodb-1.2.3/tests/readPreference/bug0851-001.phpt
new file mode 100644
index 00000000..faaa082c
--- /dev/null
+++ b/mongodb-1.2.3/tests/readPreference/bug0851-001.phpt
@@ -0,0 +1,47 @@
+--TEST--
+PHPC-851: ReadPreference constructor should not modify tagSets argument
+--FILE--
+<?php
+
+$tagSets = [
+ ['dc' => 'ny'],
+ [],
+];
+
+$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY_PREFERRED, $tagSets);
+var_dump($tagSets);
+
+/* Dump the Manager's ReadPreference to ensure that each element in the $tagSets
+ * argument was converted to an object. */
+var_dump($rp);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ array(1) {
+ ["dc"]=>
+ string(2) "ny"
+ }
+ [1]=>
+ array(0) {
+ }
+}
+object(MongoDB\Driver\ReadPreference)#%d (%d) {
+ ["mode"]=>
+ string(18) "secondaryPreferred"
+ ["tags"]=>
+ array(2) {
+ [0]=>
+ object(stdClass)#%d (%d) {
+ ["dc"]=>
+ string(2) "ny"
+ }
+ [1]=>
+ object(stdClass)#%d (%d) {
+ }
+ }
+}
+===DONE===
diff --git a/mongodb-1.2.0/tests/readPreference/readpreference-bsonserialize-001.phpt b/mongodb-1.2.3/tests/readPreference/readpreference-bsonserialize-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/readpreference-bsonserialize-001.phpt
rename to mongodb-1.2.3/tests/readPreference/readpreference-bsonserialize-001.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/readpreference-bsonserialize-002.phpt b/mongodb-1.2.3/tests/readPreference/readpreference-bsonserialize-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/readpreference-bsonserialize-002.phpt
rename to mongodb-1.2.3/tests/readPreference/readpreference-bsonserialize-002.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/readpreference-ctor-001.phpt b/mongodb-1.2.3/tests/readPreference/readpreference-ctor-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/readpreference-ctor-001.phpt
rename to mongodb-1.2.3/tests/readPreference/readpreference-ctor-001.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/readpreference-ctor_error-001.phpt b/mongodb-1.2.3/tests/readPreference/readpreference-ctor_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/readpreference-ctor_error-001.phpt
rename to mongodb-1.2.3/tests/readPreference/readpreference-ctor_error-001.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/readpreference-ctor_error-002.phpt b/mongodb-1.2.3/tests/readPreference/readpreference-ctor_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/readpreference-ctor_error-002.phpt
rename to mongodb-1.2.3/tests/readPreference/readpreference-ctor_error-002.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/readpreference-ctor_error-003.phpt b/mongodb-1.2.3/tests/readPreference/readpreference-ctor_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/readpreference-ctor_error-003.phpt
rename to mongodb-1.2.3/tests/readPreference/readpreference-ctor_error-003.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/readpreference-ctor_error-004.phpt b/mongodb-1.2.3/tests/readPreference/readpreference-ctor_error-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/readpreference-ctor_error-004.phpt
rename to mongodb-1.2.3/tests/readPreference/readpreference-ctor_error-004.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/readpreference-debug-001.phpt b/mongodb-1.2.3/tests/readPreference/readpreference-debug-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/readpreference-debug-001.phpt
rename to mongodb-1.2.3/tests/readPreference/readpreference-debug-001.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/readpreference-getMaxStalenessMS-001.phpt b/mongodb-1.2.3/tests/readPreference/readpreference-getMaxStalenessMS-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/readpreference-getMaxStalenessMS-001.phpt
rename to mongodb-1.2.3/tests/readPreference/readpreference-getMaxStalenessMS-001.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/readpreference-getMode-001.phpt b/mongodb-1.2.3/tests/readPreference/readpreference-getMode-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/readpreference-getMode-001.phpt
rename to mongodb-1.2.3/tests/readPreference/readpreference-getMode-001.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/readpreference-getTagSets-001.phpt b/mongodb-1.2.3/tests/readPreference/readpreference-getTagSets-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/readpreference-getTagSets-001.phpt
rename to mongodb-1.2.3/tests/readPreference/readpreference-getTagSets-001.phpt
diff --git a/mongodb-1.2.0/tests/readPreference/readpreference_error-001.phpt b/mongodb-1.2.3/tests/readPreference/readpreference_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/readPreference/readpreference_error-001.phpt
rename to mongodb-1.2.3/tests/readPreference/readpreference_error-001.phpt
diff --git a/mongodb-1.2.0/tests/server/bug0671-002.phpt b/mongodb-1.2.3/tests/server/bug0671-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/bug0671-002.phpt
rename to mongodb-1.2.3/tests/server/bug0671-002.phpt
diff --git a/mongodb-1.2.0/tests/server/server-constants.phpt b/mongodb-1.2.3/tests/server/server-constants.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-constants.phpt
rename to mongodb-1.2.3/tests/server/server-constants.phpt
diff --git a/mongodb-1.2.0/tests/server/server-construct-001.phpt b/mongodb-1.2.3/tests/server/server-construct-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-construct-001.phpt
rename to mongodb-1.2.3/tests/server/server-construct-001.phpt
diff --git a/mongodb-1.2.0/tests/server/server-debug.phpt b/mongodb-1.2.3/tests/server/server-debug.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-debug.phpt
rename to mongodb-1.2.3/tests/server/server-debug.phpt
diff --git a/mongodb-1.2.0/tests/server/server-errors.phpt b/mongodb-1.2.3/tests/server/server-errors.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-errors.phpt
rename to mongodb-1.2.3/tests/server/server-errors.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeBulkWrite-001.phpt b/mongodb-1.2.3/tests/server/server-executeBulkWrite-001.phpt
similarity index 97%
rename from mongodb-1.2.0/tests/server/server-executeBulkWrite-001.phpt
rename to mongodb-1.2.3/tests/server/server-executeBulkWrite-001.phpt
index 247effc9..6fce9aa7 100644
--- a/mongodb-1.2.0/tests/server/server-executeBulkWrite-001.phpt
+++ b/mongodb-1.2.3/tests/server/server-executeBulkWrite-001.phpt
@@ -1,93 +1,93 @@
--TEST--
MongoDB\Driver\Server::executeBulkWrite()
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
$manager = new MongoDB\Driver\Manager(STANDALONE);
$server = $manager->executeQuery(NS, new MongoDB\Driver\Query(array()))->getServer();
$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(array('_id' => 1, 'x' => 1));
$bulk->insert(array('_id' => 2, 'x' => 2));
$bulk->update(array('x' => 2), array('$set' => array('x' => 1)), array("limit" => 1, "upsert" => false));
$bulk->update(array('_id' => 3), array('$set' => array('x' => 3)), array("limit" => 1, "upsert" => true));
$bulk->delete(array('x' => 1), array("limit" => 1));
$result = $server->executeBulkWrite(NS, $bulk);
printf("WriteResult.server is the same: %s\n", $server == $result->getServer() ? 'yes' : 'no');
echo "\n===> WriteResult\n";
printWriteResult($result);
var_dump($result);
echo "\n===> Collection\n";
$cursor = $server->executeQuery(NS, new MongoDB\Driver\Query(array()));
var_dump(iterator_to_array($cursor));
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
WriteResult.server is the same: yes
===> WriteResult
server: %s:%d
insertedCount: 2
matchedCount: 1
modifiedCount: 1
upsertedCount: 1
deletedCount: 1
upsertedId[3]: int(3)
object(MongoDB\Driver\WriteResult)#%d (%d) {
["nInserted"]=>
int(2)
["nMatched"]=>
int(1)
["nModified"]=>
int(1)
["nRemoved"]=>
int(1)
["nUpserted"]=>
int(1)
["upsertedIds"]=>
array(1) {
[0]=>
array(%d) {
["index"]=>
int(3)
["_id"]=>
int(3)
}
}
["writeErrors"]=>
array(0) {
}
["writeConcernError"]=>
NULL
["writeConcern"]=>
- array(%d) {
+ object(MongoDB\Driver\WriteConcern)#%d (%d) {
}
}
===> Collection
array(2) {
[0]=>
object(stdClass)#%d (%d) {
["_id"]=>
int(2)
["x"]=>
int(1)
}
[1]=>
object(stdClass)#%d (%d) {
["_id"]=>
int(3)
["x"]=>
int(3)
}
}
===DONE===
diff --git a/mongodb-1.2.0/tests/server/server-executeBulkWrite-002.phpt b/mongodb-1.2.3/tests/server/server-executeBulkWrite-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeBulkWrite-002.phpt
rename to mongodb-1.2.3/tests/server/server-executeBulkWrite-002.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeBulkWrite-003.phpt b/mongodb-1.2.3/tests/server/server-executeBulkWrite-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeBulkWrite-003.phpt
rename to mongodb-1.2.3/tests/server/server-executeBulkWrite-003.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeBulkWrite-004.phpt b/mongodb-1.2.3/tests/server/server-executeBulkWrite-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeBulkWrite-004.phpt
rename to mongodb-1.2.3/tests/server/server-executeBulkWrite-004.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeBulkWrite-005.phpt b/mongodb-1.2.3/tests/server/server-executeBulkWrite-005.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeBulkWrite-005.phpt
rename to mongodb-1.2.3/tests/server/server-executeBulkWrite-005.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeCommand-001.phpt b/mongodb-1.2.3/tests/server/server-executeCommand-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeCommand-001.phpt
rename to mongodb-1.2.3/tests/server/server-executeCommand-001.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeCommand-002.phpt b/mongodb-1.2.3/tests/server/server-executeCommand-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeCommand-002.phpt
rename to mongodb-1.2.3/tests/server/server-executeCommand-002.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeCommand-003.phpt b/mongodb-1.2.3/tests/server/server-executeCommand-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeCommand-003.phpt
rename to mongodb-1.2.3/tests/server/server-executeCommand-003.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeQuery-001.phpt b/mongodb-1.2.3/tests/server/server-executeQuery-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeQuery-001.phpt
rename to mongodb-1.2.3/tests/server/server-executeQuery-001.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeQuery-002.phpt b/mongodb-1.2.3/tests/server/server-executeQuery-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeQuery-002.phpt
rename to mongodb-1.2.3/tests/server/server-executeQuery-002.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeQuery-003.phpt b/mongodb-1.2.3/tests/server/server-executeQuery-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeQuery-003.phpt
rename to mongodb-1.2.3/tests/server/server-executeQuery-003.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeQuery-004.phpt b/mongodb-1.2.3/tests/server/server-executeQuery-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeQuery-004.phpt
rename to mongodb-1.2.3/tests/server/server-executeQuery-004.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeQuery-005.phpt b/mongodb-1.2.3/tests/server/server-executeQuery-005.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeQuery-005.phpt
rename to mongodb-1.2.3/tests/server/server-executeQuery-005.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeQuery-006.phpt b/mongodb-1.2.3/tests/server/server-executeQuery-006.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeQuery-006.phpt
rename to mongodb-1.2.3/tests/server/server-executeQuery-006.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeQuery-007.phpt b/mongodb-1.2.3/tests/server/server-executeQuery-007.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeQuery-007.phpt
rename to mongodb-1.2.3/tests/server/server-executeQuery-007.phpt
diff --git a/mongodb-1.2.0/tests/server/server-executeQuery-008.phpt b/mongodb-1.2.3/tests/server/server-executeQuery-008.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server-executeQuery-008.phpt
rename to mongodb-1.2.3/tests/server/server-executeQuery-008.phpt
diff --git a/mongodb-1.2.0/tests/server/server_error-001.phpt b/mongodb-1.2.3/tests/server/server_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/server/server_error-001.phpt
rename to mongodb-1.2.3/tests/server/server_error-001.phpt
diff --git a/mongodb-1.2.0/tests/standalone/bug0159.phpt b/mongodb-1.2.3/tests/standalone/bug0159.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/bug0159.phpt
rename to mongodb-1.2.3/tests/standalone/bug0159.phpt
diff --git a/mongodb-1.2.0/tests/standalone/bug0166.phpt b/mongodb-1.2.3/tests/standalone/bug0166.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/bug0166.phpt
rename to mongodb-1.2.3/tests/standalone/bug0166.phpt
diff --git a/mongodb-1.2.0/tests/standalone/bug0231.phpt b/mongodb-1.2.3/tests/standalone/bug0231.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/bug0231.phpt
rename to mongodb-1.2.3/tests/standalone/bug0231.phpt
diff --git a/mongodb-1.2.0/tests/standalone/bug0357.phpt b/mongodb-1.2.3/tests/standalone/bug0357.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/bug0357.phpt
rename to mongodb-1.2.3/tests/standalone/bug0357.phpt
diff --git a/mongodb-1.2.0/tests/standalone/bug0487-001.phpt b/mongodb-1.2.3/tests/standalone/bug0487-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/bug0487-001.phpt
rename to mongodb-1.2.3/tests/standalone/bug0487-001.phpt
diff --git a/mongodb-1.2.0/tests/standalone/bug0487-002.phpt b/mongodb-1.2.3/tests/standalone/bug0487-002.phpt
similarity index 91%
rename from mongodb-1.2.0/tests/standalone/bug0487-002.phpt
rename to mongodb-1.2.3/tests/standalone/bug0487-002.phpt
index 762f3d86..8fd3eabc 100644
--- a/mongodb-1.2.0/tests/standalone/bug0487-002.phpt
+++ b/mongodb-1.2.3/tests/standalone/bug0487-002.phpt
@@ -1,92 +1,92 @@
--TEST--
-PHPC-487: check_closed stream handler should report closed socket as closed
+PHPC-487: Stream handler should report closed socket as closed
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; SLOW(); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
function mo_delete($id) {
$url = getMOUri() . $id;
$opts = array("http" =>
array(
"method" => "DELETE",
"timeout" => 60,
"header" => "Accept: application/json\r\n" .
"Content-type: application/x-www-form-urlencoded",
"ignore_errors" => true,
),
);
$context = stream_context_create($opts);
$out = file_get_contents($url, false, $context);
}
function mo_post($url, $body) {
global $KILLLIST;
$url = getMOUri() . $url;
$opts = array("http" =>
array(
"method" => "POST",
"timeout" => 60,
"header" => "Accept: application/json\r\n" .
"Content-type: application/x-www-form-urlencoded",
"content" => json_encode($body),
"ignore_errors" => true,
),
);
$context = stream_context_create($opts);
$out = file_get_contents($url, false, $context);
$array = json_decode($out, true);
if ($array && !empty($array["mongodb_uri"])) {
$KILLLIST[] = $array["id"];
return $array["mongodb_uri"];
}
}
$KILLLIST = array();
$dsn = mo_post("/servers", [
'id' => 'serverA',
'name' => 'mongod',
]);
$m = new MongoDB\Driver\Manager($dsn);
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
mo_post("/servers/serverA", ['action' => 'stop']);
echo throws(function() use ($m) {
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
}, 'MongoDB\Driver\Exception\RuntimeException'), "\n";
mo_post("/servers/serverA", ['action' => 'restart']);
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
foreach($KILLLIST as $id) {
mo_delete("/servers/$id");
}
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
int(1)
OK: Got MongoDB\Driver\Exception\RuntimeException
-Failed to send "insert" command with database "phongo": Failed to read %d bytes from socket within 300000 milliseconds.
+Failed to send "insert" command with database "phongo": socket error or timeout
int(1)
===DONE===
diff --git a/mongodb-1.2.0/tests/standalone/bug0545.phpt b/mongodb-1.2.3/tests/standalone/bug0545.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/bug0545.phpt
rename to mongodb-1.2.3/tests/standalone/bug0545.phpt
diff --git a/mongodb-1.2.0/tests/standalone/bug0655.phpt b/mongodb-1.2.3/tests/standalone/bug0655.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/bug0655.phpt
rename to mongodb-1.2.3/tests/standalone/bug0655.phpt
diff --git a/mongodb-1.2.0/tests/standalone/command-aggregate-001.phpt b/mongodb-1.2.3/tests/standalone/command-aggregate-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/command-aggregate-001.phpt
rename to mongodb-1.2.3/tests/standalone/command-aggregate-001.phpt
diff --git a/mongodb-1.2.0/tests/standalone/connectiontimeoutexception-001.phpt b/mongodb-1.2.3/tests/standalone/connectiontimeoutexception-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/connectiontimeoutexception-001.phpt
rename to mongodb-1.2.3/tests/standalone/connectiontimeoutexception-001.phpt
diff --git a/mongodb-1.2.0/tests/standalone/executiontimeoutexception-001.phpt b/mongodb-1.2.3/tests/standalone/executiontimeoutexception-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/executiontimeoutexception-001.phpt
rename to mongodb-1.2.3/tests/standalone/executiontimeoutexception-001.phpt
diff --git a/mongodb-1.2.0/tests/standalone/executiontimeoutexception-002.phpt b/mongodb-1.2.3/tests/standalone/executiontimeoutexception-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/executiontimeoutexception-002.phpt
rename to mongodb-1.2.3/tests/standalone/executiontimeoutexception-002.phpt
diff --git a/mongodb-1.2.0/tests/standalone/manager-as-singleton.phpt b/mongodb-1.2.3/tests/standalone/manager-as-singleton.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/manager-as-singleton.phpt
rename to mongodb-1.2.3/tests/standalone/manager-as-singleton.phpt
diff --git a/mongodb-1.2.0/tests/standalone/query-errors.phpt b/mongodb-1.2.3/tests/standalone/query-errors.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/query-errors.phpt
rename to mongodb-1.2.3/tests/standalone/query-errors.phpt
diff --git a/mongodb-1.2.0/tests/standalone/update-multi-001.phpt b/mongodb-1.2.3/tests/standalone/update-multi-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/update-multi-001.phpt
rename to mongodb-1.2.3/tests/standalone/update-multi-001.phpt
diff --git a/mongodb-1.2.0/tests/standalone/write-error-001.phpt b/mongodb-1.2.3/tests/standalone/write-error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/standalone/write-error-001.phpt
rename to mongodb-1.2.3/tests/standalone/write-error-001.phpt
diff --git a/mongodb-1.2.0/tests/standalone/writeresult-isacknowledged-001.phpt b/mongodb-1.2.3/tests/standalone/writeresult-isacknowledged-001.phpt
similarity index 95%
rename from mongodb-1.2.0/tests/standalone/writeresult-isacknowledged-001.phpt
rename to mongodb-1.2.3/tests/standalone/writeresult-isacknowledged-001.phpt
index 64214a6b..ac680680 100644
--- a/mongodb-1.2.0/tests/standalone/writeresult-isacknowledged-001.phpt
+++ b/mongodb-1.2.3/tests/standalone/writeresult-isacknowledged-001.phpt
@@ -1,46 +1,46 @@
--TEST--
MongoDB\Driver\WriteResult::isAcknowledged() with default WriteConcern
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
$manager = new MongoDB\Driver\Manager(STANDALONE);
$bulk = new \MongoDB\Driver\BulkWrite;
$bulk->insert(array('x' => 1));
$result = $manager->executeBulkWrite(NS, $bulk);
printf("WriteResult::isAcknowledged(): %s\n", $result->isAcknowledged() ? 'true' : 'false');
var_dump($result);
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
WriteResult::isAcknowledged(): true
object(MongoDB\Driver\WriteResult)#%d (%d) {
["nInserted"]=>
int(1)
["nMatched"]=>
int(0)
["nModified"]=>
int(0)
["nRemoved"]=>
int(0)
["nUpserted"]=>
int(0)
["upsertedIds"]=>
array(0) {
}
["writeErrors"]=>
array(0) {
}
["writeConcernError"]=>
NULL
["writeConcern"]=>
- array(%d) {
+ object(MongoDB\Driver\WriteConcern)#%d (%d) {
}
}
===DONE===
diff --git a/mongodb-1.2.0/tests/standalone/writeresult-isacknowledged-002.phpt b/mongodb-1.2.3/tests/standalone/writeresult-isacknowledged-002.phpt
similarity index 95%
rename from mongodb-1.2.0/tests/standalone/writeresult-isacknowledged-002.phpt
rename to mongodb-1.2.3/tests/standalone/writeresult-isacknowledged-002.phpt
index 5943f833..2eefa401 100644
--- a/mongodb-1.2.0/tests/standalone/writeresult-isacknowledged-002.phpt
+++ b/mongodb-1.2.3/tests/standalone/writeresult-isacknowledged-002.phpt
@@ -1,50 +1,50 @@
--TEST--
MongoDB\Driver\WriteResult::isAcknowledged() with inherited WriteConcern
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
/* We use w:0 here because libmongoc detects w:1 as the server's default and
*/
$manager = new MongoDB\Driver\Manager(STANDALONE . "/?w=0");
$bulk = new \MongoDB\Driver\BulkWrite;
$bulk->insert(array('x' => 1));
$result = $manager->executeBulkWrite(NS, $bulk);
printf("WriteResult::isAcknowledged(): %s\n", $result->isAcknowledged() ? 'true' : 'false');
var_dump($result);
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
WriteResult::isAcknowledged(): false
object(MongoDB\Driver\WriteResult)#%d (%d) {
["nInserted"]=>
int(0)
["nMatched"]=>
int(0)
["nModified"]=>
int(0)
["nRemoved"]=>
int(0)
["nUpserted"]=>
int(0)
["upsertedIds"]=>
array(0) {
}
["writeErrors"]=>
array(0) {
}
["writeConcernError"]=>
NULL
["writeConcern"]=>
- array(%d) {
+ object(MongoDB\Driver\WriteConcern)#%d (%d) {
["w"]=>
int(0)
}
}
===DONE===
diff --git a/mongodb-1.2.0/tests/standalone/writeresult-isacknowledged-003.phpt b/mongodb-1.2.3/tests/standalone/writeresult-isacknowledged-003.phpt
similarity index 95%
rename from mongodb-1.2.0/tests/standalone/writeresult-isacknowledged-003.phpt
rename to mongodb-1.2.3/tests/standalone/writeresult-isacknowledged-003.phpt
index 7918dcb5..e2d6fe57 100644
--- a/mongodb-1.2.0/tests/standalone/writeresult-isacknowledged-003.phpt
+++ b/mongodb-1.2.3/tests/standalone/writeresult-isacknowledged-003.phpt
@@ -1,48 +1,48 @@
--TEST--
MongoDB\Driver\WriteResult::isAcknowledged() with custom WriteConcern
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
$manager = new MongoDB\Driver\Manager(STANDALONE);
$bulk = new \MongoDB\Driver\BulkWrite;
$bulk->insert(array('x' => 2));
$result = $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));
printf("WriteResult::isAcknowledged(): %s\n", $result->isAcknowledged() ? 'true' : 'false');
var_dump($result);
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
WriteResult::isAcknowledged(): false
object(MongoDB\Driver\WriteResult)#%d (%d) {
["nInserted"]=>
NULL
["nMatched"]=>
NULL
["nModified"]=>
NULL
["nRemoved"]=>
NULL
["nUpserted"]=>
NULL
["upsertedIds"]=>
array(0) {
}
["writeErrors"]=>
array(0) {
}
["writeConcernError"]=>
NULL
["writeConcern"]=>
- array(%d) {
+ object(MongoDB\Driver\WriteConcern)#%d (%d) {
["w"]=>
int(0)
}
}
===DONE===
diff --git a/mongodb-1.2.0/tests/utils/PHONGO-FIXTURES.json.gz b/mongodb-1.2.3/tests/utils/PHONGO-FIXTURES.json.gz
similarity index 100%
rename from mongodb-1.2.0/tests/utils/PHONGO-FIXTURES.json.gz
rename to mongodb-1.2.3/tests/utils/PHONGO-FIXTURES.json.gz
diff --git a/mongodb-1.2.0/tests/utils/basic-skipif.inc b/mongodb-1.2.3/tests/utils/basic-skipif.inc
similarity index 100%
rename from mongodb-1.2.0/tests/utils/basic-skipif.inc
rename to mongodb-1.2.3/tests/utils/basic-skipif.inc
diff --git a/mongodb-1.2.0/tests/utils/basic.inc b/mongodb-1.2.3/tests/utils/basic.inc
similarity index 100%
rename from mongodb-1.2.0/tests/utils/basic.inc
rename to mongodb-1.2.3/tests/utils/basic.inc
diff --git a/mongodb-1.2.0/tests/utils/classes.inc b/mongodb-1.2.3/tests/utils/classes.inc
similarity index 100%
rename from mongodb-1.2.0/tests/utils/classes.inc
rename to mongodb-1.2.3/tests/utils/classes.inc
diff --git a/mongodb-1.2.0/tests/utils/tools.php b/mongodb-1.2.3/tests/utils/tools.php
similarity index 96%
rename from mongodb-1.2.0/tests/utils/tools.php
rename to mongodb-1.2.3/tests/utils/tools.php
index 93fb2268..a96b4227 100644
--- a/mongodb-1.2.0/tests/utils/tools.php
+++ b/mongodb-1.2.3/tests/utils/tools.php
@@ -1,394 +1,412 @@
<?php
+
/**
* Prints a traditional hex dump of byte values and printable characters.
*
* @see http://stackoverflow.com/a/4225813/162228
* @param string $data Binary data
* @param integer $width Bytes displayed per line
*/
function hex_dump($data, $width = 16)
{
static $pad = '.'; // Placeholder for non-printable characters
static $from = '';
static $to = '';
if ($from === '') {
for ($i = 0; $i <= 0xFF; $i++) {
$from .= chr($i);
$to .= ($i >= 0x20 && $i <= 0x7E) ? chr($i) : $pad;
}
}
$hex = str_split(bin2hex($data), $width * 2);
$chars = str_split(strtr($data, $from, $to), $width);
$offset = 0;
$length = $width * 3;
foreach ($hex as $i => $line) {
printf("%6X : %-{$length}s [%s]\n", $offset, implode(' ', str_split($line, 2)), $chars[$i]);
$offset += $width;
}
}
+/**
+ * Canonicalizes a JSON string.
+ *
+ * @param string $json
+ * @return string
+ */
+function json_canonicalize($json)
+{
+ $json = json_encode(json_decode($json));
+
+ /* Versions of PHP before 7.1 replace empty JSON keys with "_empty_" when
+ * decoding to a stdClass (see: https://bugs.php.net/bug.php?id=46600). Work
+ * around this by replacing "_empty_" keys before returning.
+ */
+ return str_replace('"_empty_":', '"":', $json);
+}
+
/**
* Return a collection name to use for the test file.
*
* The filename will be stripped of the base path to the test suite (prefix) as
* well as the PHP file extension (suffix). Special characters (including hyphen
* for shell compatibility) will be replaced with underscores.
*
* @param string $filename
* @return string
*/
function makeCollectionNameFromFilename($filename)
{
$filename = realpath($filename);
$prefix = realpath(dirname(__FILE__) . '/..') . DIRECTORY_SEPARATOR;
$replacements = array(
// Strip test path prefix
sprintf('/^%s/', preg_quote($prefix, '/')) => '',
// Strip file extension suffix
'/\.php$/' => '',
// SKIPIFs add ".skip" between base name and extension
'/\.skip$/' => '',
// Replace special characters with underscores
sprintf('/[%s]/', preg_quote('-$/\\', '/')) => '_',
);
return preg_replace(array_keys($replacements), array_values($replacements), $filename);
}
function TESTCOMMANDS($uri) {
$cmd = array(
"configureFailPoint" => 1,
);
$command = new MongoDB\Driver\Command($cmd);
$manager = new MongoDB\Driver\Manager($uri);
try {
$result = $manager->executeCommand("test", $command);
} catch(Exception $e) {
/* command not found */
if ($e->getCode() == 59) {
die("skip this test requires mongod with enableTestCommands");
}
}
}
function NEEDS($uri) {
if (!constant($uri)) {
exit("skip -- need '$uri' defined");
}
}
function PREDICTABLE() {
global $servers;
foreach($servers as $k => $v) {
if (!defined($k) || !constant($k)) {
exit("skip - needs predictable environment (e.g. vagrant)\n");
}
}
}
function SLOW() {
if (getenv("SKIP_SLOW_TESTS")) {
exit("skip SKIP_SLOW_TESTS");
}
}
function LOAD($uri, $dbname = DATABASE_NAME, $collname = COLLECTION_NAME, $filename = null) {
if (!$filename) {
$filename = "compress.zlib://" . __DIR__ . "/" . "PHONGO-FIXTURES.json.gz";
}
$manager = new MongoDB\Driver\Manager($uri);
$bulk = new MongoDB\Driver\BulkWrite(['ordered' => false]);
$server = $manager->selectServer(new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY));
$data = file_get_contents($filename);
$array = json_decode($data);
foreach($array as $document) {
$bulk->insert($document);
}
$retval = $server->executeBulkWrite("$dbname.$collname", $bulk);
if ($retval->getInsertedCount() !== count($array)) {
exit(sprintf('skip Fixtures were not loaded (expected: %d, actual: %d)', $total, $retval->getInsertedCount()));
}
}
function CLEANUP($uri, $dbname = DATABASE_NAME, $collname = COLLECTION_NAME) {
try {
$manager = new MongoDB\Driver\Manager($uri);
$cmd = new MongoDB\Driver\Command(array("drop" => $collname));
$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY);
try {
$manager->executeCommand($dbname, $cmd, $rp);
} catch(Exception $e) {
do {
/* ns not found */
if ($e->getCode() == 59 || $e->getCode() == 26) {
continue;
}
throw $e;
} while (0);
}
} catch(Exception $e) {
echo "skip (cleanup); $uri: " . $e->getCode(), ": ", $e->getMessage();
exit(1);
}
}
function START($id, array $options = array()) {
/* starting/stopping servers only works using the Vagrant setup */
PREDICTABLE();
$options += array("name" => "mongod", "id" => $id);
$opts = array(
"http" => array(
"timeout" => 60,
"method" => "PUT",
"header" => "Accept: application/json\r\n" .
"Content-type: application/x-www-form-urlencoded",
"content" => json_encode($options),
"ignore_errors" => true,
),
);
$ctx = stream_context_create($opts);
$json = file_get_contents(getMOUri() . "/servers/$id", false, $ctx);
$result = json_decode($json, true);
/* Failed -- or was already started */
if (!isset($result["mongodb_uri"])) {
DELETE($id);
define($id, false);
} else {
define($id, $result["mongodb_uri"]);
$FILENAME = sys_get_temp_dir() . "/PHONGO-SERVERS.json";
$json = file_get_contents($FILENAME);
$config = json_decode($json, true);
$config[$id] = constant($id);
file_put_contents($FILENAME, json_encode($config, JSON_PRETTY_PRINT));
}
}
function DELETE($id) {
$opts = array(
"http" => array(
"timeout" => 60,
"method" => "DELETE",
"header" => "Accept: application/json\r\n",
"ignore_errors" => true,
),
);
$ctx = stream_context_create($opts);
$json = file_get_contents(getMOUri() . "/servers/$id", false, $ctx);
$FILENAME = sys_get_temp_dir() . "/PHONGO-SERVERS.json";
$json = file_get_contents($FILENAME);
$config = json_decode($json, true);
unset($config[$id]);
file_put_contents($FILENAME, json_encode($config, JSON_PRETTY_PRINT));
}
function severityToString($type) {
switch($type) {
case E_WARNING:
return "E_WARNING";
default:
return "Some other #_$type";
}
}
function raises($function, $type, $infunction = null) {
$errhandler = function($severity, $message, $file, $line, $errcontext) {
throw new ErrorException($message, 0, $severity, $file, $line);
};
set_error_handler($errhandler, $type);
try {
$function();
} catch(Exception $e) {
if ($e instanceof ErrorException && $e->getSeverity() & $type) {
if ($infunction) {
$trace = $e->getTrace();
$function = $trace[0]["function"];
if (strcasecmp($function, $infunction) == 0) {
printf("OK: Got %s thrown from %s\n", $exceptionname, $infunction);
} else {
printf("ALMOST: Got %s - but was thrown in %s, not %s\n", $exceptionname, $function, $infunction);
}
restore_error_handler();
return $e->getMessage();
}
printf("OK: Got %s\n", severityToString($type));
} else {
printf("ALMOST: Got %s - expected %s\n", get_class($e), $exceptionname);
}
restore_error_handler();
return $e->getMessage();
}
echo "FAILED: Expected $exceptionname thrown!\n";
restore_error_handler();
}
function throws($function, $exceptionname, $infunction = null) {
try {
$function();
} catch(Exception $e) {
$message = str_replace(array("\n", "\r"), ' ', $e->getMessage());
if ($e instanceof $exceptionname) {
if ($infunction) {
$trace = $e->getTrace();
$function = $trace[0]["function"];
if (strcasecmp($function, $infunction) == 0) {
printf("OK: Got %s thrown from %s\n", $exceptionname, $infunction);
} else {
printf("ALMOST: Got %s - but was thrown in %s, not %s (%s)\n", $exceptionname, $function, $infunction, $message);
}
return $e->getMessage();
}
printf("OK: Got %s\n", $exceptionname);
} else {
printf("ALMOST: Got %s (%s) - expected %s\n", get_class($e), $message, $exceptionname);
}
return $e->getMessage();
}
echo "FAILED: Expected $exceptionname thrown, but no exception thrown!\n";
}
function printServer(MongoDB\Driver\Server $server)
{
printf("server: %s:%d\n", $server->getHost(), $server->getPort());
}
function printWriteResult(MongoDB\Driver\WriteResult $result, $details = true)
{
printServer($result->getServer());
printf("insertedCount: %d\n", $result->getInsertedCount());
printf("matchedCount: %d\n", $result->getMatchedCount());
printf("modifiedCount: %d\n", $result->getModifiedCount());
printf("upsertedCount: %d\n", $result->getUpsertedCount());
printf("deletedCount: %d\n", $result->getDeletedCount());
foreach ($result->getUpsertedIds() as $index => $id) {
printf("upsertedId[%d]: ", $index);
var_dump($id);
}
$writeConcernError = $result->getWriteConcernError();
printWriteConcernError($writeConcernError ? $writeConcernError : null, $details);
foreach ($result->getWriteErrors() as $writeError) {
printWriteError($writeError);
}
}
function printWriteConcernError(MongoDB\Driver\WriteConcernError $error = null, $details)
{
if ($error) {
/* This stuff is generated by the server, no need for us to test it */
if (!$details) {
printf("writeConcernError: %s (%d)\n", $error->getMessage(), $error->getCode());
return;
}
var_dump($error);
printf("writeConcernError.message: %s\n", $error->getMessage());
printf("writeConcernError.code: %d\n", $error->getCode());
printf("writeConcernError.info: ");
var_dump($error->getInfo());
}
}
function printWriteError(MongoDB\Driver\WriteError $error)
{
var_dump($error);
printf("writeError[%d].message: %s\n", $error->getIndex(), $error->getMessage());
printf("writeError[%d].code: %d\n", $error->getIndex(), $error->getCode());
}
function getInsertCount($retval) {
return $retval->getInsertedCount();
}
function getModifiedCount($retval) {
return $retval->getModifiedCount();
}
function getDeletedCount($retval) {
return $retval->getDeletedCount();
}
function getUpsertedCount($retval) {
return $retval->getUpsertedCount();
}
function getWriteErrors($retval) {
return (array)$retval->getWriteErrors();
}
function def($arr) {
foreach($arr as $const => $value) {
define($const, getenv("PHONGO_TEST_$const") ?: $value);
}
}
function configureFailPoint(MongoDB\Driver\Manager $manager, $failPoint, $mode, $data = array()) {
$doc = array(
"configureFailPoint" => $failPoint,
"mode" => $mode,
);
if ($data) {
$doc["data"] = $data;
}
$cmd = new MongoDB\Driver\Command($doc);
$result = $manager->executeCommand("admin", $cmd);
$arr = current($result->toArray());
if (empty($arr->ok)) {
var_dump($result);
throw new RuntimeException("Failpoint failed");
}
return true;
}
function failMaxTimeMS(MongoDB\Driver\Manager $manager) {
return configureFailPoint($manager, "maxTimeAlwaysTimeOut", array("times" => 1));
}
function getMOUri() {
if (!($HOST = getenv("MONGODB_ORCHESTRATION_HOST"))) {
$HOST = "192.168.112.10";
}
if (!($PORT = getenv("MONGODB_ORCHESTRATION_PORT"))) {
$PORT = "8889";
}
$MO = "http://$HOST:$PORT/v1";
return $MO;
}
function getMOPresetBase() {
if (!($BASE = getenv("mongodb_orchestration_base"))) {
$BASE = "/phongo/";
}
return $BASE;
}
function toPHP($var, $typemap = array()) {
return MongoDB\BSON\toPHP($var, $typemap);
}
function fromPHP($var) {
return MongoDB\BSON\fromPHP($var);
}
function toJSON($var) {
return MongoDB\BSON\toJSON($var);
}
function fromJSON($var) {
return MongoDB\BSON\fromJSON($var);
}
/* Note: this fail point may terminate the mongod process, so you may want to
* use this in conjunction with a throwaway server. */
function failGetMore(MongoDB\Driver\Manager $manager) {
return configureFailPoint($manager, "failReceivedGetmore", "alwaysOn");
}
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-bsonserialize-001.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-bsonserialize-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-bsonserialize-001.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-bsonserialize-001.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-bsonserialize-002.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-bsonserialize-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-bsonserialize-002.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-bsonserialize-002.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-constants.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-constants.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-constants.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-constants.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-ctor-001.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-ctor-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-ctor-001.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-ctor-001.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-ctor_error-001.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-ctor_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-ctor_error-001.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-ctor_error-001.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-ctor_error-002.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-ctor_error-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-ctor_error-002.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-ctor_error-002.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-ctor_error-003.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-ctor_error-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-ctor_error-003.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-ctor_error-003.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-ctor_error-004.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-ctor_error-004.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-ctor_error-004.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-ctor_error-004.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-ctor_error-005.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-ctor_error-005.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-ctor_error-005.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-ctor_error-005.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-debug-001.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-debug-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-debug-001.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-debug-001.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-debug-002.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-debug-002.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-debug-002.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-debug-002.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-debug-003.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-debug-003.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-debug-003.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-debug-003.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-getjournal-001.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-getjournal-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-getjournal-001.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-getjournal-001.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-getw-001.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-getw-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-getw-001.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-getw-001.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern-getwtimeout-001.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern-getwtimeout-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern-getwtimeout-001.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern-getwtimeout-001.phpt
diff --git a/mongodb-1.2.0/tests/writeConcern/writeconcern_error-001.phpt b/mongodb-1.2.3/tests/writeConcern/writeconcern_error-001.phpt
similarity index 100%
rename from mongodb-1.2.0/tests/writeConcern/writeconcern_error-001.phpt
rename to mongodb-1.2.3/tests/writeConcern/writeconcern_error-001.phpt
diff --git a/package.xml b/package.xml
index 0a347cfc..9935abc1 100644
--- a/package.xml
+++ b/package.xml
@@ -1,980 +1,889 @@
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.10.1" version="2.1" xmlns="http://pear.php.net/dtd/package-2.1" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.1 http://pear.php.net/dtd/package-2.1.xsd">
<name>mongodb</name>
<channel>pecl.php.net</channel>
<summary>MongoDB driver for PHP</summary>
<description>The purpose of this driver is to provide exceptionally thin glue between MongoDB
and PHP, implementing only fundemental and performance-critical components
necessary to build a fully-functional MongoDB driver.</description>
<lead>
<name>Hannes Magnusson</name>
<user>bjori</user>
<email>bjori@php.net</email>
<active>yes</active>
</lead>
<lead>
<name>Jeremy Mikola</name>
<user>jmikola</user>
<email>jmikola@php.net</email>
<active>yes</active>
</lead>
<lead>
<name>Derick Rethans</name>
<user>derick</user>
<email>derick@php.net</email>
<active>yes</active>
</lead>
- <date>2016-11-29</date>
- <time>15:59:59</time>
+ <date>2017-01-17</date>
+ <time>18:35:13</time>
<version>
- <release>1.2.0</release>
- <api>1.2.0</api>
+ <release>1.2.3</release>
+ <api>1.2.3</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.apache.org/licenses/LICENSE-2.0">Apache License</license>
<notes>
** Bug
- * [PHPC-316] - config.w32 should define MONGOC_ENABLE_SASL
- * [PHPC-447] - Windows builds should generate libmongoc and libbson config and version files
- * [PHPC-481] - Windows reports wrong mongoc and libbson versions
- * [PHPC-520] - Document driver dependencies
- * [PHPC-525] - Demonstrate non-empty $filter argument in Query constructor example
- * [PHPC-530] - Document MongoDB\Driver\Server type constants
- * [PHPC-554] - Rephrase unsupported/corrupt BSON messages
- * [PHPC-625] - Document that persistent sockets should not be re-used after forking
- * [PHPC-673] - Cursor::isDead() returns true despite cursor being alive
- * [PHPC-674] - Advise users to install pkg-config for building the driver
- * [PHPC-693] - Unacknowledged WriteResults have null counts
- * [PHPC-728] - Wrong example on how to provide client certificate
- * [PHPC-748] - CursorID is not properly expressed on 32-bit platforms
- * [PHPC-756] - fromJSON() should not evaluate bson_error_t.message as boolean
- * [PHPC-762] - undefined symbol: mongoc_write_concern_is_acknowledged
- * [PHPC-788] - Timestamp on 32-bit platforms breaks
- * [PHPC-790] - UTCDateTime constructor should truncate floats
- * [PHPC-794] - BulkWrite::update() silently ignores invalid arguments
- * [PHPC-801] - Empty ReadConcern and WriteConcern should serialize to BSON documents
- * [PHPC-804] - Timestamp and UTCDateTime constructors should accept integers in strict types mode
- * [PHPC-838] - Javascript objects are always serialized as BSON code types without scope
-
-** Epic
- * [PHPC-542] - Remove dependency on mongoc private symbols
+ * [PHPC-855] - Assertion failure in stream_not_found() after failed getmore operation
+ * [PHPC-856] - Build errors using bundled libbson and system libmongoc
+ * [PHPC-872] - Do not use system crypto policy for OpenSSL on Windows
+ * [PHPC-878] - php_json_serializable_ce missing in PHP versions before 5.5.10 and 5.4.26
+ * [PHPC-879] - php_date_get_immutable_ce missing in PHP versions before 5.6.8 and 5.5.24
+ * [PHPC-881] - Windows CA stores should be opened with read-only flag
+ * [PHPC-883] - BSON array keys should be disregarded during visitation
+ * [PHPC-884] - Public property with zero-length name ignored during BSON encoding
+ * [PHPC-885] - Alphabetize Regex flags when instantiating from BSON
+ * [PHPC-886] - Always recalculate field name length when encoding BSON
+ * [PHPC-891] - BSON encoding should throw if PHP keys contain null bytes
** Improvement
- * [PHPC-359] - Ensure read preference tags sets serialize as documents
- * [PHPC-424] - Validate that read preference tag set is an array of documents
- * [PHPC-433] - Persist topology state between requests
- * [PHPC-486] - Add syntax highlighting to BSON persistence articles
- * [PHPC-637] - Remind users that connection URIs should be encoded
- * [PHPC-654] - Implement comparison handlers for BSON types
- * [PHPC-676] - Do not allow BulkWrite objects to be executed multiple times
- * [PHPC-684] - Report bypassDocumentValidation in BulkWrite debug output
- * [PHPC-705] - Do not unnecessarily wrap filters in $query
- * [PHPC-721] - Javascript constructor should throw if code contains null bytes
- * [PHPC-724] - Regex constructor should throw if pattern or flags contain null bytes
- * [PHPC-726] - Allow cross-platform serialization of Timestamp and UTCDateTime
- * [PHPC-731] - Parse Timestamp argument as strings to accept large integers
- * [PHPC-739] - Rename &quot;javascript&quot; to &quot;code&quot; in Javascript BSON class
- * [PHPC-741] - Use consistent exceptions for BSON initialization methods
- * [PHPC-742] - Regex constructor should default flags arg to empty string
- * [PHPC-744] - Improve error messages for invalid Decimal128 and ObjectID strings
- * [PHPC-746] - Default Manager URI to &quot;mongodb://127.0.0.1/&quot;
- * [PHPC-754] - Remove libmongoc-priv system dependency in config.m4
- * [PHPC-755] - Remove include of private mongoc-trace.h
-
-** New Feature
- * [PHPC-459] - BSON objects should implement JsonSerializable
- * [PHPC-460] - BSON classes should support PHP serialization and var_export()
- * [PHPC-498] - ReadPreference, ReadConcern, and WriteConcern should serialize to BSON
- * [PHPC-536] - UTCDateTime constructor should default to current time and accept DateTimeInterface
- * [PHPC-552] - Implement ObjectID::getTimestamp() method
- * [PHPC-619] - Implement Decimal 128 type spec
- * [PHPC-716] - Support new readConcern level &quot;linearizable&quot;
- * [PHPC-729] - Implement __toString() method for Javascript and Binary
- * [PHPC-730] - Implement getCode() and getScope() for Javascript
- * [PHPC-734] - Support providing collation per operation
- * [PHPC-752] - Allow users to set a limit on acceptable staleness
- * [PHPC-757] - Implement The MongoDB Handshake Protocol
- * [PHPC-786] - Support appname in URI array options
-
-** Question
- * [PHPC-723] - Blocking connect() leads to cumulative timeouts for multiple inaccessible servers
+ * [PHPC-635] - WriteResult debug handler should return objects
+ * [PHPC-873] - Do not allow mixing bundled and system libbson and libmongoc libraries
** Task
- * [PHPC-313] - BSON should throw when encountering 64-bit integer on 32-bit platform
- * [PHPC-416] - Document SSL options
- * [PHPC-504] - Document how RP, RC, and WC are serialized to BSON
- * [PHPC-533] - Remove PHONGO_API macro for exported functions
- * [PHPC-584] - Remove MkDocs documentation in favor of PHP.net documentation
- * [PHPC-600] - Manager::getServers() should use mongoc_client_get_server_descriptions()
- * [PHPC-601] - Cursor::getServer() should not access mongoc_cursor_t.client
- * [PHPC-602] - Create command cursors with mongoc_cursor_new_from_command_document()
- * [PHPC-603] - Use mongoc_read_prefs_t getters instead of accessing struct fields directly
- * [PHPC-604] - WriteConcern::getJournal() should use mongoc_write_concern_journal_is_set()
- * [PHPC-605] - Rely on libmongoc&apos;s socket handling and SSL implementation
- * [PHPC-606] - Use mongoc_server_description_t public API
- * [PHPC-607] - Manager::selectServer() should use mongoc_client_select_server()
- * [PHPC-609] - Ensure client URI handling uses libmongoc public API
- * [PHPC-610] - Client construction should use mongoc_write_concern_is_valid()
- * [PHPC-611] - WriteResult::isAcknowledged() should use mongoc_write_concern_is_acknowledged()
- * [PHPC-618] - Implement SDAM Monitoring spec
- * [PHPC-629] - Upgrade libbson and libmongoc to 1.4.0
- * [PHPC-630] - Update bson_visitor_t for unsupported type function pointer
- * [PHPC-653] - Document WriteResult, WriteConcernError, and WriteError classes
- * [PHPC-659] - Update bson_visitor_t for decimal 128 type function pointer
- * [PHPC-662] - Use mongoc_bulk_operation_get_hint()
- * [PHPC-663] - Use mongoc_bulk_operation_get_write_concern()
- * [PHPC-664] - Use mongoc_write_concern_get_w()
- * [PHPC-665] - Remove private libmongoc and libbson header includes
- * [PHPC-680] - BulkWrite::count() should return number of operations instead of estimated round-trips
- * [PHPC-682] - Do not use mongoc_bulk_operation_t private API in BulkWrite debug handler
- * [PHPC-687] - Consolidate struct definitions for PHP 5 and 7
- * [PHPC-688] - Do not use mongoc_cursor_t private API in Cursor debug handler
- * [PHPC-689] - Query and command execution should use mongoc_cursor_set_hint()
- * [PHPC-703] - Update configure scripts for upstream SSL changes
- * [PHPC-704] - Do not set &quot;mongodb.debug&quot; based on Manager&apos;s $driverOptions[&quot;debug&quot;]
- * [PHPC-708] - Port http://php.net/manual/en/mongo.security.php to the new docs/driver
- * [PHPC-718] - Define extension dependencies
- * [PHPC-751] - Document MongoDB\BSON\Decimal128
- * [PHPC-758] - Disable Decimal128 for bundled libbson and libmongoc 1.4.0
- * [PHPC-761] - Remove BSON_NAMESPACE constant
- * [PHPC-769] - Javascript serialization, export, and dump should always include scope field
- * [PHPC-777] - Document MongoDB\Driver\ReadConcern::LINEARIZABLE
- * [PHPC-779] - Switch serialization from O type to C type
- * [PHPC-780] - Document persistent connection behavior
- * [PHPC-783] - Use mongoc_collection_find_with_opts() for Query execution
- * [PHPC-789] - Remove __wakeup from BSON/* classes
- * [PHPC-791] - Upgrade libbson and libmongoc to 1.5.0
- * [PHPC-796] - Use flexible opts for BulkWrite update and delete
- * [PHPC-799] - Create notice for all third party libraries
- * [PHPC-805] - Query &quot;partial&quot; option is now &quot;allowPartialResults&quot;
- * [PHPC-806] - Document Query options for mongoc_collection_find_with_opts()
- * [PHPC-807] - Document &quot;collation&quot; option for Query and BulkWrite update/delete
- * [PHPC-824] - SDAM spec update : Update the topology from each handshake
- * [PHPC-826] - Document that socket paths must be URL-encoded
- * [PHPC-827] - Update Max Staleness implementation
- * [PHPC-829] - BSON Regex flags must be alphabetically ordered
+ * [PHPC-633] - Add lines to phpinfo() output regarding support for SSL and SASL
+ * [PHPC-714] - Implement BSON corpus test suite
+ * [PHPC-890] - Add license header to source files
</notes>
<contents>
<dir name="/">
<file md5sum="b301ead064e031b76fa08488a1055594" name="scripts/centos/ldap/Domain.ldif" role="test" />
<file md5sum="4daa783214593b6d7deb42f35c6e027c" name="scripts/centos/ldap/Users.ldif" role="test" />
<file md5sum="001e9cfe2c64b4afe413c12da3a75103" name="scripts/centos/ldap/basics.ldif" role="test" />
<file md5sum="624db776065d2ce0e76c3dd252c86c27" name="scripts/centos/ldap/install.sh" role="test" />
<file md5sum="3373471c13615482fcb5abd156a99013" name="scripts/centos/ldap/mongod.ldif" role="test" />
<file md5sum="79641e9055dc9a4c810cdc580d420ccf" name="scripts/centos/ldap/pw.ldif" role="test" />
<file md5sum="7069ce3fbf9612eb20df4de56e2915e7" name="scripts/centos/ldap/saslauthd.conf" role="test" />
<file md5sum="c2d1c7b3b12d970c295ebceda4bd429f" name="scripts/centos/ldap/users" role="test" />
<file md5sum="9add0018a9ebebb32e6f9d689d53ce14" name="scripts/centos/essentials.sh" role="test" />
<file md5sum="43a925c212fc965e90d89951d04945c1" name="scripts/freebsd/essentials.sh" role="test" />
<file md5sum="18b03fd810bde00c7493002a94e24865" name="scripts/freebsd/phongo.sh" role="test" />
<file md5sum="0e6d3baeb0ffedee6a4d5500a725331b" name="scripts/presets/replicaset-30.json" role="test" />
<file md5sum="b5c14f08571fcfe2aa5641a7a18d4c3f" name="scripts/presets/replicaset.json" role="test" />
<file md5sum="d850cacbf5527fd7b4a46958e66ed5c9" name="scripts/presets/standalone-24.json" role="test" />
<file md5sum="d9b0cfc2035c3d5c0baae6959a90c36e" name="scripts/presets/standalone-26.json" role="test" />
<file md5sum="60c5e499c429eb07e1f96b37baa42adf" name="scripts/presets/standalone-30.json" role="test" />
<file md5sum="b8cc887e5bccc9bc1f715d041d2d657b" name="scripts/presets/standalone-auth.json" role="test" />
<file md5sum="2bc383470aa5dfc60185ef19a8a80276" name="scripts/presets/standalone-plain.json" role="test" />
<file md5sum="82e65a04030826c41d713787833fb52a" name="scripts/presets/standalone-ssl.json" role="test" />
<file md5sum="c5acd3fbc060927121ff626f3b730cfa" name="scripts/presets/standalone-x509.json" role="test" />
<file md5sum="17927182a5fb8fb9d1ad8c8571c32b29" name="scripts/presets/standalone.json" role="test" />
<file md5sum="06b59105c25447470ca9f7c589b80b46" name="scripts/ssl/ca.pem" role="test" />
<file md5sum="6bdc883fdbe5a1c736518e5ec5f67964" name="scripts/ssl/client.pem" role="test" />
<file md5sum="94a4db9c47b58aa3d00b70b4bd178601" name="scripts/ssl/crl.pem" role="test" />
<file md5sum="bfccd366ca201a01f8f5bea8c900abc9" name="scripts/ssl/server.pem" role="test" />
<file md5sum="cb636b47cf37dace58be73272a74efc3" name="scripts/ubuntu/ldap/install.sh" role="test" />
<file md5sum="c4c1a6c234d983da8fe0382bcb8c1420" name="scripts/ubuntu/ldap/saslauthd.conf" role="test" />
<file md5sum="b199baa1ee52bc252773485de56b10f6" name="scripts/ubuntu/essentials.sh" role="test" />
<file md5sum="b4a9eb39b992590f39b56e4fdbabe757" name="scripts/ubuntu/mongo-orchestration.sh" role="test" />
<file md5sum="903c38a7e9d59fec770c1138de85d7be" name="scripts/ubuntu/phongo.sh" role="test" />
<file md5sum="a51616233fb311f458391b668e0254e9" name="scripts/vmware/kernel.sh" role="test" />
+ <file md5sum="c88d285816124a410618f8dc72d00d89" name="scripts/convert-bson-corpus-tests.php" role="test" />
<file md5sum="28868809c797d2b57b0f21bfc66b4862" name="scripts/convert-mo-tests.php" role="test" />
<file md5sum="35671ea9b24b02610710ef676bc539a2" name="scripts/list-servers.php" role="test" />
<file md5sum="43b39f67f12cacf6f21de522b51a2900" name="scripts/start-servers.php" role="test" />
- <file md5sum="a700b338902d4b416d04ba3fb444c27a" name="src/BSON/Binary.c" role="src" />
- <file md5sum="283106a9edc86895cfb58b0655d54a14" name="src/BSON/Decimal128.c" role="src" />
- <file md5sum="2dcb930914117b50e36a68f244fee425" name="src/BSON/Javascript.c" role="src" />
- <file md5sum="f54f789c22840449e1a5f104f45075bc" name="src/BSON/MaxKey.c" role="src" />
- <file md5sum="622f3a6ca7d2bdb70750dd2c9ffe5595" name="src/BSON/MinKey.c" role="src" />
- <file md5sum="2e6e12d877e9094dbdab7d33c6ffa862" name="src/BSON/ObjectID.c" role="src" />
- <file md5sum="bdab4cd9ec6dcc6789941486c88a617b" name="src/BSON/Persistable.c" role="src" />
- <file md5sum="c565997b86b2eebb2b66815b468553f3" name="src/BSON/Regex.c" role="src" />
- <file md5sum="67d731c9a9e95f043268502de4e6298b" name="src/BSON/Serializable.c" role="src" />
- <file md5sum="56e806a165713ff662d056a4688cadfb" name="src/BSON/Timestamp.c" role="src" />
- <file md5sum="d4fddac4ba46de069cd028d2e51c4b2f" name="src/BSON/Type.c" role="src" />
- <file md5sum="06ea218c23faba895256f3ae9a9580cb" name="src/BSON/UTCDateTime.c" role="src" />
- <file md5sum="a6f37174474130a4c84208f57d141709" name="src/BSON/Unserializable.c" role="src" />
- <file md5sum="9a7a8d4b102c1cd2bdfc607dad008aa4" name="src/MongoDB/Exception/AuthenticationException.c" role="src" />
- <file md5sum="28d4d1baec7f8f4a94891d50dd7bade5" name="src/MongoDB/Exception/BulkWriteException.c" role="src" />
- <file md5sum="e2afdbe9298a14efda81a1233f9fa3b5" name="src/MongoDB/Exception/ConnectionException.c" role="src" />
- <file md5sum="ce3c5f987008020192be525f28bd0765" name="src/MongoDB/Exception/ConnectionTimeoutException.c" role="src" />
- <file md5sum="32a30824a1e1f46d6b9b7f9da12f5d1e" name="src/MongoDB/Exception/Exception.c" role="src" />
- <file md5sum="466e88737134ac65fbc580ad1d56e404" name="src/MongoDB/Exception/ExecutionTimeoutException.c" role="src" />
- <file md5sum="827569a67aa7015e926af2356cf76b6e" name="src/MongoDB/Exception/InvalidArgumentException.c" role="src" />
- <file md5sum="5150d3950d83c607d21adad0bf980262" name="src/MongoDB/Exception/LogicException.c" role="src" />
- <file md5sum="5f2ff1f090db57bf79f0eb1d84826d5a" name="src/MongoDB/Exception/RuntimeException.c" role="src" />
- <file md5sum="e05a5816f611ea8b567ecaa5d71e92ae" name="src/MongoDB/Exception/SSLConnectionException.c" role="src" />
- <file md5sum="20d7bbf19981dfe2025d6960d0c3f8a4" name="src/MongoDB/Exception/UnexpectedValueException.c" role="src" />
- <file md5sum="ece9fb9e0612280764a871f35586dad9" name="src/MongoDB/Exception/WriteException.c" role="src" />
- <file md5sum="28465102e4999c843cbd5ceda3677161" name="src/MongoDB/BulkWrite.c" role="src" />
- <file md5sum="13896ee55721ce265b245cb2f2461aff" name="src/MongoDB/Command.c" role="src" />
- <file md5sum="84c95f0cc9f1eb3ba6550259a05520ee" name="src/MongoDB/Cursor.c" role="src" />
- <file md5sum="89b7a6ce2ab7091f9b8de02cecc38876" name="src/MongoDB/CursorId.c" role="src" />
- <file md5sum="9d025151ab7b832e5f76e0c3e064574b" name="src/MongoDB/Manager.c" role="src" />
- <file md5sum="63e65301d9fe5d0c4f8d7389bf0e837d" name="src/MongoDB/Query.c" role="src" />
- <file md5sum="04a39a325139cea0399c4d5cc8b1b24a" name="src/MongoDB/ReadConcern.c" role="src" />
- <file md5sum="81b750f68d5a4121db4756ee64e2a32f" name="src/MongoDB/ReadPreference.c" role="src" />
- <file md5sum="411ceae5f0c24d197c56f8246ea1a5cc" name="src/MongoDB/Server.c" role="src" />
- <file md5sum="e6cd46af6b818596801ab498fcd92ec5" name="src/MongoDB/WriteConcern.c" role="src" />
- <file md5sum="3338d09b337ea10ab77487cebaa58a53" name="src/MongoDB/WriteConcernError.c" role="src" />
- <file md5sum="961035774c75f3abd595f40d3b5337c4" name="src/MongoDB/WriteError.c" role="src" />
- <file md5sum="d1469230855eef14daa98933468a0134" name="src/MongoDB/WriteResult.c" role="src" />
+ <file md5sum="887dbc852b03cb3b3409b0534fb84f38" name="src/BSON/Binary.c" role="src" />
+ <file md5sum="ef142d5d1ae5dd5b25f0c17f7dc4564b" name="src/BSON/Decimal128.c" role="src" />
+ <file md5sum="04fc72ae14ea89601936d0e4029ba36c" name="src/BSON/Javascript.c" role="src" />
+ <file md5sum="c2582986fe8b88541b763a826f70d2be" name="src/BSON/MaxKey.c" role="src" />
+ <file md5sum="29cd37a40764ffdfc9b7b7745f819749" name="src/BSON/MinKey.c" role="src" />
+ <file md5sum="7ecb5c1d1701670d8a3e38cf80f5647d" name="src/BSON/ObjectID.c" role="src" />
+ <file md5sum="29be27feba0c4fd22926b3fb230f32af" name="src/BSON/Persistable.c" role="src" />
+ <file md5sum="d90c70ae77ff4b4c8f1add5f9899ab8d" name="src/BSON/Regex.c" role="src" />
+ <file md5sum="ffe11cd5ab7a3ab3867762e3821bd5fa" name="src/BSON/Serializable.c" role="src" />
+ <file md5sum="6491f8fef9cf7483baedab1196fb4a7e" name="src/BSON/Timestamp.c" role="src" />
+ <file md5sum="254160369cadac36e99cae9eaced58da" name="src/BSON/Type.c" role="src" />
+ <file md5sum="a08118d8ca4784695b109ccbc9bd7127" name="src/BSON/UTCDateTime.c" role="src" />
+ <file md5sum="edf08eba86d062a6edf1450353ce9dfa" name="src/BSON/Unserializable.c" role="src" />
+ <file md5sum="593902253871c923e3aa9e4b5c280c1b" name="src/MongoDB/Exception/AuthenticationException.c" role="src" />
+ <file md5sum="37613d8c56e6eb3f1f49f2eb18ac70fd" name="src/MongoDB/Exception/BulkWriteException.c" role="src" />
+ <file md5sum="2b5d73974422a0348c27243caf4b069c" name="src/MongoDB/Exception/ConnectionException.c" role="src" />
+ <file md5sum="f8201ee15a471e28f73bbe0cd32893fb" name="src/MongoDB/Exception/ConnectionTimeoutException.c" role="src" />
+ <file md5sum="2fe7eb153dd9afe4055b07ad14045096" name="src/MongoDB/Exception/Exception.c" role="src" />
+ <file md5sum="da4efc2cf46801eadd28b27f152f9c76" name="src/MongoDB/Exception/ExecutionTimeoutException.c" role="src" />
+ <file md5sum="15194367fe2e61a77ba09272a9025ce4" name="src/MongoDB/Exception/InvalidArgumentException.c" role="src" />
+ <file md5sum="b7752dc99773bbb2cd1a566ab77b6ab1" name="src/MongoDB/Exception/LogicException.c" role="src" />
+ <file md5sum="645ac5c512ea9625f76143e0799c4a41" name="src/MongoDB/Exception/RuntimeException.c" role="src" />
+ <file md5sum="1b79b54ac2266c02ebc70092d59340a4" name="src/MongoDB/Exception/SSLConnectionException.c" role="src" />
+ <file md5sum="b42547a62ddcfeaf3a0680778bd3dd92" name="src/MongoDB/Exception/UnexpectedValueException.c" role="src" />
+ <file md5sum="5146c8a838074bb66cdac1a60bf1e3f4" name="src/MongoDB/Exception/WriteException.c" role="src" />
+ <file md5sum="d8722e3b0b0fb0451c1ee7af3983106c" name="src/MongoDB/BulkWrite.c" role="src" />
+ <file md5sum="3aebdb02c66141bc300ca990d23b453b" name="src/MongoDB/Command.c" role="src" />
+ <file md5sum="d21618f3ede6031977fa85a715657f8e" name="src/MongoDB/Cursor.c" role="src" />
+ <file md5sum="ca3952c22871de02a15b3ab8b6b5e7a4" name="src/MongoDB/CursorId.c" role="src" />
+ <file md5sum="8bd35939d3c3febbc7c2fe9dd958b954" name="src/MongoDB/Manager.c" role="src" />
+ <file md5sum="ece20c625f4f83ade4bd6b05968ebcd2" name="src/MongoDB/Query.c" role="src" />
+ <file md5sum="3ea60178579f3098045344f01fa4294c" name="src/MongoDB/ReadConcern.c" role="src" />
+ <file md5sum="8ec2039aba9590a65cb9f54fb0d2b6fb" name="src/MongoDB/ReadPreference.c" role="src" />
+ <file md5sum="211dae5aad495d8ed2e5057744b0c669" name="src/MongoDB/Server.c" role="src" />
+ <file md5sum="d624cf9741e0d68de027064c50c45ae0" name="src/MongoDB/WriteConcern.c" role="src" />
+ <file md5sum="87552471709877ae481ff4af1885314a" name="src/MongoDB/WriteConcernError.c" role="src" />
+ <file md5sum="ac45b95e6e41701484730581640a7737" name="src/MongoDB/WriteError.c" role="src" />
+ <file md5sum="546d7d2b12467854a35838083c9499ea" name="src/MongoDB/WriteResult.c" role="src" />
<file md5sum="3eb4bc184583d52ef59d9909fa96c3ae" name="src/contrib/php_array_api.h" role="src" />
<file md5sum="1066d5c9a05b1b1cb8f4de5a7e291574" name="src/libbson/build/autotools/m4/ac_check_typedef.m4" role="src" />
<file md5sum="e40a5f02f4d82a68b3df43d99dd92ed6" name="src/libbson/build/autotools/m4/ac_compile_check_sizeof.m4" role="src" />
<file md5sum="b96bb8fad4ea5d66c6b3af718186e2e0" name="src/libbson/build/autotools/m4/ac_create_stdint_h.m4" role="src" />
<file md5sum="7b5ee49855c90a9da6a0b1f1f0b8ef8f" name="src/libbson/build/autotools/m4/as-compiler-flag.m4" role="src" />
<file md5sum="8d942f69b5f3c15ecae4b75bb7e80614" name="src/libbson/build/autotools/m4/ax_check_compile_flag.m4" role="src" />
<file md5sum="05bd24609268702a36d50d5edd3661ac" name="src/libbson/build/autotools/m4/ax_check_link_flag.m4" role="src" />
<file md5sum="b5114dfcf027b0f9a47b6e6841015be6" name="src/libbson/build/autotools/m4/ax_pthread.m4" role="src" />
<file md5sum="ad8d52d54e0f97c0e4e385376ea73bc0" name="src/libbson/build/autotools/m4/pkg.m4" role="src" />
<file md5sum="ff788a8b5eea35b1cc226bb2686c3537" name="src/libbson/build/autotools/m4/silent.m4" role="src" />
<file md5sum="c78c5e9b49b67a725e831823492642da" name="src/libbson/build/autotools/CheckAtomics.m4" role="src" />
<file md5sum="33c0e73d71ead46ce5a11eda4ce160b6" name="src/libbson/build/autotools/CheckCompiler.m4" role="src" />
<file md5sum="7321a188b1b870fb49f5a003ef426f7a" name="src/libbson/build/autotools/CheckHeaders.m4" role="src" />
<file md5sum="81b2b641c597d18daa4066ed7c37d7b7" name="src/libbson/build/autotools/CheckHost.m4" role="src" />
<file md5sum="5147ee8369f1744715365976b38777fc" name="src/libbson/build/autotools/CheckProgs.m4" role="src" />
<file md5sum="fa4a5cc1c9475999c468488eb19e4ffe" name="src/libbson/build/autotools/CheckTarget.m4" role="src" />
<file md5sum="760f59b300da59088cde1fec10892516" name="src/libbson/build/autotools/Coverage.m4" role="src" />
<file md5sum="46768d326c5f994af7e1ffbb0db32a4e" name="src/libbson/build/autotools/Endian.m4" role="src" />
<file md5sum="5d8b05763742a46fa526b042bd8d1ba1" name="src/libbson/build/autotools/FindDependencies.m4" role="src" />
<file md5sum="e0e854d844eca0badff9c88943c37c26" name="src/libbson/build/autotools/MaintainerFlags.m4" role="src" />
<file md5sum="6a2e174f53c50c3bddfb31444cf24174" name="src/libbson/build/autotools/Optimizations.m4" role="src" />
<file md5sum="98c586cc0577a30efcf22b03eca1e35e" name="src/libbson/build/autotools/PrintBuildConfiguration.m4" role="src" />
<file md5sum="fba3745f469f5fe94c400ad018a8fb57" name="src/libbson/build/autotools/ReadCommandLineArguments.m4" role="src" />
<file md5sum="04ab110ebc0f75c1558392e1748770cf" name="src/libbson/build/autotools/SetupAutomake.m4" role="src" />
<file md5sum="f229599b4333a2cdf5be29136cc6f2e2" name="src/libbson/build/autotools/SetupLibtool.m4" role="src" />
<file md5sum="2e50f9a74b7624536d967c01897fd22e" name="src/libbson/build/autotools/Versions.m4" role="src" />
<file md5sum="60d5834d66c34c59c0a12a7eecbf84ab" name="src/libbson/src/bson/b64_ntop.h" role="src" />
<file md5sum="70cebe2a7a17de7d489317b7a1db7c73" name="src/libbson/src/bson/b64_pton.h" role="src" />
<file md5sum="b65b92b902052d02281a5c8772911f3a" name="src/libbson/src/bson/bcon.c" role="src" />
<file md5sum="16188df02b9c53ee8e084fbeabaa707e" name="src/libbson/src/bson/bcon.h" role="src" />
<file md5sum="2fdfba5acf3beb2fbdabaafe44d7fde7" name="src/libbson/src/bson/bson-atomic.c" role="src" />
<file md5sum="4ed90c95f202a914604bf106e757d1d0" name="src/libbson/src/bson/bson-atomic.h" role="src" />
<file md5sum="717ca038872a5c6611358a548e72dec5" name="src/libbson/src/bson/bson-clock.c" role="src" />
<file md5sum="691d6cf644ac2d58e8af36986413c4da" name="src/libbson/src/bson/bson-clock.h" role="src" />
<file md5sum="db543766d2c6eb499fd156a06620e2ed" name="src/libbson/src/bson/bson-compat.h" role="src" />
<file md5sum="2dbddf33a12a0530bbc16b8da96609fc" name="src/libbson/src/bson/bson-config.h" role="src" />
<file md5sum="f8a850d89808d7eb510bd01ac4afc67f" name="src/libbson/src/bson/bson-config.h.in" role="src" />
<file md5sum="11177a64ea0d8136b73312d0e9313dae" name="src/libbson/src/bson/bson-context-private.h" role="src" />
<file md5sum="7e41e815cd22805185e92e4b96460398" name="src/libbson/src/bson/bson-context.c" role="src" />
<file md5sum="da04f8ca2154e1d981e9bfcf495fbf10" name="src/libbson/src/bson/bson-context.h" role="src" />
<file md5sum="5da3ce74efc6b11b3c0162f22565892f" name="src/libbson/src/bson/bson-decimal128.c" role="src" />
<file md5sum="1fb1f9a67c33d160a49028ae6ce670d3" name="src/libbson/src/bson/bson-decimal128.h" role="src" />
<file md5sum="a8d2b6f9a285e267c372ec7e3def2258" name="src/libbson/src/bson/bson-endian.h" role="src" />
- <file md5sum="94281be1939683f40c2e4b8eb869a385" name="src/libbson/src/bson/bson-error.c" role="src" />
+ <file md5sum="10013b2ccaa0104a646d5f7bdf5e817d" name="src/libbson/src/bson/bson-error.c" role="src" />
<file md5sum="7f1cd62347eb8689c5d44f74339eef44" name="src/libbson/src/bson/bson-error.h" role="src" />
<file md5sum="be7c0192246dad6a30b0f3835380c343" name="src/libbson/src/bson/bson-iso8601-private.h" role="src" />
<file md5sum="bcbaf2a59bc63350978d2be3401118bb" name="src/libbson/src/bson/bson-iso8601.c" role="src" />
<file md5sum="dd58c4fad45f1fdf5e47ea8ef76da28f" name="src/libbson/src/bson/bson-iter.c" role="src" />
<file md5sum="3b60b85112afed36d7c6d6009186220b" name="src/libbson/src/bson/bson-iter.h" role="src" />
<file md5sum="13b36f988eaf632f7ed4fe7ecd3e1092" name="src/libbson/src/bson/bson-json.c" role="src" />
<file md5sum="46c5d1f93f18828b30204a53bc854213" name="src/libbson/src/bson/bson-json.h" role="src" />
<file md5sum="30bfe359c194f01ffbf1afe053c4f16c" name="src/libbson/src/bson/bson-keys.c" role="src" />
<file md5sum="8851e34c640dd841e417126a0fad24e7" name="src/libbson/src/bson/bson-keys.h" role="src" />
<file md5sum="a56682511d0ae04d6f9b5b54c6553a62" name="src/libbson/src/bson/bson-macros.h" role="src" />
<file md5sum="016da785f4bd6ed2654a1dd6e7e20711" name="src/libbson/src/bson/bson-md5.c" role="src" />
<file md5sum="d9fe5fc0e7ed5c220f44fee8144b3dfd" name="src/libbson/src/bson/bson-md5.h" role="src" />
<file md5sum="7ae6e31017ccc52a43a611f5f54703d1" name="src/libbson/src/bson/bson-memory.c" role="src" />
<file md5sum="4733c13bb3bc962ba54a8083befcd46e" name="src/libbson/src/bson/bson-memory.h" role="src" />
<file md5sum="202b1f52365ef9e6a6302cd6d705c15b" name="src/libbson/src/bson/bson-oid.c" role="src" />
<file md5sum="61e7243d7a21a5a42931d75a5671be88" name="src/libbson/src/bson/bson-oid.h" role="src" />
<file md5sum="fafa4d77b189d7eadf89c3a3e46d1f7d" name="src/libbson/src/bson/bson-private.h" role="src" />
<file md5sum="7bb1abda28771803d3aeda67f2281227" name="src/libbson/src/bson/bson-reader.c" role="src" />
<file md5sum="0f6028ee1998c26ff78494d798b64555" name="src/libbson/src/bson/bson-reader.h" role="src" />
<file md5sum="d4277ba8b3bc0f7753931062eb0cd5eb" name="src/libbson/src/bson/bson-stdint-win32.h" role="src" />
<file md5sum="aca225176c92ed018d3c240802570121" name="src/libbson/src/bson/bson-stdint.h" role="src" />
<file md5sum="3f4ab58c8dcf69dd36c8a294afed0ee5" name="src/libbson/src/bson/bson-string.c" role="src" />
<file md5sum="c9fe72eb5bece52473425623ff433410" name="src/libbson/src/bson/bson-string.h" role="src" />
<file md5sum="2a16019c51864483f27676c83e12b293" name="src/libbson/src/bson/bson-thread-private.h" role="src" />
<file md5sum="bbe5863f79868d0a153f9eb591f09f20" name="src/libbson/src/bson/bson-timegm-private.h" role="src" />
<file md5sum="346c4904b781e818f8b051e843a33bb1" name="src/libbson/src/bson/bson-timegm.c" role="src" />
<file md5sum="bfce2ccd7df4ee0f9af4c4e7603f8d34" name="src/libbson/src/bson/bson-types.h" role="src" />
<file md5sum="2569921096086498f3b7e84dd37aea1b" name="src/libbson/src/bson/bson-utf8.c" role="src" />
<file md5sum="f9ff0cc5a8d3222e68520776b67e0cae" name="src/libbson/src/bson/bson-utf8.h" role="src" />
<file md5sum="56e722161bfffd9e3061d5220a3cc38a" name="src/libbson/src/bson/bson-value.c" role="src" />
<file md5sum="d84715f50622e23a70356fe77e218a8b" name="src/libbson/src/bson/bson-value.h" role="src" />
<file md5sum="f80a6f4a82a8c86f63eaccc1c8d147ee" name="src/libbson/src/bson/bson-version-functions.c" role="src" />
<file md5sum="21e2e2b57227d3ae0f13d57db7c211db" name="src/libbson/src/bson/bson-version-functions.h" role="src" />
- <file md5sum="928da0513ed9e478b74c9fe33f524328" name="src/libbson/src/bson/bson-version.h" role="src" />
+ <file md5sum="0787cba6c988e4760769e0186d8b4121" name="src/libbson/src/bson/bson-version.h" role="src" />
<file md5sum="9036341d3488d5aec2b028fae66c8c6f" name="src/libbson/src/bson/bson-version.h.in" role="src" />
<file md5sum="8108f0a5dd05650f53c3c2eca95d587c" name="src/libbson/src/bson/bson-writer.c" role="src" />
<file md5sum="3f42b83215982f5a37fb4e90a23da49a" name="src/libbson/src/bson/bson-writer.h" role="src" />
<file md5sum="9a3aea149ec8740816be515f45edc324" name="src/libbson/src/bson/bson.c" role="src" />
<file md5sum="f04c28071d9ee3f56246fc07339336b6" name="src/libbson/src/bson/bson.h" role="src" />
<file md5sum="cf5990b5d3ad3eafa329f4e6884582c5" name="src/libbson/src/yajl/yajl.c" role="src" />
<file md5sum="1c55df90c4d949c316e6e6e7498ec15c" name="src/libbson/src/yajl/yajl_alloc.c" role="src" />
<file md5sum="f3f9167846f7260138bd38021f9bb189" name="src/libbson/src/yajl/yajl_alloc.h" role="src" />
<file md5sum="289df9f01dc8865130659219e517a4b4" name="src/libbson/src/yajl/yajl_buf.c" role="src" />
<file md5sum="505cbe3ad7cbbb5579cecc86c8f93087" name="src/libbson/src/yajl/yajl_buf.h" role="src" />
<file md5sum="0963d85f30e3afa40fb4ae813ab046c1" name="src/libbson/src/yajl/yajl_bytestack.h" role="src" />
<file md5sum="ba824372c3ea0f9824d0b69315a0dec8" name="src/libbson/src/yajl/yajl_common.h" role="src" />
<file md5sum="b60b45eb35dd40f2b3825233fa9661bc" name="src/libbson/src/yajl/yajl_encode.c" role="src" />
<file md5sum="5644d79572411e06f808ee0c9e76a41b" name="src/libbson/src/yajl/yajl_encode.h" role="src" />
<file md5sum="a4590297b6777e24dbb4910250ff9f87" name="src/libbson/src/yajl/yajl_gen.c" role="src" />
<file md5sum="e57e21bda1283a3a6a178845096b5d9c" name="src/libbson/src/yajl/yajl_gen.h" role="src" />
<file md5sum="c3eeaa1d5383a98f7d05b32ee6111d86" name="src/libbson/src/yajl/yajl_lex.c" role="src" />
<file md5sum="dcada0f60f8121bf68b73d56f32273b6" name="src/libbson/src/yajl/yajl_lex.h" role="src" />
<file md5sum="ebd7e4faccaa0f454945be170f447eef" name="src/libbson/src/yajl/yajl_parse.h" role="src" />
<file md5sum="a975a6d331f72f5c481c828cbf549788" name="src/libbson/src/yajl/yajl_parser.c" role="src" />
<file md5sum="927906b0423c3d1412188b6686821f2e" name="src/libbson/src/yajl/yajl_parser.h" role="src" />
<file md5sum="c191e94c04f9b26f4fdf6f6563ad1fd7" name="src/libbson/src/yajl/yajl_tree.c" role="src" />
<file md5sum="69650cd70a46ddf7541401203b22f00d" name="src/libbson/src/yajl/yajl_tree.h" role="src" />
<file md5sum="8d8be470862bf4c55ee6344530e8eb38" name="src/libbson/src/yajl/yajl_version.c" role="src" />
<file md5sum="4194a43380dfaef3ca94cb2ba30da1f2" name="src/libbson/src/yajl/yajl_version.h" role="src" />
- <file md5sum="35c36e89ef751b74c7aa3b07d7e0f6b6" name="src/libbson/VERSION_CURRENT" role="src" />
- <file md5sum="35c36e89ef751b74c7aa3b07d7e0f6b6" name="src/libbson/VERSION_RELEASED" role="src" />
+ <file md5sum="3c1de4a43daa0fe17b5080559cff640e" name="src/libbson/VERSION_CURRENT" role="src" />
+ <file md5sum="3c1de4a43daa0fe17b5080559cff640e" name="src/libbson/VERSION_RELEASED" role="src" />
<file md5sum="1066d5c9a05b1b1cb8f4de5a7e291574" name="src/libmongoc/build/autotools/m4/ac_check_typedef.m4" role="src" />
<file md5sum="e40a5f02f4d82a68b3df43d99dd92ed6" name="src/libmongoc/build/autotools/m4/ac_compile_check_sizeof.m4" role="src" />
<file md5sum="b96bb8fad4ea5d66c6b3af718186e2e0" name="src/libmongoc/build/autotools/m4/ac_create_stdint_h.m4" role="src" />
<file md5sum="7b5ee49855c90a9da6a0b1f1f0b8ef8f" name="src/libmongoc/build/autotools/m4/as-compiler-flag.m4" role="src" />
<file md5sum="8d942f69b5f3c15ecae4b75bb7e80614" name="src/libmongoc/build/autotools/m4/ax_check_compile_flag.m4" role="src" />
<file md5sum="05bd24609268702a36d50d5edd3661ac" name="src/libmongoc/build/autotools/m4/ax_check_link_flag.m4" role="src" />
<file md5sum="5535e823ec44002b522873b9c0e2e0bf" name="src/libmongoc/build/autotools/m4/ax_pthread.m4" role="src" />
<file md5sum="ad8d52d54e0f97c0e4e385376ea73bc0" name="src/libmongoc/build/autotools/m4/pkg.m4" role="src" />
<file md5sum="ff788a8b5eea35b1cc226bb2686c3537" name="src/libmongoc/build/autotools/m4/silent.m4" role="src" />
<file md5sum="7c20548ba18d4b99f89203d853809bfc" name="src/libmongoc/build/autotools/AutomaticInitAndCleanup.m4" role="src" />
<file md5sum="33c0e73d71ead46ce5a11eda4ce160b6" name="src/libmongoc/build/autotools/CheckCompiler.m4" role="src" />
<file md5sum="13179edcad78c81881686dacb0135cca" name="src/libmongoc/build/autotools/CheckHost.m4" role="src" />
<file md5sum="391a0c966f553057255b9e8d6fcd9984" name="src/libmongoc/build/autotools/CheckProgs.m4" role="src" />
- <file md5sum="19194929a052700a0879f7388c071630" name="src/libmongoc/build/autotools/CheckSSL.m4" role="src" />
+ <file md5sum="e470d1fcc1e8a702ddb655c231832abb" name="src/libmongoc/build/autotools/CheckSSL.m4" role="src" />
<file md5sum="2fafccbb4655f9880e2e03c16c67b9fb" name="src/libmongoc/build/autotools/CheckSasl.m4" role="src" />
<file md5sum="fa4a5cc1c9475999c468488eb19e4ffe" name="src/libmongoc/build/autotools/CheckTarget.m4" role="src" />
<file md5sum="760f59b300da59088cde1fec10892516" name="src/libmongoc/build/autotools/Coverage.m4" role="src" />
<file md5sum="e8fb530e79b3212551151dd9fef1e92a" name="src/libmongoc/build/autotools/FindDependencies.m4" role="src" />
<file md5sum="a8977370dbf28d606e4a6628bba94fca" name="src/libmongoc/build/autotools/Libbson.m4" role="src" />
<file md5sum="931e4995c218c0efaa18d0616660dfa9" name="src/libmongoc/build/autotools/MaintainerFlags.m4" role="src" />
<file md5sum="4628165f19e500c1f48dc94ee6442f87" name="src/libmongoc/build/autotools/Optimizations.m4" role="src" />
<file md5sum="47a3d8bf65c9f7924a8b0ef405967d51" name="src/libmongoc/build/autotools/PlatformFlags.m4" role="src" />
<file md5sum="f7b421657adb24865e6d6ba313153957" name="src/libmongoc/build/autotools/PrintBuildConfiguration.m4" role="src" />
<file md5sum="7e1db4b15bdad23146b1aeee2091d242" name="src/libmongoc/build/autotools/ReadCommandLineArguments.m4" role="src" />
<file md5sum="572566950ac77d916d6bf73fde7b8395" name="src/libmongoc/build/autotools/SetupAutomake.m4" role="src" />
<file md5sum="f229599b4333a2cdf5be29136cc6f2e2" name="src/libmongoc/build/autotools/SetupLibtool.m4" role="src" />
<file md5sum="82639d82b348fc309980a1d14e96b462" name="src/libmongoc/build/autotools/Versions.m4" role="src" />
<file md5sum="76e2c1a2aa19f5fab3661c992ac603fa" name="src/libmongoc/build/autotools/WeakSymbols.m4" role="src" />
<file md5sum="a787cefb077fc241a01533a5b39a6a25" name="src/libmongoc/src/mongoc/mongoc-apm-private.h" role="src" />
<file md5sum="24dc2a9a3bffc9af459d14339bacfa42" name="src/libmongoc/src/mongoc/mongoc-apm.c" role="src" />
<file md5sum="4c05f3506cf7a5207f27a6407cf78973" name="src/libmongoc/src/mongoc/mongoc-apm.h" role="src" />
<file md5sum="678bad25aa96f5eebb6cdf3d07dc8ee4" name="src/libmongoc/src/mongoc/mongoc-array-private.h" role="src" />
<file md5sum="62bb69dffa4d2756c43bb06276cc6cc9" name="src/libmongoc/src/mongoc/mongoc-array.c" role="src" />
<file md5sum="12eeffbb60680bfaa3a7f32d8c2fd564" name="src/libmongoc/src/mongoc/mongoc-async-cmd-private.h" role="src" />
<file md5sum="c77183a0d182351ae77693be12a227a6" name="src/libmongoc/src/mongoc/mongoc-async-cmd.c" role="src" />
<file md5sum="ce14f4f2c326f8b8c6e06d23b7fbe9b5" name="src/libmongoc/src/mongoc/mongoc-async-private.h" role="src" />
<file md5sum="f738d00bd8aff7e7677311fac19d68ff" name="src/libmongoc/src/mongoc/mongoc-async.c" role="src" />
<file md5sum="afa9361dbc1b31a740ad31a1895ca767" name="src/libmongoc/src/mongoc/mongoc-b64-private.h" role="src" />
<file md5sum="d34fb5802a99635fa90705f98d1a3b1d" name="src/libmongoc/src/mongoc/mongoc-b64.c" role="src" />
<file md5sum="1b68493a7c819ecd6db4cb5616c381b3" name="src/libmongoc/src/mongoc/mongoc-buffer-private.h" role="src" />
<file md5sum="40668c7a150f312cf9ddfd4388f73037" name="src/libmongoc/src/mongoc/mongoc-buffer.c" role="src" />
<file md5sum="fa9f8928b3533f50f8a0425c2ce2baef" name="src/libmongoc/src/mongoc/mongoc-bulk-operation-private.h" role="src" />
<file md5sum="30fa015e6d6edc7b59241c258a457118" name="src/libmongoc/src/mongoc/mongoc-bulk-operation.c" role="src" />
<file md5sum="dd3e094267f189dbf6c60638cc582320" name="src/libmongoc/src/mongoc/mongoc-bulk-operation.h" role="src" />
<file md5sum="aaa351e309b5fba1c68046d0f9689ef7" name="src/libmongoc/src/mongoc/mongoc-client-pool-private.h" role="src" />
<file md5sum="30288bba4d5b6ac6ce08eaaa139b10b1" name="src/libmongoc/src/mongoc/mongoc-client-pool.c" role="src" />
<file md5sum="5bcb77aa865a4e6fad4368faf6d8caa4" name="src/libmongoc/src/mongoc/mongoc-client-pool.h" role="src" />
<file md5sum="944dd87e31f5092cec98d32cd87da536" name="src/libmongoc/src/mongoc/mongoc-client-private.h" role="src" />
- <file md5sum="ebeecc54104c13ff4316e5e71851deb2" name="src/libmongoc/src/mongoc/mongoc-client.c" role="src" />
+ <file md5sum="36322dcce1e3aec362fa2fe40288f130" name="src/libmongoc/src/mongoc/mongoc-client.c" role="src" />
<file md5sum="ae403158ad38aefa4f58fa012bf5a90c" name="src/libmongoc/src/mongoc/mongoc-client.h" role="src" />
<file md5sum="b0f2d20d2de5917ac689161a5c35b0c3" name="src/libmongoc/src/mongoc/mongoc-cluster-private.h" role="src" />
- <file md5sum="85c5d0a6e6701f5d8d2f75f4c43bc802" name="src/libmongoc/src/mongoc/mongoc-cluster.c" role="src" />
+ <file md5sum="d17e5ec096952f8b12c76b3108a59391" name="src/libmongoc/src/mongoc/mongoc-cluster.c" role="src" />
<file md5sum="7c667f78176a61824f6330c0ca9d4620" name="src/libmongoc/src/mongoc/mongoc-collection-private.h" role="src" />
<file md5sum="ac26b48fa4660b1f7e317d31c0b3b22a" name="src/libmongoc/src/mongoc/mongoc-collection.c" role="src" />
<file md5sum="83a3a6e6533aa51809743fd5e360c999" name="src/libmongoc/src/mongoc/mongoc-collection.h" role="src" />
<file md5sum="31c95580f97cd0f7ad8dd23599f9ba2b" name="src/libmongoc/src/mongoc/mongoc-config.h" role="src" />
<file md5sum="2e2095a3b3644ba62adad9b54ddd6654" name="src/libmongoc/src/mongoc/mongoc-config.h.in" role="src" />
- <file md5sum="783282421c9bd4c6a9552608cdd6f2b8" name="src/libmongoc/src/mongoc/mongoc-counters-private.h" role="src" />
+ <file md5sum="c745e1b8d7d0b771c27c66e4847849f1" name="src/libmongoc/src/mongoc/mongoc-counters-private.h" role="src" />
<file md5sum="d4cc28ff33d6328db4a63dd36781467b" name="src/libmongoc/src/mongoc/mongoc-counters.c" role="src" />
<file md5sum="4bf259bbc90203a8a52270f2c9c473f7" name="src/libmongoc/src/mongoc/mongoc-counters.defs" role="src" />
<file md5sum="4af14a18a7ee70fb91b99dd08fc609f5" name="src/libmongoc/src/mongoc/mongoc-crypto-cng-private.h" role="src" />
<file md5sum="9682465713bdb3be7dc3ed289eb79972" name="src/libmongoc/src/mongoc/mongoc-crypto-cng.c" role="src" />
<file md5sum="f679d6de1eae611fac673f72c60d5bc4" name="src/libmongoc/src/mongoc/mongoc-crypto-cng.h" role="src" />
<file md5sum="848358cc4cc10dbf10aacef0e6c52990" name="src/libmongoc/src/mongoc/mongoc-crypto-common-crypto-private.h" role="src" />
<file md5sum="06b47d2ce98c56ed7dd1cc2618447eae" name="src/libmongoc/src/mongoc/mongoc-crypto-common-crypto.c" role="src" />
<file md5sum="545bd52f1f869c6a0a86c99e1c97562b" name="src/libmongoc/src/mongoc/mongoc-crypto-openssl-private.h" role="src" />
<file md5sum="85d8089915a6d187b90f1fa24e903bbd" name="src/libmongoc/src/mongoc/mongoc-crypto-openssl.c" role="src" />
<file md5sum="e6a4a250d28568351422a8a7934f61da" name="src/libmongoc/src/mongoc/mongoc-crypto-private.h" role="src" />
<file md5sum="b60c8edc574b0dd442a397214841ff06" name="src/libmongoc/src/mongoc/mongoc-crypto.c" role="src" />
<file md5sum="502eb9b02a39699ac25a428f99ff7101" name="src/libmongoc/src/mongoc/mongoc-cursor-array-private.h" role="src" />
<file md5sum="27fe24f0b50750b6a4fb9d9190944c14" name="src/libmongoc/src/mongoc/mongoc-cursor-array.c" role="src" />
<file md5sum="740d338cdf984a279869bce836ec1ff3" name="src/libmongoc/src/mongoc/mongoc-cursor-cursorid-private.h" role="src" />
- <file md5sum="851aee6c31f3dcde200d0740906c9b70" name="src/libmongoc/src/mongoc/mongoc-cursor-cursorid.c" role="src" />
- <file md5sum="a2019b11813fe65329f68ade88cb6efd" name="src/libmongoc/src/mongoc/mongoc-cursor-private.h" role="src" />
+ <file md5sum="981fd5afa1c233f2900aa9ead1dcc972" name="src/libmongoc/src/mongoc/mongoc-cursor-cursorid.c" role="src" />
+ <file md5sum="152fbfed717ca796c27aca9da9e46dce" name="src/libmongoc/src/mongoc/mongoc-cursor-private.h" role="src" />
<file md5sum="f85d601cc7248324d7eb36e05802dbc8" name="src/libmongoc/src/mongoc/mongoc-cursor-transform-private.h" role="src" />
<file md5sum="ceeb2a5e474f012330139ab2e53168c8" name="src/libmongoc/src/mongoc/mongoc-cursor-transform.c" role="src" />
- <file md5sum="a125a1002a0e5a8007986e33bd2d4d7f" name="src/libmongoc/src/mongoc/mongoc-cursor.c" role="src" />
+ <file md5sum="c988bdd1123e48621329c45f3d6ddb66" name="src/libmongoc/src/mongoc/mongoc-cursor.c" role="src" />
<file md5sum="91e8ad7bdbc61aab4cf6b2de57a71e7b" name="src/libmongoc/src/mongoc/mongoc-cursor.h" role="src" />
<file md5sum="5d13effee2564a59e0e42eb807f4773d" name="src/libmongoc/src/mongoc/mongoc-database-private.h" role="src" />
<file md5sum="d553297680d1b8d17cca9123500da8d8" name="src/libmongoc/src/mongoc/mongoc-database.c" role="src" />
<file md5sum="a7fd7142bf92f78552c7eeddd424220b" name="src/libmongoc/src/mongoc/mongoc-database.h" role="src" />
<file md5sum="0e73e2d9ee30ab20d5e462a5186e6524" name="src/libmongoc/src/mongoc/mongoc-errno-private.h" role="src" />
<file md5sum="e09f6df1547214b23f06f2198e9a7322" name="src/libmongoc/src/mongoc/mongoc-error.h" role="src" />
<file md5sum="3c86af8181b63ca6245a3d6a6fd670ee" name="src/libmongoc/src/mongoc/mongoc-find-and-modify-private.h" role="src" />
<file md5sum="ff818e28c67218b48615460ac9ddb12a" name="src/libmongoc/src/mongoc/mongoc-find-and-modify.c" role="src" />
<file md5sum="1b8d29183b4020d3023d07666c3c1cf3" name="src/libmongoc/src/mongoc/mongoc-find-and-modify.h" role="src" />
<file md5sum="a451f9575924b096df541a3159876a7e" name="src/libmongoc/src/mongoc/mongoc-flags.h" role="src" />
<file md5sum="fd3276101d79b9f0025dcb53033eb606" name="src/libmongoc/src/mongoc/mongoc-gridfs-file-list-private.h" role="src" />
<file md5sum="4fb06d89ef4336d2d8b94b003f4b58cc" name="src/libmongoc/src/mongoc/mongoc-gridfs-file-list.c" role="src" />
<file md5sum="bb0db47fd35b1a260ca66526c2ad3bc4" name="src/libmongoc/src/mongoc/mongoc-gridfs-file-list.h" role="src" />
<file md5sum="2f4044550b8f021f836e05939f843056" name="src/libmongoc/src/mongoc/mongoc-gridfs-file-page-private.h" role="src" />
<file md5sum="c54fb019dbfbcb06a5474460366ca921" name="src/libmongoc/src/mongoc/mongoc-gridfs-file-page.c" role="src" />
<file md5sum="bd1c523d758a24e137e3ab9073e22664" name="src/libmongoc/src/mongoc/mongoc-gridfs-file-page.h" role="src" />
<file md5sum="4668d0d14fe78a00ee9c89fc5d5c53a4" name="src/libmongoc/src/mongoc/mongoc-gridfs-file-private.h" role="src" />
<file md5sum="a720eacd0d197618258a9d213d2e68aa" name="src/libmongoc/src/mongoc/mongoc-gridfs-file.c" role="src" />
- <file md5sum="93fa17c6979413693d90075d017e5f47" name="src/libmongoc/src/mongoc/mongoc-gridfs-file.h" role="src" />
+ <file md5sum="44a00daafb861d9ab874fc1842df2aea" name="src/libmongoc/src/mongoc/mongoc-gridfs-file.h" role="src" />
<file md5sum="30aaef098b877725258df96fb675af1b" name="src/libmongoc/src/mongoc/mongoc-gridfs-private.h" role="src" />
<file md5sum="db8c88fdff82ed9a38212f4fcf7a463b" name="src/libmongoc/src/mongoc/mongoc-gridfs.c" role="src" />
<file md5sum="acc4752c97ceb7ed8e68922ed0576b1f" name="src/libmongoc/src/mongoc/mongoc-gridfs.h" role="src" />
- <file md5sum="0df229e76afaca7cae3a68b456d76c73" name="src/libmongoc/src/mongoc/mongoc-handshake-compiler-private.h" role="src" />
+ <file md5sum="217f5eb7438c032c116d189896eb4765" name="src/libmongoc/src/mongoc/mongoc-handshake-compiler-private.h" role="src" />
<file md5sum="f91db339db8e09e79ef114fccb25eddb" name="src/libmongoc/src/mongoc/mongoc-handshake-os-private.h" role="src" />
<file md5sum="a2ae5ec10d61769c9355749e5c8434b7" name="src/libmongoc/src/mongoc/mongoc-handshake-private.h" role="src" />
- <file md5sum="2a118ccb0f46c4abf660d36ba8d11ba6" name="src/libmongoc/src/mongoc/mongoc-handshake.c" role="src" />
+ <file md5sum="bd709567defdf300a819e427521dba47" name="src/libmongoc/src/mongoc/mongoc-handshake.c" role="src" />
<file md5sum="4d2b08fb4e093499ef6804ac4638f85d" name="src/libmongoc/src/mongoc/mongoc-handshake.h" role="src" />
<file md5sum="d36969e1ad509faff84d0bf517c62df7" name="src/libmongoc/src/mongoc/mongoc-host-list-private.h" role="src" />
<file md5sum="5ad5435d0cdb0637089e0825fb41a58c" name="src/libmongoc/src/mongoc/mongoc-host-list.c" role="src" />
<file md5sum="4294099976ce13b16ccd9f1e054ecd4e" name="src/libmongoc/src/mongoc/mongoc-host-list.h" role="src" />
<file md5sum="ecda6300117ef0a8cbe4090d7feb7138" name="src/libmongoc/src/mongoc/mongoc-index.c" role="src" />
<file md5sum="ed91c07020e9beaaccc26736eaf3d4fb" name="src/libmongoc/src/mongoc/mongoc-index.h" role="src" />
- <file md5sum="4e1dbfc306f64e964b4d5550cde5975f" name="src/libmongoc/src/mongoc/mongoc-init.c" role="src" />
+ <file md5sum="de8ff0f45d4f78384d8fd6da79502270" name="src/libmongoc/src/mongoc/mongoc-init.c" role="src" />
<file md5sum="8c35a4641b5255a3a557cc94747a2ad8" name="src/libmongoc/src/mongoc/mongoc-init.h" role="src" />
<file md5sum="952d463b654e44a66123cd8883b59748" name="src/libmongoc/src/mongoc/mongoc-iovec.h" role="src" />
<file md5sum="0d8a19472951fee25bb225c48e0ef278" name="src/libmongoc/src/mongoc/mongoc-libressl-private.h" role="src" />
- <file md5sum="7ae72c0417bcd408c0bfe2ebbc726a87" name="src/libmongoc/src/mongoc/mongoc-libressl.c" role="src" />
+ <file md5sum="53b9006e385c5bd5944c55473e835980" name="src/libmongoc/src/mongoc/mongoc-libressl.c" role="src" />
<file md5sum="ec1fd08bd3131f01a87b90ca82815d2c" name="src/libmongoc/src/mongoc/mongoc-linux-distro-scanner-private.h" role="src" />
<file md5sum="aa1726a754911daec89239a8133bad96" name="src/libmongoc/src/mongoc/mongoc-linux-distro-scanner.c" role="src" />
<file md5sum="1e710c6899e1d3a8b33b7d4015457d6d" name="src/libmongoc/src/mongoc/mongoc-list-private.h" role="src" />
<file md5sum="01f733a69d79f45e7a8b7a01fd9b61e1" name="src/libmongoc/src/mongoc/mongoc-list.c" role="src" />
<file md5sum="6ee6a1f8f01ce9235c75829ce5344edf" name="src/libmongoc/src/mongoc/mongoc-log-private.h" role="src" />
<file md5sum="e77f497753878bbbe838b2946268aa09" name="src/libmongoc/src/mongoc/mongoc-log.c" role="src" />
<file md5sum="a996633e6736c225b27f85b08ffcab6f" name="src/libmongoc/src/mongoc/mongoc-log.h" role="src" />
<file md5sum="20b88053159e284784ec570135cf09bb" name="src/libmongoc/src/mongoc/mongoc-matcher-op-private.h" role="src" />
<file md5sum="d134ab092926a9e19b4dd14f85122681" name="src/libmongoc/src/mongoc/mongoc-matcher-op.c" role="src" />
<file md5sum="8d8be12dd5774d31fe7c025af0d1483b" name="src/libmongoc/src/mongoc/mongoc-matcher-private.h" role="src" />
<file md5sum="34d9b266424c63145eb1b9fa4f8e4d49" name="src/libmongoc/src/mongoc/mongoc-matcher.c" role="src" />
<file md5sum="c31a032fe8246b8939ea4c7443752f98" name="src/libmongoc/src/mongoc/mongoc-matcher.h" role="src" />
<file md5sum="21a4bf0cbe4dbbb3e87e64a16da392e1" name="src/libmongoc/src/mongoc/mongoc-memcmp-private.h" role="src" />
<file md5sum="7a2c50776b0cb3d84b1463d5da8f9571" name="src/libmongoc/src/mongoc/mongoc-memcmp.c" role="src" />
<file md5sum="a85087cd67361993a945ecddce1b8ff3" name="src/libmongoc/src/mongoc/mongoc-opcode-private.h" role="src" />
<file md5sum="2fd75713af0b61664ca7947837b00282" name="src/libmongoc/src/mongoc/mongoc-opcode.c" role="src" />
<file md5sum="cb8c7ee22278ab7c4e17223deb233dcf" name="src/libmongoc/src/mongoc/mongoc-opcode.h" role="src" />
<file md5sum="7eb9ca07802f57c8541489ba45dbf217" name="src/libmongoc/src/mongoc/mongoc-openssl-private.h" role="src" />
- <file md5sum="92098021ca4359305f828df5e0d97082" name="src/libmongoc/src/mongoc/mongoc-openssl.c" role="src" />
+ <file md5sum="34963158b37362b1a0be5a1212f364d2" name="src/libmongoc/src/mongoc/mongoc-openssl.c" role="src" />
<file md5sum="5f4c9d0b52b32913ee15c291dd367100" name="src/libmongoc/src/mongoc/mongoc-queue-private.h" role="src" />
<file md5sum="31ed0c79e107f70616f28392469b1168" name="src/libmongoc/src/mongoc/mongoc-queue.c" role="src" />
<file md5sum="55141f0a5e1ad7046292d02e8966155b" name="src/libmongoc/src/mongoc/mongoc-rand-cng.c" role="src" />
<file md5sum="15adb6f2d7ecf6205518b68b2d97098f" name="src/libmongoc/src/mongoc/mongoc-rand-common-crypto.c" role="src" />
<file md5sum="fc75c9e587209921d216f515836c63bc" name="src/libmongoc/src/mongoc/mongoc-rand-openssl.c" role="src" />
<file md5sum="de8b26a00d4df1912e7f2aa9cd1bda64" name="src/libmongoc/src/mongoc/mongoc-rand-private.h" role="src" />
<file md5sum="9eb403d113f5a74fde117fc4d1edd35b" name="src/libmongoc/src/mongoc/mongoc-rand.h" role="src" />
<file md5sum="079f4d48a7d339a15d35442a77f0f8dd" name="src/libmongoc/src/mongoc/mongoc-read-concern-private.h" role="src" />
<file md5sum="7904d7dd43c6b815a7430e4ffa600e34" name="src/libmongoc/src/mongoc/mongoc-read-concern.c" role="src" />
<file md5sum="a363e4c8fa75df178e26ff5f5262834e" name="src/libmongoc/src/mongoc/mongoc-read-concern.h" role="src" />
<file md5sum="fb2c9d24ab2eb07a43cf68e8b5295814" name="src/libmongoc/src/mongoc/mongoc-read-prefs-private.h" role="src" />
<file md5sum="6e650d11a098a9bcd98614c50d17de20" name="src/libmongoc/src/mongoc/mongoc-read-prefs.c" role="src" />
<file md5sum="8fbd2617e9e59de4ab6cb53b3dac3832" name="src/libmongoc/src/mongoc/mongoc-read-prefs.h" role="src" />
<file md5sum="87c50be4e602261c55c9ef8c412bd3c4" name="src/libmongoc/src/mongoc/mongoc-rpc-private.h" role="src" />
- <file md5sum="67a9dcc0093d4e8784e904fdcfb6c405" name="src/libmongoc/src/mongoc/mongoc-rpc.c" role="src" />
+ <file md5sum="e5faa926b7342f8e16d07e4654efeadf" name="src/libmongoc/src/mongoc/mongoc-rpc.c" role="src" />
<file md5sum="f176910469cd2fb429ae480e19421bdb" name="src/libmongoc/src/mongoc/mongoc-sasl-private.h" role="src" />
<file md5sum="5836532c914c2d2bca30edcc85da5490" name="src/libmongoc/src/mongoc/mongoc-sasl.c" role="src" />
<file md5sum="3da5e545685332afb979bb69cc3de12c" name="src/libmongoc/src/mongoc/mongoc-scram-private.h" role="src" />
<file md5sum="38761732c7acd966f03bfd1c70c1c22a" name="src/libmongoc/src/mongoc/mongoc-scram.c" role="src" />
<file md5sum="71f092f0a49e4aae6cd44c2e320bd036" name="src/libmongoc/src/mongoc/mongoc-secure-channel-private.h" role="src" />
<file md5sum="fbfe9202223aa74abaeb2918966de14b" name="src/libmongoc/src/mongoc/mongoc-secure-channel.c" role="src" />
<file md5sum="8e05346fd79064cd0d27bb2148bdd88f" name="src/libmongoc/src/mongoc/mongoc-secure-transport-private.h" role="src" />
<file md5sum="261c83c1c0b960b747cf81d97a353473" name="src/libmongoc/src/mongoc/mongoc-secure-transport.c" role="src" />
<file md5sum="20099618f34ab2a4b4e6f3a8fac54e7a" name="src/libmongoc/src/mongoc/mongoc-server-description-private.h" role="src" />
<file md5sum="f394c6ab11b2f42a3451d4bdd82bb806" name="src/libmongoc/src/mongoc/mongoc-server-description.c" role="src" />
<file md5sum="8936d92cd7ed5269ff3805c968345595" name="src/libmongoc/src/mongoc/mongoc-server-description.h" role="src" />
<file md5sum="3427b6366f79fd488100a38080c248b3" name="src/libmongoc/src/mongoc/mongoc-server-stream-private.h" role="src" />
<file md5sum="ca1028b581086f6ecfe8f7d17c0d99de" name="src/libmongoc/src/mongoc/mongoc-server-stream.c" role="src" />
<file md5sum="0f6adaf9b219f92bc3a09b78dd7fe1c4" name="src/libmongoc/src/mongoc/mongoc-set-private.h" role="src" />
- <file md5sum="29d7c2825fce37289aa28f4b84fc737d" name="src/libmongoc/src/mongoc/mongoc-set.c" role="src" />
+ <file md5sum="3619b39acef7d8142724c66d27e587ef" name="src/libmongoc/src/mongoc/mongoc-set.c" role="src" />
<file md5sum="83783d033809df281750fb753a46a19c" name="src/libmongoc/src/mongoc/mongoc-socket-private.h" role="src" />
<file md5sum="c8c3a0a4b3f527307f51789b1ae54930" name="src/libmongoc/src/mongoc/mongoc-socket.c" role="src" />
<file md5sum="c77bb3eae9c3c2d0894c47313deb614a" name="src/libmongoc/src/mongoc/mongoc-socket.h" role="src" />
<file md5sum="7d6768da46dbdaaef7af254d0ad1f985" name="src/libmongoc/src/mongoc/mongoc-ssl-private.h" role="src" />
- <file md5sum="3f4f299a6f150c39035d9baade9d1e67" name="src/libmongoc/src/mongoc/mongoc-ssl.c" role="src" />
+ <file md5sum="24cef4c93c99bfd97a6bb8180ab2a487" name="src/libmongoc/src/mongoc/mongoc-ssl.c" role="src" />
<file md5sum="8e76343ddc7a19cffaf09f7dbf3a5ccf" name="src/libmongoc/src/mongoc/mongoc-ssl.h" role="src" />
<file md5sum="085fdcaa41a0a564e5af6a89ae48da8e" name="src/libmongoc/src/mongoc/mongoc-stream-buffered.c" role="src" />
<file md5sum="8d602dda16b9c6bd1a02be9f774bb435" name="src/libmongoc/src/mongoc/mongoc-stream-buffered.h" role="src" />
<file md5sum="80f8140eebea9142484c86185d37bca9" name="src/libmongoc/src/mongoc/mongoc-stream-file.c" role="src" />
<file md5sum="c38bf3a4be19ebb410f7d4ea8f2c4c53" name="src/libmongoc/src/mongoc/mongoc-stream-file.h" role="src" />
<file md5sum="1c8ed484da4393ad70b72aa10f5024ab" name="src/libmongoc/src/mongoc/mongoc-stream-gridfs.c" role="src" />
<file md5sum="a69948b7569311d471fe59ac388d515e" name="src/libmongoc/src/mongoc/mongoc-stream-gridfs.h" role="src" />
<file md5sum="926738c7ff4ace00bd81298b17b711a0" name="src/libmongoc/src/mongoc/mongoc-stream-private.h" role="src" />
<file md5sum="7ba65eb5a4f00e56ff244a1193ee0b72" name="src/libmongoc/src/mongoc/mongoc-stream-socket.c" role="src" />
<file md5sum="4aed0f25e2bae597f3146bda017cbd5b" name="src/libmongoc/src/mongoc/mongoc-stream-socket.h" role="src" />
<file md5sum="ea30cbec0bd8aeb1c407b726dda38d89" name="src/libmongoc/src/mongoc/mongoc-stream-tls-libressl-private.h" role="src" />
- <file md5sum="0fa7a4221b90e6baed105d32429c2b45" name="src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.c" role="src" />
+ <file md5sum="cd279517e75fc48c2fbac7d18e0f7586" name="src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.c" role="src" />
<file md5sum="a9fd9c26ddd05a7b2b6c43d216ea4125" name="src/libmongoc/src/mongoc/mongoc-stream-tls-libressl.h" role="src" />
<file md5sum="2478098192a13c2ea02af155ed6e1dc3" name="src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-bio-private.h" role="src" />
<file md5sum="56e1cb6a9e91de4f74858b6480a14f26" name="src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-bio.c" role="src" />
<file md5sum="3df4aab4defbcd5c653c32568a4900b6" name="src/libmongoc/src/mongoc/mongoc-stream-tls-openssl-private.h" role="src" />
<file md5sum="34cb27d3c7a87c0c761a8673076126e4" name="src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.c" role="src" />
<file md5sum="f0301339d8cf346a2c52255cab86ebea" name="src/libmongoc/src/mongoc/mongoc-stream-tls-openssl.h" role="src" />
<file md5sum="d1a7a583a2a25e67dd0010427b9c44f5" name="src/libmongoc/src/mongoc/mongoc-stream-tls-private.h" role="src" />
<file md5sum="4b7015782edbcd4993644c9e4f9cb9b0" name="src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel-private.h" role="src" />
<file md5sum="a5811778b255c0cc0eff00c25f2a84df" name="src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.c" role="src" />
<file md5sum="252f9046d679a4a778be70b69a2a2108" name="src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.h" role="src" />
<file md5sum="b1d8acdd7a08545e8f5826047009a66d" name="src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport-private.h" role="src" />
<file md5sum="565a0b79e1f326834befd6af67f3708e" name="src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.c" role="src" />
<file md5sum="b78f3c34df84101c8cd93cf3e2927820" name="src/libmongoc/src/mongoc/mongoc-stream-tls-secure-transport.h" role="src" />
<file md5sum="9504a0efc2a1fb519f792f0897019335" name="src/libmongoc/src/mongoc/mongoc-stream-tls.c" role="src" />
<file md5sum="2587184c3af3c590670487df1bdecbd6" name="src/libmongoc/src/mongoc/mongoc-stream-tls.h" role="src" />
<file md5sum="93efba9b58e145f74bac120b7f2c3062" name="src/libmongoc/src/mongoc/mongoc-stream.c" role="src" />
<file md5sum="229563bf6e138f72d1e37050d52dac1d" name="src/libmongoc/src/mongoc/mongoc-stream.h" role="src" />
<file md5sum="fdc4f3f3e45081c2129ea955b407a157" name="src/libmongoc/src/mongoc/mongoc-thread-private.h" role="src" />
<file md5sum="300072d1463efd55a01116410c42d0af" name="src/libmongoc/src/mongoc/mongoc-topology-description-apm-private.h" role="src" />
<file md5sum="0c202faa89643a2f606ac603ec881ca8" name="src/libmongoc/src/mongoc/mongoc-topology-description-apm.c" role="src" />
<file md5sum="90eb65d651e8a5b9b7ce1e1ed3d2e548" name="src/libmongoc/src/mongoc/mongoc-topology-description-private.h" role="src" />
<file md5sum="7381e20864ec60096c66a29a696dce9e" name="src/libmongoc/src/mongoc/mongoc-topology-description.c" role="src" />
<file md5sum="e1cee6ddceeb715f214d946e082164f3" name="src/libmongoc/src/mongoc/mongoc-topology-description.h" role="src" />
<file md5sum="74da5dce7da9ede81951bb931b3581bf" name="src/libmongoc/src/mongoc/mongoc-topology-private.h" role="src" />
<file md5sum="fc8061084508bad1b6970a070a87ee43" name="src/libmongoc/src/mongoc/mongoc-topology-scanner-private.h" role="src" />
<file md5sum="94cc722bc3839a6c5a800b67a2647e3b" name="src/libmongoc/src/mongoc/mongoc-topology-scanner.c" role="src" />
<file md5sum="54b178adfe38970d6ef5e348576b8d7b" name="src/libmongoc/src/mongoc/mongoc-topology.c" role="src" />
<file md5sum="f8fe41c378f1b6a9c22e3a0c9195909a" name="src/libmongoc/src/mongoc/mongoc-trace-private.h" role="src" />
<file md5sum="afab4d17751dc2f765a68a9072af42d1" name="src/libmongoc/src/mongoc/mongoc-uri-private.h" role="src" />
<file md5sum="ca0c01f80171fb1ec053debaf68b895a" name="src/libmongoc/src/mongoc/mongoc-uri.c" role="src" />
<file md5sum="e1da8153d86816dcc67b4c9ec717c1a8" name="src/libmongoc/src/mongoc/mongoc-uri.h" role="src" />
- <file md5sum="ab1a81dadd41190dab7645bb65bb9be0" name="src/libmongoc/src/mongoc/mongoc-util-private.h" role="src" />
+ <file md5sum="b4afcd0f02c5a33facb7ae16d974cb43" name="src/libmongoc/src/mongoc/mongoc-util-private.h" role="src" />
<file md5sum="5de983ab6c54d112986bbb74310fd2eb" name="src/libmongoc/src/mongoc/mongoc-util.c" role="src" />
<file md5sum="e699d508bdb2d3f5220bbc5bf413bae1" name="src/libmongoc/src/mongoc/mongoc-version-functions.c" role="src" />
<file md5sum="5d956716b694ce5904e0579d3ddc6853" name="src/libmongoc/src/mongoc/mongoc-version-functions.h" role="src" />
- <file md5sum="b88dffc9dae9a1effd35fa100fb44cfd" name="src/libmongoc/src/mongoc/mongoc-version.h" role="src" />
+ <file md5sum="7612e5a24601ccdb5b41ddec4ada6896" name="src/libmongoc/src/mongoc/mongoc-version.h" role="src" />
<file md5sum="2f63b4b1f86910aab6a6e7423af3f7a8" name="src/libmongoc/src/mongoc/mongoc-version.h.in" role="src" />
<file md5sum="c9284d7eff1dc27e4ff12f1bb08ca41c" name="src/libmongoc/src/mongoc/mongoc-write-command-private.h" role="src" />
<file md5sum="19512859e18a1dcbd60cd7e3ef444114" name="src/libmongoc/src/mongoc/mongoc-write-command.c" role="src" />
<file md5sum="9952c2b94437b195a5492e62541f6b80" name="src/libmongoc/src/mongoc/mongoc-write-concern-private.h" role="src" />
<file md5sum="57d761c14450d05a79c2c8c2792d74a3" name="src/libmongoc/src/mongoc/mongoc-write-concern.c" role="src" />
<file md5sum="9760b823d8859ad8cc9ac58ed2ac2604" name="src/libmongoc/src/mongoc/mongoc-write-concern.h" role="src" />
<file md5sum="203393fddc4207289be0533ab037e906" name="src/libmongoc/src/mongoc/mongoc.h" role="src" />
<file md5sum="ed1890accd7d9a1426fdac121ed42ad4" name="src/libmongoc/src/mongoc/op-delete.def" role="src" />
<file md5sum="9af88adf2ef432761bbe81db2f9bdce7" name="src/libmongoc/src/mongoc/op-get-more.def" role="src" />
<file md5sum="242fff22640f143ae262e363e8552a7e" name="src/libmongoc/src/mongoc/op-header.def" role="src" />
<file md5sum="2efe34631dd0d540d0f1d2fdb2d57813" name="src/libmongoc/src/mongoc/op-insert.def" role="src" />
<file md5sum="79ab986cb49a47e7c9bccdc4005a9697" name="src/libmongoc/src/mongoc/op-kill-cursors.def" role="src" />
<file md5sum="25dd34248b0000465c7e2ac769fc509a" name="src/libmongoc/src/mongoc/op-msg.def" role="src" />
<file md5sum="a986d22cb495d652dc6059d722bb3266" name="src/libmongoc/src/mongoc/op-query.def" role="src" />
<file md5sum="f82bc931404ce00b318675126572d667" name="src/libmongoc/src/mongoc/op-reply-header.def" role="src" />
<file md5sum="dd22bb15cb70d35fe25192f0f304871b" name="src/libmongoc/src/mongoc/op-reply.def" role="src" />
<file md5sum="03c6179a4fe8b51c606b03a763529d55" name="src/libmongoc/src/mongoc/op-update.def" role="src" />
<file md5sum="94cc18fabf34abc9acbff2ec6c5293f6" name="src/libmongoc/src/mongoc/utlist.h" role="src" />
- <file md5sum="35c36e89ef751b74c7aa3b07d7e0f6b6" name="src/libmongoc/VERSION_CURRENT" role="src" />
- <file md5sum="35c36e89ef751b74c7aa3b07d7e0f6b6" name="src/libmongoc/VERSION_RELEASED" role="src" />
- <file md5sum="7b1478887c401939672c39b616166fbf" name="src/bson.c" role="src" />
+ <file md5sum="3c1de4a43daa0fe17b5080559cff640e" name="src/libmongoc/VERSION_CURRENT" role="src" />
+ <file md5sum="3c1de4a43daa0fe17b5080559cff640e" name="src/libmongoc/VERSION_RELEASED" role="src" />
+ <file md5sum="878b2a5135d91fb93fa624af126a8a30" name="src/bson.c" role="src" />
<file md5sum="6353eaae171cb9a5c8a02f2ae08c879b" name="tests/bson/bson-binary-001.phpt" role="test" />
<file md5sum="c0bcda775b56796c4a958cd4cd74d920" name="tests/bson/bson-binary-compare-001.phpt" role="test" />
<file md5sum="0a87dad6d922760e623021996727d79c" name="tests/bson/bson-binary-compare-002.phpt" role="test" />
<file md5sum="a89324b72c9dbfffca5008d9563565c8" name="tests/bson/bson-binary-jsonserialize-001.phpt" role="test" />
<file md5sum="ba515183a779c4ce6740ba3fb1e46f77" name="tests/bson/bson-binary-jsonserialize-002.phpt" role="test" />
<file md5sum="94deed355325f66c567309e6074cfe7a" name="tests/bson/bson-binary-serialization-001.phpt" role="test" />
<file md5sum="f487c59192b7df686475bfe0be84c3e6" name="tests/bson/bson-binary-serialization_error-001.phpt" role="test" />
<file md5sum="2ebc7a07dd945df1922ca274d04478a8" name="tests/bson/bson-binary-serialization_error-002.phpt" role="test" />
<file md5sum="4a4275ac852b7457302ddcb2fdce7544" name="tests/bson/bson-binary-set_state-001.phpt" role="test" />
<file md5sum="bfee0375bac0c0e1a26a34dda9814eb0" name="tests/bson/bson-binary-set_state_error-001.phpt" role="test" />
<file md5sum="b88eb23a9a107c5300863e1dc5a780b0" name="tests/bson/bson-binary-set_state_error-002.phpt" role="test" />
<file md5sum="6d2a98d4a0877eaa48cf6715e9eaf845" name="tests/bson/bson-binary-tostring-001.phpt" role="test" />
<file md5sum="987e2a7b238833b93ddf1b3b0d879fd8" name="tests/bson/bson-binary_error-001.phpt" role="test" />
<file md5sum="a9d13886ed7bad49396fe58fb69728dc" name="tests/bson/bson-binary_error-002.phpt" role="test" />
<file md5sum="6f080af40f1a71d0f9dc97118cc65956" name="tests/bson/bson-binary_error-003.phpt" role="test" />
<file md5sum="1b07dc40c0327eaa948a01415e80156e" name="tests/bson/bson-decimal128-001.phpt" role="test" />
<file md5sum="aa1a54f32962e51878159b0b3f25a83a" name="tests/bson/bson-decimal128-002.phpt" role="test" />
<file md5sum="b17b174c54b38e37a407f8fb35aff65e" name="tests/bson/bson-decimal128-003.phpt" role="test" />
<file md5sum="b6d96feed66dfb73e8220e48e58337a1" name="tests/bson/bson-decimal128-004.phpt" role="test" />
<file md5sum="b82e77c47a326ab042f1e35ec4725e51" name="tests/bson/bson-decimal128-jsonserialize-001.phpt" role="test" />
<file md5sum="afbe9023c707b866dcc078d3b126ba0a" name="tests/bson/bson-decimal128-jsonserialize-002.phpt" role="test" />
<file md5sum="4c603508bb6b9838066286014832c97f" name="tests/bson/bson-decimal128-serialization-001.phpt" role="test" />
<file md5sum="18bcb6a21e50d2bbdfc8f05dd81ea095" name="tests/bson/bson-decimal128-serialization_error-001.phpt" role="test" />
<file md5sum="105c568368afe25b76a7f4d2cbc8ab32" name="tests/bson/bson-decimal128-serialization_error-002.phpt" role="test" />
<file md5sum="3a8bcad13be933556fd0967a643293ac" name="tests/bson/bson-decimal128-set_state-001.phpt" role="test" />
<file md5sum="db934fbaaeca32c3461ca5a0e3924b3c" name="tests/bson/bson-decimal128-set_state_error-001.phpt" role="test" />
<file md5sum="cc39b9bf030108cc2e36cec032c3e021" name="tests/bson/bson-decimal128-set_state_error-002.phpt" role="test" />
<file md5sum="e938c12d1f2fcf8db10aa35a1835d938" name="tests/bson/bson-decimal128_error-001.phpt" role="test" />
<file md5sum="c551b87ae2e2987ba8e5518c73aed1f6" name="tests/bson/bson-decimal128_error-002.phpt" role="test" />
<file md5sum="dfd51ec3a9175dbc114516174d56f999" name="tests/bson/bson-decode-001.phpt" role="test" />
<file md5sum="72c9ae0b2a63b4734b4242634b26d838" name="tests/bson/bson-decode-002.phpt" role="test" />
<file md5sum="d28cf3697b4c11c16aaff19cc8dd30fa" name="tests/bson/bson-encode-001.phpt" role="test" />
<file md5sum="7d63ae8f6ffe1c3723de519a28c518a8" name="tests/bson/bson-encode-002.phpt" role="test" />
<file md5sum="29348a9f31df1efbf7ebbce60934f443" name="tests/bson/bson-encode-003.phpt" role="test" />
<file md5sum="19012fed927912e4b9144a3fd4458c57" name="tests/bson/bson-encode-004.phpt" role="test" />
<file md5sum="9b2c1fb3ece5c67bf2593e78ebd4481d" name="tests/bson/bson-encode-005.phpt" role="test" />
<file md5sum="9f2c849e9e4d87c63fee4591fc4c3e3f" name="tests/bson/bson-fromJSON-001.phpt" role="test" />
<file md5sum="08a8c4233a4a4d3d5216bbc289189e79" name="tests/bson/bson-fromJSON-002.phpt" role="test" />
<file md5sum="43cb661e51a31350bb562e0756925fc4" name="tests/bson/bson-fromJSON_error-001.phpt" role="test" />
<file md5sum="d1be9224941f85b73491880c045f9c91" name="tests/bson/bson-fromPHP-001.phpt" role="test" />
<file md5sum="d06d3e149b4049b069ac97446292e54a" name="tests/bson/bson-fromPHP-002.phpt" role="test" />
<file md5sum="f63c536993d1f5c321194a1509a76b49" name="tests/bson/bson-fromPHP-003.phpt" role="test" />
+ <file md5sum="f90282eccdcec6a9e75c2bff3feefe52" name="tests/bson/bson-fromPHP-004.phpt" role="test" />
+ <file md5sum="cdee70ad41d06ebf5433f0c123d8b473" name="tests/bson/bson-fromPHP-005.phpt" role="test" />
+ <file md5sum="5c39bcee09ea347402f4487991e66eb2" name="tests/bson/bson-fromPHP-006.phpt" role="test" />
<file md5sum="b0eecb69117e5a61228f9779b400b3fe" name="tests/bson/bson-fromPHP_error-001.phpt" role="test" />
<file md5sum="e100a45e0dfc4a8efda78b72f6a2a9a4" name="tests/bson/bson-fromPHP_error-002.phpt" role="test" />
<file md5sum="d523ccc510646a112529afd40982a3f7" name="tests/bson/bson-fromPHP_error-003.phpt" role="test" />
<file md5sum="9bd6b7e322f81c800abd6366d52e0cce" name="tests/bson/bson-generate-document-id.phpt" role="test" />
<file md5sum="79fbd01e931e001c3738f67312083a88" name="tests/bson/bson-javascript-001.phpt" role="test" />
<file md5sum="10d535296d0c4ccefaf5b6f63198d8b7" name="tests/bson/bson-javascript-002.phpt" role="test" />
<file md5sum="b4918a171d542e0572cc9c76bdcd641c" name="tests/bson/bson-javascript-compare-001.phpt" role="test" />
<file md5sum="bf56d62d17206b8161535e357b300a0c" name="tests/bson/bson-javascript-compare-002.phpt" role="test" />
<file md5sum="3567bceb79c30dfd50838a0267a69c62" name="tests/bson/bson-javascript-getCode-001.phpt" role="test" />
<file md5sum="a4dd04e36142969b8f2cd1f855c6dd65" name="tests/bson/bson-javascript-getScope-001.phpt" role="test" />
<file md5sum="b56136e8638788b0e72210ae82293c4a" name="tests/bson/bson-javascript-jsonserialize-001.phpt" role="test" />
<file md5sum="08155bf6625a0317d0daebba81670fcc" name="tests/bson/bson-javascript-jsonserialize-002.phpt" role="test" />
<file md5sum="cded1c2f5a177637a42216f0d5064f41" name="tests/bson/bson-javascript-jsonserialize-003.phpt" role="test" />
<file md5sum="7d539fbdf45f6a3f3fd92a5b1e38e76e" name="tests/bson/bson-javascript-jsonserialize-004.phpt" role="test" />
<file md5sum="262b1747ea8f5f31b5410ce70152d917" name="tests/bson/bson-javascript-serialization-001.phpt" role="test" />
<file md5sum="3b734b3672e2fb7c22d631e30a668572" name="tests/bson/bson-javascript-serialization_error-001.phpt" role="test" />
<file md5sum="aad55f29fc2f8cb29fbe24be4f8e3f45" name="tests/bson/bson-javascript-serialization_error-002.phpt" role="test" />
<file md5sum="71105272974df96fcc305b2c19b3055f" name="tests/bson/bson-javascript-serialization_error-003.phpt" role="test" />
<file md5sum="083ea527f154bff2cb0af954007b31e4" name="tests/bson/bson-javascript-set_state-001.phpt" role="test" />
<file md5sum="b1ca12563c821779cb762995b0eb72c1" name="tests/bson/bson-javascript-set_state_error-001.phpt" role="test" />
<file md5sum="abb0c3c2cb58a5b2ee28849a5fdebcc8" name="tests/bson/bson-javascript-set_state_error-002.phpt" role="test" />
<file md5sum="23f1dcb1ec478e1ccad03999c2f7a023" name="tests/bson/bson-javascript-set_state_error-003.phpt" role="test" />
<file md5sum="e390000e3a7aba05c408d022ef9903d7" name="tests/bson/bson-javascript-tostring-001.phpt" role="test" />
<file md5sum="761570180559c8089add628f2d25cc8b" name="tests/bson/bson-javascript_error-001.phpt" role="test" />
<file md5sum="3c848a8651ccfeddeb8a6c2d60a986f3" name="tests/bson/bson-javascript_error-002.phpt" role="test" />
<file md5sum="02fba91408fc0f350a204bc8b1d3f04c" name="tests/bson/bson-javascript_error-003.phpt" role="test" />
<file md5sum="dde147455cd932bf6424aba82fe61718" name="tests/bson/bson-maxkey-001.phpt" role="test" />
<file md5sum="2bf1fbd91c808c2d90db9a92c3af9678" name="tests/bson/bson-maxkey-compare-001.phpt" role="test" />
<file md5sum="4314312c271b5c33f53a4d3887a683b0" name="tests/bson/bson-maxkey-jsonserialize-001.phpt" role="test" />
<file md5sum="a57e651d344bd32f6ac3f820a222bfa2" name="tests/bson/bson-maxkey-jsonserialize-002.phpt" role="test" />
<file md5sum="6e74674e084b8fb81f31e9863a87079d" name="tests/bson/bson-maxkey-serialization-001.phpt" role="test" />
<file md5sum="ea86c16672ce4ca92a750eb7de2837e5" name="tests/bson/bson-maxkey-set_state-001.phpt" role="test" />
<file md5sum="101130436ace2c1418413a1cdd3cc5a5" name="tests/bson/bson-maxkey_error-001.phpt" role="test" />
<file md5sum="63f2fe0e4f73d250deb31ef4861ce5bf" name="tests/bson/bson-minkey-001.phpt" role="test" />
<file md5sum="cab9d17b350f7ff0fb3930aa298f626a" name="tests/bson/bson-minkey-compare-001.phpt" role="test" />
<file md5sum="6b2c6c29ac2dbc4f91392779b99d562c" name="tests/bson/bson-minkey-jsonserialize-001.phpt" role="test" />
<file md5sum="ee6731f161e2de2523764a03c4693783" name="tests/bson/bson-minkey-jsonserialize-002.phpt" role="test" />
<file md5sum="37fe1c3d8e22afe72cdbb2b6c445eba4" name="tests/bson/bson-minkey-serialization-001.phpt" role="test" />
<file md5sum="74201982485a724a0822cc2f2093cb75" name="tests/bson/bson-minkey-set_state-001.phpt" role="test" />
<file md5sum="910f6541ade6c03374170c097907a8b2" name="tests/bson/bson-minkey_error-001.phpt" role="test" />
<file md5sum="e05511f6beae33dc190337799253a21f" name="tests/bson/bson-objectid-001.phpt" role="test" />
<file md5sum="64af3490dcf00f58afa82dab8cc1cc30" name="tests/bson/bson-objectid-002.phpt" role="test" />
<file md5sum="0d685f0d13a0a272c06ca87243a3210e" name="tests/bson/bson-objectid-003.phpt" role="test" />
<file md5sum="50b30efcd7e631ed86a1b5dc59530b9d" name="tests/bson/bson-objectid-004.phpt" role="test" />
<file md5sum="34775b2ca900140f2a6cd930821d8320" name="tests/bson/bson-objectid-compare-001.phpt" role="test" />
<file md5sum="07b78725a1cc01cfc7bf8a52f655d29a" name="tests/bson/bson-objectid-compare-002.phpt" role="test" />
<file md5sum="7384bff757b6489b84e331e5849277bf" name="tests/bson/bson-objectid-getTimestamp-001.phpt" role="test" />
<file md5sum="08087ee9dcb917059b359552a34de4e7" name="tests/bson/bson-objectid-jsonserialize-001.phpt" role="test" />
<file md5sum="c3b6fcfd69df957a8da620287dc359dd" name="tests/bson/bson-objectid-jsonserialize-002.phpt" role="test" />
<file md5sum="9ea8fa379263fdcd549e564f801014c3" name="tests/bson/bson-objectid-serialization-001.phpt" role="test" />
<file md5sum="971319b6aa9f8ee54ad8132e95fc8808" name="tests/bson/bson-objectid-serialization_error-001.phpt" role="test" />
<file md5sum="2c848f4a091368f83cbdb3f302d3a3f6" name="tests/bson/bson-objectid-serialization_error-002.phpt" role="test" />
<file md5sum="235e171e10f2e6350fea2d50f9a962f2" name="tests/bson/bson-objectid-set_state-001.phpt" role="test" />
<file md5sum="32daf05f6af1ef635dfeeaaf777cc74e" name="tests/bson/bson-objectid-set_state_error-001.phpt" role="test" />
<file md5sum="debccfc66cee957a4a432ebfbea268fc" name="tests/bson/bson-objectid-set_state_error-002.phpt" role="test" />
<file md5sum="fcbfb4e68b4b75333dfab1dd40fec51f" name="tests/bson/bson-objectid_error-001.phpt" role="test" />
<file md5sum="d20fc18fea587f7cf549fff4ddafe04c" name="tests/bson/bson-objectid_error-002.phpt" role="test" />
<file md5sum="b608cd4596a70f8be012d692d9affee2" name="tests/bson/bson-objectid_error-003.phpt" role="test" />
<file md5sum="cce7349f4677c853d066fca74eacc26d" name="tests/bson/bson-regex-001.phpt" role="test" />
<file md5sum="c6d502bd80b12b49bb86ca15cd80cb5d" name="tests/bson/bson-regex-002.phpt" role="test" />
<file md5sum="f88490a6be39ed8be80c80a65150a0cf" name="tests/bson/bson-regex-003.phpt" role="test" />
<file md5sum="511347e513bdf3bc2ae37aa34b146c01" name="tests/bson/bson-regex-004.phpt" role="test" />
<file md5sum="c5aeef20912e9660c5b9b9916e6061ed" name="tests/bson/bson-regex-005.phpt" role="test" />
<file md5sum="56bfc8e30f3eab954310dd0d02b9379b" name="tests/bson/bson-regex-compare-001.phpt" role="test" />
<file md5sum="fa19dcc92485cd60cb3b11563b1ee196" name="tests/bson/bson-regex-compare-002.phpt" role="test" />
<file md5sum="6fa2a0677b01b0c63ac9e75d7189de73" name="tests/bson/bson-regex-jsonserialize-001.phpt" role="test" />
<file md5sum="b74df13ee5230ede71e1c6dab4439d2f" name="tests/bson/bson-regex-jsonserialize-002.phpt" role="test" />
<file md5sum="f2443282d9f3e636c68051904febb3e7" name="tests/bson/bson-regex-jsonserialize-003.phpt" role="test" />
<file md5sum="3e8cea9be0207736f5f1a57b7f3f985a" name="tests/bson/bson-regex-jsonserialize-004.phpt" role="test" />
<file md5sum="66647e53b95c6eafb52d98e2d9196c7f" name="tests/bson/bson-regex-serialization-001.phpt" role="test" />
<file md5sum="f5eca804b8710b015d2f90c8d8c71368" name="tests/bson/bson-regex-serialization-002.phpt" role="test" />
<file md5sum="e42ec5b985814f1dd3c3ce3acbcbc00f" name="tests/bson/bson-regex-serialization-003.phpt" role="test" />
<file md5sum="07c7662c6b8dcc5723693077eae6c9fd" name="tests/bson/bson-regex-serialization_error-001.phpt" role="test" />
<file md5sum="733b4696d0d9e1b0da751510a761acc5" name="tests/bson/bson-regex-serialization_error-002.phpt" role="test" />
<file md5sum="1761af9218ff1583f51133d4f0cdcb19" name="tests/bson/bson-regex-set_state-001.phpt" role="test" />
<file md5sum="ab56bd68ecf9ea5717facbaa141db1b5" name="tests/bson/bson-regex-set_state-002.phpt" role="test" />
<file md5sum="22816419e87ffa591bfb03a921ea750c" name="tests/bson/bson-regex-set_state_error-001.phpt" role="test" />
<file md5sum="377e4b051a65dd08a16966cbd92f413c" name="tests/bson/bson-regex-set_state_error-002.phpt" role="test" />
<file md5sum="9324eaf63f62194dd69656d40bcb6d4d" name="tests/bson/bson-regex_error-001.phpt" role="test" />
<file md5sum="3422fde80d9b7e49dc5d430a10fa9862" name="tests/bson/bson-regex_error-002.phpt" role="test" />
<file md5sum="cdfaa1039a4cd0da222c476c1b6760ac" name="tests/bson/bson-regex_error-003.phpt" role="test" />
<file md5sum="d69349bcb7ea29d6985be366437e013c" name="tests/bson/bson-timestamp-001.phpt" role="test" />
<file md5sum="94cee14f3d06ab8085f06c241a976589" name="tests/bson/bson-timestamp-002.phpt" role="test" />
<file md5sum="a0763909d65abab501df3471d9cf0009" name="tests/bson/bson-timestamp-003.phpt" role="test" />
<file md5sum="3932a3692389d969ee55de22034324b1" name="tests/bson/bson-timestamp-004.phpt" role="test" />
<file md5sum="db926cded84f832c39e527d5fcdadcbb" name="tests/bson/bson-timestamp-005.phpt" role="test" />
<file md5sum="c3521c6cbf542f9d719c8b179ac8d2c8" name="tests/bson/bson-timestamp-compare-001.phpt" role="test" />
<file md5sum="4ff5e264bb118d99302fb918e2b54ea4" name="tests/bson/bson-timestamp-jsonserialize-001.phpt" role="test" />
<file md5sum="b3c0547739e7996b33b49eddf15ca4bf" name="tests/bson/bson-timestamp-jsonserialize-002.phpt" role="test" />
<file md5sum="5bfc985572b0eae61c2e3e7afe46588b" name="tests/bson/bson-timestamp-serialization-001.phpt" role="test" />
<file md5sum="89ee88f82bd68012d2ab0d7cec057add" name="tests/bson/bson-timestamp-serialization-002.phpt" role="test" />
<file md5sum="29db1408dde1310afa8066e7233c3db6" name="tests/bson/bson-timestamp-serialization_error-001.phpt" role="test" />
<file md5sum="546931ee801ed3c60e649573cddf813f" name="tests/bson/bson-timestamp-serialization_error-002.phpt" role="test" />
<file md5sum="3623cb6f0ef62c302ced4b3acf1f1b3f" name="tests/bson/bson-timestamp-serialization_error-003.phpt" role="test" />
<file md5sum="f7d7dd2398c27c27def6cb8dab685315" name="tests/bson/bson-timestamp-serialization_error-004.phpt" role="test" />
<file md5sum="7a13dad169f79e7cda4ab3c7a8e2dc1f" name="tests/bson/bson-timestamp-set_state-001.phpt" role="test" />
<file md5sum="2137458362aca8c1a3d8f6224c438d9e" name="tests/bson/bson-timestamp-set_state-002.phpt" role="test" />
<file md5sum="effc86aba9ebac7be6f37ace2f24fc66" name="tests/bson/bson-timestamp-set_state_error-001.phpt" role="test" />
<file md5sum="4bd04c958a1ed842374aec323736bb00" name="tests/bson/bson-timestamp-set_state_error-002.phpt" role="test" />
<file md5sum="9a74bed31b0456757323dd297e0cf7d6" name="tests/bson/bson-timestamp-set_state_error-003.phpt" role="test" />
<file md5sum="e8957247a4043fc91f223da4ed9ec84e" name="tests/bson/bson-timestamp-set_state_error-004.phpt" role="test" />
<file md5sum="4bb0b3f0ca5e48b4971f7e02a318260e" name="tests/bson/bson-timestamp_error-001.phpt" role="test" />
<file md5sum="82668bc9b4f77d46a5e32b9117fb355e" name="tests/bson/bson-timestamp_error-002.phpt" role="test" />
<file md5sum="9a0deb7c8c173de898ebee345d7b67f1" name="tests/bson/bson-timestamp_error-003.phpt" role="test" />
<file md5sum="490199683c8657f10b662d5987abf546" name="tests/bson/bson-timestamp_error-004.phpt" role="test" />
<file md5sum="e10ea28f50dcdf86978919777ed5c74e" name="tests/bson/bson-timestamp_error-005.phpt" role="test" />
<file md5sum="7bec85a32de6b6437d0d5aa0deed8e9e" name="tests/bson/bson-timestamp_error-006.phpt" role="test" />
<file md5sum="15601e2ff3cbfe1bde4e52721b8dbb26" name="tests/bson/bson-toJSON-001.phpt" role="test" />
<file md5sum="c4a10257bddb9aab679d4184d699b86b" name="tests/bson/bson-toJSON-002.phpt" role="test" />
<file md5sum="8e55b98c744f775d8b392bf52212c3d5" name="tests/bson/bson-toJSON_error-001.phpt" role="test" />
<file md5sum="0f0509269783ea5b1d879ec83d348d9d" name="tests/bson/bson-toJSON_error-002.phpt" role="test" />
<file md5sum="3ba2dc924ffb36bef6866daf2fc88a69" name="tests/bson/bson-toJSON_error-003.phpt" role="test" />
<file md5sum="852eed0a106c82c454a8b567e01018bc" name="tests/bson/bson-toPHP-001.phpt" role="test" />
<file md5sum="da19822beca89a36c70c103bc88a8aaa" name="tests/bson/bson-toPHP-002.phpt" role="test" />
<file md5sum="5ca8927796e91b33fd96e3799ddd5269" name="tests/bson/bson-toPHP-003.phpt" role="test" />
+ <file md5sum="eb9bd2bbfaafa4151e02148e1348e264" name="tests/bson/bson-toPHP-004.phpt" role="test" />
<file md5sum="ec5d6bcf2358789dceba452190d4d6fd" name="tests/bson/bson-toPHP_error-001.phpt" role="test" />
<file md5sum="1f4bc38f615c85a5a0ac8dce9c0910e1" name="tests/bson/bson-toPHP_error-002.phpt" role="test" />
<file md5sum="e4204cc33475f1a76d9670b9de1f2d50" name="tests/bson/bson-toPHP_error-003.phpt" role="test" />
<file md5sum="80d461b9ff6c1b4f0a11373b46c6d4a1" name="tests/bson/bson-toPHP_error-004.phpt" role="test" />
<file md5sum="98f5ce0002f56d572e174a6e104f5f24" name="tests/bson/bson-unknown-001.phpt" role="test" />
<file md5sum="617d694236d9a27353301c190322e83d" name="tests/bson/bson-utcdatetime-001.phpt" role="test" />
<file md5sum="de22f1e3d63048ab3db3b3514ce45bf2" name="tests/bson/bson-utcdatetime-002.phpt" role="test" />
<file md5sum="cb6b0009b8dfc770c489cd76f168f875" name="tests/bson/bson-utcdatetime-003.phpt" role="test" />
<file md5sum="de4188f960c7fd6debed280d2ce4da02" name="tests/bson/bson-utcdatetime-004.phpt" role="test" />
- <file md5sum="a1a2af3ef3f2eb6735e9e8439ab5c39d" name="tests/bson/bson-utcdatetime-005.phpt" role="test" />
- <file md5sum="6b0a5055a0d3166a4323839b561e948c" name="tests/bson/bson-utcdatetime-006.phpt" role="test" />
+ <file md5sum="ebcbd881098aeef861090012f341282d" name="tests/bson/bson-utcdatetime-005.phpt" role="test" />
+ <file md5sum="23c9998df5fe51d519abe50c27c99b32" name="tests/bson/bson-utcdatetime-006.phpt" role="test" />
<file md5sum="322715ac6f412974a9dacb1dc7a1ebc9" name="tests/bson/bson-utcdatetime-007.phpt" role="test" />
<file md5sum="b5a1e792ed87b977fa21874a12594c2c" name="tests/bson/bson-utcdatetime-compare-001.phpt" role="test" />
<file md5sum="85034e1045eb4632d9625d8c40e3b7ff" name="tests/bson/bson-utcdatetime-int-size-001.phpt" role="test" />
<file md5sum="8fbbdc845aa7cab18a7f98661c4d828d" name="tests/bson/bson-utcdatetime-int-size-002.phpt" role="test" />
<file md5sum="a93b633b97ec16f0b7707205f4709d12" name="tests/bson/bson-utcdatetime-jsonserialize-001.phpt" role="test" />
<file md5sum="1ac1ca2d4db3d5f77ccc59a3a48076c9" name="tests/bson/bson-utcdatetime-jsonserialize-002.phpt" role="test" />
<file md5sum="2bc0c3ddf3167bc788ced0582a2cd157" name="tests/bson/bson-utcdatetime-serialization-001.phpt" role="test" />
<file md5sum="3a575abb63e282591e1f150ca5ebb61a" name="tests/bson/bson-utcdatetime-serialization-002.phpt" role="test" />
<file md5sum="ac49747cfa5295c81d6e0271f827d59c" name="tests/bson/bson-utcdatetime-serialization_error-001.phpt" role="test" />
<file md5sum="a90aec321df162e83202ebabbc4248f1" name="tests/bson/bson-utcdatetime-serialization_error-002.phpt" role="test" />
<file md5sum="5f4ac622d87e508604308b21ae43f835" name="tests/bson/bson-utcdatetime-set_state-001.phpt" role="test" />
<file md5sum="cdbb4d6a6cd72816568163b8f54a0b9f" name="tests/bson/bson-utcdatetime-set_state-002.phpt" role="test" />
<file md5sum="8292f7be7a23f1afe04101f2e57f95b6" name="tests/bson/bson-utcdatetime-set_state_error-001.phpt" role="test" />
<file md5sum="d18b948a39fdb4a68f97209c48b2a846" name="tests/bson/bson-utcdatetime-set_state_error-002.phpt" role="test" />
<file md5sum="b9db4fcb289634af9d1f48a06e2b8aa0" name="tests/bson/bson-utcdatetime-todatetime-001.phpt" role="test" />
<file md5sum="8a6c7f3a7120a6135e4d8153da1fe675" name="tests/bson/bson-utcdatetime-todatetime-002.phpt" role="test" />
<file md5sum="8a10baf7be306b9d5a8e5af7dd747109" name="tests/bson/bson-utcdatetime-tostring-001.phpt" role="test" />
<file md5sum="01ff429024e70923880b7000d904f95f" name="tests/bson/bson-utcdatetime_error-001.phpt" role="test" />
<file md5sum="77b84eee9de2aa927194d1e7699de1a4" name="tests/bson/bson-utcdatetime_error-002.phpt" role="test" />
<file md5sum="b9c3f3108a0ecf7fe4f58f0c6cbc0d68" name="tests/bson/bson-utcdatetime_error-003.phpt" role="test" />
<file md5sum="78fcd6b89faca28382a3a0c90bfea9a8" name="tests/bson/bson-utcdatetime_error-004.phpt" role="test" />
<file md5sum="74978df74e164c08a7e98b2b00a850a6" name="tests/bson/bug0274.phpt" role="test" />
<file md5sum="7a78fa8d17a5f963f3eedd81a3d8e1e4" name="tests/bson/bug0313.phpt" role="test" />
<file md5sum="852106030dd7b947c767ad15ef30619c" name="tests/bson/bug0325.phpt" role="test" />
<file md5sum="5f838703ed88cbe9bfb826f6d606db67" name="tests/bson/bug0334-001.phpt" role="test" />
<file md5sum="decfd02f9f77ba7f2b7698bc2e9b1993" name="tests/bson/bug0334-002.phpt" role="test" />
<file md5sum="6e38b80bd375658cd5c9f2716c32f4c1" name="tests/bson/bug0341.phpt" role="test" />
<file md5sum="b04e028418b271bda22c519f98c61794" name="tests/bson/bug0347.phpt" role="test" />
<file md5sum="2888441736b763719632b0c3ab4d4288" name="tests/bson/bug0528.phpt" role="test" />
<file md5sum="79416a567108b8bcaf11f694a0a3f5b6" name="tests/bson/bug0531.phpt" role="test" />
<file md5sum="98df395abbaf09fe313a1ccc6d5ed0a2" name="tests/bson/bug0544.phpt" role="test" />
<file md5sum="7f0758a33e5dbd19f4f2ae41da989a2b" name="tests/bson/bug0592.phpt" role="test" />
<file md5sum="9ae13505ec2538389a8c79463ece8d1c" name="tests/bson/bug0623.phpt" role="test" />
<file md5sum="97ac756930ab930572a010dd30d574da" name="tests/bson/bug0631.phpt" role="test" />
<file md5sum="a43aaa4d0a4482370ff43c06aa082ccf" name="tests/bson/bug0672.phpt" role="test" />
<file md5sum="0b1e4c8e1683f2303f5cd22dd1f4eaeb" name="tests/bson/typemap-001.phpt" role="test" />
<file md5sum="ce3d7582821fe38452b684b7438ce67c" name="tests/bson/typemap-002.phpt" role="test" />
<file md5sum="4b1d59d2f1959529457cc64e7688633b" name="tests/bulk/bug0667.phpt" role="test" />
<file md5sum="594f059e47dfc936e4b2ef8fcb666254" name="tests/bulk/bulkwrite-count-001.phpt" role="test" />
<file md5sum="bde05e9fc07536b691f4cdbde9a929f1" name="tests/bulk/bulkwrite-countable-001.phpt" role="test" />
<file md5sum="4e806cdbc153b4ea7402a089dba6411b" name="tests/bulk/bulkwrite-debug-001.phpt" role="test" />
<file md5sum="dd4236bbed8aed59336a25d8532ddd17" name="tests/bulk/bulkwrite-delete-001.phpt" role="test" />
<file md5sum="8d10054bd97c19c978126c9dbe7992f0" name="tests/bulk/bulkwrite-delete_error-001.phpt" role="test" />
<file md5sum="db18adde47a3b0ffbb1063e0e216b428" name="tests/bulk/bulkwrite-insert-001.phpt" role="test" />
<file md5sum="88502eef0238ef643ef36d4ea1781dba" name="tests/bulk/bulkwrite-update-001.phpt" role="test" />
<file md5sum="ccf78226caff53fb79aaaf235fa84291" name="tests/bulk/bulkwrite-update_error-001.phpt" role="test" />
<file md5sum="c117f84081a29441f2df90bf68b36308" name="tests/bulk/bulkwrite_error-001.phpt" role="test" />
<file md5sum="05732249b0831f6eebef674fa84b90e8" name="tests/bulk/bulkwrite_error-002.phpt" role="test" />
<file md5sum="9ce371b37b60f0c0af62d3f8bf2ae9f3" name="tests/bulk/write-0001.phpt" role="test" />
<file md5sum="4be3531dda4cee6ef53264db72b23775" name="tests/bulk/write-0002.phpt" role="test" />
<file md5sum="1b98fa03a2968f7f9593e9fc98a0b9e8" name="tests/connect/bug0720.phpt" role="test" />
<file md5sum="02e74cf0ff0e2240901dfe918d6cbeab" name="tests/connect/replicaset-seedlist-001.phpt" role="test" />
<file md5sum="60392dab08a5778d885aac6984bc4a5a" name="tests/connect/replicaset-seedlist-002.phpt" role="test" />
<file md5sum="5782cb975ced7a0d028d9f8c36cfffc4" name="tests/connect/standalone-auth-0001.phpt" role="test" />
<file md5sum="13b4c81631c4fe5b2826b3943b65d481" name="tests/connect/standalone-auth-0002.phpt" role="test" />
<file md5sum="d31ed516811f559e1f9ecd9a557fd0be" name="tests/connect/standalone-plain-0001.phpt" role="test" />
<file md5sum="e8f9688845ac3a1b8f5da6b3d056f2f1" name="tests/connect/standalone-plain-0002.phpt" role="test" />
<file md5sum="dd86ee89cb49285d1f5967e79eed600a" name="tests/connect/standalone-ssl-no_verify-001.phpt" role="test" />
<file md5sum="63f722cee580bd0932fef6c81ea21dd9" name="tests/connect/standalone-ssl-no_verify-002.phpt" role="test" />
<file md5sum="cde2541db3184ef59b6a2e5330fd1989" name="tests/connect/standalone-ssl-verify_cert-001.phpt" role="test" />
<file md5sum="52fdef71b0fd15dc0560183f7412b169" name="tests/connect/standalone-ssl-verify_cert-002.phpt" role="test" />
<file md5sum="e4ca4afe06e73d9679a8a11f1ba4af91" name="tests/connect/standalone-ssl-verify_cert-error-001.phpt" role="test" />
<file md5sum="947ea5a9b7ac50fdb151a1cbf628eb1b" name="tests/connect/standalone-ssl-verify_cert-error-002.phpt" role="test" />
<file md5sum="5dcc1590012f20f18e735957a7e40caf" name="tests/connect/standalone-x509-auth-001.phpt" role="test" />
<file md5sum="eb801ba6249285efc4a29475ff1ddf57" name="tests/connect/standalone-x509-auth-002.phpt" role="test" />
<file md5sum="5a15b109a74060fca2df7c95fa133f18" name="tests/connect/standalone-x509-error-0001.phpt" role="test" />
<file md5sum="a1d349b948973185e98f5e1e1e13da92" name="tests/connect/standalone-x509-extract_username-001.phpt" role="test" />
<file md5sum="e58fcfda945a41736dbc53d99e776fd6" name="tests/connect/standalone-x509-extract_username-002.phpt" role="test" />
<file md5sum="dea3f769b6ea7a7cb6f4ff15ed072059" name="tests/functional/cursor-001.phpt" role="test" />
<file md5sum="400f298def6404282647635c85dea40b" name="tests/functional/cursorid-001.phpt" role="test" />
- <file md5sum="6b4b2c27fb5fd3a59af12b30ad7e875c" name="tests/functional/phpinfo-1.phpt" role="test" />
- <file md5sum="b65a28921bbe4a801dc43c8f3d1614f2" name="tests/functional/phpinfo-2.phpt" role="test" />
+ <file md5sum="8f1118a46eb22e44df5c91b3bb4ce07c" name="tests/functional/phpinfo-1.phpt" role="test" />
+ <file md5sum="51ce24e2e7ca333085958d84697c8cd8" name="tests/functional/phpinfo-2.phpt" role="test" />
<file md5sum="2a66545653e7035f281c701a4a5bfa1f" name="tests/functional/query-sort-001.phpt" role="test" />
<file md5sum="ee0ff92d6d48e5c624e7043cc4728a0c" name="tests/functional/query-sort-002.phpt" role="test" />
<file md5sum="fc136cdf12d07f1cf0975f9f37d90a22" name="tests/functional/query-sort-003.phpt" role="test" />
<file md5sum="7e15c4055e376ee0563c97a81fed1365" name="tests/functional/query-sort-004.phpt" role="test" />
<file md5sum="432630f2f57ce8bedb31b46b72c36364" name="tests/manager/bug0572.phpt" role="test" />
+ <file md5sum="f0346e6cd2ba9520eef5021167879c4e" name="tests/manager/bug0851-001.phpt" role="test" />
+ <file md5sum="9a7cb75f5eb30349c7dd731ef0977940" name="tests/manager/bug0851-002.phpt" role="test" />
<file md5sum="d582d6ff744cdbf6f65a37e63faac924" name="tests/manager/manager-ctor-001.phpt" role="test" />
<file md5sum="2739447256d9292f60da18e978a19919" name="tests/manager/manager-ctor-002.phpt" role="test" />
<file md5sum="90824d052d5f693a3e4e84b28b4a9b06" name="tests/manager/manager-ctor-003.phpt" role="test" />
<file md5sum="389882a75a62940fd3a6ac58f8f52474" name="tests/manager/manager-ctor-appname-001.phpt" role="test" />
<file md5sum="61b8d5978585fc2a3f031c4f37d2d611" name="tests/manager/manager-ctor-appname_error-001.phpt" role="test" />
<file md5sum="79e97d46bf35dde168a2b2c8b304d259" name="tests/manager/manager-ctor-read_preference-001.phpt" role="test" />
<file md5sum="a68f0249fa21dc829486e9b349d5835a" name="tests/manager/manager-ctor-read_preference-002.phpt" role="test" />
<file md5sum="932219438679606effcdf683c457362c" name="tests/manager/manager-ctor-read_preference-003.phpt" role="test" />
<file md5sum="f70c276950a04090264263d204cde1eb" name="tests/manager/manager-ctor-read_preference-error-001.phpt" role="test" />
<file md5sum="b71800ec70f4c001a0de1c83ceb9f5ed" name="tests/manager/manager-ctor-read_preference-error-002.phpt" role="test" />
<file md5sum="cacc9c381ba34b04b8837e6d1e10726c" name="tests/manager/manager-ctor-write_concern-error-001.phpt" role="test" />
<file md5sum="49ffdcbe69686e38b35bd6d9cdbd8b67" name="tests/manager/manager-ctor_error-001.phpt" role="test" />
<file md5sum="2f9426716a3fd04f9cd174c3809caf65" name="tests/manager/manager-ctor_error-002.phpt" role="test" />
<file md5sum="aa1f31f185b65f8015898e09e1b0f214" name="tests/manager/manager-debug-001.phpt" role="test" />
<file md5sum="c66217888e6d08257f72e28151141b9e" name="tests/manager/manager-debug-002.phpt" role="test" />
<file md5sum="0f8db6f664bc5cd5169365314e029598" name="tests/manager/manager-destruct-001.phpt" role="test" />
<file md5sum="eb865c94e36cb45d30deaa1fef6f6b61" name="tests/manager/manager-executeBulkWrite-001.phpt" role="test" />
<file md5sum="8699029df0d1c55416ff2e9b84f29de7" name="tests/manager/manager-executeBulkWrite-002.phpt" role="test" />
<file md5sum="e026dd6019cc223d720831cc2477f9ad" name="tests/manager/manager-executeBulkWrite-003.phpt" role="test" />
<file md5sum="5573209b66cbce19a2261b154a8965fc" name="tests/manager/manager-executeBulkWrite-004.phpt" role="test" />
<file md5sum="369baa6800666052fcd234bca4d6d212" name="tests/manager/manager-executeBulkWrite-005.phpt" role="test" />
<file md5sum="0ae8e3f91a0281b349ccbbf5a6d38645" name="tests/manager/manager-executeBulkWrite-006.phpt" role="test" />
<file md5sum="27b857c44e4cb8038de7783fefb75dbe" name="tests/manager/manager-executeBulkWrite-007.phpt" role="test" />
<file md5sum="94c563468ea9ca945cccfd489a8a569e" name="tests/manager/manager-executeBulkWrite-008.phpt" role="test" />
<file md5sum="d9b09740e5c0dfc266a730d9a15dfc5b" name="tests/manager/manager-executeBulkWrite-009.phpt" role="test" />
<file md5sum="f110b2740f1e1f63b4d922af824098b7" name="tests/manager/manager-executeBulkWrite-010.phpt" role="test" />
<file md5sum="ab6d6d06179fd4da9a9b95d512dd723e" name="tests/manager/manager-executeBulkWrite-011.phpt" role="test" />
<file md5sum="a29b35dc6a803499d584e7d6efe620aa" name="tests/manager/manager-executeBulkWrite_error-001.phpt" role="test" />
<file md5sum="72422952716c0fc6c6ee34c028ab746b" name="tests/manager/manager-executeBulkWrite_error-002.phpt" role="test" />
<file md5sum="a99efdb13d47c79a465dc890ace6b2e9" name="tests/manager/manager-executeBulkWrite_error-003.phpt" role="test" />
<file md5sum="79bebde9c592b8eaeffe0d3db98fc4b2" name="tests/manager/manager-executeBulkWrite_error-004.phpt" role="test" />
<file md5sum="f436f057342ae3112e8295ddbf8b1fc8" name="tests/manager/manager-executeBulkWrite_error-005.phpt" role="test" />
<file md5sum="98ae436fcabb824568b72b17cf9280d1" name="tests/manager/manager-executeBulkWrite_error-006.phpt" role="test" />
<file md5sum="d36794d4026aef731f405bdcba806ca9" name="tests/manager/manager-executeBulkWrite_error-007.phpt" role="test" />
<file md5sum="c22a8a88d9f1a7d4419a4369dfd7ae40" name="tests/manager/manager-executeCommand-001.phpt" role="test" />
<file md5sum="b4e242aa64446022796549bf18ef7fbd" name="tests/manager/manager-executeCommand_error-001.phpt" role="test" />
<file md5sum="ec0c4bb5549febbc8fd55ea7a29e2be6" name="tests/manager/manager-executeQuery-001.phpt" role="test" />
<file md5sum="2fdf9af56c29de3c29281622dfc6268a" name="tests/manager/manager-executeQuery-002.phpt" role="test" />
<file md5sum="46144d8bd74889415cbcb19e801dba38" name="tests/manager/manager-executeQuery-005.phpt" role="test" />
<file md5sum="828d1da5bfd8accddc3df45da5b337bd" name="tests/manager/manager-executeQuery_error-001.phpt" role="test" />
<file md5sum="59fc1f8755cee6001ff7e7cf4ec7b545" name="tests/manager/manager-executequery-without-assignment.phpt" role="test" />
<file md5sum="3fdf3959137e40815625c7af1f9bcf9c" name="tests/manager/manager-getreadconcern-001.phpt" role="test" />
<file md5sum="5b8120ba62afb13a67636fefb6ac9046" name="tests/manager/manager-getreadpreference-001.phpt" role="test" />
<file md5sum="984a06de0d8857e1df125babdfac1fef" name="tests/manager/manager-getservers-001.phpt" role="test" />
<file md5sum="99314dc63ca0a4abc49e5a56dc2c6025" name="tests/manager/manager-getservers-002.phpt" role="test" />
<file md5sum="ed0f1d54919b563cf773fed548bc9791" name="tests/manager/manager-getwriteconcern-001.phpt" role="test" />
<file md5sum="f55b83dec74f5c379cf719423abdd703" name="tests/manager/manager-invalidnamespace.phpt" role="test" />
<file md5sum="d6958dfe7978d07cb51fc4d81c86b1e9" name="tests/manager/manager-selectserver-001.phpt" role="test" />
<file md5sum="400fbbbfd04b2967e09398c479736aaa" name="tests/manager/manager-selectserver_error-001.phpt" role="test" />
<file md5sum="1b44b8daec032ca66d24b26f3a43f1ee" name="tests/manager/manager-set-uri-options-001.phpt" role="test" />
<file md5sum="31098091db5117a73880a689d1b22a69" name="tests/manager/manager-set-uri-options-002.phpt" role="test" />
<file md5sum="b80336a6a3ae99bd9709e074643e847d" name="tests/manager/manager-var-dump-001.phpt" role="test" />
<file md5sum="8c5241469e089d92c2bea067680504ee" name="tests/manager/manager-wakeup.phpt" role="test" />
<file md5sum="d9723d6bfe30a7e2691ecea5b69c2c13" name="tests/manager/manager_error-001.phpt" role="test" />
<file md5sum="e66dbf501d5db01771784dd2d668eaa3" name="tests/readPreference/bug0146-001.phpt" role="test" />
<file md5sum="87512936e327f5a49030c5ede4feed50" name="tests/readPreference/bug0146-002.phpt" role="test" />
+ <file md5sum="5bbbd73884d0d64989109201e7e1bf3f" name="tests/readPreference/bug0851-001.phpt" role="test" />
<file md5sum="6677621b6743e8d5d17b3cf0d45283d3" name="tests/readPreference/readpreference-bsonserialize-001.phpt" role="test" />
<file md5sum="ff0ce5637f8b68e7cf7c1aa65bedf89f" name="tests/readPreference/readpreference-bsonserialize-002.phpt" role="test" />
<file md5sum="f08d9809213c98acdf84fd9e656910e0" name="tests/readPreference/readpreference-ctor-001.phpt" role="test" />
<file md5sum="475a0c5eff5f7f7a211614819b886648" name="tests/readPreference/readpreference-ctor_error-001.phpt" role="test" />
<file md5sum="6a085382474901130b28e84b81029fa1" name="tests/readPreference/readpreference-ctor_error-002.phpt" role="test" />
<file md5sum="f8160df818dce1770a4bc53f6355d289" name="tests/readPreference/readpreference-ctor_error-003.phpt" role="test" />
<file md5sum="2ecac9178a92b919e2a3d744386b308d" name="tests/readPreference/readpreference-ctor_error-004.phpt" role="test" />
<file md5sum="4708202d52455d5454a03b70d029b97f" name="tests/readPreference/readpreference-debug-001.phpt" role="test" />
<file md5sum="4a4e16d677e9a242b8e2429def65e565" name="tests/readPreference/readpreference-getMaxStalenessMS-001.phpt" role="test" />
<file md5sum="2300bc05051a0d0dc183ebe1d699190a" name="tests/readPreference/readpreference-getMode-001.phpt" role="test" />
<file md5sum="2a58ca560ca933e763397fdecd6e1c22" name="tests/readPreference/readpreference-getTagSets-001.phpt" role="test" />
<file md5sum="56df736cc8af42557ae036e2eef910a8" name="tests/readPreference/readpreference_error-001.phpt" role="test" />
<file md5sum="0594c08003096c1cc1f021e4b3ea6d42" name="tests/server/bug0671-002.phpt" role="test" />
<file md5sum="75a4ec8e23ef050d7057e855fff2f5f6" name="tests/server/server-constants.phpt" role="test" />
<file md5sum="4661126e8b4887192c5b4cbb3687021e" name="tests/server/server-construct-001.phpt" role="test" />
<file md5sum="fd04e2f479e0402db99873843e712946" name="tests/server/server-debug.phpt" role="test" />
<file md5sum="d38a111b8fe29155d2e5d25072907dda" name="tests/server/server-errors.phpt" role="test" />
- <file md5sum="51aac7841cd92c8c23a07300f801eb02" name="tests/server/server-executeBulkWrite-001.phpt" role="test" />
+ <file md5sum="d5b293043d39a1662c52e856e9fcecc9" name="tests/server/server-executeBulkWrite-001.phpt" role="test" />
<file md5sum="ee5b42ab7d6083974fed746181fc58f6" name="tests/server/server-executeBulkWrite-002.phpt" role="test" />
<file md5sum="c926b3f9cbe07f825e3fa3d40080cb99" name="tests/server/server-executeBulkWrite-003.phpt" role="test" />
<file md5sum="67bb9028e8ba0e368e94f8068b67bd3c" name="tests/server/server-executeBulkWrite-004.phpt" role="test" />
<file md5sum="97fd2acd97fd481c0b87d9c70496b960" name="tests/server/server-executeBulkWrite-005.phpt" role="test" />
<file md5sum="be775815974efde6bd33e41152ac1e19" name="tests/server/server-executeCommand-001.phpt" role="test" />
<file md5sum="5fc4aeaa34980a55ddc0ea073061a9e5" name="tests/server/server-executeCommand-002.phpt" role="test" />
<file md5sum="b431241f84a378e55b470adf3746ee5e" name="tests/server/server-executeCommand-003.phpt" role="test" />
<file md5sum="f2e023f40ea3af5b1fd4b555948e7143" name="tests/server/server-executeQuery-001.phpt" role="test" />
<file md5sum="4fb14745659a9389c1a483d7edf2b93c" name="tests/server/server-executeQuery-002.phpt" role="test" />
<file md5sum="e5cb7df3413213e2d2cfb2d3e0339d37" name="tests/server/server-executeQuery-003.phpt" role="test" />
<file md5sum="044898026d584ad685adefecf4910147" name="tests/server/server-executeQuery-004.phpt" role="test" />
<file md5sum="55fe736212d4486e6239085b641b34fb" name="tests/server/server-executeQuery-005.phpt" role="test" />
<file md5sum="986bca1a493fdaa71f346eb168f8266e" name="tests/server/server-executeQuery-006.phpt" role="test" />
<file md5sum="de82332ab4df59fa7dd07b9a8be1039f" name="tests/server/server-executeQuery-007.phpt" role="test" />
<file md5sum="4d4169021903d938627d87aabb8a7e38" name="tests/server/server-executeQuery-008.phpt" role="test" />
<file md5sum="9aefd9967eed1cb334069bc28d435b71" name="tests/server/server_error-001.phpt" role="test" />
<file md5sum="ef31e8b9f59a396d435badf3c9a653c3" name="tests/standalone/bug0159.phpt" role="test" />
<file md5sum="3ff56796c1e87ea6a07ae574ea64aaf4" name="tests/standalone/bug0166.phpt" role="test" />
<file md5sum="87bb7dffe9a182e72322a74ffcbf7cb6" name="tests/standalone/bug0231.phpt" role="test" />
<file md5sum="508f7f23c5b80875cf8893f11fd636b0" name="tests/standalone/bug0357.phpt" role="test" />
<file md5sum="5cac284a2bc03ef77ec8bea7de101bf1" name="tests/standalone/bug0487-001.phpt" role="test" />
- <file md5sum="39210da8d94b6ab124c6983dbc299370" name="tests/standalone/bug0487-002.phpt" role="test" />
+ <file md5sum="555b19d37a2508138993c23e671ad65d" name="tests/standalone/bug0487-002.phpt" role="test" />
<file md5sum="907e0dfcdf61c30b9559a3a17bd2bfd7" name="tests/standalone/bug0545.phpt" role="test" />
<file md5sum="08af799afac3ebe4478c44523f19af60" name="tests/standalone/bug0655.phpt" role="test" />
<file md5sum="1eb1f1920cfbd77245d08b7da1c7e8a1" name="tests/standalone/command-aggregate-001.phpt" role="test" />
<file md5sum="727192fdd6f1dc71751a2831b0603583" name="tests/standalone/connectiontimeoutexception-001.phpt" role="test" />
<file md5sum="d1b6e3057856667e03b515c117cc6e01" name="tests/standalone/executiontimeoutexception-001.phpt" role="test" />
<file md5sum="18a8835a80982d575d574ef50c40a383" name="tests/standalone/executiontimeoutexception-002.phpt" role="test" />
<file md5sum="6708621c6c2c09bc2f261dc92c965bf9" name="tests/standalone/manager-as-singleton.phpt" role="test" />
<file md5sum="6bc5f1fba6c3ad151704fd8500d50183" name="tests/standalone/query-errors.phpt" role="test" />
<file md5sum="e199482514ae20307a7bd8125fefbf75" name="tests/standalone/update-multi-001.phpt" role="test" />
<file md5sum="18fb1fcde459435fd68d2f240b0c650c" name="tests/standalone/write-error-001.phpt" role="test" />
- <file md5sum="fb802a308506c887722e38ad7b8aa97e" name="tests/standalone/writeresult-isacknowledged-001.phpt" role="test" />
- <file md5sum="ff9bbd0cccddd05d6774c8cf05c0cd9c" name="tests/standalone/writeresult-isacknowledged-002.phpt" role="test" />
- <file md5sum="44bb6542c962e920293fdbb6da491ff9" name="tests/standalone/writeresult-isacknowledged-003.phpt" role="test" />
+ <file md5sum="3e1c19ae95c83036dc56add94ea0cd11" name="tests/standalone/writeresult-isacknowledged-001.phpt" role="test" />
+ <file md5sum="262c02b8d69ae66dc7ad5fe32cd4d84b" name="tests/standalone/writeresult-isacknowledged-002.phpt" role="test" />
+ <file md5sum="c858779a4125f12dac83f28dfa1e0bc9" name="tests/standalone/writeresult-isacknowledged-003.phpt" role="test" />
<file md5sum="59adebd29ef983f00c4d55cfc4b2d10d" name="tests/utils/PHONGO-FIXTURES.json.gz" role="test" />
<file md5sum="8eb155fe0ba18304305ec5e7095ac938" name="tests/utils/basic-skipif.inc" role="test" />
<file md5sum="d087be211838b3c030edde5946a48edf" name="tests/utils/basic.inc" role="test" />
<file md5sum="d45f34ff6fd0f526099f3131d5d17b11" name="tests/utils/classes.inc" role="test" />
- <file md5sum="6de7c960fb94099a6f9b2b2190ffe60a" name="tests/utils/tools.php" role="test" />
+ <file md5sum="b017f852d0cfb8118f46a289da3ff3b1" name="tests/utils/tools.php" role="test" />
<file md5sum="daabc03629dbb55aa9dd13c8e61c5697" name="tests/writeConcern/writeconcern-bsonserialize-001.phpt" role="test" />
<file md5sum="340ab895d2d78ec8703db01eeed96e45" name="tests/writeConcern/writeconcern-bsonserialize-002.phpt" role="test" />
<file md5sum="364b6092a91f4bf8761fc554aa8062cb" name="tests/writeConcern/writeconcern-constants.phpt" role="test" />
<file md5sum="4b14f66f2d087ed69223a978e6551dfd" name="tests/writeConcern/writeconcern-ctor-001.phpt" role="test" />
<file md5sum="9d8a5d5fbb5180c1e1a73b4885f256fd" name="tests/writeConcern/writeconcern-ctor_error-001.phpt" role="test" />
<file md5sum="46a1f16b20000db3726900b4f80945eb" name="tests/writeConcern/writeconcern-ctor_error-002.phpt" role="test" />
<file md5sum="56e3baaa054aadf32901781a09d330e1" name="tests/writeConcern/writeconcern-ctor_error-003.phpt" role="test" />
<file md5sum="9ca99acf66a4972b548678347236c25f" name="tests/writeConcern/writeconcern-ctor_error-004.phpt" role="test" />
<file md5sum="39969dc8700891be79d6ef6ca630f867" name="tests/writeConcern/writeconcern-ctor_error-005.phpt" role="test" />
<file md5sum="6514bd694b43ee6f3c2313c741740dc6" name="tests/writeConcern/writeconcern-debug-001.phpt" role="test" />
<file md5sum="0b650ccbc1a3fa831dd666e4b00c5c1a" name="tests/writeConcern/writeconcern-debug-002.phpt" role="test" />
<file md5sum="536335a91a175bce9f9a5c03991298ca" name="tests/writeConcern/writeconcern-debug-003.phpt" role="test" />
<file md5sum="afc708c9f9d830d1c3b7cf60333f1fce" name="tests/writeConcern/writeconcern-getjournal-001.phpt" role="test" />
<file md5sum="d4c305c451a28b591db0160e9f851ee5" name="tests/writeConcern/writeconcern-getw-001.phpt" role="test" />
<file md5sum="ddb88acb62b9b89316f92e3bb6076a48" name="tests/writeConcern/writeconcern-getwtimeout-001.phpt" role="test" />
<file md5sum="14ec52ea19befdf082e3ee270fa7d8ea" name="tests/writeConcern/writeconcern_error-001.phpt" role="test" />
<file md5sum="08a5fb008b50bb39301edc6130dc7a08" name="CREDITS" role="doc" />
<file md5sum="b1e01b26bacfc2232046c90a330332b3" name="LICENSE" role="doc" />
<file md5sum="9f3c76084ff72fb4668807b8d058c4ce" name="Makefile.frag" role="src" />
<file md5sum="64d70e2c61c2c5f7652d90de6bc9661f" name="README.md" role="doc" />
<file md5sum="422ba17467e9aa074a0856a15519f543" name="Vagrantfile" role="test" />
- <file md5sum="5caa971cde3795f1d58973f81cb5b283" name="config.m4" role="src" />
- <file md5sum="f831bfe291cccc71b3edb2bdae991281" name="config.w32" role="src" />
- <file md5sum="7c05211bbc08da37633238c9879d7694" name="phongo_compat.c" role="src" />
- <file md5sum="d1407006ed4291ae8d058c4bf8d8c498" name="phongo_compat.h" role="src" />
- <file md5sum="fa8285606b0955dfdf4eaf0cd510ae9a" name="php_bson.h" role="src" />
- <file md5sum="fe1d27c4399a220469051c1b19b2fec4" name="php_phongo.c" role="src" />
- <file md5sum="94b0d3d0b41cb3a63618e12e9e3dd607" name="php_phongo.h" role="src" />
- <file md5sum="157ccb0b4a7bd91e5f56611c5b2acf87" name="php_phongo_classes.h" role="src" />
- <file md5sum="1b8eed24ee08e3cca5ccd0b67339f819" name="php_phongo_structs.h" role="src" />
+ <file md5sum="0ce1abd94a85d538412254ba97afd98d" name="config.m4" role="src" />
+ <file md5sum="7e531bb1552bfd1edde6a1a344de6430" name="config.w32" role="src" />
+ <file md5sum="7cee65a3fcc059894e7badf41fcc6c93" name="phongo_compat.c" role="src" />
+ <file md5sum="387857e14552f23f3369bf3a91f61d25" name="phongo_compat.h" role="src" />
+ <file md5sum="9b6887cd796fd3878e6a429eefb61279" name="php_bson.h" role="src" />
+ <file md5sum="0ac8e768ac2c2be8fb9101b4cd86fccb" name="php_phongo.c" role="src" />
+ <file md5sum="73ba2d254ca901ce4495d9b0a4a058d3" name="php_phongo.h" role="src" />
+ <file md5sum="66c6e8411837287d43672047e21d45ef" name="php_phongo_classes.h" role="src" />
+ <file md5sum="f87716f23ef7441e1dfcc124a6d7f74f" name="php_phongo_structs.h" role="src" />
</dir>
</contents>
<dependencies>
<required>
<php>
<min>5.4.0</min>
<max>7.99.99</max>
</php>
<pearinstaller>
<min>1.4.8</min>
</pearinstaller>
</required>
</dependencies>
<providesextension>mongodb</providesextension>
<extsrcrelease />
</package>

File Metadata

Mime Type
text/x-diff
Expires
Sat, May 16, 7:36 AM (19 h, 28 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
83/f1/4c684ddde2d56ba8c5436b69bfcd
Default Alt Text
(1 MB)

Event Timeline