1    	/** \file */
2    	/*
3    	 * ***** BEGIN LICENSE BLOCK *****
4    	 * Version: MIT
5    	 *
6    	 * Portions created by Alan Antonuk are Copyright (c) 2012-2014
7    	 * Alan Antonuk. All Rights Reserved.
8    	 *
9    	 * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc.
10   	 * All Rights Reserved.
11   	 *
12   	 * Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010
13   	 * VMware, Inc. and Tony Garnock-Jones. All Rights Reserved.
14   	 *
15   	 * Permission is hereby granted, free of charge, to any person
16   	 * obtaining a copy of this software and associated documentation
17   	 * files (the "Software"), to deal in the Software without
18   	 * restriction, including without limitation the rights to use, copy,
19   	 * modify, merge, publish, distribute, sublicense, and/or sell copies
20   	 * of the Software, and to permit persons to whom the Software is
21   	 * furnished to do so, subject to the following conditions:
22   	 *
23   	 * The above copyright notice and this permission notice shall be
24   	 * included in all copies or substantial portions of the Software.
25   	 *
26   	 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27   	 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28   	 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29   	 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30   	 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31   	 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32   	 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33   	 * SOFTWARE.
34   	 * ***** END LICENSE BLOCK *****
35   	 */
36   	
37   	#ifndef AMQP_H
38   	#define AMQP_H
39   	
40   	/** \cond HIDE_FROM_DOXYGEN */
41   	
42   	#ifdef __cplusplus
43   	#define AMQP_BEGIN_DECLS extern "C" {
44   	#define AMQP_END_DECLS }
45   	#else
46   	#define AMQP_BEGIN_DECLS
47   	#define AMQP_END_DECLS
48   	#endif
49   	
50   	/*
51   	 * \internal
52   	 * Important API decorators:
53   	 *  AMQP_PUBLIC_FUNCTION - a public API function
54   	 *  AMQP_PUBLIC_VARIABLE - a public API external variable
55   	 *  AMQP_CALL - calling convension (used on Win32)
56   	 */
57   	
58   	#if defined(_WIN32) && defined(_MSC_VER)
59   	#if defined(AMQP_BUILD) && !defined(AMQP_STATIC)
60   	#define AMQP_PUBLIC_FUNCTION __declspec(dllexport)
61   	#define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern
62   	#else
63   	#define AMQP_PUBLIC_FUNCTION
64   	#if !defined(AMQP_STATIC)
65   	#define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern
66   	#else
67   	#define AMQP_PUBLIC_VARIABLE extern
68   	#endif
69   	#endif
70   	#define AMQP_CALL __cdecl
71   	
72   	#elif defined(_WIN32) && defined(__BORLANDC__)
73   	#if defined(AMQP_BUILD) && !defined(AMQP_STATIC)
74   	#define AMQP_PUBLIC_FUNCTION __declspec(dllexport)
75   	#define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern
76   	#else
77   	#define AMQP_PUBLIC_FUNCTION
78   	#if !defined(AMQP_STATIC)
79   	#define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern
80   	#else
81   	#define AMQP_PUBLIC_VARIABLE extern
82   	#endif
83   	#endif
84   	#define AMQP_CALL __cdecl
85   	
86   	#elif defined(_WIN32) && defined(__MINGW32__)
87   	#if defined(AMQP_BUILD) && !defined(AMQP_STATIC)
88   	#define AMQP_PUBLIC_FUNCTION __declspec(dllexport)
89   	#define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern
90   	#else
91   	#define AMQP_PUBLIC_FUNCTION
92   	#if !defined(AMQP_STATIC)
93   	#define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern
94   	#else
95   	#define AMQP_PUBLIC_VARIABLE extern
96   	#endif
97   	#endif
98   	#define AMQP_CALL __cdecl
99   	
100  	#elif defined(_WIN32) && defined(__CYGWIN__)
101  	#if defined(AMQP_BUILD) && !defined(AMQP_STATIC)
102  	#define AMQP_PUBLIC_FUNCTION __declspec(dllexport)
103  	#define AMQP_PUBLIC_VARIABLE __declspec(dllexport)
104  	#else
105  	#define AMQP_PUBLIC_FUNCTION
106  	#if !defined(AMQP_STATIC)
107  	#define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern
108  	#else
109  	#define AMQP_PUBLIC_VARIABLE extern
110  	#endif
111  	#endif
112  	#define AMQP_CALL __cdecl
113  	
114  	#elif defined(__GNUC__) && __GNUC__ >= 4
115  	#define AMQP_PUBLIC_FUNCTION __attribute__((visibility("default")))
116  	#define AMQP_PUBLIC_VARIABLE __attribute__((visibility("default"))) extern
117  	#define AMQP_CALL
118  	#else
119  	#define AMQP_PUBLIC_FUNCTION
120  	#define AMQP_PUBLIC_VARIABLE extern
121  	#define AMQP_CALL
122  	#endif
123  	
124  	#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
125  	#define AMQP_DEPRECATED(function) function __attribute__((__deprecated__))
126  	#elif defined(_MSC_VER)
127  	#define AMQP_DEPRECATED(function) __declspec(deprecated) function
128  	#else
129  	#define AMQP_DEPRECATED(function)
130  	#endif
131  	
132  	/* Define ssize_t on Win32/64 platforms
133  	   See: http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-April/030649.html for
134  	   details
135  	   */
136  	#if !defined(_W64)
137  	#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
138  	#define _W64 __w64
139  	#else
140  	#define _W64
141  	#endif
142  	#endif
143  	
144  	#ifdef _MSC_VER
145  	#ifdef _WIN64
146  	typedef __int64 ssize_t;
147  	#else
148  	typedef _W64 int ssize_t;
149  	#endif
150  	#endif
151  	
152  	#if defined(_WIN32) && defined(__MINGW32__)
153  	#include <sys/types.h>
154  	#endif
155  	
156  	/** \endcond */
157  	
158  	#include <stddef.h>
159  	#include <stdint.h>
160  	
161  	struct timeval;
162  	
163  	AMQP_BEGIN_DECLS
164  	
165  	/**
166  	 * \def AMQP_VERSION_MAJOR
167  	 *
168  	 * Major library version number compile-time constant
169  	 *
170  	 * The major version is incremented when backwards incompatible API changes
171  	 * are made.
172  	 *
173  	 * \sa AMQP_VERSION, AMQP_VERSION_STRING
174  	 *
175  	 * \since v0.4.0
176  	 */
177  	
178  	/**
179  	 * \def AMQP_VERSION_MINOR
180  	 *
181  	 * Minor library version number compile-time constant
182  	 *
183  	 * The minor version is incremented when new APIs are added. Existing APIs
184  	 * are left alone.
185  	 *
186  	 * \sa AMQP_VERSION, AMQP_VERSION_STRING
187  	 *
188  	 * \since v0.4.0
189  	 */
190  	
191  	/**
192  	 * \def AMQP_VERSION_PATCH
193  	 *
194  	 * Patch library version number compile-time constant
195  	 *
196  	 * The patch version is incremented when library code changes, but the API
197  	 * is not changed.
198  	 *
199  	 * \sa AMQP_VERSION, AMQP_VERSION_STRING
200  	 *
201  	 * \since v0.4.0
202  	 */
203  	
204  	/**
205  	 * \def AMQP_VERSION_IS_RELEASE
206  	 *
207  	 * Version constant set to 1 for tagged release, 0 otherwise
208  	 *
209  	 * NOTE: versions that are not tagged releases are not guaranteed to be API/ABI
210  	 * compatible with older releases, and may change commit-to-commit.
211  	 *
212  	 * \sa AMQP_VERSION, AMQP_VERSION_STRING
213  	 *
214  	 * \since v0.4.0
215  	 */
216  	/*
217  	 * Developer note: when changing these, be sure to update SOVERSION constants
218  	 *  in CMakeLists.txt and configure.ac
219  	 */
220  	
221  	#define AMQP_VERSION_MAJOR 0
222  	#define AMQP_VERSION_MINOR 9
223  	#define AMQP_VERSION_PATCH 0
224  	#define AMQP_VERSION_IS_RELEASE 1
225  	
226  	/**
227  	 * \def AMQP_VERSION_CODE
228  	 *
229  	 * Helper macro to geneate a packed version code suitable for
230  	 * comparison with AMQP_VERSION.
231  	 *
232  	 * \sa amqp_version_number() AMQP_VERSION_MAJOR, AMQP_VERSION_MINOR,
233  	 *     AMQP_VERSION_PATCH, AMQP_VERSION_IS_RELEASE, AMQP_VERSION
234  	 *
235  	 * \since v0.6.1
236  	 */
237  	#define AMQP_VERSION_CODE(major, minor, patch, release) \
238  	  ((major << 24) | (minor << 16) | (patch << 8) | (release))
239  	
240  	/**
241  	 * \def AMQP_VERSION
242  	 *
243  	 * Packed version number
244  	 *
245  	 * AMQP_VERSION is a 4-byte unsigned integer with the most significant byte
246  	 * set to AMQP_VERSION_MAJOR, the second most significant byte set to
247  	 * AMQP_VERSION_MINOR, third most significant byte set to AMQP_VERSION_PATCH,
248  	 * and the lowest byte set to AMQP_VERSION_IS_RELEASE.
249  	 *
250  	 * For example version 2.3.4 which is released version would be encoded as
251  	 * 0x02030401
252  	 *
253  	 * \sa amqp_version_number() AMQP_VERSION_MAJOR, AMQP_VERSION_MINOR,
254  	 *     AMQP_VERSION_PATCH, AMQP_VERSION_IS_RELEASE, AMQP_VERSION_CODE
255  	 *
256  	 * \since v0.4.0
257  	 */
258  	#define AMQP_VERSION                                        \
259  	  AMQP_VERSION_CODE(AMQP_VERSION_MAJOR, AMQP_VERSION_MINOR, \
260  	                    AMQP_VERSION_PATCH, AMQP_VERSION_IS_RELEASE)
261  	
262  	/** \cond HIDE_FROM_DOXYGEN */
263  	#define AMQ_STRINGIFY(s) AMQ_STRINGIFY_HELPER(s)
264  	#define AMQ_STRINGIFY_HELPER(s) #s
265  	
266  	#define AMQ_VERSION_STRING          \
267  	  AMQ_STRINGIFY(AMQP_VERSION_MAJOR) \
268  	  "." AMQ_STRINGIFY(AMQP_VERSION_MINOR) "." AMQ_STRINGIFY(AMQP_VERSION_PATCH)
269  	/** \endcond */
270  	
271  	/**
272  	 * \def AMQP_VERSION_STRING
273  	 *
274  	 * Version string compile-time constant
275  	 *
276  	 * Non-released versions of the library will have "-pre" appended to the
277  	 * version string
278  	 *
279  	 * \sa amqp_version()
280  	 *
281  	 * \since v0.4.0
282  	 */
283  	#if AMQP_VERSION_IS_RELEASE
284  	#define AMQP_VERSION_STRING AMQ_VERSION_STRING
285  	#else
286  	#define AMQP_VERSION_STRING AMQ_VERSION_STRING "-pre"
287  	#endif
288  	
289  	/**
290  	 * Returns the rabbitmq-c version as a packed integer.
291  	 *
292  	 * See \ref AMQP_VERSION
293  	 *
294  	 * \return packed 32-bit integer representing version of library at runtime
295  	 *
296  	 * \sa AMQP_VERSION, amqp_version()
297  	 *
298  	 * \since v0.4.0
299  	 */
300  	AMQP_PUBLIC_FUNCTION
301  	uint32_t AMQP_CALL amqp_version_number(void);
302  	
303  	/**
304  	 * Returns the rabbitmq-c version as a string.
305  	 *
306  	 * See \ref AMQP_VERSION_STRING
307  	 *
308  	 * \return a statically allocated string describing the version of rabbitmq-c.
309  	 *
310  	 * \sa amqp_version_number(), AMQP_VERSION_STRING, AMQP_VERSION
311  	 *
312  	 * \since v0.1
313  	 */
314  	AMQP_PUBLIC_FUNCTION
315  	char const *AMQP_CALL amqp_version(void);
316  	
317  	/**
318  	 * \def AMQP_DEFAULT_FRAME_SIZE
319  	 *
320  	 * Default frame size (128Kb)
321  	 *
322  	 * \sa amqp_login(), amqp_login_with_properties()
323  	 *
324  	 * \since v0.4.0
325  	 */
326  	#define AMQP_DEFAULT_FRAME_SIZE 131072
327  	
328  	/**
329  	 * \def AMQP_DEFAULT_MAX_CHANNELS
330  	 *
331  	 * Default maximum number of channels (0, no limit)
332  	 *
333  	 * \sa amqp_login(), amqp_login_with_properties()
334  	 *
335  	 * \since v0.4.0
336  	 */
337  	#define AMQP_DEFAULT_MAX_CHANNELS 0
338  	
339  	/**
340  	 * \def AMQP_DEFAULT_HEARTBEAT
341  	 *
342  	 * Default heartbeat interval (0, heartbeat disabled)
343  	 *
344  	 * \sa amqp_login(), amqp_login_with_properties()
345  	 *
346  	 * \since v0.4.0
347  	 */
348  	#define AMQP_DEFAULT_HEARTBEAT 0
349  	
350  	/**
351  	 * \def AMQP_DEFAULT_VHOST
352  	 *
353  	 * Default RabbitMQ vhost: "/"
354  	 *
355  	 * \sa amqp_login(), amqp_login_with_properties()
356  	 *
357  	 * \since v0.9.0
358  	 */
359  	#define AMQP_DEFAULT_VHOST "/"
360  	
361  	/**
362  	 * boolean type 0 = false, true otherwise
363  	 *
364  	 * \since v0.1
365  	 */
366  	typedef int amqp_boolean_t;
367  	
368  	/**
369  	 * Method number
370  	 *
371  	 * \since v0.1
372  	 */
373  	typedef uint32_t amqp_method_number_t;
374  	
375  	/**
376  	 * Bitmask for flags
377  	 *
378  	 * \since v0.1
379  	 */
380  	typedef uint32_t amqp_flags_t;
381  	
382  	/**
383  	 * Channel type
384  	 *
385  	 * \since v0.1
386  	 */
387  	typedef uint16_t amqp_channel_t;
388  	
389  	/**
390  	 * Buffer descriptor
391  	 *
392  	 * \since v0.1
393  	 */
394  	typedef struct amqp_bytes_t_ {
395  	  size_t len;  /**< length of the buffer in bytes */
396  	  void *bytes; /**< pointer to the beginning of the buffer */
397  	} amqp_bytes_t;
398  	
399  	/**
400  	 * Decimal data type
401  	 *
402  	 * \since v0.1
403  	 */
404  	typedef struct amqp_decimal_t_ {
405  	  uint8_t decimals; /**< the location of the decimal point */
406  	  uint32_t value;   /**< the value before the decimal point is applied */
407  	} amqp_decimal_t;
408  	
409  	/**
410  	 * AMQP field table
411  	 *
412  	 * An AMQP field table is a set of key-value pairs.
413  	 * A key is a UTF-8 encoded string up to 128 bytes long, and are not null
414  	 * terminated.
415  	 * A value can be one of several different datatypes. \sa
416  	 * amqp_field_value_kind_t
417  	 *
418  	 * \sa amqp_table_entry_t
419  	 *
420  	 * \since v0.1
421  	 */
422  	typedef struct amqp_table_t_ {
423  	  int num_entries;                     /**< length of entries array */
424  	  struct amqp_table_entry_t_ *entries; /**< an array of table entries */
425  	} amqp_table_t;
426  	
427  	/**
428  	 * An AMQP Field Array
429  	 *
430  	 * A repeated set of field values, all must be of the same type
431  	 *
432  	 * \since v0.1
433  	 */
434  	typedef struct amqp_array_t_ {
435  	  int num_entries;                     /**< Number of entries in the table */
436  	  struct amqp_field_value_t_ *entries; /**< linked list of field values */
437  	} amqp_array_t;
438  	
439  	/*
440  	  0-9   0-9-1   Qpid/Rabbit  Type               Remarks
441  	---------------------------------------------------------------------------
442  	        t       t            Boolean
443  	        b       b            Signed 8-bit
444  	        B                    Unsigned 8-bit
445  	        U       s            Signed 16-bit      (A1)
446  	        u                    Unsigned 16-bit
447  	  I     I       I            Signed 32-bit
448  	        i                    Unsigned 32-bit
449  	        L       l            Signed 64-bit      (B)
450  	        l                    Unsigned 64-bit
451  	        f       f            32-bit float
452  	        d       d            64-bit float
453  	  D     D       D            Decimal
454  	        s                    Short string       (A2)
455  	  S     S       S            Long string
456  	        A                    Nested Array
457  	  T     T       T            Timestamp (u64)
458  	  F     F       F            Nested Table
459  	  V     V       V            Void
460  	                x            Byte array
461  	
462  	Remarks:
463  	
464  	 A1, A2: Notice how the types **CONFLICT** here. In Qpid and Rabbit,
465  	         's' means a signed 16-bit integer; in 0-9-1, it means a
466  	          short string.
467  	
468  	 B: Notice how the signednesses **CONFLICT** here. In Qpid and Rabbit,
469  	    'l' means a signed 64-bit integer; in 0-9-1, it means an unsigned
470  	    64-bit integer.
471  	
472  	I'm going with the Qpid/Rabbit types, where there's a conflict, and
473  	the 0-9-1 types otherwise. 0-8 is a subset of 0-9, which is a subset
474  	of the other two, so this will work for both 0-8 and 0-9-1 branches of
475  	the code.
476  	*/
477  	
478  	/**
479  	 * A field table value
480  	 *
481  	 * \since v0.1
482  	 */
483  	typedef struct amqp_field_value_t_ {
484  	  uint8_t kind; /**< the type of the entry /sa amqp_field_value_kind_t */
485  	  union {
486  	    amqp_boolean_t boolean; /**< boolean type AMQP_FIELD_KIND_BOOLEAN */
487  	    int8_t i8;              /**< int8_t type AMQP_FIELD_KIND_I8 */
488  	    uint8_t u8;             /**< uint8_t type AMQP_FIELD_KIND_U8 */
489  	    int16_t i16;            /**< int16_t type AMQP_FIELD_KIND_I16 */
490  	    uint16_t u16;           /**< uint16_t type AMQP_FIELD_KIND_U16 */
491  	    int32_t i32;            /**< int32_t type AMQP_FIELD_KIND_I32 */
492  	    uint32_t u32;           /**< uint32_t type AMQP_FIELD_KIND_U32 */
493  	    int64_t i64;            /**< int64_t type AMQP_FIELD_KIND_I64 */
494  	    uint64_t u64;           /**< uint64_t type AMQP_FIELD_KIND_U64,
495  	                               AMQP_FIELD_KIND_TIMESTAMP */
496  	    float f32;              /**< float type AMQP_FIELD_KIND_F32 */
497  	    double f64;             /**< double type AMQP_FIELD_KIND_F64 */
498  	    amqp_decimal_t decimal; /**< amqp_decimal_t AMQP_FIELD_KIND_DECIMAL */
499  	    amqp_bytes_t bytes;     /**< amqp_bytes_t type AMQP_FIELD_KIND_UTF8,
500  	                               AMQP_FIELD_KIND_BYTES */
501  	    amqp_table_t table;     /**< amqp_table_t type AMQP_FIELD_KIND_TABLE */
502  	    amqp_array_t array;     /**< amqp_array_t type AMQP_FIELD_KIND_ARRAY */
503  	  } value;                  /**< a union of the value */
504  	} amqp_field_value_t;
505  	
506  	/**
507  	 * An entry in a field-table
508  	 *
509  	 * \sa amqp_table_encode(), amqp_table_decode(), amqp_table_clone()
510  	 *
511  	 * \since v0.1
512  	 */
513  	typedef struct amqp_table_entry_t_ {
514  	  amqp_bytes_t key; /**< the table entry key. Its a null-terminated UTF-8
515  	                     * string, with a maximum size of 128 bytes */
516  	  amqp_field_value_t value; /**< the table entry values */
517  	} amqp_table_entry_t;
518  	
519  	/**
520  	 * Field value types
521  	 *
522  	 * \since v0.1
523  	 */
524  	typedef enum {
525  	  AMQP_FIELD_KIND_BOOLEAN =
526  	      't', /**< boolean type. 0 = false, 1 = true @see amqp_boolean_t */
527  	  AMQP_FIELD_KIND_I8 = 'b',  /**< 8-bit signed integer, datatype: int8_t */
528  	  AMQP_FIELD_KIND_U8 = 'B',  /**< 8-bit unsigned integer, datatype: uint8_t */
529  	  AMQP_FIELD_KIND_I16 = 's', /**< 16-bit signed integer, datatype: int16_t */
530  	  AMQP_FIELD_KIND_U16 = 'u', /**< 16-bit unsigned integer, datatype: uint16_t */
531  	  AMQP_FIELD_KIND_I32 = 'I', /**< 32-bit signed integer, datatype: int32_t */
532  	  AMQP_FIELD_KIND_U32 = 'i', /**< 32-bit unsigned integer, datatype: uint32_t */
533  	  AMQP_FIELD_KIND_I64 = 'l', /**< 64-bit signed integer, datatype: int64_t */
534  	  AMQP_FIELD_KIND_U64 = 'L', /**< 64-bit unsigned integer, datatype: uint64_t */
535  	  AMQP_FIELD_KIND_F32 =
536  	      'f', /**< single-precision floating point value, datatype: float */
537  	  AMQP_FIELD_KIND_F64 =
538  	      'd', /**< double-precision floating point value, datatype: double */
539  	  AMQP_FIELD_KIND_DECIMAL =
540  	      'D', /**< amqp-decimal value, datatype: amqp_decimal_t */
541  	  AMQP_FIELD_KIND_UTF8 = 'S',      /**< UTF-8 null-terminated character string,
542  	                                      datatype: amqp_bytes_t */
543  	  AMQP_FIELD_KIND_ARRAY = 'A',     /**< field array (repeated values of another
544  	                                      datatype. datatype: amqp_array_t */
545  	  AMQP_FIELD_KIND_TIMESTAMP = 'T', /**< 64-bit timestamp. datatype uint64_t */
546  	  AMQP_FIELD_KIND_TABLE = 'F', /**< field table. encapsulates a table inside a
547  	                                  table entry. datatype: amqp_table_t */
548  	  AMQP_FIELD_KIND_VOID = 'V',  /**< empty entry */
549  	  AMQP_FIELD_KIND_BYTES =
550  	      'x' /**< unformatted byte string, datatype: amqp_bytes_t */
551  	} amqp_field_value_kind_t;
552  	
553  	/**
554  	 * A list of allocation blocks
555  	 *
556  	 * \since v0.1
557  	 */
558  	typedef struct amqp_pool_blocklist_t_ {
559  	  int num_blocks;   /**< Number of blocks in the block list */
560  	  void **blocklist; /**< Array of memory blocks */
561  	} amqp_pool_blocklist_t;
562  	
563  	/**
564  	 * A memory pool
565  	 *
566  	 * \since v0.1
567  	 */
568  	typedef struct amqp_pool_t_ {
569  	  size_t pagesize; /**< the size of the page in bytes. Allocations less than or
570  	                    * equal to this size are allocated in the pages block list.
571  	                    * Allocations greater than this are allocated in their own
572  	                    * own block in the large_blocks block list */
573  	
574  	  amqp_pool_blocklist_t pages; /**< blocks that are the size of pagesize */
575  	  amqp_pool_blocklist_t
576  	      large_blocks; /**< allocations larger than the pagesize */
577  	
578  	  int next_page;     /**< an index to the next unused page block */
579  	  char *alloc_block; /**< pointer to the current allocation block */
580  	  size_t alloc_used; /**< number of bytes in the current allocation block that
581  	                        has been used */
582  	} amqp_pool_t;
583  	
584  	/**
585  	 * An amqp method
586  	 *
587  	 * \since v0.1
588  	 */
589  	typedef struct amqp_method_t_ {
590  	  amqp_method_number_t id; /**< the method id number */
591  	  void *decoded;           /**< pointer to the decoded method,
592  	                            *    cast to the appropriate type to use */
593  	} amqp_method_t;
594  	
595  	/**
596  	 * An AMQP frame
597  	 *
598  	 * \since v0.1
599  	 */
600  	typedef struct amqp_frame_t_ {
601  	  uint8_t frame_type;     /**< frame type. The types:
602  	                           * - AMQP_FRAME_METHOD - use the method union member
603  	                           * - AMQP_FRAME_HEADER - use the properties union member
604  	                           * - AMQP_FRAME_BODY - use the body_fragment union member
605  	                           */
606  	  amqp_channel_t channel; /**< the channel the frame was received on */
607  	  union {
608  	    amqp_method_t
609  	        method; /**< a method, use if frame_type == AMQP_FRAME_METHOD */
610  	    struct {
611  	      uint16_t class_id;        /**< the class for the properties */
612  	      uint64_t body_size;       /**< size of the body in bytes */
613  	      void *decoded;            /**< the decoded properties */
614  	      amqp_bytes_t raw;         /**< amqp-encoded properties structure */
615  	    } properties;               /**< message header, a.k.a., properties,
616  	                                      use if frame_type == AMQP_FRAME_HEADER */
617  	    amqp_bytes_t body_fragment; /**< a body fragment, use if frame_type ==
618  	                                   AMQP_FRAME_BODY */
619  	    struct {
620  	      uint8_t transport_high;         /**< @internal first byte of handshake */
621  	      uint8_t transport_low;          /**< @internal second byte of handshake */
622  	      uint8_t protocol_version_major; /**< @internal third byte of handshake */
623  	      uint8_t protocol_version_minor; /**< @internal fourth byte of handshake */
624  	    } protocol_header; /**< Used only when doing the initial handshake with the
625  	                          broker, don't use otherwise */
626  	  } payload;           /**< the payload of the frame */
627  	} amqp_frame_t;
628  	
629  	/**
630  	 * Response type
631  	 *
632  	 * \since v0.1
633  	 */
634  	typedef enum amqp_response_type_enum_ {
635  	  AMQP_RESPONSE_NONE = 0, /**< the library got an EOF from the socket */
636  	  AMQP_RESPONSE_NORMAL, /**< response normal, the RPC completed successfully */
637  	  AMQP_RESPONSE_LIBRARY_EXCEPTION, /**< library error, an error occurred in the
638  	                                      library, examine the library_error */
639  	  AMQP_RESPONSE_SERVER_EXCEPTION   /**< server exception, the broker returned an
640  	                                      error, check replay */
641  	} amqp_response_type_enum;
642  	
643  	/**
644  	 * Reply from a RPC method on the broker
645  	 *
646  	 * \since v0.1
647  	 */
648  	typedef struct amqp_rpc_reply_t_ {
649  	  amqp_response_type_enum reply_type; /**< the reply type:
650  	                                       * - AMQP_RESPONSE_NORMAL - the RPC
651  	                                       * completed successfully
652  	                                       * - AMQP_RESPONSE_SERVER_EXCEPTION - the
653  	                                       * broker returned
654  	                                       *     an exception, check the reply field
655  	                                       * - AMQP_RESPONSE_LIBRARY_EXCEPTION - the
656  	                                       * library
657  	                                       *    encountered an error, check the
658  	                                       * library_error field
659  	                                       */
(1) Event member_decl: Class member declaration for "reply".
Also see events: [uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member]
660  	  amqp_method_t reply; /**< in case of AMQP_RESPONSE_SERVER_EXCEPTION this
661  	                        * field will be set to the method returned from the
662  	                        * broker */
(3) Event member_decl: Class member declaration for "library_error".
Also see events: [member_decl][uninit_member][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member]
663  	  int library_error;   /**< in case of AMQP_RESPONSE_LIBRARY_EXCEPTION this
664  	                        *    field will be set to an error code. An error
665  	                        *     string can be retrieved using amqp_error_string */
666  	} amqp_rpc_reply_t;
667  	
668  	/**
669  	 * SASL method type
670  	 *
671  	 * \since v0.1
672  	 */
673  	typedef enum amqp_sasl_method_enum_ {
674  	  AMQP_SASL_METHOD_UNDEFINED = -1, /**< Invalid SASL method */
675  	  AMQP_SASL_METHOD_PLAIN =
676  	      0, /**< the PLAIN SASL method for authentication to the broker */
677  	  AMQP_SASL_METHOD_EXTERNAL =
678  	      1 /**< the EXTERNAL SASL method for authentication to the broker */
679  	} amqp_sasl_method_enum;
680  	
681  	/**
682  	 * connection state object
683  	 *
684  	 * \since v0.1
685  	 */
686  	typedef struct amqp_connection_state_t_ *amqp_connection_state_t;
687  	
688  	/**
689  	 * Socket object
690  	 *
691  	 * \since v0.4.0
692  	 */
693  	typedef struct amqp_socket_t_ amqp_socket_t;
694  	
695  	/**
696  	 * Status codes
697  	 *
698  	 * \since v0.4.0
699  	 */
700  	/* NOTE: When updating this enum, update the strings in librabbitmq/amqp_api.c
701  	 */
702  	typedef enum amqp_status_enum_ {
703  	  AMQP_STATUS_OK = 0x0,                             /**< Operation successful */
704  	  AMQP_STATUS_NO_MEMORY = -0x0001,                  /**< Memory allocation
705  	                                                         failed */
706  	  AMQP_STATUS_BAD_AMQP_DATA = -0x0002,              /**< Incorrect or corrupt
707  	                                                         data was received from
708  	                                                         the broker. This is a
709  	                                                         protocol error. */
710  	  AMQP_STATUS_UNKNOWN_CLASS = -0x0003,              /**< An unknown AMQP class
711  	                                                         was received. This is
712  	                                                         a protocol error. */
713  	  AMQP_STATUS_UNKNOWN_METHOD = -0x0004,             /**< An unknown AMQP method
714  	                                                         was received. This is
715  	                                                         a protocol error. */
716  	  AMQP_STATUS_HOSTNAME_RESOLUTION_FAILED = -0x0005, /**< Unable to resolve the
717  	                                                     * hostname */
718  	  AMQP_STATUS_INCOMPATIBLE_AMQP_VERSION = -0x0006,  /**< The broker advertised
719  	                                                         an incompaible AMQP
720  	                                                         version */
721  	  AMQP_STATUS_CONNECTION_CLOSED = -0x0007,          /**< The connection to the
722  	                                                         broker has been closed
723  	                                                         */
724  	  AMQP_STATUS_BAD_URL = -0x0008,                    /**< malformed AMQP URL */
725  	  AMQP_STATUS_SOCKET_ERROR = -0x0009,               /**< A socket error
726  	                                                         occurred */
727  	  AMQP_STATUS_INVALID_PARAMETER = -0x000A,          /**< An invalid parameter
728  	                                                         was passed into the
729  	                                                         function */
730  	  AMQP_STATUS_TABLE_TOO_BIG = -0x000B,              /**< The amqp_table_t object
731  	                                                         cannot be serialized
732  	                                                         because the output
733  	                                                         buffer is too small */
734  	  AMQP_STATUS_WRONG_METHOD = -0x000C,               /**< The wrong method was
735  	                                                         received */
736  	  AMQP_STATUS_TIMEOUT = -0x000D,                    /**< Operation timed out */
737  	  AMQP_STATUS_TIMER_FAILURE = -0x000E,              /**< The underlying system
738  	                                                         timer facility failed */
739  	  AMQP_STATUS_HEARTBEAT_TIMEOUT = -0x000F,          /**< Timed out waiting for
740  	                                                         heartbeat */
741  	  AMQP_STATUS_UNEXPECTED_STATE = -0x0010,           /**< Unexpected protocol
742  	                                                         state */
743  	  AMQP_STATUS_SOCKET_CLOSED = -0x0011,              /**< Underlying socket is
744  	                                                         closed */
745  	  AMQP_STATUS_SOCKET_INUSE = -0x0012,               /**< Underlying socket is
746  	                                                         already open */
747  	  AMQP_STATUS_BROKER_UNSUPPORTED_SASL_METHOD = -0x0013, /**< Broker does not
748  	                                                          support the requested
749  	                                                          SASL mechanism */
750  	  AMQP_STATUS_UNSUPPORTED = -0x0014, /**< Parameter is unsupported
751  	                                       in this version */
752  	  _AMQP_STATUS_NEXT_VALUE = -0x0015, /**< Internal value */
753  	
754  	  AMQP_STATUS_TCP_ERROR = -0x0100,                /**< A generic TCP error
755  	                                                       occurred */
756  	  AMQP_STATUS_TCP_SOCKETLIB_INIT_ERROR = -0x0101, /**< An error occurred trying
757  	                                                       to initialize the
758  	                                                       socket library*/
759  	  _AMQP_STATUS_TCP_NEXT_VALUE = -0x0102,          /**< Internal value */
760  	
761  	  AMQP_STATUS_SSL_ERROR = -0x0200,                  /**< A generic SSL error
762  	                                                         occurred. */
763  	  AMQP_STATUS_SSL_HOSTNAME_VERIFY_FAILED = -0x0201, /**< SSL validation of
764  	                                                         hostname against
765  	                                                         peer certificate
766  	                                                         failed */
767  	  AMQP_STATUS_SSL_PEER_VERIFY_FAILED = -0x0202,     /**< SSL validation of peer
768  	                                                         certificate failed. */
769  	  AMQP_STATUS_SSL_CONNECTION_FAILED = -0x0203, /**< SSL handshake failed. */
770  	  _AMQP_STATUS_SSL_NEXT_VALUE = -0x0204        /**< Internal value */
771  	} amqp_status_enum;
772  	
773  	/**
774  	 * AMQP delivery modes.
775  	 * Use these values for the #amqp_basic_properties_t::delivery_mode field.
776  	 *
777  	 * \since v0.5
778  	 */
779  	typedef enum {
780  	  AMQP_DELIVERY_NONPERSISTENT = 1, /**< Non-persistent message */
781  	  AMQP_DELIVERY_PERSISTENT = 2     /**< Persistent message */
782  	} amqp_delivery_mode_enum;
783  	
784  	AMQP_END_DECLS
785  	
786  	#include <amqp_framing.h>
787  	
788  	AMQP_BEGIN_DECLS
789  	
790  	/**
791  	 * Empty bytes structure
792  	 *
793  	 * \since v0.2
794  	 */
795  	AMQP_PUBLIC_VARIABLE const amqp_bytes_t amqp_empty_bytes;
796  	
797  	/**
798  	 * Empty table structure
799  	 *
800  	 * \since v0.2
801  	 */
802  	AMQP_PUBLIC_VARIABLE const amqp_table_t amqp_empty_table;
803  	
804  	/**
805  	 * Empty table array structure
806  	 *
807  	 * \since v0.2
808  	 */
809  	AMQP_PUBLIC_VARIABLE const amqp_array_t amqp_empty_array;
810  	
811  	/* Compatibility macros for the above, to avoid the need to update
812  	   code written against earlier versions of librabbitmq. */
813  	
814  	/**
815  	 * \def AMQP_EMPTY_BYTES
816  	 *
817  	 * Deprecated, use \ref amqp_empty_bytes instead
818  	 *
819  	 * \deprecated use \ref amqp_empty_bytes instead
820  	 *
821  	 * \since v0.1
822  	 */
823  	#define AMQP_EMPTY_BYTES amqp_empty_bytes
824  	
825  	/**
826  	 * \def AMQP_EMPTY_TABLE
827  	 *
828  	 * Deprecated, use \ref amqp_empty_table instead
829  	 *
830  	 * \deprecated use \ref amqp_empty_table instead
831  	 *
832  	 * \since v0.1
833  	 */
834  	#define AMQP_EMPTY_TABLE amqp_empty_table
835  	
836  	/**
837  	 * \def AMQP_EMPTY_ARRAY
838  	 *
839  	 * Deprecated, use \ref amqp_empty_array instead
840  	 *
841  	 * \deprecated use \ref amqp_empty_array instead
842  	 *
843  	 * \since v0.1
844  	 */
845  	#define AMQP_EMPTY_ARRAY amqp_empty_array
846  	
847  	/**
848  	 * Initializes an amqp_pool_t memory allocation pool for use
849  	 *
850  	 * Readies an allocation pool for use. An amqp_pool_t
851  	 * must be initialized before use
852  	 *
853  	 * \param [in] pool the amqp_pool_t structure to initialize.
854  	 *              Calling this function on a pool a pool that has
855  	 *              already been initialized will result in undefined
856  	 *              behavior
857  	 * \param [in] pagesize the unit size that the pool will allocate
858  	 *              memory chunks in. Anything allocated against the pool
859  	 *              with a requested size will be carved out of a block
860  	 *              this size. Allocations larger than this will be
861  	 *              allocated individually
862  	 *
863  	 * \sa recycle_amqp_pool(), empty_amqp_pool(), amqp_pool_alloc(),
864  	 *     amqp_pool_alloc_bytes(), amqp_pool_t
865  	 *
866  	 * \since v0.1
867  	 */
868  	AMQP_PUBLIC_FUNCTION
869  	void AMQP_CALL init_amqp_pool(amqp_pool_t *pool, size_t pagesize);
870  	
871  	/**
872  	 * Recycles an amqp_pool_t memory allocation pool
873  	 *
874  	 * Recycles the space allocate by the pool
875  	 *
876  	 * This invalidates all allocations made against the pool before this call is
877  	 * made, any use of any allocations made before recycle_amqp_pool() is called
878  	 * will result in undefined behavior.
879  	 *
880  	 * Note: this may or may not release memory, to force memory to be released
881  	 * call empty_amqp_pool().
882  	 *
883  	 * \param [in] pool the amqp_pool_t to recycle
884  	 *
885  	 * \sa recycle_amqp_pool(), empty_amqp_pool(), amqp_pool_alloc(),
886  	 *      amqp_pool_alloc_bytes()
887  	 *
888  	 * \since v0.1
889  	 *
890  	 */
891  	AMQP_PUBLIC_FUNCTION
892  	void AMQP_CALL recycle_amqp_pool(amqp_pool_t *pool);
893  	
894  	/**
895  	 * Empties an amqp memory pool
896  	 *
897  	 * Releases all memory associated with an allocation pool
898  	 *
899  	 * \param [in] pool the amqp_pool_t to empty
900  	 *
901  	 * \since v0.1
902  	 */
903  	AMQP_PUBLIC_FUNCTION
904  	void AMQP_CALL empty_amqp_pool(amqp_pool_t *pool);
905  	
906  	/**
907  	 * Allocates a block of memory from an amqp_pool_t memory pool
908  	 *
909  	 * Memory will be aligned on a 8-byte boundary. If a 0-length allocation is
910  	 * requested, a NULL pointer will be returned.
911  	 *
912  	 * \param [in] pool the allocation pool to allocate the memory from
913  	 * \param [in] amount the size of the allocation in bytes.
914  	 * \return a pointer to the memory block, or NULL if the allocation cannot
915  	 *          be satisfied.
916  	 *
917  	 * \sa init_amqp_pool(), recycle_amqp_pool(), empty_amqp_pool(),
918  	 *     amqp_pool_alloc_bytes()
919  	 *
920  	 * \since v0.1
921  	 */
922  	AMQP_PUBLIC_FUNCTION
923  	void *AMQP_CALL amqp_pool_alloc(amqp_pool_t *pool, size_t amount);
924  	
925  	/**
926  	 * Allocates a block of memory from an amqp_pool_t to an amqp_bytes_t
927  	 *
928  	 * Memory will be aligned on a 8-byte boundary. If a 0-length allocation is
929  	 * requested, output.bytes = NULL.
930  	 *
931  	 * \param [in] pool the allocation pool to allocate the memory from
932  	 * \param [in] amount the size of the allocation in bytes
933  	 * \param [in] output the location to store the pointer. On success
934  	 *              output.bytes will be set to the beginning of the buffer
935  	 *              output.len will be set to amount
936  	 *              On error output.bytes will be set to NULL and output.len
937  	 *              set to 0
938  	 *
939  	 * \sa init_amqp_pool(), recycle_amqp_pool(), empty_amqp_pool(),
940  	 *     amqp_pool_alloc()
941  	 *
942  	 * \since v0.1
943  	 */
944  	AMQP_PUBLIC_FUNCTION
945  	void AMQP_CALL amqp_pool_alloc_bytes(amqp_pool_t *pool, size_t amount,
946  	                                     amqp_bytes_t *output);
947  	
948  	/**
949  	 * Wraps a c string in an amqp_bytes_t
950  	 *
951  	 * Takes a string, calculates its length and creates an
952  	 * amqp_bytes_t that points to it. The string is not duplicated.
953  	 *
954  	 * For a given input cstr, The amqp_bytes_t output.bytes is the
955  	 * same as cstr, output.len is the length of the string not including
956  	 * the \0 terminator
957  	 *
958  	 * This function uses strlen() internally so cstr must be properly
959  	 * terminated
960  	 *
961  	 * \param [in] cstr the c string to wrap
962  	 * \return an amqp_bytes_t that describes the string
963  	 *
964  	 * \since v0.1
965  	 */
966  	AMQP_PUBLIC_FUNCTION
967  	amqp_bytes_t AMQP_CALL amqp_cstring_bytes(char const *cstr);
968  	
969  	/**
970  	 * Duplicates an amqp_bytes_t buffer.
971  	 *
972  	 * The buffer is cloned and the contents copied.
973  	 *
974  	 * The memory associated with the output is allocated
975  	 * with amqp_bytes_malloc() and should be freed with
976  	 * amqp_bytes_free()
977  	 *
978  	 * \param [in] src
979  	 * \return a clone of the src
980  	 *
981  	 * \sa amqp_bytes_free(), amqp_bytes_malloc()
982  	 *
983  	 * \since v0.1
984  	 */
985  	AMQP_PUBLIC_FUNCTION
986  	amqp_bytes_t AMQP_CALL amqp_bytes_malloc_dup(amqp_bytes_t src);
987  	
988  	/**
989  	 * Allocates a amqp_bytes_t buffer
990  	 *
991  	 * Creates an amqp_bytes_t buffer of the specified amount, the buffer should be
992  	 * freed using amqp_bytes_free()
993  	 *
994  	 * \param [in] amount the size of the buffer in bytes
995  	 * \returns an amqp_bytes_t with amount bytes allocated.
996  	 *           output.bytes will be set to NULL on error
997  	 *
998  	 * \sa amqp_bytes_free(), amqp_bytes_malloc_dup()
999  	 *
1000 	 * \since v0.1
1001 	 */
1002 	AMQP_PUBLIC_FUNCTION
1003 	amqp_bytes_t AMQP_CALL amqp_bytes_malloc(size_t amount);
1004 	
1005 	/**
1006 	 * Frees an amqp_bytes_t buffer
1007 	 *
1008 	 * Frees a buffer allocated with amqp_bytes_malloc() or amqp_bytes_malloc_dup()
1009 	 *
1010 	 * Calling amqp_bytes_free on buffers not allocated with one
1011 	 * of those two functions will result in undefined behavior
1012 	 *
1013 	 * \param [in] bytes the buffer to free
1014 	 *
1015 	 * \sa amqp_bytes_malloc(), amqp_bytes_malloc_dup()
1016 	 *
1017 	 * \since v0.1
1018 	 */
1019 	AMQP_PUBLIC_FUNCTION
1020 	void AMQP_CALL amqp_bytes_free(amqp_bytes_t bytes);
1021 	
1022 	/**
1023 	 * Allocate and initialize a new amqp_connection_state_t object
1024 	 *
1025 	 * amqp_connection_state_t objects created with this function
1026 	 * should be freed with amqp_destroy_connection()
1027 	 *
1028 	 * \returns an opaque pointer on success, NULL or 0 on failure.
1029 	 *
1030 	 * \sa amqp_destroy_connection()
1031 	 *
1032 	 * \since v0.1
1033 	 */
1034 	AMQP_PUBLIC_FUNCTION
1035 	amqp_connection_state_t AMQP_CALL amqp_new_connection(void);
1036 	
1037 	/**
1038 	 * Get the underlying socket descriptor for the connection
1039 	 *
1040 	 * \warning Use the socket returned from this function carefully, incorrect use
1041 	 * of the socket outside of the library will lead to undefined behavior.
1042 	 * Additionally rabbitmq-c may use the socket differently version-to-version,
1043 	 * what may work in one version, may break in the next version. Be sure to
1044 	 * throughly test any applications that use the socket returned by this
1045 	 * function especially when using a newer version of rabbitmq-c
1046 	 *
1047 	 * \param [in] state the connection object
1048 	 * \returns the socket descriptor if one has been set, -1 otherwise
1049 	 *
1050 	 * \sa amqp_tcp_socket_new(), amqp_ssl_socket_new(), amqp_socket_open()
1051 	 *
1052 	 * \since v0.1
1053 	 */
1054 	AMQP_PUBLIC_FUNCTION
1055 	int AMQP_CALL amqp_get_sockfd(amqp_connection_state_t state);
1056 	
1057 	/**
1058 	 * Deprecated, use amqp_tcp_socket_new() or amqp_ssl_socket_new()
1059 	 *
1060 	 * \deprecated Use amqp_tcp_socket_new() or amqp_ssl_socket_new()
1061 	 *
1062 	 * Sets the socket descriptor associated with the connection. The socket
1063 	 * should be connected to a broker, and should not be read to or written from
1064 	 * before calling this function.  A socket descriptor can be created and opened
1065 	 * using amqp_open_socket()
1066 	 *
1067 	 * \param [in] state the connection object
1068 	 * \param [in] sockfd the socket
1069 	 *
1070 	 * \sa amqp_open_socket(), amqp_tcp_socket_new(), amqp_ssl_socket_new()
1071 	 *
1072 	 * \since v0.1
1073 	 */
1074 	AMQP_DEPRECATED(AMQP_PUBLIC_FUNCTION void AMQP_CALL
1075 	                    amqp_set_sockfd(amqp_connection_state_t state, int sockfd));
1076 	
1077 	/**
1078 	 * Tune client side parameters
1079 	 *
1080 	 * \warning This function may call abort() if the connection is in a certain
1081 	 *  state. As such it should probably not be called code outside the library.
1082 	 *  connection parameters should be specified when calling amqp_login() or
1083 	 *  amqp_login_with_properties()
1084 	 *
1085 	 * This function changes channel_max, frame_max, and heartbeat parameters, on
1086 	 * the client side only. It does not try to renegotiate these parameters with
1087 	 * the broker. Using this function will lead to unexpected results.
1088 	 *
1089 	 * \param [in] state the connection object
1090 	 * \param [in] channel_max the maximum number of channels.
1091 	 *              The largest this can be is 65535
1092 	 * \param [in] frame_max the maximum size of an frame.
1093 	 *              The smallest this can be is 4096
1094 	 *              The largest this can be is 2147483647
1095 	 *              Unless you know what you're doing the recommended
1096 	 *              size is 131072 or 128KB
1097 	 * \param [in] heartbeat the number of seconds between heartbeats
1098 	 *
1099 	 * \return AMQP_STATUS_OK on success, an amqp_status_enum value otherwise.
1100 	 *  Possible error codes include:
1101 	 *  - AMQP_STATUS_NO_MEMORY memory allocation failed.
1102 	 *  - AMQP_STATUS_TIMER_FAILURE the underlying system timer indicated it
1103 	 *    failed.
1104 	 *
1105 	 * \sa amqp_login(), amqp_login_with_properties()
1106 	 *
1107 	 * \since v0.1
1108 	 */
1109 	AMQP_PUBLIC_FUNCTION
1110 	int AMQP_CALL amqp_tune_connection(amqp_connection_state_t state,
1111 	                                   int channel_max, int frame_max,
1112 	                                   int heartbeat);
1113 	
1114 	/**
1115 	 * Get the maximum number of channels the connection can handle
1116 	 *
1117 	 * The maximum number of channels is set when connection negotiation takes
1118 	 * place in amqp_login() or amqp_login_with_properties().
1119 	 *
1120 	 * \param [in] state the connection object
1121 	 * \return the maximum number of channels. 0 if there is no limit
1122 	 *
1123 	 * \since v0.1
1124 	 */
1125 	AMQP_PUBLIC_FUNCTION
1126 	int AMQP_CALL amqp_get_channel_max(amqp_connection_state_t state);
1127 	
1128 	/**
1129 	 * Get the maximum size of an frame the connection can handle
1130 	 *
1131 	 * The maximum size of an frame is set when connection negotiation takes
1132 	 * place in amqp_login() or amqp_login_with_properties().
1133 	 *
1134 	 * \param [in] state the connection object
1135 	 * \return the maximum size of an frame.
1136 	 *
1137 	 * \since v0.6
1138 	 */
1139 	AMQP_PUBLIC_FUNCTION
1140 	int AMQP_CALL amqp_get_frame_max(amqp_connection_state_t state);
1141 	
1142 	/**
1143 	 * Get the number of seconds between heartbeats of the connection
1144 	 *
1145 	 * The number of seconds between heartbeats is set when connection
1146 	 * negotiation takes place in amqp_login() or amqp_login_with_properties().
1147 	 *
1148 	 * \param [in] state the connection object
1149 	 * \return the number of seconds between heartbeats.
1150 	 *
1151 	 * \since v0.6
1152 	 */
1153 	AMQP_PUBLIC_FUNCTION
1154 	int AMQP_CALL amqp_get_heartbeat(amqp_connection_state_t state);
1155 	
1156 	/**
1157 	 * Destroys an amqp_connection_state_t object
1158 	 *
1159 	 * Destroys a amqp_connection_state_t object that was created with
1160 	 * amqp_new_connection(). If the connection with the broker is open, it will be
1161 	 * implicitly closed with a reply code of 200 (success). Any memory that
1162 	 * would be freed with amqp_maybe_release_buffers() or
1163 	 * amqp_maybe_release_buffers_on_channel() will be freed, and use of that
1164 	 * memory will caused undefined behavior.
1165 	 *
1166 	 * \param [in] state the connection object
1167 	 * \return AMQP_STATUS_OK on success. amqp_status_enum value failure
1168 	 *
1169 	 * \sa amqp_new_connection()
1170 	 *
1171 	 * \since v0.1
1172 	 */
1173 	AMQP_PUBLIC_FUNCTION
1174 	int AMQP_CALL amqp_destroy_connection(amqp_connection_state_t state);
1175 	
1176 	/**
1177 	 * Process incoming data
1178 	 *
1179 	 * \warning This is a low-level function intended for those who want to
1180 	 *  have greater control over input and output over the socket from the
1181 	 *  broker. Correctly using this function requires in-depth knowledge of AMQP
1182 	 *  and rabbitmq-c.
1183 	 *
1184 	 * For a given buffer of data received from the broker, decode the first
1185 	 * frame in the buffer. If more than one frame is contained in the input buffer
1186 	 * the return value will be less than the received_data size, the caller should
1187 	 * adjust received_data buffer descriptor to point to the beginning of the
1188 	 * buffer + the return value.
1189 	 *
1190 	 * \param [in] state the connection object
1191 	 * \param [in] received_data a buffer of data received from the broker. The
1192 	 *  function will return the number of bytes of the buffer it used. The
1193 	 *  function copies these bytes to an internal buffer: this part of the buffer
1194 	 *  may be reused after this function successfully completes.
1195 	 * \param [in,out] decoded_frame caller should pass in a pointer to an
1196 	 *  amqp_frame_t struct. If there is enough data in received_data for a
1197 	 *  complete frame, decoded_frame->frame_type will be set to something OTHER
1198 	 *  than 0. decoded_frame may contain members pointing to memory owned by
1199 	 *  the state object. This memory can be recycled with
1200 	 *  amqp_maybe_release_buffers() or amqp_maybe_release_buffers_on_channel().
1201 	 * \return number of bytes consumed from received_data or 0 if a 0-length
1202 	 *  buffer was passed. A negative return value indicates failure. Possible
1203 	 * errors:
1204 	 *  - AMQP_STATUS_NO_MEMORY failure in allocating memory. The library is likely
1205 	 *    in an indeterminate state making recovery unlikely. Client should note the
1206 	 *    error and terminate the application
1207 	 *  - AMQP_STATUS_BAD_AMQP_DATA bad AMQP data was received. The connection
1208 	 *    should be shutdown immediately
1209 	 *  - AMQP_STATUS_UNKNOWN_METHOD: an unknown method was received from the
1210 	 *    broker. This is likely a protocol error and the connection should be
1211 	 *    shutdown immediately
1212 	 *  - AMQP_STATUS_UNKNOWN_CLASS: a properties frame with an unknown class
1213 	 *    was received from the broker. This is likely a protocol error and the
1214 	 *    connection should be shutdown immediately
1215 	 *
1216 	 * \since v0.1
1217 	 */
1218 	AMQP_PUBLIC_FUNCTION
1219 	int AMQP_CALL amqp_handle_input(amqp_connection_state_t state,
1220 	                                amqp_bytes_t received_data,
1221 	                                amqp_frame_t *decoded_frame);
1222 	
1223 	/**
1224 	 * Check to see if connection memory can be released
1225 	 *
1226 	 * \deprecated This function is deprecated in favor of
1227 	 *  amqp_maybe_release_buffers() or amqp_maybe_release_buffers_on_channel()
1228 	 *
1229 	 * Checks the state of an amqp_connection_state_t object to see if
1230 	 * amqp_release_buffers() can be called successfully.
1231 	 *
1232 	 * \param [in] state the connection object
1233 	 * \returns TRUE if the buffers can be released FALSE otherwise
1234 	 *
1235 	 * \sa amqp_release_buffers() amqp_maybe_release_buffers()
1236 	 *  amqp_maybe_release_buffers_on_channel()
1237 	 *
1238 	 * \since v0.1
1239 	 */
1240 	AMQP_PUBLIC_FUNCTION
1241 	amqp_boolean_t AMQP_CALL amqp_release_buffers_ok(amqp_connection_state_t state);
1242 	
1243 	/**
1244 	 * Release amqp_connection_state_t owned memory
1245 	 *
1246 	 * \deprecated This function is deprecated in favor of
1247 	 *  amqp_maybe_release_buffers() or amqp_maybe_release_buffers_on_channel()
1248 	 *
1249 	 * \warning caller should ensure amqp_release_buffers_ok() returns true before
1250 	 *  calling this function. Failure to do so may result in abort() being called.
1251 	 *
1252 	 * Release memory owned by the amqp_connection_state_t for reuse by the
1253 	 * library. Use of any memory returned by the library before this function is
1254 	 * called will result in undefined behavior.
1255 	 *
1256 	 * \note internally rabbitmq-c tries to reuse memory when possible. As a result
1257 	 * its possible calling this function may not have a noticeable effect on
1258 	 * memory usage.
1259 	 *
1260 	 * \param [in] state the connection object
1261 	 *
1262 	 * \sa amqp_release_buffers_ok() amqp_maybe_release_buffers()
1263 	 *  amqp_maybe_release_buffers_on_channel()
1264 	 *
1265 	 * \since v0.1
1266 	 */
1267 	AMQP_PUBLIC_FUNCTION
1268 	void AMQP_CALL amqp_release_buffers(amqp_connection_state_t state);
1269 	
1270 	/**
1271 	 * Release amqp_connection_state_t owned memory
1272 	 *
1273 	 * Release memory owned by the amqp_connection_state_t object related to any
1274 	 * channel, allowing reuse by the library. Use of any memory returned by the
1275 	 * library before this function is called with result in undefined behavior.
1276 	 *
1277 	 * \note internally rabbitmq-c tries to reuse memory when possible. As a result
1278 	 * its possible calling this function may not have a noticeable effect on
1279 	 * memory usage.
1280 	 *
1281 	 * \param [in] state the connection object
1282 	 *
1283 	 * \sa amqp_maybe_release_buffers_on_channel()
1284 	 *
1285 	 * \since v0.1
1286 	 */
1287 	AMQP_PUBLIC_FUNCTION
1288 	void AMQP_CALL amqp_maybe_release_buffers(amqp_connection_state_t state);
1289 	
1290 	/**
1291 	 * Release amqp_connection_state_t owned memory related to a channel
1292 	 *
1293 	 * Release memory owned by the amqp_connection_state_t object related to the
1294 	 * specified channel, allowing reuse by the library. Use of any memory returned
1295 	 * the library for a specific channel will result in undefined behavior.
1296 	 *
1297 	 * \note internally rabbitmq-c tries to reuse memory when possible. As a result
1298 	 * its possible calling this function may not have a noticeable effect on
1299 	 * memory usage.
1300 	 *
1301 	 * \param [in] state the connection object
1302 	 * \param [in] channel the channel specifier for which memory should be
1303 	 *  released. Note that the library does not care about the state of the
1304 	 *  channel when calling this function
1305 	 *
1306 	 * \sa amqp_maybe_release_buffers()
1307 	 *
1308 	 * \since v0.4.0
1309 	 */
1310 	AMQP_PUBLIC_FUNCTION
1311 	void AMQP_CALL amqp_maybe_release_buffers_on_channel(
1312 	    amqp_connection_state_t state, amqp_channel_t channel);
1313 	
1314 	/**
1315 	 * Send a frame to the broker
1316 	 *
1317 	 * \param [in] state the connection object
1318 	 * \param [in] frame the frame to send to the broker
1319 	 * \return AMQP_STATUS_OK on success, an amqp_status_enum value on error.
1320 	 *  Possible error codes:
1321 	 *  - AMQP_STATUS_BAD_AMQP_DATA the serialized form of the method or
1322 	 *    properties was too large to fit in a single AMQP frame, or the
1323 	 *    method contains an invalid value. The frame was not sent.
1324 	 *  - AMQP_STATUS_TABLE_TOO_BIG the serialized form of an amqp_table_t is
1325 	 *    too large to fit in a single AMQP frame. Frame was not sent.
1326 	 *  - AMQP_STATUS_UNKNOWN_METHOD an invalid method type was passed in
1327 	 *  - AMQP_STATUS_UNKNOWN_CLASS an invalid properties type was passed in
1328 	 *  - AMQP_STATUS_TIMER_FAILURE system timer indicated failure. The frame
1329 	 *    was sent
1330 	 *  - AMQP_STATUS_SOCKET_ERROR
1331 	 *  - AMQP_STATUS_SSL_ERROR
1332 	 *
1333 	 * \since v0.1
1334 	 */
1335 	AMQP_PUBLIC_FUNCTION
1336 	int AMQP_CALL amqp_send_frame(amqp_connection_state_t state,
1337 	                              amqp_frame_t const *frame);
1338 	
1339 	/**
1340 	 * Compare two table entries
1341 	 *
1342 	 * Works just like strcmp(), comparing two the table keys, datatype, then values
1343 	 *
1344 	 * \param [in] entry1 the entry on the left
1345 	 * \param [in] entry2 the entry on the right
1346 	 * \return 0 if entries are equal, 0 < if left is greater, 0 > if right is
1347 	 * greater
1348 	 *
1349 	 * \since v0.1
1350 	 */
1351 	AMQP_PUBLIC_FUNCTION
1352 	int AMQP_CALL amqp_table_entry_cmp(void const *entry1, void const *entry2);
1353 	
1354 	/**
1355 	 * Open a socket to a remote host
1356 	 *
1357 	 * \deprecated This function is deprecated in favor of amqp_socket_open()
1358 	 *
1359 	 * Looks up the hostname, then attempts to open a socket to the host using
1360 	 * the specified portnumber. It also sets various options on the socket to
1361 	 * improve performance and correctness.
1362 	 *
1363 	 * \param [in] hostname this can be a hostname or IP address.
1364 	 *              Both IPv4 and IPv6 are acceptable
1365 	 * \param [in] portnumber the port to connect on. RabbitMQ brokers
1366 	 *              listen on port 5672, and 5671 for SSL
1367 	 * \return a positive value indicates success and is the sockfd. A negative
1368 	 *  value (see amqp_status_enum)is returned on failure. Possible error codes:
1369 	 *  - AMQP_STATUS_TCP_SOCKETLIB_INIT_ERROR Initialization of underlying socket
1370 	 *    library failed.
1371 	 *  - AMQP_STATUS_HOSTNAME_RESOLUTION_FAILED hostname lookup failed.
1372 	 *  - AMQP_STATUS_SOCKET_ERROR a socket error occurred. errno or
1373 	 *    WSAGetLastError() may return more useful information.
1374 	 *
1375 	 * \note IPv6 support was added in v0.3
1376 	 *
1377 	 * \sa amqp_socket_open() amqp_set_sockfd()
1378 	 *
1379 	 * \since v0.1
1380 	 */
1381 	AMQP_PUBLIC_FUNCTION
1382 	int AMQP_CALL amqp_open_socket(char const *hostname, int portnumber);
1383 	
1384 	/**
1385 	 * Send initial AMQP header to the broker
1386 	 *
1387 	 * \warning this is a low level function intended for those who want to
1388 	 * interact with the broker at a very low level. Use of this function without
1389 	 * understanding what it does will result in AMQP protocol errors.
1390 	 *
1391 	 * This function sends the AMQP protocol header to the broker.
1392 	 *
1393 	 * \param [in] state the connection object
1394 	 * \return AMQP_STATUS_OK on success, a negative value on failure. Possible
1395 	 *  error codes:
1396 	 * - AMQP_STATUS_CONNECTION_CLOSED the connection to the broker was closed.
1397 	 * - AMQP_STATUS_SOCKET_ERROR a socket error occurred. It is likely the
1398 	 *   underlying socket has been closed. errno or WSAGetLastError() may provide
1399 	 *   further information.
1400 	 * - AMQP_STATUS_SSL_ERROR a SSL error occurred. The connection to the broker
1401 	 *   was closed.
1402 	 *
1403 	 * \since v0.1
1404 	 */
1405 	AMQP_PUBLIC_FUNCTION
1406 	int AMQP_CALL amqp_send_header(amqp_connection_state_t state);
1407 	
1408 	/**
1409 	 * Checks to see if there are any incoming frames ready to be read
1410 	 *
1411 	 * Checks to see if there are any amqp_frame_t objects buffered by the
1412 	 * amqp_connection_state_t object. Having one or more frames buffered means
1413 	 * that amqp_simple_wait_frame() or amqp_simple_wait_frame_noblock() will
1414 	 * return a frame without potentially blocking on a read() call.
1415 	 *
1416 	 * \param [in] state the connection object
1417 	 * \return TRUE if there are frames enqueued, FALSE otherwise
1418 	 *
1419 	 * \sa amqp_simple_wait_frame() amqp_simple_wait_frame_noblock()
1420 	 *  amqp_data_in_buffer()
1421 	 *
1422 	 * \since v0.1
1423 	 */
1424 	AMQP_PUBLIC_FUNCTION
1425 	amqp_boolean_t AMQP_CALL amqp_frames_enqueued(amqp_connection_state_t state);
1426 	
1427 	/**
1428 	 * Read a single amqp_frame_t
1429 	 *
1430 	 * Waits for the next amqp_frame_t frame to be read from the broker.
1431 	 * This function has the potential to block for a long time in the case of
1432 	 * waiting for a basic.deliver method frame from the broker.
1433 	 *
1434 	 * The library may buffer frames. When an amqp_connection_state_t object
1435 	 * has frames buffered calling amqp_simple_wait_frame() will return an
1436 	 * amqp_frame_t without entering a blocking read(). You can test to see if
1437 	 * an amqp_connection_state_t object has frames buffered by calling the
1438 	 * amqp_frames_enqueued() function.
1439 	 *
1440 	 * The library has a socket read buffer. When there is data in an
1441 	 * amqp_connection_state_t read buffer, amqp_simple_wait_frame() may return an
1442 	 * amqp_frame_t without entering a blocking read(). You can test to see if an
1443 	 * amqp_connection_state_t object has data in its read buffer by calling the
1444 	 * amqp_data_in_buffer() function.
1445 	 *
1446 	 * \param [in] state the connection object
1447 	 * \param [out] decoded_frame the frame
1448 	 * \return AMQP_STATUS_OK on success, an amqp_status_enum value
1449 	 *  is returned otherwise. Possible errors include:
1450 	 *  - AMQP_STATUS_NO_MEMORY failure in allocating memory. The library is likely
1451 	 *    in an indeterminate state making recovery unlikely. Client should note the
1452 	 *    error and terminate the application
1453 	 *  - AMQP_STATUS_BAD_AMQP_DATA bad AMQP data was received. The connection
1454 	 *    should be shutdown immediately
1455 	 *  - AMQP_STATUS_UNKNOWN_METHOD: an unknown method was received from the
1456 	 *    broker. This is likely a protocol error and the connection should be
1457 	 *    shutdown immediately
1458 	 *  - AMQP_STATUS_UNKNOWN_CLASS: a properties frame with an unknown class
1459 	 *    was received from the broker. This is likely a protocol error and the
1460 	 *    connection should be shutdown immediately
1461 	 *  - AMQP_STATUS_HEARTBEAT_TIMEOUT timed out while waiting for heartbeat
1462 	 *    from the broker. The connection has been closed.
1463 	 *  - AMQP_STATUS_TIMER_FAILURE system timer indicated failure.
1464 	 *  - AMQP_STATUS_SOCKET_ERROR a socket error occurred. The connection has
1465 	 *    been closed
1466 	 *  - AMQP_STATUS_SSL_ERROR a SSL socket error occurred. The connection has
1467 	 *    been closed.
1468 	 *
1469 	 * \sa amqp_simple_wait_frame_noblock() amqp_frames_enqueued()
1470 	 *  amqp_data_in_buffer()
1471 	 *
1472 	 * \note as of v0.4.0 this function will no longer return heartbeat frames
1473 	 *  when enabled by specifying a non-zero heartbeat value in amqp_login().
1474 	 *  Heartbeating is handled internally by the library.
1475 	 *
1476 	 * \since v0.1
1477 	 */
1478 	AMQP_PUBLIC_FUNCTION
1479 	int AMQP_CALL amqp_simple_wait_frame(amqp_connection_state_t state,
1480 	                                     amqp_frame_t *decoded_frame);
1481 	
1482 	/**
1483 	 * Read a single amqp_frame_t with a timeout.
1484 	 *
1485 	 * Waits for the next amqp_frame_t frame to be read from the broker, up to
1486 	 * a timespan specified by tv. The function will return AMQP_STATUS_TIMEOUT
1487 	 * if the timeout is reached. The tv value is not modified by the function.
1488 	 *
1489 	 * If a 0 timeval is specified, the function behaves as if its non-blocking: it
1490 	 * will test to see if a frame can be read from the broker, and return
1491 	 * immediately.
1492 	 *
1493 	 * If NULL is passed in for tv, the function will behave like
1494 	 * amqp_simple_wait_frame() and block until a frame is received from the broker
1495 	 *
1496 	 * The library may buffer frames.  When an amqp_connection_state_t object
1497 	 * has frames buffered calling amqp_simple_wait_frame_noblock() will return an
1498 	 * amqp_frame_t without entering a blocking read(). You can test to see if an
1499 	 * amqp_connection_state_t object has frames buffered by calling the
1500 	 * amqp_frames_enqueued() function.
1501 	 *
1502 	 * The library has a socket read buffer. When there is data in an
1503 	 * amqp_connection_state_t read buffer, amqp_simple_wait_frame_noblock() may
1504 	 * return
1505 	 * an amqp_frame_t without entering a blocking read(). You can test to see if an
1506 	 * amqp_connection_state_t object has data in its read buffer by calling the
1507 	 * amqp_data_in_buffer() function.
1508 	 *
1509 	 * \note This function does not return heartbeat frames. When enabled,
1510 	 *  heartbeating is handed internally internally by the library.
1511 	 *
1512 	 * \param [in,out] state the connection object
1513 	 * \param [out] decoded_frame the frame
1514 	 * \param [in] tv the maximum time to wait for a frame to be read. Setting
1515 	 * tv->tv_sec = 0 and tv->tv_usec = 0 will do a non-blocking read. Specifying
1516 	 * NULL for tv will make the function block until a frame is read.
1517 	 * \return AMQP_STATUS_OK on success. An amqp_status_enum value is returned
1518 	 *  otherwise. Possible errors include:
1519 	 *  - AMQP_STATUS_TIMEOUT the timeout was reached while waiting for a frame
1520 	 *    from the broker.
1521 	 *  - AMQP_STATUS_INVALID_PARAMETER the tv parameter contains an invalid value.
1522 	 *  - AMQP_STATUS_NO_MEMORY failure in allocating memory. The library is likely
1523 	 *    in an indeterminate state making recovery unlikely. Client should note the
1524 	 *    error and terminate the application
1525 	 *  - AMQP_STATUS_BAD_AMQP_DATA bad AMQP data was received. The connection
1526 	 *    should be shutdown immediately
1527 	 *  - AMQP_STATUS_UNKNOWN_METHOD: an unknown method was received from the
1528 	 *    broker. This is likely a protocol error and the connection should be
1529 	 *    shutdown immediately
1530 	 *  - AMQP_STATUS_UNKNOWN_CLASS: a properties frame with an unknown class
1531 	 *    was received from the broker. This is likely a protocol error and the
1532 	 *    connection should be shutdown immediately
1533 	 *  - AMQP_STATUS_HEARTBEAT_TIMEOUT timed out while waiting for heartbeat
1534 	 *    from the broker. The connection has been closed.
1535 	 *  - AMQP_STATUS_TIMER_FAILURE system timer indicated failure.
1536 	 *  - AMQP_STATUS_SOCKET_ERROR a socket error occurred. The connection has
1537 	 *    been closed
1538 	 *  - AMQP_STATUS_SSL_ERROR a SSL socket error occurred. The connection has
1539 	 *    been closed.
1540 	 *
1541 	 * \sa amqp_simple_wait_frame() amqp_frames_enqueued() amqp_data_in_buffer()
1542 	 *
1543 	 * \since v0.4.0
1544 	 */
1545 	AMQP_PUBLIC_FUNCTION
1546 	int AMQP_CALL amqp_simple_wait_frame_noblock(amqp_connection_state_t state,
1547 	                                             amqp_frame_t *decoded_frame,
1548 	                                             struct timeval *tv);
1549 	
1550 	/**
1551 	 * Waits for a specific method from the broker
1552 	 *
1553 	 * \warning You probably don't want to use this function. If this function
1554 	 *  doesn't receive exactly the frame requested it closes the whole connection.
1555 	 *
1556 	 * Waits for a single method on a channel from the broker.
1557 	 * If a frame is received that does not match expected_channel
1558 	 * or expected_method the program will abort
1559 	 *
1560 	 * \param [in] state the connection object
1561 	 * \param [in] expected_channel the channel that the method should be delivered
1562 	 *  on
1563 	 * \param [in] expected_method the method to wait for
1564 	 * \param [out] output the method
1565 	 * \returns AMQP_STATUS_OK on success. An amqp_status_enum value is returned
1566 	 *  otherwise. Possible errors include:
1567 	 *  - AMQP_STATUS_WRONG_METHOD a frame containing the wrong method, wrong frame
1568 	 *    type or wrong channel was received. The connection is closed.
1569 	 *  - AMQP_STATUS_NO_MEMORY failure in allocating memory. The library is likely
1570 	 *    in an indeterminate state making recovery unlikely. Client should note the
1571 	 *    error and terminate the application
1572 	 *  - AMQP_STATUS_BAD_AMQP_DATA bad AMQP data was received. The connection
1573 	 *    should be shutdown immediately
1574 	 *  - AMQP_STATUS_UNKNOWN_METHOD: an unknown method was received from the
1575 	 *    broker. This is likely a protocol error and the connection should be
1576 	 *    shutdown immediately
1577 	 *  - AMQP_STATUS_UNKNOWN_CLASS: a properties frame with an unknown class
1578 	 *    was received from the broker. This is likely a protocol error and the
1579 	 *    connection should be shutdown immediately
1580 	 *  - AMQP_STATUS_HEARTBEAT_TIMEOUT timed out while waiting for heartbeat
1581 	 *    from the broker. The connection has been closed.
1582 	 *  - AMQP_STATUS_TIMER_FAILURE system timer indicated failure.
1583 	 *  - AMQP_STATUS_SOCKET_ERROR a socket error occurred. The connection has
1584 	 *    been closed
1585 	 *  - AMQP_STATUS_SSL_ERROR a SSL socket error occurred. The connection has
1586 	 *    been closed.
1587 	 *
1588 	 * \since v0.1
1589 	 */
1590 	
1591 	AMQP_PUBLIC_FUNCTION
1592 	int AMQP_CALL amqp_simple_wait_method(amqp_connection_state_t state,
1593 	                                      amqp_channel_t expected_channel,
1594 	                                      amqp_method_number_t expected_method,
1595 	                                      amqp_method_t *output);
1596 	
1597 	/**
1598 	 * Sends a method to the broker
1599 	 *
1600 	 * This is a thin wrapper around amqp_send_frame(), providing a way to send
1601 	 * a method to the broker on a specified channel.
1602 	 *
1603 	 * \param [in] state the connection object
1604 	 * \param [in] channel the channel object
1605 	 * \param [in] id the method number
1606 	 * \param [in] decoded the method object
1607 	 * \returns AMQP_STATUS_OK on success, an amqp_status_enum value otherwise.
1608 	 *  Possible errors include:
1609 	 *  - AMQP_STATUS_BAD_AMQP_DATA the serialized form of the method or
1610 	 *    properties was too large to fit in a single AMQP frame, or the
1611 	 *    method contains an invalid value. The frame was not sent.
1612 	 *  - AMQP_STATUS_TABLE_TOO_BIG the serialized form of an amqp_table_t is
1613 	 *    too large to fit in a single AMQP frame. Frame was not sent.
1614 	 *  - AMQP_STATUS_UNKNOWN_METHOD an invalid method type was passed in
1615 	 *  - AMQP_STATUS_UNKNOWN_CLASS an invalid properties type was passed in
1616 	 *  - AMQP_STATUS_TIMER_FAILURE system timer indicated failure. The frame
1617 	 *    was sent
1618 	 *  - AMQP_STATUS_SOCKET_ERROR
1619 	 *  - AMQP_STATUS_SSL_ERROR
1620 	 *
1621 	 * \since v0.1
1622 	 */
1623 	AMQP_PUBLIC_FUNCTION
1624 	int AMQP_CALL amqp_send_method(amqp_connection_state_t state,
1625 	                               amqp_channel_t channel, amqp_method_number_t id,
1626 	                               void *decoded);
1627 	
1628 	/**
1629 	 * Sends a method to the broker and waits for a method response
1630 	 *
1631 	 * \param [in] state the connection object
1632 	 * \param [in] channel the channel object
1633 	 * \param [in] request_id the method number of the request
1634 	 * \param [in] expected_reply_ids a 0 terminated array of expected response
1635 	 *             method numbers
1636 	 * \param [in] decoded_request_method the method to be sent to the broker
1637 	 * \return a amqp_rpc_reply_t:
1638 	 *  - r.reply_type == AMQP_RESPONSE_NORMAL. RPC completed successfully
1639 	 *  - r.reply_type == AMQP_RESPONSE_SERVER_EXCEPTION. The broker returned an
1640 	 *    exception:
1641 	 *    - If r.reply.id == AMQP_CHANNEL_CLOSE_METHOD a channel exception
1642 	 *      occurred, cast r.reply.decoded to amqp_channel_close_t* to see details
1643 	 *      of the exception. The client should amqp_send_method() a
1644 	 *      amqp_channel_close_ok_t. The channel must be re-opened before it
1645 	 *      can be used again. Any resources associated with the channel
1646 	 *      (auto-delete exchanges, auto-delete queues, consumers) are invalid
1647 	 *      and must be recreated before attempting to use them again.
1648 	 *    - If r.reply.id == AMQP_CONNECTION_CLOSE_METHOD a connection exception
1649 	 *      occurred, cast r.reply.decoded to amqp_connection_close_t* to see
1650 	 *      details of the exception. The client amqp_send_method() a
1651 	 *      amqp_connection_close_ok_t and disconnect from the broker.
1652 	 *  - r.reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION. An exception occurred
1653 	 *    within the library. Examine r.library_error and compare it against
1654 	 *    amqp_status_enum values to determine the error.
1655 	 *
1656 	 * \sa amqp_simple_rpc_decoded()
1657 	 *
1658 	 * \since v0.1
1659 	 */
1660 	AMQP_PUBLIC_FUNCTION
1661 	amqp_rpc_reply_t AMQP_CALL amqp_simple_rpc(
1662 	    amqp_connection_state_t state, amqp_channel_t channel,
1663 	    amqp_method_number_t request_id, amqp_method_number_t *expected_reply_ids,
1664 	    void *decoded_request_method);
1665 	
1666 	/**
1667 	 * Sends a method to the broker and waits for a method response
1668 	 *
1669 	 * \param [in] state the connection object
1670 	 * \param [in] channel the channel object
1671 	 * \param [in] request_id the method number of the request
1672 	 * \param [in] reply_id the method number expected in response
1673 	 * \param [in] decoded_request_method the request method
1674 	 * \return a pointer to the method returned from the broker, or NULL on error.
1675 	 *  On error amqp_get_rpc_reply() will return an amqp_rpc_reply_t with
1676 	 *  details on the error that occurred.
1677 	 *
1678 	 * \since v0.1
1679 	 */
1680 	AMQP_PUBLIC_FUNCTION
1681 	void *AMQP_CALL amqp_simple_rpc_decoded(amqp_connection_state_t state,
1682 	                                        amqp_channel_t channel,
1683 	                                        amqp_method_number_t request_id,
1684 	                                        amqp_method_number_t reply_id,
1685 	                                        void *decoded_request_method);
1686 	
1687 	/**
1688 	 * Get the last global amqp_rpc_reply
1689 	 *
1690 	 * The API methods corresponding to most synchronous AMQP methods
1691 	 * return a pointer to the decoded method result.  Upon error, they
1692 	 * return NULL, and we need some way of discovering what, if anything,
1693 	 * went wrong. amqp_get_rpc_reply() returns the most recent
1694 	 * amqp_rpc_reply_t instance corresponding to such an API operation
1695 	 * for the given connection.
1696 	 *
1697 	 * Only use it for operations that do not themselves return
1698 	 * amqp_rpc_reply_t; operations that do return amqp_rpc_reply_t
1699 	 * generally do NOT update this per-connection-global amqp_rpc_reply_t
1700 	 * instance.
1701 	 *
1702 	 * \param [in] state the connection object
1703 	 * \return the most recent amqp_rpc_reply_t:
1704 	 *  - r.reply_type == AMQP_RESPONSE_NORMAL. RPC completed successfully
1705 	 *  - r.reply_type == AMQP_RESPONSE_SERVER_EXCEPTION. The broker returned an
1706 	 *    exception:
1707 	 *    - If r.reply.id == AMQP_CHANNEL_CLOSE_METHOD a channel exception
1708 	 *      occurred, cast r.reply.decoded to amqp_channel_close_t* to see details
1709 	 *      of the exception. The client should amqp_send_method() a
1710 	 *      amqp_channel_close_ok_t. The channel must be re-opened before it
1711 	 *      can be used again. Any resources associated with the channel
1712 	 *      (auto-delete exchanges, auto-delete queues, consumers) are invalid
1713 	 *      and must be recreated before attempting to use them again.
1714 	 *    - If r.reply.id == AMQP_CONNECTION_CLOSE_METHOD a connection exception
1715 	 *      occurred, cast r.reply.decoded to amqp_connection_close_t* to see
1716 	 *      details of the exception. The client amqp_send_method() a
1717 	 *      amqp_connection_close_ok_t and disconnect from the broker.
1718 	 *  - r.reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION. An exception occurred
1719 	 *    within the library. Examine r.library_error and compare it against
1720 	 *    amqp_status_enum values to determine the error.
1721 	 *
1722 	 * \sa amqp_simple_rpc_decoded()
1723 	 *
1724 	 * \since v0.1
1725 	 */
1726 	AMQP_PUBLIC_FUNCTION
1727 	amqp_rpc_reply_t AMQP_CALL amqp_get_rpc_reply(amqp_connection_state_t state);
1728 	
1729 	/**
1730 	 * Login to the broker
1731 	 *
1732 	 * After using amqp_open_socket and amqp_set_sockfd, call
1733 	 * amqp_login to complete connecting to the broker
1734 	 *
1735 	 * \param [in] state the connection object
1736 	 * \param [in] vhost the virtual host to connect to on the broker. The default
1737 	 *              on most brokers is "/"
1738 	 * \param [in] channel_max the limit for number of channels for the connection.
1739 	 *              0 means no limit, and is a good default
1740 	 *              (AMQP_DEFAULT_MAX_CHANNELS)
1741 	 *              Note that the maximum number of channels the protocol supports
1742 	 *              is 65535 (2^16, with the 0-channel reserved). The server can
1743 	 *              set a lower channel_max and then the client will use the lowest
1744 	 *              of the two
1745 	 * \param [in] frame_max the maximum size of an AMQP frame on the wire to
1746 	 *              request of the broker for this connection. 4096 is the minimum
1747 	 *              size, 2^31-1 is the maximum, a good default is 131072 (128KB),
1748 	 *              or AMQP_DEFAULT_FRAME_SIZE
1749 	 * \param [in] heartbeat the number of seconds between heartbeat frames to
1750 	 *              request of the broker. A value of 0 disables heartbeats.
1751 	 *              Note rabbitmq-c only has partial support for heartbeats, as of
1752 	 *              v0.4.0 they are only serviced during amqp_basic_publish() and
1753 	 *              amqp_simple_wait_frame()/amqp_simple_wait_frame_noblock()
1754 	 * \param [in] sasl_method the SASL method to authenticate with the broker.
1755 	 *              followed by the authentication information. The following SASL
1756 	 *              methods are implemented:
1757 	 *              -  AMQP_SASL_METHOD_PLAIN, the AMQP_SASL_METHOD_PLAIN argument
1758 	 *                 should be followed by two arguments in this order:
1759 	 *                 const char* username, and const char* password.
1760 	 *              -  AMQP_SASL_METHOD_EXTERNAL, the AMQP_SASL_METHOD_EXTERNAL
1761 	 *                 argument should be followed one argument:
1762 	 *                 const char* identity.
1763 	 * \return amqp_rpc_reply_t indicating success or failure.
1764 	 *  - r.reply_type == AMQP_RESPONSE_NORMAL. Login completed successfully
1765 	 *  - r.reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION. In most cases errors
1766 	 *    from the broker when logging in will be represented by the broker closing
1767 	 *    the socket. In this case r.library_error will be set to
1768 	 *    AMQP_STATUS_CONNECTION_CLOSED. This error can represent a number of
1769 	 *    error conditions including: invalid vhost, authentication failure.
1770 	 *  - r.reply_type == AMQP_RESPONSE_SERVER_EXCEPTION. The broker returned an
1771 	 *    exception:
1772 	 *    - If r.reply.id == AMQP_CHANNEL_CLOSE_METHOD a channel exception
1773 	 *      occurred, cast r.reply.decoded to amqp_channel_close_t* to see details
1774 	 *      of the exception. The client should amqp_send_method() a
1775 	 *      amqp_channel_close_ok_t. The channel must be re-opened before it
1776 	 *      can be used again. Any resources associated with the channel
1777 	 *      (auto-delete exchanges, auto-delete queues, consumers) are invalid
1778 	 *      and must be recreated before attempting to use them again.
1779 	 *    - If r.reply.id == AMQP_CONNECTION_CLOSE_METHOD a connection exception
1780 	 *      occurred, cast r.reply.decoded to amqp_connection_close_t* to see
1781 	 *      details of the exception. The client amqp_send_method() a
1782 	 *      amqp_connection_close_ok_t and disconnect from the broker.
1783 	 *
1784 	 * \since v0.1
1785 	 */
1786 	AMQP_PUBLIC_FUNCTION
1787 	amqp_rpc_reply_t AMQP_CALL amqp_login(amqp_connection_state_t state,
1788 	                                      char const *vhost, int channel_max,
1789 	                                      int frame_max, int heartbeat,
1790 	                                      amqp_sasl_method_enum sasl_method, ...);
1791 	
1792 	/**
1793 	 * Login to the broker passing a properties table
1794 	 *
1795 	 * This function is similar to amqp_login() and differs in that it provides a
1796 	 * way to pass client properties to the broker. This is commonly used to
1797 	 * negotiate newer protocol features as they are supported by the broker.
1798 	 *
1799 	 * \param [in] state the connection object
1800 	 * \param [in] vhost the virtual host to connect to on the broker. The default
1801 	 *              on most brokers is "/"
1802 	 * \param [in] channel_max the limit for the number of channels for the
1803 	 *             connection.
1804 	 *             0 means no limit, and is a good default
1805 	 *             (AMQP_DEFAULT_MAX_CHANNELS)
1806 	 *             Note that the maximum number of channels the protocol supports
1807 	 *             is 65535 (2^16, with the 0-channel reserved). The server can
1808 	 *             set a lower channel_max and then the client will use the lowest
1809 	 *             of the two
1810 	 * \param [in] frame_max the maximum size of an AMQP frame ont he wire to
1811 	 *              request of the broker for this connection. 4096 is the minimum
1812 	 *              size, 2^31-1 is the maximum, a good default is 131072 (128KB),
1813 	 *              or AMQP_DEFAULT_FRAME_SIZE
1814 	 * \param [in] heartbeat the number of seconds between heartbeat frame to
1815 	 *             request of the broker. A value of 0 disables heartbeats.
1816 	 *             Note rabbitmq-c only has partial support for hearts, as of
1817 	 *             v0.4.0 heartbeats are only serviced during amqp_basic_publish(),
1818 	 *             and amqp_simple_wait_frame()/amqp_simple_wait_frame_noblock()
1819 	 * \param [in] properties a table of properties to send the broker.
1820 	 * \param [in] sasl_method the SASL method to authenticate with the broker
1821 	 *             followed by the authentication information. The following SASL
1822 	 *             methods are implemented:
1823 	 *             -  AMQP_SASL_METHOD_PLAIN, the AMQP_SASL_METHOD_PLAIN argument
1824 	 *                should be followed by two arguments in this order:
1825 	 *                const char* username, and const char* password.
1826 	 *             -  AMQP_SASL_METHOD_EXTERNAL, the AMQP_SASL_METHOD_EXTERNAL
1827 	 *                argument should be followed one argument:
1828 	 *                const char* identity.
1829 	 * \return amqp_rpc_reply_t indicating success or failure.
1830 	 *  - r.reply_type == AMQP_RESPONSE_NORMAL. Login completed successfully
1831 	 *  - r.reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION. In most cases errors
1832 	 *    from the broker when logging in will be represented by the broker closing
1833 	 *    the socket. In this case r.library_error will be set to
1834 	 *    AMQP_STATUS_CONNECTION_CLOSED. This error can represent a number of
1835 	 *    error conditions including: invalid vhost, authentication failure.
1836 	 *  - r.reply_type == AMQP_RESPONSE_SERVER_EXCEPTION. The broker returned an
1837 	 *    exception:
1838 	 *    - If r.reply.id == AMQP_CHANNEL_CLOSE_METHOD a channel exception
1839 	 *      occurred, cast r.reply.decoded to amqp_channel_close_t* to see details
1840 	 *      of the exception. The client should amqp_send_method() a
1841 	 *      amqp_channel_close_ok_t. The channel must be re-opened before it
1842 	 *      can be used again. Any resources associated with the channel
1843 	 *      (auto-delete exchanges, auto-delete queues, consumers) are invalid
1844 	 *      and must be recreated before attempting to use them again.
1845 	 *    - If r.reply.id == AMQP_CONNECTION_CLOSE_METHOD a connection exception
1846 	 *      occurred, cast r.reply.decoded to amqp_connection_close_t* to see
1847 	 *      details of the exception. The client amqp_send_method() a
1848 	 *      amqp_connection_close_ok_t and disconnect from the broker.
1849 	 *
1850 	 * \since v0.4.0
1851 	 */
1852 	AMQP_PUBLIC_FUNCTION
1853 	amqp_rpc_reply_t AMQP_CALL amqp_login_with_properties(
1854 	    amqp_connection_state_t state, char const *vhost, int channel_max,
1855 	    int frame_max, int heartbeat, const amqp_table_t *properties,
1856 	    amqp_sasl_method_enum sasl_method, ...);
1857 	
1858 	struct amqp_basic_properties_t_;
1859 	
1860 	/**
1861 	 * Publish a message to the broker
1862 	 *
1863 	 * Publish a message on an exchange with a routing key.
1864 	 *
1865 	 * Note that at the AMQ protocol level basic.publish is an async method:
1866 	 * this means error conditions that occur on the broker (such as publishing to
1867 	 * a non-existent exchange) will not be reflected in the return value of this
1868 	 * function.
1869 	 *
1870 	 * \param [in] state the connection object
1871 	 * \param [in] channel the channel identifier
1872 	 * \param [in] exchange the exchange on the broker to publish to
1873 	 * \param [in] routing_key the routing key to use when publishing the message
1874 	 * \param [in] mandatory indicate to the broker that the message MUST be routed
1875 	 *              to a queue. If the broker cannot do this it should respond with
1876 	 *              a basic.return method.
1877 	 * \param [in] immediate indicate to the broker that the message MUST be
1878 	 *             delivered to a consumer immediately. If the broker cannot do this
1879 	 *             it should respond with a basic.return method.
1880 	 * \param [in] properties the properties associated with the message
1881 	 * \param [in] body the message body
1882 	 * \return AMQP_STATUS_OK on success, amqp_status_enum value on failure. Note
1883 	 *         that basic.publish is an async method, the return value from this
1884 	 *         function only indicates that the message data was successfully
1885 	 *         transmitted to the broker. It does not indicate failures that occur
1886 	 *         on the broker, such as publishing to a non-existent exchange.
1887 	 *         Possible error values:
1888 	 *         - AMQP_STATUS_TIMER_FAILURE: system timer facility returned an error
1889 	 *           the message was not sent.
1890 	 *         - AMQP_STATUS_HEARTBEAT_TIMEOUT: connection timed out waiting for a
1891 	 *           heartbeat from the broker. The message was not sent.
1892 	 *         - AMQP_STATUS_NO_MEMORY: memory allocation failed. The message was
1893 	 *           not sent.
1894 	 *         - AMQP_STATUS_TABLE_TOO_BIG: a table in the properties was too large
1895 	 *           to fit in a single frame. Message was not sent.
1896 	 *         - AMQP_STATUS_CONNECTION_CLOSED: the connection was closed.
1897 	 *         - AMQP_STATUS_SSL_ERROR: a SSL error occurred.
1898 	 *         - AMQP_STATUS_TCP_ERROR: a TCP error occurred. errno or
1899 	 *           WSAGetLastError() may provide more information
1900 	 *
1901 	 * Note: this function does heartbeat processing as of v0.4.0
1902 	 *
1903 	 * \since v0.1
1904 	 */
1905 	AMQP_PUBLIC_FUNCTION
1906 	int AMQP_CALL amqp_basic_publish(
1907 	    amqp_connection_state_t state, amqp_channel_t channel,
1908 	    amqp_bytes_t exchange, amqp_bytes_t routing_key, amqp_boolean_t mandatory,
1909 	    amqp_boolean_t immediate, struct amqp_basic_properties_t_ const *properties,
1910 	    amqp_bytes_t body);
1911 	
1912 	/**
1913 	 * Closes an channel
1914 	 *
1915 	 * \param [in] state the connection object
1916 	 * \param [in] channel the channel identifier
1917 	 * \param [in] code the reason for closing the channel, AMQP_REPLY_SUCCESS is a
1918 	 *             good default
1919 	 * \return amqp_rpc_reply_t indicating success or failure
1920 	 *
1921 	 * \since v0.1
1922 	 */
1923 	AMQP_PUBLIC_FUNCTION
1924 	amqp_rpc_reply_t AMQP_CALL amqp_channel_close(amqp_connection_state_t state,
1925 	                                              amqp_channel_t channel, int code);
1926 	
1927 	/**
1928 	 * Closes the entire connection
1929 	 *
1930 	 * Implicitly closes all channels and informs the broker the connection
1931 	 * is being closed, after receiving acknowledgment from the broker it closes
1932 	 * the socket.
1933 	 *
1934 	 * \param [in] state the connection object
1935 	 * \param [in] code the reason code for closing the connection.
1936 	 *             AMQP_REPLY_SUCCESS is a good default.
1937 	 * \return amqp_rpc_reply_t indicating the result
1938 	 *
1939 	 * \since v0.1
1940 	 */
1941 	AMQP_PUBLIC_FUNCTION
1942 	amqp_rpc_reply_t AMQP_CALL amqp_connection_close(amqp_connection_state_t state,
1943 	                                                 int code);
1944 	
1945 	/**
1946 	 * Acknowledges a message
1947 	 *
1948 	 * Does a basic.ack on a received message
1949 	 *
1950 	 * \param [in] state the connection object
1951 	 * \param [in] channel the channel identifier
1952 	 * \param [in] delivery_tag the delivery tag of the message to be ack'd
1953 	 * \param [in] multiple if true, ack all messages up to this delivery tag, if
1954 	 *              false ack only this delivery tag
1955 	 * \return 0 on success,  0 > on failing to send the ack to the broker.
1956 	 *            this will not indicate failure if something goes wrong on the
1957 	 *            broker
1958 	 *
1959 	 * \since v0.1
1960 	 */
1961 	AMQP_PUBLIC_FUNCTION
1962 	int AMQP_CALL amqp_basic_ack(amqp_connection_state_t state,
1963 	                             amqp_channel_t channel, uint64_t delivery_tag,
1964 	                             amqp_boolean_t multiple);
1965 	
1966 	/**
1967 	 * Do a basic.get
1968 	 *
1969 	 * Synchonously polls the broker for a message in a queue, and
1970 	 * retrieves the message if a message is in the queue.
1971 	 *
1972 	 * \param [in] state the connection object
1973 	 * \param [in] channel the channel identifier to use
1974 	 * \param [in] queue the queue name to retrieve from
1975 	 * \param [in] no_ack if true the message is automatically ack'ed
1976 	 *              if false amqp_basic_ack should be called once the message
1977 	 *              retrieved has been processed
1978 	 * \return amqp_rpc_reply indicating success or failure
1979 	 *
1980 	 * \since v0.1
1981 	 */
1982 	AMQP_PUBLIC_FUNCTION
1983 	amqp_rpc_reply_t AMQP_CALL amqp_basic_get(amqp_connection_state_t state,
1984 	                                          amqp_channel_t channel,
1985 	                                          amqp_bytes_t queue,
1986 	                                          amqp_boolean_t no_ack);
1987 	
1988 	/**
1989 	 * Do a basic.reject
1990 	 *
1991 	 * Actively reject a message that has been delivered
1992 	 *
1993 	 * \param [in] state the connection object
1994 	 * \param [in] channel the channel identifier
1995 	 * \param [in] delivery_tag the delivery tag of the message to reject
1996 	 * \param [in] requeue indicate to the broker whether it should requeue the
1997 	 *              message or just discard it.
1998 	 * \return 0 on success, 0 > on failing to send the reject method to the broker.
1999 	 *          This will not indicate failure if something goes wrong on the
2000 	 * broker.
2001 	 *
2002 	 * \since v0.1
2003 	 */
2004 	AMQP_PUBLIC_FUNCTION
2005 	int AMQP_CALL amqp_basic_reject(amqp_connection_state_t state,
2006 	                                amqp_channel_t channel, uint64_t delivery_tag,
2007 	                                amqp_boolean_t requeue);
2008 	
2009 	/**
2010 	 * Do a basic.nack
2011 	 *
2012 	 * Actively reject a message, this has the same effect as amqp_basic_reject()
2013 	 * however, amqp_basic_nack() can negatively acknowledge multiple messages with
2014 	 * one call much like amqp_basic_ack() can acknowledge mutliple messages with
2015 	 * one call.
2016 	 *
2017 	 * \param [in] state the connection object
2018 	 * \param [in] channel the channel identifier
2019 	 * \param [in] delivery_tag the delivery tag of the message to reject
2020 	 * \param [in] multiple if set to 1 negatively acknowledge all unacknowledged
2021 	 *              messages on this channel.
2022 	 * \param [in] requeue indicate to the broker whether it should requeue the
2023 	 *              message or dead-letter it.
2024 	 * \return AMQP_STATUS_OK on success, an amqp_status_enum value otherwise.
2025 	 *
2026 	 * \since v0.5.0
2027 	 */
2028 	AMQP_PUBLIC_FUNCTION
2029 	int AMQP_CALL amqp_basic_nack(amqp_connection_state_t state,
2030 	                              amqp_channel_t channel, uint64_t delivery_tag,
2031 	                              amqp_boolean_t multiple, amqp_boolean_t requeue);
2032 	/**
2033 	 * Check to see if there is data left in the receive buffer
2034 	 *
2035 	 * Can be used to see if there is data still in the buffer, if so
2036 	 * calling amqp_simple_wait_frame will not immediately enter a
2037 	 * blocking read.
2038 	 *
2039 	 * \param [in] state the connection object
2040 	 * \return true if there is data in the recieve buffer, false otherwise
2041 	 *
2042 	 * \since v0.1
2043 	 */
2044 	AMQP_PUBLIC_FUNCTION
2045 	amqp_boolean_t AMQP_CALL amqp_data_in_buffer(amqp_connection_state_t state);
2046 	
2047 	/**
2048 	 * Get the error string for the given error code.
2049 	 *
2050 	 * \deprecated This function has been deprecated in favor of
2051 	 *  \ref amqp_error_string2() which returns statically allocated
2052 	 *  string which do not need to be freed by the caller.
2053 	 *
2054 	 * The returned string resides on the heap; the caller is responsible
2055 	 * for freeing it.
2056 	 *
2057 	 * \param [in] err return error code
2058 	 * \return the error string
2059 	 *
2060 	 * \since v0.1
2061 	 */
2062 	AMQP_DEPRECATED(
2063 	    AMQP_PUBLIC_FUNCTION char *AMQP_CALL amqp_error_string(int err));
2064 	
2065 	/**
2066 	 * Get the error string for the given error code.
2067 	 *
2068 	 * Get an error string associated with an error code. The string is statically
2069 	 * allocated and does not need to be freed
2070 	 *
2071 	 * \param [in] err the error code
2072 	 * \return the error string
2073 	 *
2074 	 * \since v0.4.0
2075 	 */
2076 	AMQP_PUBLIC_FUNCTION
2077 	const char *AMQP_CALL amqp_error_string2(int err);
2078 	
2079 	/**
2080 	 * Deserialize an amqp_table_t from AMQP wireformat
2081 	 *
2082 	 * This is an internal function and is not typically used by
2083 	 * client applications
2084 	 *
2085 	 * \param [in] encoded the buffer containing the serialized data
2086 	 * \param [in] pool memory pool used to allocate the table entries from
2087 	 * \param [in] output the amqp_table_t structure to fill in. Any existing
2088 	 *             entries will be erased
2089 	 * \param [in,out] offset The offset into the encoded buffer to start
2090 	 *                 reading the serialized table. It will be updated
2091 	 *                 by this function to end of the table
2092 	 * \return AMQP_STATUS_OK on success, an amqp_status_enum value on failure
2093 	 *  Possible error codes:
2094 	 *  - AMQP_STATUS_NO_MEMORY out of memory
2095 	 *  - AMQP_STATUS_BAD_AMQP_DATA invalid wireformat
2096 	 *
2097 	 * \since v0.1
2098 	 */
2099 	AMQP_PUBLIC_FUNCTION
2100 	int AMQP_CALL amqp_decode_table(amqp_bytes_t encoded, amqp_pool_t *pool,
2101 	                                amqp_table_t *output, size_t *offset);
2102 	
2103 	/**
2104 	 * Serializes an amqp_table_t to the AMQP wireformat
2105 	 *
2106 	 * This is an internal function and is not typically used by
2107 	 * client applications
2108 	 *
2109 	 * \param [in] encoded the buffer where to serialize the table to
2110 	 * \param [in] input the amqp_table_t to serialize
2111 	 * \param [in,out] offset The offset into the encoded buffer to start
2112 	 *                 writing the serialized table. It will be updated
2113 	 *                 by this function to where writing left off
2114 	 * \return AMQP_STATUS_OK on success, an amqp_status_enum value on failure
2115 	 *  Possible error codes:
2116 	 *  - AMQP_STATUS_TABLE_TOO_BIG the serialized form is too large for the
2117 	 *    buffer
2118 	 *  - AMQP_STATUS_BAD_AMQP_DATA invalid table
2119 	 *
2120 	 * \since v0.1
2121 	 */
2122 	AMQP_PUBLIC_FUNCTION
2123 	int AMQP_CALL amqp_encode_table(amqp_bytes_t encoded, amqp_table_t *input,
2124 	                                size_t *offset);
2125 	
2126 	/**
2127 	 * Create a deep-copy of an amqp_table_t object
2128 	 *
2129 	 * Creates a deep-copy of an amqp_table_t object, using the provided pool
2130 	 * object to allocate the necessary memory. This memory can be freed later by
2131 	 * call recycle_amqp_pool(), or empty_amqp_pool()
2132 	 *
2133 	 * \param [in] original the table to copy
2134 	 * \param [in,out] clone the table to copy to
2135 	 * \param [in] pool the initialized memory pool to do allocations for the table
2136 	 *             from
2137 	 * \return AMQP_STATUS_OK on success, amqp_status_enum value on failure.
2138 	 *  Possible error values:
2139 	 *  - AMQP_STATUS_NO_MEMORY - memory allocation failure.
2140 	 *  - AMQP_STATUS_INVALID_PARAMETER - invalid table (e.g., no key name)
2141 	 *
2142 	 * \since v0.4.0
2143 	 */
2144 	AMQP_PUBLIC_FUNCTION
2145 	int AMQP_CALL amqp_table_clone(const amqp_table_t *original,
2146 	                               amqp_table_t *clone, amqp_pool_t *pool);
2147 	
2148 	/**
2149 	 * A message object
2150 	 *
2151 	 * \since v0.4.0
2152 	 */
2153 	typedef struct amqp_message_t_ {
2154 	  amqp_basic_properties_t properties; /**< message properties */
2155 	  amqp_bytes_t body;                  /**< message body */
2156 	  amqp_pool_t pool;                   /**< pool used to allocate properties */
2157 	} amqp_message_t;
2158 	
2159 	/**
2160 	 * Reads the next message on a channel
2161 	 *
2162 	 * Reads a complete message (header + body) on a specified channel. This
2163 	 * function is intended to be used with amqp_basic_get() or when an
2164 	 * AMQP_BASIC_DELIVERY_METHOD method is received.
2165 	 *
2166 	 * \param [in,out] state the connection object
2167 	 * \param [in] channel the channel on which to read the message from
2168 	 * \param [in,out] message a pointer to a amqp_message_t object. Caller should
2169 	 *                 call amqp_message_destroy() when it is done using the
2170 	 *                 fields in the message object.  The caller is responsible for
2171 	 *                 allocating/destroying the amqp_message_t object itself.
2172 	 * \param [in] flags pass in 0. Currently unused.
2173 	 * \returns a amqp_rpc_reply_t object. ret.reply_type == AMQP_RESPONSE_NORMAL on
2174 	 * success.
2175 	 *
2176 	 * \since v0.4.0
2177 	 */
2178 	AMQP_PUBLIC_FUNCTION
2179 	amqp_rpc_reply_t AMQP_CALL amqp_read_message(amqp_connection_state_t state,
2180 	                                             amqp_channel_t channel,
2181 	                                             amqp_message_t *message,
2182 	                                             int flags);
2183 	
2184 	/**
2185 	 * Frees memory associated with a amqp_message_t allocated in amqp_read_message
2186 	 *
2187 	 * \param [in] message
2188 	 *
2189 	 * \since v0.4.0
2190 	 */
2191 	AMQP_PUBLIC_FUNCTION
2192 	void AMQP_CALL amqp_destroy_message(amqp_message_t *message);
2193 	
2194 	/**
2195 	 * Envelope object
2196 	 *
2197 	 * \since v0.4.0
2198 	 */
2199 	typedef struct amqp_envelope_t_ {
2200 	  amqp_channel_t channel; /**< channel message was delivered on */
2201 	  amqp_bytes_t
2202 	      consumer_tag;      /**< the consumer tag the message was delivered to */
2203 	  uint64_t delivery_tag; /**< the messages delivery tag */
2204 	  amqp_boolean_t redelivered; /**< flag indicating whether this message is being
2205 	                                 redelivered */
2206 	  amqp_bytes_t exchange;      /**< exchange this message was published to */
2207 	  amqp_bytes_t
2208 	      routing_key; /**< the routing key this message was published with */
2209 	  amqp_message_t message; /**< the message */
2210 	} amqp_envelope_t;
2211 	
2212 	/**
2213 	 * Wait for and consume a message
2214 	 *
2215 	 * Waits for a basic.deliver method on any channel, upon receipt of
2216 	 * basic.deliver it reads that message, and returns. If any other method is
2217 	 * received before basic.deliver, this function will return an amqp_rpc_reply_t
2218 	 * with ret.reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION, and
2219 	 * ret.library_error == AMQP_STATUS_UNEXPECTED_STATE. The caller should then
2220 	 * call amqp_simple_wait_frame() to read this frame and take appropriate action.
2221 	 *
2222 	 * This function should be used after starting a consumer with the
2223 	 * amqp_basic_consume() function
2224 	 *
2225 	 * \param [in,out] state the connection object
2226 	 * \param [in,out] envelope a pointer to a amqp_envelope_t object. Caller
2227 	 *                 should call #amqp_destroy_envelope() when it is done using
2228 	 *                 the fields in the envelope object. The caller is responsible
2229 	 *                 for allocating/destroying the amqp_envelope_t object itself.
2230 	 * \param [in] timeout a timeout to wait for a message delivery. Passing in
2231 	 *             NULL will result in blocking behavior.
2232 	 * \param [in] flags pass in 0. Currently unused.
2233 	 * \returns a amqp_rpc_reply_t object.  ret.reply_type == AMQP_RESPONSE_NORMAL
2234 	 *          on success. If ret.reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION,
2235 	 *          and ret.library_error == AMQP_STATUS_UNEXPECTED_STATE, a frame other
2236 	 *          than AMQP_BASIC_DELIVER_METHOD was received, the caller should call
2237 	 *          amqp_simple_wait_frame() to read this frame and take appropriate
2238 	 *          action.
2239 	 *
2240 	 * \since v0.4.0
2241 	 */
2242 	AMQP_PUBLIC_FUNCTION
2243 	amqp_rpc_reply_t AMQP_CALL amqp_consume_message(amqp_connection_state_t state,
2244 	                                                amqp_envelope_t *envelope,
2245 	                                                struct timeval *timeout,
2246 	                                                int flags);
2247 	
2248 	/**
2249 	 * Frees memory associated with a amqp_envelope_t allocated in
2250 	 * amqp_consume_message()
2251 	 *
2252 	 * \param [in] envelope
2253 	 *
2254 	 * \since v0.4.0
2255 	 */
2256 	AMQP_PUBLIC_FUNCTION
2257 	void AMQP_CALL amqp_destroy_envelope(amqp_envelope_t *envelope);
2258 	
2259 	/**
2260 	 * Parameters used to connect to the RabbitMQ broker
2261 	 *
2262 	 * \since v0.2
2263 	 */
2264 	struct amqp_connection_info {
2265 	  char *user; /**< the username to authenticate with the broker, default on most
2266 	                 broker is 'guest' */
2267 	  char *password; /**< the password to authenticate with the broker, default on
2268 	                     most brokers is 'guest' */
2269 	  char *host;     /**< the hostname of the broker */
2270 	  char *vhost; /**< the virtual host on the broker to connect to, a good default
2271 	                  is "/" */
2272 	  int port;    /**< the port that the broker is listening on, default on most
2273 	                  brokers is 5672 */
2274 	  amqp_boolean_t ssl;
2275 	};
2276 	
2277 	/**
2278 	 * Initialze an amqp_connection_info to default values
2279 	 *
2280 	 * The default values are:
2281 	 * - user: "guest"
2282 	 * - password: "guest"
2283 	 * - host: "localhost"
2284 	 * - vhost: "/"
2285 	 * - port: 5672
2286 	 *
2287 	 * \param [out] parsed the connection info to set defaults on
2288 	 *
2289 	 * \since v0.2
2290 	 */
2291 	AMQP_PUBLIC_FUNCTION
2292 	void AMQP_CALL
2293 	    amqp_default_connection_info(struct amqp_connection_info *parsed);
2294 	
2295 	/**
2296 	 * Parse a connection URL
2297 	 *
2298 	 * An amqp connection url takes the form:
2299 	 *
2300 	 * amqp://[$USERNAME[:$PASSWORD]\@]$HOST[:$PORT]/[$VHOST]
2301 	 *
2302 	 * Examples:
2303 	 *  amqp://guest:guest\@localhost:5672//
2304 	 *  amqp://guest:guest\@localhost/myvhost
2305 	 *
2306 	 *  Any missing parts of the URL will be set to the defaults specified in
2307 	 *  amqp_default_connection_info. For amqps: URLs the default port will be set
2308 	 *  to 5671 instead of 5672 for non-SSL URLs.
2309 	 *
2310 	 * \note This function modifies url parameter.
2311 	 *
2312 	 * \param [in] url URI to parse, note that this parameter is modified by the
2313 	 *             function.
2314 	 * \param [out] parsed the connection info gleaned from the URI. The char*
2315 	 *              members will point to parts of the url input parameter.
2316 	 *              Memory management will depend on how the url is allocated.
2317 	 * \returns AMQP_STATUS_OK on success, AMQP_STATUS_BAD_URL on failure
2318 	 *
2319 	 * \since v0.2
2320 	 */
2321 	AMQP_PUBLIC_FUNCTION
2322 	int AMQP_CALL amqp_parse_url(char *url, struct amqp_connection_info *parsed);
2323 	
2324 	/* socket API */
2325 	
2326 	/**
2327 	 * Open a socket connection.
2328 	 *
2329 	 * This function opens a socket connection returned from amqp_tcp_socket_new()
2330 	 * or amqp_ssl_socket_new(). This function should be called after setting
2331 	 * socket options and prior to assigning the socket to an AMQP connection with
2332 	 * amqp_set_socket().
2333 	 *
2334 	 * \param [in,out] self A socket object.
2335 	 * \param [in] host Connect to this host.
2336 	 * \param [in] port Connect on this remote port.
2337 	 *
2338 	 * \return AMQP_STATUS_OK on success, an amqp_status_enum on failure
2339 	 *
2340 	 * \since v0.4.0
2341 	 */
2342 	AMQP_PUBLIC_FUNCTION
2343 	int AMQP_CALL amqp_socket_open(amqp_socket_t *self, const char *host, int port);
2344 	
2345 	/**
2346 	 * Open a socket connection.
2347 	 *
2348 	 * This function opens a socket connection returned from amqp_tcp_socket_new()
2349 	 * or amqp_ssl_socket_new(). This function should be called after setting
2350 	 * socket options and prior to assigning the socket to an AMQP connection with
2351 	 * amqp_set_socket().
2352 	 *
2353 	 * \param [in,out] self A socket object.
2354 	 * \param [in] host Connect to this host.
2355 	 * \param [in] port Connect on this remote port.
2356 	 * \param [in] timeout Max allowed time to spent on opening. If NULL - run in
2357 	 *             blocking mode
2358 	 *
2359 	 * \return AMQP_STATUS_OK on success, an amqp_status_enum on failure.
2360 	 *
2361 	 * \since v0.4.0
2362 	 */
2363 	AMQP_PUBLIC_FUNCTION
2364 	int AMQP_CALL amqp_socket_open_noblock(amqp_socket_t *self, const char *host,
2365 	                                       int port, struct timeval *timeout);
2366 	
2367 	/**
2368 	 * Get the socket descriptor in use by a socket object.
2369 	 *
2370 	 * Retrieve the underlying socket descriptor. This function can be used to
2371 	 * perform low-level socket operations that aren't supported by the socket
2372 	 * interface. Use with caution!
2373 	 *
2374 	 * \param [in,out] self A socket object.
2375 	 *
2376 	 * \return The underlying socket descriptor, or -1 if there is no socket
2377 	 *  descriptor associated with
2378 	 *
2379 	 * \since v0.4.0
2380 	 */
2381 	AMQP_PUBLIC_FUNCTION
2382 	int AMQP_CALL amqp_socket_get_sockfd(amqp_socket_t *self);
2383 	
2384 	/**
2385 	 * Get the socket object associated with a amqp_connection_state_t
2386 	 *
2387 	 * \param [in] state the connection object to get the socket from
2388 	 * \return a pointer to the socket object, or NULL if one has not been assigned
2389 	 *
2390 	 * \since v0.4.0
2391 	 */
2392 	AMQP_PUBLIC_FUNCTION
2393 	amqp_socket_t *AMQP_CALL amqp_get_socket(amqp_connection_state_t state);
2394 	
2395 	/**
2396 	 * Get the broker properties table
2397 	 *
2398 	 * \param [in] state the connection object
2399 	 * \return a pointer to an amqp_table_t containing the properties advertised
2400 	 *  by the broker on connection. The connection object owns the table, it
2401 	 *  should not be modified.
2402 	 *
2403 	 * \since v0.5.0
2404 	 */
2405 	AMQP_PUBLIC_FUNCTION
2406 	amqp_table_t *AMQP_CALL
2407 	    amqp_get_server_properties(amqp_connection_state_t state);
2408 	
2409 	/**
2410 	 * Get the client properties table
2411 	 *
2412 	 * Get the properties that were passed to the broker on connection.
2413 	 *
2414 	 * \param [in] state the connection object
2415 	 * \return a pointer to an amqp_table_t containing the properties advertised
2416 	 *  by the client on connection. The connection object owns the table, it
2417 	 *  should not be modified.
2418 	 *
2419 	 * \since v0.7.0
2420 	 */
2421 	AMQP_PUBLIC_FUNCTION
2422 	amqp_table_t *AMQP_CALL
2423 	    amqp_get_client_properties(amqp_connection_state_t state);
2424 	
2425 	/**
2426 	 * Get the login handshake timeout.
2427 	 *
2428 	 * amqp_login and amqp_login_with_properties perform the login handshake with
2429 	 * the broker.  This function returns the timeout associated with completing
2430 	 * this operation from the client side. This value can be set by using the
2431 	 * amqp_set_handshake_timeout.
2432 	 *
2433 	 * Note that the RabbitMQ broker has configurable timeout for completing the
2434 	 * login handshake, the default is 10 seconds.  rabbitmq-c has a default of 12
2435 	 * seconds.
2436 	 *
2437 	 * \param [in] state the connection object
2438 	 * \return a struct timeval representing the current login timeout for the state
2439 	 *  object. A NULL value represents an infinite timeout. The memory returned is
2440 	 *  owned by the connection object.
2441 	 *
2442 	 * \since v0.9.0
2443 	 */
2444 	AMQP_PUBLIC_FUNCTION
2445 	struct timeval *AMQP_CALL
2446 	    amqp_get_handshake_timeout(amqp_connection_state_t state);
2447 	
2448 	/**
2449 	 * Set the login handshake timeout.
2450 	 *
2451 	 * amqp_login and amqp_login_with_properties perform the login handshake with
2452 	 * the broker. This function sets the timeout associated with completing this
2453 	 * operation from the client side.
2454 	 *
2455 	 * The timeout must be set before amqp_login or amqp_login_with_properties is
2456 	 * called to change from the default timeout.
2457 	 *
2458 	 * Note that the RabbitMQ broker has a configurable timeout for completing the
2459 	 * login handshake, the default is 10 seconds. rabbitmq-c has a default of 12
2460 	 * seconds.
2461 	 *
2462 	 * \param [in] state the connection object
2463 	 * \param [in] timeout a struct timeval* representing new login timeout for the
2464 	 *  state object. NULL represents an infinite timeout. The value of timeout is
2465 	 *  copied internally, the caller is responsible for ownership of the passed in
2466 	 *  pointer, it does not need to remain valid after this function is called.
2467 	 * \return AMQP_STATUS_OK on success.
2468 	 *
2469 	 * \since v0.9.0
2470 	 */
2471 	AMQP_PUBLIC_FUNCTION
2472 	int AMQP_CALL amqp_set_handshake_timeout(amqp_connection_state_t state,
2473 	                                         struct timeval *timeout);
2474 	
2475 	/**
2476 	 * Get the RPC timeout
2477 	 *
2478 	 * Gets the timeout for any RPC-style AMQP command (e.g., amqp_queue_declare).
2479 	 * This timeout may be changed at any time by calling \amqp_set_rpc_timeout
2480 	 * function with a new timeout. The timeout applies individually to each RPC
2481 	 * that is made.
2482 	 *
2483 	 * The default value is NULL, or an infinite timeout.
2484 	 *
2485 	 * When an RPC times out, the function will return an error AMQP_STATUS_TIMEOUT,
2486 	 * and the connection will be closed.
2487 	 *
2488 	 *\warning RPC-timeouts are an advanced feature intended to be used to detect
2489 	 * dead connections quickly when the rabbitmq-c implementation of heartbeats
2490 	 * does not work. Do not use RPC timeouts unless you understand the implications
2491 	 * of doing so.
2492 	 *
2493 	 * \param [in] state the connection object
2494 	 * \return a struct timeval representing the current RPC timeout for the state
2495 	 * object. A NULL value represents an infinite timeout. The memory returned is
2496 	 * owned by the connection object.
2497 	 *
2498 	 * \since v0.9.0
2499 	 */
2500 	AMQP_PUBLIC_FUNCTION
2501 	struct timeval *AMQP_CALL amqp_get_rpc_timeout(amqp_connection_state_t state);
2502 	
2503 	/**
2504 	 * Set the RPC timeout
2505 	 *
2506 	 * Sets the timeout for any RPC-style AMQP command (e.g., amqp_queue_declare).
2507 	 * This timeout may be changed at any time by calling this function with a new
2508 	 * timeout. The timeout applies individually to each RPC that is made.
2509 	 *
2510 	 * The default value is NULL, or an infinite timeout.
2511 	 *
2512 	 * When an RPC times out, the function will return an error AMQP_STATUS_TIMEOUT,
2513 	 * and the connection will be closed.
2514 	 *
2515 	 *\warning RPC-timeouts are an advanced feature intended to be used to detect
2516 	 * dead connections quickly when the rabbitmq-c implementation of heartbeats
2517 	 * does not work. Do not use RPC timeouts unless you understand the implications
2518 	 * of doing so.
2519 	 *
2520 	 * \param [in] state the connection object
2521 	 * \param [in] timeout a struct timeval* representing new RPC timeout for the
2522 	 * state object. NULL represents an infinite timeout. The value of timeout is
2523 	 * copied internally, the caller is responsible for ownership of the passed
2524 	 * pointer, it does not need to remain valid after this function is called.
2525 	 * \return AMQP_STATUS_SUCCESS on success.
2526 	 *
2527 	 * \since v0.9.0
2528 	 */
2529 	AMQP_PUBLIC_FUNCTION
2530 	int AMQP_CALL amqp_set_rpc_timeout(amqp_connection_state_t state,
2531 	                                   struct timeval *timeout);
2532 	
2533 	AMQP_END_DECLS
2534 	
2535 	#endif /* AMQP_H */
2536