summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-05-12 13:08:45 +0100
committerSimon MacMullen <simon@rabbitmq.com>2011-05-12 13:08:45 +0100
commit36a1423f8ad3626303e24ba34abb2ba7429e91bc (patch)
tree9bacec0e0273010e6f44d386ebc4fdfaaafda470
parent11a5577f7c6ee26ec832bc806567e1909449dfc4 (diff)
downloadrabbitmq-c-github-ask-bug24079.tar.gz
Pre-junk. rabbitmq-c is not in fact a plugin.bug24079
-rw-r--r--AUTHORS1
-rw-r--r--COPYING8
-rw-r--r--ChangeLog0
-rw-r--r--INSTALL291
-rw-r--r--LICENSE-GPL-2.0339
-rw-r--r--LICENSE-MPL-RabbitMQ473
-rw-r--r--Makefile.am21
-rw-r--r--NEWS0
-rw-r--r--README88
-rw-r--r--README.windows115
-rw-r--r--THANKS4
-rw-r--r--TODO9
-rw-r--r--configure.ac164
-rw-r--r--debian/amqp-tools.docs3
-rw-r--r--debian/amqp-tools.install3
-rw-r--r--debian/changelog5
-rw-r--r--debian/compat1
-rw-r--r--debian/control29
-rw-r--r--debian/copyright15
-rw-r--r--debian/librabbitmq-dev.docs3
-rw-r--r--debian/librabbitmq-dev.install4
-rw-r--r--debian/librabbitmq.docs3
-rw-r--r--debian/librabbitmq.install1
-rwxr-xr-xdebian/rules24
-rwxr-xr-xetc/build-ms.sh62
-rwxr-xr-xetc/install-mingw.sh78
-rw-r--r--examples/Makefile.am29
-rw-r--r--examples/amqp_bind.c102
-rw-r--r--examples/amqp_consumer.c189
-rw-r--r--examples/amqp_exchange_declare.c97
-rw-r--r--examples/amqp_listen.c189
-rw-r--r--examples/amqp_listenq.c172
-rw-r--r--examples/amqp_producer.c159
-rw-r--r--examples/amqp_sendstring.c111
-rw-r--r--examples/amqp_unbind.c102
-rw-r--r--examples/unix/platform_utils.c69
-rw-r--r--examples/utils.c188
-rw-r--r--examples/utils.h62
-rw-r--r--examples/windows/platform_utils.c66
-rw-r--r--librabbitmq/Makefile.am35
-rw-r--r--librabbitmq/amqp.h478
-rw-r--r--librabbitmq/amqp_api.c489
-rw-r--r--librabbitmq/amqp_connection.c436
-rw-r--r--librabbitmq/amqp_mem.c200
-rw-r--r--librabbitmq/amqp_private.h251
-rw-r--r--librabbitmq/amqp_socket.c497
-rw-r--r--librabbitmq/amqp_table.c441
-rw-r--r--librabbitmq/codegen.py531
-rw-r--r--librabbitmq/unix/socket.c92
-rw-r--r--librabbitmq/unix/socket.h79
-rw-r--r--librabbitmq/windows/socket.c98
-rw-r--r--librabbitmq/windows/socket.h89
-rw-r--r--msinttypes/inttypes.h305
-rw-r--r--msinttypes/stdint.h247
-rw-r--r--tests/Makefile.am16
-rw-r--r--tests/test_tables.c403
-rw-r--r--tests/test_tables.expected90
-rw-r--r--tools/Makefile.am27
-rw-r--r--tools/common.c358
-rw-r--r--tools/common.h89
-rw-r--r--tools/consume.c212
-rw-r--r--tools/declare_queue.c99
-rw-r--r--tools/delete_queue.c99
-rw-r--r--tools/doc/Makefile.am42
-rw-r--r--tools/doc/consume.xml177
-rw-r--r--tools/doc/declare_queue.xml122
-rw-r--r--tools/doc/delete_queue.xml94
-rw-r--r--tools/doc/get.xml95
-rw-r--r--tools/doc/librabbitmq-tools.xml90
-rw-r--r--tools/doc/publish.xml160
-rw-r--r--tools/get.c95
-rw-r--r--tools/publish.c137
-rw-r--r--tools/unix/process.c100
-rw-r--r--tools/unix/process.h57
-rw-r--r--tools/windows/compat.c76
-rw-r--r--tools/windows/compat.h51
-rw-r--r--tools/windows/process.c227
-rw-r--r--tools/windows/process.h59
78 files changed, 0 insertions, 10522 deletions
diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644
index 42f64ba..0000000
--- a/AUTHORS
+++ /dev/null
@@ -1 +0,0 @@
-Tony Garnock-Jones <tonyg@rabbitmq.com>
diff --git a/COPYING b/COPYING
deleted file mode 100644
index 29e03b9..0000000
--- a/COPYING
+++ /dev/null
@@ -1,8 +0,0 @@
-This package, librabbitmq, the RabbitMQ C client, is licensed under
-the MPL and may also be used under the terms of the GPL. For the MPL,
-please see LICENSE-MPL-RabbitMQ. For the GPL, please see
-LICENSE-GPL-2.0. Please see also the license block near the top of
-each source file in the package.
-
-If you have any questions regarding licensing, please contact us at
-info@rabbitmq.com.
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/LICENSE-GPL-2.0 b/LICENSE-GPL-2.0
deleted file mode 100644
index d511905..0000000
--- a/LICENSE-GPL-2.0
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
diff --git a/LICENSE-MPL-RabbitMQ b/LICENSE-MPL-RabbitMQ
deleted file mode 100644
index 2d0a7b1..0000000
--- a/LICENSE-MPL-RabbitMQ
+++ /dev/null
@@ -1,473 +0,0 @@
- MOZILLA PUBLIC LICENSE
- Version 1.1
-
- ---------------
-
-1. Definitions.
-
- 1.0.1. "Commercial Use" means distribution or otherwise making the
- Covered Code available to a third party.
-
- 1.1. "Contributor" means each entity that creates or contributes to
- the creation of Modifications.
-
- 1.2. "Contributor Version" means the combination of the Original
- Code, prior Modifications used by a Contributor, and the Modifications
- made by that particular Contributor.
-
- 1.3. "Covered Code" means the Original Code or Modifications or the
- combination of the Original Code and Modifications, in each case
- including portions thereof.
-
- 1.4. "Electronic Distribution Mechanism" means a mechanism generally
- accepted in the software development community for the electronic
- transfer of data.
-
- 1.5. "Executable" means Covered Code in any form other than Source
- Code.
-
- 1.6. "Initial Developer" means the individual or entity identified
- as the Initial Developer in the Source Code notice required by Exhibit
- A.
-
- 1.7. "Larger Work" means a work which combines Covered Code or
- portions thereof with code not governed by the terms of this License.
-
- 1.8. "License" means this document.
-
- 1.8.1. "Licensable" means having the right to grant, to the maximum
- extent possible, whether at the time of the initial grant or
- subsequently acquired, any and all of the rights conveyed herein.
-
- 1.9. "Modifications" means any addition to or deletion from the
- substance or structure of either the Original Code or any previous
- Modifications. When Covered Code is released as a series of files, a
- Modification is:
- A. Any addition to or deletion from the contents of a file
- containing Original Code or previous Modifications.
-
- B. Any new file that contains any part of the Original Code or
- previous Modifications.
-
- 1.10. "Original Code" means Source Code of computer software code
- which is described in the Source Code notice required by Exhibit A as
- Original Code, and which, at the time of its release under this
- License is not already Covered Code governed by this License.
-
- 1.10.1. "Patent Claims" means any patent claim(s), now owned or
- hereafter acquired, including without limitation, method, process,
- and apparatus claims, in any patent Licensable by grantor.
-
- 1.11. "Source Code" means the preferred form of the Covered Code for
- making modifications to it, including all modules it contains, plus
- any associated interface definition files, scripts used to control
- compilation and installation of an Executable, or source code
- differential comparisons against either the Original Code or another
- well known, available Covered Code of the Contributor's choice. The
- Source Code can be in a compressed or archival form, provided the
- appropriate decompression or de-archiving software is widely available
- for no charge.
-
- 1.12. "You" (or "Your") means an individual or a legal entity
- exercising rights under, and complying with all of the terms of, this
- License or a future version of this License issued under Section 6.1.
- For legal entities, "You" includes any entity which controls, is
- controlled by, or is under common control with You. For purposes of
- this definition, "control" means (a) the power, direct or indirect,
- to cause the direction or management of such entity, whether by
- contract or otherwise, or (b) ownership of more than fifty percent
- (50%) of the outstanding shares or beneficial ownership of such
- entity.
-
-2. Source Code License.
-
- 2.1. The Initial Developer Grant.
- The Initial Developer hereby grants You a world-wide, royalty-free,
- non-exclusive license, subject to third party intellectual property
- claims:
- (a) under intellectual property rights (other than patent or
- trademark) Licensable by Initial Developer to use, reproduce,
- modify, display, perform, sublicense and distribute the Original
- Code (or portions thereof) with or without Modifications, and/or
- as part of a Larger Work; and
-
- (b) under Patents Claims infringed by the making, using or
- selling of Original Code, to make, have made, use, practice,
- sell, and offer for sale, and/or otherwise dispose of the
- Original Code (or portions thereof).
-
- (c) the licenses granted in this Section 2.1(a) and (b) are
- effective on the date Initial Developer first distributes
- Original Code under the terms of this License.
-
- (d) Notwithstanding Section 2.1(b) above, no patent license is
- granted: 1) for code that You delete from the Original Code; 2)
- separate from the Original Code; or 3) for infringements caused
- by: i) the modification of the Original Code or ii) the
- combination of the Original Code with other software or devices.
-
- 2.2. Contributor Grant.
- Subject to third party intellectual property claims, each Contributor
- hereby grants You a world-wide, royalty-free, non-exclusive license
-
- (a) under intellectual property rights (other than patent or
- trademark) Licensable by Contributor, to use, reproduce, modify,
- display, perform, sublicense and distribute the Modifications
- created by such Contributor (or portions thereof) either on an
- unmodified basis, with other Modifications, as Covered Code
- and/or as part of a Larger Work; and
-
- (b) under Patent Claims infringed by the making, using, or
- selling of Modifications made by that Contributor either alone
- and/or in combination with its Contributor Version (or portions
- of such combination), to make, use, sell, offer for sale, have
- made, and/or otherwise dispose of: 1) Modifications made by that
- Contributor (or portions thereof); and 2) the combination of
- Modifications made by that Contributor with its Contributor
- Version (or portions of such combination).
-
- (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
- effective on the date Contributor first makes Commercial Use of
- the Covered Code.
-
- (d) Notwithstanding Section 2.2(b) above, no patent license is
- granted: 1) for any code that Contributor has deleted from the
- Contributor Version; 2) separate from the Contributor Version;
- 3) for infringements caused by: i) third party modifications of
- Contributor Version or ii) the combination of Modifications made
- by that Contributor with other software (except as part of the
- Contributor Version) or other devices; or 4) under Patent Claims
- infringed by Covered Code in the absence of Modifications made by
- that Contributor.
-
-3. Distribution Obligations.
-
- 3.1. Application of License.
- The Modifications which You create or to which You contribute are
- governed by the terms of this License, including without limitation
- Section 2.2. The Source Code version of Covered Code may be
- distributed only under the terms of this License or a future version
- of this License released under Section 6.1, and You must include a
- copy of this License with every copy of the Source Code You
- distribute. You may not offer or impose any terms on any Source Code
- version that alters or restricts the applicable version of this
- License or the recipients' rights hereunder. However, You may include
- an additional document offering the additional rights described in
- Section 3.5.
-
- 3.2. Availability of Source Code.
- Any Modification which You create or to which You contribute must be
- made available in Source Code form under the terms of this License
- either on the same media as an Executable version or via an accepted
- Electronic Distribution Mechanism to anyone to whom you made an
- Executable version available; and if made available via Electronic
- Distribution Mechanism, must remain available for at least twelve (12)
- months after the date it initially became available, or at least six
- (6) months after a subsequent version of that particular Modification
- has been made available to such recipients. You are responsible for
- ensuring that the Source Code version remains available even if the
- Electronic Distribution Mechanism is maintained by a third party.
-
- 3.3. Description of Modifications.
- You must cause all Covered Code to which You contribute to contain a
- file documenting the changes You made to create that Covered Code and
- the date of any change. You must include a prominent statement that
- the Modification is derived, directly or indirectly, from Original
- Code provided by the Initial Developer and including the name of the
- Initial Developer in (a) the Source Code, and (b) in any notice in an
- Executable version or related documentation in which You describe the
- origin or ownership of the Covered Code.
-
- 3.4. Intellectual Property Matters
- (a) Third Party Claims.
- If Contributor has knowledge that a license under a third party's
- intellectual property rights is required to exercise the rights
- granted by such Contributor under Sections 2.1 or 2.2,
- Contributor must include a text file with the Source Code
- distribution titled "LEGAL" which describes the claim and the
- party making the claim in sufficient detail that a recipient will
- know whom to contact. If Contributor obtains such knowledge after
- the Modification is made available as described in Section 3.2,
- Contributor shall promptly modify the LEGAL file in all copies
- Contributor makes available thereafter and shall take other steps
- (such as notifying appropriate mailing lists or newsgroups)
- reasonably calculated to inform those who received the Covered
- Code that new knowledge has been obtained.
-
- (b) Contributor APIs.
- If Contributor's Modifications include an application programming
- interface and Contributor has knowledge of patent licenses which
- are reasonably necessary to implement that API, Contributor must
- also include this information in the LEGAL file.
-
- (c) Representations.
- Contributor represents that, except as disclosed pursuant to
- Section 3.4(a) above, Contributor believes that Contributor's
- Modifications are Contributor's original creation(s) and/or
- Contributor has sufficient rights to grant the rights conveyed by
- this License.
-
- 3.5. Required Notices.
- You must duplicate the notice in Exhibit A in each file of the Source
- Code. If it is not possible to put such notice in a particular Source
- Code file due to its structure, then You must include such notice in a
- location (such as a relevant directory) where a user would be likely
- to look for such a notice. If You created one or more Modification(s)
- You may add your name as a Contributor to the notice described in
- Exhibit A. You must also duplicate this License in any documentation
- for the Source Code where You describe recipients' rights or ownership
- rights relating to Covered Code. You may choose to offer, and to
- charge a fee for, warranty, support, indemnity or liability
- obligations to one or more recipients of Covered Code. However, You
- may do so only on Your own behalf, and not on behalf of the Initial
- Developer or any Contributor. You must make it absolutely clear than
- any such warranty, support, indemnity or liability obligation is
- offered by You alone, and You hereby agree to indemnify the Initial
- Developer and every Contributor for any liability incurred by the
- Initial Developer or such Contributor as a result of warranty,
- support, indemnity or liability terms You offer.
-
- 3.6. Distribution of Executable Versions.
- You may distribute Covered Code in Executable form only if the
- requirements of Section 3.1-3.5 have been met for that Covered Code,
- and if You include a notice stating that the Source Code version of
- the Covered Code is available under the terms of this License,
- including a description of how and where You have fulfilled the
- obligations of Section 3.2. The notice must be conspicuously included
- in any notice in an Executable version, related documentation or
- collateral in which You describe recipients' rights relating to the
- Covered Code. You may distribute the Executable version of Covered
- Code or ownership rights under a license of Your choice, which may
- contain terms different from this License, provided that You are in
- compliance with the terms of this License and that the license for the
- Executable version does not attempt to limit or alter the recipient's
- rights in the Source Code version from the rights set forth in this
- License. If You distribute the Executable version under a different
- license You must make it absolutely clear that any terms which differ
- from this License are offered by You alone, not by the Initial
- Developer or any Contributor. You hereby agree to indemnify the
- Initial Developer and every Contributor for any liability incurred by
- the Initial Developer or such Contributor as a result of any such
- terms You offer.
-
- 3.7. Larger Works.
- You may create a Larger Work by combining Covered Code with other code
- not governed by the terms of this License and distribute the Larger
- Work as a single product. In such a case, You must make sure the
- requirements of this License are fulfilled for the Covered Code.
-
-4. Inability to Comply Due to Statute or Regulation.
-
- If it is impossible for You to comply with any of the terms of this
- License with respect to some or all of the Covered Code due to
- statute, judicial order, or regulation then You must: (a) comply with
- the terms of this License to the maximum extent possible; and (b)
- describe the limitations and the code they affect. Such description
- must be included in the LEGAL file described in Section 3.4 and must
- be included with all distributions of the Source Code. Except to the
- extent prohibited by statute or regulation, such description must be
- sufficiently detailed for a recipient of ordinary skill to be able to
- understand it.
-
-5. Application of this License.
-
- This License applies to code to which the Initial Developer has
- attached the notice in Exhibit A and to related Covered Code.
-
-6. Versions of the License.
-
- 6.1. New Versions.
- Netscape Communications Corporation ("Netscape") may publish revised
- and/or new versions of the License from time to time. Each version
- will be given a distinguishing version number.
-
- 6.2. Effect of New Versions.
- Once Covered Code has been published under a particular version of the
- License, You may always continue to use it under the terms of that
- version. You may also choose to use such Covered Code under the terms
- of any subsequent version of the License published by Netscape. No one
- other than Netscape has the right to modify the terms applicable to
- Covered Code created under this License.
-
- 6.3. Derivative Works.
- If You create or use a modified version of this License (which you may
- only do in order to apply it to code which is not already Covered Code
- governed by this License), You must (a) rename Your license so that
- the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
- "MPL", "NPL" or any confusingly similar phrase do not appear in your
- license (except to note that your license differs from this License)
- and (b) otherwise make it clear that Your version of the license
- contains terms which differ from the Mozilla Public License and
- Netscape Public License. (Filling in the name of the Initial
- Developer, Original Code or Contributor in the notice described in
- Exhibit A shall not of themselves be deemed to be modifications of
- this License.)
-
-7. DISCLAIMER OF WARRANTY.
-
- COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
- DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
- THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
- IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
- YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
- COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
- OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
- ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
-
-8. TERMINATION.
-
- 8.1. This License and the rights granted hereunder will terminate
- automatically if You fail to comply with terms herein and fail to cure
- such breach within 30 days of becoming aware of the breach. All
- sublicenses to the Covered Code which are properly granted shall
- survive any termination of this License. Provisions which, by their
- nature, must remain in effect beyond the termination of this License
- shall survive.
-
- 8.2. If You initiate litigation by asserting a patent infringement
- claim (excluding declatory judgment actions) against Initial Developer
- or a Contributor (the Initial Developer or Contributor against whom
- You file such action is referred to as "Participant") alleging that:
-
- (a) such Participant's Contributor Version directly or indirectly
- infringes any patent, then any and all rights granted by such
- Participant to You under Sections 2.1 and/or 2.2 of this License
- shall, upon 60 days notice from Participant terminate prospectively,
- unless if within 60 days after receipt of notice You either: (i)
- agree in writing to pay Participant a mutually agreeable reasonable
- royalty for Your past and future use of Modifications made by such
- Participant, or (ii) withdraw Your litigation claim with respect to
- the Contributor Version against such Participant. If within 60 days
- of notice, a reasonable royalty and payment arrangement are not
- mutually agreed upon in writing by the parties or the litigation claim
- is not withdrawn, the rights granted by Participant to You under
- Sections 2.1 and/or 2.2 automatically terminate at the expiration of
- the 60 day notice period specified above.
-
- (b) any software, hardware, or device, other than such Participant's
- Contributor Version, directly or indirectly infringes any patent, then
- any rights granted to You by such Participant under Sections 2.1(b)
- and 2.2(b) are revoked effective as of the date You first made, used,
- sold, distributed, or had made, Modifications made by that
- Participant.
-
- 8.3. If You assert a patent infringement claim against Participant
- alleging that such Participant's Contributor Version directly or
- indirectly infringes any patent where such claim is resolved (such as
- by license or settlement) prior to the initiation of patent
- infringement litigation, then the reasonable value of the licenses
- granted by such Participant under Sections 2.1 or 2.2 shall be taken
- into account in determining the amount or value of any payment or
- license.
-
- 8.4. In the event of termination under Sections 8.1 or 8.2 above,
- all end user license agreements (excluding distributors and resellers)
- which have been validly granted by You or any distributor hereunder
- prior to termination shall survive termination.
-
-9. LIMITATION OF LIABILITY.
-
- UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
- (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
- DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
- OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
- ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
- CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
- WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
- COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
- INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
- LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
- RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
- PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
- EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
- THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
-
-10. U.S. GOVERNMENT END USERS.
-
- The Covered Code is a "commercial item," as that term is defined in
- 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
- software" and "commercial computer software documentation," as such
- terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
- C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
- all U.S. Government End Users acquire Covered Code with only those
- rights set forth herein.
-
-11. MISCELLANEOUS.
-
- This License represents the complete agreement concerning subject
- matter hereof. If any provision of this License is held to be
- unenforceable, such provision shall be reformed only to the extent
- necessary to make it enforceable. This License shall be governed by
- California law provisions (except to the extent applicable law, if
- any, provides otherwise), excluding its conflict-of-law provisions.
- With respect to disputes in which at least one party is a citizen of,
- or an entity chartered or registered to do business in the United
- States of America, any litigation relating to this License shall be
- subject to the jurisdiction of the Federal Courts of the Northern
- District of California, with venue lying in Santa Clara County,
- California, with the losing party responsible for costs, including
- without limitation, court costs and reasonable attorneys' fees and
- expenses. The application of the United Nations Convention on
- Contracts for the International Sale of Goods is expressly excluded.
- Any law or regulation which provides that the language of a contract
- shall be construed against the drafter shall not apply to this
- License.
-
-12. RESPONSIBILITY FOR CLAIMS.
-
- As between Initial Developer and the Contributors, each party is
- responsible for claims and damages arising, directly or indirectly,
- out of its utilization of rights under this License and You agree to
- work with Initial Developer and Contributors to distribute such
- responsibility on an equitable basis. Nothing herein is intended or
- shall be deemed to constitute any admission of liability.
-
-13. MULTIPLE-LICENSED CODE.
-
- Initial Developer may designate portions of the Covered Code as
- "Multiple-Licensed". "Multiple-Licensed" means that the Initial
- Developer permits you to utilize portions of the Covered Code under
- Your choice of the NPL or the alternative licenses, if any, specified
- by the Initial Developer in the file described in Exhibit A.
-
-EXHIBIT A -Mozilla Public License.
-
- ``The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in
- compliance with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS"
- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- License for the specific language governing rights and limitations
- under the License.
-
- The Original Code is RabbitMQ.
-
- The Initial Developers of the Original Code are LShift Ltd,
- Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
-
- Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
- Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
- are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
- Technologies LLC, and Rabbit Technologies Ltd.
-
- Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- Ltd. Portions created by Cohesive Financial Technologies LLC are
- Copyright (C) 2007-2009 Cohesive Financial Technologies
- LLC. Portions created by Rabbit Technologies Ltd are Copyright
- (C) 2007-2009 Rabbit Technologies Ltd.
-
- All Rights Reserved.
-
- Contributor(s): ______________________________________.''
-
- [NOTE: The text of this Exhibit A may differ slightly from the text of
- the notices in the Source Code files of the Original Code. You should
- use the text of this Exhibit A rather than the text found in the
- Original Code Source Code for Your Modifications.]
-
-
-
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index d5bac3f..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-if TOOLS
-TOOLS_SUBDIR=tools
-else
-TOOLS_SUBDIR=
-endif
-
-SUBDIRS=librabbitmq tests examples $(TOOLS_SUBDIR)
-
-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
-
-codegen:
- mkdir -p $@
- cp -r "$(top_srcdir)/$(AMQP_CODEGEN_DIR)"/* $@
- $(MAKE) -C $@ clean
-
-EXTRA_DIST=codegen debian LICENSE-MPL-RabbitMQ LICENSE-GPL-2.0
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 6ae88dc..0000000
--- a/README
+++ /dev/null
@@ -1,88 +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:
-
- hg clone http://hg.rabbitmq.com/rabbitmq-codegen/
- hg clone http://hg.rabbitmq.com/rabbitmq-c/
-
-You will also need a recent python with the simplejson module
-installed, and the GNU autotools (autoconf, automake, libtool etc).
-
-## Building the code
-
-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.
-
-## 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.windows
deleted file mode 100644
index 836a3be..0000000
--- a/README.windows
+++ /dev/null
@@ -1,115 +0,0 @@
-# Using rabbitmq-c on Windows
-
-There are two approaches to building rabbitmq-c under Windows:
-
-- Build using the MinGW/MSYS (MinGW/MSYS is a port of the GNU
- toolchain and utilities to Windows, including the gcc compiler).
- The results of building in this way are native Windows DLLs and
- EXEs, and can be used without having MinGW installed. The drawback
- to this approach is that you cannot safely call the resulting
- librabbitmq DLL from code compiled with Microsoft's C compiler. The
- advantage is that the whole of rabbitmq-c can be built under
- Windows, including the tools.
-
-- Build using Microsoft's C compiler. You will still need to install
- MinGW/MSYS in order to run the rabbitmq-c build scripts, but
- Microsoft's compiler is used to compile the code. The resulting
- librabbitmq DLL can be used from code compiled with Microsoft's C
- compiler (i.e. code developed in Visual Studio). The downside to
- this approach is that the rabbitmq-c tools cannot be built, due to
- dependencies on other libraries.
-
-
-## Common steps
-
-With either of the approaches, the initial steps are the same: You
-should download and install MinGW/MSYS and Python.
-
-Installing installing the relevant parts of MinGW/MSYS can be fairly
-time consuming - there are dozens of files to be downloaded and
-unpacked. To make it easier, we provide a bash script that automates
-this process, in `rabbitmq-c/etc/install-mingw.sh`. You can run this
-script under cygwin or Linux (obviously if you use Linux you'll need
-to transfer the resulting files over to the Windows machine).
-
-Note that some MinGW packages are .tar.lzma files, so it requires a
-system with the xz compression utility and a tar that supports the -J
-option. Recent cygwin and Linux distros should be fine here.
-
-Run the install-mingw.sh script specifying the destination directory,
-e.g.
-
- $ etc/install-mingw.sh mingw
-
-This will download all the required MinGW/MSYS packages, and unpack
-them into the `mingw` directory.
-
-The other prerequisite for the rabbitmq-c build is Python. The
-Windows installer from python.org for the latest 2.x version of Python
-will do fine.
-
-You will also need to copy the source code for rabbitmq-c and
-rabbitmq-codegen somewhere under your `mingw` directory.
-
-Then to start the MSYS bash shell, open a `cmd` window, and ensure
-that both the MinGW bin directory and the python install directory are
-in the path, e.g.
-
- C:\>set PATH=%PATH%;C:\mingw\bin;C:\Python27
-
-Then start bash, and run the following mount command (substituting the
-Windows path of your MinGW install if it isn't `C:\mingw`):
-
- C:\>bash
- bash-3.1$ mount 'C:\mingw' /mingw
-
-Finally, go to wherever you copied the rabbitmq-c source.
-
- bash-3.1$ cd /rabbitmq-c
-
-
-## Building rabbitmq-c with Microsoft's C compiler
-
-The Microsoft C/C++ compiler is part of MS Visual Studio, including
-the gratis Visual Studio Express. Visual Studio 2005 and higher are
-known to work.
-
-Start by following the steps in the previous section. The GNU build
-tools have limited support for Microsoft toolchain, but the
-install-mingw.sh script will install versions of the packages that are
-known to be suitable. In particular, only libtool version 2.2.7a is
-known to work; later versions have been reported to introduce
-problems.
-
-Once you are at the bash prompt, build rabbitmq-c by running the
-script in `rabbitmq-c/etc/build-ms.sh`:
-
- bash-3.1$ etc/build-ms.sh
-
-You should end up with a directory `build` containing the librabbitmq
-DLL, the corresponding .lib file, and header files. These are
-sufficient to create applications using librabbitmq within Visual
-Studio.
-
-
-## Building rabbitmq-c with gcc
-
-There is no script to build rabbitmq-c with gcc, but it is as
-documented in the README file:
-
- bash-3.1$ autoreconf -i && ./configure && make
-
-You can run the resulting tool EXEs without needing the rest of MinGW. To do
-this, copy the following files into a single directory:
-
-- rabbitmq-c/tools/.libs/*.exe
-
-- rabbitmq-c/librabbitmq/.libs/librabbitmq-0.dll
-
-- /bin/libpopt-0.dll
-
-- /bin/libiconv-2.dll
-
-- /bin/libintl-8.dll
-
-
diff --git a/THANKS b/THANKS
deleted file mode 100644
index 996c140..0000000
--- a/THANKS
+++ /dev/null
@@ -1,4 +0,0 @@
-Thank-you to the following people for their contributions to the
-codebase:
-
- - Scott Brooks / Epic Advertising <scott.brooks@epicadvertising.com>
diff --git a/TODO b/TODO
deleted file mode 100644
index 179d297..0000000
--- a/TODO
+++ /dev/null
@@ -1,9 +0,0 @@
-Deal with version-mismatch-header received from the server
-
-Cope with unknown frame types better. Currently it gets horribly
-confused about frame lengths.
-
-Make client brutal by default, killing the program on any amqp
-error. Only if the user disables this behaviour will the user get to
-deal with error conditions themselves. Make use of amqp_rpc_reply
-consistent (i.e. universal), and rename it something like amqp_errno.
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index ec782fb..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,164 +0,0 @@
-AC_INIT([librabbitmq],[0.0.1],[tonyg@rabbitmq.com])
-AC_CONFIG_SRCDIR(librabbitmq/codegen.py)
-AM_INIT_AUTOMAKE
-
-AC_CONFIG_HEADER([config.h])
-
-dnl Program checks
-AC_GNU_SOURCE
-AC_PROG_CC
-
-dnl Library checks
-AC_LIBTOOL_WIN32_DLL
-AM_PROG_LIBTOOL
-
-dnl Header-file checks
-AC_HEADER_STDC
-
-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
-
-dnl Detect the kind of host we're building for
-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"
-
-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 "$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
-)
diff --git a/debian/amqp-tools.docs b/debian/amqp-tools.docs
deleted file mode 100644
index c9f23af..0000000
--- a/debian/amqp-tools.docs
+++ /dev/null
@@ -1,3 +0,0 @@
-COPYING
-LICENSE-MPL-RabbitMQ
-LICENSE-GPL-2.0
diff --git a/debian/amqp-tools.install b/debian/amqp-tools.install
deleted file mode 100644
index 03e1052..0000000
--- a/debian/amqp-tools.install
+++ /dev/null
@@ -1,3 +0,0 @@
-debian/tmp/usr/bin/* usr/bin
-debian/tmp/usr/share/man/man1/* usr/share/man/man1
-debian/tmp/usr/share/man/man7/* usr/share/man/man7
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index b41f67e..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,5 +0,0 @@
-librabbitmq (1.0-1) unstable; urgency=low
-
- * Initial release
-
- -- Tony Garnock-Jones <tonyg@lshift.net> Tue, 14 Jul 2009 04:42:37 +0100
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 7ed6ff8..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 54c2c06..0000000
--- a/debian/control
+++ /dev/null
@@ -1,29 +0,0 @@
-Source: librabbitmq
-Section: libs
-Priority: extra
-Maintainer: Tony Garnock-Jones <tonyg@lshift.net>
-Build-Depends: debhelper (>= 7), autoconf, automake, libtool, python (>= 2.5), python-simplejson, libpopt-dev, xmlto
-Standards-Version: 3.8.1
-Homepage: http://www.rabbitmq.com/
-Vcs-Browser: http://hg.rabbitmq.com/rabbitmq-c
-
-Package: librabbitmq
-Architecture: any
-Section: libs
-Priority: extra
-Depends:
-Description: An AMQP client library written in C
-
-Package: librabbitmq-dev
-Architecture: any
-Section: libdevel
-Priority: extra
-Depends: librabbitmq (= ${binary:Version}), libc-dev
-Description: developer's libraries and docs for librabbitmq
-
-Package: amqp-tools
-Architecture: any
-Section: net
-Priority: extra
-Depends: librabbitmq (= ${binary:Version}), ${shlibs:Depends}
-Description: Command-line utilities for interacting with AMQP servers
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index adf8a2a..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,15 +0,0 @@
-This package was debianized by Tony Garnock-Jones <tonyg@rabbitmq.com> on
-Tue, 14 Jul 2009 04:42:37 +0100.
-
-Upstream Author: Tony Garnock-Jones <tonyg@lshift.net>
-
-Copyright: 2009 Tony Garnock-Jones, 2009 LShift Ltd.
-
-License: This package, librabbitmq, the RabbitMQ C client, is licensed
-under the MPL and may also be used under the terms of the GPL. For the
-MPL, please see LICENSE-MPL-RabbitMQ. For the GPL, please see
-LICENSE-GPL-2.0. Please see also the license block near the top of
-each source file in the package.
-
-If you have any questions regarding licensing, please contact us at
-info@rabbitmq.com.
diff --git a/debian/librabbitmq-dev.docs b/debian/librabbitmq-dev.docs
deleted file mode 100644
index c9f23af..0000000
--- a/debian/librabbitmq-dev.docs
+++ /dev/null
@@ -1,3 +0,0 @@
-COPYING
-LICENSE-MPL-RabbitMQ
-LICENSE-GPL-2.0
diff --git a/debian/librabbitmq-dev.install b/debian/librabbitmq-dev.install
deleted file mode 100644
index b4f0bfd..0000000
--- a/debian/librabbitmq-dev.install
+++ /dev/null
@@ -1,4 +0,0 @@
-debian/tmp/usr/include/*.h usr/include
-debian/tmp/usr/lib/*.a usr/lib
-debian/tmp/usr/lib/*.la usr/lib
-debian/tmp/usr/lib/*.so usr/lib
diff --git a/debian/librabbitmq.docs b/debian/librabbitmq.docs
deleted file mode 100644
index c9f23af..0000000
--- a/debian/librabbitmq.docs
+++ /dev/null
@@ -1,3 +0,0 @@
-COPYING
-LICENSE-MPL-RabbitMQ
-LICENSE-GPL-2.0
diff --git a/debian/librabbitmq.install b/debian/librabbitmq.install
deleted file mode 100644
index 84bc663..0000000
--- a/debian/librabbitmq.install
+++ /dev/null
@@ -1 +0,0 @@
-debian/tmp/usr/lib/*.so.* usr/lib
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 10327f2..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/make -f
-
-build: build-stamp
-build-stamp:
- dh build
- touch build-stamp
-
-clean:
- dh clean
- rm -f build-stamp
- rm -f install-stamp
-
-install: build install-stamp
-install-stamp:
- dh install
- touch install-stamp
-
-binary-arch: install
- dh binary-arch
-
-binary-indep: install
- dh binary-indep
-
-binary: binary-arch binary-indep
diff --git a/etc/build-ms.sh b/etc/build-ms.sh
deleted file mode 100755
index 4a70b35..0000000
--- a/etc/build-ms.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-
-# Build rabbitmq-c using Microsoft's C compiler
-
-set -e
-
-# Locate the necessary lib and include directories
-
-drive=$(echo "$SYSTEMDRIVE" | sed 's|^\([A-Za-z]\):$|/\1|')
-
-for vsvers in 10.0 9.0 8 ; do
- vsdir="$drive/Program Files/Microsoft Visual Studio $vsvers"
- [ -x "$vsdir/VC/bin/cl.exe" ] && break
-
- vsdir="$drive/Program Files (x86)/Microsoft Visual Studio $vsvers"
- [ -x "$vsdir/VC/bin/cl.exe" ] && break
-
- vsdir=
-done
-
-if [ -z "$vsdir" ] ; then
- echo "Couldn't find suitable Visual Studio installation"
- exit 1
-fi
-
-echo "Using Visual Studio install at $vsdir"
-
-for sdkpath in "Microsoft SDKs/Windows/"{v7.0A,v6.0A} "Microsoft Visual Studio 8/VC/PlatformSDK" ; do
- sdkdir="$drive/Program Files/$sdkpath"
- [ -d "$sdkdir/lib" -a -d "$sdkdir/include" ] && break
-
- sdkdir="$drive/Program Files (x86)/$sdkpath"
- [ -d "$sdkdir/lib" -a -d "$sdkdir/include" ] && break
-
- sdkdir=
-done
-
-if [ -z "$sdkdir" ] ; then
- echo "Couldn't find suitable Windows SDK installation"
- exit 1
-fi
-
-echo "Using Windows SDK install at $sdkdir"
-
-PATH="$PATH:$vsdir/VC/bin:$vsdir/Common7/IDE"
-LIB="$vsdir/VC/lib:$sdkdir/lib"
-INCLUDE="$vsdir/VC/include:$sdkdir/include"
-export PATH LIB INCLUDE
-
-# Do the build
-set -x
-autoreconf -i
-./configure CC=cl.exe LD=link.exe CFLAGS='-nologo'
-sed -i -e 's/^fix_srcfile_path=.*$/fix_srcfile_path=""/;s/^deplibs_check_method=.*$/deplibs_check_method=pass_all/;/^archive_cmds=/s/-link -dll/& -implib:\\$libname.\\$libext/' libtool
-make
-
-# Copy the results of the build into one place, as "make install"
-# isn't too useful here.
-mkdir -p build/lib build/include build/bin
-cp -a librabbitmq/.libs/*.dll examples/.libs/*.exe build/bin
-cp -a msinttypes/*.h librabbitmq/amqp.h librabbitmq/amqp_framing.h build/include
-cp -a librabbitmq/*.exp librabbitmq/*.lib build/lib
diff --git a/etc/install-mingw.sh b/etc/install-mingw.sh
deleted file mode 100755
index af70576..0000000
--- a/etc/install-mingw.sh
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/bash
-
-if [ $# -ne 1 ] ; then
- echo "usage: install-mingw.sh <destination directory>" 1>&2
- exit 1
-fi
-
-unpack_dir=$1
-
-if [ -e "$unpack_dir" ] ; then
- echo "Destination directory already exists; please delete it if you are sure" 1>&2
- exit 1
-fi
-
-set -e
-
-download_dir=/tmp/install-mingw.$$
-mkdir -p $download_dir $unpack_dir
-
-while read f ; do
- wget -P $download_dir -N http://switch.dl.sourceforge.net/project/mingw/$f
-done <<EOF
-MinGW/mpc/mpc-0.8.1-1/libmpc-0.8.1-1-mingw32-dll-2.tar.lzma
-MinGW/BaseSystem/GCC/Version4/gcc-4.5.0-1/gcc-core-4.5.0-1-mingw32-bin.tar.lzma
-MinGW/BaseSystem/GCC/Version4/gcc-4.5.0-1/libgcc-4.5.0-1-mingw32-dll-1.tar.lzma
-MSYS/BaseSystem/msys-core/msys-1.0.14-1/msysCORE-1.0.14-1-msys-1.0.14-bin.tar.lzma
-MinGW/BaseSystem/GNU-Binutils/binutils-2.20.1/binutils-2.20.1-2-mingw32-bin.tar.gz
-MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/mingwrt-3.18/mingwrt-3.18-mingw32-dll.tar.gz
-MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/mingwrt-3.18/mingwrt-3.18-mingw32-dev.tar.gz
-MinGW/pthreads-w32/pthreads-w32-2.8.0-3/libpthread-2.8.0-3-mingw32-dll-2.tar.lzma
-MinGW/mpfr/mpfr-2.4.1-1/libmpfr-2.4.1-1-mingw32-dll-1.tar.lzma
-MinGW/gmp/gmp-5.0.1-1/libgmpxx-5.0.1-1-mingw32-dll-4.tar.lzma
-MinGW/gmp/gmp-5.0.1-1/libgmp-5.0.1-1-mingw32-dll-10.tar.lzma
-MinGW/BaseSystem/RuntimeLibrary/Win32-API/w32api-3.14/w32api-3.14-mingw32-dev.tar.gz
-MSYS/make/make-3.81-2/make-3.81-2-msys-1.0.11-bin.tar.lzma
-MSYS/BaseSystem/bash/bash-3.1.17-2/bash-3.1.17-2-msys-1.0.11-bin.tar.lzma
-MSYS/BaseSystem/coreutils/coreutils-5.97-2/coreutils-5.97-2-msys-1.0.11-bin.tar.lzma
-MinGW/popt/popt-1.15-1/libpopt-1.15-1-mingw32-dll-0.tar.lzma
-MinGW/popt/popt-1.15-1/libpopt-1.15-1-mingw32-dev.tar.lzma
-MSYS/BaseSystem/diffutils/diffutils-2.8.7.20071206cvs-2/diffutils-2.8.7.20071206cvs-2-msys-1.0.11-bin.tar.lzma
-MSYS/BaseSystem/gawk/gawk-3.1.7-1/gawk-3.1.7-1-msys-1.0.11-bin.tar.lzma
-MSYS/BaseSystem/grep/grep-2.5.4-1/grep-2.5.4-1-msys-1.0.11-bin.tar.lzma
-MSYS/BaseSystem/sed/sed-4.2.1-1/sed-4.2.1-1-msys-1.0.11-bin.tar.lzma
-MSYS/libtool/libtool-2.2.7a-2/libtool-2.2.7a-2-msys-1.0.13-bin.tar.lzma
-MinGW/gettext/gettext-0.17-1/libintl-0.17-1-mingw32-dll-8.tar.lzma
-MinGW/gettext/gettext-0.17-1/gettext-0.17-1-mingw32-dev.tar.lzma
-MinGW/libiconv/libiconv-1.13.1-1/libiconv-1.13.1-1-mingw32-dll-2.tar.lzma
-MinGW/libiconv/libiconv-1.13.1-1/libiconv-1.13.1-1-mingw32-dev.tar.lzma
-MinGW/libiconv/libiconv-1.13.1-1/libcharset-1.13.1-1-mingw32-dll-1.tar.lzma
-MSYS/autoconf/autoconf-2.65-1/autoconf-2.65-1-msys-1.0.13-bin.tar.lzma
-MSYS/automake/automake-1.11.1-1/automake-1.11.1-1-msys-1.0.13-bin.tar.lzma
-MSYS/m4/m4-1.4.14-1/m4-1.4.14-1-msys-1.0.13-bin.tar.lzma
-MSYS/BaseSystem/tar/tar-1.23-1/tar-1.23-1-msys-1.0.13-bin.tar.lzma
-MSYS/BaseSystem/regex/regex-1.20090805-2/libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma
-MSYS/BaseSystem/libiconv/libiconv-1.13.1-2/libiconv-1.13.1-2-msys-1.0.13-dll-2.tar.lzma
-MSYS/BaseSystem/gettext/gettext-0.17-2/libintl-0.17-2-msys-dll-8.tar.lzma
-MSYS/perl/perl-5.6.1_2-2/perl-5.6.1_2-2-msys-1.0.13-bin.tar.lzma
-MSYS/crypt/crypt-1.1_1-3/libcrypt-1.1_1-3-msys-1.0.13-dll-0.tar.lzma
-EOF
-
-for f in $download_dir/* ; do
- case $f in
- *.tar.gz)
- tar -C $unpack_dir -xzf $f
- ;;
-
- *.tar.lzma)
- tar -C $unpack_dir -xJf $f
- ;;
-
- *)
- echo "Don't know how to unpack $f" 1>&2
- exit 1
- ;;
- esac
-done
-
-rm -rf $download_dir
diff --git a/examples/Makefile.am b/examples/Makefile.am
deleted file mode 100644
index ea10f77..0000000
--- a/examples/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
-noinst_PROGRAMS = amqp_sendstring amqp_exchange_declare amqp_listen amqp_producer amqp_consumer amqp_unbind amqp_bind amqp_listenq
-
-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
-
-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_bind.c b/examples/amqp_bind.c
deleted file mode 100644
index 561b84d..0000000
--- a/examples/amqp_bind.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <stdint.h>
-#include <amqp.h>
-#include <amqp_framing.h>
-
-#include "utils.h"
-
-int main(int argc, char const * const *argv) {
- char const *hostname;
- int port;
- char const *exchange;
- char const *bindingkey;
- char const *queue;
-
- int sockfd;
- amqp_connection_state_t conn;
-
- if (argc < 6) {
- fprintf(stderr, "Usage: amqp_bind host port exchange bindingkey queue\n");
- return 1;
- }
-
- hostname = argv[1];
- port = atoi(argv[2]);
- exchange = argv[3];
- bindingkey = argv[4];
- queue = argv[5];
-
- conn = amqp_new_connection();
-
- die_on_error(sockfd = amqp_open_socket(hostname, port), "Opening socket");
- amqp_set_sockfd(conn, sockfd);
- die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"),
- "Logging in");
- amqp_channel_open(conn, 1);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel");
-
- amqp_queue_bind(conn, 1,
- amqp_cstring_bytes(queue),
- amqp_cstring_bytes(exchange),
- amqp_cstring_bytes(bindingkey),
- amqp_empty_table);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Unbinding");
-
- die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel");
- die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection");
- die_on_error(amqp_destroy_connection(conn), "Ending connection");
- return 0;
-}
diff --git a/examples/amqp_consumer.c b/examples/amqp_consumer.c
deleted file mode 100644
index 2710643..0000000
--- a/examples/amqp_consumer.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <stdint.h>
-#include <amqp.h>
-#include <amqp_framing.h>
-
-#include <assert.h>
-
-#include "utils.h"
-
-#define SUMMARY_EVERY_US 1000000
-
-static void run(amqp_connection_state_t conn)
-{
- uint64_t start_time = now_microseconds();
- int received = 0;
- int previous_received = 0;
- uint64_t previous_report_time = start_time;
- uint64_t next_summary_time = start_time + SUMMARY_EVERY_US;
-
- amqp_frame_t frame;
- int result;
- size_t body_received;
- size_t body_target;
-
- uint64_t now;
-
- while (1) {
- now = now_microseconds();
- if (now > next_summary_time) {
- int countOverInterval = received - previous_received;
- double intervalRate = countOverInterval / ((now - previous_report_time) / 1000000.0);
- printf("%d ms: Received %d - %d since last report (%d Hz)\n",
- (int)(now - start_time) / 1000, received, countOverInterval, (int) intervalRate);
-
- previous_received = received;
- previous_report_time = now;
- next_summary_time += SUMMARY_EVERY_US;
- }
-
- amqp_maybe_release_buffers(conn);
- result = amqp_simple_wait_frame(conn, &frame);
- if (result < 0)
- return;
-
- if (frame.frame_type != AMQP_FRAME_METHOD)
- continue;
-
- if (frame.payload.method.id != AMQP_BASIC_DELIVER_METHOD)
- continue;
-
- result = amqp_simple_wait_frame(conn, &frame);
- if (result < 0)
- return;
-
- if (frame.frame_type != AMQP_FRAME_HEADER) {
- fprintf(stderr, "Expected header!");
- abort();
- }
-
- body_target = frame.payload.properties.body_size;
- body_received = 0;
-
- while (body_received < body_target) {
- result = amqp_simple_wait_frame(conn, &frame);
- if (result < 0)
- return;
-
- if (frame.frame_type != AMQP_FRAME_BODY) {
- fprintf(stderr, "Expected body!");
- abort();
- }
-
- body_received += frame.payload.body_fragment.len;
- assert(body_received <= body_target);
- }
-
- received++;
- }
-}
-
-int main(int argc, char const * const *argv) {
- char const *hostname;
- int port;
- char const *exchange;
- char const *bindingkey;
-
- int sockfd;
- amqp_connection_state_t conn;
-
- amqp_bytes_t queuename;
-
- if (argc < 3) {
- fprintf(stderr, "Usage: amqp_consumer host port\n");
- return 1;
- }
-
- hostname = argv[1];
- port = atoi(argv[2]);
- exchange = "amq.direct"; /* argv[3]; */
- bindingkey = "test queue"; /* argv[4]; */
-
- conn = amqp_new_connection();
-
- die_on_error(sockfd = amqp_open_socket(hostname, port), "Opening socket");
- amqp_set_sockfd(conn, sockfd);
- die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"),
- "Logging in");
- amqp_channel_open(conn, 1);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel");
-
- {
- amqp_queue_declare_ok_t *r = amqp_queue_declare(conn, 1, amqp_empty_bytes, 0, 0, 0, 1,
- amqp_empty_table);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring queue");
- queuename = amqp_bytes_malloc_dup(r->queue);
- if (queuename.bytes == NULL) {
- fprintf(stderr, "Out of memory while copying queue name");
- return 1;
- }
- }
-
- amqp_queue_bind(conn, 1, queuename, amqp_cstring_bytes(exchange), amqp_cstring_bytes(bindingkey),
- amqp_empty_table);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Binding queue");
-
- amqp_basic_consume(conn, 1, queuename, amqp_empty_bytes, 0, 1, 0, amqp_empty_table);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Consuming");
-
- run(conn);
-
- die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel");
- die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection");
- die_on_error(amqp_destroy_connection(conn), "Ending connection");
-
- return 0;
-}
diff --git a/examples/amqp_exchange_declare.c b/examples/amqp_exchange_declare.c
deleted file mode 100644
index 9b410ca..0000000
--- a/examples/amqp_exchange_declare.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <stdint.h>
-#include <amqp.h>
-#include <amqp_framing.h>
-
-#include "utils.h"
-
-int main(int argc, char const * const *argv) {
- char const *hostname;
- int port;
- char const *exchange;
- char const *exchangetype;
-
- int sockfd;
- amqp_connection_state_t conn;
-
- if (argc < 5) {
- fprintf(stderr, "Usage: amqp_exchange_declare host port exchange exchangetype\n");
- return 1;
- }
-
- hostname = argv[1];
- port = atoi(argv[2]);
- exchange = argv[3];
- exchangetype = argv[4];
-
- conn = amqp_new_connection();
-
- die_on_error(sockfd = amqp_open_socket(hostname, port), "Opening socket");
- amqp_set_sockfd(conn, sockfd);
- die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"),
- "Logging in");
- amqp_channel_open(conn, 1);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel");
-
- amqp_exchange_declare(conn, 1, amqp_cstring_bytes(exchange), amqp_cstring_bytes(exchangetype),
- 0, 0, amqp_empty_table);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring exchange");
-
- die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel");
- die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection");
- die_on_error(amqp_destroy_connection(conn), "Ending connection");
- return 0;
-}
diff --git a/examples/amqp_listen.c b/examples/amqp_listen.c
deleted file mode 100644
index 86c4555..0000000
--- a/examples/amqp_listen.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <stdint.h>
-#include <amqp.h>
-#include <amqp_framing.h>
-
-#include <assert.h>
-
-#include "utils.h"
-
-int main(int argc, char const * const *argv) {
- char const *hostname;
- int port;
- char const *exchange;
- char const *bindingkey;
-
- int sockfd;
- amqp_connection_state_t conn;
-
- amqp_bytes_t queuename;
-
- if (argc < 5) {
- fprintf(stderr, "Usage: amqp_listen host port exchange bindingkey\n");
- return 1;
- }
-
- hostname = argv[1];
- port = atoi(argv[2]);
- exchange = argv[3];
- bindingkey = argv[4];
-
- conn = amqp_new_connection();
-
- die_on_error(sockfd = amqp_open_socket(hostname, port), "Opening socket");
- amqp_set_sockfd(conn, sockfd);
- die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"),
- "Logging in");
- amqp_channel_open(conn, 1);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel");
-
- {
- amqp_queue_declare_ok_t *r = amqp_queue_declare(conn, 1, amqp_empty_bytes, 0, 0, 0, 1,
- amqp_empty_table);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring queue");
- queuename = amqp_bytes_malloc_dup(r->queue);
- if (queuename.bytes == NULL) {
- fprintf(stderr, "Out of memory while copying queue name");
- return 1;
- }
- }
-
- amqp_queue_bind(conn, 1, queuename, amqp_cstring_bytes(exchange), amqp_cstring_bytes(bindingkey),
- amqp_empty_table);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Binding queue");
-
- amqp_basic_consume(conn, 1, queuename, amqp_empty_bytes, 0, 1, 0, amqp_empty_table);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Consuming");
-
- {
- amqp_frame_t frame;
- int result;
-
- amqp_basic_deliver_t *d;
- amqp_basic_properties_t *p;
- size_t body_target;
- size_t body_received;
-
- while (1) {
- amqp_maybe_release_buffers(conn);
- result = amqp_simple_wait_frame(conn, &frame);
- printf("Result %d\n", result);
- if (result < 0)
- break;
-
- printf("Frame type %d, channel %d\n", frame.frame_type, frame.channel);
- if (frame.frame_type != AMQP_FRAME_METHOD)
- continue;
-
- printf("Method %s\n", amqp_method_name(frame.payload.method.id));
- if (frame.payload.method.id != AMQP_BASIC_DELIVER_METHOD)
- continue;
-
- d = (amqp_basic_deliver_t *) frame.payload.method.decoded;
- printf("Delivery %u, exchange %.*s routingkey %.*s\n",
- (unsigned) d->delivery_tag,
- (int) d->exchange.len, (char *) d->exchange.bytes,
- (int) d->routing_key.len, (char *) d->routing_key.bytes);
-
- result = amqp_simple_wait_frame(conn, &frame);
- if (result < 0)
- break;
-
- if (frame.frame_type != AMQP_FRAME_HEADER) {
- fprintf(stderr, "Expected header!");
- abort();
- }
- p = (amqp_basic_properties_t *) frame.payload.properties.decoded;
- if (p->_flags & AMQP_BASIC_CONTENT_TYPE_FLAG) {
- printf("Content-type: %.*s\n",
- (int) p->content_type.len, (char *) p->content_type.bytes);
- }
- printf("----\n");
-
- body_target = frame.payload.properties.body_size;
- body_received = 0;
-
- while (body_received < body_target) {
- result = amqp_simple_wait_frame(conn, &frame);
- if (result < 0)
- break;
-
- if (frame.frame_type != AMQP_FRAME_BODY) {
- fprintf(stderr, "Expected body!");
- abort();
- }
-
- body_received += frame.payload.body_fragment.len;
- assert(body_received <= body_target);
-
- amqp_dump(frame.payload.body_fragment.bytes,
- frame.payload.body_fragment.len);
- }
-
- if (body_received != body_target) {
- /* Can only happen when amqp_simple_wait_frame returns <= 0 */
- /* We break here to close the connection */
- break;
- }
- }
- }
-
- die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel");
- die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection");
- die_on_error(amqp_destroy_connection(conn), "Ending connection");
-
- return 0;
-}
diff --git a/examples/amqp_listenq.c b/examples/amqp_listenq.c
deleted file mode 100644
index c7c2a1e..0000000
--- a/examples/amqp_listenq.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <stdint.h>
-#include <amqp.h>
-#include <amqp_framing.h>
-
-#include <assert.h>
-
-#include "utils.h"
-
-int main(int argc, char const * const *argv) {
- char const *hostname;
- int port;
- char const *queuename;
-
- int sockfd;
- amqp_connection_state_t conn;
-
- if (argc < 4) {
- fprintf(stderr, "Usage: amqp_listenq host port queuename\n");
- return 1;
- }
-
- hostname = argv[1];
- port = atoi(argv[2]);
- queuename = argv[3];
-
- conn = amqp_new_connection();
-
- die_on_error(sockfd = amqp_open_socket(hostname, port), "Opening socket");
- amqp_set_sockfd(conn, sockfd);
- die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"),
- "Logging in");
- amqp_channel_open(conn, 1);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel");
-
- amqp_basic_consume(conn, 1, amqp_cstring_bytes(queuename), amqp_empty_bytes, 0, 0, 0, amqp_empty_table);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Consuming");
-
- {
- amqp_frame_t frame;
- int result;
-
- amqp_basic_deliver_t *d;
- amqp_basic_properties_t *p;
- size_t body_target;
- size_t body_received;
-
- while (1) {
- amqp_maybe_release_buffers(conn);
- result = amqp_simple_wait_frame(conn, &frame);
- printf("Result %d\n", result);
- if (result < 0)
- break;
-
- printf("Frame type %d, channel %d\n", frame.frame_type, frame.channel);
- if (frame.frame_type != AMQP_FRAME_METHOD)
- continue;
-
- printf("Method %s\n", amqp_method_name(frame.payload.method.id));
- if (frame.payload.method.id != AMQP_BASIC_DELIVER_METHOD)
- continue;
-
- d = (amqp_basic_deliver_t *) frame.payload.method.decoded;
- printf("Delivery %u, exchange %.*s routingkey %.*s\n",
- (unsigned) d->delivery_tag,
- (int) d->exchange.len, (char *) d->exchange.bytes,
- (int) d->routing_key.len, (char *) d->routing_key.bytes);
-
- result = amqp_simple_wait_frame(conn, &frame);
- if (result < 0)
- break;
-
- if (frame.frame_type != AMQP_FRAME_HEADER) {
- fprintf(stderr, "Expected header!");
- abort();
- }
- p = (amqp_basic_properties_t *) frame.payload.properties.decoded;
- if (p->_flags & AMQP_BASIC_CONTENT_TYPE_FLAG) {
- printf("Content-type: %.*s\n",
- (int) p->content_type.len, (char *) p->content_type.bytes);
- }
- printf("----\n");
-
- body_target = frame.payload.properties.body_size;
- body_received = 0;
-
- while (body_received < body_target) {
- result = amqp_simple_wait_frame(conn, &frame);
- if (result < 0)
- break;
-
- if (frame.frame_type != AMQP_FRAME_BODY) {
- fprintf(stderr, "Expected body!");
- abort();
- }
-
- body_received += frame.payload.body_fragment.len;
- assert(body_received <= body_target);
-
- amqp_dump(frame.payload.body_fragment.bytes,
- frame.payload.body_fragment.len);
- }
-
- if (body_received != body_target) {
- /* Can only happen when amqp_simple_wait_frame returns <= 0 */
- /* We break here to close the connection */
- break;
- }
-
- amqp_basic_ack(conn, 1, d->delivery_tag, 0);
- }
- }
-
- die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel");
- die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection");
- die_on_error(amqp_destroy_connection(conn), "Ending connection");
-
- return 0;
-}
diff --git a/examples/amqp_producer.c b/examples/amqp_producer.c
deleted file mode 100644
index 77c3e92..0000000
--- a/examples/amqp_producer.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <stdint.h>
-#include <amqp.h>
-#include <amqp_framing.h>
-
-#include "utils.h"
-
-#define SUMMARY_EVERY_US 1000000
-
-static void send_batch(amqp_connection_state_t conn,
- char const *queue_name,
- int rate_limit,
- int message_count)
-{
- uint64_t start_time = now_microseconds();
- int i;
- int sent = 0;
- int previous_sent = 0;
- uint64_t previous_report_time = start_time;
- uint64_t next_summary_time = start_time + SUMMARY_EVERY_US;
-
- char message[256];
- amqp_bytes_t message_bytes;
-
- for (i = 0; i < sizeof(message); i++) {
- message[i] = i & 0xff;
- }
-
- message_bytes.len = sizeof(message);
- message_bytes.bytes = message;
-
- for (i = 0; i < message_count; i++) {
- uint64_t now = now_microseconds();
-
- die_on_error(amqp_basic_publish(conn,
- 1,
- amqp_cstring_bytes("amq.direct"),
- amqp_cstring_bytes(queue_name),
- 0,
- 0,
- NULL,
- message_bytes),
- "Publishing");
- sent++;
- if (now > next_summary_time) {
- int countOverInterval = sent - previous_sent;
- double intervalRate = countOverInterval / ((now - previous_report_time) / 1000000.0);
- printf("%d ms: Sent %d - %d since last report (%d Hz)\n",
- (int)(now - start_time) / 1000, sent, countOverInterval, (int) intervalRate);
-
- previous_sent = sent;
- previous_report_time = now;
- next_summary_time += SUMMARY_EVERY_US;
- }
-
- while (((i * 1000000.0) / (now - start_time)) > rate_limit) {
- microsleep(2000);
- now = now_microseconds();
- }
- }
-
- {
- uint64_t stop_time = now_microseconds();
- int total_delta = stop_time - start_time;
-
- printf("PRODUCER - Message count: %d\n", message_count);
- printf("Total time, milliseconds: %d\n", total_delta / 1000);
- printf("Overall messages-per-second: %g\n", (message_count / (total_delta / 1000000.0)));
- }
-}
-
-int main(int argc, char const * const *argv) {
- char const *hostname;
- int port;
- int rate_limit;
- int message_count;
-
- int sockfd;
- amqp_connection_state_t conn;
-
- if (argc < 5) {
- fprintf(stderr, "Usage: amqp_producer host port rate_limit message_count\n");
- return 1;
- }
-
- hostname = argv[1];
- port = atoi(argv[2]);
- rate_limit = atoi(argv[3]);
- message_count = atoi(argv[4]);
-
- conn = amqp_new_connection();
-
- die_on_error(sockfd = amqp_open_socket(hostname, port), "Opening socket");
- amqp_set_sockfd(conn, sockfd);
- die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"),
- "Logging in");
- amqp_channel_open(conn, 1);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel");
-
- send_batch(conn, "test queue", rate_limit, message_count);
-
- die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel");
- die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection");
- die_on_error(amqp_destroy_connection(conn), "Ending connection");
- return 0;
-}
diff --git a/examples/amqp_sendstring.c b/examples/amqp_sendstring.c
deleted file mode 100644
index 3c94e41..0000000
--- a/examples/amqp_sendstring.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <stdint.h>
-#include <amqp.h>
-#include <amqp_framing.h>
-
-#include "utils.h"
-
-int main(int argc, char const * const *argv) {
- char const *hostname;
- int port;
- char const *exchange;
- char const *routingkey;
- char const *messagebody;
-
- int sockfd;
- amqp_connection_state_t conn;
-
- if (argc < 6) {
- fprintf(stderr, "Usage: amqp_sendstring host port exchange routingkey messagebody\n");
- return 1;
- }
-
- hostname = argv[1];
- port = atoi(argv[2]);
- exchange = argv[3];
- routingkey = argv[4];
- messagebody = argv[5];
-
- conn = amqp_new_connection();
-
- die_on_error(sockfd = amqp_open_socket(hostname, port), "Opening socket");
- amqp_set_sockfd(conn, sockfd);
- die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"),
- "Logging in");
- amqp_channel_open(conn, 1);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel");
-
- {
- amqp_basic_properties_t props;
- props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | AMQP_BASIC_DELIVERY_MODE_FLAG;
- props.content_type = amqp_cstring_bytes("text/plain");
- props.delivery_mode = 2; /* persistent delivery mode */
- die_on_error(amqp_basic_publish(conn,
- 1,
- amqp_cstring_bytes(exchange),
- amqp_cstring_bytes(routingkey),
- 0,
- 0,
- &props,
- amqp_cstring_bytes(messagebody)),
- "Publishing");
- }
-
- die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel");
- die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection");
- die_on_error(amqp_destroy_connection(conn), "Ending connection");
- return 0;
-}
diff --git a/examples/amqp_unbind.c b/examples/amqp_unbind.c
deleted file mode 100644
index fad3e2b..0000000
--- a/examples/amqp_unbind.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <stdint.h>
-#include <amqp.h>
-#include <amqp_framing.h>
-
-#include "utils.h"
-
-int main(int argc, char const * const *argv) {
- char const *hostname;
- int port;
- char const *exchange;
- char const *bindingkey;
- char const *queue;
-
- int sockfd;
- amqp_connection_state_t conn;
-
- if (argc < 6) {
- fprintf(stderr, "Usage: amqp_unbind host port exchange bindingkey queue\n");
- return 1;
- }
-
- hostname = argv[1];
- port = atoi(argv[2]);
- exchange = argv[3];
- bindingkey = argv[4];
- queue = argv[5];
-
- conn = amqp_new_connection();
-
- die_on_error(sockfd = amqp_open_socket(hostname, port), "Opening socket");
- amqp_set_sockfd(conn, sockfd);
- die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"),
- "Logging in");
- amqp_channel_open(conn, 1);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel");
-
- amqp_queue_unbind(conn, 1,
- amqp_cstring_bytes(queue),
- amqp_cstring_bytes(exchange),
- amqp_cstring_bytes(bindingkey),
- amqp_empty_table);
- die_on_amqp_error(amqp_get_rpc_reply(conn), "Unbinding");
-
- die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel");
- die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection");
- die_on_error(amqp_destroy_connection(conn), "Ending connection");
- return 0;
-}
diff --git a/examples/unix/platform_utils.c b/examples/unix/platform_utils.c
deleted file mode 100644
index b039c31..0000000
--- a/examples/unix/platform_utils.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-/* For usleep */
-#define _BSD_SOURCE
-
-#include <stdint.h>
-
-#include <sys/time.h>
-#include <unistd.h>
-
-uint64_t now_microseconds(void)
-{
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return (uint64_t) tv.tv_sec * 1000000 + (uint64_t) tv.tv_usec;
-}
-
-void microsleep(int usec)
-{
- usleep(usec);
-}
diff --git a/examples/utils.c b/examples/utils.c
deleted file mode 100644
index 1837be8..0000000
--- a/examples/utils.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
-#include <stdint.h>
-#include <amqp.h>
-#include <amqp_framing.h>
-
-#include "utils.h"
-
-void die_on_error(int x, char const *context) {
- if (x < 0) {
- char *errstr = amqp_error_string(-x);
- fprintf(stderr, "%s: %s\n", context, errstr);
- free(errstr);
- exit(1);
- }
-}
-
-void die_on_amqp_error(amqp_rpc_reply_t x, char const *context) {
- switch (x.reply_type) {
- case AMQP_RESPONSE_NORMAL:
- return;
-
- case AMQP_RESPONSE_NONE:
- fprintf(stderr, "%s: missing RPC reply type!\n", context);
- break;
-
- case AMQP_RESPONSE_LIBRARY_EXCEPTION:
- fprintf(stderr, "%s: %s\n", context, amqp_error_string(x.library_error));
- break;
-
- case AMQP_RESPONSE_SERVER_EXCEPTION:
- switch (x.reply.id) {
- case AMQP_CONNECTION_CLOSE_METHOD: {
- amqp_connection_close_t *m = (amqp_connection_close_t *) x.reply.decoded;
- fprintf(stderr, "%s: server connection error %d, message: %.*s\n",
- context,
- m->reply_code,
- (int) m->reply_text.len, (char *) m->reply_text.bytes);
- break;
- }
- case AMQP_CHANNEL_CLOSE_METHOD: {
- amqp_channel_close_t *m = (amqp_channel_close_t *) x.reply.decoded;
- fprintf(stderr, "%s: server channel error %d, message: %.*s\n",
- context,
- m->reply_code,
- (int) m->reply_text.len, (char *) m->reply_text.bytes);
- break;
- }
- default:
- fprintf(stderr, "%s: unknown server error, method id 0x%08X\n", context, x.reply.id);
- break;
- }
- break;
- }
-
- exit(1);
-}
-
-static void dump_row(long count, int numinrow, int *chs) {
- int i;
-
- printf("%08lX:", count - numinrow);
-
- if (numinrow > 0) {
- for (i = 0; i < numinrow; i++) {
- if (i == 8)
- printf(" :");
- printf(" %02X", chs[i]);
- }
- for (i = numinrow; i < 16; i++) {
- if (i == 8)
- printf(" :");
- printf(" ");
- }
- printf(" ");
- for (i = 0; i < numinrow; i++) {
- if (isprint(chs[i]))
- printf("%c", chs[i]);
- else
- printf(".");
- }
- }
- printf("\n");
-}
-
-static int rows_eq(int *a, int *b) {
- int i;
-
- for (i=0; i<16; i++)
- if (a[i] != b[i])
- return 0;
-
- return 1;
-}
-
-void amqp_dump(void const *buffer, size_t len) {
- unsigned char *buf = (unsigned char *) buffer;
- long count = 0;
- int numinrow = 0;
- int chs[16];
- int oldchs[16];
- int showed_dots = 0;
- int i;
-
- for (i = 0; i < len; i++) {
- int ch = buf[i];
-
- if (numinrow == 16) {
- int i;
-
- if (rows_eq(oldchs, chs)) {
- if (!showed_dots) {
- showed_dots = 1;
- printf(" .. .. .. .. .. .. .. .. : .. .. .. .. .. .. .. ..\n");
- }
- } else {
- showed_dots = 0;
- dump_row(count, numinrow, chs);
- }
-
- for (i=0; i<16; i++)
- oldchs[i] = chs[i];
-
- numinrow = 0;
- }
-
- count++;
- chs[numinrow++] = ch;
- }
-
- dump_row(count, numinrow, chs);
-
- if (numinrow != 0)
- printf("%08lX:\n", count);
-}
diff --git a/examples/utils.h b/examples/utils.h
deleted file mode 100644
index e5ac9a3..0000000
--- a/examples/utils.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef librabbitmq_examples_utils_h
-#define librabbitmq_examples_utils_h
-
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-extern void die_on_error(int x, char const *context);
-extern void die_on_amqp_error(amqp_rpc_reply_t x, char const *context);
-
-extern void amqp_dump(void const *buffer, size_t len);
-
-extern uint64_t now_microseconds(void);
-extern void microsleep(int usec);
-
-#endif
diff --git a/examples/windows/platform_utils.c b/examples/windows/platform_utils.c
deleted file mode 100644
index 915dd27..0000000
--- a/examples/windows/platform_utils.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdint.h>
-
-#include <windows.h>
-
-uint64_t now_microseconds(void)
-{
- FILETIME ft;
- GetSystemTimeAsFileTime(&ft);
- return (((uint64_t)ft.dwHighDateTime << 32) | (uint64_t)ft.dwLowDateTime)
- / 10;
-}
-
-void microsleep(int usec)
-{
- Sleep(usec / 1000);
-}
diff --git a/librabbitmq/Makefile.am b/librabbitmq/Makefile.am
deleted file mode 100644
index 1217c49..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 $(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
deleted file mode 100644
index 1541583..0000000
--- a/librabbitmq/amqp.h
+++ /dev/null
@@ -1,478 +0,0 @@
-#ifndef librabbitmq_amqp_h
-#define librabbitmq_amqp_h
-
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef _WIN32
-#ifdef BUILDING_LIBRABBITMQ
-#define RABBITMQ_EXPORT extern __declspec(dllexport)
-#else
-#define RABBITMQ_EXPORT extern __declspec(dllimport)
-#endif
-#else
-#define RABBITMQ_EXPORT extern
-#endif
-
-typedef int amqp_boolean_t;
-typedef uint32_t amqp_method_number_t;
-typedef uint32_t amqp_flags_t;
-typedef uint16_t amqp_channel_t;
-
-typedef struct amqp_bytes_t_ {
- size_t len;
- void *bytes;
-} amqp_bytes_t;
-
-typedef struct amqp_decimal_t_ {
- uint8_t decimals;
- uint32_t value;
-} amqp_decimal_t;
-
-typedef struct amqp_table_t_ {
- int num_entries;
- struct amqp_table_entry_t_ *entries;
-} amqp_table_t;
-
-typedef struct amqp_array_t_ {
- int num_entries;
- struct amqp_field_value_t_ *entries;
-} amqp_array_t;
-
-/*
- 0-9 0-9-1 Qpid/Rabbit Type Remarks
----------------------------------------------------------------------------
- t t Boolean
- b b Signed 8-bit
- B Unsigned 8-bit
- U s Signed 16-bit (A1)
- u Unsigned 16-bit
- I I I Signed 32-bit
- i Unsigned 32-bit
- L l Signed 64-bit (B)
- l Unsigned 64-bit
- f f 32-bit float
- d d 64-bit float
- D D D Decimal
- s Short string (A2)
- S S S Long string
- A Nested Array
- T T T Timestamp (u64)
- F F F Nested Table
- V V V Void
- x Byte array
-
-Remarks:
-
- A1, A2: Notice how the types **CONFLICT** here. In Qpid and Rabbit,
- 's' means a signed 16-bit integer; in 0-9-1, it means a
- short string.
-
- B: Notice how the signednesses **CONFLICT** here. In Qpid and Rabbit,
- 'l' means a signed 64-bit integer; in 0-9-1, it means an unsigned
- 64-bit integer.
-
-I'm going with the Qpid/Rabbit types, where there's a conflict, and
-the 0-9-1 types otherwise. 0-8 is a subset of 0-9, which is a subset
-of the other two, so this will work for both 0-8 and 0-9-1 branches of
-the code.
-*/
-
-typedef struct amqp_field_value_t_ {
- uint8_t kind;
- union {
- amqp_boolean_t boolean;
- int8_t i8;
- uint8_t u8;
- int16_t i16;
- uint16_t u16;
- int32_t i32;
- uint32_t u32;
- int64_t i64;
- uint64_t u64;
- float f32;
- double f64;
- amqp_decimal_t decimal;
- amqp_bytes_t bytes;
- amqp_table_t table;
- amqp_array_t array;
- } value;
-} amqp_field_value_t;
-
-typedef struct amqp_table_entry_t_ {
- amqp_bytes_t key;
- amqp_field_value_t value;
-} amqp_table_entry_t;
-
-typedef enum {
- AMQP_FIELD_KIND_BOOLEAN = 't',
- AMQP_FIELD_KIND_I8 = 'b',
- AMQP_FIELD_KIND_U8 = 'B',
- AMQP_FIELD_KIND_I16 = 's',
- AMQP_FIELD_KIND_U16 = 'u',
- AMQP_FIELD_KIND_I32 = 'I',
- AMQP_FIELD_KIND_U32 = 'i',
- AMQP_FIELD_KIND_I64 = 'l',
- AMQP_FIELD_KIND_U64 = 'L',
- AMQP_FIELD_KIND_F32 = 'f',
- AMQP_FIELD_KIND_F64 = 'd',
- AMQP_FIELD_KIND_DECIMAL = 'D',
- AMQP_FIELD_KIND_UTF8 = 'S',
- AMQP_FIELD_KIND_ARRAY = 'A',
- AMQP_FIELD_KIND_TIMESTAMP = 'T',
- AMQP_FIELD_KIND_TABLE = 'F',
- AMQP_FIELD_KIND_VOID = 'V',
- AMQP_FIELD_KIND_BYTES = 'x'
-} amqp_field_value_kind_t;
-
-typedef struct amqp_pool_blocklist_t_ {
- int num_blocks;
- void **blocklist;
-} amqp_pool_blocklist_t;
-
-typedef struct amqp_pool_t_ {
- size_t pagesize;
-
- amqp_pool_blocklist_t pages;
- amqp_pool_blocklist_t large_blocks;
-
- int next_page;
- char *alloc_block;
- size_t alloc_used;
-} amqp_pool_t;
-
-typedef struct amqp_method_t_ {
- amqp_method_number_t id;
- void *decoded;
-} amqp_method_t;
-
-typedef struct amqp_frame_t_ {
- uint8_t frame_type; /* 0 means no event */
- amqp_channel_t channel;
- union {
- amqp_method_t method;
- struct {
- uint16_t class_id;
- uint64_t body_size;
- void *decoded;
- amqp_bytes_t raw;
- } properties;
- amqp_bytes_t body_fragment;
- struct {
- uint8_t transport_high;
- uint8_t transport_low;
- uint8_t protocol_version_major;
- uint8_t protocol_version_minor;
- } protocol_header;
- } payload;
-} amqp_frame_t;
-
-typedef enum amqp_response_type_enum_ {
- AMQP_RESPONSE_NONE = 0,
- AMQP_RESPONSE_NORMAL,
- AMQP_RESPONSE_LIBRARY_EXCEPTION,
- AMQP_RESPONSE_SERVER_EXCEPTION
-} amqp_response_type_enum;
-
-typedef struct amqp_rpc_reply_t_ {
- amqp_response_type_enum reply_type;
- amqp_method_t reply;
- int library_error; /* if AMQP_RESPONSE_LIBRARY_EXCEPTION, then 0 here means socket EOF */
-} amqp_rpc_reply_t;
-
-typedef enum amqp_sasl_method_enum_ {
- AMQP_SASL_METHOD_PLAIN = 0
-} amqp_sasl_method_enum;
-
-/* Opaque struct. */
-typedef struct amqp_connection_state_t_ *amqp_connection_state_t;
-
-RABBITMQ_EXPORT char const *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;
-
-/* Compatibility macros for the above, to avoid the need to update
- code written against earlier versions of librabbitmq. */
-#define AMQP_EMPTY_BYTES amqp_empty_bytes
-#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 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, ...);
-
-RABBITMQ_EXPORT struct amqp_channel_open_ok_t_ *amqp_channel_open(
- amqp_connection_state_t state,
- amqp_channel_t channel);
-
-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 struct amqp_exchange_declare_ok_t_ *amqp_exchange_declare(
- amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t exchange,
- amqp_bytes_t type,
- amqp_boolean_t passive,
- amqp_boolean_t durable,
- amqp_table_t arguments);
-
-RABBITMQ_EXPORT struct amqp_queue_declare_ok_t_ *amqp_queue_declare(
- amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_boolean_t passive,
- amqp_boolean_t durable,
- amqp_boolean_t exclusive,
- amqp_boolean_t auto_delete,
- amqp_table_t arguments);
-
-RABBITMQ_EXPORT struct amqp_queue_delete_ok_t_ *amqp_queue_delete(
- amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_boolean_t if_unused,
- amqp_boolean_t if_empty);
-
-RABBITMQ_EXPORT struct amqp_queue_bind_ok_t_ *amqp_queue_bind(
- amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_bytes_t exchange,
- amqp_bytes_t routing_key,
- amqp_table_t arguments);
-
-RABBITMQ_EXPORT struct amqp_queue_unbind_ok_t_ *amqp_queue_unbind(
- amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_bytes_t exchange,
- amqp_bytes_t routing_key,
- amqp_table_t arguments);
-
-RABBITMQ_EXPORT struct amqp_basic_consume_ok_t_ *amqp_basic_consume(
- amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_bytes_t consumer_tag,
- amqp_boolean_t no_local,
- amqp_boolean_t no_ack,
- amqp_boolean_t exclusive,
- amqp_table_t filter);
-
-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 struct amqp_queue_purge_ok_t_ *amqp_queue_purge(
- amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_boolean_t no_wait);
-
-RABBITMQ_EXPORT struct amqp_tx_select_ok_t_ *amqp_tx_select(
- amqp_connection_state_t state,
- amqp_channel_t channel);
-
-RABBITMQ_EXPORT struct amqp_tx_commit_ok_t_ *amqp_tx_commit(
- amqp_connection_state_t state,
- amqp_channel_t channel);
-
-RABBITMQ_EXPORT struct amqp_tx_rollback_ok_t_ *amqp_tx_rollback(
- amqp_connection_state_t state,
- amqp_channel_t channel);
-
-/*
- * Can be used to see if there is data still in the buffer, if so
- * calling amqp_simple_wait_frame will not immediately enter a
- * blocking read.
- *
- * Possibly amqp_frames_enqueued should be used for this?
- */
-RABBITMQ_EXPORT amqp_boolean_t amqp_data_in_buffer(
- amqp_connection_state_t state);
-
-/*
- * For those API operations (such as amqp_basic_ack,
- * amqp_queue_declare, and so on) that do not themselves return
- * amqp_rpc_reply_t instances, we need some way of discovering what,
- * if anything, went wrong. amqp_get_rpc_reply() returns the most
- * recent amqp_rpc_reply_t instance corresponding to such an API
- * operation for the given connection.
- *
- * Only use it for operations that do not themselves return
- * amqp_rpc_reply_t; operations that do return amqp_rpc_reply_t
- * 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);
-
-/*
- * Get the error string for the given error code.
- *
- * The returned string resides on the heap; the caller is responsible
- * for freeing it.
- */
-RABBITMQ_EXPORT char *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);
-
-RABBITMQ_EXPORT int amqp_encode_table(amqp_bytes_t encoded,
- amqp_table_t *input,
- size_t *offset);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/librabbitmq/amqp_api.c b/librabbitmq/amqp_api.c
deleted file mode 100644
index bf19761..0000000
--- a/librabbitmq/amqp_api.c
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#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>
-
-static const char *client_error_strings[ERROR_MAX] = {
- "could not allocate memory", /* ERROR_NO_MEMORY */
- "received bad AMQP data", /* ERROR_BAD_AQMP_DATA */
- "unknown AMQP class id", /* ERROR_UNKOWN_CLASS */
- "unknown AMQP method id", /* ERROR_UNKOWN_METHOD */
- "unknown host", /* ERROR_GETHOSTBYNAME_FAILED */
- "incompatible AMQP version", /* ERROR_INCOMPATIBLE_AMQP_VERSION */
- "connection closed unexpectedly", /* ERROR_CONNECTION_CLOSED */
-};
-
-/* strdup is not in ISO C90! */
-static inline char *strdup(const char *str)
-{
- return strcpy(malloc(strlen(str) + 1),str);
-}
-
-char *amqp_error_string(int err)
-{
- const char *str;
- int category = (err & ERROR_CATEGORY_MASK);
- err = (err & ~ERROR_CATEGORY_MASK);
-
- switch (category) {
- case ERROR_CATEGORY_CLIENT:
- if (err < 1 || err > ERROR_MAX)
- str = "(undefined librabbitmq error)";
- else
- str = client_error_strings[err - 1];
- break;
-
- case ERROR_CATEGORY_OS:
- return amqp_os_error_string(err);
-
- default:
- str = "(undefined error category)";
- }
-
- return strdup(str);
-}
-
-void amqp_abort(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- fputc('\n', stderr);
- abort();
-}
-
-const amqp_bytes_t amqp_empty_bytes = { 0, NULL };
-const amqp_table_t amqp_empty_table = { 0, NULL };
-const amqp_array_t amqp_empty_array = { 0, NULL };
-
-#define RPC_REPLY(replytype) \
- (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL \
- ? (replytype *) state->most_recent_api_result.reply.decoded \
- : NULL)
-
-amqp_channel_open_ok_t *amqp_channel_open(amqp_connection_state_t state,
- amqp_channel_t channel)
-{
- amqp_method_number_t replies[2] = { AMQP_CHANNEL_OPEN_OK_METHOD, 0};
- amqp_channel_open_t req;
- req.out_of_band.bytes = NULL;
- req.out_of_band.len = 0;
-
- state->most_recent_api_result = amqp_simple_rpc(state, channel,
- AMQP_CHANNEL_OPEN_METHOD,
- replies, &req);
- if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL)
- return state->most_recent_api_result.reply.decoded;
- else
- return NULL;
-}
-
-int amqp_basic_publish(amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t exchange,
- amqp_bytes_t routing_key,
- amqp_boolean_t mandatory,
- amqp_boolean_t immediate,
- amqp_basic_properties_t const *properties,
- amqp_bytes_t body)
-{
- amqp_frame_t f;
- size_t body_offset;
- size_t usable_body_payload_size = state->frame_max - (HEADER_SIZE + FOOTER_SIZE);
- int res;
-
- amqp_basic_publish_t m;
- amqp_basic_properties_t default_properties;
-
- m.exchange = exchange;
- m.routing_key = routing_key;
- m.mandatory = mandatory;
- m.immediate = immediate;
-
- res = amqp_send_method(state, channel, AMQP_BASIC_PUBLISH_METHOD, &m);
- if (res < 0)
- return res;
-
- if (properties == NULL) {
- memset(&default_properties, 0, sizeof(default_properties));
- properties = &default_properties;
- }
-
- f.frame_type = AMQP_FRAME_HEADER;
- f.channel = channel;
- f.payload.properties.class_id = AMQP_BASIC_CLASS;
- f.payload.properties.body_size = body.len;
- f.payload.properties.decoded = (void *) properties;
-
- res = amqp_send_frame(state, &f);
- if (res < 0)
- return res;
-
- body_offset = 0;
- while (1) {
- int remaining = body.len - body_offset;
- assert(remaining >= 0);
-
- if (remaining == 0)
- break;
-
- f.frame_type = AMQP_FRAME_BODY;
- f.channel = channel;
- f.payload.body_fragment.bytes = amqp_offset(body.bytes, body_offset);
- if (remaining >= usable_body_payload_size) {
- f.payload.body_fragment.len = usable_body_payload_size;
- } else {
- f.payload.body_fragment.len = remaining;
- }
-
- body_offset += f.payload.body_fragment.len;
- res = amqp_send_frame(state, &f);
- if (res < 0)
- return res;
- }
-
- return 0;
-}
-
-amqp_rpc_reply_t amqp_channel_close(amqp_connection_state_t state,
- amqp_channel_t channel,
- int code)
-{
- char codestr[13];
- amqp_method_number_t replies[2] = { AMQP_CHANNEL_CLOSE_OK_METHOD, 0};
- amqp_channel_close_t req;
-
- req.reply_code = code;
- req.reply_text.bytes = codestr;
- req.reply_text.len = sprintf(codestr, "%d", code);
- req.class_id = 0;
- req.method_id = 0;
-
- return amqp_simple_rpc(state, channel, AMQP_CHANNEL_CLOSE_METHOD,
- replies, &req);
-}
-
-amqp_rpc_reply_t amqp_connection_close(amqp_connection_state_t state,
- int code)
-{
- char codestr[13];
- amqp_method_number_t replies[2] = { AMQP_CONNECTION_CLOSE_OK_METHOD, 0};
- amqp_channel_close_t req;
-
- req.reply_code = code;
- req.reply_text.bytes = codestr;
- req.reply_text.len = sprintf(codestr, "%d", code);
- req.class_id = 0;
- req.method_id = 0;
-
- return amqp_simple_rpc(state, 0, AMQP_CONNECTION_CLOSE_METHOD,
- replies, &req);
-}
-
-amqp_exchange_declare_ok_t *amqp_exchange_declare(amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t exchange,
- amqp_bytes_t type,
- amqp_boolean_t passive,
- amqp_boolean_t durable,
- amqp_table_t arguments)
-{
- amqp_method_number_t replies[2] = { AMQP_EXCHANGE_DECLARE_OK_METHOD, 0};
- amqp_exchange_declare_t req;
- req.exchange = exchange;
- req.type = type;
- req.passive = passive;
- req.durable = durable;
- req.auto_delete = 0;
- req.internal = 0;
- req.nowait = 0;
- req.arguments = arguments;
-
- state->most_recent_api_result = amqp_simple_rpc(state, channel,
- AMQP_EXCHANGE_DECLARE_METHOD,
- replies, &req);
- if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL)
- return state->most_recent_api_result.reply.decoded;
- else
- return NULL;
-}
-
-amqp_queue_declare_ok_t *amqp_queue_declare(amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_boolean_t passive,
- amqp_boolean_t durable,
- amqp_boolean_t exclusive,
- amqp_boolean_t auto_delete,
- amqp_table_t arguments)
-{
- amqp_method_number_t replies[2] = { AMQP_QUEUE_DECLARE_OK_METHOD, 0};
- amqp_queue_declare_t req;
- req.queue = queue;
- req.passive = passive;
- req.durable = durable;
- req.exclusive = exclusive;
- req.auto_delete = auto_delete;
- req.nowait = 0;
- req.arguments = arguments;
-
- state->most_recent_api_result = amqp_simple_rpc(state, channel,
- AMQP_QUEUE_DECLARE_METHOD,
- replies, &req);
- if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL)
- return state->most_recent_api_result.reply.decoded;
- else
- return NULL;
-}
-
-amqp_queue_delete_ok_t *amqp_queue_delete(amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_boolean_t if_unused,
- amqp_boolean_t if_empty)
-{
- amqp_method_number_t replies[2] = { AMQP_QUEUE_DELETE_OK_METHOD, 0};
- amqp_queue_delete_t req;
- req.queue = queue;
- req.if_unused = if_unused;
- req.if_empty = if_empty;
- req.nowait = 0;
-
- state->most_recent_api_result = amqp_simple_rpc(state, channel,
- AMQP_QUEUE_DELETE_METHOD,
- replies, &req);
- if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL)
- return state->most_recent_api_result.reply.decoded;
- else
- return NULL;
-}
-
-amqp_queue_bind_ok_t *amqp_queue_bind(amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_bytes_t exchange,
- amqp_bytes_t routing_key,
- amqp_table_t arguments)
-{
- amqp_method_number_t replies[2] = { AMQP_QUEUE_BIND_OK_METHOD, 0};
- amqp_queue_bind_t req;
- req.ticket = 0;
- req.queue = queue;
- req.exchange = exchange;
- req.routing_key = routing_key;
- req.nowait = 0;
- req.arguments = arguments;
-
- state->most_recent_api_result = amqp_simple_rpc(state, channel,
- AMQP_QUEUE_BIND_METHOD,
- replies, &req);
- if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL)
- return state->most_recent_api_result.reply.decoded;
- else
- return NULL;
-}
-
-amqp_queue_unbind_ok_t *amqp_queue_unbind(amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_bytes_t exchange,
- amqp_bytes_t routing_key,
- amqp_table_t arguments)
-{
- amqp_method_number_t replies[2] = { AMQP_QUEUE_UNBIND_OK_METHOD, 0};
- amqp_queue_unbind_t req;
- req.ticket = 0;
- req.queue = queue;
- req.exchange = exchange;
- req.routing_key = routing_key;
- req.arguments = arguments;
-
- state->most_recent_api_result = amqp_simple_rpc(state, channel,
- AMQP_QUEUE_UNBIND_METHOD,
- replies, &req);
- if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL)
- return state->most_recent_api_result.reply.decoded;
- else
- return NULL;
-}
-
-amqp_basic_consume_ok_t *amqp_basic_consume(amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_bytes_t consumer_tag,
- amqp_boolean_t no_local,
- amqp_boolean_t no_ack,
- amqp_boolean_t exclusive,
- amqp_table_t filter)
-{
- amqp_method_number_t replies[2] = { AMQP_BASIC_CONSUME_OK_METHOD, 0};
- amqp_basic_consume_t req;
- req.ticket = 0;
- req.queue = queue;
- req.consumer_tag = consumer_tag;
- req.no_local = no_local;
- req.no_ack = no_ack;
- req.exclusive = exclusive;
- req.nowait = 0;
- req.arguments = filter;
-
- state->most_recent_api_result = amqp_simple_rpc(state, channel,
- AMQP_BASIC_CONSUME_METHOD,
- replies, &req);
- if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL)
- return state->most_recent_api_result.reply.decoded;
- else
- return NULL;
-}
-
-int amqp_basic_ack(amqp_connection_state_t state,
- amqp_channel_t channel,
- uint64_t delivery_tag,
- amqp_boolean_t multiple)
-{
- amqp_basic_ack_t m;
- m.delivery_tag = delivery_tag;
- m.multiple = multiple;
- return amqp_send_method(state, channel, AMQP_BASIC_ACK_METHOD, &m);
-}
-
-amqp_queue_purge_ok_t *amqp_queue_purge(amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_boolean_t no_wait)
-{
- amqp_method_number_t replies[2] = { AMQP_QUEUE_PURGE_OK_METHOD, 0};
- amqp_queue_purge_t req;
- req.ticket = 0;
- req.queue = queue;
- req.nowait = 0;
-
- state->most_recent_api_result = amqp_simple_rpc(state, channel,
- AMQP_QUEUE_PURGE_METHOD,
- replies, &req);
- if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL)
- return state->most_recent_api_result.reply.decoded;
- else
- return NULL;
-}
-
-amqp_rpc_reply_t amqp_basic_get(amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_bytes_t queue,
- amqp_boolean_t no_ack)
-{
- amqp_method_number_t replies[] = { AMQP_BASIC_GET_OK_METHOD,
- AMQP_BASIC_GET_EMPTY_METHOD,
- 0 };
- amqp_basic_get_t req;
- req.ticket = 0;
- req.queue = queue;
- req.no_ack = no_ack;
-
- state->most_recent_api_result = amqp_simple_rpc(state, channel,
- AMQP_BASIC_GET_METHOD,
- replies, &req);
- return state->most_recent_api_result;
-}
-
-amqp_tx_select_ok_t *amqp_tx_select(amqp_connection_state_t state,
- amqp_channel_t channel)
-{
- amqp_method_number_t replies[2] = { AMQP_TX_SELECT_OK_METHOD, 0};
- state->most_recent_api_result = amqp_simple_rpc(state, channel,
- AMQP_TX_SELECT_METHOD,
- replies, NULL);
- if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL)
- return state->most_recent_api_result.reply.decoded;
- else
- return NULL;
-}
-
-amqp_tx_commit_ok_t *amqp_tx_commit(amqp_connection_state_t state,
- amqp_channel_t channel)
-{
- amqp_method_number_t replies[2] = { AMQP_TX_COMMIT_OK_METHOD, 0};
- state->most_recent_api_result = amqp_simple_rpc(state, channel,
- AMQP_TX_COMMIT_METHOD,
- replies, NULL);
- if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL)
- return state->most_recent_api_result.reply.decoded;
- else
- return NULL;
-}
-
-amqp_tx_rollback_ok_t *amqp_tx_rollback(amqp_connection_state_t state,
- amqp_channel_t channel)
-{
- amqp_method_number_t replies[2] = { AMQP_TX_ROLLBACK_OK_METHOD, 0};
- state->most_recent_api_result = amqp_simple_rpc(state, channel,
- AMQP_TX_ROLLBACK_METHOD,
- replies, NULL);
- if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL)
- return state->most_recent_api_result.reply.decoded;
- else
- return NULL;
-}
-
-amqp_rpc_reply_t amqp_get_rpc_reply(amqp_connection_state_t state)
-{
- return state->most_recent_api_result;
-}
diff --git a/librabbitmq/amqp_connection.c b/librabbitmq/amqp_connection.c
deleted file mode 100644
index 34d12f8..0000000
--- a/librabbitmq/amqp_connection.c
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <assert.h>
-
-#include "amqp.h"
-#include "amqp_framing.h"
-#include "amqp_private.h"
-
-#define INITIAL_FRAME_POOL_PAGE_SIZE 65536
-#define INITIAL_DECODING_POOL_PAGE_SIZE 131072
-#define INITIAL_INBOUND_SOCK_BUFFER_SIZE 131072
-
-#define ENFORCE_STATE(statevec, statenum) \
- { \
- amqp_connection_state_t _check_state = (statevec); \
- int _wanted_state = (statenum); \
- if (_check_state->state != _wanted_state) \
- amqp_abort("Programming error: invalid AMQP connection state: expected %d, got %d", \
- _wanted_state, \
- _check_state->state); \
- }
-
-amqp_connection_state_t amqp_new_connection(void) {
- amqp_connection_state_t state =
- (amqp_connection_state_t) calloc(1, sizeof(struct amqp_connection_state_t_));
-
- if (state == NULL)
- return NULL;
-
- init_amqp_pool(&state->frame_pool, INITIAL_FRAME_POOL_PAGE_SIZE);
- init_amqp_pool(&state->decoding_pool, INITIAL_DECODING_POOL_PAGE_SIZE);
-
- if (amqp_tune_connection(state, 0, INITIAL_FRAME_POOL_PAGE_SIZE, 0) != 0)
- goto out_nomem;
-
- state->inbound_buffer.bytes = amqp_pool_alloc(&state->frame_pool, state->inbound_buffer.len);
- if (state->inbound_buffer.bytes == NULL)
- goto out_nomem;
-
- state->state = CONNECTION_STATE_INITIAL;
- /* the server protocol version response is 8 bytes, which conveniently
- is also the minimum frame size */
- state->target_size = 8;
-
- state->sockfd = -1;
- state->sock_inbound_buffer.len = INITIAL_INBOUND_SOCK_BUFFER_SIZE;
- state->sock_inbound_buffer.bytes = malloc(INITIAL_INBOUND_SOCK_BUFFER_SIZE);
- if (state->sock_inbound_buffer.bytes == NULL)
- goto out_nomem;
-
- return state;
-
- out_nomem:
- free(state->sock_inbound_buffer.bytes);
- empty_amqp_pool(&state->frame_pool);
- empty_amqp_pool(&state->decoding_pool);
- free(state);
- return NULL;
-}
-
-int amqp_get_sockfd(amqp_connection_state_t state) {
- return state->sockfd;
-}
-
-void amqp_set_sockfd(amqp_connection_state_t state,
- int sockfd)
-{
- state->sockfd = sockfd;
-}
-
-int amqp_tune_connection(amqp_connection_state_t state,
- int channel_max,
- int frame_max,
- int heartbeat)
-{
- void *newbuf;
-
- ENFORCE_STATE(state, CONNECTION_STATE_IDLE);
-
- state->channel_max = channel_max;
- state->frame_max = frame_max;
- state->heartbeat = heartbeat;
-
- empty_amqp_pool(&state->frame_pool);
- init_amqp_pool(&state->frame_pool, frame_max);
-
- state->inbound_buffer.len = frame_max;
- state->outbound_buffer.len = frame_max;
- newbuf = realloc(state->outbound_buffer.bytes, frame_max);
- if (newbuf == NULL) {
- amqp_destroy_connection(state);
- return -ERROR_NO_MEMORY;
- }
- state->outbound_buffer.bytes = newbuf;
-
- return 0;
-}
-
-int amqp_get_channel_max(amqp_connection_state_t state) {
- return state->channel_max;
-}
-
-int amqp_destroy_connection(amqp_connection_state_t state) {
- int s = state->sockfd;
-
- empty_amqp_pool(&state->frame_pool);
- empty_amqp_pool(&state->decoding_pool);
- free(state->outbound_buffer.bytes);
- free(state->sock_inbound_buffer.bytes);
- free(state);
-
- if (s >= 0 && amqp_socket_close(s) < 0)
- return -amqp_socket_error();
- else
- return 0;
-}
-
-static void return_to_idle(amqp_connection_state_t state) {
- state->inbound_buffer.bytes = NULL;
- state->inbound_offset = 0;
- state->target_size = HEADER_SIZE;
- state->state = CONNECTION_STATE_IDLE;
-}
-
-static size_t consume_data(amqp_connection_state_t state,
- amqp_bytes_t *received_data)
-{
- /* how much data is available and will fit? */
- size_t bytes_consumed = state->target_size - state->inbound_offset;
- if (received_data->len < bytes_consumed)
- bytes_consumed = received_data->len;
-
- memcpy(amqp_offset(state->inbound_buffer.bytes, state->inbound_offset),
- received_data->bytes, bytes_consumed);
- state->inbound_offset += bytes_consumed;
- received_data->bytes = amqp_offset(received_data->bytes, bytes_consumed);
- received_data->len -= bytes_consumed;
-
- return bytes_consumed;
-}
-
-int amqp_handle_input(amqp_connection_state_t state,
- amqp_bytes_t received_data,
- amqp_frame_t *decoded_frame)
-{
- size_t bytes_consumed;
- void *raw_frame;
-
- /* Returning frame_type of zero indicates either insufficient input,
- or a complete, ignored frame was read. */
- decoded_frame->frame_type = 0;
-
- if (received_data.len == 0)
- return 0;
-
- if (state->state == CONNECTION_STATE_IDLE) {
- state->inbound_buffer.bytes = amqp_pool_alloc(&state->frame_pool,
- state->inbound_buffer.len);
- if (state->inbound_buffer.bytes == NULL)
- /* state->inbound_buffer.len is always nonzero, because it
- corresponds to frame_max, which is not permitted to be less
- than AMQP_FRAME_MIN_SIZE (currently 4096 bytes). */
- return -ERROR_NO_MEMORY;
-
- state->state = CONNECTION_STATE_HEADER;
- }
-
- bytes_consumed = consume_data(state, &received_data);
-
- /* do we have target_size data yet? if not, return with the
- expectation that more will arrive */
- if (state->inbound_offset < state->target_size)
- return bytes_consumed;
-
- raw_frame = state->inbound_buffer.bytes;
-
- switch (state->state) {
- case CONNECTION_STATE_INITIAL:
- /* check for a protocol header from the server */
- if (memcmp(raw_frame, "AMQP", 4) == 0) {
- decoded_frame->frame_type = AMQP_PSEUDOFRAME_PROTOCOL_HEADER;
- decoded_frame->channel = 0;
-
- decoded_frame->payload.protocol_header.transport_high
- = amqp_d8(raw_frame, 4);
- decoded_frame->payload.protocol_header.transport_low
- = amqp_d8(raw_frame, 5);
- decoded_frame->payload.protocol_header.protocol_version_major
- = amqp_d8(raw_frame, 6);
- decoded_frame->payload.protocol_header.protocol_version_minor
- = amqp_d8(raw_frame, 7);
-
- return_to_idle(state);
- return bytes_consumed;
- }
-
- /* it's not a protocol header; fall through to process it as a
- regular frame header */
-
- case CONNECTION_STATE_HEADER:
- /* frame length is 3 bytes in */
- state->target_size
- = amqp_d32(raw_frame, 3) + HEADER_SIZE + FOOTER_SIZE;
- state->state = CONNECTION_STATE_BODY;
-
- bytes_consumed += consume_data(state, &received_data);
-
- /* do we have target_size data yet? if not, return with the
- expectation that more will arrive */
- if (state->inbound_offset < state->target_size)
- return bytes_consumed;
-
- /* fall through to process body */
-
- case CONNECTION_STATE_BODY: {
- amqp_bytes_t encoded;
- int res;
-
- /* Check frame end marker (footer) */
- if (amqp_d8(raw_frame, state->target_size - 1) != AMQP_FRAME_END)
- return -ERROR_BAD_AMQP_DATA;
-
- decoded_frame->frame_type = amqp_d8(raw_frame, 0);
- decoded_frame->channel = amqp_d16(raw_frame, 1);
-
- switch (decoded_frame->frame_type) {
- case AMQP_FRAME_METHOD:
- decoded_frame->payload.method.id = amqp_d32(raw_frame, HEADER_SIZE);
- encoded.bytes = amqp_offset(raw_frame, HEADER_SIZE + 4);
- encoded.len = state->target_size - HEADER_SIZE - 4 - FOOTER_SIZE;
-
- res = amqp_decode_method(decoded_frame->payload.method.id,
- &state->decoding_pool, encoded,
- &decoded_frame->payload.method.decoded);
- if (res < 0)
- return res;
-
- break;
-
- case AMQP_FRAME_HEADER:
- decoded_frame->payload.properties.class_id
- = amqp_d16(raw_frame, HEADER_SIZE);
- /* unused 2-byte weight field goes here */
- decoded_frame->payload.properties.body_size
- = amqp_d64(raw_frame, HEADER_SIZE + 4);
- encoded.bytes = amqp_offset(raw_frame, HEADER_SIZE + 12);
- encoded.len = state->target_size - HEADER_SIZE - 12 - FOOTER_SIZE;
- decoded_frame->payload.properties.raw = encoded;
-
- res = amqp_decode_properties(decoded_frame->payload.properties.class_id,
- &state->decoding_pool, encoded,
- &decoded_frame->payload.properties.decoded);
- if (res < 0)
- return res;
-
- break;
-
- case AMQP_FRAME_BODY:
- decoded_frame->payload.body_fragment.len
- = state->target_size - HEADER_SIZE - FOOTER_SIZE;
- decoded_frame->payload.body_fragment.bytes
- = amqp_offset(raw_frame, HEADER_SIZE);
- break;
-
- case AMQP_FRAME_HEARTBEAT:
- break;
-
- default:
- /* Ignore the frame */
- decoded_frame->frame_type = 0;
- break;
- }
-
- return_to_idle(state);
- return bytes_consumed;
- }
-
- default:
- amqp_abort("Internal error: invalid amqp_connection_state_t->state %d", state->state);
- return bytes_consumed;
- }
-}
-
-amqp_boolean_t amqp_release_buffers_ok(amqp_connection_state_t state) {
- return (state->state == CONNECTION_STATE_IDLE) && (state->first_queued_frame == NULL);
-}
-
-void amqp_release_buffers(amqp_connection_state_t state) {
- ENFORCE_STATE(state, CONNECTION_STATE_IDLE);
-
- if (state->first_queued_frame)
- amqp_abort("Programming error: attempt to amqp_release_buffers while waiting events enqueued");
-
- recycle_amqp_pool(&state->frame_pool);
- recycle_amqp_pool(&state->decoding_pool);
-}
-
-void amqp_maybe_release_buffers(amqp_connection_state_t state) {
- if (amqp_release_buffers_ok(state)) {
- amqp_release_buffers(state);
- }
-}
-
-int amqp_send_frame(amqp_connection_state_t state,
- const amqp_frame_t *frame)
-{
- void *out_frame = state->outbound_buffer.bytes;
- int res;
-
- amqp_e8(out_frame, 0, frame->frame_type);
- amqp_e16(out_frame, 1, frame->channel);
-
- if (frame->frame_type == AMQP_FRAME_BODY) {
- /* For a body frame, rather than copying data around, we use
- writev to compose the frame */
- struct iovec iov[3];
- uint8_t frame_end_byte = AMQP_FRAME_END;
- const amqp_bytes_t *body = &frame->payload.body_fragment;
-
- amqp_e32(out_frame, 3, body->len);
-
- iov[0].iov_base = out_frame;
- iov[0].iov_len = HEADER_SIZE;
- iov[1].iov_base = body->bytes;
- iov[1].iov_len = body->len;
- iov[2].iov_base = &frame_end_byte;
- iov[2].iov_len = FOOTER_SIZE;
-
- res = amqp_socket_writev(state->sockfd, iov, 3);
- }
- else {
- size_t out_frame_len;
- amqp_bytes_t encoded;
-
- switch (frame->frame_type) {
- case AMQP_FRAME_METHOD:
- amqp_e32(out_frame, HEADER_SIZE, frame->payload.method.id);
-
- encoded.bytes = amqp_offset(out_frame, HEADER_SIZE + 4);
- encoded.len = state->outbound_buffer.len - HEADER_SIZE - 4 - FOOTER_SIZE;
-
- res = amqp_encode_method(frame->payload.method.id,
- frame->payload.method.decoded, encoded);
- if (res < 0)
- return res;
-
- out_frame_len = res + 4;
- break;
-
- case AMQP_FRAME_HEADER:
- amqp_e16(out_frame, HEADER_SIZE, frame->payload.properties.class_id);
- amqp_e16(out_frame, HEADER_SIZE+2, 0); /* "weight" */
- amqp_e64(out_frame, HEADER_SIZE+4, frame->payload.properties.body_size);
-
- encoded.bytes = amqp_offset(out_frame, HEADER_SIZE + 12);
- encoded.len = state->outbound_buffer.len - HEADER_SIZE - 12 - FOOTER_SIZE;
-
- res = amqp_encode_properties(frame->payload.properties.class_id,
- frame->payload.properties.decoded, encoded);
- if (res < 0)
- return res;
-
- out_frame_len = res + 12;
- break;
-
- case AMQP_FRAME_HEARTBEAT:
- out_frame_len = 0;
- break;
-
- default:
- abort();
- }
-
- amqp_e32(out_frame, 3, out_frame_len);
- amqp_e8(out_frame, out_frame_len + HEADER_SIZE, AMQP_FRAME_END);
- res = send(state->sockfd, out_frame,
- out_frame_len + HEADER_SIZE + FOOTER_SIZE, 0);
- }
-
- if (res < 0)
- return -amqp_socket_error();
- else
- return 0;
-}
diff --git a/librabbitmq/amqp_mem.c b/librabbitmq/amqp_mem.c
deleted file mode 100644
index 3ad8c3e..0000000
--- a/librabbitmq/amqp_mem.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.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 */
-}
-
-void init_amqp_pool(amqp_pool_t *pool, size_t pagesize) {
- pool->pagesize = pagesize ? pagesize : 4096;
-
- pool->pages.num_blocks = 0;
- pool->pages.blocklist = NULL;
-
- pool->large_blocks.num_blocks = 0;
- pool->large_blocks.blocklist = NULL;
-
- pool->next_page = 0;
- pool->alloc_block = NULL;
- pool->alloc_used = 0;
-}
-
-static void empty_blocklist(amqp_pool_blocklist_t *x) {
- int i;
-
- for (i = 0; i < x->num_blocks; i++) {
- free(x->blocklist[i]);
- }
- if (x->blocklist != NULL) {
- free(x->blocklist);
- }
- x->num_blocks = 0;
- x->blocklist = NULL;
-}
-
-void recycle_amqp_pool(amqp_pool_t *pool) {
- empty_blocklist(&pool->large_blocks);
- pool->next_page = 0;
- pool->alloc_block = NULL;
- pool->alloc_used = 0;
-}
-
-void empty_amqp_pool(amqp_pool_t *pool) {
- recycle_amqp_pool(pool);
- empty_blocklist(&pool->pages);
-}
-
-/* Returns 1 on success, 0 on failure */
-static int record_pool_block(amqp_pool_blocklist_t *x, void *block) {
- size_t blocklistlength = sizeof(void *) * (x->num_blocks + 1);
-
- if (x->blocklist == NULL) {
- x->blocklist = malloc(blocklistlength);
- if (x->blocklist == NULL)
- return 0;
- } else {
- void *newbl = realloc(x->blocklist, blocklistlength);
- if (newbl == NULL)
- return 0;
- x->blocklist = newbl;
- }
-
- x->blocklist[x->num_blocks] = block;
- x->num_blocks++;
- return 1;
-}
-
-void *amqp_pool_alloc(amqp_pool_t *pool, size_t amount) {
- if (amount == 0) {
- return NULL;
- }
-
- amount = (amount + 7) & (~7); /* round up to nearest 8-byte boundary */
-
- if (amount > pool->pagesize) {
- void *result = calloc(1, amount);
- if (result == NULL) {
- return NULL;
- }
- if (!record_pool_block(&pool->large_blocks, result))
- return NULL;
- return result;
- }
-
- if (pool->alloc_block != NULL) {
- assert(pool->alloc_used <= pool->pagesize);
-
- if (pool->alloc_used + amount <= pool->pagesize) {
- void *result = pool->alloc_block + pool->alloc_used;
- pool->alloc_used += amount;
- return result;
- }
- }
-
- if (pool->next_page >= pool->pages.num_blocks) {
- pool->alloc_block = calloc(1, pool->pagesize);
- if (pool->alloc_block == NULL) {
- return NULL;
- }
- if (!record_pool_block(&pool->pages, pool->alloc_block))
- return NULL;
- pool->next_page = pool->pages.num_blocks;
- } else {
- pool->alloc_block = pool->pages.blocklist[pool->next_page];
- pool->next_page++;
- }
-
- pool->alloc_used = amount;
-
- return pool->alloc_block;
-}
-
-void amqp_pool_alloc_bytes(amqp_pool_t *pool, size_t amount, amqp_bytes_t *output) {
- output->len = amount;
- output->bytes = amqp_pool_alloc(pool, amount);
-}
-
-amqp_bytes_t amqp_cstring_bytes(char const *cstr) {
- amqp_bytes_t result;
- result.len = strlen(cstr);
- result.bytes = (void *) cstr;
- return result;
-}
-
-amqp_bytes_t amqp_bytes_malloc_dup(amqp_bytes_t src) {
- amqp_bytes_t result;
- result.len = src.len;
- result.bytes = malloc(src.len);
- if (result.bytes != NULL) {
- memcpy(result.bytes, src.bytes, src.len);
- }
- return result;
-}
-
-amqp_bytes_t amqp_bytes_malloc(size_t amount) {
- amqp_bytes_t result;
- result.len = amount;
- result.bytes = malloc(amount); /* will return NULL if it fails */
- return result;
-}
-
-void amqp_bytes_free(amqp_bytes_t bytes) {
- free(bytes.bytes);
-}
diff --git a/librabbitmq/amqp_private.h b/librabbitmq/amqp_private.h
deleted file mode 100644
index eaf6b2c..0000000
--- a/librabbitmq/amqp_private.h
+++ /dev/null
@@ -1,251 +0,0 @@
-#ifndef librabbitmq_amqp_private_h
-#define librabbitmq_amqp_private_h
-
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include "config.h"
-
-/* Error numbering: Because of differences in error numbering on
- * different platforms, we want to keep error numbers opaque for
- * client code. Internally, we encode the category of an error
- * (i.e. where its number comes from) in the top bits of the number
- * (assuming that an int has at least 32 bits).
- */
-#define ERROR_CATEGORY_MASK (1 << 29)
-
-#define ERROR_CATEGORY_CLIENT (0 << 29) /* librabbitmq error codes */
-#define ERROR_CATEGORY_OS (1 << 29) /* OS-specific error codes */
-
-/* librabbitmq error codes */
-#define ERROR_NO_MEMORY 1
-#define ERROR_BAD_AMQP_DATA 2
-#define ERROR_UNKNOWN_CLASS 3
-#define ERROR_UNKNOWN_METHOD 4
-#define ERROR_GETHOSTBYNAME_FAILED 5
-#define ERROR_INCOMPATIBLE_AMQP_VERSION 6
-#define ERROR_CONNECTION_CLOSED 7
-#define ERROR_MAX 7
-
-extern char *amqp_os_error_string(int err);
-
-#include "socket.h"
-
-/*
- * Connection states: XXX FIX THIS
- *
- * - CONNECTION_STATE_INITIAL: The initial state, when we cannot be
- * sure if the next thing we will get is the first AMQP frame, or a
- * protocol header from the server.
- *
- * - CONNECTION_STATE_IDLE: The normal state between
- * frames. Connections may only be reconfigured, and the
- * connection's pools recycled, when in this state. Whenever we're
- * in this state, the inbound_buffer's bytes pointer must be NULL;
- * any other state, and it must point to a block of memory allocated
- * from the frame_pool.
- *
- * - CONNECTION_STATE_HEADER: Some bytes of an incoming frame have
- * been seen, but not a complete frame header's worth.
- *
- * - CONNECTION_STATE_BODY: A complete frame header has been seen, but
- * the frame is not yet complete. When it is completed, it will be
- * returned, and the connection will return to IDLE state.
- *
- */
-typedef enum amqp_connection_state_enum_ {
- CONNECTION_STATE_IDLE = 0,
- CONNECTION_STATE_INITIAL,
- CONNECTION_STATE_HEADER,
- CONNECTION_STATE_BODY
-} amqp_connection_state_enum;
-
-/* 7 bytes up front, then payload, then 1 byte footer */
-#define HEADER_SIZE 7
-#define FOOTER_SIZE 1
-
-#define AMQP_PSEUDOFRAME_PROTOCOL_HEADER 'A'
-
-typedef struct amqp_link_t_ {
- struct amqp_link_t_ *next;
- void *data;
-} amqp_link_t;
-
-struct amqp_connection_state_t_ {
- amqp_pool_t frame_pool;
- amqp_pool_t decoding_pool;
-
- amqp_connection_state_enum state;
-
- int channel_max;
- int frame_max;
- int heartbeat;
- amqp_bytes_t inbound_buffer;
-
- size_t inbound_offset;
- size_t target_size;
-
- amqp_bytes_t outbound_buffer;
-
- int sockfd;
- amqp_bytes_t sock_inbound_buffer;
- size_t sock_inbound_offset;
- size_t sock_inbound_limit;
-
- amqp_link_t *first_queued_frame;
- amqp_link_t *last_queued_frame;
-
- amqp_rpc_reply_t most_recent_api_result;
-};
-
-static inline void *amqp_offset(void *data, size_t offset)
-{
- return (char *)data + offset;
-}
-
-/* assuming a machine that supports unaligned accesses (for now) */
-
-#define DECLARE_CODEC_BASE_TYPE(bits, htonx, ntohx) \
- \
-static inline void amqp_e##bits(void *data, size_t offset, \
- uint##bits##_t val) \
-{ \
- *(uint##bits##_t *)amqp_offset(data, offset) = htonx(val); \
-} \
- \
-static inline uint##bits##_t amqp_d##bits(void *data, size_t offset) \
-{ \
- return ntohx(*(uint##bits##_t *)amqp_offset(data, offset)); \
-} \
- \
-static inline int amqp_encode_##bits(amqp_bytes_t encoded, size_t *offset, \
- uint##bits##_t input) \
- \
-{ \
- size_t o = *offset; \
- if ((*offset = o + bits / 8) <= encoded.len) { \
- amqp_e##bits(encoded.bytes, o, input); \
- return 1; \
- } \
- else { \
- return 0; \
- } \
-} \
- \
-static inline int amqp_decode_##bits(amqp_bytes_t encoded, size_t *offset, \
- uint##bits##_t *output) \
- \
-{ \
- size_t o = *offset; \
- if ((*offset = o + bits / 8) <= encoded.len) { \
- *output = amqp_d##bits(encoded.bytes, o); \
- *output = ntohx(*(uint##bits##_t *)((char *)encoded.bytes + o)); \
- return 1; \
- } \
- else { \
- return 0; \
- } \
-}
-
-/* assuming little endian (for now) */
-
-#define DECLARE_XTOXLL(func) \
-static inline uint64_t func##ll(uint64_t val) \
-{ \
- union { \
- uint64_t whole; \
- uint32_t halves[2]; \
- } u; \
- uint32_t t; \
- u.whole = val; \
- t = u.halves[0]; \
- u.halves[0] = func##l(u.halves[1]); \
- u.halves[1] = func##l(t); \
- return u.whole; \
-}
-
-DECLARE_XTOXLL(hton)
-DECLARE_XTOXLL(ntoh)
-
-DECLARE_CODEC_BASE_TYPE(8, (uint8_t), (uint8_t))
-DECLARE_CODEC_BASE_TYPE(16, htons, ntohs)
-DECLARE_CODEC_BASE_TYPE(32, htonl, ntohl)
-DECLARE_CODEC_BASE_TYPE(64, htonll, ntohll)
-
-static inline int amqp_encode_bytes(amqp_bytes_t encoded, size_t *offset,
- amqp_bytes_t input)
-{
- size_t o = *offset;
- if ((*offset = o + input.len) <= encoded.len) {
- memcpy(amqp_offset(encoded.bytes, o), input.bytes, input.len);
- return 1;
- }
- else {
- return 0;
- }
-}
-
-static inline int amqp_decode_bytes(amqp_bytes_t encoded, size_t *offset,
- amqp_bytes_t *output, size_t len)
-{
- size_t o = *offset;
- if ((*offset = o + len) <= encoded.len) {
- output->bytes = amqp_offset(encoded.bytes, o);
- output->len = len;
- return 1;
- }
- else {
- return 0;
- }
-}
-
-extern void amqp_abort(const char *fmt, ...);
-
-#endif
diff --git a/librabbitmq/amqp_socket.c b/librabbitmq/amqp_socket.c
deleted file mode 100644
index f23b42b..0000000
--- a/librabbitmq/amqp_socket.c
+++ /dev/null
@@ -1,497 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#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)
-{
- int sockfd, res;
- struct sockaddr_in addr;
- struct hostent *he;
- int one = 1; /* used as a buffer by setsockopt below */
-
- res = amqp_socket_init();
- if (res)
- return res;
-
- he = gethostbyname(hostname);
- if (he == NULL)
- return -ERROR_GETHOSTBYNAME_FAILED;
-
- addr.sin_family = AF_INET;
- addr.sin_port = htons(portnumber);
- addr.sin_addr.s_addr = * (uint32_t *) he->h_addr_list[0];
-
- sockfd = socket(PF_INET, SOCK_STREAM, 0);
- if (sockfd == -1)
- return -amqp_socket_error();
-
- if (amqp_socket_setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &one,
- sizeof(one)) < 0
- || connect(sockfd, (struct sockaddr *) &addr, sizeof(addr)) < 0)
- {
- res = -amqp_socket_error();
- amqp_socket_close(sockfd);
- return res;
- }
-
- return sockfd;
-}
-
-int amqp_send_header(amqp_connection_state_t state) {
- static const uint8_t header[8] = { 'A', 'M', 'Q', 'P', 0,
- AMQP_PROTOCOL_VERSION_MAJOR,
- AMQP_PROTOCOL_VERSION_MINOR,
- AMQP_PROTOCOL_VERSION_REVISION };
- return send(state->sockfd, (void *)header, 8, 0);
-}
-
-static amqp_bytes_t sasl_method_name(amqp_sasl_method_enum method) {
- amqp_bytes_t res;
-
- switch (method) {
- case AMQP_SASL_METHOD_PLAIN:
- res.bytes = "PLAIN";
- res.len = 5;
- break;
-
- default:
- amqp_abort("Invalid SASL method: %d", (int) method);
- }
-
- return res;
-}
-
-static amqp_bytes_t sasl_response(amqp_pool_t *pool,
- amqp_sasl_method_enum method,
- va_list args)
-{
- amqp_bytes_t response;
-
- switch (method) {
- case AMQP_SASL_METHOD_PLAIN: {
- char *username = va_arg(args, char *);
- size_t username_len = strlen(username);
- char *password = va_arg(args, char *);
- size_t password_len = strlen(password);
- char *response_buf;
-
- amqp_pool_alloc_bytes(pool, strlen(username) + strlen(password) + 2, &response);
- if (response.bytes == NULL)
- /* We never request a zero-length block, because of the +2
- above, so a NULL here really is ENOMEM. */
- return response;
-
- response_buf = response.bytes;
- response_buf[0] = 0;
- memcpy(response_buf + 1, username, username_len);
- response_buf[username_len + 1] = 0;
- memcpy(response_buf + username_len + 2, password, password_len);
- break;
- }
- default:
- amqp_abort("Invalid SASL method: %d", (int) method);
- }
-
- return response;
-}
-
-amqp_boolean_t amqp_frames_enqueued(amqp_connection_state_t state) {
- return (state->first_queued_frame != NULL);
-}
-
-/*
- * Check to see if we have data in our buffer. If this returns 1, we
- * will avoid an immediate blocking read in amqp_simple_wait_frame.
- */
-amqp_boolean_t amqp_data_in_buffer(amqp_connection_state_t state) {
- return (state->sock_inbound_offset < state->sock_inbound_limit);
-}
-
-static int wait_frame_inner(amqp_connection_state_t state,
- amqp_frame_t *decoded_frame)
-{
- while (1) {
- int res;
-
- while (amqp_data_in_buffer(state)) {
- amqp_bytes_t buffer;
- buffer.len = state->sock_inbound_limit - state->sock_inbound_offset;
- buffer.bytes = ((char *) state->sock_inbound_buffer.bytes) + state->sock_inbound_offset;
-
- res = amqp_handle_input(state, buffer, decoded_frame);
- if (res < 0)
- return res;
-
- state->sock_inbound_offset += res;
-
- if (decoded_frame->frame_type != 0)
- /* Complete frame was read. Return it. */
- return 0;
-
- /* Incomplete or ignored frame. Keep processing input. */
- assert(res != 0);
- }
-
- res = recv(state->sockfd, state->sock_inbound_buffer.bytes,
- state->sock_inbound_buffer.len, 0);
- if (res <= 0) {
- if (res == 0)
- return -ERROR_CONNECTION_CLOSED;
- else
- return -amqp_socket_error();
- }
-
- state->sock_inbound_limit = res;
- state->sock_inbound_offset = 0;
- }
-}
-
-int amqp_simple_wait_frame(amqp_connection_state_t state,
- amqp_frame_t *decoded_frame)
-{
- if (state->first_queued_frame != NULL) {
- amqp_frame_t *f = (amqp_frame_t *) state->first_queued_frame->data;
- state->first_queued_frame = state->first_queued_frame->next;
- if (state->first_queued_frame == NULL) {
- state->last_queued_frame = NULL;
- }
- *decoded_frame = *f;
- return 0;
- } else {
- return wait_frame_inner(state, decoded_frame);
- }
-}
-
-int amqp_simple_wait_method(amqp_connection_state_t state,
- amqp_channel_t expected_channel,
- amqp_method_number_t expected_method,
- amqp_method_t *output)
-{
- amqp_frame_t frame;
- int res = amqp_simple_wait_frame(state, &frame);
- if (res < 0)
- return res;
-
- if (frame.channel != expected_channel)
- amqp_abort("Expected 0x%08X method frame on channel %d, got frame on channel %d",
- expected_method,
- expected_channel,
- frame.channel);
- if (frame.frame_type != AMQP_FRAME_METHOD)
- amqp_abort("Expected 0x%08X method frame on channel %d, got frame type %d",
- expected_method,
- expected_channel,
- frame.frame_type);
- if (frame.payload.method.id != expected_method)
- amqp_abort("Expected method ID 0x%08X on channel %d, got ID 0x%08X",
- expected_method,
- expected_channel,
- frame.payload.method.id);
- *output = frame.payload.method;
- return 0;
-}
-
-int amqp_send_method(amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_method_number_t id,
- void *decoded)
-{
- amqp_frame_t frame;
-
- frame.frame_type = AMQP_FRAME_METHOD;
- frame.channel = channel;
- frame.payload.method.id = id;
- frame.payload.method.decoded = decoded;
- return amqp_send_frame(state, &frame);
-}
-
-static int amqp_id_in_reply_list( amqp_method_number_t expected, amqp_method_number_t *list )
-{
- while ( *list != 0 ) {
- if ( *list == expected ) return 1;
- list++;
- }
- return 0;
-}
-
-amqp_rpc_reply_t amqp_simple_rpc(amqp_connection_state_t state,
- amqp_channel_t channel,
- amqp_method_number_t request_id,
- amqp_method_number_t *expected_reply_ids,
- void *decoded_request_method)
-{
- int status;
- amqp_rpc_reply_t result;
-
- memset(&result, 0, sizeof(result));
-
- status = amqp_send_method(state, channel, request_id, decoded_request_method);
- if (status < 0) {
- result.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
- result.library_error = -status;
- return result;
- }
-
- {
- amqp_frame_t frame;
-
- retry:
- status = wait_frame_inner(state, &frame);
- if (status < 0) {
- result.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
- result.library_error = -status;
- return result;
- }
-
- /*
- * We store the frame for later processing unless it's something
- * that directly affects us here, namely a method frame that is
- * either
- * - on the channel we want, and of the expected type, or
- * - on the channel we want, and a channel.close frame, or
- * - on channel zero, and a connection.close frame.
- */
- if (!( (frame.frame_type == AMQP_FRAME_METHOD) &&
- ( ((frame.channel == channel) &&
- ((amqp_id_in_reply_list(frame.payload.method.id, expected_reply_ids)) ||
- (frame.payload.method.id == AMQP_CHANNEL_CLOSE_METHOD)))
- ||
- ((frame.channel == 0) &&
- (frame.payload.method.id == AMQP_CONNECTION_CLOSE_METHOD)) ) ))
- {
- amqp_frame_t *frame_copy = amqp_pool_alloc(&state->decoding_pool, sizeof(amqp_frame_t));
- amqp_link_t *link = amqp_pool_alloc(&state->decoding_pool, sizeof(amqp_link_t));
-
- if (frame_copy == NULL || link == NULL) {
- result.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
- result.library_error = ERROR_NO_MEMORY;
- return result;
- }
-
- *frame_copy = frame;
-
- link->next = NULL;
- link->data = frame_copy;
-
- if (state->last_queued_frame == NULL) {
- state->first_queued_frame = link;
- } else {
- state->last_queued_frame->next = link;
- }
- state->last_queued_frame = link;
-
- goto retry;
- }
-
- result.reply_type = (amqp_id_in_reply_list(frame.payload.method.id, expected_reply_ids))
- ? AMQP_RESPONSE_NORMAL
- : AMQP_RESPONSE_SERVER_EXCEPTION;
-
- result.reply = frame.payload.method;
- return result;
- }
-}
-
-static int amqp_login_inner(amqp_connection_state_t state,
- int channel_max,
- int frame_max,
- int heartbeat,
- amqp_sasl_method_enum sasl_method,
- va_list vl)
-{
- int res;
- amqp_method_t method;
- uint32_t server_frame_max;
- uint16_t server_channel_max;
- uint16_t server_heartbeat;
-
- amqp_send_header(state);
-
- res = amqp_simple_wait_method(state, 0, AMQP_CONNECTION_START_METHOD,
- &method);
- if (res < 0)
- return res;
-
- {
- amqp_connection_start_t *s = (amqp_connection_start_t *) method.decoded;
- if ((s->version_major != AMQP_PROTOCOL_VERSION_MAJOR) ||
- (s->version_minor != AMQP_PROTOCOL_VERSION_MINOR)) {
- return -ERROR_INCOMPATIBLE_AMQP_VERSION;
- }
-
- /* TODO: check that our chosen SASL mechanism is in the list of
- acceptable mechanisms. Or even let the application choose from
- the list! */
- }
-
- {
- amqp_connection_start_ok_t s;
- amqp_bytes_t response_bytes = sasl_response(&state->decoding_pool,
- sasl_method, vl);
-
- if (response_bytes.bytes == NULL)
- return -ERROR_NO_MEMORY;
-
- s.client_properties.num_entries = 0;
- s.client_properties.entries = NULL;
- s.mechanism = sasl_method_name(sasl_method);
- s.response = response_bytes;
- s.locale.bytes = "en_US";
- s.locale.len = 5;
-
- res = amqp_send_method(state, 0, AMQP_CONNECTION_START_OK_METHOD, &s);
- if (res < 0)
- return res;
- }
-
- amqp_release_buffers(state);
-
- res = amqp_simple_wait_method(state, 0, AMQP_CONNECTION_TUNE_METHOD,
- &method);
- if (res < 0)
- return res;
-
- {
- amqp_connection_tune_t *s = (amqp_connection_tune_t *) method.decoded;
- server_channel_max = s->channel_max;
- server_frame_max = s->frame_max;
- server_heartbeat = s->heartbeat;
- }
-
- if (server_channel_max != 0 && server_channel_max < channel_max)
- channel_max = server_channel_max;
-
- if (server_frame_max != 0 && server_frame_max < frame_max)
- frame_max = server_frame_max;
-
- if (server_heartbeat != 0 && server_heartbeat < heartbeat)
- heartbeat = server_heartbeat;
-
- res = amqp_tune_connection(state, channel_max, frame_max, heartbeat);
- if (res < 0)
- return res;
-
- {
- amqp_connection_tune_ok_t s;
- s.frame_max = frame_max;
- s.channel_max = channel_max;
- s.heartbeat = heartbeat;
-
- res = amqp_send_method(state, 0, AMQP_CONNECTION_TUNE_OK_METHOD, &s);
- if (res < 0)
- return res;
- }
-
- amqp_release_buffers(state);
-
- return 0;
-}
-
-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,
- ...)
-{
- va_list vl;
- amqp_rpc_reply_t result;
- int status;
-
- va_start(vl, sasl_method);
-
- status = amqp_login_inner(state, channel_max, frame_max, heartbeat, sasl_method, vl);
- if (status < 0) {
- result.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
- result.reply.id = 0;
- result.reply.decoded = NULL;
- result.library_error = -status;
- return result;
- }
-
- {
- amqp_method_number_t replies[] = { AMQP_CONNECTION_OPEN_OK_METHOD, 0 };
- amqp_connection_open_t s;
- s.virtual_host = amqp_cstring_bytes(vhost);
- s.capabilities.len = 0;
- s.capabilities.bytes = NULL;
- s.insist = 1;
-
- result = amqp_simple_rpc(state,
- 0,
- AMQP_CONNECTION_OPEN_METHOD,
- (amqp_method_number_t *) &replies,
- &s);
- if (result.reply_type != AMQP_RESPONSE_NORMAL)
- return result;
- }
- amqp_maybe_release_buffers(state);
-
- va_end(vl);
-
- result.reply_type = AMQP_RESPONSE_NORMAL;
- result.reply.id = 0;
- result.reply.decoded = NULL;
- result.library_error = 0;
- return result;
-}
diff --git a/librabbitmq/amqp_table.c b/librabbitmq/amqp_table.c
deleted file mode 100644
index e85217f..0000000
--- a/librabbitmq/amqp_table.c
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-
-#include "amqp.h"
-#include "amqp_private.h"
-
-#include <assert.h>
-
-#define INITIAL_ARRAY_SIZE 16
-#define INITIAL_TABLE_SIZE 16
-
-static int amqp_decode_field_value(amqp_bytes_t encoded,
- amqp_pool_t *pool,
- amqp_field_value_t *entry,
- size_t *offset);
-
-static int amqp_encode_field_value(amqp_bytes_t encoded,
- amqp_field_value_t *entry,
- size_t *offset);
-
-/*---------------------------------------------------------------------------*/
-
-static int amqp_decode_array(amqp_bytes_t encoded,
- amqp_pool_t *pool,
- amqp_array_t *output,
- size_t *offset)
-{
- uint32_t arraysize;
- int num_entries = 0;
- int allocated_entries = INITIAL_ARRAY_SIZE;
- amqp_field_value_t *entries;
- size_t limit;
- int res;
-
- if (!amqp_decode_32(encoded, offset, &arraysize))
- return -ERROR_BAD_AMQP_DATA;
-
- entries = malloc(allocated_entries * sizeof(amqp_field_value_t));
- if (entries == NULL)
- return -ERROR_NO_MEMORY;
-
- limit = *offset + arraysize;
- while (*offset < limit) {
- if (num_entries >= allocated_entries) {
- void *newentries;
- allocated_entries = allocated_entries * 2;
- newentries = realloc(entries, allocated_entries * sizeof(amqp_field_value_t));
- res = -ERROR_NO_MEMORY;
- if (newentries == NULL)
- goto out;
-
- entries = newentries;
- }
-
- res = amqp_decode_field_value(encoded, pool, &entries[num_entries],
- offset);
- if (res < 0)
- goto out;
-
- num_entries++;
- }
-
- output->num_entries = num_entries;
- output->entries = amqp_pool_alloc(pool, num_entries * sizeof(amqp_field_value_t));
- res = -ERROR_NO_MEMORY;
- /* NULL is legitimate if we requested a zero-length block. */
- if (output->entries == NULL && num_entries > 0)
- goto out;
-
- memcpy(output->entries, entries, num_entries * sizeof(amqp_field_value_t));
- res = 0;
-
- out:
- free(entries);
- return res;
-}
-
-int amqp_decode_table(amqp_bytes_t encoded,
- amqp_pool_t *pool,
- amqp_table_t *output,
- size_t *offset)
-{
- uint32_t tablesize;
- int num_entries = 0;
- amqp_table_entry_t *entries;
- int allocated_entries = INITIAL_TABLE_SIZE;
- size_t limit;
- int res;
-
- if (!amqp_decode_32(encoded, offset, &tablesize))
- return -ERROR_BAD_AMQP_DATA;
-
- entries = malloc(allocated_entries * sizeof(amqp_table_entry_t));
- if (entries == NULL)
- return -ERROR_NO_MEMORY;
-
- limit = *offset + tablesize;
- while (*offset < limit) {
- uint8_t keylen;
-
- res = -ERROR_BAD_AMQP_DATA;
- if (!amqp_decode_8(encoded, offset, &keylen))
- goto out;
-
- if (num_entries >= allocated_entries) {
- void *newentries;
- allocated_entries = allocated_entries * 2;
- newentries = realloc(entries, allocated_entries * sizeof(amqp_table_entry_t));
- res = -ERROR_NO_MEMORY;
- if (newentries == NULL)
- goto out;
-
- entries = newentries;
- }
-
- res = -ERROR_BAD_AMQP_DATA;
- if (!amqp_decode_bytes(encoded, offset, &entries[num_entries].key, keylen))
- goto out;
-
- res = amqp_decode_field_value(encoded, pool, &entries[num_entries].value,
- offset);
- if (res < 0)
- goto out;
-
- num_entries++;
- }
-
- output->num_entries = num_entries;
- output->entries = amqp_pool_alloc(pool, num_entries * sizeof(amqp_table_entry_t));
- res = -ERROR_NO_MEMORY;
- /* NULL is legitimate if we requested a zero-length block. */
- if (output->entries == NULL && num_entries > 0)
- goto out;
-
- memcpy(output->entries, entries, num_entries * sizeof(amqp_table_entry_t));
- res = 0;
-
- out:
- free(entries);
- return res;
-}
-
-static int amqp_decode_field_value(amqp_bytes_t encoded,
- amqp_pool_t *pool,
- amqp_field_value_t *entry,
- size_t *offset)
-{
- int res = -ERROR_BAD_AMQP_DATA;
-
- if (!amqp_decode_8(encoded, offset, &entry->kind))
- goto out;
-
-#define TRIVIAL_FIELD_DECODER(bits) if (!amqp_decode_##bits(encoded, offset, &entry->value.u##bits)) goto out; break
-#define SIMPLE_FIELD_DECODER(bits, dest, how) { uint##bits##_t val; if (!amqp_decode_##bits(encoded, offset, &val)) goto out; entry->value.dest = how; } break
-
- switch (entry->kind) {
- case AMQP_FIELD_KIND_BOOLEAN:
- SIMPLE_FIELD_DECODER(8, boolean, val ? 1 : 0);
-
- case AMQP_FIELD_KIND_I8:
- SIMPLE_FIELD_DECODER(8, i8, (int8_t)val);
- case AMQP_FIELD_KIND_U8:
- TRIVIAL_FIELD_DECODER(8);
-
- case AMQP_FIELD_KIND_I16:
- SIMPLE_FIELD_DECODER(16, i16, (int16_t)val);
- case AMQP_FIELD_KIND_U16:
- TRIVIAL_FIELD_DECODER(16);
-
- case AMQP_FIELD_KIND_I32:
- SIMPLE_FIELD_DECODER(32, i32, (int32_t)val);
- case AMQP_FIELD_KIND_U32:
- TRIVIAL_FIELD_DECODER(32);
-
- case AMQP_FIELD_KIND_I64:
- SIMPLE_FIELD_DECODER(64, i64, (int64_t)val);
- case AMQP_FIELD_KIND_U64:
- TRIVIAL_FIELD_DECODER(64);
-
- case AMQP_FIELD_KIND_F32:
- TRIVIAL_FIELD_DECODER(32);
- /* and by punning, f32 magically gets the right value...! */
-
- case AMQP_FIELD_KIND_F64:
- TRIVIAL_FIELD_DECODER(64);
- /* and by punning, f64 magically gets the right value...! */
-
- case AMQP_FIELD_KIND_DECIMAL:
- if (!amqp_decode_8(encoded, offset, &entry->value.decimal.decimals)
- || !amqp_decode_32(encoded, offset, &entry->value.decimal.value))
- goto out;
- break;
-
- case AMQP_FIELD_KIND_UTF8:
- /* AMQP_FIELD_KIND_UTF8 and AMQP_FIELD_KIND_BYTES have the
- same implementation, but different interpretations. */
- /* fall through */
- case AMQP_FIELD_KIND_BYTES: {
- uint32_t len;
- if (!amqp_decode_32(encoded, offset, &len)
- || !amqp_decode_bytes(encoded, offset, &entry->value.bytes, len))
- goto out;
- break;
- }
-
- case AMQP_FIELD_KIND_ARRAY:
- res = amqp_decode_array(encoded, pool, &(entry->value.array), offset);
- goto out;
-
- case AMQP_FIELD_KIND_TIMESTAMP:
- TRIVIAL_FIELD_DECODER(64);
-
- case AMQP_FIELD_KIND_TABLE:
- res = amqp_decode_table(encoded, pool, &(entry->value.table), offset);
- goto out;
-
- case AMQP_FIELD_KIND_VOID:
- break;
-
- default:
- goto out;
- }
-
- res = 0;
-
- out:
- return res;
-}
-
-/*---------------------------------------------------------------------------*/
-
-static int amqp_encode_array(amqp_bytes_t encoded,
- amqp_array_t *input,
- size_t *offset)
-{
- size_t start = *offset;
- int i, res;
-
- *offset += 4; /* size of the array gets filled in later on */
-
- for (i = 0; i < input->num_entries; i++) {
- res = amqp_encode_field_value(encoded, &input->entries[i], offset);
- if (res < 0)
- goto out;
- }
-
- if (amqp_encode_32(encoded, &start, *offset - start - 4))
- res = 0;
- else
- res = -ERROR_BAD_AMQP_DATA;
-
- out:
- return res;
-}
-
-int amqp_encode_table(amqp_bytes_t encoded,
- amqp_table_t *input,
- size_t *offset)
-{
- size_t start = *offset;
- int i, res;
-
- *offset += 4; /* size of the table gets filled in later on */
-
- for (i = 0; i < input->num_entries; i++) {
- res = amqp_encode_8(encoded, offset, input->entries[i].key.len);
- if (res < 0)
- goto out;
-
- res = amqp_encode_bytes(encoded, offset, input->entries[i].key);
- if (res < 0)
- goto out;
-
- res = amqp_encode_field_value(encoded, &input->entries[i].value, offset);
- if (res < 0)
- goto out;
- }
-
- if (amqp_encode_32(encoded, &start, *offset - start - 4))
- res = 0;
- else
- res = -ERROR_BAD_AMQP_DATA;
-
- out:
- return res;
-}
-
-static int amqp_encode_field_value(amqp_bytes_t encoded,
- amqp_field_value_t *entry,
- size_t *offset)
-{
- int res = -ERROR_BAD_AMQP_DATA;
-
- if (!amqp_encode_8(encoded, offset, entry->kind))
- goto out;
-
-#define FIELD_ENCODER(bits, val) if (!amqp_encode_##bits(encoded, offset, val)) goto out; break
-
- switch (entry->kind) {
- case AMQP_FIELD_KIND_BOOLEAN:
- FIELD_ENCODER(8, entry->value.boolean ? 1 : 0);
-
- case AMQP_FIELD_KIND_I8:
- FIELD_ENCODER(8, entry->value.i8);
- case AMQP_FIELD_KIND_U8:
- FIELD_ENCODER(8, entry->value.u8);
-
- case AMQP_FIELD_KIND_I16:
- FIELD_ENCODER(16, entry->value.i16);
- case AMQP_FIELD_KIND_U16:
- FIELD_ENCODER(16, entry->value.u16);
-
- case AMQP_FIELD_KIND_I32:
- FIELD_ENCODER(32, entry->value.i32);
- case AMQP_FIELD_KIND_U32:
- FIELD_ENCODER(32, entry->value.u32);
-
- case AMQP_FIELD_KIND_I64:
- FIELD_ENCODER(64, entry->value.i64);
- case AMQP_FIELD_KIND_U64:
- FIELD_ENCODER(64, entry->value.u64);
-
- case AMQP_FIELD_KIND_F32:
- /* by punning, u32 magically gets the right value...! */
- FIELD_ENCODER(32, entry->value.u32);
-
- case AMQP_FIELD_KIND_F64:
- /* by punning, u64 magically gets the right value...! */
- FIELD_ENCODER(64, entry->value.u64);
-
- case AMQP_FIELD_KIND_DECIMAL:
- if (!amqp_encode_8(encoded, offset, entry->value.decimal.decimals)
- || !amqp_encode_32(encoded, offset, entry->value.decimal.value))
- goto out;
- break;
-
- case AMQP_FIELD_KIND_UTF8:
- /* AMQP_FIELD_KIND_UTF8 and AMQP_FIELD_KIND_BYTES have the
- same implementation, but different interpretations. */
- /* fall through */
- case AMQP_FIELD_KIND_BYTES:
- if (!amqp_encode_32(encoded, offset, entry->value.bytes.len)
- || !amqp_encode_bytes(encoded, offset, entry->value.bytes))
- goto out;
- break;
-
- case AMQP_FIELD_KIND_ARRAY:
- res = amqp_encode_array(encoded, &entry->value.array, offset);
- goto out;
-
- case AMQP_FIELD_KIND_TIMESTAMP:
- FIELD_ENCODER(64, entry->value.u64);
-
- case AMQP_FIELD_KIND_TABLE:
- res = amqp_encode_table(encoded, &entry->value.table, offset);
- goto out;
-
- case AMQP_FIELD_KIND_VOID:
- break;
-
- default:
- abort();
- }
-
- res = 0;
-
- out:
- return res;
-}
-
-/*---------------------------------------------------------------------------*/
-
-int amqp_table_entry_cmp(void const *entry1, void const *entry2) {
- amqp_table_entry_t const *p1 = (amqp_table_entry_t const *) entry1;
- amqp_table_entry_t const *p2 = (amqp_table_entry_t const *) entry2;
-
- int d;
- int minlen;
-
- minlen = p1->key.len;
- if (p2->key.len < minlen) minlen = p2->key.len;
-
- d = memcmp(p1->key.bytes, p2->key.bytes, minlen);
- if (d != 0) {
- return d;
- }
-
- return p1->key.len - p2->key.len;
-}
diff --git a/librabbitmq/codegen.py b/librabbitmq/codegen.py
deleted file mode 100644
index 6fd149e..0000000
--- a/librabbitmq/codegen.py
+++ /dev/null
@@ -1,531 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0
-#
-# The contents of this file are subject to the Mozilla Public License
-# Version 1.1 (the "License"); you may not use this file except in
-# compliance with the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS"
-# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-# the License for the specific language governing rights and
-# limitations under the License.
-#
-# The Original Code is librabbitmq.
-#
-# The Initial Developers of the Original Code are LShift Ltd, Cohesive
-# Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
-# created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
-# Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
-# (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
-# Rabbit Technologies Ltd.
-#
-# Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
-# Ltd. Portions created by Cohesive Financial Technologies LLC are
-# Copyright (C) 2007-2009 Cohesive Financial Technologies
-# LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
-# 2007-2009 Rabbit Technologies Ltd.
-#
-# Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
-# LShift Ltd and Tony Garnock-Jones.
-#
-# All Rights Reserved.
-#
-# Contributor(s): ______________________________________.
-#
-# Alternatively, the contents of this file may be used under the terms
-# of the GNU General Public License Version 2 or later (the "GPL"), in
-# which case the provisions of the GPL are applicable instead of those
-# above. If you wish to allow use of your version of this file only
-# under the terms of the GPL, and not to allow others to use your
-# version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the
-# notice and other provisions required by the GPL. If you do not
-# delete the provisions above, a recipient may use your version of
-# this file under the terms of any one of the MPL or the GPL.
-#
-# ***** END LICENSE BLOCK *****
-
-from __future__ import nested_scopes
-
-from amqp_codegen import *
-import string
-import re
-
-
-class Emitter(object):
- """An object the trivially emits generated code lines.
-
- This largely exists to be wrapped by more sophisticated emitter
- classes.
- """
-
- def __init__(self, prefix):
- self.prefix = prefix
-
- def emit(self, line):
- """Emit a line of generated code."""
- print self.prefix + line
-
-
-class BitDecoder(object):
- """An emitter object that keeps track of the state involved in
- decoding the AMQP bit type."""
-
- def __init__(self, emitter):
- self.emitter = emitter
- self.bit = 0
-
- def emit(self, line):
- self.bit = 0
- self.emitter.emit(line)
-
- def decode_bit(self, lvalue):
- """Generate code to decode a value of the AMQP bit type into
- the given lvalue."""
- if self.bit == 0:
- self.emitter.emit("if (!amqp_decode_8(encoded, &offset, &bit_buffer)) return -ERROR_BAD_AMQP_DATA;")
-
- self.emitter.emit("%s = (bit_buffer & (1 << %d)) ? 1 : 0;"
- % (lvalue, self.bit))
- self.bit += 1
- if self.bit == 8:
- self.bit = 0
-
-
-class BitEncoder(object):
- """An emitter object that keeps track of the state involved in
- encoding the AMQP bit type."""
-
- def __init__(self, emitter):
- self.emitter = emitter
- self.bit = 0
-
- def flush(self):
- """Flush the state associated with AMQP bit types."""
- if self.bit:
- self.emitter.emit("if (!amqp_encode_8(encoded, &offset, bit_buffer)) return -ERROR_BAD_AMQP_DATA;")
- self.bit = 0
-
- def emit(self, line):
- self.flush()
- self.emitter.emit(line)
-
- def encode_bit(self, value):
- """Generate code to ebcode a value of the AMQP bit type from
- the given value."""
- if self.bit == 0:
- self.emitter.emit("bit_buffer = 0;")
-
- self.emitter.emit("if (%s) bit_buffer |= (1 << %d);"
- % (value, self.bit))
- self.bit += 1
- if self.bit == 8:
- self.flush()
-
-
-class SimpleType(object):
- """A AMQP type that corresponds to a simple scalar C value of a
- certain width."""
-
- def __init__(self, bits):
- self.bits = bits
- self.ctype = "uint%d_t" % (bits,)
-
- def decode(self, emitter, lvalue):
- emitter.emit("if (!amqp_decode_%d(encoded, &offset, &%s)) return -ERROR_BAD_AMQP_DATA;" % (self.bits, lvalue))
-
- def encode(self, emitter, value):
- emitter.emit("if (!amqp_encode_%d(encoded, &offset, %s)) return -ERROR_BAD_AMQP_DATA;" % (self.bits, value))
-
-
-class StrType(object):
- """The AMQP shortstr or longstr types."""
-
- def __init__(self, lenbits):
- self.lenbits = lenbits
- self.ctype = "amqp_bytes_t"
-
- def decode(self, emitter, lvalue):
- emitter.emit("{")
- emitter.emit(" uint%d_t len;" % (self.lenbits,))
- emitter.emit(" if (!amqp_decode_%d(encoded, &offset, &len)" % (self.lenbits,))
- emitter.emit(" || !amqp_decode_bytes(encoded, &offset, &%s, len))" % (lvalue,))
- emitter.emit(" return -ERROR_BAD_AMQP_DATA;")
- emitter.emit("}")
-
- def encode(self, emitter, value):
- emitter.emit("if (!amqp_encode_%d(encoded, &offset, %s.len)" % (self.lenbits, value))
- emitter.emit(" || !amqp_encode_bytes(encoded, &offset, %s))" % (value,))
- emitter.emit(" return -ERROR_BAD_AMQP_DATA;")
-
-
-class BitType(object):
- """The AMQP bit type."""
-
- def __init__(self):
- self.ctype = "amqp_boolean_t"
-
- def decode(self, emitter, lvalue):
- emitter.decode_bit(lvalue)
-
- def encode(self, emitter, value):
- emitter.encode_bit(value)
-
-
-class TableType(object):
- """The AMQP table type."""
-
- def __init__(self):
- self.ctype = "amqp_table_t"
-
- def decode(self, emitter, lvalue):
- emitter.emit("{")
- emitter.emit(" int res = amqp_decode_table(encoded, pool, &(%s), &offset);" % (lvalue,))
- emitter.emit(" if (res < 0) return res;")
- emitter.emit("}")
-
- def encode(self, emitter, value):
- emitter.emit("{")
- emitter.emit(" int res = amqp_encode_table(encoded, &(%s), &offset);" % (value,))
- emitter.emit(" if (res < 0) return res;")
- emitter.emit("}")
-
-
-types = {
- 'octet': SimpleType(8),
- 'short': SimpleType(16),
- 'long': SimpleType(32),
- 'longlong': SimpleType(64),
- 'shortstr': StrType(8),
- 'longstr': StrType(32),
- 'bit': BitType(),
- 'table': TableType(),
- 'timestamp': SimpleType(64),
-}
-
-def typeFor(spec, f):
- """Get a representation of the AMQP type of a field."""
- return types[spec.resolveDomain(f.domain)]
-
-def c_ize(s):
- s = s.replace('-', '_')
- s = s.replace(' ', '_')
- return s
-
-AmqpMethod.defName = lambda m: cConstantName(c_ize(m.klass.name) + '_' + c_ize(m.name) + "_method")
-AmqpMethod.structName = lambda m: "amqp_" + c_ize(m.klass.name) + '_' + c_ize(m.name) + "_t"
-
-AmqpClass.structName = lambda c: "amqp_" + c_ize(c.name) + "_properties_t"
-
-def cConstantName(s):
- return 'AMQP_' + '_'.join(re.split('[- ]', s.upper()))
-
-def cFlagName(c, f):
- return cConstantName(c.name + '_' + f.name) + '_FLAG'
-
-def genErl(spec):
- def fieldTempList(fields):
- return '[' + ', '.join(['F' + str(f.index) for f in fields]) + ']'
-
- def fieldMapList(fields):
- return ', '.join([c_ize(f.name) + " = F" + str(f.index) for f in fields])
-
- def genLookupMethodName(m):
- print ' case %s: return "%s";' % (m.defName(), m.defName())
-
- def genDecodeMethodFields(m):
- print " case %s: {" % (m.defName(),)
- if m.arguments:
- print " %s *m = (%s *) amqp_pool_alloc(pool, sizeof(%s));" % \
- (m.structName(), m.structName(), m.structName())
- print " if (m == NULL) { return -ERROR_NO_MEMORY; }"
- else:
- print " %s *m = NULL; /* no fields */" % (m.structName(),)
-
- emitter = BitDecoder(Emitter(" "))
- for f in m.arguments:
- typeFor(spec, f).decode(emitter, "m->"+c_ize(f.name))
-
- print " *decoded = m;"
- print " return 0;"
- print " }"
-
- def genDecodeProperties(c):
- print " case %d: {" % (c.index,)
- print " %s *p = (%s *) amqp_pool_alloc(pool, sizeof(%s));" % \
- (c.structName(), c.structName(), c.structName())
- print " if (p == NULL) { return -ERROR_NO_MEMORY; }"
- print " p->_flags = flags;"
-
- emitter = Emitter(" ")
- for f in c.fields:
- emitter.emit("if (flags & %s) {" % (cFlagName(c, f),))
- typeFor(spec, f).decode(emitter, "p->"+c_ize(f.name))
- emitter.emit("}")
-
- print " *decoded = p;"
- print " return 0;"
- print " }"
-
- def genEncodeMethodFields(m):
- print " case %s: {" % (m.defName(),)
- if m.arguments:
- print " %s *m = (%s *) decoded;" % (m.structName(), m.structName())
-
- emitter = BitEncoder(Emitter(" "))
- for f in m.arguments:
- typeFor(spec, f).encode(emitter, "m->"+c_ize(f.name))
- emitter.flush()
-
- print " return offset;"
- print " }"
-
- def genEncodeProperties(c):
- print " case %d: {" % (c.index,)
- if c.fields:
- print " %s *p = (%s *) decoded;" % (c.structName(), c.structName())
-
- emitter = Emitter(" ")
- for f in c.fields:
- emitter.emit(" if (flags & %s) {" % (cFlagName(c, f),))
- typeFor(spec, f).encode(emitter, "p->"+c_ize(f.name))
- emitter.emit("}")
-
- print " return offset;"
- print " }"
-
- methods = spec.allMethods()
-
- print '/* Autogenerated code. Do not edit. */'
- print
- print '#include <stdlib.h>'
- print '#include <stdint.h>'
- print '#include <string.h>'
- print '#include <stdio.h>'
- print
- print '#include "amqp.h"'
- print '#include "amqp_framing.h"'
- print '#include "amqp_private.h"'
- print '#include "socket.h"'
-
- print """
-char const *amqp_constant_name(int constantNumber) {
- switch (constantNumber) {"""
- for (c,v,cls) in spec.constants:
- print " case %s: return \"%s\";" % (cConstantName(c), cConstantName(c))
- print """ default: return "(unknown)";
- }
-}"""
-
- print """
-amqp_boolean_t amqp_constant_is_hard_error(int constantNumber) {
- switch (constantNumber) {"""
- for (c,v,cls) in spec.constants:
- if cls == 'hard-error':
- print " case %s: return 1;" % (cConstantName(c),)
- print """ default: return 0;
- }
-}"""
-
- print """
-char const *amqp_method_name(amqp_method_number_t methodNumber) {
- switch (methodNumber) {"""
- for m in methods: genLookupMethodName(m)
- print """ default: return NULL;
- }
-}"""
-
- print """
-amqp_boolean_t amqp_method_has_content(amqp_method_number_t methodNumber) {
- switch (methodNumber) {"""
- for m in methods:
- if m.hasContent:
- print ' case %s: return 1;' % (m.defName())
- print """ default: return 0;
- }
-}"""
-
- print """
-int amqp_decode_method(amqp_method_number_t methodNumber,
- amqp_pool_t *pool,
- amqp_bytes_t encoded,
- void **decoded)
-{
- size_t offset = 0;
- uint8_t bit_buffer;
-
- switch (methodNumber) {"""
- for m in methods: genDecodeMethodFields(m)
- print """ default: return -ERROR_UNKNOWN_METHOD;
- }
-}"""
-
- print """
-int amqp_decode_properties(uint16_t class_id,
- amqp_pool_t *pool,
- amqp_bytes_t encoded,
- void **decoded)
-{
- size_t offset = 0;
-
- amqp_flags_t flags = 0;
- int flagword_index = 0;
- uint16_t partial_flags;
-
- do {
- if (!amqp_decode_16(encoded, &offset, &partial_flags))
- return -ERROR_BAD_AMQP_DATA;
- flags |= (partial_flags << (flagword_index * 16));
- flagword_index++;
- } while (partial_flags & 1);
-
- switch (class_id) {"""
- for c in spec.allClasses(): genDecodeProperties(c)
- print """ default: return -ERROR_UNKNOWN_CLASS;
- }
-}"""
-
- print """
-int amqp_encode_method(amqp_method_number_t methodNumber,
- void *decoded,
- amqp_bytes_t encoded)
-{
- size_t offset = 0;
- uint8_t bit_buffer;
-
- switch (methodNumber) {"""
- for m in methods: genEncodeMethodFields(m)
- print """ default: return -ERROR_UNKNOWN_METHOD;
- }
-}"""
-
- print """
-int amqp_encode_properties(uint16_t class_id,
- void *decoded,
- amqp_bytes_t encoded)
-{
- size_t offset = 0;
-
- /* Cheat, and get the flags out generically, relying on the
- similarity of structure between classes */
- amqp_flags_t flags = * (amqp_flags_t *) decoded; /* cheating! */
-
- {
- /* We take a copy of flags to avoid destroying it, as it is used
- in the autogenerated code below. */
- amqp_flags_t remaining_flags = flags;
- do {
- amqp_flags_t remainder = remaining_flags >> 16;
- uint16_t partial_flags = remaining_flags & 0xFFFE;
- if (remainder != 0) { partial_flags |= 1; }
- if (!amqp_encode_16(encoded, &offset, partial_flags))
- return -ERROR_BAD_AMQP_DATA;
- remaining_flags = remainder;
- } while (remaining_flags != 0);
- }
-
- switch (class_id) {"""
- for c in spec.allClasses(): genEncodeProperties(c)
- print """ default: return -ERROR_UNKNOWN_CLASS;
- }
-}"""
-
-def genHrl(spec):
- def fieldDeclList(fields):
- if fields:
- return ''.join([" %s %s;\n" % (typeFor(spec, f).ctype,
- c_ize(f.name))
- for f in fields])
- else:
- return " char dummy; /* Dummy field to avoid empty struct */\n"
-
- def propDeclList(fields):
- return ''.join([" %s %s;\n" % (typeFor(spec, f).ctype, c_ize(f.name))
- for f in fields
- if spec.resolveDomain(f.domain) != 'bit'])
-
- methods = spec.allMethods()
-
- print """/* Autogenerated code. Do not edit. */
-#ifndef librabbitmq_amqp_framing_h
-#define librabbitmq_amqp_framing_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-"""
- print "#define AMQP_PROTOCOL_VERSION_MAJOR %d" % (spec.major)
- print "#define AMQP_PROTOCOL_VERSION_MINOR %d" % (spec.minor)
- print "#define AMQP_PROTOCOL_VERSION_REVISION %d" % (spec.revision)
- print "#define AMQP_PROTOCOL_PORT %d" % (spec.port)
-
- for (c,v,cls) in spec.constants:
- print "#define %s %s" % (cConstantName(c), v)
- print
-
- 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);
-"""
-
- print "/* Method field records. */"
- for m in methods:
- methodid = m.klass.index << 16 | m.index
- print "#define %s ((amqp_method_number_t) 0x%.08X) /* %d, %d; %d */" % \
- (m.defName(),
- methodid,
- m.klass.index,
- m.index,
- methodid)
- print "typedef struct %s_ {\n%s} %s;\n" % \
- (m.structName(), fieldDeclList(m.arguments), m.structName())
-
- print "/* Class property records. */"
- for c in spec.allClasses():
- print "#define %s (0x%.04X) /* %d */" % \
- (cConstantName(c.name + "_class"), c.index, c.index)
- index = 0
- for f in c.fields:
- if index % 16 == 15:
- index = index + 1
- shortnum = index / 16
- partialindex = 15 - (index % 16)
- bitindex = shortnum * 16 + partialindex
- print '#define %s (1 << %d)' % (cFlagName(c, f), bitindex)
- index = index + 1
- print "typedef struct %s_ {\n amqp_flags_t _flags;\n%s} %s;\n" % \
- (c.structName(),
- fieldDeclList(c.fields),
- c.structName())
-
- print """#ifdef __cplusplus
-}
-#endif
-
-#endif"""
-
-def generateErl(specPath):
- genErl(AmqpSpec(specPath))
-
-def generateHrl(specPath):
- genHrl(AmqpSpec(specPath))
-
-if __name__ == "__main__":
- do_main(generateHrl, generateErl)
diff --git a/librabbitmq/unix/socket.c b/librabbitmq/unix/socket.c
deleted file mode 100644
index 4f5368e..0000000
--- a/librabbitmq/unix/socket.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2010 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2010 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <sys/socket.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "amqp.h"
-#include "amqp_private.h"
-#include "socket.h"
-
-int amqp_socket_socket(int domain, int type, int proto)
-{
- int flags;
-
- int s = socket(domain, type, proto);
- if (s < 0)
- return s;
-
- /* Always enable CLOEXEC on the socket */
- flags = fcntl(s, F_GETFD);
- if (flags == -1
- || fcntl(s, F_SETFD, (long)(flags | FD_CLOEXEC)) == -1) {
- int e = errno;
- close(s);
- errno = e;
- return -1;
- }
-
- return s;
-}
-
-/* strdup is not in ISO C90! */
-static inline char *strdup(const char *str)
-{
- return strcpy(malloc(strlen(str) + 1),str);
-}
-
-char *amqp_os_error_string(int err)
-{
- return strdup(strerror(err));
-}
diff --git a/librabbitmq/unix/socket.h b/librabbitmq/unix/socket.h
deleted file mode 100644
index 5cb37f1..0000000
--- a/librabbitmq/unix/socket.h
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef librabbitmq_unix_socket_h
-#define librabbitmq_unix_socket_h
-
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2010 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2010 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#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>
-
-static inline int amqp_socket_init(void)
-{
- return 0;
-}
-
-extern int amqp_socket_socket(int domain, int type, int proto);
-
-#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/librabbitmq/windows/socket.c b/librabbitmq/windows/socket.c
deleted file mode 100644
index bef7b95..0000000
--- a/librabbitmq/windows/socket.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2010 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2010 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-/* See http://msdn.microsoft.com/en-us/library/ms737629%28VS.85%29.aspx */
-#define WIN32_LEAN_AND_MEAN
-
-#include <windows.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "amqp.h"
-#include "amqp_private.h"
-#include "socket.h"
-
-static int called_wsastartup;
-
-int amqp_socket_init(void)
-{
- if (!called_wsastartup) {
- WSADATA data;
- int res = WSAStartup(0x0202, &data);
- if (res)
- return -res;
-
- called_wsastartup = 1;
- }
-
- return 0;
-}
-
-/* strdup is not in ISO C90! */
-static inline char *strdup(const char *str)
-{
- return strcpy(malloc(strlen(str) + 1),str);
-}
-
-char *amqp_os_error_string(int err)
-{
- char *msg, *copy;
-
- if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
- | FORMAT_MESSAGE_ALLOCATE_BUFFER,
- NULL, err,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPSTR)&msg, 0, NULL))
- return strdup("(error retrieving Windows error message)");
-
- copy = strdup(msg);
- LocalFree(msg);
- return copy;
-}
diff --git a/librabbitmq/windows/socket.h b/librabbitmq/windows/socket.h
deleted file mode 100644
index 38ca905..0000000
--- a/librabbitmq/windows/socket.h
+++ /dev/null
@@ -1,89 +0,0 @@
-#ifndef librabbitmq_windows_socket_h
-#define librabbitmq_windows_socket_h
-
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2010 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2010 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** 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/msinttypes/inttypes.h b/msinttypes/inttypes.h
deleted file mode 100644
index 4b3828a..0000000
--- a/msinttypes/inttypes.h
+++ /dev/null
@@ -1,305 +0,0 @@
-// ISO C9x compliant inttypes.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
-//
-// Copyright (c) 2006 Alexander Chemeris
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// 3. The name of the author may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _MSC_VER // [
-#error "Use this header only with Microsoft Visual C++ compilers!"
-#endif // _MSC_VER ]
-
-#ifndef _MSC_INTTYPES_H_ // [
-#define _MSC_INTTYPES_H_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
-
-#include "stdint.h"
-
-// 7.8 Format conversion of integer types
-
-typedef struct {
- intmax_t quot;
- intmax_t rem;
-} imaxdiv_t;
-
-// 7.8.1 Macros for format specifiers
-
-#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
-
-// The fprintf macros for signed integers are:
-#define PRId8 "d"
-#define PRIi8 "i"
-#define PRIdLEAST8 "d"
-#define PRIiLEAST8 "i"
-#define PRIdFAST8 "d"
-#define PRIiFAST8 "i"
-
-#define PRId16 "hd"
-#define PRIi16 "hi"
-#define PRIdLEAST16 "hd"
-#define PRIiLEAST16 "hi"
-#define PRIdFAST16 "hd"
-#define PRIiFAST16 "hi"
-
-#define PRId32 "I32d"
-#define PRIi32 "I32i"
-#define PRIdLEAST32 "I32d"
-#define PRIiLEAST32 "I32i"
-#define PRIdFAST32 "I32d"
-#define PRIiFAST32 "I32i"
-
-#define PRId64 "I64d"
-#define PRIi64 "I64i"
-#define PRIdLEAST64 "I64d"
-#define PRIiLEAST64 "I64i"
-#define PRIdFAST64 "I64d"
-#define PRIiFAST64 "I64i"
-
-#define PRIdMAX "I64d"
-#define PRIiMAX "I64i"
-
-#define PRIdPTR "Id"
-#define PRIiPTR "Ii"
-
-// The fprintf macros for unsigned integers are:
-#define PRIo8 "o"
-#define PRIu8 "u"
-#define PRIx8 "x"
-#define PRIX8 "X"
-#define PRIoLEAST8 "o"
-#define PRIuLEAST8 "u"
-#define PRIxLEAST8 "x"
-#define PRIXLEAST8 "X"
-#define PRIoFAST8 "o"
-#define PRIuFAST8 "u"
-#define PRIxFAST8 "x"
-#define PRIXFAST8 "X"
-
-#define PRIo16 "ho"
-#define PRIu16 "hu"
-#define PRIx16 "hx"
-#define PRIX16 "hX"
-#define PRIoLEAST16 "ho"
-#define PRIuLEAST16 "hu"
-#define PRIxLEAST16 "hx"
-#define PRIXLEAST16 "hX"
-#define PRIoFAST16 "ho"
-#define PRIuFAST16 "hu"
-#define PRIxFAST16 "hx"
-#define PRIXFAST16 "hX"
-
-#define PRIo32 "I32o"
-#define PRIu32 "I32u"
-#define PRIx32 "I32x"
-#define PRIX32 "I32X"
-#define PRIoLEAST32 "I32o"
-#define PRIuLEAST32 "I32u"
-#define PRIxLEAST32 "I32x"
-#define PRIXLEAST32 "I32X"
-#define PRIoFAST32 "I32o"
-#define PRIuFAST32 "I32u"
-#define PRIxFAST32 "I32x"
-#define PRIXFAST32 "I32X"
-
-#define PRIo64 "I64o"
-#define PRIu64 "I64u"
-#define PRIx64 "I64x"
-#define PRIX64 "I64X"
-#define PRIoLEAST64 "I64o"
-#define PRIuLEAST64 "I64u"
-#define PRIxLEAST64 "I64x"
-#define PRIXLEAST64 "I64X"
-#define PRIoFAST64 "I64o"
-#define PRIuFAST64 "I64u"
-#define PRIxFAST64 "I64x"
-#define PRIXFAST64 "I64X"
-
-#define PRIoMAX "I64o"
-#define PRIuMAX "I64u"
-#define PRIxMAX "I64x"
-#define PRIXMAX "I64X"
-
-#define PRIoPTR "Io"
-#define PRIuPTR "Iu"
-#define PRIxPTR "Ix"
-#define PRIXPTR "IX"
-
-// The fscanf macros for signed integers are:
-#define SCNd8 "d"
-#define SCNi8 "i"
-#define SCNdLEAST8 "d"
-#define SCNiLEAST8 "i"
-#define SCNdFAST8 "d"
-#define SCNiFAST8 "i"
-
-#define SCNd16 "hd"
-#define SCNi16 "hi"
-#define SCNdLEAST16 "hd"
-#define SCNiLEAST16 "hi"
-#define SCNdFAST16 "hd"
-#define SCNiFAST16 "hi"
-
-#define SCNd32 "ld"
-#define SCNi32 "li"
-#define SCNdLEAST32 "ld"
-#define SCNiLEAST32 "li"
-#define SCNdFAST32 "ld"
-#define SCNiFAST32 "li"
-
-#define SCNd64 "I64d"
-#define SCNi64 "I64i"
-#define SCNdLEAST64 "I64d"
-#define SCNiLEAST64 "I64i"
-#define SCNdFAST64 "I64d"
-#define SCNiFAST64 "I64i"
-
-#define SCNdMAX "I64d"
-#define SCNiMAX "I64i"
-
-#ifdef _WIN64 // [
-# define SCNdPTR "I64d"
-# define SCNiPTR "I64i"
-#else // _WIN64 ][
-# define SCNdPTR "ld"
-# define SCNiPTR "li"
-#endif // _WIN64 ]
-
-// The fscanf macros for unsigned integers are:
-#define SCNo8 "o"
-#define SCNu8 "u"
-#define SCNx8 "x"
-#define SCNX8 "X"
-#define SCNoLEAST8 "o"
-#define SCNuLEAST8 "u"
-#define SCNxLEAST8 "x"
-#define SCNXLEAST8 "X"
-#define SCNoFAST8 "o"
-#define SCNuFAST8 "u"
-#define SCNxFAST8 "x"
-#define SCNXFAST8 "X"
-
-#define SCNo16 "ho"
-#define SCNu16 "hu"
-#define SCNx16 "hx"
-#define SCNX16 "hX"
-#define SCNoLEAST16 "ho"
-#define SCNuLEAST16 "hu"
-#define SCNxLEAST16 "hx"
-#define SCNXLEAST16 "hX"
-#define SCNoFAST16 "ho"
-#define SCNuFAST16 "hu"
-#define SCNxFAST16 "hx"
-#define SCNXFAST16 "hX"
-
-#define SCNo32 "lo"
-#define SCNu32 "lu"
-#define SCNx32 "lx"
-#define SCNX32 "lX"
-#define SCNoLEAST32 "lo"
-#define SCNuLEAST32 "lu"
-#define SCNxLEAST32 "lx"
-#define SCNXLEAST32 "lX"
-#define SCNoFAST32 "lo"
-#define SCNuFAST32 "lu"
-#define SCNxFAST32 "lx"
-#define SCNXFAST32 "lX"
-
-#define SCNo64 "I64o"
-#define SCNu64 "I64u"
-#define SCNx64 "I64x"
-#define SCNX64 "I64X"
-#define SCNoLEAST64 "I64o"
-#define SCNuLEAST64 "I64u"
-#define SCNxLEAST64 "I64x"
-#define SCNXLEAST64 "I64X"
-#define SCNoFAST64 "I64o"
-#define SCNuFAST64 "I64u"
-#define SCNxFAST64 "I64x"
-#define SCNXFAST64 "I64X"
-
-#define SCNoMAX "I64o"
-#define SCNuMAX "I64u"
-#define SCNxMAX "I64x"
-#define SCNXMAX "I64X"
-
-#ifdef _WIN64 // [
-# define SCNoPTR "I64o"
-# define SCNuPTR "I64u"
-# define SCNxPTR "I64x"
-# define SCNXPTR "I64X"
-#else // _WIN64 ][
-# define SCNoPTR "lo"
-# define SCNuPTR "lu"
-# define SCNxPTR "lx"
-# define SCNXPTR "lX"
-#endif // _WIN64 ]
-
-#endif // __STDC_FORMAT_MACROS ]
-
-// 7.8.2 Functions for greatest-width integer types
-
-// 7.8.2.1 The imaxabs function
-#define imaxabs _abs64
-
-// 7.8.2.2 The imaxdiv function
-
-// This is modified version of div() function from Microsoft's div.c found
-// in %MSVC.NET%\crt\src\div.c
-#ifdef STATIC_IMAXDIV // [
-static
-#else // STATIC_IMAXDIV ][
-_inline
-#endif // STATIC_IMAXDIV ]
-imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
-{
- imaxdiv_t result;
-
- result.quot = numer / denom;
- result.rem = numer % denom;
-
- if (numer < 0 && result.rem > 0) {
- // did division wrong; must fix up
- ++result.quot;
- result.rem -= denom;
- }
-
- return result;
-}
-
-// 7.8.2.3 The strtoimax and strtoumax functions
-#define strtoimax _strtoi64
-#define strtoumax _strtoui64
-
-// 7.8.2.4 The wcstoimax and wcstoumax functions
-#define wcstoimax _wcstoi64
-#define wcstoumax _wcstoui64
-
-
-#endif // _MSC_INTTYPES_H_ ]
diff --git a/msinttypes/stdint.h b/msinttypes/stdint.h
deleted file mode 100644
index d02608a..0000000
--- a/msinttypes/stdint.h
+++ /dev/null
@@ -1,247 +0,0 @@
-// ISO C9x compliant stdint.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
-//
-// Copyright (c) 2006-2008 Alexander Chemeris
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// 3. The name of the author may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _MSC_VER // [
-#error "Use this header only with Microsoft Visual C++ compilers!"
-#endif // _MSC_VER ]
-
-#ifndef _MSC_STDINT_H_ // [
-#define _MSC_STDINT_H_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
-
-#include <limits.h>
-
-// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
-// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
-// or compiler give many errors like this:
-// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
-#ifdef __cplusplus
-extern "C" {
-#endif
-# include <wchar.h>
-#ifdef __cplusplus
-}
-#endif
-
-// Define _W64 macros to mark types changing their size, like intptr_t.
-#ifndef _W64
-# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
-# define _W64 __w64
-# else
-# define _W64
-# endif
-#endif
-
-
-// 7.18.1 Integer types
-
-// 7.18.1.1 Exact-width integer types
-
-// Visual Studio 6 and Embedded Visual C++ 4 doesn't
-// realize that, e.g. char has the same size as __int8
-// so we give up on __intX for them.
-#if (_MSC_VER < 1300)
- typedef signed char int8_t;
- typedef signed short int16_t;
- typedef signed int int32_t;
- typedef unsigned char uint8_t;
- typedef unsigned short uint16_t;
- typedef unsigned int uint32_t;
-#else
- typedef signed __int8 int8_t;
- typedef signed __int16 int16_t;
- typedef signed __int32 int32_t;
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int16 uint16_t;
- typedef unsigned __int32 uint32_t;
-#endif
-typedef signed __int64 int64_t;
-typedef unsigned __int64 uint64_t;
-
-
-// 7.18.1.2 Minimum-width integer types
-typedef int8_t int_least8_t;
-typedef int16_t int_least16_t;
-typedef int32_t int_least32_t;
-typedef int64_t int_least64_t;
-typedef uint8_t uint_least8_t;
-typedef uint16_t uint_least16_t;
-typedef uint32_t uint_least32_t;
-typedef uint64_t uint_least64_t;
-
-// 7.18.1.3 Fastest minimum-width integer types
-typedef int8_t int_fast8_t;
-typedef int16_t int_fast16_t;
-typedef int32_t int_fast32_t;
-typedef int64_t int_fast64_t;
-typedef uint8_t uint_fast8_t;
-typedef uint16_t uint_fast16_t;
-typedef uint32_t uint_fast32_t;
-typedef uint64_t uint_fast64_t;
-
-// 7.18.1.4 Integer types capable of holding object pointers
-#ifdef _WIN64 // [
- typedef signed __int64 intptr_t;
- typedef unsigned __int64 uintptr_t;
-#else // _WIN64 ][
- typedef _W64 signed int intptr_t;
- typedef _W64 unsigned int uintptr_t;
-#endif // _WIN64 ]
-
-// 7.18.1.5 Greatest-width integer types
-typedef int64_t intmax_t;
-typedef uint64_t uintmax_t;
-
-
-// 7.18.2 Limits of specified-width integer types
-
-#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
-
-// 7.18.2.1 Limits of exact-width integer types
-#define INT8_MIN ((int8_t)_I8_MIN)
-#define INT8_MAX _I8_MAX
-#define INT16_MIN ((int16_t)_I16_MIN)
-#define INT16_MAX _I16_MAX
-#define INT32_MIN ((int32_t)_I32_MIN)
-#define INT32_MAX _I32_MAX
-#define INT64_MIN ((int64_t)_I64_MIN)
-#define INT64_MAX _I64_MAX
-#define UINT8_MAX _UI8_MAX
-#define UINT16_MAX _UI16_MAX
-#define UINT32_MAX _UI32_MAX
-#define UINT64_MAX _UI64_MAX
-
-// 7.18.2.2 Limits of minimum-width integer types
-#define INT_LEAST8_MIN INT8_MIN
-#define INT_LEAST8_MAX INT8_MAX
-#define INT_LEAST16_MIN INT16_MIN
-#define INT_LEAST16_MAX INT16_MAX
-#define INT_LEAST32_MIN INT32_MIN
-#define INT_LEAST32_MAX INT32_MAX
-#define INT_LEAST64_MIN INT64_MIN
-#define INT_LEAST64_MAX INT64_MAX
-#define UINT_LEAST8_MAX UINT8_MAX
-#define UINT_LEAST16_MAX UINT16_MAX
-#define UINT_LEAST32_MAX UINT32_MAX
-#define UINT_LEAST64_MAX UINT64_MAX
-
-// 7.18.2.3 Limits of fastest minimum-width integer types
-#define INT_FAST8_MIN INT8_MIN
-#define INT_FAST8_MAX INT8_MAX
-#define INT_FAST16_MIN INT16_MIN
-#define INT_FAST16_MAX INT16_MAX
-#define INT_FAST32_MIN INT32_MIN
-#define INT_FAST32_MAX INT32_MAX
-#define INT_FAST64_MIN INT64_MIN
-#define INT_FAST64_MAX INT64_MAX
-#define UINT_FAST8_MAX UINT8_MAX
-#define UINT_FAST16_MAX UINT16_MAX
-#define UINT_FAST32_MAX UINT32_MAX
-#define UINT_FAST64_MAX UINT64_MAX
-
-// 7.18.2.4 Limits of integer types capable of holding object pointers
-#ifdef _WIN64 // [
-# define INTPTR_MIN INT64_MIN
-# define INTPTR_MAX INT64_MAX
-# define UINTPTR_MAX UINT64_MAX
-#else // _WIN64 ][
-# define INTPTR_MIN INT32_MIN
-# define INTPTR_MAX INT32_MAX
-# define UINTPTR_MAX UINT32_MAX
-#endif // _WIN64 ]
-
-// 7.18.2.5 Limits of greatest-width integer types
-#define INTMAX_MIN INT64_MIN
-#define INTMAX_MAX INT64_MAX
-#define UINTMAX_MAX UINT64_MAX
-
-// 7.18.3 Limits of other integer types
-
-#ifdef _WIN64 // [
-# define PTRDIFF_MIN _I64_MIN
-# define PTRDIFF_MAX _I64_MAX
-#else // _WIN64 ][
-# define PTRDIFF_MIN _I32_MIN
-# define PTRDIFF_MAX _I32_MAX
-#endif // _WIN64 ]
-
-#define SIG_ATOMIC_MIN INT_MIN
-#define SIG_ATOMIC_MAX INT_MAX
-
-#ifndef SIZE_MAX // [
-# ifdef _WIN64 // [
-# define SIZE_MAX _UI64_MAX
-# else // _WIN64 ][
-# define SIZE_MAX _UI32_MAX
-# endif // _WIN64 ]
-#endif // SIZE_MAX ]
-
-// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
-#ifndef WCHAR_MIN // [
-# define WCHAR_MIN 0
-#endif // WCHAR_MIN ]
-#ifndef WCHAR_MAX // [
-# define WCHAR_MAX _UI16_MAX
-#endif // WCHAR_MAX ]
-
-#define WINT_MIN 0
-#define WINT_MAX _UI16_MAX
-
-#endif // __STDC_LIMIT_MACROS ]
-
-
-// 7.18.4 Limits of other integer types
-
-#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
-
-// 7.18.4.1 Macros for minimum-width integer constants
-
-#define INT8_C(val) val##i8
-#define INT16_C(val) val##i16
-#define INT32_C(val) val##i32
-#define INT64_C(val) val##i64
-
-#define UINT8_C(val) val##ui8
-#define UINT16_C(val) val##ui16
-#define UINT32_C(val) val##ui32
-#define UINT64_C(val) val##ui64
-
-// 7.18.4.2 Macros for greatest-width integer constants
-#define INTMAX_C INT64_C
-#define UINTMAX_C UINT64_C
-
-#endif // __STDC_CONSTANT_MACROS ]
-
-
-#endif // _MSC_STDINT_H_ ]
diff --git a/tests/Makefile.am b/tests/Makefile.am
deleted file mode 100644
index 3bd5e6e..0000000
--- a/tests/Makefile.am
+++ /dev/null
@@ -1,16 +0,0 @@
-noinst_PROGRAMS = test_tables
-
-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_tables.c b/tests/test_tables.c
deleted file mode 100644
index 5c0fbb9..0000000
--- a/tests/test_tables.c
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <inttypes.h>
-
-#include <amqp.h>
-
-#include <math.h>
-
-#define M_PI 3.14159265358979323846264338327
-
-static void dump_indent(int indent) {
- int i;
- for (i = 0; i < indent; i++) { putchar(' '); }
-}
-
-static void dump_value(int indent, amqp_field_value_t v) {
- dump_indent(indent);
- putchar(v.kind);
- putchar(' ');
- switch (v.kind) {
- case AMQP_FIELD_KIND_BOOLEAN: puts(v.value.boolean ? "true" : "false"); break;
- case AMQP_FIELD_KIND_I8: printf("%"PRId8"\n", v.value.i8); break;
- case AMQP_FIELD_KIND_U8: printf("%"PRIu8"\n", v.value.u8); break;
- case AMQP_FIELD_KIND_I16: printf("%"PRId16"\n", v.value.i16); break;
- case AMQP_FIELD_KIND_U16: printf("%"PRIu16"\n", v.value.u16); break;
- case AMQP_FIELD_KIND_I32: printf("%"PRId32"\n", v.value.i32); break;
- case AMQP_FIELD_KIND_U32: printf("%"PRIu32"\n", v.value.u32); break;
- case AMQP_FIELD_KIND_I64: printf("%"PRId64"\n", v.value.i64); break;
- case AMQP_FIELD_KIND_F32: printf("%g\n", (double) v.value.f32); break;
- case AMQP_FIELD_KIND_F64: printf("%g\n", v.value.f64); break;
- case AMQP_FIELD_KIND_DECIMAL:
- printf("%d:::%u\n", v.value.decimal.decimals, v.value.decimal.value); break;
- case AMQP_FIELD_KIND_UTF8:
- printf("%.*s\n", (int) v.value.bytes.len, (char *) v.value.bytes.bytes); break;
- case AMQP_FIELD_KIND_BYTES:
- {
- int i;
- for (i = 0; i < v.value.bytes.len; i++) {
- printf("%02x", ((char *) v.value.bytes.bytes)[i]);
- }
- putchar('\n');
- }
- break;
- case AMQP_FIELD_KIND_ARRAY:
- putchar('\n');
- {
- int i;
- for (i = 0; i < v.value.array.num_entries; i++) {
- dump_value(indent + 2, v.value.array.entries[i]);
- }
- }
- break;
- case AMQP_FIELD_KIND_TIMESTAMP: printf("%"PRIu64"\n", v.value.u64); break;
- case AMQP_FIELD_KIND_TABLE:
- putchar('\n');
- {
- int i;
- for (i = 0; i < v.value.table.num_entries; i++) {
- dump_indent(indent + 2);
- printf("%.*s ->\n",
- (int) v.value.table.entries[i].key.len,
- (char *) v.value.table.entries[i].key.bytes);
- dump_value(indent + 4, v.value.table.entries[i].value);
- }
- }
- break;
- case AMQP_FIELD_KIND_VOID: putchar('\n'); break;
- default:
- printf("???\n");
- break;
- }
-}
-
-static uint8_t pre_encoded_table[] = {
- 0x00, 0x00, 0x00, 0xff, 0x07, 0x6c, 0x6f, 0x6e,
- 0x67, 0x73, 0x74, 0x72, 0x53, 0x00, 0x00, 0x00,
- 0x15, 0x48, 0x65, 0x72, 0x65, 0x20, 0x69, 0x73,
- 0x20, 0x61, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x20,
- 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x09, 0x73,
- 0x69, 0x67, 0x6e, 0x65, 0x64, 0x69, 0x6e, 0x74,
- 0x49, 0x00, 0x00, 0x30, 0x39, 0x07, 0x64, 0x65,
- 0x63, 0x69, 0x6d, 0x61, 0x6c, 0x44, 0x03, 0x00,
- 0x01, 0xe2, 0x40, 0x09, 0x74, 0x69, 0x6d, 0x65,
- 0x73, 0x74, 0x61, 0x6d, 0x70, 0x54, 0x00, 0x00,
- 0x63, 0xee, 0xa0, 0x53, 0xc1, 0x94, 0x05, 0x74,
- 0x61, 0x62, 0x6c, 0x65, 0x46, 0x00, 0x00, 0x00,
- 0x1f, 0x03, 0x6f, 0x6e, 0x65, 0x49, 0x00, 0x00,
- 0xd4, 0x31, 0x03, 0x74, 0x77, 0x6f, 0x53, 0x00,
- 0x00, 0x00, 0x0d, 0x41, 0x20, 0x6c, 0x6f, 0x6e,
- 0x67, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67,
- 0x04, 0x62, 0x79, 0x74, 0x65, 0x62, 0xff, 0x04,
- 0x6c, 0x6f, 0x6e, 0x67, 0x6c, 0x00, 0x00, 0x00,
- 0x00, 0x49, 0x96, 0x02, 0xd2, 0x05, 0x73, 0x68,
- 0x6f, 0x72, 0x74, 0x73, 0x02, 0x8f, 0x04, 0x62,
- 0x6f, 0x6f, 0x6c, 0x74, 0x01, 0x06, 0x62, 0x69,
- 0x6e, 0x61, 0x72, 0x79, 0x78, 0x00, 0x00, 0x00,
- 0x0f, 0x61, 0x20, 0x62, 0x69, 0x6e, 0x61, 0x72,
- 0x79, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67,
- 0x04, 0x76, 0x6f, 0x69, 0x64, 0x56, 0x05, 0x61,
- 0x72, 0x72, 0x61, 0x79, 0x41, 0x00, 0x00, 0x00,
- 0x17, 0x49, 0x00, 0x00, 0xd4, 0x31, 0x53, 0x00,
- 0x00, 0x00, 0x0d, 0x41, 0x20, 0x6c, 0x6f, 0x6e,
- 0x67, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67,
- 0x05, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x66, 0x40,
- 0x49, 0x0f, 0xdb, 0x06, 0x64, 0x6f, 0x75, 0x62,
- 0x6c, 0x65, 0x64, 0x40, 0x09, 0x21, 0xfb, 0x54,
- 0x44, 0x2d, 0x18
-};
-
-static void test_table_codec(void) {
- amqp_pool_t pool;
- int result;
-
- amqp_table_entry_t inner_entries[2];
- amqp_table_t inner_table;
-
- amqp_field_value_t inner_values[2];
- amqp_array_t inner_array;
-
- amqp_table_entry_t entries[14];
- amqp_table_t table;
-
- inner_entries[0].key = amqp_cstring_bytes("one");
- inner_entries[0].value.kind = AMQP_FIELD_KIND_I32;
- inner_entries[0].value.value.i32 = 54321;
-
- inner_entries[1].key = amqp_cstring_bytes("two");
- inner_entries[1].value.kind = AMQP_FIELD_KIND_UTF8;
- inner_entries[1].value.value.bytes = amqp_cstring_bytes("A long string");
-
- inner_table.num_entries = 2;
- inner_table.entries = inner_entries;
-
- inner_values[0].kind = AMQP_FIELD_KIND_I32;
- inner_values[0].value.i32 = 54321;
-
- inner_values[1].kind = AMQP_FIELD_KIND_UTF8;
- inner_values[1].value.bytes = amqp_cstring_bytes("A long string");
-
- inner_array.num_entries = 2;
- inner_array.entries = inner_values;
-
- entries[0].key = amqp_cstring_bytes("longstr");
- entries[0].value.kind = AMQP_FIELD_KIND_UTF8;
- entries[0].value.value.bytes = amqp_cstring_bytes("Here is a long string");
-
- entries[1].key = amqp_cstring_bytes("signedint");
- entries[1].value.kind = AMQP_FIELD_KIND_I32;
- entries[1].value.value.i32 = 12345;
-
- entries[2].key = amqp_cstring_bytes("decimal");
- entries[2].value.kind = AMQP_FIELD_KIND_DECIMAL;
- entries[2].value.value.decimal.decimals = 3;
- entries[2].value.value.decimal.value = 123456;
-
- entries[3].key = amqp_cstring_bytes("timestamp");
- entries[3].value.kind = AMQP_FIELD_KIND_TIMESTAMP;
- entries[3].value.value.u64 = 109876543209876;
-
- entries[4].key = amqp_cstring_bytes("table");
- entries[4].value.kind = AMQP_FIELD_KIND_TABLE;
- entries[4].value.value.table = inner_table;
-
- entries[5].key = amqp_cstring_bytes("byte");
- entries[5].value.kind = AMQP_FIELD_KIND_I8;
- entries[5].value.value.i8 = (int8_t)255;
-
- entries[6].key = amqp_cstring_bytes("long");
- entries[6].value.kind = AMQP_FIELD_KIND_I64;
- entries[6].value.value.i64 = 1234567890;
-
- entries[7].key = amqp_cstring_bytes("short");
- entries[7].value.kind = AMQP_FIELD_KIND_I16;
- entries[7].value.value.i16 = 655;
-
- entries[8].key = amqp_cstring_bytes("bool");
- entries[8].value.kind = AMQP_FIELD_KIND_BOOLEAN;
- entries[8].value.value.boolean = 1;
-
- entries[9].key = amqp_cstring_bytes("binary");
- entries[9].value.kind = AMQP_FIELD_KIND_BYTES;
- entries[9].value.value.bytes = amqp_cstring_bytes("a binary string");
-
- entries[10].key = amqp_cstring_bytes("void");
- entries[10].value.kind = AMQP_FIELD_KIND_VOID;
-
- entries[11].key = amqp_cstring_bytes("array");
- entries[11].value.kind = AMQP_FIELD_KIND_ARRAY;
- entries[11].value.value.array = inner_array;
-
- entries[12].key = amqp_cstring_bytes("float");
- entries[12].value.kind = AMQP_FIELD_KIND_F32;
- entries[12].value.value.f32 = M_PI;
-
- entries[13].key = amqp_cstring_bytes("double");
- entries[13].value.kind = AMQP_FIELD_KIND_F64;
- entries[13].value.value.f64 = M_PI;
-
- table.num_entries = 14;
- table.entries = entries;
-
- printf("AAAAAAAAAA\n");
-
- {
- amqp_field_value_t val;
- val.kind = AMQP_FIELD_KIND_TABLE;
- val.value.table = table;
- dump_value(0, val);
- }
-
- init_amqp_pool(&pool, 4096);
-
- {
- amqp_table_t decoded;
- size_t decoding_offset = 0;
- amqp_bytes_t decoding_bytes;
- decoding_bytes.len = sizeof(pre_encoded_table);
- decoding_bytes.bytes = pre_encoded_table;
-
- result = amqp_decode_table(decoding_bytes, &pool, &decoded, &decoding_offset);
- if (result < 0) {
- char *errstr = amqp_error_string(-result);
- printf("Table decoding failed: %d (%s)\n", result, errstr);
- free(errstr);
- abort();
- }
- printf("BBBBBBBBBB\n");
-
- {
- amqp_field_value_t val;
- val.kind = AMQP_FIELD_KIND_TABLE;
- val.value.table = decoded;
-
- dump_value(0, val);
- }
- }
-
- {
- uint8_t encoding_buffer[4096];
- amqp_bytes_t encoding_result;
- size_t offset = 0;
-
- memset(&encoding_buffer[0], 0, sizeof(encoding_buffer));
- encoding_result.len = sizeof(encoding_buffer);
- encoding_result.bytes = &encoding_buffer[0];
-
- result = amqp_encode_table(encoding_result, &table, &offset);
- if (result < 0) {
- char *errstr = amqp_error_string(-result);
- printf("Table encoding failed: %d (%s)\n", result, errstr);
- free(errstr);
- abort();
- }
-
- if (offset != sizeof(pre_encoded_table)) {
- printf("Offset should be %d, was %d\n", (int) sizeof(pre_encoded_table), (int)offset);
- abort();
- }
-
- result = memcmp(pre_encoded_table, encoding_buffer, offset);
- if (result != 0) {
- printf("Table encoding differed, result = %d\n", result);
- abort();
- }
- }
-
- empty_amqp_pool(&pool);
-}
-
-int main(int argc, char const * const *argv) {
- amqp_table_entry_t entries[8];
- amqp_table_t table;
-
- union {
- uint32_t i;
- float f;
- } vi;
- union {
- uint64_t l;
- double d;
- } vl;
-
- entries[0].key = amqp_cstring_bytes("zebra");
- entries[0].value.kind = AMQP_FIELD_KIND_UTF8;
- entries[0].value.value.bytes = amqp_cstring_bytes("last");
-
- entries[1].key = amqp_cstring_bytes("aardvark");
- entries[1].value.kind = AMQP_FIELD_KIND_UTF8;
- entries[1].value.value.bytes = amqp_cstring_bytes("first");
-
- entries[2].key = amqp_cstring_bytes("middle");
- entries[2].value.kind = AMQP_FIELD_KIND_UTF8;
- entries[2].value.value.bytes = amqp_cstring_bytes("third");
-
- entries[3].key = amqp_cstring_bytes("number");
- entries[3].value.kind = AMQP_FIELD_KIND_I32;
- entries[3].value.value.i32 = 1234;
-
- entries[4].key = amqp_cstring_bytes("decimal");
- entries[4].value.kind = AMQP_FIELD_KIND_DECIMAL;
- entries[4].value.value.decimal.decimals = 2;
- entries[4].value.value.decimal.value = 1234;
-
- entries[5].key = amqp_cstring_bytes("time");
- entries[5].value.kind = AMQP_FIELD_KIND_TIMESTAMP;
- entries[5].value.value.u64 = 1234123412341234;
-
- entries[6].key = amqp_cstring_bytes("beta");
- entries[6].value.kind = AMQP_FIELD_KIND_UTF8;
- entries[6].value.value.bytes = amqp_cstring_bytes("second");
-
- entries[7].key = amqp_cstring_bytes("wombat");
- entries[7].value.kind = AMQP_FIELD_KIND_UTF8;
- entries[7].value.value.bytes = amqp_cstring_bytes("fourth");
-
- table.num_entries = 8;
- table.entries = entries;
-
- vi.f = M_PI;
- if ((sizeof(float) != 4) || (vi.i != 0x40490fdb)) {
- printf("*** ERROR: single floating point encoding does not work as expected\n");
- printf("sizeof float is %lu, float is %g, u32 is 0x%08lx\n",
- (unsigned long)sizeof(float),
- vi.f,
- (unsigned long) vi.i);
- }
-
- vl.d = M_PI;
- if ((sizeof(double) != 8) || (vl.l != 0x400921fb54442d18L)) {
- printf("*** ERROR: double floating point encoding does not work as expected\n");
- printf("sizeof double is %lu, double is %g, u64 is 0x%16"PRIx64"\n",
- (unsigned long)sizeof(double),
- vl.d, vl.l);
- }
-
- test_table_codec();
-
- qsort(table.entries, table.num_entries, sizeof(amqp_table_entry_t), &amqp_table_entry_cmp);
-
- printf("----------\n");
-
- {
- amqp_field_value_t val;
- val.kind = AMQP_FIELD_KIND_TABLE;
- val.value.table = table;
-
- dump_value(0, val);
- }
-
- return 0;
-}
diff --git a/tests/test_tables.expected b/tests/test_tables.expected
deleted file mode 100644
index 9c9dd6b..0000000
--- a/tests/test_tables.expected
+++ /dev/null
@@ -1,90 +0,0 @@
-AAAAAAAAAA
-F
- longstr ->
- S Here is a long string
- signedint ->
- I 12345
- decimal ->
- D 3:::123456
- timestamp ->
- T 109876543209876
- table ->
- F
- one ->
- I 54321
- two ->
- S A long string
- byte ->
- b -1
- long ->
- l 1234567890
- short ->
- s 655
- bool ->
- t true
- binary ->
- x 612062696e61727920737472696e67
- void ->
- V
- array ->
- A
- I 54321
- S A long string
- float ->
- f 3.14159
- double ->
- d 3.14159
-BBBBBBBBBB
-F
- longstr ->
- S Here is a long string
- signedint ->
- I 12345
- decimal ->
- D 3:::123456
- timestamp ->
- T 109876543209876
- table ->
- F
- one ->
- I 54321
- two ->
- S A long string
- byte ->
- b -1
- long ->
- l 1234567890
- short ->
- s 655
- bool ->
- t true
- binary ->
- x 612062696e61727920737472696e67
- void ->
- V
- array ->
- A
- I 54321
- S A long string
- float ->
- f 3.14159
- double ->
- d 3.14159
-----------
-F
- aardvark ->
- S first
- beta ->
- S second
- decimal ->
- D 2:::1234
- middle ->
- S third
- number ->
- I 1234
- time ->
- T 1234123412341234
- wombat ->
- S fourth
- zebra ->
- S last
diff --git a/tools/Makefile.am b/tools/Makefile.am
deleted file mode 100644
index ccd36ca..0000000
--- a/tools/Makefile.am
+++ /dev/null
@@ -1,27 +0,0 @@
-SUBDIRS=doc
-
-bin_PROGRAMS = amqp-publish amqp-get amqp-consume amqp-declare-queue amqp-delete-queue
-
-AM_CFLAGS = -I$(top_srcdir)/librabbitmq -I$(srcdir)/$(PLATFORM_DIR)
-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
deleted file mode 100644
index 7b0a969..0000000
--- a/tools/common.c
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include "common.h"
-
-#ifdef WINDOWS
-#include "compat.h"
-#endif
-
-void die(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- fprintf(stderr, "\n");
- exit(1);
-}
-
-void die_errno(int err, const char *fmt, ...)
-{
- va_list ap;
-
- if (err == 0)
- return;
-
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- fprintf(stderr, ": %s\n", strerror(errno));
- exit(1);
-}
-
-void die_amqp_error(int err, const char *fmt, ...)
-{
- va_list ap;
- char *errstr;
-
- if (err >= 0)
- return;
-
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- fprintf(stderr, ": %s\n", errstr = amqp_error_string(-err));
- free(errstr);
- exit(1);
-}
-
-char *amqp_server_exception_string(amqp_rpc_reply_t r)
-{
- int res;
- char *s;
-
- switch (r.reply.id) {
- case AMQP_CONNECTION_CLOSE_METHOD: {
- amqp_connection_close_t *m
- = (amqp_connection_close_t *)r.reply.decoded;
- res = asprintf(&s, "server connection error %d, message: %.*s",
- m->reply_code,
- (int)m->reply_text.len,
- (char *)m->reply_text.bytes);
- break;
- }
-
- case AMQP_CHANNEL_CLOSE_METHOD: {
- amqp_channel_close_t *m
- = (amqp_channel_close_t *)r.reply.decoded;
- res = asprintf(&s, "server channel error %d, message: %.*s",
- m->reply_code,
- (int)m->reply_text.len,
- (char *)m->reply_text.bytes);
- break;
- }
-
- default:
- res = asprintf(&s, "unknown server error, method id 0x%08X",
- r.reply.id);
- break;
- }
-
- return res >= 0 ? s : NULL;
-}
-
-char *amqp_rpc_reply_string(amqp_rpc_reply_t r)
-{
- switch (r.reply_type) {
- case AMQP_RESPONSE_NORMAL:
- return strdup("normal response");
-
- case AMQP_RESPONSE_NONE:
- return strdup("missing RPC reply type");
-
- case AMQP_RESPONSE_LIBRARY_EXCEPTION:
- return amqp_error_string(r.library_error);
-
- case AMQP_RESPONSE_SERVER_EXCEPTION:
- return amqp_server_exception_string(r);
-
- default:
- abort();
- }
-}
-
-void die_rpc(amqp_rpc_reply_t r, const char *fmt, ...)
-{
- va_list ap;
- char *errstr;
-
- if (r.reply_type == AMQP_RESPONSE_NORMAL)
- return;
-
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- fprintf(stderr, ": %s\n", errstr = amqp_rpc_reply_string(r));
- free(errstr);
- exit(1);
-}
-
-static char *amqp_server = "localhost";
-static char *amqp_vhost = "/";
-static char *amqp_username = "guest";
-static char *amqp_password = "guest";
-
-const char *connect_options_title = "Connection options";
-struct poptOption connect_options[] = {
- {"server", 's', POPT_ARG_STRING, &amqp_server, 0,
- "the AMQP server to connect to", "hostname:port"},
- {"vhost", 0, POPT_ARG_STRING, &amqp_vhost, 0,
- "the vhost to use when connecting", "vhost"},
- {"username", 0, POPT_ARG_STRING, &amqp_username, 0,
- "the username to login with", "username"},
- {"password", 0, POPT_ARG_STRING, &amqp_password, 0,
- "the password to login with", "password"},
- { NULL, 0, 0, NULL, 0 }
-};
-
-amqp_connection_state_t make_connection(void)
-{
- int s;
- amqp_connection_state_t conn;
- char *host = amqp_server;
- int port = 0;
-
- /* parse the server string into a hostname and a port */
- char *colon = strchr(amqp_server, ':');
- if (colon) {
- char *port_end;
- size_t host_len = colon - amqp_server;
- host = malloc(host_len + 1);
- memcpy(host, amqp_server, host_len);
- host[host_len] = 0;
-
- port = strtol(colon+1, &port_end, 10);
- if (port < 0
- || port > 65535
- || port_end == colon+1
- || *port_end != 0)
- die("bad server port number in %s", amqp_server);
- }
-
- s = amqp_open_socket(host, port ? port : 5672);
- die_amqp_error(s, "opening socket to %s", amqp_server);
-
- conn = amqp_new_connection();
- amqp_set_sockfd(conn, s);
-
- die_rpc(amqp_login(conn, amqp_vhost, 0, 131072, 0,
- AMQP_SASL_METHOD_PLAIN,
- amqp_username, amqp_password),
- "logging in to AMQP server");
-
- if (!amqp_channel_open(conn, 1))
- die_rpc(amqp_get_rpc_reply(conn), "opening channel");
-
- return conn;
-}
-
-void close_connection(amqp_connection_state_t conn)
-{
- int res;
- die_rpc(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS),
- "closing channel");
- die_rpc(amqp_connection_close(conn, AMQP_REPLY_SUCCESS),
- "closing connection");
-
- res = amqp_destroy_connection(conn);
- die_amqp_error(res, "closing connection");
-}
-
-amqp_bytes_t read_all(int fd)
-{
- size_t space = 4096;
- amqp_bytes_t bytes;
-
- bytes.bytes = malloc(space);
- bytes.len = 0;
-
- for (;;) {
- ssize_t res = read(fd, bytes.bytes+bytes.len, space-bytes.len);
- if (res == 0)
- break;
-
- if (res < 0) {
- if (errno == EINTR)
- continue;
-
- die_errno(errno, "reading");
- }
-
- bytes.len += res;
- if (bytes.len == space) {
- space *= 2;
- bytes.bytes = realloc(bytes.bytes, space);
- }
- }
-
- return bytes;
-}
-
-void write_all(int fd, amqp_bytes_t data)
-{
- while (data.len > 0) {
- ssize_t res = write(fd, data.bytes, data.len);
- if (res < 0)
- die_errno(errno, "write");
-
- data.len -= res;
- data.bytes += res;
- }
-}
-
-void copy_body(amqp_connection_state_t conn, int fd)
-{
- size_t body_remaining;
- amqp_frame_t frame;
-
- int res = amqp_simple_wait_frame(conn, &frame);
- die_amqp_error(res, "waiting for header frame");
- if (frame.frame_type != AMQP_FRAME_HEADER)
- die("expected header, got frame type 0x%X",
- frame.frame_type);
-
- body_remaining = frame.payload.properties.body_size;
- while (body_remaining) {
- res = amqp_simple_wait_frame(conn, &frame);
- die_amqp_error(res, "waiting for body frame");
- if (frame.frame_type != AMQP_FRAME_BODY)
- die("expected body, got frame type 0x%X",
- frame.frame_type);
-
- write_all(fd, frame.payload.body_fragment);
- body_remaining -= frame.payload.body_fragment.len;
- }
-}
-
-poptContext process_options(int argc, const char **argv,
- struct poptOption *options,
- const char *help)
-{
- int c;
- poptContext opts = poptGetContext(NULL, argc, argv, options, 0);
- poptSetOtherOptionHelp(opts, help);
-
- while ((c = poptGetNextOpt(opts)) >= 0) {
- /* no options require explicit handling */
- }
-
- if (c < -1) {
- fprintf(stderr, "%s: %s\n",
- poptBadOption(opts, POPT_BADOPTION_NOALIAS),
- poptStrerror(c));
- poptPrintUsage(opts, stderr, 0);
- exit(1);
- }
-
- return opts;
-}
-
-void process_all_options(int argc, const char **argv,
- struct poptOption *options)
-{
- poptContext opts = process_options(argc, argv, options,
- "[OPTIONS]...");
- const char *opt = poptPeekArg(opts);
-
- if (opt) {
- fprintf(stderr, "unexpected operand: %s\n", opt);
- poptPrintUsage(opts, stderr, 0);
- exit(1);
- }
-
- poptFreeContext(opts);
-}
-
-amqp_bytes_t cstring_bytes(const char *str)
-{
- return str ? amqp_cstring_bytes(str) : amqp_empty_bytes;
-}
diff --git a/tools/common.h b/tools/common.h
deleted file mode 100644
index 84889d3..0000000
--- a/tools/common.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdint.h>
-
-#include <popt.h>
-
-#include <amqp.h>
-#include <amqp_framing.h>
-
-extern char *amqp_server_exception_string(amqp_rpc_reply_t r);
-extern char *amqp_rpc_reply_string(amqp_rpc_reply_t r);
-
-extern void die(const char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
-extern void die_errno(int err, const char *fmt, ...)
- __attribute__ ((format (printf, 2, 3)));
-extern void die_amqp_error(int err, const char *fmt, ...)
- __attribute__ ((format (printf, 2, 3)));
-extern void die_rpc(amqp_rpc_reply_t r, const char *fmt, ...)
- __attribute__ ((format (printf, 2, 3)));
-
-extern const char *connect_options_title;
-extern struct poptOption connect_options[];
-extern amqp_connection_state_t make_connection(void);
-extern void close_connection(amqp_connection_state_t conn);
-
-extern amqp_bytes_t read_all(int fd);
-extern void write_all(int fd, amqp_bytes_t data);
-
-extern void copy_body(amqp_connection_state_t conn, int fd);
-
-#define INCLUDE_OPTIONS(options) \
- {NULL, 0, POPT_ARG_INCLUDE_TABLE, options, 0, options ## _title, NULL}
-
-extern poptContext process_options(int argc, const char **argv,
- struct poptOption *options,
- const char *help);
-extern void process_all_options(int argc, const char **argv,
- struct poptOption *options);
-
-extern amqp_bytes_t cstring_bytes(const char *str);
diff --git a/tools/consume.c b/tools/consume.c
deleted file mode 100644
index 434a6f5..0000000
--- a/tools/consume.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "common.h"
-#include "process.h"
-
-/* Convert a amqp_bytes_t to an escaped string form for printing. We
- use the same escaping conventions as rabbitmqctl. */
-static char *stringify_bytes(amqp_bytes_t bytes)
-{
- /* We will need up to 4 chars per byte, plus the terminating 0 */
- char *res = malloc(bytes.len * 4 + 1);
- uint8_t *data = bytes.bytes;
- char *p = res;
- size_t i;
-
- for (i = 0; i < bytes.len; i++) {
- if (data[i] >= 32 && data[i] != 127) {
- *p++ = data[i];
- }
- else {
- *p++ = '\\';
- *p++ = '0' + (data[i] >> 6);
- *p++ = '0' + (data[i] >> 3 & 0x7);
- *p++ = '0' + (data[i] & 0x7);
- }
- }
-
- *p = 0;
- return res;
-}
-
-static amqp_bytes_t setup_queue(amqp_connection_state_t conn,
- char *queue, char *exchange,
- char *routing_key, int declare)
-{
- amqp_bytes_t queue_bytes = cstring_bytes(queue);
-
- /* if an exchange name wasn't provided, check that we don't
- have options that require it. */
- if (!exchange && routing_key) {
- fprintf(stderr, "--routing-key option requires an exchange"
- " name to be provided with --exchange\n");
- exit(1);
- }
-
- if (!queue || exchange || declare) {
- /* Declare the queue as auto-delete. */
- amqp_queue_declare_ok_t *res = amqp_queue_declare(conn, 1,
- queue_bytes, 0, 0, 1, 1,
- amqp_empty_table);
- if (!res)
- die_rpc(amqp_get_rpc_reply(conn), "queue.declare");
-
- if (!queue) {
- /* the server should have provided a queue name */
- char *sq;
- queue_bytes = amqp_bytes_malloc_dup(res->queue);
- sq = stringify_bytes(queue_bytes);
- fprintf(stderr, "Server provided queue name: %s\n",
- sq);
- free(sq);
- }
-
- /* Bind to an exchange if requested */
- if (exchange) {
- amqp_bytes_t eb = amqp_cstring_bytes(exchange);
- if (!amqp_queue_bind(conn, 1, queue_bytes, eb,
- cstring_bytes(routing_key),
- amqp_empty_table))
- die_rpc(amqp_get_rpc_reply(conn),
- "queue.bind");
- }
- }
-
- return queue_bytes;
-}
-
-static void do_consume(amqp_connection_state_t conn, amqp_bytes_t queue,
- int no_ack, const char * const *argv)
-{
- if (!amqp_basic_consume(conn, 1, queue, amqp_empty_bytes, 0, no_ack,
- 0, amqp_empty_table))
- die_rpc(amqp_get_rpc_reply(conn), "basic.consume");
-
- for (;;) {
- amqp_frame_t frame;
- struct pipeline pl;
- uint64_t delivery_tag;
- int res = amqp_simple_wait_frame(conn, &frame);
- die_amqp_error(res, "waiting for header frame");
-
- if (frame.frame_type != AMQP_FRAME_METHOD
- || frame.payload.method.id != AMQP_BASIC_DELIVER_METHOD)
- continue;
-
- amqp_basic_deliver_t *deliver
- = (amqp_basic_deliver_t *)frame.payload.method.decoded;
- delivery_tag = deliver->delivery_tag;
-
- pipeline(argv, &pl);
- copy_body(conn, pl.infd);
-
- if (finish_pipeline(&pl) && !no_ack)
- die_amqp_error(amqp_basic_ack(conn, 1, delivery_tag,
- 0),
- "basic.ack");
-
- amqp_maybe_release_buffers(conn);
- }
-}
-
-int main(int argc, const char **argv)
-{
- poptContext opts;
- amqp_connection_state_t conn;
- const char * const *cmd_argv;
- char *queue = NULL;
- char *exchange = NULL;
- char *routing_key = NULL;
- int declare = 0;
- int no_ack = 0;
- amqp_bytes_t queue_bytes;
-
- struct poptOption options[] = {
- INCLUDE_OPTIONS(connect_options),
- {"queue", 'q', POPT_ARG_STRING, &queue, 0,
- "the queue to consume from", "queue"},
- {"exchange", 'e', POPT_ARG_STRING, &exchange, 0,
- "bind the queue to this exchange", "exchange"},
- {"routing-key", 'r', POPT_ARG_STRING, &routing_key, 0,
- "the routing key to bind with", "routing key"},
- {"declare", 'd', POPT_ARG_NONE, &declare, 0,
- "declare an exclusive queue", NULL},
- {"no-ack", 'A', POPT_ARG_NONE, &no_ack, 0,
- "consume in no-ack mode", NULL},
- POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0 }
- };
-
- opts = process_options(argc, argv, options,
- "[OPTIONS]... <command> <args>");
-
- cmd_argv = poptGetArgs(opts);
- if (!cmd_argv || !cmd_argv[0]) {
- fprintf(stderr, "consuming command not specified\n");
- poptPrintUsage(opts, stderr, 0);
- goto error;
- }
-
- conn = make_connection();
- queue_bytes = setup_queue(conn, queue, exchange, routing_key, declare);
- do_consume(conn, queue_bytes, no_ack, cmd_argv);
- close_connection(conn);
- return 0;
-
-error:
- poptFreeContext(opts);
- return 1;
-}
diff --git a/tools/declare_queue.c b/tools/declare_queue.c
deleted file mode 100644
index 145a15e..0000000
--- a/tools/declare_queue.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "common.h"
-
-int main(int argc, const char **argv)
-{
- amqp_connection_state_t conn;
- char *queue = NULL;
- int durable = 0;
-
- struct poptOption options[] = {
- INCLUDE_OPTIONS(connect_options),
- {"queue", 'q', POPT_ARG_STRING, &queue, 0,
- "the queue name to declare, or the empty string", "queue"},
- {"durable", 'd', POPT_ARG_VAL, &durable, 1,
- "declare a durable queue", NULL},
- POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0 }
- };
-
- process_all_options(argc, argv, options);
-
- if (queue == NULL) {
- fprintf(stderr, "queue name not specified\n");
- return 1;
- }
-
- conn = make_connection();
- {
- amqp_queue_declare_ok_t *reply = amqp_queue_declare(conn, 1,
- cstring_bytes(queue),
- 0,
- durable,
- 0,
- 0,
- amqp_empty_table);
- if (reply == NULL)
- die_rpc(amqp_get_rpc_reply(conn), "queue.declare");
-
- printf("%.*s\n", (int)reply->queue.len, (char *)reply->queue.bytes);
- }
- close_connection(conn);
- return 0;
-}
diff --git a/tools/delete_queue.c b/tools/delete_queue.c
deleted file mode 100644
index ccd157e..0000000
--- a/tools/delete_queue.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "common.h"
-
-int main(int argc, const char **argv)
-{
- amqp_connection_state_t conn;
- char *queue = NULL;
- int if_unused = 0;
- int if_empty = 0;
-
- struct poptOption options[] = {
- INCLUDE_OPTIONS(connect_options),
- {"queue", 'q', POPT_ARG_STRING, &queue, 0,
- "the queue name to delete", "queue"},
- {"if-unused", 'u', POPT_ARG_VAL, &if_unused, 1,
- "do not delete unless queue is unused", NULL},
- {"if-empty", 'e', POPT_ARG_VAL, &if_empty, 1,
- "do not delete unless queue is empty", NULL},
- POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0 }
- };
-
- process_all_options(argc, argv, options);
-
- if (queue == NULL || *queue == '\0') {
- fprintf(stderr, "queue name not specified\n");
- return 1;
- }
-
- conn = make_connection();
- {
- amqp_queue_delete_ok_t *reply = amqp_queue_delete(conn, 1,
- cstring_bytes(queue),
- if_unused,
- if_empty);
- if (reply == NULL) {
- die_rpc(amqp_get_rpc_reply(conn), "queue.delete");
- }
- printf("%u\n", reply->message_count);
- }
- close_connection(conn);
- return 0;
-}
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/consume.xml
deleted file mode 100644
index c6dc65c..0000000
--- a/tools/doc/consume.xml
+++ /dev/null
@@ -1,177 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd"
-[
-<!ENTITY date SYSTEM "man-date.ent" >
-]
->
-<refentry lang="en">
- <refentryinfo>
- <productname>RabbitMQ C Client</productname>
- <authorgroup>
- <corpauthor>The RabbitMQ Team &lt;<ulink url="mailto:info@rabbitmq.com"><email>info@rabbitmq.com</email></ulink>&gt;</corpauthor>
- </authorgroup>
- <date>&date;</date>
- </refentryinfo>
-
- <refmeta>
- <refentrytitle>amqp-consume</refentrytitle>
- <manvolnum>1</manvolnum>
- <refmiscinfo class="manual">RabbitMQ C Client</refmiscinfo>
- </refmeta>
-
- <refnamediv>
- <refname>amqp-consume</refname>
- <refpurpose>Consume messages from a queue on an AMQP server</refpurpose>
- </refnamediv>
-
- <refsynopsisdiv>
- <cmdsynopsis>
- <command>amqp-consume</command>
- <arg choice="opt" rep="repeat">
- <replaceable>OPTION</replaceable>
- </arg>
- <arg choice="req">
- <replaceable>command</replaceable>
- </arg>
- <arg choice="opt" rep="repeat">
- <replaceable>args</replaceable>
- </arg>
- </cmdsynopsis>
- </refsynopsisdiv>
-
- <refsect1>
- <title>Description</title>
- <para>
- <command>amqp-consume</command> consumes messages from a
- queue on an AMQP server. For each message that arrives, a
- receiving command is run, with the message body supplied
- to it on standard input.
- </para>
- <para>
- <command>amqp-consume</command> can consume from an
- existing queue, or it can create a new queue. It can
- optionally bind the queue to an existing exchange.
- </para>
- <para>
- By default, messages will be consumed with explicit
- acknowledgements. A message will only be acknowledged if
- the receiving command exits successfully (i.e. with an
- exit code of zero). The AMQP <quote>no ack</quote> mode
- (a.k.a. auto-ack mode) can be enable with the
- <option>-A</option> option.
- </para>
- </refsect1>
-
- <refsect1>
- <title>Options</title>
- <variablelist>
- <varlistentry>
- <term><option>-q</option></term>
- <term><option>--queue</option>=<replaceable class="parameter">queue name</replaceable></term>
- <listitem>
- <para>
- The name of the queue to consume messages
- from.
- </para>
-
- <para>
- If the <option>--queue</option> option is
- omitted, the AMQP server will assign a unique
- name to the queue, and that server-assigned
- name will be dixsplayed on stderr; this case
- implies that an exclusive queue should be
- declared.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-e</option></term>
- <term><option>--exchange</option>=<replaceable class="parameter">exchange name</replaceable></term>
- <listitem>
- <para>
- Specifies that an exclusive queue should
- be declared, and bound to the given exchange.
- The specified exchange should already exist
- unless the <option>--exchange-type</option>
- option is used to request the creation of an
- exchange.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-r</option></term>
- <term><option>--routing-key</option>=<replaceable class="parameter">routing key</replaceable></term>
- <listitem>
- <para>
- The routing key for binding. If omitted, an
- empty routing key is assumed.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-d</option></term>
- <term><option>--declare</option></term>
- <listitem>
- <para>
- Forces an exclusive queue to be declared,
- even when it otherwise would not be. That is,
- when a queue name is specified with the
- <option>--queue</option> option, but no
- binding to an exchange is requested with the
- <option>--exchange</option> option.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-A</option></term>
- <term><option>--no-ack</option>=<replaceable class="parameter">routing key</replaceable></term>
- <listitem>
- <para>
- Enable <quote>no ack</quote> mode: The AMQP
- server will unconditionally acknowledge each
- message that is delivered, regardless of
- whether the target command exits successfully
- or not.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>Examples</title>
- <variablelist>
- <varlistentry>
- <term>Consume messages from an existing queue
- <quote><systemitem
- class="resource">myqueue</systemitem></quote>, and
- output the message bodies on standard output via
- <command>cat</command>:</term>
- <listitem>
- <screen><prompt>$ </prompt><userinput>amqp-publish -q myqueue cat</userinput></screen>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>Bind a new exclusive queue to an
- exchange <quote><systemitem
- class="resource">myexch</systemitem></quote>, and send
- each message body to the script
- <filename>myscript</filename>, automatically
- acknowledging them on the server:</term>
- <listitem>
- <screen><prompt>$ </prompt><userinput>amqp-consume -A -e myexch ./myscript</userinput></screen>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>See also</title>
- <para>
- <citerefentry><refentrytitle>librabbitmq-tools</refentrytitle><manvolnum>7</manvolnum></citerefentry>
- describes connection-related options common to all the
- RabbitMQ C Client tools.
- </para>
- </refsect1>
-</refentry>
diff --git a/tools/doc/declare_queue.xml b/tools/doc/declare_queue.xml
deleted file mode 100644
index 7e9da32..0000000
--- a/tools/doc/declare_queue.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd"
-[
-<!ENTITY date SYSTEM "man-date.ent" >
-]
->
-<refentry lang="en">
- <refentryinfo>
- <productname>RabbitMQ C Client</productname>
- <authorgroup>
- <corpauthor>The RabbitMQ Team &lt;<ulink url="mailto:info@rabbitmq.com"><email>info@rabbitmq.com</email></ulink>&gt;</corpauthor>
- </authorgroup>
- <date>&date;</date>
- </refentryinfo>
-
- <refmeta>
- <refentrytitle>amqp-declare-queue</refentrytitle>
- <manvolnum>1</manvolnum>
- <refmiscinfo class="manual">RabbitMQ C Client</refmiscinfo>
- </refmeta>
-
- <refnamediv>
- <refname>amqp-declare-queue</refname>
- <refpurpose>Declare (create or assert the existence of) a queue on an AMQP server</refpurpose>
- </refnamediv>
-
- <refsynopsisdiv>
- <cmdsynopsis>
- <command>amqp-declare-queue</command>
- <arg choice="opt" rep="repeat">
- <replaceable>OPTION</replaceable>
- </arg>
- <arg choice="opt">-d</arg>
- <arg choice="req">-q <replaceable>queue name</replaceable></arg>
- </cmdsynopsis>
- </refsynopsisdiv>
-
- <refsect1>
- <title>Description</title>
- <para>
- <command>amqp-declare-queue</command> attempts to create a
- queue on an AMQP server, and exits. If the empty-string is
- supplied as the queue name, a fresh queue name is
- generated by the server and returned. In all cases, if a
- queue was successfully declared, the (raw binary) name of
- the queue is printed to standard output, followed by a
- newline.
- </para>
- </refsect1>
-
- <refsect1>
- <title>Options</title>
- <variablelist>
- <varlistentry>
- <term><option>-q</option></term>
- <term><option>--queue</option>=<replaceable class="parameter">queue name</replaceable></term>
- <listitem>
- <para>
- The name of the queue to declare. If the
- empty string is supplied, a fresh queue name
- is generated by the server.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-d</option></term>
- <term><option>--durable</option></term>
- <listitem>
- <para>
- Causes the queue to be declared with the
- "durable" flag set. Durable queues survive
- server restarts. By default, queues are declared
- in "transient" mode.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>Exit Status</title>
- <para>
- If the queue was successfully declared, the exit status is
- 0. If an error occurs, the exit status is 1.
- </para>
- </refsect1>
-
- <refsect1>
- <title>Examples</title>
- <variablelist>
- <varlistentry>
- <term>Declare the durable queue <quote><systemitem
- class="resource">myqueue</systemitem></quote>, and
- display the name of the queue on standard output:</term>
- <listitem>
- <screen><prompt>$ </prompt><userinput>amqp-declare-queue -d -q myqueue</userinput>
-myqueue</screen>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>Declare a fresh, server-named transient queue,
- and display the name of the queue on standard output
- (use <citerefentry><refentrytitle>amqp-delete-queue</refentrytitle>
- <manvolnum>1</manvolnum></citerefentry> to delete
- it from the server once you're done):</term>
- <listitem>
- <screen><prompt>$ </prompt><userinput>amqp-declare-queue -q ""</userinput>
-amq.gen-BW/wvociA8g6LFpb1PlqOA==</screen>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>See also</title>
- <para>
- <citerefentry><refentrytitle>librabbitmq-tools</refentrytitle><manvolnum>7</manvolnum></citerefentry>
- describes connection-related options common to all the
- RabbitMQ C Client tools.
- </para>
- </refsect1>
-</refentry>
diff --git a/tools/doc/delete_queue.xml b/tools/doc/delete_queue.xml
deleted file mode 100644
index 69d03d8..0000000
--- a/tools/doc/delete_queue.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd"
-[
-<!ENTITY date SYSTEM "man-date.ent" >
-]
->
-<refentry lang="en">
- <refentryinfo>
- <productname>RabbitMQ C Client</productname>
- <authorgroup>
- <corpauthor>The RabbitMQ Team &lt;<ulink url="mailto:info@rabbitmq.com"><email>info@rabbitmq.com</email></ulink>&gt;</corpauthor>
- </authorgroup>
- <date>&date;</date>
- </refentryinfo>
-
- <refmeta>
- <refentrytitle>amqp-delete-queue</refentrytitle>
- <manvolnum>1</manvolnum>
- <refmiscinfo class="manual">RabbitMQ C Client</refmiscinfo>
- </refmeta>
-
- <refnamediv>
- <refname>amqp-delete-queue</refname>
- <refpurpose>Delete a queue from an AMQP server</refpurpose>
- </refnamediv>
-
- <refsynopsisdiv>
- <cmdsynopsis>
- <command>amqp-delete-queue</command>
- <arg choice="opt" rep="repeat">
- <replaceable>OPTION</replaceable>
- </arg>
- <arg choice="req">-q <replaceable>queue name</replaceable></arg>
- </cmdsynopsis>
- </refsynopsisdiv>
-
- <refsect1>
- <title>Description</title>
- <para>
- <command>amqp-delete-queue</command> deletes a queue from
- an AMQP server, and exits after printing to standard
- output the number of messages that were in the queue at
- the time of its deletion.
- </para>
- </refsect1>
-
- <refsect1>
- <title>Options</title>
- <variablelist>
- <varlistentry>
- <term><option>-q</option></term>
- <term><option>--queue</option>=<replaceable class="parameter">queue name</replaceable></term>
- <listitem>
- <para>
- The name of the queue to delete.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>Exit Status</title>
- <para>
- If the queue was successfully deleted, the exit status is
- 0. If an error occurs, the exit status is 1.
- </para>
- </refsect1>
-
- <refsect1>
- <title>Examples</title>
- <variablelist>
- <varlistentry>
- <term>Delete the
- queue <quote><systemitem class="resource">myqueue</systemitem></quote>
- at a moment when it has 123 messages waiting on
- it:</term>
- <listitem>
- <screen><prompt>$ </prompt><userinput>amqp-delete-queue -q myqueue</userinput>
-123</screen>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>See also</title>
- <para>
- <citerefentry><refentrytitle>librabbitmq-tools</refentrytitle><manvolnum>7</manvolnum></citerefentry>
- describes connection-related options common to all the
- RabbitMQ C Client tools.
- </para>
- </refsect1>
-</refentry>
diff --git a/tools/doc/get.xml b/tools/doc/get.xml
deleted file mode 100644
index 9770a8b..0000000
--- a/tools/doc/get.xml
+++ /dev/null
@@ -1,95 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd"
-[
-<!ENTITY date SYSTEM "man-date.ent" >
-]
->
-<refentry lang="en">
- <refentryinfo>
- <productname>RabbitMQ C Client</productname>
- <authorgroup>
- <corpauthor>The RabbitMQ Team &lt;<ulink url="mailto:info@rabbitmq.com"><email>info@rabbitmq.com</email></ulink>&gt;</corpauthor>
- </authorgroup>
- <date>&date;</date>
- </refentryinfo>
-
- <refmeta>
- <refentrytitle>amqp-get</refentrytitle>
- <manvolnum>1</manvolnum>
- <refmiscinfo class="manual">RabbitMQ C Client</refmiscinfo>
- </refmeta>
-
- <refnamediv>
- <refname>amqp-get</refname>
- <refpurpose>Get a message from a queue on an AMQP server</refpurpose>
- </refnamediv>
-
- <refsynopsisdiv>
- <cmdsynopsis>
- <command>amqp-get</command>
- <arg choice="opt" rep="repeat">
- <replaceable>OPTION</replaceable>
- </arg>
- <arg choice="req">-q <replaceable>queue name</replaceable></arg>
- </cmdsynopsis>
- </refsynopsisdiv>
-
- <refsect1>
- <title>Description</title>
- <para>
- <command>amqp-get</command> attempts to consume a single
- message from a queue on an AMQP server, and exits. Unless
- the queue was empty, the body of the resulting message is
- sent to standard output.
- </para>
- </refsect1>
-
- <refsect1>
- <title>Options</title>
- <variablelist>
- <varlistentry>
- <term><option>-q</option></term>
- <term><option>--queue</option>=<replaceable class="parameter">queue name</replaceable></term>
- <listitem>
- <para>
- The name of the queue to consume messages
- from.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>Exit Status</title>
- <para>
- If the queue is not empty, and a message is successfully
- retrieved, the exit status is 0. If an error occurs, the
- exit status is 1. If the queue is found to be empty, the
- exit status is 2.
- </para>
- </refsect1>
-
- <refsect1>
- <title>Examples</title>
- <variablelist>
- <varlistentry>
- <term>Get a message from the queue <quote><systemitem
- class="resource">myqueue</systemitem></quote>, and
- display its body on standard output:</term>
- <listitem>
- <screen><prompt>$ </prompt><userinput>amqp-get -q myqueue</userinput></screen>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>See also</title>
- <para>
- <citerefentry><refentrytitle>librabbitmq-tools</refentrytitle><manvolnum>7</manvolnum></citerefentry>
- describes connection-related options common to all the
- RabbitMQ C Client tools.
- </para>
- </refsect1>
-</refentry>
diff --git a/tools/doc/librabbitmq-tools.xml b/tools/doc/librabbitmq-tools.xml
deleted file mode 100644
index 41f092a..0000000
--- a/tools/doc/librabbitmq-tools.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd"
-[
-<!ENTITY date SYSTEM "man-date.ent" >
-]
->
-<refentry lang="en">
- <refentryinfo>
- <productname>RabbitMQ C Client</productname>
- <authorgroup>
- <corpauthor>The RabbitMQ Team &lt;<ulink url="mailto:info@rabbitmq.com"><email>info@rabbitmq.com</email></ulink>&gt;</corpauthor>
- </authorgroup>
- <date>&date;</date>
- </refentryinfo>
-
- <refmeta>
- <refentrytitle>librabbitmq-tools</refentrytitle>
- <manvolnum>7</manvolnum>
- <refmiscinfo class="manual">RabbitMQ C Client</refmiscinfo>
- </refmeta>
-
- <refnamediv>
- <refname>librabbitmq-tools</refname>
- <refpurpose>Command line AMQP tools</refpurpose>
- </refnamediv>
-
- <refsect1>
- <title>Description</title>
- <para>
- A set of command line AMQP tools based on <systemitem
- class="library">librabbitmq</systemitem>. This page
- describes common options and conventions used by all of
- the tools.
- </para>
- </refsect1>
-
- <refsect1>
- <title>Common Options</title>
- <variablelist>
- <varlistentry>
- <term><option>-s</option></term>
- <term><option>--server</option>=<replaceable class="parameter">hostname:port</replaceable></term>
- <listitem>
- <para>
- The host name (or address) to connect to.
- Defaults to localhost. The port number may
- also be specified; if omitted, it defaults to
- the standard AMQP port number (5672).
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>--vhost</option>=<replaceable class="parameter">vhost</replaceable></term>
- <listitem>
- <para>
- The AMQP vhost to specify when connnecting.
- Defaults to <literal>/</literal>.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>--username</option>=<replaceable class="parameter">username</replaceable></term>
- <listitem>
- <para>
- The username to authenticate to the AMQP server with. Defaults to <literal>guest</literal>.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>--password</option>=<replaceable class="parameter">password</replaceable></term>
- <listitem>
- <para>
- The password to authenticate to the AMQP server with. Defaults to <literal>guest</literal>.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>See also</title>
- <para>
- <simplelist type='inline'>
- <member><citerefentry><refentrytitle>amqp-publish</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
- <member><citerefentry><refentrytitle>amqp-consume</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
- <member><citerefentry><refentrytitle>amqp-get</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
- </simplelist>
- </para>
- </refsect1>
-</refentry>
diff --git a/tools/doc/publish.xml b/tools/doc/publish.xml
deleted file mode 100644
index d2e8d2e..0000000
--- a/tools/doc/publish.xml
+++ /dev/null
@@ -1,160 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd"
-[
-<!ENTITY date SYSTEM "man-date.ent" >
-]
->
-<refentry lang="en">
- <refentryinfo>
- <productname>RabbitMQ C Client</productname>
- <authorgroup>
- <corpauthor>The RabbitMQ Team &lt;<ulink url="mailto:info@rabbitmq.com"><email>info@rabbitmq.com</email></ulink>&gt;</corpauthor>
- </authorgroup>
- <date>&date;</date>
- </refentryinfo>
-
- <refmeta>
- <refentrytitle>amqp-publish</refentrytitle>
- <manvolnum>1</manvolnum>
- <refmiscinfo class="manual">RabbitMQ C Client</refmiscinfo>
- </refmeta>
-
- <refnamediv>
- <refname>amqp-publish</refname>
- <refpurpose>Publish a message on an AMQP server</refpurpose>
- </refnamediv>
-
- <refsynopsisdiv>
- <cmdsynopsis>
- <command>amqp-publish</command>
- <arg choice="opt" rep="repeat">
- <replaceable>OPTION</replaceable>
- </arg>
- </cmdsynopsis>
- </refsynopsisdiv>
-
- <refsect1>
- <title>Description</title>
- <para>
- Publishes a message to an exchange on an AMQP server.
- Options allow the various properties of the message and
- parameters of the AMQP <function>basic.publish</function>
- method to be specified.
- </para>
- <para>
- By default, the message body is read from standard input.
- Alternatively, the <option>-b</option> option allows the message
- body to be provided as part of the command.
- </para>
- </refsect1>
-
- <refsect1>
- <title>Options</title>
- <variablelist>
- <varlistentry>
- <term><option>-e</option></term>
- <term><option>--exchange</option>=<replaceable class="parameter">exchange name</replaceable></term>
- <listitem>
- <para>
- The name of the exchange to publish to. If
- omitted, the default exchange (also known as
- the nameless exchange) is used.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-r</option></term>
- <term><option>--routing-key</option>=<replaceable class="parameter">routing key</replaceable></term>
- <listitem>
- <para>
- The routing key to publish with. If omitted,
- an empty routing key is assumed. A routing
- key must be specified when publishing to the
- default exchange; in that case, accoding to
- the AMQP specification, the routing key
- corresponds to a queue name.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-p</option></term>
- <term><option>--persistent</option></term>
- <listitem>
- <para>
- Use the persistent delivery mode. Without
- this option, non-persistent delivery is used.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-C</option></term>
- <term><option>--content-type</option>=<replaceable class="parameter">MIME type</replaceable></term>
- <listitem>
- <para>
- Specifies the content-type property for the
- message. If omitted, the content-type
- property is not set on the message.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-E</option></term>
- <term><option>--content-encoding</option>=<replaceable class="parameter">content coding</replaceable></term>
- <listitem>
- <para>
- Specifies the content-encoding property for
- the message. If omitted, the content-encoding
- property is not set on the message.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-b</option></term>
- <term><option>--body</option>=<replaceable class="parameter">message body</replaceable></term>
- <listitem>
- <para>
- Specifies the message body. If omitted, the
- message body is read from standard input.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>Examples</title>
- <variablelist>
- <varlistentry>
- <term>Send a short message, consisting of the word
- <quote><literal>Hello</literal></quote> to the queue
- <quote><systemitem
- class="resource">myqueue</systemitem></quote> via the
- default exchange:</term>
- <listitem>
- <screen><prompt>$ </prompt><userinput>amqp-publish -r myqueue -b Hello</userinput></screen>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>Send some XML data from a file to the exchange
- <quote><systemitem
- class="resource">events</systemitem></quote>, with
- persistent delivery mode, setting the content-type
- property on the message to make the data format
- explicit:</term>
- <listitem>
- <screen><prompt>$ </prompt><userinput>amqp-publish -e events -p -C text/xml &lt;event.xml</userinput></screen>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>See also</title>
- <para>
- <citerefentry><refentrytitle>librabbitmq-tools</refentrytitle><manvolnum>7</manvolnum></citerefentry>
- describes connection-related options common to all the
- RabbitMQ C Client tools.
- </para>
- </refsect1>
-</refentry>
diff --git a/tools/get.c b/tools/get.c
deleted file mode 100644
index 8f8e0d0..0000000
--- a/tools/get.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include "config.h"
-
-#include <stdio.h>
-
-#include "common.h"
-
-static int do_get(amqp_connection_state_t conn, char *queue)
-{
- amqp_rpc_reply_t r
- = amqp_basic_get(conn, 1, cstring_bytes(queue), 1);
- die_rpc(r, "basic.get");
-
- if (r.reply.id == AMQP_BASIC_GET_EMPTY_METHOD)
- return 0;
-
- copy_body(conn, 1);
- return 1;
-}
-
-int main(int argc, const char **argv)
-{
- amqp_connection_state_t conn;
- char *queue = NULL;
- int got_something;
-
- struct poptOption options[] = {
- INCLUDE_OPTIONS(connect_options),
- {"queue", 'q', POPT_ARG_STRING, &queue, 0,
- "the queue to consume from", "queue"},
- POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0 }
- };
-
- process_all_options(argc, argv, options);
-
- if (!queue) {
- fprintf(stderr, "queue not specified\n");
- return 1;
- }
-
- conn = make_connection();
- got_something = do_get(conn, queue);
- close_connection(conn);
- return got_something ? 0 : 2;
-}
diff --git a/tools/publish.c b/tools/publish.c
deleted file mode 100644
index 0917dae..0000000
--- a/tools/publish.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2009 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2009 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "common.h"
-
-static void do_publish(amqp_connection_state_t conn,
- char *exchange, char *routing_key,
- amqp_basic_properties_t *props, amqp_bytes_t body)
-{
- int res = amqp_basic_publish(conn, 1,
- cstring_bytes(exchange),
- cstring_bytes(routing_key),
- 0, 0, props, body);
- die_amqp_error(res, "basic.publish");
-}
-
-int main(int argc, const char **argv)
-{
- amqp_connection_state_t conn;
- char *exchange = NULL;
- char *routing_key = NULL;
- char *content_type = NULL;
- char *content_encoding = NULL;
- char *body = NULL;
- amqp_basic_properties_t props;
- amqp_bytes_t body_bytes;
- int delivery = 1; /* non-persistent by default */
-
- struct poptOption options[] = {
- INCLUDE_OPTIONS(connect_options),
- {"exchange", 'e', POPT_ARG_STRING, &exchange, 0,
- "the exchange to publish to", "exchange"},
- {"routing-key", 'r', POPT_ARG_STRING, &routing_key, 0,
- "the routing key to publish with", "routing key"},
- {"persistent", 'p', POPT_ARG_VAL, &delivery, 2,
- "use the persistent delivery mode", NULL},
- {"content-type", 'C', POPT_ARG_STRING, &content_type, 0,
- "the content-type for the message", "content type"},
- {"content-encoding", 'E', POPT_ARG_STRING,
- &content_encoding, 0,
- "the content-encoding for the message", "content encoding"},
- {"body", 'b', POPT_ARG_STRING, &body, 0,
- "specify the message body", "body"},
- POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0 }
- };
-
- process_all_options(argc, argv, options);
-
- if (!exchange && !routing_key) {
- fprintf(stderr,
- "neither exchange nor routing key specified\n");
- return 1;
- }
-
- memset(&props, 0, sizeof props);
- props._flags = AMQP_BASIC_DELIVERY_MODE_FLAG;
- props.delivery_mode = 2; /* persistent delivery mode */
-
- if (content_type) {
- props._flags |= AMQP_BASIC_CONTENT_TYPE_FLAG;
- props.content_type = amqp_cstring_bytes(content_type);
- }
-
- if (content_encoding) {
- props._flags |= AMQP_BASIC_CONTENT_ENCODING_FLAG;
- props.content_encoding = amqp_cstring_bytes(content_encoding);
- }
-
- conn = make_connection();
-
- if (body)
- body_bytes = amqp_cstring_bytes(body);
- else
- body_bytes = read_all(0);
-
- do_publish(conn, exchange, routing_key, &props, body_bytes);
-
- if (!body)
- free(body_bytes.bytes);
-
- close_connection(conn);
- return 0;
-}
diff --git a/tools/unix/process.c b/tools/unix/process.c
deleted file mode 100644
index 8a02afb..0000000
--- a/tools/unix/process.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2010 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2010 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <unistd.h>
-#include <errno.h>
-#include <spawn.h>
-#include <sys/wait.h>
-
-#include "common.h"
-#include "process.h"
-
-extern char **environ;
-
-void pipeline(const char *const *argv, struct pipeline *pl)
-{
- posix_spawn_file_actions_t file_acts;
-
- int pipefds[2];
- if (pipe(pipefds))
- die_errno(errno, "pipe");
-
- die_errno(posix_spawn_file_actions_init(&file_acts),
- "posix_spawn_file_actions_init");
- die_errno(posix_spawn_file_actions_adddup2(&file_acts, pipefds[0], 0),
- "posix_spawn_file_actions_adddup2");
- die_errno(posix_spawn_file_actions_addclose(&file_acts, pipefds[0]),
- "posix_spawn_file_actions_addclose");
- die_errno(posix_spawn_file_actions_addclose(&file_acts, pipefds[1]),
- "posix_spawn_file_actions_addclose");
-
- die_errno(posix_spawnp(&pl->pid, argv[0], &file_acts, NULL,
- (char * const *)argv, environ),
- "posix_spawnp: %s", argv[0]);
-
- die_errno(posix_spawn_file_actions_destroy(&file_acts),
- "posix_spawn_file_actions_destroy");
-
- if (close(pipefds[0]))
- die_errno(errno, "close");
-
- pl->infd = pipefds[1];
-}
-
-int finish_pipeline(struct pipeline *pl)
-{
- int status;
-
- if (close(pl->infd))
- die_errno(errno, "close");
- if (waitpid(pl->pid, &status, 0) < 0)
- die_errno(errno, "waitpid");
- return WIFEXITED(status) && WEXITSTATUS(status) == 0;
-}
diff --git a/tools/unix/process.h b/tools/unix/process.h
deleted file mode 100644
index ac2939d..0000000
--- a/tools/unix/process.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2010 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2010 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-struct pipeline {
- int pid;
- int infd;
-};
-
-extern void pipeline(const char *const *argv, struct pipeline *pl);
-extern int finish_pipeline(struct pipeline *pl);
diff --git a/tools/windows/compat.c b/tools/windows/compat.c
deleted file mode 100644
index bce318b..0000000
--- a/tools/windows/compat.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2010 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2010 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-
-#include "compat.h"
-
-int asprintf(char **strp, const char *fmt, ...)
-{
- va_list ap;
- int len;
-
- va_start(ap, fmt);
- len = _vscprintf(fmt, ap);
- va_end(ap);
-
- *strp = malloc(len+1);
- if (!*strp)
- return -1;
-
- va_start(ap, fmt);
- _vsnprintf(*strp, len+1, fmt, ap);
- va_end(ap);
-
- (*strp)[len] = 0;
- return len;
-}
diff --git a/tools/windows/compat.h b/tools/windows/compat.h
deleted file mode 100644
index 8211b37..0000000
--- a/tools/windows/compat.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2010 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2010 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-extern int asprintf(char **strp, const char *fmt, ...);
diff --git a/tools/windows/process.c b/tools/windows/process.c
deleted file mode 100644
index 730a5b6..0000000
--- a/tools/windows/process.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2010 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2010 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <stdio.h>
-#include <io.h>
-#include <windows.h>
-
-#include "common.h"
-#include "process.h"
-
-void die_windows_error(const char *fmt, ...)
-{
- char *msg;
-
- va_list ap;
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
-
- if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
- | FORMAT_MESSAGE_ALLOCATE_BUFFER,
- NULL, GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPSTR)&msg, 0, NULL))
- msg = "(failed to retrieve Windows error message)";
-
- fprintf(stderr, ": %s\n", msg);
- exit(1);
-}
-
-static char *make_command_line(const char *const *argv)
-{
- int i;
- size_t len = 1; /* initial quotes */
- char *buf;
- char *dest;
-
- /* calculate the length of the required buffer, making worst
- case assumptions for simplicity */
- for (i = 0;;) {
- /* each character could need escaping */
- len += strlen(argv[i]) * 2;
-
- if (!argv[++i])
- break;
-
- len += 3; /* quotes, space, quotes */
- }
-
- len += 2; /* final quotes and the terminating zero */
-
- dest = buf = malloc(len);
- if (!buf)
- die("allocating memory for subprocess command line");
-
- /* Here we perform the inverse of the CommandLineToArgvW
- function. Note that its rules are slightly crazy: A
- sequence of backslashes only act to escape if followed by
- double quotes. A sequence of backslashes not followed by
- double quotes is untouched. */
-
- for (i = 0;;) {
- const char *src = argv[i];
- int backslashes = 0;
-
- *dest++ = '\"';
-
- for (;;) {
- switch (*src) {
- case 0:
- goto done;
-
- case '\"':
- for (; backslashes; backslashes--)
- *dest++ = '\\';
-
- *dest++ = '\\';
- *dest++ = '\"';
- break;
-
- case '\\':
- backslashes++;
- *dest++ = '\\';
- break;
-
- default:
- backslashes = 0;
- *dest++ = *src;
- break;
- }
-
- src++;
- }
- done:
- for (; backslashes; backslashes--)
- *dest++ = '\\';
-
- *dest++ = '\"';
-
- if (!argv[++i])
- break;
-
- *dest++ = ' ';
- }
-
- *dest++ = 0;
- return buf;
-}
-
-void pipeline(const char *const *argv, struct pipeline *pl)
-{
- HANDLE in_read_handle, in_write_handle;
- SECURITY_ATTRIBUTES sec_attr;
- PROCESS_INFORMATION proc_info;
- STARTUPINFO start_info;
- char *cmdline = make_command_line(argv);
-
- sec_attr.nLength = sizeof sec_attr;
- sec_attr.bInheritHandle = TRUE;
- sec_attr.lpSecurityDescriptor = NULL;
-
- if (!CreatePipe(&in_read_handle, &in_write_handle, &sec_attr, 0))
- die_windows_error("CreatePipe");
-
- if (!SetHandleInformation(in_write_handle, HANDLE_FLAG_INHERIT, 0))
- die_windows_error("SetHandleInformation");
-
- /* when in Rome... */
- ZeroMemory(&proc_info, sizeof proc_info);
- ZeroMemory(&start_info, sizeof start_info);
-
- start_info.cb = sizeof start_info;
- start_info.dwFlags |= STARTF_USESTDHANDLES;
-
- if ((start_info.hStdError = GetStdHandle(STD_ERROR_HANDLE))
- == INVALID_HANDLE_VALUE
- || (start_info.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE))
- == INVALID_HANDLE_VALUE)
- die_windows_error("GetStdHandle");
-
- start_info.hStdInput = in_read_handle;
-
- if (!CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 0,
- NULL, NULL, &start_info, &proc_info))
- die_windows_error("CreateProcess");
-
- free(cmdline);
-
- if (!CloseHandle(proc_info.hThread))
- die_windows_error("CloseHandle for thread");
- if (!CloseHandle(in_read_handle))
- die_windows_error("CloseHandle");
-
- pl->proc_handle = proc_info.hProcess;
- pl->infd = _open_osfhandle((intptr_t)in_write_handle, 0);
-}
-
-int finish_pipeline(struct pipeline *pl)
-{
- DWORD code;
-
- if (close(pl->infd))
- die_errno(errno, "close");
-
- for (;;) {
- if (!GetExitCodeProcess(pl->proc_handle, &code))
- die_windows_error("GetExitCodeProcess");
- if (code != STILL_ACTIVE)
- break;
-
- if (WaitForSingleObject(pl->proc_handle, INFINITE)
- == WAIT_FAILED)
- die_windows_error("WaitForSingleObject");
- }
-
- if (!CloseHandle(pl->proc_handle))
- die_windows_error("CloseHandle for process");
-
- return code;
-}
diff --git a/tools/windows/process.h b/tools/windows/process.h
deleted file mode 100644
index df276a7..0000000
--- a/tools/windows/process.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The Original Code is librabbitmq.
- *
- * The Initial Developers of the Original Code are LShift Ltd, Cohesive
- * Financial Technologies LLC, and Rabbit Technologies Ltd. Portions
- * created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, Cohesive
- * Financial Technologies LLC, or Rabbit Technologies Ltd are Copyright
- * (C) 2007-2008 LShift Ltd, Cohesive Financial Technologies LLC, and
- * Rabbit Technologies Ltd.
- *
- * Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
- * Ltd. Portions created by Cohesive Financial Technologies LLC are
- * Copyright (C) 2007-2010 Cohesive Financial Technologies
- * LLC. Portions created by Rabbit Technologies Ltd are Copyright (C)
- * 2007-2010 Rabbit Technologies Ltd.
- *
- * Portions created by Tony Garnock-Jones are Copyright (C) 2009-2010
- * LShift Ltd and Tony Garnock-Jones.
- *
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * Alternatively, the contents of this file may be used under the terms
- * of the GNU General Public License Version 2 or later (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of those
- * above. If you wish to allow use of your version of this file only
- * under the terms of the GPL, and not to allow others to use your
- * version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the
- * notice and other provisions required by the GPL. If you do not
- * delete the provisions above, a recipient may use your version of
- * this file under the terms of any one of the MPL or the GPL.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-#include <windef.h>
-
-struct pipeline {
- HANDLE proc_handle;
- int infd;
-};
-
-extern void pipeline(const char *const *argv, struct pipeline *pl);
-extern int finish_pipeline(struct pipeline *pl);