Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
405 KB
Referenced Files
None
Subscribers
None
This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/amqp-1.6.1/CREDITS b/amqp-1.6.1/CREDITS
new file mode 100644
index 0000000..5ac3c9e
--- /dev/null
+++ b/amqp-1.6.1/CREDITS
@@ -0,0 +1,20 @@
+AMQP bindings for PHP
+All who contributed to php-amqp project
+Alexandre Kalendarev <akalend@mail.ru> (original author)
+Pieter de Zwart <pdezwart@php.net> (lead)
+Andrey Hristov (contributor)
+Brad Rodriguez <brodriguez@php.net> (contributor)
+John Skopis (contributor - PHP < 5.3 compatibility)
+Andy Wick <andy.wick@teamaol.com> (contributor - bug fixes, custom headers support)
+Jonathan Tansavatdi <jtansavatdi@php.net> (contributor)
+Bernhard Weisshuhn (maintainer)
+Lars Strojny (maintainer)
+Anatoliy Belsky (contributor)
+Alex Sladkov (contributor)
+Vladimir Kartaviy (contributor)
+Florin Patan (reported)
+Ilya a.k.a. coodix (contributor)
+Bogdan Padalko (contributor)
+Dmitry Vinogradov (contributor)
+Peter Hansen (contributor)
+Michael K. Squires <sqmk@php.net> (contributor)
\ No newline at end of file
diff --git a/amqp-1.6.1/LICENSE b/amqp-1.6.1/LICENSE
new file mode 100644
index 0000000..203ce02
--- /dev/null
+++ b/amqp-1.6.1/LICENSE
@@ -0,0 +1,68 @@
+--------------------------------------------------------------------
+ The PHP License, version 3.01
+Copyright (c) 1999 - 2012 The PHP Group. All rights reserved.
+--------------------------------------------------------------------
+
+Redistribution and use in source and binary forms, with or without
+modification, is permitted provided that the following conditions
+are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ 3. The name "PHP" must not be used to endorse or promote products
+ derived from this software without prior written permission. For
+ written permission, please contact group@php.net.
+
+ 4. Products derived from this software may not be called "PHP", nor
+ may "PHP" appear in their name, without prior written permission
+ from group@php.net. You may indicate that your software works in
+ conjunction with PHP by saying "Foo for PHP" instead of calling
+ it "PHP Foo" or "phpfoo"
+
+ 5. The PHP Group may publish revised and/or new versions of the
+ license from time to time. Each version will be given a
+ distinguishing version number.
+ Once covered code has been published under a particular version
+ of the license, you may always continue to use it under the terms
+ of that version. You may also choose to use such covered code
+ under the terms of any subsequent version of the license
+ published by the PHP Group. No one other than the PHP Group has
+ the right to modify the terms applicable to covered code created
+ under this License.
+
+ 6. Redistributions of any form whatsoever must retain the following
+ acknowledgment:
+ "This product includes PHP software, freely available from
+ <http://www.php.net/software/>".
+
+THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
+ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
+DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+--------------------------------------------------------------------
+
+This software consists of voluntary contributions made by many
+individuals on behalf of the PHP Group.
+
+The PHP Group can be contacted via Email at group@php.net.
+
+For more information on the PHP Group and the PHP project,
+please see <http://www.php.net>.
+
+PHP includes the Zend Engine, freely available at
+<http://www.zend.com>.
diff --git a/amqp-1.6.1/amqp.c b/amqp-1.6.1/amqp.c
new file mode 100644
index 0000000..2c91fbf
--- /dev/null
+++ b/amqp-1.6.1/amqp.c
@@ -0,0 +1,1055 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: amqp.c 327551 2012-09-09 03:49:34Z pdezwart $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "zend_ini.h"
+#include "zend_exceptions.h"
+
+#ifdef PHP_WIN32
+# include "win32/php_stdint.h"
+# include "win32/signal.h"
+#else
+# include <stdint.h>
+# include <signal.h>
+#endif
+#include <amqp.h>
+#include <amqp_framing.h>
+
+#include "php_amqp.h"
+#include "amqp_connection.h"
+#include "amqp_channel.h"
+#include "amqp_queue.h"
+#include "amqp_exchange.h"
+#include "amqp_envelope.h"
+#include "amqp_connection_resource.h"
+
+
+#ifdef PHP_WIN32
+# include "win32/unistd.h"
+#else
+# include <unistd.h>
+#endif
+
+/* True global resources - no need for thread safety here */
+zend_class_entry *amqp_connection_class_entry;
+zend_class_entry *amqp_channel_class_entry;
+zend_class_entry *amqp_queue_class_entry;
+zend_class_entry *amqp_exchange_class_entry;
+zend_class_entry *amqp_envelope_class_entry;
+
+zend_class_entry *amqp_exception_class_entry,
+ *amqp_connection_exception_class_entry,
+ *amqp_channel_exception_class_entry,
+ *amqp_queue_exception_class_entry,
+ *amqp_exchange_exception_class_entry;
+
+
+/* The last parameter of ZEND_BEGIN_ARG_INFO_EX indicates how many of the method flags are required. */
+/* The first parameter of ZEND_ARG_INFO indicates whether the variable is being passed by reference */
+
+/* amqp_connection_class ARG_INFO definition */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ ZEND_ARG_ARRAY_INFO(0, credentials, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_isConnected, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_connect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_pconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_pdisconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_disconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_reconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_preconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getLogin, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setLogin, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, login)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getPassword, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setPassword, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, password)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getHost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setHost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, host)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getPort, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setPort, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, port)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getVhost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setVhost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, vhost)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, timeout)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getReadTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setReadTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, timeout)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getWriteTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setWriteTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, timeout)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getUsedChannels, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getMaxChannels, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getMaxFrameSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getHeartbeatInterval, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_isPersistent, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+
+/* amqp_channel_class ARG_INFO definition */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, amqp_connection)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_isConnected, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getChannelId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setPrefetchSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, size)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getPrefetchSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setPrefetchCount, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, count)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getPrefetchCount, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_qos, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
+ ZEND_ARG_INFO(0, size)
+ ZEND_ARG_INFO(0, count)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_startTransaction, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_commitTransaction, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_rollbackTransaction, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getConnection, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_basicRecover, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ ZEND_ARG_INFO(0, requeue)
+ZEND_END_ARG_INFO()
+
+/* amqp_queue_class ARG_INFO definition */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, amqp_channel)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, queue_name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, argument)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
+ ZEND_ARG_INFO(0, key)
+ ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_ARRAY_INFO(0, arguments, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_declareQueue, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_bind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, exchange_name)
+ ZEND_ARG_INFO(0, routing_key)
+ ZEND_ARG_INFO(0, arguments)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_get, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_consume, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, callback)
+ ZEND_ARG_INFO(0, flags)
+ ZEND_ARG_INFO(0, consumer_tag)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_ack, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, delivery_tag)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_nack, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, delivery_tag)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_reject, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, delivery_tag)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_purge, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_cancel, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ ZEND_ARG_INFO(0, consumer_tag)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_unbind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, exchange_name)
+ ZEND_ARG_INFO(0, routing_key)
+ ZEND_ARG_INFO(0, arguments)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_delete, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getChannel, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getConnection, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getConsumerTag, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+/* amqp_exchange ARG_INFO definition */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, amqp_channel)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, exchange_name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, exchange_type)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, argument)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
+ ZEND_ARG_INFO(0, key)
+ ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_ARRAY_INFO(0, arguments, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_declareExchange, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_bind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
+ ZEND_ARG_INFO(0, exchange_name)
+ ZEND_ARG_INFO(0, routing_key)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_unbind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
+ ZEND_ARG_INFO(0, exchange_name)
+ ZEND_ARG_INFO(0, routing_key)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_delete, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ ZEND_ARG_INFO(0, exchange_name)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_publish, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, message)
+ ZEND_ARG_INFO(0, routing_key)
+ ZEND_ARG_INFO(0, flags)
+ ZEND_ARG_ARRAY_INFO(0, headers, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getChannel, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getConnection, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+/* amqp_envelope_class ARG_INFO definition */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getBody, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getRoutingKey, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getDeliveryTag, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getDeliveryMode, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getExchangeName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_isRedelivery, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getContentType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getContentEncoding, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getTimestamp, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getPriority, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getExpiration, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getUserId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getAppId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getMessageId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getReplyTo, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getCorrelationId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getHeaders, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getHeader, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+
+/* {{{ amqp_functions[]
+*
+*Every user visible function must have an entry in amqp_functions[].
+*/
+zend_function_entry amqp_connection_class_functions[] = {
+ PHP_ME(amqp_connection_class, __construct, arginfo_amqp_connection_class__construct, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, isConnected, arginfo_amqp_connection_class_isConnected, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, connect, arginfo_amqp_connection_class_connect, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, pconnect, arginfo_amqp_connection_class_pconnect, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, pdisconnect, arginfo_amqp_connection_class_pdisconnect, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, disconnect, arginfo_amqp_connection_class_disconnect, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, reconnect, arginfo_amqp_connection_class_reconnect, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, preconnect, arginfo_amqp_connection_class_preconnect, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_connection_class, getLogin, arginfo_amqp_connection_class_getLogin, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setLogin, arginfo_amqp_connection_class_setLogin, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_connection_class, getPassword, arginfo_amqp_connection_class_getPassword, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setPassword, arginfo_amqp_connection_class_setPassword, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_connection_class, getHost, arginfo_amqp_connection_class_getHost, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setHost, arginfo_amqp_connection_class_setHost, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_connection_class, getPort, arginfo_amqp_connection_class_getPort, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setPort, arginfo_amqp_connection_class_setPort, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_connection_class, getVhost, arginfo_amqp_connection_class_getVhost, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setVhost, arginfo_amqp_connection_class_setVhost, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_connection_class, getTimeout, arginfo_amqp_connection_class_getTimeout, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setTimeout, arginfo_amqp_connection_class_setTimeout, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_connection_class, getReadTimeout, arginfo_amqp_connection_class_getReadTimeout, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setReadTimeout, arginfo_amqp_connection_class_setReadTimeout, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_connection_class, getWriteTimeout, arginfo_amqp_connection_class_getWriteTimeout, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setWriteTimeout, arginfo_amqp_connection_class_setWriteTimeout, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_connection_class, getUsedChannels, arginfo_amqp_connection_class_getUsedChannels, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getMaxChannels, arginfo_amqp_connection_class_getMaxChannels, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, isPersistent, arginfo_amqp_connection_class_isPersistent, ZEND_ACC_PUBLIC)
+#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH > 52
+ PHP_ME(amqp_connection_class, getHeartbeatInterval, arginfo_amqp_connection_class_getHeartbeatInterval, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getMaxFrameSize, arginfo_amqp_connection_class_getMaxFrameSize, ZEND_ACC_PUBLIC)
+#endif
+
+ {NULL, NULL, NULL} /* Must be the last line in amqp_functions[] */
+};
+
+zend_function_entry amqp_channel_class_functions[] = {
+ PHP_ME(amqp_channel_class, __construct, arginfo_amqp_channel_class__construct, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, isConnected, arginfo_amqp_channel_class_isConnected, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_channel_class, getChannelId, arginfo_amqp_channel_class_getChannelId, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_channel_class, setPrefetchSize, arginfo_amqp_channel_class_setPrefetchSize, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, getPrefetchSize, arginfo_amqp_channel_class_getPrefetchSize, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, setPrefetchCount,arginfo_amqp_channel_class_setPrefetchCount,ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, getPrefetchCount,arginfo_amqp_channel_class_getPrefetchCount,ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, qos, arginfo_amqp_channel_class_qos, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_channel_class, startTransaction, arginfo_amqp_channel_class_startTransaction, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, commitTransaction, arginfo_amqp_channel_class_commitTransaction, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, rollbackTransaction, arginfo_amqp_channel_class_rollbackTransaction, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_channel_class, getConnection, arginfo_amqp_channel_class_getConnection, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_channel_class, basicRecover, arginfo_amqp_channel_class_basicRecover, ZEND_ACC_PUBLIC)
+
+ {NULL, NULL, NULL} /* Must be the last line in amqp_functions[] */
+};
+
+zend_function_entry amqp_queue_class_functions[] = {
+ PHP_ME(amqp_queue_class, __construct, arginfo_amqp_queue_class__construct, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, getName, arginfo_amqp_queue_class_getName, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, setName, arginfo_amqp_queue_class_setName, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, getFlags, arginfo_amqp_queue_class_getFlags, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, setFlags, arginfo_amqp_queue_class_setFlags, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, getArgument, arginfo_amqp_queue_class_getArgument, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, getArguments, arginfo_amqp_queue_class_getArguments, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, setArgument, arginfo_amqp_queue_class_setArgument, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, setArguments, arginfo_amqp_queue_class_setArguments, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, declareQueue, arginfo_amqp_queue_class_declareQueue, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, bind, arginfo_amqp_queue_class_bind, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, get, arginfo_amqp_queue_class_get, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, consume, arginfo_amqp_queue_class_consume, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, ack, arginfo_amqp_queue_class_ack, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, nack, arginfo_amqp_queue_class_nack, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, reject, arginfo_amqp_queue_class_reject, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, purge, arginfo_amqp_queue_class_purge, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, cancel, arginfo_amqp_queue_class_cancel, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, delete, arginfo_amqp_queue_class_delete, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, unbind, arginfo_amqp_queue_class_unbind, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, getChannel, arginfo_amqp_queue_class_getChannel, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, getConnection, arginfo_amqp_queue_class_getConnection, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, getConsumerTag, arginfo_amqp_queue_class_getConsumerTag, ZEND_ACC_PUBLIC)
+
+ PHP_MALIAS(amqp_queue_class, declare, declareQueue, arginfo_amqp_queue_class_declareQueue, ZEND_ACC_PUBLIC | ZEND_ACC_DEPRECATED)
+
+ {NULL, NULL, NULL} /* Must be the last line in amqp_functions[] */
+};
+
+zend_function_entry amqp_exchange_class_functions[] = {
+ PHP_ME(amqp_exchange_class, __construct, arginfo_amqp_exchange_class__construct, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_exchange_class, getName, arginfo_amqp_exchange_class_getName, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, setName, arginfo_amqp_exchange_class_setName, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_exchange_class, getFlags, arginfo_amqp_exchange_class_getFlags, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, setFlags, arginfo_amqp_exchange_class_setFlags, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_exchange_class, getType, arginfo_amqp_exchange_class_getType, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, setType, arginfo_amqp_exchange_class_setType, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_exchange_class, getArgument, arginfo_amqp_exchange_class_getArgument, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, getArguments, arginfo_amqp_exchange_class_getArguments, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, setArgument, arginfo_amqp_exchange_class_setArgument, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, setArguments, arginfo_amqp_exchange_class_setArguments, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_exchange_class, declareExchange,arginfo_amqp_exchange_class_declareExchange,ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, bind, arginfo_amqp_exchange_class_bind, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, unbind, arginfo_amqp_exchange_class_unbind, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, delete, arginfo_amqp_exchange_class_delete, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, publish, arginfo_amqp_exchange_class_publish, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_exchange_class, getChannel, arginfo_amqp_exchange_class_getChannel, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, getConnection, arginfo_amqp_exchange_class_getConnection, ZEND_ACC_PUBLIC)
+
+ PHP_MALIAS(amqp_exchange_class, declare, declareExchange, arginfo_amqp_exchange_class_declareExchange, ZEND_ACC_PUBLIC | ZEND_ACC_DEPRECATED)
+
+ {NULL, NULL, NULL} /* Must be the last line in amqp_functions[] */
+};
+
+zend_function_entry amqp_envelope_class_functions[] = {
+ PHP_ME(amqp_envelope_class, __construct, arginfo_amqp_envelope_class__construct, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getBody, arginfo_amqp_envelope_class_getBody, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getRoutingKey, arginfo_amqp_envelope_class_getRoutingKey, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getDeliveryTag, arginfo_amqp_envelope_class_getDeliveryTag, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getDeliveryMode, arginfo_amqp_envelope_class_getDeliveryMode, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getExchangeName, arginfo_amqp_envelope_class_getExchangeName, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, isRedelivery, arginfo_amqp_envelope_class_isRedelivery, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getContentType, arginfo_amqp_envelope_class_getContentType, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getContentEncoding, arginfo_amqp_envelope_class_getContentEncoding, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getType, arginfo_amqp_envelope_class_getType, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getTimestamp, arginfo_amqp_envelope_class_getTimestamp, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getPriority, arginfo_amqp_envelope_class_getPriority, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getExpiration, arginfo_amqp_envelope_class_getExpiration, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getUserId, arginfo_amqp_envelope_class_getUserId, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getAppId, arginfo_amqp_envelope_class_getAppId, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getMessageId, arginfo_amqp_envelope_class_getMessageId, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getReplyTo, arginfo_amqp_envelope_class_getReplyTo, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getCorrelationId, arginfo_amqp_envelope_class_getCorrelationId, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getHeaders, arginfo_amqp_envelope_class_getHeaders, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getHeader, arginfo_amqp_envelope_class_getHeader, ZEND_ACC_PUBLIC)
+
+ {NULL, NULL, NULL} /* Must be the last line in amqp_functions[] */
+};
+
+zend_function_entry amqp_functions[] = {
+ {NULL, NULL, NULL} /* Must be the last line in amqp_functions[] */
+};
+/* }}} */
+
+/* {{{ amqp_module_entry
+*/
+zend_module_entry amqp_module_entry = {
+#if ZEND_MODULE_API_NO >= 20010901
+ STANDARD_MODULE_HEADER,
+#endif
+ "amqp",
+ amqp_functions,
+ PHP_MINIT(amqp),
+ PHP_MSHUTDOWN(amqp),
+ NULL,
+ NULL,
+ PHP_MINFO(amqp),
+#if ZEND_MODULE_API_NO >= 20010901
+ PHP_AMQP_VERSION,
+#endif
+ STANDARD_MODULE_PROPERTIES
+};
+/* }}} */
+
+#ifdef COMPILE_DL_AMQP
+ ZEND_GET_MODULE(amqp)
+#endif
+
+void php_amqp_error(amqp_rpc_reply_t reply, char **message, amqp_connection_object *connection, amqp_channel_object *channel TSRMLS_DC)
+{
+ assert(connection != NULL);
+ assert(connection->connection_resource != NULL);
+
+ switch (php_amqp_connection_resource_error(reply, message, connection->connection_resource, (channel ? channel->channel_id : 0) TSRMLS_CC)) {
+ case PHP_AMQP_RESOURCE_RESPONSE_OK:
+ break;
+ case PHP_AMQP_RESOURCE_RESPONSE_ERROR:
+ /* Library or other non-protocol or even protocol related errors may be here, do nothing with this for now. */
+ break;
+ case PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED:
+ /* Mark channel as closed to prevent sending channel.close request */
+ assert(channel != NULL);
+ channel->is_connected = '\0';
+
+ /* Close channel */
+ php_amqp_close_channel(channel TSRMLS_CC);
+
+ /* No more error handling necessary, returning. */
+ break;
+ case PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED:
+ /* Mark connection as closed to prevent sending any further requests */
+ connection->is_connected = '\0';
+
+ /* Close connection with all its channels */
+ php_amqp_disconnect_force(connection TSRMLS_CC);
+
+ /* No more error handling necessary, returning. */
+ break;
+ default:
+ spprintf(message, 0, "Unknown server error, method id 0x%08X (not handled by extension)", reply.reply.id);
+ break;
+ }
+}
+
+void php_amqp_zend_throw_exception(amqp_rpc_reply_t reply, zend_class_entry *exception_ce, const char *message, long code TSRMLS_DC)
+{
+ switch (reply.reply_type) {
+ case AMQP_RESPONSE_NORMAL:
+ break;
+ case AMQP_RESPONSE_NONE:
+ exception_ce = amqp_exception_class_entry;
+ break;
+ case AMQP_RESPONSE_LIBRARY_EXCEPTION:
+ exception_ce = amqp_exception_class_entry;
+ break;
+ case AMQP_RESPONSE_SERVER_EXCEPTION:
+ switch (reply.reply.id) {
+ case AMQP_CONNECTION_CLOSE_METHOD:
+ /* Fatal errors - pass them to connection level */
+ exception_ce = amqp_connection_exception_class_entry;
+ break;
+ case AMQP_CHANNEL_CLOSE_METHOD:
+ /* Most channel-level errors occurs due to previously known action and thus their kind can be predicted. */
+ /* exception_ce = amqp_channel_exception_class_entry; */
+ break;
+ }
+ break;
+ /* Default for the above switch should be handled by the below default. */
+ default:
+ exception_ce = amqp_exception_class_entry;
+ break;
+ }
+
+ zend_throw_exception(exception_ce, message, code TSRMLS_CC);
+}
+
+
+void php_amqp_maybe_release_buffers_on_channel(amqp_connection_object *connection, amqp_channel_object *channel)
+{
+ assert(connection != NULL);
+ assert(channel != NULL);
+ assert(channel->channel_id > 0);
+
+ if (connection->connection_resource) {
+ amqp_maybe_release_buffers_on_channel(connection->connection_resource->connection_state, channel->channel_id);
+ }
+}
+
+amqp_bytes_t php_amqp_long_string(char const *cstr, int len)
+{
+ if (len < 1) {
+ return amqp_empty_bytes;
+ }
+
+ amqp_bytes_t result;
+ result.len = len;
+ result.bytes = (void *) cstr;
+ return result;
+}
+
+char *stringify_bytes(amqp_bytes_t bytes)
+{
+/* We will need up to 4 chars per byte, plus the terminating 0 */
+ char *res = emalloc(bytes.len * 4 + 1);
+ uint8_t *data = bytes.bytes;
+ char *p = res;
+ size_t i;
+
+ for (i = 0; i < bytes.len; i++) {
+ if (data[i] >= 32 && data[i] != 127) {
+ *p++ = data[i];
+ } else {
+ *p++ = '\\';
+ *p++ = '0' + (data[i] >> 6);
+ *p++ = '0' + (data[i] >> 3 & 0x7);
+ *p++ = '0' + (data[i] & 0x7);
+ }
+ }
+
+ *p = 0;
+ return res;
+}
+
+void internal_convert_zval_to_amqp_table(zval *zvalArguments, amqp_table_t *arguments, char allow_int_keys TSRMLS_DC)
+{
+ HashTable *argumentHash;
+ HashPosition pos;
+ zval **data;
+ char type[16];
+ amqp_table_t *inner_table;
+
+ argumentHash = Z_ARRVAL_P(zvalArguments);
+
+ /* Allocate all the memory necessary for storing the arguments */
+ arguments->entries = (amqp_table_entry_t *)ecalloc(zend_hash_num_elements(argumentHash), sizeof(amqp_table_entry_t));
+ arguments->num_entries = 0;
+
+ for (zend_hash_internal_pointer_reset_ex(argumentHash, &pos);
+ zend_hash_get_current_data_ex(argumentHash, (void**) &data, &pos) == SUCCESS;
+ zend_hash_move_forward_ex(argumentHash, &pos)) {
+
+ zval value;
+ char *key;
+ uint key_len;
+ ulong index;
+ char *strKey;
+ char *strValue;
+ amqp_table_entry_t *table;
+ amqp_field_value_t *field;
+
+
+ /* Make a copy of the value: */
+ value = **data;
+ zval_copy_ctor(&value);
+
+ /* Now pull the key */
+
+ if (zend_hash_get_current_key_ex(argumentHash, &key, &key_len, &index, 0, &pos) != HASH_KEY_IS_STRING) {
+
+ if (allow_int_keys) {
+ /* Convert to strings non-string keys */
+ char str[32];
+
+ key_len = sprintf(str, "%lu", index);
+ key = str;
+ } else {
+ /* Skip things that are not strings */
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Ignoring non-string header field '%lu'", index);
+
+ continue;
+ }
+
+ }
+
+ /* Build the value */
+ table = &arguments->entries[arguments->num_entries++];
+ field = &table->value;
+
+ switch (Z_TYPE_P(&value)) {
+ case IS_BOOL:
+ field->kind = AMQP_FIELD_KIND_BOOLEAN;
+ field->value.boolean = (amqp_boolean_t)Z_LVAL_P(&value);
+ break;
+ case IS_DOUBLE:
+ field->kind = AMQP_FIELD_KIND_F64;
+ field->value.f64 = Z_DVAL_P(&value);
+ break;
+ case IS_LONG:
+ field->kind = AMQP_FIELD_KIND_I64;
+ field->value.i64 = Z_LVAL_P(&value);
+ break;
+ case IS_STRING:
+ field->kind = AMQP_FIELD_KIND_UTF8;
+
+ if (Z_STRLEN_P(&value)) {
+ amqp_bytes_t bytes;
+ bytes.len = (size_t) Z_STRLEN_P(&value);
+ bytes.bytes = estrndup(Z_STRVAL_P(&value), (uint)Z_STRLEN_P(&value));
+
+ field->value.bytes = bytes;
+ } else {
+ field->value.bytes = amqp_empty_bytes;
+ }
+
+ break;
+ case IS_ARRAY:
+ field->kind = AMQP_FIELD_KIND_TABLE;
+ internal_convert_zval_to_amqp_table(&value, &field->value.table, 1 TSRMLS_CC);
+
+ break;
+ default:
+ switch(Z_TYPE_P(&value)) {
+ case IS_NULL: strcpy(type, "null"); break;
+ case IS_OBJECT: strcpy(type, "object"); break;
+ case IS_RESOURCE: strcpy(type, "resource"); break;
+ default: strcpy(type, "unknown");
+ }
+
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Ignoring field '%s' due to unsupported value type (%s)", key, type);
+
+ /* Reset entries counter back */
+ arguments->num_entries --;
+ continue;
+ }
+
+ strKey = estrndup(key, key_len);
+ table->key = amqp_cstring_bytes(strKey);
+
+ /* Clean up the zval */
+ zval_dtor(&value);
+ }
+}
+
+inline amqp_table_t *convert_zval_to_amqp_table(zval *zvalArguments TSRMLS_DC)
+{
+ amqp_table_t *arguments;
+ /* In setArguments, we are overwriting all the existing values */
+ arguments = (amqp_table_t *)emalloc(sizeof(amqp_table_t));
+
+ internal_convert_zval_to_amqp_table(zvalArguments, arguments, 0 TSRMLS_CC);
+
+ return arguments;
+}
+
+
+
+
+void internal_php_amqp_free_amqp_table(amqp_table_t *object, char clear_root)
+{
+ if (!object) {
+ return;
+ }
+
+ if (object->entries) {
+ int macroEntryCounter;
+ for (macroEntryCounter = 0; macroEntryCounter < object->num_entries; macroEntryCounter++) {
+
+ amqp_table_entry_t *entry = &object->entries[macroEntryCounter];
+ efree(entry->key.bytes);
+
+ switch (entry->value.kind) {
+ case AMQP_FIELD_KIND_TABLE:
+ internal_php_amqp_free_amqp_table(&entry->value.value.table, 0);
+ break;
+ case AMQP_FIELD_KIND_UTF8:
+ if (entry->value.value.bytes.bytes) {
+ efree(entry->value.value.bytes.bytes);
+ }
+ break;
+ }
+ }
+ efree(object->entries);
+ }
+
+ if (clear_root) {
+ efree(object);
+ }
+}
+
+void php_amqp_free_amqp_table(amqp_table_t *object)
+{
+ internal_php_amqp_free_amqp_table(object, 1);
+}
+
+
+PHP_INI_BEGIN()
+ PHP_INI_ENTRY("amqp.host", DEFAULT_HOST, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.vhost", DEFAULT_VHOST, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.port", DEFAULT_PORT, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.timeout", DEFAULT_TIMEOUT, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.read_timeout", DEFAULT_READ_TIMEOUT, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.write_timeout", DEFAULT_WRITE_TIMEOUT, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.connect_timeout", DEFAULT_CONNECT_TIMEOUT, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.login", DEFAULT_LOGIN, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.password", DEFAULT_PASSWORD, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.auto_ack", DEFAULT_AUTOACK, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.prefetch_count", DEFAULT_PREFETCH_COUNT, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.channel_max", DEFAULT_CHANNEL_MAX, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.frame_max", DEFAULT_FRAME_MAX, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.heartbeat", DEFAULT_HEARTBEAT, PHP_INI_ALL, NULL)
+PHP_INI_END()
+
+/* {{{ PHP_MINIT_FUNCTION
+*/
+PHP_MINIT_FUNCTION(amqp)
+{
+ zend_class_entry ce;
+
+ /* Set up the connection resource */
+ le_amqp_connection_resource = zend_register_list_destructors_ex(amqp_connection_resource_dtor, NULL, PHP_AMQP_CONNECTION_RES_NAME, module_number);
+ le_amqp_connection_resource_persistent = zend_register_list_destructors_ex(NULL, amqp_connection_resource_dtor_persistent, PHP_AMQP_CONNECTION_RES_NAME, module_number);
+
+ INIT_CLASS_ENTRY(ce, "AMQPConnection", amqp_connection_class_functions);
+ ce.create_object = amqp_connection_ctor;
+ amqp_connection_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+
+ INIT_CLASS_ENTRY(ce, "AMQPChannel", amqp_channel_class_functions);
+ ce.create_object = amqp_channel_ctor;
+ amqp_channel_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+
+ INIT_CLASS_ENTRY(ce, "AMQPQueue", amqp_queue_class_functions);
+ ce.create_object = amqp_queue_ctor;
+ amqp_queue_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+
+ INIT_CLASS_ENTRY(ce, "AMQPExchange", amqp_exchange_class_functions);
+ ce.create_object = amqp_exchange_ctor;
+ amqp_exchange_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+
+ INIT_CLASS_ENTRY(ce, "AMQPEnvelope", amqp_envelope_class_functions);
+ ce.create_object = amqp_envelope_ctor;
+ amqp_envelope_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+
+ /* Class Exceptions */
+ INIT_CLASS_ENTRY(ce, "AMQPException", NULL);
+ amqp_exception_class_entry = zend_register_internal_class_ex(&ce, (zend_class_entry*)zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
+
+ INIT_CLASS_ENTRY(ce, "AMQPConnectionException", NULL);
+ amqp_connection_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry, NULL TSRMLS_CC);
+
+ INIT_CLASS_ENTRY(ce, "AMQPChannelException", NULL);
+ amqp_channel_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry, NULL TSRMLS_CC);
+
+ INIT_CLASS_ENTRY(ce, "AMQPQueueException", NULL);
+ amqp_queue_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry, NULL TSRMLS_CC);
+
+ INIT_CLASS_ENTRY(ce, "AMQPExchangeException", NULL);
+ amqp_exchange_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry, NULL TSRMLS_CC);
+
+ REGISTER_INI_ENTRIES();
+
+ REGISTER_LONG_CONSTANT("AMQP_NOPARAM", AMQP_NOPARAM, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_JUST_CONSUME", AMQP_JUST_CONSUME, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_DURABLE", AMQP_DURABLE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_PASSIVE", AMQP_PASSIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_EXCLUSIVE", AMQP_EXCLUSIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_AUTODELETE", AMQP_AUTODELETE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_INTERNAL", AMQP_INTERNAL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_NOLOCAL", AMQP_NOLOCAL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_AUTOACK", AMQP_AUTOACK, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_IFEMPTY", AMQP_IFEMPTY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_IFUNUSED", AMQP_IFUNUSED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_MANDATORY", AMQP_MANDATORY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_IMMEDIATE", AMQP_IMMEDIATE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_MULTIPLE", AMQP_MULTIPLE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_NOWAIT", AMQP_NOWAIT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_REQUEUE", AMQP_REQUEUE, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_DIRECT", AMQP_EX_TYPE_DIRECT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_FANOUT", AMQP_EX_TYPE_FANOUT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_TOPIC", AMQP_EX_TYPE_TOPIC, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_HEADERS",AMQP_EX_TYPE_HEADERS, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("AMQP_OS_SOCKET_TIMEOUT_ERRNO", AMQP_OS_SOCKET_TIMEOUT_ERRNO, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_AMQP_MAX_CHANNELS", PHP_AMQP_MAX_CHANNELS, CONST_CS | CONST_PERSISTENT);
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_MSHUTDOWN_FUNCTION
+*/
+PHP_MSHUTDOWN_FUNCTION(amqp)
+{
+ UNREGISTER_INI_ENTRIES();
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+/* {{{ PHP_MINFO_FUNCTION
+*/
+PHP_MINFO_FUNCTION(amqp)
+{
+ php_info_print_table_start();
+ php_info_print_table_header(2, "Version", PHP_AMQP_VERSION);
+ php_info_print_table_header(2, "Revision", PHP_AMQP_REVISION);
+ php_info_print_table_header(2, "Compiled", __DATE__ " @ " __TIME__);
+ php_info_print_table_header(2, "AMQP protocol version", "0-9-1");
+ php_info_print_table_header(2, "librabbitmq version", amqp_version());
+ php_info_print_table_header(2, "Default max channels per connection", DEFAULT_CHANNEL_MAX);
+ php_info_print_table_header(2, "Default max frame size", DEFAULT_FRAME_MAX);
+ php_info_print_table_header(2, "Default heartbeats interval", DEFAULT_HEARTBEAT);
+ DISPLAY_INI_ENTRIES();
+}
+/* }}} */
+
+/*
+*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/amqp-1.6.1/amqp_channel.c b/amqp-1.6.1/amqp_channel.c
new file mode 100644
index 0000000..aaccbfb
--- /dev/null
+++ b/amqp-1.6.1/amqp_channel.c
@@ -0,0 +1,744 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: amqp_channel.c 318036 2011-10-11 20:30:46Z pdezwart $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "zend_exceptions.h"
+
+#ifdef PHP_WIN32
+# include "win32/php_stdint.h"
+# include "win32/signal.h"
+#else
+# include <stdint.h>
+# include <signal.h>
+#endif
+#include <amqp.h>
+#include <amqp_framing.h>
+
+#ifdef PHP_WIN32
+# include "win32/unistd.h"
+#else
+# include <unistd.h>
+#endif
+
+#include "php_amqp.h"
+#include "amqp_connection_resource.h"
+
+#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
+zend_object_handlers amqp_channel_object_handlers;
+HashTable *amqp_channel_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC) {
+ zval *value;
+ HashTable *debug_info;
+
+ /* Get the envelope object from which to read */
+ amqp_channel_object *channel = (amqp_channel_object *)zend_object_store_get_object(object TSRMLS_CC);
+
+ /* Let zend clean up for us: */
+ *is_temp = 1;
+
+ /* Keep the first number matching the number of entries in this table*/
+ ALLOC_HASHTABLE(debug_info);
+ ZEND_INIT_SYMTABLE_EX(debug_info, 4 + 1, 0);
+
+ /* Start adding values */
+ MAKE_STD_ZVAL(value);
+ ZVAL_LONG(value, channel->channel_id);
+ zend_hash_add(debug_info, "channel_id", sizeof("channel_id"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_LONG(value, channel->prefetch_count);
+ zend_hash_add(debug_info, "prefetch_count", sizeof("prefetch_count"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_LONG(value, channel->prefetch_size);
+ zend_hash_add(debug_info, "prefetch_size", sizeof("prefetch_size"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_BOOL(value, channel->is_connected);
+ zend_hash_add(debug_info, "is_connected", sizeof("is_connected"), &value, sizeof(zval *), NULL);
+
+ /* Start adding values */
+ return debug_info;
+}
+#endif
+
+void php_amqp_close_channel(amqp_channel_object *channel TSRMLS_DC)
+{
+ amqp_connection_object *connection;
+
+ assert(channel != NULL);
+
+ /* Pull out and verify the connection */
+ connection = AMQP_GET_CONNECTION(channel);
+
+ if (connection != NULL) {
+ /* First, remove it from active channels table to prevent recursion in case of connection error */
+ php_amqp_connection_resource_unregister_channel(connection->connection_resource, channel->channel_id);
+ } else {
+ channel->is_connected = '\0';
+ }
+
+ if (!channel->is_connected) {
+ /* Nothing to do more - channel was previously marked as closed, possibly, due to channel-level error */
+ return;
+ }
+
+ channel->is_connected = '\0';
+
+ if (connection->connection_resource && connection->connection_resource->is_connected) {
+ assert(connection->connection_resource != NULL);
+
+ amqp_channel_close(connection->connection_resource->connection_state, channel->channel_id, AMQP_REPLY_SUCCESS);
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+ }
+}
+
+
+void amqp_channel_dtor(void *object TSRMLS_DC)
+{
+ amqp_channel_object *channel = (amqp_channel_object*)object;
+
+ if (channel->is_connected) {
+ php_amqp_close_channel(channel TSRMLS_CC);
+ }
+
+ if (channel->connection != NULL) {
+ /* Destroy the connection storage */
+ zval_ptr_dtor(&channel->connection);
+ }
+
+ zend_object_std_dtor(&channel->zo TSRMLS_CC);
+
+ efree(object);
+}
+
+zend_object_value amqp_channel_ctor(zend_class_entry *ce TSRMLS_DC)
+{
+ zend_object_value new_value;
+ amqp_channel_object *channel = (amqp_channel_object*)emalloc(sizeof(amqp_channel_object));
+
+ memset(channel, 0, sizeof(amqp_channel_object));
+
+ zend_object_std_init(&channel->zo, ce TSRMLS_CC);
+ AMQP_OBJECT_PROPERTIES_INIT(channel->zo, ce);
+
+ new_value.handle = zend_objects_store_put(
+ channel,
+ (zend_objects_store_dtor_t)zend_objects_destroy_object,
+ (zend_objects_free_object_storage_t)amqp_channel_dtor,
+ NULL TSRMLS_CC
+ );
+
+#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
+ memcpy((void *)&amqp_channel_object_handlers, (void *)zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ amqp_channel_object_handlers.get_debug_info = amqp_channel_object_get_debug_info;
+ new_value.handlers = &amqp_channel_object_handlers;
+#else
+ new_value.handlers = zend_get_std_object_handlers();
+#endif
+
+ return new_value;
+}
+
+
+/* {{{ proto AMQPChannel::__construct(AMQPConnection obj)
+ */
+PHP_METHOD(amqp_channel_class, __construct)
+{
+ zval *id;
+ zval *connection_object = NULL;
+
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ /* Parse out the method parameters */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &id, amqp_channel_class_entry, &connection_object, amqp_connection_class_entry) == FAILURE) {
+ zend_throw_exception(amqp_channel_exception_class_entry, "Parameter must be an instance of AMQPConnection.", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+
+ channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);
+ channel->connection = connection_object;
+
+ Z_ADDREF_P(connection_object);
+
+ /* Set the prefetch count */
+ channel->prefetch_count = INI_INT("amqp.prefetch_count");
+
+ /* Pull out and verify the connection */
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not create channel.");
+
+ /* Figure out what the next available channel is on this connection */
+ channel->channel_id = php_amqp_connection_resource_get_available_channel_id(connection->connection_resource);
+
+ /* Check that we got a valid channel */
+ if (!channel->channel_id) {
+ zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. Connection has no open channel slots remaining.", 0 TSRMLS_CC);
+ return;
+ }
+
+ if (php_amqp_connection_resource_register_channel(connection->connection_resource, channel, channel->channel_id) == FAILURE) {
+ zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. Failed to add channel to connection slot.", 0 TSRMLS_CC);
+ }
+
+ /* Open up the channel for use */
+ amqp_channel_open_ok_t *r = amqp_channel_open(connection->connection_resource->connection_state, channel->channel_id);
+
+
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+
+ php_amqp_connection_resource_unregister_channel(connection->connection_resource, channel->channel_id);
+ channel->channel_id = 0;
+ return;
+ }
+
+ /* r->channel_id is a 16-bit channel number insibe amqp_bytes_t, assertion below will without converting to uint16_t*/
+ /* assert (r->channel_id == channel->channel_id);*/
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ channel->is_connected = '\1';
+
+ /* Set the prefetch count: */
+ amqp_basic_qos(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ 0, /* prefetch window size */
+ channel->prefetch_count, /* prefetch message count */
+ /* NOTE that RabbitMQ has reinterpreted global flag field. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.global for details */
+ 0 /* global flag */
+ );
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+}
+/* }}} */
+
+
+/* {{{ proto bool amqp::isConnected()
+check amqp channel */
+PHP_METHOD(amqp_channel_class, isConnected)
+{
+ zval *id;
+ amqp_channel_object *channel;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_channel_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the channel object out of the store */
+ channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* If the channel_connect is 1, we have a channel */
+ if (channel->is_connected == '\1') {
+ RETURN_TRUE;
+ }
+
+ /* We have no channel */
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto bool amqp::getChannelId()
+get amqp channel ID */
+PHP_METHOD(amqp_channel_class, getChannelId)
+{
+ zval *id;
+ amqp_channel_object *channel;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_channel_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the channel object out of the store */
+ channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_LONG(channel->channel_id);
+}
+/* }}} */
+
+/* {{{ proto bool amqp::setPrefetchCount(long count)
+set the number of prefetches */
+PHP_METHOD(amqp_channel_class, setPrefetchCount)
+{
+ zval *id;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+ long prefetch_count;
+
+ /* Get the vhost from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &id, amqp_channel_class_entry, &prefetch_count) == FAILURE) {
+ return;
+ }
+
+ /* Get the channel object out of the store */
+ channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not set prefetch count.");
+
+ /* If we are already connected, set the new prefetch count */
+ if (channel->is_connected) {
+ amqp_basic_qos(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ 0,
+ prefetch_count,
+ 0
+ );
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+ }
+
+ /* Set the prefetch count - the implication is to disable the size */
+ channel->prefetch_count = prefetch_count;
+ channel->prefetch_size = 0;
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto long amqp::setPrefetchCount()
+get the number of prefetches */
+PHP_METHOD(amqp_channel_class, getPrefetchCount)
+{
+ amqp_channel_object *channel;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "")) {
+ return;
+ }
+
+ channel = (amqp_channel_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ RETURN_LONG(channel->prefetch_count);
+}
+/* }}} */
+
+
+/* {{{ proto bool amqp::setPrefetchSize(long size)
+set the number of prefetches */
+PHP_METHOD(amqp_channel_class, setPrefetchSize)
+{
+ zval *id;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+ long prefetch_size;
+
+ /* Get the vhost from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &id, amqp_channel_class_entry, &prefetch_size) == FAILURE) {
+ return;
+ }
+
+ /* Get the channel object out of the store */
+ channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not set prefetch size.");
+
+ /* If we are already connected, set the new prefetch count */
+ if (channel->is_connected) {
+ amqp_basic_qos(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ prefetch_size,
+ 0,
+ 0
+ );
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+ }
+
+ /* Set the prefetch size - the implication is to disable the count */
+ channel->prefetch_count = 0;
+ channel->prefetch_size = prefetch_size;
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto long amqp::getPrefetchSize()
+get the number of prefetches */
+PHP_METHOD(amqp_channel_class, getPrefetchSize)
+{
+ amqp_channel_object *channel;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "")) {
+ return;
+ }
+
+ /* Get the channel object out of the store */
+ channel = (amqp_channel_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ RETURN_LONG(channel->prefetch_size);
+}
+/* }}} */
+
+
+
+/* {{{ proto amqp::qos(long size, long count)
+set the number of prefetches */
+PHP_METHOD(amqp_channel_class, qos)
+{
+ zval *id;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+ long prefetch_size;
+ long prefetch_count;
+
+ /* Get the vhost from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll", &id, amqp_channel_class_entry, &prefetch_size, &prefetch_count) == FAILURE) {
+ return;
+ }
+
+ /* Get the channel object out of the store */
+ channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Set the prefetch size - the implication is to disable the count */
+ channel->prefetch_size = prefetch_size;
+ channel->prefetch_count = prefetch_count;
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not set qos parameters.");
+
+ /* If we are already connected, set the new prefetch count */
+ if (channel->is_connected) {
+ amqp_basic_qos(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ channel->prefetch_size,
+ channel->prefetch_count,
+ /* NOTE that RabbitMQ has reinterpreted global flag field. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.global for details */
+ 0 /* Global flag - whether this change should affect every channel */
+ );
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto amqp::startTransaction()
+start a transaction on the given channel */
+PHP_METHOD(amqp_channel_class, startTransaction)
+{
+ zval *id;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ amqp_rpc_reply_t res;
+
+ /* Get the vhost from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_channel_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the channel object out of the store */
+ channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not start the transaction.");
+
+ amqp_tx_select(
+ connection->connection_resource->connection_state,
+ channel->channel_id
+ );
+
+ res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto amqp::startTransaction()
+start a transaction on the given channel */
+PHP_METHOD(amqp_channel_class, commitTransaction)
+{
+ zval *id;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ amqp_rpc_reply_t res;
+
+ /* Get the vhost from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_channel_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the channel object out of the store */
+ channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not start the transaction.");
+
+ amqp_tx_commit(
+ connection->connection_resource->connection_state,
+ channel->channel_id
+ );
+
+ res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto amqp::startTransaction()
+start a transaction on the given channel */
+PHP_METHOD(amqp_channel_class, rollbackTransaction)
+{
+ zval *id;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ amqp_rpc_reply_t res;
+
+ /* Get the vhost from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_channel_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the channel object out of the store */
+ channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not start the transaction.");
+
+ amqp_tx_rollback(
+ connection->connection_resource->connection_state,
+ channel->channel_id
+ );
+
+ res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto AMQPChannel::getConnection()
+Get the AMQPConnection object in use */
+PHP_METHOD(amqp_channel_class, getConnection)
+{
+ zval *id;
+ amqp_channel_object *channel;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_channel_class_entry) == FAILURE) {
+ return;
+ }
+
+ channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_ZVAL(channel->connection, 1, 0);
+}
+/* }}} */
+
+/* {{{ proto bool amqp::basicRecover([bool requeue=TRUE])
+Redeliver unacknowledged messages */
+PHP_METHOD(amqp_channel_class, basicRecover)
+{
+ zval *id;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ amqp_rpc_reply_t res;
+
+ zend_bool requeue = 1;
+
+ /* Get the vhost from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|b", &id, amqp_channel_class_entry, &requeue) == FAILURE) {
+ return;
+ }
+
+ /* Get the channel object out of the store */
+ channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not redeliver unacknowledged messages.");
+
+ amqp_basic_recover(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ (amqp_boolean_t) requeue
+ );
+
+ res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_TRUE;
+
+}
+/* }}} */
+
+/*
+*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/amqp-1.6.1/amqp_channel.h b/amqp-1.6.1/amqp_channel.h
new file mode 100644
index 0000000..4f77159
--- /dev/null
+++ b/amqp-1.6.1/amqp_channel.h
@@ -0,0 +1,54 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: amqp_channel.h 305865 2010-12-01 01:30:56Z pdezwart $ */
+
+void php_amqp_close_channel(amqp_channel_object *channel TSRMLS_DC);
+void amqp_channel_dtor(void *object TSRMLS_DC);
+zend_object_value amqp_channel_ctor(zend_class_entry *ce TSRMLS_DC);
+
+PHP_METHOD(amqp_channel_class, __construct);
+PHP_METHOD(amqp_channel_class, isConnected);
+PHP_METHOD(amqp_channel_class, getChannelId);
+PHP_METHOD(amqp_channel_class, setPrefetchSize);
+PHP_METHOD(amqp_channel_class, getPrefetchSize);
+PHP_METHOD(amqp_channel_class, setPrefetchCount);
+PHP_METHOD(amqp_channel_class, getPrefetchCount);
+PHP_METHOD(amqp_channel_class, qos);
+
+PHP_METHOD(amqp_channel_class, startTransaction);
+PHP_METHOD(amqp_channel_class, commitTransaction);
+PHP_METHOD(amqp_channel_class, rollbackTransaction);
+
+PHP_METHOD(amqp_channel_class, getConnection);
+
+PHP_METHOD(amqp_channel_class, basicRecover);
+
+/*
+*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/amqp-1.6.1/amqp_connection.c b/amqp-1.6.1/amqp_connection.c
new file mode 100644
index 0000000..a325e44
--- /dev/null
+++ b/amqp-1.6.1/amqp_connection.c
@@ -0,0 +1,1444 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: amqp_connection.c 327551 2012-09-09 03:49:34Z pdezwart $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "zend_exceptions.h"
+
+#ifdef PHP_WIN32
+# include "win32/php_stdint.h"
+# include "win32/signal.h"
+#else
+# include <signal.h>
+# include <stdint.h>
+#endif
+#include <amqp.h>
+#include <amqp_framing.h>
+#include <amqp_tcp_socket.h>
+
+#ifdef PHP_WIN32
+# include "win32/unistd.h"
+#else
+# include <unistd.h>
+#endif
+
+#include "php_amqp.h"
+#include "amqp_channel.h"
+#include "amqp_connection_resource.h"
+
+#ifndef E_DEPRECATED
+#define E_DEPRECATED E_WARNING
+#endif
+
+#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
+zend_object_handlers amqp_connection_object_handlers;
+HashTable *amqp_connection_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC) {
+ zval *value;
+ HashTable *debug_info;
+ amqp_connection_object *connection;
+
+ /* Let zend clean up for us: */
+ *is_temp = 1;
+
+ /* Get the envelope object from which to read */
+ connection = (amqp_connection_object *)zend_object_store_get_object(object TSRMLS_CC);
+
+ /* Keep the first number matching the number of entries in this table*/
+ ALLOC_HASHTABLE(debug_info);
+ ZEND_INIT_SYMTABLE_EX(debug_info, 15 + 1, 0);
+
+ /* Start adding values */
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, connection->login, strlen(connection->login), 1);
+ zend_hash_add(debug_info, "login", sizeof("login"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, connection->password, strlen(connection->password), 1);
+ zend_hash_add(debug_info, "password", sizeof("password"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, connection->host, strlen(connection->host), 1);
+ zend_hash_add(debug_info, "host", sizeof("host"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, connection->vhost, strlen(connection->vhost), 1);
+ zend_hash_add(debug_info, "vhost", sizeof("vhost"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_LONG(value, connection->port);
+ zend_hash_add(debug_info, "port", sizeof("port"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_DOUBLE(value, connection->read_timeout);
+ zend_hash_add(debug_info, "read_timeout", sizeof("read_timeout"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_DOUBLE(value, connection->write_timeout);
+ zend_hash_add(debug_info, "write_timeout", sizeof("write_timeout"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_DOUBLE(value, connection->connect_timeout);
+ zend_hash_add(debug_info, "connect_timeout", sizeof("connect_timeout"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_BOOL(value, connection->is_connected);
+ zend_hash_add(debug_info, "is_connected", sizeof("is_connected"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_BOOL(value, connection->is_persistent);
+ zend_hash_add(debug_info, "is_persistent", sizeof("is_persistent"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+
+ if (connection && connection->connection_resource) {
+ ZVAL_RESOURCE(value, connection->connection_resource->resource_id);
+ zend_list_addref(connection->connection_resource->resource_id);
+ } else {
+ ZVAL_NULL(value);
+ }
+ zend_hash_add(debug_info, "connection_resource", sizeof("connection_resource"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ if (connection->connection_resource) {
+ ZVAL_LONG(value, connection->connection_resource->used_slots);
+ } else {
+ ZVAL_NULL(value);
+ }
+ zend_hash_add(debug_info, "used_channels", sizeof("used_channels"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ if (connection->connection_resource) {
+ ZVAL_LONG(value, amqp_get_channel_max(connection->connection_resource->connection_state));
+ } else {
+ ZVAL_NULL(value);
+ }
+ zend_hash_add(debug_info, "max_channel_id", sizeof("max_channel_id"), &value, sizeof(zval *), NULL);
+
+#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH > 52
+ MAKE_STD_ZVAL(value);
+ if (connection->connection_resource) {
+ ZVAL_LONG(value, amqp_get_frame_max(connection->connection_resource->connection_state));
+ } else {
+ ZVAL_NULL(value);
+ }
+ zend_hash_add(debug_info, "max_frame_size", sizeof("max_frame_size"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ if (connection->connection_resource) {
+ ZVAL_LONG(value, amqp_get_heartbeat(connection->connection_resource->connection_state));
+ } else {
+ ZVAL_NULL(value);
+ }
+ zend_hash_add(debug_info, "heartbeat_interval", sizeof("heartbeat_interval"), &value, sizeof(zval *), NULL);
+#endif
+
+ /* Start adding values */
+ return debug_info;
+}
+#endif
+
+
+static void php_amqp_prepare_for_disconnect(amqp_connection_object *connection TSRMLS_DC)
+{
+ amqp_channel_object *channel;
+
+ /* Pull the connection resource out for easy access */
+ amqp_connection_resource *resource = connection->connection_resource;
+
+ if (!resource) {
+ return;
+ }
+
+ assert(resource->slots != NULL);
+
+ /* NOTE: when we have persistent connection we do not move channels between php requests
+ * due to current php-amqp extension limitation in AMQPChannel where __construct == channel.open AMQP method call
+ * and __destruct = channel.close AMQP method call
+ */
+
+ /* Clean up old memory allocations which are now invalid (new connection) */
+ amqp_channel_t slot;
+
+ for (slot = 0; slot < resource->max_slots; slot++) {
+ if (resource->slots[slot] != 0) {
+ php_amqp_close_channel(resource->slots[slot] TSRMLS_CC);
+ }
+ }
+
+ /* If it's persistent connection do not destroy connection resource (this keep connection alive) */
+ if (connection->is_persistent) {
+ /* Cleanup buffers to reduce memory usage in idle mode */
+ amqp_maybe_release_buffers(resource->connection_state);
+ }
+
+ return;
+}
+
+void php_amqp_disconnect_safe(amqp_connection_object *connection TSRMLS_DC)
+{
+ php_amqp_prepare_for_disconnect(connection TSRMLS_CC);
+
+ if (connection->is_persistent) {
+ connection->connection_resource->resource_id = 0;
+ }
+
+ if(connection->connection_resource && connection->connection_resource->resource_id > 0) {
+ zend_list_delete(connection->connection_resource->resource_id);
+ }
+
+ /* Mark connection as closed */
+ connection->connection_resource = NULL;
+ connection->is_connected = '\0';
+ connection->is_persistent = '\0';
+}
+
+void php_amqp_disconnect_force(amqp_connection_object *connection TSRMLS_DC)
+{
+ php_amqp_prepare_for_disconnect(connection TSRMLS_CC);
+
+ if(connection->connection_resource) {
+
+ if (connection->connection_resource->resource_id > 0) {
+ zend_list_delete(connection->connection_resource->resource_id);
+ }
+
+ if (connection->is_persistent) {
+ zend_rsrc_list_entry *le;
+
+ if (zend_hash_find(&EG(persistent_list), connection->connection_resource->resource_key, connection->connection_resource->resource_key_len + 1, (void **)&le) == SUCCESS) {
+ if (Z_TYPE_P(le) == le_amqp_connection_resource_persistent) {
+ zend_hash_del(&EG(persistent_list), connection->connection_resource->resource_key, connection->connection_resource->resource_key_len + 1);
+ }
+ }
+ }
+ }
+
+ /* Mark connection as closed */
+ connection->connection_resource = NULL;
+ connection->is_connected = '\0';
+ connection->is_persistent = '\0';
+}
+
+/**
+ * php_amqp_connect
+ * handles connecting to amqp
+ * called by connect(), pconnect(), reconnect(), preconnect()
+ */
+int php_amqp_connect(amqp_connection_object *connection, int persistent TSRMLS_DC)
+{
+ char *key;
+ int key_len;
+
+ /* Clean up old memory allocations which are now invalid (new connection) */
+ assert(connection->connection_resource == NULL);
+ assert(!connection->is_connected);
+
+ if (persistent) {
+ zend_rsrc_list_entry *le;
+ /* Look for an established resource */
+ key_len = spprintf(&key, 0,
+ "amqp_conn_res_%s_%d_%s_%s_%s_%d_%d_%d",
+ connection->host,
+ connection->port,
+ connection->vhost,
+ connection->login,
+ connection->password,
+ connection->frame_max,
+ connection->channel_max,
+ connection->heartbeat
+ );
+
+ if (zend_hash_find(&EG(persistent_list), key, key_len + 1, (void **)&le) == SUCCESS) {
+ efree(key);
+
+ if (Z_TYPE_P(le) != le_amqp_connection_resource_persistent) {
+ /* hash conflict, given name associate with non-amqp persistent connection resource */
+ return 0;
+ }
+
+ /* An entry for this connection resource already exists */
+ /* Stash the connection resource in the connection */
+ connection->connection_resource = le->ptr;
+
+ if (connection->connection_resource->resource_id > 0) {
+ /* resource in use! */
+ connection->connection_resource = NULL;
+
+ zend_throw_exception(amqp_connection_exception_class_entry, "There are already established persistent connection to the same resource.", 0 TSRMLS_CC);
+ return 0;
+ }
+
+ connection->connection_resource->resource_id = ZEND_REGISTER_RESOURCE(NULL, connection->connection_resource, persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource);
+
+ /* Set desired timeouts */
+ if (php_amqp_set_resource_read_timeout(connection->connection_resource, connection->read_timeout TSRMLS_CC) == 0
+ || php_amqp_set_resource_write_timeout(connection->connection_resource, connection->write_timeout TSRMLS_CC) == 0) {
+
+ php_amqp_disconnect_force(connection TSRMLS_CC);
+
+ connection->connection_resource = NULL;
+ return 0;
+ }
+
+
+ /* Set connection status to connected */
+ connection->is_connected = '\1';
+ connection->is_persistent = persistent;
+
+ return 1;
+ }
+
+ efree(key);
+ }
+
+ connection->connection_resource = connection_resource_constructor(connection, persistent TSRMLS_CC);
+
+ if (!connection->connection_resource) {
+ return 0;
+ }
+
+ connection->connection_resource->resource_id = ZEND_REGISTER_RESOURCE(NULL, connection->connection_resource, persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource);
+
+ /* Set connection status to connected */
+ connection->is_connected = '\1';
+
+ if (persistent) {
+ zend_rsrc_list_entry new_le;
+
+ connection->is_persistent = persistent;
+
+ key_len = spprintf(&key, 0,
+ "amqp_conn_res_%s_%d_%s_%s_%s_%d_%d_%d",
+ connection->host,
+ connection->port,
+ connection->vhost,
+ connection->login,
+ connection->password,
+ connection->frame_max,
+ connection->channel_max,
+ connection->heartbeat
+ );
+
+ connection->connection_resource->resource_key = pestrndup(key, key_len, persistent);
+ connection->connection_resource->resource_key_len = key_len;
+
+ efree(key);
+
+ /* Store a reference in the persistence list */
+ new_le.ptr = connection->connection_resource;
+ new_le.type = persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource;
+
+ if (FAILURE == zend_hash_add(&EG(persistent_list), connection->connection_resource->resource_key, connection->connection_resource->resource_key_len + 1, &new_le, sizeof(zend_rsrc_list_entry), NULL)) {
+ php_amqp_disconnect_force(connection TSRMLS_CC);
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+void amqp_connection_dtor(void *object TSRMLS_DC)
+{
+ amqp_connection_object *connection = (amqp_connection_object*)object;
+
+ php_amqp_disconnect_safe(connection TSRMLS_CC);
+
+ assert(connection->connection_resource == NULL);
+
+ /* Clean up all the strings */
+ if (connection->host) {
+ efree(connection->host);
+ }
+
+ if (connection->vhost) {
+ efree(connection->vhost);
+ }
+
+ if (connection->login) {
+ efree(connection->login);
+ }
+
+ if (connection->password) {
+ efree(connection->password);
+ }
+
+ zend_object_std_dtor(&connection->zo TSRMLS_CC);
+
+ efree(object);
+}
+
+zend_object_value amqp_connection_ctor(zend_class_entry *ce TSRMLS_DC)
+{
+ zend_object_value new_value;
+
+ amqp_connection_object* connection = (amqp_connection_object*)emalloc(sizeof(amqp_connection_object));
+ memset(connection, 0, sizeof(amqp_connection_object));
+
+ zend_object_std_init(&connection->zo, ce TSRMLS_CC);
+ AMQP_OBJECT_PROPERTIES_INIT(connection->zo, ce);
+
+ new_value.handle = zend_objects_store_put(
+ connection,
+ (zend_objects_store_dtor_t)zend_objects_destroy_object,
+ (zend_objects_free_object_storage_t)amqp_connection_dtor,
+ NULL TSRMLS_CC
+ );
+
+#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
+ memcpy((void *)&amqp_connection_object_handlers, (void *)zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ amqp_connection_object_handlers.get_debug_info = amqp_connection_object_get_debug_info;
+ new_value.handlers = &amqp_connection_object_handlers;
+#else
+ new_value.handlers = zend_get_std_object_handlers();
+#endif
+ return new_value;
+}
+
+
+/* {{{ proto AMQPConnection::__construct([array optional])
+ * The array can contain 'host', 'port', 'login', 'password', 'vhost', 'read_timeout', 'write_timeout', 'connect_timeout' and 'timeout' (deprecated) indexes
+ */
+PHP_METHOD(amqp_connection_class, __construct)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ zval* ini_arr = NULL;
+ zval** zdata;
+
+ /* Parse out the method parameters */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|a", &id, amqp_connection_class_entry, &ini_arr) == FAILURE) {
+ return;
+ }
+
+ /* Pull the connection off of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Pull the login out of the $params array */
+ zdata = NULL;
+ if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "login", sizeof("login"), (void*)&zdata)) {
+ convert_to_string(*zdata);
+ }
+ /* Validate the given login */
+ if (zdata && Z_STRLEN_PP(zdata) > 0) {
+ if (Z_STRLEN_PP(zdata) < 128) {
+ connection->login = estrndup(Z_STRVAL_PP(zdata), Z_STRLEN_PP(zdata));
+ } else {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'login' exceeds 128 character limit.", 0 TSRMLS_CC);
+ return;
+ }
+ } else {
+ connection->login = estrndup(INI_STR("amqp.login"), strlen(INI_STR("amqp.login")) > 128 ? 128 : strlen(INI_STR("amqp.login")));
+ }
+
+ /* Pull the password out of the $params array */
+ zdata = NULL;
+ if (ini_arr && SUCCESS == zend_hash_find(HASH_OF(ini_arr), "password", sizeof("password"), (void*)&zdata)) {
+ convert_to_string(*zdata);
+ }
+ /* Validate the given password */
+ if (zdata && Z_STRLEN_PP(zdata) > 0) {
+ if (Z_STRLEN_PP(zdata) < 128) {
+ connection->password = estrndup(Z_STRVAL_PP(zdata), Z_STRLEN_PP(zdata));
+ } else {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'password' exceeds 128 character limit.", 0 TSRMLS_CC);
+ return;
+ }
+ } else {
+ connection->password = estrndup(INI_STR("amqp.password"), strlen(INI_STR("amqp.password")) > 128 ? 128 : strlen(INI_STR("amqp.password")));
+ }
+
+ /* Pull the host out of the $params array */
+ zdata = NULL;
+ if (ini_arr && SUCCESS == zend_hash_find(HASH_OF(ini_arr), "host", sizeof("host"), (void *)&zdata)) {
+ convert_to_string(*zdata);
+ }
+ /* Validate the given host */
+ if (zdata && Z_STRLEN_PP(zdata) > 0) {
+ if (Z_STRLEN_PP(zdata) < 128) {
+ connection->host = estrndup(Z_STRVAL_PP(zdata), Z_STRLEN_PP(zdata));
+ } else {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'host' exceeds 128 character limit.", 0 TSRMLS_CC);
+ return;
+ }
+ } else {
+ connection->host = estrndup(INI_STR("amqp.host"), strlen(INI_STR("amqp.host")) > 128 ? 128 : strlen(INI_STR("amqp.host")));
+ }
+
+ /* Pull the vhost out of the $params array */
+ zdata = NULL;
+ if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "vhost", sizeof("vhost"), (void*)&zdata)) {
+ convert_to_string(*zdata);
+ }
+ /* Validate the given vhost */
+ if (zdata && Z_STRLEN_PP(zdata) > 0) {
+ if (Z_STRLEN_PP(zdata) < 128) {
+ connection->vhost = estrndup(Z_STRVAL_PP(zdata), Z_STRLEN_PP(zdata));
+ } else {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'vhost' exceeds 128 character limit.", 0 TSRMLS_CC);
+ return;
+ }
+ } else {
+ connection->vhost = estrndup(INI_STR("amqp.vhost"), strlen(INI_STR("amqp.vhost")) > 128 ? 128 : strlen(INI_STR("amqp.vhost")));
+ }
+
+ connection->port = INI_INT("amqp.port");
+
+ if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "port", sizeof("port"), (void*)&zdata)) {
+ convert_to_long(*zdata);
+ connection->port = (size_t)Z_LVAL_PP(zdata);
+ }
+
+ connection->read_timeout = INI_FLT("amqp.read_timeout");
+
+ if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "read_timeout", sizeof("read_timeout"), (void*)&zdata)) {
+ convert_to_double(*zdata);
+ if (Z_DVAL_PP(zdata) < 0) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'read_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
+ } else {
+ connection->read_timeout = Z_DVAL_PP(zdata);
+ }
+
+ if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "timeout", sizeof("timeout"), (void*)&zdata)) {
+ /* 'read_timeout' takes precedence on 'timeout' but users have to know this */
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter 'timeout' is deprecated, 'read_timeout' used instead");
+ }
+
+ } else if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "timeout", sizeof("timeout"), (void*)&zdata)) {
+
+ php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "Parameter 'timeout' is deprecated; use 'read_timeout' instead");
+
+ convert_to_double(*zdata);
+ if (Z_DVAL_PP(zdata) < 0) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
+ } else {
+ connection->read_timeout = Z_DVAL_PP(zdata);
+ }
+ } else {
+
+ assert(DEFAULT_TIMEOUT != NULL);
+ if (strcmp(DEFAULT_TIMEOUT, INI_STR("amqp.timeout")) != 0) {
+ php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "INI setting 'amqp.timeout' is deprecated; use 'amqp.read_timeout' instead");
+
+ if (strcmp(DEFAULT_READ_TIMEOUT, INI_STR("amqp.read_timeout")) == 0) {
+ connection->read_timeout = INI_FLT("amqp.timeout");
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "INI setting 'amqp.read_timeout' will be used instead of 'amqp.timeout'");
+ connection->read_timeout = INI_FLT("amqp.read_timeout");
+ }
+ } else {
+ connection->read_timeout = INI_FLT("amqp.read_timeout");
+ }
+ }
+
+ connection->write_timeout = INI_FLT("amqp.write_timeout");
+
+ if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "write_timeout", sizeof("write_timeout"), (void*)&zdata)) {
+ convert_to_double(*zdata);
+ if (Z_DVAL_PP(zdata) < 0) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'write_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
+ } else {
+ connection->write_timeout = Z_DVAL_PP(zdata);
+ }
+ }
+
+ connection->connect_timeout = INI_FLT("amqp.connect_timeout");
+
+ if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "connect_timeout", sizeof("connect_timeout"), (void*)&zdata)) {
+ convert_to_double(*zdata);
+ if (Z_DVAL_PP(zdata) < 0) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'connect_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
+ } else {
+ connection->connect_timeout = Z_DVAL_PP(zdata);
+ }
+ }
+
+ connection->channel_max = (int) INI_INT("amqp.channel_max");
+
+ if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "channel_max", sizeof("channel_max"), (void*)&zdata)) {
+ convert_to_long(*zdata);
+ if (Z_LVAL_PP(zdata) < 0 || Z_LVAL_PP(zdata) > PHP_AMQP_MAX_CHANNELS) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'channel_max' is out of range.", 0 TSRMLS_CC);
+ } else {
+ connection->channel_max = (int) Z_LVAL_PP(zdata);
+ if(connection->channel_max == 0) {
+ connection->channel_max = PHP_AMQP_DEFAULT_CHANNEL_MAX;
+ }
+
+ }
+ }
+
+ connection->frame_max = (int) INI_INT("amqp.frame_max");
+
+ if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "frame_max", sizeof("frame_max"), (void*)&zdata)) {
+ convert_to_long(*zdata);
+ if (Z_LVAL_PP(zdata) < 0 || Z_LVAL_PP(zdata) > PHP_AMQP_MAX_FRAME) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'frame_max' is out of range.", 0 TSRMLS_CC);
+ } else {
+ connection->frame_max = (int) Z_LVAL_PP(zdata);
+ if(connection->frame_max == 0) {
+ connection->frame_max = PHP_AMQP_DEFAULT_FRAME_MAX;
+ }
+ }
+ }
+
+ connection->heartbeat = (int) INI_INT("amqp.heartbeat");
+
+ if (ini_arr && SUCCESS == zend_hash_find(HASH_OF (ini_arr), "heartbeat", sizeof("heartbeat"), (void*)&zdata)) {
+ convert_to_long(*zdata);
+ if (Z_LVAL_PP(zdata) < 0 || Z_LVAL_PP(zdata) > PHP_AMQP_MAX_HEARTBEAT) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'heartbeat' is out of range.", 0 TSRMLS_CC);
+ } else {
+ connection->heartbeat = (int) Z_LVAL_PP(zdata);
+ }
+ }
+
+}
+/* }}} */
+
+
+/* {{{ proto amqp::isConnected()
+check amqp connection */
+PHP_METHOD(amqp_connection_class, isConnected)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* If the channel_connect is 1, we have a connection */
+ if (connection->is_connected == '\1') {
+ RETURN_TRUE;
+ }
+
+ /* We have no connection */
+ RETURN_FALSE;
+}
+/* }}} */
+
+
+/* {{{ proto amqp::connect()
+create amqp connection */
+PHP_METHOD(amqp_connection_class, connect)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ if (connection->is_connected) {
+
+ assert(connection->connection_resource != NULL);
+ if (connection->is_persistent) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to start transient connection while persistent transient one already established. Continue.");
+ }
+
+ RETURN_TRUE;
+ }
+
+ /* Actually connect this resource to the broker */
+ RETURN_BOOL(php_amqp_connect(connection, 0 TSRMLS_CC));
+}
+/* }}} */
+
+
+/* {{{ proto amqp::connect()
+create amqp connection */
+PHP_METHOD(amqp_connection_class, pconnect)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ if (connection->is_connected) {
+
+ assert(connection->connection_resource != NULL);
+ if (!connection->is_persistent) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to start persistent connection while transient one already established. Continue.");
+ }
+
+ RETURN_TRUE;
+ }
+
+ /* Actually connect this resource to the broker or use stored connection */
+ RETURN_BOOL(php_amqp_connect(connection, 1 TSRMLS_CC));
+}
+/* }}} */
+
+
+/* {{{ proto amqp:pdisconnect()
+destroy amqp persistent connection */
+PHP_METHOD(amqp_connection_class, pdisconnect)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ if (!connection->is_connected) {
+ RETURN_TRUE;
+ }
+
+ assert(connection->connection_resource != NULL);
+
+ if (!connection->is_persistent) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to close persistent connection while transient one already established. Abort.");
+
+ RETURN_FALSE;
+ }
+
+ php_amqp_disconnect_force(connection TSRMLS_CC);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto amqp::disconnect()
+destroy amqp connection */
+PHP_METHOD(amqp_connection_class, disconnect)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ if (!connection->is_connected) {
+ RETURN_TRUE;
+ }
+
+ if (connection->is_persistent) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to close transient connection while persistent one already established. Abort.");
+
+ RETURN_FALSE;
+ }
+
+ assert(connection->connection_resource != NULL);
+
+ php_amqp_disconnect_safe(connection TSRMLS_CC);
+
+ RETURN_TRUE;
+}
+
+/* }}} */
+
+/* {{{ proto amqp::reconnect()
+recreate amqp connection */
+PHP_METHOD(amqp_connection_class, reconnect)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ if (connection->is_connected == '\1') {
+
+ assert(connection->connection_resource != NULL);
+
+ if (connection->is_persistent) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to reconnect persistent connection while transient one already established. Abort.");
+
+ RETURN_FALSE;
+ }
+
+ php_amqp_disconnect_safe(connection TSRMLS_CC);
+ }
+
+ RETURN_BOOL(php_amqp_connect(connection, 0 TSRMLS_CC));
+}
+/* }}} */
+
+/* {{{ proto amqp::preconnect()
+recreate amqp connection */
+PHP_METHOD(amqp_connection_class, preconnect)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+
+ if (connection->is_connected == '\1') {
+
+ assert(connection->connection_resource != NULL);
+
+ if (!connection->is_persistent) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to reconnect transient connection while persistent one already established. Abort.");
+
+ RETURN_FALSE;
+ }
+
+ php_amqp_disconnect_force(connection TSRMLS_CC);
+ }
+
+ RETURN_BOOL(php_amqp_connect(connection, 1 TSRMLS_CC));
+}
+/* }}} */
+
+
+/* {{{ proto amqp::getLogin()
+get the login */
+PHP_METHOD(amqp_connection_class, getLogin)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Get the login from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Copy the login to the amqp object */
+ RETURN_STRING(connection->login, 1);
+}
+/* }}} */
+
+
+/* {{{ proto amqp::setLogin(string login)
+set the login */
+PHP_METHOD(amqp_connection_class, setLogin)
+{
+ zval *id;
+ amqp_connection_object *connection;
+ char *login;
+ int login_len;
+
+ /* Get the login from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, amqp_connection_class_entry, &login, &login_len) == FAILURE) {
+ return;
+ }
+
+ /* Validate login length */
+ if (login_len > 128) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'login' given, exceeds 128 characters limit.", 0 TSRMLS_CC);
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Free previously existing login, in cases where setLogin() is called multiple times */
+ if (connection->login) {
+ efree(connection->login);
+ }
+
+ /* Copy the login to the amqp object */
+ connection->login = estrndup(login, login_len);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto amqp::getPassword()
+get the password */
+PHP_METHOD(amqp_connection_class, getPassword)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Get the password from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Copy the password to the amqp object */
+ RETURN_STRING(connection->password, 1);
+}
+/* }}} */
+
+
+/* {{{ proto amqp::setPassword(string password)
+set the password */
+PHP_METHOD(amqp_connection_class, setPassword)
+{
+ zval *id;
+ amqp_connection_object *connection;
+ char *password;
+ int password_len;
+
+ /* Get the password from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, amqp_connection_class_entry, &password, &password_len) == FAILURE) {
+ return;
+ }
+
+ /* Validate password length */
+ if (password_len > 128) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'password' given, exceeds 128 characters limit.", 0 TSRMLS_CC);
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Free previously existing password, in cases where setPassword() is called multiple times */
+ if (connection->password) {
+ efree(connection->password);
+ }
+
+ /* Copy the password to the amqp object */
+ connection->password = estrndup(password, password_len);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto amqp::getHost()
+get the host */
+PHP_METHOD(amqp_connection_class, getHost)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Get the host from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Copy the host to the amqp object */
+ RETURN_STRING(connection->host, 1);
+}
+/* }}} */
+
+
+/* {{{ proto amqp::setHost(string host)
+set the host */
+PHP_METHOD(amqp_connection_class, setHost)
+{
+ zval *id;
+ amqp_connection_object *connection;
+ char *host;
+ int host_len;
+
+ /* Get the host from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, amqp_connection_class_entry, &host, &host_len) == FAILURE) {
+ return;
+ }
+
+ /* Validate host length */
+ if (host_len > 1024) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'host' given, exceeds 1024 character limit.", 0 TSRMLS_CC);
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Free previously existing host, in cases where setHost() is called multiple times */
+ if (connection->host) {
+ efree(connection->host);
+ }
+
+ /* Copy the host to the amqp object */
+ connection->host = estrndup(host, host_len);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto amqp::getPort()
+get the port */
+PHP_METHOD(amqp_connection_class, getPort)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Get the port from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Copy the port to the amqp object */
+ RETURN_LONG(connection->port);
+}
+/* }}} */
+
+
+/* {{{ proto amqp::setPort(mixed port)
+set the port */
+PHP_METHOD(amqp_connection_class, setPort)
+{
+ zval *id;
+ amqp_connection_object *connection;
+ zval *zvalPort;
+ int port;
+
+ /* Get the port from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz", &id, amqp_connection_class_entry, &zvalPort) == FAILURE) {
+ return;
+ }
+
+ /* Parse out the port*/
+ switch (Z_TYPE_P(zvalPort)) {
+ case IS_DOUBLE:
+ port = (int)Z_DVAL_P(zvalPort);
+ break;
+ case IS_LONG:
+ port = (int)Z_LVAL_P(zvalPort);
+ break;
+ case IS_STRING:
+ convert_to_long(zvalPort);
+ port = (int)Z_LVAL_P(zvalPort);
+ break;
+ default:
+ port = 0;
+ }
+
+ /* Check the port value */
+ if (port <= 0 || port > 65535) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Invalid port given. Value must be between 1 and 65535.", 0 TSRMLS_CC);
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Copy the port to the amqp object */
+ connection->port = port;
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto amqp::getVhost()
+get the vhost */
+PHP_METHOD(amqp_connection_class, getVhost)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Get the vhost from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Copy the vhost to the amqp object */
+ RETURN_STRING(connection->vhost, 1);
+}
+/* }}} */
+
+
+/* {{{ proto amqp::setVhost(string vhost)
+set the vhost */
+PHP_METHOD(amqp_connection_class, setVhost)
+{
+ zval *id;
+ amqp_connection_object *connection;
+ char *vhost;
+ int vhost_len;
+
+ /* Get the vhost from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, amqp_connection_class_entry, &vhost, &vhost_len) == FAILURE) {
+ return;
+ }
+
+ /* Validate vhost length */
+ if (vhost_len > 128) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'vhost' exceeds 128 characters limit.", 0 TSRMLS_CC);
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Free previously existing vhost, in cases where setVhost() is called multiple times */
+ if (connection->vhost) {
+ efree(connection->vhost);
+ }
+
+ /* Copy the vhost to the amqp object */
+ connection->vhost = estrndup(vhost, vhost_len);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto amqp::getTimeout()
+@deprecated
+get the timeout */
+PHP_METHOD(amqp_connection_class, getTimeout)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead");
+
+ /* Get the timeout from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Copy the timeout to the amqp object */
+ RETURN_DOUBLE(connection->read_timeout);
+}
+/* }}} */
+
+/* {{{ proto amqp::setTimeout(double timeout)
+@deprecated
+set the timeout */
+PHP_METHOD(amqp_connection_class, setTimeout)
+{
+ zval *id;
+ amqp_connection_object *connection;
+ double read_timeout;
+
+ php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead");
+
+ /* Get the timeout from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &id, amqp_connection_class_entry, &read_timeout) == FAILURE) {
+ return;
+ }
+
+ /* Validate timeout */
+ if (read_timeout < 0) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Copy the timeout to the amqp object */
+ connection->read_timeout = read_timeout;
+
+ if (connection->is_connected == '\1') {
+ if (php_amqp_set_resource_read_timeout(connection->connection_resource, connection->read_timeout TSRMLS_CC) == 0) {
+
+ php_amqp_disconnect_force(connection TSRMLS_CC);
+ RETURN_FALSE;
+ }
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto amqp::getReadTimeout()
+get the read timeout */
+PHP_METHOD(amqp_connection_class, getReadTimeout)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Get the timeout from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Copy the timeout to the amqp object */
+ RETURN_DOUBLE(connection->read_timeout);
+}
+/* }}} */
+
+/* {{{ proto amqp::setReadTimeout(double timeout)
+set read timeout */
+PHP_METHOD(amqp_connection_class, setReadTimeout)
+{
+ zval *id;
+ amqp_connection_object *connection;
+ double read_timeout;
+
+ /* Get the timeout from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &id, amqp_connection_class_entry, &read_timeout) == FAILURE) {
+ return;
+ }
+
+ /* Validate timeout */
+ if (read_timeout < 0) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'read_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Copy the timeout to the amqp object */
+ connection->read_timeout = read_timeout;
+
+ if (connection->is_connected == '\1') {
+ if (php_amqp_set_resource_read_timeout(connection->connection_resource, connection->read_timeout TSRMLS_CC) == 0) {
+ php_amqp_disconnect_force(connection TSRMLS_CC);
+
+ RETURN_FALSE;
+ }
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto amqp::getWriteTimeout()
+get write timeout */
+PHP_METHOD(amqp_connection_class, getWriteTimeout)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Get the timeout from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Copy the timeout to the amqp object */
+ RETURN_DOUBLE(connection->write_timeout);
+}
+/* }}} */
+
+/* {{{ proto amqp::setWriteTimeout(double timeout)
+set write timeout */
+PHP_METHOD(amqp_connection_class, setWriteTimeout)
+{
+ zval *id;
+ amqp_connection_object *connection;
+ double write_timeout;
+
+ /* Get the timeout from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &id, amqp_connection_class_entry, &write_timeout) == FAILURE) {
+ return;
+ }
+
+ /* Validate timeout */
+ if (write_timeout < 0) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'write_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Copy the timeout to the amqp object */
+ connection->write_timeout = write_timeout;
+
+ if (connection->is_connected == '\1') {
+ if (php_amqp_set_resource_write_timeout(connection->connection_resource, connection->write_timeout TSRMLS_CC) == 0) {
+
+ php_amqp_disconnect_force(connection TSRMLS_CC);
+ RETURN_FALSE;
+ }
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto amqp::getUsedChannels()
+Get max used channels number */
+PHP_METHOD(amqp_connection_class, getUsedChannels)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ /* Get the timeout from the method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ if (!connection->is_connected) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Connection is not connected.");
+
+ RETURN_LONG(0);
+ }
+
+ RETURN_LONG(connection->connection_resource->used_slots);
+}
+/* }}} */
+
+/* {{{ proto amqp::getMaxChannels()
+Get max supported channels number per connection */
+PHP_METHOD(amqp_connection_class, getMaxChannels)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ if (!connection->is_connected) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Connection is not connected.");
+
+ RETURN_NULL();
+ }
+
+ RETURN_LONG(connection->connection_resource->max_slots);
+}
+/* }}} */
+
+#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH > 52
+/* {{{ proto amqp::getMaxFrameSize()
+Get max supported frame size per connection in bytes */
+PHP_METHOD(amqp_connection_class, getMaxFrameSize)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ if (!connection->is_connected) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Connection is not connected.");
+
+ RETURN_NULL();
+ }
+
+ RETURN_LONG(amqp_get_frame_max(connection->connection_resource->connection_state));
+}
+/* }}} */
+
+/* {{{ proto amqp::getHeartbeatInterval()
+Get number of seconds between heartbeats of the connection in seconds */
+PHP_METHOD(amqp_connection_class, getHeartbeatInterval)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ if (!connection->is_connected) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Connection is not connected.");
+
+ RETURN_NULL();
+ }
+
+ RETURN_LONG(amqp_get_heartbeat(connection->connection_resource->connection_state));
+}
+/* }}} */
+#endif
+
+/* {{{ proto amqp::isPersistent()
+check whether amqp connection is persistent */
+PHP_METHOD(amqp_connection_class, isPersistent)
+{
+ zval *id;
+ amqp_connection_object *connection;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_connection_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the connection object out of the store */
+ connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_BOOL(connection->is_persistent);
+}
+/* }}} */
+
+
+/*
+*Local variables:
+*tab-width: 4
+*c-basic-offset: 4
+*End:
+*vim600: noet sw=4 ts=4 fdm=marker
+*vim<6
+*/
diff --git a/amqp-1.6.1/amqp_connection.h b/amqp-1.6.1/amqp_connection.h
new file mode 100644
index 0000000..2c6ef92
--- /dev/null
+++ b/amqp-1.6.1/amqp_connection.h
@@ -0,0 +1,85 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: amqp_connection.h 326660 2012-07-17 05:32:34Z pdezwart $ */
+
+
+void amqp_connection_dtor(void *object TSRMLS_DC);
+zend_object_value amqp_connection_ctor(zend_class_entry *ce TSRMLS_DC);
+
+void php_amqp_connect(amqp_connection_object *amqp_connection, int persistent TSRMLS_DC);
+void php_amqp_disconnect_force(amqp_connection_object *connection TSRMLS_DC);
+void php_amqp_disconnect_safe(amqp_connection_object *connection TSRMLS_DC);
+
+
+
+
+PHP_METHOD(amqp_connection_class, __construct);
+PHP_METHOD(amqp_connection_class, isConnected);
+PHP_METHOD(amqp_connection_class, connect);
+PHP_METHOD(amqp_connection_class, pconnect);
+PHP_METHOD(amqp_connection_class, pdisconnect);
+PHP_METHOD(amqp_connection_class, disconnect);
+PHP_METHOD(amqp_connection_class, reconnect);
+PHP_METHOD(amqp_connection_class, preconnect);
+
+PHP_METHOD(amqp_connection_class, getLogin);
+PHP_METHOD(amqp_connection_class, setLogin);
+
+PHP_METHOD(amqp_connection_class, getPassword);
+PHP_METHOD(amqp_connection_class, setPassword);
+
+PHP_METHOD(amqp_connection_class, getHost);
+PHP_METHOD(amqp_connection_class, setHost);
+
+PHP_METHOD(amqp_connection_class, getPort);
+PHP_METHOD(amqp_connection_class, setPort);
+
+PHP_METHOD(amqp_connection_class, getVhost);
+PHP_METHOD(amqp_connection_class, setVhost);
+
+PHP_METHOD(amqp_connection_class, getTimeout);
+PHP_METHOD(amqp_connection_class, setTimeout);
+
+PHP_METHOD(amqp_connection_class, getReadTimeout);
+PHP_METHOD(amqp_connection_class, setReadTimeout);
+
+PHP_METHOD(amqp_connection_class, getWriteTimeout);
+PHP_METHOD(amqp_connection_class, setWriteTimeout);
+
+PHP_METHOD(amqp_connection_class, getUsedChannels);
+PHP_METHOD(amqp_connection_class, getMaxChannels);
+#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH > 52
+PHP_METHOD(amqp_connection_class, getHeartbeatInterval);
+PHP_METHOD(amqp_connection_class, getMaxFrameSize);
+#endif
+PHP_METHOD(amqp_connection_class, isPersistent);
+
+/*
+*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/amqp-1.6.1/amqp_connection_resource.c b/amqp-1.6.1/amqp_connection_resource.c
new file mode 100644
index 0000000..cda9c83
--- /dev/null
+++ b/amqp-1.6.1/amqp_connection_resource.c
@@ -0,0 +1,471 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: amqp_connection.c 327551 2012-09-09 03:49:34Z pdezwart $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "ext/standard/datetime.h"
+#include "zend_exceptions.h"
+
+#ifdef PHP_WIN32
+# include "win32/php_stdint.h"
+# include "win32/signal.h"
+#else
+# include <signal.h>
+# include <stdint.h>
+#endif
+#include <amqp.h>
+#include <amqp_framing.h>
+#include <amqp_tcp_socket.h>
+
+#ifdef PHP_WIN32
+# include "win32/unistd.h"
+#else
+# include <unistd.h>
+#endif
+
+#include "php_amqp.h"
+#include "amqp_connection_resource.h"
+
+#ifndef E_DEPRECATED
+#define E_DEPRECATED E_WARNING
+#endif
+
+int le_amqp_connection_resource;
+int le_amqp_connection_resource_persistent;
+
+static void connection_resource_destructor(amqp_connection_resource *resource, int persistent TSRMLS_DC);
+
+
+/* Figure out what's going on connection and handle protocol exceptions, if any */
+
+int php_amqp_connection_resource_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC)
+{
+ assert (resource != NULL);
+
+ switch (reply.reply_type) {
+ case AMQP_RESPONSE_NORMAL:
+ return PHP_AMQP_RESOURCE_RESPONSE_OK;
+
+ case AMQP_RESPONSE_NONE:
+ spprintf(message, 0, "Missing RPC reply type.");
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
+
+ case AMQP_RESPONSE_LIBRARY_EXCEPTION:
+ spprintf(message, 0, "Library error: %s", amqp_error_string2(reply.library_error));
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
+
+ case AMQP_RESPONSE_SERVER_EXCEPTION:
+ switch (reply.reply.id) {
+ case AMQP_CONNECTION_CLOSE_METHOD: {
+ amqp_connection_close_t *m = (amqp_connection_close_t *)reply.reply.decoded;
+
+ spprintf(message, 0, "Server connection error: %d, message: %.*s",
+ m->reply_code,
+ (int) m->reply_text.len,
+ (char *) m->reply_text.bytes
+ );
+
+ /*
+ * - If r.reply.id == AMQP_CONNECTION_CLOSE_METHOD a connection exception
+ * occurred, cast r.reply.decoded to amqp_connection_close_t* to see
+ * details of the exception. The client amqp_send_method() a
+ * amqp_connection_close_ok_t and disconnect from the broker.
+ */
+
+ amqp_connection_close_ok_t *decoded = (amqp_connection_close_ok_t *) NULL;
+
+ amqp_send_method(
+ resource->connection_state,
+ 0, /* NOTE: 0-channel is reserved for things like this */
+ AMQP_CONNECTION_CLOSE_OK_METHOD,
+ &decoded
+ );
+
+ /* Prevent finishing AMQP connection in connection resource destructor */
+ resource->is_connected = '\0';
+
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED;
+ }
+ case AMQP_CHANNEL_CLOSE_METHOD: {
+ assert(channel_id > 0 && channel_id <= resource->max_slots);
+
+ amqp_channel_close_t *m = (amqp_channel_close_t *) reply.reply.decoded;
+
+ spprintf(message, 0, "Server channel error: %d, message: %.*s",
+ m->reply_code,
+ (int) m->reply_text.len,
+ (char *)m->reply_text.bytes
+ );
+
+ /*
+ * - If r.reply.id == AMQP_CHANNEL_CLOSE_METHOD a channel exception
+ * occurred, cast r.reply.decoded to amqp_channel_close_t* to see details
+ * of the exception. The client should amqp_send_method() a
+ * amqp_channel_close_ok_t. The channel must be re-opened before it
+ * can be used again. Any resources associated with the channel
+ * (auto-delete exchanges, auto-delete queues, consumers) are invalid
+ * and must be recreated before attempting to use them again.
+ */
+
+ amqp_channel_close_ok_t *decoded = (amqp_channel_close_ok_t *) NULL;
+
+ amqp_send_method(
+ resource->connection_state,
+ channel_id,
+ AMQP_CHANNEL_CLOSE_OK_METHOD,
+ &decoded
+ );
+
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED;
+ }
+ }
+ /* Default for the above switch should be handled by the below default. */
+ default:
+ spprintf(message, 0, "Unknown server error, method id 0x%08X", reply.reply.id);
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
+ }
+
+ /* Should not never get here*/
+}
+
+
+/* Socket-related functions */
+int php_amqp_set_resource_read_timeout(amqp_connection_resource *resource, double timeout TSRMLS_DC)
+{
+ assert(timeout >= 0.0);
+
+#ifdef PHP_WIN32
+ DWORD read_timeout;
+ /*
+ In Windows, setsockopt with SO_RCVTIMEO sets actual timeout
+ to a value that's 500ms greater than specified value.
+ Also, it's not possible to set timeout to any value below 500ms.
+ Zero timeout works like it should, however.
+ */
+ if (timeout == 0.) {
+ read_timeout = 0;
+ } else {
+ read_timeout = (int) (max(connection->read_timeout * 1.e+3 - .5e+3, 1.));
+ }
+#else
+ struct timeval read_timeout;
+ read_timeout.tv_sec = (int) floor(timeout);
+ read_timeout.tv_usec = (int) ((timeout - floor(timeout)) * 1.e+6);
+#endif
+
+ if (0 != setsockopt(amqp_get_sockfd(resource->connection_state), SOL_SOCKET, SO_RCVTIMEO, (char *)&read_timeout, sizeof(read_timeout))) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: cannot setsockopt SO_RCVTIMEO", 0 TSRMLS_CC);
+ return 0;
+ }
+
+ return 1;
+}
+
+int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, double timeout TSRMLS_DC)
+{
+ assert(timeout >= 0.0);
+
+#ifdef PHP_WIN32
+ DWORD write_timeout;
+
+ if (timeout == 0.) {
+ write_timeout = 0;
+ } else {
+ write_timeout = (int) (max(timeout * 1.e+3 - .5e+3, 1.));
+ }
+#else
+ struct timeval write_timeout;
+ write_timeout.tv_sec = (int) floor(timeout);
+ write_timeout.tv_usec = (int) ((timeout - floor(timeout)) * 1.e+6);
+#endif
+
+ if (0 != setsockopt(amqp_get_sockfd(resource->connection_state), SOL_SOCKET, SO_SNDTIMEO, (char *)&write_timeout, sizeof(write_timeout))) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: cannot setsockopt SO_SNDTIMEO", 0 TSRMLS_CC);
+ return 0;
+ }
+
+ return 1;
+}
+
+
+/* Channel-related functions */
+
+amqp_channel_t php_amqp_connection_resource_get_available_channel_id(amqp_connection_resource *resource)
+{
+ assert(resource != NULL);
+ assert(resource->slots != NULL);
+
+ /* Check if there are any open slots */
+ if (resource->used_slots >= resource->max_slots) {
+ return 0;
+ }
+
+ amqp_channel_t slot;
+
+ for (slot = 0; slot < resource->max_slots; slot++) {
+ if (resource->slots[slot] == 0) {
+ return (amqp_channel_t) (slot + 1);
+ }
+ }
+
+ return 0;
+}
+
+int php_amqp_connection_resource_register_channel(amqp_connection_resource *resource, amqp_channel_object *channel, amqp_channel_t channel_id)
+{
+ assert(resource != NULL);
+ assert(resource->slots != NULL);
+ assert(channel_id > 0 && channel_id <= resource->max_slots);
+
+ if (resource->slots[channel_id - 1] != 0) {
+ return FAILURE;
+ }
+
+ resource->slots[channel_id - 1] = channel;
+ resource->used_slots++;
+
+ return SUCCESS;
+}
+
+int php_amqp_connection_resource_unregister_channel(amqp_connection_resource *resource, amqp_channel_t channel_id)
+{
+ assert(resource != NULL);
+ assert(resource->slots != NULL);
+ assert(channel_id > 0 && channel_id <= resource->max_slots);
+
+ if (resource->slots[channel_id - 1] != 0) {
+ resource->slots[channel_id - 1] = 0;
+ resource->used_slots--;
+ }
+
+ return SUCCESS;
+}
+
+
+/* Creating and destroying resource */
+
+amqp_connection_resource *connection_resource_constructor(amqp_connection_object *connection, zend_bool persistent TSRMLS_DC)
+{
+ struct timeval tv = {0};
+ struct timeval *tv_ptr = &tv;
+
+ char *std_datetime;
+ amqp_table_entry_t client_properties_entries[5];
+ amqp_table_t client_properties_table;
+
+ amqp_table_entry_t custom_properties_entries[1];
+ amqp_table_t custom_properties_table;
+
+ amqp_connection_resource *resource;
+
+ /* Allocate space for the connection resource */
+ resource = (amqp_connection_resource *)pecalloc(1, sizeof(amqp_connection_resource), persistent);
+
+ /* Initialize all the data */
+ resource->is_connected = 0;
+ resource->max_slots = 0;
+ resource->used_slots = 0;
+ resource->resource_id = 0;
+
+ /* Create the connection */
+ resource->connection_state = amqp_new_connection();
+
+ /* Create socket object */
+ resource->socket = amqp_tcp_socket_new(resource->connection_state);
+
+ if (connection->connect_timeout > 0) {
+ tv.tv_sec = (long int) connection->connect_timeout;
+ tv.tv_usec = (long int) ((connection->connect_timeout - tv.tv_sec) * 1000000);
+ } else {
+ tv_ptr = NULL;
+ }
+
+ /* Try to connect and verify that no error occurred */
+ if (amqp_socket_open_noblock(resource->socket, connection->host, connection->port, tv_ptr)) {
+
+ zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not connect to host.", 0 TSRMLS_CC);
+
+ connection_resource_destructor(resource, persistent TSRMLS_CC);
+
+ return NULL;
+ }
+
+ if (!php_amqp_set_resource_read_timeout(resource, connection->read_timeout TSRMLS_CC)) {
+ connection_resource_destructor(resource, persistent TSRMLS_CC);
+ return NULL;
+ }
+
+ if (!php_amqp_set_resource_write_timeout(resource, connection->write_timeout TSRMLS_CC)) {
+ connection_resource_destructor(resource, persistent TSRMLS_CC);
+ return NULL;
+ }
+
+ std_datetime = php_std_date(time(NULL) TSRMLS_CC);
+
+ client_properties_entries[0].key = amqp_cstring_bytes("type");
+ client_properties_entries[0].value.kind = AMQP_FIELD_KIND_UTF8;
+ client_properties_entries[0].value.value.bytes = amqp_cstring_bytes("php-amqp extension");
+
+ client_properties_entries[1].key = amqp_cstring_bytes("version");
+ client_properties_entries[1].value.kind = AMQP_FIELD_KIND_UTF8;
+ client_properties_entries[1].value.value.bytes = amqp_cstring_bytes(PHP_AMQP_VERSION);
+
+ client_properties_entries[2].key = amqp_cstring_bytes("revision");
+ client_properties_entries[2].value.kind = AMQP_FIELD_KIND_UTF8;
+ client_properties_entries[2].value.value.bytes = amqp_cstring_bytes(PHP_AMQP_REVISION);
+
+ client_properties_entries[3].key = amqp_cstring_bytes("connection type");
+ client_properties_entries[3].value.kind = AMQP_FIELD_KIND_UTF8;
+ client_properties_entries[3].value.value.bytes = amqp_cstring_bytes(persistent ? "persistent" : "transient");
+
+ client_properties_entries[4].key = amqp_cstring_bytes("connection started");
+ client_properties_entries[4].value.kind = AMQP_FIELD_KIND_UTF8;
+ client_properties_entries[4].value.value.bytes = amqp_cstring_bytes(std_datetime);
+
+ client_properties_table.entries = client_properties_entries;
+ client_properties_table.num_entries = sizeof(client_properties_entries) / sizeof(amqp_table_entry_t);
+
+ custom_properties_entries[0].key = amqp_cstring_bytes("client");
+ custom_properties_entries[0].value.kind = AMQP_FIELD_KIND_TABLE;
+ custom_properties_entries[0].value.value.table = client_properties_table;
+
+ custom_properties_table.entries = custom_properties_entries;
+ custom_properties_table.num_entries = sizeof(custom_properties_entries) / sizeof(amqp_table_entry_t);
+
+ /* We can assume that connection established here but it is not true, real handshake goes during login */
+
+ assert(connection->frame_max > 0);
+
+ amqp_rpc_reply_t res = amqp_login_with_properties(
+ resource->connection_state,
+ connection->vhost,
+ connection->channel_max,
+ connection->frame_max,
+ connection->heartbeat,
+ &custom_properties_table,
+ AMQP_SASL_METHOD_PLAIN,
+ connection->login,
+ connection->password
+ );
+
+ efree(std_datetime);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ char *message, *long_message;
+
+ php_amqp_connection_resource_error(res, &message, resource, 0 TSRMLS_CC);
+
+ spprintf(&long_message, 0, "%s - Potential login failure.", message);
+ zend_throw_exception(amqp_connection_exception_class_entry, long_message, 0 TSRMLS_CC);
+
+ efree(message);
+ efree(long_message);
+
+ /* https://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf
+ *
+ * 2.2.4 The Connection Class:
+ * ... a peer that detects an error MUST close the socket without sending any further data.
+ *
+ * 4.10.2 Denial of Service Attacks:
+ * ... The general response to any exceptional condition in the connection negotiation is to pause that connection
+ * (presumably a thread) for a period of several seconds and then to close the network connection. This
+ * includes syntax errors, over-sized data, and failed attempts to authenticate.
+ */
+ connection_resource_destructor(resource, persistent TSRMLS_CC);
+ return NULL;
+ }
+
+ /* Allocate space for the channel slots in the ring buffer */
+ resource->max_slots = (amqp_channel_t) amqp_get_channel_max(resource->connection_state);
+ assert(resource->max_slots > 0);
+
+ resource->slots = (amqp_channel_object **)pecalloc(resource->max_slots + 1, sizeof(amqp_channel_object*), persistent);
+
+ resource->is_connected = '\1';
+
+ return resource;
+}
+
+ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor_persistent)
+{
+ amqp_connection_resource *resource = (amqp_connection_resource *)rsrc->ptr;
+
+ connection_resource_destructor(resource, 1 TSRMLS_CC);
+}
+
+ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor)
+{
+ amqp_connection_resource *resource = (amqp_connection_resource *)rsrc->ptr;
+
+ connection_resource_destructor(resource, 0 TSRMLS_CC);
+}
+
+static void connection_resource_destructor(amqp_connection_resource *resource, int persistent TSRMLS_DC)
+{
+ assert(resource != NULL);
+
+ zend_rsrc_list_entry *le;
+#ifndef PHP_WIN32
+ void * old_handler;
+
+ /*
+ If we are trying to close the connection and the connection already closed, it will throw
+ SIGPIPE, which is fine, so ignore all SIGPIPES
+ */
+
+ /* Start ignoring SIGPIPE */
+ old_handler = signal(SIGPIPE, SIG_IGN);
+#endif
+
+ /* connection may be closed in case of previous failure */
+ if (resource->is_connected) {
+ amqp_connection_close(resource->connection_state, AMQP_REPLY_SUCCESS);
+ }
+
+ amqp_destroy_connection(resource->connection_state);
+
+#ifndef PHP_WIN32
+ /* End ignoring of SIGPIPEs */
+ signal(SIGPIPE, old_handler);
+#endif
+
+ if (resource->resource_key_len) {
+ pefree(resource->resource_key, persistent);
+ }
+
+ if (resource->slots) {
+ pefree(resource->slots, persistent);
+ resource->slots = NULL;
+ }
+
+ pefree(resource, persistent);
+}
+
+
diff --git a/amqp-1.6.1/amqp_connection_resource.h b/amqp-1.6.1/amqp_connection_resource.h
new file mode 100644
index 0000000..ccbc16e
--- /dev/null
+++ b/amqp-1.6.1/amqp_connection_resource.h
@@ -0,0 +1,59 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+#ifndef PHP_AMQP_CONNECTION_RESOURCE_H
+#define PHP_AMQP_CONNECTION_RESOURCE_H
+
+#define PHP_AMQP_RESOURCE_RESPONSE_OK 0
+#define PHP_AMQP_RESOURCE_RESPONSE_ERROR -1
+#define PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED -2
+#define PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED -3
+
+extern int le_amqp_connection_resource;
+extern int le_amqp_connection_resource_persistent;
+
+/* Figure out what's going on connection and handle protocol exceptions, if any */
+int php_amqp_connection_resource_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC);
+
+/* Socket-related functions */
+int php_amqp_set_resource_read_timeout(amqp_connection_resource *resource, double read_timeout TSRMLS_DC);
+int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, double write_timeout TSRMLS_DC);
+
+/* Channel-related functions */
+amqp_channel_t php_amqp_connection_resource_get_available_channel_id(amqp_connection_resource *resource);
+int php_amqp_connection_resource_unregister_channel(amqp_connection_resource *resource, amqp_channel_t channel_id);
+int php_amqp_connection_resource_register_channel(amqp_connection_resource *resource, amqp_channel_object *channel, amqp_channel_t channel_id);
+
+/* Creating and destroying resource */
+amqp_connection_resource *connection_resource_constructor(amqp_connection_object *connection, zend_bool persistent TSRMLS_DC);
+ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor_persistent);
+ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor);
+
+#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/amqp-1.6.1/amqp_envelope.c b/amqp-1.6.1/amqp_envelope.c
new file mode 100644
index 0000000..b7ec417
--- /dev/null
+++ b/amqp-1.6.1/amqp_envelope.c
@@ -0,0 +1,595 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: amqp_envelope.c 327551 2012-09-09 03:49:34Z pdezwart $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "zend_exceptions.h"
+
+#ifdef PHP_WIN32
+# include "win32/php_stdint.h"
+# include "win32/signal.h"
+#else
+# include <signal.h>
+# include <stdint.h>
+#endif
+#include <amqp.h>
+#include <amqp_framing.h>
+
+#ifdef PHP_WIN32
+# include "win32/unistd.h"
+#else
+# include <unistd.h>
+#endif
+
+#include "php_amqp.h"
+
+#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
+zend_object_handlers amqp_envelope_object_handlers;
+HashTable *amqp_envelope_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC) {
+ zval *value;
+ HashTable *debug_info;
+
+ /* Get the envelope object from which to read */
+ amqp_envelope_object *envelope = (amqp_envelope_object *)zend_object_store_get_object(object TSRMLS_CC);
+
+ /* Let zend clean up for us: */
+ *is_temp = 1;
+
+ /* Keep the # 18 matching the number of entries in this table*/
+ ALLOC_HASHTABLE(debug_info);
+ ZEND_INIT_SYMTABLE_EX(debug_info, 18 + 1, 0);
+
+ /* Start adding values */
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, envelope->body, envelope->body_len, 1);
+ zend_hash_add(debug_info, "body", sizeof("body"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, envelope->content_type, strlen(envelope->content_type), 1);
+ zend_hash_add(debug_info, "content_type", sizeof("content_type"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, envelope->routing_key, strlen(envelope->routing_key), 1);
+ zend_hash_add(debug_info, "routing_key", sizeof("routing_key"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_LONG(value, envelope->delivery_tag);
+ zend_hash_add(debug_info, "delivery_tag", sizeof("delivery_tag"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_LONG(value, envelope->delivery_mode);
+ zend_hash_add(debug_info, "delivery_mode", sizeof("delivery_mode"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, envelope->exchange_name, strlen(envelope->exchange_name), 1);
+ zend_hash_add(debug_info, "exchange_name", sizeof("exchange_name"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_LONG(value, envelope->is_redelivery);
+ zend_hash_add(debug_info, "is_redelivery", sizeof("is_redelivery"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, envelope->content_encoding, strlen(envelope->content_encoding), 1);
+ zend_hash_add(debug_info, "content_encoding", sizeof("content_encoding"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, envelope->type, strlen(envelope->type), 1);
+ zend_hash_add(debug_info, "type", sizeof("type"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_LONG(value, envelope->timestamp);
+ zend_hash_add(debug_info, "timestamp", sizeof("timestamp"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_LONG(value, envelope->priority);
+ zend_hash_add(debug_info, "priority", sizeof("priority"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, envelope->expiration, strlen(envelope->expiration), 1);
+ zend_hash_add(debug_info, "expiration", sizeof("expiration"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, envelope->user_id, strlen(envelope->user_id), 1);
+ zend_hash_add(debug_info, "user_id", sizeof("user_id"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, envelope->app_id, strlen(envelope->app_id), 1);
+ zend_hash_add(debug_info, "app_id", sizeof("app_id"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, envelope->message_id, strlen(envelope->message_id), 1);
+ zend_hash_add(debug_info, "message_id", sizeof("message_id"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, envelope->reply_to, strlen(envelope->reply_to), 1);
+ zend_hash_add(debug_info, "reply_to", sizeof("reply_to"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, envelope->correlation_id, strlen(envelope->correlation_id), 1);
+ zend_hash_add(debug_info, "correlation_id", sizeof("correlation_id"), &value, sizeof(zval *), NULL);
+
+ Z_ADDREF_P(envelope->headers);
+ zend_hash_add(debug_info, "headers", sizeof("headers"), &envelope->headers, sizeof(envelope->headers), NULL);
+
+ return debug_info;
+}
+#endif
+
+void amqp_envelope_dtor(void *object TSRMLS_DC)
+{
+ amqp_envelope_object *envelope = (amqp_envelope_object*)object;
+
+ if (envelope->headers) {
+ zval_ptr_dtor(&envelope->headers);
+ }
+
+ if (envelope->body) {
+ efree(envelope->body);
+ }
+
+ zend_object_std_dtor(&envelope->zo TSRMLS_CC);
+
+ efree(object);
+}
+
+zend_object_value amqp_envelope_ctor(zend_class_entry *ce TSRMLS_DC)
+{
+ zend_object_value new_value;
+ amqp_envelope_object *envelope = (amqp_envelope_object*)emalloc(sizeof(amqp_envelope_object));
+
+ memset(envelope, 0, sizeof(amqp_envelope_object));
+
+ MAKE_STD_ZVAL(envelope->headers);
+ array_init(envelope->headers);
+
+ zend_object_std_init(&envelope->zo, ce TSRMLS_CC);
+ AMQP_OBJECT_PROPERTIES_INIT(envelope->zo, ce);
+
+ new_value.handle = zend_objects_store_put(envelope, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)amqp_envelope_dtor, NULL TSRMLS_CC);
+
+#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
+ memcpy((void *)&amqp_envelope_object_handlers, (void *)zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ amqp_envelope_object_handlers.get_debug_info = amqp_envelope_object_get_debug_info;
+ new_value.handlers = &amqp_envelope_object_handlers;
+#else
+ new_value.handlers = zend_get_std_object_handlers();
+#endif
+
+ return new_value;
+}
+
+/* {{{ proto AMQPEnvelope::__construct(AMQPConnection obj)
+ */
+PHP_METHOD(amqp_envelope_class, __construct)
+{
+ zval *id;
+
+ amqp_envelope_object *envelope;
+
+ /* Parse out the method parameters */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+}
+/* }}} */
+
+
+/* {{{ proto AMQPEnvelope::getBody()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getBody)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ if (envelope->body == 0) {
+ RETURN_FALSE;
+ }
+
+ RETURN_STRINGL(envelope->body, envelope->body_len, 1);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getRoutingKey()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getRoutingKey)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_STRING(envelope->routing_key, 1);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getDeliveryMode()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getDeliveryMode)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_LONG(envelope->delivery_mode);
+}
+/* }}} */
+
+
+/* {{{ proto AMQPEnvelope::getDeliveryTag()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getDeliveryTag)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_LONG(envelope->delivery_tag);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getExchangeName()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getExchangeName)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_STRING(envelope->exchange_name, 1);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::isRedelivery()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, isRedelivery)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* We have no envelope */
+ RETURN_BOOL(envelope->is_redelivery);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getContentType()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getContentType)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_STRING(envelope->content_type, 1);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getContentEncoding()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getContentEncoding)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_STRING(envelope->content_encoding, 1);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getType()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getType)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_STRING(envelope->type, 1);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getTimestamp()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getTimestamp)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_LONG(envelope->timestamp);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getPriority()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getPriority)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_LONG(envelope->priority);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getExpiration()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getExpiration)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_STRING(envelope->expiration, 1);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getUserId()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getUserId)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_STRING(envelope->user_id, 1);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getAppId()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getAppId)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_STRING(envelope->app_id, 1);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getMessageId()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getMessageId)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_STRING(envelope->message_id, 1);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getReplyTo()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getReplyTo)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_STRING(envelope->reply_to, 1);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getCorrelationId()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getCorrelationId)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_STRING(envelope->correlation_id, 1);
+}
+/* }}} */
+
+/* {{{ proto AMQPEnvelope::getHeader(string headerName)
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getHeader)
+{
+ zval *id;
+ zval **tmp;
+ amqp_envelope_object *envelope;
+ char *key;
+ int key_len;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, amqp_envelope_class_entry, &key, &key_len) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Look for the hash key */
+ if (zend_hash_find(HASH_OF(envelope->headers), key, key_len + 1, (void **)&tmp) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ *return_value = **tmp;
+ zval_copy_ctor(return_value);
+ INIT_PZVAL(return_value);
+
+}
+/* }}} */
+
+
+/* {{{ proto AMQPEnvelope::getHeaders()
+check amqp envelope */
+PHP_METHOD(amqp_envelope_class, getHeaders)
+{
+ zval *id;
+ amqp_envelope_object *envelope;
+
+ /* Try to pull amqp object out of method params */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_envelope_class_entry) == FAILURE) {
+ return;
+ }
+
+ /* Get the envelope object out of the store */
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ zval_dtor(return_value);
+ MAKE_COPY_ZVAL(&envelope->headers, return_value);
+}
+/* }}} */
+
+
+/*
+*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/amqp-1.6.1/amqp_envelope.h b/amqp-1.6.1/amqp_envelope.h
new file mode 100644
index 0000000..9eaa40f
--- /dev/null
+++ b/amqp-1.6.1/amqp_envelope.h
@@ -0,0 +1,60 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: amqp_envelope.h 321054 2011-12-16 01:23:28Z pdezwart $ */
+
+
+void amqp_envelope_dtor(void *object TSRMLS_DC);
+zend_object_value amqp_envelope_ctor(zend_class_entry *ce TSRMLS_DC);
+
+PHP_METHOD(amqp_envelope_class, __construct);
+PHP_METHOD(amqp_envelope_class, getBody);
+PHP_METHOD(amqp_envelope_class, getRoutingKey);
+PHP_METHOD(amqp_envelope_class, getDeliveryTag);
+PHP_METHOD(amqp_envelope_class, getDeliveryMode);
+PHP_METHOD(amqp_envelope_class, getExchangeName);
+PHP_METHOD(amqp_envelope_class, isRedelivery);
+PHP_METHOD(amqp_envelope_class, getContentType);
+PHP_METHOD(amqp_envelope_class, getContentEncoding);
+PHP_METHOD(amqp_envelope_class, getType);
+PHP_METHOD(amqp_envelope_class, getTimestamp);
+PHP_METHOD(amqp_envelope_class, getPriority);
+PHP_METHOD(amqp_envelope_class, getExpiration);
+PHP_METHOD(amqp_envelope_class, getUserId);
+PHP_METHOD(amqp_envelope_class, getAppId);
+PHP_METHOD(amqp_envelope_class, getMessageId);
+PHP_METHOD(amqp_envelope_class, getReplyTo);
+PHP_METHOD(amqp_envelope_class, getCorrelationId);
+PHP_METHOD(amqp_envelope_class, getHeaders);
+PHP_METHOD(amqp_envelope_class, getHeader);
+
+
+
+/*
+*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/amqp-1.6.1/amqp_exchange.c b/amqp-1.6.1/amqp_exchange.c
new file mode 100644
index 0000000..6161557
--- /dev/null
+++ b/amqp-1.6.1/amqp_exchange.c
@@ -0,0 +1,979 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: amqp_exchange.c 327551 2012-09-09 03:49:34Z pdezwart $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "zend_exceptions.h"
+
+#ifdef PHP_WIN32
+# include "win32/php_stdint.h"
+# include "win32/signal.h"
+#else
+# include <signal.h>
+# include <stdint.h>
+#endif
+#include <amqp.h>
+#include <amqp_framing.h>
+
+#ifdef PHP_WIN32
+# include "win32/unistd.h"
+#else
+# include <unistd.h>
+#endif
+
+#include "php_amqp.h"
+
+
+#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
+zend_object_handlers amqp_exchange_object_handlers;
+HashTable *amqp_exchange_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC) {
+ zval *value;
+ HashTable *debug_info;
+
+ /* Get the envelope object from which to read */
+ amqp_exchange_object *exchange = (amqp_exchange_object *)zend_object_store_get_object(object TSRMLS_CC);
+
+ /* Let zend clean up for us: */
+ *is_temp = 1;
+
+ /* Keep the first number matching the number of entries in this table*/
+ ALLOC_HASHTABLE(debug_info);
+ ZEND_INIT_SYMTABLE_EX(debug_info, 6 + 1, 0);
+
+ /* Start adding values */
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, exchange->name, strlen(exchange->name), 1);
+ zend_hash_add(debug_info, "name", sizeof("name"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, exchange->type, strlen(exchange->type), 1);
+ zend_hash_add(debug_info, "type", sizeof("type"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_BOOL(value, IS_PASSIVE(exchange->flags));
+ zend_hash_add(debug_info, "passive", sizeof("passive"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_BOOL(value, IS_DURABLE(exchange->flags));
+ zend_hash_add(debug_info, "durable", sizeof("durable"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_BOOL(value, IS_AUTODELETE(exchange->flags));
+ zend_hash_add(debug_info, "auto_delete", sizeof("auto_delete"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_BOOL(value, IS_INTERNAL(exchange->flags));
+ zend_hash_add(debug_info, "internal", sizeof("internal"), &value, sizeof(zval *), NULL);
+
+ Z_ADDREF_P(exchange->arguments);
+ zend_hash_add(debug_info, "arguments", sizeof("arguments"), &exchange->arguments, sizeof(&exchange->arguments), NULL);
+
+ /* Start adding values */
+ return debug_info;
+}
+#endif
+
+void amqp_exchange_dtor(void *object TSRMLS_DC)
+{
+ amqp_exchange_object *exchange = (amqp_exchange_object*)object;
+
+ /* Destroy the connection object */
+ if (exchange->channel) {
+ zval_ptr_dtor(&exchange->channel);
+ }
+
+ if (exchange->arguments) {
+ zval_ptr_dtor(&exchange->arguments);
+ }
+
+ zend_object_std_dtor(&exchange->zo TSRMLS_CC);
+
+ efree(object);
+}
+
+zend_object_value amqp_exchange_ctor(zend_class_entry *ce TSRMLS_DC)
+{
+ zend_object_value new_value;
+ amqp_exchange_object* exchange = (amqp_exchange_object*)emalloc(sizeof(amqp_exchange_object));
+
+ memset(exchange, 0, sizeof(amqp_exchange_object));
+
+ /* Initialize the arguments array: */
+ MAKE_STD_ZVAL(exchange->arguments);
+ array_init(exchange->arguments);
+
+ zend_object_std_init(&exchange->zo, ce TSRMLS_CC);
+ AMQP_OBJECT_PROPERTIES_INIT(exchange->zo, ce);
+
+ new_value.handle = zend_objects_store_put(
+ exchange,
+ (zend_objects_store_dtor_t)zend_objects_destroy_object,
+ (zend_objects_free_object_storage_t)amqp_exchange_dtor,
+ NULL TSRMLS_CC
+ );
+
+#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
+ memcpy((void *)&amqp_exchange_object_handlers, (void *)zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ amqp_exchange_object_handlers.get_debug_info = amqp_exchange_object_get_debug_info;
+ new_value.handlers = &amqp_exchange_object_handlers;
+#else
+ new_value.handlers = zend_get_std_object_handlers();
+#endif
+
+ return new_value;
+}
+
+/* {{{ proto AMQPExchange::__construct(AMQPChannel channel);
+create Exchange */
+PHP_METHOD(amqp_exchange_class, __construct)
+{
+ zval *id;
+ zval *channelObj;
+ amqp_exchange_object *exchange;
+ amqp_channel_object *channel;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &id, amqp_exchange_class_entry, &channelObj, amqp_channel_class_entry) == FAILURE) {
+ zend_throw_exception(amqp_exchange_exception_class_entry, "Parameter must be an instance of AMQPChannel.", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+
+ if (!instanceof_function(Z_OBJCE_P(channelObj), amqp_channel_class_entry TSRMLS_CC)) {
+ zend_throw_exception(amqp_exchange_exception_class_entry, "The first parameter must be and instance of AMQPChannel.", 0 TSRMLS_CC);
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ exchange->channel = channelObj;
+
+ /* Increment the ref count */
+ Z_ADDREF_P(channelObj);
+
+ /* Pull the channel out */
+ channel = AMQP_GET_CHANNEL(exchange);
+ AMQP_VERIFY_CHANNEL(channel, "Could not create exchange.");
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::getName()
+Get the exchange name */
+PHP_METHOD(amqp_exchange_class, getName)
+{
+ zval *id;
+ amqp_exchange_object *exchange;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_exchange_class_entry) == FAILURE) {
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Check if there is a name to be had: */
+ if (exchange->name_len) {
+ RETURN_STRING(exchange->name, 1);
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::setName(string name)
+Set the exchange name */
+PHP_METHOD(amqp_exchange_class, setName)
+{
+ zval *id;
+ amqp_exchange_object *exchange;
+ char *name = NULL;
+ int name_len = 0;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, amqp_exchange_class_entry, &name, &name_len) == FAILURE) {
+ return;
+ }
+
+ /* Pull the exchange off the object store */
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Verify that the name is not null and not an empty string */
+ if (name_len > 255) {
+ zend_throw_exception(amqp_exchange_exception_class_entry, "Invalid exchange name given, must be less than 255 characters long.", 0 TSRMLS_CC);
+ return;
+ }
+
+ /* Set the exchange name */
+ AMQP_SET_NAME(exchange, name);
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::getFlags()
+Get the exchange parameters */
+PHP_METHOD(amqp_exchange_class, getFlags)
+{
+ zval *id;
+ amqp_exchange_object *exchange;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_exchange_class_entry) == FAILURE) {
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_LONG(exchange->flags);
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::setFlags(long bitmask)
+Set the exchange parameters */
+PHP_METHOD(amqp_exchange_class, setFlags)
+{
+ zval *id;
+ amqp_exchange_object *exchange;
+ long flagBitmask;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &id, amqp_exchange_class_entry, &flagBitmask) == FAILURE) {
+ return;
+ }
+
+ /* Pull the exchange off the object store */
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Set the flags based on the bitmask we were given */
+ exchange->flags = flagBitmask ? flagBitmask & PHP_AMQP_EXCHANGE_FLAGS : flagBitmask;
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::getType()
+Get the exchange type */
+PHP_METHOD(amqp_exchange_class, getType)
+{
+ zval *id;
+ amqp_exchange_object *exchange;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_exchange_class_entry) == FAILURE) {
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Check if there is a type to be had: */
+ if (exchange->type_len) {
+ RETURN_STRING(exchange->type, 1);
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::setType(string type)
+Set the exchange type */
+PHP_METHOD(amqp_exchange_class, setType)
+{
+ zval *id;
+ amqp_exchange_object *exchange;
+ char *type = NULL;
+ int type_len = 0;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, amqp_exchange_class_entry, &type, &type_len) == FAILURE) {
+ return;
+ }
+
+ /* Pull the exchange off the object store */
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ AMQP_SET_TYPE(exchange, type);
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::getArgument(string key)
+Get the exchange argument referenced by key */
+PHP_METHOD(amqp_exchange_class, getArgument)
+{
+ zval *id;
+ zval **tmp;
+ amqp_exchange_object *exchange;
+ char *key;
+ int key_len;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, amqp_exchange_class_entry, &key, &key_len) == FAILURE) {
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ if (zend_hash_find(Z_ARRVAL_P(exchange->arguments), key, key_len + 1, (void **)&tmp) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ *return_value = **tmp;
+
+ zval_copy_ctor(return_value);
+ INIT_PZVAL(return_value);
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::getArguments
+Get the exchange arguments */
+PHP_METHOD(amqp_exchange_class, getArguments)
+{
+ zval *id;
+ amqp_exchange_object *exchange;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_exchange_class_entry) == FAILURE) {
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ zval_dtor(return_value);
+ MAKE_COPY_ZVAL(&exchange->arguments, return_value);
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::setArguments(array args)
+Overwrite all exchange arguments with given args */
+PHP_METHOD(amqp_exchange_class, setArguments)
+{
+ zval *id, *zvalArguments;
+ amqp_exchange_object *exchange;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa", &id, amqp_exchange_class_entry, &zvalArguments) == FAILURE) {
+ return;
+ }
+
+ /* Pull the exchange off the object store */
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Destroy the arguments storage */
+ if (exchange->arguments) {
+ zval_ptr_dtor(&exchange->arguments);
+ }
+
+ exchange->arguments = zvalArguments;
+
+ /* Increment the ref count */
+ Z_ADDREF_P(exchange->arguments);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::setArgument(key, value)
+Get the exchange name */
+PHP_METHOD(amqp_exchange_class, setArgument)
+{
+ zval *id, *value;
+ amqp_exchange_object *exchange;
+ char *key;
+ int key_len;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osz", &id, amqp_exchange_class_entry, &key, &key_len, &value) == FAILURE) {
+ return;
+ }
+
+ /* Pull the exchange off the object store */
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ switch (Z_TYPE_P(value)) {
+ case IS_NULL:
+ zend_hash_del_key_or_index(Z_ARRVAL_P(exchange->arguments), key, key_len + 1, 0, HASH_DEL_KEY);
+ break;
+ case IS_BOOL:
+ case IS_LONG:
+ case IS_DOUBLE:
+ case IS_STRING:
+ add_assoc_zval(exchange->arguments, key, value);
+ Z_ADDREF_P(value);
+ break;
+ default:
+ zend_throw_exception(amqp_exchange_exception_class_entry, "The value parameter must be of type NULL, int, double or string.", 0 TSRMLS_CC);
+ return;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::declareExchange();
+declare Exchange
+*/
+PHP_METHOD(amqp_exchange_class, declareExchange)
+{
+ zval *id;
+
+ amqp_exchange_object *exchange;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ amqp_table_t *arguments;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_exchange_class_entry) == FAILURE) {
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ AMQP_ASSIGN_CHANNEL(channel, exchange);
+ AMQP_VERIFY_CHANNEL(channel, "Could not declare exchange.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not declare exchange.");
+
+ /* Check that the exchange has a name */
+ if (exchange->name_len < 1) {
+ zend_throw_exception(amqp_exchange_exception_class_entry, "Could not declare exchange. Exchanges must have a name.", 0 TSRMLS_CC);
+ return;
+ }
+
+ /* Check that the exchange has a name */
+ if (exchange->type_len < 1) {
+ zend_throw_exception(amqp_exchange_exception_class_entry, "Could not declare exchange. Exchanges must have a type.", 0 TSRMLS_CC);
+ return;
+ }
+
+ arguments = convert_zval_to_amqp_table(exchange->arguments TSRMLS_CC);
+
+#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH > 52
+ amqp_exchange_declare(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ amqp_cstring_bytes(exchange->name),
+ amqp_cstring_bytes(exchange->type),
+ IS_PASSIVE(exchange->flags),
+ IS_DURABLE(exchange->flags),
+ IS_AUTODELETE(exchange->flags),
+ IS_INTERNAL(exchange->flags),
+ *arguments
+ );
+#else
+ amqp_exchange_declare(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ amqp_cstring_bytes(exchange->name),
+ amqp_cstring_bytes(exchange->type),
+ IS_PASSIVE(exchange->flags),
+ IS_DURABLE(exchange->flags),
+ *arguments
+ );
+#endif
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ php_amqp_free_amqp_table(arguments);
+
+ /* handle any errors that occured outside of signals */
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_exchange_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::delete([string name[, long params]]);
+delete Exchange
+*/
+PHP_METHOD(amqp_exchange_class, delete)
+{
+ zval *id;
+
+ amqp_exchange_object *exchange;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ char *name = 0;
+ int name_len = 0;
+
+ long flags = 0;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|sl", &id, amqp_exchange_class_entry, &name, &name_len, &flags) == FAILURE) {
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(exchange);
+ AMQP_VERIFY_CHANNEL(channel, "Could not delete exchange.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not delete exchange.");
+
+ amqp_exchange_delete(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ amqp_cstring_bytes(name_len ? name : exchange->name),
+ (AMQP_IFUNUSED & flags) ? 1 : 0
+ );
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_exchange_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto AMQPExchange::publish(string msg, [string key, [int flags, [array headers]]]);
+publish into Exchange
+*/
+PHP_METHOD(amqp_exchange_class, publish)
+{
+ zval *id;
+ zval *ini_arr = NULL;
+ zval** ppztmp;
+ zval *ini_arr_tmp = NULL;
+
+
+ amqp_exchange_object *exchange;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ char *key_name = NULL;
+ int key_len = 0;
+
+ char *msg;
+ int msg_len= 0;
+
+ long flags = AMQP_NOPARAM;
+
+#ifndef PHP_WIN32
+ /* Storage for previous signal handler during SIGPIPE override */
+ void * old_handler;
+#endif
+
+ amqp_basic_properties_t props;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|sla", &id, amqp_exchange_class_entry, &msg, &msg_len, &key_name, &key_len, &flags, &ini_arr) == FAILURE) {
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* By default (and for BC) content type is text/plain (may be skipped at all, then set props._flags to 0) */
+ props.content_type = amqp_cstring_bytes("text/plain");
+ props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG;
+
+ props.headers.entries = 0;
+
+ if (ini_arr) {
+ ALLOC_ZVAL(ini_arr_tmp);
+ MAKE_COPY_ZVAL(&ini_arr, ini_arr_tmp);
+ }
+
+ {
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF (ini_arr_tmp), "content_type", sizeof("content_type"), (void*)&ppztmp)) {
+ convert_to_string(*ppztmp);
+
+ if (Z_STRLEN_PP(ppztmp) > 0) {
+ props.content_type = amqp_cstring_bytes((char *)Z_STRVAL_PP(ppztmp));
+ props._flags |= AMQP_BASIC_CONTENT_TYPE_FLAG;
+ }
+ }
+
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF (ini_arr_tmp), "content_encoding", sizeof("content_encoding"), (void*)&ppztmp)) {
+ convert_to_string(*ppztmp);
+
+ if (Z_STRLEN_PP(ppztmp) > 0) {
+ props.content_encoding = amqp_cstring_bytes((char *)Z_STRVAL_PP(ppztmp));
+ props._flags |= AMQP_BASIC_CONTENT_ENCODING_FLAG;
+ }
+ }
+
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF (ini_arr_tmp), "message_id", sizeof("message_id"), (void*)&ppztmp)) {
+ convert_to_string(*ppztmp);
+
+ if (Z_STRLEN_PP(ppztmp) > 0) {
+ props.message_id = amqp_cstring_bytes((char *)Z_STRVAL_PP(ppztmp));
+ props._flags |= AMQP_BASIC_MESSAGE_ID_FLAG;
+ }
+ }
+
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF (ini_arr_tmp), "user_id", sizeof("user_id"), (void*)&ppztmp)) {
+ convert_to_string(*ppztmp);
+
+ if (Z_STRLEN_PP(ppztmp) > 0) {
+ props.user_id = amqp_cstring_bytes((char *)Z_STRVAL_PP(ppztmp));
+ props._flags |= AMQP_BASIC_USER_ID_FLAG;
+ }
+ }
+
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF (ini_arr_tmp), "app_id", sizeof("app_id"), (void*)&ppztmp)) {
+ convert_to_string(*ppztmp);
+
+ if (Z_STRLEN_PP(ppztmp) > 0) {
+ props.app_id = amqp_cstring_bytes((char *)Z_STRVAL_PP(ppztmp));
+ props._flags |= AMQP_BASIC_APP_ID_FLAG;
+ }
+ }
+
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF (ini_arr_tmp), "delivery_mode", sizeof("delivery_mode"), (void*)&ppztmp)) {
+ convert_to_long(*ppztmp);
+
+ props.delivery_mode = (uint8_t)Z_LVAL_PP(ppztmp);
+ props._flags |= AMQP_BASIC_DELIVERY_MODE_FLAG;
+ }
+
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF (ini_arr_tmp), "priority", sizeof("priority"), (void*)&ppztmp)) {
+ convert_to_long(*ppztmp);
+
+ props.priority = (uint8_t)Z_LVAL_PP(ppztmp);
+ props._flags |= AMQP_BASIC_PRIORITY_FLAG;
+ }
+
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF (ini_arr_tmp), "timestamp", sizeof("timestamp"), (void*)&ppztmp)) {
+ convert_to_long(*ppztmp);
+
+ props.timestamp = (uint64_t)Z_LVAL_PP(ppztmp);
+ props._flags |= AMQP_BASIC_TIMESTAMP_FLAG;
+ }
+
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF (ini_arr_tmp), "expiration", sizeof("expiration"), (void*)&ppztmp)) {
+ convert_to_string(*ppztmp);
+
+ if (Z_STRLEN_PP(ppztmp) > 0) {
+ props.expiration = amqp_cstring_bytes((char *)Z_STRVAL_PP(ppztmp));
+ props._flags |= AMQP_BASIC_EXPIRATION_FLAG;
+ }
+ }
+
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF (ini_arr_tmp), "type", sizeof("type"), (void*)&ppztmp)) {
+ convert_to_string(*ppztmp);
+
+ if (Z_STRLEN_PP(ppztmp) > 0) {
+ props.type = amqp_cstring_bytes((char *)Z_STRVAL_PP(ppztmp));
+ props._flags |= AMQP_BASIC_TYPE_FLAG;
+ }
+ }
+
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF (ini_arr_tmp), "reply_to", sizeof("reply_to"), (void*)&ppztmp)) {
+ convert_to_string(*ppztmp);
+
+ if (Z_STRLEN_PP(ppztmp) > 0) {
+ props.reply_to = amqp_cstring_bytes((char *)Z_STRVAL_PP(ppztmp));
+ props._flags |= AMQP_BASIC_REPLY_TO_FLAG;
+ }
+ }
+
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF (ini_arr_tmp), "correlation_id", sizeof("correlation_id"), (void*)&ppztmp)) {
+ convert_to_string(*ppztmp);
+
+ if (Z_STRLEN_PP(ppztmp) > 0) {
+ props.correlation_id = amqp_cstring_bytes((char *)Z_STRVAL_PP(ppztmp));
+ props._flags |= AMQP_BASIC_CORRELATION_ID_FLAG;
+ }
+ }
+
+ }
+
+ amqp_table_t *headers = NULL;
+
+ if (ini_arr_tmp && SUCCESS == zend_hash_find(HASH_OF(ini_arr_tmp), "headers", sizeof("headers"), (void*)&ppztmp)) {
+ convert_to_array(*ppztmp);
+
+ headers = convert_zval_to_amqp_table(*ppztmp TSRMLS_CC);
+
+ props._flags |= AMQP_BASIC_HEADERS_FLAG;
+ props.headers = *headers;
+ }
+
+ channel = AMQP_GET_CHANNEL(exchange);
+ AMQP_VERIFY_CHANNEL(channel, "Could not publish to exchange.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not publish to exchange.");
+
+#ifndef PHP_WIN32
+ /* Start ignoring SIGPIPE */
+ old_handler = signal(SIGPIPE, SIG_IGN);
+#endif
+
+ /* NOTE: basic.publish is asynchronous and thus will not indicate failure if something goes wrong on the broker */
+ int status = amqp_basic_publish(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ (exchange->name_len > 0 ? amqp_cstring_bytes(exchange->name) : amqp_empty_bytes), /* exchange */
+ (key_len > 0 ? amqp_cstring_bytes(key_name) : amqp_empty_bytes), /* routing key */
+ (AMQP_MANDATORY & flags) ? 1 : 0, /* mandatory */
+ (AMQP_IMMEDIATE & flags) ? 1 : 0, /* immediate */
+ &props,
+ php_amqp_long_string(msg, msg_len) /* message body */
+ );
+
+ if (headers) {
+ php_amqp_free_amqp_table(headers);
+ }
+
+ if (ini_arr_tmp) {
+ zval_dtor(ini_arr_tmp);
+ FREE_ZVAL(ini_arr_tmp);
+ }
+
+#ifndef PHP_WIN32
+ /* End ignoring of SIGPIPEs */
+ signal(SIGPIPE, old_handler);
+#endif
+
+ if (status != AMQP_STATUS_OK) {
+ /* Emulate library error */
+ amqp_rpc_reply_t res;
+ res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
+ res.library_error = status;
+
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto int exchange::bind(string srcExchangeName[, string routingKey, array arguments]);
+bind exchange to exchange by routing key
+*/
+PHP_METHOD(amqp_exchange_class, bind)
+{
+ zval *id, *zvalArguments = NULL;
+ amqp_exchange_object *exchange;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ char *src_name;
+ int src_name_len = 0;
+
+ char *keyname;
+ int keyname_len = 0;
+
+ int flags;
+
+ amqp_table_t *arguments;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|sa", &id, amqp_exchange_class_entry, &src_name, &src_name_len, &keyname, &keyname_len, &zvalArguments) == FAILURE) {
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(exchange);
+ AMQP_VERIFY_CHANNEL(channel, "Could not bind to exchange.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not bind to exchanges.");
+
+ if (zvalArguments) {
+ arguments = convert_zval_to_amqp_table(zvalArguments TSRMLS_CC);
+ }
+
+ amqp_exchange_bind(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ amqp_cstring_bytes(exchange->name),
+ (src_name_len > 0 ? amqp_cstring_bytes(src_name) : amqp_empty_bytes),
+ (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes),
+ (zvalArguments ? *arguments : amqp_empty_table)
+ );
+
+ if (zvalArguments) {
+ php_amqp_free_amqp_table(arguments);
+ }
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_exchange_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int exchange::unbind(string srcExchangeName[, string routingKey, array arguments]);
+remove exchange to exchange binding by routing key
+*/
+PHP_METHOD(amqp_exchange_class, unbind)
+{
+ zval *id, *zvalArguments = NULL;
+ amqp_exchange_object *exchange;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ char *src_name;
+ int src_name_len = 0;
+
+ char *keyname;
+ int keyname_len = 0;
+
+ int flags;
+
+ amqp_table_t *arguments;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|sa", &id, amqp_exchange_class_entry, &src_name, &src_name_len, &keyname, &keyname_len, &zvalArguments) == FAILURE) {
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(exchange);
+ AMQP_VERIFY_CHANNEL(channel, "Could not unbind from exchange.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not unbind from exchanges.");
+
+ if (zvalArguments) {
+ arguments = convert_zval_to_amqp_table(zvalArguments TSRMLS_CC);
+ }
+
+ amqp_exchange_unbind(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ amqp_cstring_bytes(exchange->name),
+ (src_name_len > 0 ? amqp_cstring_bytes(src_name) : amqp_empty_bytes),
+ (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes),
+ (zvalArguments ? *arguments : amqp_empty_table)
+ );
+
+ if (zvalArguments) {
+ php_amqp_free_amqp_table(arguments);
+ }
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_exchange_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto AMQPExchange::getChannel()
+Get the AMQPChannel object in use */
+PHP_METHOD(amqp_exchange_class, getChannel)
+{
+ zval *id;
+ amqp_exchange_object *exchange;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_exchange_class_entry) == FAILURE) {
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_ZVAL(exchange->channel, 1, 0);
+}
+/* }}} */
+
+/* {{{ proto AMQPExchange::getConnection()
+Get the AMQPConnection object in use */
+PHP_METHOD(amqp_exchange_class, getConnection)
+{
+ zval *id;
+ amqp_exchange_object *exchange;
+ amqp_channel_object *channel;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_exchange_class_entry) == FAILURE) {
+ return;
+ }
+
+ exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);
+ channel = AMQP_GET_CHANNEL(exchange);
+
+ RETURN_ZVAL(channel->connection, 1, 0);
+}
+/* }}} */
+
+/*
+*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/amqp-1.6.1/amqp_exchange.h b/amqp-1.6.1/amqp_exchange.h
new file mode 100644
index 0000000..cd88b95
--- /dev/null
+++ b/amqp-1.6.1/amqp_exchange.h
@@ -0,0 +1,61 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: amqp_exchange.h 318206 2011-10-19 04:17:01Z pdezwart $ */
+
+void amqp_exchange_dtor(void *object TSRMLS_DC);
+zend_object_value amqp_exchange_ctor(zend_class_entry *ce TSRMLS_DC);
+
+PHP_METHOD(amqp_exchange_class, __construct);
+
+PHP_METHOD(amqp_exchange_class, getName);
+PHP_METHOD(amqp_exchange_class, setName);
+
+PHP_METHOD(amqp_exchange_class, getType);
+PHP_METHOD(amqp_exchange_class, setType);
+
+PHP_METHOD(amqp_exchange_class, getFlags);
+PHP_METHOD(amqp_exchange_class, setFlags);
+
+PHP_METHOD(amqp_exchange_class, getArgument);
+PHP_METHOD(amqp_exchange_class, getArguments);
+PHP_METHOD(amqp_exchange_class, setArgument);
+PHP_METHOD(amqp_exchange_class, setArguments);
+
+PHP_METHOD(amqp_exchange_class, declareExchange);
+PHP_METHOD(amqp_exchange_class, delete);
+PHP_METHOD(amqp_exchange_class, bind);
+PHP_METHOD(amqp_exchange_class, unbind);
+PHP_METHOD(amqp_exchange_class, publish);
+
+PHP_METHOD(amqp_exchange_class, getChannel);
+PHP_METHOD(amqp_exchange_class, getConnection);
+
+/*
+*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/amqp-1.6.1/amqp_object_store.c b/amqp-1.6.1/amqp_object_store.c
new file mode 100644
index 0000000..ce13691
--- /dev/null
+++ b/amqp-1.6.1/amqp_object_store.c
@@ -0,0 +1,22 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+
+#include "amqp_object_store.h"
+
+void *amqp_object_store_get_valid_object(const zval *zobject TSRMLS_DC)
+{
+ if(zobject == NULL) {
+ return NULL;
+ }
+
+ zend_object_handle handle;
+ zend_object_store_bucket bucket;
+
+ handle = Z_OBJ_HANDLE_P(zobject);
+ bucket = EG(objects_store).object_buckets[handle];
+
+ return bucket.valid ? bucket.bucket.obj.object : NULL;
+}
diff --git a/amqp-1.6.1/amqp_object_store.h b/amqp-1.6.1/amqp_object_store.h
new file mode 100644
index 0000000..e748f86
--- /dev/null
+++ b/amqp-1.6.1/amqp_object_store.h
@@ -0,0 +1,4 @@
+#ifndef AMQP_OBJECT_STORE_PATCH_H
+#define AMQP_OBJECT_STORE_PATCH_H
+void *amqp_object_store_get_valid_object(const zval *zobject TSRMLS_DC);
+#endif
diff --git a/amqp-1.6.1/amqp_queue.c b/amqp-1.6.1/amqp_queue.c
new file mode 100644
index 0000000..52a14fa
--- /dev/null
+++ b/amqp-1.6.1/amqp_queue.c
@@ -0,0 +1,1453 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: amqp_queue.c 327551 2012-09-09 03:49:34Z pdezwart $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "zend_exceptions.h"
+
+#ifdef PHP_WIN32
+# include "win32/php_stdint.h"
+# include "win32/signal.h"
+#else
+# include <signal.h>
+# include <stdint.h>
+#endif
+#include <amqp.h>
+#include <amqp_framing.h>
+
+#ifdef PHP_WIN32
+# include "win32/unistd.h"
+#else
+# include <unistd.h>
+#endif
+
+#include "php_amqp.h"
+
+
+#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
+zend_object_handlers amqp_queue_object_handlers;
+HashTable *amqp_queue_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC) {
+ zval *value;
+ HashTable *debug_info;
+
+ /* Get the envelope object from which to read */
+ amqp_queue_object *queue = (amqp_queue_object *)zend_object_store_get_object(object TSRMLS_CC);
+
+ /* Let zend clean up for us: */
+ *is_temp = 1;
+
+ /* Keep the # 7 matching the number of entries in this table*/
+ ALLOC_HASHTABLE(debug_info);
+ ZEND_INIT_SYMTABLE_EX(debug_info, 7 + 1, 0);
+
+ /* Start adding values */
+ MAKE_STD_ZVAL(value);
+ ZVAL_STRINGL(value, queue->name, strlen(queue->name), 1);
+ zend_hash_add(debug_info, "queue_name", sizeof("queue_name"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ if (queue->consumer_tag_len > 0) {
+ ZVAL_STRINGL(value, queue->consumer_tag, strlen(queue->consumer_tag), 1);
+ } else {
+ ZVAL_NULL(value);
+ }
+
+ zend_hash_add(debug_info, "consumer_tag", sizeof("consumer_tag"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_BOOL(value, IS_PASSIVE(queue->flags));
+ zend_hash_add(debug_info, "passive", sizeof("passive"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_BOOL(value, IS_DURABLE(queue->flags));
+ zend_hash_add(debug_info, "durable", sizeof("durable"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_BOOL(value, IS_EXCLUSIVE(queue->flags));
+ zend_hash_add(debug_info, "exclusive", sizeof("exclusive"), &value, sizeof(zval *), NULL);
+
+ MAKE_STD_ZVAL(value);
+ ZVAL_BOOL(value, IS_AUTODELETE(queue->flags));
+ zend_hash_add(debug_info, "auto_delete", sizeof("auto_delete"), &value, sizeof(zval *), NULL);
+
+ Z_ADDREF_P(queue->arguments);
+ zend_hash_add(debug_info, "arguments", sizeof("arguments"), &queue->arguments, sizeof(&queue->arguments), NULL);
+
+ return debug_info;
+}
+#endif
+
+/* Used in ctor, so must be declated first */
+void amqp_queue_dtor(void *object TSRMLS_DC)
+{
+ amqp_queue_object *queue = (amqp_queue_object*)object;
+
+ /* Destroy the connection object */
+ if (queue->channel) {
+ zval_ptr_dtor(&queue->channel);
+ }
+
+ /* Destroy the arguments storage */
+ if (queue->arguments) {
+ zval_ptr_dtor(&queue->arguments);
+ }
+
+ zend_object_std_dtor(&queue->zo TSRMLS_CC);
+
+ /* Destroy this object */
+ efree(object);
+}
+
+zend_object_value amqp_queue_ctor(zend_class_entry *ce TSRMLS_DC)
+{
+ zend_object_value new_value;
+ amqp_queue_object* queue = (amqp_queue_object*)emalloc(sizeof(amqp_queue_object));
+
+ memset(queue, 0, sizeof(amqp_queue_object));
+
+ zend_object_std_init(&queue->zo, ce TSRMLS_CC);
+ AMQP_OBJECT_PROPERTIES_INIT(queue->zo, ce);
+
+ /* Initialize the arguments array: */
+ MAKE_STD_ZVAL(queue->arguments);
+ array_init(queue->arguments);
+
+ new_value.handle = zend_objects_store_put(
+ queue,
+ (zend_objects_store_dtor_t)zend_objects_destroy_object,
+ (zend_objects_free_object_storage_t)amqp_queue_dtor,
+ NULL TSRMLS_CC
+ );
+
+#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
+ memcpy((void *)&amqp_queue_object_handlers, (void *)zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ amqp_queue_object_handlers.get_debug_info = amqp_queue_object_get_debug_info;
+ new_value.handlers = &amqp_queue_object_handlers;
+#else
+ new_value.handlers = zend_get_std_object_handlers();
+#endif
+
+ return new_value;
+}
+
+void parse_amqp_table(amqp_table_t *table, zval *result)
+{
+ int i;
+ zval *value;
+
+ assert(Z_TYPE_P(result) == IS_ARRAY);
+
+ for (i = 0; i < table->num_entries; i++) {
+ MAKE_STD_ZVAL(value);
+
+ amqp_table_entry_t *entry = &(table->entries[i]);
+ switch (entry->value.kind) {
+ case AMQP_FIELD_KIND_BOOLEAN:
+ ZVAL_BOOL(value, entry->value.value.boolean);
+ break;
+ case AMQP_FIELD_KIND_I8:
+ ZVAL_LONG(value, entry->value.value.i8);
+ break;
+ case AMQP_FIELD_KIND_U8:
+ ZVAL_LONG(value, entry->value.value.u8);
+ break;
+ case AMQP_FIELD_KIND_I16:
+ ZVAL_LONG(value, entry->value.value.i16);
+ break;
+ case AMQP_FIELD_KIND_U16:
+ ZVAL_LONG(value, entry->value.value.u16);
+ break;
+ case AMQP_FIELD_KIND_I32:
+ ZVAL_LONG(value, entry->value.value.i32);
+ break;
+ case AMQP_FIELD_KIND_U32:
+ ZVAL_LONG(value, entry->value.value.u32);
+ break;
+ case AMQP_FIELD_KIND_I64:
+ ZVAL_LONG(value, entry->value.value.i64);
+ break;
+ case AMQP_FIELD_KIND_U64:
+ ZVAL_LONG(value, entry->value.value.i64);
+ break;
+ case AMQP_FIELD_KIND_F32:
+ ZVAL_DOUBLE(value, entry->value.value.f32);
+ break;
+ case AMQP_FIELD_KIND_F64:
+ ZVAL_DOUBLE(value, entry->value.value.f64);
+ break;
+ case AMQP_FIELD_KIND_UTF8:
+ case AMQP_FIELD_KIND_BYTES:
+ ZVAL_STRINGL(value, entry->value.value.bytes.bytes, entry->value.value.bytes.len, 1);
+ break;
+ case AMQP_FIELD_KIND_ARRAY:
+ {
+ int j;
+ array_init(value);
+ for (j = 0; j < entry->value.value.array.num_entries; ++j) {
+ switch (entry->value.value.array.entries[j].kind) {
+ case AMQP_FIELD_KIND_UTF8:
+ add_next_index_stringl(
+ value,
+ entry->value.value.array.entries[j].value.bytes.bytes,
+ entry->value.value.array.entries[j].value.bytes.len,
+ 1
+ );
+ break;
+ case AMQP_FIELD_KIND_TABLE:
+ {
+ zval *subtable;
+ MAKE_STD_ZVAL(subtable);
+ array_init(subtable);
+ parse_amqp_table(
+ &(entry->value.value.array.entries[j].value.table),
+ subtable
+ );
+ add_next_index_zval(value, subtable);
+ }
+ break;
+ }
+ }
+ }
+ break;
+ case AMQP_FIELD_KIND_TABLE:
+ array_init(value);
+ parse_amqp_table(&(entry->value.value.table), value);
+ break;
+ case AMQP_FIELD_KIND_TIMESTAMP:
+ ZVAL_DOUBLE(value, entry->value.value.u64);
+ break;
+ case AMQP_FIELD_KIND_VOID:
+ case AMQP_FIELD_KIND_DECIMAL:
+ default:
+ ZVAL_NULL(value);
+ break;
+ }
+
+ if (Z_TYPE_P(value) != IS_NULL) {
+ char *key = estrndup(entry->key.bytes, entry->key.len);
+ add_assoc_zval(result, key, value);
+ efree(key);
+ } else {
+ zval_dtor(value);
+ }
+ }
+ return;
+}
+
+void convert_amqp_envelope_to_zval(amqp_envelope_t *amqp_envelope, zval *envelopeZval TSRMLS_DC)
+{
+ amqp_envelope_object *envelope;
+
+ /* Build the envelope */
+ object_init_ex(envelopeZval, amqp_envelope_class_entry);
+ envelope = (amqp_envelope_object *)zend_object_store_get_object(envelopeZval TSRMLS_CC);
+
+ AMQP_SET_STR_PROPERTY(envelope->routing_key, amqp_envelope->routing_key.bytes, amqp_envelope->routing_key.len);
+ AMQP_SET_STR_PROPERTY(envelope->exchange_name, amqp_envelope->exchange.bytes, amqp_envelope->exchange.len);
+ AMQP_SET_LONG_PROPERTY(envelope->delivery_tag, amqp_envelope->delivery_tag);
+ AMQP_SET_BOOL_PROPERTY(envelope->is_redelivery, amqp_envelope->redelivered);
+
+ amqp_basic_properties_t *p = &amqp_envelope->message.properties;
+ amqp_message_t *message = &amqp_envelope->message;
+
+ if (p->_flags & AMQP_BASIC_CONTENT_TYPE_FLAG) {
+ AMQP_SET_STR_PROPERTY(envelope->content_type, p->content_type.bytes, p->content_type.len);
+ }
+
+ if (p->_flags & AMQP_BASIC_CONTENT_ENCODING_FLAG) {
+ AMQP_SET_STR_PROPERTY(envelope->content_encoding, p->content_encoding.bytes, p->content_encoding.len);
+ }
+
+ if (p->_flags & AMQP_BASIC_TYPE_FLAG) {
+ AMQP_SET_STR_PROPERTY(envelope->type, p->type.bytes, p->type.len);
+ }
+
+ if (p->_flags & AMQP_BASIC_TIMESTAMP_FLAG) {
+ AMQP_SET_LONG_PROPERTY(envelope->timestamp, p->timestamp);
+ }
+
+ if (p->_flags & AMQP_BASIC_DELIVERY_MODE_FLAG) {
+ AMQP_SET_LONG_PROPERTY(envelope->delivery_mode, p->delivery_mode);
+ } else {
+ AMQP_SET_LONG_PROPERTY(envelope->delivery_mode, AMQP_DELIVERY_NONPERSISTENT);
+ }
+
+ if (p->_flags & AMQP_BASIC_PRIORITY_FLAG) {
+ AMQP_SET_LONG_PROPERTY(envelope->priority, p->priority);
+ }
+
+ if (p->_flags & AMQP_BASIC_EXPIRATION_FLAG) {
+ AMQP_SET_STR_PROPERTY(envelope->expiration, p->expiration.bytes, p->expiration.len);
+ }
+
+ if (p->_flags & AMQP_BASIC_USER_ID_FLAG) {
+ AMQP_SET_STR_PROPERTY(envelope->user_id, p->user_id.bytes, p->user_id.len);
+ }
+
+ if (p->_flags & AMQP_BASIC_APP_ID_FLAG) {
+ AMQP_SET_STR_PROPERTY(envelope->app_id, p->app_id.bytes, p->app_id.len);
+ }
+
+ if (p->_flags & AMQP_BASIC_MESSAGE_ID_FLAG) {
+ AMQP_SET_STR_PROPERTY(envelope->message_id, p->message_id.bytes, p->message_id.len);
+ }
+
+ if (p->_flags & AMQP_BASIC_REPLY_TO_FLAG) {
+ AMQP_SET_STR_PROPERTY(envelope->reply_to, p->reply_to.bytes, p->reply_to.len);
+ }
+
+ if (p->_flags & AMQP_BASIC_CORRELATION_ID_FLAG) {
+ AMQP_SET_STR_PROPERTY(envelope->correlation_id, p->correlation_id.bytes, p->correlation_id.len);
+ }
+
+ if (p->_flags & AMQP_BASIC_HEADERS_FLAG) {
+ parse_amqp_table(&(p->headers), envelope->headers);
+ }
+
+ envelope->body = estrndup(message->body.bytes, message->body.len);
+ envelope->body_len = message->body.len;
+}
+
+/* {{{ proto AMQPQueue::__construct(AMQPChannel channel)
+AMQPQueue constructor
+*/
+PHP_METHOD(amqp_queue_class, __construct)
+{
+ zval *id;
+ zval *channelObj = NULL;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &id, amqp_queue_class_entry, &channelObj, amqp_channel_class_entry) == FAILURE) {
+ zend_throw_exception(amqp_queue_exception_class_entry, "Parameter must be an instance of AMQPChannel.", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+
+ /* Store the connection object for later */
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Store the channel object */
+ queue->channel = channelObj;
+
+ /* Increment the ref count */
+ Z_ADDREF_P(channelObj);
+
+ /* Pull the channel out */
+ channel = AMQP_GET_CHANNEL(queue);
+
+ /* Check that the given connection has a channel, before trying to pull the connection off the stack */
+ AMQP_VERIFY_CHANNEL(channel, "Could not construct queue.");
+
+ /* By default, the auto_delete flag should be set */
+ queue->flags = AMQP_AUTODELETE;
+}
+/* }}} */
+
+
+/* {{{ proto AMQPQueue::getName()
+Get the queue name */
+PHP_METHOD(amqp_queue_class, getName)
+{
+ zval *id;
+ amqp_queue_object *queue;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_queue_class_entry) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Check if there is a name to be had: */
+ if (queue->name_len) {
+ RETURN_STRING(queue->name, 1);
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+
+/* {{{ proto AMQPQueue::setName(string name)
+Set the queue name */
+PHP_METHOD(amqp_queue_class, setName)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ char *name = NULL;
+ int name_len = 0;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, amqp_queue_class_entry, &name, &name_len) == FAILURE) {
+ return;
+ }
+
+ /* Pull the queue off the object store */
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Verify that the name is not null and not an empty string */
+ if (name_len < 1 || name_len > 255) {
+ zend_throw_exception(amqp_queue_exception_class_entry, "Invalid queue name given, must be between 1 and 255 characters long.", 0 TSRMLS_CC);
+ return;
+ }
+
+ /* Set the queue name */
+ AMQP_SET_NAME(queue, name);
+}
+/* }}} */
+
+
+
+/* {{{ proto AMQPQueue::getFlags()
+Get the queue parameters */
+PHP_METHOD(amqp_queue_class, getFlags)
+{
+ zval *id;
+ amqp_queue_object *queue;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_queue_class_entry) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_LONG(queue->flags);
+}
+/* }}} */
+
+
+/* {{{ proto AMQPQueue::setFlags(long bitmask)
+Set the queue parameters */
+PHP_METHOD(amqp_queue_class, setFlags)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ long flagBitmask;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &id, amqp_queue_class_entry, &flagBitmask) == FAILURE) {
+ return;
+ }
+
+ /* Pull the queue off the object store */
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Set the flags based on the bitmask we were given */
+ queue->flags = flagBitmask ? flagBitmask & PHP_AMQP_QUEUE_FLAGS : flagBitmask;
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto AMQPQueue::getArgument(string key)
+Get the queue argument referenced by key */
+PHP_METHOD(amqp_queue_class, getArgument)
+{
+ zval *id;
+ zval **tmp;
+ amqp_queue_object *queue;
+ char *key;
+ int key_len;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, amqp_queue_class_entry, &key, &key_len) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ if (zend_hash_find(Z_ARRVAL_P(queue->arguments), key, key_len + 1, (void **)&tmp) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ *return_value = **tmp;
+ zval_copy_ctor(return_value);
+ INIT_PZVAL(return_value);
+
+}
+/* }}} */
+
+/* {{{ proto AMQPQueue::getArguments
+Get the queue arguments */
+PHP_METHOD(amqp_queue_class, getArguments)
+{
+ zval *id;
+ amqp_queue_object *queue;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_queue_class_entry) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ zval_dtor(return_value);
+ MAKE_COPY_ZVAL(&queue->arguments, return_value);
+}
+/* }}} */
+
+/* {{{ proto AMQPQueue::setArguments(array args)
+Overwrite all queue arguments with given args */
+PHP_METHOD(amqp_queue_class, setArguments)
+{
+ zval *id, *arguments;
+ amqp_queue_object *queue;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa", &id, amqp_queue_class_entry, &arguments) == FAILURE) {
+ return;
+ }
+
+ /* Pull the queue off the object store */
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Destroy the arguments storage */
+ if (queue->arguments) {
+ zval_ptr_dtor(&queue->arguments);
+ }
+
+ MAKE_COPY_ZVAL(&arguments, queue->arguments);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto AMQPQueue::setArgument(key, value)
+Get the queue name */
+PHP_METHOD(amqp_queue_class, setArgument)
+{
+ zval *id, *value;
+ amqp_queue_object *queue;
+ char *key;
+ int key_len;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osz", &id, amqp_queue_class_entry, &key, &key_len, &value) == FAILURE) {
+ return;
+ }
+
+ /* Pull the queue off the object store */
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ switch (Z_TYPE_P(value)) {
+ case IS_NULL:
+ zend_hash_del_key_or_index(Z_ARRVAL_P(queue->arguments), key, key_len + 1, 0, HASH_DEL_KEY);
+ break;
+ case IS_BOOL:
+ case IS_LONG:
+ case IS_DOUBLE:
+ case IS_STRING:
+ add_assoc_zval(queue->arguments, key, value);
+ Z_ADDREF_P(value);
+ break;
+ default:
+ zend_throw_exception(amqp_queue_exception_class_entry, "The value parameter must be of type NULL, int, double or string.", 0 TSRMLS_CC);
+ return;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto int AMQPQueue::declareQueue();
+declare queue
+*/
+PHP_METHOD(amqp_queue_class, declareQueue)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ char *name = "";
+ amqp_table_t *arguments;
+ long message_count;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_queue_class_entry) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ /* Make sure we have a queue name, even if its empty: */
+ if (queue->name_len < 1) {
+ AMQP_SET_NAME(queue, name);
+ }
+
+ AMQP_ASSIGN_CHANNEL(channel, queue);
+ AMQP_VERIFY_CHANNEL(channel, "Could not declare queue.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not declare queue.");
+
+ arguments = convert_zval_to_amqp_table(queue->arguments TSRMLS_CC);
+
+ amqp_queue_declare_ok_t *r = amqp_queue_declare(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ amqp_cstring_bytes(queue->name),
+ IS_PASSIVE(queue->flags),
+ IS_DURABLE(queue->flags),
+ IS_EXCLUSIVE(queue->flags),
+ IS_AUTODELETE(queue->flags),
+ *arguments
+ );
+
+ php_amqp_free_amqp_table(arguments);
+
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ message_count = r->message_count;
+
+ /* Set the queue name, in case it is an autogenerated queue name */
+ name = stringify_bytes(r->queue);
+ AMQP_SET_NAME(queue, name);
+ efree(name);
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_LONG(message_count);
+}
+/* }}} */
+
+
+/* {{{ proto int AMQPQueue::bind(string exchangeName, [string routingKey, array arguments]);
+bind queue to exchange by routing key
+*/
+PHP_METHOD(amqp_queue_class, bind)
+{
+ zval *id, *zvalArguments = NULL;
+
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ char *exchange_name;
+ int exchange_name_len;
+
+ char *keyname = NULL;
+ int keyname_len = 0;
+
+ amqp_table_t *arguments;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|sa", &id, amqp_queue_class_entry, &exchange_name, &exchange_name_len, &keyname, &keyname_len, &zvalArguments) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(queue);
+ AMQP_VERIFY_CHANNEL(channel, "Could not bind queue.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not bind queue.");
+
+ if (zvalArguments) {
+ arguments = convert_zval_to_amqp_table(zvalArguments TSRMLS_CC);
+ }
+
+ amqp_queue_bind(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ amqp_cstring_bytes(queue->name),
+ (exchange_name_len > 0 ? amqp_cstring_bytes(exchange_name) : amqp_empty_bytes),
+ (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes),
+ (zvalArguments ? *arguments : amqp_empty_table)
+ );
+
+ if (zvalArguments) {
+ php_amqp_free_amqp_table(arguments);
+ }
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto int AMQPQueue::get([bit flags=AMQP_NOPARAM]);
+read messages from queue
+return array (messages)
+*/
+PHP_METHOD(amqp_queue_class, get)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+ zval *message;
+
+ long flags = INI_INT("amqp.auto_ack") ? AMQP_AUTOACK : AMQP_NOPARAM;
+
+ /* Parse out the method parameters */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &id, amqp_queue_class_entry, &flags) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(queue);
+ AMQP_VERIFY_CHANNEL(channel, "Could not get messages from queue.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not get messages from queue.");
+
+ amqp_rpc_reply_t res = amqp_basic_get(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ amqp_cstring_bytes(queue->name),
+ (AMQP_AUTOACK & flags) ? 1 : 0
+ );
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ if (AMQP_BASIC_GET_EMPTY_METHOD == res.reply.id) {
+ RETURN_FALSE;
+ }
+
+ assert(AMQP_BASIC_GET_OK_METHOD == res.reply.id);
+
+ /* Fill the envelope from response */
+ amqp_basic_get_ok_t *get_ok_method = res.reply.decoded;
+
+ amqp_envelope_t envelope;
+
+ envelope.channel = channel->channel_id;
+ envelope.consumer_tag = amqp_empty_bytes;
+ envelope.delivery_tag = get_ok_method->delivery_tag;
+ envelope.redelivered = get_ok_method->redelivered;
+ envelope.exchange = amqp_bytes_malloc_dup(get_ok_method->exchange);
+ envelope.routing_key = amqp_bytes_malloc_dup(get_ok_method->routing_key);
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ res = amqp_read_message(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ &envelope.message,
+ 0
+ );
+
+ if (AMQP_RESPONSE_NORMAL != res.reply_type) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ amqp_destroy_envelope(&envelope);
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ MAKE_STD_ZVAL(message);
+ convert_amqp_envelope_to_zval(&envelope, message TSRMLS_CC);
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+ amqp_destroy_envelope(&envelope);
+
+ COPY_PZVAL_TO_ZVAL(*return_value, message);
+}
+/* }}} */
+
+
+/* {{{ proto array AMQPQueue::consume([callback, flags = <bitmask>, consumer_tag]);
+consume the message
+*/
+PHP_METHOD(amqp_queue_class, consume)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ zend_fcall_info fci = empty_fcall_info;
+ zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
+
+ amqp_table_t *arguments;
+
+ char *consumer_tag;
+ int consumer_tag_len = 0;
+
+ long flags = INI_INT("amqp.auto_ack") ? AMQP_AUTOACK : AMQP_NOPARAM;
+
+ int call_result;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|f!ls", &id, amqp_queue_class_entry, &fci,
+ &fci_cache, &flags, &consumer_tag, &consumer_tag_len) == FAILURE) {
+ return;
+ }
+
+ /* Pull the queue out */
+ queue = (amqp_queue_object *) zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(queue);
+ AMQP_VERIFY_CHANNEL(channel, "Could not get channel.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not get connection.");
+
+ if (!(AMQP_JUST_CONSUME & flags)) {
+ /* Setup the consume */
+ arguments = convert_zval_to_amqp_table(queue->arguments TSRMLS_CC);
+
+ amqp_basic_consume_ok_t *r = amqp_basic_consume(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ amqp_cstring_bytes(queue->name),
+ (consumer_tag_len > 0 ? amqp_cstring_bytes(consumer_tag) : amqp_empty_bytes), /* Consumer tag */
+ (AMQP_NOLOCAL & flags) ? 1 : 0, /* No local */
+ (AMQP_AUTOACK & flags) ? 1 : 0, /* no_ack, aka AUTOACK */
+ IS_EXCLUSIVE(queue->flags),
+ *arguments
+ );
+
+ php_amqp_free_amqp_table(arguments);
+
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ zend_throw_exception(amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ /* Set the consumer tag name, in case it is an autogenerated consumer tag name */
+ AMQP_SET_STR_PROPERTY(queue->consumer_tag, r->consumer_tag.bytes, r->consumer_tag.len);
+ queue->consumer_tag_len = r->consumer_tag.len;
+ }
+
+ if (!ZEND_FCI_INITIALIZED(fci)) {
+ /* Callback not set, we have nothing to do - real consuming may happens later */
+ return;
+ }
+
+ struct timeval tv = {0};
+ struct timeval *tv_ptr = &tv;
+
+ if (connection->read_timeout > 0) {
+ tv.tv_sec = (long int) connection->read_timeout;
+ tv.tv_usec = (long int) ((connection->read_timeout - tv.tv_sec) * 1000000);
+ } else {
+ tv_ptr = NULL;
+ }
+
+ while(1) {
+ /* Initialize the message */
+ zval *message;
+
+ amqp_envelope_t envelope;
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ amqp_rpc_reply_t res = amqp_consume_message(connection->connection_resource->connection_state, &envelope, tv_ptr, 0);
+
+ if (AMQP_RESPONSE_LIBRARY_EXCEPTION == res.reply_type && AMQP_STATUS_TIMEOUT == res.library_error) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ zend_throw_exception(amqp_queue_exception_class_entry, "Consumer timeout exceed", 0 TSRMLS_CC);
+
+ amqp_destroy_envelope(&envelope);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ if (AMQP_RESPONSE_NORMAL != res.reply_type) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+
+ amqp_destroy_envelope(&envelope);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ MAKE_STD_ZVAL(message);
+ convert_amqp_envelope_to_zval(&envelope, message TSRMLS_CC);
+
+ amqp_destroy_envelope(&envelope);
+
+ /* Make the callback */
+ zval *params;
+ zval *retval_ptr = NULL;
+
+ /* Build the parameter array */
+ MAKE_STD_ZVAL(params);
+ array_init(params);
+
+ /* Dump it into the params array */
+ add_index_zval(params, 0, message);
+ Z_ADDREF_P(message);
+
+ /* Add a pointer to the queue: */
+ add_index_zval(params, 1, id);
+ Z_ADDREF_P(id);
+
+ /* Convert everything to be callable */
+ zend_fcall_info_args(&fci, params TSRMLS_CC);
+ /* Initialize the return value pointer */
+ fci.retval_ptr_ptr = &retval_ptr;
+
+ /* Call the function, and track the return value */
+ if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && fci.retval_ptr_ptr && *fci.retval_ptr_ptr) {
+ COPY_PZVAL_TO_ZVAL(*return_value, *fci.retval_ptr_ptr);
+ }
+
+ /* Clean up our mess */
+ zend_fcall_info_args_clear(&fci, 1);
+ zval_ptr_dtor(&params);
+ zval_ptr_dtor(&message);
+
+ /* Check if user land function wants to bail */
+ if (EG(exception) || (Z_TYPE_P(return_value) == IS_BOOL && !Z_BVAL_P(return_value))) {
+ break;
+ }
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+ return;
+}
+/* }}} */
+
+
+/* {{{ proto int AMQPQueue::ack(long deliveryTag, [bit flags=AMQP_NOPARAM]);
+ acknowledge the message
+*/
+PHP_METHOD(amqp_queue_class, ack)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ long deliveryTag = 0;
+ long flags = AMQP_NOPARAM;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol|l", &id, amqp_queue_class_entry, &deliveryTag, &flags ) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(queue);
+ AMQP_VERIFY_CHANNEL(channel, "Could not ack message.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not ack message.");
+
+ /* NOTE: basic.ack is asynchronous and thus will not indicate failure if something goes wrong on the broker */
+ int status = amqp_basic_ack(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ deliveryTag,
+ (AMQP_MULTIPLE & flags) ? 1 : 0
+ );
+
+ if (status != AMQP_STATUS_OK) {
+ /* Emulate library error */
+ amqp_rpc_reply_t res;
+ res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
+ res.library_error = status;
+
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto int AMQPQueue::nack(long deliveryTag, [bit flags=AMQP_NOPARAM]);
+ acknowledge the message
+*/
+PHP_METHOD(amqp_queue_class, nack)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ long deliveryTag = 0;
+ long flags = AMQP_NOPARAM;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol|l", &id, amqp_queue_class_entry, &deliveryTag, &flags ) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(queue);
+ AMQP_VERIFY_CHANNEL(channel, "Could not nack message.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not nack message.");
+
+ /* NOTE: basic.nack is asynchronous and thus will not indicate failure if something goes wrong on the broker */
+ int status = amqp_basic_nack(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ deliveryTag,
+ (AMQP_MULTIPLE & flags) ? 1 : 0,
+ (AMQP_REQUEUE & flags) ? 1 : 0
+ );
+
+ if (status != AMQP_STATUS_OK) {
+ /* Emulate library error */
+ amqp_rpc_reply_t res;
+ res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
+ res.library_error = status;
+
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto int AMQPQueue::reject(long deliveryTag, [bit flags=AMQP_NOPARAM]);
+ acknowledge the message
+*/
+PHP_METHOD(amqp_queue_class, reject)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ long deliveryTag = 0;
+ long flags = AMQP_NOPARAM;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol|l", &id, amqp_queue_class_entry, &deliveryTag, &flags ) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(queue);
+ AMQP_VERIFY_CHANNEL(channel, "Could not reject message.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not reject message.");
+
+ /* NOTE: basic.reject is asynchronous and thus will not indicate failure if something goes wrong on the broker */
+ int status = amqp_basic_reject(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ deliveryTag,
+ (AMQP_REQUEUE & flags) ? 1 : 0
+ );
+
+ if (status != AMQP_STATUS_OK) {
+ /* Emulate library error */
+ amqp_rpc_reply_t res;
+ res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
+ res.library_error = status;
+
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto int AMQPQueue::purge();
+purge queue
+*/
+PHP_METHOD(amqp_queue_class, purge)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, amqp_queue_class_entry) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(queue);
+ AMQP_VERIFY_CHANNEL(channel, "Could not purge queue.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not purge queue.");
+
+ amqp_queue_purge_ok_t *r = amqp_queue_purge(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ amqp_cstring_bytes(queue->name)
+ );
+
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ /* long message_count = r->message_count; */
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ /* RETURN_LONG(message_count) */;
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto int AMQPQueue::cancel([string consumer_tag]);
+cancel queue to consumer
+*/
+PHP_METHOD(amqp_queue_class, cancel)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ char *consumer_tag = NULL;
+ int consumer_tag_len = 0;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|s", &id, amqp_queue_class_entry, &consumer_tag, &consumer_tag_len) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(queue);
+ AMQP_VERIFY_CHANNEL(channel, "Could not cancel queue.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not cancel queue.");
+
+ if (!consumer_tag_len && !queue->consumer_tag_len) {
+ return;
+ }
+
+ amqp_basic_cancel_ok_t *r = amqp_basic_cancel(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ consumer_tag_len > 0 ? amqp_cstring_bytes(consumer_tag) : amqp_cstring_bytes(queue->consumer_tag)
+ );
+
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ if (!consumer_tag_len || strcmp(consumer_tag, queue->consumer_tag) != 0) {
+ memset(queue->consumer_tag, 0, sizeof(queue->consumer_tag));
+ queue->consumer_tag_len = 0;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto int AMQPQueue::unbind(string exchangeName, [string routingKey, array arguments]);
+unbind queue from exchange
+*/
+PHP_METHOD(amqp_queue_class, unbind)
+{
+ zval *id, *zvalArguments = NULL;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ char *exchange_name;
+ int exchange_name_len;
+ char *keyname = NULL;
+ int keyname_len = 0;
+
+ amqp_table_t *arguments;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|sa", &id, amqp_queue_class_entry, &exchange_name, &exchange_name_len, &keyname, &keyname_len, &zvalArguments) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(queue);
+ AMQP_VERIFY_CHANNEL(channel, "Could not unbind queue.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not unbind queue.");
+
+ if (zvalArguments) {
+ arguments = convert_zval_to_amqp_table(zvalArguments TSRMLS_CC);
+ }
+
+ amqp_queue_unbind(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ amqp_cstring_bytes(queue->name),
+ (exchange_name_len > 0 ? amqp_cstring_bytes(exchange_name) : amqp_empty_bytes),
+ (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes),
+ (zvalArguments ? *arguments : amqp_empty_table)
+ );
+
+ if (zvalArguments) {
+ php_amqp_free_amqp_table(arguments);
+ }
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ if (res.reply_type != AMQP_RESPONSE_NORMAL) {
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
+/* {{{ proto int AMQPQueue::delete([long flags = AMQP_NOPARAM]]);
+delete queue and return the number of messages deleted in it
+*/
+PHP_METHOD(amqp_queue_class, delete)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
+
+ long flags = AMQP_NOPARAM;
+
+ long message_count;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &id, amqp_queue_class_entry, &flags) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ channel = AMQP_GET_CHANNEL(queue);
+ AMQP_VERIFY_CHANNEL(channel, "Could not delete queue.");
+
+ connection = AMQP_GET_CONNECTION(channel);
+ AMQP_VERIFY_CONNECTION(connection, "Could not delete queue.");
+
+ amqp_queue_delete_ok_t * r = amqp_queue_delete(
+ connection->connection_resource->connection_state,
+ channel->channel_id,
+ amqp_cstring_bytes(queue->name),
+ (AMQP_IFUNUSED & flags) ? 1 : 0,
+ (AMQP_IFEMPTY & flags) ? 1 : 0
+ );
+
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(connection->connection_resource->connection_state);
+
+ PHP_AMQP_INIT_ERROR_MESSAGE();
+
+ php_amqp_error(res, PHP_AMQP_ERROR_MESSAGE_PTR, connection, channel TSRMLS_CC);
+
+ php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_ERROR_MESSAGE, 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ PHP_AMQP_DESTROY_ERROR_MESSAGE();
+ return;
+ }
+
+ message_count = r->message_count;
+
+ php_amqp_maybe_release_buffers_on_channel(connection, channel);
+
+ RETURN_LONG(message_count);
+}
+/* }}} */
+
+/* {{{ proto AMQPChannel::getChannel()
+Get the AMQPChannel object in use */
+PHP_METHOD(amqp_queue_class, getChannel)
+{
+ zval *id;
+ amqp_queue_object *queue;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &id, amqp_queue_class_entry) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+
+ RETURN_ZVAL(queue->channel, 1, 0);
+}
+/* }}} */
+
+/* {{{ proto AMQPChannel::getConnection()
+Get the AMQPConnection object in use */
+PHP_METHOD(amqp_queue_class, getConnection)
+{
+ zval *id;
+ amqp_queue_object *queue;
+ amqp_channel_object *channel;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &id, amqp_queue_class_entry) == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
+ channel = AMQP_GET_CHANNEL(queue);
+
+ RETURN_ZVAL(channel->connection, 1, 0);
+}
+/* }}} */
+
+/* {{{ proto string AMQPChannel::getConsumerTag()
+Get latest consumer tag*/
+PHP_METHOD(amqp_queue_class, getConsumerTag)
+{
+ amqp_queue_object *queue;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ queue = (amqp_queue_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ if (queue->consumer_tag_len > 0) {
+ RETURN_STRINGL(queue->consumer_tag, strlen(queue->consumer_tag), 1);
+ }
+
+ RETURN_NULL();
+}
+/* }}} */
+
+
+/*
+*Local variables:
+*tab-width: 4
+*tabstop: 4
+*c-basic-offset: 4
+*End:
+*vim600: noet sw=4 ts=4 fdm=marker
+*vim<600: noet sw=4 ts=4
+*/
diff --git a/amqp-1.6.1/amqp_queue.h b/amqp-1.6.1/amqp_queue.h
new file mode 100644
index 0000000..14fc5f2
--- /dev/null
+++ b/amqp-1.6.1/amqp_queue.h
@@ -0,0 +1,67 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: amqp_queue.h 321959 2012-01-09 17:56:10Z pdezwart $ */
+
+void amqp_queue_dtor(void *object TSRMLS_DC);
+zend_object_value amqp_queue_ctor(zend_class_entry *ce TSRMLS_DC);
+
+PHP_METHOD(amqp_queue_class, __construct);
+
+PHP_METHOD(amqp_queue_class, getName);
+PHP_METHOD(amqp_queue_class, setName);
+
+PHP_METHOD(amqp_queue_class, getFlags);
+PHP_METHOD(amqp_queue_class, setFlags);
+
+PHP_METHOD(amqp_queue_class, getArgument);
+PHP_METHOD(amqp_queue_class, getArguments);
+PHP_METHOD(amqp_queue_class, setArgument);
+PHP_METHOD(amqp_queue_class, setArguments);
+
+PHP_METHOD(amqp_queue_class, declareQueue);
+PHP_METHOD(amqp_queue_class, bind);
+
+PHP_METHOD(amqp_queue_class, get);
+PHP_METHOD(amqp_queue_class, consume);
+PHP_METHOD(amqp_queue_class, ack);
+PHP_METHOD(amqp_queue_class, nack);
+PHP_METHOD(amqp_queue_class, reject);
+PHP_METHOD(amqp_queue_class, purge);
+
+PHP_METHOD(amqp_queue_class, cancel);
+PHP_METHOD(amqp_queue_class, unbind);
+PHP_METHOD(amqp_queue_class, delete);
+
+PHP_METHOD(amqp_queue_class, getChannel);
+PHP_METHOD(amqp_queue_class, getConnection);
+PHP_METHOD(amqp_queue_class, getConsumerTag);
+
+/*
+*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/amqp-1.6.1/config.m4 b/amqp-1.6.1/config.m4
new file mode 100644
index 0000000..c219769
--- /dev/null
+++ b/amqp-1.6.1/config.m4
@@ -0,0 +1,89 @@
+dnl $Id: config.m4 322428 2012-01-17 21:42:40Z pdezwart $
+dnl config.m4 for extension amqp
+
+dnl Comments in this file start with the string 'dnl'.
+dnl Remove where necessary. This file will not work
+dnl without editing.
+dnl amqp
+dnl If your extension references something external, use with:
+
+
+dnl Make sure that the comment is aligned:
+PHP_ARG_WITH(amqp, for amqp support,
+[ --with-amqp Include amqp support])
+
+PHP_ARG_WITH(librabbitmq-dir, for amqp,
+[ --with-librabbitmq-dir[=DIR] Set the path to librabbit-mq install prefix.], yes)
+
+
+if test "$PHP_AMQP" != "no"; then
+ dnl Write more examples of tests here...
+
+ AC_MSG_RESULT($PHP_AMQP)
+
+ dnl # --with-amqp -> check with-path
+
+ SEARCH_FOR="amqp_framing.h"
+
+ AC_MSG_CHECKING([for amqp files in default path])
+ if test "$PHP_LIBRABBITMQ_DIR" != "no" && test "$PHP_LIBRABBITMQ_DIR" != "yes"; then
+ for i in $PHP_LIBRABBITMQ_DIR; do
+ if test -r $i/include/$SEARCH_FOR;
+ then
+ AMQP_DIR=$i
+ AC_MSG_RESULT(found in $i)
+ break
+ fi
+ done
+ else
+ for i in $PHP_AMQP /usr/local /usr ; do
+ if test -r $i/include/$SEARCH_FOR;
+ then
+ AMQP_DIR=$i
+ AC_MSG_RESULT(found in $i)
+ break
+ fi
+ done
+ fi
+
+ if test -z "$AMQP_DIR"; then
+ AC_MSG_RESULT([not found])
+ AC_MSG_ERROR([Please reinstall the librabbitmq distribution itself or (re)install librabbitmq development package if it available in your system])
+ fi
+
+ dnl # --with-amqp -> add include path
+
+ PHP_ADD_INCLUDE($AMQP_DIR/include)
+
+ dnl # --with-amqp -> check for lib and symbol presence
+
+ LIBNAME=rabbitmq
+ LIBSYMBOL=rabbitmq
+
+ if test -z "$TRAVIS" ; then
+ type git &>/dev/null
+
+ if test $? -eq 0 ; then
+ git describe --abbrev=0 --tags &>/dev/null
+
+ if test $? -eq 0 ; then
+ AC_DEFINE_UNQUOTED([PHP_AMQP_VERSION], ["`git describe --abbrev=0 --tags`-`git rev-parse --abbrev-ref HEAD`-dev"], [git version])
+ fi
+
+ git rev-parse --short HEAD &>/dev/null
+
+ if test $? -eq 0 ; then
+ AC_DEFINE_UNQUOTED([PHP_AMQP_REVISION], ["`git rev-parse --short HEAD`"], [git revision])
+ fi
+ else
+ AC_MSG_NOTICE([git not installed. Cannot obtain php_amqp version tag. Install git.])
+ fi
+ fi
+
+ PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $AMQP_DIR/$PHP_LIBDIR, AMQP_SHARED_LIBADD)
+ PHP_SUBST(AMQP_SHARED_LIBADD)
+
+ AMQP_SOURCES="amqp.c amqp_exchange.c amqp_queue.c amqp_connection.c amqp_connection_resource.c amqp_channel.c amqp_envelope.c amqp_object_store.c"
+
+ PHP_NEW_EXTENSION(amqp, $AMQP_SOURCES, $ext_shared)
+fi
diff --git a/amqp-1.6.1/config.w32 b/amqp-1.6.1/config.w32
new file mode 100644
index 0000000..99dcab6
--- /dev/null
+++ b/amqp-1.6.1/config.w32
@@ -0,0 +1,12 @@
+ARG_WITH("amqp", "AMQP support", "no");
+
+if (PHP_AMQP != "no") {
+ if (CHECK_HEADER_ADD_INCLUDE("amqp.h", "CFLAGS_AMQP", PHP_PHP_BUILD + "\\include;" + PHP_AMQP) &&
+ CHECK_LIB("rabbinmq_a.lib;rabbitmq.lib;rabbitmq.1.lib", "amqp", PHP_PHP_BUILD + "\\lib;" + PHP_AMQP)) {
+// ADD_FLAG("CFLAGS_AMQP", "/D HAVE_AMQP_GETSOCKOPT");
+ EXTENSION('amqp', 'amqp.c amqp_exchange.c amqp_queue.c amqp_connection_resource.c amqp_connection.c amqp_channel.c amqp_envelope.c amqp_object_store.c');
+ AC_DEFINE('HAVE_AMQP', 1);
+ } else {
+ WARNING("amqp not enabled; libraries and headers not found");
+ }
+}
diff --git a/amqp-1.6.1/php_amqp.h b/amqp-1.6.1/php_amqp.h
new file mode 100644
index 0000000..837f89d
--- /dev/null
+++ b/amqp-1.6.1/php_amqp.h
@@ -0,0 +1,466 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | 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: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: php_amqp.h 327551 2012-09-09 03:49:34Z pdezwart $ */
+
+#ifndef PHP_AMQP_H
+#define PHP_AMQP_H
+
+
+
+/* Add pseudo refcount macros for PHP version < 5.3 */
+#ifndef Z_REFCOUNT_PP
+
+#define Z_REFCOUNT_PP(ppz) Z_REFCOUNT_P(*(ppz))
+#define Z_SET_REFCOUNT_PP(ppz, rc) Z_SET_REFCOUNT_P(*(ppz), rc)
+#define Z_ADDREF_PP(ppz) Z_ADDREF_P(*(ppz))
+#define Z_DELREF_PP(ppz) Z_DELREF_P(*(ppz))
+#define Z_ISREF_PP(ppz) Z_ISREF_P(*(ppz))
+#define Z_SET_ISREF_PP(ppz) Z_SET_ISREF_P(*(ppz))
+#define Z_UNSET_ISREF_PP(ppz) Z_UNSET_ISREF_P(*(ppz))
+#define Z_SET_ISREF_TO_PP(ppz, isref) Z_SET_ISREF_TO_P(*(ppz), isref)
+
+#define Z_REFCOUNT_P(pz) zval_refcount_p(pz)
+#define Z_SET_REFCOUNT_P(pz, rc) zval_set_refcount_p(pz, rc)
+#define Z_ADDREF_P(pz) zval_addref_p(pz)
+#define Z_DELREF_P(pz) zval_delref_p(pz)
+#define Z_ISREF_P(pz) zval_isref_p(pz)
+#define Z_SET_ISREF_P(pz) zval_set_isref_p(pz)
+#define Z_UNSET_ISREF_P(pz) zval_unset_isref_p(pz)
+#define Z_SET_ISREF_TO_P(pz, isref) zval_set_isref_to_p(pz, isref)
+
+#define Z_REFCOUNT(z) Z_REFCOUNT_P(&(z))
+#define Z_SET_REFCOUNT(z, rc) Z_SET_REFCOUNT_P(&(z), rc)
+#define Z_ADDREF(z) Z_ADDREF_P(&(z))
+#define Z_DELREF(z) Z_DELREF_P(&(z))
+#define Z_ISREF(z) Z_ISREF_P(&(z))
+#define Z_SET_ISREF(z) Z_SET_ISREF_P(&(z))
+#define Z_UNSET_ISREF(z) Z_UNSET_ISREF_P(&(z))
+#define Z_SET_ISREF_TO(z, isref) Z_SET_ISREF_TO_P(&(z), isref)
+
+#define ZEND_FCI_INITIALIZED(fci) ((fci).size != 0)
+
+#define MAKE_COPY_ZVAL(ppzv, pzv) \
+ *(pzv) = **(ppzv); \
+ zval_copy_ctor((pzv)); \
+ INIT_PZVAL((pzv));
+
+#if defined(__GNUC__)
+#define zend_always_inline inline __attribute__((always_inline))
+#elif defined(_MSC_VER)
+#define zend_always_inline __forceinline
+#else
+#define zend_always_inline inline
+#endif
+
+static zend_always_inline zend_uint zval_refcount_p(zval* pz) {
+ return pz->refcount;
+}
+
+static zend_always_inline zend_uint zval_set_refcount_p(zval* pz, zend_uint rc) {
+ return pz->refcount = rc;
+}
+
+static zend_always_inline zend_uint zval_addref_p(zval* pz) {
+ return ++pz->refcount;
+}
+
+static zend_always_inline zend_uint zval_delref_p(zval* pz) {
+ return --pz->refcount;
+}
+
+static zend_always_inline zend_bool zval_isref_p(zval* pz) {
+ return pz->is_ref;
+}
+
+static zend_always_inline zend_bool zval_set_isref_p(zval* pz) {
+ return pz->is_ref = 1;
+}
+
+static zend_always_inline zend_bool zval_unset_isref_p(zval* pz) {
+ return pz->is_ref = 0;
+}
+
+static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isref) {
+ return pz->is_ref = isref;
+}
+
+static zend_always_inline zend_fcall_info empty_fcall_info = { 0, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0 };
+
+#else
+
+#define PHP_ATLEAST_5_3 true
+
+#endif
+
+
+#include "amqp.h"
+#include "amqp_object_store.h"
+
+extern zend_module_entry amqp_module_entry;
+#define phpext_amqp_ptr &amqp_module_entry
+
+#ifdef PHP_WIN32
+#define PHP_AMQP_API __declspec(dllexport)
+#else
+#define PHP_AMQP_API
+#endif
+
+#ifdef ZTS
+#include "TSRM.h"
+#endif
+
+#define AMQP_NOPARAM 0
+/* Where is 1?*/
+#define AMQP_JUST_CONSUME 1
+#define AMQP_DURABLE 2
+#define AMQP_PASSIVE 4
+#define AMQP_EXCLUSIVE 8
+#define AMQP_AUTODELETE 16
+#define AMQP_INTERNAL 32
+#define AMQP_NOLOCAL 64
+#define AMQP_AUTOACK 128
+#define AMQP_IFEMPTY 256
+#define AMQP_IFUNUSED 512
+#define AMQP_MANDATORY 1024
+#define AMQP_IMMEDIATE 2048
+#define AMQP_MULTIPLE 4096
+#define AMQP_NOWAIT 8192
+#define AMQP_REQUEUE 16384
+
+/* passive, durable, auto-delete, internal, no-wait (see https://www.rabbitmq.com/amqp-0-9-1-reference.html#exchange.declare) */
+#define PHP_AMQP_EXCHANGE_FLAGS (AMQP_PASSIVE | AMQP_DURABLE | AMQP_AUTODELETE | AMQP_INTERNAL)
+
+/* passive, durable, exclusive, auto-delete, no-wait (see https://www.rabbitmq.com/amqp-0-9-1-reference.html#queue.declare) */
+#define PHP_AMQP_QUEUE_FLAGS (AMQP_PASSIVE | AMQP_DURABLE | AMQP_EXCLUSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE)
+
+#define AMQP_EX_TYPE_DIRECT "direct"
+#define AMQP_EX_TYPE_FANOUT "fanout"
+#define AMQP_EX_TYPE_TOPIC "topic"
+#define AMQP_EX_TYPE_HEADERS "headers"
+
+#define PHP_AMQP_CONNECTION_RES_NAME "AMQP Connection Resource"
+
+PHP_MINIT_FUNCTION(amqp);
+PHP_MSHUTDOWN_FUNCTION(amqp);
+PHP_MINFO_FUNCTION(amqp);
+
+amqp_table_t *convert_zval_to_amqp_table(zval *zvalArguments TSRMLS_DC);
+void php_amqp_free_amqp_table(amqp_table_t * table);
+
+char *stringify_bytes(amqp_bytes_t bytes);
+
+/* True global resources - no need for thread safety here */
+extern zend_class_entry *amqp_connection_class_entry;
+extern zend_class_entry *amqp_channel_class_entry;
+extern zend_class_entry *amqp_queue_class_entry;
+extern zend_class_entry *amqp_exchange_class_entry;
+extern zend_class_entry *amqp_envelope_class_entry;
+
+extern zend_class_entry *amqp_exception_class_entry,
+ *amqp_connection_exception_class_entry,
+ *amqp_channel_exception_class_entry,
+ *amqp_exchange_exception_class_entry,
+ *amqp_queue_exception_class_entry;
+
+
+#define DEFAULT_PORT "5672" /* default AMQP port */
+#define DEFAULT_HOST "localhost"
+#define DEFAULT_TIMEOUT ""
+#define DEFAULT_READ_TIMEOUT "0"
+#define DEFAULT_WRITE_TIMEOUT "0"
+#define DEFAULT_CONNECT_TIMEOUT "0"
+#define DEFAULT_VHOST "/"
+#define DEFAULT_LOGIN "guest"
+#define DEFAULT_PASSWORD "guest"
+#define DEFAULT_AUTOACK "0" /* These are all strings to facilitate setting default ini values */
+#define DEFAULT_PREFETCH_COUNT "3"
+
+/* Usually, default is 0 which means 65535, but underlying rabbitmq-c library pool allocates minimal pool for each channel,
+ * so it takes a lot of memory to keep all that channels. Even after channel closing that buffer still keep memory allocation.
+ */
+/* #define DEFAULT_CHANNELS_PER_CONNECTION AMQP_DEFAULT_MAX_CHANNELS */
+#define PHP_AMQP_PROTOCOL_MAX_CHANNELS 256
+
+//AMQP_DEFAULT_FRAME_SIZE 131072
+
+#if PHP_AMQP_PROTOCOL_MAX_CHANNELS > 0
+ #define PHP_AMQP_MAX_CHANNELS PHP_AMQP_PROTOCOL_MAX_CHANNELS
+#else
+ #define PHP_AMQP_MAX_CHANNELS 65535 // Note that the maximum number of channels the protocol supports is 65535 (2^16, with the 0-channel reserved)
+#endif
+
+#define PHP_AMQP_MAX_FRAME INT_MAX
+#define PHP_AMQP_MAX_HEARTBEAT INT_MAX
+
+#define PHP_AMQP_DEFAULT_CHANNEL_MAX PHP_AMQP_MAX_CHANNELS
+#define PHP_AMQP_DEFAULT_FRAME_MAX AMQP_DEFAULT_FRAME_SIZE
+#define PHP_AMQP_DEFAULT_HEARTBEAT AMQP_DEFAULT_HEARTBEAT
+
+#define PHP_AMQP_STRINGIFY(value) PHP_AMQP_TO_STRING(value)
+#define PHP_AMQP_TO_STRING(value) #value
+
+
+#define DEFAULT_CHANNEL_MAX PHP_AMQP_STRINGIFY(PHP_AMQP_MAX_CHANNELS)
+#define DEFAULT_FRAME_MAX PHP_AMQP_STRINGIFY(PHP_AMQP_DEFAULT_FRAME_MAX)
+#define DEFAULT_HEARTBEAT PHP_AMQP_STRINGIFY(PHP_AMQP_DEFAULT_HEARTBEAT)
+
+#define AMQP_READ_SUCCESS 1
+#define AMQP_READ_NO_MESSAGES 0
+#define AMQP_READ_ERROR -1
+
+
+#define IS_PASSIVE(bitmask) (AMQP_PASSIVE & (bitmask)) ? 1 : 0
+#define IS_DURABLE(bitmask) (AMQP_DURABLE & (bitmask)) ? 1 : 0
+#define IS_EXCLUSIVE(bitmask) (AMQP_EXCLUSIVE & (bitmask)) ? 1 : 0
+#define IS_AUTODELETE(bitmask) (AMQP_AUTODELETE & (bitmask)) ? 1 : 0
+#define IS_INTERNAL(bitmask) (AMQP_INTERNAL & (bitmask)) ? 1 : 0
+#define IS_NOWAIT(bitmask) (AMQP_NOWAIT & (bitmask)) ? 1 : 0 /* NOTE: always 0 in rabbitmq-c internals, so don't use it unless you are clearly understand aftermath*/
+
+
+
+#define AMQP_SET_NAME(object, str) \
+ (object)->name_len = strlen(str) >= sizeof((object)->name) ? sizeof((object)->name) - 1 : strlen(str); \
+ strncpy((object)->name, name, (object)->name_len); \
+ (object)->name[(object)->name_len] = '\0';
+
+#define AMQP_SET_TYPE(object, str) \
+ (object)->type_len = strlen(str) >= sizeof((object)->type) ? sizeof((object)->type) - 1 : strlen(str); \
+ strncpy((object)->type, type, (object)->type_len); \
+ (object)->type[(object)->type_len] = '\0';
+
+#define AMQP_SET_LONG_PROPERTY(object, value) \
+ (object) = (value);
+
+#define AMQP_SET_BOOL_PROPERTY(object, value) \
+ (object) = (value) == 0 ? 0 : 1;
+
+#define AMQP_SET_STR_PROPERTY(object, str, len) \
+ strncpy((object), (str), (len) >= sizeof(object) ? sizeof(object) - 1 : (len)); \
+ (object)[(len) >= sizeof(object) ? sizeof(object) - 1 : (len)] = '\0';
+
+#define AMQP_GET_CHANNEL(object) \
+ (amqp_channel_object *) amqp_object_store_get_valid_object((object)->channel TSRMLS_CC);
+
+#define AMQP_ASSIGN_CHANNEL(channel, object) \
+ if (!(object)->channel) { \
+ return; \
+ } \
+ channel = AMQP_GET_CHANNEL(object)
+
+#define AMQP_GET_CONNECTION(object) \
+ (amqp_connection_object *) amqp_object_store_get_valid_object((object)->connection TSRMLS_CC);
+
+#define AMQP_ASSIGN_CONNECTION(connection, object) \
+ if (!(object)->connection) { \
+ return; \
+ } \
+ connection = AMQP_GET_CONNECTION(object)
+
+
+#define AMQP_VERIFY_CHANNEL_ERROR(error, reason) \
+ char verify_channel_error_tmp[255]; \
+ snprintf(verify_channel_error_tmp, 255, "%s %s", error, reason); \
+ zend_throw_exception(amqp_channel_exception_class_entry, verify_channel_error_tmp, 0 TSRMLS_CC); \
+ return; \
+
+#define AMQP_VERIFY_CHANNEL(channel, error) \
+ if (!channel) { \
+ AMQP_VERIFY_CHANNEL_ERROR(error, "Stale reference to the channel object.") \
+ } \
+ if ((channel)->is_connected != '\1') { \
+ AMQP_VERIFY_CHANNEL_ERROR(error, "No channel available.") \
+ } \
+
+#define AMQP_VERIFY_CONNECTION_ERROR(error, reason) \
+ char verify_connection_error_tmp[255]; \
+ snprintf(verify_connection_error_tmp, 255, "%s %s", error, reason); \
+ zend_throw_exception(amqp_connection_exception_class_entry, verify_connection_error_tmp, 0 TSRMLS_CC); \
+ return; \
+
+#define AMQP_VERIFY_CONNECTION(connection, error) \
+ if (!connection) { \
+ AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \
+ } \
+ if ((connection)->is_connected != '\1') { \
+ AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \
+ } \
+
+#define PHP_AMQP_ERROR_MESSAGE_PTR &php_amqp_internal_error_message
+#define PHP_AMQP_ERROR_MESSAGE php_amqp_internal_error_message
+
+#define PHP_AMQP_INIT_ERROR_MESSAGE()\
+ char *PHP_AMQP_ERROR_MESSAGE = NULL;
+
+#define PHP_AMQP_DESTROY_ERROR_MESSAGE()\
+ if (PHP_AMQP_ERROR_MESSAGE != NULL) { efree(PHP_AMQP_ERROR_MESSAGE); }
+
+#if ZEND_MODULE_API_NO >= 20100000
+ #define AMQP_OBJECT_PROPERTIES_INIT(obj, ce) object_properties_init(&obj, ce);
+#else
+ #define AMQP_OBJECT_PROPERTIES_INIT(obj, ce) \
+ do { \
+ zval *tmp; \
+ zend_hash_copy((obj).properties, &(ce)->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); \
+ } while (0);
+#endif
+
+typedef struct _amqp_channel_object {
+ zend_object zo;
+ zval *connection;
+ amqp_channel_t channel_id;
+ char is_connected;
+ int prefetch_count;
+ int prefetch_size;
+} amqp_channel_object;
+
+typedef struct _amqp_connection_resource {
+ zend_bool is_connected;
+ int resource_id;
+ amqp_channel_t max_slots;
+ amqp_channel_t used_slots;
+ amqp_channel_object **slots;
+ char *resource_key;
+ int resource_key_len;
+ amqp_connection_state_t connection_state;
+ amqp_socket_t *socket;
+} amqp_connection_resource;
+
+typedef struct _amqp_connection_object {
+ zend_object zo;
+ char is_connected;
+ char is_persistent;
+ char *login;
+ char *password;
+ char *host;
+ char *vhost;
+ int port;
+ int channel_max;
+ int frame_max;
+ int heartbeat;
+ double read_timeout;
+ double write_timeout;
+ double connect_timeout;
+ amqp_connection_resource *connection_resource;
+} amqp_connection_object;
+
+typedef struct _amqp_queue_object {
+ zend_object zo;
+ zval *channel;
+ char name[256];
+ int name_len;
+ char consumer_tag[256];
+ int consumer_tag_len;
+ int flags;
+ zval *arguments;
+} amqp_queue_object;
+
+typedef struct _amqp_exchange_object {
+ zend_object zo;
+ zval *channel;
+ char is_connected;
+ char name[256];
+ int name_len;
+ char type[256];
+ int type_len;
+ int flags;
+ zval *arguments;
+} amqp_exchange_object;
+
+typedef struct _amqp_envelope_object {
+ zend_object zo;
+ char *body;
+ size_t body_len;
+ char routing_key[256];
+ uint delivery_tag;
+ int delivery_mode;
+ char exchange_name[256];
+ int is_redelivery;
+ char content_type[256];
+ char content_encoding[256];
+ char type[256];
+ long timestamp;
+ int priority;
+ char expiration[256];
+ char user_id[256];
+ char app_id[256];
+ char message_id[256];
+ char reply_to[256];
+ char correlation_id[256];
+ zval *headers;
+} amqp_envelope_object;
+
+
+#define AMQP_ERROR_CATEGORY_MASK (1 << 29)
+
+#ifdef PHP_WIN32
+# define AMQP_RPC_REPLY_T_CAST
+#else
+# define AMQP_RPC_REPLY_T_CAST (amqp_rpc_reply_t)
+#endif
+
+#ifdef PHP_WIN32
+# define AMQP_CLOSE_SOCKET(fd) closesocket(fd);
+#else
+# define AMQP_CLOSE_SOCKET(fd) close(fd);
+#endif
+
+#ifdef PHP_WIN32
+# define AMQP_OS_SOCKET_TIMEOUT_ERRNO AMQP_ERROR_CATEGORY_MASK | WSAETIMEDOUT
+#else
+# define AMQP_OS_SOCKET_TIMEOUT_ERRNO AMQP_ERROR_CATEGORY_MASK | EAGAIN
+#endif
+
+
+#ifdef ZTS
+#define AMQP_G(v) TSRMG(amqp_globals_id, zend_amqp_globals *, v)
+#else
+#define AMQP_G(v) (amqp_globals.v)
+#endif
+
+#ifndef PHP_AMQP_VERSION
+#define PHP_AMQP_VERSION "1.6.1"
+#endif
+
+#ifndef PHP_AMQP_REVISION
+#define PHP_AMQP_REVISION "release"
+#endif
+
+void php_amqp_error(amqp_rpc_reply_t reply, char **message, amqp_connection_object *connection, amqp_channel_object *channel TSRMLS_DC);
+void php_amqp_zend_throw_exception(amqp_rpc_reply_t reply, zend_class_entry *exception_ce, const char *message, long code TSRMLS_DC);
+
+void php_amqp_maybe_release_buffers_on_channel(amqp_connection_object *connection, amqp_channel_object *channel);
+
+amqp_bytes_t php_amqp_long_string(char const *cstr, int len);
+
+#endif /* PHP_AMQP_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/amqp-1.6.1/tests/amqpchannel_basicRecover.phpt b/amqp-1.6.1/tests/amqpchannel_basicRecover.phpt
new file mode 100644
index 0000000..1a47839
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpchannel_basicRecover.phpt
@@ -0,0 +1,112 @@
+--TEST--
+AMQPChannel::basicRecover
+--SKIPIF--
+<?php
+if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<')) {
+ print "skip";
+}
+?>
+--FILE--
+<?php
+$time = microtime(true);
+
+$connection_1 = new AMQPConnection();
+$connection_1->connect();
+
+$channel_1 = new AMQPChannel($connection_1);
+$channel_1->setPrefetchCount(5);
+
+$exchange_1 = new AMQPExchange($channel_1);
+$exchange_1->setType(AMQP_EX_TYPE_TOPIC);
+$exchange_1->setName('test_' . $time);
+$exchange_1->setFlags(AMQP_AUTODELETE);
+$exchange_1->declareExchange();
+
+$queue_1 = new AMQPQueue($channel_1);
+$queue_1->setName('test_' . $time);
+$queue_1->setFlags(AMQP_DURABLE);
+$queue_1->declareQueue();
+
+$queue_1->bind($exchange_1->getName(), 'test');
+
+$messages_count = 0;
+while ($messages_count++ < 10) {
+ $exchange_1->publish('test message #' . $messages_count, 'test');
+ //echo 'published test message #' . $messages_count, PHP_EOL;
+}
+
+$consume = 2; // NOTE: by default prefetch-count=3, so in consumer below we will ignore prefetched messages 3-5,
+ // and they will not seen by other consumers until we redeliver it.
+$queue_1->consume(function(AMQPEnvelope $e, AMQPQueue $q) use (&$consume) {
+ echo 'consumed ', $e->getBody(), ' ', ($e->isRedelivery() ? '(redelivered)' : '(original)'), PHP_EOL;
+ $q->ack($e->getDeliveryTag());
+
+ return (-- $consume > 0);
+});
+$queue_1->cancel(); // we have to do that to prevent redelivering to the same consumer
+
+$connection_2 = new AMQPConnection();
+$connection_2->setReadTimeout(1);
+
+$connection_2->connect();
+$channel_2 = new AMQPChannel($connection_2);
+$channel_2->setPrefetchCount(8);
+
+
+$queue_2 = new AMQPQueue($channel_2);
+$queue_2->setName('test_' . $time);
+
+$consume = 10;
+try {
+
+ $queue_2->consume(function (AMQPEnvelope $e, AMQPQueue $q) use (&$consume) {
+ echo 'consumed ' . $e->getBody(), ' ', ($e->isRedelivery() ? '(redelivered)' : '(original)'), PHP_EOL;
+ $q->ack($e->getDeliveryTag());
+
+ return (--$consume > 0);
+ });
+
+} catch (AMQPException $e) {
+ echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
+}
+$queue_2->cancel();
+//var_dump($connection_2, $channel_2);die;
+
+
+// yes, we do it repeatedly, basic.recover works in a slightly different way than it looks like. As it said,
+// it "asks the server to redeliver all unacknowledged messages on a specified channel.
+// ZERO OR MORE messages MAY BE redelivered"
+$channel_1->basicRecover();
+
+echo 'redelivered', PHP_EOL;
+
+$consume = 10;
+try {
+
+ $queue_2->consume(function (AMQPEnvelope $e, AMQPQueue $q) use (&$consume) {
+ echo 'consumed ' . $e->getBody(), ' ', ($e->isRedelivery() ? '(redelivered)' : '(original)'), PHP_EOL;
+ $q->ack($e->getDeliveryTag());
+
+ return (--$consume > 0);
+ });
+
+} catch (AMQPException $e) {
+ echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
+}
+
+
+?>
+--EXPECT--
+consumed test message #1 (original)
+consumed test message #2 (original)
+consumed test message #8 (original)
+consumed test message #9 (original)
+consumed test message #10 (original)
+AMQPQueueException: Consumer timeout exceed
+redelivered
+consumed test message #3 (redelivered)
+consumed test message #4 (redelivered)
+consumed test message #5 (redelivered)
+consumed test message #6 (redelivered)
+consumed test message #7 (redelivered)
+AMQPQueueException: Consumer timeout exceed
diff --git a/amqp-1.6.1/tests/amqpchannel_construct_basic.phpt b/amqp-1.6.1/tests/amqpchannel_construct_basic.phpt
new file mode 100644
index 0000000..2714111
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpchannel_construct_basic.phpt
@@ -0,0 +1,15 @@
+--TEST--
+AMQPChannel constructor
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+echo get_class($ch) . "\n";
+echo $ch->isConnected() ? 'true' : 'false';
+?>
+--EXPECT--
+AMQPChannel
+true
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpchannel_get_connection.phpt b/amqp-1.6.1/tests/amqpchannel_get_connection.phpt
new file mode 100644
index 0000000..29df770
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpchannel_get_connection.phpt
@@ -0,0 +1,32 @@
+--TEST--
+AMQPChannel getConnection test
+--SKIPIF--
+<?php
+if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<')) {
+ print "skip";
+}
+?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+
+$cnn2 = new AMQPConnection();
+
+echo $cnn === $ch->getConnection() ? 'same' : 'not same', PHP_EOL;
+echo $cnn2 === $ch->getConnection() ? 'same' : 'not same', PHP_EOL;
+
+$old_host = $cnn->getHost();
+$new_host = 'test';
+
+$ch->getConnection()->setHost($new_host);
+
+echo $cnn->getHost() == $new_host ? 'by ref' : 'copy', PHP_EOL;
+
+?>
+--EXPECT--
+same
+not same
+by ref
diff --git a/amqp-1.6.1/tests/amqpchannel_multi_channel_connection.phpt b/amqp-1.6.1/tests/amqpchannel_multi_channel_connection.phpt
new file mode 100644
index 0000000..47e9e3d
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpchannel_multi_channel_connection.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Multiple AMQPChannels per AMQPConnection
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+echo get_class($ch) . "\n";
+echo $ch->isConnected() ? 'true' : 'false';
+echo "\n";
+$ch2 = new AMQPChannel($cnn);
+echo get_class($ch) . "\n";
+echo $ch->isConnected() ? 'true' : 'false';
+
+unset($ch2);
+
+$ch->setPrefetchCount(10);
+
+?>
+--EXPECT--
+AMQPChannel
+true
+AMQPChannel
+true
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpchannel_slots_usage.phpt b/amqp-1.6.1/tests/amqpchannel_slots_usage.phpt
new file mode 100644
index 0000000..96d6691
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpchannel_slots_usage.phpt
@@ -0,0 +1,29 @@
+--TEST--
+AMQPChannel slots usage
+--SKIPIF--
+<?php
+if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<')) {
+ print "skip";
+}
+?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL;
+
+$ch = new AMQPChannel($cnn);
+echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL;
+
+$ch = new AMQPChannel($cnn);
+echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL;
+
+$ch = null;
+echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL;
+?>
+--EXPECT--
+Used channels: 0
+Used channels: 1
+Used channels: 1
+Used channels: 0
diff --git a/amqp-1.6.1/tests/amqpchannel_var_dump.phpt b/amqp-1.6.1/tests/amqpchannel_var_dump.phpt
new file mode 100644
index 0000000..816db43
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpchannel_var_dump.phpt
@@ -0,0 +1,40 @@
+--TEST--
+AMQPChannel var_dump
+--SKIPIF--
+<?php
+if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<')) {
+ print "skip";
+}
+?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+
+var_dump($ch);
+$cnn->disconnect();
+var_dump($ch);
+
+?>
+--EXPECT--
+object(AMQPChannel)#2 (4) {
+ ["channel_id"]=>
+ int(1)
+ ["prefetch_count"]=>
+ int(3)
+ ["prefetch_size"]=>
+ int(0)
+ ["is_connected"]=>
+ bool(true)
+}
+object(AMQPChannel)#2 (4) {
+ ["channel_id"]=>
+ int(1)
+ ["prefetch_count"]=>
+ int(3)
+ ["prefetch_size"]=>
+ int(0)
+ ["is_connected"]=>
+ bool(false)
+}
diff --git a/amqp-1.6.1/tests/amqpconnection_connect_login_failure.phpt b/amqp-1.6.1/tests/amqpconnection_connect_login_failure.phpt
new file mode 100644
index 0000000..0d7bf4d
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_connect_login_failure.phpt
@@ -0,0 +1,33 @@
+--TEST--
+AMQPConnection connect login failure
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+//ini_set('amqp.connect_timeout', 60);
+//ini_set('amqp.read_timeout', 60);
+//ini_set('amqp.write_timeout', 60);
+
+$cnn = new AMQPConnection();
+$cnn->setLogin('nonexistent-login-'.microtime(true));
+$cnn->setPassword('nonexistent-password-'.microtime(true));
+
+//var_dump($cnn);
+
+echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
+//
+try {
+ $cnn->connect();
+ echo 'Connected', PHP_EOL;
+} catch (AMQPException $e) {
+ echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
+}
+//
+echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
+
+// NOTE: in real-world environment (incl. travis ci) "a socket error occurred" happens, but in vagrant environment "connection closed unexpectedly" happens. WTF?
+?>
+--EXPECTF--
+disconnected
+AMQPConnectionException: %s error: %s - Potential login failure.
+disconnected
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpconnection_construct_basic.phpt b/amqp-1.6.1/tests/amqpconnection_construct_basic.phpt
new file mode 100644
index 0000000..b379f82
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_construct_basic.phpt
@@ -0,0 +1,14 @@
+--TEST--
+AMQPConnection constructor
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+echo get_class($cnn) . "\n";
+echo $cnn->isConnected() ? 'true' : 'false';
+?>
+--EXPECT--
+AMQPConnection
+true
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpconnection_construct_ini_read_timeout.phpt b/amqp-1.6.1/tests/amqpconnection_construct_ini_read_timeout.phpt
new file mode 100644
index 0000000..b108bc3
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_construct_ini_read_timeout.phpt
@@ -0,0 +1,13 @@
+--TEST--
+AMQPConnection constructor with amqp.read_timeout ini value set
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--INI--
+amqp.read_timeout=202.202
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+var_dump($cnn->getReadTimeout());
+?>
+--EXPECTF--
+float(202.202)
diff --git a/amqp-1.6.1/tests/amqpconnection_construct_ini_timeout.phpt b/amqp-1.6.1/tests/amqpconnection_construct_ini_timeout.phpt
new file mode 100644
index 0000000..e600b51
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_construct_ini_timeout.phpt
@@ -0,0 +1,14 @@
+--TEST--
+AMQPConnection constructor with amqp.timeout ini value set
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--INI--
+amqp.timeout=101.101
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+var_dump($cnn->getReadTimeout());
+?>
+--EXPECTF--
+%s: AMQPConnection::__construct(): INI setting 'amqp.timeout' is deprecated; use 'amqp.read_timeout' instead in %s on line 2
+float(101.101)
diff --git a/amqp-1.6.1/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt b/amqp-1.6.1/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt
new file mode 100644
index 0000000..5e0050d
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt
@@ -0,0 +1,17 @@
+--TEST--
+AMQPConnection constructor with both amqp.timeout and amqp.read_timeout ini values set
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--INI--
+amqp.timeout = 101.101
+amqp.read_timeout = 202.202
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+var_dump($cnn->getReadTimeout());
+?>
+--EXPECTF--
+%s: AMQPConnection::__construct(): INI setting 'amqp.timeout' is deprecated; use 'amqp.read_timeout' instead in %s on line 2
+
+Notice: AMQPConnection::__construct(): INI setting 'amqp.read_timeout' will be used instead of 'amqp.timeout' in %s on line 2
+float(202.202)
diff --git a/amqp-1.6.1/tests/amqpconnection_construct_ini_timeout_default.phpt b/amqp-1.6.1/tests/amqpconnection_construct_ini_timeout_default.phpt
new file mode 100644
index 0000000..e702a09
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_construct_ini_timeout_default.phpt
@@ -0,0 +1,13 @@
+--TEST--
+AMQPConnection constructor with amqp.timeout ini value set in code to it default value
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+ini_set('amqp.timeout', ini_get('amqp.timeout'));
+
+$cnn = new AMQPConnection();
+var_dump($cnn->getReadTimeout());
+?>
+--EXPECTF--
+float(0)
diff --git a/amqp-1.6.1/tests/amqpconnection_construct_with_connect_timeout.phpt b/amqp-1.6.1/tests/amqpconnection_construct_with_connect_timeout.phpt
new file mode 100644
index 0000000..8a55349
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_construct_with_connect_timeout.phpt
@@ -0,0 +1,43 @@
+--TEST--
+AMQPConnection constructor with timeout parameter in creadentials
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+try {
+ $cnn = new AMQPConnection(array('connect_timeout' => -1.5));
+} catch (AMQPConnectionException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+
+$timeout = 10.5;
+
+// resolve hostname to don't waste time on resolve inside library while resolve operations are not under timings limit (yet)
+$credentials = array('host' => gethostbyname('google.com'), 'connect_timeout' => $timeout);
+//$credentials = array('host' => 'google.com', 'connect_timeout' => $timeout);
+$cnn = new AMQPConnection($credentials);
+
+$start = microtime(true);
+
+try {
+ $cnn->connect();
+} catch (AMQPConnectionException $e) {
+ echo $e->getMessage(), PHP_EOL;
+ $end = microtime(true);
+
+ $error = $end - $start - $timeout;
+
+ $limit = abs(log10($timeout)); // empirical value
+
+ echo 'error: ', $error, PHP_EOL;
+ echo 'limit: ', $limit, PHP_EOL;
+
+ echo abs($error) <= $limit ? 'timings OK' : 'timings failed'; // error should be less than 5% of timeout value
+}
+?>
+--EXPECTF--
+Parameter 'connect_timeout' must be greater than or equal to zero.
+Socket error: could not connect to host.
+error: %f
+limit: %f
+timings OK
diff --git a/amqp-1.6.1/tests/amqpconnection_construct_with_timeout.phpt b/amqp-1.6.1/tests/amqpconnection_construct_with_timeout.phpt
new file mode 100644
index 0000000..2b0673b
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_construct_with_timeout.phpt
@@ -0,0 +1,13 @@
+--TEST--
+AMQPConnection constructor with timeout parameter in creadentials
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$credentials = array('timeout' => 101.101);
+$cnn = new AMQPConnection($credentials);
+var_dump($cnn->getReadTimeout());
+?>
+--EXPECTF--
+%s: AMQPConnection::__construct(): Parameter 'timeout' is deprecated; use 'read_timeout' instead in %s on line 3
+float(101.101)
diff --git a/amqp-1.6.1/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt b/amqp-1.6.1/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt
new file mode 100644
index 0000000..1e95ea2
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt
@@ -0,0 +1,13 @@
+--TEST--
+AMQPConnection constructor with both timeout and read_timeout parameters in creadentials
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$credentials = array('timeout' => 101.101, 'read_timeout' => 202.202);
+$cnn = new AMQPConnection($credentials);
+var_dump($cnn->getReadTimeout());
+?>
+--EXPECTF--
+Notice: AMQPConnection::__construct(): Parameter 'timeout' is deprecated, 'read_timeout' used instead in %s on line 3
+float(202.202)
diff --git a/amqp-1.6.1/tests/amqpconnection_construct_with_write_timeout.phpt b/amqp-1.6.1/tests/amqpconnection_construct_with_write_timeout.phpt
new file mode 100644
index 0000000..27e1151
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_construct_with_write_timeout.phpt
@@ -0,0 +1,12 @@
+--TEST--
+AMQPConnection constructor with write_timeout parameter in creadentials
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$credentials = array('write_timeout' => 303.303);
+$cnn = new AMQPConnection($credentials);
+var_dump($cnn->getWriteTimeout());
+?>
+--EXPECT--
+float(303.303)
diff --git a/amqp-1.6.1/tests/amqpconnection_persistent_construct_basic.phpt b/amqp-1.6.1/tests/amqpconnection_persistent_construct_basic.phpt
new file mode 100644
index 0000000..57dcfb0
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_persistent_construct_basic.phpt
@@ -0,0 +1,14 @@
+--TEST--
+AMQPConnection persitent constructor
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->pconnect();
+echo get_class($cnn) . "\n";
+echo $cnn->isConnected() ? 'true' : 'false';
+?>
+--EXPECT--
+AMQPConnection
+true
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpconnection_persistent_in_use.phpt b/amqp-1.6.1/tests/amqpconnection_persistent_in_use.phpt
new file mode 100644
index 0000000..20f16f2
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_persistent_in_use.phpt
@@ -0,0 +1,32 @@
+--TEST--
+AMQPConnection persitent connection resource can't be used by multiple connection
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+echo get_class($cnn), PHP_EOL;
+$cnn->pconnect();
+echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL;
+
+echo PHP_EOL;
+
+$cnn2 = new AMQPConnection();
+echo get_class($cnn), PHP_EOL;
+
+try {
+ $cnn2->pconnect();
+ echo 'reused', PHP_EOL;
+} catch (AMQPException $e) {
+ echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
+}
+echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL;
+
+?>
+--EXPECT--
+AMQPConnection
+true
+
+AMQPConnection
+AMQPConnectionException: There are already established persistent connection to the same resource.
+true
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpconnection_persistent_reusable.phpt b/amqp-1.6.1/tests/amqpconnection_persistent_reusable.phpt
new file mode 100644
index 0000000..53118a2
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_persistent_reusable.phpt
@@ -0,0 +1,28 @@
+--TEST--
+AMQPConnection persistent connection are reusable
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->pconnect();
+echo get_class($cnn), PHP_EOL;
+echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL;
+
+$cnn = null;
+echo PHP_EOL;
+
+$cnn = new AMQPConnection();
+$cnn->pconnect();
+echo get_class($cnn), PHP_EOL;
+echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL;
+
+$cnn->pdisconnect();
+
+?>
+--EXPECT--
+AMQPConnection
+true
+
+AMQPConnection
+true
diff --git a/amqp-1.6.1/tests/amqpconnection_persistent_var_dump.phpt b/amqp-1.6.1/tests/amqpconnection_persistent_var_dump.phpt
new file mode 100644
index 0000000..c4c22cf
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_persistent_var_dump.phpt
@@ -0,0 +1,148 @@
+--TEST--
+AMQPConnection: persistent connection var_dump
+--SKIPIF--
+<?php if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<') ) print "skip"; ?>
+--FILE--
+<?php
+
+$cnn = new AMQPConnection();
+var_dump($cnn);
+$cnn->pconnect();
+var_dump($cnn);
+
+$ch = new AMQPChannel($cnn);
+var_dump($cnn);
+
+$cnn->pdisconnect();
+var_dump($cnn);
+
+?>
+--EXPECT--
+object(AMQPConnection)#1 (15) {
+ ["login"]=>
+ string(5) "guest"
+ ["password"]=>
+ string(5) "guest"
+ ["host"]=>
+ string(9) "localhost"
+ ["vhost"]=>
+ string(1) "/"
+ ["port"]=>
+ int(5672)
+ ["read_timeout"]=>
+ float(0)
+ ["write_timeout"]=>
+ float(0)
+ ["connect_timeout"]=>
+ float(0)
+ ["is_connected"]=>
+ bool(false)
+ ["is_persistent"]=>
+ bool(false)
+ ["connection_resource"]=>
+ NULL
+ ["used_channels"]=>
+ NULL
+ ["max_channel_id"]=>
+ NULL
+ ["max_frame_size"]=>
+ NULL
+ ["heartbeat_interval"]=>
+ NULL
+}
+object(AMQPConnection)#1 (15) {
+ ["login"]=>
+ string(5) "guest"
+ ["password"]=>
+ string(5) "guest"
+ ["host"]=>
+ string(9) "localhost"
+ ["vhost"]=>
+ string(1) "/"
+ ["port"]=>
+ int(5672)
+ ["read_timeout"]=>
+ float(0)
+ ["write_timeout"]=>
+ float(0)
+ ["connect_timeout"]=>
+ float(0)
+ ["is_connected"]=>
+ bool(true)
+ ["is_persistent"]=>
+ bool(true)
+ ["connection_resource"]=>
+ resource(4) of type (AMQP Connection Resource)
+ ["used_channels"]=>
+ int(0)
+ ["max_channel_id"]=>
+ int(256)
+ ["max_frame_size"]=>
+ int(131072)
+ ["heartbeat_interval"]=>
+ int(0)
+}
+object(AMQPConnection)#1 (15) {
+ ["login"]=>
+ string(5) "guest"
+ ["password"]=>
+ string(5) "guest"
+ ["host"]=>
+ string(9) "localhost"
+ ["vhost"]=>
+ string(1) "/"
+ ["port"]=>
+ int(5672)
+ ["read_timeout"]=>
+ float(0)
+ ["write_timeout"]=>
+ float(0)
+ ["connect_timeout"]=>
+ float(0)
+ ["is_connected"]=>
+ bool(true)
+ ["is_persistent"]=>
+ bool(true)
+ ["connection_resource"]=>
+ resource(4) of type (AMQP Connection Resource)
+ ["used_channels"]=>
+ int(1)
+ ["max_channel_id"]=>
+ int(256)
+ ["max_frame_size"]=>
+ int(131072)
+ ["heartbeat_interval"]=>
+ int(0)
+}
+object(AMQPConnection)#1 (15) {
+ ["login"]=>
+ string(5) "guest"
+ ["password"]=>
+ string(5) "guest"
+ ["host"]=>
+ string(9) "localhost"
+ ["vhost"]=>
+ string(1) "/"
+ ["port"]=>
+ int(5672)
+ ["read_timeout"]=>
+ float(0)
+ ["write_timeout"]=>
+ float(0)
+ ["connect_timeout"]=>
+ float(0)
+ ["is_connected"]=>
+ bool(false)
+ ["is_persistent"]=>
+ bool(false)
+ ["connection_resource"]=>
+ NULL
+ ["used_channels"]=>
+ NULL
+ ["max_channel_id"]=>
+ NULL
+ ["max_frame_size"]=>
+ NULL
+ ["heartbeat_interval"]=>
+ NULL
+}
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpconnection_setHost.phpt b/amqp-1.6.1/tests/amqpconnection_setHost.phpt
new file mode 100644
index 0000000..ec6ccf8
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setHost.phpt
@@ -0,0 +1,13 @@
+--TEST--
+AMQPConnection setHost
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+var_dump($cnn->getHost());
+$cnn->setHost('nonexistent');
+var_dump($cnn->getHost());
+--EXPECTF--
+string(9) "localhost"
+string(11) "nonexistent"
diff --git a/amqp-1.6.1/tests/amqpconnection_setLogin.phpt b/amqp-1.6.1/tests/amqpconnection_setLogin.phpt
new file mode 100644
index 0000000..92fcfae
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setLogin.phpt
@@ -0,0 +1,13 @@
+--TEST--
+AMQPConnection setLogin
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+var_dump($cnn->getLogin());
+$cnn->setLogin('nonexistent');
+var_dump($cnn->getLogin());
+--EXPECTF--
+string(5) "guest"
+string(11) "nonexistent"
diff --git a/amqp-1.6.1/tests/amqpconnection_setPassword.phpt b/amqp-1.6.1/tests/amqpconnection_setPassword.phpt
new file mode 100644
index 0000000..2285b0c
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setPassword.phpt
@@ -0,0 +1,13 @@
+--TEST--
+AMQPConnection setPassword
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+var_dump($cnn->getPassword());
+$cnn->setPassword('nonexistent');
+var_dump($cnn->getPassword());
+--EXPECTF--
+string(5) "guest"
+string(11) "nonexistent"
diff --git a/amqp-1.6.1/tests/amqpconnection_setPort_int.phpt b/amqp-1.6.1/tests/amqpconnection_setPort_int.phpt
new file mode 100644
index 0000000..5dc60cf
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setPort_int.phpt
@@ -0,0 +1,11 @@
+--TEST--
+AMQPConnection constructor
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+echo $cnn->setPort(12345);
+?>
+--EXPECT--
+1
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpconnection_setPort_out_of_range.phpt b/amqp-1.6.1/tests/amqpconnection_setPort_out_of_range.phpt
new file mode 100644
index 0000000..7e45d6b
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setPort_out_of_range.phpt
@@ -0,0 +1,15 @@
+--TEST--
+AMQPConnection setPort with int out of range
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+try {
+ $cnn->setPort(1234567890);
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+?>
+--EXPECT--
+Invalid port given. Value must be between 1 and 65535.
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpconnection_setPort_string.phpt b/amqp-1.6.1/tests/amqpconnection_setPort_string.phpt
new file mode 100644
index 0000000..603de0d
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setPort_string.phpt
@@ -0,0 +1,11 @@
+--TEST--
+AMQPConnection setPort with string
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+echo $cnn->setPort('12345');
+?>
+--EXPECT--
+1
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpconnection_setReadTimeout_float.phpt b/amqp-1.6.1/tests/amqpconnection_setReadTimeout_float.phpt
new file mode 100644
index 0000000..6b28911
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setReadTimeout_float.phpt
@@ -0,0 +1,14 @@
+--TEST--
+AMQPConnection setReadTimeout float
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->setReadTimeout(.34);
+var_dump($cnn->getReadTimeout());
+$cnn->setReadTimeout(4.7e-2);
+var_dump($cnn->getReadTimeout());?>
+--EXPECT--
+float(0.34)
+float(0.047)
diff --git a/amqp-1.6.1/tests/amqpconnection_setReadTimeout_int.phpt b/amqp-1.6.1/tests/amqpconnection_setReadTimeout_int.phpt
new file mode 100644
index 0000000..136744d
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setReadTimeout_int.phpt
@@ -0,0 +1,12 @@
+--TEST--
+AMQPConnection setReadTimeout int
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->setReadTimeout(3);
+var_dump($cnn->getReadTimeout());
+?>
+--EXPECT--
+float(3)
diff --git a/amqp-1.6.1/tests/amqpconnection_setReadTimeout_out_of_range.phpt b/amqp-1.6.1/tests/amqpconnection_setReadTimeout_out_of_range.phpt
new file mode 100644
index 0000000..20e7ce5
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setReadTimeout_out_of_range.phpt
@@ -0,0 +1,18 @@
+--TEST--
+AMQPConnection setReadTimeout out of range
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+try {
+ $cnn->setReadTimeout(-1);
+} catch (Exception $e) {
+ echo get_class($e);
+ echo PHP_EOL;
+ echo $e->getMessage();
+}
+?>
+--EXPECT--
+AMQPConnectionException
+Parameter 'read_timeout' must be greater than or equal to zero.
diff --git a/amqp-1.6.1/tests/amqpconnection_setReadTimeout_string.phpt b/amqp-1.6.1/tests/amqpconnection_setReadTimeout_string.phpt
new file mode 100644
index 0000000..395b43b
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setReadTimeout_string.phpt
@@ -0,0 +1,14 @@
+--TEST--
+AMQPConnection setReadTimeout string
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->setReadTimeout(".34");
+var_dump($cnn->getReadTimeout());
+$cnn->setReadTimeout("4.7e-2");
+var_dump($cnn->getReadTimeout());?>
+--EXPECT--
+float(0.34)
+float(0.047)
diff --git a/amqp-1.6.1/tests/amqpconnection_setTimeout_deprecated.phpt b/amqp-1.6.1/tests/amqpconnection_setTimeout_deprecated.phpt
new file mode 100644
index 0000000..5875df3
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setTimeout_deprecated.phpt
@@ -0,0 +1,14 @@
+--TEST--
+AMQPConnection setTimeout deprecated
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->setTimeout(0);
+$cnn->getTimeout();
+?>
+--EXPECTF--
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3
+
+%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4
diff --git a/amqp-1.6.1/tests/amqpconnection_setTimeout_float.phpt b/amqp-1.6.1/tests/amqpconnection_setTimeout_float.phpt
new file mode 100644
index 0000000..119c2bc
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setTimeout_float.phpt
@@ -0,0 +1,21 @@
+--TEST--
+AMQPConnection setTimeout float
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->setTimeout(.34);
+var_dump($cnn->getTimeout());
+$cnn->setTimeout(4.7e-2);
+var_dump($cnn->getTimeout());?>
+--EXPECTF--
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3
+
+%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4
+float(0.34)
+
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 5
+
+%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 6
+float(0.047)
diff --git a/amqp-1.6.1/tests/amqpconnection_setTimeout_int.phpt b/amqp-1.6.1/tests/amqpconnection_setTimeout_int.phpt
new file mode 100644
index 0000000..85ecabe
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setTimeout_int.phpt
@@ -0,0 +1,15 @@
+--TEST--
+AMQPConnection setTimeout int
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->setTimeout(3);
+var_dump($cnn->getTimeout());
+?>
+--EXPECTF--
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3
+
+%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4
+float(3)
diff --git a/amqp-1.6.1/tests/amqpconnection_setTimeout_out_of_range.phpt b/amqp-1.6.1/tests/amqpconnection_setTimeout_out_of_range.phpt
new file mode 100644
index 0000000..6769f65
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setTimeout_out_of_range.phpt
@@ -0,0 +1,19 @@
+--TEST--
+AMQPConnection setTimeout out of range
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+try {
+ $cnn->setTimeout(-1);
+} catch (Exception $e) {
+ echo get_class($e);
+ echo PHP_EOL;
+ echo $e->getMessage();
+}
+?>
+--EXPECTF--
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 4
+AMQPConnectionException
+Parameter 'timeout' must be greater than or equal to zero.
diff --git a/amqp-1.6.1/tests/amqpconnection_setTimeout_string.phpt b/amqp-1.6.1/tests/amqpconnection_setTimeout_string.phpt
new file mode 100644
index 0000000..c198b4f
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setTimeout_string.phpt
@@ -0,0 +1,21 @@
+--TEST--
+AMQPConnection setTimeout string
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->setTimeout(".34");
+var_dump($cnn->getTimeout());
+$cnn->setTimeout("4.7e-2");
+var_dump($cnn->getTimeout());?>
+--EXPECTF--
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3
+
+%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4
+float(0.34)
+
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 5
+
+%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 6
+float(0.047)
diff --git a/amqp-1.6.1/tests/amqpconnection_setVhost.phpt b/amqp-1.6.1/tests/amqpconnection_setVhost.phpt
new file mode 100644
index 0000000..94899ae
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setVhost.phpt
@@ -0,0 +1,13 @@
+--TEST--
+AMQPConnection setVhost
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+var_dump($cnn->getVhost());
+$cnn->setVhost('nonexistent');
+var_dump($cnn->getVhost());
+--EXPECTF--
+string(1) "/"
+string(11) "nonexistent"
diff --git a/amqp-1.6.1/tests/amqpconnection_setWriteTimeout_float.phpt b/amqp-1.6.1/tests/amqpconnection_setWriteTimeout_float.phpt
new file mode 100644
index 0000000..8254e29
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setWriteTimeout_float.phpt
@@ -0,0 +1,14 @@
+--TEST--
+AMQPConnection setWriteTimeout float
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->setWriteTimeout(.34);
+var_dump($cnn->getWriteTimeout());
+$cnn->setWriteTimeout(4.7e-2);
+var_dump($cnn->getWriteTimeout());?>
+--EXPECT--
+float(0.34)
+float(0.047)
diff --git a/amqp-1.6.1/tests/amqpconnection_setWriteTimeout_int.phpt b/amqp-1.6.1/tests/amqpconnection_setWriteTimeout_int.phpt
new file mode 100644
index 0000000..39d334f
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setWriteTimeout_int.phpt
@@ -0,0 +1,12 @@
+--TEST--
+AMQPConnection setWriteTimeout int
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->setWriteTimeout(3);
+var_dump($cnn->getWriteTimeout());
+?>
+--EXPECT--
+float(3)
diff --git a/amqp-1.6.1/tests/amqpconnection_setWriteTimeout_out_of_range.phpt b/amqp-1.6.1/tests/amqpconnection_setWriteTimeout_out_of_range.phpt
new file mode 100644
index 0000000..4f6204a
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setWriteTimeout_out_of_range.phpt
@@ -0,0 +1,18 @@
+--TEST--
+AMQPConnection setWriteTimeout out of range
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+try {
+ $cnn->setWriteTimeout(-1);
+} catch (Exception $e) {
+ echo get_class($e);
+ echo PHP_EOL;
+ echo $e->getMessage();
+}
+?>
+--EXPECT--
+AMQPConnectionException
+Parameter 'write_timeout' must be greater than or equal to zero.
diff --git a/amqp-1.6.1/tests/amqpconnection_setWriteTimeout_string.phpt b/amqp-1.6.1/tests/amqpconnection_setWriteTimeout_string.phpt
new file mode 100644
index 0000000..0b9f917
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_setWriteTimeout_string.phpt
@@ -0,0 +1,15 @@
+--TEST--
+AMQPConnection setWriteTimeout string
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->setWriteTimeout(".34");
+var_dump($cnn->getWriteTimeout());
+$cnn->setWriteTimeout("4.7e-2");
+var_dump($cnn->getWriteTimeout());
+?>
+--EXPECT--
+float(0.34)
+float(0.047)
diff --git a/amqp-1.6.1/tests/amqpconnection_toomanychannels.phpt b/amqp-1.6.1/tests/amqpconnection_toomanychannels.phpt
new file mode 100644
index 0000000..d2dbaea
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_toomanychannels.phpt
@@ -0,0 +1,29 @@
+--TEST--
+AMQPConnection too many channels on a connection
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$channels = array();
+
+for ($i = 0; $i < PHP_AMQP_MAX_CHANNELS; $i++) {
+ $channel = $channels[] = new AMQPChannel($cnn);
+ //echo '#', $channel->getChannelId(), ', used ', $cnn->getUsedChannels(), ' of ', $cnn->getMaxChannels(), PHP_EOL;
+}
+
+echo "Good\n";
+
+try {
+ new AMQPChannel($cnn);
+ echo "Bad\n";
+} catch(Exception $e) {
+ echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
+}
+
+?>
+--EXPECT--
+Good
+AMQPChannelException: Could not create channel. Connection has no open channel slots remaining.
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpconnection_var_dump.phpt b/amqp-1.6.1/tests/amqpconnection_var_dump.phpt
new file mode 100644
index 0000000..39c53c4
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpconnection_var_dump.phpt
@@ -0,0 +1,152 @@
+--TEST--
+AMQPConnection var_dump
+--SKIPIF--
+<?php
+if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<')) {
+ print "skip";
+}
+?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+var_dump($cnn);
+$cnn->connect();
+$cnn->connect();
+var_dump($cnn);
+
+$c = new AMQPChannel($cnn);
+
+var_dump($cnn);
+
+$cnn->disconnect();
+var_dump($cnn);
+?>
+--EXPECT--
+object(AMQPConnection)#1 (15) {
+ ["login"]=>
+ string(5) "guest"
+ ["password"]=>
+ string(5) "guest"
+ ["host"]=>
+ string(9) "localhost"
+ ["vhost"]=>
+ string(1) "/"
+ ["port"]=>
+ int(5672)
+ ["read_timeout"]=>
+ float(0)
+ ["write_timeout"]=>
+ float(0)
+ ["connect_timeout"]=>
+ float(0)
+ ["is_connected"]=>
+ bool(false)
+ ["is_persistent"]=>
+ bool(false)
+ ["connection_resource"]=>
+ NULL
+ ["used_channels"]=>
+ NULL
+ ["max_channel_id"]=>
+ NULL
+ ["max_frame_size"]=>
+ NULL
+ ["heartbeat_interval"]=>
+ NULL
+}
+object(AMQPConnection)#1 (15) {
+ ["login"]=>
+ string(5) "guest"
+ ["password"]=>
+ string(5) "guest"
+ ["host"]=>
+ string(9) "localhost"
+ ["vhost"]=>
+ string(1) "/"
+ ["port"]=>
+ int(5672)
+ ["read_timeout"]=>
+ float(0)
+ ["write_timeout"]=>
+ float(0)
+ ["connect_timeout"]=>
+ float(0)
+ ["is_connected"]=>
+ bool(true)
+ ["is_persistent"]=>
+ bool(false)
+ ["connection_resource"]=>
+ resource(4) of type (AMQP Connection Resource)
+ ["used_channels"]=>
+ int(0)
+ ["max_channel_id"]=>
+ int(256)
+ ["max_frame_size"]=>
+ int(131072)
+ ["heartbeat_interval"]=>
+ int(0)
+}
+object(AMQPConnection)#1 (15) {
+ ["login"]=>
+ string(5) "guest"
+ ["password"]=>
+ string(5) "guest"
+ ["host"]=>
+ string(9) "localhost"
+ ["vhost"]=>
+ string(1) "/"
+ ["port"]=>
+ int(5672)
+ ["read_timeout"]=>
+ float(0)
+ ["write_timeout"]=>
+ float(0)
+ ["connect_timeout"]=>
+ float(0)
+ ["is_connected"]=>
+ bool(true)
+ ["is_persistent"]=>
+ bool(false)
+ ["connection_resource"]=>
+ resource(4) of type (AMQP Connection Resource)
+ ["used_channels"]=>
+ int(1)
+ ["max_channel_id"]=>
+ int(256)
+ ["max_frame_size"]=>
+ int(131072)
+ ["heartbeat_interval"]=>
+ int(0)
+}
+object(AMQPConnection)#1 (15) {
+ ["login"]=>
+ string(5) "guest"
+ ["password"]=>
+ string(5) "guest"
+ ["host"]=>
+ string(9) "localhost"
+ ["vhost"]=>
+ string(1) "/"
+ ["port"]=>
+ int(5672)
+ ["read_timeout"]=>
+ float(0)
+ ["write_timeout"]=>
+ float(0)
+ ["connect_timeout"]=>
+ float(0)
+ ["is_connected"]=>
+ bool(false)
+ ["is_persistent"]=>
+ bool(false)
+ ["connection_resource"]=>
+ NULL
+ ["used_channels"]=>
+ NULL
+ ["max_channel_id"]=>
+ NULL
+ ["max_frame_size"]=>
+ NULL
+ ["heartbeat_interval"]=>
+ NULL
+}
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpenvelope_get_accessors.phpt b/amqp-1.6.1/tests/amqpenvelope_get_accessors.phpt
new file mode 100644
index 0000000..1f0ef06
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpenvelope_get_accessors.phpt
@@ -0,0 +1,67 @@
+--TEST--
+AMQPEnvelope test get*() accessors
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+require '_test_helpers.php';
+
+$cnn = new AMQPConnection();
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-'.microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+// Create a new queue
+$q = new AMQPQueue($ch);
+$q->setName('queue1' . microtime(true));
+$q->declareQueue();
+// Bind it on the exchange to routing.key
+$q->bind($ex->getName(), 'routing.*');
+// Publish a message to the exchange with a routing key
+$ex->publish('message', 'routing.1');
+
+// Read from the queue
+$q->consume('dump_message');
+?>
+--EXPECTF--
+AMQPEnvelope
+ getBody:
+ string(7) "message"
+ getContentType:
+ string(10) "text/plain"
+ getRoutingKey:
+ string(9) "routing.1"
+ getDeliveryTag:
+ int(1)
+ getDeliveryMode:
+ int(1)
+ getExchangeName:
+ string(%d) "exchange-%f"
+ isRedelivery:
+ bool(false)
+ getContentEncoding:
+ string(0) ""
+ getType:
+ string(0) ""
+ getTimeStamp:
+ int(0)
+ getPriority:
+ int(0)
+ getExpiration:
+ string(0) ""
+ getUserId:
+ string(0) ""
+ getAppId:
+ string(0) ""
+ getMessageId:
+ string(0) ""
+ getReplyTo:
+ string(0) ""
+ getCorrelationId:
+ string(0) ""
+ getHeaders:
+ array(0) {
+}
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpenvelope_var_dump.phpt b/amqp-1.6.1/tests/amqpenvelope_var_dump.phpt
new file mode 100644
index 0000000..18e53d4
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpenvelope_var_dump.phpt
@@ -0,0 +1,114 @@
+--TEST--
+AMQPEnvelope var_dump
+--SKIPIF--
+<?php
+if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<')) {
+ print "skip";
+}
+--FILE--
+<?php
+require '_test_helpers.php';
+
+$cnn = new AMQPConnection();
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange1');
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+// Create a new queue
+$q = new AMQPQueue($ch);
+$q->setName('queue1' . microtime(true));
+$q->declareQueue();
+// Bind it on the exchange to routing.key
+$q->bind($ex->getName(), 'routing.*');
+// Publish a message to the exchange with a routing key
+$ex->publish('message', 'routing.1');
+$ex->publish('message', 'routing.1', AMQP_NOPARAM, array("headers" => array("test" => "passed")));
+
+// Read from the queue
+$q->consume("consumeThings");
+$q->consume("consumeThings");
+?>
+--EXPECT--
+object(AMQPEnvelope)#5 (18) {
+ ["body"]=>
+ string(7) "message"
+ ["content_type"]=>
+ string(10) "text/plain"
+ ["routing_key"]=>
+ string(9) "routing.1"
+ ["delivery_tag"]=>
+ int(1)
+ ["delivery_mode"]=>
+ int(1)
+ ["exchange_name"]=>
+ string(9) "exchange1"
+ ["is_redelivery"]=>
+ int(0)
+ ["content_encoding"]=>
+ string(0) ""
+ ["type"]=>
+ string(0) ""
+ ["timestamp"]=>
+ int(0)
+ ["priority"]=>
+ int(0)
+ ["expiration"]=>
+ string(0) ""
+ ["user_id"]=>
+ string(0) ""
+ ["app_id"]=>
+ string(0) ""
+ ["message_id"]=>
+ string(0) ""
+ ["reply_to"]=>
+ string(0) ""
+ ["correlation_id"]=>
+ string(0) ""
+ ["headers"]=>
+ array(0) {
+ }
+}
+object(AMQPEnvelope)#5 (18) {
+ ["body"]=>
+ string(7) "message"
+ ["content_type"]=>
+ string(10) "text/plain"
+ ["routing_key"]=>
+ string(9) "routing.1"
+ ["delivery_tag"]=>
+ int(2)
+ ["delivery_mode"]=>
+ int(1)
+ ["exchange_name"]=>
+ string(9) "exchange1"
+ ["is_redelivery"]=>
+ int(0)
+ ["content_encoding"]=>
+ string(0) ""
+ ["type"]=>
+ string(0) ""
+ ["timestamp"]=>
+ int(0)
+ ["priority"]=>
+ int(0)
+ ["expiration"]=>
+ string(0) ""
+ ["user_id"]=>
+ string(0) ""
+ ["app_id"]=>
+ string(0) ""
+ ["message_id"]=>
+ string(0) ""
+ ["reply_to"]=>
+ string(0) ""
+ ["correlation_id"]=>
+ string(0) ""
+ ["headers"]=>
+ array(1) {
+ ["test"]=>
+ string(6) "passed"
+ }
+}
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_bind.phpt b/amqp-1.6.1/tests/amqpexchange_bind.phpt
new file mode 100644
index 0000000..39b7e77
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_bind.phpt
@@ -0,0 +1,30 @@
+--TEST--
+AMQPExchange::bind
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Declare a new exchange
+$ex2 = new AMQPExchange($ch);
+$ex2->setName('exchange2-' . microtime(true));
+$ex2->setType(AMQP_EX_TYPE_FANOUT);
+$ex2->declareExchange();
+
+var_dump($ex->bind($ex2->getName(), 'test-key-1'));
+var_dump($ex->bind($ex2->getName(), 'test-key-1'));
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_bind_with_arguments.phpt b/amqp-1.6.1/tests/amqpexchange_bind_with_arguments.phpt
new file mode 100644
index 0000000..c3e1361
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_bind_with_arguments.phpt
@@ -0,0 +1,32 @@
+--TEST--
+AMQPExchange::bind with arguments
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Declare a new exchange
+$ex2 = new AMQPExchange($ch);
+$ex2->setName('exchange2-' . microtime(true));
+$ex2->setType(AMQP_EX_TYPE_FANOUT);
+$ex2->declareExchange();
+
+$time = microtime(true);
+
+var_dump($ex->bind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time)));
+var_dump($ex->bind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time)));
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_bind_without_key.phpt b/amqp-1.6.1/tests/amqpexchange_bind_without_key.phpt
new file mode 100644
index 0000000..d861e5e
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_bind_without_key.phpt
@@ -0,0 +1,32 @@
+--TEST--
+AMQPExchange::bind without key
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Declare a new exchange
+$ex2 = new AMQPExchange($ch);
+$ex2->setName('exchange2-' . microtime(true));
+$ex2->setType(AMQP_EX_TYPE_FANOUT);
+$ex2->declareExchange();
+
+var_dump($ex->bind($ex2->getName()));
+var_dump($ex->bind($ex2->getName(), null));
+var_dump($ex->bind($ex2->getName(), ''));
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_bind_without_key_with_arguments.phpt b/amqp-1.6.1/tests/amqpexchange_bind_without_key_with_arguments.phpt
new file mode 100644
index 0000000..6d6f57a
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_bind_without_key_with_arguments.phpt
@@ -0,0 +1,32 @@
+--TEST--
+AMQPExchange::bind without key with arguments
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Declare a new exchange
+$ex2 = new AMQPExchange($ch);
+$ex2->setName('exchange2-' . microtime(true));
+$ex2->setType(AMQP_EX_TYPE_FANOUT);
+$ex2->declareExchange();
+
+$time = microtime(true);
+
+var_dump($ex->bind($ex2->getName(), null, array('test' => 'passed', 'at' => $time, 'i am' => 'first')));
+var_dump($ex->bind($ex2->getName(), '', array('test' => 'passed', 'at' => $time, 'i am' => 'second')));
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_channel_refcount.phpt b/amqp-1.6.1/tests/amqpexchange_channel_refcount.phpt
new file mode 100644
index 0000000..af23e4e
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_channel_refcount.phpt
@@ -0,0 +1,32 @@
+--TEST--
+AMQPExchange channel refcount
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+function buildExchange() {
+ $cnn = new AMQPConnection();
+ $cnn->connect();
+
+ $ch = new AMQPChannel($cnn);
+
+ $ex = new AMQPExchange($ch);
+
+ $ex->setName("refcount-testing");
+
+ return $ex;
+}
+
+$ex = buildExchange();
+
+echo $ex->getName() . "\n";
+
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+
+$ex->declareExchange();
+
+$ex->delete();
+
+?>
+--EXPECT--
+refcount-testing
diff --git a/amqp-1.6.1/tests/amqpexchange_construct_basic.phpt b/amqp-1.6.1/tests/amqpexchange_construct_basic.phpt
new file mode 100644
index 0000000..6410ea1
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_construct_basic.phpt
@@ -0,0 +1,16 @@
+--TEST--
+AMQPExchange constructor
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+echo get_class($ex);
+?>
+--EXPECT--
+AMQPExchange
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_declare_basic.phpt b/amqp-1.6.1/tests/amqpexchange_declare_basic.phpt
new file mode 100644
index 0000000..a1bb4ba
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_declare_basic.phpt
@@ -0,0 +1,18 @@
+--TEST--
+AMQPExchange
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName("exchange-" . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+echo $ex->declareExchange() ? "true" : "false";
+?>
+--EXPECT--
+true
diff --git a/amqp-1.6.1/tests/amqpexchange_declare_existent.phpt b/amqp-1.6.1/tests/amqpexchange_declare_existent.phpt
new file mode 100644
index 0000000..b49de66
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_declare_existent.phpt
@@ -0,0 +1,47 @@
+--TEST--
+AMQPExchange
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+echo 'Channel id: ', $ch->getChannelId(), PHP_EOL;
+
+$exchangge_name = "exchange-" . microtime(true);
+
+$ex = new AMQPExchange($ch);
+$ex->setName($exchangge_name);
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+echo "Exchange declared: ", $ex->declareExchange() ? "true" : "false", PHP_EOL;
+
+try {
+ $ex = new AMQPExchange($ch);
+ $ex->setName($exchangge_name);
+ $ex->setType(AMQP_EX_TYPE_TOPIC);
+ $ex->declareExchange();
+ echo 'exchange ', $ex->getName(), ' declared', PHP_EOL;
+} catch (AMQPException $e) {
+ echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
+}
+
+echo "Channel connected: ", $ch->isConnected() ? "true" : "false", PHP_EOL;
+echo "Connection connected: ", $cnn->isConnected() ? "true" : "false", PHP_EOL;
+
+try {
+ $ex = new AMQPExchange($ch);
+ echo "New exchange class created", PHP_EOL;
+} catch (AMQPException $e) {
+ echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
+}
+?>
+--EXPECTF--
+Channel id: 1
+Exchange declared: true
+AMQPExchangeException: Server channel error: 406, message: PRECONDITION_FAILED - %s exchange 'exchange-%f' in vhost '/'%s
+Channel connected: false
+Connection connected: true
+AMQPChannelException: Could not create exchange. No channel available.
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_get_channel.phpt b/amqp-1.6.1/tests/amqpexchange_get_channel.phpt
new file mode 100644
index 0000000..f235f2a
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_get_channel.phpt
@@ -0,0 +1,30 @@
+--TEST--
+AMQPExchange getChannel() test
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+$ch2 = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+
+
+echo $ch === $ex->getChannel() ? 'same' : 'not same', PHP_EOL;
+echo $ch2 === $ex->getChannel() ? 'same' : 'not same', PHP_EOL;
+
+$old_prefetch = $ch->getPrefetchCount();
+$new_prefetch = 999;
+
+$ex->getChannel()->setPrefetchCount($new_prefetch);
+
+echo $ch->getPrefetchCount() == $new_prefetch ? 'by ref' : 'copy', PHP_EOL;
+
+?>
+--EXPECT--
+same
+not same
+by ref
diff --git a/amqp-1.6.1/tests/amqpexchange_get_connection.phpt b/amqp-1.6.1/tests/amqpexchange_get_connection.phpt
new file mode 100644
index 0000000..7c94481
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_get_connection.phpt
@@ -0,0 +1,34 @@
+--TEST--
+AMQPExchange getConnection test
+--SKIPIF--
+<?php
+if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<')) {
+ print "skip";
+}
+?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+
+$cnn2 = new AMQPConnection();
+
+echo $cnn === $ex->getConnection() ? 'same' : 'not same', PHP_EOL;
+echo $cnn2 === $ex->getConnection() ? 'same' : 'not same', PHP_EOL;
+
+$old_host = $cnn->getHost();
+$new_host = 'test';
+
+$ex->getConnection()->setHost($new_host);
+
+echo $cnn->getHost() == $new_host ? 'by ref' : 'copy', PHP_EOL;
+
+?>
+--EXPECT--
+same
+not same
+by ref
diff --git a/amqp-1.6.1/tests/amqpexchange_invalid_type.phpt b/amqp-1.6.1/tests/amqpexchange_invalid_type.phpt
new file mode 100644
index 0000000..aa0fbc5
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_invalid_type.phpt
@@ -0,0 +1,34 @@
+--TEST--
+AMQPExchange
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName("exchange-" . microtime(true));
+$ex->setType("invalid_exchange_type");
+
+echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
+echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
+
+try {
+ $ex->declareExchange();
+} catch (AMQPException $e) {
+ echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
+}
+
+echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
+echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
+
+?>
+--EXPECT--
+Channel connected
+Connection connected
+AMQPConnectionException: Server connection error: 503, message: COMMAND_INVALID - unknown exchange type 'invalid_exchange_type'
+Channel disconnected
+Connection disconnected
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_publish_basic.phpt b/amqp-1.6.1/tests/amqpexchange_publish_basic.phpt
new file mode 100644
index 0000000..b1b8e55
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_publish_basic.phpt
@@ -0,0 +1,20 @@
+--TEST--
+AMQPExchange
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName("exchange-" . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+echo $ex->publish('message', 'routing.key') ? 'true' : 'false';
+$ex->delete();
+?>
+--EXPECT--
+true
diff --git a/amqp-1.6.1/tests/amqpexchange_publish_empty_routing_key.phpt b/amqp-1.6.1/tests/amqpexchange_publish_empty_routing_key.phpt
new file mode 100644
index 0000000..bab006f
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_publish_empty_routing_key.phpt
@@ -0,0 +1,20 @@
+--TEST--
+AMQPExchange publish with empty routing key
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName("exchange-" . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+echo $ex->publish('message') ? 'true' : 'false';
+$ex->delete();
+?>
+--EXPECT--
+true
diff --git a/amqp-1.6.1/tests/amqpexchange_publish_with_properties.phpt b/amqp-1.6.1/tests/amqpexchange_publish_with_properties.phpt
new file mode 100644
index 0000000..68ba630
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_publish_with_properties.phpt
@@ -0,0 +1,111 @@
+--TEST--
+AMQPExchange publish with properties
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+require '_test_helpers.php';
+
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName("exchange-" . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+$q = new AMQPQueue($ch);
+$q->declareQueue();
+
+$q->bind($ex->getName());
+
+$attrs = array(
+ 'content_type' => 1, // should be string
+ 'content_encoding' => 2, // should be string
+ 'message_id' => 3, // should be string
+ //'user_id' => 4, // should be string // NOTE: fail due to Validated User-ID https://www.rabbitmq.com/validated-user-id.html, @see tests/amqpexchange_publish_with_properties_user_id_failure.phpt test
+ 'app_id' => 5, // should be string
+ 'delivery_mode' => '1-non-persistent', // should be long
+ 'priority' => '2high', // should be long
+ 'timestamp' => '123now', // should be long
+ 'expiration' => 100000000, // should be string // NOTE: in fact it is milliseconds for how long to stay in queue, see https://www.rabbitmq.com/ttl.html#per-message-ttl for details
+ 'type' => 7, // should be string
+ 'reply_to' => 8, // should be string
+ 'correlation_id' => 9, // should be string
+ //'headers' => 'not array', // should be array // NOTE: covered in tests/amqpexchange_publish_with_properties_ignore_num_header.phpt
+);
+
+$attrs_control = array(
+ 'content_type' => 1, // should be string
+ 'content_encoding' => 2, // should be string
+ 'message_id' => 3, // should be string
+ //'user_id' => 4, // should be string // NOTE: fail due to Validated User-ID https://www.rabbitmq.com/validated-user-id.html, @see tests/amqpexchange_publish_with_properties_user_id_failure.phpt test
+ 'app_id' => 5, // should be string
+ 'delivery_mode' => '1-non-persistent', // should be long
+ 'priority' => '2high', // should be long
+ 'timestamp' => '123now', // should be long
+ 'expiration' => 100000000, // should be string // NOTE: in fact it is milliseconds for how long to stay in queue, see https://www.rabbitmq.com/ttl.html#per-message-ttl for details
+ 'type' => 7, // should be string
+ 'reply_to' => 8, // should be string
+ 'correlation_id' => 9, // should be string
+ //'headers' => 'not array', // should be array // NOTE: covered in tests/amqpexchange_publish_with_properties_ignore_num_header.phpt
+);
+
+echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, $attrs) ? 'true' : 'false', PHP_EOL;
+
+
+echo 'Message attributes are ', $attrs == $attrs_control ? 'the same' : 'not the same', PHP_EOL;
+
+$msg = $q->get(AMQP_AUTOACK);
+
+
+dump_message($msg);
+
+$ex->delete();
+$q->delete();
+
+
+?>
+--EXPECTF--
+true
+Message attributes are the same
+AMQPEnvelope
+ getBody:
+ string(7) "message"
+ getContentType:
+ string(1) "1"
+ getRoutingKey:
+ string(11) "routing.key"
+ getDeliveryTag:
+ int(1)
+ getDeliveryMode:
+ int(1)
+ getExchangeName:
+ string(%d) "exchange-%f"
+ isRedelivery:
+ bool(false)
+ getContentEncoding:
+ string(1) "2"
+ getType:
+ string(1) "7"
+ getTimeStamp:
+ int(123)
+ getPriority:
+ int(2)
+ getExpiration:
+ string(9) "100000000"
+ getUserId:
+ string(0) ""
+ getAppId:
+ string(1) "5"
+ getMessageId:
+ string(1) "3"
+ getReplyTo:
+ string(1) "8"
+ getCorrelationId:
+ string(1) "9"
+ getHeaders:
+ array(0) {
+}
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt b/amqp-1.6.1/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt
new file mode 100644
index 0000000..2939eb8
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt
@@ -0,0 +1,30 @@
+--TEST--
+AMQPExchange publish with properties - ignore numeric keys in headers
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName("exchange-" . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+
+echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => 'ignored')) ? 'true' : 'false', PHP_EOL;
+echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => array(2 => 'ignore_me'))) ? 'true' : 'false', PHP_EOL;
+
+$ex->delete();
+
+
+?>
+--EXPECTF--
+Warning: AMQPExchange::publish(): Ignoring non-string header field '0' in %s on line %d
+true
+
+Warning: AMQPExchange::publish(): Ignoring non-string header field '2' in %s on line %d
+true
diff --git a/amqp-1.6.1/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt b/amqp-1.6.1/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt
new file mode 100644
index 0000000..d5bd88f
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt
@@ -0,0 +1,37 @@
+--TEST--
+AMQPExchange publish with properties - ignore unsupported header values (NULL, object, resources)
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName("exchange-" . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+$attrs = array(
+ 'headers' => array(
+ 'null' => null,
+ 'object' => new stdClass(),
+ 'resource' => fopen(__FILE__, 'r'),
+ ),
+);
+
+echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, $attrs) ? 'true' : 'false';
+
+$ex->delete();
+
+
+?>
+--EXPECTF--
+Warning: AMQPExchange::publish(): Ignoring field 'null' due to unsupported value type (null) in %s on line %d
+
+Warning: AMQPExchange::publish(): Ignoring field 'object' due to unsupported value type (object) in %s on line %d
+
+Warning: AMQPExchange::publish(): Ignoring field 'resource' due to unsupported value type (resource) in %s on line %d
+true
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_publish_with_properties_nested_header.phpt b/amqp-1.6.1/tests/amqpexchange_publish_with_properties_nested_header.phpt
new file mode 100644
index 0000000..636e4c0
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_publish_with_properties_nested_header.phpt
@@ -0,0 +1,103 @@
+--TEST--
+AMQPExchange publish with properties - nested header values
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) {
+ print "skip";
+} ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName("exchange-" . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+$q = new AMQPQueue($ch);
+$q->setName('queue-' . microtime(true));
+$q->declareQueue();
+$q->bind($ex->getName());
+
+$headers = array(
+ 'nested' => array(
+ 'string' => 'passed',
+ 999 => 'numeric works',
+ 'sub-nested' => array(
+ 'should' => 'works',
+ 42 => 'too'
+ ),
+ ),
+);
+
+$ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => $headers));
+
+$message =$q->get(AMQP_AUTOACK);
+var_dump($message->getHeaders());
+echo $message->getHeaders() == $headers ? 'same' : 'differs';
+echo PHP_EOL, PHP_EOL;
+
+
+$headers = array(
+ 'x-death' => array(
+ array (
+ 'reason' => 'rejected',
+ 'queue' => 'my_queue',
+ 'time' => 1410527691,
+ 'exchange' => 'my_exchange',
+ 'routing-keys' => array ('my_routing_key')
+ )
+ )
+);
+
+$ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => $headers));
+
+$message =$q->get(AMQP_AUTOACK);
+var_dump($message->getHeaders());
+echo $message->getHeaders() == $headers ? 'same' : 'differs';
+echo PHP_EOL, PHP_EOL;
+
+?>
+--EXPECT--
+array(1) {
+ ["nested"]=>
+ array(3) {
+ ["string"]=>
+ string(6) "passed"
+ [999]=>
+ string(13) "numeric works"
+ ["sub-nested"]=>
+ array(2) {
+ ["should"]=>
+ string(5) "works"
+ [42]=>
+ string(3) "too"
+ }
+ }
+}
+same
+
+array(1) {
+ ["x-death"]=>
+ array(1) {
+ [0]=>
+ array(5) {
+ ["reason"]=>
+ string(8) "rejected"
+ ["queue"]=>
+ string(8) "my_queue"
+ ["time"]=>
+ int(1410527691)
+ ["exchange"]=>
+ string(11) "my_exchange"
+ ["routing-keys"]=>
+ array(1) {
+ [0]=>
+ string(14) "my_routing_key"
+ }
+ }
+ }
+}
+same
diff --git a/amqp-1.6.1/tests/amqpexchange_publish_with_properties_user_id_failure.phpt b/amqp-1.6.1/tests/amqpexchange_publish_with_properties_user_id_failure.phpt
new file mode 100644
index 0000000..2edaa95
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_publish_with_properties_user_id_failure.phpt
@@ -0,0 +1,54 @@
+--TEST--
+AMQPExchange publish with properties - user_id failure
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName("exchange-" . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
+echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
+
+try {
+ // NOTE: basic.publish is asynchronous, so ...
+ echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, array('user_id' => 'unknown-' . microtime(true))) ? 'true' : 'false', PHP_EOL;
+} catch (AMQPException $e) {
+ echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
+}
+
+echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
+echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
+
+try {
+ // NOTE: ... the next socket (not only channel) operation will fail, which may lead to very strange issues
+ // if we operate here,on different entity, for example on queue.
+
+ $q = new AMQPQueue($ch);
+ $q->declareQueue();
+
+ echo "Queue declared", PHP_EOL;
+} catch (AMQPException $e) {
+ echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
+}
+
+echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
+echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
+
+?>
+--EXPECTF--
+Channel connected
+Connection connected
+true
+Channel connected
+Connection connected
+AMQPQueueException: Server channel error: 406, message: PRECONDITION_FAILED - user_id property set to 'unknown-%f' but authenticated user was 'guest'
+Channel disconnected
+Connection connected
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_set_flag.phpt b/amqp-1.6.1/tests/amqpexchange_set_flag.phpt
new file mode 100644
index 0000000..82cdd60
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_set_flag.phpt
@@ -0,0 +1,26 @@
+--TEST--
+AMQPExchange set flag string
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+
+echo $ex->getFlags();
+$ex->setFlags("2");
+echo $ex->getFlags();
+
+$ex->setFlags(NULL);
+echo $ex->getFlags();
+
+$ex->setFlags(2);
+echo $ex->getFlags();
+
+?>
+--EXPECT--
+0202
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_set_flags.phpt b/amqp-1.6.1/tests/amqpexchange_set_flags.phpt
new file mode 100644
index 0000000..4e16c58
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_set_flags.phpt
@@ -0,0 +1,41 @@
+--TEST--
+AMQPExchange setFlags()
+--SKIPIF--
+<?php
+if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<')) {
+ print "skip";
+}
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->setArguments(array("x-ha-policy" => "all"));
+$ex->setFlags(AMQP_PASSIVE | AMQP_DURABLE | AMQP_AUTODELETE | AMQP_INTERNAL);
+
+var_dump($ex);
+?>
+--EXPECTF--
+object(AMQPExchange)#3 (7) {
+ ["name"]=>
+ string(%d) "exchange-%f"
+ ["type"]=>
+ string(6) "fanout"
+ ["passive"]=>
+ bool(true)
+ ["durable"]=>
+ bool(true)
+ ["auto_delete"]=>
+ bool(true)
+ ["internal"]=>
+ bool(true)
+ ["arguments"]=>
+ array(1) {
+ ["x-ha-policy"]=>
+ string(3) "all"
+ }
+}
diff --git a/amqp-1.6.1/tests/amqpexchange_unbind.phpt b/amqp-1.6.1/tests/amqpexchange_unbind.phpt
new file mode 100644
index 0000000..ced46f7
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_unbind.phpt
@@ -0,0 +1,33 @@
+--TEST--
+AMQPExchange::unbind
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-unbind-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Declare a new exchange
+$ex2 = new AMQPExchange($ch);
+$ex2->setName('exchange2-unbind-' . microtime(true));
+$ex2->setType(AMQP_EX_TYPE_FANOUT);
+$ex2->declareExchange();
+
+var_dump($ex->bind($ex2->getName(), 'test-key-1'));
+
+var_dump($ex->unbind($ex2->getName(), 'test-key-1'));
+var_dump($ex->unbind($ex2->getName(), 'test-key-1'));
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_unbind_with_arguments.phpt b/amqp-1.6.1/tests/amqpexchange_unbind_with_arguments.phpt
new file mode 100644
index 0000000..e95e4b7
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_unbind_with_arguments.phpt
@@ -0,0 +1,35 @@
+--TEST--
+AMQPExchange::unbind with arguments
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-unbind-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Declare a new exchange
+$ex2 = new AMQPExchange($ch);
+$ex2->setName('exchange2-exchange-unbind-' . microtime(true));
+$ex2->setType(AMQP_EX_TYPE_FANOUT);
+$ex2->declareExchange();
+
+$time = microtime(true);
+
+var_dump($ex->bind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time)));
+
+var_dump($ex->unbind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time)));
+var_dump($ex->unbind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $time)));
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_unbind_without_key.phpt b/amqp-1.6.1/tests/amqpexchange_unbind_without_key.phpt
new file mode 100644
index 0000000..d8a4b79
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_unbind_without_key.phpt
@@ -0,0 +1,33 @@
+--TEST--
+AMQPExchange::unbind without key
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-unbind-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Declare a new exchange
+$ex2 = new AMQPExchange($ch);
+$ex2->setName('exchange2-unbind-' . microtime(true));
+$ex2->setType(AMQP_EX_TYPE_FANOUT);
+$ex2->declareExchange();
+
+var_dump($ex->bind($ex2->getName()));
+var_dump($ex->unbind($ex2->getName()));
+var_dump($ex->unbind($ex2->getName()));
+
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_unbind_without_key_with_arguments.phpt b/amqp-1.6.1/tests/amqpexchange_unbind_without_key_with_arguments.phpt
new file mode 100644
index 0000000..3db697c
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_unbind_without_key_with_arguments.phpt
@@ -0,0 +1,41 @@
+--TEST--
+AMQPExchange::unbind without key with arguments
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-unbind-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Declare a new exchange
+$ex2 = new AMQPExchange($ch);
+$ex2->setName('exchange2-unbind-' . microtime(true));
+$ex2->setType(AMQP_EX_TYPE_FANOUT);
+$ex2->declareExchange();
+
+$time = microtime(true);
+
+var_dump($ex->bind($ex2->getName(), null, array('test' => 'passed', 'at' => $time, 'i am' => 'first')));
+var_dump($ex->unbind($ex2->getName(), null, array('test' => 'passed', 'at' => $time, 'i am' => 'first')));
+var_dump($ex->unbind($ex2->getName(), null, array('test' => 'passed', 'at' => $time, 'i am' => 'first')));
+
+var_dump($ex->bind($ex2->getName(), '', array('test' => 'passed', 'at' => $time, 'i am' => 'second')));
+var_dump($ex->unbind($ex2->getName(), '', array('test' => 'passed', 'at' => $time, 'i am' => 'second')));
+var_dump($ex->unbind($ex2->getName(), '', array('test' => 'passed', 'at' => $time, 'i am' => 'second')));
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpexchange_var_dump.phpt b/amqp-1.6.1/tests/amqpexchange_var_dump.phpt
new file mode 100644
index 0000000..a278b84
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpexchange_var_dump.phpt
@@ -0,0 +1,57 @@
+--TEST--
+AMQPExchange var_dump
+--SKIPIF--
+<?php
+if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<')) {
+ print "skip";
+}
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+var_dump($ex);
+$ex->setArguments(array("x-ha-policy" => "all"));
+var_dump($ex);
+?>
+--EXPECTF--
+object(AMQPExchange)#3 (7) {
+ ["name"]=>
+ string(%d) "exchange-%f"
+ ["type"]=>
+ string(6) "fanout"
+ ["passive"]=>
+ bool(false)
+ ["durable"]=>
+ bool(false)
+ ["auto_delete"]=>
+ bool(false)
+ ["internal"]=>
+ bool(false)
+ ["arguments"]=>
+ array(0) {
+ }
+}
+object(AMQPExchange)#3 (7) {
+ ["name"]=>
+ string(%d) "exchange-%f"
+ ["type"]=>
+ string(6) "fanout"
+ ["passive"]=>
+ bool(false)
+ ["durable"]=>
+ bool(false)
+ ["auto_delete"]=>
+ bool(false)
+ ["internal"]=>
+ bool(false)
+ ["arguments"]=>
+ array(1) {
+ ["x-ha-policy"]=>
+ string(3) "all"
+ }
+}
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpqueue_bind_basic.phpt b/amqp-1.6.1/tests/amqpqueue_bind_basic.phpt
new file mode 100644
index 0000000..bfa89eb
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_bind_basic.phpt
@@ -0,0 +1,26 @@
+--TEST--
+AMQPQueue
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_DIRECT);
+$ex->declareExchange();
+
+$queue = new AMQPQueue($ch);
+$queue->setName("queue-" . microtime(true));
+$queue->declareQueue();
+var_dump($queue->bind($ex->getName(), 'routing.key'));
+
+$queue->delete();
+$ex->delete();
+?>
+--EXPECT--
+bool(true)
diff --git a/amqp-1.6.1/tests/amqpqueue_bind_basic_empty_routing_key.phpt b/amqp-1.6.1/tests/amqpqueue_bind_basic_empty_routing_key.phpt
new file mode 100644
index 0000000..21fc244
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_bind_basic_empty_routing_key.phpt
@@ -0,0 +1,26 @@
+--TEST--
+AMQPQueue
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_DIRECT);
+$ex->declareExchange();
+
+$queue = new AMQPQueue($ch);
+$queue->setName("queue-" . microtime(true));
+$queue->declareQueue();
+var_dump($queue->bind($ex->getName()));
+
+$queue->delete();
+$ex->delete();
+?>
+--EXPECT--
+bool(true)
diff --git a/amqp-1.6.1/tests/amqpqueue_bind_basic_headers_arguments.phpt b/amqp-1.6.1/tests/amqpqueue_bind_basic_headers_arguments.phpt
new file mode 100644
index 0000000..dffe308
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_bind_basic_headers_arguments.phpt
@@ -0,0 +1,28 @@
+--TEST--
+AMQPQueue
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_HEADERS);
+$ex->declareExchange();
+
+$queue = new AMQPQueue($ch);
+$queue->setName("queue-" . microtime(true));
+$queue->declareQueue();
+
+$arguments = array('x-match' => 'all', 'type' => 'custom');
+var_dump($queue->bind($ex->getName(), '', $arguments));
+
+$queue->delete();
+$ex->delete();
+?>
+--EXPECT--
+bool(true)
diff --git a/amqp-1.6.1/tests/amqpqueue_cancel.phpt b/amqp-1.6.1/tests/amqpqueue_cancel.phpt
new file mode 100644
index 0000000..c2e94ec
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_cancel.phpt
@@ -0,0 +1,144 @@
+--TEST--
+AMQPQueue cancel
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+function create_connection() {
+ $conn = new AMQPConnection();
+ $conn->connect();
+ return $conn;
+}
+
+function create_channel($connection) {
+ $channel = new AMQPChannel($connection);
+ $channel->setPrefetchCount(1);
+ return $channel;
+}
+
+function create_exchange($channel) {
+ $exchange = new AMQPExchange($channel);
+ $exchange->setName('test_cancel_exchange');
+ $exchange->setType(AMQP_EX_TYPE_DIRECT);
+ $exchange->declareExchange();
+ return $exchange;
+}
+
+function create_queue($channel) {
+ $queue = new AMQPQueue($channel);
+ $queue->setName('test_cancel_queue');
+ $queue->setFlags(AMQP_NOPARAM);
+ $queue->declareQueue();
+ $queue->bind('test_cancel_exchange', 'test_cancel_routing_key');
+ return $queue;
+}
+
+class TrivialAcceptor {
+ private $count = 0;
+ private $maxCount;
+
+ public function __construct($maxCount) {
+ $this->maxCount = $maxCount;
+ }
+
+ public function accept($envelope, $queue) {
+ var_dump(
+ $envelope->getBody(),
+ $envelope->getDeliveryTag(),
+ $envelope->isRedelivery()
+ );
+ echo "\n";
+ $queue->ack($envelope->getDeliveryTag());
+ $this->count++;
+ return $this->count < $this->maxCount;
+ }
+}
+
+function get_acceptor($count) {
+ $acceptorObject = new TrivialAcceptor($count);
+ return array($acceptorObject, 'accept');
+}
+
+function send_message($exchange, $message) {
+ $exchange->publish($message, 'test_cancel_routing_key');
+}
+
+function wait_for_messages($queue, $consumer_tag, $message_count, $cancel_afterwards) {
+ $consumeMethod = new ReflectionMethod('AMQPQueue', 'consume');
+ switch ($consumeMethod->getNumberOfParameters())
+ {
+ case 3:
+ $queue->consume(get_acceptor($message_count), AMQP_NOPARAM, $consumer_tag);
+ if ($cancel_afterwards)
+ $queue->cancel($consumer_tag);
+ break;
+
+ case 2:
+ $queue->consume(get_acceptor($message_count), AMQP_NOPARAM);
+ if ($cancel_afterwards)
+ $queue->cancel();
+ break;
+
+ default:
+ echo "AMQP::consume() takes neither 2 nor 3 parameters";
+ exit(1);
+ }
+}
+
+$consumer_tag_prefix = uniqid();
+
+$send_conn = create_connection();
+$send_chan = create_channel($send_conn);
+$exchange = create_exchange($send_chan);
+
+$recv_conn_1 = create_connection();
+$recv_chan_1 = create_channel($recv_conn_1);
+$queue_1 = create_queue($recv_chan_1);
+
+send_message($exchange, 'message 0');
+wait_for_messages($queue_1, $consumer_tag_prefix.'_1', 1, true);
+
+send_message($exchange, 'message 1');
+send_message($exchange, 'message 2');
+
+$recv_chan_2 = create_channel($recv_conn_1);
+$queue_2 = create_queue($recv_chan_2);
+
+wait_for_messages($queue_2, $consumer_tag_prefix.'_2', 2, false);
+
+$recv_conn_1->disconnect();
+sleep(1);
+
+$recv_conn_2 = create_connection();
+$recv_chan_3 = create_channel($recv_conn_2);
+$queue_3 = create_queue($recv_chan_3);
+
+send_message($exchange, 'message 3');
+send_message($exchange, 'message 4');
+
+wait_for_messages($queue_3, $consumer_tag_prefix.'_3', 2, false);
+
+$queue_3->delete(AMQP_NOPARAM);
+$exchange->delete();
+?>
+--EXPECT--
+string(9) "message 0"
+int(1)
+bool(false)
+
+string(9) "message 1"
+int(1)
+bool(false)
+
+string(9) "message 2"
+int(2)
+bool(false)
+
+string(9) "message 3"
+int(1)
+bool(false)
+
+string(9) "message 4"
+int(2)
+bool(false)
+
diff --git a/amqp-1.6.1/tests/amqpqueue_construct_basic.phpt b/amqp-1.6.1/tests/amqpqueue_construct_basic.phpt
new file mode 100644
index 0000000..57ea772
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_construct_basic.phpt
@@ -0,0 +1,16 @@
+--TEST--
+AMQPQueue constructor
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$queue = new AMQPQueue($ch);
+echo get_class($queue);
+?>
+--EXPECT--
+AMQPQueue
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpqueue_consume_basic.phpt b/amqp-1.6.1/tests/amqpqueue_consume_basic.phpt
new file mode 100644
index 0000000..d3e43bf
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_consume_basic.phpt
@@ -0,0 +1,139 @@
+--TEST--
+AMQPQueue::consume basic
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+require '_test_helpers.php';
+
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Create a new queue
+$q = new AMQPQueue($ch);
+$q->setName('queue-' . microtime(true));
+$q->declareQueue();
+
+// Bind it on the exchange to routing.key
+$q->bind($ex->getName(), 'routing.*');
+
+// Publish a message to the exchange with a routing key
+$ex->publish('message1', 'routing.1', AMQP_NOPARAM, array('content_type' => 'plain/test', 'headers' => array('foo' => 'bar')));
+$ex->publish('message2', 'routing.2', AMQP_NOPARAM, array('delivery_mode' => AMQP_DURABLE));
+$ex->publish('message3', 'routing.3', AMQP_DURABLE); // this is wrong way to make messages persistent
+
+$count = 0;
+
+function consumeThingsTwoTimes($message, $queue) {
+ global $count;
+
+ echo "call #$count", PHP_EOL;
+ // Read from the queue
+ dump_message($message);
+ echo PHP_EOL;
+ $count++;
+
+ if ($count >= 2) {
+ return false;
+ }
+
+ return true;
+}
+
+// Read from the queue
+$q->consume("consumeThingsTwoTimes", AMQP_AUTOACK);
+
+$q->delete();
+$ex->delete();
+
+?>
+--EXPECTF--
+call #0
+AMQPEnvelope
+ getBody:
+ string(8) "message1"
+ getContentType:
+ string(10) "plain/test"
+ getRoutingKey:
+ string(9) "routing.1"
+ getDeliveryTag:
+ int(1)
+ getDeliveryMode:
+ int(1)
+ getExchangeName:
+ string(%d) "exchange-%f"
+ isRedelivery:
+ bool(false)
+ getContentEncoding:
+ string(0) ""
+ getType:
+ string(0) ""
+ getTimeStamp:
+ int(0)
+ getPriority:
+ int(0)
+ getExpiration:
+ string(0) ""
+ getUserId:
+ string(0) ""
+ getAppId:
+ string(0) ""
+ getMessageId:
+ string(0) ""
+ getReplyTo:
+ string(0) ""
+ getCorrelationId:
+ string(0) ""
+ getHeaders:
+ array(1) {
+ ["foo"]=>
+ string(3) "bar"
+}
+
+call #1
+AMQPEnvelope
+ getBody:
+ string(8) "message2"
+ getContentType:
+ string(10) "text/plain"
+ getRoutingKey:
+ string(9) "routing.2"
+ getDeliveryTag:
+ int(2)
+ getDeliveryMode:
+ int(2)
+ getExchangeName:
+ string(%d) "exchange-%f"
+ isRedelivery:
+ bool(false)
+ getContentEncoding:
+ string(0) ""
+ getType:
+ string(0) ""
+ getTimeStamp:
+ int(0)
+ getPriority:
+ int(0)
+ getExpiration:
+ string(0) ""
+ getUserId:
+ string(0) ""
+ getAppId:
+ string(0) ""
+ getMessageId:
+ string(0) ""
+ getReplyTo:
+ string(0) ""
+ getCorrelationId:
+ string(0) ""
+ getHeaders:
+ array(0) {
+}
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpqueue_consume_multiple.phpt b/amqp-1.6.1/tests/amqpqueue_consume_multiple.phpt
new file mode 100644
index 0000000..7ba4ada
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_consume_multiple.phpt
@@ -0,0 +1,71 @@
+--TEST--
+AMQPQueue::consume multiple
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$time = microtime(true);
+
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . $time);
+$ex->setType(AMQP_EX_TYPE_TOPIC);
+$ex->declareExchange();
+
+// Create and bind queues
+$q1 = new AMQPQueue($ch);
+$q1->setName('queue-one-' . $time);
+$q1->declareQueue();
+$q1->bind($ex->getName(), 'routing.one');
+
+$q2 = new AMQPQueue($ch);
+$q2->setName('queue-two-' . $time);
+$q2->declareQueue();
+$q2->bind($ex->getName(), 'routing.two');
+
+$q3 = new AMQPQueue($ch);
+$q3->setName('queue-three-' . $time);
+$q3->declareQueue();
+$q3->bind($ex->getName(), 'routing.three');
+
+
+// Publish a message to the exchange with a routing key
+$ex->publish('message1', 'routing.one');
+$ex->publish('message2', 'routing.two');
+$ex->publish('message3', 'routing.three');
+
+$count = 0;
+
+function consumeThings(AMQPEnvelope $message, AMQPQueue $queue)
+{
+ global $count;
+
+ echo $message->getBody() . "-" . $message->getRoutingKey() . "\n";
+
+ $count++;
+
+ $queue->ack($message->getDeliveryTag());
+
+ if ($count >= 2) {
+ return false;
+ }
+
+ return true;
+}
+
+$q1->consume();
+$q2->consume('consumeThings');
+
+// This is important!
+$q1->cancel();
+$q2->cancel();
+
+?>
+--EXPECT--
+message1-routing.one
+message2-routing.two
diff --git a/amqp-1.6.1/tests/amqpqueue_consume_nonexistent.phpt b/amqp-1.6.1/tests/amqpqueue_consume_nonexistent.phpt
new file mode 100644
index 0000000..7a326d5
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_consume_nonexistent.phpt
@@ -0,0 +1,34 @@
+--TEST--
+AMQPQueue::consume from nonexistent queue
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+function noop () {return false;}
+
+$cnn = new AMQPConnection();
+$cnn->setReadTimeout(10); // both are empirical values that should be far enough to deal with busy RabbitMQ broker
+$cnn->setWriteTimeout(10);
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Create a new queue
+$q = new AMQPQueue($ch);
+$q->setName('nonexistent-' . microtime(true));
+
+try {
+ $q->consume('noop');
+} catch (Exception $e) {
+ echo get_class($e), ': ', $e->getMessage();
+}
+
+?>
+--EXPECTF--
+AMQPQueueException: Server channel error: 404, message: NOT_FOUND - no queue 'nonexistent-%f' in vhost '/'
diff --git a/amqp-1.6.1/tests/amqpqueue_consume_timeout.phpt b/amqp-1.6.1/tests/amqpqueue_consume_timeout.phpt
new file mode 100644
index 0000000..e7a590f
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_consume_timeout.phpt
@@ -0,0 +1,42 @@
+--TEST--
+AMQPQueue::consume with timeout
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+function nop() {
+}
+
+$timeout = .68;
+$conn = new AMQPConnection(array('read_timeout' => $timeout));
+$conn->connect();
+$chan = new AMQPChannel($conn);
+$queue = new AMQPQueue($chan);
+$queue->setFlags(AMQP_EXCLUSIVE);
+$queue->declareQueue();
+$start = microtime(true);
+try {
+ $queue->consume('nop');
+} catch (AMQPException $e) {
+ echo get_class($e), ': ', $e->getMessage();
+ echo PHP_EOL;
+}
+$end = microtime(true);
+$error = $end - $start - $timeout;
+$limit = abs(log10($timeout)); // empirical value
+
+echo 'timeout: ', $timeout, PHP_EOL;
+echo 'takes: ', $end - $start, PHP_EOL;
+echo 'error: ', $error, PHP_EOL;
+echo 'limit: ', $limit, PHP_EOL;
+
+echo abs($error) <= $limit ? 'timings OK' : 'timings failed'; // error should be less than 5% of timeout value
+$queue->delete();
+?>
+--EXPECTF--
+AMQPQueueException: Consumer timeout exceed
+timeout: %f
+takes: %f
+error: %f
+limit: %f
+timings OK
diff --git a/amqp-1.6.1/tests/amqpqueue_declare_basic.phpt b/amqp-1.6.1/tests/amqpqueue_declare_basic.phpt
new file mode 100644
index 0000000..68b98a6
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_declare_basic.phpt
@@ -0,0 +1,25 @@
+--TEST--
+AMQPQueue
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_DIRECT);
+$ex->declareExchange();
+
+$queue = new AMQPQueue($ch);
+$queue->setName("queue-" . microtime(true));
+$queue->declareQueue();
+var_dump($queue->bind($ex->getName(), 'routing.key'));
+
+$queue->delete();
+$ex->delete();
+?>
+--EXPECT--
+bool(true)
diff --git a/amqp-1.6.1/tests/amqpqueue_delete_basic.phpt b/amqp-1.6.1/tests/amqpqueue_delete_basic.phpt
new file mode 100644
index 0000000..a18e59f
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_delete_basic.phpt
@@ -0,0 +1,45 @@
+--TEST--
+AMQPQueue
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+$queue = new AMQPQueue($ch);
+$queue->setName("queue-" . microtime(true));
+$queue->declareQueue();
+$queue->bind($ex->getName());
+
+var_dump($queue->delete());
+var_dump($queue->delete());
+
+$queue->declareQueue();
+$queue->bind($ex->getName());
+
+$ex->publish('test 1');
+$ex->publish('test 2');
+$ex->publish('test 3');
+
+var_dump($queue->delete());
+
+$ex->publish('test 1');
+$ex->publish('test 2');
+$ex->publish('test 3');
+
+var_dump($queue->delete());
+
+$ex->delete();
+?>
+--EXPECT--
+int(0)
+int(0)
+int(3)
+int(0)
diff --git a/amqp-1.6.1/tests/amqpqueue_empty_name.phpt b/amqp-1.6.1/tests/amqpqueue_empty_name.phpt
new file mode 100644
index 0000000..959c3f8
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_empty_name.phpt
@@ -0,0 +1,24 @@
+--TEST--
+AMQPQueue declared with empty name
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_DIRECT);
+$ex->declareExchange();
+
+$queue = new AMQPQueue($ch);
+$queue->declareQueue();
+var_dump(substr($queue->getName(), 0, strlen('amq.gen-')));
+
+$queue->delete();
+$ex->delete();
+?>
+--EXPECT--
+string(8) "amq.gen-"
diff --git a/amqp-1.6.1/tests/amqpqueue_get_basic.phpt b/amqp-1.6.1/tests/amqpqueue_get_basic.phpt
new file mode 100644
index 0000000..1ee692a
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_get_basic.phpt
@@ -0,0 +1,165 @@
+--TEST--
+AMQPQueue::get basic
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+require '_test_helpers.php';
+
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-'. microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Create a new queue
+$q = new AMQPQueue($ch);
+$q->setName('queue-' . microtime(true));
+$q->declareQueue();
+
+// Bind it on the exchange to routing.key
+$q->bind($ex->getName(), 'routing.*');
+// Publish a message to the exchange with a routing key
+$ex->publish('message1', 'routing.1', AMQP_NOPARAM, array('content_type' => 'plain/test', 'headers' => array('foo' => 'bar')));
+$ex->publish('message2', 'routing.2', AMQP_DURABLE);
+$ex->publish('message3', 'routing.3');
+
+for ($i = 0; $i < 4; $i++) {
+ echo "call #$i", PHP_EOL;
+ // Read from the queue
+ $msg = $q->get(AMQP_AUTOACK);
+ dump_message($msg);
+ echo PHP_EOL;
+}
+
+?>
+--EXPECTF--
+call #0
+AMQPEnvelope
+ getBody:
+ string(8) "message1"
+ getContentType:
+ string(10) "plain/test"
+ getRoutingKey:
+ string(9) "routing.1"
+ getDeliveryTag:
+ int(1)
+ getDeliveryMode:
+ int(1)
+ getExchangeName:
+ string(%d) "exchange-%f"
+ isRedelivery:
+ bool(false)
+ getContentEncoding:
+ string(0) ""
+ getType:
+ string(0) ""
+ getTimeStamp:
+ int(0)
+ getPriority:
+ int(0)
+ getExpiration:
+ string(0) ""
+ getUserId:
+ string(0) ""
+ getAppId:
+ string(0) ""
+ getMessageId:
+ string(0) ""
+ getReplyTo:
+ string(0) ""
+ getCorrelationId:
+ string(0) ""
+ getHeaders:
+ array(1) {
+ ["foo"]=>
+ string(3) "bar"
+}
+
+call #1
+AMQPEnvelope
+ getBody:
+ string(8) "message2"
+ getContentType:
+ string(10) "text/plain"
+ getRoutingKey:
+ string(9) "routing.2"
+ getDeliveryTag:
+ int(2)
+ getDeliveryMode:
+ int(1)
+ getExchangeName:
+ string(%d) "exchange-%f"
+ isRedelivery:
+ bool(false)
+ getContentEncoding:
+ string(0) ""
+ getType:
+ string(0) ""
+ getTimeStamp:
+ int(0)
+ getPriority:
+ int(0)
+ getExpiration:
+ string(0) ""
+ getUserId:
+ string(0) ""
+ getAppId:
+ string(0) ""
+ getMessageId:
+ string(0) ""
+ getReplyTo:
+ string(0) ""
+ getCorrelationId:
+ string(0) ""
+ getHeaders:
+ array(0) {
+}
+
+call #2
+AMQPEnvelope
+ getBody:
+ string(8) "message3"
+ getContentType:
+ string(10) "text/plain"
+ getRoutingKey:
+ string(9) "routing.3"
+ getDeliveryTag:
+ int(3)
+ getDeliveryMode:
+ int(1)
+ getExchangeName:
+ string(%d) "exchange-%f"
+ isRedelivery:
+ bool(false)
+ getContentEncoding:
+ string(0) ""
+ getType:
+ string(0) ""
+ getTimeStamp:
+ int(0)
+ getPriority:
+ int(0)
+ getExpiration:
+ string(0) ""
+ getUserId:
+ string(0) ""
+ getAppId:
+ string(0) ""
+ getMessageId:
+ string(0) ""
+ getReplyTo:
+ string(0) ""
+ getCorrelationId:
+ string(0) ""
+ getHeaders:
+ array(0) {
+}
+
+call #3
+bool(false)
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpqueue_get_channel.phpt b/amqp-1.6.1/tests/amqpqueue_get_channel.phpt
new file mode 100644
index 0000000..974efe4
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_get_channel.phpt
@@ -0,0 +1,29 @@
+--TEST--
+AMQPQueue getChannel() test
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+$ch2 = new AMQPChannel($cnn);
+
+$q = new AMQPQueue($ch);
+
+echo $ch === $q->getChannel() ? 'same' : 'not same', PHP_EOL;
+echo $ch2 === $q->getChannel() ? 'same' : 'not same', PHP_EOL;
+
+$old_prefetch = $ch->getPrefetchCount();
+$new_prefetch = 999;
+
+$q->getChannel()->setPrefetchCount($new_prefetch);
+
+echo $ch->getPrefetchCount() == $new_prefetch ? 'by ref' : 'copy', PHP_EOL;
+
+?>
+--EXPECT--
+same
+not same
+by ref
diff --git a/amqp-1.6.1/tests/amqpqueue_get_connection.phpt b/amqp-1.6.1/tests/amqpqueue_get_connection.phpt
new file mode 100644
index 0000000..d88c7f7
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_get_connection.phpt
@@ -0,0 +1,35 @@
+--TEST--
+AMQPQueue getConnection test
+--SKIPIF--
+<?php
+if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<')) {
+ print "skip";
+}
+?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$q = new AMQPQueue($ch);
+
+$cnn2 = new AMQPConnection();
+
+echo $cnn === $q->getConnection() ? 'same' : 'not same', PHP_EOL;
+echo $cnn2 === $q->getConnection() ? 'same' : 'not same', PHP_EOL;
+
+$old_host = $cnn->getHost();
+$new_host = 'test';
+
+$q->getConnection()->setHost($new_host);
+
+echo $cnn->getHost() == $new_host ? 'by ref' : 'copy', PHP_EOL;
+
+?>
+--EXPECT--
+same
+not same
+by ref
diff --git a/amqp-1.6.1/tests/amqpqueue_get_empty_body.phpt b/amqp-1.6.1/tests/amqpqueue_get_empty_body.phpt
new file mode 100644
index 0000000..89e9ab1
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_get_empty_body.phpt
@@ -0,0 +1,44 @@
+--TEST--
+AMQPQueue::get empty body
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Create a new queue
+$q = new AMQPQueue($ch);
+$q->setName('queue1' . microtime(true));
+$q->declareQueue();
+
+// Bind it on the exchange to routing.key
+$q->bind($ex->getName(), 'routing.*');
+
+// Publish a message to the exchange with a routing key
+$ex->publish('', 'routing.1');
+
+// Read from the queue
+$msg = $q->get(AMQP_AUTOACK);
+echo "'" . $msg->getBody() . "'\n";
+
+$msg = $q->get(AMQP_AUTOACK);
+
+if ($msg === FALSE) {
+ echo "No more messages\n";
+}
+
+$ex->delete();
+$q->delete();
+?>
+--EXPECT--
+''
+No more messages
diff --git a/amqp-1.6.1/tests/amqpqueue_get_headers.phpt b/amqp-1.6.1/tests/amqpqueue_get_headers.phpt
new file mode 100644
index 0000000..5ea6727
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_get_headers.phpt
@@ -0,0 +1,56 @@
+--TEST--
+AMQPQueue::get headers
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Create a new queue
+$q = new AMQPQueue($ch);
+$q->setName('queue1' . microtime(true));
+$q->declareQueue();
+
+// Bind it on the exchange to routing.key
+$q->bind($ex->getName(), 'routing.*');
+
+// Publish a message to the exchange with a routing key
+$ex->publish('body', 'routing.1', AMQP_NOPARAM, array("headers" => array(
+ "first" => "one",
+ "second" => 2
+)));
+
+// Read from the queue
+$msg = $q->get(AMQP_AUTOACK);
+
+echo $msg->getBody() . "\n";
+var_dump($msg->getHeaders());
+echo $msg->getContentType() . "\n";
+echo $msg->getHeader("first") . "\n";
+echo $msg->getHeader("second") . "\n";
+
+$ex->delete();
+$q->delete();
+?>
+--EXPECT--
+body
+array(2) {
+ ["first"]=>
+ string(3) "one"
+ ["second"]=>
+ int(2)
+}
+text/plain
+one
+2
+
+
diff --git a/amqp-1.6.1/tests/amqpqueue_get_nonexistent.phpt b/amqp-1.6.1/tests/amqpqueue_get_nonexistent.phpt
new file mode 100644
index 0000000..9879b09
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_get_nonexistent.phpt
@@ -0,0 +1,32 @@
+--TEST--
+AMQPQueue::get from nonexistent queue
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->setReadTimeout(10); // both are empirical values that should be far enough to deal with busy RabbitMQ broker
+$cnn->setWriteTimeout(10);
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Create a new queue
+$q = new AMQPQueue($ch);
+$q->setName('nonexistent-' . microtime(true));
+
+try {
+ $q->get();
+} catch (Exception $e) {
+ echo get_class($e), ': ', $e->getMessage();
+}
+
+?>
+--EXPECTF--
+AMQPQueueException: Server channel error: 404, message: NOT_FOUND - no queue 'nonexistent-%f' in vhost '/'
diff --git a/amqp-1.6.1/tests/amqpqueue_nack.phpt b/amqp-1.6.1/tests/amqpqueue_nack.phpt
new file mode 100644
index 0000000..d6765fb
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_nack.phpt
@@ -0,0 +1,55 @@
+--TEST--
+AMQPQueue::nack
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+ini_set('amqp.auto_ack', false);
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('testnack' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+$exchangeName = $ex->getName();
+
+// Create a new queue
+$q = new AMQPQueue($ch);
+$q->setName('testnack' . microtime(true));
+$q->declareQueue();
+$q->bind($exchangeName, '#');
+
+// Bind it on the exchange to routing.key
+// Publish a message to the exchange with a routing key
+$ex->publish('message', 'foo');
+
+$env = $q->get(AMQP_NOPARAM);
+echo $env->getBody() . PHP_EOL;
+echo $env->isRedelivery() ? 'true' : 'false';
+echo PHP_EOL;
+
+// send the message back to the queue
+$q->nack($env->getDeliveryTag(), AMQP_REQUEUE);
+
+// read again
+$env2 = $q->get(AMQP_NOPARAM);
+if (false !== $env2) {
+ $q->ack($env2->getDeliveryTag());
+ echo $env2->getBody() . PHP_EOL;
+ echo $env2->isRedelivery() ? 'true' : 'false';
+ echo PHP_EOL;
+} else {
+ echo "could not read message" . PHP_EOL;
+}
+
+$ex->delete();
+$q->delete();
+--EXPECT--
+message
+false
+message
+true
diff --git a/amqp-1.6.1/tests/amqpqueue_nested_arrays.phpt b/amqp-1.6.1/tests/amqpqueue_nested_arrays.phpt
new file mode 100644
index 0000000..bbf2e9e
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_nested_arrays.phpt
@@ -0,0 +1,64 @@
+--TEST--
+AMQPQueue::get headers
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_TOPIC);
+$ex->declareExchange();
+$q = new AMQPQueue($ch);
+$q->setName('queue1' . microtime(true));
+$q->declareQueue();
+$q->bind($ex->getName(), '#');
+
+
+// publish a message:
+$ex->publish(
+ 'body', 'routing.1', AMQP_NOPARAM, array(
+ 'headers' => array(
+ 'foo' => 'bar',
+ 'baz' => array('a', 'bc', 'def')
+ )
+ )
+);
+
+// Read from the queue
+$msg = $q->get(AMQP_AUTOACK);
+
+var_dump($msg->getHeaders());
+echo $msg->getHeader('foo') . "\n";
+var_dump($msg->getHeader('baz'));
+
+$ex->delete();
+$q->delete();
+?>
+--EXPECT--
+array(2) {
+ ["foo"]=>
+ string(3) "bar"
+ ["baz"]=>
+ array(3) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(2) "bc"
+ [2]=>
+ string(3) "def"
+ }
+}
+bar
+array(3) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(2) "bc"
+ [2]=>
+ string(3) "def"
+}
diff --git a/amqp-1.6.1/tests/amqpqueue_nested_headers.phpt b/amqp-1.6.1/tests/amqpqueue_nested_headers.phpt
new file mode 100644
index 0000000..32c9d3e
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_nested_headers.phpt
@@ -0,0 +1,86 @@
+--TEST--
+AMQPQueue::get headers
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// create an error exchange and bind a queue to it:
+$errorXchange = new AMQPExchange($ch);
+$errorXchange->setName('errorXchange' . microtime(true));
+$errorXchange->setType(AMQP_EX_TYPE_TOPIC);
+$errorXchange->declareExchange();
+
+$errorQ = new AMQPQueue($ch);
+$errorQ->setName('errorQueue' . microtime(true));
+$errorQ->declareQueue();
+$errorQ->bind($errorXchange->getName(), '#');
+
+
+// Declare a new exchange and queue using this dead-letter-exchange:
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_TOPIC);
+$ex->declareExchange();
+$q = new AMQPQueue($ch);
+$q->setName('queue-' . microtime(true));
+$q->setArgument('x-dead-letter-exchange', $errorXchange->getName());
+$q->declareQueue();
+$q->bind($ex->getName(), '#');
+
+
+// publish a message:
+$ex->publish(
+ 'body', 'routing.1', AMQP_NOPARAM, array(
+ 'headers' => array(
+ 'foo' => 'bar',
+ 'baz' => array('a', 'bc', 'def')
+ )
+ )
+);
+
+// Read from the queue and reject, so it gets dead-lettered:
+$msg = $q->get(AMQP_NOPARAM);
+$q->nack($msg->getDeliveryTag());
+
+sleep(1);
+// Now read from the error queue:
+$msg = $errorQ->get(AMQP_AUTOACK);
+
+$header = $msg->getHeader('x-death');
+
+echo isset($header['count']) ? 'with' : 'without', ' count ', PHP_EOL;
+
+unset($header['count']);
+
+var_dump($header);
+
+$ex->delete();
+$q->delete();
+$errorXchange->delete();
+$errorQ->delete();
+?>
+--EXPECTF--
+%s
+array(1) {
+ [0]=>
+ array(5) {
+ ["reason"]=>
+ string(8) "rejected"
+ ["queue"]=>
+ string(%d) "queue-%f"
+ ["time"]=>
+ float(%d)
+ ["exchange"]=>
+ string(%d) "exchange-%f"
+ ["routing-keys"]=>
+ array(1) {
+ [0]=>
+ string(9) "routing.1"
+ }
+ }
+}
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/amqpqueue_purge_basic.phpt b/amqp-1.6.1/tests/amqpqueue_purge_basic.phpt
new file mode 100644
index 0000000..639b34c
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_purge_basic.phpt
@@ -0,0 +1,8 @@
+--TEST--
+AMQPQueue
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+?>
+--EXPECT--
diff --git a/amqp-1.6.1/tests/amqpqueue_unbind_basic_empty_routing_key.phpt b/amqp-1.6.1/tests/amqpqueue_unbind_basic_empty_routing_key.phpt
new file mode 100644
index 0000000..d786153
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_unbind_basic_empty_routing_key.phpt
@@ -0,0 +1,28 @@
+--TEST--
+AMQPQueue
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_DIRECT);
+$ex->declareExchange();
+
+$queue = new AMQPQueue($ch);
+$queue->setName("queue-" . microtime(true));
+$queue->declareQueue();
+var_dump($queue->bind($ex->getName()));
+var_dump($queue->unbind($ex->getName()));
+
+$queue->delete();
+$ex->delete();
+?>
+--EXPECT--
+bool(true)
+bool(true)
diff --git a/amqp-1.6.1/tests/amqpqueue_unbind_basic_headers_arguments.phpt b/amqp-1.6.1/tests/amqpqueue_unbind_basic_headers_arguments.phpt
new file mode 100644
index 0000000..a79e705
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_unbind_basic_headers_arguments.phpt
@@ -0,0 +1,31 @@
+--TEST--
+AMQPQueue
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . microtime(true));
+$ex->setType(AMQP_EX_TYPE_DIRECT);
+$ex->declareExchange();
+
+$queue = new AMQPQueue($ch);
+$queue->setName("queue-" . microtime(true));
+$queue->declareQueue();
+
+$arguments = array('x-match' => 'all', 'type' => 'custom');
+
+var_dump($queue->bind($ex->getName(), '', $arguments));
+var_dump($queue->unbind($ex->getName(), '', $arguments));
+
+$queue->delete();
+$ex->delete();
+?>
+--EXPECT--
+bool(true)
+bool(true)
diff --git a/amqp-1.6.1/tests/amqpqueue_var_dump.phpt b/amqp-1.6.1/tests/amqpqueue_var_dump.phpt
new file mode 100644
index 0000000..85c1105
--- /dev/null
+++ b/amqp-1.6.1/tests/amqpqueue_var_dump.phpt
@@ -0,0 +1,41 @@
+--TEST--
+AMQPQueue var_dump
+--SKIPIF--
+<?php
+if (!extension_loaded("amqp") || version_compare(PHP_VERSION, '5.3', '<')) {
+ print "skip";
+}
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange1');
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+// Create a new queue
+$q = new AMQPQueue($ch);
+$q->setName('queue_var_dump');
+$q->declareQueue();
+var_dump($q);
+?>
+--EXPECT--
+object(AMQPQueue)#4 (7) {
+ ["queue_name"]=>
+ string(14) "queue_var_dump"
+ ["consumer_tag"]=>
+ NULL
+ ["passive"]=>
+ bool(false)
+ ["durable"]=>
+ bool(false)
+ ["exclusive"]=>
+ bool(false)
+ ["auto_delete"]=>
+ bool(true)
+ ["arguments"]=>
+ array(0) {
+ }
+}
diff --git a/amqp-1.6.1/tests/bug_17831.phpt b/amqp-1.6.1/tests/bug_17831.phpt
new file mode 100644
index 0000000..52e6bd9
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_17831.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Segfault when publishing to non existent exchange
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$c = new AMQPConnection();
+$c->connect();
+
+$ch = new AMQPChannel($c);
+
+$ex = new AMQPExchange($ch);
+$ex->setName("exchange-" . microtime(true));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+try {
+ $ex->publish("data", "bar");
+ echo "Success\n";
+} catch (Exception $e) {
+ echo "Success\n";
+}
+$ex->delete();
+?>
+--EXPECT--
+Success
diff --git a/amqp-1.6.1/tests/bug_19707.phpt b/amqp-1.6.1/tests/bug_19707.phpt
new file mode 100644
index 0000000..488b42c
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_19707.phpt
@@ -0,0 +1,61 @@
+--TEST--
+AMQPQueue::get() doesn't return the message
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$cnn = new AMQPConnection();
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName("exchange_testing_19707");
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+$q = new AMQPQueue($ch);
+$q->setName('queue' . microtime(true));
+$q->setFlags(AMQP_DURABLE);
+$q->declareQueue();
+
+$q->bind($ex->getName(), 'routing.key');
+
+$ex->publish('message', 'routing.key');
+
+$msg = $q->get();
+
+echo "message received from get:\n";
+$funcs = array(
+ 'getAppId', 'getBody', 'getContentEncoding', 'getContentType',
+ 'getCorrelationId', 'getDeliveryTag', 'getExchangeName', 'getExpiration',
+ 'getHeaders', 'getMessageId', 'getPriority', 'getReplyTo', 'getRoutingKey',
+ 'getTimeStamp', 'getType', 'getUserId', 'isRedelivery'
+);
+foreach ($funcs as $func) {
+ printf("%s => %s\n", $func, var_export($msg->$func(), true));
+};
+
+$q->delete();
+$ex->delete();
+?>
+--EXPECT--
+message received from get:
+getAppId => ''
+getBody => 'message'
+getContentEncoding => ''
+getContentType => 'text/plain'
+getCorrelationId => ''
+getDeliveryTag => 1
+getExchangeName => 'exchange_testing_19707'
+getExpiration => ''
+getHeaders => array (
+)
+getMessageId => ''
+getPriority => 0
+getReplyTo => ''
+getRoutingKey => 'routing.key'
+getTimeStamp => 0
+getType => ''
+getUserId => ''
+isRedelivery => false
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/bug_19840.phpt b/amqp-1.6.1/tests/bug_19840.phpt
new file mode 100644
index 0000000..1e615e8
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_19840.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug 19840: Connection Exception
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$lServer['host'] = 'ip.ad.dr.ess';
+$lServer['port'] = '5672';
+$lServer['vhost'] = '/test';
+$lServer['user'] = 'test';
+$lServer['password'] = 'test';
+
+try {
+ $conn = new AMQPConnection($lServer);
+ $conn->connect();
+ echo "No exception thrown\n";
+} catch (Exception $e) {
+ echo get_class($e), ': ', $e->getMessage();
+}
+?>
+--EXPECT--
+AMQPConnectionException: Socket error: could not connect to host.
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/bug_61533.phpt b/amqp-1.6.1/tests/bug_61533.phpt
new file mode 100644
index 0000000..34e0b31
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_61533.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Constructing AMQPQueue with AMQPConnection segfaults
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$conn = new AMQPConnection();
+$conn->connect();
+$chan = new AMQPChannel($conn);
+try {
+ error_reporting(error_reporting() & ~E_WARNING);
+ $queue = new AMQPQueue($conn);
+} catch (AMQPQueueException $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECTF--
+Parameter must be an instance of AMQPChannel.
diff --git a/amqp-1.6.1/tests/bug_62354.phpt b/amqp-1.6.1/tests/bug_62354.phpt
new file mode 100644
index 0000000..d2a173b
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_62354.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Constructing AMQPQueue with AMQPConnection segfaults
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+class Amqptest {};
+$o = new Amqptest();
+$o->conn = new AMQPConnection();
+$funcs = array(
+ 'getHost', 'getLogin', 'getPassword', 'getPort', 'getVHost', 'isConnected'
+);
+foreach ($funcs as $func) {
+ printf("%s => %s\n", $func, var_export($o->conn->$func(), true));
+};
+?>
+--EXPECT--
+getHost => 'localhost'
+getLogin => 'guest'
+getPassword => 'guest'
+getPort => 5672
+getVHost => '/'
+isConnected => false
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/bug_gh147.phpt b/amqp-1.6.1/tests/bug_gh147.phpt
new file mode 100644
index 0000000..806aa0b
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_gh147.phpt
@@ -0,0 +1,44 @@
+--TEST--
+#147 Segfault when catchable fatal error happens in consumer
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$time = microtime(true);
+
+$connection = new AMQPConnection();
+$connection->connect();
+
+$channel = new AMQPChannel($connection);
+$channel->setPrefetchCount(2);
+
+$exchange = new AMQPExchange($channel);
+$exchange->setType(AMQP_EX_TYPE_TOPIC);
+$exchange->setName('test_' . $time);
+$exchange->setFlags(AMQP_AUTODELETE);
+$exchange->declareExchange();
+
+$queue = new AMQPQueue($channel);
+$queue->setName('test_' . $time);
+$queue->declareQueue();
+
+$queue->bind($exchange->getName(), 'test');
+
+$exchange->publish('test message', 'test');
+
+echo 'start', PHP_EOL;
+$queue->consume(function(AMQPEnvelope $e) use (&$consume) {
+ echo 'consuming';
+ $e . 'should fail';
+
+ return false;
+});
+
+echo 'done', PHP_EOL;
+
+
+?>
+--EXPECTF--
+start
+consuming
+Catchable fatal error: Object of class %s could not be converted to string in %s on line %d
\ No newline at end of file
diff --git a/amqp-1.6.1/tests/bug_gh50-1.phpt b/amqp-1.6.1/tests/bug_gh50-1.phpt
new file mode 100644
index 0000000..280ff76
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_gh50-1.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (1)
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$connection = new AMQPConnection();
+$connection->connect();
+
+for ($i = 0; $i < 3; $i++) {
+
+ $channel = new AMQPChannel($connection);
+ var_dump($channel->getChannelId());
+
+ $queue = new AMQPQueue($channel);
+ $queue->setName('test' . $i);
+
+ $queue->declareQueue();
+ $queue->delete();
+}
+?>
+==DONE==
+--EXPECT--
+int(1)
+int(2)
+int(1)
+==DONE==
diff --git a/amqp-1.6.1/tests/bug_gh50-2.phpt b/amqp-1.6.1/tests/bug_gh50-2.phpt
new file mode 100644
index 0000000..b95b290
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_gh50-2.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (2)
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$connection = new AMQPConnection();
+$connection->connect();
+
+for ($i = 0; $i < 3; $i++) {
+
+ $channel = new AMQPChannel($connection);
+ var_dump($channel->getChannelId());
+
+ $queue = new AMQPQueue($channel);
+ $queue->setName('test' . $i);
+
+ $queue->declareQueue();
+ $queue->delete();
+
+ unset($queue);
+ unset($channel);
+}
+?>
+==DONE==
+--EXPECT--
+int(1)
+int(1)
+int(1)
+==DONE==
diff --git a/amqp-1.6.1/tests/bug_gh50-3.phpt b/amqp-1.6.1/tests/bug_gh50-3.phpt
new file mode 100644
index 0000000..f63e3a6
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_gh50-3.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (3)
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$connection = new AMQPConnection();
+$connection->connect();
+
+for ($i = 0; $i < 3; $i++) {
+
+ $channel = new AMQPChannel($connection);
+ var_dump($channel->getChannelId());
+
+ $queue = new AMQPQueue($channel);
+ $queue->setName('test' . $i);
+
+ $queue->declareQueue();
+ $queue->delete();
+}
+
+$connection = new AMQPConnection();
+$connection->connect();
+
+for ($i = 0; $i < 3; $i++) {
+
+ $channel = new AMQPChannel($connection);
+ var_dump($channel->getChannelId());
+
+ $queue = new AMQPQueue($channel);
+ $queue->setName('test' . $i);
+
+ $queue->declareQueue();
+ $queue->delete();
+}
+
+
+?>
+==DONE==
+--EXPECT--
+int(1)
+int(2)
+int(1)
+int(1)
+int(2)
+int(1)
+==DONE==
diff --git a/amqp-1.6.1/tests/bug_gh50-4.phpt b/amqp-1.6.1/tests/bug_gh50-4.phpt
new file mode 100644
index 0000000..eb3539d
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_gh50-4.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (4)
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$connection = new AMQPConnection();
+$connection->connect();
+
+$channels = array();
+
+for ($i = 0; $i < 3; $i++) {
+
+ $channel = $channels[] = new AMQPChannel($connection);
+ var_dump($channel->getChannelId());
+
+ $queue = new AMQPQueue($channel);
+ $queue->setName('test' . $i);
+
+ $queue->declareQueue();
+ $queue->delete();
+}
+
+$connection = new AMQPConnection();
+$connection->connect();
+
+for ($i = 0; $i < 3; $i++) {
+
+ $channel = $channels[] = new AMQPChannel($connection);
+ var_dump($channel->getChannelId());
+
+ $queue = new AMQPQueue($channel);
+ $queue->setName('test' . $i);
+
+ $queue->declareQueue();
+ $queue->delete();
+}
+
+
+?>
+==DONE==
+--EXPECT--
+int(1)
+int(2)
+int(3)
+int(1)
+int(2)
+int(3)
+==DONE==
diff --git a/amqp-1.6.1/tests/bug_gh53-2.phpt b/amqp-1.6.1/tests/bug_gh53-2.phpt
new file mode 100644
index 0000000..08674a1
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_gh53-2.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Upgrade to RabbitMQ 3.1.0-1: AMQPConnectionException: connection closed unexpectedly (2)
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$connection = new AMQPConnection();
+$connection->connect();
+
+$channel = new AMQPChannel($connection);
+
+$exchange = new AMQPExchange($channel);
+$exchange->setName('exchange' . microtime(true));
+$exchange->setType(AMQP_EX_TYPE_TOPIC);
+$exchange->declareExchange();
+
+$queue = new AMQPQueue($channel);
+$queue->setName('queue1' . microtime(true));
+$queue->declareQueue();
+$queue->bind($exchange->getName(), '#');
+
+$exchange->publish('body1', 'routing.1');
+$exchange->publish('body2', 'routing.1');
+
+$msg = $queue->get(AMQP_AUTOACK);
+var_dump($msg->getBody());
+
+$msg = $queue->get(AMQP_AUTOACK);
+var_dump($msg->getBody());
+
+?>
+==DONE==
+--EXPECT--
+string(5) "body1"
+string(5) "body2"
+==DONE==
diff --git a/amqp-1.6.1/tests/bug_gh53.phpt b/amqp-1.6.1/tests/bug_gh53.phpt
new file mode 100644
index 0000000..b6f7bf7
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_gh53.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Upgrade to RabbitMQ 3.1.0-1: AMQPConnectionException: connection closed unexpectedly
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$connection = new AMQPConnection();
+$connection->connect();
+
+$channel = new AMQPChannel($connection);
+var_dump($channel->getPrefetchSize());
+var_dump($channel->getPrefetchCount());
+
+$channel->setPrefetchCount(10);
+var_dump($channel->getPrefetchSize());
+var_dump($channel->getPrefetchCount());
+
+// NOTE: RabbitMQ Doesn't support prefetch size
+try {
+ $channel->setPrefetchSize(1024);
+
+} catch (AMQPConnectionException $e) {
+ echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
+}
+var_dump($channel->isConnected());
+var_dump($connection->isConnected());
+var_dump($channel->getPrefetchSize());
+var_dump($channel->getPrefetchCount());
+
+?>
+==DONE==
+--EXPECTF--
+int(0)
+int(3)
+int(0)
+int(10)
+AMQPConnectionException: Server connection error: 540, message: NOT_IMPLEMENTED - prefetch_size!=0 (%d)
+bool(false)
+bool(false)
+int(0)
+int(10)
+==DONE==
diff --git a/amqp-1.6.1/tests/bug_gh72-1.phpt b/amqp-1.6.1/tests/bug_gh72-1.phpt
new file mode 100644
index 0000000..d123758
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_gh72-1.phpt
@@ -0,0 +1,18 @@
+--TEST--
+#72 Publishing to an exchange with an empty name is valid and should not throw an exception (1)
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$connection = new AMQPConnection();
+$connection->connect();
+$channel = new AMQPChannel($connection);
+
+$exchange = new AMQPExchange($channel);
+$exchange->setName('');
+
+$exchange->publish('msg', 'key');
+?>
+==DONE==
+--EXPECT--
+==DONE==
diff --git a/amqp-1.6.1/tests/bug_gh72-2.phpt b/amqp-1.6.1/tests/bug_gh72-2.phpt
new file mode 100644
index 0000000..e3cf0da
--- /dev/null
+++ b/amqp-1.6.1/tests/bug_gh72-2.phpt
@@ -0,0 +1,22 @@
+--TEST--
+#72 Publishing to an exchange with an empty name is valid and should not throw an exception (2)
+--SKIPIF--
+<?php if (!extension_loaded("amqp")) print "skip"; ?>
+--FILE--
+<?php
+$connection = new AMQPConnection();
+$connection->connect();
+$channel = new AMQPChannel($connection);
+
+$exchange = new AMQPExchange($channel);
+
+try {
+ $exchange->setName(str_repeat('a', 256));
+} catch (AMQPExchangeException $e) {
+ var_dump($e->getMessage());
+}
+?>
+==DONE==
+--EXPECT--
+string(67) "Invalid exchange name given, must be less than 255 characters long."
+==DONE==
diff --git a/amqp-1.6.1/tests/package-version.phpt b/amqp-1.6.1/tests/package-version.phpt
new file mode 100644
index 0000000..c275d58
--- /dev/null
+++ b/amqp-1.6.1/tests/package-version.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Compare version in package.xml and module
+--SKIPIF--
+<?php if (!function_exists('simplexml_load_file')) print "skip"; ?>
+--FILE--
+<?php
+$package = simplexml_load_file(dirname(__FILE__) . '/../package.xml');
+$packageVersion = $package->version->release;
+
+$ext = new ReflectionExtension('amqp');
+ob_start();
+$ext->info();
+$info = ob_get_contents();
+ob_end_clean();
+$matches = array();
+preg_match('/Version\s*=>\s*([0-9.a-z-]+)/m', $info, $matches);
+$srcVersion = $matches[1];
+
+if (0 === strcmp($packageVersion, $srcVersion)) {
+ echo "package.xml matches phpinfo() output\n";
+} else {
+ printf("src version: %s, package.xml: %s\n", $srcVersion, $packageVersion);
+}
+if (0 === strcmp($packageVersion, $ext->getVersion())) {
+ echo "package.xml matches extension version\n";
+} else {
+ printf("ext version: %s, package.xml: %s\n", $ext->getVersion(), $packageVersion);
+}
+--EXPECT--
+package.xml matches phpinfo() output
+package.xml matches extension version
diff --git a/package.xml b/package.xml
new file mode 100644
index 0000000..42d3de2
--- /dev/null
+++ b/package.xml
@@ -0,0 +1,366 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.10.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" 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.0 http://pear.php.net/dtd/package-2.0.xsd">
+ <name>amqp</name>
+ <channel>pecl.php.net</channel>
+ <summary>Communicate with any AMQP compliant server</summary>
+ <description>This extension can communicate with any AMQP spec 0-9-1 compatible server, such as RabbitMQ, OpenAMQP and Qpid, giving you the ability to create and delete exchanges and queues, as well as publish to any exchange and consume from any queue.</description>
+ <lead>
+ <name>Lars Strojny</name>
+ <user>lstrojny</user>
+ <email>lstrojny@php.net</email>
+ <active>yes</active>
+ </lead>
+ <lead>
+ <name>Pieter de Zwart</name>
+ <user>pdezwart</user>
+ <email>pdezwart@php.net</email>
+ <active>no</active>
+ </lead>
+ <date>2015-11-23</date>
+ <time>18:00:39</time>
+ <version>
+ <release>1.6.1</release>
+ <api>1.0.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+1.6.1 Release:
+ * Fix invalid amqp_table_t arguments population and freeing
+ * Fix not properly deleted connection resource
+
+ For a complete list of changes see:
+ https://github.com/pdezwart/php-amqp/compare/v1.6.0...v1.6.1
+
+1.6.0 Release:
+ * Various build fixes (Remi Collet)
+ * librabbitmq 0.5 compatibility (Remi Collet)
+
+ For a complete list of changes see:
+ https://github.com/pdezwart/php-amqp/compare/v1.6.0beta4...v1.6.0
+
+
+1.6.0beta4 Release:
+ * Add ability to re-attach consuming callback (Bogdan Padalko)
+ * Add AMQPQueue::getConsumerTag() method and fix consumer tag handling in AMQPQueue class methods (Bogdan Padalko)
+ * Add channel_max, frame_max and hearbeat support (see AMQPConnection::__construct() method) (librabbitmq version &gt;= 0.6.0 required) (Bogdan Padalko)
+ * Fix issue with message truncating to first null-byte during sending (Bogdan Padalko, special thanks to Alex Kazinskiy, Alvaro Videla and Michael Klishin)
+ * Fix issue with message truncating to first null-byte during sending (Bogdan Padalko)
+ * Fix invalid delivery mode returned by AMQPEnvelop::getDeliveryMode (Bogdan Padalko)
+
+ For a complete list of changes see:
+ https://github.com/pdezwart/php-amqp/compare/v1.6.0beta3...v1.6.0beta4
+
+1.6.0beta3 Release:
+ * Add basic.recover AMQP method support (see AMQPChannel::basicRecover() method) (Bogdan Padalko)
+ * Fix building on OS X (Bogdan Padalko)
+
+ For a complete list of changes see:
+ https://github.com/pdezwart/php-amqp/compare/v1.6.0beta2...v1.6.0beta3
+
+1.6.0beta2 Release:
+ * Pulled 1.6.0beta1, as it had the stable tag
+
+ For a complete list of changes see:
+ https://github.com/pdezwart/php-amqp/compare/v1.6.0beta1...v1.6.0beta2
+
+1.6.0beta1 Release:
+ * Add support for nested arguments values (Bogdan Padalko)
+ * Add auto_delete and internal flags support for AMQPExchange::declare (librabbitmq version &gt; 0.5.2 required) (Bogdan Padalko)
+ * Fix persistence support (Bogdan Padalko)
+ * Add AMQPExchange::unbind method and fix AMQPExchange::bind method. WARNING: this can potentially break BC (Bogdan Padalko)
+ * Add support to consume messages from multiple queues (Bogdan Padalko)
+ * Add AMQP_DURABLE flag support to AMQPExchange::setFlags (librabbitmq version &gt; 0.5.2 required) (Bogdan Padalko)
+ * Fix inconsistent INI values comparison which leads to deprecation warnings (Bogdan Padalko)
+ * Various segfault and memory leak fixes (Bogdan Padalko)
+
+ For a complete list of changes see:
+ https://github.com/pdezwart/php-amqp/compare/v1.4.0...v1.6.0beta1
+
+1.4.0 Release:
+ * Fix #72: Publishing to an exchange with an empty name is valid and should not throw an exception (lstrojny)
+ * Fix #77: AMQPQueue::delete() now no longer returns a boolean, but an integer of how many messages were deleted. WARNING: this can potentially break BC (Bogdan Padalko)
+ * Fix #75: adhering to the AMQP spec by closing channel and sometimes even the connection in case of certain errors (Bogdan Padalko)
+ * Fix #81: Add optional arguments parameter to bind()/unbind() (Michael Squires)
+ * Fix #82: additional getters (getChannel(), getConnection()) (Bogdan Padalko)
+ * Fix #92: fix various memory leaks in the AMQPConnection class (Lars Strojny)
+ * Using amqp_error_string2() instead of deprecated amqp_error_string() (Lars Strojny)
+ * Fix memory leaks in setHost, setLogin, setPassword, setVhost (Lars Strojny, Bogdan Padalko)
+ * Fixed a memleak in php_amqp_connect (Julien Pauli)
+ * Use rabbitmq-c defaults for max channels and default frame size (Bogdan Padalko)
+ * Fix socket timeout error when connecting over high-latency network (Bogdan Padalko)
+
+ For a complete list of changes see:
+ https://github.com/pdezwart/php-amqp/compare/v1.3.0...v1.4.0
+
+1.3.0 Release:
+ * Allow retrieving auto-delete exchanges (Guilherme Blanco)
+ * Add connection timeout support. This requires bumping the version requirement for librabbitmq to &gt;= 0.4.1 (Bogdan Padalko)
+
+ For a complete list of changes see:
+ https://github.com/pdezwart/php-amqp/compare/v1.2.0...v1.3.0
+
+1.2.0 Release:
+ * New methods AMQPChannel::getPrefetchCount() and AMQPChannel::getPrefetchSize()
+ * Deprecate AMQPQueue::declare() in favor of AMQPQueue::declareQueue()
+ * Deprecate AMQPExchange::declare() in favor of AMQPExchange::declareExchange()
+ * Smaller fixes to our stubs
+
+ For a complete list of changes see:
+ https://github.com/pdezwart/php-amqp/compare/v1.0.10...v1.2.0
+
+1.0.10 Release:
+ * report correct version in module info (Lars Strojny)
+ * fix class interface definitions (Vladimir Kartaviy)
+ * add ability to bind a queue with an empty routing key (Vladimir Kartaviy)
+ * fix constant AMQP_IFUNUSED (Florin Patan, Bernhard Weisshuhn)
+ * added stubs for ide use (Vladimir Kartaviy, Bernhard Weisshuhn)
+ * Fixed memory leak in queue-&gt;declareQueue (Ilya a.k.a. coodix)
+ * support for php 5.5 (Lars Strojny)
+ * add support for read and write timeouts (Bogdan Padalko)
+ * fix memory leak in queue-&gt;consume (Dmitry Vinogradov)
+ * add support for custom exchange types (empi89)
+ * support for nested custom headers (Bernhard Weisshuhn)
+ * fix memory (Bernhard Weisshuhn)
+
+ For a complete list of changes see:
+ https://github.com/pdezwart/php-amqp/compare/v1.0.9...v1.0.10
+
+1.0.9 Release:
+ * Fix pecl relase
+
+1.0.8 Release:
+ * Skip var_dump test on PHP 5.2
+ * Initialize consumer tag string length to zero
+ * Support connection time outs
+ * Adding consumer_tag parameter to AMQPQueue::cancel
+ * Clean up error code handling
+
+1.0.6 Release:
+ * 62354: Segmentation fault when printing or dumping an object that contains an AMQP object
+ * Adding in missing tests
+ * Fixing release number in PHP information
+ * Adding .gitignore info for Git users
+ * Cleaning up debug handling
+
+1.0.5 Release:
+ * 62696: Incorrect exchange type
+ * Handles server connections being closed during consume and publish correctly
+ * 62628: Exception thrown in consume will lock PHP
+ * 61533: Segmentation fault when instantiating channel, queue or exchange with wrong object, then using it
+
+1.0.4 Release:
+ * 62549: Fixing broken persistent connection
+ * 62412: Fixing segfault due to destruction order
+ * 62411: Fixing declaration overload bug
+ * 62410: Fixing declaration overload for 5.4
+ * 61337: Adding License file
+ * 61749: Fixing handling for binary content in envelope
+ * 62087: Adding appropriate version information
+ * 62354: Enabling debugging dumping of objects
+ * 61351: Updating min PHP version requirements to 5.2.0
+
+1.0.3 Release:
+ * Fixing compilation issue with PHP 5.4
+
+1.0.2 Release:
+Fixed bug:
+ * Memory leak when using AMQPQueue::get from a queue with no messages
+
+1.0.1 Release:
+Fixed bug:
+ * 61247: Allow queue creation with empty queue name, and return auto generated name
+ * 61127: Segmentation fault when cleaning up an AMQPChannel without calling AMQPConnection::connect first
+
+1.0.0 Release:
+Changed/finalized API signature:
+ * Exposing AMQPChannel
+ * Exposing AMQPEnvelope
+ * Exposing more queue and exchange arguments and flags
+ * Exposing basic.qos
+Added persistent connections
+Cleaned up codebase
+Fixed memory leaks and segmentation faults
+
+0.3.1 Release:
+Fixed bug:
+ * 24323: Cannot get the name for auto-named reply-to queues
+
+0.3.0 Release:
+Fixed memory leaks in many functions (courtesy Jonathan Tansavatdi and Andy Wick)
+Fixed consume method to return proper values
+Cleaned up variable usage
+Fixed bugs:
+ * 22638: Unexpected exit code 1 with AMQPQueue::consume()
+ * 22698: AMQPQueue::consume
+
+0.2.2 Release:
+Made extension compatible with PHP lt 5.3 (courtesy John Skopis)
+Fixed wrong typing of message properties (courtesy John Skopis)
+
+0.2.1 Release:
+Fixed refcount decrementing bug causing segfaults.
+
+0.2.0 Release:
+Works with AMQP 0-8 and 0-9-1 (used by RabbitMQ 2.*)
+Modified AMQPConnection object:
+ * Requires call to &apos;connect&apos; method to connect (no longer connects on instantiation)
+ * Added support for disconnect and reconnect
+ * Added helper setters for port, host, vhost, login and password
+Improved consume method to block for MIN messages, and try to get MAX messages if available
+Fixed zval descoping bugs
+Fixed bugs:
+ * 17809: Couldn&apos;t compile pecl extension under PHP 5.3
+ * 17831: Segmentation fault when the exchange doesn&apos;t exists
+ * 19707: AMQPQueue::get() doesn&apos;t return the message
+ * 19840: Connection Exception
+ </notes>
+ <contents>
+ <dir name="/">
+ <file md5sum="35dd03a933dc4b3faaa54ea7badc3dfc" name="amqp.c" role="src" />
+ <file md5sum="27869c52fb2800b14772cb3eb5034768" name="amqp_channel.c" role="src" />
+ <file md5sum="fdb8b53b626109d312fbe7ad9f99f3ea" name="amqp_connection.c" role="src" />
+ <file md5sum="7f0a52d3e37412747c4a59bfcab2788c" name="amqp_connection_resource.c" role="src" />
+ <file md5sum="13e263066c72a311bd463519cfae93ba" name="amqp_envelope.c" role="src" />
+ <file md5sum="fa38dd4d4df65fddb7a1d24676206a2a" name="amqp_exchange.c" role="src" />
+ <file md5sum="c33552d23da16d01b106911bf51fb0d0" name="amqp_object_store.c" role="src" />
+ <file md5sum="e6b7842d73e3188ae6d5f2523320a008" name="amqp_queue.c" role="src" />
+ <file md5sum="391d67736e0fbffcdc4e3af0fcc111bd" name="config.m4" role="src" />
+ <file md5sum="1518f35a7beb49a2d83575eaa1b84865" name="config.w32" role="src" />
+ <file md5sum="c2bc5a8aa3fb7f8d0c924f584e20809d" name="CREDITS" role="doc" />
+ <file md5sum="b3e70313289e3ea66cae3089b7e571b8" name="LICENSE" role="doc" />
+ <file md5sum="c0fcf8d2c35a0e27a0c338780e579861" name="amqp_channel.h" role="src" />
+ <file md5sum="02fb9c54a6fc70e0c3219e1eedd7a967" name="amqp_connection.h" role="src" />
+ <file md5sum="56659de12f9e0374f711048f9d3efdec" name="amqp_connection_resource.h" role="src" />
+ <file md5sum="5e84967d3642c45730286ab3e5bd5215" name="amqp_envelope.h" role="src" />
+ <file md5sum="24f3dae0ed8629dbf29aec2b18f1e348" name="amqp_exchange.h" role="src" />
+ <file md5sum="ddb57bd20a3b14932317c42112dc4e33" name="amqp_object_store.h" role="src" />
+ <file md5sum="c933137201a5d1cbe6bee01512c847cb" name="amqp_queue.h" role="src" />
+ <file md5sum="d396883b9b0c91bbd7b1294fe3ce8cca" name="php_amqp.h" role="src" />
+ <file md5sum="a0301397259981c1946f7c59c01308dd" name="tests/amqpchannel_basicRecover.phpt" role="test" />
+ <file md5sum="804eb9007733180f4300197288e7cd30" name="tests/amqpchannel_construct_basic.phpt" role="test" />
+ <file md5sum="9c9cc955cdfd88e9824613aa90cc07aa" name="tests/amqpchannel_get_connection.phpt" role="test" />
+ <file md5sum="01d45f7bd3a1c41cb967ff0e1008b968" name="tests/amqpchannel_multi_channel_connection.phpt" role="test" />
+ <file md5sum="7ed3240775603a7ddbf37e6876e61e45" name="tests/amqpchannel_slots_usage.phpt" role="test" />
+ <file md5sum="9bfa66a3547041631bd59c7f170a1cc1" name="tests/amqpchannel_var_dump.phpt" role="test" />
+ <file md5sum="6c380b88cdd43f18c4d2a9e226fe0b60" name="tests/amqpconnection_connect_login_failure.phpt" role="test" />
+ <file md5sum="977f81cbd4431c61d5292f91d21d4b61" name="tests/amqpconnection_construct_basic.phpt" role="test" />
+ <file md5sum="5824298e6564f6e9231d196114d1c77e" name="tests/amqpconnection_construct_ini_read_timeout.phpt" role="test" />
+ <file md5sum="5e6235fbdbc75cbd99cad1c0617a3269" name="tests/amqpconnection_construct_ini_timeout.phpt" role="test" />
+ <file md5sum="97e9d595eab5d25db6bcbb050f9c5f19" name="tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt" role="test" />
+ <file md5sum="cafbd1b8ec295026c37ac67a9e779b3c" name="tests/amqpconnection_construct_ini_timeout_default.phpt" role="test" />
+ <file md5sum="756da50d19cbc4665b16efb389404421" name="tests/amqpconnection_construct_with_connect_timeout.phpt" role="test" />
+ <file md5sum="71943060ef1010289ab73222cc098cb0" name="tests/amqpconnection_construct_with_timeout.phpt" role="test" />
+ <file md5sum="251f182e831e2ccfaf02fdc2f7babd58" name="tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt" role="test" />
+ <file md5sum="6e7be2cf0ba67bdbd51b4549d4a05d95" name="tests/amqpconnection_construct_with_write_timeout.phpt" role="test" />
+ <file md5sum="d7018287bc6dca5fb5d0a8bff4a1c922" name="tests/amqpconnection_persistent_construct_basic.phpt" role="test" />
+ <file md5sum="cc14d8575873810f182d6a5caf88e9f1" name="tests/amqpconnection_persistent_in_use.phpt" role="test" />
+ <file md5sum="9d10b0e4d17a0f79e8e0c493e9f1dda1" name="tests/amqpconnection_persistent_reusable.phpt" role="test" />
+ <file md5sum="c0ec41c937366128d259d01ee3061b31" name="tests/amqpconnection_persistent_var_dump.phpt" role="test" />
+ <file md5sum="2cb04633b3e25285b16eba11c468091e" name="tests/amqpconnection_setHost.phpt" role="test" />
+ <file md5sum="2d98d2921087152f05baf03b4c3d38f9" name="tests/amqpconnection_setLogin.phpt" role="test" />
+ <file md5sum="b947e9a0862c329d77b3c1c359e06d1e" name="tests/amqpconnection_setPassword.phpt" role="test" />
+ <file md5sum="b0d4fff032394ffac3b1f723eaa5aef3" name="tests/amqpconnection_setPort_int.phpt" role="test" />
+ <file md5sum="7c24ac91124bd6bbffd3ef302cfd1721" name="tests/amqpconnection_setPort_out_of_range.phpt" role="test" />
+ <file md5sum="f3851993f5d2be8bfd6093825c308b8e" name="tests/amqpconnection_setPort_string.phpt" role="test" />
+ <file md5sum="8223be5940730e6ca06f80d2a7e7460e" name="tests/amqpconnection_setReadTimeout_float.phpt" role="test" />
+ <file md5sum="8393a7fea7816e107d3e1c56d6511a6b" name="tests/amqpconnection_setReadTimeout_int.phpt" role="test" />
+ <file md5sum="acc371cda24e1225060e2be3635e96c4" name="tests/amqpconnection_setReadTimeout_out_of_range.phpt" role="test" />
+ <file md5sum="8f3d1d22f5af666600b19ec4d20e72d2" name="tests/amqpconnection_setReadTimeout_string.phpt" role="test" />
+ <file md5sum="2887356c3bd4544d08f97f1266e9028d" name="tests/amqpconnection_setTimeout_deprecated.phpt" role="test" />
+ <file md5sum="fca046c775db1ea3087458a1561c227a" name="tests/amqpconnection_setTimeout_float.phpt" role="test" />
+ <file md5sum="40dfd77c4c08f8528951d47e42cda7fb" name="tests/amqpconnection_setTimeout_int.phpt" role="test" />
+ <file md5sum="d0cd2aa004803b2f05ab467edf4f1036" name="tests/amqpconnection_setTimeout_out_of_range.phpt" role="test" />
+ <file md5sum="28ef38b64e446ac2dfcc748862387ceb" name="tests/amqpconnection_setTimeout_string.phpt" role="test" />
+ <file md5sum="b045ae9098ff06a00ee7146d8d413a69" name="tests/amqpconnection_setVhost.phpt" role="test" />
+ <file md5sum="1b5380a431ebf72b2c0b8a5f6e370721" name="tests/amqpconnection_setWriteTimeout_float.phpt" role="test" />
+ <file md5sum="eb34d68a4069135dac436bf2b3cf2b8f" name="tests/amqpconnection_setWriteTimeout_int.phpt" role="test" />
+ <file md5sum="1557d33bc6c620c3cb6f64aefec95eb6" name="tests/amqpconnection_setWriteTimeout_out_of_range.phpt" role="test" />
+ <file md5sum="63efc639ba17621d65facd6a957e4a3e" name="tests/amqpconnection_setWriteTimeout_string.phpt" role="test" />
+ <file md5sum="f27e48180e45ffaff7fc2945b2bb6718" name="tests/amqpconnection_toomanychannels.phpt" role="test" />
+ <file md5sum="02ba7a1c003ebf0b8888f04cc6133ed7" name="tests/amqpconnection_var_dump.phpt" role="test" />
+ <file md5sum="528ae67de535a92e62cd5a7a7974cea3" name="tests/amqpenvelope_get_accessors.phpt" role="test" />
+ <file md5sum="bc1c52e4d1e459c8a60aa2fe6175f96f" name="tests/amqpenvelope_var_dump.phpt" role="test" />
+ <file md5sum="3cdd27b9ac134c99278e13a7783ee0bf" name="tests/amqpexchange_bind.phpt" role="test" />
+ <file md5sum="a8d465a0ba6d926e77b03a0af44972d8" name="tests/amqpexchange_bind_with_arguments.phpt" role="test" />
+ <file md5sum="0d1917327d0be2a106107fd40da240c2" name="tests/amqpexchange_bind_without_key.phpt" role="test" />
+ <file md5sum="14d8f19aaa7ef5dfc6433a69ad1392f7" name="tests/amqpexchange_bind_without_key_with_arguments.phpt" role="test" />
+ <file md5sum="5c0c19fbe0080234182f77b88f8a3b49" name="tests/amqpexchange_channel_refcount.phpt" role="test" />
+ <file md5sum="e14bc6d3e6bf2db658522fd880ff8342" name="tests/amqpexchange_construct_basic.phpt" role="test" />
+ <file md5sum="978a4d0d8bf603990e99d686d6298dcf" name="tests/amqpexchange_declare_basic.phpt" role="test" />
+ <file md5sum="e910acd5d274bb722be2e4c5c564eacf" name="tests/amqpexchange_declare_existent.phpt" role="test" />
+ <file md5sum="8e5fb0edb96401eb40b02fa96403231b" name="tests/amqpexchange_get_channel.phpt" role="test" />
+ <file md5sum="f7576d0cfaba1da1861438f9372cb221" name="tests/amqpexchange_get_connection.phpt" role="test" />
+ <file md5sum="bf2e1921405cd73178fba23fdc94812c" name="tests/amqpexchange_invalid_type.phpt" role="test" />
+ <file md5sum="28d40d0147069b95f19370dabcc05d51" name="tests/amqpexchange_publish_basic.phpt" role="test" />
+ <file md5sum="4d07c2070b00e062b8dbeb3ba47e7423" name="tests/amqpexchange_publish_empty_routing_key.phpt" role="test" />
+ <file md5sum="3104f4df0061613ca1b2fa958cddbe17" name="tests/amqpexchange_publish_with_properties.phpt" role="test" />
+ <file md5sum="100a493cfe499876c744c6320021f6d5" name="tests/amqpexchange_publish_with_properties_ignore_num_header.phpt" role="test" />
+ <file md5sum="e70ffc740233f2a84d6e98234584c195" name="tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt" role="test" />
+ <file md5sum="1c5594bea4a280b282e1cf0a3c3454c1" name="tests/amqpexchange_publish_with_properties_nested_header.phpt" role="test" />
+ <file md5sum="4137d0f1d5b6a9e6a9cf08a0f25bd3fc" name="tests/amqpexchange_publish_with_properties_user_id_failure.phpt" role="test" />
+ <file md5sum="6692eef7a0bb10e53ef74e1809e3dd85" name="tests/amqpexchange_set_flag.phpt" role="test" />
+ <file md5sum="88f38d2d9512e48022d36605eb6fd282" name="tests/amqpexchange_set_flags.phpt" role="test" />
+ <file md5sum="647497c26f3df6a927848a51bb871fc8" name="tests/amqpexchange_unbind.phpt" role="test" />
+ <file md5sum="f638c9fc507429242b9ddcd775f99abc" name="tests/amqpexchange_unbind_with_arguments.phpt" role="test" />
+ <file md5sum="db754e7e6d2dba44ab49f92b736e1de4" name="tests/amqpexchange_unbind_without_key.phpt" role="test" />
+ <file md5sum="497f46c611f6520f68a56f244a594a4b" name="tests/amqpexchange_unbind_without_key_with_arguments.phpt" role="test" />
+ <file md5sum="bb6596d9586ad78b20cdcac842791c52" name="tests/amqpexchange_var_dump.phpt" role="test" />
+ <file md5sum="4a0a5a690b1f784d85bd040302575a3d" name="tests/amqpqueue_bind_basic.phpt" role="test" />
+ <file md5sum="da143124281d829386f617269ec93fcf" name="tests/amqpqueue_bind_basic_empty_routing_key.phpt" role="test" />
+ <file md5sum="de63dbee4f05ec49ce48ec198b843f4b" name="tests/amqpqueue_bind_basic_headers_arguments.phpt" role="test" />
+ <file md5sum="9b39051f8ef3472bb23b9748da28314d" name="tests/amqpqueue_cancel.phpt" role="test" />
+ <file md5sum="2fc0d97c30d609f40b7c85f529d3f752" name="tests/amqpqueue_construct_basic.phpt" role="test" />
+ <file md5sum="f5a98750453e50334b0aba98efa0b048" name="tests/amqpqueue_consume_basic.phpt" role="test" />
+ <file md5sum="e772e975f5b3d44935e6bb7766ad88e1" name="tests/amqpqueue_consume_multiple.phpt" role="test" />
+ <file md5sum="3cfe9025a23532d552f23fc54d2826d8" name="tests/amqpqueue_consume_nonexistent.phpt" role="test" />
+ <file md5sum="036b629ee10295b0807c73719f22c27f" name="tests/amqpqueue_consume_timeout.phpt" role="test" />
+ <file md5sum="52fff1bf831ded585e3f8819504204b8" name="tests/amqpqueue_declare_basic.phpt" role="test" />
+ <file md5sum="589544992486dc8be9060c3a9ed0c531" name="tests/amqpqueue_delete_basic.phpt" role="test" />
+ <file md5sum="5f559bb943f89d6d2b7f5ab1a85dc42b" name="tests/amqpqueue_empty_name.phpt" role="test" />
+ <file md5sum="23bd785da99b207b13f77d098e4c3f54" name="tests/amqpqueue_get_basic.phpt" role="test" />
+ <file md5sum="6cce48f3831c2d78e92ef263097386d9" name="tests/amqpqueue_get_channel.phpt" role="test" />
+ <file md5sum="5d764f35a9635bd532e9af55f6e63f41" name="tests/amqpqueue_get_connection.phpt" role="test" />
+ <file md5sum="3148d357f550c22bd83ec5339ca63133" name="tests/amqpqueue_get_empty_body.phpt" role="test" />
+ <file md5sum="b29f533327baac398ea760643d3f057f" name="tests/amqpqueue_get_headers.phpt" role="test" />
+ <file md5sum="a591a624eb357a0ef50fc71f0465974d" name="tests/amqpqueue_get_nonexistent.phpt" role="test" />
+ <file md5sum="0f586fa4ee026cef30cf5d330af1133e" name="tests/amqpqueue_nack.phpt" role="test" />
+ <file md5sum="c61d7596374c94b3adc4fab185d00c80" name="tests/amqpqueue_nested_arrays.phpt" role="test" />
+ <file md5sum="3015b1c0f6984bb934dd02748cae6514" name="tests/amqpqueue_nested_headers.phpt" role="test" />
+ <file md5sum="abaf080a5feab914919e8bcf837e9d83" name="tests/amqpqueue_purge_basic.phpt" role="test" />
+ <file md5sum="cc8d6bd67a59536e3a92a3550016e82e" name="tests/amqpqueue_unbind_basic_empty_routing_key.phpt" role="test" />
+ <file md5sum="49ab1e6c77ed9331b5371c04faf95653" name="tests/amqpqueue_unbind_basic_headers_arguments.phpt" role="test" />
+ <file md5sum="186881024eaa17a83a1d93aba3ca5942" name="tests/amqpqueue_var_dump.phpt" role="test" />
+ <file md5sum="efbcc35b58c7b65064660ca65fb1f8da" name="tests/bug_17831.phpt" role="test" />
+ <file md5sum="d85e785d26e265b242b94af5ed2fa046" name="tests/bug_19707.phpt" role="test" />
+ <file md5sum="aac2b2dbbea1bef2322ac549e416ca38" name="tests/bug_19840.phpt" role="test" />
+ <file md5sum="b734fa81a4bb70550ef447ec2dadb5a4" name="tests/bug_61533.phpt" role="test" />
+ <file md5sum="70c4b1222072be9591ff0f2d6bd4a0c9" name="tests/bug_62354.phpt" role="test" />
+ <file md5sum="764b70058dc0694eb7060c50f9bda611" name="tests/bug_gh50-1.phpt" role="test" />
+ <file md5sum="61c947c8bcc32226f09c845f1ca69734" name="tests/bug_gh50-2.phpt" role="test" />
+ <file md5sum="555901187984375d0eda9fd2aa5fb9ed" name="tests/bug_gh50-3.phpt" role="test" />
+ <file md5sum="c791ab105f32830962f2961745dc433e" name="tests/bug_gh50-4.phpt" role="test" />
+ <file md5sum="b7c71b6b0c0653eafe9f8caa15335975" name="tests/bug_gh53-2.phpt" role="test" />
+ <file md5sum="6dab7744024b4d6258141513c15ed102" name="tests/bug_gh53.phpt" role="test" />
+ <file md5sum="d8de8918a3c73ebdcb4159581ea58b5f" name="tests/bug_gh72-1.phpt" role="test" />
+ <file md5sum="0bed5ba885ea925a6045502569a1e946" name="tests/bug_gh72-2.phpt" role="test" />
+ <file md5sum="4f646dfe852ca88d292c987b4b16a71f" name="tests/bug_gh147.phpt" role="test" />
+ <file md5sum="167ef3d96b27b21a1f41e4124ff732e5" name="tests/package-version.phpt" role="test" />
+ </dir>
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.2.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.4.0</min>
+ </pearinstaller>
+ </required>
+ </dependencies>
+ <providesextension>amqp</providesextension>
+ <extsrcrelease />
+</package>

File Metadata

Mime Type
text/x-diff
Expires
Sat, May 16, 7:30 AM (20 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
64101
Default Alt Text
(405 KB)

Event Timeline