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