diff -Nru librabbitmq-0.7.1/appveyor.yml librabbitmq-0.9.0-0.1/appveyor.yml --- librabbitmq-0.7.1/appveyor.yml 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/appveyor.yml 2019-10-20 10:14:51.000000000 +0000 @@ -1,13 +1,33 @@ # appveyor configuration version: '{build}' +# Limit history cloned. This matches what travis-CI currently does. +clone_depth: 50 + environment: matrix: - GENERATOR: Visual Studio 12 Win64 + BITS: 64 - GENERATOR: Visual Studio 12 + BITS: 32 + +cache: + - c:\deps -> appveyor.yml + +# borrowed from https://github.com/FreeTDS/freetds +install: + # xidel (xpath command line tool) + - appveyor DownloadFile "https://downloads.sourceforge.net/project/videlibri/Xidel/Xidel 0.9.6/xidel-0.9.6.win32.zip" + - 7z x xidel-0.9.6.win32.zip xidel.exe + # detect version of Windows OpenSSL binaries published by the Shining Light Productions crew + - xidel https://slproweb.com/products/Win32OpenSSL.html --extract "(//td/a[starts-with(@href, '/download') and starts-with(text(), 'Win32 OpenSSL') and ends-with(text(), 'Light')])[1]/translate(substring-before(substring-after(text(), 'Win32 OpenSSL v'), ' Light'), '.', '_')" > openssl_ver.txt + - set /P OPENSSL_VER=< openssl_ver.txt + # OpenSSL + - appveyor DownloadFile https://slproweb.com/download/Win%BITS%OpenSSL-%OPENSSL_VER%.exe + - "Win%BITS%OpenSSL-%OPENSSL_VER%.exe /SP- /SILENT /SUPPRESSMSGBOXES /NORESTART" before_build: - - cmake -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_TESTS=ON -DENABLE_SSL_SUPPORT=False -G"%GENERATOR%" . + - cmake -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_TESTS=ON -DENABLE_SSL_SUPPORT=True -G"%GENERATOR%" . build: project: ALL_BUILD.vcxproj diff -Nru librabbitmq-0.7.1/.astyle librabbitmq-0.9.0-0.1/.astyle --- librabbitmq-0.7.1/.astyle 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.astyle 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ ---style=1tbs ---indent=spaces=2 ---indent-preprocessor ---align-pointer=name diff -Nru librabbitmq-0.7.1/ChangeLog.md librabbitmq-0.9.0-0.1/ChangeLog.md --- librabbitmq-0.7.1/ChangeLog.md 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/ChangeLog.md 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,68 @@ # Change Log +## v0.9.0 - 2018-05-08 +### Added: +- amqp-publish: added support for specifying headers via the -H flag +- Add support for specifying timeout for amqp_login calls via + amqp_set_handshake_timeout +- Add support for specifying timeouts in RPC-style AMQP methods via + amqp_set_rpc_timeout +- Add define for `AMQP_DEFAULT_VHOST` +- Support for SSL SNI +- Support for OpenSSL v1.1.0 + +### Changed: +- rabbitmq-c now requires Windows Vista or better +- rabbitmq-c enables TCP keep-alive by default on platforms that support it +- dropped support for compiling rabbitmq-c without threading support +- OpenSSL is no longer un-intialized automatically by default. OpenSSL can be + explicitly initialized by calling amqp_initialize_ssl_library and + uninitialized by calling amqp_uninitialize_ssl_library. + +### Fixed: +- Correct bugs in processing of --url flag in tools (#364). +- Improve documentation on AMQP_SASL_METHOD_EXTERNAL (#349) +- Improve support for compiling under mingw-w64 +- Better support for handing SIGPIPE on Linux over SSL (#401) +- Improve publish performance on Linux by not specifying MSG_MORE on last part + of message. +- Fix connection logic where multiple hostnames won't be tried if connection to + doesn't fail immediately (#430) + +### Removed: +- autotools build system has been removed +- many duplicate amqps_* examples, they did not add a lot of value + + +## v0.8.0 - 2016-04-09 +### Added: +- SSL: peer certificate and hostname validation can now be controlled separately + using `amqp_ssl_socket_set_verify_peer` and + `amqp_ssl_socket_set_verify_hostname`. +- SSL: the desire SSL version range can now be specified using the + `amqp_ssl_socket_set_ssl_versions` function. +- Add flags to SSL examples on controlling hostname verification. + +### Changed: +- SSL: SSLv2, and SSLv3 have been disabled by default. +- SSL: OpenSSL hostname validation has been improved. +- Win32 debug information is built with /Z7 on MSVC to embed debug info instead + of using a .pdb + +### Fixed: +- Connection failure results in hang on Win32 (#297, #346) +- Rabbitmq-c may block when attempting to close an SSL socket (#313) +- amqp_parse_url does not correctly initialize default parameters (#319) +- x509 objects are leaked in verify_hostname (#323) +- TCP_NOPUSH doesn't work under cygwin (#335) + +### Deprecated +- SSL: `amqp_ssl_socket_set_verify` is being replaced by + `amqp_ssl_socket_set_verify_peer` and `amqp_ssl_socket_set_verify_hostname`. + +### Removed: +- OpenVMS build system and related files. +- Unmaintained PolarSSL, CyaSSL, and gnuTLS SSL backends + ## Changes since v0.7.0 (a.k.a., v0.7.1) - `41fa9df` Autoconf: add missing files in build system - `ef73c06` Win32: Use WSAEWOULDBLOCK instead of EWOULDBLOCK on Win32 diff -Nru librabbitmq-0.7.1/cmake/CMakePushCheckState.cmake librabbitmq-0.9.0-0.1/cmake/CMakePushCheckState.cmake --- librabbitmq-0.7.1/cmake/CMakePushCheckState.cmake 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/cmake/CMakePushCheckState.cmake 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -# This module defines two macros: -# CMAKE_PUSH_CHECK_STATE() -# and -# CMAKE_POP_CHECK_STATE() -# These two macros can be used to save and restore the state of the variables -# CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_LIBRARIES -# and CMAKE_REQUIRED_INCLUDES used by the various Check-files coming with CMake, -# like e.g. check_function_exists() etc. -# The variable contents are pushed on a stack, pushing multiple times is supported. -# This is useful e.g. when executing such tests in a Find-module, where they have to be set, -# but after the Find-module has been executed they should have the same value -# as they had before. -# -# Usage: -# cmake_push_check_state() -# set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF) -# check_function_exists(...) -# cmake_pop_check_state() - -#============================================================================= -# Copyright 2006-2011 Alexander Neundorf, -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the names of Kitware, Inc., the Insight Software Consortium, -# nor the names of their contributors may be used to endorse or promote -# products derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# ------------------------------------------------------------------------------ -# -# The above copyright and license notice applies to distributions of -# CMake in source and binary form. Some source files contain additional -# notices of original copyright by their contributors; see each source -# for details. Third-party software packages supplied with CMake under -# compatible licenses provide their own copyright notices documented in -# corresponding subdirectories. -# -# ------------------------------------------------------------------------------ -# -# CMake was initially developed by Kitware with the following sponsorship: -# -# * National Library of Medicine at the National Institutes of Health -# as part of the Insight Segmentation and Registration Toolkit (ITK). -# -# * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel -# Visualization Initiative. -# -# * National Alliance for Medical Image Computing (NAMIC) is funded by the -# National Institutes of Health through the NIH Roadmap for Medical Research, -# Grant U54 EB005149. -# -# * Kitware, Inc. - -macro(CMAKE_PUSH_CHECK_STATE) - - if(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER) - set(_CMAKE_PUSH_CHECK_STATE_COUNTER 0) - endif() - - math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1") - - set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES}) - set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) - set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) - set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) -endmacro() - -macro(CMAKE_POP_CHECK_STATE) - -# don't pop more than we pushed - if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0") - - set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - - math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") - endif() - -endmacro() diff -Nru librabbitmq-0.7.1/cmake/config.h.in librabbitmq-0.9.0-0.1/cmake/config.h.in --- librabbitmq-0.7.1/cmake/config.h.in 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/cmake/config.h.in 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ #ifndef CONFIG_H #define CONFIG_H @@ -6,8 +5,6 @@ # define inline ${C_INLINE_KEYWORD} #endif -#cmakedefine HAVE_HTONLL - #cmakedefine HAVE_SELECT #cmakedefine HAVE_POLL diff -Nru librabbitmq-0.7.1/cmake/FindcyaSSL.cmake librabbitmq-0.9.0-0.1/cmake/FindcyaSSL.cmake --- librabbitmq-0.7.1/cmake/FindcyaSSL.cmake 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/cmake/FindcyaSSL.cmake 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -# - Try to find the cyaSSL SSL Library -# The module will set the following variables -# -# CYASSL_FOUND - System has popt -# CYASSL_INCLUDE_DIR - The popt include directory -# CYASSL_LIBRARIES - The libraries needed to use popt - -# Find the include directories -FIND_PATH(CYASSL_INCLUDE_DIR - NAMES cyassl/ssl.h - DOC "Path containing the cyassl/ssl.h include file" - ) - -FIND_LIBRARY(CYASSL_LIBRARIES - NAMES cyassl - DOC "cyassl library path" - ) - -include(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(CYASSL - REQUIRED_VARS CYASSL_INCLUDE_DIR CYASSL_LIBRARIES - ) diff -Nru librabbitmq-0.7.1/cmake/FindPolarSSL.cmake librabbitmq-0.9.0-0.1/cmake/FindPolarSSL.cmake --- librabbitmq-0.7.1/cmake/FindPolarSSL.cmake 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/cmake/FindPolarSSL.cmake 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -# - Try to find the PolarSSL SSL Library -# The module will set the following variables -# -# POLARSSL_FOUND - System has popt -# POLARSSL_INCLUDE_DIR - The popt include directory -# POLARSSL_LIBRARIES - The libraries needed to use popt - -# Find the include directories -FIND_PATH(POLARSSL_INCLUDE_DIR - NAMES polarssl/ssl.h - DOC "Path containing the polarssl/ssl.h include file" - ) - -FIND_LIBRARY(POLARSSL_LIBRARIES - NAMES polarssl - DOC "polarssl library path" - ) - -include(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(POLARSSL - REQUIRED_VARS POLARSSL_INCLUDE_DIR POLARSSL_LIBRARIES - ) diff -Nru librabbitmq-0.7.1/cmake/FindPOPT.cmake librabbitmq-0.9.0-0.1/cmake/FindPOPT.cmake --- librabbitmq-0.7.1/cmake/FindPOPT.cmake 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/cmake/FindPOPT.cmake 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -# vim:set ts=2 sw=2 sts=2 et: # - Try to find the popt options processing library # The module will set the following variables # diff -Nru librabbitmq-0.7.1/cmake/FindXmlTo.cmake librabbitmq-0.9.0-0.1/cmake/FindXmlTo.cmake --- librabbitmq-0.7.1/cmake/FindXmlTo.cmake 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/cmake/FindXmlTo.cmake 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -# vim:set ts=2 sw=2 sts=2 et: # - Convert XML docBook files to various formats # This will convert XML docBook files to various formats like: # man html txt dvi ps pdf diff -Nru librabbitmq-0.7.1/cmake/GNUInstallDirs.cmake librabbitmq-0.9.0-0.1/cmake/GNUInstallDirs.cmake --- librabbitmq-0.7.1/cmake/GNUInstallDirs.cmake 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/cmake/GNUInstallDirs.cmake 1970-01-01 00:00:00.000000000 +0000 @@ -1,205 +0,0 @@ -#.rst: -# GNUInstallDirs -# -------------- -# -# Define GNU standard installation directories -# -# Provides install directory variables as defined for GNU software: -# -# :: -# -# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html -# -# Inclusion of this module defines the following variables: -# -# :: -# -# CMAKE_INSTALL_ - destination for files of a given type -# CMAKE_INSTALL_FULL_ - corresponding absolute path -# -# where is one of: -# -# :: -# -# BINDIR - user executables (bin) -# SBINDIR - system admin executables (sbin) -# LIBEXECDIR - program executables (libexec) -# SYSCONFDIR - read-only single-machine data (etc) -# SHAREDSTATEDIR - modifiable architecture-independent data (com) -# LOCALSTATEDIR - modifiable single-machine data (var) -# LIBDIR - object code libraries (lib or lib64 or lib/ on Debian) -# INCLUDEDIR - C header files (include) -# OLDINCLUDEDIR - C header files for non-gcc (/usr/include) -# DATAROOTDIR - read-only architecture-independent data root (share) -# DATADIR - read-only architecture-independent data (DATAROOTDIR) -# INFODIR - info documentation (DATAROOTDIR/info) -# LOCALEDIR - locale-dependent data (DATAROOTDIR/locale) -# MANDIR - man documentation (DATAROOTDIR/man) -# DOCDIR - documentation root (DATAROOTDIR/doc/PROJECT_NAME) -# -# Each CMAKE_INSTALL_ value may be passed to the DESTINATION -# options of install() commands for the corresponding file type. If the -# includer does not define a value the above-shown default will be used -# and the value will appear in the cache for editing by the user. Each -# CMAKE_INSTALL_FULL_ value contains an absolute path constructed -# from the corresponding destination by prepending (if necessary) the -# value of CMAKE_INSTALL_PREFIX. - -#============================================================================= -# Copyright 2011 Nikita Krupen'ko -# Copyright 2011 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# Installation directories -# -if(NOT DEFINED CMAKE_INSTALL_BINDIR) - set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)") -endif() - -if(NOT DEFINED CMAKE_INSTALL_SBINDIR) - set(CMAKE_INSTALL_SBINDIR "sbin" CACHE PATH "system admin executables (sbin)") -endif() - -if(NOT DEFINED CMAKE_INSTALL_LIBEXECDIR) - set(CMAKE_INSTALL_LIBEXECDIR "libexec" CACHE PATH "program executables (libexec)") -endif() - -if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR) - set(CMAKE_INSTALL_SYSCONFDIR "etc" CACHE PATH "read-only single-machine data (etc)") -endif() - -if(NOT DEFINED CMAKE_INSTALL_SHAREDSTATEDIR) - set(CMAKE_INSTALL_SHAREDSTATEDIR "com" CACHE PATH "modifiable architecture-independent data (com)") -endif() - -if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR) - set(CMAKE_INSTALL_LOCALSTATEDIR "var" CACHE PATH "modifiable single-machine data (var)") -endif() - -if(NOT DEFINED CMAKE_INSTALL_LIBDIR) - set(_LIBDIR_DEFAULT "lib") - # Override this default 'lib' with 'lib64' iff: - # - we are on Linux system but NOT cross-compiling - # - we are NOT on debian - # - we are on a 64 bits system - # reason is: amd64 ABI: http://www.x86-64.org/documentation/abi.pdf - # For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if - # CMAKE_LIBRARY_ARCHITECTURE is set (which contains e.g. "i386-linux-gnu" - # See http://wiki.debian.org/Multiarch - if(CMAKE_SYSTEM_NAME MATCHES "Linux" - AND NOT CMAKE_CROSSCOMPILING) - if (EXISTS "/etc/debian_version") # is this a debian system ? - if(CMAKE_LIBRARY_ARCHITECTURE) - set(_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}") - endif() - else() # not debian, rely on CMAKE_SIZEOF_VOID_P: - if(NOT DEFINED CMAKE_SIZEOF_VOID_P) - message(AUTHOR_WARNING - "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. " - "Please enable at least one language before including GNUInstallDirs.") - else() - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - set(_LIBDIR_DEFAULT "lib64") - endif() - endif() - endif() - endif() - set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})") -endif() - -if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR) - set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C header files (include)") -endif() - -if(NOT DEFINED CMAKE_INSTALL_OLDINCLUDEDIR) - set(CMAKE_INSTALL_OLDINCLUDEDIR "/usr/include" CACHE PATH "C header files for non-gcc (/usr/include)") -endif() - -if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR) - set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "read-only architecture-independent data root (share)") -endif() - -#----------------------------------------------------------------------------- -# Values whose defaults are relative to DATAROOTDIR. Store empty values in -# the cache and store the defaults in local variables if the cache values are -# not set explicitly. This auto-updates the defaults as DATAROOTDIR changes. - -if(NOT CMAKE_INSTALL_DATADIR) - set(CMAKE_INSTALL_DATADIR "" CACHE PATH "read-only architecture-independent data (DATAROOTDIR)") - set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}") -endif() - -if(NOT CMAKE_INSTALL_INFODIR) - set(CMAKE_INSTALL_INFODIR "" CACHE PATH "info documentation (DATAROOTDIR/info)") - set(CMAKE_INSTALL_INFODIR "${CMAKE_INSTALL_DATAROOTDIR}/info") -endif() - -if(NOT CMAKE_INSTALL_LOCALEDIR) - set(CMAKE_INSTALL_LOCALEDIR "" CACHE PATH "locale-dependent data (DATAROOTDIR/locale)") - set(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DATAROOTDIR}/locale") -endif() - -if(NOT CMAKE_INSTALL_MANDIR) - set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)") - set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man") -endif() - -if(NOT CMAKE_INSTALL_DOCDIR) - set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/PROJECT_NAME)") - set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}") -endif() - -#----------------------------------------------------------------------------- - -mark_as_advanced( - CMAKE_INSTALL_BINDIR - CMAKE_INSTALL_SBINDIR - CMAKE_INSTALL_LIBEXECDIR - CMAKE_INSTALL_SYSCONFDIR - CMAKE_INSTALL_SHAREDSTATEDIR - CMAKE_INSTALL_LOCALSTATEDIR - CMAKE_INSTALL_LIBDIR - CMAKE_INSTALL_INCLUDEDIR - CMAKE_INSTALL_OLDINCLUDEDIR - CMAKE_INSTALL_DATAROOTDIR - CMAKE_INSTALL_DATADIR - CMAKE_INSTALL_INFODIR - CMAKE_INSTALL_LOCALEDIR - CMAKE_INSTALL_MANDIR - CMAKE_INSTALL_DOCDIR - ) - -# Result directories -# -foreach(dir - BINDIR - SBINDIR - LIBEXECDIR - SYSCONFDIR - SHAREDSTATEDIR - LOCALSTATEDIR - LIBDIR - INCLUDEDIR - OLDINCLUDEDIR - DATAROOTDIR - DATADIR - INFODIR - LOCALEDIR - MANDIR - DOCDIR - ) - if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}}) - set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}") - else() - set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}") - endif() -endforeach() diff -Nru librabbitmq-0.7.1/cmake/InstallMacros.cmake librabbitmq-0.9.0-0.1/cmake/InstallMacros.cmake --- librabbitmq-0.7.1/cmake/InstallMacros.cmake 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/cmake/InstallMacros.cmake 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -# vim:set ts=2 sw=2 sts=2 et: -# -# This module install PDB files. -# -# Based on users posts: -# http://www.cmake.org/pipermail/cmake/2007-October/016924.html -# -# Copyright (c) 2006-2011 Mathieu Malaterre -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# - -macro (install_pdb library) - if (MSVC) - if(CMAKE_CONFIGURATION_TYPES) - # Visual Studio - # The following does not work with LOCATION keyword. See: - # http://www.cmake.org/pipermail/cmake/2011-February/042579.html - foreach(cfg ${CMAKE_CONFIGURATION_TYPES}) - get_target_property(library_dll ${library} LOCATION_${cfg}) - string(REPLACE .dll .pdb library_pdb ${library_dll}) - string(TOLOWER ${cfg} lcfg) - if(lcfg STREQUAL "debug" OR lcfg STREQUAL "relwithdebinfo") - install (FILES ${library_pdb} - DESTINATION bin - CONFIGURATIONS ${cfg} - ) - endif() - endforeach() - else() - # nmake - # Same as above we need the explicit location_ variable to account for - # the value of CMAKE_DEBUG_POSTFIX - get_target_property(library_dll ${library} LOCATION_${CMAKE_BUILD_TYPE}) - string(REPLACE .dll .pdb library_pdb ${library_dll}) - string(TOLOWER ${CMAKE_BUILD_TYPE} lcfg) - if(lcfg STREQUAL "debug" OR lcfg STREQUAL "relwithdebinfo") - install (FILES ${library_pdb} - DESTINATION bin - ) - endif() - endif() - endif () -endmacro () diff -Nru librabbitmq-0.7.1/cmake/TestCInline.cmake librabbitmq-0.9.0-0.1/cmake/TestCInline.cmake --- librabbitmq-0.7.1/cmake/TestCInline.cmake 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/cmake/TestCInline.cmake 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -# vim:set ts=2 sw=2 sts=2 et: #Inspired from http://www.cmake.org/Wiki/CMakeTestInline IF(NOT DEFINED C_INLINE_KEYWORD) diff -Nru librabbitmq-0.7.1/CMakeLists.txt librabbitmq-0.9.0-0.1/CMakeLists.txt --- librabbitmq-0.7.1/CMakeLists.txt 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/CMakeLists.txt 2019-10-20 10:14:51.000000000 +0000 @@ -1,7 +1,11 @@ -# vim:set ts=2 sw=2 sts=2 et: -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8.12) project(rabbitmq-c "C") +# Enable MACOSX_RPATH by default. See: cmake --help-policy CMP0042 +if (POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) +endif() + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # Follow all steps below in order to calculate new ABI version when updating the library @@ -12,9 +16,9 @@ # 3. If any interfaces have been added since the last public release, then increment age. # 4. If any interfaces have been removed since the last public release, then set age to 0. -set(RMQ_SOVERSION_CURRENT 5) -set(RMQ_SOVERSION_REVISION 3) -set(RMQ_SOVERSION_AGE 1) +set(RMQ_SOVERSION_CURRENT 7) +set(RMQ_SOVERSION_REVISION 0) +set(RMQ_SOVERSION_AGE 3) math(EXPR RMQ_SOVERSION_MAJOR "${RMQ_SOVERSION_CURRENT} - ${RMQ_SOVERSION_AGE}") math(EXPR RMQ_SOVERSION_MINOR "${RMQ_SOVERSION_AGE}") @@ -34,19 +38,6 @@ # VERSION to match what is in autotools set(VERSION ${_API_VERSION_MAJOR}.${_API_VERSION_MINOR}.${_API_VERSION_PATCH}) -if (MSVC) - set(CMAKE_C_FLAGS "/W4 /nologo ${CMAKE_C_FLAGS}") -elseif (CMAKE_C_COMPILER_ID MATCHES ".*Clang") - set(CMAKE_C_FLAGS "-Wall -Wextra -Wstrict-prototypes -Wno-unused-function -fno-common -fvisibility=hidden ${CMAKE_C_FLAGS}") -elseif (CMAKE_COMPILER_IS_GNUCC) - set(RMQ_C_FLAGS "-Wall -Wextra -Wstrict-prototypes -Wno-unused-function -fno-common") - execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) - if (GCC_VERSION VERSION_GREATER 4.0 OR GCC_VERSION VERSION_EQUAL 4.0) - set(RMQ_C_FLAGS "${RMQ_C_FLAGS} -fvisibility=hidden") - endif() - set(CMAKE_C_FLAGS "${RMQ_C_FLAGS} ${CMAKE_C_FLAGS}") -endif () - if (CMAKE_GENERATOR MATCHES ".*(Make|Ninja).*" AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) @@ -54,23 +45,12 @@ endif() include(TestCInline) -include(CheckFunctionExists) include(CheckSymbolExists) include(CheckLibraryExists) include(CMakePushCheckState) include(GNUInstallDirs) include(CheckCCompilerFlag) -CHECK_C_COMPILER_FLAG("-std=gnu90" HAVE_GNU90) -if (HAVE_GNU90) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90") -else() - CHECK_C_COMPILER_FLAG("-std=c90" HAVE_C90) - if (HAVE_C90) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c90") - endif() -endif() - # Detect if we need to link against a socket library: cmake_push_check_state() if (WIN32) @@ -78,13 +58,15 @@ set(SOCKET_LIBRARIES ws2_32) else () # Is it in the default link? - CHECK_FUNCTION_EXISTS(getaddrinfo HAVE_GETADDRINFO) + check_symbol_exists(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO) if (NOT (HAVE_GETADDRINFO EQUAL 1)) - CHECK_LIBRARY_EXISTS(socket getaddrinfo "" HAVE_GETADDRINFO2) + SET(CMAKE_REQUIRED_LIBRARIES "socket") + check_symbol_exists(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO2) if (HAVE_GETADDRINFO2 EQUAL 1) set(SOCKET_LIBRARIES socket) else () - CHECK_LIBRARY_EXISTS("socket;nsl" getaddrinfo "" HAVE_GETADDRINFO3) + SET(CMAKE_REQUIRED_LIBRARIES "socket;nsl") + check_symbol_exists(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO3) if (HAVE_GETADDRINFO3 EQUAL 1) set(SOCKET_LIBRARIES socket nsl) else () @@ -94,13 +76,15 @@ endif () set(CMAKE_REQUIRED_LIBRARIES ${SOCKET_LIBRARIES}) - CHECK_FUNCTION_EXISTS(socket HAVE_SOCKET) + check_symbol_exists(socket "sys/types.h;sys/socket.h" HAVE_SOCKET) if (NOT HAVE_SOCKET EQUAL 1) - CHECK_LIBRARY_EXISTS(socket socket "" HAVE_SOCKET2) - if (NOT HAVE_SOCKET2 EQUAL 1) + set(CMAKE_REQUIRED_LIBRARIES socket ${SOCKET_LIBRARIES}) + check_symbol_exists(socket "sys/types.h;sys/socket.h" HAVE_SOCKET2) + if (HAVE_SOCKET2 EQUAL 1) set(SOCKET_LIBRARIES socket ${SOCKET_LIBRARIES}) else () - CHECK_LIBRARY_EXISTS("socket;nsl" socket "" HAVE_SOCKET3) + set(CMAKE_REQUIRED_LIBRARIES socket nsl ${SOCKET_LIBRARIES}) + check_symbol_exists(socket "sys/types.h;sys/socket.h" HAVE_SOCKET3) if (HAVE_SOCKET3 EQUAL 1) set(SOCKET_LIBRARIES socket nsl ${SOCKET_LIBRARIES}) else () @@ -113,24 +97,12 @@ cmake_push_check_state() set(CMAKE_REQUIRED_LIBRARIES ${SOCKET_LIBRARIES}) -if (WIN32) - check_symbol_exists(htonll Winsock2.h HAVE_HTONLL) -else (WIN32) - check_symbol_exists(htonll arpa/inet.h HAVE_HTONLL) -endif (WIN32) -cmake_pop_check_state() - -cmake_push_check_state() -set(CMAKE_REQUIRED_INCLUDES "poll.h") -check_function_exists(poll HAVE_POLL) -set(CMAKE_REQUIRED_INCLUDES ) +check_symbol_exists(poll poll.h HAVE_POLL) if (NOT HAVE_POLL) if (WIN32) set(HAVE_SELECT 1) else() - set(CMAKE_REQUIRED_INCLUDES sys/select.h) - check_function_exists(select HAVE_SELECT) - set(CMAKE_REQUIRED_INCLUDES ) + check_symbol_exists(select sys/select.h HAVE_SELECT) endif() if (NOT HAVE_SELECT) message(FATAL_ERROR "rabbitmq-c requires poll() or select() to be available") @@ -139,10 +111,45 @@ cmake_pop_check_state() check_library_exists(rt clock_gettime "time.h" CLOCK_GETTIME_NEEDS_LIBRT) -if (CLOCK_GETTIME_NEEDS_LIBRT) +check_library_exists(rt posix_spawnp "spawn.h" POSIX_SPAWNP_NEEDS_LIBRT) +if (CLOCK_GETTIME_NEEDS_LIBRT OR POSIX_SPAWNP_NEEDS_LIBRT) set(LIBRT rt) endif() +option(ENABLE_SSL_SUPPORT "Enable SSL support" ON) + +if (ENABLE_SSL_SUPPORT) + find_package(OpenSSL 0.9.8 REQUIRED) + + cmake_push_check_state() + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + cmake_pop_check_state() +endif() + +if (MSVC) + set(CMAKE_C_FLAGS "/W4 /nologo ${CMAKE_C_FLAGS}") +elseif (CMAKE_C_COMPILER_ID MATCHES ".*Clang") + set(CMAKE_C_FLAGS "-Wall -Wextra -Wstrict-prototypes -Wno-unused-function -fno-common -fvisibility=hidden ${CMAKE_C_FLAGS}") +elseif (CMAKE_COMPILER_IS_GNUCC) + set(RMQ_C_FLAGS "-Wall -Wextra -Wstrict-prototypes -Wno-unused-function -fno-common") + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) + if (GCC_VERSION VERSION_GREATER 4.0 OR GCC_VERSION VERSION_EQUAL 4.0) + set(RMQ_C_FLAGS "${RMQ_C_FLAGS} -fvisibility=hidden") + endif() + set(CMAKE_C_FLAGS "${RMQ_C_FLAGS} ${CMAKE_C_FLAGS}") +endif () + +CHECK_C_COMPILER_FLAG("-std=gnu90" HAVE_GNU90) +if (HAVE_GNU90) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90") +else() + CHECK_C_COMPILER_FLAG("-std=c90" HAVE_C90) + if (HAVE_C90) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c90") + endif() +endif() + option(REGENERATE_AMQP_FRAMING "Regenerate amqp_framing.h/amqp_framing.c sources (for developer use)" OFF) mark_as_advanced(REGENERATE_AMQP_FRAMING) @@ -250,7 +257,6 @@ set(DO_DOCS ON) endif() -find_package(Threads) option(BUILD_SHARED_LIBS "Build rabbitmq-c as a shared library" ON) option(BUILD_STATIC_LIBS "Build rabbitmq-c as a static library" ON) @@ -260,29 +266,6 @@ option(BUILD_TOOLS_DOCS "Build man pages for Tools (requires xmlto)" ${DO_DOCS}) option(BUILD_TESTS "Build tests (run tests with make test)" ON) option(BUILD_API_DOCS "Build Doxygen API docs" ${DOXYGEN_FOUND}) -option(ENABLE_SSL_SUPPORT "Enable SSL support" ON) -option(ENABLE_THREAD_SAFETY "Enable thread safety when using OpenSSL" ${Threads_FOUND}) - -set(SSL_ENGINE "OpenSSL" CACHE STRING "SSL Backend to use, valid options: OpenSSL, cyaSSL, GnuTLS, PolarSSL") -mark_as_advanced(SSL_ENGINE) - -if (ENABLE_SSL_SUPPORT) - if (SSL_ENGINE STREQUAL "OpenSSL") - find_package(OpenSSL 0.9.8 REQUIRED) - - elseif (SSL_ENGINE STREQUAL "cyaSSL") - find_package(cyaSSL REQUIRED) - - elseif (SSL_ENGINE STREQUAL "GnuTLS") - find_package(GnuTLS REQUIRED) - - elseif (SSL_ENGINE STREQUAL "PolarSSL") - find_package(PolarSSL REQUIRED) - - else() - message(FATAL_ERROR "Unsupported SSL_ENGINE ${SSL_ENGINE}, valid engines: OpenSSL, cyaSSL, GnuTLS, or PolarSSL") - endif() -endif() if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) message(FATAL_ERROR "One or both of BUILD_SHARED_LIBS or BUILD_STATIC_LIBS must be set to ON to build") @@ -330,12 +313,8 @@ set(libs_private ${SOCKET_LIBRARIES} ${LIBRT}) if (ENABLE_SSL_SUPPORT) - if (SSL_ENGINE STREQUAL "OpenSSL") - set(requires_private "openssl") - endif() - if (ENABLE_THREAD_SAFETY) - set(libs_private ${libs_private} ${CMAKE_THREAD_LIBS_INIT}) - endif() + set(requires_private "openssl") + set(libs_private ${libs_private} ${CMAKE_THREAD_LIBS_INIT}) endif() set(prefix ${CMAKE_INSTALL_PREFIX}) diff -Nru librabbitmq-0.7.1/configure.ac librabbitmq-0.9.0-0.1/configure.ac --- librabbitmq-0.7.1/configure.ac 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/configure.ac 1970-01-01 00:00:00.000000000 +0000 @@ -1,210 +0,0 @@ -# vim:set ts=2 sw=2 sts=2 et: -AC_PREREQ([2.59]) - -m4_define([major_version], [0]) -m4_define([minor_version], [7]) -m4_define([micro_version], [1]) - -# Follow all steps below in order to calculate new ABI version when updating the library -# NOTE: THIS IS UNRELATED to the actual project version -# -# 1. If the library source code has changed at all since the last update, then increment revision -# 2. If any interfaces have been added, removed, or changed since the last update, increment current and set revision to 0. -# 3. If any interfaces have been added since the last public release, then increment age. -# 4. If any interfaces have been removed since the last public release, then set age to 0. -m4_define([soversion_current], [5]) -m4_define([soversion_revision], [3]) -m4_define([soversion_age], [1]) - -AC_INIT([rabbitmq-c], [major_version.minor_version.micro_version], - [https://github.com/alanxz/rabbitmq-c/issues], [rabbitmq-c], - [http://www.rabbitmq.com/]) -AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE([1.9 subdir-objects foreign -Wno-portability]) -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -AC_CONFIG_SRCDIR([librabbitmq/amqp.h]) -AC_GNU_SOURCE - -# Initialize Libtool -LT_PREREQ([2.2]) -LT_INIT([disable-static win32-dll]) - -# Program checks -m4_ifdef([AC_PROG_CC_89], [AC_PROG_CC_89], - [AC_MSG_WARN([Attempt c89 workaround for old versions of autoconf]) - AC_PROG_CC - AX_TRY_CFLAGS([-std=gnu90], [AX_CFLAGS([-std=gnu90])])]) -PKG_PROG_PKG_CONFIG([0.17]) - -# Environment setup -AC_CANONICAL_HOST -AC_C_INLINE - -# Set compiler flags -AX_TRY_CFLAGS([-Wall], [AX_CFLAGS([-Wall])]) -AX_TRY_CFLAGS([-Wextra], [AX_CFLAGS([-Wextra])]) -AX_TRY_CFLAGS([-Wstrict-prototypes], [AX_CFLAGS([-Wstrict-prototypes])]) -AX_TRY_CFLAGS([-Wno-unused-function], [AX_CFLAGS([-Wno-unused-function])]) -AX_TRY_CFLAGS([-fno-common], [AX_CFLAGS([-fno-common])]) -AX_TRY_CFLAGS([-fvisibility=hidden], [AX_CFLAGS([-fvisibility=hidden])]) -AX_TRY_LDFLAGS([-no-undefined], [NO_UNDEFINED=-no-undefined]) -AC_SUBST([NO_UNDEFINED]) - -# Libtool versioning -LT_CURRENT=soversion_current -LT_REVISION=soversion_revision -LT_AGE=soversion_age -AC_SUBST([LT_CURRENT]) -AC_SUBST([LT_REVISION]) -AC_SUBST([LT_AGE]) - -# OS setup -os_unix=no -os_apple=no -os_win32=no -AS_CASE([$host], - [*-*-mingw*], - [os_win32=yes], - [*-apple-darwin*], - [os_apple=yes; os_unix=yes], - [*], - [os_unix=yes]) -AM_CONDITIONAL([OS_UNIX], [test "x$os_unix" = xyes]) -AM_CONDITIONAL([OS_APPLE], [test "x$os_apple" = xyes]) -AM_CONDITIONAL([OS_WIN32], [test "x$os_win32" = xyes]) -AC_DEFINE([ENABLE_THREAD_SAFETY], [1], [Define to 1 to enable thread safety]) - -# Extra Win32 setup -AS_IF([test "x$os_win32" = xyes], - [AC_DEFINE([OS_WIN32], [1], [Define to 1 for Win32.]) - AC_DEFINE([AMQP_BUILD], [1], [Define to 1 for a Win32 build.]) - AS_IF([test "x$GCC" = xyes], - [AX_LDFLAGS([-lws2_32])], - [AX_LDFLAGS([ws2_32.lib])]) - AS_IF([test "x$enable_static" = "xyes"], - [AS_IF([test "x$enable_shared" = "xyes"], - [AC_MSG_ERROR([select one of shared @<:@--enable-shared@:>@ or static @<:@--enable-static@:>@.])], - [AC_DEFINE([AMQP_STATIC], [1], - [Define to 1 for a static Win32 build.])])])]) - -# Detect which libraries we might need to use socket functions: -# Solaris needs -lsocket -lnsl -# QNX will need -lsocket - -AC_SEARCH_LIBS([getaddrinfo], [socket], [], - [AC_CHECK_LIB([getaddrinfo], [socket], - [LIBS="-lsocket -lnsl $LIBS"], - [AC_MSG_ERROR([cannot find name resolution library (library with getaddrinfo symbol)])], - [-lnsl])]) -AC_SEARCH_LIBS([socket], [socket], [], - [AC_CHECK_LIB([socket], [socket], - [LIBS="-lsocket -lnsl $LIBS"], - [AC_MSG_ERROR([cannot find socket library (library with socket symbol)])], - [-lnsl])]) -AC_SEARCH_LIBS([clock_gettime], [rt]) -AC_MSG_CHECKING([if htonll is defined]) - -dnl # Check for htonll -AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ - #include - ]], - [[ - return htonll(0); - ]] - )], - [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_HTONLL, 1, [Define to 1 if the function (or macro) htonll exists.]) - ], - [ - AC_MSG_RESULT(no) - ] -) - -# Need poll() or select() -AX_HAVE_POLL([AC_DEFINE([HAVE_POLL], [], ["Have poll()"])], - AX_HAVE_SELECT([AC_DEFINE([HAVE_SELECT], [], ["Have select()"])], - [AC_MSG_ERROR([rabbitmq-c needs poll() or select()])])) - -# Configure SSL/TLS -AC_ARG_WITH([ssl], - [AS_HELP_STRING([--with-ssl=@<:@cyassl/gnutls/no/openssl/polarssl/yes@:>@], - [enable SSL/TLS support @<:@default=openssl@:>@])], - [AS_CASE([$withval], - [yes], [with_ssl=openssl], - [*], [with_ssl=$withval])], - [with_ssl=openssl]) - -AS_IF([test "x$with_ssl" = "xcyassl"], - [PKG_CHECK_MODULES([SSL], [libcyassl],, [with_ssl=no])], - [test "x$with_ssl" = "xgnutls"], - [PKG_CHECK_MODULES([SSL], [gnutls],, [with_ssl=no])], - [test "x$with_ssl" = "xopenssl"], - [PKG_CHECK_MODULES([SSL], [openssl >= 0.9.8], [ssl_pkg_required=openssl], - [with_ssl=no])], - [test "x$with_ssl" = "xpolarssl"], - [AX_LIB_POLARSSL([SSL_CFLAGS=$POLARSSL_CFLAGS - SSL_LIBS=$POLARSSL_LIBS], - [with_ssl=no])], - [test "x$with_ssl" = "xno"],, - [AC_MSG_ERROR([unknown SSL/TLS implementation: $with_ssl])]) -AM_CONDITIONAL([SSL_CYASSL], [test "x$with_ssl" = "xcyassl"]) -AM_CONDITIONAL([SSL_GNUTLS], [test "x$with_ssl" = "xgnutls"]) -AM_CONDITIONAL([SSL_OPENSSL], [test "x$with_ssl" = "xopenssl"]) -AM_CONDITIONAL([SSL_POLARSSL], [test "x$with_ssl" = "xpolarssl"]) -AM_CONDITIONAL([SSL], [test "x$with_ssl" != "xno"]) -AS_IF([test "x$with_ssl" != "xno"], - [AC_DEFINE([WITH_SSL], [1], [Define to 1 if SSL/TLS is enabled.])]) - -# Configure AMQP command-line tools -AC_ARG_ENABLE([tools], - [AS_HELP_STRING([--enable-tools], - [build AMQP command-line tools @<:@auto@:>@])],, - [enable_tools=auto]) -AS_IF([test "x$enable_tools" != "xno"], - [AX_LIB_POPT([enable_tools=yes], [enable_tools=no])]) -AM_CONDITIONAL([TOOLS], [test "x$enable_tools" = "xyes"]) - -# Configure command-line tool documentation -AC_ARG_ENABLE([docs], - [AS_HELP_STRING([--enable-docs], - [build command-line tool documentation @<:@auto@:>@])],, - [AS_IF([test "x$enable_tools" = "xno"], - [enable_docs=no], - [enable_docs=auto])]) -AC_ARG_VAR([XMLTO], [xmlto command]) -AS_IF([test "x$enable_docs" != "xno"], - [AS_IF([test "x$XMLTO" = "x"], - [AC_CHECK_PROGS([XMLTO], [xmlto])]) - AS_IF([test "x$XMLTO" != "x"], - [enable_docs=yes], - [enable_docs=no])]) -AM_CONDITIONAL([DOCS], [test "x$enable_docs" = "xyes"]) - -# Configure examples -AC_ARG_ENABLE([examples], - [AS_HELP_STRING([--enable-examples], - [build example code @<:@auto@:>@])],, - [enable_examples=yes]) -AM_CONDITIONAL([EXAMPLES], [test "x$enable_examples" = "xyes"]) - -AC_SUBST([requires_private], [$ssl_pkg_required]) -AC_SUBST([libs_private], [$LIBS]) -AC_DEFINE_UNQUOTED([AMQ_PLATFORM], ["$host_os"], [Host operating system string]) -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_FILES([ - librabbitmq.pc - Makefile -]) -AC_OUTPUT -AC_MSG_RESULT([ -$PACKAGE_NAME build options: - Host: $host - Version: $VERSION - SSL/TLS: $with_ssl - Tools: $enable_tools - Documentation: $enable_docs - Examples: $enable_examples -]) diff -Nru librabbitmq-0.7.1/coverity/model.c librabbitmq-0.9.0-0.1/coverity/model.c --- librabbitmq-0.7.1/coverity/model.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/coverity/model.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,16 +1,17 @@ /* Functions to help coverity do static analysis on rabbitmq-c */ -void amqp_abort(const char *fmt, ...) -{ - __coverity_panic__(); -} +typedef struct { +} amqp_rpc_reply_t; -void die_on_amqp_error(amqp_rpc_reply *r) -{ - __coverity_panic__(); -} +/* librabbitmq/amqp_private.h */ +void amqp_abort(const char* fmt, ...) { __coverity_panic__(); } -void die_on_error(int r) -{ - __coverity_panic__(); -} +/* tools/common.h */ +void die(const char* fmt, ...) { __coverity_panic__(); } +void die_errno(int err, const char* fmt, ...) { __coverity_panic__(); } +void die_amqp_error(int err, const char* fmt, ...) { __coverity_panic__(); } +void die_rpc(amqp_rpc_reply_t r, const char* fmt, ...) { __coverity_panic__(); } + +/* examples/utils.h */ +void die_on_amqp_error(amqp_rpc_reply_t* r) { __coverity_panic__(); } +void die_on_error(int r) { __coverity_panic__(); } diff -Nru librabbitmq-0.7.1/debian/changelog librabbitmq-0.9.0-0.1/debian/changelog --- librabbitmq-0.7.1/debian/changelog 2015-11-19 10:06:13.000000000 +0000 +++ librabbitmq-0.9.0-0.1/debian/changelog 2019-10-20 10:14:51.000000000 +0000 @@ -1,3 +1,29 @@ +librabbitmq (0.9.0-0.1-0hsu0~201910170641+g9e0f91b~ubuntu16.04.1) xenial; urgency=low + + * Auto build. + + -- Justin Kim Sun, 20 Oct 2019 10:14:51 +0000 + +librabbitmq (0.9.0-0.1) unstable; urgency=medium + + * Non-maintainer upload + * Update Vcs-* links + * New upstream version 0.9.0 + * Rebase patches for librabbitmq 0.9.0 + * Update librabbitmq4.symbols file + * Replace old manual dbg package with auto dbgsym packages + + -- Ondřej Surý Mon, 01 Oct 2018 12:54:12 +0000 + +librabbitmq (0.8.0-1) unstable; urgency=medium + + * Update Vcs-Git header to use https. + * Update standards version to 3.9.8. + * New upstream version. Closes: #824792. + * Distribute static archive. Closes: #686829. + + -- Brian May Sun, 24 Jul 2016 11:14:26 +1000 + librabbitmq (0.7.1-1) unstable; urgency=medium * New upstream release. diff -Nru librabbitmq-0.7.1/debian/control librabbitmq-0.9.0-0.1/debian/control --- librabbitmq-0.7.1/debian/control 2015-11-19 10:06:13.000000000 +0000 +++ librabbitmq-0.9.0-0.1/debian/control 2019-10-20 10:14:51.000000000 +0000 @@ -9,10 +9,10 @@ libpopt-dev, libssl-dev, libtool -Standards-Version: 3.9.6 +Standards-Version: 3.9.8 Homepage: https://github.com/alanxz/rabbitmq-c -Vcs-Git: git://anonscm.debian.org/collab-maint/librabbitmq.git -Vcs-Browser: https://anonscm.debian.org/cgit/collab-maint/librabbitmq.git +Vcs-Git: https://salsa.debian.org/debian/librabbitmq.git +Vcs-Browser: https://salsa.debian.org/debian/librabbitmq Package: librabbitmq-dev Section: libdevel @@ -29,23 +29,6 @@ . This package provides the files needed for development. -Package: librabbitmq-dbg -Section: debug -Architecture: any -Multi-Arch: same -Priority: extra -Depends: librabbitmq4 (= ${binary:Version}), - ${misc:Depends}, - ${shlibs:Depends} -Pre-Depends: ${misc:Pre-Depends} -Description: AMQP client library written in C - Debug Files - RabbitMQ provides robust messaging for applications. It is easy to use, fit - for purpose at cloud scale and supported on all major operating systems and - developer platforms. librabbitmq is a C-language AMQP client library for use - with AMQP servers such as RabbitMQ speaking protocol versions 0-9-1. - . - This package provides debugging symbols. - Package: librabbitmq4 Architecture: any Multi-Arch: same diff -Nru librabbitmq-0.7.1/debian/git-build-recipe.manifest librabbitmq-0.9.0-0.1/debian/git-build-recipe.manifest --- librabbitmq-0.7.1/debian/git-build-recipe.manifest 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/debian/git-build-recipe.manifest 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1,2 @@ +# git-build-recipe format 0.4 deb-version {debversion}-0hsu0~201910170641+g9e0f91b +lp:~hwangsaeul/+git/librabbitmq git-commit:9e0f91bf63c2a24d56e25a6a7e4a95ded414cced diff -Nru librabbitmq-0.7.1/debian/librabbitmq4.symbols librabbitmq-0.9.0-0.1/debian/librabbitmq4.symbols --- librabbitmq-0.7.1/debian/librabbitmq4.symbols 2015-11-19 10:06:13.000000000 +0000 +++ librabbitmq-0.9.0-0.1/debian/librabbitmq4.symbols 2019-10-20 10:14:51.000000000 +0000 @@ -44,12 +44,15 @@ amqp_get_channel_max@Base 0.6.0 amqp_get_client_properties@Base 0.7.1 amqp_get_frame_max@Base 0.6.0 + amqp_get_handshake_timeout@Base 0.9.0 amqp_get_heartbeat@Base 0.6.0 amqp_get_rpc_reply@Base 0.6.0 + amqp_get_rpc_timeout@Base 0.9.0 amqp_get_server_properties@Base 0.6.0 amqp_get_socket@Base 0.6.0 amqp_get_sockfd@Base 0.6.0 amqp_handle_input@Base 0.6.0 + amqp_initialize_ssl_library@Base 0.9.0 amqp_login@Base 0.6.0 amqp_login_with_properties@Base 0.6.0 amqp_maybe_release_buffers@Base 0.6.0 @@ -72,7 +75,9 @@ amqp_send_frame@Base 0.6.0 amqp_send_header@Base 0.6.0 amqp_send_method@Base 0.6.0 + amqp_set_handshake_timeout@Base 0.9.0 amqp_set_initialize_ssl_library@Base 0.6.0 + amqp_set_rpc_timeout@Base 0.9.0 amqp_set_sockfd@Base 0.6.0 amqp_simple_rpc@Base 0.6.0 amqp_simple_rpc_decoded@Base 0.6.0 @@ -86,7 +91,10 @@ amqp_ssl_socket_set_cacert@Base 0.6.0 amqp_ssl_socket_set_key@Base 0.6.0 amqp_ssl_socket_set_key_buffer@Base 0.6.0 + amqp_ssl_socket_set_ssl_versions@Base 0.8.0 amqp_ssl_socket_set_verify@Base 0.6.0 + amqp_ssl_socket_set_verify_hostname@Base 0.8.0 + amqp_ssl_socket_set_verify_peer@Base 0.8.0 amqp_table_clone@Base 0.6.0 amqp_table_entry_cmp@Base 0.6.0 amqp_tcp_socket_new@Base 0.6.0 @@ -95,6 +103,7 @@ amqp_tx_commit@Base 0.6.0 amqp_tx_rollback@Base 0.6.0 amqp_tx_select@Base 0.6.0 + amqp_uninitialize_ssl_library@Base 0.9.0 amqp_version@Base 0.6.0 amqp_version_number@Base 0.6.0 empty_amqp_pool@Base 0.6.0 diff -Nru librabbitmq-0.7.1/debian/librabbitmq-dev.install librabbitmq-0.9.0-0.1/debian/librabbitmq-dev.install --- librabbitmq-0.7.1/debian/librabbitmq-dev.install 2015-11-19 10:06:13.000000000 +0000 +++ librabbitmq-0.9.0-0.1/debian/librabbitmq-dev.install 2019-10-20 10:14:51.000000000 +0000 @@ -1,3 +1,4 @@ usr/include/*.h usr/lib/*/lib*.so +usr/lib/*/lib*.a usr/lib/*/pkgconfig/librabbitmq.pc diff -Nru librabbitmq-0.7.1/debian/patches/cmake_with_ssl.patch librabbitmq-0.9.0-0.1/debian/patches/cmake_with_ssl.patch --- librabbitmq-0.7.1/debian/patches/cmake_with_ssl.patch 2015-11-19 10:06:13.000000000 +0000 +++ librabbitmq-0.9.0-0.1/debian/patches/cmake_with_ssl.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -Description: Enable SSL support for tools. - Add WITH_SSL preprocessor macro it SSL support is enabled. Otherwise tools - would abort it they see an SSL URL. -Author: Michael Fladischer -Last-Update: 2014-10-17 -Bug-Debian: https://bugs.debian.org/764080 -Forwarded: https://github.com/alanxz/rabbitmq-c/pull/220 - ---- a/tools/CMakeLists.txt -+++ b/tools/CMakeLists.txt -@@ -76,6 +76,10 @@ - add_definitions(-DWITH_SSL=1) - endif() - -+if (ENABLE_SSL_SUPPORT) -+ add_definitions(-DWITH_SSL=1) -+endif() -+ - install(TARGETS amqp-publish amqp-get amqp-consume amqp-declare-queue amqp-delete-queue - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib diff -Nru librabbitmq-0.7.1/debian/patches/series librabbitmq-0.9.0-0.1/debian/patches/series --- librabbitmq-0.7.1/debian/patches/series 2015-11-19 10:06:13.000000000 +0000 +++ librabbitmq-0.9.0-0.1/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -cmake_with_ssl.patch -use_cmake_package.patch diff -Nru librabbitmq-0.7.1/debian/patches/use_cmake_package.patch librabbitmq-0.9.0-0.1/debian/patches/use_cmake_package.patch --- librabbitmq-0.7.1/debian/patches/use_cmake_package.patch 2015-11-19 10:06:13.000000000 +0000 +++ librabbitmq-0.9.0-0.1/debian/patches/use_cmake_package.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,324 +0,0 @@ -Description: Remove files already included in cmake distribution - The project builds fine without these files as they are already provided by cmake - upstream. This also fixes a problem with multiarch library paths in Debian - kFreeBSD and HURD, because the included GNUInstallDirs.cmake did not check for - these systems. -Author: Michael Fladischer -Last-Update: 2014-09-16 -Forwarded: https://github.com/alanxz/rabbitmq-c/pull/214 -Bug-Debian: https://bugs.debian.org/760227 - ---- a/cmake/CMakePushCheckState.cmake -+++ /dev/null -@@ -1,103 +0,0 @@ --# This module defines two macros: --# CMAKE_PUSH_CHECK_STATE() --# and --# CMAKE_POP_CHECK_STATE() --# These two macros can be used to save and restore the state of the variables --# CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_LIBRARIES --# and CMAKE_REQUIRED_INCLUDES used by the various Check-files coming with CMake, --# like e.g. check_function_exists() etc. --# The variable contents are pushed on a stack, pushing multiple times is supported. --# This is useful e.g. when executing such tests in a Find-module, where they have to be set, --# but after the Find-module has been executed they should have the same value --# as they had before. --# --# Usage: --# cmake_push_check_state() --# set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF) --# check_function_exists(...) --# cmake_pop_check_state() -- --#============================================================================= --# Copyright 2006-2011 Alexander Neundorf, --# --# Redistribution and use in source and binary forms, with or without --# modification, are permitted provided that the following conditions --# are met: --# --# * Redistributions of source code must retain the above copyright --# notice, this list of conditions and the following disclaimer. --# --# * Redistributions in binary form must reproduce the above copyright --# notice, this list of conditions and the following disclaimer in the --# documentation and/or other materials provided with the distribution. --# --# * Neither the names of Kitware, Inc., the Insight Software Consortium, --# nor the names of their contributors may be used to endorse or promote --# products derived from this software without specific prior written --# permission. --# --# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --# --# ------------------------------------------------------------------------------ --# --# The above copyright and license notice applies to distributions of --# CMake in source and binary form. Some source files contain additional --# notices of original copyright by their contributors; see each source --# for details. Third-party software packages supplied with CMake under --# compatible licenses provide their own copyright notices documented in --# corresponding subdirectories. --# --# ------------------------------------------------------------------------------ --# --# CMake was initially developed by Kitware with the following sponsorship: --# --# * National Library of Medicine at the National Institutes of Health --# as part of the Insight Segmentation and Registration Toolkit (ITK). --# --# * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel --# Visualization Initiative. --# --# * National Alliance for Medical Image Computing (NAMIC) is funded by the --# National Institutes of Health through the NIH Roadmap for Medical Research, --# Grant U54 EB005149. --# --# * Kitware, Inc. -- --macro(CMAKE_PUSH_CHECK_STATE) -- -- if(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER) -- set(_CMAKE_PUSH_CHECK_STATE_COUNTER 0) -- endif() -- -- math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1") -- -- set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES}) -- set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) -- set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) -- set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) --endmacro() -- --macro(CMAKE_POP_CHECK_STATE) -- --# don't pop more than we pushed -- if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0") -- -- set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) -- set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) -- set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) -- set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) -- -- math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") -- endif() -- --endmacro() ---- a/cmake/GNUInstallDirs.cmake -+++ /dev/null -@@ -1,205 +0,0 @@ --#.rst: --# GNUInstallDirs --# -------------- --# --# Define GNU standard installation directories --# --# Provides install directory variables as defined for GNU software: --# --# :: --# --# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html --# --# Inclusion of this module defines the following variables: --# --# :: --# --# CMAKE_INSTALL_ - destination for files of a given type --# CMAKE_INSTALL_FULL_ - corresponding absolute path --# --# where is one of: --# --# :: --# --# BINDIR - user executables (bin) --# SBINDIR - system admin executables (sbin) --# LIBEXECDIR - program executables (libexec) --# SYSCONFDIR - read-only single-machine data (etc) --# SHAREDSTATEDIR - modifiable architecture-independent data (com) --# LOCALSTATEDIR - modifiable single-machine data (var) --# LIBDIR - object code libraries (lib or lib64 or lib/ on Debian) --# INCLUDEDIR - C header files (include) --# OLDINCLUDEDIR - C header files for non-gcc (/usr/include) --# DATAROOTDIR - read-only architecture-independent data root (share) --# DATADIR - read-only architecture-independent data (DATAROOTDIR) --# INFODIR - info documentation (DATAROOTDIR/info) --# LOCALEDIR - locale-dependent data (DATAROOTDIR/locale) --# MANDIR - man documentation (DATAROOTDIR/man) --# DOCDIR - documentation root (DATAROOTDIR/doc/PROJECT_NAME) --# --# Each CMAKE_INSTALL_ value may be passed to the DESTINATION --# options of install() commands for the corresponding file type. If the --# includer does not define a value the above-shown default will be used --# and the value will appear in the cache for editing by the user. Each --# CMAKE_INSTALL_FULL_ value contains an absolute path constructed --# from the corresponding destination by prepending (if necessary) the --# value of CMAKE_INSTALL_PREFIX. -- --#============================================================================= --# Copyright 2011 Nikita Krupen'ko --# Copyright 2011 Kitware, Inc. --# --# Distributed under the OSI-approved BSD License (the "License"); --# see accompanying file Copyright.txt for details. --# --# This software is distributed WITHOUT ANY WARRANTY; without even the --# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --# See the License for more information. --#============================================================================= --# (To distribute this file outside of CMake, substitute the full --# License text for the above reference.) -- --# Installation directories --# --if(NOT DEFINED CMAKE_INSTALL_BINDIR) -- set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)") --endif() -- --if(NOT DEFINED CMAKE_INSTALL_SBINDIR) -- set(CMAKE_INSTALL_SBINDIR "sbin" CACHE PATH "system admin executables (sbin)") --endif() -- --if(NOT DEFINED CMAKE_INSTALL_LIBEXECDIR) -- set(CMAKE_INSTALL_LIBEXECDIR "libexec" CACHE PATH "program executables (libexec)") --endif() -- --if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR) -- set(CMAKE_INSTALL_SYSCONFDIR "etc" CACHE PATH "read-only single-machine data (etc)") --endif() -- --if(NOT DEFINED CMAKE_INSTALL_SHAREDSTATEDIR) -- set(CMAKE_INSTALL_SHAREDSTATEDIR "com" CACHE PATH "modifiable architecture-independent data (com)") --endif() -- --if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR) -- set(CMAKE_INSTALL_LOCALSTATEDIR "var" CACHE PATH "modifiable single-machine data (var)") --endif() -- --if(NOT DEFINED CMAKE_INSTALL_LIBDIR) -- set(_LIBDIR_DEFAULT "lib") -- # Override this default 'lib' with 'lib64' iff: -- # - we are on Linux system but NOT cross-compiling -- # - we are NOT on debian -- # - we are on a 64 bits system -- # reason is: amd64 ABI: http://www.x86-64.org/documentation/abi.pdf -- # For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if -- # CMAKE_LIBRARY_ARCHITECTURE is set (which contains e.g. "i386-linux-gnu" -- # See http://wiki.debian.org/Multiarch -- if(CMAKE_SYSTEM_NAME MATCHES "Linux" -- AND NOT CMAKE_CROSSCOMPILING) -- if (EXISTS "/etc/debian_version") # is this a debian system ? -- if(CMAKE_LIBRARY_ARCHITECTURE) -- set(_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}") -- endif() -- else() # not debian, rely on CMAKE_SIZEOF_VOID_P: -- if(NOT DEFINED CMAKE_SIZEOF_VOID_P) -- message(AUTHOR_WARNING -- "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. " -- "Please enable at least one language before including GNUInstallDirs.") -- else() -- if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") -- set(_LIBDIR_DEFAULT "lib64") -- endif() -- endif() -- endif() -- endif() -- set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})") --endif() -- --if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR) -- set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C header files (include)") --endif() -- --if(NOT DEFINED CMAKE_INSTALL_OLDINCLUDEDIR) -- set(CMAKE_INSTALL_OLDINCLUDEDIR "/usr/include" CACHE PATH "C header files for non-gcc (/usr/include)") --endif() -- --if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR) -- set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "read-only architecture-independent data root (share)") --endif() -- --#----------------------------------------------------------------------------- --# Values whose defaults are relative to DATAROOTDIR. Store empty values in --# the cache and store the defaults in local variables if the cache values are --# not set explicitly. This auto-updates the defaults as DATAROOTDIR changes. -- --if(NOT CMAKE_INSTALL_DATADIR) -- set(CMAKE_INSTALL_DATADIR "" CACHE PATH "read-only architecture-independent data (DATAROOTDIR)") -- set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}") --endif() -- --if(NOT CMAKE_INSTALL_INFODIR) -- set(CMAKE_INSTALL_INFODIR "" CACHE PATH "info documentation (DATAROOTDIR/info)") -- set(CMAKE_INSTALL_INFODIR "${CMAKE_INSTALL_DATAROOTDIR}/info") --endif() -- --if(NOT CMAKE_INSTALL_LOCALEDIR) -- set(CMAKE_INSTALL_LOCALEDIR "" CACHE PATH "locale-dependent data (DATAROOTDIR/locale)") -- set(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DATAROOTDIR}/locale") --endif() -- --if(NOT CMAKE_INSTALL_MANDIR) -- set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)") -- set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man") --endif() -- --if(NOT CMAKE_INSTALL_DOCDIR) -- set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/PROJECT_NAME)") -- set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}") --endif() -- --#----------------------------------------------------------------------------- -- --mark_as_advanced( -- CMAKE_INSTALL_BINDIR -- CMAKE_INSTALL_SBINDIR -- CMAKE_INSTALL_LIBEXECDIR -- CMAKE_INSTALL_SYSCONFDIR -- CMAKE_INSTALL_SHAREDSTATEDIR -- CMAKE_INSTALL_LOCALSTATEDIR -- CMAKE_INSTALL_LIBDIR -- CMAKE_INSTALL_INCLUDEDIR -- CMAKE_INSTALL_OLDINCLUDEDIR -- CMAKE_INSTALL_DATAROOTDIR -- CMAKE_INSTALL_DATADIR -- CMAKE_INSTALL_INFODIR -- CMAKE_INSTALL_LOCALEDIR -- CMAKE_INSTALL_MANDIR -- CMAKE_INSTALL_DOCDIR -- ) -- --# Result directories --# --foreach(dir -- BINDIR -- SBINDIR -- LIBEXECDIR -- SYSCONFDIR -- SHAREDSTATEDIR -- LOCALSTATEDIR -- LIBDIR -- INCLUDEDIR -- OLDINCLUDEDIR -- DATAROOTDIR -- DATADIR -- INFODIR -- LOCALEDIR -- MANDIR -- DOCDIR -- ) -- if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}}) -- set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}") -- else() -- set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}") -- endif() --endforeach() diff -Nru librabbitmq-0.7.1/debian/rules librabbitmq-0.9.0-0.1/debian/rules --- librabbitmq-0.7.1/debian/rules 2015-11-19 10:06:13.000000000 +0000 +++ librabbitmq-0.9.0-0.1/debian/rules 2019-10-20 10:14:51.000000000 +0000 @@ -1,10 +1,8 @@ #!/usr/bin/make -f +DEB_BUILD_OPTIONS=nocheck %: - dh $@ --buildsystem=cmake - -override_dh_strip: - dh_strip --dbg-package=librabbitmq-dbg + dh $@ --buildsystem=cmake --dbgsym-migration='librabbitmq-dbg (<< 0.9.0-0.1~)' override_dh_installman: set -e ; \ @@ -13,3 +11,10 @@ done docbook-to-man tools/doc/librabbitmq-tools.xml > librabbitmq-tools.7 dh_installman + +override_dh_auto_test: +ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),) + make -j1 test +endif + + diff -Nru librabbitmq-0.7.1/debian/source/format librabbitmq-0.9.0-0.1/debian/source/format --- librabbitmq-0.7.1/debian/source/format 2015-11-19 10:06:13.000000000 +0000 +++ librabbitmq-0.9.0-0.1/debian/source/format 2019-10-20 10:14:51.000000000 +0000 @@ -1 +1 @@ -3.0 (quilt) +3.0 (native) diff -Nru librabbitmq-0.7.1/descrip.mms librabbitmq-0.9.0-0.1/descrip.mms --- librabbitmq-0.7.1/descrip.mms 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/descrip.mms 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ - -ALL : LIBRABBITMQ - @ CONTINUE - -LIBRABBITMQ : - SET DEFAULT [.LIBRABBITMQ] - MMK$(MMSQUALIFIERS) - SET DEFAULT [-] - -EXAMPLES : LIBRABBITMQ - SET DEFAULT [.EXAMPLES] - MMK$(MMSQUALIFIERS) - SET DEFAULT [-] - diff -Nru librabbitmq-0.7.1/etc/build-ms.sh librabbitmq-0.9.0-0.1/etc/build-ms.sh --- librabbitmq-0.7.1/etc/build-ms.sh 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/etc/build-ms.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -#!/bin/bash - -# Build rabbitmq-c using Microsoft's C compiler - -set -e - -vs64= -sdk64= - -while [ $# -gt 0 ] ; do - case $1 in - --enable-64-bit) - vs64=/amd64 - sdk64=/x64 - ;; - *) - echo "Usage: build-ms.sh [ --enable-64-bit ]" 1>&2 - exit 1 - esac - shift -done - -# Locate the necessary lib and include directories - -drive=$(echo "$SYSTEMDRIVE" | sed 's|^\([A-Za-z]\):$|/\1|') - -for vsvers in 10.0 9.0 8 ; do - vsdir="$drive/Program Files/Microsoft Visual Studio $vsvers" - [ -x "$vsdir/VC/bin$vs64/cl.exe" ] && break - - vsdir="$drive/Program Files (x86)/Microsoft Visual Studio $vsvers" - [ -x "$vsdir/VC/bin$vs64/cl.exe" ] && break - - vsdir= -done - -if [ -z "$vsdir" ] ; then - echo "Couldn't find a suitable Visual Studio installation" - exit 1 -fi - -echo "Using Visual Studio install at $vsdir" - -for sdkpath in "Microsoft SDKs/Windows/"{v7.0A,v6.0A} "Microsoft Visual Studio 8/VC/PlatformSDK" ; do - sdkdir="$drive/Program Files/$sdkpath" - [ -d "$sdkdir/lib$sdk64" -a -d "$sdkdir/include" ] && break - - sdkdir="$drive/Program Files (x86)/$sdkpath" - [ -d "$sdkdir/lib$sdk64" -a -d "$sdkdir/include" ] && break - - sdkdir= -done - -if [ -z "$sdkdir" ] ; then - echo "Couldn't find suitable Windows SDK installation" - exit 1 -fi - -echo "Using Windows SDK install at $sdkdir" - -PATH="$PATH:$vsdir/VC/bin$vs64:$vsdir/Common7/IDE" -LIB="$vsdir/VC/lib$vs64:$sdkdir/lib$sdk64" -INCLUDE="$vsdir/VC/include:$sdkdir/include" -export PATH LIB INCLUDE - -# Do the build -set -x -autoreconf -i -./configure CC=cl.exe LD=link.exe CFLAGS='-nologo' -sed -i -e 's/^fix_srcfile_path=.*$/fix_srcfile_path=""/;s/^deplibs_check_method=.*$/deplibs_check_method=pass_all/;/^archive_cmds=/s/-link -dll/& -implib:\\$libname.\\$libext/' libtool -make - -# Copy the results of the build into one place, as "make install" -# isn't too useful here. -mkdir -p build/lib build/include build/bin -cp -a librabbitmq/.libs/*.dll examples/.libs/*.exe build/bin -cp -a librabbitmq/win32/msinttypes/*.h librabbitmq/amqp.h librabbitmq/amqp_framing.h build/include -cp -a librabbitmq/*.exp librabbitmq/*.lib build/lib diff -Nru librabbitmq-0.7.1/etc/install-mingw.sh librabbitmq-0.9.0-0.1/etc/install-mingw.sh --- librabbitmq-0.7.1/etc/install-mingw.sh 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/etc/install-mingw.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -#!/bin/bash - -if [ $# -ne 1 ] ; then - echo "usage: install-mingw.sh " 1>&2 - exit 1 -fi - -unpack_dir=$1 - -if [ -e "$unpack_dir" ] ; then - echo "Destination directory already exists; please delete it if you are sure" 1>&2 - exit 1 -fi - -set -e - -download_dir=/tmp/install-mingw.$$ -mkdir -p $download_dir $unpack_dir - -while read f ; do - wget -P $download_dir -N http://switch.dl.sourceforge.net/project/mingw/$f -done <&2 - exit 1 - ;; - esac -done - -rm -rf $download_dir diff -Nru librabbitmq-0.7.1/examples/amqp_bind.c librabbitmq-0.9.0-0.1/examples/amqp_bind.c --- librabbitmq-0.7.1/examples/amqp_bind.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqp_bind.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -34,19 +33,17 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include +#include #include -#include -#include #include -#include +#include #include "utils.h" -int main(int argc, char const *const *argv) -{ +int main(int argc, char const *const *argv) { char const *hostname; int port, status; char const *exchange; @@ -78,20 +75,21 @@ die("opening TCP socket"); } - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), + die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, + "guest", "guest"), "Logging in"); amqp_channel_open(conn, 1); die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); - amqp_queue_bind(conn, 1, - amqp_cstring_bytes(queue), - amqp_cstring_bytes(exchange), - amqp_cstring_bytes(bindingkey), + amqp_queue_bind(conn, 1, amqp_cstring_bytes(queue), + amqp_cstring_bytes(exchange), amqp_cstring_bytes(bindingkey), amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Unbinding"); - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); + die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), + "Closing channel"); + die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), + "Closing connection"); die_on_error(amqp_destroy_connection(conn), "Ending connection"); return 0; } diff -Nru librabbitmq-0.7.1/examples/amqp_connect_timeout.c librabbitmq-0.9.0-0.1/examples/amqp_connect_timeout.c --- librabbitmq-0.7.1/examples/amqp_connect_timeout.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqp_connect_timeout.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -37,46 +36,48 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include +#include #include -#include #include #include #include #ifdef _WIN32 -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include #else -# include +#include #endif #include "utils.h" -int main(int argc, char const *const *argv) -{ +int main(int argc, char const *const *argv) { char const *hostname; int port; amqp_socket_t *socket; amqp_connection_state_t conn; + struct timeval tval; struct timeval *tv; if (argc < 3) { - fprintf(stderr, "Usage: amqp_connect_timeout host port [timeout_sec [timeout_usec=0]]\n"); + fprintf(stderr, + "Usage: amqp_connect_timeout host port [timeout_sec " + "[timeout_usec=0]]\n"); return 1; } if (argc > 3) { - tv = malloc(sizeof(struct timeval)); + tv = &tval; tv->tv_sec = atoi(argv[3]); - if (argc > 4 ) { + if (argc > 4) { tv->tv_usec = atoi(argv[4]); } else { tv->tv_usec = 0; @@ -86,7 +87,6 @@ tv = NULL; } - hostname = argv[1]; port = atoi(argv[2]); @@ -98,13 +98,17 @@ die("creating TCP socket"); } - die_on_error(amqp_socket_open_noblock(socket, hostname, port, tv), "opening TCP socket"); + die_on_error(amqp_socket_open_noblock(socket, hostname, port, tv), + "opening TCP socket"); - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), "Logging in"); + die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, + "guest", "guest"), + "Logging in"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); + die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), + "Closing connection"); die_on_error(amqp_destroy_connection(conn), "Ending connection"); - printf ("Done\n"); + printf("Done\n"); return 0; } diff -Nru librabbitmq-0.7.1/examples/amqp_consumer.c librabbitmq-0.9.0-0.1/examples/amqp_consumer.c --- librabbitmq-0.7.1/examples/amqp_consumer.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqp_consumer.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -34,14 +33,13 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include +#include #include -#include -#include #include -#include +#include #include @@ -49,8 +47,7 @@ #define SUMMARY_EVERY_US 1000000 -static void run(amqp_connection_state_t conn) -{ +static void run(amqp_connection_state_t conn) { uint64_t start_time = now_microseconds(); int received = 0; int previous_received = 0; @@ -61,16 +58,18 @@ uint64_t now; - while (1) { + for (;;) { amqp_rpc_reply_t ret; amqp_envelope_t envelope; now = now_microseconds(); if (now > next_summary_time) { int countOverInterval = received - previous_received; - double intervalRate = countOverInterval / ((now - previous_report_time) / 1000000.0); + double intervalRate = + countOverInterval / ((now - previous_report_time) / 1000000.0); printf("%d ms: Received %d - %d since last report (%d Hz)\n", - (int)(now - start_time) / 1000, received, countOverInterval, (int) intervalRate); + (int)(now - start_time) / 1000, received, countOverInterval, + (int)intervalRate); previous_received = received; previous_report_time = now; @@ -90,14 +89,14 @@ if (AMQP_FRAME_METHOD == frame.frame_type) { switch (frame.payload.method.id) { case AMQP_BASIC_ACK_METHOD: - /* if we've turned publisher confirms on, and we've published a message - * here is a message being confirmed + /* if we've turned publisher confirms on, and we've published a + * message here is a message being confirmed. */ - break; case AMQP_BASIC_RETURN_METHOD: - /* if a published message couldn't be routed and the mandatory flag was set - * this is what would be returned. The message then needs to be read. + /* if a published message couldn't be routed and the mandatory + * flag was set this is what would be returned. The message then + * needs to be read. */ { amqp_message_t message; @@ -112,25 +111,28 @@ break; case AMQP_CHANNEL_CLOSE_METHOD: - /* a channel.close method happens when a channel exception occurs, this - * can happen by publishing to an exchange that doesn't exist for example + /* a channel.close method happens when a channel exception occurs, + * this can happen by publishing to an exchange that doesn't exist + * for example. * - * In this case you would need to open another channel redeclare any queues - * that were declared auto-delete, and restart any consumers that were attached - * to the previous channel + * In this case you would need to open another channel redeclare + * any queues that were declared auto-delete, and restart any + * consumers that were attached to the previous channel. */ return; case AMQP_CONNECTION_CLOSE_METHOD: - /* a connection.close method happens when a connection exception occurs, - * this can happen by trying to use a channel that isn't open for example. + /* a connection.close method happens when a connection exception + * occurs, this can happen by trying to use a channel that isn't + * open for example. * * In this case the whole connection must be restarted. */ return; default: - fprintf(stderr ,"An unexpected method was received %d\n", frame.payload.method.id); + fprintf(stderr, "An unexpected method was received %u\n", + frame.payload.method.id); return; } } @@ -144,8 +146,7 @@ } } -int main(int argc, char const *const *argv) -{ +int main(int argc, char const *const *argv) { char const *hostname; int port, status; char const *exchange; @@ -162,7 +163,7 @@ hostname = argv[1]; port = atoi(argv[2]); - exchange = "amq.direct"; /* argv[3]; */ + exchange = "amq.direct"; /* argv[3]; */ bindingkey = "test queue"; /* argv[4]; */ conn = amqp_new_connection(); @@ -177,14 +178,15 @@ die("opening TCP socket"); } - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), + die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, + "guest", "guest"), "Logging in"); amqp_channel_open(conn, 1); die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); { - amqp_queue_declare_ok_t *r = amqp_queue_declare(conn, 1, amqp_empty_bytes, 0, 0, 0, 1, - amqp_empty_table); + amqp_queue_declare_ok_t *r = amqp_queue_declare( + conn, 1, amqp_empty_bytes, 0, 0, 0, 1, amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring queue"); queuename = amqp_bytes_malloc_dup(r->queue); if (queuename.bytes == NULL) { @@ -193,17 +195,20 @@ } } - amqp_queue_bind(conn, 1, queuename, amqp_cstring_bytes(exchange), amqp_cstring_bytes(bindingkey), - amqp_empty_table); + amqp_queue_bind(conn, 1, queuename, amqp_cstring_bytes(exchange), + amqp_cstring_bytes(bindingkey), amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Binding queue"); - amqp_basic_consume(conn, 1, queuename, amqp_empty_bytes, 0, 1, 0, amqp_empty_table); + amqp_basic_consume(conn, 1, queuename, amqp_empty_bytes, 0, 1, 0, + amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Consuming"); run(conn); - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); + die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), + "Closing channel"); + die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), + "Closing connection"); die_on_error(amqp_destroy_connection(conn), "Ending connection"); return 0; diff -Nru librabbitmq-0.7.1/examples/amqp_exchange_declare.c librabbitmq-0.9.0-0.1/examples/amqp_exchange_declare.c --- librabbitmq-0.7.1/examples/amqp_exchange_declare.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqp_exchange_declare.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -34,19 +33,17 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include +#include #include -#include -#include #include -#include +#include #include "utils.h" -int main(int argc, char const *const *argv) -{ +int main(int argc, char const *const *argv) { char const *hostname; int port, status; char const *exchange; @@ -55,7 +52,8 @@ amqp_connection_state_t conn; if (argc < 5) { - fprintf(stderr, "Usage: amqp_exchange_declare host port exchange exchangetype\n"); + fprintf(stderr, + "Usage: amqp_exchange_declare host port exchange exchangetype\n"); return 1; } @@ -76,17 +74,21 @@ die("opening TCP socket"); } - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), + die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, + "guest", "guest"), "Logging in"); amqp_channel_open(conn, 1); die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); - amqp_exchange_declare(conn, 1, amqp_cstring_bytes(exchange), amqp_cstring_bytes(exchangetype), - 0, 0, 0, 0, amqp_empty_table); + amqp_exchange_declare(conn, 1, amqp_cstring_bytes(exchange), + amqp_cstring_bytes(exchangetype), 0, 0, 0, 0, + amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring exchange"); - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); + die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), + "Closing channel"); + die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), + "Closing connection"); die_on_error(amqp_destroy_connection(conn), "Ending connection"); return 0; } diff -Nru librabbitmq-0.7.1/examples/amqp_listen.c librabbitmq-0.9.0-0.1/examples/amqp_listen.c --- librabbitmq-0.7.1/examples/amqp_listen.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqp_listen.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -34,21 +33,19 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include +#include #include -#include -#include #include -#include +#include #include #include "utils.h" -int main(int argc, char const *const *argv) -{ +int main(int argc, char const *const *argv) { char const *hostname; int port, status; char const *exchange; @@ -80,14 +77,15 @@ die("opening TCP socket"); } - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), + die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, + "guest", "guest"), "Logging in"); amqp_channel_open(conn, 1); die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); { - amqp_queue_declare_ok_t *r = amqp_queue_declare(conn, 1, amqp_empty_bytes, 0, 0, 0, 1, - amqp_empty_table); + amqp_queue_declare_ok_t *r = amqp_queue_declare( + conn, 1, amqp_empty_bytes, 0, 0, 0, 1, amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring queue"); queuename = amqp_bytes_malloc_dup(r->queue); if (queuename.bytes == NULL) { @@ -96,15 +94,16 @@ } } - amqp_queue_bind(conn, 1, queuename, amqp_cstring_bytes(exchange), amqp_cstring_bytes(bindingkey), - amqp_empty_table); + amqp_queue_bind(conn, 1, queuename, amqp_cstring_bytes(exchange), + amqp_cstring_bytes(bindingkey), amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Binding queue"); - amqp_basic_consume(conn, 1, queuename, amqp_empty_bytes, 0, 1, 0, amqp_empty_table); + amqp_basic_consume(conn, 1, queuename, amqp_empty_bytes, 0, 1, 0, + amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Consuming"); { - while (1) { + for (;;) { amqp_rpc_reply_t res; amqp_envelope_t envelope; @@ -117,14 +116,14 @@ } printf("Delivery %u, exchange %.*s routingkey %.*s\n", - (unsigned) envelope.delivery_tag, - (int) envelope.exchange.len, (char *) envelope.exchange.bytes, - (int) envelope.routing_key.len, (char *) envelope.routing_key.bytes); + (unsigned)envelope.delivery_tag, (int)envelope.exchange.len, + (char *)envelope.exchange.bytes, (int)envelope.routing_key.len, + (char *)envelope.routing_key.bytes); if (envelope.message.properties._flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { printf("Content-type: %.*s\n", - (int) envelope.message.properties.content_type.len, - (char *) envelope.message.properties.content_type.bytes); + (int)envelope.message.properties.content_type.len, + (char *)envelope.message.properties.content_type.bytes); } printf("----\n"); @@ -134,8 +133,10 @@ } } - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); + die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), + "Closing channel"); + die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), + "Closing connection"); die_on_error(amqp_destroy_connection(conn), "Ending connection"); return 0; diff -Nru librabbitmq-0.7.1/examples/amqp_listenq.c librabbitmq-0.9.0-0.1/examples/amqp_listenq.c --- librabbitmq-0.7.1/examples/amqp_listenq.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqp_listenq.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -34,21 +33,19 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include +#include #include -#include -#include #include -#include +#include #include #include "utils.h" -int main(int argc, char const *const *argv) -{ +int main(int argc, char const *const *argv) { char const *hostname; int port, status; char const *queuename; @@ -76,47 +73,49 @@ die("opening TCP socket"); } - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), + die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, + "guest", "guest"), "Logging in"); amqp_channel_open(conn, 1); die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); - amqp_basic_consume(conn, 1, amqp_cstring_bytes(queuename), amqp_empty_bytes, 0, 0, 0, amqp_empty_table); + amqp_basic_consume(conn, 1, amqp_cstring_bytes(queuename), amqp_empty_bytes, + 0, 0, 0, amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Consuming"); - { - while (1) { - amqp_rpc_reply_t res; - amqp_envelope_t envelope; - - amqp_maybe_release_buffers(conn); - - res = amqp_consume_message(conn, &envelope, NULL, 0); - - if (AMQP_RESPONSE_NORMAL != res.reply_type) { - break; - } - - printf("Delivery %u, exchange %.*s routingkey %.*s\n", - (unsigned) envelope.delivery_tag, - (int) envelope.exchange.len, (char *) envelope.exchange.bytes, - (int) envelope.routing_key.len, (char *) envelope.routing_key.bytes); - - if (envelope.message.properties._flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { - printf("Content-type: %.*s\n", - (int) envelope.message.properties.content_type.len, - (char *) envelope.message.properties.content_type.bytes); - } - printf("----\n"); + for (;;) { + amqp_rpc_reply_t res; + amqp_envelope_t envelope; - amqp_dump(envelope.message.body.bytes, envelope.message.body.len); + amqp_maybe_release_buffers(conn); - amqp_destroy_envelope(&envelope); + res = amqp_consume_message(conn, &envelope, NULL, 0); + + if (AMQP_RESPONSE_NORMAL != res.reply_type) { + break; + } + + printf("Delivery %u, exchange %.*s routingkey %.*s\n", + (unsigned)envelope.delivery_tag, (int)envelope.exchange.len, + (char *)envelope.exchange.bytes, (int)envelope.routing_key.len, + (char *)envelope.routing_key.bytes); + + if (envelope.message.properties._flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { + printf("Content-type: %.*s\n", + (int)envelope.message.properties.content_type.len, + (char *)envelope.message.properties.content_type.bytes); } + printf("----\n"); + + amqp_dump(envelope.message.body.bytes, envelope.message.body.len); + + amqp_destroy_envelope(&envelope); } - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); + die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), + "Closing channel"); + die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), + "Closing connection"); die_on_error(amqp_destroy_connection(conn), "Ending connection"); return 0; diff -Nru librabbitmq-0.7.1/examples/amqp_producer.c librabbitmq-0.9.0-0.1/examples/amqp_producer.c --- librabbitmq-0.7.1/examples/amqp_producer.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqp_producer.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -34,24 +33,20 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include +#include #include -#include -#include #include -#include +#include #include "utils.h" #define SUMMARY_EVERY_US 1000000 -static void send_batch(amqp_connection_state_t conn, - char const *queue_name, - int rate_limit, - int message_count) -{ +static void send_batch(amqp_connection_state_t conn, char const *queue_name, + int rate_limit, int message_count) { uint64_t start_time = now_microseconds(); int i; int sent = 0; @@ -72,21 +67,18 @@ for (i = 0; i < message_count; i++) { uint64_t now = now_microseconds(); - die_on_error(amqp_basic_publish(conn, - 1, - amqp_cstring_bytes("amq.direct"), - amqp_cstring_bytes(queue_name), - 0, - 0, - NULL, + die_on_error(amqp_basic_publish(conn, 1, amqp_cstring_bytes("amq.direct"), + amqp_cstring_bytes(queue_name), 0, 0, NULL, message_bytes), "Publishing"); sent++; if (now > next_summary_time) { int countOverInterval = sent - previous_sent; - double intervalRate = countOverInterval / ((now - previous_report_time) / 1000000.0); + double intervalRate = + countOverInterval / ((now - previous_report_time) / 1000000.0); printf("%d ms: Sent %d - %d since last report (%d Hz)\n", - (int)(now - start_time) / 1000, sent, countOverInterval, (int) intervalRate); + (int)(now - start_time) / 1000, sent, countOverInterval, + (int)intervalRate); previous_sent = sent; previous_report_time = now; @@ -105,12 +97,12 @@ printf("PRODUCER - Message count: %d\n", message_count); printf("Total time, milliseconds: %d\n", total_delta / 1000); - printf("Overall messages-per-second: %g\n", (message_count / (total_delta / 1000000.0))); + printf("Overall messages-per-second: %g\n", + (message_count / (total_delta / 1000000.0))); } } -int main(int argc, char const *const *argv) -{ +int main(int argc, char const *const *argv) { char const *hostname; int port, status; int rate_limit; @@ -119,7 +111,8 @@ amqp_connection_state_t conn; if (argc < 5) { - fprintf(stderr, "Usage: amqp_producer host port rate_limit message_count\n"); + fprintf(stderr, + "Usage: amqp_producer host port rate_limit message_count\n"); return 1; } @@ -140,15 +133,18 @@ die("opening TCP socket"); } - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), + die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, + "guest", "guest"), "Logging in"); amqp_channel_open(conn, 1); die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); send_batch(conn, "test queue", rate_limit, message_count); - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); + die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), + "Closing channel"); + die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), + "Closing connection"); die_on_error(amqp_destroy_connection(conn), "Ending connection"); return 0; } diff -Nru librabbitmq-0.7.1/examples/amqp_rpc_sendstring_client.c librabbitmq-0.9.0-0.1/examples/amqp_rpc_sendstring_client.c --- librabbitmq-0.7.1/examples/amqp_rpc_sendstring_client.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqp_rpc_sendstring_client.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -34,21 +33,19 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include +#include #include -#include -#include #include -#include +#include #include #include "utils.h" -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { char const *hostname; int port, status; char const *exchange; @@ -59,7 +56,9 @@ amqp_bytes_t reply_to_queue; if (argc < 6) { /* minimum number of mandatory arguments */ - fprintf(stderr, "usage:\namqp_rpc_sendstring_client host port exchange routingkey messagebody\n"); + fprintf(stderr, + "usage:\namqp_rpc_sendstring_client host port exchange routingkey " + "messagebody\n"); return 1; } @@ -85,7 +84,8 @@ die("opening TCP socket"); } - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), + die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, + "guest", "guest"), "Logging in"); amqp_channel_open(conn, 1); die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); @@ -95,7 +95,8 @@ */ { - amqp_queue_declare_ok_t *r = amqp_queue_declare(conn, 1, amqp_empty_bytes, 0, 0, 0, 1, amqp_empty_table); + amqp_queue_declare_ok_t *r = amqp_queue_declare( + conn, 1, amqp_empty_bytes, 0, 0, 0, 1, amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring queue"); reply_to_queue = amqp_bytes_malloc_dup(r->queue); if (reply_to_queue.bytes == NULL) { @@ -114,8 +115,7 @@ */ amqp_basic_properties_t props; props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | - AMQP_BASIC_DELIVERY_MODE_FLAG | - AMQP_BASIC_REPLY_TO_FLAG | + AMQP_BASIC_DELIVERY_MODE_FLAG | AMQP_BASIC_REPLY_TO_FLAG | AMQP_BASIC_CORRELATION_ID_FLAG; props.content_type = amqp_cstring_bytes("text/plain"); props.delivery_mode = 2; /* persistent delivery mode */ @@ -129,14 +129,9 @@ /* publish */ - die_on_error(amqp_basic_publish(conn, - 1, - amqp_cstring_bytes(exchange), - amqp_cstring_bytes(routingkey), - 0, - 0, - &props, - amqp_cstring_bytes(messagebody)), + die_on_error(amqp_basic_publish(conn, 1, amqp_cstring_bytes(exchange), + amqp_cstring_bytes(routingkey), 0, 0, + &props, amqp_cstring_bytes(messagebody)), "Publishing"); amqp_bytes_free(props.reply_to); @@ -147,7 +142,8 @@ */ { - amqp_basic_consume(conn, 1, reply_to_queue, amqp_empty_bytes, 0, 1, 0, amqp_empty_table); + amqp_basic_consume(conn, 1, reply_to_queue, amqp_empty_bytes, 0, 1, 0, + amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Consuming"); amqp_bytes_free(reply_to_queue); @@ -160,7 +156,7 @@ size_t body_target; size_t body_received; - while (1) { + for (;;) { amqp_maybe_release_buffers(conn); result = amqp_simple_wait_frame(conn, &frame); printf("Result: %d\n", result); @@ -168,7 +164,7 @@ break; } - printf("Frame type: %d channel: %d\n", frame.frame_type, frame.channel); + printf("Frame type: %u channel: %u\n", frame.frame_type, frame.channel); if (frame.frame_type != AMQP_FRAME_METHOD) { continue; } @@ -178,11 +174,11 @@ continue; } - d = (amqp_basic_deliver_t *) frame.payload.method.decoded; + d = (amqp_basic_deliver_t *)frame.payload.method.decoded; printf("Delivery: %u exchange: %.*s routingkey: %.*s\n", - (unsigned) d->delivery_tag, - (int) d->exchange.len, (char *) d->exchange.bytes, - (int) d->routing_key.len, (char *) d->routing_key.bytes); + (unsigned)d->delivery_tag, (int)d->exchange.len, + (char *)d->exchange.bytes, (int)d->routing_key.len, + (char *)d->routing_key.bytes); result = amqp_simple_wait_frame(conn, &frame); if (result < 0) { @@ -193,10 +189,10 @@ fprintf(stderr, "Expected header!"); abort(); } - p = (amqp_basic_properties_t *) frame.payload.properties.decoded; + p = (amqp_basic_properties_t *)frame.payload.properties.decoded; if (p->_flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { - printf("Content-type: %.*s\n", - (int) p->content_type.len, (char *) p->content_type.bytes); + printf("Content-type: %.*s\n", (int)p->content_type.len, + (char *)p->content_type.bytes); } printf("----\n"); @@ -230,7 +226,6 @@ /* everything was fine, we can quit now because we received the reply */ break; } - } } @@ -238,8 +233,10 @@ closing */ - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); + die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), + "Closing channel"); + die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), + "Closing connection"); die_on_error(amqp_destroy_connection(conn), "Ending connection"); return 0; diff -Nru librabbitmq-0.7.1/examples/amqps_bind.c librabbitmq-0.9.0-0.1/examples/amqps_bind.c --- librabbitmq-0.7.1/examples/amqps_bind.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqps_bind.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ -/* - * ***** BEGIN LICENSE BLOCK ***** - * Version: MIT - * - * Portions created by Alan Antonuk are Copyright (c) 2012-2013 - * Alan Antonuk. All Rights Reserved. - * - * Portions created by Mike Steinert are Copyright (c) 2012-2013 - * Mike Steinert. All Rights Reserved. - * - * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc. - * All Rights Reserved. - * - * Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010 - * VMware, Inc. and Tony Garnock-Jones. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * ***** END LICENSE BLOCK ***** - */ - -#include -#include -#include - -#include -#include -#include - -#include "utils.h" - -int main(int argc, char const *const *argv) -{ - char const *hostname; - int port, status; - char const *exchange; - char const *bindingkey; - char const *queue; - amqp_socket_t *socket; - amqp_connection_state_t conn; - - if (argc < 6) { - fprintf(stderr, "Usage: amqps_bind host port exchange bindingkey queue " - "[cacert.pem [key.pem cert.pem]]\n"); - return 1; - } - - hostname = argv[1]; - port = atoi(argv[2]); - exchange = argv[3]; - bindingkey = argv[4]; - queue = argv[5]; - - conn = amqp_new_connection(); - - socket = amqp_ssl_socket_new(conn); - if (!socket) { - die("creating SSL/TLS socket"); - } - - if (argc > 6) { - status = amqp_ssl_socket_set_cacert(socket, argv[6]); - if (status) { - die("setting CA certificate"); - } - } - - if (argc > 8) { - status = amqp_ssl_socket_set_key(socket, argv[8], argv[7]); - if (status) { - die("setting client cert"); - } - } - - status = amqp_socket_open(socket, hostname, port); - if (status) { - die("opening SSL/TLS connection"); - } - - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), - "Logging in"); - amqp_channel_open(conn, 1); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); - - amqp_queue_bind(conn, 1, - amqp_cstring_bytes(queue), - amqp_cstring_bytes(exchange), - amqp_cstring_bytes(bindingkey), - amqp_empty_table); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Unbinding"); - - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); - die_on_error(amqp_destroy_connection(conn), "Ending connection"); - return 0; -} diff -Nru librabbitmq-0.7.1/examples/amqps_connect_timeout.c librabbitmq-0.9.0-0.1/examples/amqps_connect_timeout.c --- librabbitmq-0.7.1/examples/amqps_connect_timeout.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqps_connect_timeout.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ -/* - * ***** BEGIN LICENSE BLOCK ***** - * Version: MIT - * - * Portions created by Alan Antonuk are Copyright (c) 2012-2013 - * Alan Antonuk. All Rights Reserved. - * - * Portions created by Mike Steinert are Copyright (c) 2012-2013 - * Mike Steinert. All Rights Reserved. - * - * Portions created by Bogdan Padalko are Copyright (c) 2013. - * Bogdan Padalko. All Rights Reserved. - * - * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc. - * All Rights Reserved. - * - * Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010 - * VMware, Inc. and Tony Garnock-Jones. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * ***** END LICENSE BLOCK ***** - */ - -#include -#include -#include - -#include -#include - -#include - -#ifdef _WIN32 -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include -#else -# include -#endif - -#include "utils.h" - - -int main(int argc, char const *const *argv) -{ - char const nofile[2] = "-"; - char const *hostname; - int port, status; - amqp_socket_t *socket; - amqp_connection_state_t conn; - struct timeval *tv; - - if (argc < 3) { - fprintf(stderr, "Usage: amqps_connect_timeout host port " - "[cacert.pem [key.pem cert.pem [timeout_sec [timeout_usec=0]]]]\n"); - return 1; - } - - hostname = argv[1]; - port = atoi(argv[2]); - - if (argc > 6) { - tv = malloc(sizeof(struct timeval)); - - tv->tv_sec = atoi(argv[6]); - - if (argc > 7 ) { - tv->tv_usec = atoi(argv[7]); - } else { - tv->tv_usec = 0; - } - - } else { - tv = NULL; - } - - conn = amqp_new_connection(); - - socket = amqp_ssl_socket_new(conn); - if (!socket) { - die("creating SSL/TLS socket"); - } - - if (argc > 3 && strcmp(nofile, argv[3])) { - die_on_error(amqp_ssl_socket_set_cacert(socket, argv[3]), "setting CA certificate"); - } - - if (argc > 5) { - if (!strcmp(nofile, argv[5]) && !strcmp(nofile, argv[4])) { - status = 0; - } else if (!strcmp(nofile, argv[5]) || !strcmp(nofile, argv[4])) { - status = -1; - } else { - status = amqp_ssl_socket_set_key(socket, argv[5], argv[4]); - } - - if (status) { - die("setting client key"); - } - } - - die_on_error(amqp_socket_open_noblock(socket, hostname, port, tv), "opening SSL/TLS connection"); - - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), - "Logging in"); - - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); - die_on_error(amqp_destroy_connection(conn), "Ending connection"); - - printf ("Done\n"); - return 0; -} diff -Nru librabbitmq-0.7.1/examples/amqps_consumer.c librabbitmq-0.9.0-0.1/examples/amqps_consumer.c --- librabbitmq-0.7.1/examples/amqps_consumer.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqps_consumer.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,227 +0,0 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ -/* - * ***** BEGIN LICENSE BLOCK ***** - * Version: MIT - * - * Portions created by Alan Antonuk are Copyright (c) 2012-2013 - * Alan Antonuk. All Rights Reserved. - * - * Portions created by Mike Steinert are Copyright (c) 2012-2013 - * Mike Steinert. All Rights Reserved. - * - * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc. - * All Rights Reserved. - * - * Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010 - * VMware, Inc. and Tony Garnock-Jones. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * ***** END LICENSE BLOCK ***** - */ - -#include -#include -#include - -#include -#include -#include - -#include - -#include "utils.h" - -#define SUMMARY_EVERY_US 1000000 - -static void run(amqp_connection_state_t conn) -{ - uint64_t start_time = now_microseconds(); - int received = 0; - int previous_received = 0; - uint64_t previous_report_time = start_time; - uint64_t next_summary_time = start_time + SUMMARY_EVERY_US; - - amqp_frame_t frame; - - uint64_t now; - - while (1) { - amqp_rpc_reply_t ret; - amqp_envelope_t envelope; - - now = now_microseconds(); - if (now > next_summary_time) { - int countOverInterval = received - previous_received; - double intervalRate = countOverInterval / ((now - previous_report_time) / 1000000.0); - printf("%d ms: Received %d - %d since last report (%d Hz)\n", - (int)(now - start_time) / 1000, received, countOverInterval, (int) intervalRate); - - previous_received = received; - previous_report_time = now; - next_summary_time += SUMMARY_EVERY_US; - } - - amqp_maybe_release_buffers(conn); - ret = amqp_consume_message(conn, &envelope, NULL, 0); - - if (AMQP_RESPONSE_NORMAL != ret.reply_type) { - if (AMQP_RESPONSE_LIBRARY_EXCEPTION == ret.reply_type && - AMQP_STATUS_UNEXPECTED_STATE == ret.library_error) { - if (AMQP_STATUS_OK != amqp_simple_wait_frame(conn, &frame)) { - return; - } - - if (AMQP_FRAME_METHOD == frame.frame_type) { - switch (frame.payload.method.id) { - case AMQP_BASIC_ACK_METHOD: - /* if we've turned publisher confirms on, and we've published a message - * here is a message being confirmed - */ - - break; - case AMQP_BASIC_RETURN_METHOD: - /* if a published message couldn't be routed and the mandatory flag was set - * this is what would be returned. The message then needs to be read. - */ - { - amqp_message_t message; - ret = amqp_read_message(conn, frame.channel, &message, 0); - if (AMQP_RESPONSE_NORMAL != ret.reply_type) { - return; - } - - amqp_destroy_message(&message); - } - - break; - - case AMQP_CHANNEL_CLOSE_METHOD: - /* a channel.close method happens when a channel exception occurs, this - * can happen by publishing to an exchange that doesn't exist for example - * - * In this case you would need to open another channel redeclare any queues - * that were declared auto-delete, and restart any consumers that were attached - * to the previous channel - */ - return; - - case AMQP_CONNECTION_CLOSE_METHOD: - /* a connection.close method happens when a connection exception occurs, - * this can happen by trying to use a channel that isn't open for example. - * - * In this case the whole connection must be restarted. - */ - return; - - default: - fprintf(stderr ,"An unexpected method was received %d\n", frame.payload.method.id); - return; - } - } - } - - } else { - amqp_destroy_envelope(&envelope); - } - - - received++; - } -} - -int main(int argc, char const *const *argv) -{ - char const *hostname; - int port, status; - char const *exchange; - char const *bindingkey; - amqp_socket_t *socket; - amqp_connection_state_t conn; - amqp_bytes_t queuename; - - if (argc < 3) { - fprintf(stderr, "Usage: amqps_consumer host port " - "[cacert.pem [key.pem cert.pem]]\n"); - return 1; - } - - hostname = argv[1]; - port = atoi(argv[2]); - exchange = "amq.direct"; /* argv[3]; */ - bindingkey = "test queue"; /* argv[4]; */ - - conn = amqp_new_connection(); - - socket = amqp_ssl_socket_new(conn); - if (!socket) { - die("creating SSL/TLS socket"); - } - - if (argc > 3) { - status = amqp_ssl_socket_set_cacert(socket, argv[3]); - if (status) { - die("setting CA certificate"); - } - } - - if (argc > 5) { - status = amqp_ssl_socket_set_key(socket, argv[5], argv[4]); - if (status) { - die("setting client key"); - } - } - - status = amqp_socket_open(socket, hostname, port); - if (status) { - die("opening SSL/TLS connection"); - } - - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), - "Logging in"); - amqp_channel_open(conn, 1); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); - - { - amqp_queue_declare_ok_t *r = amqp_queue_declare(conn, 1, amqp_empty_bytes, 0, 0, 0, 1, - amqp_empty_table); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring queue"); - queuename = amqp_bytes_malloc_dup(r->queue); - if (queuename.bytes == NULL) { - fprintf(stderr, "Out of memory while copying queue name"); - return 1; - } - } - - amqp_queue_bind(conn, 1, queuename, amqp_cstring_bytes(exchange), amqp_cstring_bytes(bindingkey), - amqp_empty_table); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Binding queue"); - - amqp_basic_consume(conn, 1, queuename, amqp_empty_bytes, 0, 1, 0, amqp_empty_table); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Consuming"); - - run(conn); - - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); - die_on_error(amqp_destroy_connection(conn), "Ending connection"); - - return 0; -} diff -Nru librabbitmq-0.7.1/examples/amqp_sendstring.c librabbitmq-0.9.0-0.1/examples/amqp_sendstring.c --- librabbitmq-0.7.1/examples/amqp_sendstring.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqp_sendstring.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -34,19 +33,17 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include +#include #include -#include -#include #include -#include +#include #include "utils.h" -int main(int argc, char const *const *argv) -{ +int main(int argc, char const *const *argv) { char const *hostname; int port, status; char const *exchange; @@ -56,7 +53,9 @@ amqp_connection_state_t conn; if (argc < 6) { - fprintf(stderr, "Usage: amqp_sendstring host port exchange routingkey messagebody\n"); + fprintf( + stderr, + "Usage: amqp_sendstring host port exchange routingkey messagebody\n"); return 1; } @@ -78,7 +77,8 @@ die("opening TCP socket"); } - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), + die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, + "guest", "guest"), "Logging in"); amqp_channel_open(conn, 1); die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); @@ -88,19 +88,16 @@ props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | AMQP_BASIC_DELIVERY_MODE_FLAG; props.content_type = amqp_cstring_bytes("text/plain"); props.delivery_mode = 2; /* persistent delivery mode */ - die_on_error(amqp_basic_publish(conn, - 1, - amqp_cstring_bytes(exchange), - amqp_cstring_bytes(routingkey), - 0, - 0, - &props, - amqp_cstring_bytes(messagebody)), + die_on_error(amqp_basic_publish(conn, 1, amqp_cstring_bytes(exchange), + amqp_cstring_bytes(routingkey), 0, 0, + &props, amqp_cstring_bytes(messagebody)), "Publishing"); } - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); + die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), + "Closing channel"); + die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), + "Closing connection"); die_on_error(amqp_destroy_connection(conn), "Ending connection"); return 0; } diff -Nru librabbitmq-0.7.1/examples/amqps_exchange_declare.c librabbitmq-0.9.0-0.1/examples/amqps_exchange_declare.c --- librabbitmq-0.7.1/examples/amqps_exchange_declare.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqps_exchange_declare.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ -/* - * ***** BEGIN LICENSE BLOCK ***** - * Version: MIT - * - * Portions created by Alan Antonuk are Copyright (c) 2012-2013 - * Alan Antonuk. All Rights Reserved. - * - * Portions created by Mike Steinert are Copyright (c) 2012-2013 - * Mike Steinert. All Rights Reserved. - * - * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc. - * All Rights Reserved. - * - * Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010 - * VMware, Inc. and Tony Garnock-Jones. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * ***** END LICENSE BLOCK ***** - */ - -#include -#include -#include - -#include -#include -#include - -#include "utils.h" - -int main(int argc, char const *const *argv) -{ - char const *hostname; - int port, status; - char const *exchange; - char const *exchangetype; - amqp_socket_t *socket; - amqp_connection_state_t conn; - - if (argc < 5) { - fprintf(stderr, "Usage: amqps_exchange_declare host port exchange " - "exchangetype [cacert.pem [key.pem cert.pem]]\n"); - return 1; - } - - hostname = argv[1]; - port = atoi(argv[2]); - exchange = argv[3]; - exchangetype = argv[4]; - - conn = amqp_new_connection(); - - socket = amqp_ssl_socket_new(conn); - if (!socket) { - die("creating SSL/TLS socket"); - } - - if (argc > 5) { - status = amqp_ssl_socket_set_cacert(socket, argv[5]); - if (status) { - die("setting CA certificate"); - } - } - - if (argc > 7) { - status = amqp_ssl_socket_set_key(socket, argv[7], argv[6]); - if (status) { - die("setting client key/cert"); - } - } - - status = amqp_socket_open(socket, hostname, port); - if (status) { - die("opening SSL/TLS connection"); - } - - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), - "Logging in"); - amqp_channel_open(conn, 1); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); - - amqp_exchange_declare(conn, 1, amqp_cstring_bytes(exchange), amqp_cstring_bytes(exchangetype), - 0, 0, 0, 0, amqp_empty_table); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring exchange"); - - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); - die_on_error(amqp_destroy_connection(conn), "Ending connection"); - return 0; -} diff -Nru librabbitmq-0.7.1/examples/amqps_listen.c librabbitmq-0.9.0-0.1/examples/amqps_listen.c --- librabbitmq-0.7.1/examples/amqps_listen.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqps_listen.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,159 +0,0 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ -/* - * ***** BEGIN LICENSE BLOCK ***** - * Version: MIT - * - * Portions created by Alan Antonuk are Copyright (c) 2012-2013 - * Alan Antonuk. All Rights Reserved. - * - * Portions created by Mike Steinert are Copyright (c) 2012-2013 - * Mike Steinert. All Rights Reserved. - * - * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc. - * All Rights Reserved. - * - * Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010 - * VMware, Inc. and Tony Garnock-Jones. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * ***** END LICENSE BLOCK ***** - */ - -#include -#include -#include - -#include -#include -#include - -#include - -#include "utils.h" - -int main(int argc, char const *const *argv) -{ - char const *hostname; - int port, status; - char const *exchange; - char const *bindingkey; - amqp_socket_t *socket; - amqp_connection_state_t conn; - - amqp_bytes_t queuename; - - if (argc < 5) { - fprintf(stderr, "Usage: amqps_listen host port exchange bindingkey " - "[cacert.pem [key.pem cert.pem]]\n"); - return 1; - } - - hostname = argv[1]; - port = atoi(argv[2]); - exchange = argv[3]; - bindingkey = argv[4]; - - conn = amqp_new_connection(); - - socket = amqp_ssl_socket_new(conn); - if (!socket) { - die("creating SSL/TLS socket"); - } - - if (argc > 5) { - status = amqp_ssl_socket_set_cacert(socket, argv[5]); - if (status) { - die("setting CA certificate"); - } - } - - if (argc > 7) { - status = amqp_ssl_socket_set_key(socket, argv[7], argv[6]); - if (status) { - die("setting client cert"); - } - } - - status = amqp_socket_open(socket, hostname, port); - if (status) { - die("opening SSL/TLS connection"); - } - - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), - "Logging in"); - amqp_channel_open(conn, 1); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); - - { - amqp_queue_declare_ok_t *r = amqp_queue_declare(conn, 1, amqp_empty_bytes, 0, 0, 0, 1, - amqp_empty_table); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring queue"); - queuename = amqp_bytes_malloc_dup(r->queue); - if (queuename.bytes == NULL) { - fprintf(stderr, "Out of memory while copying queue name"); - return 1; - } - } - - amqp_queue_bind(conn, 1, queuename, amqp_cstring_bytes(exchange), amqp_cstring_bytes(bindingkey), - amqp_empty_table); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Binding queue"); - - amqp_basic_consume(conn, 1, queuename, amqp_empty_bytes, 0, 1, 0, amqp_empty_table); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Consuming"); - - { - while (1) { - amqp_rpc_reply_t res; - amqp_envelope_t envelope; - - amqp_maybe_release_buffers(conn); - - res = amqp_consume_message(conn, &envelope, NULL, 0); - - if (AMQP_RESPONSE_NORMAL != res.reply_type) { - break; - } - - printf("Delivery %u, exchange %.*s routingkey %.*s\n", - (unsigned) envelope.delivery_tag, - (int) envelope.exchange.len, (char *) envelope.exchange.bytes, - (int) envelope.routing_key.len, (char *) envelope.routing_key.bytes); - - if (envelope.message.properties._flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { - printf("Content-type: %.*s\n", - (int) envelope.message.properties.content_type.len, - (char *) envelope.message.properties.content_type.bytes); - } - printf("----\n"); - - amqp_dump(envelope.message.body.bytes, envelope.message.body.len); - - amqp_destroy_envelope(&envelope); - } - } - - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); - die_on_error(amqp_destroy_connection(conn), "Ending connection"); - - return 0; -} diff -Nru librabbitmq-0.7.1/examples/amqps_listenq.c librabbitmq-0.9.0-0.1/examples/amqps_listenq.c --- librabbitmq-0.7.1/examples/amqps_listenq.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqps_listenq.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ -/* - * ***** BEGIN LICENSE BLOCK ***** - * Version: MIT - * - * Portions created by Alan Antonuk are Copyright (c) 2012-2013 - * Alan Antonuk. All Rights Reserved. - * - * Portions created by Mike Steinert are Copyright (c) 2012-2013 - * Mike Steinert. All Rights Reserved. - * - * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc. - * All Rights Reserved. - * - * Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010 - * VMware, Inc. and Tony Garnock-Jones. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * ***** END LICENSE BLOCK ***** - */ - -#include -#include -#include - -#include -#include -#include - -#include - -#include "utils.h" - -int main(int argc, char const *const *argv) -{ - char const *hostname; - int port, status; - char const *queuename; - amqp_socket_t *socket; - amqp_connection_state_t conn; - - if (argc < 4) { - fprintf(stderr, "Usage: amqps_listenq host port queuename " - "[cacert.pem [key.pem cert.pem]]\n"); - return 1; - } - - hostname = argv[1]; - port = atoi(argv[2]); - queuename = argv[3]; - - conn = amqp_new_connection(); - - socket = amqp_ssl_socket_new(conn); - if (!socket) { - die("creating SSL/TLS socket"); - } - - if (argc > 4) { - status = amqp_ssl_socket_set_cacert(socket, argv[4]); - if (status) { - die("setting CA certificate"); - } - } - - if (argc > 6) { - status = amqp_ssl_socket_set_key(socket, argv[6], argv[5]); - if (status) { - die("setting client cert"); - } - } - - status = amqp_socket_open(socket, hostname, port); - if (status) { - die("opening SSL/TLS connection"); - } - - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), - "Logging in"); - amqp_channel_open(conn, 1); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); - - amqp_basic_consume(conn, 1, amqp_cstring_bytes(queuename), amqp_empty_bytes, 0, 0, 0, amqp_empty_table); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Consuming"); - - { - while (1) { - amqp_rpc_reply_t res; - amqp_envelope_t envelope; - - amqp_maybe_release_buffers(conn); - - res = amqp_consume_message(conn, &envelope, NULL, 0); - - if (AMQP_RESPONSE_NORMAL != res.reply_type) { - break; - } - - printf("Delivery %u, exchange %.*s routingkey %.*s\n", - (unsigned) envelope.delivery_tag, - (int) envelope.exchange.len, (char *) envelope.exchange.bytes, - (int) envelope.routing_key.len, (char *) envelope.routing_key.bytes); - - if (envelope.message.properties._flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { - printf("Content-type: %.*s\n", - (int) envelope.message.properties.content_type.len, - (char *) envelope.message.properties.content_type.bytes); - } - printf("----\n"); - - amqp_dump(envelope.message.body.bytes, envelope.message.body.len); - - amqp_destroy_envelope(&envelope); - } - } - - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); - die_on_error(amqp_destroy_connection(conn), "Ending connection"); - - return 0; -} diff -Nru librabbitmq-0.7.1/examples/amqps_producer.c librabbitmq-0.9.0-0.1/examples/amqps_producer.c --- librabbitmq-0.7.1/examples/amqps_producer.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqps_producer.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ -/* - * ***** BEGIN LICENSE BLOCK ***** - * Version: MIT - * - * Portions created by Alan Antonuk are Copyright (c) 2012-2013 - * Alan Antonuk. All Rights Reserved. - * - * Portions created by Mike Steinert are Copyright (c) 2012-2013 - * Mike Steinert. All Rights Reserved. - * - * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc. - * All Rights Reserved. - * - * Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010 - * VMware, Inc. and Tony Garnock-Jones. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * ***** END LICENSE BLOCK ***** - */ - -#include -#include -#include - -#include -#include -#include - -#include "utils.h" - -#define SUMMARY_EVERY_US 1000000 - -static void send_batch(amqp_connection_state_t conn, - char const *queue_name, - int rate_limit, - int message_count) -{ - uint64_t start_time = now_microseconds(); - int i; - int sent = 0; - int previous_sent = 0; - uint64_t previous_report_time = start_time; - uint64_t next_summary_time = start_time + SUMMARY_EVERY_US; - - char message[256]; - amqp_bytes_t message_bytes; - - for (i = 0; i < (int)sizeof(message); i++) { - message[i] = i & 0xff; - } - - message_bytes.len = sizeof(message); - message_bytes.bytes = message; - - for (i = 0; i < message_count; i++) { - uint64_t now = now_microseconds(); - - die_on_error(amqp_basic_publish(conn, - 1, - amqp_cstring_bytes("amq.direct"), - amqp_cstring_bytes(queue_name), - 0, - 0, - NULL, - message_bytes), - "Publishing"); - sent++; - if (now > next_summary_time) { - int countOverInterval = sent - previous_sent; - double intervalRate = countOverInterval / ((now - previous_report_time) / 1000000.0); - printf("%d ms: Sent %d - %d since last report (%d Hz)\n", - (int)(now - start_time) / 1000, sent, countOverInterval, (int) intervalRate); - - previous_sent = sent; - previous_report_time = now; - next_summary_time += SUMMARY_EVERY_US; - } - - while (((i * 1000000.0) / (now - start_time)) > rate_limit) { - microsleep(2000); - now = now_microseconds(); - } - } - - { - uint64_t stop_time = now_microseconds(); - int total_delta = stop_time - start_time; - - printf("PRODUCER - Message count: %d\n", message_count); - printf("Total time, milliseconds: %d\n", total_delta / 1000); - printf("Overall messages-per-second: %g\n", (message_count / (total_delta / 1000000.0))); - } -} - -int main(int argc, char const *const *argv) -{ - char const *hostname; - int port, status; - int rate_limit; - int message_count; - amqp_socket_t *socket; - amqp_connection_state_t conn; - - if (argc < 5) { - fprintf(stderr, "Usage: amqps_producer host port rate_limit message_count " - "[cacert.pem [key.pem cert.pem]]\n"); - return 1; - } - - hostname = argv[1]; - port = atoi(argv[2]); - rate_limit = atoi(argv[3]); - message_count = atoi(argv[4]); - - conn = amqp_new_connection(); - - socket = amqp_ssl_socket_new(conn); - if (!socket) { - die("creating SSL/TLS socket"); - } - - if (argc > 5) { - status = amqp_ssl_socket_set_cacert(socket, argv[5]); - if (status) { - die("setting CA certificate"); - } - } - - if (argc > 7) { - status = amqp_ssl_socket_set_key(socket, argv[7], argv[6]); - if (status) { - die("setting client cert"); - } - } - - status = amqp_socket_open(socket, hostname, port); - if (status) { - die("opening SSL/TLS connection"); - } - - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), - "Logging in"); - amqp_channel_open(conn, 1); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); - - send_batch(conn, "test queue", rate_limit, message_count); - - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); - die_on_error(amqp_destroy_connection(conn), "Ending connection"); - return 0; -} diff -Nru librabbitmq-0.7.1/examples/amqps_sendstring.c librabbitmq-0.9.0-0.1/examples/amqps_sendstring.c --- librabbitmq-0.7.1/examples/amqps_sendstring.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqps_sendstring.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ -/* - * ***** BEGIN LICENSE BLOCK ***** - * Version: MIT - * - * Portions created by Alan Antonuk are Copyright (c) 2012-2013 - * Alan Antonuk. All Rights Reserved. - * - * Portions created by Mike Steinert are Copyright (c) 2012-2013 - * Mike Steinert. All Rights Reserved. - * - * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc. - * All Rights Reserved. - * - * Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010 - * VMware, Inc. and Tony Garnock-Jones. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * ***** END LICENSE BLOCK ***** - */ - -#include -#include -#include - -#include -#include -#include - -#include "utils.h" - -int main(int argc, char const *const *argv) -{ - char const *hostname; - int port, status; - char const *exchange; - char const *routingkey; - char const *messagebody; - amqp_socket_t *socket; - amqp_connection_state_t conn; - - if (argc < 6) { - fprintf(stderr, "Usage: amqps_sendstring host port exchange routingkey " - "messagebody [cacert.pem [key.pem cert.pem]]\n"); - return 1; - } - - hostname = argv[1]; - port = atoi(argv[2]); - exchange = argv[3]; - routingkey = argv[4]; - messagebody = argv[5]; - - conn = amqp_new_connection(); - - socket = amqp_ssl_socket_new(conn); - if (!socket) { - die("creating SSL/TLS socket"); - } - - if (argc > 6) { - status = amqp_ssl_socket_set_cacert(socket, argv[6]); - if (status) { - die("setting CA certificate"); - } - } - - if (argc > 8) { - status = amqp_ssl_socket_set_key(socket, argv[8], argv[7]); - if (status) { - die("setting client cert"); - } - } - - status = amqp_socket_open(socket, hostname, port); - if (status) { - die("opening SSL/TLS connection"); - } - - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), - "Logging in"); - amqp_channel_open(conn, 1); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); - - { - amqp_basic_properties_t props; - props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | AMQP_BASIC_DELIVERY_MODE_FLAG; - props.content_type = amqp_cstring_bytes("text/plain"); - props.delivery_mode = 2; /* persistent delivery mode */ - die_on_error(amqp_basic_publish(conn, - 1, - amqp_cstring_bytes(exchange), - amqp_cstring_bytes(routingkey), - 0, - 0, - &props, - amqp_cstring_bytes(messagebody)), - "Publishing"); - } - - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); - die_on_error(amqp_destroy_connection(conn), "Ending connection"); - return 0; -} diff -Nru librabbitmq-0.7.1/examples/amqp_ssl_connect.c librabbitmq-0.9.0-0.1/examples/amqp_ssl_connect.c --- librabbitmq-0.7.1/examples/amqp_ssl_connect.c 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqp_ssl_connect.c 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1,135 @@ +/* + * ***** BEGIN LICENSE BLOCK ***** + * Version: MIT + * + * Portions created by Alan Antonuk are Copyright (c) 2012-2013 + * Alan Antonuk. All Rights Reserved. + * + * Portions created by Mike Steinert are Copyright (c) 2012-2013 + * Mike Steinert. All Rights Reserved. + * + * Portions created by Bogdan Padalko are Copyright (c) 2013. + * Bogdan Padalko. All Rights Reserved. + * + * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc. + * All Rights Reserved. + * + * Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010 + * VMware, Inc. and Tony Garnock-Jones. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * ***** END LICENSE BLOCK ***** + */ + +#include +#include +#include +#include + +#include +#include + +#include + +#ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#else +#include +#endif + +#include "utils.h" + +int main(int argc, char const *const *argv) { + char const *hostname; + int port; + int timeout; + amqp_socket_t *socket; + amqp_connection_state_t conn; + struct timeval tval; + struct timeval *tv; + + if (argc < 3) { + fprintf(stderr, + "Usage: amqps_connect_timeout host port timeout_sec " + "[cacert.pem [verifypeer] [verifyhostname] [key.pem cert.pem]]\n"); + return 1; + } + + hostname = argv[1]; + port = atoi(argv[2]); + + timeout = atoi(argv[3]); + if (timeout > 0) { + tv = &tval; + + tv->tv_sec = timeout; + tv->tv_usec = 0; + } else { + tv = NULL; + } + + conn = amqp_new_connection(); + + socket = amqp_ssl_socket_new(conn); + if (!socket) { + die("creating SSL/TLS socket"); + } + + amqp_ssl_socket_set_verify_peer(socket, 0); + amqp_ssl_socket_set_verify_hostname(socket, 0); + + if (argc > 5) { + int nextarg = 5; + die_on_error(amqp_ssl_socket_set_cacert(socket, argv[4]), + "setting CA certificate"); + if (argc > nextarg && !strcmp("verifypeer", argv[nextarg])) { + amqp_ssl_socket_set_verify_peer(socket, 1); + nextarg++; + } + if (argc > nextarg && !strcmp("verifyhostname", argv[nextarg])) { + amqp_ssl_socket_set_verify_hostname(socket, 1); + nextarg++; + } + if (argc > nextarg + 1) { + die_on_error( + amqp_ssl_socket_set_key(socket, argv[nextarg + 1], argv[nextarg]), + "setting client key"); + } + } + + die_on_error(amqp_socket_open_noblock(socket, hostname, port, tv), + "opening SSL/TLS connection"); + + die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, + "guest", "guest"), + "Logging in"); + + die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), + "Closing connection"); + die_on_error(amqp_destroy_connection(conn), "Ending connection"); + die_on_error(amqp_uninitialize_ssl_library(), "Uninitializing SSL library"); + + printf("Done\n"); + return 0; +} diff -Nru librabbitmq-0.7.1/examples/amqps_unbind.c librabbitmq-0.9.0-0.1/examples/amqps_unbind.c --- librabbitmq-0.7.1/examples/amqps_unbind.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqps_unbind.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ -/* - * ***** BEGIN LICENSE BLOCK ***** - * Version: MIT - * - * Portions created by Alan Antonuk are Copyright (c) 2012-2013 - * Alan Antonuk. All Rights Reserved. - * - * Portions created by Mike Steinert are Copyright (c) 2012-2013 - * Mike Steinert. All Rights Reserved. - * - * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc. - * All Rights Reserved. - * - * Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010 - * VMware, Inc. and Tony Garnock-Jones. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * ***** END LICENSE BLOCK ***** - */ - -#include -#include -#include - -#include -#include -#include - -#include "utils.h" - -int main(int argc, char const *const *argv) -{ - char const *hostname; - int port, status; - char const *exchange; - char const *bindingkey; - char const *queue; - amqp_socket_t *socket; - amqp_connection_state_t conn; - - if (argc < 6) { - fprintf(stderr, "Usage: amqps_unbind host port exchange bindingkey queue " - "[cacert.pem [key.pem cert.pem]]\n"); - return 1; - } - - hostname = argv[1]; - port = atoi(argv[2]); - exchange = argv[3]; - bindingkey = argv[4]; - queue = argv[5]; - - conn = amqp_new_connection(); - - socket = amqp_ssl_socket_new(conn); - if (!socket) { - die("creating SSL/TLS socket"); - } - - if (argc > 6) { - status = amqp_ssl_socket_set_cacert(socket, argv[6]); - if (status) { - die("setting CA certificate"); - } - } - - if (argc > 8) { - status = amqp_ssl_socket_set_key(socket, argv[8], argv[7]); - if (status) { - die("setting client cert"); - } - } - - status = amqp_socket_open(socket, hostname, port); - if (status) { - die("opening SSL/TLS connection"); - } - - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), - "Logging in"); - amqp_channel_open(conn, 1); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); - - amqp_queue_unbind(conn, 1, - amqp_cstring_bytes(queue), - amqp_cstring_bytes(exchange), - amqp_cstring_bytes(bindingkey), - amqp_empty_table); - die_on_amqp_error(amqp_get_rpc_reply(conn), "Unbinding"); - - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); - die_on_error(amqp_destroy_connection(conn), "Ending connection"); - return 0; -} diff -Nru librabbitmq-0.7.1/examples/amqp_unbind.c librabbitmq-0.9.0-0.1/examples/amqp_unbind.c --- librabbitmq-0.7.1/examples/amqp_unbind.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/amqp_unbind.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -34,19 +33,17 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include +#include #include -#include -#include #include -#include +#include #include "utils.h" -int main(int argc, char const *const *argv) -{ +int main(int argc, char const *const *argv) { char const *hostname; int port, status; char const *exchange; @@ -78,20 +75,21 @@ die("opening TCP socket"); } - die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), + die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, + "guest", "guest"), "Logging in"); amqp_channel_open(conn, 1); die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel"); - amqp_queue_unbind(conn, 1, - amqp_cstring_bytes(queue), + amqp_queue_unbind(conn, 1, amqp_cstring_bytes(queue), amqp_cstring_bytes(exchange), - amqp_cstring_bytes(bindingkey), - amqp_empty_table); + amqp_cstring_bytes(bindingkey), amqp_empty_table); die_on_amqp_error(amqp_get_rpc_reply(conn), "Unbinding"); - die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); - die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); + die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), + "Closing channel"); + die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), + "Closing connection"); die_on_error(amqp_destroy_connection(conn), "Ending connection"); return 0; } diff -Nru librabbitmq-0.7.1/examples/CMakeLists.txt librabbitmq-0.9.0-0.1/examples/CMakeLists.txt --- librabbitmq-0.7.1/examples/CMakeLists.txt 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/CMakeLists.txt 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,7 @@ -# vim:set ts=2 sw=2 sts=2 et: +if (NOT BUILD_SHARED_LIBS) + add_definitions(-DAMQP_STATIC) +endif() + include_directories(${LIBRABBITMQ_INCLUDE_DIRS}) if (WIN32) @@ -44,30 +47,6 @@ target_link_libraries(amqp_listenq ${RMQ_LIBRARY_TARGET}) if (ENABLE_SSL_SUPPORT) -add_executable(amqps_connect_timeout amqps_connect_timeout.c ${COMMON_SRCS}) -target_link_libraries(amqps_connect_timeout ${RMQ_LIBRARY_TARGET}) - -add_executable(amqps_sendstring amqps_sendstring.c ${COMMON_SRCS}) -target_link_libraries(amqps_sendstring ${RMQ_LIBRARY_TARGET}) - -add_executable(amqps_exchange_declare amqps_exchange_declare.c ${COMMON_SRCS}) -target_link_libraries(amqps_exchange_declare ${RMQ_LIBRARY_TARGET}) - -add_executable(amqps_listen amqps_listen.c ${COMMON_SRCS}) -target_link_libraries(amqps_listen ${RMQ_LIBRARY_TARGET}) - -add_executable(amqps_producer amqps_producer.c ${COMMON_SRCS}) -target_link_libraries(amqps_producer ${RMQ_LIBRARY_TARGET}) - -add_executable(amqps_consumer amqps_consumer.c ${COMMON_SRCS}) -target_link_libraries(amqps_consumer ${RMQ_LIBRARY_TARGET}) - -add_executable(amqps_unbind amqps_unbind.c ${COMMON_SRCS}) -target_link_libraries(amqps_unbind ${RMQ_LIBRARY_TARGET}) - -add_executable(amqps_bind amqps_bind.c ${COMMON_SRCS}) -target_link_libraries(amqps_bind ${RMQ_LIBRARY_TARGET}) - -add_executable(amqps_listenq amqps_listenq.c ${COMMON_SRCS}) -target_link_libraries(amqps_listenq ${RMQ_LIBRARY_TARGET}) +add_executable(amqp_ssl_connect amqp_ssl_connect.c ${COMMON_SRCS}) +target_link_libraries(amqp_ssl_connect ${RMQ_LIBRARY_TARGET}) endif (ENABLE_SSL_SUPPORT) diff -Nru librabbitmq-0.7.1/examples/descrip.mms librabbitmq-0.9.0-0.1/examples/descrip.mms --- librabbitmq-0.7.1/examples/descrip.mms 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/descrip.mms 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ - -OBJS = AMQP_BIND.OBJ, AMQP_CONSUMER.OBJ, AMQP_EXCHANGE_DECLARE.OBJ, AMQP_LISTEN.OBJ,- - AMQP_LISTENQ.OBJ, AMQP_PRODUCER.OBJ, AMQP_SENDSTRING.OBJ, AMQP_UNBIND.OBJ, UTILS.OBJ,- - PLATFORM_UTILS.OBJ - -COM_OBJS = UTILS.OBJ, PLATFORM_UTILS.OBJ - -REAL_TARGETS = AMQP_BIND.EXE AMQP_CONSUMER.EXE AMQP_EXCHANGE_DECLARE.EXE AMQP_LISTEN.EXE AMQP_LISTENQ.EXE AMQP_PRODUCER.EXE AMQP_SENDSTRING.EXE AMQP_UNBIND.EXE - -.INCLUDE [-.vms]INCLUDE.MMS - -CFLAGS = $(OPTFLAGS)/DEFINE=($(DEFS))/INCLUDE=($(INC),"../vms","../librabbitmq") -LDFLAGS = /TRACE - -AMQP_BIND.EXE : AMQP_BIND.OBJ, $(COM_OBJS) - LINK$(LDFLAGS)/EXE=$(MMS$TARGET) $(MMS$SOURCE_LIST),[-.librabbitmq]rabbitmq.olb/lib - -AMQP_CONSUMER.EXE : AMQP_CONSUMER.OBJ, $(COM_OBJS) - LINK$(LDFLAGS)/EXE=$(MMS$TARGET) $(MMS$SOURCE_LIST),[-.librabbitmq]rabbitmq.olb/lib - -AMQP_EXCHANGE_DECLARE.EXE : AMQP_EXCHANGE_DECLARE.OBJ, $(COM_OBJS) - LINK$(LDFLAGS)/EXE=$(MMS$TARGET) $(MMS$SOURCE_LIST),[-.librabbitmq]rabbitmq.olb/lib - -AMQP_LISTEN.EXE : AMQP_LISTEN.OBJ, $(COM_OBJS) - LINK$(LDFLAGS)/EXE=$(MMS$TARGET) $(MMS$SOURCE_LIST),[-.librabbitmq]rabbitmq.olb/lib - -AMQP_LISTENQ.EXE : AMQP_LISTENQ.OBJ, $(COM_OBJS) - LINK$(LDFLAGS)/EXE=$(MMS$TARGET) $(MMS$SOURCE_LIST),[-.librabbitmq]rabbitmq.olb/lib - -AMQP_PRODUCER.EXE : AMQP_PRODUCER.OBJ, $(COM_OBJS) - LINK$(LDFLAGS)/EXE=$(MMS$TARGET) $(MMS$SOURCE_LIST),[-.librabbitmq]rabbitmq.olb/lib - -AMQP_SENDSTRING.EXE : AMQP_SENDSTRING.OBJ, $(COM_OBJS) - LINK$(LDFLAGS)/EXE=$(MMS$TARGET) $(MMS$SOURCE_LIST),[-.librabbitmq]rabbitmq.olb/lib - -AMQP_UNBIND.EXE : AMQP_UNBIND.OBJ, $(COM_OBJS) - LINK$(LDFLAGS)/EXE=$(MMS$TARGET) $(MMS$SOURCE_LIST),[-.librabbitmq]rabbitmq.olb/lib - - -PLATFORM_UTILS.OBJ : [.UNIX]PLATFORM_UTILS.C -PLATFORM_UTILS.MMSD : [.UNIX]PLATFORM_UTILS.C diff -Nru librabbitmq-0.7.1/examples/unix/platform_utils.c librabbitmq-0.9.0-0.1/examples/unix/platform_utils.c --- librabbitmq-0.7.1/examples/unix/platform_utils.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/unix/platform_utils.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -35,19 +34,17 @@ */ #include -#include #include +#include #include -uint64_t now_microseconds(void) -{ +uint64_t now_microseconds(void) { struct timeval tv; gettimeofday(&tv, NULL); - return (uint64_t) tv.tv_sec * 1000000 + (uint64_t) tv.tv_usec; + return (uint64_t)tv.tv_sec * 1000000 + (uint64_t)tv.tv_usec; } -void microsleep(int usec) -{ +void microsleep(int usec) { struct timespec req; req.tv_sec = 0; req.tv_nsec = 1000 * usec; diff -Nru librabbitmq-0.7.1/examples/utils.c librabbitmq-0.9.0-0.1/examples/utils.c --- librabbitmq-0.7.1/examples/utils.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/utils.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -34,20 +33,19 @@ * ***** END LICENSE BLOCK ***** */ +#include #include -#include #include +#include #include -#include -#include #include #include +#include #include "utils.h" -void die(const char *fmt, ...) -{ +void die(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); @@ -56,58 +54,55 @@ exit(1); } -void die_on_error(int x, char const *context) -{ +void die_on_error(int x, char const *context) { if (x < 0) { fprintf(stderr, "%s: %s\n", context, amqp_error_string2(x)); exit(1); } } -void die_on_amqp_error(amqp_rpc_reply_t x, char const *context) -{ +void die_on_amqp_error(amqp_rpc_reply_t x, char const *context) { switch (x.reply_type) { - case AMQP_RESPONSE_NORMAL: - return; + case AMQP_RESPONSE_NORMAL: + return; - case AMQP_RESPONSE_NONE: - fprintf(stderr, "%s: missing RPC reply type!\n", context); - break; - - case AMQP_RESPONSE_LIBRARY_EXCEPTION: - fprintf(stderr, "%s: %s\n", context, amqp_error_string2(x.library_error)); - break; - - case AMQP_RESPONSE_SERVER_EXCEPTION: - switch (x.reply.id) { - case AMQP_CONNECTION_CLOSE_METHOD: { - amqp_connection_close_t *m = (amqp_connection_close_t *) x.reply.decoded; - fprintf(stderr, "%s: server connection error %d, message: %.*s\n", - context, - m->reply_code, - (int) m->reply_text.len, (char *) m->reply_text.bytes); + case AMQP_RESPONSE_NONE: + fprintf(stderr, "%s: missing RPC reply type!\n", context); break; - } - case AMQP_CHANNEL_CLOSE_METHOD: { - amqp_channel_close_t *m = (amqp_channel_close_t *) x.reply.decoded; - fprintf(stderr, "%s: server channel error %d, message: %.*s\n", - context, - m->reply_code, - (int) m->reply_text.len, (char *) m->reply_text.bytes); + + case AMQP_RESPONSE_LIBRARY_EXCEPTION: + fprintf(stderr, "%s: %s\n", context, amqp_error_string2(x.library_error)); break; - } - default: - fprintf(stderr, "%s: unknown server error, method id 0x%08X\n", context, x.reply.id); + + case AMQP_RESPONSE_SERVER_EXCEPTION: + switch (x.reply.id) { + case AMQP_CONNECTION_CLOSE_METHOD: { + amqp_connection_close_t *m = + (amqp_connection_close_t *)x.reply.decoded; + fprintf(stderr, "%s: server connection error %uh, message: %.*s\n", + context, m->reply_code, (int)m->reply_text.len, + (char *)m->reply_text.bytes); + break; + } + case AMQP_CHANNEL_CLOSE_METHOD: { + amqp_channel_close_t *m = (amqp_channel_close_t *)x.reply.decoded; + fprintf(stderr, "%s: server channel error %uh, message: %.*s\n", + context, m->reply_code, (int)m->reply_text.len, + (char *)m->reply_text.bytes); + break; + } + default: + fprintf(stderr, "%s: unknown server error, method id 0x%08X\n", + context, x.reply.id); + break; + } break; - } - break; } exit(1); } -static void dump_row(long count, int numinrow, int *chs) -{ +static void dump_row(long count, int numinrow, int *chs) { int i; printf("%08lX:", count - numinrow); @@ -137,11 +132,10 @@ printf("\n"); } -static int rows_eq(int *a, int *b) -{ +static int rows_eq(int *a, int *b) { int i; - for (i=0; i<16; i++) + for (i = 0; i < 16; i++) if (a[i] != b[i]) { return 0; } @@ -149,9 +143,8 @@ return 1; } -void amqp_dump(void const *buffer, size_t len) -{ - unsigned char *buf = (unsigned char *) buffer; +void amqp_dump(void const *buffer, size_t len) { + unsigned char *buf = (unsigned char *)buffer; long count = 0; int numinrow = 0; int chs[16]; @@ -163,20 +156,21 @@ int ch = buf[i]; if (numinrow == 16) { - int i; + int j; if (rows_eq(oldchs, chs)) { if (!showed_dots) { showed_dots = 1; - printf(" .. .. .. .. .. .. .. .. : .. .. .. .. .. .. .. ..\n"); + printf( + " .. .. .. .. .. .. .. .. : .. .. .. .. .. .. .. ..\n"); } } else { showed_dots = 0; dump_row(count, numinrow, chs); } - for (i=0; i<16; i++) { - oldchs[i] = chs[i]; + for (j = 0; j < 16; j++) { + oldchs[j] = chs[j]; } numinrow = 0; diff -Nru librabbitmq-0.7.1/examples/utils.h librabbitmq-0.9.0-0.1/examples/utils.h --- librabbitmq-0.7.1/examples/utils.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/utils.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ #ifndef librabbitmq_examples_utils_h #define librabbitmq_examples_utils_h diff -Nru librabbitmq-0.7.1/examples/win32/platform_utils.c librabbitmq-0.9.0-0.1/examples/win32/platform_utils.c --- librabbitmq-0.7.1/examples/win32/platform_utils.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/examples/win32/platform_utils.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -38,15 +37,11 @@ #include -uint64_t now_microseconds(void) -{ +uint64_t now_microseconds(void) { FILETIME ft; GetSystemTimeAsFileTime(&ft); - return (((uint64_t)ft.dwHighDateTime << 32) | (uint64_t)ft.dwLowDateTime) - / 10; + return (((uint64_t)ft.dwHighDateTime << 32) | (uint64_t)ft.dwLowDateTime) / + 10; } -void microsleep(int usec) -{ - Sleep(usec / 1000); -} +void microsleep(int usec) { Sleep(usec / 1000); } diff -Nru librabbitmq-0.7.1/.gitattributes librabbitmq-0.9.0-0.1/.gitattributes --- librabbitmq-0.7.1/.gitattributes 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.gitattributes 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -# Default for those who don't have core.autocrlf set -* text=auto - -# Things that should be treated like text (lines converted on checkout): -*.c text -*.h text -*.py text -*.cmake text -*.md text -# This is for the output of table_test -*.expected text -*.xml - -# Exceptions to the rule: -*.ac text eol=lf -*.am text eol=lf -*.m4 text eol=lf - diff -Nru librabbitmq-0.7.1/.gitignore librabbitmq-0.9.0-0.1/.gitignore --- librabbitmq-0.7.1/.gitignore 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.gitignore 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -*.la -*.lo -*.o -.deps -.dirstamp -.libs -/aclocal.m4 -/autom4te.cache -/bin* -/compile -/config.guess -/config.h -/config.h.in -/config.h.in~ -/config.log -/config.status -/config.sub -/configure -/cscope.* -/depcomp -/install-sh -/libtool -/ltmain.sh -/missing -/stamp-h1 -/test-suite.log -INSTALL -Makefile -Makefile.in -examples/amqp_bind -examples/amqp_connect_timeout -examples/amqp_consumer -examples/amqp_exchange_declare -examples/amqp_listen -examples/amqp_listenq -examples/amqp_producer -examples/amqp_rpc_sendstring_client -examples/amqp_sendstring -examples/amqp_unbind -examples/amqps_bind -examples/amqps_connect_timeout -examples/amqps_consumer -examples/amqps_exchange_declare -examples/amqps_listen -examples/amqps_listenq -examples/amqps_producer -examples/amqps_sendstring -examples/amqps_unbind -librabbitmq.pc -test-driver -tests/*.log -tests/*.trs -tests/test_hostcheck -tests/test_parse_url -tests/test_status_enum -tests/test_tables -tools/amqp-consume -tools/amqp-declare-queue -tools/amqp-delete-queue -tools/amqp-get -tools/amqp-publish -tools/doc/*.1 -tools/doc/*.7 -tools/doc/man-date.ent -.ycm_extra_conf.py? -.DS_Store - -# Ignore editor swap files -*~ -*.sw? -.#* -\#*# diff -Nru librabbitmq-0.7.1/.gitmodules librabbitmq-0.9.0-0.1/.gitmodules --- librabbitmq-0.7.1/.gitmodules 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.gitmodules 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -[submodule "codegen"] - path = codegen - url = https://github.com/rabbitmq/rabbitmq-codegen.git diff -Nru librabbitmq-0.7.1/.hgignore librabbitmq-0.9.0-0.1/.hgignore --- librabbitmq-0.7.1/.hgignore 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.hgignore 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -^scratch$ - -^autom4te\.cache$ -^aclocal\.m4$ -^config\.(guess|log|status|sub|h\.in~?)$ -^configure$ -^depcomp$ -^install-sh$ -^ltmain.sh$ -^missing$ - -(^|/)\.libs$ -(^|/)\.deps$ -\.(o|lo|la)$ -^config\.h$ -^stamp-h1$ -^libtool$ - -^librabbitmq/amqp_framing\.[ch]$ - -^(|librabbitmq/|tests/|examples/|tools/|tools/doc/)Makefile(\.in)?$ -^tests/test_tables$ -^tests/test_parse_url$ -^examples/amqp_sendstring$ -^examples/amqp_rpc_sendstring_client$ -^examples/amqp_exchange_declare$ -^examples/amqp_listen$ -^examples/amqp_producer$ -^examples/amqp_consumer$ -^examples/amqp_unbind$ -^examples/amqp_bind$ -^examples/amqp_listenq$ - -^tools/amqp-publish$ -^tools/amqp-get$ -^tools/amqp-consume$ -^tools/amqp-declare-queue$ -^tools/amqp-delete-queue$ -^tools/.*\.[17]$ -^tools/doc/man-date.ent$ diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_api.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_api.c --- librabbitmq-0.7.1/librabbitmq/amqp_api.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_api.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -40,14 +39,13 @@ #ifdef _MSC_VER /* MSVC complains about sprintf being deprecated in favor of sprintf_s */ -# define _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS /* MSVC complains about strdup being deprecated in favor of _strdup */ -# define _CRT_NONSTDC_NO_DEPRECATE +#define _CRT_NONSTDC_NO_DEPRECATE #endif #include "amqp_private.h" #include "amqp_time.h" -#include #include #include #include @@ -57,51 +55,71 @@ #define ERROR_MASK (0x00FF) #define ERROR_CATEGORY_MASK (0xFF00) -enum error_category_enum_ { - EC_base = 0, - EC_tcp = 1, - EC_ssl = 2 -}; +enum error_category_enum_ { EC_base = 0, EC_tcp = 1, EC_ssl = 2 }; static const char *base_error_strings[] = { - "operation completed successfully", /* AMQP_STATUS_OK 0x0 */ - "could not allocate memory", /* AMQP_STATUS_NO_MEMORY -0x0001 */ - "invalid AMQP data", /* AMQP_STATUS_BAD_AQMP_DATA -0x0002 */ - "unknown AMQP class id", /* AMQP_STATUS_UNKNOWN_CLASS -0x0003 */ - "unknown AMQP method id", /* AMQP_STATUS_UNKNOWN_METHOD -0x0004 */ - "hostname lookup failed", /* AMQP_STATUS_HOSTNAME_RESOLUTION_FAILED -0x0005 */ - "incompatible AMQP version", /* AMQP_STATUS_INCOMPATIBLE_AMQP_VERSION -0x0006 */ - "connection closed unexpectedly", /* AMQP_STATUS_CONNECTION_CLOSED -0x0007 */ - "could not parse AMQP URL", /* AMQP_STATUS_BAD_AMQP_URL -0x0008 */ - "a socket error occurred", /* AMQP_STATUS_SOCKET_ERROR -0x0009 */ - "invalid parameter", /* AMQP_STATUS_INVALID_PARAMETER -0x000A */ - "table too large for buffer", /* AMQP_STATUS_TABLE_TOO_BIG -0x000B */ - "unexpected method received", /* AMQP_STATUS_WRONG_METHOD -0x000C */ - "request timed out", /* AMQP_STATUS_TIMEOUT -0x000D */ - "system timer has failed", /* AMQP_STATUS_TIMER_FAILED -0x000E */ - "heartbeat timeout, connection closed",/* AMQP_STATUS_HEARTBEAT_TIMEOUT -0x000F */ - "unexpected protocol state", /* AMQP_STATUS_UNEXPECTED STATE -0x0010 */ - "socket is closed", /* AMQP_STATUS_SOCKET_CLOSED -0x0011 */ - "socket already open", /* AMQP_STATUS_SOCKET_INUSE -0x0012 */ - "unsupported sasl method requested" /* AMQP_STATUS_BROKER_UNSUPPORTED_SASL_METHOD -0x0013 */ -}; + /* AMQP_STATUS_OK 0x0 */ + "operation completed successfully", + /* AMQP_STATUS_NO_MEMORY -0x0001 */ + "could not allocate memory", + /* AMQP_STATUS_BAD_AQMP_DATA -0x0002 */ + "invalid AMQP data", + /* AMQP_STATUS_UNKNOWN_CLASS -0x0003 */ + "unknown AMQP class id", + /* AMQP_STATUS_UNKNOWN_METHOD -0x0004 */ + "unknown AMQP method id", + /* AMQP_STATUS_HOSTNAME_RESOLUTION_FAILED -0x0005 */ + "hostname lookup failed", + /* AMQP_STATUS_INCOMPATIBLE_AMQP_VERSION -0x0006 */ + "incompatible AMQP version", + /* AMQP_STATUS_CONNECTION_CLOSED -0x0007 */ + "connection closed unexpectedly", + /* AMQP_STATUS_BAD_AMQP_URL -0x0008 */ + "could not parse AMQP URL", + /* AMQP_STATUS_SOCKET_ERROR -0x0009 */ + "a socket error occurred", + /* AMQP_STATUS_INVALID_PARAMETER -0x000A */ + "invalid parameter", + /* AMQP_STATUS_TABLE_TOO_BIG -0x000B */ + "table too large for buffer", + /* AMQP_STATUS_WRONG_METHOD -0x000C */ + "unexpected method received", + /* AMQP_STATUS_TIMEOUT -0x000D */ + "request timed out", + /* AMQP_STATUS_TIMER_FAILED -0x000E */ + "system timer has failed", + /* AMQP_STATUS_HEARTBEAT_TIMEOUT -0x000F */ + "heartbeat timeout, connection closed", + /* AMQP_STATUS_UNEXPECTED STATE -0x0010 */ + "unexpected protocol state", + /* AMQP_STATUS_SOCKET_CLOSED -0x0011 */ + "socket is closed", + /* AMQP_STATUS_SOCKET_INUSE -0x0012 */ + "socket already open", + /* AMQP_STATUS_BROKER_UNSUPPORTED_SASL_METHOD -0x00013 */ + "unsupported sasl method requested", + /* AMQP_STATUS_UNSUPPORTED -0x0014 */ + "parameter value is unsupported"}; static const char *tcp_error_strings[] = { - "a socket error occurred", /* AMQP_STATUS_TCP_ERROR -0x0100 */ - "socket library initialization failed" /* AMQP_STATUS_TCP_SOCKETLIB_INIT_ERROR -0x0101 */ -}; + /* AMQP_STATUS_TCP_ERROR -0x0100 */ + "a socket error occurred", + /* AMQP_STATUS_TCP_SOCKETLIB_INIT_ERROR -0x0101 */ + "socket library initialization failed"}; static const char *ssl_error_strings[] = { - "a SSL error occurred", /* AMQP_STATUS_SSL_ERROR -0x0200 */ - "SSL hostname verification failed", /* AMQP_STATUS_SSL_HOSTNAME_VERIFY_FAILED -0x0201 */ - "SSL peer cert verification failed", /* AMQP_STATUS_SSL_PEER_VERIFY_FAILED -0x0202 */ - "SSL handshake failed" /* AMQP_STATUS_SSL_CONNECTION_FAILED -0x0203 */ -}; + /* AMQP_STATUS_SSL_ERRO R -0x0200 */ + "a SSL error occurred", + /* AMQP_STATUS_SSL_HOSTNAME_VERIFY_FAILED -0x0201 */ + "SSL hostname verification failed", + /* AMQP_STATUS_SSL_PEER_VERIFY_FAILED -0x0202 */ + "SSL peer cert verification failed", + /* AMQP_STATUS_SSL_CONNECTION_FAILED -0x0203 */ + "SSL handshake failed"}; static const char *unknown_error_string = "(unknown error)"; -const char *amqp_error_string2(int code) -{ +const char *amqp_error_string2(int code) { const char *error_string; size_t category = (((-code) & ERROR_CATEGORY_MASK) >> 8); size_t error = (-code) & ERROR_MASK; @@ -135,14 +153,12 @@ default: error_string = unknown_error_string; break; - } return error_string; } -char *amqp_error_string(int code) -{ +char *amqp_error_string(int code) { /* Previously sometimes clients had to flip the sign on a return value from a * function to get the correct error code. Now, all error codes are negative. * To keep people's legacy code running correctly, we map all error codes to @@ -156,8 +172,7 @@ return strdup(amqp_error_string2(code)); } -void amqp_abort(const char *fmt, ...) -{ +void amqp_abort(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); @@ -166,28 +181,21 @@ abort(); } -const amqp_bytes_t amqp_empty_bytes = { 0, NULL }; -const amqp_table_t amqp_empty_table = { 0, NULL }; -const amqp_array_t amqp_empty_array = { 0, NULL }; - -#define RPC_REPLY(replytype)\ - (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL\ - ? (replytype *) state->most_recent_api_result.reply.decoded\ - : NULL) - -int amqp_basic_publish(amqp_connection_state_t state, - amqp_channel_t channel, - amqp_bytes_t exchange, - amqp_bytes_t routing_key, - amqp_boolean_t mandatory, - amqp_boolean_t immediate, +const amqp_bytes_t amqp_empty_bytes = {0, NULL}; +const amqp_table_t amqp_empty_table = {0, NULL}; +const amqp_array_t amqp_empty_array = {0, NULL}; + +int amqp_basic_publish(amqp_connection_state_t state, amqp_channel_t channel, + amqp_bytes_t exchange, amqp_bytes_t routing_key, + amqp_boolean_t mandatory, amqp_boolean_t immediate, amqp_basic_properties_t const *properties, - amqp_bytes_t body) -{ + amqp_bytes_t body) { amqp_frame_t f; size_t body_offset; - size_t usable_body_payload_size = state->frame_max - (HEADER_SIZE + FOOTER_SIZE); + size_t usable_body_payload_size = + state->frame_max - (HEADER_SIZE + FOOTER_SIZE); int res; + int flagz; amqp_basic_publish_t m; amqp_basic_properties_t default_properties; @@ -213,7 +221,7 @@ } res = amqp_send_method_inner(state, channel, AMQP_BASIC_PUBLISH_METHOD, &m, - AMQP_SF_MORE); + AMQP_SF_MORE, amqp_time_infinite()); if (res < 0) { return res; } @@ -227,9 +235,14 @@ f.channel = channel; f.payload.properties.class_id = AMQP_BASIC_CLASS; f.payload.properties.body_size = body.len; - f.payload.properties.decoded = (void *) properties; + f.payload.properties.decoded = (void *)properties; - res = amqp_send_frame_inner(state, &f, AMQP_SF_MORE); + if (body.len > 0) { + flagz = AMQP_SF_MORE; + } else { + flagz = AMQP_SF_NONE; + } + res = amqp_send_frame_inner(state, &f, flagz, amqp_time_infinite()); if (res < 0) { return res; } @@ -237,7 +250,6 @@ body_offset = 0; while (body_offset < body.len) { size_t remaining = body.len - body_offset; - int flagz; if (remaining == 0) { break; @@ -255,7 +267,7 @@ } body_offset += f.payload.body_fragment.len; - res = amqp_send_frame_inner(state, &f, flagz); + res = amqp_send_frame_inner(state, &f, flagz, amqp_time_infinite()); if (res < 0) { return res; } @@ -265,45 +277,46 @@ } amqp_rpc_reply_t amqp_channel_close(amqp_connection_state_t state, - amqp_channel_t channel, - int code) -{ + amqp_channel_t channel, int code) { char codestr[13]; - amqp_method_number_t replies[2] = { AMQP_CHANNEL_CLOSE_OK_METHOD, 0}; + amqp_method_number_t replies[2] = {AMQP_CHANNEL_CLOSE_OK_METHOD, 0}; amqp_channel_close_t req; - req.reply_code = code; + if (code < 0 || code > UINT16_MAX) { + return amqp_rpc_reply_error(AMQP_STATUS_INVALID_PARAMETER); + } + + req.reply_code = (uint16_t)code; req.reply_text.bytes = codestr; req.reply_text.len = sprintf(codestr, "%d", code); req.class_id = 0; req.method_id = 0; - return amqp_simple_rpc(state, channel, AMQP_CHANNEL_CLOSE_METHOD, - replies, &req); + return amqp_simple_rpc(state, channel, AMQP_CHANNEL_CLOSE_METHOD, replies, + &req); } amqp_rpc_reply_t amqp_connection_close(amqp_connection_state_t state, - int code) -{ + int code) { char codestr[13]; - amqp_method_number_t replies[2] = { AMQP_CONNECTION_CLOSE_OK_METHOD, 0}; + amqp_method_number_t replies[2] = {AMQP_CONNECTION_CLOSE_OK_METHOD, 0}; amqp_channel_close_t req; - req.reply_code = code; + if (code < 0 || code > UINT16_MAX) { + return amqp_rpc_reply_error(AMQP_STATUS_INVALID_PARAMETER); + } + + req.reply_code = (uint16_t)code; req.reply_text.bytes = codestr; req.reply_text.len = sprintf(codestr, "%d", code); req.class_id = 0; req.method_id = 0; - return amqp_simple_rpc(state, 0, AMQP_CONNECTION_CLOSE_METHOD, - replies, &req); + return amqp_simple_rpc(state, 0, AMQP_CONNECTION_CLOSE_METHOD, replies, &req); } -int amqp_basic_ack(amqp_connection_state_t state, - amqp_channel_t channel, - uint64_t delivery_tag, - amqp_boolean_t multiple) -{ +int amqp_basic_ack(amqp_connection_state_t state, amqp_channel_t channel, + uint64_t delivery_tag, amqp_boolean_t multiple) { amqp_basic_ack_t m; m.delivery_tag = delivery_tag; m.multiple = multiple; @@ -311,30 +324,22 @@ } 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) -{ - amqp_method_number_t replies[] = { AMQP_BASIC_GET_OK_METHOD, - AMQP_BASIC_GET_EMPTY_METHOD, - 0 - }; + amqp_channel_t channel, amqp_bytes_t queue, + amqp_boolean_t no_ack) { + amqp_method_number_t replies[] = {AMQP_BASIC_GET_OK_METHOD, + AMQP_BASIC_GET_EMPTY_METHOD, 0}; amqp_basic_get_t req; req.ticket = 0; req.queue = queue; req.no_ack = no_ack; - state->most_recent_api_result = amqp_simple_rpc(state, channel, - AMQP_BASIC_GET_METHOD, - replies, &req); + state->most_recent_api_result = + amqp_simple_rpc(state, channel, AMQP_BASIC_GET_METHOD, replies, &req); return state->most_recent_api_result; } -int amqp_basic_reject(amqp_connection_state_t state, - amqp_channel_t channel, - uint64_t delivery_tag, - amqp_boolean_t requeue) -{ +int amqp_basic_reject(amqp_connection_state_t state, amqp_channel_t channel, + uint64_t delivery_tag, amqp_boolean_t requeue) { amqp_basic_reject_t req; req.delivery_tag = delivery_tag; req.requeue = requeue; @@ -342,12 +347,48 @@ } int amqp_basic_nack(amqp_connection_state_t state, amqp_channel_t channel, - uint64_t delivery_tag, amqp_boolean_t multiple, - amqp_boolean_t requeue) -{ + uint64_t delivery_tag, amqp_boolean_t multiple, + amqp_boolean_t requeue) { amqp_basic_nack_t req; req.delivery_tag = delivery_tag; req.multiple = multiple; req.requeue = requeue; return amqp_send_method(state, channel, AMQP_BASIC_NACK_METHOD, &req); } + +struct timeval *amqp_get_handshake_timeout(amqp_connection_state_t state) { + return state->handshake_timeout; +} + +int amqp_set_handshake_timeout(amqp_connection_state_t state, + struct timeval *timeout) { + if (timeout) { + if (timeout->tv_sec < 0 || timeout->tv_usec < 0) { + return AMQP_STATUS_INVALID_PARAMETER; + } + state->internal_handshake_timeout = *timeout; + state->handshake_timeout = &state->internal_handshake_timeout; + } else { + state->handshake_timeout = NULL; + } + + return AMQP_STATUS_OK; +} + +struct timeval *amqp_get_rpc_timeout(amqp_connection_state_t state) { + return state->rpc_timeout; +} + +int amqp_set_rpc_timeout(amqp_connection_state_t state, + struct timeval *timeout) { + if (timeout) { + if (timeout->tv_sec < 0 || timeout->tv_usec < 0) { + return AMQP_STATUS_INVALID_PARAMETER; + } + state->rpc_timeout = &state->internal_rpc_timeout; + *state->rpc_timeout = *timeout; + } else { + state->rpc_timeout = NULL; + } + return AMQP_STATUS_OK; +} diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_connection.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_connection.c --- librabbitmq-0.7.1/librabbitmq/amqp_connection.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_connection.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -39,13 +38,12 @@ #endif #ifdef _MSC_VER -# define _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS #endif -#include "amqp_tcp_socket.h" #include "amqp_private.h" +#include "amqp_tcp_socket.h" #include "amqp_time.h" -#include #include #include #include @@ -60,22 +58,25 @@ #define AMQP_INITIAL_INBOUND_SOCK_BUFFER_SIZE 131072 #endif +#ifndef AMQP_DEFAULT_LOGIN_TIMEOUT_SEC +#define AMQP_DEFAULT_LOGIN_TIMEOUT_SEC 12 +#endif -#define ENFORCE_STATE(statevec, statenum) \ - { \ - amqp_connection_state_t _check_state = (statevec); \ - size_t _wanted_state = (statenum); \ - if (_check_state->state != _wanted_state) \ - amqp_abort("Programming error: invalid AMQP connection state: expected %d, got %d", \ - _wanted_state, \ - _check_state->state); \ +#define ENFORCE_STATE(statevec, statenum) \ + { \ + amqp_connection_state_t _check_state = (statevec); \ + amqp_connection_state_enum _wanted_state = (statenum); \ + if (_check_state->state != _wanted_state) \ + amqp_abort( \ + "Programming error: invalid AMQP connection state: expected %d, " \ + "got %d", \ + _wanted_state, _check_state->state); \ } -amqp_connection_state_t amqp_new_connection(void) -{ +amqp_connection_state_t amqp_new_connection(void) { int res; - amqp_connection_state_t state = - (amqp_connection_state_t) calloc(1, sizeof(struct amqp_connection_state_t_)); + amqp_connection_state_t state = (amqp_connection_state_t)calloc( + 1, sizeof(struct amqp_connection_state_t_)); if (state == NULL) { return NULL; @@ -95,13 +96,19 @@ state->target_size = 8; state->sock_inbound_buffer.len = AMQP_INITIAL_INBOUND_SOCK_BUFFER_SIZE; - state->sock_inbound_buffer.bytes = malloc(AMQP_INITIAL_INBOUND_SOCK_BUFFER_SIZE); + state->sock_inbound_buffer.bytes = + malloc(AMQP_INITIAL_INBOUND_SOCK_BUFFER_SIZE); if (state->sock_inbound_buffer.bytes == NULL) { goto out_nomem; } init_amqp_pool(&state->properties_pool, 512); + /* Use address of the internal_handshake_timeout object by default. */ + state->internal_handshake_timeout.tv_sec = AMQP_DEFAULT_LOGIN_TIMEOUT_SEC; + state->internal_handshake_timeout.tv_usec = 0; + state->handshake_timeout = &state->internal_handshake_timeout; + return state; out_nomem: @@ -110,14 +117,11 @@ return NULL; } -int amqp_get_sockfd(amqp_connection_state_t state) -{ +int amqp_get_sockfd(amqp_connection_state_t state) { return state->socket ? amqp_socket_get_sockfd(state->socket) : -1; } -void amqp_set_sockfd(amqp_connection_state_t state, - int sockfd) -{ +void amqp_set_sockfd(amqp_connection_state_t state, int sockfd) { amqp_socket_t *socket = amqp_tcp_socket_new(state); if (!socket) { amqp_abort("%s", strerror(errno)); @@ -125,23 +129,17 @@ amqp_tcp_socket_set_sockfd(socket, sockfd); } -void amqp_set_socket(amqp_connection_state_t state, amqp_socket_t *socket) -{ +void amqp_set_socket(amqp_connection_state_t state, amqp_socket_t *socket) { amqp_socket_delete(state->socket); state->socket = socket; } -amqp_socket_t * -amqp_get_socket(amqp_connection_state_t state) -{ +amqp_socket_t *amqp_get_socket(amqp_connection_state_t state) { return state->socket; } -int amqp_tune_connection(amqp_connection_state_t state, - int channel_max, - int frame_max, - int heartbeat) -{ +int amqp_tune_connection(amqp_connection_state_t state, int channel_max, + int frame_max, int heartbeat) { void *newbuf; int res; @@ -176,23 +174,19 @@ return AMQP_STATUS_OK; } -int amqp_get_channel_max(amqp_connection_state_t state) -{ +int amqp_get_channel_max(amqp_connection_state_t state) { return state->channel_max; } -int amqp_get_frame_max(amqp_connection_state_t state) -{ +int amqp_get_frame_max(amqp_connection_state_t state) { return state->frame_max; } -int amqp_get_heartbeat(amqp_connection_state_t state) -{ +int amqp_get_heartbeat(amqp_connection_state_t state) { return state->heartbeat; } -int amqp_destroy_connection(amqp_connection_state_t state) -{ +int amqp_destroy_connection(amqp_connection_state_t state) { int status = AMQP_STATUS_OK; if (state) { int i; @@ -215,8 +209,7 @@ return status; } -static void return_to_idle(amqp_connection_state_t state) -{ +static void return_to_idle(amqp_connection_state_t state) { state->inbound_buffer.len = sizeof(state->header_buffer); state->inbound_buffer.bytes = state->header_buffer; state->inbound_offset = 0; @@ -225,8 +218,7 @@ } static size_t consume_data(amqp_connection_state_t state, - amqp_bytes_t *received_data) -{ + amqp_bytes_t *received_data) { /* how much data is available and will fit? */ size_t bytes_consumed = state->target_size - state->inbound_offset; if (received_data->len < bytes_consumed) { @@ -242,10 +234,8 @@ return bytes_consumed; } -int amqp_handle_input(amqp_connection_state_t state, - amqp_bytes_t received_data, - amqp_frame_t *decoded_frame) -{ +int amqp_handle_input(amqp_connection_state_t state, amqp_bytes_t received_data, + amqp_frame_t *decoded_frame) { size_t bytes_consumed; void *raw_frame; @@ -272,172 +262,172 @@ raw_frame = state->inbound_buffer.bytes; switch (state->state) { - case CONNECTION_STATE_INITIAL: - /* check for a protocol header from the server */ - if (memcmp(raw_frame, "AMQP", 4) == 0) { - decoded_frame->frame_type = AMQP_PSEUDOFRAME_PROTOCOL_HEADER; - decoded_frame->channel = 0; - - decoded_frame->payload.protocol_header.transport_high - = amqp_d8(raw_frame, 4); - decoded_frame->payload.protocol_header.transport_low - = amqp_d8(raw_frame, 5); - decoded_frame->payload.protocol_header.protocol_version_major - = amqp_d8(raw_frame, 6); - decoded_frame->payload.protocol_header.protocol_version_minor - = amqp_d8(raw_frame, 7); + case CONNECTION_STATE_INITIAL: + /* check for a protocol header from the server */ + if (memcmp(raw_frame, "AMQP", 4) == 0) { + decoded_frame->frame_type = AMQP_PSEUDOFRAME_PROTOCOL_HEADER; + decoded_frame->channel = 0; + + decoded_frame->payload.protocol_header.transport_high = + amqp_d8(amqp_offset(raw_frame, 4)); + decoded_frame->payload.protocol_header.transport_low = + amqp_d8(amqp_offset(raw_frame, 5)); + decoded_frame->payload.protocol_header.protocol_version_major = + amqp_d8(amqp_offset(raw_frame, 6)); + decoded_frame->payload.protocol_header.protocol_version_minor = + amqp_d8(amqp_offset(raw_frame, 7)); - return_to_idle(state); - return (int)bytes_consumed; - } + return_to_idle(state); + return (int)bytes_consumed; + } /* it's not a protocol header; fall through to process it as a regular frame header */ - case CONNECTION_STATE_HEADER: { - amqp_channel_t channel; - amqp_pool_t *channel_pool; - /* frame length is 3 bytes in */ - channel = amqp_d16(raw_frame, 1); + case CONNECTION_STATE_HEADER: { + amqp_channel_t channel; + amqp_pool_t *channel_pool; + /* frame length is 3 bytes in */ + channel = amqp_d16(amqp_offset(raw_frame, 1)); - state->target_size - = amqp_d32(raw_frame, 3) + HEADER_SIZE + FOOTER_SIZE; + state->target_size = + amqp_d32(amqp_offset(raw_frame, 3)) + HEADER_SIZE + FOOTER_SIZE; - if ((size_t)state->frame_max < state->target_size) { - return AMQP_STATUS_BAD_AMQP_DATA; - } + if ((size_t)state->frame_max < state->target_size) { + return AMQP_STATUS_BAD_AMQP_DATA; + } - channel_pool = amqp_get_or_create_channel_pool(state, channel); - if (NULL == channel_pool) { - return AMQP_STATUS_NO_MEMORY; - } + channel_pool = amqp_get_or_create_channel_pool(state, channel); + if (NULL == channel_pool) { + return AMQP_STATUS_NO_MEMORY; + } - amqp_pool_alloc_bytes(channel_pool, state->target_size, &state->inbound_buffer); - if (NULL == state->inbound_buffer.bytes) { - return AMQP_STATUS_NO_MEMORY; - } - memcpy(state->inbound_buffer.bytes, state->header_buffer, HEADER_SIZE); - raw_frame = state->inbound_buffer.bytes; + amqp_pool_alloc_bytes(channel_pool, state->target_size, + &state->inbound_buffer); + if (NULL == state->inbound_buffer.bytes) { + return AMQP_STATUS_NO_MEMORY; + } + memcpy(state->inbound_buffer.bytes, state->header_buffer, HEADER_SIZE); + raw_frame = state->inbound_buffer.bytes; - state->state = CONNECTION_STATE_BODY; + state->state = CONNECTION_STATE_BODY; - bytes_consumed += consume_data(state, &received_data); + bytes_consumed += consume_data(state, &received_data); - /* do we have target_size data yet? if not, return with the - expectation that more will arrive */ - if (state->inbound_offset < state->target_size) { - return (int)bytes_consumed; + /* do we have target_size data yet? if not, return with the + expectation that more will arrive */ + if (state->inbound_offset < state->target_size) { + return (int)bytes_consumed; + } } - - } /* fall through to process body */ - case CONNECTION_STATE_BODY: { - amqp_bytes_t encoded; - int res; - amqp_pool_t *channel_pool; - - /* Check frame end marker (footer) */ - if (amqp_d8(raw_frame, state->target_size - 1) != AMQP_FRAME_END) { - return AMQP_STATUS_BAD_AMQP_DATA; - } - - decoded_frame->frame_type = amqp_d8(raw_frame, 0); - decoded_frame->channel = amqp_d16(raw_frame, 1); + case CONNECTION_STATE_BODY: { + amqp_bytes_t encoded; + int res; + amqp_pool_t *channel_pool; + + /* Check frame end marker (footer) */ + if (amqp_d8(amqp_offset(raw_frame, state->target_size - 1)) != + AMQP_FRAME_END) { + return AMQP_STATUS_BAD_AMQP_DATA; + } - channel_pool = amqp_get_or_create_channel_pool(state, decoded_frame->channel); - if (NULL == channel_pool) { - return AMQP_STATUS_NO_MEMORY; - } + decoded_frame->frame_type = amqp_d8(amqp_offset(raw_frame, 0)); + decoded_frame->channel = amqp_d16(amqp_offset(raw_frame, 1)); - switch (decoded_frame->frame_type) { - case AMQP_FRAME_METHOD: - decoded_frame->payload.method.id = amqp_d32(raw_frame, HEADER_SIZE); - encoded.bytes = amqp_offset(raw_frame, HEADER_SIZE + 4); - encoded.len = state->target_size - HEADER_SIZE - 4 - FOOTER_SIZE; - - res = amqp_decode_method(decoded_frame->payload.method.id, - channel_pool, encoded, - &decoded_frame->payload.method.decoded); - if (res < 0) { - return res; + channel_pool = + amqp_get_or_create_channel_pool(state, decoded_frame->channel); + if (NULL == channel_pool) { + return AMQP_STATUS_NO_MEMORY; } - break; - - case AMQP_FRAME_HEADER: - decoded_frame->payload.properties.class_id - = amqp_d16(raw_frame, HEADER_SIZE); - /* unused 2-byte weight field goes here */ - decoded_frame->payload.properties.body_size - = amqp_d64(raw_frame, HEADER_SIZE + 4); - encoded.bytes = amqp_offset(raw_frame, HEADER_SIZE + 12); - encoded.len = state->target_size - HEADER_SIZE - 12 - FOOTER_SIZE; - decoded_frame->payload.properties.raw = encoded; + switch (decoded_frame->frame_type) { + case AMQP_FRAME_METHOD: + decoded_frame->payload.method.id = + amqp_d32(amqp_offset(raw_frame, HEADER_SIZE)); + encoded.bytes = amqp_offset(raw_frame, HEADER_SIZE + 4); + encoded.len = state->target_size - HEADER_SIZE - 4 - FOOTER_SIZE; - res = amqp_decode_properties(decoded_frame->payload.properties.class_id, + res = amqp_decode_method(decoded_frame->payload.method.id, channel_pool, encoded, - &decoded_frame->payload.properties.decoded); - if (res < 0) { - return res; + &decoded_frame->payload.method.decoded); + if (res < 0) { + return res; + } + + break; + + case AMQP_FRAME_HEADER: + decoded_frame->payload.properties.class_id = + amqp_d16(amqp_offset(raw_frame, HEADER_SIZE)); + /* unused 2-byte weight field goes here */ + decoded_frame->payload.properties.body_size = + amqp_d64(amqp_offset(raw_frame, HEADER_SIZE + 4)); + encoded.bytes = amqp_offset(raw_frame, HEADER_SIZE + 12); + encoded.len = state->target_size - HEADER_SIZE - 12 - FOOTER_SIZE; + decoded_frame->payload.properties.raw = encoded; + + res = amqp_decode_properties( + decoded_frame->payload.properties.class_id, channel_pool, encoded, + &decoded_frame->payload.properties.decoded); + if (res < 0) { + return res; + } + + break; + + case AMQP_FRAME_BODY: + decoded_frame->payload.body_fragment.len = + state->target_size - HEADER_SIZE - FOOTER_SIZE; + decoded_frame->payload.body_fragment.bytes = + amqp_offset(raw_frame, HEADER_SIZE); + break; + + case AMQP_FRAME_HEARTBEAT: + break; + + default: + /* Ignore the frame */ + decoded_frame->frame_type = 0; + break; } - break; - - case AMQP_FRAME_BODY: - decoded_frame->payload.body_fragment.len - = state->target_size - HEADER_SIZE - FOOTER_SIZE; - decoded_frame->payload.body_fragment.bytes - = amqp_offset(raw_frame, HEADER_SIZE); - break; - - case AMQP_FRAME_HEARTBEAT: - break; - - default: - /* Ignore the frame */ - decoded_frame->frame_type = 0; - break; + return_to_idle(state); + return (int)bytes_consumed; } - return_to_idle(state); - return (int)bytes_consumed; - } - - default: - amqp_abort("Internal error: invalid amqp_connection_state_t->state %d", state->state); - return (int)bytes_consumed; + default: + amqp_abort("Internal error: invalid amqp_connection_state_t->state %d", + state->state); } } -amqp_boolean_t amqp_release_buffers_ok(amqp_connection_state_t state) -{ +amqp_boolean_t amqp_release_buffers_ok(amqp_connection_state_t state) { return (state->state == CONNECTION_STATE_IDLE); } -void amqp_release_buffers(amqp_connection_state_t state) -{ +void amqp_release_buffers(amqp_connection_state_t state) { int i; ENFORCE_STATE(state, CONNECTION_STATE_IDLE); for (i = 0; i < POOL_TABLE_SIZE; ++i) { amqp_pool_table_entry_t *entry = state->pool_table[i]; - for ( ;NULL != entry; entry = entry->next) { + for (; NULL != entry; entry = entry->next) { amqp_maybe_release_buffers_on_channel(state, entry->channel); } } } -void amqp_maybe_release_buffers(amqp_connection_state_t state) -{ +void amqp_maybe_release_buffers(amqp_connection_state_t state) { if (amqp_release_buffers_ok(state)) { amqp_release_buffers(state); } } -void amqp_maybe_release_buffers_on_channel(amqp_connection_state_t state, amqp_channel_t channel) -{ +void amqp_maybe_release_buffers_on_channel(amqp_connection_state_t state, + amqp_channel_t channel) { amqp_link_t *queued_link; amqp_pool_t *pool; if (CONNECTION_STATE_IDLE != state->state) { @@ -468,8 +458,8 @@ size_t out_frame_len; int res; - amqp_e8(out_frame, 0, frame->frame_type); - amqp_e16(out_frame, 1, frame->channel); + amqp_e8(frame->frame_type, amqp_offset(out_frame, 0)); + amqp_e16(frame->channel, amqp_offset(out_frame, 1)); switch (frame->frame_type) { case AMQP_FRAME_BODY: { @@ -483,7 +473,7 @@ case AMQP_FRAME_METHOD: { amqp_bytes_t method_encoded; - amqp_e32(out_frame, HEADER_SIZE, frame->payload.method.id); + amqp_e32(frame->payload.method.id, amqp_offset(out_frame, HEADER_SIZE)); method_encoded.bytes = amqp_offset(out_frame, HEADER_SIZE + 4); method_encoded.len = buffer.len - HEADER_SIZE - 4 - FOOTER_SIZE; @@ -498,22 +488,28 @@ break; } - case AMQP_FRAME_HEADER: - amqp_e16(out_frame, HEADER_SIZE, frame->payload.properties.class_id); - amqp_e16(out_frame, HEADER_SIZE + 2, 0); /* "weight" */ - amqp_e64(out_frame, HEADER_SIZE + 4, frame->payload.properties.body_size); + case AMQP_FRAME_HEADER: { + amqp_bytes_t properties_encoded; - encoded->bytes = amqp_offset(out_frame, HEADER_SIZE + 12); - encoded->len = buffer.len - HEADER_SIZE - 12 - FOOTER_SIZE; + amqp_e16(frame->payload.properties.class_id, + amqp_offset(out_frame, HEADER_SIZE)); + amqp_e16(0, amqp_offset(out_frame, HEADER_SIZE + 2)); /* "weight" */ + amqp_e64(frame->payload.properties.body_size, + amqp_offset(out_frame, HEADER_SIZE + 4)); + + properties_encoded.bytes = amqp_offset(out_frame, HEADER_SIZE + 12); + properties_encoded.len = buffer.len - HEADER_SIZE - 12 - FOOTER_SIZE; res = amqp_encode_properties(frame->payload.properties.class_id, - frame->payload.properties.decoded, *encoded); + frame->payload.properties.decoded, + properties_encoded); if (res < 0) { return res; } out_frame_len = res + 12; break; + } case AMQP_FRAME_HEARTBEAT: out_frame_len = 0; @@ -523,8 +519,8 @@ return AMQP_STATUS_INVALID_PARAMETER; } - amqp_e32(out_frame, 3, (uint32_t)out_frame_len); - amqp_e8(out_frame, HEADER_SIZE + out_frame_len, AMQP_FRAME_END); + amqp_e32((uint32_t)out_frame_len, amqp_offset(out_frame, 3)); + amqp_e8(AMQP_FRAME_END, amqp_offset(out_frame, HEADER_SIZE + out_frame_len)); encoded->bytes = out_frame; encoded->len = out_frame_len + HEADER_SIZE + FOOTER_SIZE; @@ -532,16 +528,18 @@ return AMQP_STATUS_OK; } -int amqp_send_frame(amqp_connection_state_t state, - const amqp_frame_t *frame) { - return amqp_send_frame_inner(state, frame, AMQP_SF_NONE); +int amqp_send_frame(amqp_connection_state_t state, const amqp_frame_t *frame) { + return amqp_send_frame_inner(state, frame, AMQP_SF_NONE, + amqp_time_infinite()); } int amqp_send_frame_inner(amqp_connection_state_t state, - const amqp_frame_t *frame, int flags) { + const amqp_frame_t *frame, int flags, + amqp_time_t deadline) { int res; ssize_t sent; amqp_bytes_t encoded; + amqp_time_t next_timeout; /* TODO: if the AMQP_SF_MORE socket optimization can be shown to work * correctly, then this could be un-done so that body-frames are sent as 3 @@ -554,15 +552,22 @@ } start_send: - sent = amqp_try_send(state, encoded.bytes, encoded.len, - state->next_recv_heartbeat, flags); + + next_timeout = amqp_time_first(deadline, state->next_recv_heartbeat); + + sent = amqp_try_send(state, encoded.bytes, encoded.len, next_timeout, flags); if (0 > sent) { return (int)sent; } - /* A partial send has occurred, because of a heartbeat timeout, try and recv - * something */ + /* A partial send has occurred, because of a heartbeat timeout (so try recv + * something) or common timeout (so return AMQP_STATUS_TIMEOUT) */ if ((ssize_t)encoded.len != sent) { + if (amqp_time_equal(next_timeout, deadline)) { + /* timeout of method was received, so return from method*/ + return AMQP_STATUS_TIMEOUT; + } + res = amqp_try_recv(state); if (AMQP_STATUS_TIMEOUT == res) { @@ -571,7 +576,7 @@ return res; } - encoded.bytes = (uint8_t*)encoded.bytes + sent; + encoded.bytes = (uint8_t *)encoded.bytes + sent; encoded.len -= sent; goto start_send; } @@ -581,14 +586,10 @@ return res; } -amqp_table_t * -amqp_get_server_properties(amqp_connection_state_t state) -{ +amqp_table_t *amqp_get_server_properties(amqp_connection_state_t state) { return &state->server_properties; } -amqp_table_t * -amqp_get_client_properties(amqp_connection_state_t state) -{ +amqp_table_t *amqp_get_client_properties(amqp_connection_state_t state) { return &state->client_properties; } diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_consumer.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_consumer.c --- librabbitmq-0.7.1/librabbitmq/amqp_consumer.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_consumer.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -34,23 +33,21 @@ #include #include -static -int amqp_basic_properties_clone(amqp_basic_properties_t *original, - amqp_basic_properties_t *clone, - amqp_pool_t *pool) -{ - memset(clone, 0, sizeof(amqp_basic_properties_t)); +static int amqp_basic_properties_clone(amqp_basic_properties_t *original, + amqp_basic_properties_t *clone, + amqp_pool_t *pool) { + memset(clone, 0, sizeof(*clone)); clone->_flags = original->_flags; -#define CLONE_BYTES_POOL(original, clone, pool) \ - if (0 == original.len) { \ - clone = amqp_empty_bytes; \ - } else { \ - amqp_pool_alloc_bytes(pool, original.len, &clone); \ - if (NULL == clone.bytes) { \ - return AMQP_STATUS_NO_MEMORY; \ - } \ - memcpy(clone.bytes, original.bytes, clone.len); \ +#define CLONE_BYTES_POOL(original, clone, pool) \ + if (0 == original.len) { \ + clone = amqp_empty_bytes; \ + } else { \ + amqp_pool_alloc_bytes(pool, original.len, &clone); \ + if (NULL == clone.bytes) { \ + return AMQP_STATUS_NO_MEMORY; \ + } \ + memcpy(clone.bytes, original.bytes, clone.len); \ } if (clone->_flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { @@ -116,40 +113,36 @@ #undef CLONE_BYTES_POOL } - -void amqp_destroy_message(amqp_message_t *message) -{ +void amqp_destroy_message(amqp_message_t *message) { empty_amqp_pool(&message->pool); amqp_bytes_free(message->body); } -void amqp_destroy_envelope(amqp_envelope_t *envelope) -{ +void amqp_destroy_envelope(amqp_envelope_t *envelope) { amqp_destroy_message(&envelope->message); amqp_bytes_free(envelope->routing_key); amqp_bytes_free(envelope->exchange); amqp_bytes_free(envelope->consumer_tag); } -static -int amqp_bytes_malloc_dup_failed(amqp_bytes_t bytes) { +static int amqp_bytes_malloc_dup_failed(amqp_bytes_t bytes) { if (bytes.len != 0 && bytes.bytes == NULL) { return 1; } return 0; } -amqp_rpc_reply_t -amqp_consume_message(amqp_connection_state_t state, amqp_envelope_t *envelope, - struct timeval *timeout, AMQP_UNUSED int flags) -{ +amqp_rpc_reply_t amqp_consume_message(amqp_connection_state_t state, + amqp_envelope_t *envelope, + struct timeval *timeout, + AMQP_UNUSED int flags) { int res; amqp_frame_t frame; amqp_basic_deliver_t *delivery_method; amqp_rpc_reply_t ret; - memset(&ret, 0, sizeof(amqp_rpc_reply_t)); - memset(envelope, 0, sizeof(amqp_envelope_t)); + memset(&ret, 0, sizeof(ret)); + memset(envelope, 0, sizeof(*envelope)); res = amqp_simple_wait_frame_noblock(state, &frame, timeout); if (AMQP_STATUS_OK != res) { @@ -158,8 +151,8 @@ goto error_out1; } - if (AMQP_FRAME_METHOD != frame.frame_type - || AMQP_BASIC_DELIVER_METHOD != frame.payload.method.id) { + if (AMQP_FRAME_METHOD != frame.frame_type || + AMQP_BASIC_DELIVER_METHOD != frame.payload.method.id) { amqp_put_back_frame(state, &frame); ret.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; ret.library_error = AMQP_STATUS_UNEXPECTED_STATE; @@ -202,8 +195,7 @@ amqp_rpc_reply_t amqp_read_message(amqp_connection_state_t state, amqp_channel_t channel, amqp_message_t *message, - AMQP_UNUSED int flags) -{ + AMQP_UNUSED int flags) { amqp_frame_t frame; amqp_rpc_reply_t ret; @@ -211,8 +203,8 @@ char *body_read_ptr; int res; - memset(&ret, 0, sizeof(amqp_rpc_reply_t)); - memset(message, 0, sizeof(amqp_message_t)); + memset(&ret, 0, sizeof(ret)); + memset(message, 0, sizeof(*message)); res = amqp_simple_wait_frame_on_channel(state, channel, &frame); if (AMQP_STATUS_OK != res) { @@ -257,7 +249,8 @@ ret.library_error = AMQP_STATUS_NO_MEMORY; goto error_out1; } - message->body = amqp_bytes_malloc((size_t)frame.payload.properties.body_size); + message->body = + amqp_bytes_malloc((size_t)frame.payload.properties.body_size); if (NULL == message->body.bytes) { ret.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; ret.library_error = AMQP_STATUS_NO_MEMORY; @@ -295,7 +288,8 @@ goto error_out2; } - memcpy(body_read_ptr, frame.payload.body_fragment.bytes, frame.payload.body_fragment.len); + memcpy(body_read_ptr, frame.payload.body_fragment.bytes, + frame.payload.body_fragment.len); body_read += frame.payload.body_fragment.len; body_read_ptr += frame.payload.body_fragment.len; diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_cyassl.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_cyassl.c --- librabbitmq-0.7.1/librabbitmq/amqp_cyassl.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_cyassl.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,270 +0,0 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ -/* - * Copyright 2012-2013 Michael Steinert - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "amqp_ssl_socket.h" -#include "amqp_private.h" -#include -#include -#include - -#ifndef AMQP_USE_UNTESTED_SSL_BACKEND -# error This SSL backend is alpha quality and likely contains errors.\ - -DAMQP_USE_UNTESTED_SSL_BACKEND to use this backend -#endif - -struct amqp_ssl_socket_t { - const struct amqp_socket_class_t *klass; - CYASSL_CTX *ctx; - CYASSL *ssl; - int sockfd; - char *buffer; - size_t length; - int last_error; -}; - -static ssize_t -amqp_ssl_socket_send(void *base, - const void *buf, - size_t len, - AMQP_UNUSED int flags) -{ - int status; - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - - self->last_error = 0; - status = CyaSSL_write(self->ssl, buf, len); - if (status <= 0) { - self->last_error = AMQP_STATUS_SSL_ERROR; - } - - return status; -} - -static ssize_t -amqp_ssl_socket_writev(void *base, - const struct iovec *iov, - int iovcnt) -{ - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - ssize_t written = -1; - char *bufferp; - size_t bytes; - int i; - self->last_error = 0; - bytes = 0; - for (i = 0; i < iovcnt; ++i) { - bytes += iov[i].iov_len; - } - if (self->length < bytes) { - free(self->buffer); - self->buffer = malloc(bytes); - if (!self->buffer) { - self->length = 0; - self->last_error = AMQP_STATUS_NO_MEMORY; - goto exit; - } - self->length = bytes; - } - bufferp = self->buffer; - for (i = 0; i < iovcnt; ++i) { - memcpy(bufferp, iov[i].iov_base, iov[i].iov_len); - bufferp += iov[i].iov_len; - } - written = amqp_ssl_socket_send(self, self->buffer, bytes, 0); -exit: - return written; -} - -static ssize_t -amqp_ssl_socket_recv(void *base, - void *buf, - size_t len, - AMQP_UNUSED int flags) -{ - int status; - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - - self->last_error = 0; - status = CyaSSL_read(self->ssl, buf, len); - if (status <= 0) { - self->last_error = AMQP_STATUS_SSL_ERROR; - } - - return status; -} - -static int -amqp_ssl_socket_get_sockfd(void *base) -{ - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - return self->sockfd; -} - -static int -amqp_ssl_socket_close(void *base) -{ - int status = -1; - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - if (self->sockfd >= 0) { - status = amqp_os_socket_close(self->sockfd); - } - if (self) { - CyaSSL_free(self->ssl); - CyaSSL_CTX_free(self->ctx); - free(self->buffer); - free(self); - } - return status; -} - -static int -amqp_ssl_socket_error(void *base) -{ - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - return self->last_error; -} - -char * -amqp_ssl_error_string(AMQP_UNUSED int err) -{ - return strdup("A ssl socket error occurred."); -} - -static int -amqp_ssl_socket_open(void *base, const char *host, int port, struct timeval *timeout) -{ - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - int status; - self->last_error = 0; - - self->ssl = CyaSSL_new(self->ctx); - if (NULL == self->ssl) { - self->last_error = AMQP_STATUS_SSL_ERROR; - return -1; - } - - self->sockfd = amqp_open_socket_noblock(host, port, timeout); - if (0 > self->sockfd) { - self->last_error = - self->sockfd; - return -1; - } - CyaSSL_set_fd(self->ssl, self->sockfd); - status = CyaSSL_connect(self->ssl); - if (SSL_SUCCESS != status) { - self->last_error = AMQP_STATUS_SSL_ERROR; - return -1; - } - return 0; -} - -static const struct amqp_socket_class_t amqp_ssl_socket_class = { - amqp_ssl_socket_writev, /* writev */ - amqp_ssl_socket_send, /* send */ - amqp_ssl_socket_recv, /* recv */ - amqp_ssl_socket_open, /* open */ - amqp_ssl_socket_close, /* close */ - amqp_ssl_socket_error, /* error */ - amqp_ssl_socket_get_sockfd /* get_sockfd */ -}; - -amqp_socket_t * -amqp_ssl_socket_new(void) -{ - struct amqp_ssl_socket_t *self = calloc(1, sizeof(*self)); - if (!self) { - goto error; - } - CyaSSL_Init(); - self->ctx = CyaSSL_CTX_new(CyaSSLv23_client_method()); - if (!self->ctx) { - goto error; - } - self->klass = &amqp_ssl_socket_class; - return (amqp_socket_t *)self; -error: - amqp_socket_close((amqp_socket_t *)self); - return NULL; -} - -int -amqp_ssl_socket_set_cacert(amqp_socket_t *base, - const char *cacert) -{ - int status; - struct amqp_ssl_socket_t *self; - if (base->klass != &amqp_ssl_socket_class) { - amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); - } - self = (struct amqp_ssl_socket_t *)base; - status = CyaSSL_CTX_load_verify_locations(self->ctx, cacert, NULL); - if (SSL_SUCCESS != status) { - return -1; - } - return 0; -} - -int -amqp_ssl_socket_set_key(amqp_socket_t *base, - const char *cert, - const char *key) -{ - int status; - struct amqp_ssl_socket_t *self; - if (base->klass != &amqp_ssl_socket_class) { - amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); - } - self = (struct amqp_ssl_socket_t *)base; - status = CyaSSL_CTX_use_PrivateKey_file(self->ctx, key, - SSL_FILETYPE_PEM); - if (SSL_SUCCESS != status) { - return -1; - } - status = CyaSSL_CTX_use_certificate_chain_file(self->ctx, cert); - return 0; -} - -int -amqp_ssl_socket_set_key_buffer(AMQP_UNUSED amqp_socket_t *base, - AMQP_UNUSED const char *cert, - AMQP_UNUSED const void *key, - AMQP_UNUSED size_t n) -{ - amqp_abort("%s is not implemented for CyaSSL", __func__); - return -1; -} - -void -amqp_ssl_socket_set_verify(AMQP_UNUSED amqp_socket_t *base, - AMQP_UNUSED amqp_boolean_t verify) -{ - /* noop for CyaSSL */ -} - -void -amqp_set_initialize_ssl_library(AMQP_UNUSED amqp_boolean_t do_initialize) -{ -} diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_framing.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_framing.c --- librabbitmq-0.7.1/librabbitmq/amqp_framing.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_framing.c 2019-10-20 10:14:51.000000000 +0000 @@ -44,380 +44,568 @@ #include #include - char const *amqp_constant_name(int constantNumber) { switch (constantNumber) { - case AMQP_FRAME_METHOD: return "AMQP_FRAME_METHOD"; - case AMQP_FRAME_HEADER: return "AMQP_FRAME_HEADER"; - case AMQP_FRAME_BODY: return "AMQP_FRAME_BODY"; - case AMQP_FRAME_HEARTBEAT: return "AMQP_FRAME_HEARTBEAT"; - case AMQP_FRAME_MIN_SIZE: return "AMQP_FRAME_MIN_SIZE"; - case AMQP_FRAME_END: return "AMQP_FRAME_END"; - case AMQP_REPLY_SUCCESS: return "AMQP_REPLY_SUCCESS"; - case AMQP_CONTENT_TOO_LARGE: return "AMQP_CONTENT_TOO_LARGE"; - case AMQP_NO_ROUTE: return "AMQP_NO_ROUTE"; - case AMQP_NO_CONSUMERS: return "AMQP_NO_CONSUMERS"; - case AMQP_ACCESS_REFUSED: return "AMQP_ACCESS_REFUSED"; - case AMQP_NOT_FOUND: return "AMQP_NOT_FOUND"; - case AMQP_RESOURCE_LOCKED: return "AMQP_RESOURCE_LOCKED"; - case AMQP_PRECONDITION_FAILED: return "AMQP_PRECONDITION_FAILED"; - case AMQP_CONNECTION_FORCED: return "AMQP_CONNECTION_FORCED"; - case AMQP_INVALID_PATH: return "AMQP_INVALID_PATH"; - case AMQP_FRAME_ERROR: return "AMQP_FRAME_ERROR"; - case AMQP_SYNTAX_ERROR: return "AMQP_SYNTAX_ERROR"; - case AMQP_COMMAND_INVALID: return "AMQP_COMMAND_INVALID"; - case AMQP_CHANNEL_ERROR: return "AMQP_CHANNEL_ERROR"; - case AMQP_UNEXPECTED_FRAME: return "AMQP_UNEXPECTED_FRAME"; - case AMQP_RESOURCE_ERROR: return "AMQP_RESOURCE_ERROR"; - case AMQP_NOT_ALLOWED: return "AMQP_NOT_ALLOWED"; - case AMQP_NOT_IMPLEMENTED: return "AMQP_NOT_IMPLEMENTED"; - case AMQP_INTERNAL_ERROR: return "AMQP_INTERNAL_ERROR"; - default: return "(unknown)"; + case AMQP_FRAME_METHOD: + return "AMQP_FRAME_METHOD"; + case AMQP_FRAME_HEADER: + return "AMQP_FRAME_HEADER"; + case AMQP_FRAME_BODY: + return "AMQP_FRAME_BODY"; + case AMQP_FRAME_HEARTBEAT: + return "AMQP_FRAME_HEARTBEAT"; + case AMQP_FRAME_MIN_SIZE: + return "AMQP_FRAME_MIN_SIZE"; + case AMQP_FRAME_END: + return "AMQP_FRAME_END"; + case AMQP_REPLY_SUCCESS: + return "AMQP_REPLY_SUCCESS"; + case AMQP_CONTENT_TOO_LARGE: + return "AMQP_CONTENT_TOO_LARGE"; + case AMQP_NO_ROUTE: + return "AMQP_NO_ROUTE"; + case AMQP_NO_CONSUMERS: + return "AMQP_NO_CONSUMERS"; + case AMQP_ACCESS_REFUSED: + return "AMQP_ACCESS_REFUSED"; + case AMQP_NOT_FOUND: + return "AMQP_NOT_FOUND"; + case AMQP_RESOURCE_LOCKED: + return "AMQP_RESOURCE_LOCKED"; + case AMQP_PRECONDITION_FAILED: + return "AMQP_PRECONDITION_FAILED"; + case AMQP_CONNECTION_FORCED: + return "AMQP_CONNECTION_FORCED"; + case AMQP_INVALID_PATH: + return "AMQP_INVALID_PATH"; + case AMQP_FRAME_ERROR: + return "AMQP_FRAME_ERROR"; + case AMQP_SYNTAX_ERROR: + return "AMQP_SYNTAX_ERROR"; + case AMQP_COMMAND_INVALID: + return "AMQP_COMMAND_INVALID"; + case AMQP_CHANNEL_ERROR: + return "AMQP_CHANNEL_ERROR"; + case AMQP_UNEXPECTED_FRAME: + return "AMQP_UNEXPECTED_FRAME"; + case AMQP_RESOURCE_ERROR: + return "AMQP_RESOURCE_ERROR"; + case AMQP_NOT_ALLOWED: + return "AMQP_NOT_ALLOWED"; + case AMQP_NOT_IMPLEMENTED: + return "AMQP_NOT_IMPLEMENTED"; + case AMQP_INTERNAL_ERROR: + return "AMQP_INTERNAL_ERROR"; + default: + return "(unknown)"; } } amqp_boolean_t amqp_constant_is_hard_error(int constantNumber) { switch (constantNumber) { - case AMQP_CONNECTION_FORCED: return 1; - case AMQP_INVALID_PATH: return 1; - case AMQP_FRAME_ERROR: return 1; - case AMQP_SYNTAX_ERROR: return 1; - case AMQP_COMMAND_INVALID: return 1; - case AMQP_CHANNEL_ERROR: return 1; - case AMQP_UNEXPECTED_FRAME: return 1; - case AMQP_RESOURCE_ERROR: return 1; - case AMQP_NOT_ALLOWED: return 1; - case AMQP_NOT_IMPLEMENTED: return 1; - case AMQP_INTERNAL_ERROR: return 1; - default: return 0; + case AMQP_CONNECTION_FORCED: + return 1; + case AMQP_INVALID_PATH: + return 1; + case AMQP_FRAME_ERROR: + return 1; + case AMQP_SYNTAX_ERROR: + return 1; + case AMQP_COMMAND_INVALID: + return 1; + case AMQP_CHANNEL_ERROR: + return 1; + case AMQP_UNEXPECTED_FRAME: + return 1; + case AMQP_RESOURCE_ERROR: + return 1; + case AMQP_NOT_ALLOWED: + return 1; + case AMQP_NOT_IMPLEMENTED: + return 1; + case AMQP_INTERNAL_ERROR: + return 1; + default: + return 0; } } char const *amqp_method_name(amqp_method_number_t methodNumber) { switch (methodNumber) { - case AMQP_CONNECTION_START_METHOD: return "AMQP_CONNECTION_START_METHOD"; - case AMQP_CONNECTION_START_OK_METHOD: return "AMQP_CONNECTION_START_OK_METHOD"; - case AMQP_CONNECTION_SECURE_METHOD: return "AMQP_CONNECTION_SECURE_METHOD"; - case AMQP_CONNECTION_SECURE_OK_METHOD: return "AMQP_CONNECTION_SECURE_OK_METHOD"; - case AMQP_CONNECTION_TUNE_METHOD: return "AMQP_CONNECTION_TUNE_METHOD"; - case AMQP_CONNECTION_TUNE_OK_METHOD: return "AMQP_CONNECTION_TUNE_OK_METHOD"; - case AMQP_CONNECTION_OPEN_METHOD: return "AMQP_CONNECTION_OPEN_METHOD"; - case AMQP_CONNECTION_OPEN_OK_METHOD: return "AMQP_CONNECTION_OPEN_OK_METHOD"; - case AMQP_CONNECTION_CLOSE_METHOD: return "AMQP_CONNECTION_CLOSE_METHOD"; - case AMQP_CONNECTION_CLOSE_OK_METHOD: return "AMQP_CONNECTION_CLOSE_OK_METHOD"; - case AMQP_CONNECTION_BLOCKED_METHOD: return "AMQP_CONNECTION_BLOCKED_METHOD"; - case AMQP_CONNECTION_UNBLOCKED_METHOD: return "AMQP_CONNECTION_UNBLOCKED_METHOD"; - case AMQP_CHANNEL_OPEN_METHOD: return "AMQP_CHANNEL_OPEN_METHOD"; - case AMQP_CHANNEL_OPEN_OK_METHOD: return "AMQP_CHANNEL_OPEN_OK_METHOD"; - case AMQP_CHANNEL_FLOW_METHOD: return "AMQP_CHANNEL_FLOW_METHOD"; - case AMQP_CHANNEL_FLOW_OK_METHOD: return "AMQP_CHANNEL_FLOW_OK_METHOD"; - case AMQP_CHANNEL_CLOSE_METHOD: return "AMQP_CHANNEL_CLOSE_METHOD"; - case AMQP_CHANNEL_CLOSE_OK_METHOD: return "AMQP_CHANNEL_CLOSE_OK_METHOD"; - case AMQP_ACCESS_REQUEST_METHOD: return "AMQP_ACCESS_REQUEST_METHOD"; - case AMQP_ACCESS_REQUEST_OK_METHOD: return "AMQP_ACCESS_REQUEST_OK_METHOD"; - case AMQP_EXCHANGE_DECLARE_METHOD: return "AMQP_EXCHANGE_DECLARE_METHOD"; - case AMQP_EXCHANGE_DECLARE_OK_METHOD: return "AMQP_EXCHANGE_DECLARE_OK_METHOD"; - case AMQP_EXCHANGE_DELETE_METHOD: return "AMQP_EXCHANGE_DELETE_METHOD"; - case AMQP_EXCHANGE_DELETE_OK_METHOD: return "AMQP_EXCHANGE_DELETE_OK_METHOD"; - case AMQP_EXCHANGE_BIND_METHOD: return "AMQP_EXCHANGE_BIND_METHOD"; - case AMQP_EXCHANGE_BIND_OK_METHOD: return "AMQP_EXCHANGE_BIND_OK_METHOD"; - case AMQP_EXCHANGE_UNBIND_METHOD: return "AMQP_EXCHANGE_UNBIND_METHOD"; - case AMQP_EXCHANGE_UNBIND_OK_METHOD: return "AMQP_EXCHANGE_UNBIND_OK_METHOD"; - case AMQP_QUEUE_DECLARE_METHOD: return "AMQP_QUEUE_DECLARE_METHOD"; - case AMQP_QUEUE_DECLARE_OK_METHOD: return "AMQP_QUEUE_DECLARE_OK_METHOD"; - case AMQP_QUEUE_BIND_METHOD: return "AMQP_QUEUE_BIND_METHOD"; - case AMQP_QUEUE_BIND_OK_METHOD: return "AMQP_QUEUE_BIND_OK_METHOD"; - case AMQP_QUEUE_PURGE_METHOD: return "AMQP_QUEUE_PURGE_METHOD"; - case AMQP_QUEUE_PURGE_OK_METHOD: return "AMQP_QUEUE_PURGE_OK_METHOD"; - case AMQP_QUEUE_DELETE_METHOD: return "AMQP_QUEUE_DELETE_METHOD"; - case AMQP_QUEUE_DELETE_OK_METHOD: return "AMQP_QUEUE_DELETE_OK_METHOD"; - case AMQP_QUEUE_UNBIND_METHOD: return "AMQP_QUEUE_UNBIND_METHOD"; - case AMQP_QUEUE_UNBIND_OK_METHOD: return "AMQP_QUEUE_UNBIND_OK_METHOD"; - case AMQP_BASIC_QOS_METHOD: return "AMQP_BASIC_QOS_METHOD"; - case AMQP_BASIC_QOS_OK_METHOD: return "AMQP_BASIC_QOS_OK_METHOD"; - case AMQP_BASIC_CONSUME_METHOD: return "AMQP_BASIC_CONSUME_METHOD"; - case AMQP_BASIC_CONSUME_OK_METHOD: return "AMQP_BASIC_CONSUME_OK_METHOD"; - case AMQP_BASIC_CANCEL_METHOD: return "AMQP_BASIC_CANCEL_METHOD"; - case AMQP_BASIC_CANCEL_OK_METHOD: return "AMQP_BASIC_CANCEL_OK_METHOD"; - case AMQP_BASIC_PUBLISH_METHOD: return "AMQP_BASIC_PUBLISH_METHOD"; - case AMQP_BASIC_RETURN_METHOD: return "AMQP_BASIC_RETURN_METHOD"; - case AMQP_BASIC_DELIVER_METHOD: return "AMQP_BASIC_DELIVER_METHOD"; - case AMQP_BASIC_GET_METHOD: return "AMQP_BASIC_GET_METHOD"; - case AMQP_BASIC_GET_OK_METHOD: return "AMQP_BASIC_GET_OK_METHOD"; - case AMQP_BASIC_GET_EMPTY_METHOD: return "AMQP_BASIC_GET_EMPTY_METHOD"; - case AMQP_BASIC_ACK_METHOD: return "AMQP_BASIC_ACK_METHOD"; - case AMQP_BASIC_REJECT_METHOD: return "AMQP_BASIC_REJECT_METHOD"; - case AMQP_BASIC_RECOVER_ASYNC_METHOD: return "AMQP_BASIC_RECOVER_ASYNC_METHOD"; - case AMQP_BASIC_RECOVER_METHOD: return "AMQP_BASIC_RECOVER_METHOD"; - case AMQP_BASIC_RECOVER_OK_METHOD: return "AMQP_BASIC_RECOVER_OK_METHOD"; - case AMQP_BASIC_NACK_METHOD: return "AMQP_BASIC_NACK_METHOD"; - case AMQP_TX_SELECT_METHOD: return "AMQP_TX_SELECT_METHOD"; - case AMQP_TX_SELECT_OK_METHOD: return "AMQP_TX_SELECT_OK_METHOD"; - case AMQP_TX_COMMIT_METHOD: return "AMQP_TX_COMMIT_METHOD"; - case AMQP_TX_COMMIT_OK_METHOD: return "AMQP_TX_COMMIT_OK_METHOD"; - case AMQP_TX_ROLLBACK_METHOD: return "AMQP_TX_ROLLBACK_METHOD"; - case AMQP_TX_ROLLBACK_OK_METHOD: return "AMQP_TX_ROLLBACK_OK_METHOD"; - case AMQP_CONFIRM_SELECT_METHOD: return "AMQP_CONFIRM_SELECT_METHOD"; - case AMQP_CONFIRM_SELECT_OK_METHOD: return "AMQP_CONFIRM_SELECT_OK_METHOD"; - default: return NULL; + case AMQP_CONNECTION_START_METHOD: + return "AMQP_CONNECTION_START_METHOD"; + case AMQP_CONNECTION_START_OK_METHOD: + return "AMQP_CONNECTION_START_OK_METHOD"; + case AMQP_CONNECTION_SECURE_METHOD: + return "AMQP_CONNECTION_SECURE_METHOD"; + case AMQP_CONNECTION_SECURE_OK_METHOD: + return "AMQP_CONNECTION_SECURE_OK_METHOD"; + case AMQP_CONNECTION_TUNE_METHOD: + return "AMQP_CONNECTION_TUNE_METHOD"; + case AMQP_CONNECTION_TUNE_OK_METHOD: + return "AMQP_CONNECTION_TUNE_OK_METHOD"; + case AMQP_CONNECTION_OPEN_METHOD: + return "AMQP_CONNECTION_OPEN_METHOD"; + case AMQP_CONNECTION_OPEN_OK_METHOD: + return "AMQP_CONNECTION_OPEN_OK_METHOD"; + case AMQP_CONNECTION_CLOSE_METHOD: + return "AMQP_CONNECTION_CLOSE_METHOD"; + case AMQP_CONNECTION_CLOSE_OK_METHOD: + return "AMQP_CONNECTION_CLOSE_OK_METHOD"; + case AMQP_CONNECTION_BLOCKED_METHOD: + return "AMQP_CONNECTION_BLOCKED_METHOD"; + case AMQP_CONNECTION_UNBLOCKED_METHOD: + return "AMQP_CONNECTION_UNBLOCKED_METHOD"; + case AMQP_CHANNEL_OPEN_METHOD: + return "AMQP_CHANNEL_OPEN_METHOD"; + case AMQP_CHANNEL_OPEN_OK_METHOD: + return "AMQP_CHANNEL_OPEN_OK_METHOD"; + case AMQP_CHANNEL_FLOW_METHOD: + return "AMQP_CHANNEL_FLOW_METHOD"; + case AMQP_CHANNEL_FLOW_OK_METHOD: + return "AMQP_CHANNEL_FLOW_OK_METHOD"; + case AMQP_CHANNEL_CLOSE_METHOD: + return "AMQP_CHANNEL_CLOSE_METHOD"; + case AMQP_CHANNEL_CLOSE_OK_METHOD: + return "AMQP_CHANNEL_CLOSE_OK_METHOD"; + case AMQP_ACCESS_REQUEST_METHOD: + return "AMQP_ACCESS_REQUEST_METHOD"; + case AMQP_ACCESS_REQUEST_OK_METHOD: + return "AMQP_ACCESS_REQUEST_OK_METHOD"; + case AMQP_EXCHANGE_DECLARE_METHOD: + return "AMQP_EXCHANGE_DECLARE_METHOD"; + case AMQP_EXCHANGE_DECLARE_OK_METHOD: + return "AMQP_EXCHANGE_DECLARE_OK_METHOD"; + case AMQP_EXCHANGE_DELETE_METHOD: + return "AMQP_EXCHANGE_DELETE_METHOD"; + case AMQP_EXCHANGE_DELETE_OK_METHOD: + return "AMQP_EXCHANGE_DELETE_OK_METHOD"; + case AMQP_EXCHANGE_BIND_METHOD: + return "AMQP_EXCHANGE_BIND_METHOD"; + case AMQP_EXCHANGE_BIND_OK_METHOD: + return "AMQP_EXCHANGE_BIND_OK_METHOD"; + case AMQP_EXCHANGE_UNBIND_METHOD: + return "AMQP_EXCHANGE_UNBIND_METHOD"; + case AMQP_EXCHANGE_UNBIND_OK_METHOD: + return "AMQP_EXCHANGE_UNBIND_OK_METHOD"; + case AMQP_QUEUE_DECLARE_METHOD: + return "AMQP_QUEUE_DECLARE_METHOD"; + case AMQP_QUEUE_DECLARE_OK_METHOD: + return "AMQP_QUEUE_DECLARE_OK_METHOD"; + case AMQP_QUEUE_BIND_METHOD: + return "AMQP_QUEUE_BIND_METHOD"; + case AMQP_QUEUE_BIND_OK_METHOD: + return "AMQP_QUEUE_BIND_OK_METHOD"; + case AMQP_QUEUE_PURGE_METHOD: + return "AMQP_QUEUE_PURGE_METHOD"; + case AMQP_QUEUE_PURGE_OK_METHOD: + return "AMQP_QUEUE_PURGE_OK_METHOD"; + case AMQP_QUEUE_DELETE_METHOD: + return "AMQP_QUEUE_DELETE_METHOD"; + case AMQP_QUEUE_DELETE_OK_METHOD: + return "AMQP_QUEUE_DELETE_OK_METHOD"; + case AMQP_QUEUE_UNBIND_METHOD: + return "AMQP_QUEUE_UNBIND_METHOD"; + case AMQP_QUEUE_UNBIND_OK_METHOD: + return "AMQP_QUEUE_UNBIND_OK_METHOD"; + case AMQP_BASIC_QOS_METHOD: + return "AMQP_BASIC_QOS_METHOD"; + case AMQP_BASIC_QOS_OK_METHOD: + return "AMQP_BASIC_QOS_OK_METHOD"; + case AMQP_BASIC_CONSUME_METHOD: + return "AMQP_BASIC_CONSUME_METHOD"; + case AMQP_BASIC_CONSUME_OK_METHOD: + return "AMQP_BASIC_CONSUME_OK_METHOD"; + case AMQP_BASIC_CANCEL_METHOD: + return "AMQP_BASIC_CANCEL_METHOD"; + case AMQP_BASIC_CANCEL_OK_METHOD: + return "AMQP_BASIC_CANCEL_OK_METHOD"; + case AMQP_BASIC_PUBLISH_METHOD: + return "AMQP_BASIC_PUBLISH_METHOD"; + case AMQP_BASIC_RETURN_METHOD: + return "AMQP_BASIC_RETURN_METHOD"; + case AMQP_BASIC_DELIVER_METHOD: + return "AMQP_BASIC_DELIVER_METHOD"; + case AMQP_BASIC_GET_METHOD: + return "AMQP_BASIC_GET_METHOD"; + case AMQP_BASIC_GET_OK_METHOD: + return "AMQP_BASIC_GET_OK_METHOD"; + case AMQP_BASIC_GET_EMPTY_METHOD: + return "AMQP_BASIC_GET_EMPTY_METHOD"; + case AMQP_BASIC_ACK_METHOD: + return "AMQP_BASIC_ACK_METHOD"; + case AMQP_BASIC_REJECT_METHOD: + return "AMQP_BASIC_REJECT_METHOD"; + case AMQP_BASIC_RECOVER_ASYNC_METHOD: + return "AMQP_BASIC_RECOVER_ASYNC_METHOD"; + case AMQP_BASIC_RECOVER_METHOD: + return "AMQP_BASIC_RECOVER_METHOD"; + case AMQP_BASIC_RECOVER_OK_METHOD: + return "AMQP_BASIC_RECOVER_OK_METHOD"; + case AMQP_BASIC_NACK_METHOD: + return "AMQP_BASIC_NACK_METHOD"; + case AMQP_TX_SELECT_METHOD: + return "AMQP_TX_SELECT_METHOD"; + case AMQP_TX_SELECT_OK_METHOD: + return "AMQP_TX_SELECT_OK_METHOD"; + case AMQP_TX_COMMIT_METHOD: + return "AMQP_TX_COMMIT_METHOD"; + case AMQP_TX_COMMIT_OK_METHOD: + return "AMQP_TX_COMMIT_OK_METHOD"; + case AMQP_TX_ROLLBACK_METHOD: + return "AMQP_TX_ROLLBACK_METHOD"; + case AMQP_TX_ROLLBACK_OK_METHOD: + return "AMQP_TX_ROLLBACK_OK_METHOD"; + case AMQP_CONFIRM_SELECT_METHOD: + return "AMQP_CONFIRM_SELECT_METHOD"; + case AMQP_CONFIRM_SELECT_OK_METHOD: + return "AMQP_CONFIRM_SELECT_OK_METHOD"; + default: + return NULL; } } amqp_boolean_t amqp_method_has_content(amqp_method_number_t methodNumber) { switch (methodNumber) { - case AMQP_BASIC_PUBLISH_METHOD: return 1; - case AMQP_BASIC_RETURN_METHOD: return 1; - case AMQP_BASIC_DELIVER_METHOD: return 1; - case AMQP_BASIC_GET_OK_METHOD: return 1; - default: return 0; + case AMQP_BASIC_PUBLISH_METHOD: + return 1; + case AMQP_BASIC_RETURN_METHOD: + return 1; + case AMQP_BASIC_DELIVER_METHOD: + return 1; + case AMQP_BASIC_GET_OK_METHOD: + return 1; + default: + return 0; } } -int amqp_decode_method(amqp_method_number_t methodNumber, - amqp_pool_t *pool, - amqp_bytes_t encoded, - void **decoded) -{ +int amqp_decode_method(amqp_method_number_t methodNumber, amqp_pool_t *pool, + amqp_bytes_t encoded, void **decoded) { size_t offset = 0; uint8_t bit_buffer; switch (methodNumber) { case AMQP_CONNECTION_START_METHOD: { - amqp_connection_start_t *m = (amqp_connection_start_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_start_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_8(encoded, &offset, &m->version_major)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_8(encoded, &offset, &m->version_minor)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_connection_start_t *m = (amqp_connection_start_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_start_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_8(encoded, &offset, &m->version_major)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &m->version_minor)) + return AMQP_STATUS_BAD_AMQP_DATA; { - int res = amqp_decode_table(encoded, pool, &(m->server_properties), &offset); + int res = + amqp_decode_table(encoded, pool, &(m->server_properties), &offset); if (res < 0) return res; } { uint32_t len; - if (!amqp_decode_32(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->mechanisms, len)) + if (!amqp_decode_32(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->mechanisms, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint32_t len; - if (!amqp_decode_32(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->locales, len)) + if (!amqp_decode_32(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->locales, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_CONNECTION_START_OK_METHOD: { - amqp_connection_start_ok_t *m = (amqp_connection_start_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_start_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_connection_start_ok_t *m = + (amqp_connection_start_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_start_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { - int res = amqp_decode_table(encoded, pool, &(m->client_properties), &offset); + int res = + amqp_decode_table(encoded, pool, &(m->client_properties), &offset); if (res < 0) return res; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->mechanism, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->mechanism, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint32_t len; - if (!amqp_decode_32(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->response, len)) + if (!amqp_decode_32(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->response, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->locale, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->locale, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_CONNECTION_SECURE_METHOD: { - amqp_connection_secure_t *m = (amqp_connection_secure_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_secure_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_connection_secure_t *m = (amqp_connection_secure_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_secure_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint32_t len; - if (!amqp_decode_32(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->challenge, len)) + if (!amqp_decode_32(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->challenge, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_CONNECTION_SECURE_OK_METHOD: { - amqp_connection_secure_ok_t *m = (amqp_connection_secure_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_secure_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_connection_secure_ok_t *m = + (amqp_connection_secure_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_secure_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint32_t len; - if (!amqp_decode_32(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->response, len)) + if (!amqp_decode_32(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->response, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_CONNECTION_TUNE_METHOD: { - amqp_connection_tune_t *m = (amqp_connection_tune_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_tune_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->channel_max)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_32(encoded, &offset, &m->frame_max)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_16(encoded, &offset, &m->heartbeat)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_connection_tune_t *m = (amqp_connection_tune_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_tune_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->channel_max)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_32(encoded, &offset, &m->frame_max)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_16(encoded, &offset, &m->heartbeat)) + return AMQP_STATUS_BAD_AMQP_DATA; *decoded = m; return 0; } case AMQP_CONNECTION_TUNE_OK_METHOD: { - amqp_connection_tune_ok_t *m = (amqp_connection_tune_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_tune_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->channel_max)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_32(encoded, &offset, &m->frame_max)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_16(encoded, &offset, &m->heartbeat)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_connection_tune_ok_t *m = + (amqp_connection_tune_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_tune_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->channel_max)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_32(encoded, &offset, &m->frame_max)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_16(encoded, &offset, &m->heartbeat)) + return AMQP_STATUS_BAD_AMQP_DATA; *decoded = m; return 0; } case AMQP_CONNECTION_OPEN_METHOD: { - amqp_connection_open_t *m = (amqp_connection_open_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_open_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_connection_open_t *m = (amqp_connection_open_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_open_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->virtual_host, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->virtual_host, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->capabilities, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->capabilities, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->insist = (bit_buffer & (1 << 0)) ? 1 : 0; *decoded = m; return 0; } case AMQP_CONNECTION_OPEN_OK_METHOD: { - amqp_connection_open_ok_t *m = (amqp_connection_open_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_open_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_connection_open_ok_t *m = + (amqp_connection_open_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_open_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->known_hosts, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->known_hosts, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_CONNECTION_CLOSE_METHOD: { - amqp_connection_close_t *m = (amqp_connection_close_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_close_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->reply_code)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_connection_close_t *m = (amqp_connection_close_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_close_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->reply_code)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->reply_text, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->reply_text, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_16(encoded, &offset, &m->class_id)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_16(encoded, &offset, &m->method_id)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_16(encoded, &offset, &m->class_id)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_16(encoded, &offset, &m->method_id)) + return AMQP_STATUS_BAD_AMQP_DATA; *decoded = m; return 0; } case AMQP_CONNECTION_CLOSE_OK_METHOD: { - amqp_connection_close_ok_t *m = (amqp_connection_close_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_close_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_connection_close_ok_t *m = + (amqp_connection_close_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_close_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_CONNECTION_BLOCKED_METHOD: { - amqp_connection_blocked_t *m = (amqp_connection_blocked_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_blocked_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_connection_blocked_t *m = + (amqp_connection_blocked_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_blocked_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->reason, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->reason, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_CONNECTION_UNBLOCKED_METHOD: { - amqp_connection_unblocked_t *m = (amqp_connection_unblocked_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_unblocked_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_connection_unblocked_t *m = + (amqp_connection_unblocked_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_unblocked_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_CHANNEL_OPEN_METHOD: { - amqp_channel_open_t *m = (amqp_channel_open_t *) amqp_pool_alloc(pool, sizeof(amqp_channel_open_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_channel_open_t *m = (amqp_channel_open_t *)amqp_pool_alloc( + pool, sizeof(amqp_channel_open_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->out_of_band, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->out_of_band, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_CHANNEL_OPEN_OK_METHOD: { - amqp_channel_open_ok_t *m = (amqp_channel_open_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_channel_open_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_channel_open_ok_t *m = (amqp_channel_open_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_channel_open_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint32_t len; - if (!amqp_decode_32(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->channel_id, len)) + if (!amqp_decode_32(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->channel_id, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_CHANNEL_FLOW_METHOD: { - amqp_channel_flow_t *m = (amqp_channel_flow_t *) amqp_pool_alloc(pool, sizeof(amqp_channel_flow_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_channel_flow_t *m = (amqp_channel_flow_t *)amqp_pool_alloc( + pool, sizeof(amqp_channel_flow_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->active = (bit_buffer & (1 << 0)) ? 1 : 0; *decoded = m; return 0; } case AMQP_CHANNEL_FLOW_OK_METHOD: { - amqp_channel_flow_ok_t *m = (amqp_channel_flow_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_channel_flow_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_channel_flow_ok_t *m = (amqp_channel_flow_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_channel_flow_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->active = (bit_buffer & (1 << 0)) ? 1 : 0; *decoded = m; return 0; } case AMQP_CHANNEL_CLOSE_METHOD: { - amqp_channel_close_t *m = (amqp_channel_close_t *) amqp_pool_alloc(pool, sizeof(amqp_channel_close_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->reply_code)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_channel_close_t *m = (amqp_channel_close_t *)amqp_pool_alloc( + pool, sizeof(amqp_channel_close_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->reply_code)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->reply_text, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->reply_text, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_16(encoded, &offset, &m->class_id)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_16(encoded, &offset, &m->method_id)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_16(encoded, &offset, &m->class_id)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_16(encoded, &offset, &m->method_id)) + return AMQP_STATUS_BAD_AMQP_DATA; *decoded = m; return 0; } case AMQP_CHANNEL_CLOSE_OK_METHOD: { - amqp_channel_close_ok_t *m = (amqp_channel_close_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_channel_close_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_channel_close_ok_t *m = (amqp_channel_close_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_channel_close_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_ACCESS_REQUEST_METHOD: { - amqp_access_request_t *m = (amqp_access_request_t *) amqp_pool_alloc(pool, sizeof(amqp_access_request_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_access_request_t *m = (amqp_access_request_t *)amqp_pool_alloc( + pool, sizeof(amqp_access_request_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->realm, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->realm, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->exclusive = (bit_buffer & (1 << 0)) ? 1 : 0; m->passive = (bit_buffer & (1 << 1)) ? 1 : 0; m->active = (bit_buffer & (1 << 2)) ? 1 : 0; @@ -427,29 +615,38 @@ return 0; } case AMQP_ACCESS_REQUEST_OK_METHOD: { - amqp_access_request_ok_t *m = (amqp_access_request_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_access_request_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_access_request_ok_t *m = (amqp_access_request_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_access_request_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; *decoded = m; return 0; } case AMQP_EXCHANGE_DECLARE_METHOD: { - amqp_exchange_declare_t *m = (amqp_exchange_declare_t *) amqp_pool_alloc(pool, sizeof(amqp_exchange_declare_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_exchange_declare_t *m = (amqp_exchange_declare_t *)amqp_pool_alloc( + pool, sizeof(amqp_exchange_declare_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->type, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->type, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->passive = (bit_buffer & (1 << 0)) ? 1 : 0; m->durable = (bit_buffer & (1 << 1)) ? 1 : 0; m->auto_delete = (bit_buffer & (1 << 2)) ? 1 : 0; @@ -463,56 +660,74 @@ return 0; } case AMQP_EXCHANGE_DECLARE_OK_METHOD: { - amqp_exchange_declare_ok_t *m = (amqp_exchange_declare_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_exchange_declare_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_exchange_declare_ok_t *m = + (amqp_exchange_declare_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_exchange_declare_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_EXCHANGE_DELETE_METHOD: { - amqp_exchange_delete_t *m = (amqp_exchange_delete_t *) amqp_pool_alloc(pool, sizeof(amqp_exchange_delete_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_exchange_delete_t *m = (amqp_exchange_delete_t *)amqp_pool_alloc( + pool, sizeof(amqp_exchange_delete_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->if_unused = (bit_buffer & (1 << 0)) ? 1 : 0; m->nowait = (bit_buffer & (1 << 1)) ? 1 : 0; *decoded = m; return 0; } case AMQP_EXCHANGE_DELETE_OK_METHOD: { - amqp_exchange_delete_ok_t *m = (amqp_exchange_delete_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_exchange_delete_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_exchange_delete_ok_t *m = + (amqp_exchange_delete_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_exchange_delete_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_EXCHANGE_BIND_METHOD: { - amqp_exchange_bind_t *m = (amqp_exchange_bind_t *) amqp_pool_alloc(pool, sizeof(amqp_exchange_bind_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_exchange_bind_t *m = (amqp_exchange_bind_t *)amqp_pool_alloc( + pool, sizeof(amqp_exchange_bind_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->destination, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->destination, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->source, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->source, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->nowait = (bit_buffer & (1 << 0)) ? 1 : 0; { int res = amqp_decode_table(encoded, pool, &(m->arguments), &offset); @@ -522,34 +737,42 @@ return 0; } case AMQP_EXCHANGE_BIND_OK_METHOD: { - amqp_exchange_bind_ok_t *m = (amqp_exchange_bind_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_exchange_bind_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_exchange_bind_ok_t *m = (amqp_exchange_bind_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_exchange_bind_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_EXCHANGE_UNBIND_METHOD: { - amqp_exchange_unbind_t *m = (amqp_exchange_unbind_t *) amqp_pool_alloc(pool, sizeof(amqp_exchange_unbind_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_exchange_unbind_t *m = (amqp_exchange_unbind_t *)amqp_pool_alloc( + pool, sizeof(amqp_exchange_unbind_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->destination, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->destination, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->source, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->source, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->nowait = (bit_buffer & (1 << 0)) ? 1 : 0; { int res = amqp_decode_table(encoded, pool, &(m->arguments), &offset); @@ -559,22 +782,31 @@ return 0; } case AMQP_EXCHANGE_UNBIND_OK_METHOD: { - amqp_exchange_unbind_ok_t *m = (amqp_exchange_unbind_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_exchange_unbind_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_exchange_unbind_ok_t *m = + (amqp_exchange_unbind_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_exchange_unbind_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_QUEUE_DECLARE_METHOD: { - amqp_queue_declare_t *m = (amqp_queue_declare_t *) amqp_pool_alloc(pool, sizeof(amqp_queue_declare_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_queue_declare_t *m = (amqp_queue_declare_t *)amqp_pool_alloc( + pool, sizeof(amqp_queue_declare_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->queue, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->queue, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->passive = (bit_buffer & (1 << 0)) ? 1 : 0; m->durable = (bit_buffer & (1 << 1)) ? 1 : 0; m->exclusive = (bit_buffer & (1 << 2)) ? 1 : 0; @@ -588,42 +820,52 @@ return 0; } case AMQP_QUEUE_DECLARE_OK_METHOD: { - amqp_queue_declare_ok_t *m = (amqp_queue_declare_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_queue_declare_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_queue_declare_ok_t *m = (amqp_queue_declare_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_queue_declare_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->queue, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->queue, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_32(encoded, &offset, &m->message_count)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_32(encoded, &offset, &m->consumer_count)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_32(encoded, &offset, &m->message_count)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_32(encoded, &offset, &m->consumer_count)) + return AMQP_STATUS_BAD_AMQP_DATA; *decoded = m; return 0; } case AMQP_QUEUE_BIND_METHOD: { - amqp_queue_bind_t *m = (amqp_queue_bind_t *) amqp_pool_alloc(pool, sizeof(amqp_queue_bind_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_queue_bind_t *m = + (amqp_queue_bind_t *)amqp_pool_alloc(pool, sizeof(amqp_queue_bind_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->queue, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->queue, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->nowait = (bit_buffer & (1 << 0)) ? 1 : 0; { int res = amqp_decode_table(encoded, pool, &(m->arguments), &offset); @@ -633,44 +875,61 @@ return 0; } case AMQP_QUEUE_BIND_OK_METHOD: { - amqp_queue_bind_ok_t *m = (amqp_queue_bind_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_queue_bind_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_queue_bind_ok_t *m = (amqp_queue_bind_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_queue_bind_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_QUEUE_PURGE_METHOD: { - amqp_queue_purge_t *m = (amqp_queue_purge_t *) amqp_pool_alloc(pool, sizeof(amqp_queue_purge_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_queue_purge_t *m = (amqp_queue_purge_t *)amqp_pool_alloc( + pool, sizeof(amqp_queue_purge_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->queue, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->queue, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->nowait = (bit_buffer & (1 << 0)) ? 1 : 0; *decoded = m; return 0; } case AMQP_QUEUE_PURGE_OK_METHOD: { - amqp_queue_purge_ok_t *m = (amqp_queue_purge_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_queue_purge_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_32(encoded, &offset, &m->message_count)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_queue_purge_ok_t *m = (amqp_queue_purge_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_queue_purge_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_32(encoded, &offset, &m->message_count)) + return AMQP_STATUS_BAD_AMQP_DATA; *decoded = m; return 0; } case AMQP_QUEUE_DELETE_METHOD: { - amqp_queue_delete_t *m = (amqp_queue_delete_t *) amqp_pool_alloc(pool, sizeof(amqp_queue_delete_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_queue_delete_t *m = (amqp_queue_delete_t *)amqp_pool_alloc( + pool, sizeof(amqp_queue_delete_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->queue, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->queue, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->if_unused = (bit_buffer & (1 << 0)) ? 1 : 0; m->if_empty = (bit_buffer & (1 << 1)) ? 1 : 0; m->nowait = (bit_buffer & (1 << 2)) ? 1 : 0; @@ -678,32 +937,40 @@ return 0; } case AMQP_QUEUE_DELETE_OK_METHOD: { - amqp_queue_delete_ok_t *m = (amqp_queue_delete_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_queue_delete_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_32(encoded, &offset, &m->message_count)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_queue_delete_ok_t *m = (amqp_queue_delete_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_queue_delete_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_32(encoded, &offset, &m->message_count)) + return AMQP_STATUS_BAD_AMQP_DATA; *decoded = m; return 0; } case AMQP_QUEUE_UNBIND_METHOD: { - amqp_queue_unbind_t *m = (amqp_queue_unbind_t *) amqp_pool_alloc(pool, sizeof(amqp_queue_unbind_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_queue_unbind_t *m = (amqp_queue_unbind_t *)amqp_pool_alloc( + pool, sizeof(amqp_queue_unbind_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->queue, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->queue, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { @@ -714,44 +981,61 @@ return 0; } case AMQP_QUEUE_UNBIND_OK_METHOD: { - amqp_queue_unbind_ok_t *m = (amqp_queue_unbind_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_queue_unbind_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_queue_unbind_ok_t *m = (amqp_queue_unbind_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_queue_unbind_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_BASIC_QOS_METHOD: { - amqp_basic_qos_t *m = (amqp_basic_qos_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_qos_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_32(encoded, &offset, &m->prefetch_size)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_16(encoded, &offset, &m->prefetch_count)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_qos_t *m = + (amqp_basic_qos_t *)amqp_pool_alloc(pool, sizeof(amqp_basic_qos_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_32(encoded, &offset, &m->prefetch_size)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_16(encoded, &offset, &m->prefetch_count)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->global = (bit_buffer & (1 << 0)) ? 1 : 0; *decoded = m; return 0; } case AMQP_BASIC_QOS_OK_METHOD: { - amqp_basic_qos_ok_t *m = (amqp_basic_qos_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_qos_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_basic_qos_ok_t *m = (amqp_basic_qos_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_qos_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_BASIC_CONSUME_METHOD: { - amqp_basic_consume_t *m = (amqp_basic_consume_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_consume_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_consume_t *m = (amqp_basic_consume_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_consume_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->queue, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->queue, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->consumer_tag, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->consumer_tag, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->no_local = (bit_buffer & (1 << 0)) ? 1 : 0; m->no_ack = (bit_buffer & (1 << 1)) ? 1 : 0; m->exclusive = (bit_buffer & (1 << 2)) ? 1 : 0; @@ -764,275 +1048,363 @@ return 0; } case AMQP_BASIC_CONSUME_OK_METHOD: { - amqp_basic_consume_ok_t *m = (amqp_basic_consume_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_consume_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_basic_consume_ok_t *m = (amqp_basic_consume_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_consume_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->consumer_tag, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->consumer_tag, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_BASIC_CANCEL_METHOD: { - amqp_basic_cancel_t *m = (amqp_basic_cancel_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_cancel_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_basic_cancel_t *m = (amqp_basic_cancel_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_cancel_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->consumer_tag, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->consumer_tag, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->nowait = (bit_buffer & (1 << 0)) ? 1 : 0; *decoded = m; return 0; } case AMQP_BASIC_CANCEL_OK_METHOD: { - amqp_basic_cancel_ok_t *m = (amqp_basic_cancel_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_cancel_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_basic_cancel_ok_t *m = (amqp_basic_cancel_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_cancel_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->consumer_tag, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->consumer_tag, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_BASIC_PUBLISH_METHOD: { - amqp_basic_publish_t *m = (amqp_basic_publish_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_publish_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_publish_t *m = (amqp_basic_publish_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_publish_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->mandatory = (bit_buffer & (1 << 0)) ? 1 : 0; m->immediate = (bit_buffer & (1 << 1)) ? 1 : 0; *decoded = m; return 0; } case AMQP_BASIC_RETURN_METHOD: { - amqp_basic_return_t *m = (amqp_basic_return_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_return_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->reply_code)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_return_t *m = (amqp_basic_return_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_return_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->reply_code)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->reply_text, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->reply_text, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_BASIC_DELIVER_METHOD: { - amqp_basic_deliver_t *m = (amqp_basic_deliver_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_deliver_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_basic_deliver_t *m = (amqp_basic_deliver_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_deliver_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->consumer_tag, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->consumer_tag, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_64(encoded, &offset, &m->delivery_tag)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_64(encoded, &offset, &m->delivery_tag)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->redelivered = (bit_buffer & (1 << 0)) ? 1 : 0; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_BASIC_GET_METHOD: { - amqp_basic_get_t *m = (amqp_basic_get_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_get_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_16(encoded, &offset, &m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_get_t *m = + (amqp_basic_get_t *)amqp_pool_alloc(pool, sizeof(amqp_basic_get_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_16(encoded, &offset, &m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->queue, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->queue, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->no_ack = (bit_buffer & (1 << 0)) ? 1 : 0; *decoded = m; return 0; } case AMQP_BASIC_GET_OK_METHOD: { - amqp_basic_get_ok_t *m = (amqp_basic_get_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_get_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_64(encoded, &offset, &m->delivery_tag)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_get_ok_t *m = (amqp_basic_get_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_get_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_64(encoded, &offset, &m->delivery_tag)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->redelivered = (bit_buffer & (1 << 0)) ? 1 : 0; { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->exchange, len)) return AMQP_STATUS_BAD_AMQP_DATA; } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->routing_key, len)) return AMQP_STATUS_BAD_AMQP_DATA; } - if (!amqp_decode_32(encoded, &offset, &m->message_count)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_32(encoded, &offset, &m->message_count)) + return AMQP_STATUS_BAD_AMQP_DATA; *decoded = m; return 0; } case AMQP_BASIC_GET_EMPTY_METHOD: { - amqp_basic_get_empty_t *m = (amqp_basic_get_empty_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_get_empty_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_basic_get_empty_t *m = (amqp_basic_get_empty_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_get_empty_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } { uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &m->cluster_id, len)) + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &m->cluster_id, len)) return AMQP_STATUS_BAD_AMQP_DATA; } *decoded = m; return 0; } case AMQP_BASIC_ACK_METHOD: { - amqp_basic_ack_t *m = (amqp_basic_ack_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_ack_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_64(encoded, &offset, &m->delivery_tag)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_ack_t *m = + (amqp_basic_ack_t *)amqp_pool_alloc(pool, sizeof(amqp_basic_ack_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_64(encoded, &offset, &m->delivery_tag)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->multiple = (bit_buffer & (1 << 0)) ? 1 : 0; *decoded = m; return 0; } case AMQP_BASIC_REJECT_METHOD: { - amqp_basic_reject_t *m = (amqp_basic_reject_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_reject_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_64(encoded, &offset, &m->delivery_tag)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_reject_t *m = (amqp_basic_reject_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_reject_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_64(encoded, &offset, &m->delivery_tag)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->requeue = (bit_buffer & (1 << 0)) ? 1 : 0; *decoded = m; return 0; } case AMQP_BASIC_RECOVER_ASYNC_METHOD: { - amqp_basic_recover_async_t *m = (amqp_basic_recover_async_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_recover_async_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_recover_async_t *m = + (amqp_basic_recover_async_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_recover_async_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->requeue = (bit_buffer & (1 << 0)) ? 1 : 0; *decoded = m; return 0; } case AMQP_BASIC_RECOVER_METHOD: { - amqp_basic_recover_t *m = (amqp_basic_recover_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_recover_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_recover_t *m = (amqp_basic_recover_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_recover_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->requeue = (bit_buffer & (1 << 0)) ? 1 : 0; *decoded = m; return 0; } case AMQP_BASIC_RECOVER_OK_METHOD: { - amqp_basic_recover_ok_t *m = (amqp_basic_recover_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_recover_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_basic_recover_ok_t *m = (amqp_basic_recover_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_recover_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_BASIC_NACK_METHOD: { - amqp_basic_nack_t *m = (amqp_basic_nack_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_nack_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_64(encoded, &offset, &m->delivery_tag)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_nack_t *m = + (amqp_basic_nack_t *)amqp_pool_alloc(pool, sizeof(amqp_basic_nack_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_64(encoded, &offset, &m->delivery_tag)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->multiple = (bit_buffer & (1 << 0)) ? 1 : 0; m->requeue = (bit_buffer & (1 << 1)) ? 1 : 0; *decoded = m; return 0; } case AMQP_TX_SELECT_METHOD: { - amqp_tx_select_t *m = (amqp_tx_select_t *) amqp_pool_alloc(pool, sizeof(amqp_tx_select_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_tx_select_t *m = + (amqp_tx_select_t *)amqp_pool_alloc(pool, sizeof(amqp_tx_select_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_TX_SELECT_OK_METHOD: { - amqp_tx_select_ok_t *m = (amqp_tx_select_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_tx_select_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_tx_select_ok_t *m = (amqp_tx_select_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_tx_select_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_TX_COMMIT_METHOD: { - amqp_tx_commit_t *m = (amqp_tx_commit_t *) amqp_pool_alloc(pool, sizeof(amqp_tx_commit_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_tx_commit_t *m = + (amqp_tx_commit_t *)amqp_pool_alloc(pool, sizeof(amqp_tx_commit_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_TX_COMMIT_OK_METHOD: { - amqp_tx_commit_ok_t *m = (amqp_tx_commit_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_tx_commit_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_tx_commit_ok_t *m = (amqp_tx_commit_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_tx_commit_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_TX_ROLLBACK_METHOD: { - amqp_tx_rollback_t *m = (amqp_tx_rollback_t *) amqp_pool_alloc(pool, sizeof(amqp_tx_rollback_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_tx_rollback_t *m = (amqp_tx_rollback_t *)amqp_pool_alloc( + pool, sizeof(amqp_tx_rollback_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_TX_ROLLBACK_OK_METHOD: { - amqp_tx_rollback_ok_t *m = (amqp_tx_rollback_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_tx_rollback_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_tx_rollback_ok_t *m = (amqp_tx_rollback_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_tx_rollback_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } case AMQP_CONFIRM_SELECT_METHOD: { - amqp_confirm_select_t *m = (amqp_confirm_select_t *) amqp_pool_alloc(pool, sizeof(amqp_confirm_select_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } - if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_confirm_select_t *m = (amqp_confirm_select_t *)amqp_pool_alloc( + pool, sizeof(amqp_confirm_select_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } + if (!amqp_decode_8(encoded, &offset, &bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; m->nowait = (bit_buffer & (1 << 0)) ? 1 : 0; *decoded = m; return 0; } case AMQP_CONFIRM_SELECT_OK_METHOD: { - amqp_confirm_select_ok_t *m = (amqp_confirm_select_ok_t *) amqp_pool_alloc(pool, sizeof(amqp_confirm_select_ok_t)); - if (m == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_confirm_select_ok_t *m = (amqp_confirm_select_ok_t *)amqp_pool_alloc( + pool, sizeof(amqp_confirm_select_ok_t)); + if (m == NULL) { + return AMQP_STATUS_NO_MEMORY; + } *decoded = m; return 0; } - default: return AMQP_STATUS_UNKNOWN_METHOD; + default: + return AMQP_STATUS_UNKNOWN_METHOD; } } -int amqp_decode_properties(uint16_t class_id, - amqp_pool_t *pool, - amqp_bytes_t encoded, - void **decoded) -{ +int amqp_decode_properties(uint16_t class_id, amqp_pool_t *pool, + amqp_bytes_t encoded, void **decoded) { size_t offset = 0; amqp_flags_t flags = 0; @@ -1048,278 +1420,320 @@ switch (class_id) { case 10: { - amqp_connection_properties_t *p = (amqp_connection_properties_t *) amqp_pool_alloc(pool, sizeof(amqp_connection_properties_t)); - if (p == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_connection_properties_t *p = + (amqp_connection_properties_t *)amqp_pool_alloc( + pool, sizeof(amqp_connection_properties_t)); + if (p == NULL) { + return AMQP_STATUS_NO_MEMORY; + } p->_flags = flags; *decoded = p; return 0; } case 20: { - amqp_channel_properties_t *p = (amqp_channel_properties_t *) amqp_pool_alloc(pool, sizeof(amqp_channel_properties_t)); - if (p == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_channel_properties_t *p = + (amqp_channel_properties_t *)amqp_pool_alloc( + pool, sizeof(amqp_channel_properties_t)); + if (p == NULL) { + return AMQP_STATUS_NO_MEMORY; + } p->_flags = flags; *decoded = p; return 0; } case 30: { - amqp_access_properties_t *p = (amqp_access_properties_t *) amqp_pool_alloc(pool, sizeof(amqp_access_properties_t)); - if (p == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_access_properties_t *p = (amqp_access_properties_t *)amqp_pool_alloc( + pool, sizeof(amqp_access_properties_t)); + if (p == NULL) { + return AMQP_STATUS_NO_MEMORY; + } p->_flags = flags; *decoded = p; return 0; } case 40: { - amqp_exchange_properties_t *p = (amqp_exchange_properties_t *) amqp_pool_alloc(pool, sizeof(amqp_exchange_properties_t)); - if (p == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_exchange_properties_t *p = + (amqp_exchange_properties_t *)amqp_pool_alloc( + pool, sizeof(amqp_exchange_properties_t)); + if (p == NULL) { + return AMQP_STATUS_NO_MEMORY; + } p->_flags = flags; *decoded = p; return 0; } case 50: { - amqp_queue_properties_t *p = (amqp_queue_properties_t *) amqp_pool_alloc(pool, sizeof(amqp_queue_properties_t)); - if (p == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_queue_properties_t *p = (amqp_queue_properties_t *)amqp_pool_alloc( + pool, sizeof(amqp_queue_properties_t)); + if (p == NULL) { + return AMQP_STATUS_NO_MEMORY; + } p->_flags = flags; *decoded = p; return 0; } case 60: { - amqp_basic_properties_t *p = (amqp_basic_properties_t *) amqp_pool_alloc(pool, sizeof(amqp_basic_properties_t)); - if (p == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_basic_properties_t *p = (amqp_basic_properties_t *)amqp_pool_alloc( + pool, sizeof(amqp_basic_properties_t)); + if (p == NULL) { + return AMQP_STATUS_NO_MEMORY; + } p->_flags = flags; if (flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { - { - uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &p->content_type, len)) - return AMQP_STATUS_BAD_AMQP_DATA; - } + { + uint8_t len; + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &p->content_type, len)) + return AMQP_STATUS_BAD_AMQP_DATA; + } } if (flags & AMQP_BASIC_CONTENT_ENCODING_FLAG) { - { - uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &p->content_encoding, len)) - return AMQP_STATUS_BAD_AMQP_DATA; - } + { + uint8_t len; + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &p->content_encoding, len)) + return AMQP_STATUS_BAD_AMQP_DATA; + } } if (flags & AMQP_BASIC_HEADERS_FLAG) { - { - int res = amqp_decode_table(encoded, pool, &(p->headers), &offset); - if (res < 0) return res; - } + { + int res = amqp_decode_table(encoded, pool, &(p->headers), &offset); + if (res < 0) return res; + } } if (flags & AMQP_BASIC_DELIVERY_MODE_FLAG) { - if (!amqp_decode_8(encoded, &offset, &p->delivery_mode)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_decode_8(encoded, &offset, &p->delivery_mode)) + return AMQP_STATUS_BAD_AMQP_DATA; } if (flags & AMQP_BASIC_PRIORITY_FLAG) { - if (!amqp_decode_8(encoded, &offset, &p->priority)) return AMQP_STATUS_BAD_AMQP_DATA; - } - if (flags & AMQP_BASIC_CORRELATION_ID_FLAG) { - { - uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &p->correlation_id, len)) + if (!amqp_decode_8(encoded, &offset, &p->priority)) return AMQP_STATUS_BAD_AMQP_DATA; } + if (flags & AMQP_BASIC_CORRELATION_ID_FLAG) { + { + uint8_t len; + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &p->correlation_id, len)) + return AMQP_STATUS_BAD_AMQP_DATA; + } } if (flags & AMQP_BASIC_REPLY_TO_FLAG) { - { - uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &p->reply_to, len)) - return AMQP_STATUS_BAD_AMQP_DATA; - } + { + uint8_t len; + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &p->reply_to, len)) + return AMQP_STATUS_BAD_AMQP_DATA; + } } if (flags & AMQP_BASIC_EXPIRATION_FLAG) { - { - uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &p->expiration, len)) - return AMQP_STATUS_BAD_AMQP_DATA; - } + { + uint8_t len; + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &p->expiration, len)) + return AMQP_STATUS_BAD_AMQP_DATA; + } } if (flags & AMQP_BASIC_MESSAGE_ID_FLAG) { - { - uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &p->message_id, len)) - return AMQP_STATUS_BAD_AMQP_DATA; - } + { + uint8_t len; + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &p->message_id, len)) + return AMQP_STATUS_BAD_AMQP_DATA; + } } if (flags & AMQP_BASIC_TIMESTAMP_FLAG) { - if (!amqp_decode_64(encoded, &offset, &p->timestamp)) return AMQP_STATUS_BAD_AMQP_DATA; - } - if (flags & AMQP_BASIC_TYPE_FLAG) { - { - uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &p->type, len)) + if (!amqp_decode_64(encoded, &offset, &p->timestamp)) return AMQP_STATUS_BAD_AMQP_DATA; } + if (flags & AMQP_BASIC_TYPE_FLAG) { + { + uint8_t len; + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &p->type, len)) + return AMQP_STATUS_BAD_AMQP_DATA; + } } if (flags & AMQP_BASIC_USER_ID_FLAG) { - { - uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &p->user_id, len)) - return AMQP_STATUS_BAD_AMQP_DATA; - } + { + uint8_t len; + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &p->user_id, len)) + return AMQP_STATUS_BAD_AMQP_DATA; + } } if (flags & AMQP_BASIC_APP_ID_FLAG) { - { - uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &p->app_id, len)) - return AMQP_STATUS_BAD_AMQP_DATA; - } + { + uint8_t len; + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &p->app_id, len)) + return AMQP_STATUS_BAD_AMQP_DATA; + } } if (flags & AMQP_BASIC_CLUSTER_ID_FLAG) { - { - uint8_t len; - if (!amqp_decode_8(encoded, &offset, &len) - || !amqp_decode_bytes(encoded, &offset, &p->cluster_id, len)) - return AMQP_STATUS_BAD_AMQP_DATA; - } + { + uint8_t len; + if (!amqp_decode_8(encoded, &offset, &len) || + !amqp_decode_bytes(encoded, &offset, &p->cluster_id, len)) + return AMQP_STATUS_BAD_AMQP_DATA; + } } *decoded = p; return 0; } case 90: { - amqp_tx_properties_t *p = (amqp_tx_properties_t *) amqp_pool_alloc(pool, sizeof(amqp_tx_properties_t)); - if (p == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_tx_properties_t *p = (amqp_tx_properties_t *)amqp_pool_alloc( + pool, sizeof(amqp_tx_properties_t)); + if (p == NULL) { + return AMQP_STATUS_NO_MEMORY; + } p->_flags = flags; *decoded = p; return 0; } case 85: { - amqp_confirm_properties_t *p = (amqp_confirm_properties_t *) amqp_pool_alloc(pool, sizeof(amqp_confirm_properties_t)); - if (p == NULL) { return AMQP_STATUS_NO_MEMORY; } + amqp_confirm_properties_t *p = + (amqp_confirm_properties_t *)amqp_pool_alloc( + pool, sizeof(amqp_confirm_properties_t)); + if (p == NULL) { + return AMQP_STATUS_NO_MEMORY; + } p->_flags = flags; *decoded = p; return 0; } - default: return AMQP_STATUS_UNKNOWN_CLASS; + default: + return AMQP_STATUS_UNKNOWN_CLASS; } } -int amqp_encode_method(amqp_method_number_t methodNumber, - void *decoded, - amqp_bytes_t encoded) -{ +int amqp_encode_method(amqp_method_number_t methodNumber, void *decoded, + amqp_bytes_t encoded) { size_t offset = 0; uint8_t bit_buffer; switch (methodNumber) { case AMQP_CONNECTION_START_METHOD: { - amqp_connection_start_t *m = (amqp_connection_start_t *) decoded; - if (!amqp_encode_8(encoded, &offset, m->version_major)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_8(encoded, &offset, m->version_minor)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_connection_start_t *m = (amqp_connection_start_t *)decoded; + if (!amqp_encode_8(encoded, &offset, m->version_major)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, m->version_minor)) + return AMQP_STATUS_BAD_AMQP_DATA; { int res = amqp_encode_table(encoded, &(m->server_properties), &offset); if (res < 0) return res; } - if (UINT32_MAX < m->mechanisms.len - || !amqp_encode_32(encoded, &offset, (uint32_t)m->mechanisms.len) - || !amqp_encode_bytes(encoded, &offset, m->mechanisms)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT32_MAX < m->locales.len - || !amqp_encode_32(encoded, &offset, (uint32_t)m->locales.len) - || !amqp_encode_bytes(encoded, &offset, m->locales)) + if (UINT32_MAX < m->mechanisms.len || + !amqp_encode_32(encoded, &offset, (uint32_t)m->mechanisms.len) || + !amqp_encode_bytes(encoded, &offset, m->mechanisms)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT32_MAX < m->locales.len || + !amqp_encode_32(encoded, &offset, (uint32_t)m->locales.len) || + !amqp_encode_bytes(encoded, &offset, m->locales)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CONNECTION_START_OK_METHOD: { - amqp_connection_start_ok_t *m = (amqp_connection_start_ok_t *) decoded; + amqp_connection_start_ok_t *m = (amqp_connection_start_ok_t *)decoded; { int res = amqp_encode_table(encoded, &(m->client_properties), &offset); if (res < 0) return res; } - if (UINT8_MAX < m->mechanism.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->mechanism.len) - || !amqp_encode_bytes(encoded, &offset, m->mechanism)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT32_MAX < m->response.len - || !amqp_encode_32(encoded, &offset, (uint32_t)m->response.len) - || !amqp_encode_bytes(encoded, &offset, m->response)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->locale.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->locale.len) - || !amqp_encode_bytes(encoded, &offset, m->locale)) + if (UINT8_MAX < m->mechanism.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->mechanism.len) || + !amqp_encode_bytes(encoded, &offset, m->mechanism)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT32_MAX < m->response.len || + !amqp_encode_32(encoded, &offset, (uint32_t)m->response.len) || + !amqp_encode_bytes(encoded, &offset, m->response)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->locale.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->locale.len) || + !amqp_encode_bytes(encoded, &offset, m->locale)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CONNECTION_SECURE_METHOD: { - amqp_connection_secure_t *m = (amqp_connection_secure_t *) decoded; - if (UINT32_MAX < m->challenge.len - || !amqp_encode_32(encoded, &offset, (uint32_t)m->challenge.len) - || !amqp_encode_bytes(encoded, &offset, m->challenge)) + amqp_connection_secure_t *m = (amqp_connection_secure_t *)decoded; + if (UINT32_MAX < m->challenge.len || + !amqp_encode_32(encoded, &offset, (uint32_t)m->challenge.len) || + !amqp_encode_bytes(encoded, &offset, m->challenge)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CONNECTION_SECURE_OK_METHOD: { - amqp_connection_secure_ok_t *m = (amqp_connection_secure_ok_t *) decoded; - if (UINT32_MAX < m->response.len - || !amqp_encode_32(encoded, &offset, (uint32_t)m->response.len) - || !amqp_encode_bytes(encoded, &offset, m->response)) + amqp_connection_secure_ok_t *m = (amqp_connection_secure_ok_t *)decoded; + if (UINT32_MAX < m->response.len || + !amqp_encode_32(encoded, &offset, (uint32_t)m->response.len) || + !amqp_encode_bytes(encoded, &offset, m->response)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CONNECTION_TUNE_METHOD: { - amqp_connection_tune_t *m = (amqp_connection_tune_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->channel_max)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_32(encoded, &offset, m->frame_max)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_16(encoded, &offset, m->heartbeat)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_connection_tune_t *m = (amqp_connection_tune_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->channel_max)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_32(encoded, &offset, m->frame_max)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_16(encoded, &offset, m->heartbeat)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CONNECTION_TUNE_OK_METHOD: { - amqp_connection_tune_ok_t *m = (amqp_connection_tune_ok_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->channel_max)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_32(encoded, &offset, m->frame_max)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_16(encoded, &offset, m->heartbeat)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_connection_tune_ok_t *m = (amqp_connection_tune_ok_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->channel_max)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_32(encoded, &offset, m->frame_max)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_16(encoded, &offset, m->heartbeat)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CONNECTION_OPEN_METHOD: { - amqp_connection_open_t *m = (amqp_connection_open_t *) decoded; - if (UINT8_MAX < m->virtual_host.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->virtual_host.len) - || !amqp_encode_bytes(encoded, &offset, m->virtual_host)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->capabilities.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->capabilities.len) - || !amqp_encode_bytes(encoded, &offset, m->capabilities)) + amqp_connection_open_t *m = (amqp_connection_open_t *)decoded; + if (UINT8_MAX < m->virtual_host.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->virtual_host.len) || + !amqp_encode_bytes(encoded, &offset, m->virtual_host)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->capabilities.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->capabilities.len) || + !amqp_encode_bytes(encoded, &offset, m->capabilities)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->insist) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CONNECTION_OPEN_OK_METHOD: { - amqp_connection_open_ok_t *m = (amqp_connection_open_ok_t *) decoded; - if (UINT8_MAX < m->known_hosts.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->known_hosts.len) - || !amqp_encode_bytes(encoded, &offset, m->known_hosts)) + amqp_connection_open_ok_t *m = (amqp_connection_open_ok_t *)decoded; + if (UINT8_MAX < m->known_hosts.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->known_hosts.len) || + !amqp_encode_bytes(encoded, &offset, m->known_hosts)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CONNECTION_CLOSE_METHOD: { - amqp_connection_close_t *m = (amqp_connection_close_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->reply_code)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->reply_text.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->reply_text.len) - || !amqp_encode_bytes(encoded, &offset, m->reply_text)) + amqp_connection_close_t *m = (amqp_connection_close_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->reply_code)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->reply_text.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->reply_text.len) || + !amqp_encode_bytes(encoded, &offset, m->reply_text)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_16(encoded, &offset, m->class_id)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_16(encoded, &offset, m->method_id)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_16(encoded, &offset, m->class_id)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_16(encoded, &offset, m->method_id)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CONNECTION_CLOSE_OK_METHOD: { return (int)offset; } case AMQP_CONNECTION_BLOCKED_METHOD: { - amqp_connection_blocked_t *m = (amqp_connection_blocked_t *) decoded; - if (UINT8_MAX < m->reason.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->reason.len) - || !amqp_encode_bytes(encoded, &offset, m->reason)) + amqp_connection_blocked_t *m = (amqp_connection_blocked_t *)decoded; + if (UINT8_MAX < m->reason.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->reason.len) || + !amqp_encode_bytes(encoded, &offset, m->reason)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } @@ -1327,54 +1741,59 @@ return (int)offset; } case AMQP_CHANNEL_OPEN_METHOD: { - amqp_channel_open_t *m = (amqp_channel_open_t *) decoded; - if (UINT8_MAX < m->out_of_band.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->out_of_band.len) - || !amqp_encode_bytes(encoded, &offset, m->out_of_band)) + amqp_channel_open_t *m = (amqp_channel_open_t *)decoded; + if (UINT8_MAX < m->out_of_band.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->out_of_band.len) || + !amqp_encode_bytes(encoded, &offset, m->out_of_band)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CHANNEL_OPEN_OK_METHOD: { - amqp_channel_open_ok_t *m = (amqp_channel_open_ok_t *) decoded; - if (UINT32_MAX < m->channel_id.len - || !amqp_encode_32(encoded, &offset, (uint32_t)m->channel_id.len) - || !amqp_encode_bytes(encoded, &offset, m->channel_id)) + amqp_channel_open_ok_t *m = (amqp_channel_open_ok_t *)decoded; + if (UINT32_MAX < m->channel_id.len || + !amqp_encode_32(encoded, &offset, (uint32_t)m->channel_id.len) || + !amqp_encode_bytes(encoded, &offset, m->channel_id)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CHANNEL_FLOW_METHOD: { - amqp_channel_flow_t *m = (amqp_channel_flow_t *) decoded; + amqp_channel_flow_t *m = (amqp_channel_flow_t *)decoded; bit_buffer = 0; if (m->active) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CHANNEL_FLOW_OK_METHOD: { - amqp_channel_flow_ok_t *m = (amqp_channel_flow_ok_t *) decoded; + amqp_channel_flow_ok_t *m = (amqp_channel_flow_ok_t *)decoded; bit_buffer = 0; if (m->active) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CHANNEL_CLOSE_METHOD: { - amqp_channel_close_t *m = (amqp_channel_close_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->reply_code)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->reply_text.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->reply_text.len) - || !amqp_encode_bytes(encoded, &offset, m->reply_text)) + amqp_channel_close_t *m = (amqp_channel_close_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->reply_code)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->reply_text.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->reply_text.len) || + !amqp_encode_bytes(encoded, &offset, m->reply_text)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_16(encoded, &offset, m->class_id)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_16(encoded, &offset, m->method_id)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_16(encoded, &offset, m->class_id)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_16(encoded, &offset, m->method_id)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CHANNEL_CLOSE_OK_METHOD: { return (int)offset; } case AMQP_ACCESS_REQUEST_METHOD: { - amqp_access_request_t *m = (amqp_access_request_t *) decoded; - if (UINT8_MAX < m->realm.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->realm.len) - || !amqp_encode_bytes(encoded, &offset, m->realm)) + amqp_access_request_t *m = (amqp_access_request_t *)decoded; + if (UINT8_MAX < m->realm.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->realm.len) || + !amqp_encode_bytes(encoded, &offset, m->realm)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->exclusive) bit_buffer |= (1 << 0); @@ -1382,24 +1801,27 @@ if (m->active) bit_buffer |= (1 << 2); if (m->write) bit_buffer |= (1 << 3); if (m->read) bit_buffer |= (1 << 4); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_ACCESS_REQUEST_OK_METHOD: { - amqp_access_request_ok_t *m = (amqp_access_request_ok_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_access_request_ok_t *m = (amqp_access_request_ok_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_EXCHANGE_DECLARE_METHOD: { - amqp_exchange_declare_t *m = (amqp_exchange_declare_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->exchange.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) - || !amqp_encode_bytes(encoded, &offset, m->exchange)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->type.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->type.len) - || !amqp_encode_bytes(encoded, &offset, m->type)) + amqp_exchange_declare_t *m = (amqp_exchange_declare_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->exchange.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) || + !amqp_encode_bytes(encoded, &offset, m->exchange)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->type.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->type.len) || + !amqp_encode_bytes(encoded, &offset, m->type)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->passive) bit_buffer |= (1 << 0); @@ -1407,7 +1829,8 @@ if (m->auto_delete) bit_buffer |= (1 << 2); if (m->internal) bit_buffer |= (1 << 3); if (m->nowait) bit_buffer |= (1 << 4); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; { int res = amqp_encode_table(encoded, &(m->arguments), &offset); if (res < 0) return res; @@ -1418,39 +1841,43 @@ return (int)offset; } case AMQP_EXCHANGE_DELETE_METHOD: { - amqp_exchange_delete_t *m = (amqp_exchange_delete_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->exchange.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) - || !amqp_encode_bytes(encoded, &offset, m->exchange)) + amqp_exchange_delete_t *m = (amqp_exchange_delete_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->exchange.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) || + !amqp_encode_bytes(encoded, &offset, m->exchange)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->if_unused) bit_buffer |= (1 << 0); if (m->nowait) bit_buffer |= (1 << 1); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_EXCHANGE_DELETE_OK_METHOD: { return (int)offset; } case AMQP_EXCHANGE_BIND_METHOD: { - amqp_exchange_bind_t *m = (amqp_exchange_bind_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->destination.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->destination.len) - || !amqp_encode_bytes(encoded, &offset, m->destination)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->source.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->source.len) - || !amqp_encode_bytes(encoded, &offset, m->source)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->routing_key.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) - || !amqp_encode_bytes(encoded, &offset, m->routing_key)) + amqp_exchange_bind_t *m = (amqp_exchange_bind_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->destination.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->destination.len) || + !amqp_encode_bytes(encoded, &offset, m->destination)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->source.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->source.len) || + !amqp_encode_bytes(encoded, &offset, m->source)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->routing_key.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) || + !amqp_encode_bytes(encoded, &offset, m->routing_key)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->nowait) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; { int res = amqp_encode_table(encoded, &(m->arguments), &offset); if (res < 0) return res; @@ -1461,23 +1888,25 @@ return (int)offset; } case AMQP_EXCHANGE_UNBIND_METHOD: { - amqp_exchange_unbind_t *m = (amqp_exchange_unbind_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->destination.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->destination.len) - || !amqp_encode_bytes(encoded, &offset, m->destination)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->source.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->source.len) - || !amqp_encode_bytes(encoded, &offset, m->source)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->routing_key.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) - || !amqp_encode_bytes(encoded, &offset, m->routing_key)) + amqp_exchange_unbind_t *m = (amqp_exchange_unbind_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->destination.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->destination.len) || + !amqp_encode_bytes(encoded, &offset, m->destination)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->source.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->source.len) || + !amqp_encode_bytes(encoded, &offset, m->source)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->routing_key.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) || + !amqp_encode_bytes(encoded, &offset, m->routing_key)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->nowait) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; { int res = amqp_encode_table(encoded, &(m->arguments), &offset); if (res < 0) return res; @@ -1488,11 +1917,12 @@ return (int)offset; } case AMQP_QUEUE_DECLARE_METHOD: { - amqp_queue_declare_t *m = (amqp_queue_declare_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->queue.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) - || !amqp_encode_bytes(encoded, &offset, m->queue)) + amqp_queue_declare_t *m = (amqp_queue_declare_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->queue.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) || + !amqp_encode_bytes(encoded, &offset, m->queue)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->passive) bit_buffer |= (1 << 0); @@ -1500,7 +1930,8 @@ if (m->exclusive) bit_buffer |= (1 << 2); if (m->auto_delete) bit_buffer |= (1 << 3); if (m->nowait) bit_buffer |= (1 << 4); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; { int res = amqp_encode_table(encoded, &(m->arguments), &offset); if (res < 0) return res; @@ -1508,33 +1939,37 @@ return (int)offset; } case AMQP_QUEUE_DECLARE_OK_METHOD: { - amqp_queue_declare_ok_t *m = (amqp_queue_declare_ok_t *) decoded; - if (UINT8_MAX < m->queue.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) - || !amqp_encode_bytes(encoded, &offset, m->queue)) + amqp_queue_declare_ok_t *m = (amqp_queue_declare_ok_t *)decoded; + if (UINT8_MAX < m->queue.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) || + !amqp_encode_bytes(encoded, &offset, m->queue)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_32(encoded, &offset, m->message_count)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_32(encoded, &offset, m->consumer_count)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_32(encoded, &offset, m->message_count)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_32(encoded, &offset, m->consumer_count)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_QUEUE_BIND_METHOD: { - amqp_queue_bind_t *m = (amqp_queue_bind_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->queue.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) - || !amqp_encode_bytes(encoded, &offset, m->queue)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->exchange.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) - || !amqp_encode_bytes(encoded, &offset, m->exchange)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->routing_key.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) - || !amqp_encode_bytes(encoded, &offset, m->routing_key)) + amqp_queue_bind_t *m = (amqp_queue_bind_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->queue.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) || + !amqp_encode_bytes(encoded, &offset, m->queue)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->exchange.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) || + !amqp_encode_bytes(encoded, &offset, m->exchange)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->routing_key.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) || + !amqp_encode_bytes(encoded, &offset, m->routing_key)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->nowait) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; { int res = amqp_encode_table(encoded, &(m->arguments), &offset); if (res < 0) return res; @@ -1545,55 +1980,62 @@ return (int)offset; } case AMQP_QUEUE_PURGE_METHOD: { - amqp_queue_purge_t *m = (amqp_queue_purge_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->queue.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) - || !amqp_encode_bytes(encoded, &offset, m->queue)) + amqp_queue_purge_t *m = (amqp_queue_purge_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->queue.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) || + !amqp_encode_bytes(encoded, &offset, m->queue)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->nowait) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_QUEUE_PURGE_OK_METHOD: { - amqp_queue_purge_ok_t *m = (amqp_queue_purge_ok_t *) decoded; - if (!amqp_encode_32(encoded, &offset, m->message_count)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_queue_purge_ok_t *m = (amqp_queue_purge_ok_t *)decoded; + if (!amqp_encode_32(encoded, &offset, m->message_count)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_QUEUE_DELETE_METHOD: { - amqp_queue_delete_t *m = (amqp_queue_delete_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->queue.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) - || !amqp_encode_bytes(encoded, &offset, m->queue)) + amqp_queue_delete_t *m = (amqp_queue_delete_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->queue.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) || + !amqp_encode_bytes(encoded, &offset, m->queue)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->if_unused) bit_buffer |= (1 << 0); if (m->if_empty) bit_buffer |= (1 << 1); if (m->nowait) bit_buffer |= (1 << 2); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_QUEUE_DELETE_OK_METHOD: { - amqp_queue_delete_ok_t *m = (amqp_queue_delete_ok_t *) decoded; - if (!amqp_encode_32(encoded, &offset, m->message_count)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_queue_delete_ok_t *m = (amqp_queue_delete_ok_t *)decoded; + if (!amqp_encode_32(encoded, &offset, m->message_count)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_QUEUE_UNBIND_METHOD: { - amqp_queue_unbind_t *m = (amqp_queue_unbind_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->queue.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) - || !amqp_encode_bytes(encoded, &offset, m->queue)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->exchange.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) - || !amqp_encode_bytes(encoded, &offset, m->exchange)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->routing_key.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) - || !amqp_encode_bytes(encoded, &offset, m->routing_key)) + amqp_queue_unbind_t *m = (amqp_queue_unbind_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->queue.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) || + !amqp_encode_bytes(encoded, &offset, m->queue)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->exchange.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) || + !amqp_encode_bytes(encoded, &offset, m->exchange)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->routing_key.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) || + !amqp_encode_bytes(encoded, &offset, m->routing_key)) return AMQP_STATUS_BAD_AMQP_DATA; { int res = amqp_encode_table(encoded, &(m->arguments), &offset); @@ -1605,34 +2047,39 @@ return (int)offset; } case AMQP_BASIC_QOS_METHOD: { - amqp_basic_qos_t *m = (amqp_basic_qos_t *) decoded; - if (!amqp_encode_32(encoded, &offset, m->prefetch_size)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_16(encoded, &offset, m->prefetch_count)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_qos_t *m = (amqp_basic_qos_t *)decoded; + if (!amqp_encode_32(encoded, &offset, m->prefetch_size)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_16(encoded, &offset, m->prefetch_count)) + return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->global) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_QOS_OK_METHOD: { return (int)offset; } case AMQP_BASIC_CONSUME_METHOD: { - amqp_basic_consume_t *m = (amqp_basic_consume_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->queue.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) - || !amqp_encode_bytes(encoded, &offset, m->queue)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->consumer_tag.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->consumer_tag.len) - || !amqp_encode_bytes(encoded, &offset, m->consumer_tag)) + amqp_basic_consume_t *m = (amqp_basic_consume_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->queue.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) || + !amqp_encode_bytes(encoded, &offset, m->queue)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->consumer_tag.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->consumer_tag.len) || + !amqp_encode_bytes(encoded, &offset, m->consumer_tag)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->no_local) bit_buffer |= (1 << 0); if (m->no_ack) bit_buffer |= (1 << 1); if (m->exclusive) bit_buffer |= (1 << 2); if (m->nowait) bit_buffer |= (1 << 3); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; { int res = amqp_encode_table(encoded, &(m->arguments), &offset); if (res < 0) return res; @@ -1640,163 +2087,182 @@ return (int)offset; } case AMQP_BASIC_CONSUME_OK_METHOD: { - amqp_basic_consume_ok_t *m = (amqp_basic_consume_ok_t *) decoded; - if (UINT8_MAX < m->consumer_tag.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->consumer_tag.len) - || !amqp_encode_bytes(encoded, &offset, m->consumer_tag)) + amqp_basic_consume_ok_t *m = (amqp_basic_consume_ok_t *)decoded; + if (UINT8_MAX < m->consumer_tag.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->consumer_tag.len) || + !amqp_encode_bytes(encoded, &offset, m->consumer_tag)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_CANCEL_METHOD: { - amqp_basic_cancel_t *m = (amqp_basic_cancel_t *) decoded; - if (UINT8_MAX < m->consumer_tag.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->consumer_tag.len) - || !amqp_encode_bytes(encoded, &offset, m->consumer_tag)) + amqp_basic_cancel_t *m = (amqp_basic_cancel_t *)decoded; + if (UINT8_MAX < m->consumer_tag.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->consumer_tag.len) || + !amqp_encode_bytes(encoded, &offset, m->consumer_tag)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->nowait) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_CANCEL_OK_METHOD: { - amqp_basic_cancel_ok_t *m = (amqp_basic_cancel_ok_t *) decoded; - if (UINT8_MAX < m->consumer_tag.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->consumer_tag.len) - || !amqp_encode_bytes(encoded, &offset, m->consumer_tag)) + amqp_basic_cancel_ok_t *m = (amqp_basic_cancel_ok_t *)decoded; + if (UINT8_MAX < m->consumer_tag.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->consumer_tag.len) || + !amqp_encode_bytes(encoded, &offset, m->consumer_tag)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_PUBLISH_METHOD: { - amqp_basic_publish_t *m = (amqp_basic_publish_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->exchange.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) - || !amqp_encode_bytes(encoded, &offset, m->exchange)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->routing_key.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) - || !amqp_encode_bytes(encoded, &offset, m->routing_key)) + amqp_basic_publish_t *m = (amqp_basic_publish_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->exchange.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) || + !amqp_encode_bytes(encoded, &offset, m->exchange)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->routing_key.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) || + !amqp_encode_bytes(encoded, &offset, m->routing_key)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->mandatory) bit_buffer |= (1 << 0); if (m->immediate) bit_buffer |= (1 << 1); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_RETURN_METHOD: { - amqp_basic_return_t *m = (amqp_basic_return_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->reply_code)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->reply_text.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->reply_text.len) - || !amqp_encode_bytes(encoded, &offset, m->reply_text)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->exchange.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) - || !amqp_encode_bytes(encoded, &offset, m->exchange)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->routing_key.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) - || !amqp_encode_bytes(encoded, &offset, m->routing_key)) + amqp_basic_return_t *m = (amqp_basic_return_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->reply_code)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->reply_text.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->reply_text.len) || + !amqp_encode_bytes(encoded, &offset, m->reply_text)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->exchange.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) || + !amqp_encode_bytes(encoded, &offset, m->exchange)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->routing_key.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) || + !amqp_encode_bytes(encoded, &offset, m->routing_key)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_DELIVER_METHOD: { - amqp_basic_deliver_t *m = (amqp_basic_deliver_t *) decoded; - if (UINT8_MAX < m->consumer_tag.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->consumer_tag.len) - || !amqp_encode_bytes(encoded, &offset, m->consumer_tag)) + amqp_basic_deliver_t *m = (amqp_basic_deliver_t *)decoded; + if (UINT8_MAX < m->consumer_tag.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->consumer_tag.len) || + !amqp_encode_bytes(encoded, &offset, m->consumer_tag)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_64(encoded, &offset, m->delivery_tag)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_64(encoded, &offset, m->delivery_tag)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->redelivered) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->exchange.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) - || !amqp_encode_bytes(encoded, &offset, m->exchange)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->routing_key.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) - || !amqp_encode_bytes(encoded, &offset, m->routing_key)) + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->exchange.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) || + !amqp_encode_bytes(encoded, &offset, m->exchange)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->routing_key.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) || + !amqp_encode_bytes(encoded, &offset, m->routing_key)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_GET_METHOD: { - amqp_basic_get_t *m = (amqp_basic_get_t *) decoded; - if (!amqp_encode_16(encoded, &offset, m->ticket)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->queue.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) - || !amqp_encode_bytes(encoded, &offset, m->queue)) + amqp_basic_get_t *m = (amqp_basic_get_t *)decoded; + if (!amqp_encode_16(encoded, &offset, m->ticket)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->queue.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->queue.len) || + !amqp_encode_bytes(encoded, &offset, m->queue)) return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->no_ack) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_GET_OK_METHOD: { - amqp_basic_get_ok_t *m = (amqp_basic_get_ok_t *) decoded; - if (!amqp_encode_64(encoded, &offset, m->delivery_tag)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_get_ok_t *m = (amqp_basic_get_ok_t *)decoded; + if (!amqp_encode_64(encoded, &offset, m->delivery_tag)) + return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->redelivered) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->exchange.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) - || !amqp_encode_bytes(encoded, &offset, m->exchange)) - return AMQP_STATUS_BAD_AMQP_DATA; - if (UINT8_MAX < m->routing_key.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) - || !amqp_encode_bytes(encoded, &offset, m->routing_key)) + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->exchange.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->exchange.len) || + !amqp_encode_bytes(encoded, &offset, m->exchange)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (UINT8_MAX < m->routing_key.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->routing_key.len) || + !amqp_encode_bytes(encoded, &offset, m->routing_key)) + return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_32(encoded, &offset, m->message_count)) return AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_encode_32(encoded, &offset, m->message_count)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_GET_EMPTY_METHOD: { - amqp_basic_get_empty_t *m = (amqp_basic_get_empty_t *) decoded; - if (UINT8_MAX < m->cluster_id.len - || !amqp_encode_8(encoded, &offset, (uint8_t)m->cluster_id.len) - || !amqp_encode_bytes(encoded, &offset, m->cluster_id)) + amqp_basic_get_empty_t *m = (amqp_basic_get_empty_t *)decoded; + if (UINT8_MAX < m->cluster_id.len || + !amqp_encode_8(encoded, &offset, (uint8_t)m->cluster_id.len) || + !amqp_encode_bytes(encoded, &offset, m->cluster_id)) return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_ACK_METHOD: { - amqp_basic_ack_t *m = (amqp_basic_ack_t *) decoded; - if (!amqp_encode_64(encoded, &offset, m->delivery_tag)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_ack_t *m = (amqp_basic_ack_t *)decoded; + if (!amqp_encode_64(encoded, &offset, m->delivery_tag)) + return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->multiple) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_REJECT_METHOD: { - amqp_basic_reject_t *m = (amqp_basic_reject_t *) decoded; - if (!amqp_encode_64(encoded, &offset, m->delivery_tag)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_reject_t *m = (amqp_basic_reject_t *)decoded; + if (!amqp_encode_64(encoded, &offset, m->delivery_tag)) + return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->requeue) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_RECOVER_ASYNC_METHOD: { - amqp_basic_recover_async_t *m = (amqp_basic_recover_async_t *) decoded; + amqp_basic_recover_async_t *m = (amqp_basic_recover_async_t *)decoded; bit_buffer = 0; if (m->requeue) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_RECOVER_METHOD: { - amqp_basic_recover_t *m = (amqp_basic_recover_t *) decoded; + amqp_basic_recover_t *m = (amqp_basic_recover_t *)decoded; bit_buffer = 0; if (m->requeue) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_BASIC_RECOVER_OK_METHOD: { return (int)offset; } case AMQP_BASIC_NACK_METHOD: { - amqp_basic_nack_t *m = (amqp_basic_nack_t *) decoded; - if (!amqp_encode_64(encoded, &offset, m->delivery_tag)) return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_nack_t *m = (amqp_basic_nack_t *)decoded; + if (!amqp_encode_64(encoded, &offset, m->delivery_tag)) + return AMQP_STATUS_BAD_AMQP_DATA; bit_buffer = 0; if (m->multiple) bit_buffer |= (1 << 0); if (m->requeue) bit_buffer |= (1 << 1); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_TX_SELECT_METHOD: { @@ -1818,28 +2284,28 @@ return (int)offset; } case AMQP_CONFIRM_SELECT_METHOD: { - amqp_confirm_select_t *m = (amqp_confirm_select_t *) decoded; + amqp_confirm_select_t *m = (amqp_confirm_select_t *)decoded; bit_buffer = 0; if (m->nowait) bit_buffer |= (1 << 0); - if (!amqp_encode_8(encoded, &offset, bit_buffer)) return AMQP_STATUS_BAD_AMQP_DATA; + if (!amqp_encode_8(encoded, &offset, bit_buffer)) + return AMQP_STATUS_BAD_AMQP_DATA; return (int)offset; } case AMQP_CONFIRM_SELECT_OK_METHOD: { return (int)offset; } - default: return AMQP_STATUS_UNKNOWN_METHOD; + default: + return AMQP_STATUS_UNKNOWN_METHOD; } } -int amqp_encode_properties(uint16_t class_id, - void *decoded, - amqp_bytes_t encoded) -{ +int amqp_encode_properties(uint16_t class_id, void *decoded, + amqp_bytes_t encoded) { size_t offset = 0; /* Cheat, and get the flags out generically, relying on the similarity of structure between classes */ - amqp_flags_t flags = * (amqp_flags_t *) decoded; /* cheating! */ + amqp_flags_t flags = *(amqp_flags_t *)decoded; /* cheating! */ { /* We take a copy of flags to avoid destroying it, as it is used @@ -1848,7 +2314,9 @@ do { amqp_flags_t remainder = remaining_flags >> 16; uint16_t partial_flags = remaining_flags & 0xFFFE; - if (remainder != 0) { partial_flags |= 1; } + if (remainder != 0) { + partial_flags |= 1; + } if (!amqp_encode_16(encoded, &offset, partial_flags)) return AMQP_STATUS_BAD_AMQP_DATA; remaining_flags = remainder; @@ -1872,81 +2340,85 @@ return (int)offset; } case 60: { - amqp_basic_properties_t *p = (amqp_basic_properties_t *) decoded; - if (flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { - if (UINT8_MAX < p->content_type.len - || !amqp_encode_8(encoded, &offset, (uint8_t)p->content_type.len) - || !amqp_encode_bytes(encoded, &offset, p->content_type)) - return AMQP_STATUS_BAD_AMQP_DATA; - } - if (flags & AMQP_BASIC_CONTENT_ENCODING_FLAG) { - if (UINT8_MAX < p->content_encoding.len - || !amqp_encode_8(encoded, &offset, (uint8_t)p->content_encoding.len) - || !amqp_encode_bytes(encoded, &offset, p->content_encoding)) - return AMQP_STATUS_BAD_AMQP_DATA; + amqp_basic_properties_t *p = (amqp_basic_properties_t *)decoded; + if (flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { + if (UINT8_MAX < p->content_type.len || + !amqp_encode_8(encoded, &offset, (uint8_t)p->content_type.len) || + !amqp_encode_bytes(encoded, &offset, p->content_type)) + return AMQP_STATUS_BAD_AMQP_DATA; } - if (flags & AMQP_BASIC_HEADERS_FLAG) { - { - int res = amqp_encode_table(encoded, &(p->headers), &offset); - if (res < 0) return res; + if (flags & AMQP_BASIC_CONTENT_ENCODING_FLAG) { + if (UINT8_MAX < p->content_encoding.len || + !amqp_encode_8(encoded, &offset, + (uint8_t)p->content_encoding.len) || + !amqp_encode_bytes(encoded, &offset, p->content_encoding)) + return AMQP_STATUS_BAD_AMQP_DATA; } + if (flags & AMQP_BASIC_HEADERS_FLAG) { + { + int res = amqp_encode_table(encoded, &(p->headers), &offset); + if (res < 0) return res; + } } - if (flags & AMQP_BASIC_DELIVERY_MODE_FLAG) { - if (!amqp_encode_8(encoded, &offset, p->delivery_mode)) return AMQP_STATUS_BAD_AMQP_DATA; + if (flags & AMQP_BASIC_DELIVERY_MODE_FLAG) { + if (!amqp_encode_8(encoded, &offset, p->delivery_mode)) + return AMQP_STATUS_BAD_AMQP_DATA; } - if (flags & AMQP_BASIC_PRIORITY_FLAG) { - if (!amqp_encode_8(encoded, &offset, p->priority)) return AMQP_STATUS_BAD_AMQP_DATA; + if (flags & AMQP_BASIC_PRIORITY_FLAG) { + if (!amqp_encode_8(encoded, &offset, p->priority)) + return AMQP_STATUS_BAD_AMQP_DATA; } - if (flags & AMQP_BASIC_CORRELATION_ID_FLAG) { - if (UINT8_MAX < p->correlation_id.len - || !amqp_encode_8(encoded, &offset, (uint8_t)p->correlation_id.len) - || !amqp_encode_bytes(encoded, &offset, p->correlation_id)) - return AMQP_STATUS_BAD_AMQP_DATA; + if (flags & AMQP_BASIC_CORRELATION_ID_FLAG) { + if (UINT8_MAX < p->correlation_id.len || + !amqp_encode_8(encoded, &offset, (uint8_t)p->correlation_id.len) || + !amqp_encode_bytes(encoded, &offset, p->correlation_id)) + return AMQP_STATUS_BAD_AMQP_DATA; } - if (flags & AMQP_BASIC_REPLY_TO_FLAG) { - if (UINT8_MAX < p->reply_to.len - || !amqp_encode_8(encoded, &offset, (uint8_t)p->reply_to.len) - || !amqp_encode_bytes(encoded, &offset, p->reply_to)) - return AMQP_STATUS_BAD_AMQP_DATA; + if (flags & AMQP_BASIC_REPLY_TO_FLAG) { + if (UINT8_MAX < p->reply_to.len || + !amqp_encode_8(encoded, &offset, (uint8_t)p->reply_to.len) || + !amqp_encode_bytes(encoded, &offset, p->reply_to)) + return AMQP_STATUS_BAD_AMQP_DATA; } - if (flags & AMQP_BASIC_EXPIRATION_FLAG) { - if (UINT8_MAX < p->expiration.len - || !amqp_encode_8(encoded, &offset, (uint8_t)p->expiration.len) - || !amqp_encode_bytes(encoded, &offset, p->expiration)) - return AMQP_STATUS_BAD_AMQP_DATA; + if (flags & AMQP_BASIC_EXPIRATION_FLAG) { + if (UINT8_MAX < p->expiration.len || + !amqp_encode_8(encoded, &offset, (uint8_t)p->expiration.len) || + !amqp_encode_bytes(encoded, &offset, p->expiration)) + return AMQP_STATUS_BAD_AMQP_DATA; } - if (flags & AMQP_BASIC_MESSAGE_ID_FLAG) { - if (UINT8_MAX < p->message_id.len - || !amqp_encode_8(encoded, &offset, (uint8_t)p->message_id.len) - || !amqp_encode_bytes(encoded, &offset, p->message_id)) - return AMQP_STATUS_BAD_AMQP_DATA; + if (flags & AMQP_BASIC_MESSAGE_ID_FLAG) { + if (UINT8_MAX < p->message_id.len || + !amqp_encode_8(encoded, &offset, (uint8_t)p->message_id.len) || + !amqp_encode_bytes(encoded, &offset, p->message_id)) + return AMQP_STATUS_BAD_AMQP_DATA; } - if (flags & AMQP_BASIC_TIMESTAMP_FLAG) { - if (!amqp_encode_64(encoded, &offset, p->timestamp)) return AMQP_STATUS_BAD_AMQP_DATA; + if (flags & AMQP_BASIC_TIMESTAMP_FLAG) { + if (!amqp_encode_64(encoded, &offset, p->timestamp)) + return AMQP_STATUS_BAD_AMQP_DATA; } - if (flags & AMQP_BASIC_TYPE_FLAG) { - if (UINT8_MAX < p->type.len - || !amqp_encode_8(encoded, &offset, (uint8_t)p->type.len) - || !amqp_encode_bytes(encoded, &offset, p->type)) - return AMQP_STATUS_BAD_AMQP_DATA; + if (flags & AMQP_BASIC_TYPE_FLAG) { + if (UINT8_MAX < p->type.len || + !amqp_encode_8(encoded, &offset, (uint8_t)p->type.len) || + !amqp_encode_bytes(encoded, &offset, p->type)) + return AMQP_STATUS_BAD_AMQP_DATA; } - if (flags & AMQP_BASIC_USER_ID_FLAG) { - if (UINT8_MAX < p->user_id.len - || !amqp_encode_8(encoded, &offset, (uint8_t)p->user_id.len) - || !amqp_encode_bytes(encoded, &offset, p->user_id)) - return AMQP_STATUS_BAD_AMQP_DATA; + if (flags & AMQP_BASIC_USER_ID_FLAG) { + if (UINT8_MAX < p->user_id.len || + !amqp_encode_8(encoded, &offset, (uint8_t)p->user_id.len) || + !amqp_encode_bytes(encoded, &offset, p->user_id)) + return AMQP_STATUS_BAD_AMQP_DATA; } - if (flags & AMQP_BASIC_APP_ID_FLAG) { - if (UINT8_MAX < p->app_id.len - || !amqp_encode_8(encoded, &offset, (uint8_t)p->app_id.len) - || !amqp_encode_bytes(encoded, &offset, p->app_id)) - return AMQP_STATUS_BAD_AMQP_DATA; + if (flags & AMQP_BASIC_APP_ID_FLAG) { + if (UINT8_MAX < p->app_id.len || + !amqp_encode_8(encoded, &offset, (uint8_t)p->app_id.len) || + !amqp_encode_bytes(encoded, &offset, p->app_id)) + return AMQP_STATUS_BAD_AMQP_DATA; } - if (flags & AMQP_BASIC_CLUSTER_ID_FLAG) { - if (UINT8_MAX < p->cluster_id.len - || !amqp_encode_8(encoded, &offset, (uint8_t)p->cluster_id.len) - || !amqp_encode_bytes(encoded, &offset, p->cluster_id)) - return AMQP_STATUS_BAD_AMQP_DATA; + if (flags & AMQP_BASIC_CLUSTER_ID_FLAG) { + if (UINT8_MAX < p->cluster_id.len || + !amqp_encode_8(encoded, &offset, (uint8_t)p->cluster_id.len) || + !amqp_encode_bytes(encoded, &offset, p->cluster_id)) + return AMQP_STATUS_BAD_AMQP_DATA; } return (int)offset; } @@ -1956,7 +2428,8 @@ case 85: { return (int)offset; } - default: return AMQP_STATUS_UNKNOWN_CLASS; + default: + return AMQP_STATUS_UNKNOWN_CLASS; } } @@ -1968,16 +2441,15 @@ * @returns amqp_channel_open_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_channel_open_ok_t * -AMQP_CALL amqp_channel_open(amqp_connection_state_t state, amqp_channel_t channel) -{ +amqp_channel_open_ok_t *AMQP_CALL + amqp_channel_open(amqp_connection_state_t state, amqp_channel_t channel) { amqp_channel_open_t req; req.out_of_band = amqp_empty_bytes; - return amqp_simple_rpc_decoded(state, channel, AMQP_CHANNEL_OPEN_METHOD, AMQP_CHANNEL_OPEN_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_CHANNEL_OPEN_METHOD, + AMQP_CHANNEL_OPEN_OK_METHOD, &req); } - /** * amqp_channel_flow * @@ -1987,16 +2459,16 @@ * @returns amqp_channel_flow_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_channel_flow_ok_t * -AMQP_CALL amqp_channel_flow(amqp_connection_state_t state, amqp_channel_t channel, amqp_boolean_t active) -{ +amqp_channel_flow_ok_t *AMQP_CALL + amqp_channel_flow(amqp_connection_state_t state, amqp_channel_t channel, + amqp_boolean_t active) { amqp_channel_flow_t req; req.active = active; - return amqp_simple_rpc_decoded(state, channel, AMQP_CHANNEL_FLOW_METHOD, AMQP_CHANNEL_FLOW_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_CHANNEL_FLOW_METHOD, + AMQP_CHANNEL_FLOW_OK_METHOD, &req); } - /** * amqp_exchange_declare * @@ -2012,9 +2484,11 @@ * @returns amqp_exchange_declare_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_exchange_declare_ok_t * -AMQP_CALL 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) -{ +amqp_exchange_declare_ok_t *AMQP_CALL 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) { amqp_exchange_declare_t req; req.ticket = 0; req.exchange = exchange; @@ -2026,10 +2500,10 @@ req.nowait = 0; req.arguments = arguments; - return amqp_simple_rpc_decoded(state, channel, AMQP_EXCHANGE_DECLARE_METHOD, AMQP_EXCHANGE_DECLARE_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_EXCHANGE_DECLARE_METHOD, + AMQP_EXCHANGE_DECLARE_OK_METHOD, &req); } - /** * amqp_exchange_delete * @@ -2040,19 +2514,19 @@ * @returns amqp_exchange_delete_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_exchange_delete_ok_t * -AMQP_CALL amqp_exchange_delete(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t exchange, amqp_boolean_t if_unused) -{ +amqp_exchange_delete_ok_t *AMQP_CALL + amqp_exchange_delete(amqp_connection_state_t state, amqp_channel_t channel, + amqp_bytes_t exchange, amqp_boolean_t if_unused) { amqp_exchange_delete_t req; req.ticket = 0; req.exchange = exchange; req.if_unused = if_unused; req.nowait = 0; - return amqp_simple_rpc_decoded(state, channel, AMQP_EXCHANGE_DELETE_METHOD, AMQP_EXCHANGE_DELETE_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_EXCHANGE_DELETE_METHOD, + AMQP_EXCHANGE_DELETE_OK_METHOD, &req); } - /** * amqp_exchange_bind * @@ -2065,9 +2539,10 @@ * @returns amqp_exchange_bind_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_exchange_bind_ok_t * -AMQP_CALL 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) -{ +amqp_exchange_bind_ok_t *AMQP_CALL + 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) { amqp_exchange_bind_t req; req.ticket = 0; req.destination = destination; @@ -2076,10 +2551,10 @@ req.nowait = 0; req.arguments = arguments; - return amqp_simple_rpc_decoded(state, channel, AMQP_EXCHANGE_BIND_METHOD, AMQP_EXCHANGE_BIND_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_EXCHANGE_BIND_METHOD, + AMQP_EXCHANGE_BIND_OK_METHOD, &req); } - /** * amqp_exchange_unbind * @@ -2092,9 +2567,10 @@ * @returns amqp_exchange_unbind_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_exchange_unbind_ok_t * -AMQP_CALL 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) -{ +amqp_exchange_unbind_ok_t *AMQP_CALL + 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) { amqp_exchange_unbind_t req; req.ticket = 0; req.destination = destination; @@ -2103,10 +2579,10 @@ req.nowait = 0; req.arguments = arguments; - return amqp_simple_rpc_decoded(state, channel, AMQP_EXCHANGE_UNBIND_METHOD, AMQP_EXCHANGE_UNBIND_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_EXCHANGE_UNBIND_METHOD, + AMQP_EXCHANGE_UNBIND_OK_METHOD, &req); } - /** * amqp_queue_declare * @@ -2121,9 +2597,10 @@ * @returns amqp_queue_declare_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_queue_declare_ok_t * -AMQP_CALL 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) -{ +amqp_queue_declare_ok_t *AMQP_CALL 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) { amqp_queue_declare_t req; req.ticket = 0; req.queue = queue; @@ -2134,10 +2611,10 @@ req.nowait = 0; req.arguments = arguments; - return amqp_simple_rpc_decoded(state, channel, AMQP_QUEUE_DECLARE_METHOD, AMQP_QUEUE_DECLARE_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_QUEUE_DECLARE_METHOD, + AMQP_QUEUE_DECLARE_OK_METHOD, &req); } - /** * amqp_queue_bind * @@ -2150,9 +2627,9 @@ * @returns amqp_queue_bind_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_queue_bind_ok_t * -AMQP_CALL 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) -{ +amqp_queue_bind_ok_t *AMQP_CALL 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) { amqp_queue_bind_t req; req.ticket = 0; req.queue = queue; @@ -2161,10 +2638,10 @@ req.nowait = 0; req.arguments = arguments; - return amqp_simple_rpc_decoded(state, channel, AMQP_QUEUE_BIND_METHOD, AMQP_QUEUE_BIND_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_QUEUE_BIND_METHOD, + AMQP_QUEUE_BIND_OK_METHOD, &req); } - /** * amqp_queue_purge * @@ -2174,18 +2651,18 @@ * @returns amqp_queue_purge_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_queue_purge_ok_t * -AMQP_CALL amqp_queue_purge(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t queue) -{ +amqp_queue_purge_ok_t *AMQP_CALL amqp_queue_purge(amqp_connection_state_t state, + amqp_channel_t channel, + amqp_bytes_t queue) { amqp_queue_purge_t req; req.ticket = 0; req.queue = queue; req.nowait = 0; - return amqp_simple_rpc_decoded(state, channel, AMQP_QUEUE_PURGE_METHOD, AMQP_QUEUE_PURGE_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_QUEUE_PURGE_METHOD, + AMQP_QUEUE_PURGE_OK_METHOD, &req); } - /** * amqp_queue_delete * @@ -2197,9 +2674,9 @@ * @returns amqp_queue_delete_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_queue_delete_ok_t * -AMQP_CALL 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) -{ +amqp_queue_delete_ok_t *AMQP_CALL 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) { amqp_queue_delete_t req; req.ticket = 0; req.queue = queue; @@ -2207,10 +2684,10 @@ req.if_empty = if_empty; req.nowait = 0; - return amqp_simple_rpc_decoded(state, channel, AMQP_QUEUE_DELETE_METHOD, AMQP_QUEUE_DELETE_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_QUEUE_DELETE_METHOD, + AMQP_QUEUE_DELETE_OK_METHOD, &req); } - /** * amqp_queue_unbind * @@ -2223,9 +2700,9 @@ * @returns amqp_queue_unbind_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_queue_unbind_ok_t * -AMQP_CALL 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) -{ +amqp_queue_unbind_ok_t *AMQP_CALL 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) { amqp_queue_unbind_t req; req.ticket = 0; req.queue = queue; @@ -2233,10 +2710,10 @@ req.routing_key = routing_key; req.arguments = arguments; - return amqp_simple_rpc_decoded(state, channel, AMQP_QUEUE_UNBIND_METHOD, AMQP_QUEUE_UNBIND_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_QUEUE_UNBIND_METHOD, + AMQP_QUEUE_UNBIND_OK_METHOD, &req); } - /** * amqp_basic_qos * @@ -2248,18 +2725,20 @@ * @returns amqp_basic_qos_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_basic_qos_ok_t * -AMQP_CALL amqp_basic_qos(amqp_connection_state_t state, amqp_channel_t channel, uint32_t prefetch_size, uint16_t prefetch_count, amqp_boolean_t global) -{ +amqp_basic_qos_ok_t *AMQP_CALL amqp_basic_qos(amqp_connection_state_t state, + amqp_channel_t channel, + uint32_t prefetch_size, + uint16_t prefetch_count, + amqp_boolean_t global) { amqp_basic_qos_t req; req.prefetch_size = prefetch_size; req.prefetch_count = prefetch_count; req.global = global; - return amqp_simple_rpc_decoded(state, channel, AMQP_BASIC_QOS_METHOD, AMQP_BASIC_QOS_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_BASIC_QOS_METHOD, + AMQP_BASIC_QOS_OK_METHOD, &req); } - /** * amqp_basic_consume * @@ -2274,9 +2753,10 @@ * @returns amqp_basic_consume_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_basic_consume_ok_t * -AMQP_CALL 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) -{ +amqp_basic_consume_ok_t *AMQP_CALL 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) { amqp_basic_consume_t req; req.ticket = 0; req.queue = queue; @@ -2287,10 +2767,10 @@ req.nowait = 0; req.arguments = arguments; - return amqp_simple_rpc_decoded(state, channel, AMQP_BASIC_CONSUME_METHOD, AMQP_BASIC_CONSUME_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_BASIC_CONSUME_METHOD, + AMQP_BASIC_CONSUME_OK_METHOD, &req); } - /** * amqp_basic_cancel * @@ -2300,17 +2780,17 @@ * @returns amqp_basic_cancel_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_basic_cancel_ok_t * -AMQP_CALL amqp_basic_cancel(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t consumer_tag) -{ +amqp_basic_cancel_ok_t *AMQP_CALL + amqp_basic_cancel(amqp_connection_state_t state, amqp_channel_t channel, + amqp_bytes_t consumer_tag) { amqp_basic_cancel_t req; req.consumer_tag = consumer_tag; req.nowait = 0; - return amqp_simple_rpc_decoded(state, channel, AMQP_BASIC_CANCEL_METHOD, AMQP_BASIC_CANCEL_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_BASIC_CANCEL_METHOD, + AMQP_BASIC_CANCEL_OK_METHOD, &req); } - /** * amqp_basic_recover * @@ -2320,16 +2800,16 @@ * @returns amqp_basic_recover_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_basic_recover_ok_t * -AMQP_CALL amqp_basic_recover(amqp_connection_state_t state, amqp_channel_t channel, amqp_boolean_t requeue) -{ +amqp_basic_recover_ok_t *AMQP_CALL + amqp_basic_recover(amqp_connection_state_t state, amqp_channel_t channel, + amqp_boolean_t requeue) { amqp_basic_recover_t req; req.requeue = requeue; - return amqp_simple_rpc_decoded(state, channel, AMQP_BASIC_RECOVER_METHOD, AMQP_BASIC_RECOVER_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_BASIC_RECOVER_METHOD, + AMQP_BASIC_RECOVER_OK_METHOD, &req); } - /** * amqp_tx_select * @@ -2338,15 +2818,14 @@ * @returns amqp_tx_select_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_tx_select_ok_t * -AMQP_CALL amqp_tx_select(amqp_connection_state_t state, amqp_channel_t channel) -{ +amqp_tx_select_ok_t *AMQP_CALL amqp_tx_select(amqp_connection_state_t state, + amqp_channel_t channel) { amqp_tx_select_t req; - return amqp_simple_rpc_decoded(state, channel, AMQP_TX_SELECT_METHOD, AMQP_TX_SELECT_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_TX_SELECT_METHOD, + AMQP_TX_SELECT_OK_METHOD, &req); } - /** * amqp_tx_commit * @@ -2355,15 +2834,14 @@ * @returns amqp_tx_commit_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_tx_commit_ok_t * -AMQP_CALL amqp_tx_commit(amqp_connection_state_t state, amqp_channel_t channel) -{ +amqp_tx_commit_ok_t *AMQP_CALL amqp_tx_commit(amqp_connection_state_t state, + amqp_channel_t channel) { amqp_tx_commit_t req; - return amqp_simple_rpc_decoded(state, channel, AMQP_TX_COMMIT_METHOD, AMQP_TX_COMMIT_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_TX_COMMIT_METHOD, + AMQP_TX_COMMIT_OK_METHOD, &req); } - /** * amqp_tx_rollback * @@ -2372,15 +2850,14 @@ * @returns amqp_tx_rollback_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_tx_rollback_ok_t * -AMQP_CALL amqp_tx_rollback(amqp_connection_state_t state, amqp_channel_t channel) -{ +amqp_tx_rollback_ok_t *AMQP_CALL amqp_tx_rollback(amqp_connection_state_t state, + amqp_channel_t channel) { amqp_tx_rollback_t req; - return amqp_simple_rpc_decoded(state, channel, AMQP_TX_ROLLBACK_METHOD, AMQP_TX_ROLLBACK_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_TX_ROLLBACK_METHOD, + AMQP_TX_ROLLBACK_OK_METHOD, &req); } - /** * amqp_confirm_select * @@ -2389,12 +2866,11 @@ * @returns amqp_confirm_select_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_confirm_select_ok_t * -AMQP_CALL amqp_confirm_select(amqp_connection_state_t state, amqp_channel_t channel) -{ +amqp_confirm_select_ok_t *AMQP_CALL + amqp_confirm_select(amqp_connection_state_t state, amqp_channel_t channel) { amqp_confirm_select_t req; req.nowait = 0; - return amqp_simple_rpc_decoded(state, channel, AMQP_CONFIRM_SELECT_METHOD, AMQP_CONFIRM_SELECT_OK_METHOD, &req); + return amqp_simple_rpc_decoded(state, channel, AMQP_CONFIRM_SELECT_METHOD, + AMQP_CONFIRM_SELECT_OK_METHOD, &req); } - diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_framing.h librabbitmq-0.9.0-0.1/librabbitmq/amqp_framing.h --- librabbitmq-0.7.1/librabbitmq/amqp_framing.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_framing.h 2019-10-20 10:14:51.000000000 +0000 @@ -42,35 +42,37 @@ AMQP_BEGIN_DECLS -#define AMQP_PROTOCOL_VERSION_MAJOR 0 /**< AMQP protocol version major */ -#define AMQP_PROTOCOL_VERSION_MINOR 9 /**< AMQP protocol version minor */ -#define AMQP_PROTOCOL_VERSION_REVISION 1 /**< AMQP protocol version revision */ -#define AMQP_PROTOCOL_PORT 5672 /**< Default AMQP Port */ -#define AMQP_FRAME_METHOD 1 /**< Constant: FRAME-METHOD */ -#define AMQP_FRAME_HEADER 2 /**< Constant: FRAME-HEADER */ -#define AMQP_FRAME_BODY 3 /**< Constant: FRAME-BODY */ -#define AMQP_FRAME_HEARTBEAT 8 /**< Constant: FRAME-HEARTBEAT */ -#define AMQP_FRAME_MIN_SIZE 4096 /**< Constant: FRAME-MIN-SIZE */ -#define AMQP_FRAME_END 206 /**< Constant: FRAME-END */ -#define AMQP_REPLY_SUCCESS 200 /**< Constant: REPLY-SUCCESS */ -#define AMQP_CONTENT_TOO_LARGE 311 /**< Constant: CONTENT-TOO-LARGE */ -#define AMQP_NO_ROUTE 312 /**< Constant: NO-ROUTE */ -#define AMQP_NO_CONSUMERS 313 /**< Constant: NO-CONSUMERS */ -#define AMQP_ACCESS_REFUSED 403 /**< Constant: ACCESS-REFUSED */ -#define AMQP_NOT_FOUND 404 /**< Constant: NOT-FOUND */ -#define AMQP_RESOURCE_LOCKED 405 /**< Constant: RESOURCE-LOCKED */ -#define AMQP_PRECONDITION_FAILED 406 /**< Constant: PRECONDITION-FAILED */ -#define AMQP_CONNECTION_FORCED 320 /**< Constant: CONNECTION-FORCED */ -#define AMQP_INVALID_PATH 402 /**< Constant: INVALID-PATH */ -#define AMQP_FRAME_ERROR 501 /**< Constant: FRAME-ERROR */ -#define AMQP_SYNTAX_ERROR 502 /**< Constant: SYNTAX-ERROR */ -#define AMQP_COMMAND_INVALID 503 /**< Constant: COMMAND-INVALID */ -#define AMQP_CHANNEL_ERROR 504 /**< Constant: CHANNEL-ERROR */ -#define AMQP_UNEXPECTED_FRAME 505 /**< Constant: UNEXPECTED-FRAME */ -#define AMQP_RESOURCE_ERROR 506 /**< Constant: RESOURCE-ERROR */ -#define AMQP_NOT_ALLOWED 530 /**< Constant: NOT-ALLOWED */ -#define AMQP_NOT_IMPLEMENTED 540 /**< Constant: NOT-IMPLEMENTED */ -#define AMQP_INTERNAL_ERROR 541 /**< Constant: INTERNAL-ERROR */ +#define AMQP_PROTOCOL_VERSION_MAJOR 0 /**< AMQP protocol version major */ +#define AMQP_PROTOCOL_VERSION_MINOR 9 /**< AMQP protocol version minor */ +#define AMQP_PROTOCOL_VERSION_REVISION \ + 1 /**< AMQP protocol version revision \ + */ +#define AMQP_PROTOCOL_PORT 5672 /**< Default AMQP Port */ +#define AMQP_FRAME_METHOD 1 /**< Constant: FRAME-METHOD */ +#define AMQP_FRAME_HEADER 2 /**< Constant: FRAME-HEADER */ +#define AMQP_FRAME_BODY 3 /**< Constant: FRAME-BODY */ +#define AMQP_FRAME_HEARTBEAT 8 /**< Constant: FRAME-HEARTBEAT */ +#define AMQP_FRAME_MIN_SIZE 4096 /**< Constant: FRAME-MIN-SIZE */ +#define AMQP_FRAME_END 206 /**< Constant: FRAME-END */ +#define AMQP_REPLY_SUCCESS 200 /**< Constant: REPLY-SUCCESS */ +#define AMQP_CONTENT_TOO_LARGE 311 /**< Constant: CONTENT-TOO-LARGE */ +#define AMQP_NO_ROUTE 312 /**< Constant: NO-ROUTE */ +#define AMQP_NO_CONSUMERS 313 /**< Constant: NO-CONSUMERS */ +#define AMQP_ACCESS_REFUSED 403 /**< Constant: ACCESS-REFUSED */ +#define AMQP_NOT_FOUND 404 /**< Constant: NOT-FOUND */ +#define AMQP_RESOURCE_LOCKED 405 /**< Constant: RESOURCE-LOCKED */ +#define AMQP_PRECONDITION_FAILED 406 /**< Constant: PRECONDITION-FAILED */ +#define AMQP_CONNECTION_FORCED 320 /**< Constant: CONNECTION-FORCED */ +#define AMQP_INVALID_PATH 402 /**< Constant: INVALID-PATH */ +#define AMQP_FRAME_ERROR 501 /**< Constant: FRAME-ERROR */ +#define AMQP_SYNTAX_ERROR 502 /**< Constant: SYNTAX-ERROR */ +#define AMQP_COMMAND_INVALID 503 /**< Constant: COMMAND-INVALID */ +#define AMQP_CHANNEL_ERROR 504 /**< Constant: CHANNEL-ERROR */ +#define AMQP_UNEXPECTED_FRAME 505 /**< Constant: UNEXPECTED-FRAME */ +#define AMQP_RESOURCE_ERROR 506 /**< Constant: RESOURCE-ERROR */ +#define AMQP_NOT_ALLOWED 530 /**< Constant: NOT-ALLOWED */ +#define AMQP_NOT_IMPLEMENTED 540 /**< Constant: NOT-IMPLEMENTED */ +#define AMQP_INTERNAL_ERROR 541 /**< Constant: INTERNAL-ERROR */ /* Function prototypes. */ @@ -82,8 +84,7 @@ * the library and should not be free()'d by the program */ AMQP_PUBLIC_FUNCTION -char const * -AMQP_CALL amqp_constant_name(int constantNumber); +char const *AMQP_CALL amqp_constant_name(int constantNumber); /** * Checks to see if a constant is a hard error @@ -95,8 +96,7 @@ * @returns true if its a hard error, false otherwise */ AMQP_PUBLIC_FUNCTION -amqp_boolean_t -AMQP_CALL amqp_constant_is_hard_error(int constantNumber); +amqp_boolean_t AMQP_CALL amqp_constant_is_hard_error(int constantNumber); /** * Get method name string from method number @@ -106,8 +106,7 @@ * and should not be freed()'d by the program */ AMQP_PUBLIC_FUNCTION -char const * -AMQP_CALL amqp_method_name(amqp_method_number_t methodNumber); +char const *AMQP_CALL amqp_method_name(amqp_method_number_t methodNumber); /** * Check whether a method has content @@ -119,8 +118,8 @@ * @returns true if method has content, false otherwise */ AMQP_PUBLIC_FUNCTION -amqp_boolean_t -AMQP_CALL amqp_method_has_content(amqp_method_number_t methodNumber); +amqp_boolean_t AMQP_CALL + amqp_method_has_content(amqp_method_number_t methodNumber); /** * Decodes a method from AMQP wireformat @@ -132,11 +131,9 @@ * @returns 0 on success, an error code otherwise */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_decode_method(amqp_method_number_t methodNumber, - amqp_pool_t *pool, - amqp_bytes_t encoded, - void **decoded); +int AMQP_CALL amqp_decode_method(amqp_method_number_t methodNumber, + amqp_pool_t *pool, amqp_bytes_t encoded, + void **decoded); /** * Decodes a header frame properties structure from AMQP wireformat @@ -148,11 +145,8 @@ * @returns 0 on success, an error code otherwise */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_decode_properties(uint16_t class_id, - amqp_pool_t *pool, - amqp_bytes_t encoded, - void **decoded); +int AMQP_CALL amqp_decode_properties(uint16_t class_id, amqp_pool_t *pool, + amqp_bytes_t encoded, void **decoded); /** * Encodes a method structure in AMQP wireformat @@ -165,595 +159,722 @@ * @returns 0 on success, an error code otherwise. */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_encode_method(amqp_method_number_t methodNumber, - void *decoded, - amqp_bytes_t encoded); +int AMQP_CALL amqp_encode_method(amqp_method_number_t methodNumber, + void *decoded, amqp_bytes_t encoded); /** * Encodes a properties structure in AMQP wireformat * * @param [in] class_id the class id for the decoded parameter * @param [in] decoded the properties structure (e.g., amqp_basic_properties_t) - * @param [in] encoded an allocated byte buffer for the encoded properties to written to. + * @param [in] encoded an allocated byte buffer for the encoded properties to + * written to. * If the buffer isn't large enough to hold the encoded method, an * an error code will be returned * @returns 0 on success, an error code otherwise. */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_encode_properties(uint16_t class_id, - void *decoded, - amqp_bytes_t encoded); +int AMQP_CALL amqp_encode_properties(uint16_t class_id, void *decoded, + amqp_bytes_t encoded); /* Method field records. */ -#define AMQP_CONNECTION_START_METHOD ((amqp_method_number_t) 0x000A000A) /**< connection.start method id @internal 10, 10; 655370 */ +#define AMQP_CONNECTION_START_METHOD \ + ((amqp_method_number_t)0x000A000A) /**< connection.start method id \ + @internal 10, 10; 655370 */ /** connection.start method fields */ typedef struct amqp_connection_start_t_ { - uint8_t version_major; /**< version-major */ - uint8_t version_minor; /**< version-minor */ + uint8_t version_major; /**< version-major */ + uint8_t version_minor; /**< version-minor */ amqp_table_t server_properties; /**< server-properties */ - amqp_bytes_t mechanisms; /**< mechanisms */ - amqp_bytes_t locales; /**< locales */ + amqp_bytes_t mechanisms; /**< mechanisms */ + amqp_bytes_t locales; /**< locales */ } amqp_connection_start_t; -#define AMQP_CONNECTION_START_OK_METHOD ((amqp_method_number_t) 0x000A000B) /**< connection.start-ok method id @internal 10, 11; 655371 */ +#define AMQP_CONNECTION_START_OK_METHOD \ + ((amqp_method_number_t)0x000A000B) /**< connection.start-ok method id \ + @internal 10, 11; 655371 */ /** connection.start-ok method fields */ typedef struct amqp_connection_start_ok_t_ { amqp_table_t client_properties; /**< client-properties */ - amqp_bytes_t mechanism; /**< mechanism */ - amqp_bytes_t response; /**< response */ - amqp_bytes_t locale; /**< locale */ + amqp_bytes_t mechanism; /**< mechanism */ + amqp_bytes_t response; /**< response */ + amqp_bytes_t locale; /**< locale */ } amqp_connection_start_ok_t; -#define AMQP_CONNECTION_SECURE_METHOD ((amqp_method_number_t) 0x000A0014) /**< connection.secure method id @internal 10, 20; 655380 */ +#define AMQP_CONNECTION_SECURE_METHOD \ + ((amqp_method_number_t)0x000A0014) /**< connection.secure method id \ + @internal 10, 20; 655380 */ /** connection.secure method fields */ typedef struct amqp_connection_secure_t_ { amqp_bytes_t challenge; /**< challenge */ } amqp_connection_secure_t; -#define AMQP_CONNECTION_SECURE_OK_METHOD ((amqp_method_number_t) 0x000A0015) /**< connection.secure-ok method id @internal 10, 21; 655381 */ +#define AMQP_CONNECTION_SECURE_OK_METHOD \ + ((amqp_method_number_t)0x000A0015) /**< connection.secure-ok method id \ + @internal 10, 21; 655381 */ /** connection.secure-ok method fields */ typedef struct amqp_connection_secure_ok_t_ { amqp_bytes_t response; /**< response */ } amqp_connection_secure_ok_t; -#define AMQP_CONNECTION_TUNE_METHOD ((amqp_method_number_t) 0x000A001E) /**< connection.tune method id @internal 10, 30; 655390 */ +#define AMQP_CONNECTION_TUNE_METHOD \ + ((amqp_method_number_t)0x000A001E) /**< connection.tune method id \ + @internal 10, 30; 655390 */ /** connection.tune method fields */ typedef struct amqp_connection_tune_t_ { uint16_t channel_max; /**< channel-max */ - uint32_t frame_max; /**< frame-max */ - uint16_t heartbeat; /**< heartbeat */ + uint32_t frame_max; /**< frame-max */ + uint16_t heartbeat; /**< heartbeat */ } amqp_connection_tune_t; -#define AMQP_CONNECTION_TUNE_OK_METHOD ((amqp_method_number_t) 0x000A001F) /**< connection.tune-ok method id @internal 10, 31; 655391 */ +#define AMQP_CONNECTION_TUNE_OK_METHOD \ + ((amqp_method_number_t)0x000A001F) /**< connection.tune-ok method id \ + @internal 10, 31; 655391 */ /** connection.tune-ok method fields */ typedef struct amqp_connection_tune_ok_t_ { uint16_t channel_max; /**< channel-max */ - uint32_t frame_max; /**< frame-max */ - uint16_t heartbeat; /**< heartbeat */ + uint32_t frame_max; /**< frame-max */ + uint16_t heartbeat; /**< heartbeat */ } amqp_connection_tune_ok_t; -#define AMQP_CONNECTION_OPEN_METHOD ((amqp_method_number_t) 0x000A0028) /**< connection.open method id @internal 10, 40; 655400 */ +#define AMQP_CONNECTION_OPEN_METHOD \ + ((amqp_method_number_t)0x000A0028) /**< connection.open method id \ + @internal 10, 40; 655400 */ /** connection.open method fields */ typedef struct amqp_connection_open_t_ { amqp_bytes_t virtual_host; /**< virtual-host */ amqp_bytes_t capabilities; /**< capabilities */ - amqp_boolean_t insist; /**< insist */ + amqp_boolean_t insist; /**< insist */ } amqp_connection_open_t; -#define AMQP_CONNECTION_OPEN_OK_METHOD ((amqp_method_number_t) 0x000A0029) /**< connection.open-ok method id @internal 10, 41; 655401 */ +#define AMQP_CONNECTION_OPEN_OK_METHOD \ + ((amqp_method_number_t)0x000A0029) /**< connection.open-ok method id \ + @internal 10, 41; 655401 */ /** connection.open-ok method fields */ typedef struct amqp_connection_open_ok_t_ { amqp_bytes_t known_hosts; /**< known-hosts */ } amqp_connection_open_ok_t; -#define AMQP_CONNECTION_CLOSE_METHOD ((amqp_method_number_t) 0x000A0032) /**< connection.close method id @internal 10, 50; 655410 */ +#define AMQP_CONNECTION_CLOSE_METHOD \ + ((amqp_method_number_t)0x000A0032) /**< connection.close method id \ + @internal 10, 50; 655410 */ /** connection.close method fields */ typedef struct amqp_connection_close_t_ { - uint16_t reply_code; /**< reply-code */ + uint16_t reply_code; /**< reply-code */ amqp_bytes_t reply_text; /**< reply-text */ - uint16_t class_id; /**< class-id */ - uint16_t method_id; /**< method-id */ + uint16_t class_id; /**< class-id */ + uint16_t method_id; /**< method-id */ } amqp_connection_close_t; -#define AMQP_CONNECTION_CLOSE_OK_METHOD ((amqp_method_number_t) 0x000A0033) /**< connection.close-ok method id @internal 10, 51; 655411 */ +#define AMQP_CONNECTION_CLOSE_OK_METHOD \ + ((amqp_method_number_t)0x000A0033) /**< connection.close-ok method id \ + @internal 10, 51; 655411 */ /** connection.close-ok method fields */ typedef struct amqp_connection_close_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_connection_close_ok_t; -#define AMQP_CONNECTION_BLOCKED_METHOD ((amqp_method_number_t) 0x000A003C) /**< connection.blocked method id @internal 10, 60; 655420 */ +#define AMQP_CONNECTION_BLOCKED_METHOD \ + ((amqp_method_number_t)0x000A003C) /**< connection.blocked method id \ + @internal 10, 60; 655420 */ /** connection.blocked method fields */ typedef struct amqp_connection_blocked_t_ { amqp_bytes_t reason; /**< reason */ } amqp_connection_blocked_t; -#define AMQP_CONNECTION_UNBLOCKED_METHOD ((amqp_method_number_t) 0x000A003D) /**< connection.unblocked method id @internal 10, 61; 655421 */ +#define AMQP_CONNECTION_UNBLOCKED_METHOD \ + ((amqp_method_number_t)0x000A003D) /**< connection.unblocked method id \ + @internal 10, 61; 655421 */ /** connection.unblocked method fields */ typedef struct amqp_connection_unblocked_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_connection_unblocked_t; -#define AMQP_CHANNEL_OPEN_METHOD ((amqp_method_number_t) 0x0014000A) /**< channel.open method id @internal 20, 10; 1310730 */ +#define AMQP_CHANNEL_OPEN_METHOD \ + ((amqp_method_number_t)0x0014000A) /**< channel.open method id @internal \ + 20, 10; 1310730 */ /** channel.open method fields */ typedef struct amqp_channel_open_t_ { amqp_bytes_t out_of_band; /**< out-of-band */ } amqp_channel_open_t; -#define AMQP_CHANNEL_OPEN_OK_METHOD ((amqp_method_number_t) 0x0014000B) /**< channel.open-ok method id @internal 20, 11; 1310731 */ +#define AMQP_CHANNEL_OPEN_OK_METHOD \ + ((amqp_method_number_t)0x0014000B) /**< channel.open-ok method id \ + @internal 20, 11; 1310731 */ /** channel.open-ok method fields */ typedef struct amqp_channel_open_ok_t_ { amqp_bytes_t channel_id; /**< channel-id */ } amqp_channel_open_ok_t; -#define AMQP_CHANNEL_FLOW_METHOD ((amqp_method_number_t) 0x00140014) /**< channel.flow method id @internal 20, 20; 1310740 */ +#define AMQP_CHANNEL_FLOW_METHOD \ + ((amqp_method_number_t)0x00140014) /**< channel.flow method id @internal \ + 20, 20; 1310740 */ /** channel.flow method fields */ typedef struct amqp_channel_flow_t_ { amqp_boolean_t active; /**< active */ } amqp_channel_flow_t; -#define AMQP_CHANNEL_FLOW_OK_METHOD ((amqp_method_number_t) 0x00140015) /**< channel.flow-ok method id @internal 20, 21; 1310741 */ +#define AMQP_CHANNEL_FLOW_OK_METHOD \ + ((amqp_method_number_t)0x00140015) /**< channel.flow-ok method id \ + @internal 20, 21; 1310741 */ /** channel.flow-ok method fields */ typedef struct amqp_channel_flow_ok_t_ { amqp_boolean_t active; /**< active */ } amqp_channel_flow_ok_t; -#define AMQP_CHANNEL_CLOSE_METHOD ((amqp_method_number_t) 0x00140028) /**< channel.close method id @internal 20, 40; 1310760 */ +#define AMQP_CHANNEL_CLOSE_METHOD \ + ((amqp_method_number_t)0x00140028) /**< channel.close method id @internal \ + 20, 40; 1310760 */ /** channel.close method fields */ typedef struct amqp_channel_close_t_ { - uint16_t reply_code; /**< reply-code */ + uint16_t reply_code; /**< reply-code */ amqp_bytes_t reply_text; /**< reply-text */ - uint16_t class_id; /**< class-id */ - uint16_t method_id; /**< method-id */ + uint16_t class_id; /**< class-id */ + uint16_t method_id; /**< method-id */ } amqp_channel_close_t; -#define AMQP_CHANNEL_CLOSE_OK_METHOD ((amqp_method_number_t) 0x00140029) /**< channel.close-ok method id @internal 20, 41; 1310761 */ +#define AMQP_CHANNEL_CLOSE_OK_METHOD \ + ((amqp_method_number_t)0x00140029) /**< channel.close-ok method id \ + @internal 20, 41; 1310761 */ /** channel.close-ok method fields */ typedef struct amqp_channel_close_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_channel_close_ok_t; -#define AMQP_ACCESS_REQUEST_METHOD ((amqp_method_number_t) 0x001E000A) /**< access.request method id @internal 30, 10; 1966090 */ +#define AMQP_ACCESS_REQUEST_METHOD \ + ((amqp_method_number_t)0x001E000A) /**< access.request method id @internal \ + 30, 10; 1966090 */ /** access.request method fields */ typedef struct amqp_access_request_t_ { - amqp_bytes_t realm; /**< realm */ + amqp_bytes_t realm; /**< realm */ amqp_boolean_t exclusive; /**< exclusive */ - amqp_boolean_t passive; /**< passive */ - amqp_boolean_t active; /**< active */ - amqp_boolean_t write; /**< write */ - amqp_boolean_t read; /**< read */ + amqp_boolean_t passive; /**< passive */ + amqp_boolean_t active; /**< active */ + amqp_boolean_t write; /**< write */ + amqp_boolean_t read; /**< read */ } amqp_access_request_t; -#define AMQP_ACCESS_REQUEST_OK_METHOD ((amqp_method_number_t) 0x001E000B) /**< access.request-ok method id @internal 30, 11; 1966091 */ +#define AMQP_ACCESS_REQUEST_OK_METHOD \ + ((amqp_method_number_t)0x001E000B) /**< access.request-ok method id \ + @internal 30, 11; 1966091 */ /** access.request-ok method fields */ typedef struct amqp_access_request_ok_t_ { uint16_t ticket; /**< ticket */ } amqp_access_request_ok_t; -#define AMQP_EXCHANGE_DECLARE_METHOD ((amqp_method_number_t) 0x0028000A) /**< exchange.declare method id @internal 40, 10; 2621450 */ +#define AMQP_EXCHANGE_DECLARE_METHOD \ + ((amqp_method_number_t)0x0028000A) /**< exchange.declare method id \ + @internal 40, 10; 2621450 */ /** exchange.declare method fields */ typedef struct amqp_exchange_declare_t_ { - uint16_t ticket; /**< ticket */ - amqp_bytes_t exchange; /**< exchange */ - amqp_bytes_t type; /**< type */ - amqp_boolean_t passive; /**< passive */ - amqp_boolean_t durable; /**< durable */ + uint16_t ticket; /**< ticket */ + amqp_bytes_t exchange; /**< exchange */ + amqp_bytes_t type; /**< type */ + amqp_boolean_t passive; /**< passive */ + amqp_boolean_t durable; /**< durable */ amqp_boolean_t auto_delete; /**< auto-delete */ - amqp_boolean_t internal; /**< internal */ - amqp_boolean_t nowait; /**< nowait */ - amqp_table_t arguments; /**< arguments */ + amqp_boolean_t internal; /**< internal */ + amqp_boolean_t nowait; /**< nowait */ + amqp_table_t arguments; /**< arguments */ } amqp_exchange_declare_t; -#define AMQP_EXCHANGE_DECLARE_OK_METHOD ((amqp_method_number_t) 0x0028000B) /**< exchange.declare-ok method id @internal 40, 11; 2621451 */ +#define AMQP_EXCHANGE_DECLARE_OK_METHOD \ + ((amqp_method_number_t)0x0028000B) /**< exchange.declare-ok method id \ + @internal 40, 11; 2621451 */ /** exchange.declare-ok method fields */ typedef struct amqp_exchange_declare_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_exchange_declare_ok_t; -#define AMQP_EXCHANGE_DELETE_METHOD ((amqp_method_number_t) 0x00280014) /**< exchange.delete method id @internal 40, 20; 2621460 */ +#define AMQP_EXCHANGE_DELETE_METHOD \ + ((amqp_method_number_t)0x00280014) /**< exchange.delete method id \ + @internal 40, 20; 2621460 */ /** exchange.delete method fields */ typedef struct amqp_exchange_delete_t_ { - uint16_t ticket; /**< ticket */ - amqp_bytes_t exchange; /**< exchange */ + uint16_t ticket; /**< ticket */ + amqp_bytes_t exchange; /**< exchange */ amqp_boolean_t if_unused; /**< if-unused */ - amqp_boolean_t nowait; /**< nowait */ + amqp_boolean_t nowait; /**< nowait */ } amqp_exchange_delete_t; -#define AMQP_EXCHANGE_DELETE_OK_METHOD ((amqp_method_number_t) 0x00280015) /**< exchange.delete-ok method id @internal 40, 21; 2621461 */ +#define AMQP_EXCHANGE_DELETE_OK_METHOD \ + ((amqp_method_number_t)0x00280015) /**< exchange.delete-ok method id \ + @internal 40, 21; 2621461 */ /** exchange.delete-ok method fields */ typedef struct amqp_exchange_delete_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_exchange_delete_ok_t; -#define AMQP_EXCHANGE_BIND_METHOD ((amqp_method_number_t) 0x0028001E) /**< exchange.bind method id @internal 40, 30; 2621470 */ +#define AMQP_EXCHANGE_BIND_METHOD \ + ((amqp_method_number_t)0x0028001E) /**< exchange.bind method id @internal \ + 40, 30; 2621470 */ /** exchange.bind method fields */ typedef struct amqp_exchange_bind_t_ { - uint16_t ticket; /**< ticket */ + uint16_t ticket; /**< ticket */ amqp_bytes_t destination; /**< destination */ - amqp_bytes_t source; /**< source */ + amqp_bytes_t source; /**< source */ amqp_bytes_t routing_key; /**< routing-key */ - amqp_boolean_t nowait; /**< nowait */ - amqp_table_t arguments; /**< arguments */ + amqp_boolean_t nowait; /**< nowait */ + amqp_table_t arguments; /**< arguments */ } amqp_exchange_bind_t; -#define AMQP_EXCHANGE_BIND_OK_METHOD ((amqp_method_number_t) 0x0028001F) /**< exchange.bind-ok method id @internal 40, 31; 2621471 */ +#define AMQP_EXCHANGE_BIND_OK_METHOD \ + ((amqp_method_number_t)0x0028001F) /**< exchange.bind-ok method id \ + @internal 40, 31; 2621471 */ /** exchange.bind-ok method fields */ typedef struct amqp_exchange_bind_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_exchange_bind_ok_t; -#define AMQP_EXCHANGE_UNBIND_METHOD ((amqp_method_number_t) 0x00280028) /**< exchange.unbind method id @internal 40, 40; 2621480 */ +#define AMQP_EXCHANGE_UNBIND_METHOD \ + ((amqp_method_number_t)0x00280028) /**< exchange.unbind method id \ + @internal 40, 40; 2621480 */ /** exchange.unbind method fields */ typedef struct amqp_exchange_unbind_t_ { - uint16_t ticket; /**< ticket */ + uint16_t ticket; /**< ticket */ amqp_bytes_t destination; /**< destination */ - amqp_bytes_t source; /**< source */ + amqp_bytes_t source; /**< source */ amqp_bytes_t routing_key; /**< routing-key */ - amqp_boolean_t nowait; /**< nowait */ - amqp_table_t arguments; /**< arguments */ + amqp_boolean_t nowait; /**< nowait */ + amqp_table_t arguments; /**< arguments */ } amqp_exchange_unbind_t; -#define AMQP_EXCHANGE_UNBIND_OK_METHOD ((amqp_method_number_t) 0x00280033) /**< exchange.unbind-ok method id @internal 40, 51; 2621491 */ +#define AMQP_EXCHANGE_UNBIND_OK_METHOD \ + ((amqp_method_number_t)0x00280033) /**< exchange.unbind-ok method id \ + @internal 40, 51; 2621491 */ /** exchange.unbind-ok method fields */ typedef struct amqp_exchange_unbind_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_exchange_unbind_ok_t; -#define AMQP_QUEUE_DECLARE_METHOD ((amqp_method_number_t) 0x0032000A) /**< queue.declare method id @internal 50, 10; 3276810 */ +#define AMQP_QUEUE_DECLARE_METHOD \ + ((amqp_method_number_t)0x0032000A) /**< queue.declare method id @internal \ + 50, 10; 3276810 */ /** queue.declare method fields */ typedef struct amqp_queue_declare_t_ { - uint16_t ticket; /**< ticket */ - amqp_bytes_t queue; /**< queue */ - amqp_boolean_t passive; /**< passive */ - amqp_boolean_t durable; /**< durable */ - amqp_boolean_t exclusive; /**< exclusive */ + uint16_t ticket; /**< ticket */ + amqp_bytes_t queue; /**< queue */ + amqp_boolean_t passive; /**< passive */ + amqp_boolean_t durable; /**< durable */ + amqp_boolean_t exclusive; /**< exclusive */ amqp_boolean_t auto_delete; /**< auto-delete */ - amqp_boolean_t nowait; /**< nowait */ - amqp_table_t arguments; /**< arguments */ + amqp_boolean_t nowait; /**< nowait */ + amqp_table_t arguments; /**< arguments */ } amqp_queue_declare_t; -#define AMQP_QUEUE_DECLARE_OK_METHOD ((amqp_method_number_t) 0x0032000B) /**< queue.declare-ok method id @internal 50, 11; 3276811 */ +#define AMQP_QUEUE_DECLARE_OK_METHOD \ + ((amqp_method_number_t)0x0032000B) /**< queue.declare-ok method id \ + @internal 50, 11; 3276811 */ /** queue.declare-ok method fields */ typedef struct amqp_queue_declare_ok_t_ { - amqp_bytes_t queue; /**< queue */ - uint32_t message_count; /**< message-count */ + amqp_bytes_t queue; /**< queue */ + uint32_t message_count; /**< message-count */ uint32_t consumer_count; /**< consumer-count */ } amqp_queue_declare_ok_t; -#define AMQP_QUEUE_BIND_METHOD ((amqp_method_number_t) 0x00320014) /**< queue.bind method id @internal 50, 20; 3276820 */ +#define AMQP_QUEUE_BIND_METHOD \ + ((amqp_method_number_t)0x00320014) /**< queue.bind method id @internal 50, \ + 20; 3276820 */ /** queue.bind method fields */ typedef struct amqp_queue_bind_t_ { - uint16_t ticket; /**< ticket */ - amqp_bytes_t queue; /**< queue */ - amqp_bytes_t exchange; /**< exchange */ + uint16_t ticket; /**< ticket */ + amqp_bytes_t queue; /**< queue */ + amqp_bytes_t exchange; /**< exchange */ amqp_bytes_t routing_key; /**< routing-key */ - amqp_boolean_t nowait; /**< nowait */ - amqp_table_t arguments; /**< arguments */ + amqp_boolean_t nowait; /**< nowait */ + amqp_table_t arguments; /**< arguments */ } amqp_queue_bind_t; -#define AMQP_QUEUE_BIND_OK_METHOD ((amqp_method_number_t) 0x00320015) /**< queue.bind-ok method id @internal 50, 21; 3276821 */ +#define AMQP_QUEUE_BIND_OK_METHOD \ + ((amqp_method_number_t)0x00320015) /**< queue.bind-ok method id @internal \ + 50, 21; 3276821 */ /** queue.bind-ok method fields */ typedef struct amqp_queue_bind_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_queue_bind_ok_t; -#define AMQP_QUEUE_PURGE_METHOD ((amqp_method_number_t) 0x0032001E) /**< queue.purge method id @internal 50, 30; 3276830 */ +#define AMQP_QUEUE_PURGE_METHOD \ + ((amqp_method_number_t)0x0032001E) /**< queue.purge method id @internal \ + 50, 30; 3276830 */ /** queue.purge method fields */ typedef struct amqp_queue_purge_t_ { - uint16_t ticket; /**< ticket */ - amqp_bytes_t queue; /**< queue */ + uint16_t ticket; /**< ticket */ + amqp_bytes_t queue; /**< queue */ amqp_boolean_t nowait; /**< nowait */ } amqp_queue_purge_t; -#define AMQP_QUEUE_PURGE_OK_METHOD ((amqp_method_number_t) 0x0032001F) /**< queue.purge-ok method id @internal 50, 31; 3276831 */ +#define AMQP_QUEUE_PURGE_OK_METHOD \ + ((amqp_method_number_t)0x0032001F) /**< queue.purge-ok method id @internal \ + 50, 31; 3276831 */ /** queue.purge-ok method fields */ typedef struct amqp_queue_purge_ok_t_ { uint32_t message_count; /**< message-count */ } amqp_queue_purge_ok_t; -#define AMQP_QUEUE_DELETE_METHOD ((amqp_method_number_t) 0x00320028) /**< queue.delete method id @internal 50, 40; 3276840 */ +#define AMQP_QUEUE_DELETE_METHOD \ + ((amqp_method_number_t)0x00320028) /**< queue.delete method id @internal \ + 50, 40; 3276840 */ /** queue.delete method fields */ typedef struct amqp_queue_delete_t_ { - uint16_t ticket; /**< ticket */ - amqp_bytes_t queue; /**< queue */ + uint16_t ticket; /**< ticket */ + amqp_bytes_t queue; /**< queue */ amqp_boolean_t if_unused; /**< if-unused */ - amqp_boolean_t if_empty; /**< if-empty */ - amqp_boolean_t nowait; /**< nowait */ + amqp_boolean_t if_empty; /**< if-empty */ + amqp_boolean_t nowait; /**< nowait */ } amqp_queue_delete_t; -#define AMQP_QUEUE_DELETE_OK_METHOD ((amqp_method_number_t) 0x00320029) /**< queue.delete-ok method id @internal 50, 41; 3276841 */ +#define AMQP_QUEUE_DELETE_OK_METHOD \ + ((amqp_method_number_t)0x00320029) /**< queue.delete-ok method id \ + @internal 50, 41; 3276841 */ /** queue.delete-ok method fields */ typedef struct amqp_queue_delete_ok_t_ { uint32_t message_count; /**< message-count */ } amqp_queue_delete_ok_t; -#define AMQP_QUEUE_UNBIND_METHOD ((amqp_method_number_t) 0x00320032) /**< queue.unbind method id @internal 50, 50; 3276850 */ +#define AMQP_QUEUE_UNBIND_METHOD \ + ((amqp_method_number_t)0x00320032) /**< queue.unbind method id @internal \ + 50, 50; 3276850 */ /** queue.unbind method fields */ typedef struct amqp_queue_unbind_t_ { - uint16_t ticket; /**< ticket */ - amqp_bytes_t queue; /**< queue */ - amqp_bytes_t exchange; /**< exchange */ + uint16_t ticket; /**< ticket */ + amqp_bytes_t queue; /**< queue */ + amqp_bytes_t exchange; /**< exchange */ amqp_bytes_t routing_key; /**< routing-key */ - amqp_table_t arguments; /**< arguments */ + amqp_table_t arguments; /**< arguments */ } amqp_queue_unbind_t; -#define AMQP_QUEUE_UNBIND_OK_METHOD ((amqp_method_number_t) 0x00320033) /**< queue.unbind-ok method id @internal 50, 51; 3276851 */ +#define AMQP_QUEUE_UNBIND_OK_METHOD \ + ((amqp_method_number_t)0x00320033) /**< queue.unbind-ok method id \ + @internal 50, 51; 3276851 */ /** queue.unbind-ok method fields */ typedef struct amqp_queue_unbind_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_queue_unbind_ok_t; -#define AMQP_BASIC_QOS_METHOD ((amqp_method_number_t) 0x003C000A) /**< basic.qos method id @internal 60, 10; 3932170 */ +#define AMQP_BASIC_QOS_METHOD \ + ((amqp_method_number_t)0x003C000A) /**< basic.qos method id @internal 60, \ + 10; 3932170 */ /** basic.qos method fields */ typedef struct amqp_basic_qos_t_ { - uint32_t prefetch_size; /**< prefetch-size */ + uint32_t prefetch_size; /**< prefetch-size */ uint16_t prefetch_count; /**< prefetch-count */ - amqp_boolean_t global; /**< global */ + amqp_boolean_t global; /**< global */ } amqp_basic_qos_t; -#define AMQP_BASIC_QOS_OK_METHOD ((amqp_method_number_t) 0x003C000B) /**< basic.qos-ok method id @internal 60, 11; 3932171 */ +#define AMQP_BASIC_QOS_OK_METHOD \ + ((amqp_method_number_t)0x003C000B) /**< basic.qos-ok method id @internal \ + 60, 11; 3932171 */ /** basic.qos-ok method fields */ typedef struct amqp_basic_qos_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_basic_qos_ok_t; -#define AMQP_BASIC_CONSUME_METHOD ((amqp_method_number_t) 0x003C0014) /**< basic.consume method id @internal 60, 20; 3932180 */ +#define AMQP_BASIC_CONSUME_METHOD \ + ((amqp_method_number_t)0x003C0014) /**< basic.consume method id @internal \ + 60, 20; 3932180 */ /** basic.consume method fields */ typedef struct amqp_basic_consume_t_ { - uint16_t ticket; /**< ticket */ - amqp_bytes_t queue; /**< queue */ + uint16_t ticket; /**< ticket */ + amqp_bytes_t queue; /**< queue */ amqp_bytes_t consumer_tag; /**< consumer-tag */ - amqp_boolean_t no_local; /**< no-local */ - amqp_boolean_t no_ack; /**< no-ack */ - amqp_boolean_t exclusive; /**< exclusive */ - amqp_boolean_t nowait; /**< nowait */ - amqp_table_t arguments; /**< arguments */ + amqp_boolean_t no_local; /**< no-local */ + amqp_boolean_t no_ack; /**< no-ack */ + amqp_boolean_t exclusive; /**< exclusive */ + amqp_boolean_t nowait; /**< nowait */ + amqp_table_t arguments; /**< arguments */ } amqp_basic_consume_t; -#define AMQP_BASIC_CONSUME_OK_METHOD ((amqp_method_number_t) 0x003C0015) /**< basic.consume-ok method id @internal 60, 21; 3932181 */ +#define AMQP_BASIC_CONSUME_OK_METHOD \ + ((amqp_method_number_t)0x003C0015) /**< basic.consume-ok method id \ + @internal 60, 21; 3932181 */ /** basic.consume-ok method fields */ typedef struct amqp_basic_consume_ok_t_ { amqp_bytes_t consumer_tag; /**< consumer-tag */ } amqp_basic_consume_ok_t; -#define AMQP_BASIC_CANCEL_METHOD ((amqp_method_number_t) 0x003C001E) /**< basic.cancel method id @internal 60, 30; 3932190 */ +#define AMQP_BASIC_CANCEL_METHOD \ + ((amqp_method_number_t)0x003C001E) /**< basic.cancel method id @internal \ + 60, 30; 3932190 */ /** basic.cancel method fields */ typedef struct amqp_basic_cancel_t_ { amqp_bytes_t consumer_tag; /**< consumer-tag */ - amqp_boolean_t nowait; /**< nowait */ + amqp_boolean_t nowait; /**< nowait */ } amqp_basic_cancel_t; -#define AMQP_BASIC_CANCEL_OK_METHOD ((amqp_method_number_t) 0x003C001F) /**< basic.cancel-ok method id @internal 60, 31; 3932191 */ +#define AMQP_BASIC_CANCEL_OK_METHOD \ + ((amqp_method_number_t)0x003C001F) /**< basic.cancel-ok method id \ + @internal 60, 31; 3932191 */ /** basic.cancel-ok method fields */ typedef struct amqp_basic_cancel_ok_t_ { amqp_bytes_t consumer_tag; /**< consumer-tag */ } amqp_basic_cancel_ok_t; -#define AMQP_BASIC_PUBLISH_METHOD ((amqp_method_number_t) 0x003C0028) /**< basic.publish method id @internal 60, 40; 3932200 */ +#define AMQP_BASIC_PUBLISH_METHOD \ + ((amqp_method_number_t)0x003C0028) /**< basic.publish method id @internal \ + 60, 40; 3932200 */ /** basic.publish method fields */ typedef struct amqp_basic_publish_t_ { - uint16_t ticket; /**< ticket */ - amqp_bytes_t exchange; /**< exchange */ + uint16_t ticket; /**< ticket */ + amqp_bytes_t exchange; /**< exchange */ amqp_bytes_t routing_key; /**< routing-key */ amqp_boolean_t mandatory; /**< mandatory */ amqp_boolean_t immediate; /**< immediate */ } amqp_basic_publish_t; -#define AMQP_BASIC_RETURN_METHOD ((amqp_method_number_t) 0x003C0032) /**< basic.return method id @internal 60, 50; 3932210 */ +#define AMQP_BASIC_RETURN_METHOD \ + ((amqp_method_number_t)0x003C0032) /**< basic.return method id @internal \ + 60, 50; 3932210 */ /** basic.return method fields */ typedef struct amqp_basic_return_t_ { - uint16_t reply_code; /**< reply-code */ - amqp_bytes_t reply_text; /**< reply-text */ - amqp_bytes_t exchange; /**< exchange */ + uint16_t reply_code; /**< reply-code */ + amqp_bytes_t reply_text; /**< reply-text */ + amqp_bytes_t exchange; /**< exchange */ amqp_bytes_t routing_key; /**< routing-key */ } amqp_basic_return_t; -#define AMQP_BASIC_DELIVER_METHOD ((amqp_method_number_t) 0x003C003C) /**< basic.deliver method id @internal 60, 60; 3932220 */ +#define AMQP_BASIC_DELIVER_METHOD \ + ((amqp_method_number_t)0x003C003C) /**< basic.deliver method id @internal \ + 60, 60; 3932220 */ /** basic.deliver method fields */ typedef struct amqp_basic_deliver_t_ { - amqp_bytes_t consumer_tag; /**< consumer-tag */ - uint64_t delivery_tag; /**< delivery-tag */ + amqp_bytes_t consumer_tag; /**< consumer-tag */ + uint64_t delivery_tag; /**< delivery-tag */ amqp_boolean_t redelivered; /**< redelivered */ - amqp_bytes_t exchange; /**< exchange */ - amqp_bytes_t routing_key; /**< routing-key */ + amqp_bytes_t exchange; /**< exchange */ + amqp_bytes_t routing_key; /**< routing-key */ } amqp_basic_deliver_t; -#define AMQP_BASIC_GET_METHOD ((amqp_method_number_t) 0x003C0046) /**< basic.get method id @internal 60, 70; 3932230 */ +#define AMQP_BASIC_GET_METHOD \ + ((amqp_method_number_t)0x003C0046) /**< basic.get method id @internal 60, \ + 70; 3932230 */ /** basic.get method fields */ typedef struct amqp_basic_get_t_ { - uint16_t ticket; /**< ticket */ - amqp_bytes_t queue; /**< queue */ + uint16_t ticket; /**< ticket */ + amqp_bytes_t queue; /**< queue */ amqp_boolean_t no_ack; /**< no-ack */ } amqp_basic_get_t; -#define AMQP_BASIC_GET_OK_METHOD ((amqp_method_number_t) 0x003C0047) /**< basic.get-ok method id @internal 60, 71; 3932231 */ +#define AMQP_BASIC_GET_OK_METHOD \ + ((amqp_method_number_t)0x003C0047) /**< basic.get-ok method id @internal \ + 60, 71; 3932231 */ /** basic.get-ok method fields */ typedef struct amqp_basic_get_ok_t_ { - uint64_t delivery_tag; /**< delivery-tag */ + uint64_t delivery_tag; /**< delivery-tag */ amqp_boolean_t redelivered; /**< redelivered */ - amqp_bytes_t exchange; /**< exchange */ - amqp_bytes_t routing_key; /**< routing-key */ - uint32_t message_count; /**< message-count */ + amqp_bytes_t exchange; /**< exchange */ + amqp_bytes_t routing_key; /**< routing-key */ + uint32_t message_count; /**< message-count */ } amqp_basic_get_ok_t; -#define AMQP_BASIC_GET_EMPTY_METHOD ((amqp_method_number_t) 0x003C0048) /**< basic.get-empty method id @internal 60, 72; 3932232 */ +#define AMQP_BASIC_GET_EMPTY_METHOD \ + ((amqp_method_number_t)0x003C0048) /**< basic.get-empty method id \ + @internal 60, 72; 3932232 */ /** basic.get-empty method fields */ typedef struct amqp_basic_get_empty_t_ { amqp_bytes_t cluster_id; /**< cluster-id */ } amqp_basic_get_empty_t; -#define AMQP_BASIC_ACK_METHOD ((amqp_method_number_t) 0x003C0050) /**< basic.ack method id @internal 60, 80; 3932240 */ +#define AMQP_BASIC_ACK_METHOD \ + ((amqp_method_number_t)0x003C0050) /**< basic.ack method id @internal 60, \ + 80; 3932240 */ /** basic.ack method fields */ typedef struct amqp_basic_ack_t_ { - uint64_t delivery_tag; /**< delivery-tag */ + uint64_t delivery_tag; /**< delivery-tag */ amqp_boolean_t multiple; /**< multiple */ } amqp_basic_ack_t; -#define AMQP_BASIC_REJECT_METHOD ((amqp_method_number_t) 0x003C005A) /**< basic.reject method id @internal 60, 90; 3932250 */ +#define AMQP_BASIC_REJECT_METHOD \ + ((amqp_method_number_t)0x003C005A) /**< basic.reject method id @internal \ + 60, 90; 3932250 */ /** basic.reject method fields */ typedef struct amqp_basic_reject_t_ { - uint64_t delivery_tag; /**< delivery-tag */ + uint64_t delivery_tag; /**< delivery-tag */ amqp_boolean_t requeue; /**< requeue */ } amqp_basic_reject_t; -#define AMQP_BASIC_RECOVER_ASYNC_METHOD ((amqp_method_number_t) 0x003C0064) /**< basic.recover-async method id @internal 60, 100; 3932260 */ +#define AMQP_BASIC_RECOVER_ASYNC_METHOD \ + ((amqp_method_number_t)0x003C0064) /**< basic.recover-async method id \ + @internal 60, 100; 3932260 */ /** basic.recover-async method fields */ typedef struct amqp_basic_recover_async_t_ { amqp_boolean_t requeue; /**< requeue */ } amqp_basic_recover_async_t; -#define AMQP_BASIC_RECOVER_METHOD ((amqp_method_number_t) 0x003C006E) /**< basic.recover method id @internal 60, 110; 3932270 */ +#define AMQP_BASIC_RECOVER_METHOD \ + ((amqp_method_number_t)0x003C006E) /**< basic.recover method id @internal \ + 60, 110; 3932270 */ /** basic.recover method fields */ typedef struct amqp_basic_recover_t_ { amqp_boolean_t requeue; /**< requeue */ } amqp_basic_recover_t; -#define AMQP_BASIC_RECOVER_OK_METHOD ((amqp_method_number_t) 0x003C006F) /**< basic.recover-ok method id @internal 60, 111; 3932271 */ +#define AMQP_BASIC_RECOVER_OK_METHOD \ + ((amqp_method_number_t)0x003C006F) /**< basic.recover-ok method id \ + @internal 60, 111; 3932271 */ /** basic.recover-ok method fields */ typedef struct amqp_basic_recover_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_basic_recover_ok_t; -#define AMQP_BASIC_NACK_METHOD ((amqp_method_number_t) 0x003C0078) /**< basic.nack method id @internal 60, 120; 3932280 */ +#define AMQP_BASIC_NACK_METHOD \ + ((amqp_method_number_t)0x003C0078) /**< basic.nack method id @internal 60, \ + 120; 3932280 */ /** basic.nack method fields */ typedef struct amqp_basic_nack_t_ { - uint64_t delivery_tag; /**< delivery-tag */ + uint64_t delivery_tag; /**< delivery-tag */ amqp_boolean_t multiple; /**< multiple */ - amqp_boolean_t requeue; /**< requeue */ + amqp_boolean_t requeue; /**< requeue */ } amqp_basic_nack_t; -#define AMQP_TX_SELECT_METHOD ((amqp_method_number_t) 0x005A000A) /**< tx.select method id @internal 90, 10; 5898250 */ +#define AMQP_TX_SELECT_METHOD \ + ((amqp_method_number_t)0x005A000A) /**< tx.select method id @internal 90, \ + 10; 5898250 */ /** tx.select method fields */ typedef struct amqp_tx_select_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_tx_select_t; -#define AMQP_TX_SELECT_OK_METHOD ((amqp_method_number_t) 0x005A000B) /**< tx.select-ok method id @internal 90, 11; 5898251 */ +#define AMQP_TX_SELECT_OK_METHOD \ + ((amqp_method_number_t)0x005A000B) /**< tx.select-ok method id @internal \ + 90, 11; 5898251 */ /** tx.select-ok method fields */ typedef struct amqp_tx_select_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_tx_select_ok_t; -#define AMQP_TX_COMMIT_METHOD ((amqp_method_number_t) 0x005A0014) /**< tx.commit method id @internal 90, 20; 5898260 */ +#define AMQP_TX_COMMIT_METHOD \ + ((amqp_method_number_t)0x005A0014) /**< tx.commit method id @internal 90, \ + 20; 5898260 */ /** tx.commit method fields */ typedef struct amqp_tx_commit_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_tx_commit_t; -#define AMQP_TX_COMMIT_OK_METHOD ((amqp_method_number_t) 0x005A0015) /**< tx.commit-ok method id @internal 90, 21; 5898261 */ +#define AMQP_TX_COMMIT_OK_METHOD \ + ((amqp_method_number_t)0x005A0015) /**< tx.commit-ok method id @internal \ + 90, 21; 5898261 */ /** tx.commit-ok method fields */ typedef struct amqp_tx_commit_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_tx_commit_ok_t; -#define AMQP_TX_ROLLBACK_METHOD ((amqp_method_number_t) 0x005A001E) /**< tx.rollback method id @internal 90, 30; 5898270 */ +#define AMQP_TX_ROLLBACK_METHOD \ + ((amqp_method_number_t)0x005A001E) /**< tx.rollback method id @internal \ + 90, 30; 5898270 */ /** tx.rollback method fields */ typedef struct amqp_tx_rollback_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_tx_rollback_t; -#define AMQP_TX_ROLLBACK_OK_METHOD ((amqp_method_number_t) 0x005A001F) /**< tx.rollback-ok method id @internal 90, 31; 5898271 */ +#define AMQP_TX_ROLLBACK_OK_METHOD \ + ((amqp_method_number_t)0x005A001F) /**< tx.rollback-ok method id @internal \ + 90, 31; 5898271 */ /** tx.rollback-ok method fields */ typedef struct amqp_tx_rollback_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_tx_rollback_ok_t; -#define AMQP_CONFIRM_SELECT_METHOD ((amqp_method_number_t) 0x0055000A) /**< confirm.select method id @internal 85, 10; 5570570 */ +#define AMQP_CONFIRM_SELECT_METHOD \ + ((amqp_method_number_t)0x0055000A) /**< confirm.select method id @internal \ + 85, 10; 5570570 */ /** confirm.select method fields */ typedef struct amqp_confirm_select_t_ { amqp_boolean_t nowait; /**< nowait */ } amqp_confirm_select_t; -#define AMQP_CONFIRM_SELECT_OK_METHOD ((amqp_method_number_t) 0x0055000B) /**< confirm.select-ok method id @internal 85, 11; 5570571 */ +#define AMQP_CONFIRM_SELECT_OK_METHOD \ + ((amqp_method_number_t)0x0055000B) /**< confirm.select-ok method id \ + @internal 85, 11; 5570571 */ /** confirm.select-ok method fields */ typedef struct amqp_confirm_select_ok_t_ { char dummy; /**< Dummy field to avoid empty struct */ } amqp_confirm_select_ok_t; /* Class property records. */ -#define AMQP_CONNECTION_CLASS (0x000A) /**< connection class id @internal 10 */ +#define AMQP_CONNECTION_CLASS \ + (0x000A) /**< connection class id @internal 10 \ + */ /** connection class properties */ typedef struct amqp_connection_properties_t_ { amqp_flags_t _flags; /**< bit-mask of set fields */ - char dummy; /**< Dummy field to avoid empty struct */ + char dummy; /**< Dummy field to avoid empty struct */ } amqp_connection_properties_t; #define AMQP_CHANNEL_CLASS (0x0014) /**< channel class id @internal 20 */ /** channel class properties */ typedef struct amqp_channel_properties_t_ { amqp_flags_t _flags; /**< bit-mask of set fields */ - char dummy; /**< Dummy field to avoid empty struct */ + char dummy; /**< Dummy field to avoid empty struct */ } amqp_channel_properties_t; #define AMQP_ACCESS_CLASS (0x001E) /**< access class id @internal 30 */ /** access class properties */ typedef struct amqp_access_properties_t_ { amqp_flags_t _flags; /**< bit-mask of set fields */ - char dummy; /**< Dummy field to avoid empty struct */ + char dummy; /**< Dummy field to avoid empty struct */ } amqp_access_properties_t; #define AMQP_EXCHANGE_CLASS (0x0028) /**< exchange class id @internal 40 */ /** exchange class properties */ typedef struct amqp_exchange_properties_t_ { amqp_flags_t _flags; /**< bit-mask of set fields */ - char dummy; /**< Dummy field to avoid empty struct */ + char dummy; /**< Dummy field to avoid empty struct */ } amqp_exchange_properties_t; #define AMQP_QUEUE_CLASS (0x0032) /**< queue class id @internal 50 */ /** queue class properties */ typedef struct amqp_queue_properties_t_ { amqp_flags_t _flags; /**< bit-mask of set fields */ - char dummy; /**< Dummy field to avoid empty struct */ + char dummy; /**< Dummy field to avoid empty struct */ } amqp_queue_properties_t; #define AMQP_BASIC_CLASS (0x003C) /**< basic class id @internal 60 */ -#define AMQP_BASIC_CONTENT_TYPE_FLAG (1 << 15) /**< basic.content-type property flag */ -#define AMQP_BASIC_CONTENT_ENCODING_FLAG (1 << 14) /**< basic.content-encoding property flag */ -#define AMQP_BASIC_HEADERS_FLAG (1 << 13) /**< basic.headers property flag */ -#define AMQP_BASIC_DELIVERY_MODE_FLAG (1 << 12) /**< basic.delivery-mode property flag */ -#define AMQP_BASIC_PRIORITY_FLAG (1 << 11) /**< basic.priority property flag */ -#define AMQP_BASIC_CORRELATION_ID_FLAG (1 << 10) /**< basic.correlation-id property flag */ -#define AMQP_BASIC_REPLY_TO_FLAG (1 << 9) /**< basic.reply-to property flag */ -#define AMQP_BASIC_EXPIRATION_FLAG (1 << 8) /**< basic.expiration property flag */ -#define AMQP_BASIC_MESSAGE_ID_FLAG (1 << 7) /**< basic.message-id property flag */ -#define AMQP_BASIC_TIMESTAMP_FLAG (1 << 6) /**< basic.timestamp property flag */ -#define AMQP_BASIC_TYPE_FLAG (1 << 5) /**< basic.type property flag */ -#define AMQP_BASIC_USER_ID_FLAG (1 << 4) /**< basic.user-id property flag */ -#define AMQP_BASIC_APP_ID_FLAG (1 << 3) /**< basic.app-id property flag */ -#define AMQP_BASIC_CLUSTER_ID_FLAG (1 << 2) /**< basic.cluster-id property flag */ +#define AMQP_BASIC_CONTENT_TYPE_FLAG (1 << 15) +#define AMQP_BASIC_CONTENT_ENCODING_FLAG (1 << 14) +#define AMQP_BASIC_HEADERS_FLAG (1 << 13) +#define AMQP_BASIC_DELIVERY_MODE_FLAG (1 << 12) +#define AMQP_BASIC_PRIORITY_FLAG (1 << 11) +#define AMQP_BASIC_CORRELATION_ID_FLAG (1 << 10) +#define AMQP_BASIC_REPLY_TO_FLAG (1 << 9) +#define AMQP_BASIC_EXPIRATION_FLAG (1 << 8) +#define AMQP_BASIC_MESSAGE_ID_FLAG (1 << 7) +#define AMQP_BASIC_TIMESTAMP_FLAG (1 << 6) +#define AMQP_BASIC_TYPE_FLAG (1 << 5) +#define AMQP_BASIC_USER_ID_FLAG (1 << 4) +#define AMQP_BASIC_APP_ID_FLAG (1 << 3) +#define AMQP_BASIC_CLUSTER_ID_FLAG (1 << 2) /** basic class properties */ typedef struct amqp_basic_properties_t_ { - amqp_flags_t _flags; /**< bit-mask of set fields */ - amqp_bytes_t content_type; /**< content-type */ + amqp_flags_t _flags; /**< bit-mask of set fields */ + amqp_bytes_t content_type; /**< content-type */ amqp_bytes_t content_encoding; /**< content-encoding */ - amqp_table_t headers; /**< headers */ - uint8_t delivery_mode; /**< delivery-mode */ - uint8_t priority; /**< priority */ - amqp_bytes_t correlation_id; /**< correlation-id */ - amqp_bytes_t reply_to; /**< reply-to */ - amqp_bytes_t expiration; /**< expiration */ - amqp_bytes_t message_id; /**< message-id */ - uint64_t timestamp; /**< timestamp */ - amqp_bytes_t type; /**< type */ - amqp_bytes_t user_id; /**< user-id */ - amqp_bytes_t app_id; /**< app-id */ - amqp_bytes_t cluster_id; /**< cluster-id */ + amqp_table_t headers; /**< headers */ + uint8_t delivery_mode; /**< delivery-mode */ + uint8_t priority; /**< priority */ + amqp_bytes_t correlation_id; /**< correlation-id */ + amqp_bytes_t reply_to; /**< reply-to */ + amqp_bytes_t expiration; /**< expiration */ + amqp_bytes_t message_id; /**< message-id */ + uint64_t timestamp; /**< timestamp */ + amqp_bytes_t type; /**< type */ + amqp_bytes_t user_id; /**< user-id */ + amqp_bytes_t app_id; /**< app-id */ + amqp_bytes_t cluster_id; /**< cluster-id */ } amqp_basic_properties_t; #define AMQP_TX_CLASS (0x005A) /**< tx class id @internal 90 */ /** tx class properties */ typedef struct amqp_tx_properties_t_ { amqp_flags_t _flags; /**< bit-mask of set fields */ - char dummy; /**< Dummy field to avoid empty struct */ + char dummy; /**< Dummy field to avoid empty struct */ } amqp_tx_properties_t; #define AMQP_CONFIRM_CLASS (0x0055) /**< confirm class id @internal 85 */ /** confirm class properties */ typedef struct amqp_confirm_properties_t_ { amqp_flags_t _flags; /**< bit-mask of set fields */ - char dummy; /**< Dummy field to avoid empty struct */ + char dummy; /**< Dummy field to avoid empty struct */ } amqp_confirm_properties_t; /* API functions for methods */ @@ -766,8 +887,8 @@ * @returns amqp_channel_open_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_channel_open_ok_t * -AMQP_CALL amqp_channel_open(amqp_connection_state_t state, amqp_channel_t channel); +amqp_channel_open_ok_t *AMQP_CALL + amqp_channel_open(amqp_connection_state_t state, amqp_channel_t channel); /** * amqp_channel_flow * @@ -777,8 +898,9 @@ * @returns amqp_channel_flow_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_channel_flow_ok_t * -AMQP_CALL amqp_channel_flow(amqp_connection_state_t state, amqp_channel_t channel, amqp_boolean_t active); +amqp_channel_flow_ok_t *AMQP_CALL + amqp_channel_flow(amqp_connection_state_t state, amqp_channel_t channel, + amqp_boolean_t active); /** * amqp_exchange_declare * @@ -794,8 +916,11 @@ * @returns amqp_exchange_declare_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_exchange_declare_ok_t * -AMQP_CALL 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); +amqp_exchange_declare_ok_t *AMQP_CALL 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); /** * amqp_exchange_delete * @@ -806,8 +931,9 @@ * @returns amqp_exchange_delete_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_exchange_delete_ok_t * -AMQP_CALL amqp_exchange_delete(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t exchange, amqp_boolean_t if_unused); +amqp_exchange_delete_ok_t *AMQP_CALL + amqp_exchange_delete(amqp_connection_state_t state, amqp_channel_t channel, + amqp_bytes_t exchange, amqp_boolean_t if_unused); /** * amqp_exchange_bind * @@ -820,8 +946,10 @@ * @returns amqp_exchange_bind_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_exchange_bind_ok_t * -AMQP_CALL 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); +amqp_exchange_bind_ok_t *AMQP_CALL + 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); /** * amqp_exchange_unbind * @@ -834,8 +962,10 @@ * @returns amqp_exchange_unbind_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_exchange_unbind_ok_t * -AMQP_CALL 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); +amqp_exchange_unbind_ok_t *AMQP_CALL + 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); /** * amqp_queue_declare * @@ -850,8 +980,10 @@ * @returns amqp_queue_declare_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_queue_declare_ok_t * -AMQP_CALL 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); +amqp_queue_declare_ok_t *AMQP_CALL 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); /** * amqp_queue_bind * @@ -864,8 +996,9 @@ * @returns amqp_queue_bind_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_queue_bind_ok_t * -AMQP_CALL 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); +amqp_queue_bind_ok_t *AMQP_CALL 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); /** * amqp_queue_purge * @@ -875,8 +1008,9 @@ * @returns amqp_queue_purge_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_queue_purge_ok_t * -AMQP_CALL amqp_queue_purge(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t queue); +amqp_queue_purge_ok_t *AMQP_CALL amqp_queue_purge(amqp_connection_state_t state, + amqp_channel_t channel, + amqp_bytes_t queue); /** * amqp_queue_delete * @@ -888,8 +1022,9 @@ * @returns amqp_queue_delete_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_queue_delete_ok_t * -AMQP_CALL 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); +amqp_queue_delete_ok_t *AMQP_CALL 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); /** * amqp_queue_unbind * @@ -902,8 +1037,9 @@ * @returns amqp_queue_unbind_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_queue_unbind_ok_t * -AMQP_CALL 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); +amqp_queue_unbind_ok_t *AMQP_CALL 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); /** * amqp_basic_qos * @@ -915,8 +1051,11 @@ * @returns amqp_basic_qos_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_basic_qos_ok_t * -AMQP_CALL amqp_basic_qos(amqp_connection_state_t state, amqp_channel_t channel, uint32_t prefetch_size, uint16_t prefetch_count, amqp_boolean_t global); +amqp_basic_qos_ok_t *AMQP_CALL amqp_basic_qos(amqp_connection_state_t state, + amqp_channel_t channel, + uint32_t prefetch_size, + uint16_t prefetch_count, + amqp_boolean_t global); /** * amqp_basic_consume * @@ -931,8 +1070,10 @@ * @returns amqp_basic_consume_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_basic_consume_ok_t * -AMQP_CALL 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); +amqp_basic_consume_ok_t *AMQP_CALL 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); /** * amqp_basic_cancel * @@ -942,8 +1083,9 @@ * @returns amqp_basic_cancel_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_basic_cancel_ok_t * -AMQP_CALL amqp_basic_cancel(amqp_connection_state_t state, amqp_channel_t channel, amqp_bytes_t consumer_tag); +amqp_basic_cancel_ok_t *AMQP_CALL + amqp_basic_cancel(amqp_connection_state_t state, amqp_channel_t channel, + amqp_bytes_t consumer_tag); /** * amqp_basic_recover * @@ -953,8 +1095,9 @@ * @returns amqp_basic_recover_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_basic_recover_ok_t * -AMQP_CALL amqp_basic_recover(amqp_connection_state_t state, amqp_channel_t channel, amqp_boolean_t requeue); +amqp_basic_recover_ok_t *AMQP_CALL + amqp_basic_recover(amqp_connection_state_t state, amqp_channel_t channel, + amqp_boolean_t requeue); /** * amqp_tx_select * @@ -963,8 +1106,8 @@ * @returns amqp_tx_select_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_tx_select_ok_t * -AMQP_CALL amqp_tx_select(amqp_connection_state_t state, amqp_channel_t channel); +amqp_tx_select_ok_t *AMQP_CALL amqp_tx_select(amqp_connection_state_t state, + amqp_channel_t channel); /** * amqp_tx_commit * @@ -973,8 +1116,8 @@ * @returns amqp_tx_commit_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_tx_commit_ok_t * -AMQP_CALL amqp_tx_commit(amqp_connection_state_t state, amqp_channel_t channel); +amqp_tx_commit_ok_t *AMQP_CALL amqp_tx_commit(amqp_connection_state_t state, + amqp_channel_t channel); /** * amqp_tx_rollback * @@ -983,8 +1126,8 @@ * @returns amqp_tx_rollback_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_tx_rollback_ok_t * -AMQP_CALL amqp_tx_rollback(amqp_connection_state_t state, amqp_channel_t channel); +amqp_tx_rollback_ok_t *AMQP_CALL amqp_tx_rollback(amqp_connection_state_t state, + amqp_channel_t channel); /** * amqp_confirm_select * @@ -993,8 +1136,8 @@ * @returns amqp_confirm_select_ok_t */ AMQP_PUBLIC_FUNCTION -amqp_confirm_select_ok_t * -AMQP_CALL amqp_confirm_select(amqp_connection_state_t state, amqp_channel_t channel); +amqp_confirm_select_ok_t *AMQP_CALL + amqp_confirm_select(amqp_connection_state_t state, amqp_channel_t channel); AMQP_END_DECLS diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_gnutls.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_gnutls.c --- librabbitmq-0.7.1/librabbitmq/amqp_gnutls.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_gnutls.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,362 +0,0 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ -/* - * Copyright 2012-2013 Michael Steinert - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "amqp_ssl_socket.h" -#include "amqp_private.h" -#include -#include -#include -#include - -#ifndef AMQP_USE_UNTESTED_SSL_BACKEND -# error This SSL backend is alpha quality and likely contains errors.\ - -DAMQP_USE_UNTESTED_SSL_BACKEND to use this backend -#endif - -struct amqp_ssl_socket_t { - const struct amqp_socket_class_t *klass; - gnutls_session_t session; - gnutls_certificate_credentials_t credentials; - int sockfd; - char *host; - char *buffer; - size_t length; - int last_error; -}; - -static ssize_t -amqp_ssl_socket_send(void *base, - const void *buf, - size_t len, - AMQP_UNUSED int flags) -{ - ssize_t status; - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - - self->last_error = 0; - status = gnutls_record_send(self->session, buf, len); - if (status < 0) { - self->last_error = AMQP_STATUS_SSL_ERROR; - } - return status; -} - -static ssize_t -amqp_ssl_socket_writev(void *base, - const struct iovec *iov, - int iovcnt) -{ - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - ssize_t written = -1; - char *bufferp; - size_t bytes; - int i; - self->last_error = 0; - bytes = 0; - for (i = 0; i < iovcnt; ++i) { - bytes += iov[i].iov_len; - } - if (self->length < bytes) { - free(self->buffer); - self->buffer = malloc(bytes); - if (!self->buffer) { - self->length = 0; - self->last_error = AMQP_STATUS_NO_MEMORY; - goto exit; - } - self->length = 0; - } - bufferp = self->buffer; - for (i = 0; i < iovcnt; ++i) { - memcpy(bufferp, iov[i].iov_base, iov[i].iov_len); - bufferp += iov[i].iov_len; - } - written = amqp_ssl_socket_send(self, self->buffer, bytes, 0); -exit: - return written; -} - -static ssize_t -amqp_ssl_socket_recv(void *base, - void *buf, - size_t len, - AMQP_UNUSED int flags) -{ - ssize_t status; - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - - self->last_error = 0; - status = gnutls_record_recv(self->session, buf, len); - if (status < 0) { - self->last_error = AMQP_STATUS_SSL_ERROR; - } - - return status; -} - -static int -amqp_ssl_socket_open(void *base, const char *host, int port, struct timeval *timeout) -{ - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - int status; - self->last_error = 0; - - free(self->host); - self->host = strdup(host); - if (NULL == self->host) { - self->last_error = AMQP_STATUS_NO_MEMORY; - return -1; - } - - self->sockfd = amqp_open_socket_noblock(host, port, timeout); - if (0 > self->sockfd) { - self->last_error = -self->sockfd; - return -1; - } - gnutls_transport_set_ptr(self->session, - (gnutls_transport_ptr_t)self->sockfd); - do { - status = gnutls_handshake(self->session); - } while (status < 0 && !gnutls_error_is_fatal(status)); - - if (gnutls_error_is_fatal(status)) { - self->last_error = AMQP_STATUS_SSL_ERROR; - } - - return status; -} - -static int -amqp_ssl_socket_close(void *base) -{ - int status = -1; - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - if (self->sockfd >= 0) { - status = amqp_os_socket_close(self->sockfd); - } - if (self) { - gnutls_deinit(self->session); - gnutls_certificate_free_credentials(self->credentials); - free(self->host); - free(self->buffer); - free(self); - } - return status; -} - -static int -amqp_ssl_socket_error(void *base) -{ - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - return self->last_error; -} - -char * -amqp_ssl_error_string(AMQP_UNUSED int err) -{ - return strdup("A SSL error occurred"); -} - -static int -amqp_ssl_socket_get_sockfd(void *base) -{ - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - return self->sockfd; -} - -static int -amqp_ssl_verify(gnutls_session_t session) -{ - int ret; - unsigned int status, size; - const gnutls_datum_t *list; - gnutls_x509_crt_t cert = NULL; - struct amqp_ssl_socket_t *self = gnutls_session_get_ptr(session); - ret = gnutls_certificate_verify_peers2(session, &status); - if (0 > ret) { - goto error; - } - if (status & GNUTLS_CERT_INVALID) { - goto error; - } - if (status & GNUTLS_CERT_SIGNER_NOT_FOUND) { - goto error; - } - if (status & GNUTLS_CERT_REVOKED) { - goto error; - } - if (status & GNUTLS_CERT_EXPIRED) { - goto error; - } - if (status & GNUTLS_CERT_NOT_ACTIVATED) { - goto error; - } - if (gnutls_certificate_type_get(session) != GNUTLS_CRT_X509) { - goto error; - } - if (gnutls_x509_crt_init(&cert) < 0) { - goto error; - } - list = gnutls_certificate_get_peers(session, &size); - if (!list) { - goto error; - } - ret = gnutls_x509_crt_import(cert, &list[0], GNUTLS_X509_FMT_DER); - if (0 > ret) { - goto error; - } - if (!gnutls_x509_crt_check_hostname(cert, self->host)) { - goto error; - } - gnutls_x509_crt_deinit(cert); - return 0; -error: - if (cert) { - gnutls_x509_crt_deinit (cert); - } - return GNUTLS_E_CERTIFICATE_ERROR; -} - -static const struct amqp_socket_class_t amqp_ssl_socket_class = { - amqp_ssl_socket_writev, /* writev */ - amqp_ssl_socket_send, /* send */ - amqp_ssl_socket_recv, /* recv */ - amqp_ssl_socket_open, /* open */ - amqp_ssl_socket_close, /* close */ - amqp_ssl_socket_error, /* error */ - amqp_ssl_socket_get_sockfd /* get_sockfd */ -}; - -amqp_socket_t * -amqp_ssl_socket_new(void) -{ - struct amqp_ssl_socket_t *self = calloc(1, sizeof(*self)); - const char *error; - int status; - if (!self) { - goto error; - } - gnutls_global_init(); - status = gnutls_init(&self->session, GNUTLS_CLIENT); - if (GNUTLS_E_SUCCESS != status) { - goto error; - } - status = gnutls_certificate_allocate_credentials(&self->credentials); - if (GNUTLS_E_SUCCESS != status) { - goto error; - } - gnutls_certificate_set_verify_function(self->credentials, - amqp_ssl_verify); - status = gnutls_credentials_set(self->session, GNUTLS_CRD_CERTIFICATE, - self->credentials); - if (GNUTLS_E_SUCCESS != status) { - goto error; - } - gnutls_session_set_ptr(self->session, self); - status = gnutls_priority_set_direct(self->session, "NORMAL", &error); - if (GNUTLS_E_SUCCESS != status) { - goto error; - } - self->klass = &amqp_ssl_socket_class; - return (amqp_socket_t *)self; -error: - amqp_socket_close((amqp_socket_t *)self); - return NULL; -} - -int -amqp_ssl_socket_set_cacert(amqp_socket_t *base, - const char *cacert) -{ - int status; - struct amqp_ssl_socket_t *self; - if (base->klass != &amqp_ssl_socket_class) { - amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); - } - self = (struct amqp_ssl_socket_t *)base; - status = gnutls_certificate_set_x509_trust_file(self->credentials, - cacert, - GNUTLS_X509_FMT_PEM); - if (0 > status) { - return -1; - } - return 0; -} - -int -amqp_ssl_socket_set_key(amqp_socket_t *base, - const char *cert, - const char *key) -{ - int status; - struct amqp_ssl_socket_t *self; - if (base->klass != &amqp_ssl_socket_class) { - amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); - } - self = (struct amqp_ssl_socket_t *)base; - status = gnutls_certificate_set_x509_key_file(self->credentials, - cert, - key, - GNUTLS_X509_FMT_PEM); - if (0 > status) { - return -1; - } - return 0; -} - -int -amqp_ssl_socket_set_key_buffer(AMQP_UNUSED amqp_socket_t *base, - AMQP_UNUSED const char *cert, - AMQP_UNUSED const void *key, - AMQP_UNUSED size_t n) -{ - amqp_abort("%s is not implemented for GnuTLS", __func__); - return -1; -} - -void -amqp_ssl_socket_set_verify(amqp_socket_t *base, - amqp_boolean_t verify) -{ - struct amqp_ssl_socket_t *self; - if (base->klass != &amqp_ssl_socket_class) { - amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); - } - self = (struct amqp_ssl_socket_t *)base; - if (verify) { - gnutls_certificate_set_verify_function(self->credentials, - amqp_ssl_verify); - } else { - gnutls_certificate_set_verify_function(self->credentials, - NULL); - } -} - -void -amqp_set_initialize_ssl_library(AMQP_UNUSED amqp_boolean_t do_initialize) -{ -} diff -Nru librabbitmq-0.7.1/librabbitmq/amqp.h librabbitmq-0.9.0-0.1/librabbitmq/amqp.h --- librabbitmq-0.7.1/librabbitmq/amqp.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /** \file */ /* * ***** BEGIN LICENSE BLOCK ***** @@ -57,85 +56,82 @@ */ #if defined(_WIN32) && defined(_MSC_VER) -# if defined(AMQP_BUILD) && !defined(AMQP_STATIC) -# define AMQP_PUBLIC_FUNCTION __declspec(dllexport) -# define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern -# else -# define AMQP_PUBLIC_FUNCTION -# if !defined(AMQP_STATIC) -# define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern -# else -# define AMQP_PUBLIC_VARIABLE extern -# endif -# endif -# define AMQP_CALL __cdecl +#if defined(AMQP_BUILD) && !defined(AMQP_STATIC) +#define AMQP_PUBLIC_FUNCTION __declspec(dllexport) +#define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern +#else +#define AMQP_PUBLIC_FUNCTION +#if !defined(AMQP_STATIC) +#define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern +#else +#define AMQP_PUBLIC_VARIABLE extern +#endif +#endif +#define AMQP_CALL __cdecl #elif defined(_WIN32) && defined(__BORLANDC__) -# if defined(AMQP_BUILD) && !defined(AMQP_STATIC) -# define AMQP_PUBLIC_FUNCTION __declspec(dllexport) -# define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern -# else -# define AMQP_PUBLIC_FUNCTION -# if !defined(AMQP_STATIC) -# define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern -# else -# define AMQP_PUBLIC_VARIABLE extern -# endif -# endif -# define AMQP_CALL __cdecl +#if defined(AMQP_BUILD) && !defined(AMQP_STATIC) +#define AMQP_PUBLIC_FUNCTION __declspec(dllexport) +#define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern +#else +#define AMQP_PUBLIC_FUNCTION +#if !defined(AMQP_STATIC) +#define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern +#else +#define AMQP_PUBLIC_VARIABLE extern +#endif +#endif +#define AMQP_CALL __cdecl #elif defined(_WIN32) && defined(__MINGW32__) -# if defined(AMQP_BUILD) && !defined(AMQP_STATIC) -# define AMQP_PUBLIC_FUNCTION __declspec(dllexport) -# define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern -# else -# define AMQP_PUBLIC_FUNCTION -# if !defined(AMQP_STATIC) -# define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern -# else -# define AMQP_PUBLIC_VARIABLE extern -# endif -# endif -# define AMQP_CALL __cdecl +#if defined(AMQP_BUILD) && !defined(AMQP_STATIC) +#define AMQP_PUBLIC_FUNCTION __declspec(dllexport) +#define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern +#else +#define AMQP_PUBLIC_FUNCTION +#if !defined(AMQP_STATIC) +#define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern +#else +#define AMQP_PUBLIC_VARIABLE extern +#endif +#endif +#define AMQP_CALL __cdecl #elif defined(_WIN32) && defined(__CYGWIN__) -# if defined(AMQP_BUILD) && !defined(AMQP_STATIC) -# define AMQP_PUBLIC_FUNCTION __declspec(dllexport) -# define AMQP_PUBLIC_VARIABLE __declspec(dllexport) -# else -# define AMQP_PUBLIC_FUNCTION -# if !defined(AMQP_STATIC) -# define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern -# else -# define AMQP_PUBLIC_VARIABLE extern -# endif -# endif -# define AMQP_CALL __cdecl +#if defined(AMQP_BUILD) && !defined(AMQP_STATIC) +#define AMQP_PUBLIC_FUNCTION __declspec(dllexport) +#define AMQP_PUBLIC_VARIABLE __declspec(dllexport) +#else +#define AMQP_PUBLIC_FUNCTION +#if !defined(AMQP_STATIC) +#define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern +#else +#define AMQP_PUBLIC_VARIABLE extern +#endif +#endif +#define AMQP_CALL __cdecl #elif defined(__GNUC__) && __GNUC__ >= 4 -# define AMQP_PUBLIC_FUNCTION \ - __attribute__ ((visibility ("default"))) -# define AMQP_PUBLIC_VARIABLE \ - __attribute__ ((visibility ("default"))) extern -# define AMQP_CALL +#define AMQP_PUBLIC_FUNCTION __attribute__((visibility("default"))) +#define AMQP_PUBLIC_VARIABLE __attribute__((visibility("default"))) extern +#define AMQP_CALL #else -# define AMQP_PUBLIC_FUNCTION -# define AMQP_PUBLIC_VARIABLE extern -# define AMQP_CALL +#define AMQP_PUBLIC_FUNCTION +#define AMQP_PUBLIC_VARIABLE extern +#define AMQP_CALL #endif #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) -# define AMQP_DEPRECATED(function) \ - function __attribute__ ((__deprecated__)) +#define AMQP_DEPRECATED(function) function __attribute__((__deprecated__)) #elif defined(_MSC_VER) -# define AMQP_DEPRECATED(function) \ - __declspec(deprecated) function +#define AMQP_DEPRECATED(function) __declspec(deprecated) function #else -# define AMQP_DEPRECATED(function) +#define AMQP_DEPRECATED(function) #endif /* Define ssize_t on Win32/64 platforms - See: http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-April/030649.html for details + See: http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-April/030649.html for + details */ #if !defined(_W64) #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 @@ -223,11 +219,10 @@ */ #define AMQP_VERSION_MAJOR 0 -#define AMQP_VERSION_MINOR 7 -#define AMQP_VERSION_PATCH 1 +#define AMQP_VERSION_MINOR 9 +#define AMQP_VERSION_PATCH 0 #define AMQP_VERSION_IS_RELEASE 1 - /** * \def AMQP_VERSION_CODE * @@ -240,11 +235,7 @@ * \since v0.6.1 */ #define AMQP_VERSION_CODE(major, minor, patch, release) \ - ((major << 24) | \ - (minor << 16) | \ - (patch << 8) | \ - (release)) - + ((major << 24) | (minor << 16) | (patch << 8) | (release)) /** * \def AMQP_VERSION @@ -264,18 +255,17 @@ * * \since v0.4.0 */ -#define AMQP_VERSION AMQP_VERSION_CODE(AMQP_VERSION_MAJOR, \ - AMQP_VERSION_MINOR, \ - AMQP_VERSION_PATCH, \ - AMQP_VERSION_IS_RELEASE) +#define AMQP_VERSION \ + AMQP_VERSION_CODE(AMQP_VERSION_MAJOR, AMQP_VERSION_MINOR, \ + AMQP_VERSION_PATCH, AMQP_VERSION_IS_RELEASE) /** \cond HIDE_FROM_DOXYGEN */ #define AMQ_STRINGIFY(s) AMQ_STRINGIFY_HELPER(s) #define AMQ_STRINGIFY_HELPER(s) #s -#define AMQ_VERSION_STRING AMQ_STRINGIFY(AMQP_VERSION_MAJOR) "." \ - AMQ_STRINGIFY(AMQP_VERSION_MINOR) "." \ - AMQ_STRINGIFY(AMQP_VERSION_PATCH) +#define AMQ_VERSION_STRING \ + AMQ_STRINGIFY(AMQP_VERSION_MAJOR) \ + "." AMQ_STRINGIFY(AMQP_VERSION_MINOR) "." AMQ_STRINGIFY(AMQP_VERSION_PATCH) /** \endcond */ /** @@ -291,12 +281,11 @@ * \since v0.4.0 */ #if AMQP_VERSION_IS_RELEASE -# define AMQP_VERSION_STRING AMQ_VERSION_STRING +#define AMQP_VERSION_STRING AMQ_VERSION_STRING #else -# define AMQP_VERSION_STRING AMQ_VERSION_STRING "-pre" +#define AMQP_VERSION_STRING AMQ_VERSION_STRING "-pre" #endif - /** * Returns the rabbitmq-c version as a packed integer. * @@ -309,8 +298,7 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -uint32_t -AMQP_CALL amqp_version_number(void); +uint32_t AMQP_CALL amqp_version_number(void); /** * Returns the rabbitmq-c version as a string. @@ -324,8 +312,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -char const * -AMQP_CALL amqp_version(void); +char const *AMQP_CALL amqp_version(void); /** * \def AMQP_DEFAULT_FRAME_SIZE @@ -361,6 +348,17 @@ #define AMQP_DEFAULT_HEARTBEAT 0 /** + * \def AMQP_DEFAULT_VHOST + * + * Default RabbitMQ vhost: "/" + * + * \sa amqp_login(), amqp_login_with_properties() + * + * \since v0.9.0 + */ +#define AMQP_DEFAULT_VHOST "/" + +/** * boolean type 0 = false, true otherwise * * \since v0.1 @@ -394,8 +392,8 @@ * \since v0.1 */ typedef struct amqp_bytes_t_ { - size_t len; /**< length of the buffer in bytes */ - void *bytes; /**< pointer to the beginning of the buffer */ + size_t len; /**< length of the buffer in bytes */ + void *bytes; /**< pointer to the beginning of the buffer */ } amqp_bytes_t; /** @@ -404,8 +402,8 @@ * \since v0.1 */ typedef struct amqp_decimal_t_ { - uint8_t decimals; /**< the location of the decimal point */ - uint32_t value; /**< the value before the decimal point is applied */ + uint8_t decimals; /**< the location of the decimal point */ + uint32_t value; /**< the value before the decimal point is applied */ } amqp_decimal_t; /** @@ -414,15 +412,16 @@ * An AMQP field table is a set of key-value pairs. * A key is a UTF-8 encoded string up to 128 bytes long, and are not null * terminated. - * A value can be one of several different datatypes. \sa amqp_field_value_kind_t + * A value can be one of several different datatypes. \sa + * amqp_field_value_kind_t * * \sa amqp_table_entry_t * * \since v0.1 */ typedef struct amqp_table_t_ { - int num_entries; /**< length of entries array */ - struct amqp_table_entry_t_ *entries; /**< an array of table entries */ + int num_entries; /**< length of entries array */ + struct amqp_table_entry_t_ *entries; /**< an array of table entries */ } amqp_table_t; /** @@ -433,8 +432,8 @@ * \since v0.1 */ typedef struct amqp_array_t_ { - int num_entries; /**< Number of entries in the table */ - struct amqp_field_value_t_ *entries; /**< linked list of field values */ + int num_entries; /**< Number of entries in the table */ + struct amqp_field_value_t_ *entries; /**< linked list of field values */ } amqp_array_t; /* @@ -482,24 +481,26 @@ * \since v0.1 */ typedef struct amqp_field_value_t_ { - uint8_t kind; /**< the type of the entry /sa amqp_field_value_kind_t */ + uint8_t kind; /**< the type of the entry /sa amqp_field_value_kind_t */ union { - amqp_boolean_t boolean; /**< boolean type AMQP_FIELD_KIND_BOOLEAN */ - int8_t i8; /**< int8_t type AMQP_FIELD_KIND_I8 */ - uint8_t u8; /**< uint8_t type AMQP_FIELD_KIND_U8 */ - int16_t i16; /**< int16_t type AMQP_FIELD_KIND_I16 */ - uint16_t u16; /**< uint16_t type AMQP_FIELD_KIND_U16 */ - int32_t i32; /**< int32_t type AMQP_FIELD_KIND_I32 */ - uint32_t u32; /**< uint32_t type AMQP_FIELD_KIND_U32 */ - int64_t i64; /**< int64_t type AMQP_FIELD_KIND_I64 */ - uint64_t u64; /**< uint64_t type AMQP_FIELD_KIND_U64, AMQP_FIELD_KIND_TIMESTAMP */ - float f32; /**< float type AMQP_FIELD_KIND_F32 */ - double f64; /**< double type AMQP_FIELD_KIND_F64 */ - amqp_decimal_t decimal; /**< amqp_decimal_t AMQP_FIELD_KIND_DECIMAL */ - amqp_bytes_t bytes; /**< amqp_bytes_t type AMQP_FIELD_KIND_UTF8, AMQP_FIELD_KIND_BYTES */ - amqp_table_t table; /**< amqp_table_t type AMQP_FIELD_KIND_TABLE */ - amqp_array_t array; /**< amqp_array_t type AMQP_FIELD_KIND_ARRAY */ - } value; /**< a union of the value */ + amqp_boolean_t boolean; /**< boolean type AMQP_FIELD_KIND_BOOLEAN */ + int8_t i8; /**< int8_t type AMQP_FIELD_KIND_I8 */ + uint8_t u8; /**< uint8_t type AMQP_FIELD_KIND_U8 */ + int16_t i16; /**< int16_t type AMQP_FIELD_KIND_I16 */ + uint16_t u16; /**< uint16_t type AMQP_FIELD_KIND_U16 */ + int32_t i32; /**< int32_t type AMQP_FIELD_KIND_I32 */ + uint32_t u32; /**< uint32_t type AMQP_FIELD_KIND_U32 */ + int64_t i64; /**< int64_t type AMQP_FIELD_KIND_I64 */ + uint64_t u64; /**< uint64_t type AMQP_FIELD_KIND_U64, + AMQP_FIELD_KIND_TIMESTAMP */ + float f32; /**< float type AMQP_FIELD_KIND_F32 */ + double f64; /**< double type AMQP_FIELD_KIND_F64 */ + amqp_decimal_t decimal; /**< amqp_decimal_t AMQP_FIELD_KIND_DECIMAL */ + amqp_bytes_t bytes; /**< amqp_bytes_t type AMQP_FIELD_KIND_UTF8, + AMQP_FIELD_KIND_BYTES */ + amqp_table_t table; /**< amqp_table_t type AMQP_FIELD_KIND_TABLE */ + amqp_array_t array; /**< amqp_array_t type AMQP_FIELD_KIND_ARRAY */ + } value; /**< a union of the value */ } amqp_field_value_t; /** @@ -510,9 +511,9 @@ * \since v0.1 */ typedef struct amqp_table_entry_t_ { - amqp_bytes_t key; /**< the table entry key. Its a null-terminated UTF-8 string, - * with a maximum size of 128 bytes */ - amqp_field_value_t value; /**< the table entry values */ + amqp_bytes_t key; /**< the table entry key. Its a null-terminated UTF-8 + * string, with a maximum size of 128 bytes */ + amqp_field_value_t value; /**< the table entry values */ } amqp_table_entry_t; /** @@ -521,24 +522,32 @@ * \since v0.1 */ typedef enum { - AMQP_FIELD_KIND_BOOLEAN = 't', /**< boolean type. 0 = false, 1 = true @see amqp_boolean_t */ - AMQP_FIELD_KIND_I8 = 'b', /**< 8-bit signed integer, datatype: int8_t */ - AMQP_FIELD_KIND_U8 = 'B', /**< 8-bit unsigned integer, datatype: uint8_t */ - AMQP_FIELD_KIND_I16 = 's', /**< 16-bit signed integer, datatype: int16_t */ - AMQP_FIELD_KIND_U16 = 'u', /**< 16-bit unsigned integer, datatype: uint16_t */ - AMQP_FIELD_KIND_I32 = 'I', /**< 32-bit signed integer, datatype: int32_t */ - AMQP_FIELD_KIND_U32 = 'i', /**< 32-bit unsigned integer, datatype: uint32_t */ - AMQP_FIELD_KIND_I64 = 'l', /**< 64-bit signed integer, datatype: int64_t */ - AMQP_FIELD_KIND_U64 = 'L', /**< 64-bit unsigned integer, datatype: uint64_t */ - AMQP_FIELD_KIND_F32 = 'f', /**< single-precision floating point value, datatype: float */ - AMQP_FIELD_KIND_F64 = 'd', /**< double-precision floating point value, datatype: double */ - AMQP_FIELD_KIND_DECIMAL = 'D', /**< amqp-decimal value, datatype: amqp_decimal_t */ - AMQP_FIELD_KIND_UTF8 = 'S', /**< UTF-8 null-terminated character string, datatype: amqp_bytes_t */ - AMQP_FIELD_KIND_ARRAY = 'A', /**< field array (repeated values of another datatype. datatype: amqp_array_t */ - AMQP_FIELD_KIND_TIMESTAMP = 'T',/**< 64-bit timestamp. datatype uint64_t */ - AMQP_FIELD_KIND_TABLE = 'F', /**< field table. encapsulates a table inside a table entry. datatype: amqp_table_t */ - AMQP_FIELD_KIND_VOID = 'V', /**< empty entry */ - AMQP_FIELD_KIND_BYTES = 'x' /**< unformatted byte string, datatype: amqp_bytes_t */ + AMQP_FIELD_KIND_BOOLEAN = + 't', /**< boolean type. 0 = false, 1 = true @see amqp_boolean_t */ + AMQP_FIELD_KIND_I8 = 'b', /**< 8-bit signed integer, datatype: int8_t */ + AMQP_FIELD_KIND_U8 = 'B', /**< 8-bit unsigned integer, datatype: uint8_t */ + AMQP_FIELD_KIND_I16 = 's', /**< 16-bit signed integer, datatype: int16_t */ + AMQP_FIELD_KIND_U16 = 'u', /**< 16-bit unsigned integer, datatype: uint16_t */ + AMQP_FIELD_KIND_I32 = 'I', /**< 32-bit signed integer, datatype: int32_t */ + AMQP_FIELD_KIND_U32 = 'i', /**< 32-bit unsigned integer, datatype: uint32_t */ + AMQP_FIELD_KIND_I64 = 'l', /**< 64-bit signed integer, datatype: int64_t */ + AMQP_FIELD_KIND_U64 = 'L', /**< 64-bit unsigned integer, datatype: uint64_t */ + AMQP_FIELD_KIND_F32 = + 'f', /**< single-precision floating point value, datatype: float */ + AMQP_FIELD_KIND_F64 = + 'd', /**< double-precision floating point value, datatype: double */ + AMQP_FIELD_KIND_DECIMAL = + 'D', /**< amqp-decimal value, datatype: amqp_decimal_t */ + AMQP_FIELD_KIND_UTF8 = 'S', /**< UTF-8 null-terminated character string, + datatype: amqp_bytes_t */ + AMQP_FIELD_KIND_ARRAY = 'A', /**< field array (repeated values of another + datatype. datatype: amqp_array_t */ + AMQP_FIELD_KIND_TIMESTAMP = 'T', /**< 64-bit timestamp. datatype uint64_t */ + AMQP_FIELD_KIND_TABLE = 'F', /**< field table. encapsulates a table inside a + table entry. datatype: amqp_table_t */ + AMQP_FIELD_KIND_VOID = 'V', /**< empty entry */ + AMQP_FIELD_KIND_BYTES = + 'x' /**< unformatted byte string, datatype: amqp_bytes_t */ } amqp_field_value_kind_t; /** @@ -547,8 +556,8 @@ * \since v0.1 */ typedef struct amqp_pool_blocklist_t_ { - int num_blocks; /**< Number of blocks in the block list */ - void **blocklist; /**< Array of memory blocks */ + int num_blocks; /**< Number of blocks in the block list */ + void **blocklist; /**< Array of memory blocks */ } amqp_pool_blocklist_t; /** @@ -557,18 +566,19 @@ * \since v0.1 */ typedef struct amqp_pool_t_ { - size_t pagesize; /**< the size of the page in bytes. - * allocations less than or equal to this size are - * allocated in the pages block list - * allocations greater than this are allocated in their - * own block in the large_blocks block list */ - - amqp_pool_blocklist_t pages; /**< blocks that are the size of pagesize */ - amqp_pool_blocklist_t large_blocks; /**< allocations larger than the pagesize */ - - int next_page; /**< an index to the next unused page block */ - char *alloc_block; /**< pointer to the current allocation block */ - size_t alloc_used; /**< number of bytes in the current allocation block that has been used */ + size_t pagesize; /**< the size of the page in bytes. Allocations less than or + * equal to this size are allocated in the pages block list. + * Allocations greater than this are allocated in their own + * own block in the large_blocks block list */ + + amqp_pool_blocklist_t pages; /**< blocks that are the size of pagesize */ + amqp_pool_blocklist_t + large_blocks; /**< allocations larger than the pagesize */ + + int next_page; /**< an index to the next unused page block */ + char *alloc_block; /**< pointer to the current allocation block */ + size_t alloc_used; /**< number of bytes in the current allocation block that + has been used */ } amqp_pool_t; /** @@ -577,9 +587,9 @@ * \since v0.1 */ typedef struct amqp_method_t_ { - amqp_method_number_t id; /**< the method id number */ - void *decoded; /**< pointer to the decoded method, - * cast to the appropriate type to use */ + amqp_method_number_t id; /**< the method id number */ + void *decoded; /**< pointer to the decoded method, + * cast to the appropriate type to use */ } amqp_method_t; /** @@ -588,30 +598,32 @@ * \since v0.1 */ typedef struct amqp_frame_t_ { - uint8_t frame_type; /**< frame type. The types: - * - AMQP_FRAME_METHOD - use the method union member - * - AMQP_FRAME_HEADER - use the properties union member - * - AMQP_FRAME_BODY - use the body_fragment union member - */ - amqp_channel_t channel; /**< the channel the frame was received on */ + uint8_t frame_type; /**< frame type. The types: + * - AMQP_FRAME_METHOD - use the method union member + * - AMQP_FRAME_HEADER - use the properties union member + * - AMQP_FRAME_BODY - use the body_fragment union member + */ + amqp_channel_t channel; /**< the channel the frame was received on */ union { - amqp_method_t method; /**< a method, use if frame_type == AMQP_FRAME_METHOD */ + amqp_method_t + method; /**< a method, use if frame_type == AMQP_FRAME_METHOD */ struct { - uint16_t class_id; /**< the class for the properties */ - uint64_t body_size; /**< size of the body in bytes */ - void *decoded; /**< the decoded properties */ - amqp_bytes_t raw; /**< amqp-encoded properties structure */ - } properties; /**< message header, a.k.a., properties, - use if frame_type == AMQP_FRAME_HEADER */ - amqp_bytes_t body_fragment; /**< a body fragment, use if frame_type == AMQP_FRAME_BODY */ + uint16_t class_id; /**< the class for the properties */ + uint64_t body_size; /**< size of the body in bytes */ + void *decoded; /**< the decoded properties */ + amqp_bytes_t raw; /**< amqp-encoded properties structure */ + } properties; /**< message header, a.k.a., properties, + use if frame_type == AMQP_FRAME_HEADER */ + amqp_bytes_t body_fragment; /**< a body fragment, use if frame_type == + AMQP_FRAME_BODY */ struct { - uint8_t transport_high; /**< @internal first byte of handshake */ - uint8_t transport_low; /**< @internal second byte of handshake */ - uint8_t protocol_version_major; /**< @internal third byte of handshake */ - uint8_t protocol_version_minor; /**< @internal fourth byte of handshake */ - } protocol_header; /**< Used only when doing the initial handshake with the broker, - don't use otherwise */ - } payload; /**< the payload of the frame */ + uint8_t transport_high; /**< @internal first byte of handshake */ + uint8_t transport_low; /**< @internal second byte of handshake */ + uint8_t protocol_version_major; /**< @internal third byte of handshake */ + uint8_t protocol_version_minor; /**< @internal fourth byte of handshake */ + } protocol_header; /**< Used only when doing the initial handshake with the + broker, don't use otherwise */ + } payload; /**< the payload of the frame */ } amqp_frame_t; /** @@ -620,10 +632,12 @@ * \since v0.1 */ typedef enum amqp_response_type_enum_ { - AMQP_RESPONSE_NONE = 0, /**< the library got an EOF from the socket */ - AMQP_RESPONSE_NORMAL, /**< response normal, the RPC completed successfully */ - AMQP_RESPONSE_LIBRARY_EXCEPTION,/**< library error, an error occurred in the library, examine the library_error */ - AMQP_RESPONSE_SERVER_EXCEPTION /**< server exception, the broker returned an error, check replay */ + AMQP_RESPONSE_NONE = 0, /**< the library got an EOF from the socket */ + AMQP_RESPONSE_NORMAL, /**< response normal, the RPC completed successfully */ + AMQP_RESPONSE_LIBRARY_EXCEPTION, /**< library error, an error occurred in the + library, examine the library_error */ + AMQP_RESPONSE_SERVER_EXCEPTION /**< server exception, the broker returned an + error, check replay */ } amqp_response_type_enum; /** @@ -632,18 +646,23 @@ * \since v0.1 */ typedef struct amqp_rpc_reply_t_ { - amqp_response_type_enum reply_type; /**< the reply type: - * - AMQP_RESPONSE_NORMAL - the RPC completed successfully - * - AMQP_RESPONSE_SERVER_EXCEPTION - the broker returned - * an exception, check the reply field - * - AMQP_RESPONSE_LIBRARY_EXCEPTION - the library - * encountered an error, check the library_error field - */ - amqp_method_t reply; /**< in case of AMQP_RESPONSE_SERVER_EXCEPTION this - * field will be set to the method returned from the broker */ - int library_error; /**< in case of AMQP_RESPONSE_LIBRARY_EXCEPTION this - * field will be set to an error code. An error - * string can be retrieved using amqp_error_string */ + amqp_response_type_enum reply_type; /**< the reply type: + * - AMQP_RESPONSE_NORMAL - the RPC + * completed successfully + * - AMQP_RESPONSE_SERVER_EXCEPTION - the + * broker returned + * an exception, check the reply field + * - AMQP_RESPONSE_LIBRARY_EXCEPTION - the + * library + * encountered an error, check the + * library_error field + */ + amqp_method_t reply; /**< in case of AMQP_RESPONSE_SERVER_EXCEPTION this + * field will be set to the method returned from the + * broker */ + int library_error; /**< in case of AMQP_RESPONSE_LIBRARY_EXCEPTION this + * field will be set to an error code. An error + * string can be retrieved using amqp_error_string */ } amqp_rpc_reply_t; /** @@ -653,8 +672,10 @@ */ typedef enum amqp_sasl_method_enum_ { AMQP_SASL_METHOD_UNDEFINED = -1, /**< Invalid SASL method */ - AMQP_SASL_METHOD_PLAIN = 0, /**< the PLAIN SASL method for authentication to the broker */ - AMQP_SASL_METHOD_EXTERNAL = 1 /**< the EXTERNAL SASL method for authentication to the broker */ + AMQP_SASL_METHOD_PLAIN = + 0, /**< the PLAIN SASL method for authentication to the broker */ + AMQP_SASL_METHOD_EXTERNAL = + 1 /**< the EXTERNAL SASL method for authentication to the broker */ } amqp_sasl_method_enum; /** @@ -676,75 +697,77 @@ * * \since v0.4.0 */ -/* NOTE: When updating this enum, update the strings in librabbitmq/amqp_api.c */ -typedef enum amqp_status_enum_ -{ - AMQP_STATUS_OK = 0x0, /**< Operation successful */ - AMQP_STATUS_NO_MEMORY = -0x0001, /**< Memory allocation +/* NOTE: When updating this enum, update the strings in librabbitmq/amqp_api.c + */ +typedef enum amqp_status_enum_ { + AMQP_STATUS_OK = 0x0, /**< Operation successful */ + AMQP_STATUS_NO_MEMORY = -0x0001, /**< Memory allocation failed */ - AMQP_STATUS_BAD_AMQP_DATA = -0x0002, /**< Incorrect or corrupt - data was received from - the broker. This is a - protocol error. */ - AMQP_STATUS_UNKNOWN_CLASS = -0x0003, /**< An unknown AMQP class - was received. This is - a protocol error. */ - AMQP_STATUS_UNKNOWN_METHOD = -0x0004, /**< An unknown AMQP method - was received. This is - a protocol error. */ - AMQP_STATUS_HOSTNAME_RESOLUTION_FAILED= -0x0005, /**< Unable to resolve the - * hostname */ - AMQP_STATUS_INCOMPATIBLE_AMQP_VERSION = -0x0006, /**< The broker advertised - an incompaible AMQP - version */ - AMQP_STATUS_CONNECTION_CLOSED = -0x0007, /**< The connection to the - broker has been closed - */ - AMQP_STATUS_BAD_URL = -0x0008, /**< malformed AMQP URL */ - AMQP_STATUS_SOCKET_ERROR = -0x0009, /**< A socket error - occurred */ - AMQP_STATUS_INVALID_PARAMETER = -0x000A, /**< An invalid parameter - was passed into the - function */ - AMQP_STATUS_TABLE_TOO_BIG = -0x000B, /**< The amqp_table_t object - cannot be serialized - because the output - buffer is too small */ - AMQP_STATUS_WRONG_METHOD = -0x000C, /**< The wrong method was - received */ - AMQP_STATUS_TIMEOUT = -0x000D, /**< Operation timed out */ - AMQP_STATUS_TIMER_FAILURE = -0x000E, /**< The underlying system - timer facility failed */ - AMQP_STATUS_HEARTBEAT_TIMEOUT = -0x000F, /**< Timed out waiting for - heartbeat */ - AMQP_STATUS_UNEXPECTED_STATE = -0x0010, /**< Unexpected protocol - state */ - AMQP_STATUS_SOCKET_CLOSED = -0x0011, /**< Underlying socket is - closed */ - AMQP_STATUS_SOCKET_INUSE = -0x0012, /**< Underlying socket is - already open */ + AMQP_STATUS_BAD_AMQP_DATA = -0x0002, /**< Incorrect or corrupt + data was received from + the broker. This is a + protocol error. */ + AMQP_STATUS_UNKNOWN_CLASS = -0x0003, /**< An unknown AMQP class + was received. This is + a protocol error. */ + AMQP_STATUS_UNKNOWN_METHOD = -0x0004, /**< An unknown AMQP method + was received. This is + a protocol error. */ + AMQP_STATUS_HOSTNAME_RESOLUTION_FAILED = -0x0005, /**< Unable to resolve the + * hostname */ + AMQP_STATUS_INCOMPATIBLE_AMQP_VERSION = -0x0006, /**< The broker advertised + an incompaible AMQP + version */ + AMQP_STATUS_CONNECTION_CLOSED = -0x0007, /**< The connection to the + broker has been closed + */ + AMQP_STATUS_BAD_URL = -0x0008, /**< malformed AMQP URL */ + AMQP_STATUS_SOCKET_ERROR = -0x0009, /**< A socket error + occurred */ + AMQP_STATUS_INVALID_PARAMETER = -0x000A, /**< An invalid parameter + was passed into the + function */ + AMQP_STATUS_TABLE_TOO_BIG = -0x000B, /**< The amqp_table_t object + cannot be serialized + because the output + buffer is too small */ + AMQP_STATUS_WRONG_METHOD = -0x000C, /**< The wrong method was + received */ + AMQP_STATUS_TIMEOUT = -0x000D, /**< Operation timed out */ + AMQP_STATUS_TIMER_FAILURE = -0x000E, /**< The underlying system + timer facility failed */ + AMQP_STATUS_HEARTBEAT_TIMEOUT = -0x000F, /**< Timed out waiting for + heartbeat */ + AMQP_STATUS_UNEXPECTED_STATE = -0x0010, /**< Unexpected protocol + state */ + AMQP_STATUS_SOCKET_CLOSED = -0x0011, /**< Underlying socket is + closed */ + AMQP_STATUS_SOCKET_INUSE = -0x0012, /**< Underlying socket is + already open */ AMQP_STATUS_BROKER_UNSUPPORTED_SASL_METHOD = -0x0013, /**< Broker does not support the requested SASL mechanism */ - _AMQP_STATUS_NEXT_VALUE = -0x0014, /**< Internal value */ - - AMQP_STATUS_TCP_ERROR = -0x0100, /**< A generic TCP error - occurred */ - AMQP_STATUS_TCP_SOCKETLIB_INIT_ERROR = -0x0101, /**< An error occurred trying - to initialize the - socket library*/ - _AMQP_STATUS_TCP_NEXT_VALUE = -0x0102, /**< Internal value */ - - AMQP_STATUS_SSL_ERROR = -0x0200, /**< A generic SSL error - occurred. */ - AMQP_STATUS_SSL_HOSTNAME_VERIFY_FAILED= -0x0201, /**< SSL validation of - hostname against - peer certificate - failed */ - AMQP_STATUS_SSL_PEER_VERIFY_FAILED = -0x0202, /**< SSL validation of peer - certificate failed. */ - AMQP_STATUS_SSL_CONNECTION_FAILED = -0x0203, /**< SSL handshake failed. */ - _AMQP_STATUS_SSL_NEXT_VALUE = -0x0204 /**< Internal value */ + AMQP_STATUS_UNSUPPORTED = -0x0014, /**< Parameter is unsupported + in this version */ + _AMQP_STATUS_NEXT_VALUE = -0x0015, /**< Internal value */ + + AMQP_STATUS_TCP_ERROR = -0x0100, /**< A generic TCP error + occurred */ + AMQP_STATUS_TCP_SOCKETLIB_INIT_ERROR = -0x0101, /**< An error occurred trying + to initialize the + socket library*/ + _AMQP_STATUS_TCP_NEXT_VALUE = -0x0102, /**< Internal value */ + + AMQP_STATUS_SSL_ERROR = -0x0200, /**< A generic SSL error + occurred. */ + AMQP_STATUS_SSL_HOSTNAME_VERIFY_FAILED = -0x0201, /**< SSL validation of + hostname against + peer certificate + failed */ + AMQP_STATUS_SSL_PEER_VERIFY_FAILED = -0x0202, /**< SSL validation of peer + certificate failed. */ + AMQP_STATUS_SSL_CONNECTION_FAILED = -0x0203, /**< SSL handshake failed. */ + _AMQP_STATUS_SSL_NEXT_VALUE = -0x0204 /**< Internal value */ } amqp_status_enum; /** @@ -754,8 +777,8 @@ * \since v0.5 */ typedef enum { - AMQP_DELIVERY_NONPERSISTENT = 1, /**< Non-persistent message */ - AMQP_DELIVERY_PERSISTENT = 2 /**< Persistent message */ + AMQP_DELIVERY_NONPERSISTENT = 1, /**< Non-persistent message */ + AMQP_DELIVERY_PERSISTENT = 2 /**< Persistent message */ } amqp_delivery_mode_enum; AMQP_END_DECLS @@ -843,8 +866,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL init_amqp_pool(amqp_pool_t *pool, size_t pagesize); +void AMQP_CALL init_amqp_pool(amqp_pool_t *pool, size_t pagesize); /** * Recycles an amqp_pool_t memory allocation pool @@ -867,8 +889,7 @@ * */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL recycle_amqp_pool(amqp_pool_t *pool); +void AMQP_CALL recycle_amqp_pool(amqp_pool_t *pool); /** * Empties an amqp memory pool @@ -880,8 +901,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL empty_amqp_pool(amqp_pool_t *pool); +void AMQP_CALL empty_amqp_pool(amqp_pool_t *pool); /** * Allocates a block of memory from an amqp_pool_t memory pool @@ -900,8 +920,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -void * -AMQP_CALL amqp_pool_alloc(amqp_pool_t *pool, size_t amount); +void *AMQP_CALL amqp_pool_alloc(amqp_pool_t *pool, size_t amount); /** * Allocates a block of memory from an amqp_pool_t to an amqp_bytes_t @@ -923,8 +942,8 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL amqp_pool_alloc_bytes(amqp_pool_t *pool, size_t amount, amqp_bytes_t *output); +void AMQP_CALL amqp_pool_alloc_bytes(amqp_pool_t *pool, size_t amount, + amqp_bytes_t *output); /** * Wraps a c string in an amqp_bytes_t @@ -945,8 +964,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_bytes_t -AMQP_CALL amqp_cstring_bytes(char const *cstr); +amqp_bytes_t AMQP_CALL amqp_cstring_bytes(char const *cstr); /** * Duplicates an amqp_bytes_t buffer. @@ -965,8 +983,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_bytes_t -AMQP_CALL amqp_bytes_malloc_dup(amqp_bytes_t src); +amqp_bytes_t AMQP_CALL amqp_bytes_malloc_dup(amqp_bytes_t src); /** * Allocates a amqp_bytes_t buffer @@ -983,8 +1000,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_bytes_t -AMQP_CALL amqp_bytes_malloc(size_t amount); +amqp_bytes_t AMQP_CALL amqp_bytes_malloc(size_t amount); /** * Frees an amqp_bytes_t buffer @@ -1001,8 +1017,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL amqp_bytes_free(amqp_bytes_t bytes); +void AMQP_CALL amqp_bytes_free(amqp_bytes_t bytes); /** * Allocate and initialize a new amqp_connection_state_t object @@ -1017,8 +1032,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_connection_state_t -AMQP_CALL amqp_new_connection(void); +amqp_connection_state_t AMQP_CALL amqp_new_connection(void); /** * Get the underlying socket descriptor for the connection @@ -1038,9 +1052,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_get_sockfd(amqp_connection_state_t state); - +int AMQP_CALL amqp_get_sockfd(amqp_connection_state_t state); /** * Deprecated, use amqp_tcp_socket_new() or amqp_ssl_socket_new() @@ -1059,12 +1071,8 @@ * * \since v0.1 */ -AMQP_DEPRECATED( - AMQP_PUBLIC_FUNCTION - void - AMQP_CALL amqp_set_sockfd(amqp_connection_state_t state, int sockfd) -); - +AMQP_DEPRECATED(AMQP_PUBLIC_FUNCTION void AMQP_CALL + amqp_set_sockfd(amqp_connection_state_t state, int sockfd)); /** * Tune client side parameters @@ -1099,11 +1107,9 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_tune_connection(amqp_connection_state_t state, - int channel_max, - int frame_max, - int heartbeat); +int AMQP_CALL amqp_tune_connection(amqp_connection_state_t state, + int channel_max, int frame_max, + int heartbeat); /** * Get the maximum number of channels the connection can handle @@ -1117,8 +1123,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_get_channel_max(amqp_connection_state_t state); +int AMQP_CALL amqp_get_channel_max(amqp_connection_state_t state); /** * Get the maximum size of an frame the connection can handle @@ -1132,8 +1137,7 @@ * \since v0.6 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_get_frame_max(amqp_connection_state_t state); +int AMQP_CALL amqp_get_frame_max(amqp_connection_state_t state); /** * Get the number of seconds between heartbeats of the connection @@ -1147,8 +1151,7 @@ * \since v0.6 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_get_heartbeat(amqp_connection_state_t state); +int AMQP_CALL amqp_get_heartbeat(amqp_connection_state_t state); /** * Destroys an amqp_connection_state_t object @@ -1168,8 +1171,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_destroy_connection(amqp_connection_state_t state); +int AMQP_CALL amqp_destroy_connection(amqp_connection_state_t state); /** * Process incoming data @@ -1194,13 +1196,14 @@ * amqp_frame_t struct. If there is enough data in received_data for a * complete frame, decoded_frame->frame_type will be set to something OTHER * than 0. decoded_frame may contain members pointing to memory owned by - * the state object. This memory can be recycled with amqp_maybe_release_buffers() - * or amqp_maybe_release_buffers_on_channel() + * the state object. This memory can be recycled with + * amqp_maybe_release_buffers() or amqp_maybe_release_buffers_on_channel(). * \return number of bytes consumed from received_data or 0 if a 0-length - * buffer was passed. A negative return value indicates failure. Possible errors: - * - AMQP_STATUS_NO_MEMORY failure in allocating memory. The library is likely in - * an indeterminate state making recovery unlikely. Client should note the error - * and terminate the application + * buffer was passed. A negative return value indicates failure. Possible + * errors: + * - AMQP_STATUS_NO_MEMORY failure in allocating memory. The library is likely + * in an indeterminate state making recovery unlikely. Client should note the + * error and terminate the application * - AMQP_STATUS_BAD_AMQP_DATA bad AMQP data was received. The connection * should be shutdown immediately * - AMQP_STATUS_UNKNOWN_METHOD: an unknown method was received from the @@ -1213,10 +1216,9 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_handle_input(amqp_connection_state_t state, - amqp_bytes_t received_data, - amqp_frame_t *decoded_frame); +int AMQP_CALL amqp_handle_input(amqp_connection_state_t state, + amqp_bytes_t received_data, + amqp_frame_t *decoded_frame); /** * Check to see if connection memory can be released @@ -1236,8 +1238,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_boolean_t -AMQP_CALL amqp_release_buffers_ok(amqp_connection_state_t state); +amqp_boolean_t AMQP_CALL amqp_release_buffers_ok(amqp_connection_state_t state); /** * Release amqp_connection_state_t owned memory @@ -1264,8 +1265,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL amqp_release_buffers(amqp_connection_state_t state); +void AMQP_CALL amqp_release_buffers(amqp_connection_state_t state); /** * Release amqp_connection_state_t owned memory @@ -1285,8 +1285,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL amqp_maybe_release_buffers(amqp_connection_state_t state); +void AMQP_CALL amqp_maybe_release_buffers(amqp_connection_state_t state); /** * Release amqp_connection_state_t owned memory related to a channel @@ -1309,9 +1308,8 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL amqp_maybe_release_buffers_on_channel(amqp_connection_state_t state, - amqp_channel_t channel); +void AMQP_CALL amqp_maybe_release_buffers_on_channel( + amqp_connection_state_t state, amqp_channel_t channel); /** * Send a frame to the broker @@ -1335,8 +1333,8 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_send_frame(amqp_connection_state_t state, amqp_frame_t const *frame); +int AMQP_CALL amqp_send_frame(amqp_connection_state_t state, + amqp_frame_t const *frame); /** * Compare two table entries @@ -1345,13 +1343,13 @@ * * \param [in] entry1 the entry on the left * \param [in] entry2 the entry on the right - * \return 0 if entries are equal, 0 < if left is greater, 0 > if right is greater + * \return 0 if entries are equal, 0 < if left is greater, 0 > if right is + * greater * * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_table_entry_cmp(void const *entry1, void const *entry2); +int AMQP_CALL amqp_table_entry_cmp(void const *entry1, void const *entry2); /** * Open a socket to a remote host @@ -1371,8 +1369,8 @@ * - AMQP_STATUS_TCP_SOCKETLIB_INIT_ERROR Initialization of underlying socket * library failed. * - AMQP_STATUS_HOSTNAME_RESOLUTION_FAILED hostname lookup failed. - * - AMQP_STATUS_SOCKET_ERROR a socket error occurred. errno or WSAGetLastError() - * may return more useful information. + * - AMQP_STATUS_SOCKET_ERROR a socket error occurred. errno or + * WSAGetLastError() may return more useful information. * * \note IPv6 support was added in v0.3 * @@ -1381,8 +1379,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_open_socket(char const *hostname, int portnumber); +int AMQP_CALL amqp_open_socket(char const *hostname, int portnumber); /** * Send initial AMQP header to the broker @@ -1406,8 +1403,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_send_header(amqp_connection_state_t state); +int AMQP_CALL amqp_send_header(amqp_connection_state_t state); /** * Checks to see if there are any incoming frames ready to be read @@ -1426,8 +1422,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_boolean_t -AMQP_CALL amqp_frames_enqueued(amqp_connection_state_t state); +amqp_boolean_t AMQP_CALL amqp_frames_enqueued(amqp_connection_state_t state); /** * Read a single amqp_frame_t @@ -1452,9 +1447,9 @@ * \param [out] decoded_frame the frame * \return AMQP_STATUS_OK on success, an amqp_status_enum value * is returned otherwise. Possible errors include: - * - AMQP_STATUS_NO_MEMORY failure in allocating memory. The library is likely in - * an indeterminate state making recovery unlikely. Client should note the error - * and terminate the application + * - AMQP_STATUS_NO_MEMORY failure in allocating memory. The library is likely + * in an indeterminate state making recovery unlikely. Client should note the + * error and terminate the application * - AMQP_STATUS_BAD_AMQP_DATA bad AMQP data was received. The connection * should be shutdown immediately * - AMQP_STATUS_UNKNOWN_METHOD: an unknown method was received from the @@ -1481,9 +1476,8 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_simple_wait_frame(amqp_connection_state_t state, - amqp_frame_t *decoded_frame); +int AMQP_CALL amqp_simple_wait_frame(amqp_connection_state_t state, + amqp_frame_t *decoded_frame); /** * Read a single amqp_frame_t with a timeout. @@ -1493,7 +1487,8 @@ * if the timeout is reached. The tv value is not modified by the function. * * If a 0 timeval is specified, the function behaves as if its non-blocking: it - * will test to see if a frame can be read from the broker, and return immediately. + * will test to see if a frame can be read from the broker, and return + * immediately. * * If NULL is passed in for tv, the function will behave like * amqp_simple_wait_frame() and block until a frame is received from the broker @@ -1505,13 +1500,14 @@ * amqp_frames_enqueued() function. * * The library has a socket read buffer. When there is data in an - * amqp_connection_state_t read buffer, amqp_simple_wait_frame_noblock() may return + * amqp_connection_state_t read buffer, amqp_simple_wait_frame_noblock() may + * return * an amqp_frame_t without entering a blocking read(). You can test to see if an * amqp_connection_state_t object has data in its read buffer by calling the * amqp_data_in_buffer() function. * - * \note This function does not return heartbeat frames. When enabled, heartbeating - * is handed internally internally by the library + * \note This function does not return heartbeat frames. When enabled, + * heartbeating is handed internally internally by the library. * * \param [in,out] state the connection object * \param [out] decoded_frame the frame @@ -1523,9 +1519,9 @@ * - AMQP_STATUS_TIMEOUT the timeout was reached while waiting for a frame * from the broker. * - AMQP_STATUS_INVALID_PARAMETER the tv parameter contains an invalid value. - * - AMQP_STATUS_NO_MEMORY failure in allocating memory. The library is likely in - * an indeterminate state making recovery unlikely. Client should note the error - * and terminate the application + * - AMQP_STATUS_NO_MEMORY failure in allocating memory. The library is likely + * in an indeterminate state making recovery unlikely. Client should note the + * error and terminate the application * - AMQP_STATUS_BAD_AMQP_DATA bad AMQP data was received. The connection * should be shutdown immediately * - AMQP_STATUS_UNKNOWN_METHOD: an unknown method was received from the @@ -1547,10 +1543,9 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_simple_wait_frame_noblock(amqp_connection_state_t state, - amqp_frame_t *decoded_frame, - struct timeval *tv); +int AMQP_CALL amqp_simple_wait_frame_noblock(amqp_connection_state_t state, + amqp_frame_t *decoded_frame, + struct timeval *tv); /** * Waits for a specific method from the broker @@ -1563,16 +1558,17 @@ * or expected_method the program will abort * * \param [in] state the connection object - * \param [in] expected_channel the channel that the method should be delivered on + * \param [in] expected_channel the channel that the method should be delivered + * on * \param [in] expected_method the method to wait for * \param [out] output the method * \returns AMQP_STATUS_OK on success. An amqp_status_enum value is returned * otherwise. Possible errors include: * - AMQP_STATUS_WRONG_METHOD a frame containing the wrong method, wrong frame * type or wrong channel was received. The connection is closed. - * - AMQP_STATUS_NO_MEMORY failure in allocating memory. The library is likely in - * an indeterminate state making recovery unlikely. Client should note the error - * and terminate the application + * - AMQP_STATUS_NO_MEMORY failure in allocating memory. The library is likely + * in an indeterminate state making recovery unlikely. Client should note the + * error and terminate the application * - AMQP_STATUS_BAD_AMQP_DATA bad AMQP data was received. The connection * should be shutdown immediately * - AMQP_STATUS_UNKNOWN_METHOD: an unknown method was received from the @@ -1593,11 +1589,10 @@ */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_simple_wait_method(amqp_connection_state_t state, - amqp_channel_t expected_channel, - amqp_method_number_t expected_method, - amqp_method_t *output); +int AMQP_CALL amqp_simple_wait_method(amqp_connection_state_t state, + amqp_channel_t expected_channel, + amqp_method_number_t expected_method, + amqp_method_t *output); /** * Sends a method to the broker @@ -1626,11 +1621,9 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_send_method(amqp_connection_state_t state, - amqp_channel_t channel, - amqp_method_number_t id, - void *decoded); +int AMQP_CALL amqp_send_method(amqp_connection_state_t state, + amqp_channel_t channel, amqp_method_number_t id, + void *decoded); /** * Sends a method to the broker and waits for a method response @@ -1665,12 +1658,10 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_rpc_reply_t -AMQP_CALL 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); +amqp_rpc_reply_t AMQP_CALL 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); /** * Sends a method to the broker and waits for a method response @@ -1687,12 +1678,11 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -void * -AMQP_CALL 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); +void *AMQP_CALL 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); /** * Get the last global amqp_rpc_reply @@ -1734,8 +1724,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_rpc_reply_t -AMQP_CALL amqp_get_rpc_reply(amqp_connection_state_t state); +amqp_rpc_reply_t AMQP_CALL amqp_get_rpc_reply(amqp_connection_state_t state); /** * Login to the broker @@ -1747,25 +1736,30 @@ * \param [in] vhost the virtual host to connect to on the broker. The default * on most brokers is "/" * \param [in] channel_max the limit for number of channels for the connection. - * 0 means no limit, and is a good default (AMQP_DEFAULT_MAX_CHANNELS) + * 0 means no limit, and is a good default + * (AMQP_DEFAULT_MAX_CHANNELS) * Note that the maximum number of channels the protocol supports * is 65535 (2^16, with the 0-channel reserved). The server can * set a lower channel_max and then the client will use the lowest * of the two * \param [in] frame_max the maximum size of an AMQP frame on the wire to * request of the broker for this connection. 4096 is the minimum - * size, 2^31-1 is the maximum, a good default is 131072 (128KB), or - * AMQP_DEFAULT_FRAME_SIZE + * size, 2^31-1 is the maximum, a good default is 131072 (128KB), + * or AMQP_DEFAULT_FRAME_SIZE * \param [in] heartbeat the number of seconds between heartbeat frames to * request of the broker. A value of 0 disables heartbeats. * Note rabbitmq-c only has partial support for heartbeats, as of * v0.4.0 they are only serviced during amqp_basic_publish() and * amqp_simple_wait_frame()/amqp_simple_wait_frame_noblock() * \param [in] sasl_method the SASL method to authenticate with the broker. - * followed by the authentication information. - * For AMQP_SASL_METHOD_PLAIN, the AMQP_SASL_METHOD_PLAIN - * should be followed by two arguments in this order: - * const char* username, and const char* password. + * followed by the authentication information. The following SASL + * methods are implemented: + * - AMQP_SASL_METHOD_PLAIN, the AMQP_SASL_METHOD_PLAIN argument + * should be followed by two arguments in this order: + * const char* username, and const char* password. + * - AMQP_SASL_METHOD_EXTERNAL, the AMQP_SASL_METHOD_EXTERNAL + * argument should be followed one argument: + * const char* identity. * \return amqp_rpc_reply_t indicating success or failure. * - r.reply_type == AMQP_RESPONSE_NORMAL. Login completed successfully * - r.reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION. In most cases errors @@ -1790,10 +1784,10 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_rpc_reply_t -AMQP_CALL amqp_login(amqp_connection_state_t state, char const *vhost, - int channel_max, int frame_max, int heartbeat, - amqp_sasl_method_enum sasl_method, ...); +amqp_rpc_reply_t AMQP_CALL amqp_login(amqp_connection_state_t state, + char const *vhost, int channel_max, + int frame_max, int heartbeat, + amqp_sasl_method_enum sasl_method, ...); /** * Login to the broker passing a properties table @@ -1805,16 +1799,18 @@ * \param [in] state the connection object * \param [in] vhost the virtual host to connect to on the broker. The default * on most brokers is "/" - * \param [in] channel_max the limit for the number of channels for the connection. - * 0 means no limit, and is a good default (AMQP_DEFAULT_MAX_CHANNELS) + * \param [in] channel_max the limit for the number of channels for the + * connection. + * 0 means no limit, and is a good default + * (AMQP_DEFAULT_MAX_CHANNELS) * Note that the maximum number of channels the protocol supports * is 65535 (2^16, with the 0-channel reserved). The server can * set a lower channel_max and then the client will use the lowest * of the two * \param [in] frame_max the maximum size of an AMQP frame ont he wire to * request of the broker for this connection. 4096 is the minimum - * size, 2^31-1 is the maximum, a good default is 131072 (128KB), or - * AMQP_DEFAULT_FRAME_SIZE + * size, 2^31-1 is the maximum, a good default is 131072 (128KB), + * or AMQP_DEFAULT_FRAME_SIZE * \param [in] heartbeat the number of seconds between heartbeat frame to * request of the broker. A value of 0 disables heartbeats. * Note rabbitmq-c only has partial support for hearts, as of @@ -1822,10 +1818,14 @@ * and amqp_simple_wait_frame()/amqp_simple_wait_frame_noblock() * \param [in] properties a table of properties to send the broker. * \param [in] sasl_method the SASL method to authenticate with the broker - * followed by the authentication information. - * For AMQP_SASL_METHOD_PLAN, the AMQP_SASL_METHOD_PLAIN parameter - * should be followed by two arguments in this order: - * const char* username, and const char* password. + * followed by the authentication information. The following SASL + * methods are implemented: + * - AMQP_SASL_METHOD_PLAIN, the AMQP_SASL_METHOD_PLAIN argument + * should be followed by two arguments in this order: + * const char* username, and const char* password. + * - AMQP_SASL_METHOD_EXTERNAL, the AMQP_SASL_METHOD_EXTERNAL + * argument should be followed one argument: + * const char* identity. * \return amqp_rpc_reply_t indicating success or failure. * - r.reply_type == AMQP_RESPONSE_NORMAL. Login completed successfully * - r.reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION. In most cases errors @@ -1850,10 +1850,10 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -amqp_rpc_reply_t -AMQP_CALL amqp_login_with_properties(amqp_connection_state_t state, char const *vhost, - int channel_max, int frame_max, int heartbeat, - const amqp_table_t *properties, amqp_sasl_method_enum sasl_method, ...); +amqp_rpc_reply_t AMQP_CALL amqp_login_with_properties( + amqp_connection_state_t state, char const *vhost, int channel_max, + int frame_max, int heartbeat, const amqp_table_t *properties, + amqp_sasl_method_enum sasl_method, ...); struct amqp_basic_properties_t_; @@ -1873,10 +1873,10 @@ * \param [in] routing_key the routing key to use when publishing the message * \param [in] mandatory indicate to the broker that the message MUST be routed * to a queue. If the broker cannot do this it should respond with - * a basic.reject method. - * \param [in] immediate indicate to the broker that the message MUST be delivered - * to a consumer immediately. If the broker cannot do this it should - * response with a basic.reject method. + * a basic.return method. + * \param [in] immediate indicate to the broker that the message MUST be + * delivered to a consumer immediately. If the broker cannot do this + * it should respond with a basic.return method. * \param [in] properties the properties associated with the message * \param [in] body the message body * \return AMQP_STATUS_OK on success, amqp_status_enum value on failure. Note @@ -1903,44 +1903,44 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_basic_publish(amqp_connection_state_t state, amqp_channel_t channel, - amqp_bytes_t exchange, amqp_bytes_t routing_key, - amqp_boolean_t mandatory, amqp_boolean_t immediate, - struct amqp_basic_properties_t_ const *properties, - amqp_bytes_t body); +int AMQP_CALL amqp_basic_publish( + amqp_connection_state_t state, amqp_channel_t channel, + amqp_bytes_t exchange, amqp_bytes_t routing_key, amqp_boolean_t mandatory, + amqp_boolean_t immediate, struct amqp_basic_properties_t_ const *properties, + amqp_bytes_t body); /** * Closes an channel * * \param [in] state the connection object * \param [in] channel the channel identifier - * \param [in] code the reason for closing the channel, AMQP_REPLY_SUCCESS is a good default + * \param [in] code the reason for closing the channel, AMQP_REPLY_SUCCESS is a + * good default * \return amqp_rpc_reply_t indicating success or failure * * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_rpc_reply_t -AMQP_CALL amqp_channel_close(amqp_connection_state_t state, amqp_channel_t channel, - int code); +amqp_rpc_reply_t AMQP_CALL amqp_channel_close(amqp_connection_state_t state, + amqp_channel_t channel, int code); /** * Closes the entire connection * * Implicitly closes all channels and informs the broker the connection - * is being closed, after receiving acknowldgement from the broker it closes + * is being closed, after receiving acknowledgment from the broker it closes * the socket. * * \param [in] state the connection object - * \param [in] code the reason code for closing the connection. AMQP_REPLY_SUCCESS is a good default. + * \param [in] code the reason code for closing the connection. + * AMQP_REPLY_SUCCESS is a good default. * \return amqp_rpc_reply_t indicating the result * * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_rpc_reply_t -AMQP_CALL amqp_connection_close(amqp_connection_state_t state, int code); +amqp_rpc_reply_t AMQP_CALL amqp_connection_close(amqp_connection_state_t state, + int code); /** * Acknowledges a message @@ -1953,14 +1953,15 @@ * \param [in] multiple if true, ack all messages up to this delivery tag, if * false ack only this delivery tag * \return 0 on success, 0 > on failing to send the ack to the broker. - * this will not indicate failure if something goes wrong on the broker + * this will not indicate failure if something goes wrong on the + * broker * * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_basic_ack(amqp_connection_state_t state, amqp_channel_t channel, - uint64_t delivery_tag, amqp_boolean_t multiple); +int AMQP_CALL amqp_basic_ack(amqp_connection_state_t state, + amqp_channel_t channel, uint64_t delivery_tag, + amqp_boolean_t multiple); /** * Do a basic.get @@ -1979,9 +1980,10 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_rpc_reply_t -AMQP_CALL amqp_basic_get(amqp_connection_state_t state, amqp_channel_t channel, - amqp_bytes_t queue, amqp_boolean_t no_ack); +amqp_rpc_reply_t AMQP_CALL amqp_basic_get(amqp_connection_state_t state, + amqp_channel_t channel, + amqp_bytes_t queue, + amqp_boolean_t no_ack); /** * Do a basic.reject @@ -1994,14 +1996,15 @@ * \param [in] requeue indicate to the broker whether it should requeue the * message or just discard it. * \return 0 on success, 0 > on failing to send the reject method to the broker. - * This will not indicate failure if something goes wrong on the broker. + * This will not indicate failure if something goes wrong on the + * broker. * * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_basic_reject(amqp_connection_state_t state, amqp_channel_t channel, - uint64_t delivery_tag, amqp_boolean_t requeue); +int AMQP_CALL amqp_basic_reject(amqp_connection_state_t state, + amqp_channel_t channel, uint64_t delivery_tag, + amqp_boolean_t requeue); /** * Do a basic.nack @@ -2023,10 +2026,9 @@ * \since v0.5.0 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_basic_nack(amqp_connection_state_t state, amqp_channel_t channel, - uint64_t delivery_tag, amqp_boolean_t multiple, - amqp_boolean_t requeue); +int AMQP_CALL amqp_basic_nack(amqp_connection_state_t state, + amqp_channel_t channel, uint64_t delivery_tag, + amqp_boolean_t multiple, amqp_boolean_t requeue); /** * Check to see if there is data left in the receive buffer * @@ -2040,8 +2042,7 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -amqp_boolean_t -AMQP_CALL amqp_data_in_buffer(amqp_connection_state_t state); +amqp_boolean_t AMQP_CALL amqp_data_in_buffer(amqp_connection_state_t state); /** * Get the error string for the given error code. @@ -2059,11 +2060,7 @@ * \since v0.1 */ AMQP_DEPRECATED( - AMQP_PUBLIC_FUNCTION - char * - AMQP_CALL amqp_error_string(int err) -); - + AMQP_PUBLIC_FUNCTION char *AMQP_CALL amqp_error_string(int err)); /** * Get the error string for the given error code. @@ -2077,9 +2074,7 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -const char * -AMQP_CALL amqp_error_string2(int err); - +const char *AMQP_CALL amqp_error_string2(int err); /** * Deserialize an amqp_table_t from AMQP wireformat @@ -2102,9 +2097,8 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_decode_table(amqp_bytes_t encoded, amqp_pool_t *pool, - amqp_table_t *output, size_t *offset); +int AMQP_CALL amqp_decode_table(amqp_bytes_t encoded, amqp_pool_t *pool, + amqp_table_t *output, size_t *offset); /** * Serializes an amqp_table_t to the AMQP wireformat @@ -2126,9 +2120,8 @@ * \since v0.1 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_encode_table(amqp_bytes_t encoded, amqp_table_t *input, size_t *offset); - +int AMQP_CALL amqp_encode_table(amqp_bytes_t encoded, amqp_table_t *input, + size_t *offset); /** * Create a deep-copy of an amqp_table_t object @@ -2149,8 +2142,8 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_table_clone(const amqp_table_t *original, amqp_table_t *clone, amqp_pool_t *pool); +int AMQP_CALL amqp_table_clone(const amqp_table_t *original, + amqp_table_t *clone, amqp_pool_t *pool); /** * A message object @@ -2177,15 +2170,16 @@ * fields in the message object. The caller is responsible for * allocating/destroying the amqp_message_t object itself. * \param [in] flags pass in 0. Currently unused. - * \returns a amqp_rpc_reply_t object. ret.reply_type == AMQP_RESPONSE_NORMAL on success. + * \returns a amqp_rpc_reply_t object. ret.reply_type == AMQP_RESPONSE_NORMAL on + * success. * * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -amqp_rpc_reply_t -AMQP_CALL amqp_read_message(amqp_connection_state_t state, - amqp_channel_t channel, - amqp_message_t *message, int flags); +amqp_rpc_reply_t AMQP_CALL amqp_read_message(amqp_connection_state_t state, + amqp_channel_t channel, + amqp_message_t *message, + int flags); /** * Frees memory associated with a amqp_message_t allocated in amqp_read_message @@ -2195,8 +2189,7 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL amqp_destroy_message(amqp_message_t *message); +void AMQP_CALL amqp_destroy_message(amqp_message_t *message); /** * Envelope object @@ -2204,13 +2197,16 @@ * \since v0.4.0 */ typedef struct amqp_envelope_t_ { - amqp_channel_t channel; /**< channel message was delivered on */ - amqp_bytes_t consumer_tag; /**< the consumer tag the message was delivered to */ - uint64_t delivery_tag; /**< the messages delivery tag */ - amqp_boolean_t redelivered; /**< flag indicating whether this message is being redelivered */ - amqp_bytes_t exchange; /**< exchange this message was published to */ - amqp_bytes_t routing_key; /**< the routing key this message was published with */ - amqp_message_t message; /**< the message */ + amqp_channel_t channel; /**< channel message was delivered on */ + amqp_bytes_t + consumer_tag; /**< the consumer tag the message was delivered to */ + uint64_t delivery_tag; /**< the messages delivery tag */ + amqp_boolean_t redelivered; /**< flag indicating whether this message is being + redelivered */ + amqp_bytes_t exchange; /**< exchange this message was published to */ + amqp_bytes_t + routing_key; /**< the routing key this message was published with */ + amqp_message_t message; /**< the message */ } amqp_envelope_t; /** @@ -2220,7 +2216,7 @@ * basic.deliver it reads that message, and returns. If any other method is * received before basic.deliver, this function will return an amqp_rpc_reply_t * with ret.reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION, and - * ret.library_error == AMQP_STATUS_UNEXPECTED_FRAME. The caller should then + * ret.library_error == AMQP_STATUS_UNEXPECTED_STATE. The caller should then * call amqp_simple_wait_frame() to read this frame and take appropriate action. * * This function should be used after starting a consumer with the @@ -2235,8 +2231,8 @@ * NULL will result in blocking behavior. * \param [in] flags pass in 0. Currently unused. * \returns a amqp_rpc_reply_t object. ret.reply_type == AMQP_RESPONSE_NORMAL - * on success. If ret.reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION, and - * ret.library_error == AMQP_STATUS_UNEXPECTED_FRAME, a frame other + * on success. If ret.reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION, + * and ret.library_error == AMQP_STATUS_UNEXPECTED_STATE, a frame other * than AMQP_BASIC_DELIVER_METHOD was received, the caller should call * amqp_simple_wait_frame() to read this frame and take appropriate * action. @@ -2244,22 +2240,21 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -amqp_rpc_reply_t -AMQP_CALL amqp_consume_message(amqp_connection_state_t state, - amqp_envelope_t *envelope, - struct timeval *timeout, int flags); +amqp_rpc_reply_t AMQP_CALL amqp_consume_message(amqp_connection_state_t state, + amqp_envelope_t *envelope, + struct timeval *timeout, + int flags); /** - * Frees memory associated with a amqp_envelope_t allocated in amqp_consume_message() + * Frees memory associated with a amqp_envelope_t allocated in + * amqp_consume_message() * * \param [in] envelope * * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL amqp_destroy_envelope(amqp_envelope_t *envelope); - +void AMQP_CALL amqp_destroy_envelope(amqp_envelope_t *envelope); /** * Parameters used to connect to the RabbitMQ broker @@ -2267,11 +2262,15 @@ * \since v0.2 */ struct amqp_connection_info { - char *user; /**< the username to authenticate with the broker, default on most broker is 'guest' */ - char *password; /**< the password to authenticate with the broker, default on most brokers is 'guest' */ - char *host; /**< the hostname of the broker */ - char *vhost; /**< the virtual host on the broker to connect to, a good default is "/" */ - int port; /**< the port that the broker is listening on, default on most brokers is 5672 */ + char *user; /**< the username to authenticate with the broker, default on most + broker is 'guest' */ + char *password; /**< the password to authenticate with the broker, default on + most brokers is 'guest' */ + char *host; /**< the hostname of the broker */ + char *vhost; /**< the virtual host on the broker to connect to, a good default + is "/" */ + int port; /**< the port that the broker is listening on, default on most + brokers is 5672 */ amqp_boolean_t ssl; }; @@ -2290,8 +2289,8 @@ * \since v0.2 */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL amqp_default_connection_info(struct amqp_connection_info *parsed); +void AMQP_CALL + amqp_default_connection_info(struct amqp_connection_info *parsed); /** * Parse a connection URL @@ -2304,6 +2303,10 @@ * amqp://guest:guest\@localhost:5672// * amqp://guest:guest\@localhost/myvhost * + * Any missing parts of the URL will be set to the defaults specified in + * amqp_default_connection_info. For amqps: URLs the default port will be set + * to 5671 instead of 5672 for non-SSL URLs. + * * \note This function modifies url parameter. * * \param [in] url URI to parse, note that this parameter is modified by the @@ -2316,8 +2319,7 @@ * \since v0.2 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL amqp_parse_url(char *url, struct amqp_connection_info *parsed); +int AMQP_CALL amqp_parse_url(char *url, struct amqp_connection_info *parsed); /* socket API */ @@ -2338,9 +2340,7 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL -amqp_socket_open(amqp_socket_t *self, const char *host, int port); +int AMQP_CALL amqp_socket_open(amqp_socket_t *self, const char *host, int port); /** * Open a socket connection. @@ -2353,16 +2353,16 @@ * \param [in,out] self A socket object. * \param [in] host Connect to this host. * \param [in] port Connect on this remote port. - * \param [in] timeout Max allowed time to spent on opening. If NULL - run in blocking mode + * \param [in] timeout Max allowed time to spent on opening. If NULL - run in + * blocking mode * * \return AMQP_STATUS_OK on success, an amqp_status_enum on failure. * * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL -amqp_socket_open_noblock(amqp_socket_t *self, const char *host, int port, struct timeval *timeout); +int AMQP_CALL amqp_socket_open_noblock(amqp_socket_t *self, const char *host, + int port, struct timeval *timeout); /** * Get the socket descriptor in use by a socket object. @@ -2373,16 +2373,13 @@ * * \param [in,out] self A socket object. * - * \return The underlying socket descriptor, or -1 if there is no socket descriptor - * associated with - * with + * \return The underlying socket descriptor, or -1 if there is no socket + * descriptor associated with * * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL -amqp_socket_get_sockfd(amqp_socket_t *self); +int AMQP_CALL amqp_socket_get_sockfd(amqp_socket_t *self); /** * Get the socket object associated with a amqp_connection_state_t @@ -2393,8 +2390,7 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -amqp_socket_t * -amqp_get_socket(amqp_connection_state_t state); +amqp_socket_t *AMQP_CALL amqp_get_socket(amqp_connection_state_t state); /** * Get the broker properties table @@ -2407,8 +2403,8 @@ * \since v0.5.0 */ AMQP_PUBLIC_FUNCTION -amqp_table_t * -amqp_get_server_properties(amqp_connection_state_t state); +amqp_table_t *AMQP_CALL + amqp_get_server_properties(amqp_connection_state_t state); /** * Get the client properties table @@ -2423,10 +2419,117 @@ * \since v0.7.0 */ AMQP_PUBLIC_FUNCTION -amqp_table_t * -amqp_get_client_properties(amqp_connection_state_t state); +amqp_table_t *AMQP_CALL + amqp_get_client_properties(amqp_connection_state_t state); -AMQP_END_DECLS +/** + * Get the login handshake timeout. + * + * amqp_login and amqp_login_with_properties perform the login handshake with + * the broker. This function returns the timeout associated with completing + * this operation from the client side. This value can be set by using the + * amqp_set_handshake_timeout. + * + * Note that the RabbitMQ broker has configurable timeout for completing the + * login handshake, the default is 10 seconds. rabbitmq-c has a default of 12 + * seconds. + * + * \param [in] state the connection object + * \return a struct timeval representing the current login timeout for the state + * object. A NULL value represents an infinite timeout. The memory returned is + * owned by the connection object. + * + * \since v0.9.0 + */ +AMQP_PUBLIC_FUNCTION +struct timeval *AMQP_CALL + amqp_get_handshake_timeout(amqp_connection_state_t state); + +/** + * Set the login handshake timeout. + * + * amqp_login and amqp_login_with_properties perform the login handshake with + * the broker. This function sets the timeout associated with completing this + * operation from the client side. + * + * The timeout must be set before amqp_login or amqp_login_with_properties is + * called to change from the default timeout. + * + * Note that the RabbitMQ broker has a configurable timeout for completing the + * login handshake, the default is 10 seconds. rabbitmq-c has a default of 12 + * seconds. + * + * \param [in] state the connection object + * \param [in] timeout a struct timeval* representing new login timeout for the + * state object. NULL represents an infinite timeout. The value of timeout is + * copied internally, the caller is responsible for ownership of the passed in + * pointer, it does not need to remain valid after this function is called. + * \return AMQP_STATUS_OK on success. + * + * \since v0.9.0 + */ +AMQP_PUBLIC_FUNCTION +int AMQP_CALL amqp_set_handshake_timeout(amqp_connection_state_t state, + struct timeval *timeout); +/** + * Get the RPC timeout + * + * Gets the timeout for any RPC-style AMQP command (e.g., amqp_queue_declare). + * This timeout may be changed at any time by calling \amqp_set_rpc_timeout + * function with a new timeout. The timeout applies individually to each RPC + * that is made. + * + * The default value is NULL, or an infinite timeout. + * + * When an RPC times out, the function will return an error AMQP_STATUS_TIMEOUT, + * and the connection will be closed. + * + *\warning RPC-timeouts are an advanced feature intended to be used to detect + * dead connections quickly when the rabbitmq-c implementation of heartbeats + * does not work. Do not use RPC timeouts unless you understand the implications + * of doing so. + * + * \param [in] state the connection object + * \return a struct timeval representing the current RPC timeout for the state + * object. A NULL value represents an infinite timeout. The memory returned is + * owned by the connection object. + * + * \since v0.9.0 + */ +AMQP_PUBLIC_FUNCTION +struct timeval *AMQP_CALL amqp_get_rpc_timeout(amqp_connection_state_t state); + +/** + * Set the RPC timeout + * + * Sets the timeout for any RPC-style AMQP command (e.g., amqp_queue_declare). + * This timeout may be changed at any time by calling this function with a new + * timeout. The timeout applies individually to each RPC that is made. + * + * The default value is NULL, or an infinite timeout. + * + * When an RPC times out, the function will return an error AMQP_STATUS_TIMEOUT, + * and the connection will be closed. + * + *\warning RPC-timeouts are an advanced feature intended to be used to detect + * dead connections quickly when the rabbitmq-c implementation of heartbeats + * does not work. Do not use RPC timeouts unless you understand the implications + * of doing so. + * + * \param [in] state the connection object + * \param [in] timeout a struct timeval* representing new RPC timeout for the + * state object. NULL represents an infinite timeout. The value of timeout is + * copied internally, the caller is responsible for ownership of the passed + * pointer, it does not need to remain valid after this function is called. + * \return AMQP_STATUS_SUCCESS on success. + * + * \since v0.9.0 + */ +AMQP_PUBLIC_FUNCTION +int AMQP_CALL amqp_set_rpc_timeout(amqp_connection_state_t state, + struct timeval *timeout); + +AMQP_END_DECLS #endif /* AMQP_H */ diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_hostcheck.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_hostcheck.c --- librabbitmq-0.7.1/librabbitmq/amqp_hostcheck.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_hostcheck.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * Copyright 1996-2014 Daniel Stenberg . * Copyright 2014 Michael Steinert @@ -23,7 +22,7 @@ * copyright holder. */ -#include "amqp_private.h" +#include "amqp_hostcheck.h" #include @@ -31,62 +30,60 @@ * because its behavior is altered by the current locale. */ -static char -amqp_raw_toupper(char in) -{ +static char amqp_raw_toupper(char in) { switch (in) { - case 'a': - return 'A'; - case 'b': - return 'B'; - case 'c': - return 'C'; - case 'd': - return 'D'; - case 'e': - return 'E'; - case 'f': - return 'F'; - case 'g': - return 'G'; - case 'h': - return 'H'; - case 'i': - return 'I'; - case 'j': - return 'J'; - case 'k': - return 'K'; - case 'l': - return 'L'; - case 'm': - return 'M'; - case 'n': - return 'N'; - case 'o': - return 'O'; - case 'p': - return 'P'; - case 'q': - return 'Q'; - case 'r': - return 'R'; - case 's': - return 'S'; - case 't': - return 'T'; - case 'u': - return 'U'; - case 'v': - return 'V'; - case 'w': - return 'W'; - case 'x': - return 'X'; - case 'y': - return 'Y'; - case 'z': - return 'Z'; + case 'a': + return 'A'; + case 'b': + return 'B'; + case 'c': + return 'C'; + case 'd': + return 'D'; + case 'e': + return 'E'; + case 'f': + return 'F'; + case 'g': + return 'G'; + case 'h': + return 'H'; + case 'i': + return 'I'; + case 'j': + return 'J'; + case 'k': + return 'K'; + case 'l': + return 'L'; + case 'm': + return 'M'; + case 'n': + return 'N'; + case 'o': + return 'O'; + case 'p': + return 'P'; + case 'q': + return 'Q'; + case 'r': + return 'R'; + case 's': + return 'S'; + case 't': + return 'T'; + case 'u': + return 'U'; + case 'v': + return 'V'; + case 'w': + return 'W'; + case 'x': + return 'X'; + case 'y': + return 'Y'; + case 'z': + return 'Z'; } return in; } @@ -101,9 +98,7 @@ * non-ascii. */ -static int -amqp_raw_equal(const char *first, const char *second) -{ +static int amqp_raw_equal(const char *first, const char *second) { while (*first && *second) { if (amqp_raw_toupper(*first) != amqp_raw_toupper(*second)) { /* get out of the loop as soon as they don't match */ @@ -119,9 +114,7 @@ return (amqp_raw_toupper(*first) == amqp_raw_toupper(*second)); } -static int -amqp_raw_nequal(const char *first, const char *second, size_t max) -{ +static int amqp_raw_nequal(const char *first, const char *second, size_t max) { while (*first && *second && max) { if (amqp_raw_toupper(*first) != amqp_raw_toupper(*second)) { break; @@ -145,57 +138,58 @@ * http://tools.ietf.org/html/rfc6125#section-6.4.3 */ -static int -amqp_hostmatch(const char *hostname, const char *pattern) -{ +static amqp_hostcheck_result amqp_hostmatch(const char *hostname, + const char *pattern) { const char *pattern_label_end, *pattern_wildcard, *hostname_label_end; int wildcard_enabled; size_t prefixlen, suffixlen; pattern_wildcard = strchr(pattern, '*'); if (pattern_wildcard == NULL) { - return amqp_raw_equal(pattern, hostname) ? 1 : 0; + return amqp_raw_equal(pattern, hostname) ? AMQP_HCR_MATCH + : AMQP_HCR_NO_MATCH; } /* We require at least 2 dots in pattern to avoid too wide wildcard match. */ wildcard_enabled = 1; pattern_label_end = strchr(pattern, '.'); - if (pattern_label_end == NULL || - strchr(pattern_label_end + 1, '.') == NULL || + if (pattern_label_end == NULL || strchr(pattern_label_end + 1, '.') == NULL || pattern_wildcard > pattern_label_end || amqp_raw_nequal(pattern, "xn--", 4)) { wildcard_enabled = 0; } if (!wildcard_enabled) { - return amqp_raw_equal(pattern, hostname) ? 1 : 0; + return amqp_raw_equal(pattern, hostname) ? AMQP_HCR_MATCH + : AMQP_HCR_NO_MATCH; } hostname_label_end = strchr(hostname, '.'); if (hostname_label_end == NULL || !amqp_raw_equal(pattern_label_end, hostname_label_end)) { - return 0; + return AMQP_HCR_NO_MATCH; } /* The wildcard must match at least one character, so the left-most * label of the hostname is at least as large as the left-most label * of the pattern. */ if (hostname_label_end - hostname < pattern_label_end - pattern) { - return 0; + return AMQP_HCR_NO_MATCH; } prefixlen = pattern_wildcard - pattern; suffixlen = pattern_label_end - (pattern_wildcard + 1); return amqp_raw_nequal(pattern, hostname, prefixlen) && - amqp_raw_nequal(pattern_wildcard + 1, hostname_label_end - suffixlen, - suffixlen) ? 1 : 0; + amqp_raw_nequal(pattern_wildcard + 1, + hostname_label_end - suffixlen, suffixlen) + ? AMQP_HCR_MATCH + : AMQP_HCR_NO_MATCH; } -int -amqp_hostcheck(const char *match_pattern, const char *hostname) -{ +amqp_hostcheck_result amqp_hostcheck(const char *match_pattern, + const char *hostname) { /* sanity check */ if (!match_pattern || !*match_pattern || !hostname || !*hostname) { - return 0; + return AMQP_HCR_NO_MATCH; } /* trivial case */ if (amqp_raw_equal(hostname, match_pattern)) { - return 1; + return AMQP_HCR_MATCH; } return amqp_hostmatch(hostname, match_pattern); } diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_hostcheck.h librabbitmq-0.9.0-0.1/librabbitmq/amqp_hostcheck.h --- librabbitmq-0.7.1/librabbitmq/amqp_hostcheck.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_hostcheck.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ #ifndef librabbitmq_amqp_hostcheck_h #define librabbitmq_amqp_hostcheck_h @@ -26,11 +25,24 @@ * copyright holder. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +typedef enum { + AMQP_HCR_NO_MATCH = 0, + AMQP_HCR_MATCH = 1 +} amqp_hostcheck_result; -int -amqp_hostcheck(const char *match_pattern, const char *hostname); +/** + * Determine whether hostname matches match_pattern. + * + * match_pattern may include wildcards. + * + * Match is performed based on the rules set forth in RFC6125 section 6.4.3. + * http://tools.ietf.org/html/rfc6125#section-6.4.3 + * + * \param match_pattern RFC6125 compliant pattern + * \param hostname to match against + * \returns AMQP_HCR_MATCH if its a match, AMQP_HCR_NO_MATCH otherwise. + */ +amqp_hostcheck_result amqp_hostcheck(const char *match_pattern, + const char *hostname); #endif diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_mem.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_mem.c --- librabbitmq-0.7.1/librabbitmq/amqp_mem.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_mem.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -46,18 +45,11 @@ #include #include -char const *amqp_version(void) -{ - return AMQP_VERSION_STRING; -} +char const *amqp_version(void) { return AMQP_VERSION_STRING; } -uint32_t amqp_version_number(void) -{ - return AMQP_VERSION; -} +uint32_t amqp_version_number(void) { return AMQP_VERSION; } -void init_amqp_pool(amqp_pool_t *pool, size_t pagesize) -{ +void init_amqp_pool(amqp_pool_t *pool, size_t pagesize) { pool->pagesize = pagesize ? pagesize : 4096; pool->pages.num_blocks = 0; @@ -71,37 +63,33 @@ pool->alloc_used = 0; } -static void empty_blocklist(amqp_pool_blocklist_t *x) -{ +static void empty_blocklist(amqp_pool_blocklist_t *x) { int i; - for (i = 0; i < x->num_blocks; i++) { - free(x->blocklist[i]); - } if (x->blocklist != NULL) { + for (i = 0; i < x->num_blocks; i++) { + free(x->blocklist[i]); + } free(x->blocklist); } x->num_blocks = 0; x->blocklist = NULL; } -void recycle_amqp_pool(amqp_pool_t *pool) -{ +void recycle_amqp_pool(amqp_pool_t *pool) { empty_blocklist(&pool->large_blocks); pool->next_page = 0; pool->alloc_block = NULL; pool->alloc_used = 0; } -void empty_amqp_pool(amqp_pool_t *pool) -{ +void empty_amqp_pool(amqp_pool_t *pool) { recycle_amqp_pool(pool); empty_blocklist(&pool->pages); } /* Returns 1 on success, 0 on failure */ -static int record_pool_block(amqp_pool_blocklist_t *x, void *block) -{ +static int record_pool_block(amqp_pool_blocklist_t *x, void *block) { size_t blocklistlength = sizeof(void *) * (x->num_blocks + 1); if (x->blocklist == NULL) { @@ -122,8 +110,7 @@ return 1; } -void *amqp_pool_alloc(amqp_pool_t *pool, size_t amount) -{ +void *amqp_pool_alloc(amqp_pool_t *pool, size_t amount) { if (amount == 0) { return NULL; } @@ -136,6 +123,7 @@ return NULL; } if (!record_pool_block(&pool->large_blocks, result)) { + free(result); return NULL; } return result; @@ -170,22 +158,20 @@ return pool->alloc_block; } -void amqp_pool_alloc_bytes(amqp_pool_t *pool, size_t amount, amqp_bytes_t *output) -{ +void amqp_pool_alloc_bytes(amqp_pool_t *pool, size_t amount, + amqp_bytes_t *output) { output->len = amount; output->bytes = amqp_pool_alloc(pool, amount); } -amqp_bytes_t amqp_cstring_bytes(char const *cstr) -{ +amqp_bytes_t amqp_cstring_bytes(char const *cstr) { amqp_bytes_t result; result.len = strlen(cstr); - result.bytes = (void *) cstr; + result.bytes = (void *)cstr; return result; } -amqp_bytes_t amqp_bytes_malloc_dup(amqp_bytes_t src) -{ +amqp_bytes_t amqp_bytes_malloc_dup(amqp_bytes_t src) { amqp_bytes_t result; result.len = src.len; result.bytes = malloc(src.len); @@ -195,27 +181,23 @@ return result; } -amqp_bytes_t amqp_bytes_malloc(size_t amount) -{ +amqp_bytes_t amqp_bytes_malloc(size_t amount) { amqp_bytes_t result; result.len = amount; result.bytes = malloc(amount); /* will return NULL if it fails */ return result; } -void amqp_bytes_free(amqp_bytes_t bytes) -{ - free(bytes.bytes); -} +void amqp_bytes_free(amqp_bytes_t bytes) { free(bytes.bytes); } -amqp_pool_t *amqp_get_or_create_channel_pool(amqp_connection_state_t state, amqp_channel_t channel) -{ +amqp_pool_t *amqp_get_or_create_channel_pool(amqp_connection_state_t state, + amqp_channel_t channel) { amqp_pool_table_entry_t *entry; size_t index = channel % POOL_TABLE_SIZE; entry = state->pool_table[index]; - for ( ; NULL != entry; entry = entry->next) { + for (; NULL != entry; entry = entry->next) { if (channel == entry->channel) { return &entry->pool; } @@ -235,14 +217,14 @@ return &entry->pool; } -amqp_pool_t *amqp_get_channel_pool(amqp_connection_state_t state, amqp_channel_t channel) -{ +amqp_pool_t *amqp_get_channel_pool(amqp_connection_state_t state, + amqp_channel_t channel) { amqp_pool_table_entry_t *entry; size_t index = channel % POOL_TABLE_SIZE; entry = state->pool_table[index]; - for ( ; NULL != entry; entry = entry->next) { + for (; NULL != entry; entry = entry->next) { if (channel == entry->channel) { return &entry->pool; } diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_openssl_bio.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_openssl_bio.c --- librabbitmq-0.7.1/librabbitmq/amqp_openssl_bio.c 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_openssl_bio.c 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1,193 @@ +/* + * Portions created by Alan Antonuk are Copyright (c) 2017 Alan Antonuk. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "amqp_openssl_bio.h" +#include "amqp_socket.h" + +#include +#include +#if ((defined(_WIN32)) || (defined(__MINGW32__)) || (defined(__MINGW64__))) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#else +#include +#include +#endif + +#ifdef MSG_NOSIGNAL +#define AMQP_USE_AMQP_BIO +#endif + +static int amqp_ssl_bio_initialized = 0; + +#ifdef AMQP_USE_AMQP_BIO + +static BIO_METHOD *amqp_bio_method; + +static int amqp_openssl_bio_should_retry(int res) { + if (res == -1) { + int err = amqp_os_socket_error(); + if ( +#ifdef EWOULDBLOCK + err == EWOULDBLOCK || +#endif +#ifdef WSAEWOULDBLOCK + err == WSAEWOULDBLOCK || +#endif +#ifdef ENOTCONN + err == ENOTCONN || +#endif +#ifdef EINTR + err == EINTR || +#endif +#ifdef EAGAIN + err == EAGAIN || +#endif +#ifdef EPROTO + err == EPROTO || +#endif +#ifdef EINPROGRESS + err == EINPROGRESS || +#endif +#ifdef EALREADY + err == EALREADY || +#endif + 0) { + return 1; + } + } + return 0; +} + +static int amqp_openssl_bio_write(BIO *b, const char *in, int inl) { + int flags = 0; + int fd; + int res; + +#ifdef MSG_NOSIGNAL + flags |= MSG_NOSIGNAL; +#endif + + BIO_get_fd(b, &fd); + res = send(fd, in, inl, flags); + + BIO_clear_retry_flags(b); + if (res <= 0 && amqp_openssl_bio_should_retry(res)) { + BIO_set_retry_write(b); + } + + return res; +} + +static int amqp_openssl_bio_read(BIO *b, char *out, int outl) { + int flags = 0; + int fd; + int res; + +#ifdef MSG_NOSIGNAL + flags |= MSG_NOSIGNAL; +#endif + + BIO_get_fd(b, &fd); + res = recv(fd, out, outl, flags); + + BIO_clear_retry_flags(b); + if (res <= 0 && amqp_openssl_bio_should_retry(res)) { + BIO_set_retry_read(b); + } + + return res; +} + +#ifndef AMQP_OPENSSL_V110 +static int BIO_meth_set_write(BIO_METHOD *biom, + int (*wfn)(BIO *, const char *, int)) { + biom->bwrite = wfn; + return 0; +} + +static int BIO_meth_set_read(BIO_METHOD *biom, int (*rfn)(BIO *, char *, int)) { + biom->bread = rfn; + return 0; +} +#endif /* AQP_OPENSSL_V110 */ +#endif /* AMQP_USE_AMQP_BIO */ + +int amqp_openssl_bio_init(void) { + assert(!amqp_ssl_bio_initialized); +#ifdef AMQP_USE_AMQP_BIO +#ifdef AMQP_OPENSSL_V110 + if (!(amqp_bio_method = BIO_meth_new(BIO_TYPE_SOCKET, "amqp_bio_method"))) { + return AMQP_STATUS_NO_MEMORY; + } + + // casting away const is necessary until + // https://github.com/openssl/openssl/pull/2181/, which is targeted for + // openssl 1.1.1 + BIO_METHOD *meth = (BIO_METHOD *)BIO_s_socket(); + BIO_meth_set_create(amqp_bio_method, BIO_meth_get_create(meth)); + BIO_meth_set_destroy(amqp_bio_method, BIO_meth_get_destroy(meth)); + BIO_meth_set_ctrl(amqp_bio_method, BIO_meth_get_ctrl(meth)); + BIO_meth_set_callback_ctrl(amqp_bio_method, BIO_meth_get_callback_ctrl(meth)); + BIO_meth_set_read(amqp_bio_method, BIO_meth_get_read(meth)); + BIO_meth_set_write(amqp_bio_method, BIO_meth_get_write(meth)); + BIO_meth_set_gets(amqp_bio_method, BIO_meth_get_gets(meth)); + BIO_meth_set_puts(amqp_bio_method, BIO_meth_get_puts(meth)); +#else + if (!(amqp_bio_method = OPENSSL_malloc(sizeof(BIO_METHOD)))) { + return AMQP_STATUS_NO_MEMORY; + } + + memcpy(amqp_bio_method, BIO_s_socket(), sizeof(BIO_METHOD)); +#endif + BIO_meth_set_write(amqp_bio_method, amqp_openssl_bio_write); + BIO_meth_set_read(amqp_bio_method, amqp_openssl_bio_read); +#endif + + amqp_ssl_bio_initialized = 1; + return AMQP_STATUS_OK; +} + +void amqp_openssl_bio_destroy(void) { + assert(amqp_ssl_bio_initialized); +#ifdef AMQP_USE_AMQP_BIO +#ifdef AMQP_OPENSSL_V110 + BIO_meth_free(amqp_bio_method); +#else + OPENSSL_free(amqp_bio_method); +#endif + amqp_bio_method = NULL; +#endif + amqp_ssl_bio_initialized = 0; +} + +BIO_METHOD_PTR amqp_openssl_bio(void) { + assert(amqp_ssl_bio_initialized); +#ifdef AMQP_USE_AMQP_BIO + return amqp_bio_method; +#else + return BIO_s_socket(); +#endif +} diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_openssl_bio.h librabbitmq-0.9.0-0.1/librabbitmq/amqp_openssl_bio.h --- librabbitmq-0.7.1/librabbitmq/amqp_openssl_bio.h 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_openssl_bio.h 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1,44 @@ +/* + * Portions created by Alan Antonuk are Copyright (c) 2017 Alan Antonuk. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#ifndef AMQP_OPENSSL_BIO +#define AMQP_OPENSSL_BIO + +#include + +int amqp_openssl_bio_init(void); + +void amqp_openssl_bio_destroy(void); + +#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) +#define AMQP_OPENSSL_V110 +#endif + +#ifdef AMQP_OPENSSL_V110 +typedef const BIO_METHOD *BIO_METHOD_PTR; +#else +typedef BIO_METHOD *BIO_METHOD_PTR; +#endif + +BIO_METHOD_PTR amqp_openssl_bio(void); + +#endif /* ifndef AMQP_OPENSSL_BIO */ diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_openssl.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_openssl.c --- librabbitmq-0.7.1/librabbitmq/amqp_openssl.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_openssl.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * Portions created by Alan Antonuk are Copyright (c) 2012-2014 Alan Antonuk. * All Rights Reserved. @@ -29,65 +28,77 @@ #include "config.h" #endif -#include "amqp_ssl_socket.h" -#include "amqp_socket.h" -#include "amqp_hostcheck.h" +#include "amqp_openssl_bio.h" +#include "amqp_openssl_hostname_validation.h" #include "amqp_private.h" +#include "amqp_socket.h" +#include "amqp_ssl_socket.h" #include "amqp_time.h" #include "threads.h" #include +#include +#include #include +#include #include #include #include #include #include +static int initialize_ssl_and_increment_connections(void); +static int decrement_ssl_connections(void); -static int initialize_openssl(void); -static int destroy_openssl(void); +static unsigned long ssl_threadid_callback(void); +static void ssl_locking_callback(int mode, int n, const char *file, int line); +static pthread_mutex_t *amqp_openssl_lockarray = NULL; -static int open_ssl_connections = 0; +static pthread_mutex_t openssl_init_mutex = PTHREAD_MUTEX_INITIALIZER; static amqp_boolean_t do_initialize_openssl = 1; static amqp_boolean_t openssl_initialized = 0; +static amqp_boolean_t openssl_bio_initialized = 0; +static int openssl_connections = 0; -#ifdef ENABLE_THREAD_SAFETY -static unsigned long amqp_ssl_threadid_callback(void); -static void amqp_ssl_locking_callback(int mode, int n, const char *file, int line); - -#ifdef _WIN32 -static long win32_create_mutex = 0; -static pthread_mutex_t openssl_init_mutex = NULL; -#else -static pthread_mutex_t openssl_init_mutex = PTHREAD_MUTEX_INITIALIZER; -#endif -static pthread_mutex_t *amqp_openssl_lockarray = NULL; -#endif /* ENABLE_THREAD_SAFETY */ +#define CHECK_SUCCESS(condition) \ + do { \ + int check_success_ret = (condition); \ + if (check_success_ret) { \ + amqp_abort("Check %s failed <%d>: %s", #condition, check_success_ret, \ + strerror(check_success_ret)); \ + } \ + } while (0) struct amqp_ssl_socket_t { const struct amqp_socket_class_t *klass; SSL_CTX *ctx; int sockfd; SSL *ssl; - amqp_boolean_t verify; + amqp_boolean_t verify_peer; + amqp_boolean_t verify_hostname; int internal_error; }; static ssize_t amqp_ssl_socket_send(void *base, const void *buf, size_t len, AMQP_UNUSED int flags) { struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - ssize_t res; + int res; if (-1 == self->sockfd) { return AMQP_STATUS_SOCKET_CLOSED; } + /* SSL_write takes an int for length of buffer, protect against len being + * larger than larger than what SSL_write can take */ + if (len > INT_MAX) { + return AMQP_STATUS_INVALID_PARAMETER; + } + ERR_clear_error(); self->internal_error = 0; /* This will only return on error, or once the whole buffer has been * written to the SSL stream. See SSL_MODE_ENABLE_PARTIAL_WRITE */ - res = SSL_write(self->ssl, buf, len); + res = SSL_write(self->ssl, buf, (int)len); if (0 >= res) { self->internal_error = SSL_get_error(self->ssl, res); /* TODO: Close connection if it isn't already? */ @@ -110,156 +121,56 @@ self->internal_error = 0; } - return res; + return (ssize_t)res; } -static ssize_t -amqp_ssl_socket_recv(void *base, - void *buf, - size_t len, - AMQP_UNUSED int flags) -{ +static ssize_t amqp_ssl_socket_recv(void *base, void *buf, size_t len, + AMQP_UNUSED int flags) { struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - ssize_t received; + int received; if (-1 == self->sockfd) { return AMQP_STATUS_SOCKET_CLOSED; } + + /* SSL_read takes an int for length of buffer, protect against len being + * larger than larger than what SSL_read can take */ + if (len > INT_MAX) { + return AMQP_STATUS_INVALID_PARAMETER; + } + ERR_clear_error(); self->internal_error = 0; - received = SSL_read(self->ssl, buf, len); + received = SSL_read(self->ssl, buf, (int)len); if (0 >= received) { self->internal_error = SSL_get_error(self->ssl, received); switch (self->internal_error) { - case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_READ: received = AMQP_PRIVATE_STATUS_SOCKET_NEEDREAD; break; - case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_WRITE: received = AMQP_PRIVATE_STATUS_SOCKET_NEEDWRITE; break; - case SSL_ERROR_ZERO_RETURN: - received = AMQP_STATUS_CONNECTION_CLOSED; - break; - default: - received = AMQP_STATUS_SSL_ERROR; - break; - } - } - - return received; -} - -static int match(ASN1_STRING *entry_string, const char *string) -{ - unsigned char *utf8_value = NULL, *cp, ch; - int utf8_length, status = 1; - utf8_length = ASN1_STRING_to_UTF8(&utf8_value, entry_string); - if (0 > utf8_length) { - goto error; - } - while (utf8_length > 0 && utf8_value[utf8_length - 1] == 0) { - --utf8_length; - } - if (utf8_length >= 256) { - goto error; - } - if ((size_t)utf8_length != strlen((char *)utf8_value)) { - goto error; - } - for (cp = utf8_value; (ch = *cp) != '\0'; ++cp) { - if (isascii(ch) && !isprint(ch)) { - goto error; - } - } - if (!amqp_hostcheck((char *)utf8_value, string)) { - goto error; - } -exit: - OPENSSL_free(utf8_value); - return status; -error: - status = 0; - goto exit; -} - -/* Does this hostname match an entry in the subjectAltName extension? - * returns: 0 if no, 1 if yes, -1 if no subjectAltName entries were found. - */ -static int hostname_matches_subject_alt_name(const char *hostname, X509 *cert) -{ - int found_any_entries = 0; - int found_match; - GENERAL_NAME *namePart = NULL; - STACK_OF(GENERAL_NAME) *san = - (STACK_OF(GENERAL_NAME)*) X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL); - - while (sk_GENERAL_NAME_num(san) > 0) - { - namePart = sk_GENERAL_NAME_pop(san); - - if (namePart->type == GEN_DNS) { - found_any_entries = 1; - found_match = match(namePart->d.uniformResourceIdentifier, hostname); - if (found_match) - return 1; + case SSL_ERROR_ZERO_RETURN: + received = AMQP_STATUS_CONNECTION_CLOSED; + break; + default: + received = AMQP_STATUS_SSL_ERROR; + break; } } - return (found_any_entries ? 0 : -1); -} - -static int hostname_matches_subject_common_name(const char *hostname, X509 *cert) -{ - X509_NAME *name; - X509_NAME_ENTRY *name_entry; - int position; - ASN1_STRING *entry_string; - - name = X509_get_subject_name(cert); - position = -1; - for (;;) { - position = X509_NAME_get_index_by_NID(name, NID_commonName, position); - if (position == -1) - break; - name_entry = X509_NAME_get_entry(name, position); - entry_string = X509_NAME_ENTRY_get_data(name_entry); - if (match(entry_string, hostname)) - return 1; - } - return 0; -} - -static int -amqp_ssl_socket_verify_hostname(void *base, const char *host) -{ - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - int status = 0; - X509 *cert; - int res; - cert = SSL_get_peer_certificate(self->ssl); - if (!cert) { - goto error; - } - res = hostname_matches_subject_alt_name(host, cert); - if (res != 1) { - res = hostname_matches_subject_common_name(host, cert); - if (!res) - goto error; - } -exit: - return status; -error: - status = -1; - goto exit; + return (ssize_t)received; } -static int -amqp_ssl_socket_open(void *base, const char *host, int port, struct timeval *timeout) -{ +static int amqp_ssl_socket_open(void *base, const char *host, int port, + struct timeval *timeout) { struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; long result; int status; amqp_time_t deadline; + X509 *cert; + BIO *bio; if (-1 != self->sockfd) { return AMQP_STATUS_SOCKET_INUSE; } @@ -285,7 +196,16 @@ goto error_out1; } - status = SSL_set_fd(self->ssl, self->sockfd); + bio = BIO_new(amqp_openssl_bio()); + if (!bio) { + status = AMQP_STATUS_NO_MEMORY; + goto error_out2; + } + + BIO_set_fd(bio, self->sockfd, BIO_NOCLOSE); + SSL_set_bio(self->ssl, bio, bio); + + status = SSL_set_tlsext_host_name(self->ssl, host); if (!status) { self->internal_error = SSL_get_error(self->ssl, status); status = AMQP_STATUS_SSL_ERROR; @@ -312,27 +232,45 @@ goto error_out2; } - result = SSL_get_verify_result(self->ssl); - if (X509_V_OK != result) { - self->internal_error = result; - status = AMQP_STATUS_SSL_PEER_VERIFY_FAILED; - goto error_out3; - } - if (self->verify) { - int verify_status = amqp_ssl_socket_verify_hostname(self, host); - if (verify_status) { + cert = SSL_get_peer_certificate(self->ssl); + + if (self->verify_peer) { + if (!cert) { + self->internal_error = 0; + status = AMQP_STATUS_SSL_PEER_VERIFY_FAILED; + goto error_out3; + } + + result = SSL_get_verify_result(self->ssl); + if (X509_V_OK != result) { + self->internal_error = result; + status = AMQP_STATUS_SSL_PEER_VERIFY_FAILED; + goto error_out4; + } + } + if (self->verify_hostname) { + if (!cert) { self->internal_error = 0; status = AMQP_STATUS_SSL_HOSTNAME_VERIFY_FAILED; goto error_out3; } + + if (AMQP_HVR_MATCH_FOUND != amqp_ssl_validate_hostname(host, cert)) { + self->internal_error = 0; + status = AMQP_STATUS_SSL_HOSTNAME_VERIFY_FAILED; + goto error_out4; + } } + X509_free(cert); self->internal_error = 0; status = AMQP_STATUS_OK; exit: return status; +error_out4: + X509_free(cert); error_out3: SSL_shutdown(self->ssl); error_out2: @@ -344,35 +282,18 @@ goto exit; } -static int -amqp_ssl_socket_close(void *base) -{ - int res; +static int amqp_ssl_socket_close(void *base, amqp_socket_close_enum force) { struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; if (-1 == self->sockfd) { return AMQP_STATUS_SOCKET_CLOSED; } -start_shutdown: - res = SSL_shutdown(self->ssl); - if (0 == res) { - goto start_shutdown; - } else if (-1 == res) { - self->internal_error = SSL_get_error(self->ssl, res); - switch (self->internal_error) { - case SSL_ERROR_WANT_READ: - res = amqp_poll(self->sockfd, AMQP_SF_POLLIN, amqp_time_infinite()); - break; - case SSL_ERROR_WANT_WRITE: - res = amqp_poll(self->sockfd, AMQP_SF_POLLOUT, amqp_time_infinite()); - break; - } - if (AMQP_STATUS_OK == res) { - goto start_shutdown; - } - /* Swallow errors in poll, just consider the connection dead */ + if (AMQP_SC_NONE == force) { + /* don't try too hard to shutdown the connection */ + SSL_shutdown(self->ssl); } + SSL_free(self->ssl); self->ssl = NULL; @@ -384,39 +305,33 @@ return AMQP_STATUS_OK; } -static int -amqp_ssl_socket_get_sockfd(void *base) -{ +static int amqp_ssl_socket_get_sockfd(void *base) { struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; return self->sockfd; } -static void -amqp_ssl_socket_delete(void *base) -{ +static void amqp_ssl_socket_delete(void *base) { struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; if (self) { - amqp_ssl_socket_close(self); + amqp_ssl_socket_close(self, AMQP_SC_NONE); SSL_CTX_free(self->ctx); free(self); } - destroy_openssl(); + decrement_ssl_connections(); } static const struct amqp_socket_class_t amqp_ssl_socket_class = { - amqp_ssl_socket_send, /* send */ - amqp_ssl_socket_recv, /* recv */ - amqp_ssl_socket_open, /* open */ - amqp_ssl_socket_close, /* close */ - amqp_ssl_socket_get_sockfd, /* get_sockfd */ - amqp_ssl_socket_delete /* delete */ + amqp_ssl_socket_send, /* send */ + amqp_ssl_socket_recv, /* recv */ + amqp_ssl_socket_open, /* open */ + amqp_ssl_socket_close, /* close */ + amqp_ssl_socket_get_sockfd, /* get_sockfd */ + amqp_ssl_socket_delete /* delete */ }; -amqp_socket_t * -amqp_ssl_socket_new(amqp_connection_state_t state) -{ +amqp_socket_t *amqp_ssl_socket_new(amqp_connection_state_t state) { struct amqp_ssl_socket_t *self = calloc(1, sizeof(*self)); int status; if (!self) { @@ -425,9 +340,10 @@ self->sockfd = -1; self->klass = &amqp_ssl_socket_class; - self->verify = 1; + self->verify_peer = 1; + self->verify_hostname = 1; - status = initialize_openssl(); + status = initialize_ssl_and_increment_connections(); if (status) { goto error; } @@ -436,6 +352,8 @@ if (!self->ctx) { goto error; } + /* Disable SSLv2 and SSLv3 */ + SSL_CTX_set_options(self->ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); amqp_set_socket(state, (amqp_socket_t *)self); @@ -445,10 +363,7 @@ return NULL; } -int -amqp_ssl_socket_set_cacert(amqp_socket_t *base, - const char *cacert) -{ +int amqp_ssl_socket_set_cacert(amqp_socket_t *base, const char *cacert) { int status; struct amqp_ssl_socket_t *self; if (base->klass != &amqp_ssl_socket_class) { @@ -462,11 +377,8 @@ return AMQP_STATUS_OK; } -int -amqp_ssl_socket_set_key(amqp_socket_t *base, - const char *cert, - const char *key) -{ +int amqp_ssl_socket_set_key(amqp_socket_t *base, const char *cert, + const char *key) { int status; struct amqp_ssl_socket_t *self; if (base->klass != &amqp_ssl_socket_class) { @@ -477,30 +389,20 @@ if (1 != status) { return AMQP_STATUS_SSL_ERROR; } - status = SSL_CTX_use_PrivateKey_file(self->ctx, key, - SSL_FILETYPE_PEM); + status = SSL_CTX_use_PrivateKey_file(self->ctx, key, SSL_FILETYPE_PEM); if (1 != status) { return AMQP_STATUS_SSL_ERROR; } return AMQP_STATUS_OK; } -static int -password_cb(AMQP_UNUSED char *buffer, - AMQP_UNUSED int length, - AMQP_UNUSED int rwflag, - AMQP_UNUSED void *user_data) -{ +static int password_cb(AMQP_UNUSED char *buffer, AMQP_UNUSED int length, + AMQP_UNUSED int rwflag, AMQP_UNUSED void *user_data) { amqp_abort("rabbitmq-c does not support password protected keys"); - return 0; } -int -amqp_ssl_socket_set_key_buffer(amqp_socket_t *base, - const char *cert, - const void *key, - size_t n) -{ +int amqp_ssl_socket_set_key_buffer(amqp_socket_t *base, const char *cert, + const void *key, size_t n) { int status = AMQP_STATUS_OK; BIO *buf = NULL; RSA *rsa = NULL; @@ -508,12 +410,15 @@ if (base->klass != &amqp_ssl_socket_class) { amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); } + if (n > INT_MAX) { + return AMQP_STATUS_INVALID_PARAMETER; + } self = (struct amqp_ssl_socket_t *)base; status = SSL_CTX_use_certificate_chain_file(self->ctx, cert); if (1 != status) { return AMQP_STATUS_SSL_ERROR; } - buf = BIO_new_mem_buf((void *)key, n); + buf = BIO_new_mem_buf((void *)key, (int)n); if (!buf) { goto error; } @@ -534,10 +439,7 @@ goto exit; } -int -amqp_ssl_socket_set_cert(amqp_socket_t *base, - const char *cert) -{ +int amqp_ssl_socket_set_cert(amqp_socket_t *base, const char *cert) { int status; struct amqp_ssl_socket_t *self; if (base->klass != &amqp_ssl_socket_class) { @@ -551,140 +453,252 @@ return AMQP_STATUS_OK; } -void -amqp_ssl_socket_set_verify(amqp_socket_t *base, - amqp_boolean_t verify) -{ +void amqp_ssl_socket_set_verify(amqp_socket_t *base, amqp_boolean_t verify) { + amqp_ssl_socket_set_verify_peer(base, verify); + amqp_ssl_socket_set_verify_hostname(base, verify); +} + +void amqp_ssl_socket_set_verify_peer(amqp_socket_t *base, + amqp_boolean_t verify) { struct amqp_ssl_socket_t *self; if (base->klass != &amqp_ssl_socket_class) { amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); } self = (struct amqp_ssl_socket_t *)base; - self->verify = verify; + self->verify_peer = verify; } -void -amqp_set_initialize_ssl_library(amqp_boolean_t do_initialize) -{ - if (!openssl_initialized) { +void amqp_ssl_socket_set_verify_hostname(amqp_socket_t *base, + amqp_boolean_t verify) { + struct amqp_ssl_socket_t *self; + if (base->klass != &amqp_ssl_socket_class) { + amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); + } + self = (struct amqp_ssl_socket_t *)base; + self->verify_hostname = verify; +} + +int amqp_ssl_socket_set_ssl_versions(amqp_socket_t *base, + amqp_tls_version_t min, + amqp_tls_version_t max) { + struct amqp_ssl_socket_t *self; + if (base->klass != &amqp_ssl_socket_class) { + amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); + } + self = (struct amqp_ssl_socket_t *)base; + + { + long clear_options; + long set_options = 0; +#if defined(SSL_OP_NO_TLSv1_2) + amqp_tls_version_t max_supported = AMQP_TLSv1_2; + clear_options = SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2; +#elif defined(SSL_OP_NO_TLSv1_1) + amqp_tls_version_t max_supported = AMQP_TLSv1_1; + clear_options = SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1; +#elif defined(SSL_OP_NO_TLSv1) + amqp_tls_version_t max_supported = AMQP_TLSv1; + clear_options = SSL_OP_NO_TLSv1; +#else +#error "Need a version of OpenSSL that can support TLSv1 or greater." +#endif + + if (AMQP_TLSvLATEST == max) { + max = max_supported; + } + if (AMQP_TLSvLATEST == min) { + min = max_supported; + } + + if (min > max) { + return AMQP_STATUS_INVALID_PARAMETER; + } + + if (max > max_supported || min > max_supported) { + return AMQP_STATUS_UNSUPPORTED; + } + + if (min > AMQP_TLSv1) { + set_options |= SSL_OP_NO_TLSv1; + } +#ifdef SSL_OP_NO_TLSv1_1 + if (min > AMQP_TLSv1_1 || max < AMQP_TLSv1_1) { + set_options |= SSL_OP_NO_TLSv1_1; + } +#endif +#ifdef SSL_OP_NO_TLSv1_2 + if (max < AMQP_TLSv1_2) { + set_options |= SSL_OP_NO_TLSv1_2; + } +#endif + SSL_CTX_clear_options(self->ctx, clear_options); + SSL_CTX_set_options(self->ctx, set_options); + } + + return AMQP_STATUS_OK; +} + +void amqp_set_initialize_ssl_library(amqp_boolean_t do_initialize) { + CHECK_SUCCESS(pthread_mutex_lock(&openssl_init_mutex)); + + if (openssl_connections == 0 && !openssl_initialized) { do_initialize_openssl = do_initialize; } + CHECK_SUCCESS(pthread_mutex_unlock(&openssl_init_mutex)); } -#ifdef ENABLE_THREAD_SAFETY -unsigned long -amqp_ssl_threadid_callback(void) -{ +static unsigned long ssl_threadid_callback(void) { return (unsigned long)pthread_self(); } -void -amqp_ssl_locking_callback(int mode, int n, - AMQP_UNUSED const char *file, - AMQP_UNUSED int line) -{ +static void ssl_locking_callback(int mode, int n, AMQP_UNUSED const char *file, + AMQP_UNUSED int line) { if (mode & CRYPTO_LOCK) { - if (pthread_mutex_lock(&amqp_openssl_lockarray[n])) { - amqp_abort("Runtime error: Failure in trying to lock OpenSSL mutex"); - } + CHECK_SUCCESS(pthread_mutex_lock(&amqp_openssl_lockarray[n])); } else { - if (pthread_mutex_unlock(&amqp_openssl_lockarray[n])) { - amqp_abort("Runtime error: Failure in trying to unlock OpenSSL mutex"); - } + CHECK_SUCCESS(pthread_mutex_unlock(&amqp_openssl_lockarray[n])); } } -#endif /* ENABLE_THREAD_SAFETY */ -static int -initialize_openssl(void) -{ -#ifdef ENABLE_THREAD_SAFETY -#ifdef _WIN32 - /* No such thing as PTHREAD_INITIALIZE_MUTEX macro on Win32, so we use this */ - if (NULL == openssl_init_mutex) { - while (InterlockedExchange(&win32_create_mutex, 1) == 1) - /* Loop, someone else is holding this lock */ ; - - if (NULL == openssl_init_mutex) { - if (pthread_mutex_init(&openssl_init_mutex, NULL)) { - return -1; +static int setup_openssl(void) { + int status; + + int i; + amqp_openssl_lockarray = calloc(CRYPTO_num_locks(), sizeof(pthread_mutex_t)); + if (!amqp_openssl_lockarray) { + status = AMQP_STATUS_NO_MEMORY; + goto out; + } + for (i = 0; i < CRYPTO_num_locks(); i++) { + if (pthread_mutex_init(&amqp_openssl_lockarray[i], NULL)) { + int j; + for (j = 0; j < i; j++) { + pthread_mutex_destroy(&amqp_openssl_lockarray[j]); } + free(amqp_openssl_lockarray); + status = AMQP_STATUS_SSL_ERROR; + goto out; } - InterlockedExchange(&win32_create_mutex, 0); } -#endif /* _WIN32 */ + CRYPTO_set_id_callback(ssl_threadid_callback); + CRYPTO_set_locking_callback(ssl_locking_callback); - if (pthread_mutex_lock(&openssl_init_mutex)) { - return -1; +#ifdef AMQP_OPENSSL_V110 + if (CONF_modules_load_file(NULL, "rabbitmq-c", CONF_MFLAGS_DEFAULT_SECTION) <= + 0) { + status = AMQP_STATUS_SSL_ERROR; + goto out; } -#endif /* ENABLE_THREAD_SAFETY */ - if (do_initialize_openssl) { -#ifdef ENABLE_THREAD_SAFETY - if (NULL == amqp_openssl_lockarray) { - int i = 0; - amqp_openssl_lockarray = calloc(CRYPTO_num_locks(), sizeof(pthread_mutex_t)); - if (!amqp_openssl_lockarray) { - pthread_mutex_unlock(&openssl_init_mutex); - return -1; - } - for (i = 0; i < CRYPTO_num_locks(); ++i) { - if (pthread_mutex_init(&amqp_openssl_lockarray[i], NULL)) { - free(amqp_openssl_lockarray); - amqp_openssl_lockarray = NULL; - pthread_mutex_unlock(&openssl_init_mutex); - return -1; - } - } - } +#else + OPENSSL_config(NULL); +#endif + SSL_library_init(); + SSL_load_error_strings(); + + status = AMQP_STATUS_OK; +out: + return status; +} - if (0 == open_ssl_connections) { - CRYPTO_set_id_callback(amqp_ssl_threadid_callback); - CRYPTO_set_locking_callback(amqp_ssl_locking_callback); +int amqp_initialize_ssl_library(void) { + int status; + CHECK_SUCCESS(pthread_mutex_lock(&openssl_init_mutex)); + + if (!openssl_initialized) { + status = setup_openssl(); + if (status) { + goto out; } -#endif /* ENABLE_THREAD_SAFETY */ + openssl_initialized = 1; + } - if (!openssl_initialized) { - OPENSSL_config(NULL); + status = AMQP_STATUS_OK; +out: + CHECK_SUCCESS(pthread_mutex_unlock(&openssl_init_mutex)); + return status; +} - SSL_library_init(); - SSL_load_error_strings(); +static int initialize_ssl_and_increment_connections() { + int status; + CHECK_SUCCESS(pthread_mutex_lock(&openssl_init_mutex)); - openssl_initialized = 1; + if (do_initialize_openssl && !openssl_initialized) { + status = setup_openssl(); + if (status) { + goto exit; } + openssl_initialized = 1; } - ++open_ssl_connections; + if (!openssl_bio_initialized) { + status = amqp_openssl_bio_init(); + if (status) { + goto exit; + } + openssl_bio_initialized = 1; + } -#ifdef ENABLE_THREAD_SAFETY - pthread_mutex_unlock(&openssl_init_mutex); -#endif /* ENABLE_THREAD_SAFETY */ - return 0; + openssl_connections += 1; + status = AMQP_STATUS_OK; +exit: + CHECK_SUCCESS(pthread_mutex_unlock(&openssl_init_mutex)); + return status; } -static int -destroy_openssl(void) -{ -#ifdef ENABLE_THREAD_SAFETY - if (pthread_mutex_lock(&openssl_init_mutex)) { - return -1; +static int decrement_ssl_connections(void) { + CHECK_SUCCESS(pthread_mutex_lock(&openssl_init_mutex)); + + if (openssl_connections > 0) { + openssl_connections--; } -#endif /* ENABLE_THREAD_SAFETY */ - if (open_ssl_connections > 0) { - --open_ssl_connections; + CHECK_SUCCESS(pthread_mutex_unlock(&openssl_init_mutex)); + return AMQP_STATUS_OK; +} + +int amqp_uninitialize_ssl_library(void) { + int status; + CHECK_SUCCESS(pthread_mutex_lock(&openssl_init_mutex)); + + if (openssl_connections > 0) { + status = AMQP_STATUS_SOCKET_INUSE; + goto out; } -#ifdef ENABLE_THREAD_SAFETY - if (0 == open_ssl_connections && do_initialize_openssl) { - /* Unsetting these allows the rabbitmq-c library to be unloaded - * safely. We do leak the amqp_openssl_lockarray. Which is only - * an issue if you repeatedly unload and load the library - */ - CRYPTO_set_locking_callback(NULL); - CRYPTO_set_id_callback(NULL); + amqp_openssl_bio_destroy(); + openssl_bio_initialized = 0; + +#ifndef AMQP_OPENSSL_V110 + ERR_remove_state(0); +#endif + +#ifndef LIBRESSL_VERSION_NUMBER + FIPS_mode_set(0); +#endif + + CRYPTO_set_locking_callback(NULL); + CRYPTO_set_id_callback(NULL); + { + int i; + for (i = 0; i < CRYPTO_num_locks(); i++) { + pthread_mutex_destroy(&amqp_openssl_lockarray[i]); + } + free(amqp_openssl_lockarray); } - pthread_mutex_unlock(&openssl_init_mutex); -#endif /* ENABLE_THREAD_SAFETY */ - return 0; + ENGINE_cleanup(); + CONF_modules_free(); + EVP_cleanup(); + CRYPTO_cleanup_all_ex_data(); + ERR_free_strings(); +#if (OPENSSL_VERSION_NUMBER >= 0x10002003L) && !defined(LIBRESSL_VERSION_NUMBER) + SSL_COMP_free_compression_methods(); +#endif + + openssl_initialized = 0; + + status = AMQP_STATUS_OK; +out: + CHECK_SUCCESS(pthread_mutex_unlock(&openssl_init_mutex)); + return status; } diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_openssl_hostname_validation.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_openssl_hostname_validation.c --- librabbitmq-0.7.1/librabbitmq/amqp_openssl_hostname_validation.c 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_openssl_hostname_validation.c 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2012, iSEC Partners. + * Copyright (C) 2015 Alan Antonuk. + * + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization of the + * copyright holder. + */ + +/* Originally from: + * https://github.com/iSECPartners/ssl-conservatory + * https://wiki.openssl.org/index.php/Hostname_validation + */ + +#include +#include + +#include "amqp_hostcheck.h" +#include "amqp_openssl_bio.h" +#include "amqp_openssl_hostname_validation.h" + +#include + +#define HOSTNAME_MAX_SIZE 255 + +/** + * Tries to find a match for hostname in the certificate's Common Name field. + * + * Returns AMQP_HVR_MATCH_FOUND if a match was found. + * Returns AMQP_HVR_MATCH_NOT_FOUND if no matches were found. + * Returns AMQP_HVR_MALFORMED_CERTIFICATE if the Common Name had a NUL character + * embedded in it. + * Returns AMQP_HVR_ERROR if the Common Name could not be extracted. + */ +static amqp_hostname_validation_result amqp_matches_common_name( + const char *hostname, const X509 *server_cert) { + int common_name_loc = -1; + X509_NAME_ENTRY *common_name_entry = NULL; + ASN1_STRING *common_name_asn1 = NULL; + const char *common_name_str = NULL; + + // Find the position of the CN field in the Subject field of the certificate + common_name_loc = X509_NAME_get_index_by_NID( + X509_get_subject_name((X509 *)server_cert), NID_commonName, -1); + if (common_name_loc < 0) { + return AMQP_HVR_ERROR; + } + + // Extract the CN field + common_name_entry = X509_NAME_get_entry( + X509_get_subject_name((X509 *)server_cert), common_name_loc); + if (common_name_entry == NULL) { + return AMQP_HVR_ERROR; + } + + // Convert the CN field to a C string + common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry); + if (common_name_asn1 == NULL) { + return AMQP_HVR_ERROR; + } + +#ifdef AMQP_OPENSSL_V110 + common_name_str = (const char *)ASN1_STRING_get0_data(common_name_asn1); +#else + common_name_str = (char *)ASN1_STRING_data(common_name_asn1); +#endif + + // Make sure there isn't an embedded NUL character in the CN + if ((size_t)ASN1_STRING_length(common_name_asn1) != strlen(common_name_str)) { + return AMQP_HVR_MALFORMED_CERTIFICATE; + } + + // Compare expected hostname with the CN + if (amqp_hostcheck(common_name_str, hostname) == AMQP_HCR_MATCH) { + return AMQP_HVR_MATCH_FOUND; + } else { + return AMQP_HVR_MATCH_NOT_FOUND; + } +} + +/** + * Tries to find a match for hostname in the certificate's Subject Alternative + * Name extension. + * + * Returns AMQP_HVR_MATCH_FOUND if a match was found. + * Returns AMQP_HVR_MATCH_NOT_FOUND if no matches were found. + * Returns AMQP_HVR_MALFORMED_CERTIFICATE if any of the hostnames had a NUL + * character embedded in it. + * Returns AMQP_HVR_NO_SAN_PRESENT if the SAN extension was not present in the + * certificate. + */ +static amqp_hostname_validation_result amqp_matches_subject_alternative_name( + const char *hostname, const X509 *server_cert) { + amqp_hostname_validation_result result = AMQP_HVR_MATCH_NOT_FOUND; + int i; + int san_names_nb = -1; + STACK_OF(GENERAL_NAME) *san_names = NULL; + + // Try to extract the names within the SAN extension from the certificate + san_names = + X509_get_ext_d2i((X509 *)server_cert, NID_subject_alt_name, NULL, NULL); + if (san_names == NULL) { + return AMQP_HVR_NO_SAN_PRESENT; + } + san_names_nb = sk_GENERAL_NAME_num(san_names); + + // Check each name within the extension + for (i = 0; i < san_names_nb; i++) { + const GENERAL_NAME *current_name = sk_GENERAL_NAME_value(san_names, i); + + if (current_name->type == GEN_DNS) { + // Current name is a DNS name, let's check it + const char *dns_name = (const char *) +#ifdef AMQP_OPENSSL_V110 + ASN1_STRING_get0_data(current_name->d.dNSName); +#else + ASN1_STRING_data(current_name->d.dNSName); +#endif + + // Make sure there isn't an embedded NUL character in the DNS name + if ((size_t)ASN1_STRING_length(current_name->d.dNSName) != + strlen(dns_name)) { + result = AMQP_HVR_MALFORMED_CERTIFICATE; + break; + } else { // Compare expected hostname with the DNS name + if (amqp_hostcheck(dns_name, hostname) == AMQP_HCR_MATCH) { + result = AMQP_HVR_MATCH_FOUND; + break; + } + } + } + } + sk_GENERAL_NAME_pop_free(san_names, GENERAL_NAME_free); + + return result; +} + +/** + * Validates the server's identity by looking for the expected hostname in the + * server's certificate. As described in RFC 6125, it first tries to find a + * match in the Subject Alternative Name extension. If the extension is not + * present in the certificate, it checks the Common Name instead. + * + * Returns AMQP_HVR_MATCH_FOUND if a match was found. + * Returns AMQP_HVR_MATCH_NOT_FOUND if no matches were found. + * Returns AMQP_HVR_MALFORMED_CERTIFICATE if any of the hostnames had a NUL + * character embedded in it. + * Returns AMQP_HVR_ERROR if there was an error. + */ +amqp_hostname_validation_result amqp_ssl_validate_hostname( + const char *hostname, const X509 *server_cert) { + amqp_hostname_validation_result result; + + if ((hostname == NULL) || (server_cert == NULL)) return AMQP_HVR_ERROR; + + // First try the Subject Alternative Names extension + result = amqp_matches_subject_alternative_name(hostname, server_cert); + if (result == AMQP_HVR_NO_SAN_PRESENT) { + // Extension was not found: try the Common Name + result = amqp_matches_common_name(hostname, server_cert); + } + + return result; +} diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_openssl_hostname_validation.h librabbitmq-0.9.0-0.1/librabbitmq/amqp_openssl_hostname_validation.h --- librabbitmq-0.7.1/librabbitmq/amqp_openssl_hostname_validation.h 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_openssl_hostname_validation.h 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1,58 @@ +#ifndef librabbitmq_amqp_openssl_hostname_validation_h +#define librabbitmq_amqp_openssl_hostname_validation_h + +/* + * Copyright (C) 2012, iSEC Partners. + * Copyright (C) 2015 Alan Antonuk. + * + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization of the + * copyright holder. + */ + +/* Originally from: + * https://github.com/iSECPartners/ssl-conservatory + * https://wiki.openssl.org/index.php/Hostname_validation + */ + +#include + +typedef enum { + AMQP_HVR_MATCH_FOUND, + AMQP_HVR_MATCH_NOT_FOUND, + AMQP_HVR_NO_SAN_PRESENT, + AMQP_HVR_MALFORMED_CERTIFICATE, + AMQP_HVR_ERROR +} amqp_hostname_validation_result; + +/** +* Validates the server's identity by looking for the expected hostname in the +* server's certificate. As described in RFC 6125, it first tries to find a match +* in the Subject Alternative Name extension. If the extension is not present in +* the certificate, it checks the Common Name instead. +* +* Returns AMQP_HVR_MATCH_FOUND if a match was found. +* Returns AMQP_HVR_MATCH_NOT_FOUND if no matches were found. +* Returns AMQP_HVR_MALFORMED_CERTIFICATE if any of the hostnames had a NUL +* character embedded in it. +* Returns AMQP_HVR_ERROR if there was an error. +*/ +amqp_hostname_validation_result amqp_ssl_validate_hostname( + const char *hostname, const X509 *server_cert); + +#endif diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_polarssl.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_polarssl.c --- librabbitmq-0.7.1/librabbitmq/amqp_polarssl.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_polarssl.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,362 +0,0 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ -/* - * Copyright 2012-2013 Michael Steinert - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "amqp_ssl_socket.h" -#include "amqp_private.h" -#include -#include -#include -#include -#include -#include -#include - -#ifndef AMQP_USE_UNTESTED_SSL_BACKEND -# error This SSL backend is alpha quality and likely contains errors.\ - -DAMQP_USE_UNTESTED_SSL_BACKEND to use this backend -#endif - -struct amqp_ssl_socket_t { - const struct amqp_socket_class_t *klass; - int sockfd; - entropy_context *entropy; - ctr_drbg_context *ctr_drbg; - x509_cert *cacert; - rsa_context *key; - x509_cert *cert; - ssl_context *ssl; - ssl_session *session; - char *buffer; - size_t length; - int last_error; -}; - -static ssize_t -amqp_ssl_socket_send(void *base, - const void *buf, - size_t len, - AMQP_UNUSED int flags) -{ - ssize_t status; - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - - self->last_error = 0; - status = ssl_write(self->ssl, buf, len); - if (status < 0) { - self->last_error = AMQP_STATUS_SSL_ERROR; - } - - return status; -} - -static ssize_t -amqp_ssl_socket_writev(void *base, - const struct iovec *iov, - int iovcnt) -{ - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - ssize_t written = -1; - char *bufferp; - size_t bytes; - int i; - self->last_error = 0; - bytes = 0; - for (i = 0; i < iovcnt; ++i) { - bytes += iov[i].iov_len; - } - if (self->length < bytes) { - free(self->buffer); - self->buffer = malloc(bytes); - if (!self->buffer) { - self->length = 0; - self->last_error = AMQP_STATUS_NO_MEMORY; - goto exit; - } - self->length = bytes; - } - bufferp = self->buffer; - for (i = 0; i < iovcnt; ++i) { - memcpy(bufferp, iov[i].iov_base, iov[i].iov_len); - bufferp += iov[i].iov_len; - } - written = amqp_ssl_socket_send(self, (const unsigned char *)self->buffer, - bytes, 0); -exit: - return written; -} - -static ssize_t -amqp_ssl_socket_recv(void *base, - void *buf, - size_t len, - AMQP_UNUSED int flags) -{ - ssize_t status; - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - - self->last_error = 0; - status = ssl_read(self->ssl, buf, len); - if (status < 0) { - self->last_error = AMQP_STATUS_SSL_ERROR; - } - - return status; -} - -static int -amqp_ssl_socket_open(void *base, const char *host, int port, struct timeval *timeout) -{ - int status; - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - self->last_error = 0; - - if (timeout && (timeout->tv_sec != 0 || timeout->tv_usec != 0)) { - /* We don't support PolarSSL for now because it uses its own connect() wrapper - * It is not too hard to implement net_connect() with noblock support, - * but then we will have to maintain that piece of code and keep it synced with main PolarSSL code base - */ - return AMQP_STATUS_INVALID_PARAMETER; - } - - status = net_connect(&self->sockfd, host, port); - if (status) { - /* This isn't quite right. We should probably translate between - * POLARSSL_ERR_* to our internal error codes - */ - self->last_error = AMQP_STATUS_SSL_ERROR; - return -1; - } - if (self->cacert) { - ssl_set_ca_chain(self->ssl, self->cacert, NULL, host); - } - ssl_set_bio(self->ssl, net_recv, &self->sockfd, - net_send, &self->sockfd); - if (self->key && self->cert) { - ssl_set_own_cert(self->ssl, self->cert, self->key); - } - while (0 != (status = ssl_handshake(self->ssl))) { - switch (status) { - case POLARSSL_ERR_NET_WANT_READ: - case POLARSSL_ERR_NET_WANT_WRITE: - continue; - default: - self->last_error = AMQP_STATUS_SSL_ERROR; - break; - } - } - return status; -} - -static int -amqp_ssl_socket_close(void *base) -{ - int status = -1; - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - if (self) { - free(self->entropy); - free(self->ctr_drbg); - x509_free(self->cacert); - free(self->cacert); - rsa_free(self->key); - free(self->key); - x509_free(self->cert); - free(self->cert); - ssl_free(self->ssl); - free(self->ssl); - free(self->session); - free(self->buffer); - if (self->sockfd >= 0) { - net_close(self->sockfd); - status = 0; - } - free(self); - } - return status; -} - -static int -amqp_ssl_socket_error(AMQP_UNUSED void *user_data) -{ - return AMQP_STATUS_SSL_ERROR; -} - -char * -amqp_ssl_error_string(AMQP_UNUSED int err) -{ - return strdup("A SSL socket error occurred"); -} - -static int -amqp_ssl_socket_get_sockfd(void *base) -{ - struct amqp_ssl_socket_t *self = (struct amqp_ssl_socket_t *)base; - return self->sockfd; -} - -static const struct amqp_socket_class_t amqp_ssl_socket_class = { - amqp_ssl_socket_writev, /* writev */ - amqp_ssl_socket_send, /* send */ - amqp_ssl_socket_recv, /* recv */ - amqp_ssl_socket_open, /* open */ - amqp_ssl_socket_close, /* close */ - amqp_ssl_socket_error, /* error */ - amqp_ssl_socket_get_sockfd /* get_sockfd */ -}; - -amqp_socket_t * -amqp_ssl_socket_new(void) -{ - struct amqp_ssl_socket_t *self = calloc(1, sizeof(*self)); - int status; - if (!self) { - goto error; - } - self->entropy = calloc(1, sizeof(*self->entropy)); - if (!self->entropy) { - goto error; - } - self->sockfd = -1; - entropy_init(self->entropy); - self->ctr_drbg = calloc(1, sizeof(*self->ctr_drbg)); - if (!self->ctr_drbg) { - goto error; - } - status = ctr_drbg_init(self->ctr_drbg, entropy_func, self->entropy, - NULL, 0); - if (status) { - goto error; - } - self->ssl = calloc(1, sizeof(*self->ssl)); - if (!self->ssl) { - goto error; - } - status = ssl_init(self->ssl); - if (status) { - goto error; - } - ssl_set_endpoint(self->ssl, SSL_IS_CLIENT); - ssl_set_rng(self->ssl, ctr_drbg_random, self->ctr_drbg); - ssl_set_ciphersuites(self->ssl, ssl_default_ciphersuites); - ssl_set_authmode(self->ssl, SSL_VERIFY_REQUIRED); - self->session = calloc(1, sizeof(*self->session)); - if (!self->session) { - goto error; - } -#if POLARSSL_VERSION_NUMBER >= 0x01020000 - ssl_set_session(self->ssl, self->session); -#else - ssl_set_session(self->ssl, 0, 0, self->session); -#endif - - self->klass = &amqp_ssl_socket_class; - return (amqp_socket_t *)self; -error: - amqp_socket_close((amqp_socket_t *)self); - return NULL; -} - -int -amqp_ssl_socket_set_cacert(amqp_socket_t *base, - const char *cacert) -{ - int status; - struct amqp_ssl_socket_t *self; - if (base->klass != &amqp_ssl_socket_class) { - amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); - } - self = (struct amqp_ssl_socket_t *)base; - self->cacert = calloc(1, sizeof(*self->cacert)); - if (!self->cacert) { - return -1; - } - status = x509parse_crtfile(self->cacert, cacert); - if (status) { - return -1; - } - return 0; -} - -int -amqp_ssl_socket_set_key(amqp_socket_t *base, - const char *cert, - const char *key) -{ - int status; - struct amqp_ssl_socket_t *self; - if (base->klass != &amqp_ssl_socket_class) { - amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); - } - self = (struct amqp_ssl_socket_t *)base; - self->key = calloc(1, sizeof(*self->key)); - if (!self->key) { - return -1; - } - status = x509parse_keyfile(self->key, key, NULL); - if (status) { - return -1; - } - self->cert = calloc(1, sizeof(*self->cert)); - if (!self->cert) { - return -1; - } - status = x509parse_crtfile(self->cert, cert); - if (status) { - return -1; - } - return 0; -} - -int -amqp_ssl_socket_set_key_buffer(AMQP_UNUSED amqp_socket_t *base, - AMQP_UNUSED const char *cert, - AMQP_UNUSED const void *key, - AMQP_UNUSED size_t n) -{ - amqp_abort("%s is not implemented for PolarSSL", __func__); - return -1; -} - -void -amqp_ssl_socket_set_verify(amqp_socket_t *base, - amqp_boolean_t verify) -{ - struct amqp_ssl_socket_t *self; - if (base->klass != &amqp_ssl_socket_class) { - amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); - } - self = (struct amqp_ssl_socket_t *)base; - if (verify) { - ssl_set_authmode(self->ssl, SSL_VERIFY_REQUIRED); - } else { - ssl_set_authmode(self->ssl, SSL_VERIFY_NONE); - } -} - -void -amqp_set_initialize_ssl_library(AMQP_UNUSED amqp_boolean_t do_initialize) -{ -} diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_private.h librabbitmq-0.9.0-0.1/librabbitmq/amqp_private.h --- librabbitmq-0.7.1/librabbitmq/amqp_private.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_private.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ #ifndef librabbitmq_amqp_private_h #define librabbitmq_amqp_private_h @@ -41,52 +40,53 @@ #include "config.h" #endif -#define AMQ_COPYRIGHT "Copyright (c) 2007-2014 VMWare Inc, Tony Garnock-Jones," \ - " and Alan Antonuk." +#define AMQ_COPYRIGHT \ + "Copyright (c) 2007-2014 VMWare Inc, Tony Garnock-Jones," \ + " and Alan Antonuk." #include "amqp.h" #include "amqp_framing.h" #include -#ifdef _WIN32 -# ifndef WINVER +#if ((defined(_WIN32)) || (defined(__MINGW32__)) || (defined(__MINGW64__))) +#ifndef WINVER /* WINVER 0x0502 is WinXP SP2+, Windows Server 2003 SP1+ - * See: http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx#macros_for_conditional_declarations */ -# define WINVER 0x0502 -# endif -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include + * See: + * http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx#macros_for_conditional_declarations + */ +#define WINVER 0x0502 +#endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include #else -# include -# include +#include +#include #endif /* GCC attributes */ -#if __GNUC__ > 2 | (__GNUC__ == 2 && __GNUC_MINOR__ > 4) -#define AMQP_NORETURN \ - __attribute__ ((__noreturn__)) -#define AMQP_UNUSED \ - __attribute__ ((__unused__)) +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +#define AMQP_NORETURN __attribute__((__noreturn__)) +#define AMQP_UNUSED __attribute__((__unused__)) +#elif defined(_MSC_VER) +#define AMQP_NORETURN __declspec(noreturn) +#define AMQP_UNUSED #else #define AMQP_NORETURN #define AMQP_UNUSED #endif #if __GNUC__ >= 4 -#define AMQP_PRIVATE \ - __attribute__ ((visibility ("hidden"))) +#define AMQP_PRIVATE __attribute__((visibility("hidden"))) #else #define AMQP_PRIVATE #endif -char * -amqp_os_error_string(int err); +char *amqp_os_error_string(int err); #ifdef WITH_SSL -char * -amqp_ssl_error_string(int err); +char *amqp_ssl_error_string(int err); #endif #include "amqp_socket.h" @@ -121,12 +121,11 @@ CONNECTION_STATE_BODY } amqp_connection_state_enum; -typedef enum amqp_status_private_enum_ -{ +typedef enum amqp_status_private_enum_ { /* 0x00xx -> AMQP_STATUS_*/ /* 0x01xx -> AMQP_STATUS_TCP_* */ /* 0x02xx -> AMQP_STATUS_SSL_* */ - AMQP_PRIVATE_STATUS_SOCKET_NEEDREAD = -0x1301, + AMQP_PRIVATE_STATUS_SOCKET_NEEDREAD = -0x1301, AMQP_PRIVATE_STATUS_SOCKET_NEEDWRITE = -0x1302 } amqp_status_private_enum; @@ -189,11 +188,17 @@ amqp_table_t server_properties; amqp_table_t client_properties; amqp_pool_t properties_pool; -}; -amqp_pool_t *amqp_get_or_create_channel_pool(amqp_connection_state_t connection, amqp_channel_t channel); -amqp_pool_t *amqp_get_channel_pool(amqp_connection_state_t state, amqp_channel_t channel); + struct timeval *handshake_timeout; + struct timeval internal_handshake_timeout; + struct timeval *rpc_timeout; + struct timeval internal_rpc_timeout; +}; +amqp_pool_t *amqp_get_or_create_channel_pool(amqp_connection_state_t connection, + amqp_channel_t channel); +amqp_pool_t *amqp_get_channel_pool(amqp_connection_state_t state, + amqp_channel_t channel); static inline int amqp_heartbeat_send(amqp_connection_state_t state) { return state->heartbeat; @@ -205,143 +210,132 @@ int amqp_try_recv(amqp_connection_state_t state); -static inline void *amqp_offset(void *data, size_t offset) -{ +static inline void *amqp_offset(void *data, size_t offset) { return (char *)data + offset; } /* This macro defines the encoding and decoding functions associated with a simple type. */ -#define DECLARE_CODEC_BASE_TYPE(bits, htonx, ntohx) \ - \ - static inline void amqp_e##bits(void *data, size_t offset, \ - uint##bits##_t val) \ - { \ - /* The AMQP data might be unaligned. So we encode and then copy the \ - result into place. */ \ - uint##bits##_t res = htonx(val); \ - memcpy(amqp_offset(data, offset), &res, bits/8); \ - } \ - \ - static inline uint##bits##_t amqp_d##bits(void *data, size_t offset) \ - { \ - /* The AMQP data might be unaligned. So we copy the source value \ - into a variable and then decode it. */ \ - uint##bits##_t val; \ - memcpy(&val, amqp_offset(data, offset), bits/8); \ - return ntohx(val); \ - } \ - \ - static inline int amqp_encode_##bits(amqp_bytes_t encoded, size_t *offset, \ - uint##bits##_t input) \ - \ - { \ - size_t o = *offset; \ - if ((*offset = o + bits / 8) <= encoded.len) { \ - amqp_e##bits(encoded.bytes, o, input); \ - return 1; \ - } \ - else { \ - return 0; \ - } \ - } \ - \ - static inline int amqp_decode_##bits(amqp_bytes_t encoded, size_t *offset, \ - uint##bits##_t *output) \ - \ - { \ - size_t o = *offset; \ - if ((*offset = o + bits / 8) <= encoded.len) { \ - *output = amqp_d##bits(encoded.bytes, o); \ - return 1; \ - } \ - else { \ - return 0; \ - } \ +#define DECLARE_CODEC_BASE_TYPE(bits) \ + \ + static inline int amqp_encode_##bits(amqp_bytes_t encoded, size_t *offset, \ + uint##bits##_t input) { \ + size_t o = *offset; \ + if ((*offset = o + bits / 8) <= encoded.len) { \ + amqp_e##bits(input, amqp_offset(encoded.bytes, o)); \ + return 1; \ + } \ + return 0; \ + } \ + \ + static inline int amqp_decode_##bits(amqp_bytes_t encoded, size_t *offset, \ + uint##bits##_t *output) { \ + size_t o = *offset; \ + if ((*offset = o + bits / 8) <= encoded.len) { \ + *output = amqp_d##bits(amqp_offset(encoded.bytes, o)); \ + return 1; \ + } \ + return 0; \ } -/* Determine byte order */ -#if defined(__GLIBC__) -# include -# if (__BYTE_ORDER == __LITTLE_ENDIAN) -# define AMQP_LITTLE_ENDIAN -# elif (__BYTE_ORDER == __BIG_ENDIAN) -# define AMQP_BIG_ENDIAN -# else -/* Don't define anything */ -# endif -#elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) || \ - defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) -# define AMQP_BIG_ENDIAN -#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) || \ - defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) -# define AMQP_LITTLE_ENDIAN -#elif defined(__hppa__) || defined(__HPPA__) || defined(__hppa) || \ - defined(_POWER) || defined(__powerpc__) || defined(__ppc___) || \ - defined(_MIPSEB) || defined(__s390__) || \ - defined(__sparc) || defined(__sparc__) -# define AMQP_BIG_ENDIAN -#elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) || \ - defined(__amd64__) || defined(__x86_64__) || defined(_M_X64) || \ - defined(__ia64) || defined(__ia64__) || defined(_M_IA64) || \ - defined(__arm__) || defined(_M_ARM) || \ - defined(__i386__) || defined(_M_IX86) -# define AMQP_LITTLE_ENDIAN -#else -/* Don't define anything */ -#endif +static inline int is_bigendian(void) { + union { + uint32_t i; + char c[4]; + } bint = {0x01020304}; + return bint.c[0] == 1; +} + +static inline void amqp_e8(uint8_t val, void *data) { + memcpy(data, &val, sizeof(val)); +} -#if defined(AMQP_LITTLE_ENDIAN) +static inline uint8_t amqp_d8(void *data) { + uint8_t val; + memcpy(&val, data, sizeof(val)); + return val; +} -#define DECLARE_XTOXLL(func) \ - static inline uint64_t func##ll(uint64_t val) \ - { \ - union { \ - uint64_t whole; \ - uint32_t halves[2]; \ - } u; \ - uint32_t t; \ - u.whole = val; \ - t = u.halves[0]; \ - u.halves[0] = func##l(u.halves[1]); \ - u.halves[1] = func##l(t); \ - return u.whole; \ +static inline void amqp_e16(uint16_t val, void *data) { + if (!is_bigendian()) { + val = ((val & 0xFF00u) >> 8u) | ((val & 0x00FFu) << 8u); } + memcpy(data, &val, sizeof(val)); +} -#elif defined(AMQP_BIG_ENDIAN) +static inline uint16_t amqp_d16(void *data) { + uint16_t val; + memcpy(&val, data, sizeof(val)); + if (!is_bigendian()) { + val = ((val & 0xFF00u) >> 8u) | ((val & 0x00FFu) << 8u); + } + return val; +} -#define DECLARE_XTOXLL(func) \ - static inline uint64_t func##ll(uint64_t val) \ - { \ - union { \ - uint64_t whole; \ - uint32_t halves[2]; \ - } u; \ - u.whole = val; \ - u.halves[0] = func##l(u.halves[0]); \ - u.halves[1] = func##l(u.halves[1]); \ - return u.whole; \ +static inline void amqp_e32(uint32_t val, void *data) { + if (!is_bigendian()) { + val = ((val & 0xFF000000u) >> 24u) | ((val & 0x00FF0000u) >> 8u) | + ((val & 0x0000FF00u) << 8u) | ((val & 0x000000FFu) << 24u); } + memcpy(data, &val, sizeof(val)); +} -#else -# error Endianness not known -#endif +static inline uint32_t amqp_d32(void *data) { + uint32_t val; + memcpy(&val, data, sizeof(val)); + if (!is_bigendian()) { + val = ((val & 0xFF000000u) >> 24u) | ((val & 0x00FF0000u) >> 8u) | + ((val & 0x0000FF00u) << 8u) | ((val & 0x000000FFu) << 24u); + } + return val; +} -#ifndef HAVE_HTONLL -DECLARE_XTOXLL(hton) -DECLARE_XTOXLL(ntoh) -#endif +static inline void amqp_e64(uint64_t val, void *data) { + if (!is_bigendian()) { + val = ((val & 0xFF00000000000000u) >> 56u) | + ((val & 0x00FF000000000000u) >> 40u) | + ((val & 0x0000FF0000000000u) >> 24u) | + ((val & 0x000000FF00000000u) >> 8u) | + ((val & 0x00000000FF000000u) << 8u) | + ((val & 0x0000000000FF0000u) << 24u) | + ((val & 0x000000000000FF00u) << 40u) | + ((val & 0x00000000000000FFu) << 56u); + } + memcpy(data, &val, sizeof(val)); +} -DECLARE_CODEC_BASE_TYPE(8, (uint8_t), (uint8_t)) -DECLARE_CODEC_BASE_TYPE(16, htons, ntohs) -DECLARE_CODEC_BASE_TYPE(32, htonl, ntohl) -DECLARE_CODEC_BASE_TYPE(64, htonll, ntohll) +static inline uint64_t amqp_d64(void *data) { + uint64_t val; + memcpy(&val, data, sizeof(val)); + if (!is_bigendian()) { + val = ((val & 0xFF00000000000000u) >> 56u) | + ((val & 0x00FF000000000000u) >> 40u) | + ((val & 0x0000FF0000000000u) >> 24u) | + ((val & 0x000000FF00000000u) >> 8u) | + ((val & 0x00000000FF000000u) << 8u) | + ((val & 0x0000000000FF0000u) << 24u) | + ((val & 0x000000000000FF00u) << 40u) | + ((val & 0x00000000000000FFu) << 56u); + } + return val; +} + +DECLARE_CODEC_BASE_TYPE(8) +DECLARE_CODEC_BASE_TYPE(16) +DECLARE_CODEC_BASE_TYPE(32) +DECLARE_CODEC_BASE_TYPE(64) static inline int amqp_encode_bytes(amqp_bytes_t encoded, size_t *offset, - amqp_bytes_t input) -{ + amqp_bytes_t input) { size_t o = *offset; + /* The memcpy below has undefined behavior if the input is NULL. It is valid + * for a 0-length amqp_bytes_t to have .bytes == NULL. Thus we should check + * before encoding. + */ + if (input.len == 0) { + return 1; + } if ((*offset = o + input.len) <= encoded.len) { memcpy(amqp_offset(encoded.bytes, o), input.bytes, input.len); return 1; @@ -351,8 +345,7 @@ } static inline int amqp_decode_bytes(amqp_bytes_t encoded, size_t *offset, - amqp_bytes_t *output, size_t len) -{ + amqp_bytes_t *output, size_t len) { size_t o = *offset; if ((*offset = o + len) <= encoded.len) { output->bytes = amqp_offset(encoded.bytes, o); @@ -364,11 +357,18 @@ } AMQP_NORETURN -void -amqp_abort(const char *fmt, ...); +void amqp_abort(const char *fmt, ...); int amqp_bytes_equal(amqp_bytes_t r, amqp_bytes_t l); +static inline amqp_rpc_reply_t amqp_rpc_reply_error(amqp_status_enum status) { + amqp_rpc_reply_t reply; + reply.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; + reply.library_error = status; + return reply; +} + int amqp_send_frame_inner(amqp_connection_state_t state, - const amqp_frame_t *frame, int flags); + const amqp_frame_t *frame, int flags, + amqp_time_t deadline); #endif diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_socket.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_socket.c --- librabbitmq-0.7.1/librabbitmq/amqp_socket.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_socket.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -39,7 +38,7 @@ #endif #ifdef _MSC_VER -# define _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS #endif #include "amqp_private.h" @@ -57,36 +56,36 @@ #include -#ifdef _WIN32 -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include -# include +#if ((defined(_WIN32)) || (defined(__MINGW32__)) || (defined(__MINGW64__))) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include #else -# include /* On older BSD this must come before net includes */ -# include -# include -# ifdef HAVE_SELECT -# include -# endif -# include -# include -# include -# include -# ifdef HAVE_POLL -# include -# endif -# include +#include +/* On older BSD types.h must come before net includes */ +#include +#include +#ifdef HAVE_SELECT +#include +#endif +#include +#include +#include +#include +#ifdef HAVE_POLL +#include +#endif +#include #endif -static int amqp_id_in_reply_list( amqp_method_number_t expected, amqp_method_number_t *list ); +static int amqp_id_in_reply_list(amqp_method_number_t expected, + amqp_method_number_t *list); -static int -amqp_os_socket_init(void) -{ +static int amqp_os_socket_init(void) { #ifdef _WIN32 - static called_wsastartup = 0; + static int called_wsastartup = 0; if (!called_wsastartup) { WSADATA data; int res = WSAStartup(0x0202, &data); @@ -103,87 +102,7 @@ #endif } -static int -amqp_os_socket_socket(int domain, int type, int protocol) -{ -#ifdef _WIN32 - /* - This cast is to squash warnings on Win64, see: - http://stackoverflow.com/questions/1953639/is-it-safe-to-cast-socket-to-int-under-win64 - */ - return (int)socket(domain, type, protocol); -#else - int flags; - - int s = socket(domain, type, protocol); - if (s < 0) { - return s; - } - - /* Always enable CLOEXEC on the socket */ - flags = fcntl(s, F_GETFD); - if (flags == -1 - || fcntl(s, F_SETFD, (long)(flags | FD_CLOEXEC)) == -1) { - int e = errno; - close(s); - errno = e; - return -1; - } - - return s; - -#endif -} - -static int -amqp_os_socket_setsockopt(int sock, int level, int optname, - const void *optval, size_t optlen) -{ -#ifdef _WIN32 - /* the winsock setsockopt function has its 4th argument as a - const char * */ - return setsockopt(sock, level, optname, (const char *)optval, (int)optlen); -#else - return setsockopt(sock, level, optname, optval, optlen); -#endif -} - -static int -amqp_os_socket_setsockblock(int sock, int block) -{ - -#ifdef _WIN32 - int nonblock = !block; - if (NO_ERROR != ioctlsocket(sock, FIONBIO, &nonblock)) { - return AMQP_STATUS_SOCKET_ERROR; - } else { - return AMQP_STATUS_OK; - } -#else - long arg; - - if ((arg = fcntl(sock, F_GETFL, NULL)) < 0) { - return AMQP_STATUS_SOCKET_ERROR; - } - - if (block) { - arg &= (~O_NONBLOCK); - } else { - arg |= O_NONBLOCK; - } - - if (fcntl(sock, F_SETFL, arg) < 0) { - return AMQP_STATUS_SOCKET_ERROR; - } - - return AMQP_STATUS_OK; -#endif -} - - -int -amqp_os_socket_error(void) -{ +int amqp_os_socket_error(void) { #ifdef _WIN32 return WSAGetLastError(); #else @@ -191,9 +110,7 @@ #endif } -int -amqp_os_socket_close(int sockfd) -{ +int amqp_os_socket_close(int sockfd) { #ifdef _WIN32 return closesocket(sockfd); #else @@ -201,58 +118,47 @@ #endif } -ssize_t -amqp_socket_send(amqp_socket_t *self, const void *buf, size_t len, int flags) -{ +ssize_t amqp_socket_send(amqp_socket_t *self, const void *buf, size_t len, + int flags) { assert(self); assert(self->klass->send); return self->klass->send(self, buf, len, flags); } -ssize_t -amqp_socket_recv(amqp_socket_t *self, void *buf, size_t len, int flags) -{ +ssize_t amqp_socket_recv(amqp_socket_t *self, void *buf, size_t len, + int flags) { assert(self); assert(self->klass->recv); return self->klass->recv(self, buf, len, flags); } -int -amqp_socket_open(amqp_socket_t *self, const char *host, int port) -{ +int amqp_socket_open(amqp_socket_t *self, const char *host, int port) { assert(self); assert(self->klass->open); return self->klass->open(self, host, port, NULL); } -int -amqp_socket_open_noblock(amqp_socket_t *self, const char *host, int port, struct timeval *timeout) -{ +int amqp_socket_open_noblock(amqp_socket_t *self, const char *host, int port, + struct timeval *timeout) { assert(self); assert(self->klass->open); return self->klass->open(self, host, port, timeout); } -int -amqp_socket_close(amqp_socket_t *self) -{ +int amqp_socket_close(amqp_socket_t *self, amqp_socket_close_enum force) { assert(self); assert(self->klass->close); - return self->klass->close(self); + return self->klass->close(self, force); } -void -amqp_socket_delete(amqp_socket_t *self) -{ +void amqp_socket_delete(amqp_socket_t *self) { if (self) { assert(self->klass->delete); - self->klass->delete(self); + self->klass->delete (self); } } -int -amqp_socket_get_sockfd(amqp_socket_t *self) -{ +int amqp_socket_get_sockfd(amqp_socket_t *self) { assert(self); assert(self->klass->get_sockfd); return self->klass->get_sockfd(self); @@ -303,27 +209,40 @@ return AMQP_STATUS_OK; #elif defined(HAVE_SELECT) fd_set fds; + fd_set exceptfds; + fd_set *exceptfdsp; int res; struct timeval tv; struct timeval *tvp; - assert(event == AMQP_SF_POLLIN || event == AMQP_SF_POLLOUT); + assert((0 != (event & AMQP_SF_POLLIN)) || (0 != (event & AMQP_SF_POLLOUT))); +#ifndef _WIN32 + /* On Win32 connect() failure is indicated through the exceptfds, it does not + * make any sense to allow POLLERR on any other platform or condition */ + assert(0 == (event & AMQP_SF_POLLERR)); +#endif start_select: FD_ZERO(&fds); FD_SET(fd, &fds); + if (event & AMQP_SF_POLLERR) { + FD_ZERO(&exceptfds); + FD_SET(fd, &exceptfds); + exceptfdsp = &exceptfds; + } else { + exceptfdsp = NULL; + } + res = amqp_time_tv_until(deadline, &tv, &tvp); if (res != AMQP_STATUS_OK) { return res; } - switch (event) { - case AMQP_SF_POLLIN: - res = select(fd + 1, &fds, NULL, NULL, tvp); - break; - case AMQP_SF_POLLOUT: - res = select(fd + 1, NULL, &fds, NULL, tvp); + if (event & AMQP_SF_POLLIN) { + res = select(fd + 1, &fds, NULL, exceptfdsp, tvp); + } else if (event & AMQP_SF_POLLOUT) { + res = select(fd + 1, NULL, &fds, exceptfdsp, tvp); } if (0 < res) { @@ -338,14 +257,13 @@ return AMQP_STATUS_SOCKET_ERROR; } } - return AMQP_STATUS_OK; #else -# error "poll() or select() is needed to compile rabbitmq-c" +#error "poll() or select() is needed to compile rabbitmq-c" #endif } static ssize_t do_poll(amqp_connection_state_t state, ssize_t res, - amqp_time_t deadline) { + amqp_time_t deadline) { int fd = amqp_get_sockfd(state); if (-1 == fd) { return AMQP_STATUS_SOCKET_CLOSED; @@ -364,7 +282,7 @@ ssize_t amqp_try_send(amqp_connection_state_t state, const void *buf, size_t len, amqp_time_t deadline, int flags) { ssize_t res; - void* buf_left = (void*)buf; + void *buf_left = (void *)buf; /* Assume that len is not going to be larger than ssize_t can hold. */ ssize_t len_left = (size_t)len; @@ -373,7 +291,7 @@ if (res > 0) { len_left -= res; - buf_left = (char*)buf_left + res; + buf_left = (char *)buf_left + res; if (0 == len_left) { return (ssize_t)len; } @@ -389,18 +307,12 @@ return res; } -int -amqp_open_socket(char const *hostname, - int portnumber) -{ - return amqp_open_socket_inner(hostname, portnumber, - amqp_time_infinite()); +int amqp_open_socket(char const *hostname, int portnumber) { + return amqp_open_socket_inner(hostname, portnumber, amqp_time_infinite()); } -int amqp_open_socket_noblock(char const *hostname, - int portnumber, - struct timeval *timeout) -{ +int amqp_open_socket_noblock(char const *hostname, int portnumber, + struct timeval *timeout) { amqp_time_t deadline; int res = amqp_time_from_now(&deadline, timeout); if (AMQP_STATUS_OK != res) { @@ -409,17 +321,162 @@ return amqp_open_socket_inner(hostname, portnumber, deadline); } -int amqp_open_socket_inner(char const *hostname, - int portnumber, +#ifdef _WIN32 +static int connect_socket(struct addrinfo *addr, amqp_time_t deadline) { + int one = 1; + SOCKET sockfd; + int last_error; + + /* + * This cast is to squash warnings on Win64, see: + * http://stackoverflow.com/questions/1953639/is-it-safe-to-cast-socket-to-int-under-win64 + */ + + sockfd = (int)socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); + if (INVALID_SOCKET == sockfd) { + return AMQP_STATUS_SOCKET_ERROR; + } + + /* Set the socket to be non-blocking */ + if (SOCKET_ERROR == ioctlsocket(sockfd, FIONBIO, &one)) { + last_error = AMQP_STATUS_SOCKET_ERROR; + goto err; + } + + /* Disable nagle */ + if (SOCKET_ERROR == setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, + (const char *)&one, sizeof(one))) { + last_error = AMQP_STATUS_SOCKET_ERROR; + goto err; + } + + /* Enable TCP keepalives */ + if (SOCKET_ERROR == setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, + (const char *)&one, sizeof(one))) { + last_error = AMQP_STATUS_SOCKET_ERROR; + goto err; + } + + if (SOCKET_ERROR != connect(sockfd, addr->ai_addr, (int)addr->ai_addrlen)) { + return (int)sockfd; + } + + if (WSAEWOULDBLOCK != WSAGetLastError()) { + last_error = AMQP_STATUS_SOCKET_ERROR; + goto err; + } + + last_error = + amqp_poll((int)sockfd, AMQP_SF_POLLOUT | AMQP_SF_POLLERR, deadline); + if (AMQP_STATUS_OK != last_error) { + goto err; + } + + { + int result; + int result_len = sizeof(result); + + if (SOCKET_ERROR == getsockopt(sockfd, SOL_SOCKET, SO_ERROR, + (char *)&result, &result_len) || + result != 0) { + last_error = AMQP_STATUS_SOCKET_ERROR; + goto err; + } + } + + return (int)sockfd; + +err: + closesocket(sockfd); + return last_error; +} +#else +static int connect_socket(struct addrinfo *addr, amqp_time_t deadline) { + int one = 1; + int sockfd; + int flags; + int last_error; + + sockfd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); + if (-1 == sockfd) { + return AMQP_STATUS_SOCKET_ERROR; + } + + /* Enable CLOEXEC on socket */ + flags = fcntl(sockfd, F_GETFD); + if (flags == -1 || fcntl(sockfd, F_SETFD, (long)(flags | FD_CLOEXEC)) == -1) { + last_error = AMQP_STATUS_SOCKET_ERROR; + goto err; + } + + /* Set the socket as non-blocking */ + flags = fcntl(sockfd, F_GETFL); + if (flags == -1 || fcntl(sockfd, F_SETFL, (long)(flags | O_NONBLOCK)) == -1) { + last_error = AMQP_STATUS_SOCKET_ERROR; + goto err; + } + +#ifdef SO_NOSIGPIPE + /* Turn off SIGPIPE on platforms that support it, BSD, MacOSX */ + if (0 != setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &one, sizeof(one))) { + last_error = AMQP_STATUS_SOCKET_ERROR; + goto err; + } +#endif /* SO_NOSIGPIPE */ + + /* Disable nagle */ + if (0 != setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one))) { + last_error = AMQP_STATUS_SOCKET_ERROR; + goto err; + } + + /* Enable TCP keepalives */ + if (0 != setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof(one))) { + last_error = AMQP_STATUS_SOCKET_ERROR; + goto err; + } + + if (0 == connect(sockfd, addr->ai_addr, addr->ai_addrlen)) { + return sockfd; + } + + if (EINPROGRESS != errno) { + last_error = AMQP_STATUS_SOCKET_ERROR; + goto err; + } + + last_error = amqp_poll(sockfd, AMQP_SF_POLLOUT, deadline); + if (AMQP_STATUS_OK != last_error) { + goto err; + } + + { + int result; + socklen_t result_len = sizeof(result); + + if (-1 == getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &result, &result_len) || + result != 0) { + last_error = AMQP_STATUS_SOCKET_ERROR; + goto err; + } + } + + return sockfd; + +err: + close(sockfd); + return last_error; +} +#endif + +int amqp_open_socket_inner(char const *hostname, int portnumber, amqp_time_t deadline) { struct addrinfo hint; struct addrinfo *address_list; struct addrinfo *addr; char portnumber_string[33]; int sockfd = -1; - int last_error = AMQP_STATUS_OK; - int one = 1; /* for setsockopt */ - int res; + int last_error; last_error = amqp_os_socket_init(); if (AMQP_STATUS_OK != last_error) { @@ -434,138 +491,70 @@ (void)sprintf(portnumber_string, "%d", portnumber); last_error = getaddrinfo(hostname, portnumber_string, &hint, &address_list); - if (0 != last_error) { return AMQP_STATUS_HOSTNAME_RESOLUTION_FAILED; } for (addr = address_list; addr; addr = addr->ai_next) { - if (-1 != sockfd) { - amqp_os_socket_close(sockfd); - } - - sockfd = amqp_os_socket_socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); - - if (-1 == sockfd) { - last_error = AMQP_STATUS_SOCKET_ERROR; - continue; - } - -#ifdef SO_NOSIGPIPE - if (0 != amqp_os_socket_setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &one, sizeof(one))) { - last_error = AMQP_STATUS_SOCKET_ERROR; - continue; - } -#endif /* SO_NOSIGPIPE */ - - if (0 != amqp_os_socket_setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one))) { - last_error = AMQP_STATUS_SOCKET_ERROR; - continue; - } - - if (AMQP_STATUS_OK != amqp_os_socket_setsockblock(sockfd, 0)) { - last_error = AMQP_STATUS_SOCKET_ERROR; - continue; - } - -#ifdef _WIN32 - res = connect(sockfd, addr->ai_addr, (int)addr->ai_addrlen); -#else - res = connect(sockfd, addr->ai_addr, addr->ai_addrlen); -#endif + sockfd = connect_socket(addr, deadline); - if (0 == res) { + if (sockfd >= 0) { last_error = AMQP_STATUS_OK; break; - } - -#ifdef _WIN32 - if (WSAEWOULDBLOCK == amqp_os_socket_error()) { -#else - if (EINPROGRESS == amqp_os_socket_error()) { -#endif - last_error = amqp_poll(sockfd, AMQP_SF_POLLOUT, deadline); - if (AMQP_STATUS_OK == last_error) { - int result; - socklen_t result_len = sizeof(result); - -#ifdef _WIN32 - if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (char *)&result, - (int *)&result_len) < 0 -#else - if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &result, &result_len) < 0 -#endif - || result != 0) { - last_error = AMQP_STATUS_SOCKET_ERROR; - } else { - last_error = AMQP_STATUS_OK; - } - } - - if (last_error == AMQP_STATUS_OK || last_error == AMQP_STATUS_TIMEOUT || - last_error == AMQP_STATUS_TIMER_FAILURE) { - /* Exit for loop on timer errors or when connection established */ - break; - } - - } else { - /* Error connecting */ - last_error = AMQP_STATUS_SOCKET_ERROR; + } else if (sockfd == AMQP_STATUS_TIMEOUT) { + last_error = sockfd; break; } } freeaddrinfo(address_list); - if (last_error != AMQP_STATUS_OK) { - if (-1 != sockfd) { - amqp_os_socket_close(sockfd); - } - + if (last_error != AMQP_STATUS_OK || sockfd == -1) { return last_error; } - return sockfd; } -int amqp_send_header(amqp_connection_state_t state) -{ +static int send_header_inner(amqp_connection_state_t state, + amqp_time_t deadline) { ssize_t res; - static const uint8_t header[8] = { 'A', 'M', 'Q', 'P', 0, - AMQP_PROTOCOL_VERSION_MAJOR, - AMQP_PROTOCOL_VERSION_MINOR, - AMQP_PROTOCOL_VERSION_REVISION - }; - res = amqp_try_send(state, header, sizeof(header), amqp_time_infinite(), - AMQP_SF_NONE); + static const uint8_t header[8] = {'A', + 'M', + 'Q', + 'P', + 0, + AMQP_PROTOCOL_VERSION_MAJOR, + AMQP_PROTOCOL_VERSION_MINOR, + AMQP_PROTOCOL_VERSION_REVISION}; + res = amqp_try_send(state, header, sizeof(header), deadline, AMQP_SF_NONE); if (sizeof(header) == res) { return AMQP_STATUS_OK; } return (int)res; } -static amqp_bytes_t sasl_method_name(amqp_sasl_method_enum method) -{ +int amqp_send_header(amqp_connection_state_t state) { + return send_header_inner(state, amqp_time_infinite()); +} + +static amqp_bytes_t sasl_method_name(amqp_sasl_method_enum method) { amqp_bytes_t res; switch (method) { - case AMQP_SASL_METHOD_PLAIN: - res.bytes = "PLAIN"; - res.len = 5; - break; - case AMQP_SASL_METHOD_EXTERNAL: - res.bytes = "EXTERNAL"; - res.len = 8; - break; + case AMQP_SASL_METHOD_PLAIN: + res = amqp_cstring_bytes("PLAIN"); + break; + case AMQP_SASL_METHOD_EXTERNAL: + res = amqp_cstring_bytes("EXTERNAL"); + break; - default: - amqp_abort("Invalid SASL method: %d", (int) method); + default: + amqp_abort("Invalid SASL method: %d", (int)method); } return res; } -static int bytes_equal(amqp_bytes_t l, amqp_bytes_t r) -{ +static int bytes_equal(amqp_bytes_t l, amqp_bytes_t r) { if (l.len == r.len) { if (l.bytes && r.bytes) { if (0 == memcmp(l.bytes, r.bytes, l.len)) { @@ -577,23 +566,22 @@ } int sasl_mechanism_in_list(amqp_bytes_t mechanisms, - amqp_sasl_method_enum method) -{ + amqp_sasl_method_enum method) { amqp_bytes_t mechanism; amqp_bytes_t supported_mechanism; - uint8_t* start; - uint8_t* end; - uint8_t* current; + uint8_t *start; + uint8_t *end; + uint8_t *current; assert(NULL != mechanisms.bytes); mechanism = sasl_method_name(method); - start = (uint8_t*)mechanisms.bytes; + start = (uint8_t *)mechanisms.bytes; current = start; end = start + mechanisms.len; - for ( ; current != end; start = current + 1) { + for (; current != end; start = current + 1) { /* HACK: SASL states that we should be parsing this string as a UTF-8 * string, which we're plainly not doing here. At this point its not worth * dragging an entire UTF-8 parser for this one case, and this should work @@ -613,55 +601,53 @@ } static amqp_bytes_t sasl_response(amqp_pool_t *pool, - amqp_sasl_method_enum method, - va_list args) -{ + amqp_sasl_method_enum method, va_list args) { amqp_bytes_t response; switch (method) { - case AMQP_SASL_METHOD_PLAIN: { - char *username = va_arg(args, char *); - size_t username_len = strlen(username); - char *password = va_arg(args, char *); - size_t password_len = strlen(password); - char *response_buf; - - amqp_pool_alloc_bytes(pool, strlen(username) + strlen(password) + 2, &response); - if (response.bytes == NULL) + case AMQP_SASL_METHOD_PLAIN: { + char *username = va_arg(args, char *); + size_t username_len = strlen(username); + char *password = va_arg(args, char *); + size_t password_len = strlen(password); + char *response_buf; + + amqp_pool_alloc_bytes(pool, strlen(username) + strlen(password) + 2, + &response); + if (response.bytes == NULL) /* We never request a zero-length block, because of the +2 above, so a NULL here really is ENOMEM. */ - { - return response; - } - - response_buf = response.bytes; - response_buf[0] = 0; - memcpy(response_buf + 1, username, username_len); - response_buf[username_len + 1] = 0; - memcpy(response_buf + username_len + 2, password, password_len); - break; - } - case AMQP_SASL_METHOD_EXTERNAL: { - char *identity = va_arg(args, char *); - size_t identity_len = strlen(identity); + { + return response; + } - amqp_pool_alloc_bytes(pool, identity_len, &response); - if (response.bytes == NULL) { - return response; + response_buf = response.bytes; + response_buf[0] = 0; + memcpy(response_buf + 1, username, username_len); + response_buf[username_len + 1] = 0; + memcpy(response_buf + username_len + 2, password, password_len); + break; } + case AMQP_SASL_METHOD_EXTERNAL: { + char *identity = va_arg(args, char *); + size_t identity_len = strlen(identity); + + amqp_pool_alloc_bytes(pool, identity_len, &response); + if (response.bytes == NULL) { + return response; + } - memcpy(response.bytes, identity, identity_len); - break; - } - default: - amqp_abort("Invalid SASL method: %d", (int) method); + memcpy(response.bytes, identity, identity_len); + break; + } + default: + amqp_abort("Invalid SASL method: %d", (int)method); } return response; } -amqp_boolean_t amqp_frames_enqueued(amqp_connection_state_t state) -{ +amqp_boolean_t amqp_frames_enqueued(amqp_connection_state_t state) { return (state->first_queued_frame != NULL); } @@ -669,18 +655,18 @@ * Check to see if we have data in our buffer. If this returns 1, we * will avoid an immediate blocking read in amqp_simple_wait_frame. */ -amqp_boolean_t amqp_data_in_buffer(amqp_connection_state_t state) -{ +amqp_boolean_t amqp_data_in_buffer(amqp_connection_state_t state) { return (state->sock_inbound_offset < state->sock_inbound_limit); } -static int consume_one_frame(amqp_connection_state_t state, amqp_frame_t *decoded_frame) -{ +static int consume_one_frame(amqp_connection_state_t state, + amqp_frame_t *decoded_frame) { int res; amqp_bytes_t buffer; buffer.len = state->sock_inbound_limit - state->sock_inbound_offset; - buffer.bytes = ((char *) state->sock_inbound_buffer.bytes) + state->sock_inbound_offset; + buffer.bytes = + ((char *)state->sock_inbound_buffer.bytes) + state->sock_inbound_offset; res = amqp_handle_input(state, buffer, decoded_frame); if (res < 0) { @@ -692,8 +678,8 @@ return AMQP_STATUS_OK; } - -static int recv_with_timeout(amqp_connection_state_t state, amqp_time_t timeout) { +static int recv_with_timeout(amqp_connection_state_t state, + amqp_time_t timeout) { ssize_t res; int fd; @@ -781,20 +767,11 @@ static int wait_frame_inner(amqp_connection_state_t state, amqp_frame_t *decoded_frame, - struct timeval *timeout) -{ + amqp_time_t timeout_deadline) { amqp_time_t deadline; - amqp_time_t timeout_deadline; int res; - res = amqp_time_from_now(&timeout_deadline, timeout); - if (AMQP_STATUS_OK != res) { - return res; - } - - while (1) { - int res; - + for (;;) { while (amqp_data_in_buffer(state)) { res = consume_one_frame(state, decoded_frame); @@ -813,7 +790,7 @@ } } -beginrecv: + beginrecv: res = amqp_time_has_past(state->next_send_heartbeat); if (AMQP_STATUS_TIMER_FAILURE == res) { return res; @@ -837,7 +814,7 @@ if (AMQP_STATUS_TIMEOUT == res) { if (amqp_time_equal(deadline, state->next_recv_heartbeat)) { - amqp_socket_close(state->socket); + amqp_socket_close(state->socket, AMQP_SC_FORCE); return AMQP_STATUS_HEARTBEAT_TIMEOUT; } else if (amqp_time_equal(deadline, timeout_deadline)) { return AMQP_STATUS_TIMEOUT; @@ -853,12 +830,13 @@ } } -static amqp_link_t * amqp_create_link_for_frame(amqp_connection_state_t state, amqp_frame_t *frame) -{ +static amqp_link_t *amqp_create_link_for_frame(amqp_connection_state_t state, + amqp_frame_t *frame) { amqp_link_t *link; amqp_frame_t *frame_copy; - amqp_pool_t *channel_pool = amqp_get_or_create_channel_pool(state, frame->channel); + amqp_pool_t *channel_pool = + amqp_get_or_create_channel_pool(state, frame->channel); if (NULL == channel_pool) { return NULL; @@ -877,8 +855,7 @@ return link; } -int amqp_queue_frame(amqp_connection_state_t state, amqp_frame_t *frame) -{ +int amqp_queue_frame(amqp_connection_state_t state, amqp_frame_t *frame) { amqp_link_t *link = amqp_create_link_for_frame(state, frame); if (NULL == link) { return AMQP_STATUS_NO_MEMORY; @@ -896,8 +873,7 @@ return AMQP_STATUS_OK; } -int amqp_put_back_frame(amqp_connection_state_t state, amqp_frame_t *frame) -{ +int amqp_put_back_frame(amqp_connection_state_t state, amqp_frame_t *frame) { amqp_link_t *link = amqp_create_link_for_frame(state, frame); if (NULL == link) { return AMQP_STATUS_NO_MEMORY; @@ -917,8 +893,7 @@ int amqp_simple_wait_frame_on_channel(amqp_connection_state_t state, amqp_channel_t channel, - amqp_frame_t *decoded_frame) -{ + amqp_frame_t *decoded_frame) { amqp_frame_t *frame_ptr; amqp_link_t *cur; int res; @@ -938,8 +913,8 @@ } } - while (1) { - res = wait_frame_inner(state, decoded_frame, NULL); + for (;;) { + res = wait_frame_inner(state, decoded_frame, amqp_time_infinite()); if (AMQP_STATUS_OK != res) { return res; @@ -957,17 +932,22 @@ } int amqp_simple_wait_frame(amqp_connection_state_t state, - amqp_frame_t *decoded_frame) -{ + amqp_frame_t *decoded_frame) { return amqp_simple_wait_frame_noblock(state, decoded_frame, NULL); } int amqp_simple_wait_frame_noblock(amqp_connection_state_t state, amqp_frame_t *decoded_frame, - struct timeval *timeout) -{ + struct timeval *timeout) { + amqp_time_t deadline; + + int res = amqp_time_from_now(&deadline, timeout); + if (AMQP_STATUS_OK != res) { + return res; + } + if (state->first_queued_frame != NULL) { - amqp_frame_t *f = (amqp_frame_t *) state->first_queued_frame->data; + amqp_frame_t *f = (amqp_frame_t *)state->first_queued_frame->data; state->first_queued_frame = state->first_queued_frame->next; if (state->first_queued_frame == NULL) { state->last_queued_frame = NULL; @@ -975,16 +955,25 @@ *decoded_frame = *f; return AMQP_STATUS_OK; } else { - return wait_frame_inner(state, decoded_frame, timeout); + return wait_frame_inner(state, decoded_frame, deadline); } } static int amqp_simple_wait_method_list(amqp_connection_state_t state, amqp_channel_t expected_channel, amqp_method_number_t *expected_methods, + amqp_time_t deadline, amqp_method_t *output) { amqp_frame_t frame; - int res = amqp_simple_wait_frame(state, &frame); + struct timeval tv; + struct timeval *tvp; + + int res = amqp_time_tv_until(deadline, &tv, &tvp); + if (res != AMQP_STATUS_OK) { + return res; + } + + res = amqp_simple_wait_frame_noblock(state, &frame, tvp); if (AMQP_STATUS_OK != res) { return res; } @@ -998,38 +987,46 @@ return AMQP_STATUS_OK; } +static int simple_wait_method_inner(amqp_connection_state_t state, + amqp_channel_t expected_channel, + amqp_method_number_t expected_method, + amqp_time_t deadline, + amqp_method_t *output) { + amqp_method_number_t expected_methods[] = {expected_method, 0}; + return amqp_simple_wait_method_list(state, expected_channel, expected_methods, + deadline, output); +} + 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) -{ - amqp_method_number_t expected_methods[] = { 0, 0 }; - expected_methods[0] = expected_method; - return amqp_simple_wait_method_list(state, expected_channel, expected_methods, - output); + amqp_method_t *output) { + return simple_wait_method_inner(state, expected_channel, expected_method, + amqp_time_infinite(), output); } int amqp_send_method(amqp_connection_state_t state, amqp_channel_t channel, amqp_method_number_t id, void *decoded) { - return amqp_send_method_inner(state, channel, id, decoded, AMQP_SF_NONE); + return amqp_send_method_inner(state, channel, id, decoded, AMQP_SF_NONE, + amqp_time_infinite()); } int amqp_send_method_inner(amqp_connection_state_t state, amqp_channel_t channel, amqp_method_number_t id, - void *decoded, int flags) { + void *decoded, int flags, amqp_time_t deadline) { amqp_frame_t frame; frame.frame_type = AMQP_FRAME_METHOD; frame.channel = channel; frame.payload.method.id = id; frame.payload.method.decoded = decoded; - return amqp_send_frame_inner(state, &frame, flags); + return amqp_send_frame_inner(state, &frame, flags, deadline); } -static int amqp_id_in_reply_list( amqp_method_number_t expected, amqp_method_number_t *list ) -{ - while ( *list != 0 ) { - if ( *list == expected ) { +static int amqp_id_in_reply_list(amqp_method_number_t expected, + amqp_method_number_t *list) { + while (*list != 0) { + if (*list == expected) { return 1; } list++; @@ -1037,12 +1034,10 @@ return 0; } -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) -{ +static amqp_rpc_reply_t simple_rpc_inner( + 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, amqp_time_t deadline) { int status; amqp_rpc_reply_t result; @@ -1050,20 +1045,19 @@ status = amqp_send_method(state, channel, request_id, decoded_request_method); if (status < 0) { - result.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; - result.library_error = status; - return result; + return amqp_rpc_reply_error(status); } { amqp_frame_t frame; -retry: - status = wait_frame_inner(state, &frame, NULL); + retry: + status = wait_frame_inner(state, &frame, deadline); if (status < 0) { - result.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; - result.library_error = status; - return result; + if (status == AMQP_STATUS_TIMEOUT) { + amqp_socket_close(state->socket, AMQP_SC_FORCE); + } + return amqp_rpc_reply_error(status); } /* @@ -1074,34 +1068,27 @@ * - on the channel we want, and a channel.close frame, or * - on channel zero, and a connection.close frame. */ - if (!((frame.frame_type == AMQP_FRAME_METHOD) - && ( - ((frame.channel == channel) - && (amqp_id_in_reply_list(frame.payload.method.id, expected_reply_ids) - || (frame.payload.method.id == AMQP_CHANNEL_CLOSE_METHOD))) - || - ((frame.channel == 0) - && (frame.payload.method.id == AMQP_CONNECTION_CLOSE_METHOD)) - ) - )) { + if (!((frame.frame_type == AMQP_FRAME_METHOD) && + (((frame.channel == channel) && + (amqp_id_in_reply_list(frame.payload.method.id, + expected_reply_ids) || + (frame.payload.method.id == AMQP_CHANNEL_CLOSE_METHOD))) || + ((frame.channel == 0) && + (frame.payload.method.id == AMQP_CONNECTION_CLOSE_METHOD))))) { amqp_pool_t *channel_pool; amqp_frame_t *frame_copy; amqp_link_t *link; channel_pool = amqp_get_or_create_channel_pool(state, frame.channel); if (NULL == channel_pool) { - result.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; - result.library_error = AMQP_STATUS_NO_MEMORY; - return result; + return amqp_rpc_reply_error(AMQP_STATUS_NO_MEMORY); } frame_copy = amqp_pool_alloc(channel_pool, sizeof(amqp_frame_t)); link = amqp_pool_alloc(channel_pool, sizeof(amqp_link_t)); if (frame_copy == NULL || link == NULL) { - result.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; - result.library_error = AMQP_STATUS_NO_MEMORY; - return result; + return amqp_rpc_reply_error(AMQP_STATUS_NO_MEMORY); } *frame_copy = frame; @@ -1119,29 +1106,54 @@ goto retry; } - result.reply_type = (amqp_id_in_reply_list(frame.payload.method.id, expected_reply_ids)) - ? AMQP_RESPONSE_NORMAL - : AMQP_RESPONSE_SERVER_EXCEPTION; + result.reply_type = + (amqp_id_in_reply_list(frame.payload.method.id, expected_reply_ids)) + ? AMQP_RESPONSE_NORMAL + : AMQP_RESPONSE_SERVER_EXCEPTION; result.reply = frame.payload.method; return result; } } +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) { + amqp_time_t deadline; + int res; + + res = amqp_time_from_now(&deadline, state->rpc_timeout); + if (res != AMQP_STATUS_OK) { + return amqp_rpc_reply_error(res); + } + + return simple_rpc_inner(state, channel, request_id, expected_reply_ids, + decoded_request_method, deadline); +} + 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) -{ + void *decoded_request_method) { + amqp_time_t deadline; + int res; amqp_method_number_t replies[2]; + res = amqp_time_from_now(&deadline, state->rpc_timeout); + if (res != AMQP_STATUS_OK) { + state->most_recent_api_result = amqp_rpc_reply_error(res); + return NULL; + } + replies[0] = reply_id; replies[1] = 0; - state->most_recent_api_result = amqp_simple_rpc(state, channel, - request_id, replies, - decoded_request_method); + state->most_recent_api_result = simple_rpc_inner( + state, channel, request_id, replies, decoded_request_method, deadline); + if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL) { return state->most_recent_api_result.reply.decoded; } else { @@ -1149,8 +1161,7 @@ } } -amqp_rpc_reply_t amqp_get_rpc_reply(amqp_connection_state_t state) -{ +amqp_rpc_reply_t amqp_get_rpc_reply(amqp_connection_state_t state) { return state->most_recent_api_result; } @@ -1215,37 +1226,59 @@ return res; } -static amqp_rpc_reply_t amqp_login_inner(amqp_connection_state_t state, - char const *vhost, - int channel_max, - int frame_max, - int heartbeat, - const amqp_table_t *client_properties, - amqp_sasl_method_enum sasl_method, - va_list vl) -{ +static amqp_rpc_reply_t amqp_login_inner( + amqp_connection_state_t state, char const *vhost, int channel_max, + int frame_max, int heartbeat, const amqp_table_t *client_properties, + struct timeval *timeout, amqp_sasl_method_enum sasl_method, va_list vl) { int res; amqp_method_t method; - int server_frame_max; + + uint16_t client_channel_max; + uint32_t client_frame_max; + uint16_t client_heartbeat; + uint16_t server_channel_max; + uint32_t server_frame_max; uint16_t server_heartbeat; + amqp_rpc_reply_t result; + amqp_time_t deadline; - res = amqp_send_header(state); + if (channel_max < 0 || channel_max > UINT16_MAX) { + return amqp_rpc_reply_error(AMQP_STATUS_INVALID_PARAMETER); + } + client_channel_max = (uint16_t)channel_max; + + if (frame_max < 0) { + return amqp_rpc_reply_error(AMQP_STATUS_INVALID_PARAMETER); + } + client_frame_max = (uint32_t)frame_max; + + if (heartbeat < 0 || heartbeat > UINT16_MAX) { + return amqp_rpc_reply_error(AMQP_STATUS_INVALID_PARAMETER); + } + client_heartbeat = (uint16_t)heartbeat; + + res = amqp_time_from_now(&deadline, timeout); if (AMQP_STATUS_OK != res) { goto error_res; } - res = amqp_simple_wait_method(state, 0, AMQP_CONNECTION_START_METHOD, - &method); - if (res < 0) { + res = send_header_inner(state, deadline); + if (AMQP_STATUS_OK != res) { + goto error_res; + } + + res = simple_wait_method_inner(state, 0, AMQP_CONNECTION_START_METHOD, + deadline, &method); + if (AMQP_STATUS_OK != res) { goto error_res; } { - amqp_connection_start_t *s = (amqp_connection_start_t *) method.decoded; - if ((s->version_major != AMQP_PROTOCOL_VERSION_MAJOR) - || (s->version_minor != AMQP_PROTOCOL_VERSION_MINOR)) { + amqp_connection_start_t *s = (amqp_connection_start_t *)method.decoded; + if ((s->version_major != AMQP_PROTOCOL_VERSION_MAJOR) || + (s->version_minor != AMQP_PROTOCOL_VERSION_MINOR)) { res = AMQP_STATUS_INCOMPATIBLE_AMQP_VERSION; goto error_res; } @@ -1269,7 +1302,7 @@ { amqp_table_entry_t default_properties[6]; amqp_table_t default_table; - amqp_table_entry_t client_capabilities[1]; + amqp_table_entry_t client_capabilities[2]; amqp_table_t client_capabilities_table; amqp_connection_start_ok_t s; amqp_pool_t *channel_pool; @@ -1281,8 +1314,7 @@ goto error_res; } - response_bytes = sasl_response(channel_pool, - sasl_method, vl); + response_bytes = sasl_response(channel_pool, sasl_method, vl); if (response_bytes.bytes == NULL) { res = AMQP_STATUS_NO_MEMORY; goto error_res; @@ -1290,6 +1322,8 @@ client_capabilities[0] = amqp_table_construct_bool_entry("authentication_failure_close", 1); + client_capabilities[1] = + amqp_table_construct_bool_entry("exchange_exchange_bindings", 1); client_capabilities_table.entries = client_capabilities; client_capabilities_table.num_entries = @@ -1323,7 +1357,8 @@ s.response = response_bytes; s.locale = amqp_cstring_bytes("en_US"); - res = amqp_send_method(state, 0, AMQP_CONNECTION_START_OK_METHOD, &s); + res = amqp_send_method_inner(state, 0, AMQP_CONNECTION_START_OK_METHOD, &s, + AMQP_SF_NONE, deadline); if (res < 0) { goto error_res; } @@ -1332,9 +1367,10 @@ amqp_release_buffers(state); { - amqp_method_number_t expected[] = { AMQP_CONNECTION_TUNE_METHOD, - AMQP_CONNECTION_CLOSE_METHOD, 0 }; - res = amqp_simple_wait_method_list(state, 0, expected, &method); + amqp_method_number_t expected[] = {AMQP_CONNECTION_TUNE_METHOD, + AMQP_CONNECTION_CLOSE_METHOD, 0}; + + res = amqp_simple_wait_method_list(state, 0, expected, deadline, &method); if (AMQP_STATUS_OK != res) { goto error_res; } @@ -1348,39 +1384,41 @@ } { - amqp_connection_tune_t *s = (amqp_connection_tune_t *) method.decoded; + amqp_connection_tune_t *s = (amqp_connection_tune_t *)method.decoded; server_channel_max = s->channel_max; server_frame_max = s->frame_max; server_heartbeat = s->heartbeat; } if (server_channel_max != 0 && - (server_channel_max < channel_max || channel_max == 0)) { - channel_max = server_channel_max; - } else if (server_channel_max == 0 && channel_max == 0) { - channel_max = UINT16_MAX; + (server_channel_max < client_channel_max || client_channel_max == 0)) { + client_channel_max = server_channel_max; + } else if (server_channel_max == 0 && client_channel_max == 0) { + client_channel_max = UINT16_MAX; } - if (server_frame_max != 0 && server_frame_max < frame_max) { - frame_max = server_frame_max; + if (server_frame_max != 0 && server_frame_max < client_frame_max) { + client_frame_max = server_frame_max; } - if (server_heartbeat != 0 && server_heartbeat < heartbeat) { - heartbeat = server_heartbeat; + if (server_heartbeat != 0 && server_heartbeat < client_heartbeat) { + client_heartbeat = server_heartbeat; } - res = amqp_tune_connection(state, channel_max, frame_max, heartbeat); + res = amqp_tune_connection(state, client_channel_max, client_frame_max, + client_heartbeat); if (res < 0) { goto error_res; } { amqp_connection_tune_ok_t s; - s.frame_max = frame_max; - s.channel_max = channel_max; - s.heartbeat = heartbeat; + s.frame_max = client_frame_max; + s.channel_max = client_channel_max; + s.heartbeat = client_heartbeat; - res = amqp_send_method(state, 0, AMQP_CONNECTION_TUNE_OK_METHOD, &s); + res = amqp_send_method_inner(state, 0, AMQP_CONNECTION_TUNE_OK_METHOD, &s, + AMQP_SF_NONE, deadline); if (res < 0) { goto error_res; } @@ -1389,18 +1427,14 @@ amqp_release_buffers(state); { - amqp_method_number_t replies[] = { AMQP_CONNECTION_OPEN_OK_METHOD, 0 }; + amqp_method_number_t replies[] = {AMQP_CONNECTION_OPEN_OK_METHOD, 0}; amqp_connection_open_t s; s.virtual_host = amqp_cstring_bytes(vhost); - s.capabilities.len = 0; - s.capabilities.bytes = NULL; + s.capabilities = amqp_empty_bytes; s.insist = 1; - result = amqp_simple_rpc(state, - 0, - AMQP_CONNECTION_OPEN_METHOD, - (amqp_method_number_t *) &replies, - &s); + result = simple_rpc_inner(state, 0, AMQP_CONNECTION_OPEN_METHOD, replies, + &s, deadline); if (result.reply_type != AMQP_RESPONSE_NORMAL) { goto out; } @@ -1416,51 +1450,41 @@ return result; error_res: - result.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION; - result.reply.id = 0; - result.reply.decoded = NULL; - result.library_error = res; + amqp_socket_close(state->socket, AMQP_SC_FORCE); + result = amqp_rpc_reply_error(res); goto out; } -amqp_rpc_reply_t amqp_login(amqp_connection_state_t state, - char const *vhost, - int channel_max, - int frame_max, - int heartbeat, - amqp_sasl_method_enum sasl_method, - ...) -{ +amqp_rpc_reply_t amqp_login(amqp_connection_state_t state, char const *vhost, + int channel_max, int frame_max, int heartbeat, + int sasl_method, ...) { va_list vl; amqp_rpc_reply_t ret; va_start(vl, sasl_method); ret = amqp_login_inner(state, vhost, channel_max, frame_max, heartbeat, - &amqp_empty_table, sasl_method, vl); + &amqp_empty_table, state->handshake_timeout, + sasl_method, vl); va_end(vl); return ret; } -amqp_rpc_reply_t amqp_login_with_properties(amqp_connection_state_t state, - char const *vhost, - int channel_max, - int frame_max, - int heartbeat, - const amqp_table_t *client_properties, - amqp_sasl_method_enum sasl_method, - ...) -{ +amqp_rpc_reply_t amqp_login_with_properties( + amqp_connection_state_t state, char const *vhost, int channel_max, + int frame_max, int heartbeat, const amqp_table_t *client_properties, + int sasl_method, ...) { va_list vl; amqp_rpc_reply_t ret; va_start(vl, sasl_method); ret = amqp_login_inner(state, vhost, channel_max, frame_max, heartbeat, - client_properties, sasl_method, vl); + client_properties, state->handshake_timeout, + sasl_method, vl); va_end(vl); diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_socket.h librabbitmq-0.9.0-0.1/librabbitmq/amqp_socket.h --- librabbitmq-0.7.1/librabbitmq/amqp_socket.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_socket.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * Portions created by Alan Antonuk are Copyright (c) 2013-2014 Alan Antonuk. * All Rights Reserved. @@ -41,20 +40,21 @@ AMQP_SF_NONE = 0, AMQP_SF_MORE = 1, AMQP_SF_POLLIN = 2, - AMQP_SF_POLLOUT = 4 + AMQP_SF_POLLOUT = 4, + AMQP_SF_POLLERR = 8 } amqp_socket_flag_enum; -int -amqp_os_socket_error(void); +typedef enum { AMQP_SC_NONE = 0, AMQP_SC_FORCE = 1 } amqp_socket_close_enum; -int -amqp_os_socket_close(int sockfd); +int amqp_os_socket_error(void); + +int amqp_os_socket_close(int sockfd); /* Socket callbacks. */ typedef ssize_t (*amqp_socket_send_fn)(void *, const void *, size_t, int); typedef ssize_t (*amqp_socket_recv_fn)(void *, void *, size_t, int); typedef int (*amqp_socket_open_fn)(void *, const char *, int, struct timeval *); -typedef int (*amqp_socket_close_fn)(void *); +typedef int (*amqp_socket_close_fn)(void *, amqp_socket_close_enum); typedef int (*amqp_socket_get_sockfd_fn)(void *); typedef void (*amqp_socket_delete_fn)(void *); @@ -73,7 +73,6 @@ const struct amqp_socket_class_t *klass; }; - /** * Set set the socket object for a connection * @@ -83,9 +82,7 @@ * \param [in] state The connection object to add the socket to * \param [in] socket The socket object to assign to the connection */ -void -amqp_set_socket(amqp_connection_state_t state, amqp_socket_t *socket); - +void amqp_set_socket(amqp_connection_state_t state, amqp_socket_t *socket); /** * Send a message from a socket. @@ -102,8 +99,8 @@ * * \return AMQP_STATUS_OK on success. amqp_status_enum value otherwise */ -ssize_t -amqp_socket_send(amqp_socket_t *self, const void *buf, size_t len, int flags); +ssize_t amqp_socket_send(amqp_socket_t *self, const void *buf, size_t len, + int flags); ssize_t amqp_try_send(amqp_connection_state_t state, const void *buf, size_t len, amqp_time_t deadline, int flags); @@ -120,8 +117,7 @@ * * \return The number of bytes received, or < 0 on error (\ref amqp_status_enum) */ -ssize_t -amqp_socket_recv(amqp_socket_t *self, void *buf, size_t len, int flags); +ssize_t amqp_socket_recv(amqp_socket_t *self, void *buf, size_t len, int flags); /** * Close a socket connection and free resources. @@ -131,19 +127,19 @@ * longer be referenced. * * \param [in,out] self A socket object. + * \param [in] force, if set, just close the socket, don't attempt a TLS + * shutdown. * * \return Zero upon success, non-zero otherwise. */ -int -amqp_socket_close(amqp_socket_t *self); +int amqp_socket_close(amqp_socket_t *self, amqp_socket_close_enum force); /** * Destroy a socket object * * \param [in] self the socket object to delete */ -void -amqp_socket_delete(amqp_socket_t *self); +void amqp_socket_delete(amqp_socket_t *self); /** * Open a socket connection. @@ -155,12 +151,13 @@ * * \param [in] host Connect to this host. * \param [in] port Connect on this remote port. - * \param [in] timeout Max allowed time to spent on opening. If NULL - run in blocking mode + * \param [in] timeout Max allowed time to spent on opening. If NULL - run in + * blocking mode * * \return File descriptor upon success, non-zero negative error code otherwise. */ -int -amqp_open_socket_noblock(char const *hostname, int portnumber, struct timeval *timeout); +int amqp_open_socket_noblock(char const *hostname, int portnumber, + struct timeval *timeout); int amqp_open_socket_inner(char const *hostname, int portnumber, amqp_time_t deadline); @@ -171,20 +168,18 @@ int amqp_send_method_inner(amqp_connection_state_t state, amqp_channel_t channel, amqp_method_number_t id, - void *decoded, int flags); -int -amqp_queue_frame(amqp_connection_state_t state, amqp_frame_t *frame); - -int -amqp_put_back_frame(amqp_connection_state_t state, amqp_frame_t *frame); - -int -amqp_simple_wait_frame_on_channel(amqp_connection_state_t state, - amqp_channel_t channel, - amqp_frame_t *decoded_frame); + void *decoded, int flags, amqp_time_t deadline); + +int amqp_queue_frame(amqp_connection_state_t state, amqp_frame_t *frame); + +int amqp_put_back_frame(amqp_connection_state_t state, amqp_frame_t *frame); + +int amqp_simple_wait_frame_on_channel(amqp_connection_state_t state, + amqp_channel_t channel, + amqp_frame_t *decoded_frame); -int -sasl_mechanism_in_list(amqp_bytes_t mechanisms, amqp_sasl_method_enum method); +int sasl_mechanism_in_list(amqp_bytes_t mechanisms, + amqp_sasl_method_enum method); int amqp_merge_capabilities(const amqp_table_t *base, const amqp_table_t *add, amqp_table_t *result, amqp_pool_t *pool); diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_ssl_socket.h librabbitmq-0.9.0-0.1/librabbitmq/amqp_ssl_socket.h --- librabbitmq-0.7.1/librabbitmq/amqp_ssl_socket.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_ssl_socket.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /** \file */ /* * Portions created by Alan Antonuk are Copyright (c) 2013-2014 Alan Antonuk. @@ -36,9 +35,9 @@ /** * Create a new SSL/TLS socket object. * - * The returned socket object is owned by the \ref amqp_connection_state_t object - * and will be destroyed when the state object is destroyed or a new socket - * object is created. + * The returned socket object is owned by the \ref amqp_connection_state_t + * object and will be destroyed when the state object is destroyed or a new + * socket object is created. * * If the socket object creation fails, the \ref amqp_connection_state_t object * will not be changed. @@ -46,7 +45,8 @@ * The object returned by this function can be retrieved from the * amqp_connection_state_t object later using the amqp_get_socket() function. * - * Calling this function may result in the underlying SSL library being initialized. + * Calling this function may result in the underlying SSL library being + * initialized. * \sa amqp_set_initialize_ssl_library() * * \param [in,out] state The connection object that owns the SSL/TLS socket @@ -55,9 +55,7 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -amqp_socket_t * -AMQP_CALL -amqp_ssl_socket_new(amqp_connection_state_t state); +amqp_socket_t *AMQP_CALL amqp_ssl_socket_new(amqp_connection_state_t state); /** * Set the CA certificate. @@ -71,10 +69,8 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL -amqp_ssl_socket_set_cacert(amqp_socket_t *self, - const char *cacert); +int AMQP_CALL amqp_ssl_socket_set_cacert(amqp_socket_t *self, + const char *cacert); /** * Set the client key. @@ -89,11 +85,8 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL -amqp_ssl_socket_set_key(amqp_socket_t *self, - const char *cert, - const char *key); +int AMQP_CALL amqp_ssl_socket_set_key(amqp_socket_t *self, const char *cert, + const char *key); /** * Set the client key from a buffer. @@ -109,16 +102,16 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -int -AMQP_CALL -amqp_ssl_socket_set_key_buffer(amqp_socket_t *self, - const char *cert, - const void *key, - size_t n); +int AMQP_CALL amqp_ssl_socket_set_key_buffer(amqp_socket_t *self, + const char *cert, const void *key, + size_t n); /** * Enable or disable peer verification. * + * \deprecated use \amqp_ssl_socket_set_verify_peer and + * \amqp_ssl_socket_set_verify_hostname instead. + * * If peer verification is enabled then the common name in the server * certificate must match the server name. Peer verification is enabled by * default. @@ -128,26 +121,78 @@ * * \since v0.4.0 */ +AMQP_DEPRECATED(AMQP_PUBLIC_FUNCTION void AMQP_CALL amqp_ssl_socket_set_verify( + amqp_socket_t *self, amqp_boolean_t verify)); + +/** + * Enable or disable peer verification. + * + * Peer verification validates the certificate chain that is sent by the broker. + * Hostname validation is controlled by \amqp_ssl_socket_set_verify_peer. + * + * \param [in,out] self An SSL/TLS socket object. + * \param [in] verify enable or disable peer validation + * + * \since v0.8.0 + */ +AMQP_PUBLIC_FUNCTION +void AMQP_CALL amqp_ssl_socket_set_verify_peer(amqp_socket_t *self, + amqp_boolean_t verify); + +/** + * Enable or disable hostname verification. + * + * Hostname verification checks the broker cert for a CN or SAN that matches the + * hostname that amqp_socket_open() is presented. Peer verification is + * controlled by \amqp_ssl_socket_set_verify_peer + * + * \since v0.8.0 + */ +AMQP_PUBLIC_FUNCTION +void AMQP_CALL amqp_ssl_socket_set_verify_hostname(amqp_socket_t *self, + amqp_boolean_t verify); + +typedef enum { + AMQP_TLSv1 = 1, + AMQP_TLSv1_1 = 2, + AMQP_TLSv1_2 = 3, + AMQP_TLSvLATEST = 0xFFFF +} amqp_tls_version_t; + +/** + * Set min and max TLS versions. + * + * Set the oldest and newest acceptable TLS versions that are acceptable when + * connecting to the broker. Set min == max to restrict to just that + * version. + * + * \param [in,out] self An SSL/TLS socket object. + * \param [in] min the minimum acceptable TLS version + * \param [in] max the maxmium acceptable TLS version + * \returns AMQP_STATUS_OK on success, AMQP_STATUS_UNSUPPORTED if OpenSSL does + * not support the requested TLS version, AMQP_STATUS_INVALID_PARAMETER if an + * invalid combination of parameters is passed. + * + * \since v0.8.0 + */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL -amqp_ssl_socket_set_verify(amqp_socket_t *self, - amqp_boolean_t verify); +int AMQP_CALL amqp_ssl_socket_set_ssl_versions(amqp_socket_t *self, + amqp_tls_version_t min, + amqp_tls_version_t max); /** - * Sets whether rabbitmq-c initializes the underlying SSL library. - * - * For SSL libraries that require a one-time initialization across - * a whole program (e.g., OpenSSL) this sets whether or not rabbitmq-c - * will initialize the SSL library when the first call to - * amqp_open_socket() is made. You should call this function with + * Sets whether rabbitmq-c will initialize OpenSSL. + * + * OpenSSL requires a one-time initialization across a whole program, this sets + * whether or not rabbitmq-c will initialize the SSL library when the first call + * to amqp_ssl_socket_new() is made. You should call this function with * do_init = 0 if the underlying SSL library is initialized somewhere else * the program. * * Failing to initialize or double initialization of the SSL library will * result in undefined behavior * - * By default rabbitmq-c will initialize the underlying SSL library + * By default rabbitmq-c will initialize the underlying SSL library. * * NOTE: calling this function after the first socket has been opened with * amqp_open_socket() will not have any effect. @@ -159,9 +204,35 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL -amqp_set_initialize_ssl_library(amqp_boolean_t do_initialize); +void AMQP_CALL amqp_set_initialize_ssl_library(amqp_boolean_t do_initialize); + +/** + * Initialize the underlying SSL/TLS library. + * + * The OpenSSL library requires a one-time initialization across the whole + * program. + * + * This function unconditionally initializes OpenSSL so that rabbitmq-c may + * use it. + * + * This function is thread-safe, and may be called more than once. + * + * \return AMQP_STATUS_OK on success. + * + * \since v0.9.0 + */ +AMQP_PUBLIC_FUNCTION +int AMQP_CALL amqp_initialize_ssl_library(void); + +/** + * Uninitialize the underlying SSL/TLS library. + * + * \return AMQP_STATUS_OK on success. + * + * \since v0.9.0 + */ +AMQP_PUBLIC_FUNCTION +int AMQP_CALL amqp_uninitialize_ssl_library(void); AMQP_END_DECLS diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_table.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_table.c --- librabbitmq-0.7.1/librabbitmq/amqp_table.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_table.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -49,22 +48,16 @@ #define INITIAL_ARRAY_SIZE 16 #define INITIAL_TABLE_SIZE 16 -static int amqp_decode_field_value(amqp_bytes_t encoded, - amqp_pool_t *pool, - amqp_field_value_t *entry, - size_t *offset); +static int amqp_decode_field_value(amqp_bytes_t encoded, amqp_pool_t *pool, + amqp_field_value_t *entry, size_t *offset); static int amqp_encode_field_value(amqp_bytes_t encoded, - amqp_field_value_t *entry, - size_t *offset); + amqp_field_value_t *entry, size_t *offset); /*---------------------------------------------------------------------------*/ -static int amqp_decode_array(amqp_bytes_t encoded, - amqp_pool_t *pool, - amqp_array_t *output, - size_t *offset) -{ +static int amqp_decode_array(amqp_bytes_t encoded, amqp_pool_t *pool, + amqp_array_t *output, size_t *offset) { uint32_t arraysize; int num_entries = 0; int allocated_entries = INITIAL_ARRAY_SIZE; @@ -76,6 +69,10 @@ return AMQP_STATUS_BAD_AMQP_DATA; } + if (arraysize + *offset > encoded.len) { + return AMQP_STATUS_BAD_AMQP_DATA; + } + entries = malloc(allocated_entries * sizeof(amqp_field_value_t)); if (entries == NULL) { return AMQP_STATUS_NO_MEMORY; @@ -86,7 +83,8 @@ if (num_entries >= allocated_entries) { void *newentries; allocated_entries = allocated_entries * 2; - newentries = realloc(entries, allocated_entries * sizeof(amqp_field_value_t)); + newentries = + realloc(entries, allocated_entries * sizeof(amqp_field_value_t)); res = AMQP_STATUS_NO_MEMORY; if (newentries == NULL) { goto out; @@ -95,8 +93,7 @@ entries = newentries; } - res = amqp_decode_field_value(encoded, pool, &entries[num_entries], - offset); + res = amqp_decode_field_value(encoded, pool, &entries[num_entries], offset); if (res < 0) { goto out; } @@ -105,26 +102,28 @@ } output->num_entries = num_entries; - output->entries = amqp_pool_alloc(pool, num_entries * sizeof(amqp_field_value_t)); - res = AMQP_STATUS_NO_MEMORY; + output->entries = + amqp_pool_alloc(pool, num_entries * sizeof(amqp_field_value_t)); /* NULL is legitimate if we requested a zero-length block. */ - if (output->entries == NULL && num_entries > 0) { + if (output->entries == NULL) { + if (num_entries == 0) { + res = AMQP_STATUS_OK; + } else { + res = AMQP_STATUS_NO_MEMORY; + } goto out; } memcpy(output->entries, entries, num_entries * sizeof(amqp_field_value_t)); - res = 0; + res = AMQP_STATUS_OK; out: free(entries); return res; } -int amqp_decode_table(amqp_bytes_t encoded, - amqp_pool_t *pool, - amqp_table_t *output, - size_t *offset) -{ +int amqp_decode_table(amqp_bytes_t encoded, amqp_pool_t *pool, + amqp_table_t *output, size_t *offset) { uint32_t tablesize; int num_entries = 0; amqp_table_entry_t *entries; @@ -136,6 +135,10 @@ return AMQP_STATUS_BAD_AMQP_DATA; } + if (tablesize + *offset > encoded.len) { + return AMQP_STATUS_BAD_AMQP_DATA; + } + entries = malloc(allocated_entries * sizeof(amqp_table_entry_t)); if (entries == NULL) { return AMQP_STATUS_NO_MEMORY; @@ -153,7 +156,8 @@ if (num_entries >= allocated_entries) { void *newentries; allocated_entries = allocated_entries * 2; - newentries = realloc(entries, allocated_entries * sizeof(amqp_table_entry_t)); + newentries = + realloc(entries, allocated_entries * sizeof(amqp_table_entry_t)); res = AMQP_STATUS_NO_MEMORY; if (newentries == NULL) { goto out; @@ -163,7 +167,8 @@ } res = AMQP_STATUS_BAD_AMQP_DATA; - if (!amqp_decode_bytes(encoded, offset, &entries[num_entries].key, keylen)) { + if (!amqp_decode_bytes(encoded, offset, &entries[num_entries].key, + keylen)) { goto out; } @@ -177,10 +182,15 @@ } output->num_entries = num_entries; - output->entries = amqp_pool_alloc(pool, num_entries * sizeof(amqp_table_entry_t)); - res = AMQP_STATUS_NO_MEMORY; + output->entries = + amqp_pool_alloc(pool, num_entries * sizeof(amqp_table_entry_t)); /* NULL is legitimate if we requested a zero-length block. */ - if (output->entries == NULL && num_entries > 0) { + if (output->entries == NULL) { + if (num_entries == 0) { + res = AMQP_STATUS_OK; + } else { + res = AMQP_STATUS_NO_MEMORY; + } goto out; } @@ -192,88 +202,93 @@ return res; } -static int amqp_decode_field_value(amqp_bytes_t encoded, - amqp_pool_t *pool, - amqp_field_value_t *entry, - size_t *offset) -{ +static int amqp_decode_field_value(amqp_bytes_t encoded, amqp_pool_t *pool, + amqp_field_value_t *entry, size_t *offset) { int res = AMQP_STATUS_BAD_AMQP_DATA; if (!amqp_decode_8(encoded, offset, &entry->kind)) { goto out; } -#define TRIVIAL_FIELD_DECODER(bits) if (!amqp_decode_##bits(encoded, offset, &entry->value.u##bits)) goto out; break -#define SIMPLE_FIELD_DECODER(bits, dest, how) { uint##bits##_t val; if (!amqp_decode_##bits(encoded, offset, &val)) goto out; entry->value.dest = how; } break +#define TRIVIAL_FIELD_DECODER(bits) \ + if (!amqp_decode_##bits(encoded, offset, &entry->value.u##bits)) goto out; \ + break +#define SIMPLE_FIELD_DECODER(bits, dest, how) \ + { \ + uint##bits##_t val; \ + if (!amqp_decode_##bits(encoded, offset, &val)) goto out; \ + entry->value.dest = how; \ + } \ + break switch (entry->kind) { - case AMQP_FIELD_KIND_BOOLEAN: - SIMPLE_FIELD_DECODER(8, boolean, val ? 1 : 0); + case AMQP_FIELD_KIND_BOOLEAN: + SIMPLE_FIELD_DECODER(8, boolean, val ? 1 : 0); + + case AMQP_FIELD_KIND_I8: + SIMPLE_FIELD_DECODER(8, i8, (int8_t)val); + case AMQP_FIELD_KIND_U8: + TRIVIAL_FIELD_DECODER(8); + + case AMQP_FIELD_KIND_I16: + SIMPLE_FIELD_DECODER(16, i16, (int16_t)val); + case AMQP_FIELD_KIND_U16: + TRIVIAL_FIELD_DECODER(16); + + case AMQP_FIELD_KIND_I32: + SIMPLE_FIELD_DECODER(32, i32, (int32_t)val); + case AMQP_FIELD_KIND_U32: + TRIVIAL_FIELD_DECODER(32); - case AMQP_FIELD_KIND_I8: - SIMPLE_FIELD_DECODER(8, i8, (int8_t)val); - case AMQP_FIELD_KIND_U8: - TRIVIAL_FIELD_DECODER(8); - - case AMQP_FIELD_KIND_I16: - SIMPLE_FIELD_DECODER(16, i16, (int16_t)val); - case AMQP_FIELD_KIND_U16: - TRIVIAL_FIELD_DECODER(16); - - case AMQP_FIELD_KIND_I32: - SIMPLE_FIELD_DECODER(32, i32, (int32_t)val); - case AMQP_FIELD_KIND_U32: - TRIVIAL_FIELD_DECODER(32); - - case AMQP_FIELD_KIND_I64: - SIMPLE_FIELD_DECODER(64, i64, (int64_t)val); - case AMQP_FIELD_KIND_U64: - TRIVIAL_FIELD_DECODER(64); + case AMQP_FIELD_KIND_I64: + SIMPLE_FIELD_DECODER(64, i64, (int64_t)val); + case AMQP_FIELD_KIND_U64: + TRIVIAL_FIELD_DECODER(64); - case AMQP_FIELD_KIND_F32: - TRIVIAL_FIELD_DECODER(32); + case AMQP_FIELD_KIND_F32: + TRIVIAL_FIELD_DECODER(32); /* and by punning, f32 magically gets the right value...! */ - case AMQP_FIELD_KIND_F64: - TRIVIAL_FIELD_DECODER(64); + case AMQP_FIELD_KIND_F64: + TRIVIAL_FIELD_DECODER(64); /* and by punning, f64 magically gets the right value...! */ - case AMQP_FIELD_KIND_DECIMAL: - if (!amqp_decode_8(encoded, offset, &entry->value.decimal.decimals) - || !amqp_decode_32(encoded, offset, &entry->value.decimal.value)) { - goto out; - } - break; + case AMQP_FIELD_KIND_DECIMAL: + if (!amqp_decode_8(encoded, offset, &entry->value.decimal.decimals) || + !amqp_decode_32(encoded, offset, &entry->value.decimal.value)) { + goto out; + } + break; - case AMQP_FIELD_KIND_UTF8: + case AMQP_FIELD_KIND_UTF8: /* AMQP_FIELD_KIND_UTF8 and AMQP_FIELD_KIND_BYTES have the same implementation, but different interpretations. */ /* fall through */ - case AMQP_FIELD_KIND_BYTES: { - uint32_t len; - if (!amqp_decode_32(encoded, offset, &len) - || !amqp_decode_bytes(encoded, offset, &entry->value.bytes, len)) { - goto out; + case AMQP_FIELD_KIND_BYTES: { + uint32_t len; + if (!amqp_decode_32(encoded, offset, &len) || + !amqp_decode_bytes(encoded, offset, &entry->value.bytes, len)) { + goto out; + } + break; } - break; - } - case AMQP_FIELD_KIND_ARRAY: - res = amqp_decode_array(encoded, pool, &(entry->value.array), offset); - goto out; + case AMQP_FIELD_KIND_ARRAY: + res = amqp_decode_array(encoded, pool, &(entry->value.array), offset); + goto out; - case AMQP_FIELD_KIND_TIMESTAMP: - TRIVIAL_FIELD_DECODER(64); + case AMQP_FIELD_KIND_TIMESTAMP: + TRIVIAL_FIELD_DECODER(64); - case AMQP_FIELD_KIND_TABLE: - res = amqp_decode_table(encoded, pool, &(entry->value.table), offset); - goto out; + case AMQP_FIELD_KIND_TABLE: + res = amqp_decode_table(encoded, pool, &(entry->value.table), offset); + goto out; - case AMQP_FIELD_KIND_VOID: - break; + case AMQP_FIELD_KIND_VOID: + break; - default: - goto out; + default: + goto out; } res = AMQP_STATUS_OK; @@ -284,10 +299,8 @@ /*---------------------------------------------------------------------------*/ -static int amqp_encode_array(amqp_bytes_t encoded, - amqp_array_t *input, - size_t *offset) -{ +static int amqp_encode_array(amqp_bytes_t encoded, amqp_array_t *input, + size_t *offset) { size_t start = *offset; int i, res; @@ -311,10 +324,8 @@ return res; } -int amqp_encode_table(amqp_bytes_t encoded, - amqp_table_t *input, - size_t *offset) -{ +int amqp_encode_table(amqp_bytes_t encoded, amqp_table_t *input, + size_t *offset) { size_t start = *offset; int i, res; @@ -349,90 +360,89 @@ } static int amqp_encode_field_value(amqp_bytes_t encoded, - amqp_field_value_t *entry, - size_t *offset) -{ + amqp_field_value_t *entry, size_t *offset) { int res = AMQP_STATUS_BAD_AMQP_DATA; if (!amqp_encode_8(encoded, offset, entry->kind)) { goto out; } -#define FIELD_ENCODER(bits, val) if (!amqp_encode_##bits(encoded, offset, val)) { \ - res = AMQP_STATUS_TABLE_TOO_BIG; \ - goto out; \ - } \ - break +#define FIELD_ENCODER(bits, val) \ + if (!amqp_encode_##bits(encoded, offset, val)) { \ + res = AMQP_STATUS_TABLE_TOO_BIG; \ + goto out; \ + } \ + break switch (entry->kind) { - case AMQP_FIELD_KIND_BOOLEAN: - FIELD_ENCODER(8, entry->value.boolean ? 1 : 0); + case AMQP_FIELD_KIND_BOOLEAN: + FIELD_ENCODER(8, entry->value.boolean ? 1 : 0); - case AMQP_FIELD_KIND_I8: - FIELD_ENCODER(8, entry->value.i8); - case AMQP_FIELD_KIND_U8: - FIELD_ENCODER(8, entry->value.u8); - - case AMQP_FIELD_KIND_I16: - FIELD_ENCODER(16, entry->value.i16); - case AMQP_FIELD_KIND_U16: - FIELD_ENCODER(16, entry->value.u16); - - case AMQP_FIELD_KIND_I32: - FIELD_ENCODER(32, entry->value.i32); - case AMQP_FIELD_KIND_U32: - FIELD_ENCODER(32, entry->value.u32); - - case AMQP_FIELD_KIND_I64: - FIELD_ENCODER(64, entry->value.i64); - case AMQP_FIELD_KIND_U64: - FIELD_ENCODER(64, entry->value.u64); - - case AMQP_FIELD_KIND_F32: - /* by punning, u32 magically gets the right value...! */ - FIELD_ENCODER(32, entry->value.u32); - - case AMQP_FIELD_KIND_F64: - /* by punning, u64 magically gets the right value...! */ - FIELD_ENCODER(64, entry->value.u64); - - case AMQP_FIELD_KIND_DECIMAL: - if (!amqp_encode_8(encoded, offset, entry->value.decimal.decimals) - || !amqp_encode_32(encoded, offset, entry->value.decimal.value)) { - res = AMQP_STATUS_TABLE_TOO_BIG; - goto out; - } - break; + case AMQP_FIELD_KIND_I8: + FIELD_ENCODER(8, entry->value.i8); + case AMQP_FIELD_KIND_U8: + FIELD_ENCODER(8, entry->value.u8); + + case AMQP_FIELD_KIND_I16: + FIELD_ENCODER(16, entry->value.i16); + case AMQP_FIELD_KIND_U16: + FIELD_ENCODER(16, entry->value.u16); + + case AMQP_FIELD_KIND_I32: + FIELD_ENCODER(32, entry->value.i32); + case AMQP_FIELD_KIND_U32: + FIELD_ENCODER(32, entry->value.u32); + + case AMQP_FIELD_KIND_I64: + FIELD_ENCODER(64, entry->value.i64); + case AMQP_FIELD_KIND_U64: + FIELD_ENCODER(64, entry->value.u64); + + case AMQP_FIELD_KIND_F32: + /* by punning, u32 magically gets the right value...! */ + FIELD_ENCODER(32, entry->value.u32); + + case AMQP_FIELD_KIND_F64: + /* by punning, u64 magically gets the right value...! */ + FIELD_ENCODER(64, entry->value.u64); - case AMQP_FIELD_KIND_UTF8: + case AMQP_FIELD_KIND_DECIMAL: + if (!amqp_encode_8(encoded, offset, entry->value.decimal.decimals) || + !amqp_encode_32(encoded, offset, entry->value.decimal.value)) { + res = AMQP_STATUS_TABLE_TOO_BIG; + goto out; + } + break; + + case AMQP_FIELD_KIND_UTF8: /* AMQP_FIELD_KIND_UTF8 and AMQP_FIELD_KIND_BYTES have the same implementation, but different interpretations. */ /* fall through */ - case AMQP_FIELD_KIND_BYTES: - if (!amqp_encode_32(encoded, offset, (uint32_t)entry->value.bytes.len) - || !amqp_encode_bytes(encoded, offset, entry->value.bytes)) { - res = AMQP_STATUS_TABLE_TOO_BIG; - goto out; - } - break; + case AMQP_FIELD_KIND_BYTES: + if (!amqp_encode_32(encoded, offset, (uint32_t)entry->value.bytes.len) || + !amqp_encode_bytes(encoded, offset, entry->value.bytes)) { + res = AMQP_STATUS_TABLE_TOO_BIG; + goto out; + } + break; - case AMQP_FIELD_KIND_ARRAY: - res = amqp_encode_array(encoded, &entry->value.array, offset); - goto out; + case AMQP_FIELD_KIND_ARRAY: + res = amqp_encode_array(encoded, &entry->value.array, offset); + goto out; - case AMQP_FIELD_KIND_TIMESTAMP: - FIELD_ENCODER(64, entry->value.u64); + case AMQP_FIELD_KIND_TIMESTAMP: + FIELD_ENCODER(64, entry->value.u64); - case AMQP_FIELD_KIND_TABLE: - res = amqp_encode_table(encoded, &entry->value.table, offset); - goto out; + case AMQP_FIELD_KIND_TABLE: + res = amqp_encode_table(encoded, &entry->value.table, offset); + goto out; - case AMQP_FIELD_KIND_VOID: - break; + case AMQP_FIELD_KIND_VOID: + break; - default: - res = AMQP_STATUS_INVALID_PARAMETER; - goto out; + default: + res = AMQP_STATUS_INVALID_PARAMETER; + goto out; } res = AMQP_STATUS_OK; @@ -443,10 +453,9 @@ /*---------------------------------------------------------------------------*/ -int amqp_table_entry_cmp(void const *entry1, void const *entry2) -{ - amqp_table_entry_t const *p1 = (amqp_table_entry_t const *) entry1; - amqp_table_entry_t const *p2 = (amqp_table_entry_t const *) entry2; +int amqp_table_entry_cmp(void const *entry1, void const *entry2) { + amqp_table_entry_t const *p1 = (amqp_table_entry_t const *)entry1; + amqp_table_entry_t const *p2 = (amqp_table_entry_t const *)entry2; int d; size_t minlen; @@ -464,9 +473,9 @@ return (int)p1->key.len - (int)p2->key.len; } -static int -amqp_field_value_clone(const amqp_field_value_t *original, amqp_field_value_t *clone, amqp_pool_t *pool) -{ +static int amqp_field_value_clone(const amqp_field_value_t *original, + amqp_field_value_t *clone, + amqp_pool_t *pool) { int i; int res; clone->kind = original->kind; @@ -526,11 +535,13 @@ if (0 == original->value.bytes.len) { clone->value.bytes = amqp_empty_bytes; } else { - amqp_pool_alloc_bytes(pool, original->value.bytes.len, &clone->value.bytes); + amqp_pool_alloc_bytes(pool, original->value.bytes.len, + &clone->value.bytes); if (NULL == clone->value.bytes.bytes) { return AMQP_STATUS_NO_MEMORY; } - memcpy(clone->value.bytes.bytes, original->value.bytes.bytes, clone->value.bytes.len); + memcpy(clone->value.bytes.bytes, original->value.bytes.bytes, + clone->value.bytes.len); } break; @@ -539,13 +550,15 @@ clone->value.array = amqp_empty_array; } else { clone->value.array.num_entries = original->value.array.num_entries; - clone->value.array.entries = amqp_pool_alloc(pool, clone->value.array.num_entries * sizeof(amqp_field_value_t)); + clone->value.array.entries = amqp_pool_alloc( + pool, clone->value.array.num_entries * sizeof(amqp_field_value_t)); if (NULL == clone->value.array.entries) { return AMQP_STATUS_NO_MEMORY; } for (i = 0; i < clone->value.array.num_entries; ++i) { - res = amqp_field_value_clone(&original->value.array.entries[i], &clone->value.array.entries[i], pool); + res = amqp_field_value_clone(&original->value.array.entries[i], + &clone->value.array.entries[i], pool); if (AMQP_STATUS_OK != res) { return res; } @@ -554,7 +567,8 @@ break; case AMQP_FIELD_KIND_TABLE: - return amqp_table_clone(&original->value.table, &clone->value.table, pool); + return amqp_table_clone(&original->value.table, &clone->value.table, + pool); case AMQP_FIELD_KIND_VOID: break; @@ -566,10 +580,9 @@ return AMQP_STATUS_OK; } - -static int -amqp_table_entry_clone(const amqp_table_entry_t *original, amqp_table_entry_t *clone, amqp_pool_t *pool) -{ +static int amqp_table_entry_clone(const amqp_table_entry_t *original, + amqp_table_entry_t *clone, + amqp_pool_t *pool) { if (0 == original->key.len) { return AMQP_STATUS_INVALID_PARAMETER; } @@ -584,9 +597,8 @@ return amqp_field_value_clone(&original->value, &clone->value, pool); } -int -amqp_table_clone(const amqp_table_t *original, amqp_table_t *clone, amqp_pool_t *pool) -{ +int amqp_table_clone(const amqp_table_t *original, amqp_table_t *clone, + amqp_pool_t *pool) { int i; int res; clone->num_entries = original->num_entries; @@ -595,14 +607,16 @@ return AMQP_STATUS_OK; } - clone->entries = amqp_pool_alloc(pool, clone->num_entries * sizeof(amqp_table_entry_t)); + clone->entries = + amqp_pool_alloc(pool, clone->num_entries * sizeof(amqp_table_entry_t)); if (NULL == clone->entries) { return AMQP_STATUS_NO_MEMORY; } for (i = 0; i < clone->num_entries; ++i) { - res = amqp_table_entry_clone(&original->entries[i], &clone->entries[i], pool); + res = + amqp_table_entry_clone(&original->entries[i], &clone->entries[i], pool); if (AMQP_STATUS_OK != res) { goto error_out1; } diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_table.h librabbitmq-0.9.0-0.1/librabbitmq/amqp_table.h --- librabbitmq-0.7.1/librabbitmq/amqp_table.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_table.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -79,4 +78,4 @@ amqp_table_entry_t *amqp_table_get_entry_by_key(const amqp_table_t *table, const amqp_bytes_t key); -#endif /* AMQP_TABLE_H */ +#endif /* AMQP_TABLE_H */ diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_tcp_socket.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_tcp_socket.c --- librabbitmq-0.7.1/librabbitmq/amqp_tcp_socket.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_tcp_socket.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * Copyright 2012-2013 Michael Steinert * @@ -29,15 +28,15 @@ #include "amqp_tcp_socket.h" #include -#ifdef _WIN32 -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include +#if ((defined(_WIN32)) || (defined(__MINGW32__)) || (defined(__MINGW64__))) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include #else -# include -# include -# include +#include +#include +#include #endif #include #include @@ -49,10 +48,8 @@ int state; }; - -static ssize_t -amqp_tcp_socket_send(void *base, const void *buf, size_t len, int flags) -{ +static ssize_t amqp_tcp_socket_send(void *base, const void *buf, size_t len, + int flags) { struct amqp_tcp_socket_t *self = (struct amqp_tcp_socket_t *)base; ssize_t res; int flagz = 0; @@ -69,7 +66,9 @@ if (flags & AMQP_SF_MORE) { flagz |= MSG_MORE; } -#elif defined(TCP_NOPUSH) +/* Cygwin defines TCP_NOPUSH, but trying to use it will return not + * implemented. Disable it here. */ +#elif defined(TCP_NOPUSH) && !defined(__CYGWIN__) if (flags & AMQP_SF_MORE && !(self->state & AMQP_SF_MORE)) { int one = 1; res = setsockopt(self->sockfd, IPPROTO_TCP, TCP_NOPUSH, &one, sizeof(one)); @@ -79,14 +78,15 @@ } self->state |= AMQP_SF_MORE; } else if (!(flags & AMQP_SF_MORE) && self->state & AMQP_SF_MORE) { - int zero = 0; - res = setsockopt(self->sockfd, IPPROTO_TCP, TCP_NOPUSH, &zero, sizeof(&zero)); - if (0 != res) { - self->internal_error = res; - res = AMQP_STATUS_SOCKET_ERROR; - } else { - self->state &= ~AMQP_SF_MORE; - } + int zero = 0; + res = + setsockopt(self->sockfd, IPPROTO_TCP, TCP_NOPUSH, &zero, sizeof(&zero)); + if (0 != res) { + self->internal_error = res; + res = AMQP_STATUS_SOCKET_ERROR; + } else { + self->state &= ~AMQP_SF_MORE; + } } #endif @@ -122,9 +122,8 @@ return res; } -static ssize_t -amqp_tcp_socket_recv(void *base, void *buf, size_t len, int flags) -{ +static ssize_t amqp_tcp_socket_recv(void *base, void *buf, size_t len, + int flags) { struct amqp_tcp_socket_t *self = (struct amqp_tcp_socket_t *)base; ssize_t ret; if (-1 == self->sockfd) { @@ -163,9 +162,8 @@ return ret; } -static int -amqp_tcp_socket_open(void *base, const char *host, int port, struct timeval *timeout) -{ +static int amqp_tcp_socket_open(void *base, const char *host, int port, + struct timeval *timeout) { struct amqp_tcp_socket_t *self = (struct amqp_tcp_socket_t *)base; if (-1 != self->sockfd) { return AMQP_STATUS_SOCKET_INUSE; @@ -179,9 +177,8 @@ return AMQP_STATUS_OK; } -static int -amqp_tcp_socket_close(void *base) -{ +static int amqp_tcp_socket_close(void *base, + AMQP_UNUSED amqp_socket_close_enum force) { struct amqp_tcp_socket_t *self = (struct amqp_tcp_socket_t *)base; if (-1 == self->sockfd) { return AMQP_STATUS_SOCKET_CLOSED; @@ -195,36 +192,30 @@ return AMQP_STATUS_OK; } -static int -amqp_tcp_socket_get_sockfd(void *base) -{ +static int amqp_tcp_socket_get_sockfd(void *base) { struct amqp_tcp_socket_t *self = (struct amqp_tcp_socket_t *)base; return self->sockfd; } -static void -amqp_tcp_socket_delete(void *base) -{ +static void amqp_tcp_socket_delete(void *base) { struct amqp_tcp_socket_t *self = (struct amqp_tcp_socket_t *)base; if (self) { - amqp_tcp_socket_close(self); + amqp_tcp_socket_close(self, AMQP_SC_NONE); free(self); } } static const struct amqp_socket_class_t amqp_tcp_socket_class = { - amqp_tcp_socket_send, /* send */ - amqp_tcp_socket_recv, /* recv */ - amqp_tcp_socket_open, /* open */ - amqp_tcp_socket_close, /* close */ - amqp_tcp_socket_get_sockfd, /* get_sockfd */ - amqp_tcp_socket_delete /* delete */ + amqp_tcp_socket_send, /* send */ + amqp_tcp_socket_recv, /* recv */ + amqp_tcp_socket_open, /* open */ + amqp_tcp_socket_close, /* close */ + amqp_tcp_socket_get_sockfd, /* get_sockfd */ + amqp_tcp_socket_delete /* delete */ }; -amqp_socket_t * -amqp_tcp_socket_new(amqp_connection_state_t state) -{ +amqp_socket_t *amqp_tcp_socket_new(amqp_connection_state_t state) { struct amqp_tcp_socket_t *self = calloc(1, sizeof(*self)); if (!self) { return NULL; @@ -237,9 +228,7 @@ return (amqp_socket_t *)self; } -void -amqp_tcp_socket_set_sockfd(amqp_socket_t *base, int sockfd) -{ +void amqp_tcp_socket_set_sockfd(amqp_socket_t *base, int sockfd) { struct amqp_tcp_socket_t *self; if (base->klass != &amqp_tcp_socket_class) { amqp_abort("<%p> is not of type amqp_tcp_socket_t", base); diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_tcp_socket.h librabbitmq-0.9.0-0.1/librabbitmq/amqp_tcp_socket.h --- librabbitmq-0.7.1/librabbitmq/amqp_tcp_socket.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_tcp_socket.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /** \file */ /* * Portions created by Alan Antonuk are Copyright (c) 2013-2014 Alan Antonuk. @@ -47,9 +46,7 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -amqp_socket_t * -AMQP_CALL -amqp_tcp_socket_new(amqp_connection_state_t state); +amqp_socket_t *AMQP_CALL amqp_tcp_socket_new(amqp_connection_state_t state); /** * Assign an open file descriptor to a socket object. @@ -64,9 +61,7 @@ * \since v0.4.0 */ AMQP_PUBLIC_FUNCTION -void -AMQP_CALL -amqp_tcp_socket_set_sockfd(amqp_socket_t *self, int sockfd); +void AMQP_CALL amqp_tcp_socket_set_sockfd(amqp_socket_t *self, int sockfd); AMQP_END_DECLS diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_time.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_time.c --- librabbitmq-0.7.1/librabbitmq/amqp_time.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_time.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * Portions created by Alan Antonuk are Copyright (c) 2013-2014 Alan Antonuk. * All Rights Reserved. @@ -21,28 +20,28 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -#include "amqp.h" #include "amqp_time.h" +#include "amqp.h" #include #include #include -#if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) -# define AMQP_WIN_TIMER_API +#if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || \ + defined(__MINGW32__) || defined(__MINGW64__)) +#define AMQP_WIN_TIMER_API #elif (defined(machintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) -# define AMQP_MAC_TIMER_API +#define AMQP_MAC_TIMER_API #else -# define AMQP_POSIX_TIMER_API +#define AMQP_POSIX_TIMER_API #endif - #ifdef AMQP_WIN_TIMER_API +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN -#include +#endif +#include -uint64_t -amqp_get_monotonic_timestamp(void) -{ +uint64_t amqp_get_monotonic_timestamp(void) { static double NS_PER_COUNT = 0; LARGE_INTEGER perf_count; @@ -63,11 +62,9 @@ #endif /* AMQP_WIN_TIMER_API */ #ifdef AMQP_MAC_TIMER_API -# include +#include -uint64_t -amqp_get_monotonic_timestamp(void) -{ +uint64_t amqp_get_monotonic_timestamp(void) { static mach_timebase_info_data_t s_timebase = {0, 0}; uint64_t timestamp; @@ -90,9 +87,7 @@ #ifdef AMQP_POSIX_TIMER_API #include -uint64_t -amqp_get_monotonic_timestamp(void) -{ +uint64_t amqp_get_monotonic_timestamp(void) { #ifdef __hpux return (uint64_t)gethrtime(); #else diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_time.h librabbitmq-0.9.0-0.1/librabbitmq/amqp_time.h --- librabbitmq-0.7.1/librabbitmq/amqp_time.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_time.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * Portions created by Alan Antonuk are Copyright (c) 2013-2014 Alan Antonuk. * All Rights Reserved. @@ -26,21 +25,21 @@ #include -#ifdef _WIN32 -# ifndef WINVER -# define WINVER 0x0502 -# endif -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include +#if ((defined(_WIN32)) || (defined(__MINGW32__)) || (defined(__MINGW64__))) +#ifndef WINVER +#define WINVER 0x0502 +#endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include #else -# include +#include #endif -#define AMQP_MS_PER_S 1000 +#define AMQP_MS_PER_S 1000 #define AMQP_US_PER_MS 1000 -#define AMQP_NS_PER_S 1000000000 +#define AMQP_NS_PER_S 1000000000 #define AMQP_NS_PER_MS 1000000 #define AMQP_NS_PER_US 1000 @@ -54,9 +53,7 @@ * - UINT64_MAX: means 'at infinity', its mean for polls with an infinite * timeout */ -typedef struct amqp_time_t_ { - uint64_t time_point_ns; -} amqp_time_t; +typedef struct amqp_time_t_ { uint64_t time_point_ns; } amqp_time_t; /* Gets a monotonic timestamp. This will return 0 if the underlying call to the * system fails. diff -Nru librabbitmq-0.7.1/librabbitmq/amqp_url.c librabbitmq-0.9.0-0.1/librabbitmq/amqp_url.c --- librabbitmq-0.7.1/librabbitmq/amqp_url.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/amqp_url.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -39,17 +38,17 @@ #endif #ifdef _MSC_VER -# define _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS #endif #include "amqp_private.h" +#include #include #include #include #include -void amqp_default_connection_info(struct amqp_connection_info *ci) -{ +void amqp_default_connection_info(struct amqp_connection_info *ci) { /* Apply defaults */ ci->user = "guest"; ci->password = "guest"; @@ -60,8 +59,7 @@ } /* Scan for the next delimiter, handling percent-encodings on the way. */ -static char find_delim(char **pp, int colon_and_at_sign_are_delims) -{ +static char find_delim(char **pp, int colon_and_at_sign_are_delims) { char *from = *pp; char *to = from; @@ -69,57 +67,58 @@ char ch = *from++; switch (ch) { - case ':': - case '@': - if (!colon_and_at_sign_are_delims) { - *to++ = ch; - break; - } + case ':': + case '@': + if (!colon_and_at_sign_are_delims) { + *to++ = ch; + break; + } /* fall through */ - case 0: - case '/': - case '?': - case '#': - case '[': - case ']': - *to = 0; - *pp = from; - return ch; - - case '%': { - unsigned int val; - int chars; - int res = sscanf(from, "%2x%n", &val, &chars); + case 0: + case '/': + case '?': + case '#': + case '[': + case ']': + *to = 0; + *pp = from; + return ch; + + case '%': { + unsigned int val; + int chars; + int res = sscanf(from, "%2x%n", &val, &chars); - if (res == EOF || res < 1 || chars != 2) + if (res == EOF || res < 1 || chars != 2 || val > CHAR_MAX) /* Return a surprising delimiter to force an error. */ - { - return '%'; - } + { + return '%'; + } - *to++ = val; - from += 2; - break; - } + *to++ = (char)val; + from += 2; + break; + } - default: - *to++ = ch; - break; + default: + *to++ = ch; + break; } } } /* Parse an AMQP URL into its component parts. */ -int amqp_parse_url(char *url, struct amqp_connection_info *parsed) -{ +int amqp_parse_url(char *url, struct amqp_connection_info *parsed) { int res = AMQP_STATUS_BAD_URL; char delim; char *start; char *host; char *port = NULL; + amqp_default_connection_info(parsed); + /* check the prefix */ if (!strncmp(url, "amqp://", 7)) { /* do nothing */ @@ -214,8 +213,7 @@ res = AMQP_STATUS_OK; } - /* Any other delimiter is bad, and we will return - AMQP_STATUS_BAD_AMQP_URL. */ +/* Any other delimiter is bad, and we will return AMQP_STATUS_BAD_AMQP_URL. */ out: return res; diff -Nru librabbitmq-0.7.1/librabbitmq/CMakeLists.txt librabbitmq-0.9.0-0.1/librabbitmq/CMakeLists.txt --- librabbitmq-0.7.1/librabbitmq/CMakeLists.txt 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/CMakeLists.txt 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -# vim:set ts=2 sw=2 sts=2 et: project(librabbitmq "C") if (REGENERATE_AMQP_FRAMING) @@ -80,47 +79,27 @@ add_definitions(-DWITH_SSL=1) set(AMQP_SSL_SOCKET_H_PATH amqp_ssl_socket.h) - if (SSL_ENGINE STREQUAL "OpenSSL") - set(AMQP_SSL_SRCS ${AMQP_SSL_SOCKET_H_PATH} - amqp_openssl.c - amqp_hostcheck.c - amqp_hostcheck.h - ) - include_directories(${OPENSSL_INCLUDE_DIR}) - set(AMQP_SSL_LIBS ${OPENSSL_LIBRARIES}) - if (APPLE) - # Apple has deprecated OpenSSL in 10.7+. This disables that warning. - set_source_files_properties(${AMQP_SSL_SRCS} - PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations) - endif() - - elseif (SSL_ENGINE STREQUAL "cyaSSL") - set(AMQP_SSL_SRCS ${AMQP_SSL_SOCKET_H_PATH} amqp_cyassl.c) - include_directories(${CYASSL_INCLUDE_DIR}) - set(AMQP_SSL_LIBS ${CYASSL_LIBRARIES}) - - elseif (SSL_ENGINE STREQUAL "GnuTLS") - set(AMQP_SSL_SRCS ${AMQP_SSL_SOCKET_H_PATH} amqp_gnutls.c) - include_directories(${GNUTLS_INCLUDE_DIR}) - add_definitions(${GNUTLS_DEFINITIONS}) - set(AMQP_SSL_LIBS ${GNUTLS_LIBRARIES}) - - elseif (SSL_ENGINE STREQUAL "PolarSSL") - set(AMQP_SSL_SRCS ${AMQP_SSL_SOCKET_H_PATH} amqp_polarssl.c) - include_directories(${POLARSSL_INCLUDE_DIR}) - set(AMQP_SSL_LIBS ${POLARSSL_LIBRARIES}) - - else() - message(FATAL_ERROR "Unknown SSL_ENGINE ${SSL_ENGINE}") + set(AMQP_SSL_SRCS ${AMQP_SSL_SOCKET_H_PATH} + amqp_openssl.c + amqp_openssl_hostname_validation.c + amqp_openssl_hostname_validation.h + amqp_hostcheck.c + amqp_hostcheck.h + amqp_openssl_bio.c + amqp_openssl_bio.h + ) + include_directories(${OPENSSL_INCLUDE_DIR}) + set(AMQP_SSL_LIBS ${OPENSSL_LIBRARIES}) + if (APPLE) + # Apple has deprecated OpenSSL in 10.7+. This disables that warning. + set_source_files_properties(${AMQP_SSL_SRCS} + PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations) endif() - if (ENABLE_THREAD_SAFETY) - add_definitions(-DENABLE_THREAD_SAFETY) - if (WIN32) - set(AMQP_SSL_SRCS ${AMQP_SSL_SRCS} win32/threads.h win32/threads.c) - else() - set(AMQP_SSL_SRCS ${AMQP_SSL_SRCS} unix/threads.h) - endif() + if (WIN32) + set(AMQP_SSL_SRCS ${AMQP_SSL_SRCS} win32/threads.h win32/threads.c) + else() + set(AMQP_SSL_SRCS ${AMQP_SSL_SRCS} unix/threads.h) endif() endif() @@ -136,12 +115,13 @@ add_definitions(-DAMQP_BUILD) -include(InstallMacros) - set(RMQ_LIBRARIES ${AMQP_SSL_LIBS} ${SOCKET_LIBRARIES} ${LIBRT} ${CMAKE_THREAD_LIBS_INIT}) if (BUILD_SHARED_LIBS) add_library(rabbitmq SHARED ${RABBITMQ_SOURCES}) + if (THREADS_HAVE_PTHREAD_ARG) + target_compile_options(rabbitmq PUBLIC "-pthread") + endif() target_link_libraries(rabbitmq ${RMQ_LIBRARIES}) @@ -156,19 +136,31 @@ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) - install_pdb(rabbitmq) set(RMQ_LIBRARY_TARGET rabbitmq) endif (BUILD_SHARED_LIBS) if (BUILD_STATIC_LIBS) add_library(rabbitmq-static STATIC ${RABBITMQ_SOURCES}) + if (THREADS_HAVE_PTHREAD_ARG) + target_compile_options(rabbitmq-static PUBLIC "-pthread") + endif() target_link_libraries(rabbitmq-static ${RMQ_LIBRARIES}) set_target_properties(rabbitmq-static PROPERTIES COMPILE_DEFINITIONS AMQP_STATIC) if (WIN32) - set_target_properties(rabbitmq-static PROPERTIES VERSION ${RMQ_VERSION} OUTPUT_NAME librabbitmq.${RMQ_SOVERSION}) + set_target_properties(rabbitmq-static PROPERTIES + VERSION ${RMQ_VERSION} + OUTPUT_NAME librabbitmq.${RMQ_SOVERSION}) + + if(MSVC) + set_target_properties(rabbitmq-static PROPERTIES + # Embed debugging info in the library itself instead of generating + # a .pdb file. + COMPILE_OPTIONS "/Z7") + endif(MSVC) + else (WIN32) set_target_properties(rabbitmq-static PROPERTIES VERSION ${RMQ_VERSION} SOVERSION ${RMQ_SOVERSION} OUTPUT_NAME rabbitmq) endif (WIN32) @@ -176,7 +168,6 @@ install(TARGETS rabbitmq-static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) - install_pdb(rabbitmq-static) if (NOT DEFINED RMQ_LIBRARY_TARGET) set(RMQ_LIBRARY_TARGET rabbitmq-static) diff -Nru librabbitmq-0.7.1/librabbitmq/codegen.py librabbitmq-0.9.0-0.1/librabbitmq/codegen.py --- librabbitmq-0.7.1/librabbitmq/codegen.py 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/codegen.py 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -# vim:set ts=2 sw=2 sts=2 et # ***** BEGIN LICENSE BLOCK ***** # Version: MIT # diff -Nru librabbitmq-0.7.1/librabbitmq/descrip.mms librabbitmq-0.9.0-0.1/librabbitmq/descrip.mms --- librabbitmq-0.7.1/librabbitmq/descrip.mms 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/descrip.mms 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -OBJS = AMQP_FRAMING.OBJ, AMQP_API.OBJ, AMQP_CONNECTION.OBJ, AMQP_MEM.OBJ, AMQP_SOCKET.OBJ, AMQP_TABLE.OBJ, AMQP_URL.OBJ, AMQP_TCP_SOCKET.OBJ, AMQP_TIMER.OBJ - -REAL_TARGETS = RABBITMQ.OLB - -.INCLUDE [-.vms]INCLUDE.MMS - -CFLAGS = $(OPTFLAGS)/DEFINE=($(DEFS))/INCLUDE=($(INC),"./","../vms","./unix")/WARN=(DIS=PTRMISMATCH1) -LDFLAGS = /TRACE - -RABBITMQ.OLB : $(OBJS) - IF F$SEARCH("$(MMS$TARGET)") .EQS. "" THEN LIBRARY/CREATE $(MMS$TARGET) - LIBRARY/REPLACE $(MMS$TARGET) $(MMS$SOURCE_LIST) - -SOCKET.OBJ : [.UNIX]SOCKET.C -SOCKET.MMSD : [.UNIX]SOCKET.C diff -Nru librabbitmq-0.7.1/librabbitmq/unix/threads.h librabbitmq-0.9.0-0.1/librabbitmq/unix/threads.h --- librabbitmq-0.7.1/librabbitmq/unix/threads.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/unix/threads.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * Copyright 2012-2013 Michael Steinert * diff -Nru librabbitmq-0.7.1/librabbitmq/win32/msinttypes/stdint.h librabbitmq-0.9.0-0.1/librabbitmq/win32/msinttypes/stdint.h --- librabbitmq-0.7.1/librabbitmq/win32/msinttypes/stdint.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/win32/msinttypes/stdint.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,39 +1,39 @@ // ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// // Copyright (c) 2006-2008 Alexander Chemeris -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. The name of the author may be used to endorse or promote products // derived from this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// /////////////////////////////////////////////////////////////////////////////// -#ifndef _MSC_VER // [ +#ifndef _MSC_VER // [ #error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] +#endif // _MSC_VER ] -#ifndef _MSC_STDINT_H_ // [ +#ifndef _MSC_STDINT_H_ // [ #define _MSC_STDINT_H_ #if _MSC_VER > 1000 @@ -49,20 +49,19 @@ #ifdef __cplusplus extern "C" { #endif -# include +#include #ifdef __cplusplus } #endif // Define _W64 macros to mark types changing their size, like intptr_t. #ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif +#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +#define _W64 __w64 +#else +#define _W64 +#endif #endif - // 7.18.1 Integer types @@ -72,176 +71,175 @@ // realize that, e.g. char has the same size as __int8 // so we give up on __intX for them. #if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; #else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; +typedef signed __int8 int8_t; +typedef signed __int16 int16_t; +typedef signed __int32 int32_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; #endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; // 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; // 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; // 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] +#ifdef _WIN64 // [ +typedef signed __int64 intptr_t; +typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ +typedef _W64 signed int intptr_t; +typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] // 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; // 7.18.2 Limits of specified-width integer types -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 +#if !defined(__cplusplus) || \ + defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and + // footnote 221 at page 259 // 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX // 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX // 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX // 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] +#ifdef _WIN64 // [ +#define INTPTR_MIN INT64_MIN +#define INTPTR_MAX INT64_MAX +#define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +#define INTPTR_MIN INT32_MIN +#define INTPTR_MAX INT32_MAX +#define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] // 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX // 7.18.3 Limits of other integer types -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX +#ifdef _WIN64 // [ +#define PTRDIFF_MIN _I64_MIN +#define PTRDIFF_MAX _I64_MAX #else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX +#define PTRDIFF_MIN _I32_MIN +#define PTRDIFF_MAX _I32_MAX #endif // _WIN64 ] -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] +#ifndef SIZE_MAX // [ +#ifdef _WIN64 // [ +#define SIZE_MAX _UI64_MAX +#else // _WIN64 ][ +#define SIZE_MAX _UI32_MAX +#endif // _WIN64 ] +#endif // SIZE_MAX ] // WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX +#ifndef WCHAR_MIN // [ +#define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +#define WCHAR_MAX _UI16_MAX #endif // WCHAR_MAX ] -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX +#endif // __STDC_LIMIT_MACROS ] // 7.18.4 Limits of other integer types -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 +#if !defined(__cplusplus) || \ + defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 // 7.18.4.1 Macros for minimum-width integer constants -#define INT8_C(val) val##i8 +#define INT8_C(val) val##i8 #define INT16_C(val) val##i16 #define INT32_C(val) val##i32 #define INT64_C(val) val##i64 -#define UINT8_C(val) val##ui8 +#define UINT8_C(val) val##ui8 #define UINT16_C(val) val##ui16 #define UINT32_C(val) val##ui32 #define UINT64_C(val) val##ui64 // 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C +#endif // __STDC_CONSTANT_MACROS ] -#endif // _MSC_STDINT_H_ ] +#endif // _MSC_STDINT_H_ ] diff -Nru librabbitmq-0.7.1/librabbitmq/win32/threads.c librabbitmq-0.9.0-0.1/librabbitmq/win32/threads.c --- librabbitmq-0.7.1/librabbitmq/win32/threads.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/win32/threads.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * Copyright 2012-2013 Michael Steinert * @@ -23,41 +22,35 @@ #include "threads.h" -DWORD -pthread_self(void) -{ - return GetCurrentThreadId(); -} +#include + +DWORD pthread_self(void) { return GetCurrentThreadId(); } -int -pthread_mutex_init(pthread_mutex_t *mutex, void *attr) -{ - *mutex = malloc(sizeof(CRITICAL_SECTION)); - if (!*mutex) { +int pthread_mutex_init(pthread_mutex_t *mutex, void *attr) { + if (!mutex) { return 1; } - InitializeCriticalSection(*mutex); + InitializeSRWLock(mutex); return 0; } -int -pthread_mutex_lock(pthread_mutex_t *mutex) -{ - if (!*mutex) { +int pthread_mutex_lock(pthread_mutex_t *mutex) { + if (!mutex) { return 1; } - - EnterCriticalSection(*mutex); + AcquireSRWLockExclusive(mutex); return 0; } -int -pthread_mutex_unlock(pthread_mutex_t *mutex) -{ - if (!*mutex) { +int pthread_mutex_unlock(pthread_mutex_t *mutex) { + if (!mutex) { return 1; } + ReleaseSRWLockExclusive(mutex); + return 0; +} - LeaveCriticalSection(*mutex); +int pthread_mutex_destroy(pthread_mutex_t *mutex) { + /* SRW's do not require destruction. */ return 0; } diff -Nru librabbitmq-0.7.1/librabbitmq/win32/threads.h librabbitmq-0.9.0-0.1/librabbitmq/win32/threads.h --- librabbitmq-0.7.1/librabbitmq/win32/threads.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/librabbitmq/win32/threads.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * Portions created by Alan Antonuk are Copyright (c) 2013-2014 Alan Antonuk. * All Rights Reserved. @@ -28,20 +27,26 @@ #ifndef AMQP_THREAD_H #define AMQP_THREAD_H -#ifndef WINVER -# define WINVER 0x0502 +#if !defined(WINVER) || defined(__MINGW32__) || defined(__MINGW64__) +#ifdef WINVER +#undef WINVER +#endif +/* Windows Vista or newer */ +#define WINVER 0x0600 #endif #ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN #endif -#include +#include -typedef CRITICAL_SECTION *pthread_mutex_t; -typedef int pthread_once_t; +typedef SRWLOCK pthread_mutex_t; +#define PTHREAD_MUTEX_INITIALIZER SRWLOCK_INIT; DWORD pthread_self(void); int pthread_mutex_init(pthread_mutex_t *, void *attr); int pthread_mutex_lock(pthread_mutex_t *); int pthread_mutex_unlock(pthread_mutex_t *); +int pthread_mutex_destroy(pthread_mutex_t *); + #endif /* AMQP_THREAD_H */ diff -Nru librabbitmq-0.7.1/m4/ax_have_poll.m4 librabbitmq-0.9.0-0.1/m4/ax_have_poll.m4 --- librabbitmq-0.7.1/m4/ax_have_poll.m4 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/m4/ax_have_poll.m4 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_have_poll.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_HAVE_POLL([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# AX_HAVE_PPOLL([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# DESCRIPTION -# -# This macro determines whether the system supports the poll I/O event -# interface. A neat usage example would be: -# -# AX_HAVE_POLL( -# [AX_CONFIG_FEATURE_ENABLE(poll)], -# [AX_CONFIG_FEATURE_DISABLE(poll)]) -# AX_CONFIG_FEATURE( -# [poll], [This platform supports poll(7)], -# [HAVE_POLL], [This platform supports poll(7).]) -# -# Some systems -- most notably Linux kernel 2.6.16 and later -- also have -# the variant ppoll(). The availability of that function can be tested -# with the second macro. Generally speaking, it is safe to assume that -# AX_HAVE_POLL would succeed if AX_HAVE_PPOLL has, but not the other way -# round. -# -# LICENSE -# -# Copyright (c) 2009 Peter Simons -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 7 - -AC_DEFUN([AX_HAVE_POLL], [dnl - AC_MSG_CHECKING([for poll(2)]) - AC_CACHE_VAL([ax_cv_have_poll], [dnl - AC_LINK_IFELSE([dnl - AC_LANG_PROGRAM( - [#include ], - [int rc; rc = poll((struct pollfd *)(0), 0, 0);])], - [ax_cv_have_poll=yes], - [ax_cv_have_poll=no])]) - AS_IF([test "${ax_cv_have_poll}" = "yes"], - [AC_MSG_RESULT([yes]) -$1],[AC_MSG_RESULT([no]) -$2]) -])dnl - -AC_DEFUN([AX_HAVE_PPOLL], [dnl - AC_MSG_CHECKING([for ppoll(2)]) - AC_CACHE_VAL([ax_cv_have_ppoll], [dnl - AC_LINK_IFELSE([dnl - AC_LANG_PROGRAM( - [dnl -#include -#include ], - [dnl -int rc; -rc = poll((struct pollfd *)(0), 0, 0); -rc = ppoll((struct pollfd *)(0), 0, (struct timespec const *)(0), (sigset_t const *)(0));])], - [ax_cv_have_ppoll=yes], - [ax_cv_have_ppoll=no])]) - AS_IF([test "${ax_cv_have_ppoll}" = "yes"], - [AC_MSG_RESULT([yes]) -$1],[AC_MSG_RESULT([no]) -$2]) -]) diff -Nru librabbitmq-0.7.1/m4/ax_have_select.m4 librabbitmq-0.9.0-0.1/m4/ax_have_select.m4 --- librabbitmq-0.7.1/m4/ax_have_select.m4 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/m4/ax_have_select.m4 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_have_select.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_HAVE_SELECT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# AX_HAVE_PSELECT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# DESCRIPTION -# -# This macro determines whether the system supports the select I/O event -# interface. A neat usage example would be: -# -# AX_HAVE_SELECT( -# [AX_CONFIG_FEATURE_ENABLE(select)], -# [AX_CONFIG_FEATURE_DISABLE(select)]) -# AX_CONFIG_FEATURE( -# [select], [This platform supports select(7)], -# [HAVE_SELECT], [This platform supports select(7).]) -# -# Some systems also have the variant pselect(). The availability of that -# function can be tested with the second macro. Generally speaking, it is -# safe to assume that AX_HAVE_SELECT would succeed if AX_HAVE_SELECT_PWAIT -# has, but not the other way round. -# -# LICENSE -# -# Copyright (c) 2009 Peter Simons -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 7 - -AC_DEFUN([AX_HAVE_SELECT], [dnl - AC_MSG_CHECKING([for select(2)]) - AC_CACHE_VAL([ax_cv_have_select], [dnl - AC_LINK_IFELSE([dnl - AC_LANG_PROGRAM( - [#include ], - [int rc; rc = select(0, (fd_set *)(0), (fd_set *)(0), (fd_set *)(0), (struct timeval *)(0));])], - [ax_cv_have_select=yes], - [ax_cv_have_select=no])]) - AS_IF([test "${ax_cv_have_select}" = "yes"], - [AC_MSG_RESULT([yes]) -$1],[AC_MSG_RESULT([no]) -$2]) -])dnl - -AC_DEFUN([AX_HAVE_PSELECT], [dnl - AC_MSG_CHECKING([for pselect(2)]) - AC_CACHE_VAL([ax_cv_have_pselect], [dnl - AC_LINK_IFELSE([dnl - AC_LANG_PROGRAM( - [dnl -#include -#include ], - [dnl -int rc; -rc = select(0, (fd_set *)(0), (fd_set *)(0), (fd_set *)(0), (struct timeval *)(0)); -rc = pselect(0, (fd_set *)(0), (fd_set *)(0), (fd_set *)(0), (struct timespec const *)(0), (sigset_t const *)(0));])], - [ax_cv_have_pselect=yes], - [ax_cv_have_pselect=no])]) - AS_IF([test "${ax_cv_have_pselect}" = "yes"], - [AC_MSG_RESULT([yes]) -$1],[AC_MSG_RESULT([no]) -$2]) -])dnl diff -Nru librabbitmq-0.7.1/m4/ax_python_module.m4 librabbitmq-0.9.0-0.1/m4/ax_python_module.m4 --- librabbitmq-0.7.1/m4/ax_python_module.m4 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/m4/ax_python_module.m4 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_python_module.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PYTHON_MODULE(modname[, fatal]) -# -# DESCRIPTION -# -# Checks for Python module. -# -# If fatal is non-empty then absence of a module will trigger an error. -# -# LICENSE -# -# Copyright (c) 2008 Andrew Collier -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 5 - -AU_ALIAS([AC_PYTHON_MODULE], [AX_PYTHON_MODULE]) -AC_DEFUN([AX_PYTHON_MODULE],[ - if test -z $PYTHON; - then - PYTHON="python" - fi - PYTHON_NAME=`basename $PYTHON` - AC_MSG_CHECKING($PYTHON_NAME module: $1) - $PYTHON -c "import $1" 2>/dev/null - if test $? -eq 0; - then - AC_MSG_RESULT(yes) - eval AS_TR_CPP(HAVE_PYMOD_$1)=yes - else - AC_MSG_RESULT(no) - eval AS_TR_CPP(HAVE_PYMOD_$1)=no - # - if test -n "$2" - then - AC_MSG_ERROR(failed to find required module $1) - exit 1 - fi - fi -]) diff -Nru librabbitmq-0.7.1/m4/cflags.m4 librabbitmq-0.9.0-0.1/m4/cflags.m4 --- librabbitmq-0.7.1/m4/cflags.m4 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/m4/cflags.m4 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -# cflags.m4 - Test and set compiler flags -# -# Copyright 2011, 2012 Michael Steinert -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -# THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -#serial 1 - -# AX_TRY_CFLAGS(FLAG, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) -# -------------------------------------------------------- -# Test a compiler flag is supported. -# FLAG: a compiler flag to try -# ACTION-IF-TRUE: commands to execute if FLAG is supported -# ACTION-IF-FALSE: commands to execute if FLAG is not supported -AC_DEFUN([AX_TRY_CFLAGS], -[dnl -AC_REQUIRE([AC_PROG_CC]) -_ax_cflags=$CFLAGS -CFLAGS="$1 $CFLAGS" -AC_MSG_CHECKING([if compiler accepts '$1']) -AC_TRY_COMPILE([], [], - [AC_MSG_RESULT([yes]) - CFLAGS=$_ax_cflags - $2], - [AC_MSG_RESULT([no]) - CFLAGS=$_ax_cflags - $3]) -])dnl - -# AX_CFLAGS(FLAGS) -# ---------------- -# Enable compiler flags. -# FLAGS: a whitespace-separated list of compiler flags to set -AC_DEFUN([AX_CFLAGS], -[dnl -m4_foreach_w([_ax_flag], [$1], - [AS_CASE([" $CFLAGS "], - [*[[\ \ ]]_ax_flag[[\ \ ]]*], - [], - [*], - [CFLAGS="$CFLAGS _ax_flag"])]) -])dnl diff -Nru librabbitmq-0.7.1/m4/.gitignore librabbitmq-0.9.0-0.1/m4/.gitignore --- librabbitmq-0.7.1/m4/.gitignore 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/m4/.gitignore 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -libtool.m4 -ltoptions.m4 -ltsugar.m4 -ltversion.m4 -lt~obsolete.m4 diff -Nru librabbitmq-0.7.1/m4/ldflags.m4 librabbitmq-0.9.0-0.1/m4/ldflags.m4 --- librabbitmq-0.7.1/m4/ldflags.m4 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/m4/ldflags.m4 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -# ldflags.m4 - Test and set linker flags -# -# Copyright 2011, 2012 Michael Steinert -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -# THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -#serial 1 - -# AX_TRY_LDFLAGS(FLAG, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) -# --------------------------------------------------------- -# Test if a linker flag is supported. -# FLAG: a linker flag to try -# ACTION-IF-TRUE: commands to execute if FLAG is supported -# ACTION-IF-FALSE: commands to execute if FLAG is not supported -AC_DEFUN([AX_TRY_LDFLAGS], -[dnl -_ax_ldflags=$LDFLAGS -LDFLAGS="$1 $LDFLAGS" -AC_MSG_CHECKING([if linker accepts '$1']) -AC_TRY_LINK([], [], - [AC_MSG_RESULT([yes]) - LDFLAGS=$_ax_ldflags - $2], - [AC_MSG_RESULT([no]) - LDFLAGS=$_ax_ldflags - $3]) -])dnl - -# AX_LDFLAGS(flags) -# ----------------- -# Enable linker flags. -# FLAGS: a whitespace-separated list of linker flags to set -AC_DEFUN([AX_LDFLAGS], -[dnl -m4_foreach_w([_ax_flag], [$1], - [AS_CASE([" $LDFLAGS "], - [*[[\ \ ]]_ax_flag[[\ \ ]]*], - [], - [*], - [LDFLAGS="$LDFLAGS _ax_flag"])]) -])dnl diff -Nru librabbitmq-0.7.1/m4/polarssl.m4 librabbitmq-0.9.0-0.1/m4/polarssl.m4 --- librabbitmq-0.7.1/m4/polarssl.m4 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/m4/polarssl.m4 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -# polarssl.m4 - Check for PolarSSL -# -# Copyright 2012 Michael Steinert -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -# THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -#serial 1 - -# _AX_LIB_POLARSSL -# ---------------- -# Check for the PolarSSL library and header file. If found the cache variable -# ax_cv_have_polarssl will be set to yes. -AC_DEFUN([_AX_LIB_POLARSSL], -[dnl -ax_cv_have_polarssl=no -_ax_polarssl_h=no -_ax_polarssl_lib=no -AC_ARG_VAR([POLARSSL_CFLAGS], - [C compiler flags for PolarSSL, overriding defaults]) -AC_ARG_VAR([POLARSSL_LIBS], [linker flags for PolarSSL, overriding defaults]) -AC_CHECK_HEADERS([polarssl/ssl.h], - [_ax_polarssl_h=yes],, - [$POLARSSL_CFLAGS]) -AS_IF([test "x$POLARSSL_LIBS" = "x"], - [AC_CHECK_LIB([polarssl], [entropy_init], - [POLARSSL_LIBS=-lpolarssl - _ax_polarssl_lib=yes])], - [_ax_polarssl_cflags=$CFLAGS - CFLAGS="$POLARSSL_CFLAGS $CFLAGS" - _ax_polarssl_ldflags=$LDFLAGS - LDFLAGS="$POLARSSL_LIBS $LDFLAGS" - AC_MSG_CHECKING([for libpolarssl]) - AC_TRY_LINK([#include ], - [entropy_init(NULL)], - [AC_MSG_RESULT([$POLARSSL_LIBS]) - _ax_polarssl_lib=yes], - [AC_MSG_RESULT([no])]) - CFLAGS=$_ax_polarssl_cflags - LDFLAGS=$_ax_polarssl_ldflags]) -AS_IF([test "x$_ax_polarssl_h" = "xyes" && \ - test "x$_ax_polarssl_lib" = "xyes"], - [ax_cv_have_polarssl=yes]) -])dnl - -# AX_LIB_POLARSSL([ACTION-IF-TRUE], [ACTION-IF-FALSE]) -# ------------------------------------------------ -# Check if PolarSSL is installed. If found the variable ax_have_polarssl will -# be set to yes. -# ACTION-IF-TRUE: commands to execute if PolarSSL is installed -# ACTION-IF-FALSE: commands to execute if PoloarSSL is not installed -AC_DEFUN([AX_LIB_POLARSSL], -[dnl -AC_CACHE_VAL([ax_cv_have_polarssl], [_AX_LIB_POLARSSL]) -ax_have_polarssl=$ax_cv_have_polarssl -AS_IF([test "x$ax_have_polarssl" = "xyes"], - [AC_DEFINE([HAVE_POLARSSL], [1], [Define to 1 if PolarSSL is available.]) - $1], [$2]) -])dnl diff -Nru librabbitmq-0.7.1/m4/popt.m4 librabbitmq-0.9.0-0.1/m4/popt.m4 --- librabbitmq-0.7.1/m4/popt.m4 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/m4/popt.m4 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -# popt.m4 - Check for Popt -# -# Copyright 2012 Michael Steinert -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -# THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -#serial 1 - -# _AX_LIB_POPT -# ------------ -# Check for the Popt library and header file. If found the cache variable -# ax_cv_have_popt will be set to yes. -AC_DEFUN([_AX_LIB_POPT], -[dnl -ax_cv_have_popt=no -_ax_popt_h=no -_ax_popt_lib=no -AC_ARG_VAR([POPT_CFLAGS], [C compiler flags for Popt, overriding defaults]) -AC_ARG_VAR([POPT_LIBS], [linker flags for Popt, overriding defaults]) -AC_CHECK_HEADERS([popt.h], - [_ax_popt_h=yes],, - [$POPT_CFLAGS]) -AS_IF([test "x$POPT_LIBS" = "x"], - [AC_CHECK_LIB([popt], [poptGetContext], - [POPT_LIBS=-lpopt - _ax_popt_lib=yes])], - [_ax_popt_cflags=$CFLAGS - CFLAGS="$POPT_CFLAGS $CFLAGS" - _ax_popt_ldflags=$LDFLAGS - LDFLAGS="$POPT_LIBS $LDFLAGS" - AC_MSG_CHECKING([for libpopt]) - AC_TRY_LINK([#include ], - [poptFreeContext(NULL)], - [AC_MSG_RESULT([$POPT_LIBS]) - _ax_popt_lib=yes], - [AC_MSG_RESULT([no])]) - CFLAGS=$_ax_popt_cflags - LDFLAGS=$_ax_popt_ldflags]) -AS_IF([test "x$_ax_popt_h" = "xyes" && \ - test "x$_ax_popt_lib" = "xyes"], - [ax_cv_have_popt=yes]) -])dnl - -# AX_LIB_POPT([ACTION-IF-TRUE], [ACTION-IF-FALSE]) -# ------------------------------------------------ -# Check is installed. If found the variable ax_have_popt will be set to yes. -# ACTION-IF-TRUE: commands to execute if Popt is installed -# ACTION-IF-FALSE: commands to execute if Popt is not installed -AC_DEFUN([AX_LIB_POPT], -[dnl -AC_CACHE_VAL([ax_cv_have_popt], [_AX_LIB_POPT]) -ax_have_popt=$ax_cv_have_popt -AS_IF([test "x$ax_have_popt" = "xyes"], - [AC_DEFINE([HAVE_POPT], [1], [Define to 1 if Popt is available.]) - $1], [$2]) -])dnl diff -Nru librabbitmq-0.7.1/Makefile.am librabbitmq-0.9.0-0.1/Makefile.am --- librabbitmq-0.7.1/Makefile.am 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,413 +0,0 @@ -# vim:set ts=2 sw=2 sts=2 noet: -ACLOCAL_AMFLAGS = -I m4 - -AM_CFLAGS = -I$(top_srcdir)/librabbitmq - -lib_LTLIBRARIES = librabbitmq/librabbitmq.la - -librabbitmq_librabbitmq_la_CFLAGS = \ - $(SSL_CFLAGS) \ - $(AM_CFLAGS) - -librabbitmq_librabbitmq_la_LDFLAGS = \ - -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ - $(NO_UNDEFINED) \ - $(SSL_LIBS) - -include_HEADERS = \ - librabbitmq/amqp.h \ - librabbitmq/amqp_framing.h \ - librabbitmq/amqp_tcp_socket.h - -if SSL -include_HEADERS += librabbitmq/amqp_ssl_socket.h -endif - -librabbitmq_librabbitmq_la_SOURCES = \ - librabbitmq/amqp_api.c \ - librabbitmq/amqp_connection.c \ - librabbitmq/amqp_consumer.c \ - librabbitmq/amqp_framing.c \ - librabbitmq/amqp_mem.c \ - librabbitmq/amqp_private.h \ - librabbitmq/amqp_socket.c \ - librabbitmq/amqp_socket.h \ - librabbitmq/amqp_table.c \ - librabbitmq/amqp_table.h \ - librabbitmq/amqp_tcp_socket.c \ - librabbitmq/amqp_tcp_socket.h \ - librabbitmq/amqp_time.c \ - librabbitmq/amqp_time.h \ - librabbitmq/amqp_url.c - - -if SSL_CYASSL -librabbitmq_librabbitmq_la_SOURCES += librabbitmq/amqp_cyassl.c -endif - -if SSL_GNUTLS -librabbitmq_librabbitmq_la_SOURCES += librabbitmq/amqp_gnutls.c -endif - -if SSL_OPENSSL -librabbitmq_librabbitmq_la_SOURCES += \ - librabbitmq/amqp_hostcheck.c \ - librabbitmq/amqp_hostcheck.h \ - librabbitmq/amqp_openssl.c -if OS_APPLE -librabbitmq_librabbitmq_la_CFLAGS += -Wno-deprecated-declarations -endif -endif - -if SSL_POLARSSL -librabbitmq_librabbitmq_la_SOURCES += librabbitmq/amqp_polarssl.c -endif - -if OS_UNIX -librabbitmq_librabbitmq_la_SOURCES += librabbitmq/unix/threads.h -librabbitmq_librabbitmq_la_CFLAGS += -I$(top_srcdir)/librabbitmq/unix -endif - -if OS_WIN32 -librabbitmq_librabbitmq_la_SOURCES += librabbitmq/win32/threads.h -librabbitmq_librabbitmq_la_CFLAGS += \ - -I$(top_srcdir)/librabbitmq/win32 \ - -I$(top_srcdir)/librabbitmq/win32/msinttypes -endif - - -check_PROGRAMS = \ - tests/test_tables \ - tests/test_parse_url \ - tests/test_hostcheck \ - tests/test_status_enum \ - tests/test_sasl_mechanism \ - tests/test_merge_capabilities - -TESTS = $(check_PROGRAMS) - -tests_test_tables_SOURCES = tests/test_tables.c -tests_test_tables_LDADD = librabbitmq/librabbitmq.a - -tests_test_parse_url_SOURCES = tests/test_parse_url.c -tests_test_parse_url_LDADD = librabbitmq/librabbitmq.a - -tests_test_hostcheck_SOURCES = \ - tests/test_hostcheck.c \ - librabbitmq/amqp_hostcheck.c - -tests_test_status_enum_SOURCES = tests/test_status_enum.c -tests_test_status_enum_LDADD = librabbitmq/librabbitmq.a - -tests_test_sasl_mechanism_SOURCES = tests/test_sasl_mechanism.c -tests_test_sasl_mechanism_LDADD = librabbitmq/librabbitmq.a - -tests_test_merge_capabilities_SOURCES = tests/test_merge_capabilities.c -tests_test_merge_capabilities_LDADD = librabbitmq/librabbitmq.a - -noinst_LTLIBRARIES = - -if EXAMPLES -noinst_LTLIBRARIES += examples/libutils.la - -examples_libutils_la_SOURCES = \ - examples/utils.c \ - examples/utils.h -examples_libutils_la_CFLAGS = $(AM_CFLAGS) - -if OS_UNIX -examples_libutils_la_SOURCES += examples/unix/platform_utils.c -endif - -if OS_WIN32 -examples_libutils_la_SOURCES += examples/win32/platform_utils.c -examples_libutils_la_CFLAGS += -I$(top_srcdir)/tools/win32/msinttypes -endif - -noinst_PROGRAMS = \ - examples/amqp_bind \ - examples/amqp_consumer \ - examples/amqp_connect_timeout \ - examples/amqp_exchange_declare \ - examples/amqp_listen \ - examples/amqp_listenq \ - examples/amqp_producer \ - examples/amqp_rpc_sendstring_client \ - examples/amqp_sendstring \ - examples/amqp_unbind - -examples_amqp_sendstring_SOURCES = examples/amqp_sendstring.c -examples_amqp_sendstring_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqp_exchange_declare_SOURCES = examples/amqp_exchange_declare.c -examples_amqp_exchange_declare_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqp_listen_SOURCES = examples/amqp_listen.c -examples_amqp_listen_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqp_producer_SOURCES = examples/amqp_producer.c -examples_amqp_producer_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqp_consumer_SOURCES = examples/amqp_consumer.c -examples_amqp_consumer_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqp_connect_timeout_SOURCES = examples/amqp_connect_timeout.c -examples_amqp_connect_timeout_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqp_unbind_SOURCES = examples/amqp_unbind.c -examples_amqp_unbind_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqp_bind_SOURCES = examples/amqp_bind.c -examples_amqp_bind_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqp_listenq_SOURCES = examples/amqp_listenq.c -examples_amqp_listenq_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqp_rpc_sendstring_client_SOURCES = \ - examples/amqp_rpc_sendstring_client.c -examples_amqp_rpc_sendstring_client_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -if SSL -noinst_PROGRAMS += \ - examples/amqps_bind \ - examples/amqps_connect_timeout \ - examples/amqps_consumer \ - examples/amqps_exchange_declare \ - examples/amqps_listen \ - examples/amqps_listenq \ - examples/amqps_producer \ - examples/amqps_sendstring \ - examples/amqps_unbind - -examples_amqps_bind_SOURCES = examples/amqps_bind.c -examples_amqps_bind_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqps_connect_timeout_SOURCES = examples/amqps_connect_timeout.c -examples_amqps_connect_timeout_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqps_consumer_SOURCES = examples/amqps_consumer.c -examples_amqps_consumer_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqps_exchange_declare_SOURCES = examples/amqps_exchange_declare.c -examples_amqps_exchange_declare_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqps_listen_SOURCES = examples/amqps_listen.c -examples_amqps_listen_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqps_listenq_SOURCES = examples/amqps_listenq.c -examples_amqps_listenq_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqps_producer_SOURCES = examples/amqps_producer.c -examples_amqps_producer_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqps_sendstring_SOURCES = examples/amqps_sendstring.c -examples_amqps_sendstring_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la - -examples_amqps_unbind_SOURCES = examples/amqps_unbind.c -examples_amqps_unbind_LDADD = \ - examples/libutils.la \ - librabbitmq/librabbitmq.la -endif -endif - -if TOOLS -noinst_LTLIBRARIES += tools/libcommon.la - -tools_libcommon_la_SOURCES = \ - tools/common.c \ - tools/common.h -tools_libcommon_la_CFLAGS = \ - $(AM_CFLAGS) \ - -I$(top_srcdir)/tools - -tools_platform_CFLAGS = $(AM_CFLAGS) - -if OS_UNIX -tools_libcommon_la_SOURCES += \ - tools/unix/process.c \ - tools/unix/process.h -tools_platform_CFLAGS += -I$(top_srcdir)/tools/unix -endif - -if OS_WIN32 -tools_libcommon_la_SOURCES += \ - tools/win32/compat.c \ - tools/win32/compat.h \ - tools/win32/process.c \ - tools/win32/process.h -tools_platform_CFLAGS += \ - -I$(top_srcdir)/tools/win32 \ - -I$(top_srcdir)/tools/win32/msinttypes -endif - -bin_PROGRAMS = \ - tools/amqp-consume \ - tools/amqp-declare-queue \ - tools/amqp-delete-queue \ - tools/amqp-get \ - tools/amqp-publish - -tools_amqp_publish_SOURCES = tools/publish.c -tools_amqp_publish_CFLAGS = \ - $(AM_CFLAGS) \ - $(POPT_CFLAGS) \ - $(tools_platform_CFLAGS) \ - -I$(top_srcdir)/tools -tools_amqp_publish_LDADD = \ - $(POPT_LIBS) \ - tools/libcommon.la \ - librabbitmq/librabbitmq.la - -tools_amqp_get_SOURCES = tools/get.c -tools_amqp_get_CFLAGS = \ - $(AM_CFLAGS) \ - $(POPT_CFLAGS) \ - $(tools_platform_CFLAGS) \ - -I$(top_srcdir)/tools -tools_amqp_get_LDADD = \ - $(POPT_LIBS) \ - tools/libcommon.la \ - librabbitmq/librabbitmq.la - -tools_amqp_consume_SOURCES = tools/consume.c -tools_amqp_consume_CFLAGS = \ - $(AM_CFLAGS) \ - $(POPT_CFLAGS) \ - $(tools_platform_CFLAGS) \ - -I$(top_srcdir)/tools -tools_amqp_consume_LDADD = \ - $(POPT_LIBS) \ - tools/libcommon.la \ - librabbitmq/librabbitmq.la - -tools_amqp_declare_queue_SOURCES = tools/declare_queue.c -tools_amqp_declare_queue_CFLAGS = \ - $(AM_CFLAGS) \ - $(POPT_CFLAGS) \ - $(tools_platform_CFLAGS) \ - -I$(top_srcdir)/tools -tools_amqp_declare_queue_LDADD = \ - $(POPT_LIBS) \ - tools/libcommon.la \ - librabbitmq/librabbitmq.la - -tools_amqp_delete_queue_SOURCES = tools/delete_queue.c -tools_amqp_delete_queue_CFLAGS = \ - $(AM_CFLAGS) \ - $(POPT_CFLAGS) \ - $(tools_platform_CFLAGS) \ - -I$(top_srcdir)/tools -tools_amqp_delete_queue_LDADD = \ - $(POPT_LIBS) \ - tools/libcommon.la \ - librabbitmq/librabbitmq.la - -if DOCS -man_MANS = \ - $(top_builddir)/tools/doc/amqp-publish.1 \ - $(top_builddir)/tools/doc/amqp-consume.1 \ - $(top_builddir)/tools/doc/amqp-get.1 \ - $(top_builddir)/tools/doc/amqp-declare-queue.1 \ - $(top_builddir)/tools/doc/amqp-delete-queue.1 \ - $(top_builddir)/tools/doc/librabbitmq-tools.7 - -# xmlto's --searchpath doesn't get passed through to xmllint, so we disable -# xmllint validation with --skip-validation for the benefit of build/source -# separation as required by distcheck, debian packaging etc. -XMLTO_FLAGS = \ - --skip-validation \ - --searchpath $(abs_top_builddir)/tools/doc - -%.1: %.xml $(top_builddir)/tools/doc/man-date.ent - $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) -o $(top_builddir)/tools/doc man $< - -%.7: %.xml $(top_builddir)/tools/doc/man-date.ent - $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) -o $(top_builddir)/tools/doc man $< - -$(top_builddir)/tools/doc/man-date.ent: - $(AM_V_at)$(MKDIR_P) $(top_builddir)/tools/doc - $(AM_V_GEN)date +'%Y-%m-%d' > $@ -endif # DOCS -endif # TOOLS - -EXTRA_DIST = \ - AUTHORS \ - CMakeLists.txt \ - CONTRIBUTING.md \ - ChangeLog.md \ - LICENSE-MIT \ - README-win32.md \ - README.md \ - README.vms \ - THANKS \ - TODO \ - cmake \ - codegen \ - descrip.mms \ - docs \ - examples/CMakeLists.txt \ - examples/descrip.mms \ - librabbitmq/CMakeLists.txt \ - librabbitmq/codegen.py \ - librabbitmq/descrip.mms \ - librabbitmq/win32 \ - tests/CMakeLists.txt \ - tests/test_tables.expected \ - tests/win32 \ - tools/CMakeLists.txt \ - tools/doc/amqp-consume.xml \ - tools/doc/amqp-declare-queue.xml \ - tools/doc/amqp-delete-queue.xml \ - tools/doc/amqp-get.xml \ - tools/doc/amqp-publish.xml \ - tools/doc/librabbitmq-tools.xml \ - vms - -MOSTLYCLEANFILES = \ - $(man_MANS) \ - $(top_builddir)/tools/doc/man-date.ent - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = librabbitmq.pc - -clean-local: - -$(MAKE) -C codegen clean - -distclean-local: - -$(MAKE) -C codegen distclean diff -Nru librabbitmq-0.7.1/.pc/applied-patches librabbitmq-0.9.0-0.1/.pc/applied-patches --- librabbitmq-0.7.1/.pc/applied-patches 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.pc/applied-patches 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1,2 @@ +cmake_with_ssl.patch +use_cmake_package.patch diff -Nru librabbitmq-0.7.1/.pc/cmake_with_ssl.patch/tools/CMakeLists.txt librabbitmq-0.9.0-0.1/.pc/cmake_with_ssl.patch/tools/CMakeLists.txt --- librabbitmq-0.7.1/.pc/cmake_with_ssl.patch/tools/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.pc/cmake_with_ssl.patch/tools/CMakeLists.txt 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1,82 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${LIBRABBITMQ_INCLUDE_DIRS} ${POPT_INCLUDE_DIR}) + +if (WIN32) + set(PLATFORM_DIR win32) + set(PLATFORM_SRCS + win32/compat.c + ) +else (WIN32) + set(PLATFORM_DIR unix) +endif (WIN32) + +include_directories(${PLATFORM_DIR}) + +set(COMMON_SRCS + common.h + common.c + ${PLATFORM_SRCS} + ) + +add_executable(amqp-publish publish.c ${COMMON_SRCS}) +target_link_libraries(amqp-publish ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY}) + +add_executable(amqp-get get.c ${COMMON_SRCS}) +target_link_libraries(amqp-get ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY}) + +add_executable(amqp-consume consume.c ${PLATFORM_DIR}/process.c ${COMMON_SRCS}) +target_link_libraries(amqp-consume ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY}) + +add_executable(amqp-declare-queue declare_queue.c ${COMMON_SRCS}) +target_link_libraries(amqp-declare-queue ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY}) + +add_executable(amqp-delete-queue delete_queue.c ${COMMON_SRCS}) +target_link_libraries(amqp-delete-queue ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY}) + +if (BUILD_TOOLS_DOCS) + if (XMLTO_FOUND) + set(DOCS_SRCS + doc/amqp-consume.xml + doc/amqp-declare-queue.xml + doc/amqp-delete-queue.xml + doc/amqp-get.xml + doc/amqp-publish.xml + doc/librabbitmq-tools.xml + ) + + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc) + set(XMLTO_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/doc/man-date.ent) + add_custom_command( + OUTPUT ${XMLTO_DEPENDS} + COMMAND date +'%Y-%m-%d' > ${XMLTO_DEPENDS} + VERBATIM + ) + + set(XMLTO_COMMAND_ARGS --skip-validation --searchpath "${CMAKE_CURRENT_BINARY_DIR}/doc") + + XMLTO(${DOCS_SRCS} + MODES man + ALL) + + foreach(file ${XMLTO_FILES_man}) + get_filename_component(fileExt ${file} EXT) + string( REGEX REPLACE "^[.]" "" fileExt ${fileExt} ) + install( + FILES ${file} + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man${fileExt} + ) + endforeach() + + else(XMLTO_FOUND) + message(WARNING "xmlto not found, will not build tools documentation") + endif(XMLTO_FOUND) +endif() + +if (ENABLE_SSL_SUPPORT) + add_definitions(-DWITH_SSL=1) +endif() + +install(TARGETS amqp-publish amqp-get amqp-consume amqp-declare-queue amqp-delete-queue + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + PUBLIC_HEADER DESTINATION include) diff -Nru librabbitmq-0.7.1/.pc/.quilt_patches librabbitmq-0.9.0-0.1/.pc/.quilt_patches --- librabbitmq-0.7.1/.pc/.quilt_patches 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.pc/.quilt_patches 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1 @@ +/home/buildd/build-RECIPEBRANCHBUILD-2425307/chroot-autobuild/home/buildd/work/tree/recipe/debian/patches diff -Nru librabbitmq-0.7.1/.pc/.quilt_series librabbitmq-0.9.0-0.1/.pc/.quilt_series --- librabbitmq-0.7.1/.pc/.quilt_series 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.pc/.quilt_series 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1 @@ +/home/buildd/build-RECIPEBRANCHBUILD-2425307/chroot-autobuild/home/buildd/work/tree/recipe/debian/patches/series diff -Nru librabbitmq-0.7.1/.pc/use_cmake_package.patch/cmake/CMakePushCheckState.cmake librabbitmq-0.9.0-0.1/.pc/use_cmake_package.patch/cmake/CMakePushCheckState.cmake --- librabbitmq-0.7.1/.pc/use_cmake_package.patch/cmake/CMakePushCheckState.cmake 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.pc/use_cmake_package.patch/cmake/CMakePushCheckState.cmake 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1,103 @@ +# This module defines two macros: +# CMAKE_PUSH_CHECK_STATE() +# and +# CMAKE_POP_CHECK_STATE() +# These two macros can be used to save and restore the state of the variables +# CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_LIBRARIES +# and CMAKE_REQUIRED_INCLUDES used by the various Check-files coming with CMake, +# like e.g. check_function_exists() etc. +# The variable contents are pushed on a stack, pushing multiple times is supported. +# This is useful e.g. when executing such tests in a Find-module, where they have to be set, +# but after the Find-module has been executed they should have the same value +# as they had before. +# +# Usage: +# cmake_push_check_state() +# set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF) +# check_function_exists(...) +# cmake_pop_check_state() + +#============================================================================= +# Copyright 2006-2011 Alexander Neundorf, +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the names of Kitware, Inc., the Insight Software Consortium, +# nor the names of their contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ------------------------------------------------------------------------------ +# +# The above copyright and license notice applies to distributions of +# CMake in source and binary form. Some source files contain additional +# notices of original copyright by their contributors; see each source +# for details. Third-party software packages supplied with CMake under +# compatible licenses provide their own copyright notices documented in +# corresponding subdirectories. +# +# ------------------------------------------------------------------------------ +# +# CMake was initially developed by Kitware with the following sponsorship: +# +# * National Library of Medicine at the National Institutes of Health +# as part of the Insight Segmentation and Registration Toolkit (ITK). +# +# * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel +# Visualization Initiative. +# +# * National Alliance for Medical Image Computing (NAMIC) is funded by the +# National Institutes of Health through the NIH Roadmap for Medical Research, +# Grant U54 EB005149. +# +# * Kitware, Inc. + +macro(CMAKE_PUSH_CHECK_STATE) + + if(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER) + set(_CMAKE_PUSH_CHECK_STATE_COUNTER 0) + endif() + + math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1") + + set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES}) + set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) + set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) + set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) +endmacro() + +macro(CMAKE_POP_CHECK_STATE) + +# don't pop more than we pushed + if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0") + + set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + + math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") + endif() + +endmacro() diff -Nru librabbitmq-0.7.1/.pc/use_cmake_package.patch/cmake/GNUInstallDirs.cmake librabbitmq-0.9.0-0.1/.pc/use_cmake_package.patch/cmake/GNUInstallDirs.cmake --- librabbitmq-0.7.1/.pc/use_cmake_package.patch/cmake/GNUInstallDirs.cmake 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.pc/use_cmake_package.patch/cmake/GNUInstallDirs.cmake 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1,205 @@ +#.rst: +# GNUInstallDirs +# -------------- +# +# Define GNU standard installation directories +# +# Provides install directory variables as defined for GNU software: +# +# :: +# +# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html +# +# Inclusion of this module defines the following variables: +# +# :: +# +# CMAKE_INSTALL_ - destination for files of a given type +# CMAKE_INSTALL_FULL_ - corresponding absolute path +# +# where is one of: +# +# :: +# +# BINDIR - user executables (bin) +# SBINDIR - system admin executables (sbin) +# LIBEXECDIR - program executables (libexec) +# SYSCONFDIR - read-only single-machine data (etc) +# SHAREDSTATEDIR - modifiable architecture-independent data (com) +# LOCALSTATEDIR - modifiable single-machine data (var) +# LIBDIR - object code libraries (lib or lib64 or lib/ on Debian) +# INCLUDEDIR - C header files (include) +# OLDINCLUDEDIR - C header files for non-gcc (/usr/include) +# DATAROOTDIR - read-only architecture-independent data root (share) +# DATADIR - read-only architecture-independent data (DATAROOTDIR) +# INFODIR - info documentation (DATAROOTDIR/info) +# LOCALEDIR - locale-dependent data (DATAROOTDIR/locale) +# MANDIR - man documentation (DATAROOTDIR/man) +# DOCDIR - documentation root (DATAROOTDIR/doc/PROJECT_NAME) +# +# Each CMAKE_INSTALL_ value may be passed to the DESTINATION +# options of install() commands for the corresponding file type. If the +# includer does not define a value the above-shown default will be used +# and the value will appear in the cache for editing by the user. Each +# CMAKE_INSTALL_FULL_ value contains an absolute path constructed +# from the corresponding destination by prepending (if necessary) the +# value of CMAKE_INSTALL_PREFIX. + +#============================================================================= +# Copyright 2011 Nikita Krupen'ko +# Copyright 2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Installation directories +# +if(NOT DEFINED CMAKE_INSTALL_BINDIR) + set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_SBINDIR) + set(CMAKE_INSTALL_SBINDIR "sbin" CACHE PATH "system admin executables (sbin)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_LIBEXECDIR) + set(CMAKE_INSTALL_LIBEXECDIR "libexec" CACHE PATH "program executables (libexec)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR) + set(CMAKE_INSTALL_SYSCONFDIR "etc" CACHE PATH "read-only single-machine data (etc)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_SHAREDSTATEDIR) + set(CMAKE_INSTALL_SHAREDSTATEDIR "com" CACHE PATH "modifiable architecture-independent data (com)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR) + set(CMAKE_INSTALL_LOCALSTATEDIR "var" CACHE PATH "modifiable single-machine data (var)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_LIBDIR) + set(_LIBDIR_DEFAULT "lib") + # Override this default 'lib' with 'lib64' iff: + # - we are on Linux system but NOT cross-compiling + # - we are NOT on debian + # - we are on a 64 bits system + # reason is: amd64 ABI: http://www.x86-64.org/documentation/abi.pdf + # For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if + # CMAKE_LIBRARY_ARCHITECTURE is set (which contains e.g. "i386-linux-gnu" + # See http://wiki.debian.org/Multiarch + if(CMAKE_SYSTEM_NAME MATCHES "Linux" + AND NOT CMAKE_CROSSCOMPILING) + if (EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE) + set(_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}") + endif() + else() # not debian, rely on CMAKE_SIZEOF_VOID_P: + if(NOT DEFINED CMAKE_SIZEOF_VOID_P) + message(AUTHOR_WARNING + "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. " + "Please enable at least one language before including GNUInstallDirs.") + else() + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(_LIBDIR_DEFAULT "lib64") + endif() + endif() + endif() + endif() + set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})") +endif() + +if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR) + set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C header files (include)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_OLDINCLUDEDIR) + set(CMAKE_INSTALL_OLDINCLUDEDIR "/usr/include" CACHE PATH "C header files for non-gcc (/usr/include)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR) + set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "read-only architecture-independent data root (share)") +endif() + +#----------------------------------------------------------------------------- +# Values whose defaults are relative to DATAROOTDIR. Store empty values in +# the cache and store the defaults in local variables if the cache values are +# not set explicitly. This auto-updates the defaults as DATAROOTDIR changes. + +if(NOT CMAKE_INSTALL_DATADIR) + set(CMAKE_INSTALL_DATADIR "" CACHE PATH "read-only architecture-independent data (DATAROOTDIR)") + set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}") +endif() + +if(NOT CMAKE_INSTALL_INFODIR) + set(CMAKE_INSTALL_INFODIR "" CACHE PATH "info documentation (DATAROOTDIR/info)") + set(CMAKE_INSTALL_INFODIR "${CMAKE_INSTALL_DATAROOTDIR}/info") +endif() + +if(NOT CMAKE_INSTALL_LOCALEDIR) + set(CMAKE_INSTALL_LOCALEDIR "" CACHE PATH "locale-dependent data (DATAROOTDIR/locale)") + set(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DATAROOTDIR}/locale") +endif() + +if(NOT CMAKE_INSTALL_MANDIR) + set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)") + set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man") +endif() + +if(NOT CMAKE_INSTALL_DOCDIR) + set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/PROJECT_NAME)") + set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}") +endif() + +#----------------------------------------------------------------------------- + +mark_as_advanced( + CMAKE_INSTALL_BINDIR + CMAKE_INSTALL_SBINDIR + CMAKE_INSTALL_LIBEXECDIR + CMAKE_INSTALL_SYSCONFDIR + CMAKE_INSTALL_SHAREDSTATEDIR + CMAKE_INSTALL_LOCALSTATEDIR + CMAKE_INSTALL_LIBDIR + CMAKE_INSTALL_INCLUDEDIR + CMAKE_INSTALL_OLDINCLUDEDIR + CMAKE_INSTALL_DATAROOTDIR + CMAKE_INSTALL_DATADIR + CMAKE_INSTALL_INFODIR + CMAKE_INSTALL_LOCALEDIR + CMAKE_INSTALL_MANDIR + CMAKE_INSTALL_DOCDIR + ) + +# Result directories +# +foreach(dir + BINDIR + SBINDIR + LIBEXECDIR + SYSCONFDIR + SHAREDSTATEDIR + LOCALSTATEDIR + LIBDIR + INCLUDEDIR + OLDINCLUDEDIR + DATAROOTDIR + DATADIR + INFODIR + LOCALEDIR + MANDIR + DOCDIR + ) + if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}}) + set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}") + else() + set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}") + endif() +endforeach() diff -Nru librabbitmq-0.7.1/.pc/.version librabbitmq-0.9.0-0.1/.pc/.version --- librabbitmq-0.7.1/.pc/.version 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.pc/.version 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1 @@ +2 diff -Nru librabbitmq-0.7.1/README.md librabbitmq-0.9.0-0.1/README.md --- librabbitmq-0.7.1/README.md 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/README.md 2019-10-20 10:14:51.000000000 +0000 @@ -2,6 +2,8 @@ [![Build Status](https://secure.travis-ci.org/alanxz/rabbitmq-c.png?branch=master)](http://travis-ci.org/alanxz/rabbitmq-c) +[![Coverage Status](https://coveralls.io/repos/github/alanxz/rabbitmq-c/badge.svg?branch=master)](https://coveralls.io/github/alanxz/rabbitmq-c?branch=master) + ## Introduction This is a C-language AMQP client library for use with v2.0+ of the @@ -10,8 +12,9 @@ - Announcements regarding the library are periodically made on the -rabbitmq-users mailing list: +rabbitmq-c-users and cross-posted to rabbitmq-users. + - - ## Latest Stable Version @@ -22,9 +25,9 @@ ## Documentation -API documentation for v0.5.0+ can viewed from: +API documentation for v0.8.0+ can viewed from: - + ## Getting started @@ -43,8 +46,8 @@ - *Optionally* [Doxygen](http://www.stack.nl/~dimitri/doxygen/) to build developer API documentation. -After downloading and extracting the source from a tarball to a directory. -([see above][Latest Stable Version]), the commands to build rabbitmq-c on most +After downloading and extracting the source from a tarball to a directory +([see above](#latest-stable-version)), the commands to build rabbitmq-c on most systems are: mkdir build && cd build @@ -79,23 +82,9 @@ find the XmlTo utility. * `ENABLE_SSL_SUPPORT=ON/OFF` toggles building rabbitmq-c with SSL support. By default this is ON if the OpenSSL headers and library can be found. -* `ENABLE_THREAD_SAFETY=ON/OFF` toggles OpenSSL thread-safety. By default this - is ON * `BUILD_API_DOCS=ON/OFF` - toggles building the Doxygen API documentation, by default this is OFF -#### autotools - -For legacy purposes, a GNU autotools based build system is also maintained. The required -utilities you need are autoconf v2.59+, automake v1.9+, libtool v2.2+, and pkg-config. - -Then the standard autotools build procedure will build rabbitmq-c: - - autoreconf -i - ./configure - make - make install - ## Running the examples Arrange for a RabbitMQ or other AMQP server to be running on diff -Nru librabbitmq-0.7.1/README.vms librabbitmq-0.9.0-0.1/README.vms --- librabbitmq-0.7.1/README.vms 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/README.vms 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -# rabbitmq-c on OpenVMS - -This rabbitmq-c has been tested and appears to work on OpenVMS v8.3 on the -Alpha platform, with HP TCP/IP services v5.5 -running. There is no reason to believe it won't work on OpenVMS v8.3 on -IA-64 (Itanium, a.k.a., Integrety) with an equivalent version of TCP/IP. -Or an older version of either of these pieces of software. - -NOTE: the maintainers of rabbitmq-c do not have access to an OpenVMS box to -regularly build and test rabbitmq-c, so this code may not build out of the box -and if it does it may not work correctly. However, the build system should -serve as a good starting point for getting something that does work. - -# Pre-reqs for building: -- HP C compiler - -# Instructions for building -1. Extract this package somewhere where you have space. -2. Run mms or mmk to run the build -3. The result of the build are a library and header files: - [.librabbitmq]rabbitmq.OLB for the library - [.librabbitmq]amqp.h and [.librabbitmq]amqp_framing.h for the header files. -To build against the library put these in a place where your compiler/linker can find them - -# Other notes about the build: -- The library is built using IEEE float with denormals enabled. This can be - adjusted by editing the OPTFLAGS line in [.vms]include.mms - - NOTE: the library takes no special care to translate vax-floats into IEEE-floats - so if you plan on compiling the library with vax-floats enabled you'll need - to make some changes - -- The library is built using /NAMES=(UPPER,TRUNC). Adjust OPTFLAGS line in [.vms]include.mms - as necessary to get the desired naming scheme. - -- The library is built using /POINTER=SHORT. Adjust OPTFLAGS line in [.vms]include.mms as - necessary to get the desired pointer size diff -Nru librabbitmq-0.7.1/README-win32.md librabbitmq-0.9.0-0.1/README-win32.md --- librabbitmq-0.7.1/README-win32.md 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/README-win32.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,131 +0,0 @@ -# Using rabbitmq-c on Windows - -================== -# This document is out of date - -To build rabbitmq-c on Win32 look at the "Building and Installing with CMake" section of README.md -================== - -There are three approaches to building rabbitmq-c under Windows: - -- THE PREFERRED METHOD: - Build using CMake, which will cover building with MSVC or MinGW - See the README file for details on how to build with cmake. - -- Build using the MinGW/MSYS (MinGW/MSYS is a port of the GNU - toolchain and utilities to Windows, including the gcc compiler). - The results of building in this way are native Windows DLLs and - EXEs, and can be used without having MinGW installed. The drawback - to this approach is that you cannot safely call the resulting - librabbitmq DLL from code compiled with Microsoft's C compiler. The - advantage is that the whole of rabbitmq-c can be built under - Windows, including the tools. - -- Build using Microsoft's C compiler. You will still need to install - MinGW/MSYS in order to run the rabbitmq-c build scripts, but - Microsoft's compiler is used to compile the code. The resulting - librabbitmq DLL can be used from code compiled with Microsoft's C - compiler (i.e. code developed in Visual Studio). The downside to - this approach is that the rabbitmq-c tools cannot be built, due to - dependencies on other libraries. - - -## Common steps - -With either of the approaches, the initial steps are the same: You -should download and install MinGW/MSYS and Python. - -Installing installing the relevant parts of MinGW/MSYS can be fairly -time consuming - there are dozens of files to be downloaded and -unpacked. To make it easier, we provide a bash script that automates -this process, in `rabbitmq-c/etc/install-mingw.sh`. You can run this -script under cygwin or Linux (obviously if you use Linux you'll need -to transfer the resulting files over to the Windows machine). - -Note that some MinGW packages are .tar.lzma files, so it requires a -system with the xz compression utility and a tar that supports the -J -option. Recent cygwin and Linux distros should be fine here. - -Run the install-mingw.sh script specifying the destination directory, -e.g. - - $ etc/install-mingw.sh mingw - -This will download all the required MinGW/MSYS packages, and unpack -them into the `mingw` directory. - -The other prerequisite for the rabbitmq-c build is Python. The -Windows installer from python.org for the latest 2.x version of Python -will do fine. - -You will also need to copy the source code for rabbitmq-c and -rabbitmq-codegen somewhere under your `mingw` directory. - -Then to start the MSYS bash shell, open a `cmd` window, and ensure -that both the MinGW bin directory and the python install directory are -in the path, e.g. - - C:\>set PATH=%PATH%;C:\mingw\bin;C:\Python27 - -Then start bash, and run the following mount command (substituting the -Windows path of your MinGW install if it isn't `C:\mingw`): - - C:\>bash - bash-3.1$ mount 'C:\mingw' /mingw - -Finally, go to wherever you copied the rabbitmq-c source. - - bash-3.1$ cd /rabbitmq-c - - -## Building rabbitmq-c with Microsoft's C compiler - -The Microsoft C/C++ compiler is part of MS Visual Studio, including -the gratis Visual Studio Express. Visual Studio 2005 and higher are -known to work. - -Start by following the steps in the previous section. The GNU build -tools have limited support for Microsoft toolchain, but the -install-mingw.sh script will install versions of the packages that are -known to be suitable. In particular, only libtool version 2.2.7a is -known to work; later versions have been reported to introduce -problems. - -Once you are at the bash prompt, build rabbitmq-c by running the -script in `rabbitmq-c/etc/build-ms.sh`: - - bash-3.1$ etc/build-ms.sh - -You should end up with a directory `build` containing the librabbitmq -DLL, the corresponding .lib file, and header files. These are -sufficient to create applications using librabbitmq within Visual -Studio. - -build-ms.sh produces 32-bit binaries by default. If you have an -appropriate version of Visual Studio (e.g. VS2010), you can build -64-bit binaries with: - - bash-3.1$ etc/build-ms.sh --enable-64-bit - - -## Building rabbitmq-c with gcc - -There is no script to build rabbitmq-c with gcc, but it is as -documented in the README file: - - bash-3.1$ autoreconf -i && ./configure && make - -You can run the resulting tool EXEs without needing the rest of MinGW. To do -this, copy the following files into a single directory: - -- rabbitmq-c/tools/.libs/*.exe - -- rabbitmq-c/librabbitmq/.libs/librabbitmq-0.dll - -- /bin/libpopt-0.dll - -- /bin/libiconv-2.dll - -- /bin/libintl-8.dll - - diff -Nru librabbitmq-0.7.1/tests/CMakeLists.txt librabbitmq-0.9.0-0.1/tests/CMakeLists.txt --- librabbitmq-0.7.1/tests/CMakeLists.txt 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tests/CMakeLists.txt 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -# vim:set ts=2 sw=2 sts=2 et: include_directories(${LIBRABBITMQ_INCLUDE_DIRS}) if (MSVC) @@ -30,6 +29,14 @@ target_link_libraries(test_status_enum rabbitmq-static) add_test(status_enum test_status_enum) +add_executable(test_basic + test_basic.c) +target_link_libraries(test_basic rabbitmq-static) + +if (NOT APPLE) + add_test(basic test_basic) +endif() + add_executable(test_sasl_mechanism test_sasl_mechanism.c) target_link_libraries(test_sasl_mechanism rabbitmq-static) add_test(sasl_mechanism test_sasl_mechanism) @@ -37,3 +44,4 @@ add_executable(test_merge_capabilities test_merge_capabilities.c) target_link_libraries(test_merge_capabilities rabbitmq-static) add_test(merge_capabilities test_merge_capabilities) + diff -Nru librabbitmq-0.7.1/tests/test_basic.c librabbitmq-0.9.0-0.1/tests/test_basic.c --- librabbitmq-0.7.1/tests/test_basic.c 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tests/test_basic.c 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1,207 @@ +/* + * Copyright 2017 Simon Giesecke + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "amqp.h" +#include "amqp_tcp_socket.h" +#include "amqp_time.h" + +#include +#include +#include + +#ifdef _WIN32 +#include +#else +#include +#endif + +#ifdef NDEBUG +#undef NDEBUG +#endif +#include + +static const int fixed_channel_id = 1; +static const char test_queue_name[] = "test_queue"; + +amqp_connection_state_t setup_connection_and_channel(void) { + amqp_connection_state_t connection_state_ = amqp_new_connection(); + + amqp_socket_t *socket = amqp_tcp_socket_new(connection_state_); + assert(socket); + + int rc = amqp_socket_open(socket, "localhost", AMQP_PROTOCOL_PORT); + assert(rc == AMQP_STATUS_OK); + + amqp_rpc_reply_t rpc_reply = amqp_login( + connection_state_, "/", 1, AMQP_DEFAULT_FRAME_SIZE, + AMQP_DEFAULT_HEARTBEAT, AMQP_SASL_METHOD_PLAIN, "guest", "guest"); + assert(rpc_reply.reply_type == AMQP_RESPONSE_NORMAL); + + amqp_channel_open_ok_t *res = + amqp_channel_open(connection_state_, fixed_channel_id); + assert(res != NULL); + + return connection_state_; +} + +void close_and_destroy_connection(amqp_connection_state_t connection_state_) { + amqp_rpc_reply_t rpc_reply = + amqp_connection_close(connection_state_, AMQP_REPLY_SUCCESS); + assert(rpc_reply.reply_type == AMQP_RESPONSE_NORMAL); + + int rc = amqp_destroy_connection(connection_state_); + assert(rc == AMQP_STATUS_OK); +} + +void basic_publish(amqp_connection_state_t connectionState_, + const char *message_) { + amqp_bytes_t message_bytes = amqp_cstring_bytes(message_); + + amqp_basic_properties_t properties; + properties._flags = 0; + + properties._flags |= AMQP_BASIC_DELIVERY_MODE_FLAG; + properties.delivery_mode = AMQP_DELIVERY_NONPERSISTENT; + + int retval = amqp_basic_publish( + connectionState_, fixed_channel_id, amqp_cstring_bytes(""), + amqp_cstring_bytes(test_queue_name), + /* mandatory=*/1, + /* immediate=*/0, /* RabbitMQ 3.x does not support the "immediate" flag + according to + https://www.rabbitmq.com/specification.html */ + &properties, message_bytes); + + assert(retval == 0); +} + +void queue_declare(amqp_connection_state_t connection_state_, + const char *queue_name_) { + amqp_queue_declare_ok_t *res = amqp_queue_declare( + connection_state_, fixed_channel_id, amqp_cstring_bytes(queue_name_), + /*passive*/ 0, + /*durable*/ 0, + /*exclusive*/ 0, + /*auto_delete*/ 1, amqp_empty_table); + assert(res != NULL); +} + +char *basic_get(amqp_connection_state_t connection_state_, + const char *queue_name_, uint64_t *out_body_size_) { + amqp_rpc_reply_t rpc_reply; + amqp_time_t deadline; + struct timeval timeout = {5, 0}; + int time_rc = amqp_time_from_now(&deadline, &timeout); + assert(time_rc == AMQP_STATUS_OK); + + do { + rpc_reply = amqp_basic_get(connection_state_, fixed_channel_id, + amqp_cstring_bytes(queue_name_), /*no_ack*/ 1); + } while (rpc_reply.reply_type == AMQP_RESPONSE_NORMAL && + rpc_reply.reply.id == AMQP_BASIC_GET_EMPTY_METHOD && + amqp_time_has_past(deadline) == AMQP_STATUS_OK); + + assert(rpc_reply.reply_type == AMQP_RESPONSE_NORMAL); + assert(rpc_reply.reply.id == AMQP_BASIC_GET_OK_METHOD); + + amqp_message_t message; + rpc_reply = + amqp_read_message(connection_state_, fixed_channel_id, &message, 0); + assert(rpc_reply.reply_type == AMQP_RESPONSE_NORMAL); + + char *body = malloc(message.body.len); + memcpy(body, message.body.bytes, message.body.len); + *out_body_size_ = message.body.len; + amqp_destroy_message(&message); + + return body; +} + +void publish_and_basic_get_message(const char *msg_to_publish) { + amqp_connection_state_t connection_state = setup_connection_and_channel(); + + queue_declare(connection_state, test_queue_name); + basic_publish(connection_state, msg_to_publish); + + uint64_t body_size; + char *msg = basic_get(connection_state, test_queue_name, &body_size); + + assert(body_size == strlen(msg_to_publish)); + assert(strncmp(msg_to_publish, msg, body_size) == 0); + free(msg); + + close_and_destroy_connection(connection_state); +} + +char *consume_message(amqp_connection_state_t connection_state_, + const char *queue_name_, uint64_t *out_body_size_) { + amqp_basic_consume_ok_t *result = + amqp_basic_consume(connection_state_, fixed_channel_id, + amqp_cstring_bytes(queue_name_), amqp_empty_bytes, + /*no_local*/ 0, + /*no_ack*/ 1, + /*exclusive*/ 0, amqp_empty_table); + assert(result != NULL); + + amqp_envelope_t envelope; + struct timeval timeout = {5, 0}; + amqp_rpc_reply_t rpc_reply = + amqp_consume_message(connection_state_, &envelope, &timeout, 0); + assert(rpc_reply.reply_type == AMQP_RESPONSE_NORMAL); + + *out_body_size_ = envelope.message.body.len; + char *body = malloc(*out_body_size_); + if (*out_body_size_) { + memcpy(body, envelope.message.body.bytes, *out_body_size_); + } + + amqp_destroy_envelope(&envelope); + return body; +} + +void publish_and_consume_message(const char *msg_to_publish) { + amqp_connection_state_t connection_state = setup_connection_and_channel(); + + queue_declare(connection_state, test_queue_name); + basic_publish(connection_state, msg_to_publish); + + uint64_t body_size; + char *msg = consume_message(connection_state, test_queue_name, &body_size); + + assert(body_size == strlen(msg_to_publish)); + assert(strncmp(msg_to_publish, msg, body_size) == 0); + free(msg); + + close_and_destroy_connection(connection_state); +} + +int main(void) { + publish_and_basic_get_message(""); + publish_and_basic_get_message("TEST"); + + publish_and_consume_message(""); + publish_and_consume_message("TEST"); + + return 0; +} diff -Nru librabbitmq-0.7.1/tests/test_hostcheck.c librabbitmq-0.9.0-0.1/tests/test_hostcheck.c --- librabbitmq-0.7.1/tests/test_hostcheck.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tests/test_hostcheck.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * Copyright 2014 Michael Steinert * @@ -32,13 +31,11 @@ #include #include -static void -hostcheck_success(const char *match_pattern, const char *url) -{ +static void hostcheck_success(const char *match_pattern, const char *url) { int ok; ok = amqp_hostcheck(match_pattern, url); - if (! ok) { + if (!ok) { fprintf(stderr, "Expected hostname check to pass, but didn't: %s (%s)\n", url, match_pattern); abort(); @@ -47,9 +44,7 @@ fprintf(stdout, "ok: [success] %s, %s\n", url, match_pattern); } -static void -hostcheck_fail(const char *match_pattern, const char *url) -{ +static void hostcheck_fail(const char *match_pattern, const char *url) { int ok; ok = amqp_hostcheck(match_pattern, url); @@ -62,9 +57,7 @@ fprintf(stdout, "ok: [fail] %s, %s\n", url, match_pattern); } -int -main(void) -{ +int main(void) { hostcheck_success("www.rabbitmq.com", "www.rabbitmq.com"); hostcheck_success("www.rabbitmq.com", "wWw.RaBbItMq.CoM"); hostcheck_success("*.rabbitmq.com", "wWw.RaBbItMq.CoM"); diff -Nru librabbitmq-0.7.1/tests/test_merge_capabilities.c librabbitmq-0.9.0-0.1/tests/test_merge_capabilities.c --- librabbitmq-0.7.1/tests/test_merge_capabilities.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tests/test_merge_capabilities.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * Copyright 2015 Alan Antonuk. All Rights Reserved. * @@ -87,23 +86,21 @@ case AMQP_FIELD_KIND_UTF8: case AMQP_FIELD_KIND_BYTES: return compare_bytes(result.value.bytes, expect.value.bytes); - case AMQP_FIELD_KIND_ARRAY: - { - int i; - if (result.value.array.num_entries != expect.value.array.num_entries) { + case AMQP_FIELD_KIND_ARRAY: { + int i; + if (result.value.array.num_entries != expect.value.array.num_entries) { + return 0; + } + for (i = 0; i < result.value.array.num_entries; ++i) { + if (!compare_field_value(result.value.array.entries[i], + expect.value.array.entries[i])) { return 0; } - for (i = 0; i < result.value.array.num_entries; ++i) { - if (!compare_field_value(result.value.array.entries[i], - expect.value.array.entries[i])) { - return 0; - } - } - return 1; } + return 1; + } case AMQP_FIELD_KIND_TABLE: - return compare_amqp_table(&result.value.table, - &expect.value.table); + return compare_amqp_table(&result.value.table, &expect.value.table); case AMQP_FIELD_KIND_VOID: return 1; } @@ -164,7 +161,8 @@ amqp_table_entry_t expect_entries[4]; sub_base_entries[0] = amqp_table_construct_utf8_entry("foo", "bar"); - sub_base.num_entries = sizeof(sub_base_entries) / sizeof(amqp_table_entry_t); + sub_base.num_entries = + sizeof(sub_base_entries) / sizeof(amqp_table_entry_t); sub_base.entries = sub_base_entries; sub_add_entries[0] = amqp_table_construct_utf8_entry("something", "else"); @@ -173,8 +171,10 @@ sub_add.entries = sub_add_entries; sub_expect_entries[0] = amqp_table_construct_utf8_entry("foo", "baz"); - sub_expect_entries[1] = amqp_table_construct_utf8_entry("something", "else"); - sub_expect.num_entries = sizeof(sub_expect_entries) / sizeof(amqp_table_entry_t); + sub_expect_entries[1] = + amqp_table_construct_utf8_entry("something", "else"); + sub_expect.num_entries = + sizeof(sub_expect_entries) / sizeof(amqp_table_entry_t); sub_expect.entries = sub_expect_entries; base_entries[0] = amqp_table_construct_utf8_entry("product", "1.0"); @@ -201,4 +201,3 @@ fprintf(stderr, "ok\n"); return 0; } - diff -Nru librabbitmq-0.7.1/tests/test_parse_url.c librabbitmq-0.9.0-0.1/tests/test_parse_url.c --- librabbitmq-0.7.1/tests/test_parse_url.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tests/test_parse_url.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -38,51 +37,42 @@ #ifdef _MSC_VER /* MSVC complains about strdup being deprecated in favor of _strdup */ -# define _CRT_NONSTDC_NO_DEPRECATE +#define _CRT_NONSTDC_NO_DEPRECATE #endif #include -#include #include +#include #include #include -static void match_string(const char *what, const char *expect, const char *got) -{ +static void match_string(const char *what, const char *expect, + const char *got) { if (strcmp(got, expect)) { - fprintf(stderr, "Expected %s '%s', got '%s'\n", - what, expect, got); + fprintf(stderr, "Expected %s '%s', got '%s'\n", what, expect, got); abort(); } } -static void match_int(const char *what, int expect, int got) -{ +static void match_int(const char *what, int expect, int got) { if (got != expect) { - fprintf(stderr, "Expected %s '%d', got '%d'\n", - what, expect, got); + fprintf(stderr, "Expected %s '%d', got '%d'\n", what, expect, got); abort(); } } -static void parse_success(const char *url, - const char *user, - const char *password, - const char *host, - int port, - const char *vhost) -{ +static void parse_success(const char *url, const char *user, + const char *password, const char *host, int port, + const char *vhost) { char *s = strdup(url); struct amqp_connection_info ci; int res; - amqp_default_connection_info(&ci); res = amqp_parse_url(s, &ci); if (res) { - fprintf(stderr, - "Expected to successfully parse URL, but didn't: %s (%s)\n", + fprintf(stderr, "Expected to successfully parse URL, but didn't: %s (%s)\n", url, amqp_error_string2(res)); abort(); } @@ -96,34 +86,30 @@ free(s); } -static void parse_fail(const char *url) -{ +static void parse_fail(const char *url) { char *s = strdup(url); struct amqp_connection_info ci; amqp_default_connection_info(&ci); if (amqp_parse_url(s, &ci) >= 0) { - fprintf(stderr, - "Expected to fail parsing URL, but didn't: %s\n", - url); + fprintf(stderr, "Expected to fail parsing URL, but didn't: %s\n", url); abort(); } free(s); } -int main(void) -{ +int main(void) { /* From the spec */ - parse_success("amqp://user:pass@host:10000/vhost", "user", "pass", - "host", 10000, "vhost"); - parse_success("amqps://user:pass@host:10000/vhost", "user", "pass", - "host", 10000, "vhost"); - - parse_success("amqp://user%61:%61pass@ho%61st:10000/v%2fhost", - "usera", "apass", "hoast", 10000, "v/host"); - parse_success("amqps://user%61:%61pass@ho%61st:10000/v%2fhost", - "usera", "apass", "hoast", 10000, "v/host"); + parse_success("amqp://user:pass@host:10000/vhost", "user", "pass", "host", + 10000, "vhost"); + parse_success("amqps://user:pass@host:10000/vhost", "user", "pass", "host", + 10000, "vhost"); + + parse_success("amqp://user%61:%61pass@ho%61st:10000/v%2fhost", "usera", + "apass", "hoast", 10000, "v/host"); + parse_success("amqps://user%61:%61pass@ho%61st:10000/v%2fhost", "usera", + "apass", "hoast", 10000, "v/host"); parse_success("amqp://", "guest", "guest", "localhost", 5672, "/"); parse_success("amqps://", "guest", "guest", "localhost", 5671, "/"); @@ -134,23 +120,17 @@ parse_success("amqp://user@", "user", "guest", "localhost", 5672, "/"); parse_success("amqps://user@", "user", "guest", "localhost", 5671, "/"); - parse_success("amqp://user:pass@", "user", "pass", - "localhost", 5672, "/"); - parse_success("amqps://user:pass@", "user", "pass", - "localhost", 5671, "/"); + parse_success("amqp://user:pass@", "user", "pass", "localhost", 5672, "/"); + parse_success("amqps://user:pass@", "user", "pass", "localhost", 5671, "/"); parse_success("amqp://host", "guest", "guest", "host", 5672, "/"); parse_success("amqps://host", "guest", "guest", "host", 5671, "/"); - parse_success("amqp://:10000", "guest", "guest", "localhost", 10000, - "/"); - parse_success("amqps://:10000", "guest", "guest", "localhost", 10000, - "/"); + parse_success("amqp://:10000", "guest", "guest", "localhost", 10000, "/"); + parse_success("amqps://:10000", "guest", "guest", "localhost", 10000, "/"); - parse_success("amqp:///vhost", "guest", "guest", "localhost", 5672, - "vhost"); - parse_success("amqps:///vhost", "guest", "guest", "localhost", 5671, - "vhost"); + parse_success("amqp:///vhost", "guest", "guest", "localhost", 5672, "vhost"); + parse_success("amqps:///vhost", "guest", "guest", "localhost", 5671, "vhost"); parse_success("amqp://host/", "guest", "guest", "host", 5672, ""); parse_success("amqps://host/", "guest", "guest", "host", 5671, ""); @@ -168,55 +148,37 @@ parse_success("amqp://[::1]:100", "guest", "guest", "::1", 100, "/"); parse_success("amqps://[::1]:100", "guest", "guest", "::1", 100, "/"); - parse_success("amqp://host/blah", "guest", "guest", - "host", 5672, "blah"); - parse_success("amqps://host/blah", "guest", "guest", - "host", 5671, "blah"); - - parse_success("amqp://host:100/blah", "guest", "guest", - "host", 100, "blah"); - parse_success("amqps://host:100/blah", "guest", "guest", - "host", 100, "blah"); - - parse_success("amqp://:100/blah", "guest", "guest", - "localhost", 100, "blah"); - parse_success("amqps://:100/blah", "guest", "guest", - "localhost", 100, "blah"); - - parse_success("amqp://[::1]/blah", "guest", "guest", - "::1", 5672, "blah"); - parse_success("amqps://[::1]/blah", "guest", "guest", - "::1", 5671, "blah"); - - parse_success("amqp://[::1]:100/blah", "guest", "guest", - "::1", 100, "blah"); - parse_success("amqps://[::1]:100/blah", "guest", "guest", - "::1", 100, "blah"); - - parse_success("amqp://user:pass@host", "user", "pass", - "host", 5672, "/"); - parse_success("amqps://user:pass@host", "user", "pass", - "host", 5671, "/"); - - parse_success("amqp://user:pass@host:100", "user", "pass", - "host", 100, "/"); - parse_success("amqps://user:pass@host:100", "user", "pass", - "host", 100, "/"); - - parse_success("amqp://user:pass@:100", "user", "pass", - "localhost", 100, "/"); - parse_success("amqps://user:pass@:100", "user", "pass", - "localhost", 100, "/"); - - parse_success("amqp://user:pass@[::1]", "user", "pass", - "::1", 5672, "/"); - parse_success("amqps://user:pass@[::1]", "user", "pass", - "::1", 5671, "/"); - - parse_success("amqp://user:pass@[::1]:100", "user", "pass", - "::1", 100, "/"); - parse_success("amqps://user:pass@[::1]:100", "user", "pass", - "::1", 100, "/"); + parse_success("amqp://host/blah", "guest", "guest", "host", 5672, "blah"); + parse_success("amqps://host/blah", "guest", "guest", "host", 5671, "blah"); + + parse_success("amqp://host:100/blah", "guest", "guest", "host", 100, "blah"); + parse_success("amqps://host:100/blah", "guest", "guest", "host", 100, "blah"); + + parse_success("amqp://:100/blah", "guest", "guest", "localhost", 100, "blah"); + parse_success("amqps://:100/blah", "guest", "guest", "localhost", 100, + "blah"); + + parse_success("amqp://[::1]/blah", "guest", "guest", "::1", 5672, "blah"); + parse_success("amqps://[::1]/blah", "guest", "guest", "::1", 5671, "blah"); + + parse_success("amqp://[::1]:100/blah", "guest", "guest", "::1", 100, "blah"); + parse_success("amqps://[::1]:100/blah", "guest", "guest", "::1", 100, "blah"); + + parse_success("amqp://user:pass@host", "user", "pass", "host", 5672, "/"); + parse_success("amqps://user:pass@host", "user", "pass", "host", 5671, "/"); + + parse_success("amqp://user:pass@host:100", "user", "pass", "host", 100, "/"); + parse_success("amqps://user:pass@host:100", "user", "pass", "host", 100, "/"); + + parse_success("amqp://user:pass@:100", "user", "pass", "localhost", 100, "/"); + parse_success("amqps://user:pass@:100", "user", "pass", "localhost", 100, + "/"); + + parse_success("amqp://user:pass@[::1]", "user", "pass", "::1", 5672, "/"); + parse_success("amqps://user:pass@[::1]", "user", "pass", "::1", 5671, "/"); + + parse_success("amqp://user:pass@[::1]:100", "user", "pass", "::1", 100, "/"); + parse_success("amqps://user:pass@[::1]:100", "user", "pass", "::1", 100, "/"); /* Various failure cases */ parse_fail("http://www.rabbitmq.com"); diff -Nru librabbitmq-0.7.1/tests/test_sasl_mechanism.c librabbitmq-0.9.0-0.1/tests/test_sasl_mechanism.c --- librabbitmq-0.7.1/tests/test_sasl_mechanism.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tests/test_sasl_mechanism.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -35,25 +34,21 @@ */ #include -#include #include +#include #include static void parse_success(amqp_bytes_t mechanisms, - amqp_sasl_method_enum method) -{ + amqp_sasl_method_enum method) { if (!sasl_mechanism_in_list(mechanisms, method)) { - fprintf(stderr, - "Expected to find mechanism in list, but didn't: %s\n", + fprintf(stderr, "Expected to find mechanism in list, but didn't: %s\n", (char *)mechanisms.bytes); abort(); } } -static void parse_fail(amqp_bytes_t mechanisms, - amqp_sasl_method_enum method) -{ +static void parse_fail(amqp_bytes_t mechanisms, amqp_sasl_method_enum method) { if (sasl_mechanism_in_list(mechanisms, method)) { fprintf(stderr, "Expected the mechanism not on the list, but it was present: %s\n", @@ -62,11 +57,14 @@ } } -int main(void) -{ - parse_success(amqp_cstring_bytes("DIGEST-MD5 CRAM-MD5 LOGIN PLAIN"), AMQP_SASL_METHOD_PLAIN); - parse_fail(amqp_cstring_bytes("DIGEST-MD5 CRAM-MD5 LOGIN PLAIN"), AMQP_SASL_METHOD_EXTERNAL); - parse_success(amqp_cstring_bytes("DIGEST-MD5 CRAM-MD5 EXTERNAL"), AMQP_SASL_METHOD_EXTERNAL); - parse_fail(amqp_cstring_bytes("DIGEST-MD5 CRAM-MD5 EXTERNAL"), AMQP_SASL_METHOD_PLAIN); +int main(void) { + parse_success(amqp_cstring_bytes("DIGEST-MD5 CRAM-MD5 LOGIN PLAIN"), + AMQP_SASL_METHOD_PLAIN); + parse_fail(amqp_cstring_bytes("DIGEST-MD5 CRAM-MD5 LOGIN PLAIN"), + AMQP_SASL_METHOD_EXTERNAL); + parse_success(amqp_cstring_bytes("DIGEST-MD5 CRAM-MD5 EXTERNAL"), + AMQP_SASL_METHOD_EXTERNAL); + parse_fail(amqp_cstring_bytes("DIGEST-MD5 CRAM-MD5 EXTERNAL"), + AMQP_SASL_METHOD_PLAIN); return 0; } diff -Nru librabbitmq-0.7.1/tests/test_status_enum.c librabbitmq-0.9.0-0.1/tests/test_status_enum.c --- librabbitmq-0.7.1/tests/test_status_enum.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tests/test_status_enum.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * Copyright 2015 Alan Antonuk * @@ -38,9 +37,7 @@ for (i = start; i > end; --i) { const char* err = amqp_error_string2(i); if (0 == strcmp(err, "(unknown error)")) { - printf("amqp_status_enum value %s%X", - i < 0 ? "-" : "", - (unsigned)i); + printf("amqp_status_enum value %s%X", i < 0 ? "-" : "", (unsigned)i); abort(); } } diff -Nru librabbitmq-0.7.1/tests/test_tables.c librabbitmq-0.9.0-0.1/tests/test_tables.c --- librabbitmq-0.7.1/tests/test_tables.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tests/test_tables.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -35,15 +34,15 @@ */ #ifdef _MSC_VER -# define _USE_MATH_DEFINES -# define _CRT_SECURE_NO_WARNINGS +#define _USE_MATH_DEFINES +#define _CRT_SECURE_NO_WARNINGS #endif -#include +#include +#include #include +#include #include -#include -#include #include @@ -51,8 +50,7 @@ #include -void die(const char *fmt, ...) -{ +void die(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); @@ -61,8 +59,7 @@ abort(); } -static void dump_indent(int indent, FILE *out) -{ +static void dump_indent(int indent, FILE *out) { int i; for (i = 0; i < indent; i++) { @@ -70,109 +67,106 @@ } } -static void dump_value(int indent, amqp_field_value_t v, FILE *out) -{ +static void dump_value(int indent, amqp_field_value_t v, FILE *out) { int i; dump_indent(indent, out); fputc(v.kind, out); switch (v.kind) { - case AMQP_FIELD_KIND_BOOLEAN: - fputs(v.value.boolean ? " true\n" : " false\n", out); - break; - - case AMQP_FIELD_KIND_I8: - fprintf(out, " %"PRId8"\n", v.value.i8); - break; - - case AMQP_FIELD_KIND_U8: - fprintf(out, " %"PRIu8"\n", v.value.u8); - break; - - case AMQP_FIELD_KIND_I16: - fprintf(out, " %"PRId16"\n", v.value.i16); - break; - - case AMQP_FIELD_KIND_U16: - fprintf(out, " %"PRIu16"\n", v.value.u16); - break; - - case AMQP_FIELD_KIND_I32: - fprintf(out, " %"PRId32"\n", v.value.i32); - break; - - case AMQP_FIELD_KIND_U32: - fprintf(out, " %"PRIu32"\n", v.value.u32); - break; - - case AMQP_FIELD_KIND_I64: - fprintf(out, " %"PRId64"\n", v.value.i64); - break; - - case AMQP_FIELD_KIND_F32: - fprintf(out, " %g\n", (double) v.value.f32); - break; - - case AMQP_FIELD_KIND_F64: - fprintf(out, " %g\n", v.value.f64); - break; - - case AMQP_FIELD_KIND_DECIMAL: - fprintf(out, " %d:::%u\n", v.value.decimal.decimals, - v.value.decimal.value); - break; - - case AMQP_FIELD_KIND_UTF8: - fprintf(out, " %.*s\n", (int)v.value.bytes.len, - (char *)v.value.bytes.bytes); - break; + case AMQP_FIELD_KIND_BOOLEAN: + fputs(v.value.boolean ? " true\n" : " false\n", out); + break; - case AMQP_FIELD_KIND_BYTES: - fputc(' ', out); - for (i = 0; i < (int)v.value.bytes.len; i++) { - fprintf(out, "%02x", ((char *) v.value.bytes.bytes)[i]); - } + case AMQP_FIELD_KIND_I8: + fprintf(out, " %" PRId8 "\n", v.value.i8); + break; - fputc('\n', out); - break; + case AMQP_FIELD_KIND_U8: + fprintf(out, " %" PRIu8 "\n", v.value.u8); + break; - case AMQP_FIELD_KIND_ARRAY: - fputc('\n', out); - for (i = 0; i < v.value.array.num_entries; i++) { - dump_value(indent + 2, v.value.array.entries[i], out); - } + case AMQP_FIELD_KIND_I16: + fprintf(out, " %" PRId16 "\n", v.value.i16); + break; - break; + case AMQP_FIELD_KIND_U16: + fprintf(out, " %" PRIu16 "\n", v.value.u16); + break; - case AMQP_FIELD_KIND_TIMESTAMP: - fprintf(out, " %"PRIu64"\n", v.value.u64); - break; - - case AMQP_FIELD_KIND_TABLE: - fputc('\n', out); - for (i = 0; i < v.value.table.num_entries; i++) { - dump_indent(indent + 2, out); - fprintf(out, "%.*s ->\n", - (int)v.value.table.entries[i].key.len, - (char *)v.value.table.entries[i].key.bytes); - dump_value(indent + 4, v.value.table.entries[i].value, out); - } + case AMQP_FIELD_KIND_I32: + fprintf(out, " %" PRId32 "\n", v.value.i32); + break; + + case AMQP_FIELD_KIND_U32: + fprintf(out, " %" PRIu32 "\n", v.value.u32); + break; - break; + case AMQP_FIELD_KIND_I64: + fprintf(out, " %" PRId64 "\n", v.value.i64); + break; + + case AMQP_FIELD_KIND_F32: + fprintf(out, " %g\n", (double)v.value.f32); + break; + + case AMQP_FIELD_KIND_F64: + fprintf(out, " %g\n", v.value.f64); + break; - case AMQP_FIELD_KIND_VOID: - fputc('\n', out); - break; - - default: - fprintf(out, "???\n"); - break; + case AMQP_FIELD_KIND_DECIMAL: + fprintf(out, " %u:::%u\n", v.value.decimal.decimals, + v.value.decimal.value); + break; + + case AMQP_FIELD_KIND_UTF8: + fprintf(out, " %.*s\n", (int)v.value.bytes.len, + (char *)v.value.bytes.bytes); + break; + + case AMQP_FIELD_KIND_BYTES: + fputc(' ', out); + for (i = 0; i < (int)v.value.bytes.len; i++) { + fprintf(out, "%02x", ((char *)v.value.bytes.bytes)[i]); + } + + fputc('\n', out); + break; + + case AMQP_FIELD_KIND_ARRAY: + fputc('\n', out); + for (i = 0; i < v.value.array.num_entries; i++) { + dump_value(indent + 2, v.value.array.entries[i], out); + } + + break; + + case AMQP_FIELD_KIND_TIMESTAMP: + fprintf(out, " %" PRIu64 "\n", v.value.u64); + break; + + case AMQP_FIELD_KIND_TABLE: + fputc('\n', out); + for (i = 0; i < v.value.table.num_entries; i++) { + dump_indent(indent + 2, out); + fprintf(out, "%.*s ->\n", (int)v.value.table.entries[i].key.len, + (char *)v.value.table.entries[i].key.bytes); + dump_value(indent + 4, v.value.table.entries[i].value, out); + } + + break; + + case AMQP_FIELD_KIND_VOID: + fputc('\n', out); + break; + + default: + fprintf(out, "???\n"); + break; } } -static void test_dump_value(FILE *out) -{ +static void test_dump_value(FILE *out) { amqp_table_entry_t entries[8]; amqp_table_t table; amqp_field_value_t val; @@ -213,7 +207,8 @@ table.num_entries = 8; table.entries = entries; - qsort(table.entries, table.num_entries, sizeof(amqp_table_entry_t), &amqp_table_entry_cmp); + qsort(table.entries, table.num_entries, sizeof(amqp_table_entry_t), + &amqp_table_entry_cmp); val.kind = AMQP_FIELD_KIND_TABLE; val.value.table = table; @@ -222,43 +217,30 @@ } static uint8_t pre_encoded_table[] = { - 0x00, 0x00, 0x00, 0xff, 0x07, 0x6c, 0x6f, 0x6e, - 0x67, 0x73, 0x74, 0x72, 0x53, 0x00, 0x00, 0x00, - 0x15, 0x48, 0x65, 0x72, 0x65, 0x20, 0x69, 0x73, - 0x20, 0x61, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x20, - 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x09, 0x73, - 0x69, 0x67, 0x6e, 0x65, 0x64, 0x69, 0x6e, 0x74, - 0x49, 0x00, 0x00, 0x30, 0x39, 0x07, 0x64, 0x65, - 0x63, 0x69, 0x6d, 0x61, 0x6c, 0x44, 0x03, 0x00, - 0x01, 0xe2, 0x40, 0x09, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x54, 0x00, 0x00, - 0x63, 0xee, 0xa0, 0x53, 0xc1, 0x94, 0x05, 0x74, - 0x61, 0x62, 0x6c, 0x65, 0x46, 0x00, 0x00, 0x00, - 0x1f, 0x03, 0x6f, 0x6e, 0x65, 0x49, 0x00, 0x00, - 0xd4, 0x31, 0x03, 0x74, 0x77, 0x6f, 0x53, 0x00, - 0x00, 0x00, 0x0d, 0x41, 0x20, 0x6c, 0x6f, 0x6e, - 0x67, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x04, 0x62, 0x79, 0x74, 0x65, 0x62, 0xff, 0x04, - 0x6c, 0x6f, 0x6e, 0x67, 0x6c, 0x00, 0x00, 0x00, - 0x00, 0x49, 0x96, 0x02, 0xd2, 0x05, 0x73, 0x68, - 0x6f, 0x72, 0x74, 0x73, 0x02, 0x8f, 0x04, 0x62, - 0x6f, 0x6f, 0x6c, 0x74, 0x01, 0x06, 0x62, 0x69, - 0x6e, 0x61, 0x72, 0x79, 0x78, 0x00, 0x00, 0x00, - 0x0f, 0x61, 0x20, 0x62, 0x69, 0x6e, 0x61, 0x72, - 0x79, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x04, 0x76, 0x6f, 0x69, 0x64, 0x56, 0x05, 0x61, - 0x72, 0x72, 0x61, 0x79, 0x41, 0x00, 0x00, 0x00, - 0x17, 0x49, 0x00, 0x00, 0xd4, 0x31, 0x53, 0x00, - 0x00, 0x00, 0x0d, 0x41, 0x20, 0x6c, 0x6f, 0x6e, - 0x67, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x05, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x66, 0x40, - 0x49, 0x0f, 0xdb, 0x06, 0x64, 0x6f, 0x75, 0x62, - 0x6c, 0x65, 0x64, 0x40, 0x09, 0x21, 0xfb, 0x54, - 0x44, 0x2d, 0x18 -}; + 0x00, 0x00, 0x00, 0xff, 0x07, 0x6c, 0x6f, 0x6e, 0x67, 0x73, 0x74, 0x72, + 0x53, 0x00, 0x00, 0x00, 0x15, 0x48, 0x65, 0x72, 0x65, 0x20, 0x69, 0x73, + 0x20, 0x61, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x73, 0x74, 0x72, 0x69, + 0x6e, 0x67, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x69, 0x6e, 0x74, + 0x49, 0x00, 0x00, 0x30, 0x39, 0x07, 0x64, 0x65, 0x63, 0x69, 0x6d, 0x61, + 0x6c, 0x44, 0x03, 0x00, 0x01, 0xe2, 0x40, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x54, 0x00, 0x00, 0x63, 0xee, 0xa0, 0x53, + 0xc1, 0x94, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x00, 0x00, 0x00, + 0x1f, 0x03, 0x6f, 0x6e, 0x65, 0x49, 0x00, 0x00, 0xd4, 0x31, 0x03, 0x74, + 0x77, 0x6f, 0x53, 0x00, 0x00, 0x00, 0x0d, 0x41, 0x20, 0x6c, 0x6f, 0x6e, + 0x67, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x04, 0x62, 0x79, 0x74, + 0x65, 0x62, 0xff, 0x04, 0x6c, 0x6f, 0x6e, 0x67, 0x6c, 0x00, 0x00, 0x00, + 0x00, 0x49, 0x96, 0x02, 0xd2, 0x05, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x73, + 0x02, 0x8f, 0x04, 0x62, 0x6f, 0x6f, 0x6c, 0x74, 0x01, 0x06, 0x62, 0x69, + 0x6e, 0x61, 0x72, 0x79, 0x78, 0x00, 0x00, 0x00, 0x0f, 0x61, 0x20, 0x62, + 0x69, 0x6e, 0x61, 0x72, 0x79, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, + 0x04, 0x76, 0x6f, 0x69, 0x64, 0x56, 0x05, 0x61, 0x72, 0x72, 0x61, 0x79, + 0x41, 0x00, 0x00, 0x00, 0x17, 0x49, 0x00, 0x00, 0xd4, 0x31, 0x53, 0x00, + 0x00, 0x00, 0x0d, 0x41, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x73, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x05, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x66, 0x40, + 0x49, 0x0f, 0xdb, 0x06, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x64, 0x40, + 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18}; -static void test_table_codec(FILE *out) -{ +static void test_table_codec(FILE *out) { amqp_pool_t pool; int result; @@ -314,7 +296,7 @@ entries[5].key = amqp_cstring_bytes("byte"); entries[5].value.kind = AMQP_FIELD_KIND_I8; - entries[5].value.value.i8 = (int8_t)255; + entries[5].value.value.i8 = (int8_t)-1; entries[6].key = amqp_cstring_bytes("long"); entries[6].value.kind = AMQP_FIELD_KIND_I64; @@ -368,8 +350,8 @@ decoding_bytes.len = sizeof(pre_encoded_table); decoding_bytes.bytes = pre_encoded_table; - result = amqp_decode_table(decoding_bytes, &pool, &decoded, - &decoding_offset); + result = + amqp_decode_table(decoding_bytes, &pool, &decoded, &decoding_offset); if (result < 0) { die("Table decoding failed: %s", amqp_error_string2(result)); } @@ -414,8 +396,7 @@ #define CHUNK_SIZE 4096 -static int compare_files(FILE *f1_in, FILE *f2_in) -{ +static int compare_files(FILE *f1_in, FILE *f2_in) { char f1_buf[CHUNK_SIZE]; char f2_buf[CHUNK_SIZE]; int res; @@ -445,8 +426,7 @@ const char *expected_file_name = "tests/test_tables.expected"; -int main(void) -{ +int main(void) { char *srcdir = getenv("srcdir"); FILE *out, *expected = NULL; char *expected_path; @@ -465,6 +445,9 @@ } expected_path = malloc(strlen(srcdir) + strlen(expected_file_name) + 2); + if (!expected_path) { + die("out of memory"); + } sprintf(expected_path, "%s/%s", srcdir, expected_file_name); expected = fopen(expected_path, "r"); if (!expected) { diff -Nru librabbitmq-0.7.1/tests/win32/msinttypes/inttypes.h librabbitmq-0.9.0-0.1/tests/win32/msinttypes/inttypes.h --- librabbitmq-0.7.1/tests/win32/msinttypes/inttypes.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tests/win32/msinttypes/inttypes.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,39 +1,39 @@ // ISO C9x compliant inttypes.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// // Copyright (c) 2006 Alexander Chemeris -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// +// // 3. The name of the author may be used to endorse or promote products // derived from this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// /////////////////////////////////////////////////////////////////////////////// -#ifndef _MSC_VER // [ +#ifndef _MSC_VER // [ #error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] +#endif // _MSC_VER ] -#ifndef _MSC_INTTYPES_H_ // [ +#ifndef _MSC_INTTYPES_H_ // [ #define _MSC_INTTYPES_H_ #if _MSC_VER > 1000 @@ -45,223 +45,224 @@ // 7.8 Format conversion of integer types typedef struct { - intmax_t quot; - intmax_t rem; + intmax_t quot; + intmax_t rem; } imaxdiv_t; // 7.8.1 Macros for format specifiers -#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 +#if !defined(__cplusplus) || \ + defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 // The fprintf macros for signed integers are: -#define PRId8 "d" -#define PRIi8 "i" -#define PRIdLEAST8 "d" -#define PRIiLEAST8 "i" -#define PRIdFAST8 "d" -#define PRIiFAST8 "i" - -#define PRId16 "hd" -#define PRIi16 "hi" -#define PRIdLEAST16 "hd" -#define PRIiLEAST16 "hi" -#define PRIdFAST16 "hd" -#define PRIiFAST16 "hi" - -#define PRId32 "I32d" -#define PRIi32 "I32i" -#define PRIdLEAST32 "I32d" -#define PRIiLEAST32 "I32i" -#define PRIdFAST32 "I32d" -#define PRIiFAST32 "I32i" - -#define PRId64 "I64d" -#define PRIi64 "I64i" -#define PRIdLEAST64 "I64d" -#define PRIiLEAST64 "I64i" -#define PRIdFAST64 "I64d" -#define PRIiFAST64 "I64i" +#define PRId8 "d" +#define PRIi8 "i" +#define PRIdLEAST8 "d" +#define PRIiLEAST8 "i" +#define PRIdFAST8 "d" +#define PRIiFAST8 "i" + +#define PRId16 "hd" +#define PRIi16 "hi" +#define PRIdLEAST16 "hd" +#define PRIiLEAST16 "hi" +#define PRIdFAST16 "hd" +#define PRIiFAST16 "hi" + +#define PRId32 "I32d" +#define PRIi32 "I32i" +#define PRIdLEAST32 "I32d" +#define PRIiLEAST32 "I32i" +#define PRIdFAST32 "I32d" +#define PRIiFAST32 "I32i" + +#define PRId64 "I64d" +#define PRIi64 "I64i" +#define PRIdLEAST64 "I64d" +#define PRIiLEAST64 "I64i" +#define PRIdFAST64 "I64d" +#define PRIiFAST64 "I64i" -#define PRIdMAX "I64d" -#define PRIiMAX "I64i" +#define PRIdMAX "I64d" +#define PRIiMAX "I64i" -#define PRIdPTR "Id" -#define PRIiPTR "Ii" +#define PRIdPTR "Id" +#define PRIiPTR "Ii" // The fprintf macros for unsigned integers are: -#define PRIo8 "o" -#define PRIu8 "u" -#define PRIx8 "x" -#define PRIX8 "X" -#define PRIoLEAST8 "o" -#define PRIuLEAST8 "u" -#define PRIxLEAST8 "x" -#define PRIXLEAST8 "X" -#define PRIoFAST8 "o" -#define PRIuFAST8 "u" -#define PRIxFAST8 "x" -#define PRIXFAST8 "X" - -#define PRIo16 "ho" -#define PRIu16 "hu" -#define PRIx16 "hx" -#define PRIX16 "hX" -#define PRIoLEAST16 "ho" -#define PRIuLEAST16 "hu" -#define PRIxLEAST16 "hx" -#define PRIXLEAST16 "hX" -#define PRIoFAST16 "ho" -#define PRIuFAST16 "hu" -#define PRIxFAST16 "hx" -#define PRIXFAST16 "hX" - -#define PRIo32 "I32o" -#define PRIu32 "I32u" -#define PRIx32 "I32x" -#define PRIX32 "I32X" -#define PRIoLEAST32 "I32o" -#define PRIuLEAST32 "I32u" -#define PRIxLEAST32 "I32x" -#define PRIXLEAST32 "I32X" -#define PRIoFAST32 "I32o" -#define PRIuFAST32 "I32u" -#define PRIxFAST32 "I32x" -#define PRIXFAST32 "I32X" - -#define PRIo64 "I64o" -#define PRIu64 "I64u" -#define PRIx64 "I64x" -#define PRIX64 "I64X" -#define PRIoLEAST64 "I64o" -#define PRIuLEAST64 "I64u" -#define PRIxLEAST64 "I64x" -#define PRIXLEAST64 "I64X" -#define PRIoFAST64 "I64o" -#define PRIuFAST64 "I64u" -#define PRIxFAST64 "I64x" -#define PRIXFAST64 "I64X" - -#define PRIoMAX "I64o" -#define PRIuMAX "I64u" -#define PRIxMAX "I64x" -#define PRIXMAX "I64X" - -#define PRIoPTR "Io" -#define PRIuPTR "Iu" -#define PRIxPTR "Ix" -#define PRIXPTR "IX" +#define PRIo8 "o" +#define PRIu8 "u" +#define PRIx8 "x" +#define PRIX8 "X" +#define PRIoLEAST8 "o" +#define PRIuLEAST8 "u" +#define PRIxLEAST8 "x" +#define PRIXLEAST8 "X" +#define PRIoFAST8 "o" +#define PRIuFAST8 "u" +#define PRIxFAST8 "x" +#define PRIXFAST8 "X" + +#define PRIo16 "ho" +#define PRIu16 "hu" +#define PRIx16 "hx" +#define PRIX16 "hX" +#define PRIoLEAST16 "ho" +#define PRIuLEAST16 "hu" +#define PRIxLEAST16 "hx" +#define PRIXLEAST16 "hX" +#define PRIoFAST16 "ho" +#define PRIuFAST16 "hu" +#define PRIxFAST16 "hx" +#define PRIXFAST16 "hX" + +#define PRIo32 "I32o" +#define PRIu32 "I32u" +#define PRIx32 "I32x" +#define PRIX32 "I32X" +#define PRIoLEAST32 "I32o" +#define PRIuLEAST32 "I32u" +#define PRIxLEAST32 "I32x" +#define PRIXLEAST32 "I32X" +#define PRIoFAST32 "I32o" +#define PRIuFAST32 "I32u" +#define PRIxFAST32 "I32x" +#define PRIXFAST32 "I32X" + +#define PRIo64 "I64o" +#define PRIu64 "I64u" +#define PRIx64 "I64x" +#define PRIX64 "I64X" +#define PRIoLEAST64 "I64o" +#define PRIuLEAST64 "I64u" +#define PRIxLEAST64 "I64x" +#define PRIXLEAST64 "I64X" +#define PRIoFAST64 "I64o" +#define PRIuFAST64 "I64u" +#define PRIxFAST64 "I64x" +#define PRIXFAST64 "I64X" + +#define PRIoMAX "I64o" +#define PRIuMAX "I64u" +#define PRIxMAX "I64x" +#define PRIXMAX "I64X" + +#define PRIoPTR "Io" +#define PRIuPTR "Iu" +#define PRIxPTR "Ix" +#define PRIXPTR "IX" // The fscanf macros for signed integers are: -#define SCNd8 "d" -#define SCNi8 "i" -#define SCNdLEAST8 "d" -#define SCNiLEAST8 "i" -#define SCNdFAST8 "d" -#define SCNiFAST8 "i" - -#define SCNd16 "hd" -#define SCNi16 "hi" -#define SCNdLEAST16 "hd" -#define SCNiLEAST16 "hi" -#define SCNdFAST16 "hd" -#define SCNiFAST16 "hi" - -#define SCNd32 "ld" -#define SCNi32 "li" -#define SCNdLEAST32 "ld" -#define SCNiLEAST32 "li" -#define SCNdFAST32 "ld" -#define SCNiFAST32 "li" - -#define SCNd64 "I64d" -#define SCNi64 "I64i" -#define SCNdLEAST64 "I64d" -#define SCNiLEAST64 "I64i" -#define SCNdFAST64 "I64d" -#define SCNiFAST64 "I64i" - -#define SCNdMAX "I64d" -#define SCNiMAX "I64i" - -#ifdef _WIN64 // [ -# define SCNdPTR "I64d" -# define SCNiPTR "I64i" +#define SCNd8 "d" +#define SCNi8 "i" +#define SCNdLEAST8 "d" +#define SCNiLEAST8 "i" +#define SCNdFAST8 "d" +#define SCNiFAST8 "i" + +#define SCNd16 "hd" +#define SCNi16 "hi" +#define SCNdLEAST16 "hd" +#define SCNiLEAST16 "hi" +#define SCNdFAST16 "hd" +#define SCNiFAST16 "hi" + +#define SCNd32 "ld" +#define SCNi32 "li" +#define SCNdLEAST32 "ld" +#define SCNiLEAST32 "li" +#define SCNdFAST32 "ld" +#define SCNiFAST32 "li" + +#define SCNd64 "I64d" +#define SCNi64 "I64i" +#define SCNdLEAST64 "I64d" +#define SCNiLEAST64 "I64i" +#define SCNdFAST64 "I64d" +#define SCNiFAST64 "I64i" + +#define SCNdMAX "I64d" +#define SCNiMAX "I64i" + +#ifdef _WIN64 // [ +#define SCNdPTR "I64d" +#define SCNiPTR "I64i" #else // _WIN64 ][ -# define SCNdPTR "ld" -# define SCNiPTR "li" +#define SCNdPTR "ld" +#define SCNiPTR "li" #endif // _WIN64 ] // The fscanf macros for unsigned integers are: -#define SCNo8 "o" -#define SCNu8 "u" -#define SCNx8 "x" -#define SCNX8 "X" -#define SCNoLEAST8 "o" -#define SCNuLEAST8 "u" -#define SCNxLEAST8 "x" -#define SCNXLEAST8 "X" -#define SCNoFAST8 "o" -#define SCNuFAST8 "u" -#define SCNxFAST8 "x" -#define SCNXFAST8 "X" - -#define SCNo16 "ho" -#define SCNu16 "hu" -#define SCNx16 "hx" -#define SCNX16 "hX" -#define SCNoLEAST16 "ho" -#define SCNuLEAST16 "hu" -#define SCNxLEAST16 "hx" -#define SCNXLEAST16 "hX" -#define SCNoFAST16 "ho" -#define SCNuFAST16 "hu" -#define SCNxFAST16 "hx" -#define SCNXFAST16 "hX" - -#define SCNo32 "lo" -#define SCNu32 "lu" -#define SCNx32 "lx" -#define SCNX32 "lX" -#define SCNoLEAST32 "lo" -#define SCNuLEAST32 "lu" -#define SCNxLEAST32 "lx" -#define SCNXLEAST32 "lX" -#define SCNoFAST32 "lo" -#define SCNuFAST32 "lu" -#define SCNxFAST32 "lx" -#define SCNXFAST32 "lX" - -#define SCNo64 "I64o" -#define SCNu64 "I64u" -#define SCNx64 "I64x" -#define SCNX64 "I64X" -#define SCNoLEAST64 "I64o" -#define SCNuLEAST64 "I64u" -#define SCNxLEAST64 "I64x" -#define SCNXLEAST64 "I64X" -#define SCNoFAST64 "I64o" -#define SCNuFAST64 "I64u" -#define SCNxFAST64 "I64x" -#define SCNXFAST64 "I64X" - -#define SCNoMAX "I64o" -#define SCNuMAX "I64u" -#define SCNxMAX "I64x" -#define SCNXMAX "I64X" - -#ifdef _WIN64 // [ -# define SCNoPTR "I64o" -# define SCNuPTR "I64u" -# define SCNxPTR "I64x" -# define SCNXPTR "I64X" +#define SCNo8 "o" +#define SCNu8 "u" +#define SCNx8 "x" +#define SCNX8 "X" +#define SCNoLEAST8 "o" +#define SCNuLEAST8 "u" +#define SCNxLEAST8 "x" +#define SCNXLEAST8 "X" +#define SCNoFAST8 "o" +#define SCNuFAST8 "u" +#define SCNxFAST8 "x" +#define SCNXFAST8 "X" + +#define SCNo16 "ho" +#define SCNu16 "hu" +#define SCNx16 "hx" +#define SCNX16 "hX" +#define SCNoLEAST16 "ho" +#define SCNuLEAST16 "hu" +#define SCNxLEAST16 "hx" +#define SCNXLEAST16 "hX" +#define SCNoFAST16 "ho" +#define SCNuFAST16 "hu" +#define SCNxFAST16 "hx" +#define SCNXFAST16 "hX" + +#define SCNo32 "lo" +#define SCNu32 "lu" +#define SCNx32 "lx" +#define SCNX32 "lX" +#define SCNoLEAST32 "lo" +#define SCNuLEAST32 "lu" +#define SCNxLEAST32 "lx" +#define SCNXLEAST32 "lX" +#define SCNoFAST32 "lo" +#define SCNuFAST32 "lu" +#define SCNxFAST32 "lx" +#define SCNXFAST32 "lX" + +#define SCNo64 "I64o" +#define SCNu64 "I64u" +#define SCNx64 "I64x" +#define SCNX64 "I64X" +#define SCNoLEAST64 "I64o" +#define SCNuLEAST64 "I64u" +#define SCNxLEAST64 "I64x" +#define SCNXLEAST64 "I64X" +#define SCNoFAST64 "I64o" +#define SCNuFAST64 "I64u" +#define SCNxFAST64 "I64x" +#define SCNXFAST64 "I64X" + +#define SCNoMAX "I64o" +#define SCNuMAX "I64u" +#define SCNxMAX "I64x" +#define SCNXMAX "I64X" + +#ifdef _WIN64 // [ +#define SCNoPTR "I64o" +#define SCNuPTR "I64u" +#define SCNxPTR "I64x" +#define SCNXPTR "I64X" #else // _WIN64 ][ -# define SCNoPTR "lo" -# define SCNuPTR "lu" -# define SCNxPTR "lx" -# define SCNXPTR "lX" +#define SCNoPTR "lo" +#define SCNuPTR "lu" +#define SCNxPTR "lx" +#define SCNXPTR "lX" #endif // _WIN64 ] -#endif // __STDC_FORMAT_MACROS ] +#endif // __STDC_FORMAT_MACROS ] // 7.8.2 Functions for greatest-width integer types @@ -272,25 +273,24 @@ // This is modified version of div() function from Microsoft's div.c found // in %MSVC.NET%\crt\src\div.c -#ifdef STATIC_IMAXDIV // [ +#ifdef STATIC_IMAXDIV // [ static -#else // STATIC_IMAXDIV ][ +#else // STATIC_IMAXDIV ][ _inline -#endif // STATIC_IMAXDIV ] -imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) -{ - imaxdiv_t result; - - result.quot = numer / denom; - result.rem = numer % denom; - - if (numer < 0 && result.rem > 0) { - // did division wrong; must fix up - ++result.quot; - result.rem -= denom; - } +#endif // STATIC_IMAXDIV ] + imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) { + imaxdiv_t result; + + result.quot = numer / denom; + result.rem = numer % denom; + + if (numer < 0 && result.rem > 0) { + // did division wrong; must fix up + ++result.quot; + result.rem -= denom; + } - return result; + return result; } // 7.8.2.3 The strtoimax and strtoumax functions @@ -301,5 +301,4 @@ #define wcstoimax _wcstoi64 #define wcstoumax _wcstoui64 - -#endif // _MSC_INTTYPES_H_ ] +#endif // _MSC_INTTYPES_H_ ] diff -Nru librabbitmq-0.7.1/tools/CMakeLists.txt librabbitmq-0.9.0-0.1/tools/CMakeLists.txt --- librabbitmq-0.7.1/tools/CMakeLists.txt 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/CMakeLists.txt 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -# vim:set ts=2 sw=2 sts=2 et: include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${LIBRABBITMQ_INCLUDE_DIRS} ${POPT_INCLUDE_DIR}) if (WIN32) @@ -73,6 +72,10 @@ endif() if (ENABLE_SSL_SUPPORT) + add_definitions(-DWITH_SSL=1) +endif() + +if (ENABLE_SSL_SUPPORT) add_definitions(-DWITH_SSL=1) endif() diff -Nru librabbitmq-0.7.1/tools/common.c librabbitmq-0.9.0-0.1/tools/common.c --- librabbitmq-0.7.1/tools/common.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/common.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -55,8 +54,7 @@ #include "compat.h" #endif -void die(const char *fmt, ...) -{ +void die(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); @@ -65,8 +63,7 @@ exit(1); } -void die_errno(int err, const char *fmt, ...) -{ +void die_errno(int err, const char *fmt, ...) { va_list ap; if (err == 0) { @@ -80,8 +77,7 @@ exit(1); } -void die_amqp_error(int err, const char *fmt, ...) -{ +void die_amqp_error(int err, const char *fmt, ...) { va_list ap; if (err >= 0) { @@ -95,63 +91,56 @@ exit(1); } -const char *amqp_server_exception_string(amqp_rpc_reply_t r) -{ +const char *amqp_server_exception_string(amqp_rpc_reply_t r) { int res; static char s[512]; switch (r.reply.id) { - case AMQP_CONNECTION_CLOSE_METHOD: { - amqp_connection_close_t *m - = (amqp_connection_close_t *)r.reply.decoded; - res = snprintf(s, sizeof(s), "server connection error %d, message: %.*s", - m->reply_code, - (int)m->reply_text.len, - (char *)m->reply_text.bytes); - break; - } - - case AMQP_CHANNEL_CLOSE_METHOD: { - amqp_channel_close_t *m - = (amqp_channel_close_t *)r.reply.decoded; - res = snprintf(s, sizeof(s), "server channel error %d, message: %.*s", - m->reply_code, - (int)m->reply_text.len, - (char *)m->reply_text.bytes); - break; - } - - default: - res = snprintf(s, sizeof(s), "unknown server error, method id 0x%08X", - r.reply.id); - break; + case AMQP_CONNECTION_CLOSE_METHOD: { + amqp_connection_close_t *m = (amqp_connection_close_t *)r.reply.decoded; + res = snprintf(s, sizeof(s), "server connection error %d, message: %.*s", + m->reply_code, (int)m->reply_text.len, + (char *)m->reply_text.bytes); + break; + } + + case AMQP_CHANNEL_CLOSE_METHOD: { + amqp_channel_close_t *m = (amqp_channel_close_t *)r.reply.decoded; + res = snprintf(s, sizeof(s), "server channel error %d, message: %.*s", + m->reply_code, (int)m->reply_text.len, + (char *)m->reply_text.bytes); + break; + } + + default: + res = snprintf(s, sizeof(s), "unknown server error, method id 0x%08X", + r.reply.id); + break; } return res >= 0 ? s : NULL; } -const char *amqp_rpc_reply_string(amqp_rpc_reply_t r) -{ +const char *amqp_rpc_reply_string(amqp_rpc_reply_t r) { switch (r.reply_type) { - case AMQP_RESPONSE_NORMAL: - return "normal response"; + case AMQP_RESPONSE_NORMAL: + return "normal response"; - case AMQP_RESPONSE_NONE: - return "missing RPC reply type"; + case AMQP_RESPONSE_NONE: + return "missing RPC reply type"; - case AMQP_RESPONSE_LIBRARY_EXCEPTION: - return amqp_error_string2(r.library_error); + case AMQP_RESPONSE_LIBRARY_EXCEPTION: + return amqp_error_string2(r.library_error); - case AMQP_RESPONSE_SERVER_EXCEPTION: - return amqp_server_exception_string(r); + case AMQP_RESPONSE_SERVER_EXCEPTION: + return amqp_server_exception_string(r); - default: - abort(); + default: + abort(); } } -void die_rpc(amqp_rpc_reply_t r, const char *fmt, ...) -{ +void die_rpc(amqp_rpc_reply_t r, const char *fmt, ...) { va_list ap; if (r.reply_type == AMQP_RESPONSE_NORMAL) { @@ -181,57 +170,31 @@ const char *connect_options_title = "Connection options"; struct poptOption connect_options[] = { - { - "url", 'u', POPT_ARG_STRING, &amqp_url, 0, - "the AMQP URL to connect to", "amqp://..." - }, - { - "server", 's', POPT_ARG_STRING, &amqp_server, 0, - "the AMQP server to connect to", "hostname" - }, - { - "port", 0, POPT_ARG_INT, &amqp_port, 0, - "the port to connect on", "port" - }, - { - "vhost", 0, POPT_ARG_STRING, &amqp_vhost, 0, - "the vhost to use when connecting", "vhost" - }, - { - "username", 0, POPT_ARG_STRING, &amqp_username, 0, - "the username to login with", "username" - }, - { - "password", 0, POPT_ARG_STRING, &amqp_password, 0, - "the password to login with", "password" - }, - { - "heartbeat", 0, POPT_ARG_INT, &amqp_heartbeat, 0, - "heartbeat interval, set to 0 to disable", "heartbeat" - }, + {"url", 'u', POPT_ARG_STRING, &amqp_url, 0, "the AMQP URL to connect to", + "amqp://..."}, + {"server", 's', POPT_ARG_STRING, &amqp_server, 0, + "the AMQP server to connect to", "hostname"}, + {"port", 0, POPT_ARG_INT, &amqp_port, 0, "the port to connect on", "port"}, + {"vhost", 0, POPT_ARG_STRING, &amqp_vhost, 0, + "the vhost to use when connecting", "vhost"}, + {"username", 0, POPT_ARG_STRING, &amqp_username, 0, + "the username to login with", "username"}, + {"password", 0, POPT_ARG_STRING, &amqp_password, 0, + "the password to login with", "password"}, + {"heartbeat", 0, POPT_ARG_INT, &amqp_heartbeat, 0, + "heartbeat interval, set to 0 to disable", "heartbeat"}, #ifdef WITH_SSL - { - "ssl", 0, POPT_ARG_NONE, &amqp_ssl, 0, - "connect over SSL/TLS", NULL - }, - { - "cacert", 0, POPT_ARG_STRING, &amqp_cacert, 0, - "path to the CA certificate file", "cacert.pem" - }, - { - "key", 0, POPT_ARG_STRING, &amqp_key, 0, - "path to the client private key file", "key.pem" - }, - { - "cert", 0, POPT_ARG_STRING, &amqp_cert, 0, - "path to the client certificate file", "cert.pem" - }, + {"ssl", 0, POPT_ARG_NONE, &amqp_ssl, 0, "connect over SSL/TLS", NULL}, + {"cacert", 0, POPT_ARG_STRING, &amqp_cacert, 0, + "path to the CA certificate file", "cacert.pem"}, + {"key", 0, POPT_ARG_STRING, &amqp_key, 0, + "path to the client private key file", "key.pem"}, + {"cert", 0, POPT_ARG_STRING, &amqp_cert, 0, + "path to the client certificate file", "cert.pem"}, #endif /* WITH_SSL */ - { NULL, '\0', 0, NULL, 0, NULL, NULL } -}; + {NULL, '\0', 0, NULL, 0, NULL, NULL}}; -static void init_connection_info(struct amqp_connection_info *ci) -{ +static void init_connection_info(struct amqp_connection_info *ci) { ci->user = NULL; ci->password = NULL; ci->host = NULL; @@ -242,14 +205,14 @@ amqp_default_connection_info(ci); if (amqp_url) - die_amqp_error(amqp_parse_url(strdup(amqp_url), ci), - "Parsing URL '%s'", amqp_url); + die_amqp_error(amqp_parse_url(strdup(amqp_url), ci), "Parsing URL '%s'", + amqp_url); if (amqp_server) { char *colon; - if (ci->host) - die("both --server and --url options specify" - " server host"); + if (amqp_url) { + die("--server and --url options cannot be used at the same time"); + } /* parse the server string into a hostname and a port */ colon = strchr(amqp_server, ':'); @@ -260,67 +223,61 @@ /* Deprecate specifying the port number with the --server option, because it is not ipv6 friendly. --url now allows connection options to be - specificied concisely. */ - fprintf(stderr, "Specifying the port number with" - " --server is deprecated\n"); + specified concisely. */ + fprintf(stderr, + "Specifying the port number with --server is deprecated\n"); host_len = colon - amqp_server; ci->host = malloc(host_len + 1); memcpy(ci->host, amqp_server, host_len); ci->host[host_len] = 0; - if (ci->port >= 0) - die("both --server and --url options specify" - " server port"); - if (amqp_port >= 0) - die("both --server and --port options specify" - " server port"); - - ci->port = strtol(colon+1, &port_end, 10); - if (ci->port < 0 - || ci->port > 65535 - || port_end == colon+1 - || *port_end != 0) - die("bad server port number in '%s'", - amqp_server); + if (amqp_port >= 0) { + die("both --server and --port options specify server port"); + } + + ci->port = strtol(colon + 1, &port_end, 10); + if (ci->port < 0 || ci->port > 65535 || port_end == colon + 1 || + *port_end != 0) + die("bad server port number in '%s'", amqp_server); } #if WITH_SSL if (amqp_ssl && !ci->ssl) { die("the --ssl option specifies an SSL connection" - " but the --server option does not"); + " but the --url option does not"); } #endif } if (amqp_port >= 0) { - if (ci->port >= 0) - die("both --port and --url options specify" - " server port"); + if (amqp_url) { + die("--port and --url options cannot be used at the same time"); + } ci->port = amqp_port; } if (amqp_username) { - if (ci->user) - die("both --username and --url options specify" - " AMQP username"); + if (amqp_url) { + die("--username and --url options cannot be used at the same time"); + } ci->user = amqp_username; } if (amqp_password) { - if (ci->password) - die("both --password and --url options specify" - " AMQP password"); + if (amqp_url) { + die("--password and --url options cannot be used at the same time"); + } ci->password = amqp_password; } if (amqp_vhost) { - if (ci->vhost) - die("both --vhost and --url options specify" - " AMQP vhost"); + if (amqp_url) { + die("--vhost and --url options cannot be used at the same time"); + } ci->vhost = amqp_vhost; } @@ -330,8 +287,7 @@ } } -amqp_connection_state_t make_connection(void) -{ +amqp_connection_state_t make_connection(void) { int status; amqp_socket_t *socket = NULL; struct amqp_connection_info ci; @@ -365,8 +321,7 @@ die("opening socket to %s:%d", ci.host, ci.port); } die_rpc(amqp_login(conn, ci.vhost, 0, 131072, amqp_heartbeat, - AMQP_SASL_METHOD_PLAIN, - ci.user, ci.password), + AMQP_SASL_METHOD_PLAIN, ci.user, ci.password), "logging in to AMQP server"); if (!amqp_channel_open(conn, 1)) { die_rpc(amqp_get_rpc_reply(conn), "opening channel"); @@ -374,11 +329,9 @@ return conn; } -void close_connection(amqp_connection_state_t conn) -{ +void close_connection(amqp_connection_state_t conn) { int res; - die_rpc(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), - "closing channel"); + die_rpc(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "closing channel"); die_rpc(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "closing connection"); @@ -386,8 +339,7 @@ die_amqp_error(res, "closing connection"); } -amqp_bytes_t read_all(int fd) -{ +amqp_bytes_t read_all(int fd) { size_t space = 4096; amqp_bytes_t bytes; @@ -395,8 +347,7 @@ bytes.len = 0; for (;;) { - ssize_t res = read(fd, (char *)bytes.bytes + bytes.len, - space-bytes.len); + ssize_t res = read(fd, (char *)bytes.bytes + bytes.len, space - bytes.len); if (res == 0) { break; } @@ -419,8 +370,7 @@ return bytes; } -void write_all(int fd, amqp_bytes_t data) -{ +void write_all(int fd, amqp_bytes_t data) { while (data.len > 0) { ssize_t res = write(fd, data.bytes, data.len); if (res < 0) { @@ -432,16 +382,14 @@ } } -void copy_body(amqp_connection_state_t conn, int fd) -{ +void copy_body(amqp_connection_state_t conn, int fd) { size_t body_remaining; amqp_frame_t frame; int res = amqp_simple_wait_frame(conn, &frame); die_amqp_error(res, "waiting for header frame"); if (frame.frame_type != AMQP_FRAME_HEADER) { - die("expected header, got frame type 0x%X", - frame.frame_type); + die("expected header, got frame type 0x%X", frame.frame_type); } body_remaining = frame.payload.properties.body_size; @@ -449,8 +397,7 @@ res = amqp_simple_wait_frame(conn, &frame); die_amqp_error(res, "waiting for body frame"); if (frame.frame_type != AMQP_FRAME_BODY) { - die("expected body, got frame type 0x%X", - frame.frame_type); + die("expected body, got frame type 0x%X", frame.frame_type); } write_all(fd, frame.payload.body_fragment); @@ -459,9 +406,7 @@ } poptContext process_options(int argc, const char **argv, - struct poptOption *options, - const char *help) -{ + struct poptOption *options, const char *help) { int c; poptContext opts = poptGetContext(NULL, argc, argv, options, 0); poptSetOtherOptionHelp(opts, help); @@ -471,8 +416,7 @@ } if (c < -1) { - fprintf(stderr, "%s: %s\n", - poptBadOption(opts, POPT_BADOPTION_NOALIAS), + fprintf(stderr, "%s: %s\n", poptBadOption(opts, POPT_BADOPTION_NOALIAS), poptStrerror(c)); poptPrintUsage(opts, stderr, 0); exit(1); @@ -482,10 +426,8 @@ } void process_all_options(int argc, const char **argv, - struct poptOption *options) -{ - poptContext opts = process_options(argc, argv, options, - "[OPTIONS]..."); + struct poptOption *options) { + poptContext opts = process_options(argc, argv, options, "[OPTIONS]..."); const char *opt = poptPeekArg(opts); if (opt) { @@ -497,7 +439,6 @@ poptFreeContext(opts); } -amqp_bytes_t cstring_bytes(const char *str) -{ +amqp_bytes_t cstring_bytes(const char *str) { return str ? amqp_cstring_bytes(str) : amqp_empty_bytes; } diff -Nru librabbitmq-0.7.1/tools/common.h librabbitmq-0.9.0-0.1/tools/common.h --- librabbitmq-0.7.1/tools/common.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/common.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -44,14 +43,13 @@ extern const char *amqp_server_exception_string(amqp_rpc_reply_t r); extern const char *amqp_rpc_reply_string(amqp_rpc_reply_t r); -extern void die(const char *fmt, ...) -__attribute__ ((format (printf, 1, 2))); +extern void die(const char *fmt, ...) __attribute__((format(printf, 1, 2))); extern void die_errno(int err, const char *fmt, ...) -__attribute__ ((format (printf, 2, 3))); + __attribute__((format(printf, 2, 3))); extern void die_amqp_error(int err, const char *fmt, ...) -__attribute__ ((format (printf, 2, 3))); + __attribute__((format(printf, 2, 3))); extern void die_rpc(amqp_rpc_reply_t r, const char *fmt, ...) -__attribute__ ((format (printf, 2, 3))); + __attribute__((format(printf, 2, 3))); extern const char *connect_options_title; extern struct poptOption connect_options[]; @@ -64,7 +62,7 @@ extern void copy_body(amqp_connection_state_t conn, int fd); #define INCLUDE_OPTIONS(options) \ - {NULL, 0, POPT_ARG_INCLUDE_TABLE, options, 0, options ## _title, NULL} + { NULL, 0, POPT_ARG_INCLUDE_TABLE, options, 0, options##_title, NULL } extern poptContext process_options(int argc, const char **argv, struct poptOption *options, diff -Nru librabbitmq-0.7.1/tools/consume.c librabbitmq-0.9.0-0.1/tools/consume.c --- librabbitmq-0.7.1/tools/consume.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/consume.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -50,8 +49,7 @@ /* Convert a amqp_bytes_t to an escaped string form for printing. We use the same escaping conventions as rabbitmqctl. */ -static char *stringify_bytes(amqp_bytes_t bytes) -{ +static char *stringify_bytes(amqp_bytes_t bytes) { /* We will need up to 4 chars per byte, plus the terminating 0 */ char *res = malloc(bytes.len * 4 + 1); uint8_t *data = bytes.bytes; @@ -73,11 +71,9 @@ return res; } -static amqp_bytes_t setup_queue(amqp_connection_state_t conn, - char *queue, char *exchange, - char *routing_key, int declare, - int exclusive) -{ +static amqp_bytes_t setup_queue(amqp_connection_state_t conn, char *queue, + char *exchange, char *routing_key, int declare, + int exclusive) { amqp_bytes_t queue_bytes = cstring_bytes(queue); char *routing_key_rest; @@ -85,19 +81,19 @@ char *routing_tmp; int routing_key_count = 0; - /* if an exchange name wasn't provided, check that we don't - have options that require it. */ + /* if an exchange name wasn't provided, check that we don't have options that + * require it. */ if (!exchange && routing_key) { - fprintf(stderr, "--routing-key option requires an exchange" - " name to be provided with --exchange\n"); + fprintf(stderr, + "--routing-key option requires an exchange name to be provided " + "with --exchange\n"); exit(1); } if (!queue || exchange || declare || exclusive) { /* Declare the queue as auto-delete. */ - amqp_queue_declare_ok_t *res = amqp_queue_declare(conn, 1, - queue_bytes, 0, 0, exclusive, 1, - amqp_empty_table); + amqp_queue_declare_ok_t *res = amqp_queue_declare( + conn, 1, queue_bytes, 0, 0, exclusive, 1, amqp_empty_table); if (!res) { die_rpc(amqp_get_rpc_reply(conn), "queue.declare"); } @@ -107,8 +103,7 @@ char *sq; queue_bytes = amqp_bytes_malloc_dup(res->queue); sq = stringify_bytes(queue_bytes); - fprintf(stderr, "Server provided queue name: %s\n", - sq); + fprintf(stderr, "Server provided queue name: %s\n", sq); free(sq); } @@ -116,17 +111,17 @@ if (exchange) { amqp_bytes_t eb = amqp_cstring_bytes(exchange); - routing_tmp = strdup( routing_key ); - if ( NULL == routing_tmp ) { - fprintf(stderr, "could not allocate memory to parse routing key\n" ); + routing_tmp = strdup(routing_key); + if (NULL == routing_tmp) { + fprintf(stderr, "could not allocate memory to parse routing key\n"); exit(1); } - for ( - routing_key_token = strtok_r( routing_tmp, LISTEN_KEYS_DELIMITER, &routing_key_rest ) - ; NULL != routing_key_token && routing_key_count < MAX_LISTEN_KEYS - 1 - ; routing_key_token = strtok_r( NULL, LISTEN_KEYS_DELIMITER, &routing_key_rest ) - ) { + for (routing_key_token = + strtok_r(routing_tmp, LISTEN_KEYS_DELIMITER, &routing_key_rest); + NULL != routing_key_token && routing_key_count < MAX_LISTEN_KEYS - 1; + routing_key_token = + strtok_r(NULL, LISTEN_KEYS_DELIMITER, &routing_key_rest)) { if (!amqp_queue_bind(conn, 1, queue_bytes, eb, cstring_bytes(routing_key_token), @@ -134,7 +129,7 @@ die_rpc(amqp_get_rpc_reply(conn), "queue.bind"); } } - free( routing_tmp ); + free(routing_tmp); } } @@ -145,13 +140,12 @@ static void do_consume(amqp_connection_state_t conn, amqp_bytes_t queue, int no_ack, int count, int prefetch_count, - const char *const *argv) -{ + const char *const *argv) { int i; /* If there is a limit, set the qos to match */ - if (count > 0 && count <= AMQP_CONSUME_MAX_PREFETCH_COUNT - && !amqp_basic_qos(conn, 1, 0, count, 0)) { + if (count > 0 && count <= AMQP_CONSUME_MAX_PREFETCH_COUNT && + !amqp_basic_qos(conn, 1, 0, count, 0)) { die_rpc(amqp_get_rpc_reply(conn), "basic.qos"); } @@ -160,15 +154,16 @@ if (prefetch_count > 0 && prefetch_count <= AMQP_CONSUME_MAX_PREFETCH_COUNT) { /* the maximum number of messages to be received at a time must be less * than the global maximum number of messages. */ - if (!(count > 0 && count <= AMQP_CONSUME_MAX_PREFETCH_COUNT && prefetch_count >= count)) { + if (!(count > 0 && count <= AMQP_CONSUME_MAX_PREFETCH_COUNT && + prefetch_count >= count)) { if (!amqp_basic_qos(conn, 1, 0, prefetch_count, 0)) { die_rpc(amqp_get_rpc_reply(conn), "basic.qos"); } } } - if (!amqp_basic_consume(conn, 1, queue, amqp_empty_bytes, 0, no_ack, - 0, amqp_empty_table)) { + if (!amqp_basic_consume(conn, 1, queue, amqp_empty_bytes, 0, no_ack, 0, + amqp_empty_table)) { die_rpc(amqp_get_rpc_reply(conn), "basic.consume"); } @@ -180,8 +175,8 @@ int res = amqp_simple_wait_frame(conn, &frame); die_amqp_error(res, "waiting for header frame"); - if (frame.frame_type != AMQP_FRAME_METHOD - || frame.payload.method.id != AMQP_BASIC_DELIVER_METHOD) { + if (frame.frame_type != AMQP_FRAME_METHOD || + frame.payload.method.id != AMQP_BASIC_DELIVER_METHOD) { continue; } @@ -192,16 +187,13 @@ copy_body(conn, pl.infd); if (finish_pipeline(&pl) && !no_ack) - die_amqp_error(amqp_basic_ack(conn, 1, delivery_tag, - 0), - "basic.ack"); + die_amqp_error(amqp_basic_ack(conn, 1, delivery_tag, 0), "basic.ack"); amqp_maybe_release_buffers(conn); } } -int main(int argc, const char **argv) -{ +int main(int argc, const char **argv) { poptContext opts; amqp_connection_state_t conn; const char *const *cmd_argv; @@ -216,47 +208,27 @@ amqp_bytes_t queue_bytes; struct poptOption options[] = { - INCLUDE_OPTIONS(connect_options), - { - "queue", 'q', POPT_ARG_STRING, &queue, 0, - "the queue to consume from", "queue" - }, - { - "exchange", 'e', POPT_ARG_STRING, &exchange, 0, - "bind the queue to this exchange", "exchange" - }, - { - "routing-key", 'r', POPT_ARG_STRING, &routing_key, 0, - "the routing key to bind with", "routing key" - }, - { - "declare", 'd', POPT_ARG_NONE, &declare, 0, - "declare an exclusive queue (deprecated, use --exclusive instead)", NULL - }, - { - "exclusive", 'x', POPT_ARG_NONE, &exclusive, 0, - "declare the queue as exclusive", NULL - }, - { - "no-ack", 'A', POPT_ARG_NONE, &no_ack, 0, - "consume in no-ack mode", NULL - }, - { - "count", 'c', POPT_ARG_INT, &count, 0, - "stop consuming after this many messages are consumed", - "limit" - }, - { - "prefetch-count", 'p', POPT_ARG_INT, &prefetch_count, 0, - "receive only this many message at a time from the server", - "limit" - }, - POPT_AUTOHELP - { NULL, '\0', 0, NULL, 0, NULL, NULL } - }; + INCLUDE_OPTIONS(connect_options), + {"queue", 'q', POPT_ARG_STRING, &queue, 0, "the queue to consume from", + "queue"}, + {"exchange", 'e', POPT_ARG_STRING, &exchange, 0, + "bind the queue to this exchange", "exchange"}, + {"routing-key", 'r', POPT_ARG_STRING, &routing_key, 0, + "the routing key to bind with", "routing key"}, + {"declare", 'd', POPT_ARG_NONE, &declare, 0, + "declare an exclusive queue (deprecated, use --exclusive instead)", + NULL}, + {"exclusive", 'x', POPT_ARG_NONE, &exclusive, 0, + "declare the queue as exclusive", NULL}, + {"no-ack", 'A', POPT_ARG_NONE, &no_ack, 0, "consume in no-ack mode", + NULL}, + {"count", 'c', POPT_ARG_INT, &count, 0, + "stop consuming after this many messages are consumed", "limit"}, + {"prefetch-count", 'p', POPT_ARG_INT, &prefetch_count, 0, + "receive only this many message at a time from the server", "limit"}, + POPT_AUTOHELP{NULL, '\0', 0, NULL, 0, NULL, NULL}}; - opts = process_options(argc, argv, options, - "[OPTIONS]... "); + opts = process_options(argc, argv, options, "[OPTIONS]... "); cmd_argv = poptGetArgs(opts); if (!cmd_argv || !cmd_argv[0]) { @@ -266,7 +238,8 @@ } conn = make_connection(); - queue_bytes = setup_queue(conn, queue, exchange, routing_key, declare, exclusive); + queue_bytes = + setup_queue(conn, queue, exchange, routing_key, declare, exclusive); do_consume(conn, queue_bytes, no_ack, count, prefetch_count, cmd_argv); close_connection(conn); return 0; diff -Nru librabbitmq-0.7.1/tools/declare_queue.c librabbitmq-0.9.0-0.1/tools/declare_queue.c --- librabbitmq-0.7.1/tools/declare_queue.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/declare_queue.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -45,25 +44,18 @@ #include "common.h" -int main(int argc, const char **argv) -{ +int main(int argc, const char **argv) { amqp_connection_state_t conn; static char *queue = NULL; static int durable = 0; struct poptOption options[] = { - INCLUDE_OPTIONS(connect_options), - { - "queue", 'q', POPT_ARG_STRING, &queue, 0, - "the queue name to declare, or the empty string", "queue" - }, - { - "durable", 'd', POPT_ARG_VAL, &durable, 1, - "declare a durable queue", NULL - }, - POPT_AUTOHELP - { NULL, '\0', 0, NULL, 0, NULL, NULL } - }; + INCLUDE_OPTIONS(connect_options), + {"queue", 'q', POPT_ARG_STRING, &queue, 0, + "the queue name to declare, or the empty string", "queue"}, + {"durable", 'd', POPT_ARG_VAL, &durable, 1, "declare a durable queue", + NULL}, + POPT_AUTOHELP{NULL, '\0', 0, NULL, 0, NULL, NULL}}; process_all_options(argc, argv, options); @@ -74,13 +66,8 @@ conn = make_connection(); { - amqp_queue_declare_ok_t *reply = amqp_queue_declare(conn, 1, - cstring_bytes(queue), - 0, - durable, - 0, - 0, - amqp_empty_table); + amqp_queue_declare_ok_t *reply = amqp_queue_declare( + conn, 1, cstring_bytes(queue), 0, durable, 0, 0, amqp_empty_table); if (reply == NULL) { die_rpc(amqp_get_rpc_reply(conn), "queue.declare"); } diff -Nru librabbitmq-0.7.1/tools/delete_queue.c librabbitmq-0.9.0-0.1/tools/delete_queue.c --- librabbitmq-0.7.1/tools/delete_queue.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/delete_queue.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -45,30 +44,21 @@ #include "common.h" -int main(int argc, const char **argv) -{ +int main(int argc, const char **argv) { amqp_connection_state_t conn; static char *queue = NULL; static int if_unused = 0; static int if_empty = 0; struct poptOption options[] = { - INCLUDE_OPTIONS(connect_options), - { - "queue", 'q', POPT_ARG_STRING, &queue, 0, - "the queue name to delete", "queue" - }, - { - "if-unused", 'u', POPT_ARG_VAL, &if_unused, 1, - "do not delete unless queue is unused", NULL - }, - { - "if-empty", 'e', POPT_ARG_VAL, &if_empty, 1, - "do not delete unless queue is empty", NULL - }, - POPT_AUTOHELP - { NULL, '\0', 0, NULL, 0, NULL, NULL } - }; + INCLUDE_OPTIONS(connect_options), + {"queue", 'q', POPT_ARG_STRING, &queue, 0, "the queue name to delete", + "queue"}, + {"if-unused", 'u', POPT_ARG_VAL, &if_unused, 1, + "do not delete unless queue is unused", NULL}, + {"if-empty", 'e', POPT_ARG_VAL, &if_empty, 1, + "do not delete unless queue is empty", NULL}, + POPT_AUTOHELP{NULL, '\0', 0, NULL, 0, NULL, NULL}}; process_all_options(argc, argv, options); @@ -79,10 +69,8 @@ conn = make_connection(); { - amqp_queue_delete_ok_t *reply = amqp_queue_delete(conn, 1, - cstring_bytes(queue), - if_unused, - if_empty); + amqp_queue_delete_ok_t *reply = + amqp_queue_delete(conn, 1, cstring_bytes(queue), if_unused, if_empty); if (reply == NULL) { die_rpc(amqp_get_rpc_reply(conn), "queue.delete"); } diff -Nru librabbitmq-0.7.1/tools/doc/amqp-publish.xml librabbitmq-0.9.0-0.1/tools/doc/amqp-publish.xml --- librabbitmq-0.7.1/tools/doc/amqp-publish.xml 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/doc/amqp-publish.xml 2019-10-20 10:14:51.000000000 +0000 @@ -118,6 +118,15 @@ + + + =header + + + Specifies an optional header in the form "key: value". + + + diff -Nru librabbitmq-0.7.1/tools/doc/librabbitmq-tools.xml librabbitmq-0.9.0-0.1/tools/doc/librabbitmq-tools.xml --- librabbitmq-0.7.1/tools/doc/librabbitmq-tools.xml 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/doc/librabbitmq-tools.xml 2019-10-20 10:14:51.000000000 +0000 @@ -53,7 +53,7 @@ =vhost - The AMQP vhost to specify when connnecting. + The AMQP vhost to specify when connecting. Defaults to /. diff -Nru librabbitmq-0.7.1/tools/get.c librabbitmq-0.9.0-0.1/tools/get.c --- librabbitmq-0.7.1/tools/get.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/get.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -42,10 +41,8 @@ #include "common.h" -static int do_get(amqp_connection_state_t conn, char *queue) -{ - amqp_rpc_reply_t r - = amqp_basic_get(conn, 1, cstring_bytes(queue), 1); +static int do_get(amqp_connection_state_t conn, char *queue) { + amqp_rpc_reply_t r = amqp_basic_get(conn, 1, cstring_bytes(queue), 1); die_rpc(r, "basic.get"); if (r.reply.id == AMQP_BASIC_GET_EMPTY_METHOD) { @@ -56,21 +53,16 @@ return 1; } -int main(int argc, const char **argv) -{ +int main(int argc, const char **argv) { amqp_connection_state_t conn; static char *queue = NULL; int got_something; struct poptOption options[] = { - INCLUDE_OPTIONS(connect_options), - { - "queue", 'q', POPT_ARG_STRING, &queue, 0, - "the queue to consume from", "queue" - }, - POPT_AUTOHELP - { NULL, '\0', 0, NULL, 0, NULL, NULL } - }; + INCLUDE_OPTIONS(connect_options), + {"queue", 'q', POPT_ARG_STRING, &queue, 0, "the queue to consume from", + "queue"}, + POPT_AUTOHELP{NULL, '\0', 0, NULL, 0, NULL, NULL}}; process_all_options(argc, argv, options); diff -Nru librabbitmq-0.7.1/tools/publish.c librabbitmq-0.9.0-0.1/tools/publish.c --- librabbitmq-0.7.1/tools/publish.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/publish.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -46,75 +45,56 @@ #define MAX_LINE_LENGTH 1024 * 32 -static void do_publish(amqp_connection_state_t conn, - char *exchange, char *routing_key, - amqp_basic_properties_t *props, amqp_bytes_t body) -{ - int res = amqp_basic_publish(conn, 1, - cstring_bytes(exchange), - cstring_bytes(routing_key), - 0, 0, props, body); +static void do_publish(amqp_connection_state_t conn, char *exchange, + char *routing_key, amqp_basic_properties_t *props, + amqp_bytes_t body) { + int res = amqp_basic_publish(conn, 1, cstring_bytes(exchange), + cstring_bytes(routing_key), 0, 0, props, body); die_amqp_error(res, "basic.publish"); } -int main(int argc, const char **argv) -{ +int main(int argc, const char **argv) { amqp_connection_state_t conn; static char *exchange = NULL; static char *routing_key = NULL; static char *content_type = NULL; static char *content_encoding = NULL; + static char **headers = NULL; static char *reply_to = NULL; static char *body = NULL; amqp_basic_properties_t props; amqp_bytes_t body_bytes; static int delivery = 1; /* non-persistent by default */ static int line_buffered = 0; + static char **pos; struct poptOption options[] = { - INCLUDE_OPTIONS(connect_options), - { - "exchange", 'e', POPT_ARG_STRING, &exchange, 0, - "the exchange to publish to", "exchange" - }, - { - "routing-key", 'r', POPT_ARG_STRING, &routing_key, 0, - "the routing key to publish with", "routing key" - }, - { - "persistent", 'p', POPT_ARG_VAL, &delivery, 2, - "use the persistent delivery mode", NULL - }, - { - "content-type", 'C', POPT_ARG_STRING, &content_type, 0, - "the content-type for the message", "content type" - }, - { - "reply-to", 't', POPT_ARG_STRING, &reply_to, 0, - "the replyTo to use for the message", "reply to" - }, - { - "line-buffered", 'l', POPT_ARG_VAL, &line_buffered, 2, - "treat each line from standard in as a separate message", NULL - }, - { - "content-encoding", 'E', POPT_ARG_STRING, - &content_encoding, 0, - "the content-encoding for the message", "content encoding" - }, - { - "body", 'b', POPT_ARG_STRING, &body, 0, - "specify the message body", "body" - }, - POPT_AUTOHELP - { NULL, '\0', 0, NULL, 0, NULL, NULL } - }; + INCLUDE_OPTIONS(connect_options), + {"exchange", 'e', POPT_ARG_STRING, &exchange, 0, + "the exchange to publish to", "exchange"}, + {"routing-key", 'r', POPT_ARG_STRING, &routing_key, 0, + "the routing key to publish with", "routing key"}, + {"persistent", 'p', POPT_ARG_VAL, &delivery, 2, + "use the persistent delivery mode", NULL}, + {"content-type", 'C', POPT_ARG_STRING, &content_type, 0, + "the content-type for the message", "content type"}, + {"reply-to", 't', POPT_ARG_STRING, &reply_to, 0, + "the replyTo to use for the message", "reply to"}, + {"line-buffered", 'l', POPT_ARG_VAL, &line_buffered, 2, + "treat each line from standard in as a separate message", NULL}, + {"content-encoding", 'E', POPT_ARG_STRING, &content_encoding, 0, + "the content-encoding for the message", "content encoding"}, + {"header", 'H', POPT_ARG_ARGV, &headers, 0, + "set a message header (may be specified multiple times)", + "\"key: value\""}, + {"body", 'b', POPT_ARG_STRING, &body, 0, "specify the message body", + "body"}, + POPT_AUTOHELP{NULL, '\0', 0, NULL, 0, NULL, NULL}}; process_all_options(argc, argv, options); if (!exchange && !routing_key) { - fprintf(stderr, - "neither exchange nor routing key specified\n"); + fprintf(stderr, "neither exchange nor routing key specified\n"); return 1; } @@ -137,15 +117,45 @@ props.reply_to = amqp_cstring_bytes(reply_to); } + if (headers) { + int num = 0; + for (pos = headers; *pos; pos++) { + num++; + } + + if (num > 0) { + amqp_table_t *table = &props.headers; + table->num_entries = num; + table->entries = calloc(num, sizeof(amqp_table_entry_t)); + int i = 0; + for (pos = headers; *pos; pos++) { + char *colon = strchr(*pos, ':'); + if (colon) { + *colon++ = '\0'; + while (*colon == ' ') colon++; + table->entries[i].key = amqp_cstring_bytes(*pos); + table->entries[i].value.kind = AMQP_FIELD_KIND_UTF8; + table->entries[i].value.value.bytes = amqp_cstring_bytes(colon); + i++; + } else { + fprintf(stderr, + "Ignored header definition missing ':' delimiter in \"%s\"\n", + *pos); + } + } + props._flags |= AMQP_BASIC_HEADERS_FLAG; + } + } + conn = make_connection(); if (body) { body_bytes = amqp_cstring_bytes(body); } else { - if ( line_buffered ) { - body_bytes.bytes = ( char * ) malloc( MAX_LINE_LENGTH ); - while ( fgets( body_bytes.bytes, MAX_LINE_LENGTH, stdin ) ) { - body_bytes.len = strlen( body_bytes.bytes ); + if (line_buffered) { + body_bytes.bytes = (char *)malloc(MAX_LINE_LENGTH); + while (fgets(body_bytes.bytes, MAX_LINE_LENGTH, stdin)) { + body_bytes.len = strlen(body_bytes.bytes); do_publish(conn, exchange, routing_key, &props, body_bytes); } } else { @@ -153,10 +163,14 @@ } } - if ( !line_buffered ) { + if (!line_buffered) { do_publish(conn, exchange, routing_key, &props, body_bytes); } + if (props.headers.num_entries > 0) { + free(props.headers.entries); + } + if (!body) { free(body_bytes.bytes); } diff -Nru librabbitmq-0.7.1/tools/unix/process.c librabbitmq-0.9.0-0.1/tools/unix/process.c --- librabbitmq-0.7.1/tools/unix/process.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/unix/process.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -38,18 +37,17 @@ #include "config.h" #endif -#include #include #include #include +#include #include "common.h" #include "process.h" extern char **environ; -void pipeline(const char *const *argv, struct pipeline *pl) -{ +void pipeline(const char *const *argv, struct pipeline *pl) { posix_spawn_file_actions_t file_acts; int pipefds[2]; @@ -67,7 +65,7 @@ "posix_spawn_file_actions_addclose"); die_errno(posix_spawnp(&pl->pid, argv[0], &file_acts, NULL, - (char * const *)argv, environ), + (char *const *)argv, environ), "posix_spawnp: %s", argv[0]); die_errno(posix_spawn_file_actions_destroy(&file_acts), @@ -80,8 +78,7 @@ pl->infd = pipefds[1]; } -int finish_pipeline(struct pipeline *pl) -{ +int finish_pipeline(struct pipeline *pl) { int status; if (close(pl->infd)) { diff -Nru librabbitmq-0.7.1/tools/unix/process.h librabbitmq-0.9.0-0.1/tools/unix/process.h --- librabbitmq-0.7.1/tools/unix/process.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/unix/process.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT diff -Nru librabbitmq-0.7.1/tools/win32/compat.c librabbitmq-0.9.0-0.1/tools/win32/compat.c --- librabbitmq-0.7.1/tools/win32/compat.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/win32/compat.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -38,14 +37,13 @@ #include "config.h" #endif -#include #include +#include #include #include "compat.h" -int asprintf(char **strp, const char *fmt, ...) -{ +int asprintf(char **strp, const char *fmt, ...) { va_list ap; int len; @@ -53,13 +51,13 @@ len = _vscprintf(fmt, ap); va_end(ap); - *strp = malloc(len+1); + *strp = malloc(len + 1); if (!*strp) { return -1; } va_start(ap, fmt); - _vsnprintf(*strp, len+1, fmt, ap); + _vsnprintf(*strp, len + 1, fmt, ap); va_end(ap); (*strp)[len] = 0; diff -Nru librabbitmq-0.7.1/tools/win32/compat.h librabbitmq-0.9.0-0.1/tools/win32/compat.h --- librabbitmq-0.7.1/tools/win32/compat.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/win32/compat.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT diff -Nru librabbitmq-0.7.1/tools/win32/process.c librabbitmq-0.9.0-0.1/tools/win32/process.c --- librabbitmq-0.7.1/tools/win32/process.c 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/win32/process.c 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -38,15 +37,14 @@ #include "config.h" #endif -#include #include +#include #include #include "common.h" #include "process.h" -void die_windows_error(const char *fmt, ...) -{ +void die_windows_error(const char *fmt, ...) { char *msg; va_list ap; @@ -54,11 +52,10 @@ vfprintf(stderr, fmt, ap); va_end(ap); - if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM - | FORMAT_MESSAGE_ALLOCATE_BUFFER, - NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPSTR)&msg, 0, NULL)) { + if (!FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, + GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR)&msg, 0, NULL)) { msg = "(failed to retrieve Windows error message)"; } @@ -66,8 +63,7 @@ exit(1); } -static char *make_command_line(const char *const *argv) -{ +static char *make_command_line(const char *const *argv) { int i; size_t len = 1; /* initial quotes */ char *buf; @@ -107,32 +103,32 @@ for (;;) { switch (*src) { - case 0: - goto done; + case 0: + goto done; + + case '\"': + for (; backslashes; backslashes--) { + *dest++ = '\\'; + } + + *dest++ = '\\'; + *dest++ = '\"'; + break; - case '\"': - for (; backslashes; backslashes--) { + case '\\': + backslashes++; *dest++ = '\\'; - } + break; - *dest++ = '\\'; - *dest++ = '\"'; - break; - - case '\\': - backslashes++; - *dest++ = '\\'; - break; - - default: - backslashes = 0; - *dest++ = *src; - break; + default: + backslashes = 0; + *dest++ = *src; + break; } src++; } -done: + done: for (; backslashes; backslashes--) { *dest++ = '\\'; } @@ -150,8 +146,7 @@ return buf; } -void pipeline(const char *const *argv, struct pipeline *pl) -{ +void pipeline(const char *const *argv, struct pipeline *pl) { HANDLE in_read_handle, in_write_handle; SECURITY_ATTRIBUTES sec_attr; PROCESS_INFORMATION proc_info; @@ -177,17 +172,17 @@ start_info.cb = sizeof start_info; start_info.dwFlags |= STARTF_USESTDHANDLES; - if ((start_info.hStdError = GetStdHandle(STD_ERROR_HANDLE)) - == INVALID_HANDLE_VALUE - || (start_info.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE)) - == INVALID_HANDLE_VALUE) { + if ((start_info.hStdError = GetStdHandle(STD_ERROR_HANDLE)) == + INVALID_HANDLE_VALUE || + (start_info.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE)) == + INVALID_HANDLE_VALUE) { die_windows_error("GetStdHandle"); } start_info.hStdInput = in_read_handle; - if (!CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 0, - NULL, NULL, &start_info, &proc_info)) { + if (!CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, + &start_info, &proc_info)) { die_windows_error("CreateProcess"); } @@ -204,8 +199,7 @@ pl->infd = _open_osfhandle((intptr_t)in_write_handle, 0); } -int finish_pipeline(struct pipeline *pl) -{ +int finish_pipeline(struct pipeline *pl) { DWORD code; if (close(pl->infd)) { @@ -220,8 +214,7 @@ break; } - if (WaitForSingleObject(pl->proc_handle, INFINITE) - == WAIT_FAILED) { + if (WaitForSingleObject(pl->proc_handle, INFINITE) == WAIT_FAILED) { die_windows_error("WaitForSingleObject"); } } diff -Nru librabbitmq-0.7.1/tools/win32/process.h librabbitmq-0.9.0-0.1/tools/win32/process.h --- librabbitmq-0.7.1/tools/win32/process.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/tools/win32/process.h 2019-10-20 10:14:51.000000000 +0000 @@ -1,4 +1,3 @@ -/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT diff -Nru librabbitmq-0.7.1/travis/clang-format.sh librabbitmq-0.9.0-0.1/travis/clang-format.sh --- librabbitmq-0.7.1/travis/clang-format.sh 1970-01-01 00:00:00.000000000 +0000 +++ librabbitmq-0.9.0-0.1/travis/clang-format.sh 2019-10-20 10:14:51.000000000 +0000 @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +exec clang-format-3.9 -style=file $@ diff -Nru librabbitmq-0.7.1/travis.sh librabbitmq-0.9.0-0.1/travis.sh --- librabbitmq-0.7.1/travis.sh 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/travis.sh 2019-10-20 10:14:51.000000000 +0000 @@ -1,23 +1,35 @@ #!/usr/bin/env bash -build_autotools() { - autoreconf -i - ./configure --prefix=$PWD/_install - make install +build_cmake() { + mkdir $PWD/_build && cd $PWD/_build + cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../_install -DCMAKE_C_FLAGS="-Werror" \ + ${_CMAKE_OPENSSL_FLAG} + cmake --build . --target install + ctest -V . } -build_cmake() { - CFLAGS="-fsanitize=undefined" +build_format() { + ./travis/run-clang-format/run-clang-format.py \ + --clang-format-executable="${PWD}/travis/clang-format.sh" \ + --recursive examples librabbitmq tests tools +} + +build_coverage() { mkdir $PWD/_build && cd $PWD/_build - cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../_install + cmake .. -DCMAKE_BUILD_TYPE=Coverage -DCMAKE_INSTALL_PREFIX=$PWD/../_install \ + -DCMAKE_C_FLAGS="-Werror -fprofile-arcs -ftest-coverage" \ + ${_CMAKE_OPENSSL_FLAG} cmake --build . --target install ctest -V . + + pip install --user cpp-coveralls + coveralls --exclude tests --build-root . --root .. --gcov-options '\-lp' } build_asan() { mkdir $PWD/_build && cd $PWD/_build cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/../_install \ - -DCMAKE_C_FLAGS="-fsanitize=address,undefined -O1" + -DCMAKE_C_FLAGS="-Werror -fsanitize=address,undefined -O1" cmake --build . --target install ctest -V . } @@ -25,17 +37,35 @@ build_tsan() { mkdir $PWD/_build && cd $PWD/_build cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/../_install \ - -DCMAKE_C_FLAGS="-fsanitize=thread,undefined -O1" + -DCMAKE_C_FLAGS="-Werror -fsanitize=thread,undefined -O1" cmake --build . --target install ctest -V . } +build_scan-build() { + mkdir $PWD/_build && cd $PWD/_build + scan-build-3.9 cmake .. -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX=$PWD/../_install \ + -DCMAKE_C_FLAGS="-Werror" + scan-build-3.9 make install +} + if [ "$#" -ne 1 ]; then - echo "Usage: $0 {autotools|cmake|asan|tsan}" + echo "Usage: $0 {cmake|asan|tsan|scan-build}" exit 1 fi set -e # exit on error. set -x # echo commands. +case $TRAVIS_OS_NAME in +osx) + # This prints out a long list of updated packages, which isn't useful. + brew update > /dev/null + brew install popt + brew outdated openssl || brew install openssl + export _CMAKE_OPENSSL_FLAG="-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl" + ;; +esac + eval "build_$1" diff -Nru librabbitmq-0.7.1/.travis.yml librabbitmq-0.9.0-0.1/.travis.yml --- librabbitmq-0.7.1/.travis.yml 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.travis.yml 2019-10-20 10:14:51.000000000 +0000 @@ -3,8 +3,9 @@ language: c -# Use the faster container-based infrastructure. -sudo: false +dist: trusty +# Currently libpopt-dev is not on the list of whitelisted apt-packages. +sudo: true env: global: @@ -12,14 +13,22 @@ # via the "travis encrypt" command using the project repo's public key - secure: "gDwqo3jHj+HHGzFKnxL/nwZhbVeh2pItw0TbeaHcLtWubUZaf85ViEQRaXPyfnbG7l0OEQq+PjyhKAfvViVq2NP0lGeeu4VM5uMZJhsCLN594BJr39Y4XzOapg0O8mEMhQ0DU2u1Zo4LMgEcRz67aosVQOj6QV30tOzp9fnxn9U=" +services: + - rabbitmq + matrix: include: + # Note that the first compiler in the matrix must be gcc, so that the + # coverity_scan branch hack below works correctly. - compiler: gcc os: linux - env: CONFIG=autotools + env: CONFIG=cmake - compiler: gcc os: linux - env: CONFIG=cmake + env: CONFIG=format + - compiler: gcc + os: linux + env: CONFIG=coverage - compiler: clang os: linux env: CONFIG=cmake @@ -30,23 +39,54 @@ os: linux env: CONFIG=tsan - compiler: clang + os: linux + env: CONFIG=scan-build + - compiler: clang os: osx env: CONFIG=cmake + - compiler: gcc + os: linux + env: NAME="openssl-1.1.0" CONFIG=cmake + addons: + apt: + sources: + - sourceline: 'ppa:ondrej/nginx-mainline' + packages: + - libssl1.1 + - openssl + - libssl-dev + + allow_failures: + - compiler: clang + os: linux + env: CONFIG=tsan + +before_install: + - | + if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then + wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo apt-add-repository "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main" + sudo apt-get -q update; + sudo apt-get install -y clang-3.9 clang-format-3.9 libpopt-dev; + fi + # ugly hack; if running a coverity scan abort all except the 1st build + # see note re gcc compiler above needing to be 1st + # also note that branch_pattern & the TRAVIS_BRANCH check must match + # unfortunately COVERITY_SCAN_BRANCH isn't defined until later in the + # build process + - if ([[ "${TRAVIS_JOB_NUMBER##*.}" != "1" ]] && [[ "${TRAVIS_BRANCH}" == "coverity_scan" ]]); then false ; fi + -# Run the Build script script: - - ./travis.sh $CONFIG + # Don't bother building if this is being done in the coverity_scan branch. + - if [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then ./travis.sh $CONFIG ; fi addons: - apt: - packages: - - libpopt-dev - coverity_scan: project: name: "alanxz/rabbitmq-c" description: "C AMQP client for RabbitMQ" notification_email: alan.antonuk@gmail.com - build_command_prepend: cmake .. - build_command: cmake --build . + build_command_prepend: mkdir build && pushd build && cmake .. && popd + build_command: cmake --build ./build branch_pattern: coverity_scan diff -Nru librabbitmq-0.7.1/vms/config.h librabbitmq-0.9.0-0.1/vms/config.h --- librabbitmq-0.7.1/vms/config.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/vms/config.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -#ifndef LIBRABBITMQ_CONFIG_H -#define LIBRABBITMQ_CONFIG_H - -#define VERSION "v0.1" - -#endif diff -Nru librabbitmq-0.7.1/vms/include.mms librabbitmq-0.9.0-0.1/vms/include.mms --- librabbitmq-0.7.1/vms/include.mms 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/vms/include.mms 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ - -.SUFFIXES ; - -.SUFFIXES .EXE $(OLB) .OBJ .MMSD .cpp .cc .C .FOR .Y .L - -.L.C - flex -l $(MMS$SOURCE) -o $(MMS$TARGET) - -.Y.C - yacc $(MMS$SOURCE) -o $(MMS$TARGET) - -.C.OBJ - CC$(CFLAGS)/MMS=(FILE=$(MMS$TARGET_NAME).MMSD)/OBJ=$(MMS$TARGET_NAME).OBJ $(MMS$SOURCE) - -.C.MMSD - CC$(CFLAGS)/MMS=(FILE=$(MMS$TARGET_NAME).MMSD)/OBJ=$(MMS$TARGET_NAME).OBJ $(MMS$SOURCE) - -.CPP.OBJ - CXX$(CXXFLAGS)/MMS=(FILE=$(MMS$TARGET_NAME).MMSD)/OBJ=$(MMS$TARGET) $(MMS$SOURCE) - -.CPP.MMSD - CXX$(CXXFLAGS)/MMS=(FILE=$(MMS$TARGET))/OBJ=$(MMS$TARGET_NAME).OBJ $(MMS$SOURCE) - -.CC.OBJ - CXX$(CXXFLAGS)/MMS=(FILE=$(MMS$TARGET_NAME).MMSD)/OBJ=$(MMS$TARGET) $(MMS$SOURCE) - -.CC.MMSD - CXX$(CXXFLAGS)/MMS=(FILE=$(MMS$TARGET))/OBJ=$(MMS$TARGET_NAME).OBJ $(MMS$SOURCE) - -.OBJ$(OLB) - @ IF F$SEARCH("$(MMS$TARGET)") .EQS. "" THEN LIBRARY/CREATE $(MMS$TARGET) - LIBRARY/REPLACE $(MMS$TARGET) $(MMS$SOURCE_LIST) - -.FOR.OBJ - FOR$(FORFLAGS)/OBJ=$(MMS$TARGET) $(MMS$SOURCE) - -.FIRST - @ continue - -.IFDEF USE_DEPEND -.ELSE - @ WRITE SYS$OUTPUT "Entering ''F$ENVIRONMENT(""DEFAULT"")'" -.ENDIF - -.IFDEF USE_DEPEND -.ELSE -.LAST - @ WRITE SYS$OUTPUT "Leaving ''F$ENVIRONMENT(""DEFAULT"")'" -.ENDIF - -ECHO = WRITE SYS$OUTPUT - -DEPS = $(OBJS:.OBJ=.MMSD) - -OPTFLAGS = /PREFIX=ALL/FLOAT=IEEE/IEEE=DENORM/NAMES=(UPPER,TRUNC)/POINTER=SHORT -DEFS = __USE_STD_IOSTREAM=1,VMS -CDEFS = VMS -INC = . - -DEFAULT_TARGET : $(DEPS) MMS$DEPEND.MMSD INCLUDE_DEPS - @ CONTINUE - -MMS$DEPEND.MMSD : $(DEPS) MMS$GEN_DEPEND.COM - @MMS$GEN_DEPEND.COM - -MMS$GEN_DEPEND.COM : - @ WRITE SYS$OUTPUT "Regenerating GEN_DEPEND.COM" - @ OPEN/WRITE F MMS$GEN_DEPEND.COM - @ WRITE F "$ OPEN/WRITE FH MMS$DEPEND.MMSD" - @ WRITE F "$ WRITE FH ""# File generated by GEN_DEPEND.COM - DO NOT EDIT""" - @ WRITE F "$ WRITE FH ""# Changes will be overwritten next time product is built""" - @ WRITE F "$ WRITE FH "".IFDEF USE_DEPEND""" - @ WRITE F "$ LOOP:" - @ WRITE F "$ FIL = F$SEARCH(""*.MMSD"")" - @ WRITE F "$ IF FIL .NES. """"" - @ WRITE F "$ THEN" - @ WRITE F "$ NAM = F$PARSE(FIL,,,""NAME"")" - @ WRITE F "$ IF NAM .EQS. ""MMS$DEPEND"" THEN GOTO LOOP" - @ WRITE F "$ TYP = F$PARSE(FIL,,,""TYPE"")" - @ WRITE F "$ FUL = NAM + TYP" - @ WRITE F "$ WRITE FH "".INCLUDE "" + FUL" - @ WRITE F "$ GOTO LOOP" - @ WRITE F "$ ENDIF" - @ WRITE F "$ WRITE FH "".ELSE""" - @ WRITE F "$ WRITE FH ""DUMMY :""" - @ WRITE F "$ WRITE FH "" @ WRITE SYS$OUTPUT """"MMS$DEPEND.MMS must .INCLUDED by appropriate DESCRIP.MMS and not called directly""""""" - @ WRITE F "$ WRITE FH "".ENDIF""" - @ WRITE F "$ CLOSE FH" - @ CLOSE F - -INCLUDE_DEPS : - MMK/EXTEND/MACRO=("USE_DEPEND=1") REAL_TARGET - -REAL_TARGET : $(REAL_TARGETS) - @ CONTINUE - -CLEAN : - IF F$SEARCH("*.MMSD*") .NES. "" THEN DEL/NOLOG *.MMSD*;* - IF F$SEARCH("MMS$GEN_DEPEND.COM*") .NES. "" THEN DEL/NOLOG MMS$GEN_DEPEND.COM*;* - IF F$SEARCH("MMS$LINK.OPT*") .NES. "" THEN DEL/NOLOG MMS$LINK.OPT*;* - IF F$SEARCH("MMS$SYMBOLS.OPT*") .NES. "" THEN DEL/NOLOG MMS$SYMBOLS.OPT*;* - IF F$SEARCH("*.OBJ*") .NES. "" THEN DEL/NOLOG *.OBJ*;* - IF F$SEARCH("[.CXX_REPOSITORY*]*.*") .NES. "" THEN DEL/NOLOG [.CXX_REPOSITORY*]*.*;* - IF F$SEARCH("CXX_REPOSITORY*.DIR") .NES. "" THEN - - PIPE (SET SEC/PROT=O:D CXX_REPOSITORY*.DIR; && DEL CXX_REPOSITORY*.DIR;) - IF F$SEARCH("*.OLB") .NES. "" THEN DEL/NOLOG *.OLB;* - IF F$SEARCH("*.EXE") .NES. "" THEN DEL/NOLOG *.EXE;* - IF F$SEARCH("*.OUT") .NES. "" THEN DEL/NOLOG *.OUT;* - IF F$SEARCH("*.TMP") .NES. "" THEN DEL/NOLOG *.TMP;* - IF F$SEARCH("TAGS.") .NES. "" THEN DEL/NOLOG TAGS.;* -.IFDEF EXTRA_FILES - - DEL/NOLOG $(EXTRA_FILES) -.ENDIF - -PURGE : - - PURGE *.OLB,*.MMSD,*.OBJ,*.EXE,[.CXX_REPOSITORY]*.* - -TAGS. : - @ IF "''CTAGS'" .NES. "" THEN CTAGS --language-force=c++ --c++-kinds=+p --fields=+iaS --extra=+q *.h *.cxx *.cpp - -.IFDEF USE_DEPEND -.INCLUDE MMS$DEPEND.MMSD -.ELSE -.ENDIF - diff -Nru librabbitmq-0.7.1/vms/stdint.h librabbitmq-0.9.0-0.1/vms/stdint.h --- librabbitmq-0.7.1/vms/stdint.h 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/vms/stdint.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* Simply forward this header to what VMS has */ -#include diff -Nru librabbitmq-0.7.1/.ycm_extra_conf.py librabbitmq-0.9.0-0.1/.ycm_extra_conf.py --- librabbitmq-0.7.1/.ycm_extra_conf.py 2015-10-13 02:40:12.000000000 +0000 +++ librabbitmq-0.9.0-0.1/.ycm_extra_conf.py 2019-10-20 10:14:51.000000000 +0000 @@ -51,6 +51,7 @@ '-x', 'c', '-I', './librabbitmq', +'-I', './librabbitmq/unix', '-D', 'HAVE_POLL', ]