1 module kaleidic.api.rabbitmq; 2 version(OpenSSL) 3 { 4 import deimos.openssl.x509v3; 5 import deimos.openssl.bio; 6 } 7 import core.stdc.string:memcpy; 8 alias ssize_t= long; // FIXME 9 struct amqp_time_t {} 10 version(Posix) import core.sys.posix.sys.types:pthread_mutex_t; 11 else struct pthread_mutex_t {} 12 13 alias DWORD=int; 14 15 version(Posix) 16 { 17 // import pthread; 18 public import core.sys.posix.sys.time: timeval; 19 } 20 21 else version(Windows) 22 { 23 public import core.sys.windows.winsock2: timeval; 24 } 25 26 /+ 27 import limits; 28 29 30 31 // 7.18.1.2 Minimum-width integer types 32 typedef char int_least8_t; 33 typedef short int_least16_t; 34 typedef int int_least32_t; 35 typedef long int_least64_t; 36 typedef ubyte uint_least8_t; 37 typedef ushort uint_least16_t; 38 typedef uint uint_least32_t; 39 typedef ulong uint_least64_t; 40 41 // 7.18.1.3 Fastest minimum-width integer types 42 typedef char int_fast8_t; 43 typedef short int_fast16_t; 44 typedef int int_fast32_t; 45 typedef long int_fast64_t; 46 typedef ubyte uint_fast8_t; 47 typedef ushort uint_fast16_t; 48 typedef uint uint_fast32_t; 49 typedef ulong uint_fast64_t; 50 51 // 7.18.1.4 Integer types capable of holding object pointers 52 #ifdef _WIN64 // [ 53 typedef signed __int64 intptr_t; 54 typedef unsigned __int64 uintptr_t; 55 #else // _WIN64 ][ 56 typedef _W64 signed int intptr_t; 57 typedef _W64 unsigned int uintptr_t; 58 #endif // _WIN64 ] 59 60 // 7.18.1.5 Greatest-width integer types 61 typedef long intmax_t; 62 typedef ulong uintmax_t; 63 64 65 // 7.18.2 Limits of specified-width integer types 66 67 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 68 69 // 7.18.2.1 Limits of exact-width integer types 70 enum INT8_MIN ((char)_I8_MIN) 71 enum INT8_MAX _I8_MAX 72 enum INT16_MIN ((short)_I16_MIN) 73 enum INT16_MAX _I16_MAX 74 enum INT32_MIN ((int)_I32_MIN) 75 enum INT32_MAX _I32_MAX 76 enum INT64_MIN ((long)_I64_MIN) 77 enum INT64_MAX _I64_MAX 78 enum UINT8_MAX _UI8_MAX 79 enum UINT16_MAX _UI16_MAX 80 enum UINT32_MAX _UI32_MAX 81 enum UINT64_MAX _UI64_MAX 82 83 // 7.18.2.2 Limits of minimum-width integer types 84 enum INT_LEAST8_MIN INT8_MIN 85 enum INT_LEAST8_MAX INT8_MAX 86 enum INT_LEAST16_MIN INT16_MIN 87 enum INT_LEAST16_MAX INT16_MAX 88 enum INT_LEAST32_MIN INT32_MIN 89 enum INT_LEAST32_MAX INT32_MAX 90 enum INT_LEAST64_MIN INT64_MIN 91 enum INT_LEAST64_MAX INT64_MAX 92 enum UINT_LEAST8_MAX UINT8_MAX 93 enum UINT_LEAST16_MAX UINT16_MAX 94 enum UINT_LEAST32_MAX UINT32_MAX 95 enum UINT_LEAST64_MAX UINT64_MAX 96 97 // 7.18.2.3 Limits of fastest minimum-width integer types 98 enum INT_FAST8_MIN INT8_MIN 99 enum INT_FAST8_MAX INT8_MAX 100 enum INT_FAST16_MIN INT16_MIN 101 enum INT_FAST16_MAX INT16_MAX 102 enum INT_FAST32_MIN INT32_MIN 103 enum INT_FAST32_MAX INT32_MAX 104 enum INT_FAST64_MIN INT64_MIN 105 enum INT_FAST64_MAX INT64_MAX 106 enum UINT_FAST8_MAX UINT8_MAX 107 enum UINT_FAST16_MAX UINT16_MAX 108 enum UINT_FAST32_MAX UINT32_MAX 109 enum UINT_FAST64_MAX UINT64_MAX 110 111 // 7.18.2.4 Limits of integer types capable of holding object pointers 112 #ifdef _WIN64 // [ 113 # define INTPTR_MIN INT64_MIN 114 # define INTPTR_MAX INT64_MAX 115 # define UINTPTR_MAX UINT64_MAX 116 #else // _WIN64 ][ 117 # define INTPTR_MIN INT32_MIN 118 # define INTPTR_MAX INT32_MAX 119 # define UINTPTR_MAX UINT32_MAX 120 #endif // _WIN64 ] 121 122 // 7.18.2.5 Limits of greatest-width integer types 123 enum INTMAX_MIN INT64_MIN 124 enum INTMAX_MAX INT64_MAX 125 enum UINTMAX_MAX UINT64_MAX 126 127 // 7.18.3 Limits of other integer types 128 129 #ifdef _WIN64 // [ 130 # define PTRDIFF_MIN _I64_MIN 131 # define PTRDIFF_MAX _I64_MAX 132 #else // _WIN64 ][ 133 # define PTRDIFF_MIN _I32_MIN 134 # define PTRDIFF_MAX _I32_MAX 135 #endif // _WIN64 ] 136 137 enum SIG_ATOMIC_MIN INT_MIN 138 enum SIG_ATOMIC_MAX INT_MAX 139 140 #ifndef SIZE_MAX // [ 141 # ifdef _WIN64 // [ 142 # define SIZE_MAX _UI64_MAX 143 # else // _WIN64 ][ 144 # define SIZE_MAX _UI32_MAX 145 # endif // _WIN64 ] 146 #endif // SIZE_MAX ] 147 148 // WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h> 149 #ifndef WCHAR_MIN // [ 150 # define WCHAR_MIN 0 151 #endif // WCHAR_MIN ] 152 #ifndef WCHAR_MAX // [ 153 # define WCHAR_MAX _UI16_MAX 154 #endif // WCHAR_MAX ] 155 156 enum WINT_MIN 0 157 enum WINT_MAX _UI16_MAX 158 159 #endif // __STDC_LIMIT_MACROS ] 160 161 162 // 7.18.4 Limits of other integer types 163 164 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 165 166 // 7.18.4.1 Macros for minimum-width integer constants 167 168 enum INT8_C(val) val##i8 169 enum INT16_C(val) val##i16 170 enum INT32_C(val) val##i32 171 enum INT64_C(val) val##i64 172 173 enum UINT8_C(val) val##ui8 174 enum UINT16_C(val) val##ui16 175 enum UINT32_C(val) val##ui32 176 enum UINT64_C(val) val##ui64 177 178 // 7.18.4.2 Macros for greatest-width integer constants 179 enum INTMAX_C INT64_C 180 enum UINTMAX_C UINT64_C 181 182 #endif // __STDC_CONSTANT_MACROS ] 183 184 185 #endif // _MSC_STDINT_H_ ] 186 187 188 /* 189 * \internal 190 * Important API decorators: 191 * - a public API function 192 * AMQP_PUBLIC_VARIABLE - a public API external variable 193 * - calling convension (used on Win32) 194 */ 195 196 #if defined(_WIN32) && defined(_MSC_VER) 197 # if defined(AMQP_BUILD) && !defined(AMQP_STATIC) 198 # define __declspec(dllexport) 199 # define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern 200 # else 201 # define 202 # if !defined(AMQP_STATIC) 203 # define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern 204 # else 205 # define AMQP_PUBLIC_VARIABLE extern 206 # endif 207 # endif 208 # define __cdecl 209 210 #elif defined(_WIN32) && defined(__BORLANDC__) 211 # if defined(AMQP_BUILD) && !defined(AMQP_STATIC) 212 # define __declspec(dllexport) 213 # define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern 214 # else 215 # define 216 # if !defined(AMQP_STATIC) 217 # define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern 218 # else 219 # define AMQP_PUBLIC_VARIABLE extern 220 # endif 221 # endif 222 # define __cdecl 223 224 #elif defined(_WIN32) && defined(__MINGW32__) 225 # if defined(AMQP_BUILD) && !defined(AMQP_STATIC) 226 # define __declspec(dllexport) 227 # define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern 228 # else 229 # define 230 # if !defined(AMQP_STATIC) 231 # define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern 232 # else 233 # define AMQP_PUBLIC_VARIABLE extern 234 # endif 235 # endif 236 # define __cdecl 237 238 #elif defined(_WIN32) && defined(__CYGWIN__) 239 # if defined(AMQP_BUILD) && !defined(AMQP_STATIC) 240 # define __declspec(dllexport) 241 # define AMQP_PUBLIC_VARIABLE __declspec(dllexport) 242 # else 243 # define 244 # if !defined(AMQP_STATIC) 245 # define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern 246 # else 247 # define AMQP_PUBLIC_VARIABLE extern 248 # endif 249 # endif 250 # define __cdecl 251 252 #elif defined(__GNUC__) && __GNUC__ >= 4 253 # define \ 254 __attribute__ ((visibility ("default"))) 255 # define AMQP_PUBLIC_VARIABLE \ 256 __attribute__ ((visibility ("default"))) extern 257 # define AMQP_CALL 258 #else 259 # define 260 # define AMQP_PUBLIC_VARIABLE extern 261 # define AMQP_CALL 262 #endif 263 264 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) 265 # define AMQP_DEPRECATED(function) \ 266 function __attribute__ ((__deprecated__)) 267 #elif defined(_MSC_VER) 268 # define AMQP_DEPRECATED(function) \ 269 __declspec(deprecated) function 270 #else 271 # define AMQP_DEPRECATED(function) 272 #endif 273 274 /* Define ssize_t on Win32/64 platforms 275 See: http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-April/030649.html for details 276 */ 277 #if !defined(_W64) 278 #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 279 enum _W64 __w64 280 #else 281 enum _W64 282 #endif 283 #endif 284 285 typedef unsigned long long size_t; 286 typedef long long ssize_t; 287 288 #ifdef _MSC_VER 289 #ifdef _WIN64 290 typedef __int64 ssize_t; 291 #else 292 typedef _W64 int ssize_t; 293 #endif 294 #endif 295 296 #if defined(_WIN32) && defined(__MINGW32__) 297 #include <sys/types.h> 298 #endif 299 300 /** \endcond */ 301 +/ 302 303 extern(C): 304 305 306 enum AMQP_VERSION_MAJOR=0; 307 enum AMQP_VERSION_MINOR=8; 308 enum AMQP_VERSION_PATCH=1; 309 enum AMQP_VERSION_IS_RELEASE=0; 310 311 auto AMQP_VERSION_CODE(int major, int minor, int patch, int release) 312 { 313 return 314 ((major << 24) | 315 (minor << 16) | 316 (patch << 8) | 317 (release)); 318 } 319 320 321 322 uint amqp_version_number(); 323 const(char)* amqp_version(); 324 enum AMQP_DEFAULT_FRAME_SIZE = 131072; 325 enum AMQP_DEFAULT_MAX_CHANNELS=0; 326 enum AMQP_DEFAULT_HEARTBEAT=0; 327 alias amqp_boolean_t = int; 328 alias amqp_method_number_t = uint; 329 alias amqp_flags_t = uint; 330 alias amqp_channel_t = ushort; 331 332 struct amqp_bytes_t 333 { 334 size_t len; /**< length of the buffer in bytes */ 335 void *bytes; /**< pointer to the beginning of the buffer */ 336 } 337 338 struct amqp_decimal_t 339 { 340 ubyte decimals; /**< the location of the decimal point */ 341 uint value; /**< the value before the decimal point is applied */ 342 } 343 344 struct amqp_table_t 345 { 346 int num_entries; /**< length of entries array */ 347 amqp_table_entry_t* entries; /**< an array of table entries */ 348 } 349 350 struct amqp_array_t 351 { 352 int num_entries; /**< Number of entries in the table */ 353 amqp_field_value_t* entries; /**< linked list of field values */ 354 } 355 356 struct amqp_field_value_t 357 { 358 ubyte kind; /**< the type of the entry /sa amqp_field_value_kind_t */ 359 union Value 360 { 361 amqp_boolean_t boolean; /**< boolean type AMQP_FIELD_KIND_BOOLEAN */ 362 char i8; /**< char type AMQP_FIELD_KIND_I8 */ 363 ubyte u8; /**< ubyte type AMQP_FIELD_KIND_U8 */ 364 short i16; /**< short type AMQP_FIELD_KIND_I16 */ 365 ushort u16; /**< ushort type AMQP_FIELD_KIND_U16 */ 366 int i32; /**< int type AMQP_FIELD_KIND_I32 */ 367 uint u32; /**< uint type AMQP_FIELD_KIND_U32 */ 368 long i64; /**< long type AMQP_FIELD_KIND_I64 */ 369 ulong u64; /**< ulong type AMQP_FIELD_KIND_U64, AMQP_FIELD_KIND_TIMESTAMP */ 370 float f32; /**< float type AMQP_FIELD_KIND_F32 */ 371 double f64; /**< double type AMQP_FIELD_KIND_F64 */ 372 amqp_decimal_t decimal; /**< amqp_decimal_t AMQP_FIELD_KIND_DECIMAL */ 373 amqp_bytes_t bytes; /**< amqp_bytes_t type AMQP_FIELD_KIND_UTF8, AMQP_FIELD_KIND_BYTES */ 374 amqp_table_t table; /**< amqp_table_t type AMQP_FIELD_KIND_TABLE */ 375 amqp_array_t array; /**< amqp_array_t type AMQP_FIELD_KIND_ARRAY */ 376 } 377 Value value; /**< a union of the value */ 378 } 379 380 381 struct amqp_table_entry_t 382 { 383 amqp_bytes_t key; /**< the table entry key. Its a null-terminated UTF-8 string, 384 * with a maximum size of 128 bytes */ 385 amqp_field_value_t value; /**< the table entry values */ 386 } 387 388 enum amqp_field_value_kind_t 389 { 390 AMQP_FIELD_KIND_BOOLEAN = 't', /**< boolean type. 0 = false, 1 = true @see amqp_boolean_t */ 391 AMQP_FIELD_KIND_I8 = 'b', /**< 8-bit signed integer, datatype: char */ 392 AMQP_FIELD_KIND_U8 = 'B', /**< 8-bit unsigned integer, datatype: ubyte */ 393 AMQP_FIELD_KIND_I16 = 's', /**< 16-bit signed integer, datatype: short */ 394 AMQP_FIELD_KIND_U16 = 'u', /**< 16-bit unsigned integer, datatype: ushort */ 395 AMQP_FIELD_KIND_I32 = 'I', /**< 32-bit signed integer, datatype: int */ 396 AMQP_FIELD_KIND_U32 = 'i', /**< 32-bit unsigned integer, datatype: uint */ 397 AMQP_FIELD_KIND_I64 = 'l', /**< 64-bit signed integer, datatype: long */ 398 AMQP_FIELD_KIND_U64 = 'L', /**< 64-bit unsigned integer, datatype: ulong */ 399 AMQP_FIELD_KIND_F32 = 'f', /**< single-precision floating point value, datatype: float */ 400 AMQP_FIELD_KIND_F64 = 'd', /**< double-precision floating point value, datatype: double */ 401 AMQP_FIELD_KIND_DECIMAL = 'D', /**< amqp-decimal value, datatype: amqp_decimal_t */ 402 AMQP_FIELD_KIND_UTF8 = 'S', /**< UTF-8 null-terminated character string, datatype: amqp_bytes_t */ 403 AMQP_FIELD_KIND_ARRAY = 'A', /**< field array (repeated values of another datatype. datatype: amqp_array_t */ 404 AMQP_FIELD_KIND_TIMESTAMP = 'T',/**< 64-bit timestamp. datatype ulong */ 405 AMQP_FIELD_KIND_TABLE = 'F', /**< field table. encapsulates a table inside a table entry. datatype: amqp_table_t */ 406 AMQP_FIELD_KIND_VOID = 'V', /**< empty entry */ 407 AMQP_FIELD_KIND_BYTES = 'x' /**< unformatted byte string, datatype: amqp_bytes_t */ 408 } 409 410 struct amqp_pool_blocklist_t 411 { 412 int num_blocks; /**< Number of blocks in the block list */ 413 void **blocklist; /**< Array of memory blocks */ 414 } 415 416 struct amqp_pool_t 417 { 418 size_t pagesize; /**< the size of the page in bytes. 419 * allocations less than or equal to this size are 420 * allocated in the pages block list 421 * allocations greater than this are allocated in their 422 * own block in the large_blocks block list */ 423 424 amqp_pool_blocklist_t pages; /**< blocks that are the size of pagesize */ 425 amqp_pool_blocklist_t large_blocks; /**< allocations larger than the pagesize */ 426 427 int next_page; /**< an index to the next unused page block */ 428 char* alloc_block; /**< pointer to the current allocation block */ 429 size_t alloc_used; /**< number of bytes in the current allocation block that has been used */ 430 } 431 432 struct amqp_method_t 433 { 434 amqp_method_number_t id; /**< the method id number */ 435 void* decoded; /**< pointer to the decoded method, 436 * cast to the appropriate type to use */ 437 } 438 439 struct amqp_frame_t 440 { 441 ubyte frame_type; /**< frame type. The types: 442 * - AMQP_FRAME_METHOD - use the method union member 443 * - AMQP_FRAME_HEADER - use the properties union member 444 * - AMQP_FRAME_BODY - use the body_fragment union member 445 */ 446 amqp_channel_t channel; /**< the channel the frame was received on */ 447 union Payload 448 { 449 amqp_method_t method; /**< a method, use if frame_type == AMQP_FRAME_METHOD */ 450 struct Properties 451 { 452 ushort class_id; /**< the class for the properties */ 453 ulong body_size; /**< size of the body in bytes */ 454 void *decoded; /**< the decoded properties */ 455 amqp_bytes_t raw; /**< amqp-encoded properties structure */ 456 } 457 Properties properties; /**< message header, a.k.a., properties, 458 use if frame_type == AMQP_FRAME_HEADER */ 459 amqp_bytes_t body_fragment; /**< a body fragment, use if frame_type == AMQP_FRAME_BODY */ 460 struct ProtocolHeader 461 { 462 ubyte transport_high; /**< @internal first byte of handshake */ 463 ubyte transport_low; /**< @internal second byte of handshake */ 464 ubyte protocol_version_major; /**< @internal third byte of handshake */ 465 ubyte protocol_version_minor; /**< @internal fourth byte of handshake */ 466 } 467 ProtocolHeader protocol_header; /**< Used only when doing the initial handshake with the broker, 468 don't use otherwise */ 469 } 470 Payload payload; /**< the payload of the frame */ 471 } 472 473 enum 474 { 475 AMQP_RESPONSE_NONE = 0, /**< the library got an EOF from the socket */ 476 AMQP_RESPONSE_NORMAL, /**< response normal, the RPC completed successfully */ 477 AMQP_RESPONSE_LIBRARY_EXCEPTION,/**< library error, an error occurred in the library, examine the library_error */ 478 AMQP_RESPONSE_SERVER_EXCEPTION /**< server exception, the broker returned an error, check replay */ 479 } 480 481 enum ResponseType 482 { 483 none = AMQP_RESPONSE_NONE, 484 normal = AMQP_RESPONSE_NORMAL, 485 libraryException = AMQP_RESPONSE_LIBRARY_EXCEPTION, 486 serverException = AMQP_RESPONSE_SERVER_EXCEPTION, 487 } 488 489 alias amqp_response_type_enum = ResponseType; 490 491 492 struct amqp_rpc_reply_t 493 { 494 amqp_response_type_enum reply_type; /**< the reply type: 495 * - AMQP_RESPONSE_NORMAL - the RPC completed successfully 496 * - AMQP_RESPONSE_SERVER_EXCEPTION - the broker returned 497 * an exception, check the reply field 498 * - AMQP_RESPONSE_LIBRARY_EXCEPTION - the library 499 * encountered an error, check the library_error field 500 */ 501 amqp_method_t reply; /**< in case of AMQP_RESPONSE_SERVER_EXCEPTION this 502 * field will be set to the method returned from the broker */ 503 int library_error; /**< in case of AMQP_RESPONSE_LIBRARY_EXCEPTION this 504 * field will be set to an error code. An error 505 * string can be retrieved using amqp_error_string */ 506 } 507 508 enum SaslMethod 509 { 510 undefined = AMQP_SASL_METHOD_UNDEFINED, 511 plain = AMQP_SASL_METHOD_PLAIN, 512 external = AMQP_SASL_METHOD_EXTERNAL, 513 } 514 alias amqp_sasl_method_enum = SaslMethod; 515 516 enum 517 { 518 AMQP_SASL_METHOD_UNDEFINED = -1, /**< Invalid SASL method */ 519 AMQP_SASL_METHOD_PLAIN = 0, /**< the PLAIN SASL method for authentication to the broker */ 520 AMQP_SASL_METHOD_EXTERNAL = 1 /**< the EXTERNAL SASL method for authentication to the broker */ 521 } 522 523 alias amqp_connection_state_t = amqp_connection_state_t_ *; 524 alias amqp_status_enum = int; 525 526 enum 527 { 528 AMQP_STATUS_OK = 0x0, /**< Operation successful */ 529 AMQP_STATUS_NO_MEMORY = -0x0001, /**< Memory allocation 530 failed */ 531 AMQP_STATUS_BAD_AMQP_DATA = -0x0002, /**< Incorrect or corrupt 532 data was received from 533 the broker. This is a 534 protocol error. */ 535 AMQP_STATUS_UNKNOWN_CLASS = -0x0003, /**< An unknown AMQP class 536 was received. This is 537 a protocol error. */ 538 AMQP_STATUS_UNKNOWN_METHOD = -0x0004, /**< An unknown AMQP method 539 was received. This is 540 a protocol error. */ 541 AMQP_STATUS_HOSTNAME_RESOLUTION_FAILED= -0x0005, /**< Unable to resolve the 542 * hostname */ 543 AMQP_STATUS_INCOMPATIBLE_AMQP_VERSION = -0x0006, /**< The broker advertised 544 an incompaible AMQP 545 version */ 546 AMQP_STATUS_CONNECTION_CLOSED = -0x0007, /**< The connection to the 547 broker has been closed 548 */ 549 AMQP_STATUS_BAD_URL = -0x0008, /**< malformed AMQP URL */ 550 AMQP_STATUS_SOCKET_ERROR = -0x0009, /**< A socket error 551 occurred */ 552 AMQP_STATUS_INVALID_PARAMETER = -0x000A, /**< An invalid parameter 553 was passed into the 554 function */ 555 AMQP_STATUS_TABLE_TOO_BIG = -0x000B, /**< The amqp_table_t object 556 cannot be serialized 557 because the output 558 buffer is too small */ 559 AMQP_STATUS_WRONG_METHOD = -0x000C, /**< The wrong method was 560 received */ 561 AMQP_STATUS_TIMEOUT = -0x000D, /**< Operation timed out */ 562 AMQP_STATUS_TIMER_FAILURE = -0x000E, /**< The underlying system 563 timer facility failed */ 564 AMQP_STATUS_HEARTBEAT_TIMEOUT = -0x000F, /**< Timed out waiting for 565 heartbeat */ 566 AMQP_STATUS_UNEXPECTED_STATE = -0x0010, /**< Unexpected protocol 567 state */ 568 AMQP_STATUS_SOCKET_CLOSED = -0x0011, /**< Underlying socket is 569 closed */ 570 AMQP_STATUS_SOCKET_INUSE = -0x0012, /**< Underlying socket is 571 already open */ 572 AMQP_STATUS_BROKER_UNSUPPORTED_SASL_METHOD = -0x0013, /**< Broker does not 573 support the requested 574 SASL mechanism */ 575 AMQP_STATUS_UNSUPPORTED = -0x0014, /**< Parameter is unsupported 576 in this version */ 577 _AMQP_STATUS_NEXT_VALUE = -0x0015, /**< Internal value */ 578 579 AMQP_STATUS_TCP_ERROR = -0x0100, /**< A generic TCP error 580 occurred */ 581 AMQP_STATUS_TCP_SOCKETLIB_INIT_ERROR = -0x0101, /**< An error occurred trying 582 to initialize the 583 socket library*/ 584 _AMQP_STATUS_TCP_NEXT_VALUE = -0x0102, /**< Internal value */ 585 586 AMQP_STATUS_SSL_ERROR = -0x0200, /**< A generic SSL error 587 occurred. */ 588 AMQP_STATUS_SSL_HOSTNAME_VERIFY_FAILED= -0x0201, /**< SSL validation of 589 hostname against 590 peer certificate 591 failed */ 592 AMQP_STATUS_SSL_PEER_VERIFY_FAILED = -0x0202, /**< SSL validation of peer 593 certificate failed. */ 594 AMQP_STATUS_SSL_CONNECTION_FAILED = -0x0203, /**< SSL handshake failed. */ 595 _AMQP_STATUS_SSL_NEXT_VALUE = -0x0204 /**< Internal value */ 596 } 597 598 enum amqp_delivery_mode_enum 599 { 600 AMQP_DELIVERY_NONPERSISTENT = 1, /**< Non-persistent message */ 601 AMQP_DELIVERY_PERSISTENT = 2 /**< Persistent message */ 602 } 603 604 // const causes problems with prototypes of functions 605 // const 606 __gshared amqp_bytes_t amqp_empty_bytes; 607 __gshared amqp_table_t amqp_empty_table; 608 __gshared amqp_array_t amqp_empty_array; 609 610 alias AMQP_EMPTY_BYTES= amqp_empty_bytes; 611 alias AMQP_EMPTY_TABLE= amqp_empty_table; 612 alias AMQP_EMPTY_ARRAY = amqp_empty_array; 613 void init_amqp_pool(amqp_pool_t *pool, size_t pagesize); 614 void recycle_amqp_pool(amqp_pool_t *pool); 615 void empty_amqp_pool(amqp_pool_t *pool); 616 void * amqp_pool_alloc(amqp_pool_t *pool, size_t amount); 617 void amqp_pool_alloc_bytes(amqp_pool_t *pool, size_t amount, amqp_bytes_t *output); 618 amqp_bytes_t amqp_cstring_bytes(const(char)* cstr); 619 amqp_bytes_t amqp_bytes_malloc_dup(amqp_bytes_t src); 620 amqp_bytes_t amqp_bytes_malloc(size_t amount); 621 void amqp_bytes_free(amqp_bytes_t bytes); 622 amqp_connection_state_t amqp_new_connection(); 623 int amqp_get_sockfd(amqp_connection_state_t state); 624 void amqp_set_sockfd(amqp_connection_state_t state, int sockfd); 625 int amqp_tune_connection(amqp_connection_state_t state, int channel_max, int frame_max, int heartbeat); 626 int amqp_get_channel_max(amqp_connection_state_t state); 627 int amqp_get_frame_max(amqp_connection_state_t state); 628 int amqp_get_heartbeat(amqp_connection_state_t state); 629 int amqp_destroy_connection(amqp_connection_state_t state); 630 int amqp_handle_input(amqp_connection_state_t state, amqp_bytes_t received_data, amqp_frame_t *decoded_frame); 631 amqp_boolean_t amqp_release_buffers_ok(amqp_connection_state_t state); 632 void amqp_release_buffers(amqp_connection_state_t state); 633 void amqp_maybe_release_buffers(amqp_connection_state_t state); 634 void amqp_maybe_release_buffers_on_channel(amqp_connection_state_t state, amqp_channel_t channel); 635 int amqp_send_frame(amqp_connection_state_t state, const(amqp_frame_t)* frame); 636 int amqp_table_entry_cmp(const(void)* entry1, const(void)* entry2); 637 int amqp_open_socket(const(char)* hostname, int portnumber); 638 int amqp_send_header(amqp_connection_state_t state); 639 amqp_boolean_t amqp_frames_enqueued(amqp_connection_state_t state); 640 int amqp_simple_wait_frame(amqp_connection_state_t state, amqp_frame_t *decoded_frame); 641 int amqp_simple_wait_frame_noblock(amqp_connection_state_t state, amqp_frame_t *decoded_frame, timeval *tv); 642 int amqp_simple_wait_method(amqp_connection_state_t state, amqp_channel_t expected_channel, amqp_method_number_t expected_method, amqp_method_t *output); 643 int amqp_send_method(amqp_connection_state_t state, amqp_channel_t channel, amqp_method_number_t id, void *decoded); 644 amqp_rpc_reply_t amqp_simple_rpc(amqp_connection_state_t state, amqp_channel_t channel, amqp_method_number_t request_id, amqp_method_number_t *expected_reply_ids, void *decoded_request_method); 645 void * amqp_simple_rpc_decoded(amqp_connection_state_t state, amqp_channel_t channel, amqp_method_number_t request_id, amqp_method_number_t reply_id, void *decoded_request_method); 646 amqp_rpc_reply_t amqp_get_rpc_reply(amqp_connection_state_t state); 647 amqp_rpc_reply_t amqp_login(amqp_connection_state_t state, const(char)* vhost, int channel_max, int frame_max, int heartbeat, amqp_sasl_method_enum sasl_method, ...); 648 amqp_rpc_reply_t amqp_login_with_properties(amqp_connection_state_t state, const(char)* vhost, int channel_max, int frame_max, int heartbeat, const amqp_table_t *properties, amqp_sasl_method_enum sasl_method, ...); 649 int amqp_basic_publish(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t exchange, amqp_bytes_t routing_key, 650 amqp_boolean_t mandatory, amqp_boolean_t immediate, const(amqp_basic_properties_t)* properties, amqp_bytes_t body_); 651 652 amqp_rpc_reply_t amqp_channel_close(amqp_connection_state_t state, amqp_channel_t channel, int code); 653 amqp_rpc_reply_t amqp_connection_close(amqp_connection_state_t state, int code); 654 int amqp_basic_ack(amqp_connection_state_t state, amqp_channel_t channel, ulong delivery_tag, amqp_boolean_t multiple); 655 amqp_rpc_reply_t amqp_basic_get(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t queue, amqp_boolean_t no_ack); 656 int amqp_basic_reject(amqp_connection_state_t state, amqp_channel_t channel, ulong delivery_tag, amqp_boolean_t requeue); 657 int amqp_basic_nack(amqp_connection_state_t state, amqp_channel_t channel, ulong delivery_tag, amqp_boolean_t multiple, amqp_boolean_t requeue); 658 amqp_boolean_t amqp_data_in_buffer(amqp_connection_state_t state); 659 char* amqp_error_string(int err); 660 const(char)* amqp_error_string2(int err); 661 int amqp_decode_table(amqp_bytes_t encoded, amqp_pool_t *pool, amqp_table_t *output, size_t *offset); 662 int amqp_encode_table(amqp_bytes_t encoded, amqp_table_t *input, size_t *offset); 663 int amqp_table_clone(const amqp_table_t *original, amqp_table_t *clone, amqp_pool_t *pool); 664 665 666 struct amqp_message_t 667 { 668 amqp_basic_properties_t properties; /**< message properties */ 669 amqp_bytes_t body_; /**< message body */ 670 amqp_pool_t pool; /**< pool used to allocate properties */ 671 } 672 673 amqp_rpc_reply_t amqp_read_message(amqp_connection_state_t state, amqp_channel_t channel, amqp_message_t *message, int flags); 674 void amqp_destroy_message(amqp_message_t *message); 675 676 struct amqp_envelope_t 677 { 678 amqp_channel_t channel; /**< channel message was delivered on */ 679 amqp_bytes_t consumer_tag; /**< the consumer tag the message was delivered to */ 680 ulong delivery_tag; /**< the messages delivery tag */ 681 amqp_boolean_t redelivered; /**< flag indicating whether this message is being redelivered */ 682 amqp_bytes_t exchange; /**< exchange this message was published to */ 683 amqp_bytes_t routing_key; /**< the routing key this message was published with */ 684 amqp_message_t message; /**< the message */ 685 } 686 687 amqp_rpc_reply_t amqp_consume_message(amqp_connection_state_t state, amqp_envelope_t *envelope, timeval *timeout, int flags); 688 void amqp_destroy_envelope(amqp_envelope_t *envelope); 689 690 691 struct amqp_connection_info 692 { 693 char *user; /**< the username to authenticate with the broker, default on most broker is 'guest' */ 694 char *password; /**< the password to authenticate with the broker, default on most brokers is 'guest' */ 695 char *host; /**< the hostname of the broker */ 696 char *vhost; /**< the virtual host on the broker to connect to, a good default is "/" */ 697 int port; /**< the port that the broker is listening on, default on most brokers is 5672 */ 698 amqp_boolean_t ssl; 699 } 700 701 void amqp_default_connection_info(amqp_connection_info* parsed); 702 int amqp_parse_url(char *url, amqp_connection_info* parsed); 703 int amqp_socket_open(amqp_socket_t *self, const(char)*host, int port); 704 int amqp_socket_open_noblock(amqp_socket_t *self, const(char)*host, int port, timeval* timeout); 705 int amqp_socket_get_sockfd(amqp_socket_t *self); 706 amqp_socket_t * amqp_get_socket(amqp_connection_state_t state); 707 amqp_table_t * amqp_get_server_properties(amqp_connection_state_t state); 708 amqp_table_t * amqp_get_client_properties(amqp_connection_state_t state); 709 timeval* amqp_get_handshake_timeout(amqp_connection_state_t state); 710 int amqp_set_handshake_timeout(amqp_connection_state_t state, timeval* timeout); 711 timeval* amqp_get_rpc_timeout(amqp_connection_state_t state); 712 int amqp_set_rpc_timeout(amqp_connection_state_t state, timeval* timeout); 713 714 amqp_socket_t * amqp_tcp_socket_new(amqp_connection_state_t state); 715 void amqp_tcp_socket_set_sockfd(amqp_socket_t *self, int sockfd); 716 amqp_table_entry_t amqp_table_construct_utf8_entry(const(char)*key, const(char)*value); 717 amqp_table_entry_t amqp_table_construct_table_entry(const(char)*key, const amqp_table_t *value); 718 amqp_table_entry_t amqp_table_construct_bool_entry(const(char)*key, const int value); 719 amqp_table_entry_t *amqp_table_get_entry_by_key(const amqp_table_t *table, const amqp_bytes_t key); 720 721 version(OpenSSL) 722 { 723 amqp_socket_t * amqp_ssl_socket_new(amqp_connection_state_t state); 724 int amqp_ssl_socket_set_cacert(amqp_socket_t *self, const(char)*cacert); 725 int amqp_ssl_socket_set_key(amqp_socket_t *self, const(char)*cert, const(char)*key); 726 int amqp_ssl_socket_set_key_buffer(amqp_socket_t *self, const(char)*cert, const void *key, size_t n); 727 void amqp_ssl_socket_set_verify(amqp_socket_t *self, amqp_boolean_t verify); 728 void amqp_ssl_socket_set_verify_peer(amqp_socket_t *self, amqp_boolean_t verify); 729 void amqp_ssl_socket_set_verify_hostname(amqp_socket_t *self, amqp_boolean_t verify); 730 731 enum amqp_tls_version_t 732 { 733 AMQP_TLSv1 = 1, 734 AMQP_TLSv1_1 = 2, 735 AMQP_TLSv1_2 = 3, 736 AMQP_TLSvLATEST = 0xFFFF 737 } 738 739 int amqp_ssl_socket_set_ssl_versions(amqp_socket_t *self, amqp_tls_version_t min, amqp_tls_version_t max); 740 void amqp_set_initialize_ssl_library(amqp_boolean_t do_initialize); 741 } 742 743 744 enum amqp_socket_flag_enum 745 { 746 AMQP_SF_NONE = 0, 747 AMQP_SF_MORE = 1, 748 AMQP_SF_POLLIN = 2, 749 AMQP_SF_POLLOUT = 4, 750 AMQP_SF_POLLERR = 8 751 } 752 753 enum amqp_socket_close_enum 754 { 755 AMQP_SC_NONE = 0, 756 AMQP_SC_FORCE = 1 757 } 758 759 int amqp_os_socket_error(); 760 int amqp_os_socket_close(int sockfd); 761 762 /* Socket callbacks. */ 763 alias amqp_socket_send_fn = ssize_t function(void *, const void *, size_t, int); 764 alias amqp_socket_recv_fn = ssize_t function(void *, void *, size_t, int); 765 alias amqp_socket_open_fn = int function(void *, const(char)*, int, timeval*); 766 alias amqp_socket_close_fn = int function(void *, amqp_socket_close_enum); 767 alias amqp_socket_get_sockfd_fn = int function(void *); 768 alias amqp_socket_delete_fn = void function(void *); 769 770 /// V-table for amqp_socket_t 771 struct amqp_socket_class_t 772 { 773 amqp_socket_send_fn send; 774 amqp_socket_recv_fn recv; 775 amqp_socket_open_fn open; 776 amqp_socket_close_fn close; 777 amqp_socket_get_sockfd_fn get_sockfd; 778 amqp_socket_delete_fn delete_; 779 } 780 781 /** Abstract base class for amqp_socket_t */ 782 struct amqp_socket_t 783 { 784 amqp_socket_class_t *klass; 785 } 786 787 void amqp_set_socket(amqp_connection_state_t state, amqp_socket_t *socket); 788 ssize_t amqp_socket_send(amqp_socket_t *self, const void *buf, size_t len, int flags); 789 ssize_t amqp_try_send(amqp_connection_state_t state, const void *buf, size_t len, amqp_time_t deadline, int flags); 790 ssize_t amqp_socket_recv(amqp_socket_t *self, void *buf, size_t len, int flags); 791 int amqp_socket_close(amqp_socket_t *self, amqp_socket_close_enum force); 792 void amqp_socket_delete(amqp_socket_t *self); 793 int amqp_open_socket_noblock(const(char)* hostname, int portnumber, timeval* timeout); 794 int amqp_open_socket_inner(const(char)* hostname, int portnumber, amqp_time_t deadline); 795 int amqp_poll(int fd, int event, amqp_time_t deadline); 796 int amqp_send_method_inner(amqp_connection_state_t state, amqp_channel_t channel, amqp_method_number_t id, void *decoded, int flags, amqp_time_t deadline); 797 int amqp_queue_frame(amqp_connection_state_t state, amqp_frame_t *frame); 798 int amqp_put_back_frame(amqp_connection_state_t state, amqp_frame_t *frame); 799 int amqp_simple_wait_frame_on_channel(amqp_connection_state_t state, amqp_channel_t channel, amqp_frame_t *decoded_frame); 800 int sasl_mechanism_in_list(amqp_bytes_t mechanisms, amqp_sasl_method_enum method); 801 int amqp_merge_capabilities(const amqp_table_t *base, const amqp_table_t *add, amqp_table_t *result, amqp_pool_t *pool); 802 enum AMQ_COPYRIGHT = "Copyright (c) 2007-2014 VMWare Inc, Tony Garnock-Jones, and Alan Antonuk."; 803 804 enum amqp_connection_state_enum 805 { 806 CONNECTION_STATE_IDLE = 0, 807 CONNECTION_STATE_INITIAL, 808 CONNECTION_STATE_HEADER, 809 CONNECTION_STATE_BODY 810 } 811 812 enum amqp_status_private_enum 813 { 814 /* 0x00xx . AMQP_STATUS_*/ 815 /* 0x01xx . AMQP_STATUS_TCP_* */ 816 /* 0x02xx . AMQP_STATUS_SSL_* */ 817 AMQP_PRIVATE_STATUS_SOCKET_NEEDREAD = -0x1301, 818 AMQP_PRIVATE_STATUS_SOCKET_NEEDWRITE = -0x1302 819 } 820 821 /* 7 bytes up front, then payload, then 1 byte footer */ 822 enum HEADER_SIZE =7; 823 enum FOOTER_SIZE =1; 824 enum AMQP_PSEUDOFRAME_PROTOCOL_HEADER ='A'; 825 826 struct amqp_link_t 827 { 828 amqp_link_t* next; 829 void *data; 830 } 831 832 enum POOL_TABLE_SIZE=16; 833 834 struct amqp_pool_table_entry_t 835 { 836 amqp_pool_table_entry_t* next; 837 amqp_pool_t pool; 838 amqp_channel_t channel; 839 } 840 841 struct amqp_connection_state_t_ 842 { 843 amqp_pool_table_entry_t*[POOL_TABLE_SIZE] pool_table; 844 845 amqp_connection_state_enum state; 846 847 int channel_max; 848 int frame_max; 849 850 /* Heartbeat interval in seconds. If this is <= 0, then heartbeats are not 851 * enabled, and next_recv_heartbeat and next_send_heartbeat are set to 852 * infinite */ 853 int heartbeat; 854 amqp_time_t next_recv_heartbeat; 855 amqp_time_t next_send_heartbeat; 856 857 /* buffer for holding frame headers. Allows us to delay allocating 858 * the raw frame buffer until the type, channel, and size are all known 859 */ 860 char[HEADER_SIZE + 1] header_buffer; 861 amqp_bytes_t inbound_buffer; 862 863 size_t inbound_offset; 864 size_t target_size; 865 866 amqp_bytes_t outbound_buffer; 867 868 amqp_socket_t *socket; 869 870 amqp_bytes_t sock_inbound_buffer; 871 size_t sock_inbound_offset; 872 size_t sock_inbound_limit; 873 874 amqp_link_t *first_queued_frame; 875 amqp_link_t *last_queued_frame; 876 877 amqp_rpc_reply_t most_recent_api_result; 878 879 amqp_table_t server_properties; 880 amqp_table_t client_properties; 881 amqp_pool_t properties_pool; 882 883 timeval *handshake_timeout; 884 timeval internal_handshake_timeout; 885 timeval *rpc_timeout; 886 timeval internal_rpc_timeout; 887 } 888 889 amqp_pool_t *amqp_get_or_create_channel_pool(amqp_connection_state_t connection, amqp_channel_t channel); 890 amqp_pool_t *amqp_get_channel_pool(amqp_connection_state_t state, amqp_channel_t channel); 891 892 893 pragma(inline,true) 894 int amqp_heartbeat_send(amqp_connection_state_t state) 895 { 896 return state.heartbeat; 897 } 898 899 pragma(inline,true) 900 int amqp_heartbeat_recv(amqp_connection_state_t state) 901 { 902 return 2 * state.heartbeat; 903 } 904 905 906 int amqp_try_recv(amqp_connection_state_t state); 907 908 pragma(inline,true) 909 void *amqp_offset(void *data, size_t offset) 910 { 911 return cast(char *)data + offset; 912 } 913 914 /+ 915 /* This macro defines the encoding and decoding functions associated with a 916 simple type. */ 917 918 enum DECLARE_CODEC_BASE_TYPE(bits, htonx, ntohx) \ 919 \ 920 static inline void amqp_e##bits(void *data, size_t offset, \ 921 uint##bits##_t val) \ 922 { \ 923 /* The AMQP data might be unaligned. So we encode and then copy the \ 924 result into place. */ \ 925 uint##bits##_t res = htonx(val); \ 926 memcpy(amqp_offset(data, offset), &res, bits/8); \ 927 } \ 928 \ 929 static inline uint##bits##_t amqp_d##bits(void *data, size_t offset) \ 930 { \ 931 /* The AMQP data might be unaligned. So we copy the source value \ 932 into a variable and then decode it. */ \ 933 uint##bits##_t val; \ 934 memcpy(&val, amqp_offset(data, offset), bits/8); \ 935 return ntohx(val); \ 936 } \ 937 \ 938 static inline int amqp_encode_##bits(amqp_bytes_t encoded, size_t *offset, \ 939 uint##bits##_t input) \ 940 \ 941 { \ 942 size_t o = *offset; \ 943 if ((*offset = o + bits / 8) <= encoded.len) { \ 944 amqp_e##bits(encoded.bytes, o, input); \ 945 return 1; \ 946 } \ 947 else { \ 948 return 0; \ 949 } \ 950 } \ 951 \ 952 static inline int amqp_decode_##bits(amqp_bytes_t encoded, size_t *offset, \ 953 uint##bits##_t *output) \ 954 \ 955 { \ 956 size_t o = *offset; \ 957 if ((*offset = o + bits / 8) <= encoded.len) { \ 958 *output = amqp_d##bits(encoded.bytes, o); \ 959 return 1; \ 960 } \ 961 else { \ 962 return 0; \ 963 } \ 964 } 965 966 /* Determine byte order */ 967 #if defined(__GLIBC__) 968 # include <endian.h> 969 # if (__BYTE_ORDER == __LITTLE_ENDIAN) 970 # define AMQP_LITTLE_ENDIAN 971 # elif (__BYTE_ORDER == __BIG_ENDIAN) 972 # define AMQP_BIG_ENDIAN 973 # else 974 /* Don't define anything */ 975 # endif 976 #elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) || \ 977 defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) 978 # define AMQP_BIG_ENDIAN 979 #elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) || \ 980 defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) 981 # define AMQP_LITTLE_ENDIAN 982 #elif defined(__hppa__) || defined(__HPPA__) || defined(__hppa) || \ 983 defined(_POWER) || defined(__powerpc__) || defined(__ppc___) || \ 984 defined(_MIPSEB) || defined(__s390__) || \ 985 defined(__sparc) || defined(__sparc__) 986 # define AMQP_BIG_ENDIAN 987 #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) || \ 988 defined(__amd64__) || defined(__x86_64__) || defined(_M_X64) || \ 989 defined(__ia64) || defined(__ia64__) || defined(_M_IA64) || \ 990 defined(__arm__) || defined(_M_ARM) || \ 991 defined(__i386__) || defined(_M_IX86) 992 # define AMQP_LITTLE_ENDIAN 993 #else 994 /* Don't define anything */ 995 #endif 996 997 #if defined(AMQP_LITTLE_ENDIAN) 998 999 enum DECLARE_XTOXLL(func) \ 1000 static inline ulong func##ll(ulong val) \ 1001 { \ 1002 union { \ 1003 ulong whole; \ 1004 uint halves[2]; \ 1005 } u; \ 1006 uint t; \ 1007 u.whole = val; \ 1008 t = u.halves[0]; \ 1009 u.halves[0] = func##l(u.halves[1]); \ 1010 u.halves[1] = func##l(t); \ 1011 return u.whole; \ 1012 } 1013 1014 #elif defined(AMQP_BIG_ENDIAN) 1015 1016 enum DECLARE_XTOXLL(func) \ 1017 static inline ulong func##ll(ulong val) \ 1018 { \ 1019 union { \ 1020 ulong whole; \ 1021 uint halves[2]; \ 1022 } u; \ 1023 u.whole = val; \ 1024 u.halves[0] = func##l(u.halves[0]); \ 1025 u.halves[1] = func##l(u.halves[1]); \ 1026 return u.whole; \ 1027 } 1028 1029 #else 1030 # error Endianness not known 1031 #endif 1032 1033 #ifndef HAVE_HTONLL 1034 DECLARE_XTOXLL(hton) 1035 DECLARE_XTOXLL(ntoh) 1036 #endif 1037 1038 DECLARE_CODEC_BASE_TYPE(8, (ubyte), (ubyte)) 1039 DECLARE_CODEC_BASE_TYPE(16, htons, ntohs) 1040 DECLARE_CODEC_BASE_TYPE(32, htonl, ntohl) 1041 DECLARE_CODEC_BASE_TYPE(64, htonll, ntohll) 1042 +/ 1043 1044 pragma(inline,true) 1045 int amqp_encode_bytes(amqp_bytes_t encoded, size_t *offset, amqp_bytes_t input) 1046 { 1047 size_t o = *offset; 1048 /* The memcpy below has undefined behavior if the input is NULL. It is valid 1049 * for a 0-length amqp_bytes_t to have .bytes == NULL. Thus we should check 1050 * before encoding. 1051 */ 1052 if (input.len == 0) { 1053 return 1; 1054 } 1055 if ((*offset = o + input.len) <= encoded.len) { 1056 memcpy(amqp_offset(encoded.bytes, o), input.bytes, input.len); 1057 return 1; 1058 } else { 1059 return 0; 1060 } 1061 } 1062 1063 pragma(inline,true) 1064 int amqp_decode_bytes(amqp_bytes_t encoded, size_t *offset, amqp_bytes_t *output, size_t len) 1065 { 1066 size_t o = *offset; 1067 if ((*offset = o + len) <= encoded.len) { 1068 output.bytes = amqp_offset(encoded.bytes, o); 1069 output.len = len; 1070 return 1; 1071 } else { 1072 return 0; 1073 } 1074 } 1075 1076 void amqp_abort(const(char)*fmt, ...); 1077 int amqp_bytes_equal(amqp_bytes_t r, amqp_bytes_t l); 1078 1079 pragma(inline,true) 1080 amqp_rpc_reply_t amqp_rpc_reply_error(amqp_status_enum status) 1081 { 1082 amqp_rpc_reply_t reply; 1083 reply.reply_type = ResponseType.libraryException; 1084 reply.library_error = status; 1085 return reply; 1086 } 1087 1088 int amqp_send_frame_inner(amqp_connection_state_t state, const amqp_frame_t *frame, int flags, amqp_time_t deadline); 1089 1090 1091 1092 enum amqp_hostname_validation_result 1093 { 1094 AMQP_HVR_MATCH_FOUND, 1095 AMQP_HVR_MATCH_NOT_FOUND, 1096 AMQP_HVR_NO_SAN_PRESENT, 1097 AMQP_HVR_MALFORMED_CERTIFICATE, 1098 AMQP_HVR_ERROR 1099 } 1100 version(OpenSSL) 1101 { 1102 amqp_hostname_validation_result amqp_ssl_validate_hostname(const(char)*hostname, const X509* server_cert); 1103 BIO_METHOD* amqp_openssl_bio(); 1104 } 1105 enum amqp_hostcheck_result 1106 { 1107 AMQP_HCR_NO_MATCH = 0, 1108 AMQP_HCR_MATCH = 1 1109 } 1110 amqp_hostcheck_result amqp_hostcheck(const(char)*match_pattern, const(char)*hostname); 1111 1112 1113 enum AMQP_PROTOCOL_VERSION_MAJOR=0; 1114 enum AMQP_PROTOCOL_VERSION_MINOR=9; 1115 enum AMQP_PROTOCOL_VERSION_REVISION=1; 1116 enum AMQP_PROTOCOL_PORT= 5672; 1117 enum AMQP_FRAME_METHOD=1; 1118 enum AMQP_FRAME_HEADER=2; 1119 enum AMQP_FRAME_BODY=3; 1120 enum AMQP_FRAME_HEARTBEAT=8; 1121 enum AMQP_FRAME_MIN_SIZE=4096; 1122 enum AMQP_FRAME_END=206; 1123 enum AMQP_REPLY_SUCCESS=200; 1124 enum AMQP_CONTENT_TOO_LARGE= 311; 1125 enum AMQP_NO_ROUTE= 312; 1126 enum AMQP_NO_CONSUMERS= 313; 1127 enum AMQP_ACCESS_REFUSED= 403; 1128 enum AMQP_NOT_FOUND= 404; 1129 enum AMQP_RESOURCE_LOCKED= 405; 1130 enum AMQP_PRECONDITION_FAILED= 406; 1131 enum AMQP_CONNECTION_FORCED=320; 1132 enum AMQP_INVALID_PATH=402; 1133 enum AMQP_FRAME_ERROR=501; 1134 enum AMQP_SYNTAX_ERROR=502; 1135 enum AMQP_COMMAND_INVALID=503; 1136 enum AMQP_CHANNEL_ERROR=504; 1137 enum AMQP_UNEXPECTED_FRAME=505; 1138 enum AMQP_RESOURCE_ERROR=506; 1139 enum AMQP_NOT_ALLOWED=530; 1140 enum AMQP_NOT_IMPLEMENTED=540; 1141 enum AMQP_INTERNAL_ERROR=541; 1142 1143 alias ReplySuccess = AMQP_REPLY_SUCCESS; 1144 1145 const(char)* amqp_constant_name(int constantNumber); 1146 amqp_boolean_t amqp_constant_is_hard_error(int constantNumber); 1147 const(char)* amqp_method_name(amqp_method_number_t methodNumber); 1148 amqp_boolean_t amqp_method_has_content(amqp_method_number_t methodNumber); 1149 int amqp_decode_method(amqp_method_number_t methodNumber, amqp_pool_t *pool, amqp_bytes_t encoded, void **decoded); 1150 int amqp_decode_properties(ushort class_id, amqp_pool_t *pool, amqp_bytes_t encoded, void **decoded); 1151 int amqp_encode_method(amqp_method_number_t methodNumber, void *decoded, amqp_bytes_t encoded); 1152 int amqp_encode_properties(ushort class_id, void *decoded, amqp_bytes_t encoded); 1153 enum amqp_method_number_t AMQP_CONNECTION_START_METHOD = 0x000A000A; 1154 1155 struct amqp_connection_start_t 1156 { 1157 ubyte version_major; /**< version-major */ 1158 ubyte version_minor; /**< version-minor */ 1159 amqp_table_t server_properties; /**< server-properties */ 1160 amqp_bytes_t mechanisms; /**< mechanisms */ 1161 amqp_bytes_t locales; /**< locales */ 1162 } 1163 1164 enum amqp_method_number_t AMQP_CONNECTION_START_OK_METHOD = 0x000A000B; 1165 struct amqp_connection_start_ok_t 1166 { 1167 amqp_table_t client_properties; /**< client-properties */ 1168 amqp_bytes_t mechanism; /**< mechanism */ 1169 amqp_bytes_t response; /**< response */ 1170 amqp_bytes_t locale; /**< locale */ 1171 } 1172 1173 enum amqp_method_number_t AMQP_CONNECTION_SECURE_METHOD= 0x000A0014; 1174 struct amqp_connection_secure_t 1175 { 1176 amqp_bytes_t challenge; /**< challenge */ 1177 } 1178 1179 enum amqp_method_number_t AMQP_CONNECTION_SECURE_OK_METHOD= 0x000A0015; 1180 struct amqp_connection_secure_ok_t 1181 { 1182 amqp_bytes_t response; /**< response */ 1183 } 1184 1185 enum amqp_method_number_t AMQP_CONNECTION_TUNE_METHOD = 0x000A001E; 1186 struct amqp_connection_tune_t 1187 { 1188 ushort channel_max; /**< channel-max */ 1189 uint frame_max; /**< frame-max */ 1190 ushort heartbeat; /**< heartbeat */ 1191 } 1192 1193 enum amqp_method_number_t AMQP_CONNECTION_TUNE_OK_METHOD= 0x000A001F; 1194 struct amqp_connection_tune_ok_t 1195 { 1196 ushort channel_max; /**< channel-max */ 1197 uint frame_max; /**< frame-max */ 1198 ushort heartbeat; /**< heartbeat */ 1199 } 1200 1201 enum amqp_method_number_tAMQP_CONNECTION_OPEN_METHOD= 0x000A0028; 1202 struct amqp_connection_open_t 1203 { 1204 amqp_bytes_t virtual_host; /**< virtual-host */ 1205 amqp_bytes_t capabilities; /**< capabilities */ 1206 amqp_boolean_t insist; /**< insist */ 1207 } 1208 1209 enum amqp_method_number_t AMQP_CONNECTION_OPEN_OK_METHOD = 0x000A0029; 1210 struct amqp_connection_open_ok_t 1211 { 1212 amqp_bytes_t known_hosts; /**< known-hosts */ 1213 } 1214 1215 enum amqp_method_number_t AMQP_CONNECTION_CLOSE_METHOD = 0x000A0032; 1216 struct amqp_connection_close_t 1217 { 1218 ushort reply_code; /**< reply-code */ 1219 amqp_bytes_t reply_text; /**< reply-text */ 1220 ushort class_id; /**< class-id */ 1221 ushort method_id; /**< method-id */ 1222 } 1223 1224 enum amqp_method_number_t AMQP_CONNECTION_CLOSE_OK_METHOD = 0x000A0033; 1225 struct amqp_connection_close_ok_t 1226 { 1227 char dummy; /**< Dummy field to avoid empty struct */ 1228 } 1229 1230 enum amqp_method_number_t AMQP_CONNECTION_BLOCKED_METHOD = 0x000A003C; 1231 struct amqp_connection_blocked_t 1232 { 1233 amqp_bytes_t reason; /**< reason */ 1234 } 1235 1236 enum amqp_method_number_t AMQP_CONNECTION_UNBLOCKED_METHOD = 0x000A003D; 1237 struct amqp_connection_unblocked_t 1238 { 1239 char dummy; /**< Dummy field to avoid empty struct */ 1240 } 1241 1242 enum amqp_method_number_t AMQP_CHANNEL_OPEN_METHOD = 0x0014000A; 1243 struct amqp_channel_open_t 1244 { 1245 amqp_bytes_t out_of_band; /**< out-of-band */ 1246 } 1247 1248 enum amqp_method_number_t AMQP_CHANNEL_OPEN_OK_METHOD = 0x0014000B; 1249 struct amqp_channel_open_ok_t 1250 { 1251 amqp_bytes_t channel_id; /**< channel-id */ 1252 } 1253 1254 enum amqp_method_number_t AMQP_CHANNEL_FLOW_METHOD = 0x00140014; 1255 struct amqp_channel_flow_t 1256 { 1257 amqp_boolean_t active; /**< active */ 1258 } 1259 1260 enum amqp_method_number_t AMQP_CHANNEL_FLOW_OK_METHOD = 0x00140015; 1261 struct amqp_channel_flow_ok_t 1262 { 1263 amqp_boolean_t active; /**< active */ 1264 } 1265 1266 enum amqp_method_number_t AMQP_CHANNEL_CLOSE_METHOD = 0x00140028; 1267 struct amqp_channel_close_t 1268 { 1269 ushort reply_code; /**< reply-code */ 1270 amqp_bytes_t reply_text; /**< reply-text */ 1271 ushort class_id; /**< class-id */ 1272 ushort method_id; /**< method-id */ 1273 } 1274 1275 enum amqp_method_number_t AMQP_CHANNEL_CLOSE_OK_METHOD = 0x00140029; 1276 struct amqp_channel_close_ok_t 1277 { 1278 char dummy; /**< Dummy field to avoid empty struct */ 1279 } 1280 1281 enum amqp_method_number_t AMQP_ACCESS_REQUEST_METHOD = 0x001E000A; 1282 struct amqp_access_request_t 1283 { 1284 amqp_bytes_t realm; /**< realm */ 1285 amqp_boolean_t exclusive; /**< exclusive */ 1286 amqp_boolean_t passive; /**< passive */ 1287 amqp_boolean_t active; /**< active */ 1288 amqp_boolean_t write; /**< write */ 1289 amqp_boolean_t read; /**< read */ 1290 } 1291 1292 enum amqp_method_number_t AMQP_ACCESS_REQUEST_OK_METHOD= 0x001E000B; 1293 struct amqp_access_request_ok_t 1294 { 1295 ushort ticket; /**< ticket */ 1296 } 1297 1298 enum amqp_method_number_t AMQP_EXCHANGE_DECLARE_METHOD = 0x0028000A; 1299 struct amqp_exchange_declare_t 1300 { 1301 ushort ticket; /**< ticket */ 1302 amqp_bytes_t exchange; /**< exchange */ 1303 amqp_bytes_t type; /**< type */ 1304 amqp_boolean_t passive; /**< passive */ 1305 amqp_boolean_t durable; /**< durable */ 1306 amqp_boolean_t auto_delete; /**< auto-delete */ 1307 amqp_boolean_t internal; /**< internal */ 1308 amqp_boolean_t nowait; /**< nowait */ 1309 amqp_table_t arguments; /**< arguments */ 1310 } 1311 1312 enum amqp_method_number_t AMQP_EXCHANGE_DECLARE_OK_METHOD = 0x0028000B; 1313 struct amqp_exchange_declare_ok_t 1314 { 1315 char dummy; /**< Dummy field to avoid empty struct */ 1316 } 1317 1318 enum amqp_method_number_t AMQP_EXCHANGE_DELETE_METHOD = 0x00280014; 1319 struct amqp_exchange_delete_t 1320 { 1321 ushort ticket; /**< ticket */ 1322 amqp_bytes_t exchange; /**< exchange */ 1323 amqp_boolean_t if_unused; /**< if-unused */ 1324 amqp_boolean_t nowait; /**< nowait */ 1325 } 1326 1327 enum amqp_method_number_t AMQP_EXCHANGE_DELETE_OK_METHOD = 0x00280015; 1328 struct amqp_exchange_delete_ok_t 1329 { 1330 char dummy; /**< Dummy field to avoid empty struct */ 1331 } 1332 1333 enum amqp_method_number_t AMQP_EXCHANGE_BIND_METHOD = 0x0028001E; 1334 struct amqp_exchange_bind_t 1335 { 1336 ushort ticket; /**< ticket */ 1337 amqp_bytes_t destination; /**< destination */ 1338 amqp_bytes_t source; /**< source */ 1339 amqp_bytes_t routing_key; /**< routing-key */ 1340 amqp_boolean_t nowait; /**< nowait */ 1341 amqp_table_t arguments; /**< arguments */ 1342 } 1343 1344 enum amqp_method_number_t AMQP_EXCHANGE_BIND_OK_METHOD = 0x0028001F; 1345 struct amqp_exchange_bind_ok_t 1346 { 1347 char dummy; /**< Dummy field to avoid empty struct */ 1348 } 1349 1350 enum amqp_method_number_t AMQP_EXCHANGE_UNBIND_METHOD = 0x00280028; 1351 struct amqp_exchange_unbind_t 1352 { 1353 ushort ticket; /**< ticket */ 1354 amqp_bytes_t destination; /**< destination */ 1355 amqp_bytes_t source; /**< source */ 1356 amqp_bytes_t routing_key; /**< routing-key */ 1357 amqp_boolean_t nowait; /**< nowait */ 1358 amqp_table_t arguments; /**< arguments */ 1359 } 1360 1361 enum amqp_method_number_t AMQP_EXCHANGE_UNBIND_OK_METHOD = 0x00280033; 1362 struct amqp_exchange_unbind_ok_t 1363 { 1364 char dummy; /**< Dummy field to avoid empty struct */ 1365 } 1366 1367 enum amqp_method_number_t AMQP_QUEUE_DECLARE_METHOD = 0x0032000A; 1368 struct amqp_queue_declare_t 1369 { 1370 ushort ticket; /**< ticket */ 1371 amqp_bytes_t queue; /**< queue */ 1372 amqp_boolean_t passive; /**< passive */ 1373 amqp_boolean_t durable; /**< durable */ 1374 amqp_boolean_t exclusive; /**< exclusive */ 1375 amqp_boolean_t auto_delete; /**< auto-delete */ 1376 amqp_boolean_t nowait; /**< nowait */ 1377 amqp_table_t arguments; /**< arguments */ 1378 } 1379 1380 enum amqp_method_number_t AMQP_QUEUE_DECLARE_OK_METHOD= 0x0032000B; 1381 struct amqp_queue_declare_ok_t 1382 { 1383 amqp_bytes_t queue; /**< queue */ 1384 uint message_count; /**< message-count */ 1385 uint consumer_count; /**< consumer-count */ 1386 } 1387 1388 enum amqp_method_number_t AMQP_QUEUE_BIND_METHOD = 0x00320014; 1389 struct amqp_queue_bind_t 1390 { 1391 ushort ticket; /**< ticket */ 1392 amqp_bytes_t queue; /**< queue */ 1393 amqp_bytes_t exchange; /**< exchange */ 1394 amqp_bytes_t routing_key; /**< routing-key */ 1395 amqp_boolean_t nowait; /**< nowait */ 1396 amqp_table_t arguments; /**< arguments */ 1397 } 1398 1399 enum amqp_method_number_t AMQP_QUEUE_BIND_OK_METHOD = 0x00320015; 1400 struct amqp_queue_bind_ok_t 1401 { 1402 char dummy; /**< Dummy field to avoid empty struct */ 1403 } 1404 1405 enum amqp_method_number_t AMQP_QUEUE_PURGE_METHOD =0x0032001E; 1406 struct amqp_queue_purge_t 1407 { 1408 ushort ticket; /**< ticket */ 1409 amqp_bytes_t queue; /**< queue */ 1410 amqp_boolean_t nowait; /**< nowait */ 1411 } 1412 1413 enum amqp_method_number_t AMQP_QUEUE_PURGE_OK_METHOD = 0x0032001F; 1414 struct amqp_queue_purge_ok_t 1415 { 1416 uint message_count; /**< message-count */ 1417 } 1418 1419 enum amqp_method_number_t AMQP_QUEUE_DELETE_METHOD = 0x00320028; 1420 struct amqp_queue_delete_t 1421 { 1422 ushort ticket; /**< ticket */ 1423 amqp_bytes_t queue; /**< queue */ 1424 amqp_boolean_t if_unused; /**< if-unused */ 1425 amqp_boolean_t if_empty; /**< if-empty */ 1426 amqp_boolean_t nowait; /**< nowait */ 1427 } 1428 1429 enum amqp_method_number_t AMQP_QUEUE_DELETE_OK_METHOD = 0x00320029; 1430 struct amqp_queue_delete_ok_t{ 1431 uint message_count; /**< message-count */ 1432 } 1433 1434 enum amqp_method_number_t AMQP_QUEUE_UNBIND_METHOD = 0x00320032; 1435 struct amqp_queue_unbind_t 1436 { 1437 ushort ticket; /**< ticket */ 1438 amqp_bytes_t queue; /**< queue */ 1439 amqp_bytes_t exchange; /**< exchange */ 1440 amqp_bytes_t routing_key; /**< routing-key */ 1441 amqp_table_t arguments; /**< arguments */ 1442 } 1443 1444 enum amqp_method_number_t AMQP_QUEUE_UNBIND_OK_METHOD = 0x00320033; 1445 struct amqp_queue_unbind_ok_t 1446 { 1447 char dummy; /**< Dummy field to avoid empty struct */ 1448 } 1449 1450 enum amqp_method_number_t AMQP_BASIC_QOS_METHOD = 0x003C000A; 1451 struct amqp_basic_qos_t 1452 { 1453 uint prefetch_size; /**< prefetch-size */ 1454 ushort prefetch_count; /**< prefetch-count */ 1455 amqp_boolean_t global; /**< global */ 1456 } 1457 1458 enum amqp_method_number_t AMQP_BASIC_QOS_OK_METHOD = 0x003C000B; 1459 struct amqp_basic_qos_ok_t 1460 { 1461 char dummy; /**< Dummy field to avoid empty struct */ 1462 } 1463 1464 enum amqp_method_number_t AMQP_BASIC_CONSUME_METHOD = 0x003C0014; 1465 struct amqp_basic_consume_t 1466 { 1467 ushort ticket; /**< ticket */ 1468 amqp_bytes_t queue; /**< queue */ 1469 amqp_bytes_t consumer_tag; /**< consumer-tag */ 1470 amqp_boolean_t no_local; /**< no-local */ 1471 amqp_boolean_t no_ack; /**< no-ack */ 1472 amqp_boolean_t exclusive; /**< exclusive */ 1473 amqp_boolean_t nowait; /**< nowait */ 1474 amqp_table_t arguments; /**< arguments */ 1475 } 1476 1477 enum amqp_method_number_t AMQP_BASIC_CONSUME_OK_METHOD = 0x003C0015; 1478 struct amqp_basic_consume_ok_t 1479 { 1480 amqp_bytes_t consumer_tag; /**< consumer-tag */ 1481 } 1482 1483 enum amqp_method_number_t AMQP_BASIC_CANCEL_METHOD= 0x003C001E; 1484 struct amqp_basic_cancel_t 1485 { 1486 amqp_bytes_t consumer_tag; /**< consumer-tag */ 1487 amqp_boolean_t nowait; /**< nowait */ 1488 } 1489 1490 enum amqp_method_number_t AMQP_BASIC_CANCEL_OK_METHOD = 0x003C001F; 1491 struct amqp_basic_cancel_ok_t 1492 { 1493 amqp_bytes_t consumer_tag; /**< consumer-tag */ 1494 } 1495 1496 enum amqp_method_number_t AMQP_BASIC_PUBLISH_METHOD = 0x003C0028; 1497 struct amqp_basic_publish_t 1498 { 1499 ushort ticket; /**< ticket */ 1500 amqp_bytes_t exchange; /**< exchange */ 1501 amqp_bytes_t routing_key; /**< routing-key */ 1502 amqp_boolean_t mandatory; /**< mandatory */ 1503 amqp_boolean_t immediate; /**< immediate */ 1504 } 1505 1506 enum amqp_method_number_t AMQP_BASIC_RETURN_METHOD = 0x003C0032; 1507 struct amqp_basic_return_t 1508 { 1509 ushort reply_code; /**< reply-code */ 1510 amqp_bytes_t reply_text; /**< reply-text */ 1511 amqp_bytes_t exchange; /**< exchange */ 1512 amqp_bytes_t routing_key; /**< routing-key */ 1513 } 1514 1515 enum amqp_method_number_t AMQP_BASIC_DELIVER_METHOD = 0x003C003C; 1516 struct amqp_basic_deliver_t 1517 { 1518 amqp_bytes_t consumer_tag; /**< consumer-tag */ 1519 ulong delivery_tag; /**< delivery-tag */ 1520 amqp_boolean_t redelivered; /**< redelivered */ 1521 amqp_bytes_t exchange; /**< exchange */ 1522 amqp_bytes_t routing_key; /**< routing-key */ 1523 } 1524 1525 enum amqp_method_number_t AMQP_BASIC_GET_METHOD = 0x003C0046; 1526 struct amqp_basic_get_t 1527 { 1528 ushort ticket; /**< ticket */ 1529 amqp_bytes_t queue; /**< queue */ 1530 amqp_boolean_t no_ack; /**< no-ack */ 1531 } 1532 1533 enum amqp_method_number_t AMQP_BASIC_GET_OK_METHOD = 0x003C0047; 1534 struct amqp_basic_get_ok_t 1535 { 1536 ulong delivery_tag; /**< delivery-tag */ 1537 amqp_boolean_t redelivered; /**< redelivered */ 1538 amqp_bytes_t exchange; /**< exchange */ 1539 amqp_bytes_t routing_key; /**< routing-key */ 1540 uint message_count; /**< message-count */ 1541 } 1542 1543 enum amqp_method_number_t AMQP_BASIC_GET_EMPTY_METHOD = 0x003C0048; 1544 struct amqp_basic_get_empty_t 1545 { 1546 amqp_bytes_t cluster_id; /**< cluster-id */ 1547 } 1548 1549 enum amqp_method_number_t AMQP_BASIC_ACK_METHOD = 0x003C0050; 1550 struct amqp_basic_ack_t 1551 { 1552 ulong delivery_tag; /**< delivery-tag */ 1553 amqp_boolean_t multiple; /**< multiple */ 1554 } 1555 1556 enum amqp_method_number_t AMQP_BASIC_REJECT_METHOD = 0x003C005A; 1557 struct amqp_basic_reject_t 1558 { 1559 ulong delivery_tag; /**< delivery-tag */ 1560 amqp_boolean_t requeue; /**< requeue */ 1561 } 1562 1563 enum amqp_method_number_t AMQP_BASIC_RECOVER_ASYNC_METHOD = 0x003C0064; 1564 struct amqp_basic_recover_async_t 1565 { 1566 amqp_boolean_t requeue; /**< requeue */ 1567 } 1568 1569 enum amqp_method_number_t AMQP_BASIC_RECOVER_METHOD = 0x003C006E; 1570 struct amqp_basic_recover_t 1571 { 1572 amqp_boolean_t requeue; /**< requeue */ 1573 } 1574 1575 enum amqp_method_number_t AMQP_BASIC_RECOVER_OK_METHOD = 0x003C006F; 1576 struct amqp_basic_recover_ok_t 1577 { 1578 char dummy; /**< Dummy field to avoid empty struct */ 1579 } 1580 1581 enum amqp_method_number_t AMQP_BASIC_NACK_METHOD = 0x003C0078; 1582 struct amqp_basic_nack_t 1583 { 1584 ulong delivery_tag; /**< delivery-tag */ 1585 amqp_boolean_t multiple; /**< multiple */ 1586 amqp_boolean_t requeue; /**< requeue */ 1587 } 1588 1589 enum amqp_method_number_t AMQP_TX_SELECT_METHOD = 0x005A000A; 1590 struct amqp_tx_select_t 1591 { 1592 char dummy; /**< Dummy field to avoid empty struct */ 1593 } 1594 1595 enum amqp_method_number_t AMQP_TX_SELECT_OK_METHOD= 0x005A000B; 1596 struct amqp_tx_select_ok_t 1597 { 1598 char dummy; /**< Dummy field to avoid empty struct */ 1599 } 1600 1601 enum amqp_method_number_t AMQP_TX_COMMIT_METHOD = 0x005A0014; 1602 struct amqp_tx_commit_t 1603 { 1604 char dummy; /**< Dummy field to avoid empty struct */ 1605 } 1606 1607 enum amqp_method_number_t AMQP_TX_COMMIT_OK_METHOD= 0x005A0015; 1608 struct amqp_tx_commit_ok_t 1609 { 1610 char dummy; /**< Dummy field to avoid empty struct */ 1611 } 1612 1613 enum amqp_method_number_t AMQP_TX_ROLLBACK_METHOD = 0x005A001E; 1614 struct amqp_tx_rollback_t 1615 { 1616 char dummy; /**< Dummy field to avoid empty struct */ 1617 } 1618 1619 enum amqp_method_number_t AMQP_TX_ROLLBACK_OK_METHOD= 0x005A001F; 1620 struct amqp_tx_rollback_ok_t 1621 { 1622 char dummy; /**< Dummy field to avoid empty struct */ 1623 } 1624 1625 enum amqp_method_number_t AMQP_CONFIRM_SELECT_METHOD= 0x0055000A; 1626 struct amqp_confirm_select_t 1627 { 1628 amqp_boolean_t nowait; /**< nowait */ 1629 } 1630 1631 enum amqp_method_number_t AMQP_CONFIRM_SELECT_OK_METHOD= 0x0055000B; 1632 struct amqp_confirm_select_ok_t 1633 { 1634 char dummy; /**< Dummy field to avoid empty struct */ 1635 } 1636 1637 /* Class property records. */ 1638 enum AMQP_CONNECTION_CLASS = 0x000A; 1639 /** connection class properties */ 1640 struct amqp_connection_properties_t 1641 { 1642 amqp_flags_t _flags; /**< bit-mask of set fields */ 1643 char dummy; /**< Dummy field to avoid empty struct */ 1644 } 1645 1646 enum AMQP_CHANNEL_CLASS = 0x0014; 1647 struct amqp_channel_properties_t 1648 { 1649 amqp_flags_t _flags; /**< bit-mask of set fields */ 1650 char dummy; /**< Dummy field to avoid empty struct */ 1651 } 1652 1653 enum AMQP_ACCESS_CLASS = 0x001E; 1654 struct amqp_access_properties_t_ 1655 { 1656 amqp_flags_t _flags; /**< bit-mask of set fields */ 1657 char dummy; /**< Dummy field to avoid empty struct */ 1658 } 1659 1660 enum AMQP_EXCHANGE_CLASS = 0x0028; 1661 struct amqp_exchange_properties_t 1662 { 1663 amqp_flags_t _flags; /**< bit-mask of set fields */ 1664 char dummy; /**< Dummy field to avoid empty struct */ 1665 } 1666 1667 enum AMQP_QUEUE_CLASS = 0x0032; 1668 struct amqp_queue_properties_t 1669 { 1670 amqp_flags_t _flags; /**< bit-mask of set fields */ 1671 char dummy; /**< Dummy field to avoid empty struct */ 1672 } 1673 1674 enum AMQP_BASIC_CLASS = 0x003C; 1675 enum AMQP_BASIC_CONTENT_TYPE_FLAG =(1 << 15); /**< basic.content-type property flag */ 1676 enum AMQP_BASIC_CONTENT_ENCODING_FLAG= (1 << 14); /**< basic.content-encoding property flag */ 1677 enum AMQP_BASIC_HEADERS_FLAG=(1 << 13); /**< basic.headers property flag */ 1678 enum AMQP_BASIC_DELIVERY_MODE_FLAG=(1 << 12); /**< basic.delivery-mode property flag */ 1679 enum AMQP_BASIC_PRIORITY_FLAG=(1 << 11); /**< basic.priority property flag */ 1680 enum AMQP_BASIC_CORRELATION_ID_FLAG=(1 << 10); /**< basic.correlation-id property flag */ 1681 enum AMQP_BASIC_REPLY_TO_FLAG=(1 << 9); /**< basic.reply-to property flag */ 1682 enum AMQP_BASIC_EXPIRATION_FLAG=(1 << 8); /**< basic.expiration property flag */ 1683 enum AMQP_BASIC_MESSAGE_ID_FLAG=(1 << 7); /**< basic.message-id property flag */ 1684 enum AMQP_BASIC_TIMESTAMP_FLAG=(1 << 6); /**< basic.timestamp property flag */ 1685 enum AMQP_BASIC_TYPE_FLAG=(1 << 5); /**< basic.type property flag */ 1686 enum AMQP_BASIC_USER_ID_FLAG=(1 << 4); /**< basic.user-id property flag */ 1687 enum AMQP_BASIC_APP_ID_FLAG=(1 << 3); /**< basic.app-id property flag */ 1688 enum AMQP_BASIC_CLUSTER_ID_FLAG=(1 << 2); /**< basic.cluster-id property flag */ 1689 1690 /** basic class properties */ 1691 struct amqp_basic_properties_t 1692 { 1693 amqp_flags_t _flags; /**< bit-mask of set fields */ 1694 amqp_bytes_t content_type; /**< content-type */ 1695 amqp_bytes_t content_encoding; /**< content-encoding */ 1696 amqp_table_t headers; /**< headers */ 1697 ubyte delivery_mode; /**< delivery-mode */ 1698 ubyte priority; /**< priority */ 1699 amqp_bytes_t correlation_id; /**< correlation-id */ 1700 amqp_bytes_t reply_to; /**< reply-to */ 1701 amqp_bytes_t expiration; /**< expiration */ 1702 amqp_bytes_t message_id; /**< message-id */ 1703 ulong timestamp; /**< timestamp */ 1704 amqp_bytes_t type; /**< type */ 1705 amqp_bytes_t user_id; /**< user-id */ 1706 amqp_bytes_t app_id; /**< app-id */ 1707 amqp_bytes_t cluster_id; /**< cluster-id */ 1708 } 1709 1710 enum AMQP_TX_CLASS = 0x005A; 1711 /** tx class properties */ 1712 struct amqp_tx_properties_t 1713 { 1714 amqp_flags_t _flags; /**< bit-mask of set fields */ 1715 char dummy; /**< Dummy field to avoid empty struct */ 1716 } 1717 1718 enum AMQP_CONFIRM_CLASS = 0x0055; 1719 struct amqp_confirm_properties_t 1720 { 1721 amqp_flags_t _flags; /**< bit-mask of set fields */ 1722 char dummy; /**< Dummy field to avoid empty struct */ 1723 } 1724 1725 amqp_channel_open_ok_t * amqp_channel_open(amqp_connection_state_t state, amqp_channel_t channel); 1726 amqp_channel_flow_ok_t * amqp_channel_flow(amqp_connection_state_t state, amqp_channel_t channel, amqp_boolean_t active); 1727 amqp_exchange_declare_ok_t* amqp_exchange_declare(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t exchange, amqp_bytes_t type, amqp_boolean_t passive, amqp_boolean_t durable, amqp_boolean_t auto_delete, amqp_boolean_t internal, amqp_table_t arguments); 1728 amqp_exchange_delete_ok_t * amqp_exchange_delete(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t exchange, amqp_boolean_t if_unused); 1729 amqp_exchange_bind_ok_t * amqp_exchange_bind(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t destination, amqp_bytes_t source, amqp_bytes_t routing_key, amqp_table_t arguments); 1730 amqp_exchange_unbind_ok_t * amqp_exchange_unbind(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t destination, amqp_bytes_t source, amqp_bytes_t routing_key, amqp_table_t arguments); 1731 amqp_queue_declare_ok_t * amqp_queue_declare(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t queue, amqp_boolean_t passive, amqp_boolean_t durable, amqp_boolean_t exclusive, amqp_boolean_t auto_delete, amqp_table_t arguments); 1732 amqp_queue_bind_ok_t * amqp_queue_bind(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t queue, amqp_bytes_t exchange, amqp_bytes_t routing_key, amqp_table_t arguments); 1733 amqp_queue_purge_ok_t * amqp_queue_purge(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t queue); 1734 amqp_queue_delete_ok_t * amqp_queue_delete(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t queue, amqp_boolean_t if_unused, amqp_boolean_t if_empty); 1735 amqp_queue_unbind_ok_t * amqp_queue_unbind(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t queue, amqp_bytes_t exchange, amqp_bytes_t routing_key, amqp_table_t arguments); 1736 amqp_basic_qos_ok_t * amqp_basic_qos(amqp_connection_state_t state, amqp_channel_t channel, uint prefetch_size, ushort prefetch_count, amqp_boolean_t global); 1737 amqp_basic_consume_ok_t * amqp_basic_consume(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t queue, amqp_bytes_t consumer_tag, amqp_boolean_t no_local, amqp_boolean_t no_ack, amqp_boolean_t exclusive, amqp_table_t arguments); 1738 amqp_basic_cancel_ok_t * amqp_basic_cancel(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t consumer_tag); 1739 amqp_basic_recover_ok_t * amqp_basic_recover(amqp_connection_state_t state, amqp_channel_t channel, amqp_boolean_t requeue); 1740 amqp_tx_select_ok_t * amqp_tx_select(amqp_connection_state_t state, amqp_channel_t channel); 1741 amqp_tx_commit_ok_t * amqp_tx_commit(amqp_connection_state_t state, amqp_channel_t channel); 1742 amqp_tx_rollback_ok_t * amqp_tx_rollback(amqp_connection_state_t state, amqp_channel_t channel); 1743 amqp_confirm_select_ok_t * amqp_confirm_select(amqp_connection_state_t state, amqp_channel_t channel); 1744 1745 //typedef SRWLOCK pthread_mutex_t; 1746 //enum PTHREAD_MUTEX_INITIALIZER SRWLOCK_INIT; 1747 DWORD pthread_self(); 1748 int pthread_mutex_init(pthread_mutex_t *, void *attr); 1749 int pthread_mutex_lock(pthread_mutex_t *); 1750 int pthread_mutex_unlock(pthread_mutex_t *); 1751 1752 1753 amqp_bytes_t amqp_string(string s) 1754 { 1755 import std.string: toStringz; 1756 return s.toStringz.amqp_cstring_bytes; 1757 } 1758 1759 amqp_bytes_t asRabbit(ubyte[] buf) 1760 { 1761 amqp_bytes_t ret; 1762 ret.len = buf.length; 1763 ret.bytes = cast(void*) buf.ptr; 1764 return ret; 1765 } 1766 1767