1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 5                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2007 The PHP Group                                |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP license,      |
8   | that is bundled with this package in the file LICENSE, and is        |
9   | available through the world-wide-web at the following url:           |
10   | http://www.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
16   | Lead:                                                                |
17   | - Pieter de Zwart                                                    |
18   | Maintainers:                                                         |
19   | - Brad Rodriguez                                                     |
20   | - Jonathan Tansavatdi                                                |
21   +----------------------------------------------------------------------+
22 */
23 #ifndef PHP_AMQP_CONNECTION_RESOURCE_H
24 #define PHP_AMQP_CONNECTION_RESOURCE_H
25 
26 #define PHP_AMQP_RESOURCE_RESPONSE_BREAK                    1
27 #define PHP_AMQP_RESOURCE_RESPONSE_OK                       0
28 #define PHP_AMQP_RESOURCE_RESPONSE_ERROR                   -1
29 #define PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED    -2
30 #define PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED -3
31 
32 extern int le_amqp_connection_resource;
33 extern int le_amqp_connection_resource_persistent;
34 
35 #include "php_amqp.h"
36 #include "amqp.h"
37 
38 void php_amqp_prepare_for_disconnect(amqp_connection_resource *resource TSRMLS_DC);
39 
40 typedef struct _amqp_connection_params {
41   char *login;
42   char *password;
43   char *host;
44   char *vhost;
45   int port;
46   int channel_max;
47   int frame_max;
48   int heartbeat;
49   double read_timeout;
50   double write_timeout;
51   double connect_timeout;
52   double rpc_timeout;
53   char *cacert;
54   char *cert;
55   char *key;
56   int verify;
57   int sasl_method;
58   char *connection_name;
59 } amqp_connection_params;
60 
61 /* Figure out what's going on connection and handle protocol exceptions, if any */
62 int php_amqp_connection_resource_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC);
63 int php_amqp_connection_resource_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel TSRMLS_DC);
64 
65 /* Socket-related functions */
66 int php_amqp_set_resource_read_timeout(amqp_connection_resource *resource, double read_timeout TSRMLS_DC);
67 int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, double write_timeout TSRMLS_DC);
68 
69 /*Not socket-related rpc timeout function */
70 int php_amqp_set_resource_rpc_timeout(amqp_connection_resource *resource, double rpc_timeout TSRMLS_DC);
71 
72 /* Channel-related functions */
73 amqp_channel_t php_amqp_connection_resource_get_available_channel_id(amqp_connection_resource *resource);
74 int php_amqp_connection_resource_unregister_channel(amqp_connection_resource *resource, amqp_channel_t channel_id);
75 int php_amqp_connection_resource_register_channel(amqp_connection_resource *resource, amqp_channel_resource *channel_resource, amqp_channel_t channel_id);
76 
77 /* Creating and destroying resource */
78 amqp_connection_resource *connection_resource_constructor(amqp_connection_params *params, zend_bool persistent TSRMLS_DC);
79 ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor_persistent);
80 ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor);
81 
82 #endif
83 /*
84 *Local variables:
85 *tab-width: 4
86 *c-basic-offset: 4
87 *End:
88 *vim600: noet sw=4 ts=4 fdm=marker
89 *vim<600: noet sw=4 ts=4
90 */
91