summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2012-05-24 12:16:55 -0700
committerAlan Antonuk <alan.antonuk@gmail.com>2012-05-24 12:16:55 -0700
commit7a74c3574afb32ab31dc5f946afbf89f3022a36d (patch)
tree905ce64fbee48f720b553cda46cee272ea064b17
parent50a298e6c0df1ef8f2ec19da5949adef392e5131 (diff)
parente567f9eb8918d35db4ebc78e9a512d3e838afe00 (diff)
downloadrabbitmq-c-github-ask-7a74c3574afb32ab31dc5f946afbf89f3022a36d.tar.gz
Merge pull request #16 from msteinert/autotools
Cleanup autoconf/automake build
-rw-r--r--.gitignore46
-rw-r--r--.gitmodules3
-rw-r--r--CMakeLists.txt6
-rw-r--r--COPYING1
-rw-r--r--ChangeLog0
-rw-r--r--INSTALL291
-rw-r--r--Makefile.am291
-rw-r--r--NEWS0
-rw-r--r--README137
-rw-r--r--README-win32.md (renamed from README.windows)0
-rw-r--r--[l---------]README.md140
-rw-r--r--cmake/TestCInline.cmake (renamed from TestCInline.cmake)0
m---------codegen0
-rw-r--r--configure.ac300
-rwxr-xr-xetc/build-ms.sh2
-rw-r--r--examples/CMakeLists.txt2
-rw-r--r--examples/Makefile.am33
-rw-r--r--examples/amqp_producer.c2
-rw-r--r--examples/utils.c2
-rw-r--r--examples/win32/platform_utils.c (renamed from examples/windows/platform_utils.c)0
-rw-r--r--librabbitmq.pc.in12
-rw-r--r--librabbitmq/CMakeLists.txt14
-rw-r--r--librabbitmq/Makefile.am35
-rw-r--r--librabbitmq/amqp.h433
-rw-r--r--librabbitmq/amqp_api.c21
-rw-r--r--librabbitmq/amqp_connection.c17
-rw-r--r--librabbitmq/amqp_mem.c14
-rw-r--r--librabbitmq/amqp_private.h28
-rw-r--r--librabbitmq/amqp_socket.c12
-rw-r--r--librabbitmq/amqp_table.c15
-rw-r--r--librabbitmq/amqp_url.c13
-rw-r--r--librabbitmq/codegen.py90
-rw-r--r--librabbitmq/unix/socket.c26
-rw-r--r--librabbitmq/unix/socket.h25
-rw-r--r--librabbitmq/win32/msinttypes/inttypes.h (renamed from msinttypes/inttypes.h)0
-rw-r--r--librabbitmq/win32/msinttypes/stdint.h (renamed from msinttypes/stdint.h)0
-rw-r--r--librabbitmq/win32/socket.c (renamed from librabbitmq/windows/socket.c)35
-rw-r--r--librabbitmq/win32/socket.h60
-rw-r--r--librabbitmq/windows/socket.h71
-rw-r--r--m4/.gitignore5
-rw-r--r--m4/cflags.m459
-rw-r--r--m4/ldflags.m458
-rw-r--r--m4/popt.m473
-rw-r--r--tests/Makefile.am18
-rw-r--r--tests/test_parse_url.c2
-rw-r--r--tests/test_tables.c51
-rw-r--r--tools/CMakeLists.txt2
-rw-r--r--tools/Makefile.am31
-rw-r--r--tools/common.c9
-rw-r--r--tools/consume.c4
-rw-r--r--tools/declare_queue.c4
-rw-r--r--tools/delete_queue.c4
-rw-r--r--tools/doc/Makefile.am42
-rw-r--r--tools/doc/amqp-consume.xml (renamed from tools/doc/consume.xml)0
-rw-r--r--tools/doc/amqp-declare-queue.xml (renamed from tools/doc/declare_queue.xml)0
-rw-r--r--tools/doc/amqp-delete-queue.xml (renamed from tools/doc/delete_queue.xml)0
-rw-r--r--tools/doc/amqp-get.xml (renamed from tools/doc/get.xml)0
-rw-r--r--tools/doc/amqp-publish.xml (renamed from tools/doc/publish.xml)0
-rw-r--r--tools/get.c4
-rw-r--r--tools/publish.c4
-rw-r--r--tools/unix/process.c4
-rw-r--r--tools/win32/compat.c (renamed from tools/windows/compat.c)4
-rw-r--r--tools/win32/compat.h (renamed from tools/windows/compat.h)0
-rw-r--r--tools/win32/process.c (renamed from tools/windows/process.c)4
-rw-r--r--tools/win32/process.h (renamed from tools/windows/process.h)0
65 files changed, 1420 insertions, 1139 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e329cb2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,46 @@
+*.la
+*.lo
+*.o
+.deps
+.dirstamp
+.libs
+/aclocal.m4
+/autom4te.cache
+/config.guess
+/config.h
+/config.h.in
+/config.h.in~
+/config.log
+/config.status
+/config.sub
+/configure
+/depcomp
+/install-sh
+/libtool
+/ltmain.sh
+/missing
+/stamp-h1
+INSTALL
+Makefile
+Makefile.in
+examples/amqp_bind
+examples/amqp_consumer
+examples/amqp_exchange_declare
+examples/amqp_listen
+examples/amqp_listenq
+examples/amqp_producer
+examples/amqp_sendstring
+examples/amqp_unbind
+librabbitmq.pc
+librabbitmq/amqp_framing.c
+librabbitmq/amqp_framing.h
+tests/test_parse_url
+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
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..78954dc
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "codegen"]
+ path = codegen
+ url = git://github.com/rabbitmq/rabbitmq-codegen.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a5615d1..b4f95e2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 2.8)
project(rabbitmq-c "C")
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
+
#find python
find_package(PythonInterp REQUIRED)
@@ -19,7 +21,6 @@ if (CHECK_PYTHON_JSON_FAILED)
endif (CHECK_PYTHON_SIMPLEJSON_FAILED)
endif (CHECK_PYTHON_JSON_FAILED)
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
include(TestCInline)
option(FETCH_CODEGEN_FROM_GIT "Fetch codegen directly from the git repository" OFF)
@@ -46,6 +47,7 @@ else (FETCH_CODEGEN_FROM_GIT)
amqp_codegen.py
PATHS ${CMAKE_SOURCE_DIR}/rabbitmq-codegen
${CMAKE_SOURCE_DIR}/../rabbitmq-codegen
+ ${CMAKE_SOURCE_DIR}/codegen
DOC "Path to directory containing amqp_codegen.py (rabbitmq-codegen)"
NO_DEFAULT_PATH
)
@@ -61,8 +63,6 @@ endif (FETCH_CODEGEN_FROM_GIT)
mark_as_advanced(AMQP_CODEGEN_DIR)
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
-
find_package(POPT)
option(BUILD_SHARED_LIBS "Build rabbitmq-c as a shared library" ON)
diff --git a/COPYING b/COPYING
deleted file mode 100644
index f5997d4..0000000
--- a/COPYING
+++ /dev/null
@@ -1 +0,0 @@
-See LICENSE-MIT.
diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
index e69de29..0000000
--- a/ChangeLog
+++ /dev/null
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 8b82ade..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,291 +0,0 @@
-Installation Instructions
-*************************
-
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006, 2007, 2008 Free Software Foundation, Inc.
-
- This file is free documentation; the Free Software Foundation gives
-unlimited permission to copy, distribute and modify it.
-
-Basic Installation
-==================
-
- Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package. The following
-more-detailed instructions are generic; see the `README' file for
-instructions specific to this package.
-
- The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation. It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions. Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
- It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring. Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.
-
- If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release. If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
- The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'. You need `configure.ac' if
-you want to change it or regenerate `configure' using a newer version
-of `autoconf'.
-
-The simplest way to compile this package is:
-
- 1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system.
-
- Running `configure' might take a while. While running, it prints
- some messages telling which features it is checking for.
-
- 2. Type `make' to compile the package.
-
- 3. Optionally, type `make check' to run any self-tests that come with
- the package.
-
- 4. Type `make install' to install the programs and any data files and
- documentation.
-
- 5. You can remove the program binaries and object files from the
- source code directory by typing `make clean'. To also remove the
- files that `configure' created (so you can compile the package for
- a different kind of computer), type `make distclean'. There is
- also a `make maintainer-clean' target, but that is intended mainly
- for the package's developers. If you use it, you may have to get
- all sorts of other programs in order to regenerate files that came
- with the distribution.
-
- 6. Often, you can also type `make uninstall' to remove the installed
- files again.
-
-Compilers and Options
-=====================
-
- Some systems require unusual options for compilation or linking that
-the `configure' script does not know about. Run `./configure --help'
-for details on some of the pertinent environment variables.
-
- You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment. Here
-is an example:
-
- ./configure CC=c99 CFLAGS=-g LIBS=-lposix
-
- *Note Defining Variables::, for more details.
-
-Compiling For Multiple Architectures
-====================================
-
- You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory. To do this, you can use GNU `make'. `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script. `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
-
- With a non-GNU `make', it is safer to compile the package for one
-architecture at a time in the source code directory. After you have
-installed the package for one architecture, use `make distclean' before
-reconfiguring for another architecture.
-
- On MacOS X 10.5 and later systems, you can create libraries and
-executables that work on multiple system types--known as "fat" or
-"universal" binaries--by specifying multiple `-arch' options to the
-compiler but only a single `-arch' option to the preprocessor. Like
-this:
-
- ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
- CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
- CPP="gcc -E" CXXCPP="g++ -E"
-
- This is not guaranteed to produce working output in all cases, you
-may have to build one architecture at a time and combine the results
-using the `lipo' tool if you have problems.
-
-Installation Names
-==================
-
- By default, `make install' installs the package's commands under
-`/usr/local/bin', include files under `/usr/local/include', etc. You
-can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX'.
-
- You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files. If you
-pass the option `--exec-prefix=PREFIX' to `configure', the package uses
-PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files still use the regular prefix.
-
- In addition, if you use an unusual directory layout you can give
-options like `--bindir=DIR' to specify different values for particular
-kinds of files. Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
-
- If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-Optional Features
-=================
-
- Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System). The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
- For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-Particular systems
-==================
-
- On HP-UX, the default C compiler is not ANSI C compatible. If GNU
-CC is not installed, it is recommended to use the following options in
-order to use an ANSI C compiler:
-
- ./configure CC="cc -Ae"
-
-and if that doesn't work, install pre-built binaries of GCC for HP-UX.
-
- On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
-parse its `<wchar.h>' header file. The option `-nodtk' can be used as
-a workaround. If GNU CC is not installed, it is therefore recommended
-to try
-
- ./configure CC="cc"
-
-and if that doesn't work, try
-
- ./configure CC="cc -nodtk"
-
-Specifying the System Type
-==========================
-
- There may be some features `configure' cannot figure out
-automatically, but needs to determine by the type of machine the package
-will run on. Usually, assuming the package is built to be run on the
-_same_ architectures, `configure' can figure that out, but if it prints
-a message saying it cannot guess the machine type, give it the
-`--build=TYPE' option. TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
-
- CPU-COMPANY-SYSTEM
-
-where SYSTEM can have one of these forms:
-
- OS KERNEL-OS
-
- See the file `config.sub' for the possible values of each field. If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
- If you are _building_ compiler tools for cross-compiling, you should
-use the option `--target=TYPE' to select the type of system they will
-produce code for.
-
- If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
-
-Sharing Defaults
-================
-
- If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists. Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Defining Variables
-==================
-
- Variables not defined in a site shell script can be set in the
-environment passed to `configure'. However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost. In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'. For example:
-
- ./configure CC=/usr/local2/bin/gcc
-
-causes the specified `gcc' to be used as the C compiler (unless it is
-overridden in the site shell script).
-
-Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf bug. Until the bug is fixed you can use this workaround:
-
- CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
-
-`configure' Invocation
-======================
-
- `configure' recognizes the following options to control how it
-operates.
-
-`--help'
-`-h'
- Print a summary of all of the options to `configure', and exit.
-
-`--help=short'
-`--help=recursive'
- Print a summary of the options unique to this package's
- `configure', and exit. The `short' variant lists options used
- only in the top level, while the `recursive' variant lists options
- also present in any nested packages.
-
-`--version'
-`-V'
- Print the version of Autoconf used to generate the `configure'
- script, and exit.
-
-`--cache-file=FILE'
- Enable the cache: use and save the results of the tests in FILE,
- traditionally `config.cache'. FILE defaults to `/dev/null' to
- disable caching.
-
-`--config-cache'
-`-C'
- Alias for `--cache-file=config.cache'.
-
-`--quiet'
-`--silent'
-`-q'
- Do not print messages saying which checks are being made. To
- suppress all normal output, redirect it to `/dev/null' (any error
- messages will still be shown).
-
-`--srcdir=DIR'
- Look for the package's source code in directory DIR. Usually
- `configure' can determine that directory automatically.
-
-`--prefix=DIR'
- Use DIR as the installation prefix. *Note Installation Names::
- for more details, including other options available for fine-tuning
- the installation locations.
-
-`--no-create'
-`-n'
- Run the configure checks, but stop before creating any output
- files.
-
-`configure' also accepts some other, not widely useful, options. Run
-`configure --help' for more details.
-
diff --git a/Makefile.am b/Makefile.am
index a990faa..204f0c7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,21 +1,282 @@
+ACLOCAL_AMFLAGS = -I m4
+
+lib_LTLIBRARIES = librabbitmq/librabbitmq.la
+
+librabbitmq_librabbitmq_la_SOURCES = \
+ librabbitmq/amqp_api.c \
+ librabbitmq/amqp_connection.c \
+ librabbitmq/amqp_framing.c \
+ librabbitmq/amqp_mem.c \
+ librabbitmq/amqp_private.h \
+ librabbitmq/amqp_socket.c \
+ librabbitmq/amqp_table.c \
+ librabbitmq/amqp_url.c
+
+librabbitmq_librabbitmq_la_CFLAGS = \
+ -I$(top_srcdir)/librabbitmq
+
+librabbitmq_librabbitmq_la_LDFLAGS = \
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+ $(NO_UNDEFINED)
+
+if OS_UNIX
+librabbitmq_librabbitmq_la_SOURCES += librabbitmq/unix/socket.c
+librabbitmq_librabbitmq_la_SOURCES += librabbitmq/unix/socket.h
+librabbitmq_librabbitmq_la_CFLAGS += -I$(top_srcdir)/librabbitmq/unix
+endif
+
+if OS_WIN32
+librabbitmq_librabbitmq_la_SOURCES += librabbitmq/win32/socket.c
+librabbitmq_librabbitmq_la_SOURCES += librabbitmq/win32/socket.h
+librabbitmq_librabbitmq_la_CFLAGS += -I$(top_srcdir)/librabbitmq/win32
+librabbitmq_librabbitmq_la_CFLAGS += -I$(top_srcdir)/librabbitmq/win32/msinttypes
+endif
+
+include_HEADERS = \
+ librabbitmq/amqp.h \
+ librabbitmq/amqp_framing.h
+
+BUILT_SOURCES = \
+ librabbitmq/amqp_framing.h \
+ librabbitmq/amqp_framing.c
+
+codegen_py = $(top_srcdir)/librabbitmq/codegen.py
+amqp_codegen_json = $(top_srcdir)/codegen/amqp-rabbitmq-0.9.1.json
+
+librabbitmq/amqp_framing.h: $(amqp_codegen_json) $(codegen_py)
+ $(AM_V_GEN)PYTHONPATH=$(top_srcdir)/codegen $(PYTHON) $(codegen_py) header $< $@
+
+librabbitmq/amqp_framing.c: $(amqp_codegen_json) $(codegen_py)
+ $(AM_V_GEN)PYTHONPATH=$(top_srcdir)/codegen $(PYTHON) $(codegen_py) body $< $@
+
+AM_CFLAGS = -I$(top_srcdir)/librabbitmq
+
+check_PROGRAMS = \
+ tests/test_tables \
+ tests/test_parse_url
+
+TESTS = $(check_PROGRAMS)
+
+tests_test_tables_SOURCES = tests/test_tables.c
+tests_test_tables_LDADD = librabbitmq/librabbitmq.la
+
+tests_test_parse_url_SOURCES = tests/test_parse_url.c
+tests_test_parse_url_LDADD = librabbitmq/librabbitmq.la
+
+noinst_LTLIBRARIES = examples/libutils.la
+
+examples_libutils_la_SOURCES = \
+ examples/utils.c \
+ examples/utils.h
+
+examples_libutils_la_CFLAGS = -I$(top_srcdir)/librabbitmq
+
+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_exchange_declare \
+ examples/amqp_listen \
+ examples/amqp_listenq \
+ examples/amqp_producer \
+ 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_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
+
if TOOLS
-TOOLS_SUBDIR=tools
-else
-TOOLS_SUBDIR=
+noinst_LTLIBRARIES += tools/libcommon.la
+
+tools_libcommon_la_SOURCES = \
+ tools/common.c \
+ tools/common.h
+tools_libcommon_la_CFLAGS = \
+ -I$(top_srcdir)/librabbitmq \
+ -I$(top_srcdir)/tools
+
+tools_platform_CFLAGS =
+
+if OS_UNIX
+tools_libcommon_la_SOURCES += tools/unix/process.c
+tools_libcommon_la_SOURCES += tools/unix/process.h
+tools_platform_CFLAGS += -I$(top_srcdir)/tools/unix
endif
-SUBDIRS=librabbitmq tests examples $(TOOLS_SUBDIR)
+if OS_WIN32
+tools_libcommon_la_SOURCES += tools/win32/compat.c
+tools_libcommon_la_SOURCES += tools/win32/compat.h
+tools_libcommon_la_SOURCES += tools/win32/process.c
+tools_libcommon_la_SOURCES += tools/win32/process.h
+tools_platform_CFLAGS += -I$(top_srcdir)/tools/win32
+tools_platform_CFLAGS += -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 = \
+ $(POPT_CFLAGS) \
+ $(tools_platform_CFLAGS) \
+ -I$(top_srcdir)/librabbitmq \
+ -I$(top_srcdir)/tools
+tools_amqp_publish_LDADD = \
+ $(POPT_LIBS) \
+ librabbitmq/librabbitmq.la \
+ tools/libcommon.la
+
+tools_amqp_get_SOURCES = tools/get.c
+tools_amqp_get_CFLAGS = \
+ $(POPT_CFLAGS) \
+ $(tools_platform_CFLAGS) \
+ -I$(top_srcdir)/librabbitmq \
+ -I$(top_srcdir)/tools
+tools_amqp_get_LDADD = \
+ $(POPT_LIBS) \
+ librabbitmq/librabbitmq.la \
+ tools/libcommon.la
+
+tools_amqp_consume_SOURCES = tools/consume.c
+tools_amqp_consume_CFLAGS = \
+ $(POPT_CFLAGS) \
+ $(tools_platform_CFLAGS) \
+ -I$(top_srcdir)/librabbitmq \
+ -I$(top_srcdir)/tools
+tools_amqp_consume_LDADD = \
+ $(POPT_LIBS) \
+ librabbitmq/librabbitmq.la \
+ tools/libcommon.la
+
+tools_amqp_declare_queue_SOURCES = tools/declare_queue.c
+tools_amqp_declare_queue_CFLAGS = \
+ $(POPT_CFLAGS) \
+ $(tools_platform_CFLAGS) \
+ -I$(top_srcdir)/librabbitmq \
+ -I$(top_srcdir)/tools
+tools_amqp_declare_queue_LDADD = \
+ $(POPT_LIBS) \
+ librabbitmq/librabbitmq.la \
+ tools/libcommon.la
+
+tools_amqp_delete_queue_SOURCES = tools/delete_queue.c
+tools_amqp_delete_queue_CFLAGS = \
+ $(POPT_CFLAGS) \
+ $(tools_platform_CFLAGS) \
+ -I$(top_srcdir)/librabbitmq \
+ -I$(top_srcdir)/tools
+tools_amqp_delete_queue_LDADD = \
+ $(POPT_LIBS) \
+ librabbitmq/librabbitmq.la \
+ tools/libcommon.la
+if DOCS
+man_MANS = \
+ $(top_srcdir)/tools/doc/amqp-publish.1 \
+ $(top_srcdir)/tools/doc/amqp-consume.1 \
+ $(top_srcdir)/tools/doc/amqp-get.1 \
+ $(top_srcdir)/tools/doc/amqp-declare-queue.1 \
+ $(top_srcdir)/tools/doc/amqp-delete-queue.1 \
+ $(top_srcdir)/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
+
+%.1: %.xml tools/doc/man-date.ent
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) -o $(top_srcdir)/tools/doc man $<
+
+%.7: %.xml tools/doc/man-date.ent
+ $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) -o $(top_srcdir)/tools/doc man $<
+
+$(top_srcdir)/tools/doc/man-date.ent:
+ $(AM_V_at)$(MKDIR_P) tools/doc
+ $(AM_V_GEN)date +'%Y-%m-%d' > $@
+endif # DOCS
+endif # TOOLS
+
+EXTRA_DIST = \
+ $(man_MANS) \
+ LICENSE-MIT \
+ codegen/LICENSE \
+ codegen/LICENSE-MPL-RabbitMQ \
+ codegen/Makefile \
+ codegen/README.extensions.md \
+ codegen/amqp-rabbitmq-0.8.json \
+ codegen/amqp-rabbitmq-0.9.1.json \
+ codegen/amqp_codegen.py \
+ codegen/demo_extension.json \
+ codegen/license_info \
+ debian \
+ librabbitmq/codegen.py \
+ tests/test_tables.expected \
+ 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 \
+ tools/doc/man-date.ent
+
+MOSTLYCLEANFILES = \
+ $(man_MANS) \
+ tools/doc/man-date.ent
-squeakyclean: maintainer-clean
- rm -f Makefile.in librabbitmq/Makefile.in tests/Makefile.in examples/Makefile.in tools/Makefile.in
- rm -f aclocal.m4
- rm -f config.guess config.h.in* config.sub configure
- rm -f depcomp install-sh ltmain.sh missing
- rm -rf codegen
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = librabbitmq.pc
-codegen:
- mkdir -p $@
- cp -r "$(top_srcdir)/$(AMQP_CODEGEN_DIR)"/* $@
- $(MAKE) -C $@ clean
+clean-local:
+ -$(MAKE) -C codegen clean
-EXTRA_DIST=codegen debian LICENSE-MIT
+distclean-local:
+ -$(MAKE) -C codegen distclean
diff --git a/NEWS b/NEWS
deleted file mode 100644
index e69de29..0000000
--- a/NEWS
+++ /dev/null
diff --git a/README b/README
deleted file mode 100644
index c5974e3..0000000
--- a/README
+++ /dev/null
@@ -1,137 +0,0 @@
-# RabbitMQ C AMQP client library
-
-## Introduction
-
-This is a C-language AMQP client library for use with AMQP servers
-speaking protocol versions 0-9-1.
-
- - <http://www.rabbitmq.com/>
- - <http://www.amqp.org/>
- - <http://hg.rabbitmq.com/rabbitmq-c>
-
-Announcements regarding the library are periodically made on the
-RabbitMQ mailing list and on the RabbitMQ blog.
-
- - <http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss>
- - <http://www.rabbitmq.com/blog/>
-
-## Retrieving the code
-
-In addition to the source code for this library, you will require a
-copy of `rabbitmq-codegen`. Here is a short `sh` script for retrieving
-the necessary pieces:
-
- git clone https://github.com/rabbitmq/rabbitmq-codegen/
- git clone https://github.com/alanxz/rabbitmq-c
-
-You will also need a recent python with the simplejson module
-installed, and the GNU autotools (autoconf, automake, libtool etc)
-or as an alternative CMake
-
-## Building the code
-
-# Using autoconf
-
-Once you have all the prerequisites, change to the `rabbitmq-c`
-directory and run
-
- autoreconf -i
-
-to run the GNU autotools and generate the configure script, followed
-by
-
- ./configure
- make
-
-to build the `librabbitmq` library and the example programs.
-
-# Using cmake
-
-You will need CMake: http://cmake.org/
-
-You will need a working python install in your path.
-
-If you would like the build system to fetch the rabbitmq-codegen
-automatically you will need to have a working git install in your
-path. Otherwise you will need to checkout the rabbitmq-codegen as
-stated above.
-
-Create a binary directory in a sibling directory from the directory
-you cloned the rabbitmq-c repository
-
- mkdir bin-rabbitmq-c
-
-Run CMake in the binary directory
-
- cmake /path/to/source/directory
-
-Build it:
-
-* On linux: `make`
-* On win32: `nmake` or `msbuild`, or open it in visual studio and
- build from there
-
-Things you can pass to cmake to change the build:
-
-* `-DRABBITMQ_CODEGEN_DIR=/path/to/rabbitmq-codegen/checkout` - if you
- have your codegen directory in a different place [Default is
- sibiling directory to source]
-* `-DFETCH_CODEGEN_FROM_GIT=ON` - if you want cmake to fetch the
- rabbitmq-codegen from https://github.com/rabbitmq/rabbitmq-codegen
- at build time. If this option is selected `-DRABBITMQ_CODEGEN_DIR`
- will be ignored [Default is off]
-* `-DCODEGEN_GIT_TAG=rabbitmq_v2_5_1` - specifies the tag to check out
- if using the `-DFETCH_CODEGEN_FROM_GIT` option above. [Default is
- `rabbitmq_v2_5_1`]
-* `-DBUILD_TOOLS=OFF` build the programs in the tools directory
- [Default is ON if the POPT library can be found]
-
-Other interesting flags to pass to CMake (see cmake docs for more info)
-
-* `-DCMAKE_BUILD_TYPE` - specify the type of build (Debug or Release)
-* `-DCMAKE_INSTALL_PREFIX` - specify where the install target puts files
-
-## Running the examples
-
-Arrange for a RabbitMQ or other AMQP server to be running on
-`localhost` at TCP port number 5672.
-
-In one terminal, run
-
- ./examples/amqp_listen localhost 5672 amq.direct test
-
-In another terminal,
-
- ./examples/amqp_sendstring localhost 5672 amq.direct test "hello world"
-
-You should see output similar to the following in the listener's
-terminal window:
-
- Result 1
- Frame type 1, channel 1
- Method AMQP_BASIC_DELIVER_METHOD
- Delivery 1, exchange amq.direct routingkey test
- Content-type: text/plain
- ----
- 00000000: 68 65 6C 6C 6F 20 77 6F : 72 6C 64 hello world
- 0000000B:
-
-## Writing applications using `librabbitmq`
-
-Please see the `examples` directory for short examples of the use of
-the `librabbitmq` library.
-
-### Threading
-
-You cannot share a socket, an `amqp_connection_state_t`, or a channel
-between threads using `librabbitmq`. The `librabbitmq` library is
-built with event-driven, single-threaded applications in mind, and
-does not yet cater to any of the requirements of `pthread`ed
-applications.
-
-Your applications instead should open an AMQP connection (and an
-associated socket, of course) per thread. If your program needs to
-access an AMQP connection or any of its channels from more than one
-thread, it is entirely responsible for designing and implementing an
-appropriate locking scheme. It will generally be much simpler to have
-a connection exclusive to each thread that needs AMQP service.
diff --git a/README.windows b/README-win32.md
index afa338a..afa338a 100644
--- a/README.windows
+++ b/README-win32.md
diff --git a/README.md b/README.md
index 100b938..92fd1a5 120000..100644
--- a/README.md
+++ b/README.md
@@ -1 +1,139 @@
-README \ No newline at end of file
+# RabbitMQ C AMQP client library
+
+## Introduction
+
+This is a C-language AMQP client library for use with AMQP servers
+speaking protocol versions 0-9-1.
+
+ - <http://www.rabbitmq.com/>
+ - <http://www.amqp.org/>
+ - <http://github.com/alanxz/rabbitmq-c>
+
+Announcements regarding the library are periodically made on the
+RabbitMQ mailing list and on the RabbitMQ blog.
+
+ - <http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss>
+ - <http://www.rabbitmq.com/blog/>
+
+## Retrieving the code
+
+In addition to the source code for this library, you will require a
+copy of `rabbitmq-codegen`, which resides in the `codegen` directory
+as a git submodule. To update the submodule(s):
+
+ git clone git://github.com/alanxz/rabbitmq-c.git
+ cd rabbitmq-c
+ git submodule init
+ git submodule update
+
+You will also need a recent python with the simplejson module
+installed, and the GNU autotools (autoconf, automake, libtool etc.),
+or as an alternative CMake.
+
+## Building the code
+
+### Using autoconf
+
+Once you have all the prerequisites, change to the `rabbitmq-c`
+directory and run
+
+ autoreconf -i
+
+to run the GNU autotools and generate the configure script, followed
+by
+
+ ./configure
+ make
+
+to build the `librabbitmq` library and the example programs.
+
+### Using cmake
+
+You will need CMake: http://cmake.org/
+
+You will need a working python install in your path.
+
+If you would like the build system to fetch the rabbitmq-codegen
+automatically you will need to have a working git install in your
+path. Otherwise you will need to checkout the rabbitmq-codegen as
+stated above.
+
+Create a binary directory in a sibling directory from the directory
+you cloned the rabbitmq-c repository
+
+ mkdir bin-rabbitmq-c
+
+Run CMake in the binary directory
+
+ cmake /path/to/source/directory
+
+Build it:
+
+* On linux: `make`
+* On win32: `nmake` or `msbuild`, or open it in visual studio and
+ build from there
+
+Things you can pass to cmake to change the build:
+
+* `-DRABBITMQ_CODEGEN_DIR=/path/to/rabbitmq-codegen/checkout` - if you
+ have your codegen directory in a different place [Default is
+ sibiling directory to source]
+* `-DFETCH_CODEGEN_FROM_GIT=ON` - if you want cmake to fetch the
+ rabbitmq-codegen from https://github.com/rabbitmq/rabbitmq-codegen
+ at build time. If this option is selected `-DRABBITMQ_CODEGEN_DIR`
+ will be ignored [Default is off]
+* `-DCODEGEN_GIT_TAG=rabbitmq_v2_5_1` - specifies the tag to check out
+ if using the `-DFETCH_CODEGEN_FROM_GIT` option above. [Default is
+ `rabbitmq_v2_5_1`]
+* `-DBUILD_TOOLS=OFF` build the programs in the tools directory
+ [Default is ON if the POPT library can be found]
+
+Other interesting flags to pass to CMake (see cmake docs for more info)
+
+* `-DCMAKE_BUILD_TYPE` - specify the type of build (Debug or Release)
+* `-DCMAKE_INSTALL_PREFIX` - specify where the install target puts files
+
+## Running the examples
+
+Arrange for a RabbitMQ or other AMQP server to be running on
+`localhost` at TCP port number 5672.
+
+In one terminal, run
+
+ ./examples/amqp_listen localhost 5672 amq.direct test
+
+In another terminal,
+
+ ./examples/amqp_sendstring localhost 5672 amq.direct test "hello world"
+
+You should see output similar to the following in the listener's
+terminal window:
+
+ Result 1
+ Frame type 1, channel 1
+ Method AMQP_BASIC_DELIVER_METHOD
+ Delivery 1, exchange amq.direct routingkey test
+ Content-type: text/plain
+ ----
+ 00000000: 68 65 6C 6C 6F 20 77 6F : 72 6C 64 hello world
+ 0000000B:
+
+## Writing applications using `librabbitmq`
+
+Please see the `examples` directory for short examples of the use of
+the `librabbitmq` library.
+
+### Threading
+
+You cannot share a socket, an `amqp_connection_state_t`, or a channel
+between threads using `librabbitmq`. The `librabbitmq` library is
+built with event-driven, single-threaded applications in mind, and
+does not yet cater to any of the requirements of `pthread`ed
+applications.
+
+Your applications instead should open an AMQP connection (and an
+associated socket, of course) per thread. If your program needs to
+access an AMQP connection or any of its channels from more than one
+thread, it is entirely responsible for designing and implementing an
+appropriate locking scheme. It will generally be much simpler to have
+a connection exclusive to each thread that needs AMQP service.
diff --git a/TestCInline.cmake b/cmake/TestCInline.cmake
index 4fdd4c5..4fdd4c5 100644
--- a/TestCInline.cmake
+++ b/cmake/TestCInline.cmake
diff --git a/codegen b/codegen
new file mode 160000
+Subproject 4e97f731cdd7ad6b246b3fb9bbc081be7877b40
diff --git a/configure.ac b/configure.ac
index e6aac32..211858e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,166 +1,148 @@
-AC_INIT([librabbitmq],[0.0.1],[support@rabbitmq.com])
-AC_CONFIG_SRCDIR(librabbitmq/codegen.py)
-AM_INIT_AUTOMAKE
-
-AC_CONFIG_HEADER([config.h])
-
-dnl Program checks
+AC_PREREQ([2.59])
+
+# Library versioning
+# Making releases:
+# micro_version += 1
+# interface_age += 1
+# If functions have been added or backward-compatibility has been broken:
+# interface_age = 0
+m4_define([major_version], [0])
+m4_define([minor_version], [2])
+m4_define([micro_version], [0])
+m4_define([interface_age], [0])
+
+AC_INIT([rabbitmq-c], [major_version.minor_version.micro_version],
+ [https://github.com/alanxz/rabbitmq-c/issues], [librabbitmq],
+ [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
-AC_PROG_CC
-
-dnl Library checks
-AC_LIBTOOL_WIN32_DLL
-AM_PROG_LIBTOOL
-dnl Header-file checks
-AC_HEADER_STDC
+# Initialize Libtool
+LT_PREREQ([2.2])
+LT_INIT([disable-static win32-dll])
-if test "x$GCC" = "xyes"; then
- dnl Only use -Wall if we have gcc
- if ! echo "$CFLAGS" | grep "\-Wall" 2> /dev/null ; then
- CFLAGS="$CFLAGS -Wall"
- fi
-fi
+# Program checks
+m4_ifdef([AC_PROG_CC_C99], [AC_PROG_CC_C99],
+ [AC_MSG_WARN([Attempt c99 workaround for old versions of autoconf])
+ AC_PROG_CC
+ AX_TRY_CFLAGS([-std=c99], [AX_CFLAGS([-std=c99])])])
-dnl Detect the kind of host we're building for
+# Environment setup
AC_CANONICAL_HOST
-windows=no
-case "${host}" in
-*-*-mingw*)
- windows=yes
- ;;
-esac
-AM_CONDITIONAL(WINDOWS, test "x$windows" = xyes)
-AS_IF([test "x$windows" = xyes],
- [AC_DEFINE([WINDOWS], [1], [Define to 1 if on Windows.])]
-)
-
-AM_CONDITIONAL(GCC, test "x$GCC" = xyes)
-
-# Detect how to declare inline functions. Because we will sometimes
-# use "-ansi -pedantic" with gcc, we need to make sure the result will
-# work in that context.
-orig_cflags="$CFLAGS"
-AS_IF([test "x$GCC" = "xyes"], [CFLAGS="$CFLAGS -ansi -pedantic"])
-AC_C_INLINE
-CFLAGS="$orig_cflags"
-
AC_C_BIGENDIAN
+AC_C_INLINE
-dnl Decide which API abstraction layer to use
-PLATFORM_DIR=unix
-if test "x$windows" = xyes ; then
- PLATFORM_DIR=windows
-fi
-AC_SUBST(PLATFORM_DIR)
-
-dnl Enable -m64 if we were asked to do so
-AC_ARG_ENABLE(64-bit,
-[ --enable-64-bit produce 64-bit library],
-[CFLAGS="$CFLAGS -m64"; LDFLAGS="$LDFLAGS -m64"],
-)
-
-AC_MSG_CHECKING(location of AMQP codegen directory)
-for d in ../rabbitmq-codegen codegen ; do
- AMQP_CODEGEN_DIR="$d"
- test -d "$srcdir/$AMQP_CODEGEN_DIR" && break
-done
-AMQP_SPEC_JSON_PATH="$AMQP_CODEGEN_DIR/amqp-rabbitmq-0.9.1.json"
-
-if test -f "$srcdir/$AMQP_SPEC_JSON_PATH"
-then
- AC_MSG_RESULT($AMQP_CODEGEN_DIR)
-else
- AC_MSG_ERROR(could not find AMQP spec file at "'$AMQP_SPEC_JSON_PATH'")
-fi
-
-AC_MSG_CHECKING(finding a python with simplejson installed)
-found_python=no
-checkPython() {
- if test "$found_python" = "yes"
- then
- return
- fi
- PYTHON=$1
- if $PYTHON -c 'import json' 2>/dev/null \
- || $PYTHON -c 'import simplejson' 2>/dev/null
- then
- found_python=yes
- AC_MSG_RESULT($PYTHON)
- fi
-}
-checkPython python
-checkPython python2.6
-checkPython python2.5
-if test "$found_python" = "no"
-then
- AC_MSG_ERROR(could not find a python that can 'import simplejson')
-fi
-
-AC_SUBST(AMQP_CODEGEN_DIR)
-AC_SUBST(AMQP_SPEC_JSON_PATH)
-AC_SUBST(PYTHON)
-
-dnl Decide which extra win32 libs we need, and handle other special
-dnl cases when building with the Microsoft compiler
-EXTRA_LIBS=
-USE_MISINTTYPES=
-AS_IF([test "x$windows" = xyes],
- [
- AS_IF([test "x$GCC" = xyes],
- [EXTRA_LIBS="-lws2_32 $EXTRA_LIBS"],
- [
- EXTRA_LIBS="ws2_32.lib $EXTRA_LIBS"
- USE_MSINTTYPES=yes
- ])
- ])
-
-AC_SUBST(EXTRA_LIBS)
-AM_CONDITIONAL(USE_MSINTTYPES, test "x$USE_MSINTTYPES" != "x")
-
-dnl Check for libpopt, which we need to build the tools
-AC_ARG_WITH([popt],
- [AS_HELP_STRING([--with-popt], [use the popt library. Needed for tools.])],
- [],
- [with_popt=check])
-
-LIBPOPT=
-AS_IF([test "x$with_popt" != xno],
- [AC_CHECK_LIB([popt], [poptGetContext],
- [AC_SUBST([LIBPOPT], ["-lpopt"])
- AC_DEFINE([HAVE_LIBPOPT], [1], [Define if you have libpopt])
- ],
- [if test "x$with_popt" != xcheck; then
- AC_MSG_FAILURE([--with-popt was given, but test for libpopt failed])
- fi
- ])])
-
-AS_IF([test "x$LIBPOPT" != "x"],
- [AC_CHECK_HEADER([popt.h], [],
- [AC_MSG_FAILURE([You have libpopt, but could not find the popt.h header])])
- ])
-
-AM_CONDITIONAL(TOOLS, test "x$LIBPOPT" != "x")
-
-AC_ARG_WITH([xmlto],
- [AS_HELP_STRING([--with-xmlto], [use the xmlto toolchain. Needed for tools man pages.])],
- [],
- [with_xmlto=check])
-
-XMLTO=
-AS_IF([test "x$with_xmlto" != xno],
- [AC_CHECK_PROG([XMLTO], [xmlto], [xmlto])
- if test "x$with_xmlto" != xcheck; then
- AC_MSG_FAILURE([--with-xmlto was given, but xmlto not found])
- fi])
-
-AM_CONDITIONAL(TOOLS_DOC, test "x$XMLTO" != "x")
-
-AC_OUTPUT(
-Makefile
-librabbitmq/Makefile
-tests/Makefile
-examples/Makefile
-tools/Makefile
-tools/doc/Makefile
-)
+# Set compiler flags
+AX_TRY_CFLAGS([-Wall], [AX_CFLAGS([-Wall])])
+AX_TRY_CFLAGS([-Wextra], [AX_CFLAGS([-Wextra])])
+AX_TRY_CFLAGS([-pedantic], [AX_CFLAGS([-pedantic])])
+AX_TRY_CFLAGS([-Wstrict-prototypes], [AX_CFLAGS([-Wstrict-prototypes])])
+AX_TRY_CFLAGS([-Wcast-align], [AX_CFLAGS([-Wcast-align])])
+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=m4_eval(minor_version + micro_version - interface_age)
+LT_REVISION=interface_age
+LT_AGE=m4_eval(m4_eval(minor_version + micro_version) - interface_age)
+AC_SUBST([LT_CURRENT])
+AC_SUBST([LT_REVISION])
+AC_SUBST([LT_AGE])
+
+# OS setup
+os_unix=no
+os_win32=no
+AS_CASE([$host],
+ [*-*-mingw*],
+ [os_win32=yes],
+ [*],
+ [os_unix=yes])
+AM_CONDITIONAL([OS_UNIX], [test "x$os_unix" = xyes])
+AM_CONDITIONAL([OS_WIN32], [test "x$os_win32" = xyes])
+
+# 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.])])])])
+
+# 64-bit option
+AC_ARG_ENABLE([64-bit],
+ [AS_HELP_STRING([--enable-64-bit],
+ [produce 64-bit library @<:@no@:>@])],
+ [AX_TRY_CFLAGS([-m64], AX_CFLAGS([-m64]))
+ AX_TRY_LDFLAGS([-m64], [AX_LDFLAGS([-m64])])],
+ [enable_64_bit=no])
+
+# Configure python
+pythons="python python2.6 python2.5"
+AC_CACHE_CHECK([for Python with 'json'], [ac_cv_path_PYTHON],
+ [AC_PATH_PROGS_FEATURE_CHECK([PYTHON], [$pythons],
+ [$ac_path_PYTHON -c 'import json' 2>/dev/null
+ AS_IF([test "x$?" = "x0"],
+ [ac_cv_path_PYTHON=$ac_path_PYTHON
+ ac_path_PYTHON_found=:])],
+ [AC_MSG_RESULT([not found])])])
+AC_CACHE_CHECK([for Python with 'simplejson'], [ac_cv_path_PYTHON],
+ [AC_PATH_PROGS_FEATURE_CHECK([PYTHON], [$pythons],
+ [$ac_path_PYTHON -c 'import simplejson' 2>/dev/null
+ AS_IF([test "x$?" = "x0"],
+ [ac_cv_path_PYTHON=$ac_path_PYTHON
+ ac_path_PYTHON_found=:])],
+ [AC_MSG_RESULT([not found])])])
+AS_IF([test "x$ac_cv_path_PYTHON" = "x"],
+ [ac_cv_path_PYTHON=:
+ AC_MSG_WARN([unable to rebuild AMQP framing])])
+AC_SUBST([PYTHON], [$ac_cv_path_PYTHON])
+
+# 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"])
+
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_FILES([
+ librabbitmq.pc
+ Makefile
+])
+AC_OUTPUT
+AC_MSG_RESULT([
+$PACKAGE_NAME build options:
+ Host: $host
+ Version: $VERSION
+ 64-bit: $enable_64_bit
+ Tools: $enable_tools
+ Documentation: $enable_docs
+])
diff --git a/etc/build-ms.sh b/etc/build-ms.sh
index 8567eac..02d024c 100755
--- a/etc/build-ms.sh
+++ b/etc/build-ms.sh
@@ -74,5 +74,5 @@ make
# 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 msinttypes/*.h librabbitmq/amqp.h librabbitmq/amqp_framing.h build/include
+cp -a librabbitmq/win32/msinttypes/*.h librabbitmq/amqp.h librabbitmq/amqp_framing.h build/include
cp -a librabbitmq/*.exp librabbitmq/*.lib build/lib
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index d5ea525..3194e13 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,7 +1,7 @@
include_directories(${LIBRABBITMQ_INCLUDE_DIRS})
if (WIN32)
- set(PLATFORM_DIR windows)
+ set(PLATFORM_DIR win32)
else (WIN32)
set(PLATFORM_DIR unix)
endif (WIN32)
diff --git a/examples/Makefile.am b/examples/Makefile.am
deleted file mode 100644
index bde66bd..0000000
--- a/examples/Makefile.am
+++ /dev/null
@@ -1,33 +0,0 @@
-noinst_PROGRAMS = amqp_sendstring amqp_exchange_declare amqp_listen amqp_producer amqp_consumer amqp_unbind amqp_bind amqp_listenq
-
-# The -I to srcdir's librabbitmq is for the main amqp header
-# files. The -I to builddir's librabbitmq is less obvious; it's for
-# VPATH-based builds: the amqp_framing.h gets generated into the
-# *build* directory, not the source directory.
-AM_CFLAGS = -I$(top_srcdir)/librabbitmq -I$(top_builddir)/librabbitmq
-
-if GCC
-# Because we want to build under Microsoft's C compiler (for which
-# there is apparently no demand for C99 support), it's a good idea
-# to have gcc tell us when we stray from the old standard.
-AM_CFLAGS += -ansi -pedantic
-endif
-
-if USE_MSINTTYPES
-AM_CFLAGS += -I$(top_srcdir)/msinttypes
-endif
-
-AM_LDFLAGS = $(top_builddir)/librabbitmq/librabbitmq.la
-
-noinst_HEADERS = utils.h
-
-COMMON_SOURCES = utils.c $(PLATFORM_DIR)/platform_utils.c
-
-amqp_sendstring_SOURCES = amqp_sendstring.c $(COMMON_SOURCES)
-amqp_exchange_declare_SOURCES = amqp_exchange_declare.c $(COMMON_SOURCES)
-amqp_listen_SOURCES = amqp_listen.c $(COMMON_SOURCES)
-amqp_producer_SOURCES = amqp_producer.c $(COMMON_SOURCES)
-amqp_consumer_SOURCES = amqp_consumer.c $(COMMON_SOURCES)
-amqp_unbind_SOURCES = amqp_unbind.c $(COMMON_SOURCES)
-amqp_bind_SOURCES = amqp_bind.c $(COMMON_SOURCES)
-amqp_listenq_SOURCES = amqp_listenq.c $(COMMON_SOURCES)
diff --git a/examples/amqp_producer.c b/examples/amqp_producer.c
index c149a72..22ac6fa 100644
--- a/examples/amqp_producer.c
+++ b/examples/amqp_producer.c
@@ -57,7 +57,7 @@ static void send_batch(amqp_connection_state_t conn,
char message[256];
amqp_bytes_t message_bytes;
- for (i = 0; i < sizeof(message); i++) {
+ for (i = 0; i < (int)sizeof(message); i++) {
message[i] = i & 0xff;
}
diff --git a/examples/utils.c b/examples/utils.c
index 5adbc2c..871fc2a 100644
--- a/examples/utils.c
+++ b/examples/utils.c
@@ -135,7 +135,7 @@ void amqp_dump(void const *buffer, size_t len) {
int chs[16];
int oldchs[16];
int showed_dots = 0;
- int i;
+ size_t i;
for (i = 0; i < len; i++) {
int ch = buf[i];
diff --git a/examples/windows/platform_utils.c b/examples/win32/platform_utils.c
index ee97238..ee97238 100644
--- a/examples/windows/platform_utils.c
+++ b/examples/win32/platform_utils.c
diff --git a/librabbitmq.pc.in b/librabbitmq.pc.in
new file mode 100644
index 0000000..5d13143
--- /dev/null
+++ b/librabbitmq.pc.in
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Librabbitmq
+Description: An AMQP 0-9-1 client library
+Version: @VERSION@
+Requires:
+Requires.private:
+Libs: -L${libdir} -lrabbitmq
+CFlags: -I${includedir}
diff --git a/librabbitmq/CMakeLists.txt b/librabbitmq/CMakeLists.txt
index 7b1322d..a369c0b 100644
--- a/librabbitmq/CMakeLists.txt
+++ b/librabbitmq/CMakeLists.txt
@@ -43,15 +43,15 @@ SET(CONFIG_CONTENTS "#define VERSION \"0.2\"
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/config.h" ${CONFIG_CONTENTS})
if(WIN32)
- set(SOCKET_IMPL "windows")
+ set(SOCKET_IMPL "win32")
else(WIN32)
set(SOCKET_IMPL "unix")
endif(WIN32)
if(MSVC)
if(MSVC_VERSION LESS 1600)
- set(MSINTTYPES_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/../msinttypes")
- set(STDINT_H_INSTALL_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../msinttypes/stdint.h")
+ set(MSINTTYPES_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/win32/msinttypes")
+ set(STDINT_H_INSTALL_FILE "${CMAKE_CURRENT_SOURCE_DIR}/win32/msinttypes/stdint.h")
endif(MSVC_VERSION LESS 1600)
endif(MSVC)
@@ -68,7 +68,7 @@ set(LIBRABBITMQ_INCLUDE_DIRS
${LIBRABBITMQ_INCLUDE_DIRS}
PARENT_SCOPE)
-add_definitions(-DBUILDING_LIBRABBITMQ)
+add_definitions(-DHAVE_CONFIG_H)
set(RABBITMQ_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/amqp_framing.h
@@ -79,6 +79,12 @@ set(RABBITMQ_SOURCES
${SOCKET_IMPL}/socket.h ${SOCKET_IMPL}/socket.c
)
+add_definitions(-DAMQP_BUILD)
+
+if (NOT BUILD_SHARED_LIBS)
+ add_definitions(-DAMQP_STATIC)
+endif()
+
add_library(rabbitmq ${RABBITMQ_SOURCES})
if(WIN32)
diff --git a/librabbitmq/Makefile.am b/librabbitmq/Makefile.am
deleted file mode 100644
index f5908c3..0000000
--- a/librabbitmq/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-lib_LTLIBRARIES = librabbitmq.la
-
-AM_CFLAGS = -I$(srcdir)/$(PLATFORM_DIR) -DBUILDING_LIBRABBITMQ
-
-if GCC
-# Because we want to build under Microsoft's C compiler (for which
-# there is apparently no demand for C99 support), it's a good idea
-# to have gcc tell us when we stray from the old standard.
-AM_CFLAGS += -ansi -pedantic
-endif
-
-if USE_MSINTTYPES
-AM_CFLAGS += -I$(top_srcdir)/msinttypes
-endif
-
-librabbitmq_la_SOURCES = amqp_mem.c amqp_table.c amqp_connection.c amqp_socket.c amqp_api.c amqp_url.c $(PLATFORM_DIR)/socket.c
-librabbitmq_la_LDFLAGS = -no-undefined
-librabbitmq_la_LIBADD = $(EXTRA_LIBS)
-nodist_librabbitmq_la_SOURCES = amqp_framing.c
-include_HEADERS = amqp_framing.h amqp.h
-noinst_HEADERS = amqp_private.h $(PLATFORM_DIR)/socket.h
-BUILT_SOURCES = amqp_framing.h amqp_framing.c
-CLEANFILES = amqp_framing.h amqp_framing.c
-EXTRA_DIST = \
- codegen.py \
- unix/socket.c unix/socket.h \
- windows/socket.c windows/socket.h
-
-CODEGEN_PY=$(srcdir)/codegen.py
-
-amqp_framing.h: $(top_srcdir)/$(AMQP_SPEC_JSON_PATH) $(CODEGEN_PY)
- PYTHONPATH=$(top_srcdir)/$(AMQP_CODEGEN_DIR) $(PYTHON) $(CODEGEN_PY) header $< $@
-
-amqp_framing.c: $(top_srcdir)/$(AMQP_SPEC_JSON_PATH) $(CODEGEN_PY)
- PYTHONPATH=$(top_srcdir)/$(AMQP_CODEGEN_DIR) $(PYTHON) $(CODEGEN_PY) body $< $@
diff --git a/librabbitmq/amqp.h b/librabbitmq/amqp.h
index 8b91cdc..c8d0127 100644
--- a/librabbitmq/amqp.h
+++ b/librabbitmq/amqp.h
@@ -1,6 +1,3 @@
-#ifndef librabbitmq_amqp_h
-#define librabbitmq_amqp_h
-
/*
* ***** BEGIN LICENSE BLOCK *****
* Version: MIT
@@ -33,23 +30,96 @@
* ***** END LICENSE BLOCK *****
*/
-#include <stdint.h>
-#include <stddef.h>
+#ifndef AMQP_H
+#define AMQP_H
#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef _WIN32
-#ifdef BUILDING_LIBRABBITMQ
-#define RABBITMQ_EXPORT extern __declspec(dllexport)
+#define AMQP_BEGIN_DECLS extern "C" {
+#define AMQP_END_DECLS }
#else
-#define RABBITMQ_EXPORT extern __declspec(dllimport)
+#define AMQP_BEGIN_DECLS
+#define AMQP_END_DECLS
#endif
+
+/** Important API Decorators
+ * AMQP_PUBLIC_FUNCTION - Declares an exportable function
+ * AMQP_PUBLIC_VARIABLE - Declares an exportable variable
+ * AMQP_CALL - Declares the calling convention
+ */
+
+#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
+
+#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
+
+#elif defined(_WIN32) && defined(__MINGW32__)
+# 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(_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
+
+#elif defined(__GNUC__) && __GNUC__ >= 4
+# define AMQP_PUBLIC_FUNCTION \
+ __attribute__ ((visibility ("default")))
+# define AMQP_PUBLIC_VARIABLE \
+ __attribute__ ((visibility ("default"))) extern
+# define AMQP_CALL
#else
-#define RABBITMQ_EXPORT extern
+# define AMQP_PUBLIC_FUNCTION
+# define AMQP_PUBLIC_VARIABLE extern
+# define AMQP_CALL
#endif
+#include <stddef.h>
+#include <stdint.h>
+
+AMQP_BEGIN_DECLS
+
typedef int amqp_boolean_t;
typedef uint32_t amqp_method_number_t;
typedef uint32_t amqp_flags_t;
@@ -223,12 +293,14 @@ typedef enum amqp_sasl_method_enum_ {
/* Opaque struct. */
typedef struct amqp_connection_state_t_ *amqp_connection_state_t;
-RABBITMQ_EXPORT char const *amqp_version(void);
+AMQP_PUBLIC_FUNCTION
+char const *
+AMQP_CALL amqp_version(void);
/* Exported empty data structures */
-RABBITMQ_EXPORT const amqp_bytes_t amqp_empty_bytes;
-RABBITMQ_EXPORT const amqp_table_t amqp_empty_table;
-RABBITMQ_EXPORT const amqp_array_t amqp_empty_array;
+AMQP_PUBLIC_VARIABLE const amqp_bytes_t amqp_empty_bytes;
+AMQP_PUBLIC_VARIABLE const amqp_table_t amqp_empty_table;
+AMQP_PUBLIC_VARIABLE const amqp_array_t amqp_empty_array;
/* Compatibility macros for the above, to avoid the need to update
code written against earlier versions of librabbitmq. */
@@ -236,79 +308,141 @@ RABBITMQ_EXPORT const amqp_array_t amqp_empty_array;
#define AMQP_EMPTY_TABLE amqp_empty_table
#define AMQP_EMPTY_ARRAY amqp_empty_array
-RABBITMQ_EXPORT void init_amqp_pool(amqp_pool_t *pool, size_t pagesize);
-RABBITMQ_EXPORT void recycle_amqp_pool(amqp_pool_t *pool);
-RABBITMQ_EXPORT void empty_amqp_pool(amqp_pool_t *pool);
-
-RABBITMQ_EXPORT void *amqp_pool_alloc(amqp_pool_t *pool, size_t amount);
-RABBITMQ_EXPORT void amqp_pool_alloc_bytes(amqp_pool_t *pool,
- size_t amount, amqp_bytes_t *output);
-
-RABBITMQ_EXPORT amqp_bytes_t amqp_cstring_bytes(char const *cstr);
-RABBITMQ_EXPORT amqp_bytes_t amqp_bytes_malloc_dup(amqp_bytes_t src);
-RABBITMQ_EXPORT amqp_bytes_t amqp_bytes_malloc(size_t amount);
-RABBITMQ_EXPORT void amqp_bytes_free(amqp_bytes_t bytes);
-
-RABBITMQ_EXPORT amqp_connection_state_t amqp_new_connection(void);
-RABBITMQ_EXPORT int amqp_get_sockfd(amqp_connection_state_t state);
-RABBITMQ_EXPORT void amqp_set_sockfd(amqp_connection_state_t state,
- int sockfd);
-RABBITMQ_EXPORT int amqp_tune_connection(amqp_connection_state_t state,
- int channel_max,
- int frame_max,
- int heartbeat);
-RABBITMQ_EXPORT int amqp_get_channel_max(amqp_connection_state_t state);
-RABBITMQ_EXPORT int amqp_destroy_connection(amqp_connection_state_t state);
-
-RABBITMQ_EXPORT int amqp_handle_input(amqp_connection_state_t state,
- amqp_bytes_t received_data,
- amqp_frame_t *decoded_frame);
-
-RABBITMQ_EXPORT amqp_boolean_t amqp_release_buffers_ok(
- amqp_connection_state_t state);
-
-RABBITMQ_EXPORT void amqp_release_buffers(amqp_connection_state_t state);
-
-RABBITMQ_EXPORT void amqp_maybe_release_buffers(amqp_connection_state_t state);
-
-RABBITMQ_EXPORT int amqp_send_frame(amqp_connection_state_t state,
- amqp_frame_t const *frame);
-
-RABBITMQ_EXPORT int amqp_table_entry_cmp(void const *entry1,
- void const *entry2);
-
-RABBITMQ_EXPORT int amqp_open_socket(char const *hostname,
- int portnumber);
-
-RABBITMQ_EXPORT int amqp_send_header(amqp_connection_state_t state);
-
-RABBITMQ_EXPORT amqp_boolean_t amqp_frames_enqueued(
- amqp_connection_state_t state);
-
-RABBITMQ_EXPORT int amqp_simple_wait_frame(amqp_connection_state_t state,
- amqp_frame_t *decoded_frame);
-
-RABBITMQ_EXPORT 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);
-
-RABBITMQ_EXPORT int amqp_send_method(amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_method_number_t id,
- void *decoded);
-
-RABBITMQ_EXPORT 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);
-
-RABBITMQ_EXPORT 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);
+AMQP_PUBLIC_FUNCTION
+void
+AMQP_CALL init_amqp_pool(amqp_pool_t *pool, size_t pagesize);
+
+AMQP_PUBLIC_FUNCTION
+void
+AMQP_CALL recycle_amqp_pool(amqp_pool_t *pool);
+
+AMQP_PUBLIC_FUNCTION
+void
+AMQP_CALL empty_amqp_pool(amqp_pool_t *pool);
+
+AMQP_PUBLIC_FUNCTION
+void *
+AMQP_CALL amqp_pool_alloc(amqp_pool_t *pool, size_t amount);
+
+AMQP_PUBLIC_FUNCTION
+void
+AMQP_CALL amqp_pool_alloc_bytes(amqp_pool_t *pool, size_t amount, amqp_bytes_t *output);
+
+AMQP_PUBLIC_FUNCTION
+amqp_bytes_t
+AMQP_CALL amqp_cstring_bytes(char const *cstr);
+
+AMQP_PUBLIC_FUNCTION
+amqp_bytes_t
+AMQP_CALL amqp_bytes_malloc_dup(amqp_bytes_t src);
+
+AMQP_PUBLIC_FUNCTION
+amqp_bytes_t
+AMQP_CALL amqp_bytes_malloc(size_t amount);
+
+AMQP_PUBLIC_FUNCTION
+void
+AMQP_CALL amqp_bytes_free(amqp_bytes_t bytes);
+
+AMQP_PUBLIC_FUNCTION
+amqp_connection_state_t
+AMQP_CALL amqp_new_connection(void);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_get_sockfd(amqp_connection_state_t state);
+
+AMQP_PUBLIC_FUNCTION
+void
+AMQP_CALL amqp_set_sockfd(amqp_connection_state_t state, int sockfd);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_tune_connection(amqp_connection_state_t state,
+ int channel_max,
+ int frame_max,
+ int heartbeat);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_get_channel_max(amqp_connection_state_t state);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_destroy_connection(amqp_connection_state_t state);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_handle_input(amqp_connection_state_t state,
+ amqp_bytes_t received_data,
+ amqp_frame_t *decoded_frame);
+
+AMQP_PUBLIC_FUNCTION
+amqp_boolean_t
+AMQP_CALL amqp_release_buffers_ok(amqp_connection_state_t state);
+
+AMQP_PUBLIC_FUNCTION
+void
+AMQP_CALL amqp_release_buffers(amqp_connection_state_t state);
+
+AMQP_PUBLIC_FUNCTION
+void
+AMQP_CALL amqp_maybe_release_buffers(amqp_connection_state_t state);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_send_frame(amqp_connection_state_t state, amqp_frame_t const *frame);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_table_entry_cmp(void const *entry1, void const *entry2);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_open_socket(char const *hostname, int portnumber);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_send_header(amqp_connection_state_t state);
+
+AMQP_PUBLIC_FUNCTION
+amqp_boolean_t
+AMQP_CALL amqp_frames_enqueued(amqp_connection_state_t state);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_simple_wait_frame(amqp_connection_state_t state,
+ amqp_frame_t *decoded_frame);
+
+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);
+
+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);
+
+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_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);
/*
* The API methods corresponding to most synchronous AMQP methods
@@ -323,48 +457,49 @@ RABBITMQ_EXPORT void *amqp_simple_rpc_decoded(amqp_connection_state_t state,
* generally do NOT update this per-connection-global amqp_rpc_reply_t
* instance.
*/
-RABBITMQ_EXPORT amqp_rpc_reply_t amqp_get_rpc_reply(
- amqp_connection_state_t state);
+AMQP_PUBLIC_FUNCTION
+amqp_rpc_reply_t
+AMQP_CALL amqp_get_rpc_reply(amqp_connection_state_t state);
-RABBITMQ_EXPORT 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_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, ...);
struct amqp_basic_properties_t_;
-RABBITMQ_EXPORT 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,
- struct amqp_basic_properties_t_ const *properties,
- amqp_bytes_t body);
-
-RABBITMQ_EXPORT amqp_rpc_reply_t amqp_channel_close(
- amqp_connection_state_t state,
- amqp_channel_t channel,
- int code);
-RABBITMQ_EXPORT amqp_rpc_reply_t amqp_connection_close(
- amqp_connection_state_t state,
- int code);
-
-RABBITMQ_EXPORT int amqp_basic_ack(amqp_connection_state_t state,
- amqp_channel_t channel,
- uint64_t delivery_tag,
- amqp_boolean_t multiple);
-
-RABBITMQ_EXPORT 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);
-
-RABBITMQ_EXPORT int amqp_basic_reject(amqp_connection_state_t state,
- amqp_channel_t channel,
- uint64_t delivery_tag,
- amqp_boolean_t requeue);
+
+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);
+
+AMQP_PUBLIC_FUNCTION
+amqp_rpc_reply_t
+AMQP_CALL amqp_channel_close(amqp_connection_state_t state, amqp_channel_t channel,
+ int code);
+
+AMQP_PUBLIC_FUNCTION
+amqp_rpc_reply_t
+AMQP_CALL amqp_connection_close(amqp_connection_state_t state, int code);
+
+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);
+
+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_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);
/*
* Can be used to see if there is data still in the buffer, if so
@@ -373,8 +508,9 @@ RABBITMQ_EXPORT int amqp_basic_reject(amqp_connection_state_t state,
*
* Possibly amqp_frames_enqueued should be used for this?
*/
-RABBITMQ_EXPORT amqp_boolean_t amqp_data_in_buffer(
- amqp_connection_state_t state);
+AMQP_PUBLIC_FUNCTION
+amqp_boolean_t
+AMQP_CALL amqp_data_in_buffer(amqp_connection_state_t state);
/*
* Get the error string for the given error code.
@@ -382,16 +518,18 @@ RABBITMQ_EXPORT amqp_boolean_t amqp_data_in_buffer(
* The returned string resides on the heap; the caller is responsible
* for freeing it.
*/
-RABBITMQ_EXPORT char *amqp_error_string(int err);
+AMQP_PUBLIC_FUNCTION
+char *
+AMQP_CALL amqp_error_string(int err);
-RABBITMQ_EXPORT int amqp_decode_table(amqp_bytes_t encoded,
- amqp_pool_t *pool,
- amqp_table_t *output,
- size_t *offset);
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_decode_table(amqp_bytes_t encoded, amqp_pool_t *pool,
+ amqp_table_t *output, size_t *offset);
-RABBITMQ_EXPORT int amqp_encode_table(amqp_bytes_t encoded,
- amqp_table_t *input,
- size_t *offset);
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_encode_table(amqp_bytes_t encoded, amqp_table_t *input, size_t *offset);
struct amqp_connection_info {
char *user;
@@ -401,15 +539,16 @@ struct amqp_connection_info {
int port;
};
-RABBITMQ_EXPORT void amqp_default_connection_info(
- struct amqp_connection_info *parsed);
-RABBITMQ_EXPORT int amqp_parse_url(char *url,
- struct amqp_connection_info *parsed);
+AMQP_PUBLIC_FUNCTION
+void
+AMQP_CALL amqp_default_connection_info(struct amqp_connection_info *parsed);
-#ifdef __cplusplus
-}
-#endif
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_parse_url(char *url, struct amqp_connection_info *parsed);
+
+AMQP_END_DECLS
#include <amqp_framing.h>
-#endif
+#endif /* AMQP_H */
diff --git a/librabbitmq/amqp_api.c b/librabbitmq/amqp_api.c
index 621e71b..f011354 100644
--- a/librabbitmq/amqp_api.c
+++ b/librabbitmq/amqp_api.c
@@ -30,19 +30,17 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <stdarg.h>
-
-#include "amqp.h"
-#include "amqp_framing.h"
#include "amqp_private.h"
-
#include <assert.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
static const char *client_error_strings[ERROR_MAX] = {
"could not allocate memory", /* ERROR_NO_MEMORY */
@@ -141,9 +139,8 @@ int amqp_basic_publish(amqp_connection_state_t state,
return res;
body_offset = 0;
- while (1) {
- int remaining = body.len - body_offset;
- assert(remaining >= 0);
+ while (body_offset < body.len) {
+ size_t remaining = body.len - body_offset;
if (remaining == 0)
break;
diff --git a/librabbitmq/amqp_connection.c b/librabbitmq/amqp_connection.c
index fc99862..561d496 100644
--- a/librabbitmq/amqp_connection.c
+++ b/librabbitmq/amqp_connection.c
@@ -30,15 +30,16 @@
* ***** END LICENSE BLOCK *****
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <assert.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
-#include "amqp.h"
-#include "amqp_framing.h"
#include "amqp_private.h"
+#include <assert.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#define INITIAL_FRAME_POOL_PAGE_SIZE 65536
#define INITIAL_DECODING_POOL_PAGE_SIZE 131072
@@ -47,7 +48,7 @@
#define ENFORCE_STATE(statevec, statenum) \
{ \
amqp_connection_state_t _check_state = (statevec); \
- int _wanted_state = (statenum); \
+ 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, \
diff --git a/librabbitmq/amqp_mem.c b/librabbitmq/amqp_mem.c
index 429d423..d1cf2ad 100644
--- a/librabbitmq/amqp_mem.c
+++ b/librabbitmq/amqp_mem.c
@@ -30,15 +30,17 @@
* ***** END LICENSE BLOCK *****
*/
-#include <stdlib.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "amqp_private.h"
+#include <assert.h>
+#include <stdint.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <stdint.h>
#include <sys/types.h>
-#include <assert.h>
-
-#include "amqp.h"
-#include "config.h"
char const *amqp_version(void) {
return VERSION; /* defined in config.h */
diff --git a/librabbitmq/amqp_private.h b/librabbitmq/amqp_private.h
index 7cfb65c..67d5fdd 100644
--- a/librabbitmq/amqp_private.h
+++ b/librabbitmq/amqp_private.h
@@ -33,7 +33,13 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
+
+#include "amqp.h"
+#include "amqp_framing.h"
+#include <string.h>
/* Error numbering: Because of differences in error numbering on
* different platforms, we want to keep error numbers opaque for
@@ -57,7 +63,23 @@
#define ERROR_BAD_AMQP_URL 8
#define ERROR_MAX 8
-extern char *amqp_os_error_string(int err);
+/* GCC attributes */
+#if __GNUC__ > 2 | (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+#define AMQP_NORETURN \
+ __attribute__ ((__noreturn__))
+#else
+#define AMQP_NORETURN
+#endif
+
+#if __GNUC__ >= 4
+#define AMQP_PRIVATE \
+ __attribute__ ((visibility ("hidden")))
+#else
+#define AMQP_PRIVATE
+#endif
+
+char *
+amqp_os_error_string(int err);
#include "socket.h"
@@ -253,6 +275,8 @@ static inline int amqp_decode_bytes(amqp_bytes_t encoded, size_t *offset,
}
}
-extern void amqp_abort(const char *fmt, ...);
+AMQP_NORETURN
+void
+amqp_abort(const char *fmt, ...);
#endif
diff --git a/librabbitmq/amqp_socket.c b/librabbitmq/amqp_socket.c
index d7c523e..6b9486c 100644
--- a/librabbitmq/amqp_socket.c
+++ b/librabbitmq/amqp_socket.c
@@ -30,6 +30,11 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "amqp_private.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -37,11 +42,6 @@
#include <stdarg.h>
#include <assert.h>
-#include "amqp.h"
-#include "amqp_framing.h"
-#include "amqp_private.h"
-
-
int amqp_open_socket(char const *hostname,
int portnumber)
{
@@ -368,7 +368,7 @@ static int amqp_login_inner(amqp_connection_state_t state,
{
int res;
amqp_method_t method;
- uint32_t server_frame_max;
+ int server_frame_max;
uint16_t server_channel_max;
uint16_t server_heartbeat;
diff --git a/librabbitmq/amqp_table.c b/librabbitmq/amqp_table.c
index 3f78a5b..4e0de12 100644
--- a/librabbitmq/amqp_table.c
+++ b/librabbitmq/amqp_table.c
@@ -30,15 +30,16 @@
* ***** END LICENSE BLOCK *****
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
-#include "amqp.h"
#include "amqp_private.h"
-
#include <assert.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#define INITIAL_ARRAY_SIZE 16
#define INITIAL_TABLE_SIZE 16
@@ -409,7 +410,7 @@ int amqp_table_entry_cmp(void const *entry1, void const *entry2) {
amqp_table_entry_t const *p2 = (amqp_table_entry_t const *) entry2;
int d;
- int minlen;
+ size_t minlen;
minlen = p1->key.len;
if (p2->key.len < minlen) minlen = p2->key.len;
diff --git a/librabbitmq/amqp_url.c b/librabbitmq/amqp_url.c
index 476d5dc..eb29ca8 100644
--- a/librabbitmq/amqp_url.c
+++ b/librabbitmq/amqp_url.c
@@ -30,14 +30,15 @@
* ***** END LICENSE BLOCK *****
*/
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
-#include "amqp.h"
-#include "amqp_framing.h"
#include "amqp_private.h"
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
void amqp_default_connection_info(struct amqp_connection_info *ci)
{
diff --git a/librabbitmq/codegen.py b/librabbitmq/codegen.py
index 67255a6..42d039d 100644
--- a/librabbitmq/codegen.py
+++ b/librabbitmq/codegen.py
@@ -250,7 +250,7 @@ def methodApiPrototype(m):
args.append(" ")
args.append(n)
- return "%s_ok_t *%s(amqp_connection_state_t state, amqp_channel_t channel%s)" % (fn, fn, ''.join(args))
+ return "AMQP_PUBLIC_FUNCTION %s_ok_t * AMQP_CALL %s(amqp_connection_state_t state, amqp_channel_t channel%s)" % (fn, fn, ''.join(args))
AmqpMethod.apiPrototype = methodApiPrototype
@@ -366,15 +366,16 @@ def genErl(spec):
* ***** END LICENSE BLOCK *****
*/
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
-#include "amqp.h"
-#include "amqp_framing.h"
#include "amqp_private.h"
#include "socket.h"
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
"""
print """
@@ -551,14 +552,12 @@ def genHrl(spec):
methods = spec.allMethods()
print """/* Autogenerated code. Do not edit. */
-#ifndef librabbitmq_amqp_framing_h
-#define librabbitmq_amqp_framing_h
+#ifndef AMQP_FRAMING_H
+#define AMQP_FRAMING_H
#include <amqp.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+AMQP_BEGIN_DECLS
"""
print "#define AMQP_PROTOCOL_VERSION_MAJOR %d" % (spec.major)
print "#define AMQP_PROTOCOL_VERSION_MINOR %d" % (spec.minor)
@@ -571,24 +570,47 @@ extern "C" {
print """/* Function prototypes. */
-extern char const *amqp_constant_name(int constantNumber);
-extern amqp_boolean_t amqp_constant_is_hard_error(int constantNumber);
-RABBITMQ_EXPORT char const *amqp_method_name(amqp_method_number_t methodNumber);
-extern amqp_boolean_t amqp_method_has_content(amqp_method_number_t methodNumber);
-extern int amqp_decode_method(amqp_method_number_t methodNumber,
- amqp_pool_t *pool,
- amqp_bytes_t encoded,
- void **decoded);
-extern int amqp_decode_properties(uint16_t class_id,
- amqp_pool_t *pool,
- amqp_bytes_t encoded,
- void **decoded);
-extern int amqp_encode_method(amqp_method_number_t methodNumber,
- void *decoded,
- amqp_bytes_t encoded);
-extern int amqp_encode_properties(uint16_t class_id,
- void *decoded,
- amqp_bytes_t encoded);
+AMQP_PUBLIC_FUNCTION
+char const *
+AMQP_CALL amqp_constant_name(int constantNumber);
+
+AMQP_PUBLIC_FUNCTION
+amqp_boolean_t
+AMQP_CALL amqp_constant_is_hard_error(int constantNumber);
+
+AMQP_PUBLIC_FUNCTION
+char const *
+AMQP_CALL amqp_method_name(amqp_method_number_t methodNumber);
+
+AMQP_PUBLIC_FUNCTION
+amqp_boolean_t
+AMQP_CALL amqp_method_has_content(amqp_method_number_t methodNumber);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_decode_method(amqp_method_number_t methodNumber,
+ amqp_pool_t *pool,
+ amqp_bytes_t encoded,
+ void **decoded);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_decode_properties(uint16_t class_id,
+ amqp_pool_t *pool,
+ amqp_bytes_t encoded,
+ void **decoded);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_encode_method(amqp_method_number_t methodNumber,
+ void *decoded,
+ amqp_bytes_t encoded);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_encode_properties(uint16_t class_id,
+ void *decoded,
+ amqp_bytes_t encoded);
"""
print "/* Method field records. */\n"
@@ -625,14 +647,12 @@ extern int amqp_encode_properties(uint16_t class_id,
for m in methods:
if m.isSynchronous and apiMethodInfo.get(m.fullName()) is not False:
- print "RABBITMQ_EXPORT %s;" % (m.apiPrototype(),)
+ print "%s;" % (m.apiPrototype(),)
print """
-#ifdef __cplusplus
-}
-#endif
+AMQP_END_DECLS
-#endif"""
+#endif /* AMQP_FRAMING_H */"""
def generateErl(specPath):
genErl(AmqpSpec(specPath))
diff --git a/librabbitmq/unix/socket.c b/librabbitmq/unix/socket.c
index 5d339e6..cb8a2b9 100644
--- a/librabbitmq/unix/socket.c
+++ b/librabbitmq/unix/socket.c
@@ -30,19 +30,31 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <unistd.h>
+#include "amqp_private.h"
+#include "socket.h"
#include <fcntl.h>
#include <stdint.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <unistd.h>
-#include "amqp.h"
-#include "amqp_private.h"
-#include "socket.h"
+int
+amqp_socket_init(void)
+{
+ return 0;
+}
+
+int
+amqp_socket_error(void)
+{
+ return errno | ERROR_CATEGORY_OS;
+}
int amqp_socket_socket(int domain, int type, int proto)
{
diff --git a/librabbitmq/unix/socket.h b/librabbitmq/unix/socket.h
index af86ffb..ff6fa73 100644
--- a/librabbitmq/unix/socket.h
+++ b/librabbitmq/unix/socket.h
@@ -34,28 +34,25 @@
*/
#include <errno.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <sys/uio.h>
-#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
-static inline int amqp_socket_init(void)
-{
- return 0;
-}
+int
+amqp_socket_init(void);
-extern int amqp_socket_socket(int domain, int type, int proto);
+int
+amqp_socket_socket(int domain, int type, int proto);
+
+int
+amqp_socket_error(void);
#define amqp_socket_setsockopt setsockopt
#define amqp_socket_close close
#define amqp_socket_writev writev
-static inline int amqp_socket_error()
-{
- return errno | ERROR_CATEGORY_OS;
-}
-
#endif
diff --git a/msinttypes/inttypes.h b/librabbitmq/win32/msinttypes/inttypes.h
index 4b3828a..4b3828a 100644
--- a/msinttypes/inttypes.h
+++ b/librabbitmq/win32/msinttypes/inttypes.h
diff --git a/msinttypes/stdint.h b/librabbitmq/win32/msinttypes/stdint.h
index d02608a..d02608a 100644
--- a/msinttypes/stdint.h
+++ b/librabbitmq/win32/msinttypes/stdint.h
diff --git a/librabbitmq/windows/socket.c b/librabbitmq/win32/socket.c
index faf6819..43b919b 100644
--- a/librabbitmq/windows/socket.c
+++ b/librabbitmq/win32/socket.c
@@ -33,15 +33,15 @@
/* See http://msdn.microsoft.com/en-us/library/ms737629%28VS.85%29.aspx */
#define WIN32_LEAN_AND_MEAN
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
-#include <windows.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "amqp.h"
#include "amqp_private.h"
#include "socket.h"
+#include <stdint.h>
+#include <stdlib.h>
+#include <windows.h>
static int called_wsastartup;
@@ -74,3 +74,28 @@ char *amqp_os_error_string(int err)
LocalFree(msg);
return copy;
}
+
+int
+amqp_socket_setsockopt(int sock, int level, int optname,
+ const void *optval, size_t optlen)
+{
+ /* the winsock setsockopt function has its 4th argument as a
+ const char * */
+ return setsockopt(sock, level, optname, (const char *)optval, optlen);
+}
+
+int
+amqp_socket_writev(int sock, struct iovec *iov, int nvecs)
+{
+ DWORD ret;
+ if (WSASend(sock, (LPWSABUF)iov, nvecs, &ret, 0, NULL, NULL) == 0)
+ return ret;
+ else
+ return -1;
+}
+
+int
+amqp_socket_error(void)
+{
+ return WSAGetLastError() | ERROR_CATEGORY_OS;
+}
diff --git a/librabbitmq/win32/socket.h b/librabbitmq/win32/socket.h
new file mode 100644
index 0000000..4572410
--- /dev/null
+++ b/librabbitmq/win32/socket.h
@@ -0,0 +1,60 @@
+#ifndef librabbitmq_windows_socket_h
+#define librabbitmq_windows_socket_h
+
+/*
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MIT
+ *
+ * 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 <winsock2.h>
+
+/* same as WSABUF */
+struct iovec {
+ u_long iov_len;
+ void *iov_base;
+};
+
+int
+amqp_socket_init(void);
+
+#define amqp_socket_socket socket
+#define amqp_socket_close closesocket
+
+int
+amqp_socket_setsockopt(int sock, int level, int optname, const void *optval,
+ size_t optlen);
+
+int
+amqp_socket_writev(int sock, struct iovec *iov, int nvecs);
+
+int
+amqp_socket_error(void);
+
+#endif
diff --git a/librabbitmq/windows/socket.h b/librabbitmq/windows/socket.h
deleted file mode 100644
index 0665b3a..0000000
--- a/librabbitmq/windows/socket.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef librabbitmq_windows_socket_h
-#define librabbitmq_windows_socket_h
-
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MIT
- *
- * 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 <winsock2.h>
-
-extern int amqp_socket_init(void);
-
-#define amqp_socket_socket socket
-#define amqp_socket_close closesocket
-
-static inline int amqp_socket_setsockopt(int sock, int level, int optname,
- const void *optval, size_t optlen)
-{
- /* the winsock setsockopt function has its 4th argument as a
- const char * */
- return setsockopt(sock, level, optname, (const char *)optval, optlen);
-}
-
-/* same as WSABUF */
-struct iovec {
- u_long iov_len;
- void *iov_base;
-};
-
-static inline int amqp_socket_writev(int sock, struct iovec *iov, int nvecs)
-{
- DWORD ret;
- if (WSASend(sock, (LPWSABUF)iov, nvecs, &ret, 0, NULL, NULL) == 0)
- return ret;
- else
- return -1;
-}
-
-static inline int amqp_socket_error()
-{
- return WSAGetLastError() | ERROR_CATEGORY_OS;
-}
-
-#endif
diff --git a/m4/.gitignore b/m4/.gitignore
new file mode 100644
index 0000000..38066dd
--- /dev/null
+++ b/m4/.gitignore
@@ -0,0 +1,5 @@
+libtool.m4
+ltoptions.m4
+ltsugar.m4
+ltversion.m4
+lt~obsolete.m4
diff --git a/m4/cflags.m4 b/m4/cflags.m4
new file mode 100644
index 0000000..015d07b
--- /dev/null
+++ b/m4/cflags.m4
@@ -0,0 +1,59 @@
+# 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 --git a/m4/ldflags.m4 b/m4/ldflags.m4
new file mode 100644
index 0000000..bc07c7b
--- /dev/null
+++ b/m4/ldflags.m4
@@ -0,0 +1,58 @@
+# 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 --git a/m4/popt.m4 b/m4/popt.m4
new file mode 100644
index 0000000..55f4162
--- /dev/null
+++ b/m4/popt.m4
@@ -0,0 +1,73 @@
+# 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 <popt.h>],
+ [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 --git a/tests/Makefile.am b/tests/Makefile.am
deleted file mode 100644
index ac694dc..0000000
--- a/tests/Makefile.am
+++ /dev/null
@@ -1,18 +0,0 @@
-check_PROGRAMS = test_tables test_parse_url
-TESTS = $(check_PROGRAMS)
-EXTRA_DIST = test_tables.expected
-
-AM_CFLAGS = -I$(top_srcdir)/librabbitmq
-
-if GCC
-# Because we want to build under Microsoft's C compiler (for which
-# there is apparently no demand for C99 support), it's a good idea
-# to have gcc tell us when we stray from the old standard.
-AM_CFLAGS += -ansi -pedantic
-endif
-
-if USE_MSINTTYPES
-AM_CFLAGS += -I$(top_srcdir)/msinttypes
-endif
-
-AM_LDFLAGS = $(top_builddir)/librabbitmq/librabbitmq.la
diff --git a/tests/test_parse_url.c b/tests/test_parse_url.c
index 4870e12..a4c5f09 100644
--- a/tests/test_parse_url.c
+++ b/tests/test_parse_url.c
@@ -103,7 +103,7 @@ static void parse_fail(const char *url)
free(s);
}
-int main(int argc, char **argv)
+int main(void)
{
/* From the spec */
parse_success("amqp://user:pass@host:10000/vhost", "user", "pass",
diff --git a/tests/test_tables.c b/tests/test_tables.c
index 363b9f4..e4b0f43 100644
--- a/tests/test_tables.c
+++ b/tests/test_tables.c
@@ -40,6 +40,9 @@
#include <amqp.h>
+#ifdef _MSC_VER
+#define _USE_MATH_DEFINES
+#endif
#include <math.h>
void die(const char *fmt, ...)
@@ -52,8 +55,6 @@ void die(const char *fmt, ...)
abort();
}
-#define M_PI 3.14159265358979323846264338327
-
static void dump_indent(int indent, FILE *out)
{
int i;
@@ -122,7 +123,7 @@ static void dump_value(int indent, amqp_field_value_t v, FILE *out)
case AMQP_FIELD_KIND_BYTES:
fputc(' ', out);
- for (i = 0; i < v.value.bytes.len; i++)
+ for (i = 0; i < (int)v.value.bytes.len; i++)
fprintf(out, "%02x", ((char *) v.value.bytes.bytes)[i]);
fputc('\n', out);
@@ -401,21 +402,14 @@ static void test_table_codec(FILE *out)
#define CHUNK_SIZE 4096
-static int compare_files(const char *f1, const char *f2)
+static int compare_files(FILE *f1_in, FILE *f2_in)
{
- FILE *f1_in;
- FILE *f2_in;
char f1_buf[CHUNK_SIZE];
char f2_buf[CHUNK_SIZE];
int res;
- f1_in = fopen(f1, "r");
- if (f1_in == NULL)
- die("opening %s: %s", f1, strerror(errno));
-
- f2_in = fopen(f2, "r");
- if (f2_in == NULL)
- die("opening %s: %s", f2, strerror(errno));
+ rewind(f1_in);
+ rewind(f2_in);
for (;;) {
size_t f1_got = fread(f1_buf, 1, CHUNK_SIZE, f1_in);
@@ -427,45 +421,44 @@ static int compare_files(const char *f1, const char *f2)
if (f1_got < CHUNK_SIZE || f2_got < CHUNK_SIZE) {
if (f1_got != f2_got)
- res = (f1_got < f2_got ? -1 : 1);
+ res = (f1_got < f2_got ? -1 : 1);
break;
}
}
- fclose(f1_in);
- fclose(f2_in);
-
return res;
}
-const char *expected_file_name = "test_tables.expected";
+const char *expected_file_name = "tests/test_tables.expected";
-int main(int argc, char **argv)
+int main(void)
{
char *srcdir = getenv("srcdir");
- char out_path[L_tmpnam];
- FILE *out = fopen(tmpnam(out_path), "w");
+ FILE *out, *expected = NULL;
char *expected_path;
+ out = tmpfile();
if (out == NULL)
- die("opening %s: %s", out_path, strerror(errno));
+ die("failed to create temporary file: %s", strerror(errno));
test_table_codec(out);
fprintf(out, "----------\n");
test_dump_value(out);
- fclose(out);
-
if (srcdir == NULL)
- die("'srcdir' environment variable not defined");
+ srcdir = "tests";
expected_path = malloc(strlen(srcdir) + strlen(expected_file_name) + 2);
sprintf(expected_path, "%s/%s", srcdir, expected_file_name);
- if (compare_files(expected_path, out_path))
- die("output file did not have expected contents; see %s", out_path);
+ expected = fopen(expected_path, "r");
+ if (!expected)
+ die("failed to open %s: %s", expected_path, strerror(errno));
+
+ if (compare_files(expected, out))
+ die("output file did not have expected contents");
- if (remove(out_path))
- die("deleting %s: %s", out_path, strerror(errno));
+ fclose(out);
+ fclose(expected);
return 0;
}
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 579a3b9..bdeddaf 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -3,7 +3,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${librabbitmq_SOURCE_DIR} ${libr
if (WIN32)
set(PLATFORM_DIR win32)
set(PLATFORM_SRCS
- windows/compat.c
+ win32/compat.c
)
else (WIN32)
set(PLATFORM_DIR unix)
diff --git a/tools/Makefile.am b/tools/Makefile.am
deleted file mode 100644
index 6fa1e4b..0000000
--- a/tools/Makefile.am
+++ /dev/null
@@ -1,31 +0,0 @@
-SUBDIRS=doc
-
-bin_PROGRAMS = amqp-publish amqp-get amqp-consume amqp-declare-queue amqp-delete-queue
-
-# The -I to srcdir's librabbitmq is for the main amqp header
-# files. The -I to builddir's librabbitmq is less obvious; it's for
-# VPATH-based builds: the amqp_framing.h gets generated into the
-# *build* directory, not the source directory.
-AM_CFLAGS = -I$(top_srcdir)/librabbitmq -I$(srcdir)/$(PLATFORM_DIR) -I$(top_builddir)/librabbitmq
-AM_LDFLAGS = $(top_builddir)/librabbitmq/librabbitmq.la
-
-LDADD=$(LIBPOPT)
-
-noinst_HEADERS = common.h $(PLATFORM_DIR)/process.h
-
-COMMON_SOURCES = common.c
-
-if WINDOWS
-COMMON_SOURCES += windows/compat.c
-endif
-
-amqp_publish_SOURCES = publish.c $(COMMON_SOURCES)
-amqp_get_SOURCES = get.c $(COMMON_SOURCES)
-amqp_consume_SOURCES = consume.c $(PLATFORM_DIR)/process.c $(COMMON_SOURCES)
-amqp_declare_queue_SOURCES = declare_queue.c $(COMMON_SOURCES)
-amqp_delete_queue_SOURCES = delete_queue.c $(COMMON_SOURCES)
-
-EXTRA_DIST = \
- unix/process.c unix/process.h \
- windows/process.c windows/process.h \
- windows/compat.c windows/compat.h
diff --git a/tools/common.c b/tools/common.c
index 38df751..2c248b9 100644
--- a/tools/common.c
+++ b/tools/common.c
@@ -30,7 +30,9 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#include <stdio.h>
#include <stdlib.h>
@@ -179,7 +181,7 @@ struct poptOption connect_options[] = {
"the username to login with", "username"},
{"password", 0, POPT_ARG_STRING, &amqp_password, 0,
"the password to login with", "password"},
- { NULL, 0, 0, NULL, 0 }
+ { NULL, '\0', 0, NULL, 0, NULL, NULL }
};
static void init_connection_info(struct amqp_connection_info *ci)
@@ -329,7 +331,8 @@ amqp_bytes_t read_all(int fd)
bytes.len = 0;
for (;;) {
- ssize_t res = read(fd, bytes.bytes+bytes.len, space-bytes.len);
+ ssize_t res = read(fd, (char *)bytes.bytes + bytes.len,
+ space-bytes.len);
if (res == 0)
break;
@@ -358,7 +361,7 @@ void write_all(int fd, amqp_bytes_t data)
die_errno(errno, "write");
data.len -= res;
- data.bytes += res;
+ data.bytes = (char *)data.bytes + res;
}
}
diff --git a/tools/consume.c b/tools/consume.c
index 83a5164..4f79889 100644
--- a/tools/consume.c
+++ b/tools/consume.c
@@ -30,7 +30,9 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#include <stdio.h>
#include <stdlib.h>
@@ -180,7 +182,7 @@ int main(int argc, const char **argv)
"stop consuming after this many messages are consumed",
"limit"},
POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0 }
+ { NULL, '\0', 0, NULL, 0, NULL, NULL }
};
opts = process_options(argc, argv, options,
diff --git a/tools/declare_queue.c b/tools/declare_queue.c
index d6bb9db..fc9524c 100644
--- a/tools/declare_queue.c
+++ b/tools/declare_queue.c
@@ -30,7 +30,9 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#include <stdio.h>
#include <stdlib.h>
@@ -52,7 +54,7 @@ int main(int argc, const char **argv)
{"durable", 'd', POPT_ARG_VAL, &durable, 1,
"declare a durable queue", NULL},
POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0 }
+ { NULL, '\0', 0, NULL, 0, NULL, NULL }
};
process_all_options(argc, argv, options);
diff --git a/tools/delete_queue.c b/tools/delete_queue.c
index e596096..4577d74 100644
--- a/tools/delete_queue.c
+++ b/tools/delete_queue.c
@@ -30,7 +30,9 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#include <stdio.h>
#include <stdlib.h>
@@ -55,7 +57,7 @@ int main(int argc, const char **argv)
{"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, '\0', 0, NULL, 0, NULL, NULL }
};
process_all_options(argc, argv, options);
diff --git a/tools/doc/Makefile.am b/tools/doc/Makefile.am
deleted file mode 100644
index f482d94..0000000
--- a/tools/doc/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-EXTRA_DIST = \
- publish.xml \
- consume.xml \
- get.xml \
- declare_queue.xml \
- delete_queue.xml \
- librabbitmq-tools.xml
-
-if TOOLS_DOC
-man_MANS = \
- amqp-publish.1 \
- amqp-consume.1 \
- amqp-get.1 \
- amqp-declare-queue.1 \
- amqp-delete-queue.1 \
- librabbitmq-tools.7
-MOSTLYCLEANFILES = man-date.ent $(man_MANS)
-
-# automake complains about % pattern rules, and suffix rules don't
-# support multiple dependencies, so we have to expand all these out.
-#
-# Also, 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.
-amqp-publish.1: publish.xml man-date.ent
- $(XMLTO) --skip-validation --searchpath $(CURDIR) man $<
-amqp-consume.1: consume.xml man-date.ent
- $(XMLTO) --skip-validation --searchpath $(CURDIR) man $<
-amqp-get.1: get.xml man-date.ent
- $(XMLTO) --skip-validation --searchpath $(CURDIR) man $<
-amqp-declare-queue.1: declare_queue.xml man-date.ent
- $(XMLTO) --skip-validation --searchpath $(CURDIR) man $<
-amqp-delete-queue.1: delete_queue.xml man-date.ent
- $(XMLTO) --skip-validation --searchpath $(CURDIR) man $<
-librabbitmq-tools.7: librabbitmq-tools.xml man-date.ent
- $(XMLTO) --skip-validation --searchpath $(CURDIR) man $<
-
-man-date.ent:
- date +'%Y-%m-%d' >$@
-
-endif
diff --git a/tools/doc/consume.xml b/tools/doc/amqp-consume.xml
index b5f40d7..b5f40d7 100644
--- a/tools/doc/consume.xml
+++ b/tools/doc/amqp-consume.xml
diff --git a/tools/doc/declare_queue.xml b/tools/doc/amqp-declare-queue.xml
index 0fc0440..0fc0440 100644
--- a/tools/doc/declare_queue.xml
+++ b/tools/doc/amqp-declare-queue.xml
diff --git a/tools/doc/delete_queue.xml b/tools/doc/amqp-delete-queue.xml
index 040a384..040a384 100644
--- a/tools/doc/delete_queue.xml
+++ b/tools/doc/amqp-delete-queue.xml
diff --git a/tools/doc/get.xml b/tools/doc/amqp-get.xml
index 08abe2b..08abe2b 100644
--- a/tools/doc/get.xml
+++ b/tools/doc/amqp-get.xml
diff --git a/tools/doc/publish.xml b/tools/doc/amqp-publish.xml
index e609972..e609972 100644
--- a/tools/doc/publish.xml
+++ b/tools/doc/amqp-publish.xml
diff --git a/tools/get.c b/tools/get.c
index 57ebedb..3e536c7 100644
--- a/tools/get.c
+++ b/tools/get.c
@@ -30,7 +30,9 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#include <stdio.h>
@@ -60,7 +62,7 @@ int main(int argc, const char **argv)
{"queue", 'q', POPT_ARG_STRING, &queue, 0,
"the queue to consume from", "queue"},
POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0 }
+ { NULL, '\0', 0, NULL, 0, NULL, NULL }
};
process_all_options(argc, argv, options);
diff --git a/tools/publish.c b/tools/publish.c
index 57060df..f7e7e77 100644
--- a/tools/publish.c
+++ b/tools/publish.c
@@ -30,7 +30,9 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#include <stdio.h>
#include <stdlib.h>
@@ -77,7 +79,7 @@ int main(int argc, const char **argv)
{"body", 'b', POPT_ARG_STRING, &body, 0,
"specify the message body", "body"},
POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0 }
+ { NULL, '\0', 0, NULL, 0, NULL, NULL }
};
process_all_options(argc, argv, options);
diff --git a/tools/unix/process.c b/tools/unix/process.c
index 1e0d1d6..624f016 100644
--- a/tools/unix/process.c
+++ b/tools/unix/process.c
@@ -30,6 +30,10 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <unistd.h>
#include <errno.h>
#include <spawn.h>
diff --git a/tools/windows/compat.c b/tools/win32/compat.c
index acba42e..07afa9a 100644
--- a/tools/windows/compat.c
+++ b/tools/win32/compat.c
@@ -30,6 +30,10 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
diff --git a/tools/windows/compat.h b/tools/win32/compat.h
index 9b9c96a..9b9c96a 100644
--- a/tools/windows/compat.h
+++ b/tools/win32/compat.h
diff --git a/tools/windows/process.c b/tools/win32/process.c
index 26b9a70..8bc9337 100644
--- a/tools/windows/process.c
+++ b/tools/win32/process.c
@@ -30,6 +30,10 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <io.h>
#include <windows.h>
diff --git a/tools/windows/process.h b/tools/win32/process.h
index c2a8a0d..c2a8a0d 100644
--- a/tools/windows/process.h
+++ b/tools/win32/process.h