diff --git a/.cproject b/.cproject
index 9aaacbfb..f2483dad 100644
--- a/.cproject
+++ b/.cproject
@@ -5,12 +5,12 @@
+
-
@@ -38,6 +38,17 @@
+
+
+
+
+
+
+
+
+
@@ -46,12 +57,12 @@
+
-
@@ -79,6 +90,14 @@
+
+
+
+
+
+
@@ -87,12 +106,12 @@
+
-
@@ -120,6 +139,14 @@
+
+
+
+
+
+
@@ -128,9 +155,6 @@
-
-
-
@@ -144,4 +168,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
index a68d9280..8b0809de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
/dep/
-/build/output/
+/build/
+*.swp
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 00000000..2d16be7e
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=git.eclipse.org
+port=29418
+project=paho/org.eclipse.paho.mqtt.c
+defaultbranch=develop
diff --git a/.project b/.project
index 8c28da6b..afb95ae2 100644
--- a/.project
+++ b/.project
@@ -5,6 +5,11 @@
+
+ org.python.pydev.PyDevBuilder
+
+
+
org.eclipse.cdt.managedbuilder.core.genmakebuilder
clean,full,incremental,
@@ -23,5 +28,6 @@
org.eclipse.cdt.core.ccnature
org.eclipse.cdt.managedbuilder.core.managedBuildNature
org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ org.python.pydev.pythonNature
diff --git a/.pydevproject b/.pydevproject
new file mode 100644
index 00000000..40e9f40a
--- /dev/null
+++ b/.pydevproject
@@ -0,0 +1,5 @@
+
+
+Default
+python 2.7
+
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000..3708a87c
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,12 @@
+language: c
+
+compiler:
+ - gcc
+ - clang
+
+os:
+ - linux
+ - osx
+
+script:
+ - make
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000..0a7fc663
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,55 @@
+#*******************************************************************************
+# Copyright (c) 2015 logi.cals GmbH
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# and Eclipse Distribution License v1.0 which accompany this distribution.
+#
+# The Eclipse Public License is available at
+# http://www.eclipse.org/legal/epl-v10.html
+# and the Eclipse Distribution License is available at
+# http://www.eclipse.org/org/documents/edl-v10.php.
+#
+# Contributors:
+# Rainer Poisel - initial version
+#*******************************************************************************/
+
+# Note: on OS X you should install XCode and the associated command-line tools
+
+PROJECT("paho" C)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
+
+## build settings
+SET(PAHO_VERSION_MAJOR 1)
+SET(PAHO_VERSION_MINOR 0)
+SET(PAHO_VERSION_PATCH 3)
+SET(CLIENT_VERSION ${PAHO_VERSION_MAJOR}.${PAHO_VERSION_MINOR}.${PAHO_VERSION_PATCH})
+
+EXECUTE_PROCESS(COMMAND date -u OUTPUT_VARIABLE BUILD_TIMESTAMP)
+STRING(STRIP ${BUILD_TIMESTAMP} BUILD_TIMESTAMP)
+
+## build options
+SET(PAHO_WITH_SSL FALSE CACHE BOOL "Flag that defines whether to build ssl-enabled binaries too. ")
+SET(PAHO_BUILD_DOCUMENTATION FALSE CACHE BOOL "Create and install the HTML based API documentation (requires Doxygen)")
+SET(PAHO_BUILD_SAMPLES FALSE CACHE BOOL "Build sample programs")
+
+ADD_SUBDIRECTORY(src)
+IF(PAHO_BUILD_SAMPLES)
+ ADD_SUBDIRECTORY(src/samples)
+ENDIF()
+
+IF(PAHO_BUILD_DOCUMENTATION)
+ ADD_SUBDIRECTORY(doc)
+ENDIF()
+
+### packaging settings
+IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
+ SET(CPACK_GENERATOR "ZIP")
+ELSE()
+ SET(CPACK_GENERATOR "TGZ")
+ENDIF()
+
+SET(CPACK_PACKAGE_VERSION_MAJOR ${PAHO_VERSION_MAJOR})
+SET(CPACK_PACKAGE_VERSION_MINOR ${PAHO_VERSION_MINOR})
+SET(CPACK_PACKAGE_VERSION_PATCH ${PAHO_VERSION_PATCH})
+INCLUDE(CPack)
diff --git a/Makefile b/Makefile
index d2e72f4b..b4668ff4 100755
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
#*******************************************************************************
-# Copyright (c) 2009, 2015 IBM Corp.
+# Copyright (c) 2009, 2016 IBM Corp.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
@@ -24,7 +24,7 @@ SHELL = /bin/sh
.PHONY: clean, mkdir, install, uninstall, html
ifndef release.version
- release.version = 1.0.3
+ release.version = 1.1.0
endif
# determine current platform
@@ -50,6 +50,18 @@ ifndef blddir
blddir = build/output
endif
+ifndef blddir_work
+ blddir_work = build
+endif
+
+ifndef docdir
+ docdir = $(blddir)/doc
+endif
+
+ifndef docdir_work
+ docdir_work = $(blddir)/../doc
+endif
+
ifndef prefix
prefix = /usr/local
endif
@@ -72,19 +84,19 @@ HEADERS = $(srcdir)/*.h
HEADERS_C = $(filter-out $(srcdir)/MQTTAsync.h, $(HEADERS))
HEADERS_A = $(HEADERS)
-SAMPLE_FILES_C = stdinpub stdoutsub pubsync pubasync subasync
+SAMPLE_FILES_C = paho_cs_pub paho_cs_sub MQTTClient_publish MQTTClient_publish_async MQTTClient_subscribe
SYNC_SAMPLES = ${addprefix ${blddir}/samples/,${SAMPLE_FILES_C}}
-SAMPLE_FILES_A = stdoutsuba MQTTAsync_subscribe MQTTAsync_publish
+SAMPLE_FILES_A = paho_c_pub paho_c_sub MQTTAsync_subscribe MQTTAsync_publish
ASYNC_SAMPLES = ${addprefix ${blddir}/samples/,${SAMPLE_FILES_A}}
-TEST_FILES_C = test1 sync_client_test test_mqtt4sync
+TEST_FILES_C = test1 test2 sync_client_test test_mqtt4sync
SYNC_TESTS = ${addprefix ${blddir}/test/,${TEST_FILES_C}}
TEST_FILES_CS = test3
SYNC_SSL_TESTS = ${addprefix ${blddir}/test/,${TEST_FILES_CS}}
-TEST_FILES_A = test4 test_mqtt4async
+TEST_FILES_A = test4 test9 test_mqtt4async
ASYNC_TESTS = ${addprefix ${blddir}/test/,${TEST_FILES_A}}
TEST_FILES_AS = test5
@@ -115,7 +127,7 @@ MQTTLIB_A_TARGET = ${blddir}/lib${MQTTLIB_A}.so.${VERSION}
MQTTLIB_AS_TARGET = ${blddir}/lib${MQTTLIB_AS}.so.${VERSION}
MQTTVERSION_TARGET = ${blddir}/MQTTVersion
-CCFLAGS_SO = -g -fPIC $(CFLAGS) -Os -Wall -fvisibility=hidden
+CCFLAGS_SO = -g -fPIC $(CFLAGS) -Os -Wall -fvisibility=hidden -I$(blddir_work)
FLAGS_EXE = $(LDFLAGS) -I ${srcdir} -lpthread -L ${blddir}
FLAGS_EXES = $(LDFLAGS) -I ${srcdir} ${START_GROUP} -lpthread -lssl -lcrypto ${END_GROUP} -L ${blddir}
@@ -125,9 +137,11 @@ LDFLAGS_CS = $(LDFLAGS) -shared $(START_GROUP) -lpthread $(EXTRA_LIB) -lssl -lcr
LDFLAGS_A = $(LDFLAGS) -shared -Wl,-init,$(MQTTASYNC_INIT) -lpthread
LDFLAGS_AS = $(LDFLAGS) -shared $(START_GROUP) -lpthread $(EXTRA_LIB) -lssl -lcrypto $(END_GROUP) -Wl,-init,$(MQTTASYNC_INIT)
-ifeq ($(OSTYPE),Linux)
+SED_COMMAND = sed \
+ -e "s/@CLIENT_VERSION@/${release.version}/g" \
+ -e "s/@BUILD_TIMESTAMP@/${build.level}/g"
-SED_COMMAND = sed -i "s/\#\#MQTTCLIENT_VERSION_TAG\#\#/${release.version}/g; s/\#\#MQTTCLIENT_BUILD_TAG\#\#/${build.level}/g"
+ifeq ($(OSTYPE),Linux)
MQTTCLIENT_INIT = MQTTClient_init
MQTTASYNC_INIT = MQTTAsync_init
@@ -143,8 +157,6 @@ LDFLAGS_AS += -Wl,-soname,lib${MQTTLIB_AS}.so.${MAJOR_VERSION} -Wl,-no-whole-arc
else ifeq ($(OSTYPE),Darwin)
-SED_COMMAND = sed -i "" -e "s/\#\#MQTTCLIENT_VERSION_TAG\#\#/${release.version}/g" -e "s/\#\#MQTTCLIENT_BUILD_TAG\#\#/${build.level}/g"
-
MQTTCLIENT_INIT = _MQTTClient_init
MQTTASYNC_INIT = _MQTTAsync_init
START_GROUP =
@@ -173,7 +185,7 @@ mkdir:
echo OSTYPE is $(OSTYPE)
${SYNC_TESTS}: ${blddir}/test/%: ${srcdir}/../test/%.c $(MQTTLIB_C_TARGET)
- ${CC} -g -o $@ $< -l${MQTTLIB_C} ${FLAGS_EXE}
+ ${CC} -DNOSTACKTRACE $(srcdir)/Thread.c -g -o $@ $< -l${MQTTLIB_C} ${FLAGS_EXE}
${SYNC_SSL_TESTS}: ${blddir}/test/%: ${srcdir}/../test/%.c $(MQTTLIB_CS_TARGET)
${CC} -g -o $@ $< -l${MQTTLIB_CS} ${FLAGS_EXES}
@@ -190,26 +202,25 @@ ${SYNC_SAMPLES}: ${blddir}/samples/%: ${srcdir}/samples/%.c $(MQTTLIB_C_TARGET)
${ASYNC_SAMPLES}: ${blddir}/samples/%: ${srcdir}/samples/%.c $(MQTTLIB_A_TARGET)
${CC} -o $@ $< -l${MQTTLIB_A} ${FLAGS_EXE}
-${MQTTLIB_C_TARGET}: ${SOURCE_FILES_C} ${HEADERS_C}
- $(SED_COMMAND) $(srcdir)/MQTTClient.c
+$(blddir_work)/VersionInfo.h: $(srcdir)/VersionInfo.h.in
+ $(SED_COMMAND) $< > $@
+
+${MQTTLIB_C_TARGET}: ${SOURCE_FILES_C} ${HEADERS_C} $(blddir_work)/VersionInfo.h
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_C} ${LDFLAGS_C}
-ln -s lib$(MQTTLIB_C).so.${VERSION} ${blddir}/lib$(MQTTLIB_C).so.${MAJOR_VERSION}
-ln -s lib$(MQTTLIB_C).so.${MAJOR_VERSION} ${blddir}/lib$(MQTTLIB_C).so
-${MQTTLIB_CS_TARGET}: ${SOURCE_FILES_CS} ${HEADERS_C}
- $(SED_COMMAND) $(srcdir)/MQTTClient.c
+${MQTTLIB_CS_TARGET}: ${SOURCE_FILES_CS} ${HEADERS_C} $(blddir_work)/VersionInfo.h
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_CS} -DOPENSSL ${LDFLAGS_CS}
-ln -s lib$(MQTTLIB_CS).so.${VERSION} ${blddir}/lib$(MQTTLIB_CS).so.${MAJOR_VERSION}
-ln -s lib$(MQTTLIB_CS).so.${MAJOR_VERSION} ${blddir}/lib$(MQTTLIB_CS).so
-${MQTTLIB_A_TARGET}: ${SOURCE_FILES_A} ${HEADERS_A}
- $(SED_COMMAND) $(srcdir)/MQTTAsync.c
+${MQTTLIB_A_TARGET}: ${SOURCE_FILES_A} ${HEADERS_A} $(blddir_work)/VersionInfo.h
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_A} ${LDFLAGS_A}
-ln -s lib$(MQTTLIB_A).so.${VERSION} ${blddir}/lib$(MQTTLIB_A).so.${MAJOR_VERSION}
-ln -s lib$(MQTTLIB_A).so.${MAJOR_VERSION} ${blddir}/lib$(MQTTLIB_A).so
-${MQTTLIB_AS_TARGET}: ${SOURCE_FILES_AS} ${HEADERS_A}
- $(SED_COMMAND) $(srcdir)/MQTTAsync.c
+${MQTTLIB_AS_TARGET}: ${SOURCE_FILES_AS} ${HEADERS_A} $(blddir_work)/VersionInfo.h
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_AS} -DOPENSSL ${LDFLAGS_AS}
-ln -s lib$(MQTTLIB_AS).so.${VERSION} ${blddir}/lib$(MQTTLIB_AS).so.${MAJOR_VERSION}
-ln -s lib$(MQTTLIB_AS).so.${MAJOR_VERSION} ${blddir}/lib$(MQTTLIB_AS).so
@@ -252,8 +263,18 @@ uninstall:
rm $(DESTDIR)${includedir}/MQTTClient.h
rm $(DESTDIR)${includedir}/MQTTClientPersistence.h
+REGEX_DOXYGEN := \
+ 's;@PROJECT_SOURCE_DIR@/src/\?;;' \
+ 's;@PROJECT_SOURCE_DIR@;..;' \
+ 's;@CMAKE_CURRENT_BINARY_DIR@;../build/output;'
+SED_DOXYGEN := $(foreach sed_exp,$(REGEX_DOXYGEN),-e $(sed_exp))
+define process_doxygen
+ cd ${srcdir}; sed $(SED_DOXYGEN) ../doc/${1}.in > ../$(docdir_work)/${1}
+ cd ${srcdir}; $(DOXYGEN_COMMAND) ../$(docdir_work)/${1}
+endef
html:
- -mkdir -p ${blddir}/doc
- cd ${srcdir}; $(DOXYGEN_COMMAND) ../doc/DoxyfileV3ClientAPI
- cd ${srcdir}; $(DOXYGEN_COMMAND) ../doc/DoxyfileV3AsyncAPI
- cd ${srcdir}; $(DOXYGEN_COMMAND) ../doc/DoxyfileV3ClientInternal
+ -mkdir -p $(docdir_work)
+ -mkdir -p ${docdir}
+ $(call process_doxygen,DoxyfileV3ClientAPI)
+ $(call process_doxygen,DoxyfileV3AsyncAPI)
+ $(call process_doxygen,DoxyfileV3ClientInternal)
diff --git a/README.md b/README.md
index 4a28c681..729bf3be 100644
--- a/README.md
+++ b/README.md
@@ -7,34 +7,114 @@ This code builds libraries which enable applications to connect to an [MQTT](htt
Both synchronous and asynchronous modes of operation are supported.
-## Build requirements / compilation
+## Build requirements / compilation using CMake
-The build process requires GNU Make and gcc, and also requires OpenSSL libraries and includes to be available. There are make rules for a number of Linux "flavors" including ARM and s390, OS X, AIX and Solaris.
+There build process currently supports a number of Linux "flavors" including ARM and s390, OS X, AIX and Solaris as well as the Windows operating system. The build process requires the following tools:
+ * CMake (http://cmake.org)
+ * Ninja (https://martine.github.io/ninja/; preferred) or
+ GNU Make (https://www.gnu.org/software/make/), and
+ * gcc (https://gcc.gnu.org/).
-The documentation requires doxygen and optionally graphviz.
-
-Before compiling, set some environment variables (or pass these values to the make command directly) in order to configure library locations and other options.
-
-Specify the location of OpenSSL using `SSL_DIR`
-
-e.g. using [homebrew](http://mxcl.github.com/homebrew/) on OS X:
-
-`export SSL_DIR=/usr/local/Cellar/openssl/1.0.1e`
-
-Specify where the source files are in relation to where the make command is being executed.
-
-``export MQTTCLIENT_DIR=../src``
-
-To build the samples, enable the option (`BUILD_SAMPLES`), and specify the location of the code:
+On Debian based systems this would mean that the following packages have to be installed:
```
-export BUILD_SAMPLES=YES
-export SAMPLES_DIR=../src/samples
+apt-get install build-essential gcc make cmake cmake-gui cmake-curses-gui
+```
+Ninja can be downloaded from its github project page in the "releases" section. Optionally it is possible to build binaries with SSL support. This requires the OpenSSL libraries and includes to be available. E. g. on Debian:
+
+```
+apt-get install libssl-dev
```
-One more useful environment variable is ``TARGET_PLATFORM``. This provides for cross-compilation. Currently the only recognised value is "Arm" - for instance to cross-compile a Linux ARM version of the libraries:
+The documentation requires doxygen and optionally graphviz:
-``export TARGET_PLATFORM=Arm``
+```
+apt-get install doxygen graphviz
+```
+
+Before compiling, determine the value of some variables in order to configure features, library locations, and other options:
+
+Variable | Default Value | Description
+------------ | ------------- | -------------
+PAHO_WITH_SSL | FALSE | Flag that defines whether to build ssl-enabled binaries too.
+OPENSSL_INC_SEARCH_PATH | "" (system default) | Directory containing OpenSSL includes
+OPENSSL_LIB_SEARCH_PATH | "" (system default) | Directory containing OpenSSL libraries
+PAHO_BUILD_DOCUMENTATION | FALSE | Create and install the HTML based API documentation (requires Doxygen)
+PAHO_BUILD_SAMPLES | FALSE | Build sample programs
+
+Using these variables CMake can be used to generate your Ninja or Make files. Using CMake, building out-of-source is the default. Therefore it is recommended to invoke all build commands inside your chosen build directory but outside of the source tree.
+
+An example build session targeting the build platform could look like this:
+
+```
+mkdir /tmp/build.paho
+cd /tmp/build.paho
+cmake -GNinja -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_DOCUMENTATION=TRUE -DPAHO_BUILD_SAMPLES=TRUE ~/git/org.eclipse.paho.mqtt.c
+```
+
+Invoking cmake and specifying build options can also be performed using cmake-gui or ccmake (see https://cmake.org/runningcmake/). For example:
+
+```
+ccmake -GNinja ~/git/org.eclipse.paho.mqtt.c
+```
+
+To compile/link the binaries and to generate packages, simply invoke `ninja package` or `make -j package` after CMake. To simply compile/link invoke `ninja` or `make -j `.
+
+### Debug builds
+
+Debug builds can be performed by defining the value of the ```CMAKE_BUILD_TYPE``` option to ```Debug```. For example:
+
+```
+cmake -GNinja -DCMAKE_BUILD_TYPE=Debug git/org.eclipse.paho.mqtt.c
+```
+
+### Cross compilation
+
+Cross compilation using CMake is performed by using so called "toolchain files" (see: http://www.vtk.org/Wiki/CMake_Cross_Compiling).
+
+The path to the toolchain file can be specified by using CMake's `-DCMAKE_TOOLCHAIN_FILE` option. In case no toolchain file is specified, the build is performed for the native build platform.
+
+For your convenience toolchain files for the following platforms can be found in the `cmake` directory of Eclipse Paho:
+ * Linux x86
+ * Linux ARM11 (a.k.a. the Raspberry Pi)
+ * Windows x86_64
+ * Windows x86
+
+The provided toolchain files assume that required compilers/linkers are to be found in the environment, i. e. the PATH-Variable of your user or system. If you prefer, you can also specify the absolute location of your compilers in the toolchain files.
+
+Example invocation for the Raspberry Pi:
+
+```
+cmake -GNinja -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_SAMPLES=TRUE -DPAHO_BUILD_DOCUMENTATION=TRUE -DOPENSSL_LIB_SEARCH_PATH=/tmp/libssl-dev/usr/lib/arm-linux-gnueabihf -DOPENSSL_INC_SEARCH_PATH="/tmp/libssl-dev/usr/include/openssl;/tmp/libssl-dev/usr/include/arm-linux-gnueabihf" -DCMAKE_TOOLCHAIN_FILE=~/git/org.eclipse.paho.mqtt.c/cmake/toolchain.linux-arm11.cmake ~/git/org.eclipse.paho.mqtt.c
+```
+
+Compilers for the Raspberry Pi can be obtained from e. g. Linaro (see: http://releases.linaro.org/15.06/components/toolchain/binaries/4.8/arm-linux-gnueabihf/). This example assumes that OpenSSL-libraries and includes have been installed in the ```/tmp/libssl-dev``` directory.
+
+Example invocation for Windows 64 bit:
+
+```
+cmake -GNinja -DPAHO_BUILD_SAMPLES=TRUE -DCMAKE_TOOLCHAIN_FILE=~/git/org.eclipse.paho.mqtt.c/cmake/toolchain.win64.cmake ~/git/org.eclipse.paho.mqtt.c
+
+```
+
+In this case the libraries and executable are not linked against OpenSSL Libraries. Cross compilers for the Windows platform can be installed on Debian like systems like this:
+
+```
+apt-get install gcc-mingw-w64-x86-64 gcc-mingw-w64-i686
+```
+
+
+## Build instructions for GNU Make (deprecated)
+
+The provided GNU Makefile is intended to perform all build steps in the ```build``` directory within the source-tree of Eclipse Paho. Generated binares, libraries, and the documentation can be found in the ```build/output``` directory after completion.
+
+Options that are passed to the compiler/linker can be specified by typical Unix build variables:
+
+Variable | Description
+------------ | -------------
+CC | Path to the C compiler
+CFLAGS | Flags passed to compiler calls
+LDFLAGS | Flags passed to linker calls
## Libraries
diff --git a/Windows Build/MQTTVersion/MQTTVersion.vcxproj b/Windows Build/MQTTVersion/MQTTVersion.vcxproj
index d567a441..e9ccf8e9 100644
--- a/Windows Build/MQTTVersion/MQTTVersion.vcxproj
+++ b/Windows Build/MQTTVersion/MQTTVersion.vcxproj
@@ -5,10 +5,18 @@
Debug
Win32
+
+ Debug
+ x64
+
Release
Win32
+
+ Release
+ x64
+
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}
@@ -23,6 +31,12 @@
v120
Unicode
+
+ Application
+ true
+ v120
+ Unicode
+
Application
false
@@ -30,23 +44,42 @@
true
Unicode
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
true
+
+ true
+
false
$(SolutionDir)..\build\output\
+
+ false
+
@@ -62,6 +95,21 @@
true
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ 4996
+
+
+ Console
+ true
+
+
Level3
@@ -81,6 +129,25 @@
true
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ 4996
+
+
+ Console
+ true
+ true
+ true
+
+
diff --git a/Windows Build/Paho C MQTT APIs.sln b/Windows Build/Paho C MQTT APIs.sln
index b56fd755..63eb1b2c 100644
--- a/Windows Build/Paho C MQTT APIs.sln
+++ b/Windows Build/Paho C MQTT APIs.sln
@@ -34,56 +34,118 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test4", "test4\test4.vcxpro
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test5", "test5\test5.vcxproj", "{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test9", "test9\test9.vcxproj", "{D133C05E-87A6-48C6-A703-188A83B82400}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test2", "test2\test2.vcxproj", "{A4E14611-05DC-40A1-815B-DA30CA167C9B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{172F8995-C780-44A1-996C-C7949B4DB35A}.Debug|Win32.ActiveCfg = Debug|Win32
{172F8995-C780-44A1-996C-C7949B4DB35A}.Debug|Win32.Build.0 = Debug|Win32
+ {172F8995-C780-44A1-996C-C7949B4DB35A}.Debug|x64.ActiveCfg = Debug|x64
+ {172F8995-C780-44A1-996C-C7949B4DB35A}.Debug|x64.Build.0 = Debug|x64
{172F8995-C780-44A1-996C-C7949B4DB35A}.Release|Win32.ActiveCfg = Release|Win32
{172F8995-C780-44A1-996C-C7949B4DB35A}.Release|Win32.Build.0 = Release|Win32
+ {172F8995-C780-44A1-996C-C7949B4DB35A}.Release|x64.ActiveCfg = Release|x64
+ {172F8995-C780-44A1-996C-C7949B4DB35A}.Release|x64.Build.0 = Release|x64
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Debug|Win32.ActiveCfg = Debug|Win32
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Debug|Win32.Build.0 = Debug|Win32
+ {B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Debug|x64.ActiveCfg = Debug|x64
+ {B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Debug|x64.Build.0 = Debug|x64
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Release|Win32.ActiveCfg = Release|Win32
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Release|Win32.Build.0 = Release|Win32
+ {B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Release|x64.ActiveCfg = Release|x64
+ {B479B6EF-787D-4716-912A-E0F6F7BDA7A9}.Release|x64.Build.0 = Release|x64
{DFDF6238-DA97-4474-84C2-D313E8B985AE}.Debug|Win32.ActiveCfg = Debug|Win32
{DFDF6238-DA97-4474-84C2-D313E8B985AE}.Debug|Win32.Build.0 = Debug|Win32
+ {DFDF6238-DA97-4474-84C2-D313E8B985AE}.Debug|x64.ActiveCfg = Debug|x64
+ {DFDF6238-DA97-4474-84C2-D313E8B985AE}.Debug|x64.Build.0 = Debug|x64
{DFDF6238-DA97-4474-84C2-D313E8B985AE}.Release|Win32.ActiveCfg = Release|Win32
{DFDF6238-DA97-4474-84C2-D313E8B985AE}.Release|Win32.Build.0 = Release|Win32
+ {DFDF6238-DA97-4474-84C2-D313E8B985AE}.Release|x64.ActiveCfg = Release|x64
+ {DFDF6238-DA97-4474-84C2-D313E8B985AE}.Release|x64.Build.0 = Release|x64
{AF322561-C692-43D3-8502-CC1E6CD2869A}.Debug|Win32.ActiveCfg = Debug|Win32
{AF322561-C692-43D3-8502-CC1E6CD2869A}.Debug|Win32.Build.0 = Debug|Win32
+ {AF322561-C692-43D3-8502-CC1E6CD2869A}.Debug|x64.ActiveCfg = Debug|x64
+ {AF322561-C692-43D3-8502-CC1E6CD2869A}.Debug|x64.Build.0 = Debug|x64
{AF322561-C692-43D3-8502-CC1E6CD2869A}.Release|Win32.ActiveCfg = Release|Win32
{AF322561-C692-43D3-8502-CC1E6CD2869A}.Release|Win32.Build.0 = Release|Win32
+ {AF322561-C692-43D3-8502-CC1E6CD2869A}.Release|x64.ActiveCfg = Release|x64
+ {AF322561-C692-43D3-8502-CC1E6CD2869A}.Release|x64.Build.0 = Release|x64
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Debug|Win32.ActiveCfg = Debug|Win32
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Debug|Win32.Build.0 = Debug|Win32
+ {6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Debug|x64.ActiveCfg = Debug|x64
+ {6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Debug|x64.Build.0 = Debug|x64
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Release|Win32.ActiveCfg = Release|Win32
{6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Release|Win32.Build.0 = Release|Win32
+ {6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Release|x64.ActiveCfg = Release|x64
+ {6EFC1F3B-CEE1-4DD2-80B4-CEC37954D468}.Release|x64.Build.0 = Release|x64
{DEF21D1B-CB65-4A78-805F-CF421249EB83}.Debug|Win32.ActiveCfg = Debug|Win32
{DEF21D1B-CB65-4A78-805F-CF421249EB83}.Debug|Win32.Build.0 = Debug|Win32
+ {DEF21D1B-CB65-4A78-805F-CF421249EB83}.Debug|x64.ActiveCfg = Debug|x64
+ {DEF21D1B-CB65-4A78-805F-CF421249EB83}.Debug|x64.Build.0 = Debug|x64
{DEF21D1B-CB65-4A78-805F-CF421249EB83}.Release|Win32.ActiveCfg = Release|Win32
{DEF21D1B-CB65-4A78-805F-CF421249EB83}.Release|Win32.Build.0 = Release|Win32
+ {DEF21D1B-CB65-4A78-805F-CF421249EB83}.Release|x64.ActiveCfg = Release|x64
+ {DEF21D1B-CB65-4A78-805F-CF421249EB83}.Release|x64.Build.0 = Release|x64
{17F07F98-AA5F-4373-9877-992A341D650A}.Debug|Win32.ActiveCfg = Debug|Win32
{17F07F98-AA5F-4373-9877-992A341D650A}.Debug|Win32.Build.0 = Debug|Win32
+ {17F07F98-AA5F-4373-9877-992A341D650A}.Debug|x64.ActiveCfg = Debug|x64
+ {17F07F98-AA5F-4373-9877-992A341D650A}.Debug|x64.Build.0 = Debug|x64
{17F07F98-AA5F-4373-9877-992A341D650A}.Release|Win32.ActiveCfg = Release|Win32
{17F07F98-AA5F-4373-9877-992A341D650A}.Release|Win32.Build.0 = Release|Win32
+ {17F07F98-AA5F-4373-9877-992A341D650A}.Release|x64.ActiveCfg = Release|x64
+ {17F07F98-AA5F-4373-9877-992A341D650A}.Release|x64.Build.0 = Release|x64
{4E643090-289D-487D-BCA8-685EA2210480}.Debug|Win32.ActiveCfg = Debug|Win32
{4E643090-289D-487D-BCA8-685EA2210480}.Debug|Win32.Build.0 = Debug|Win32
+ {4E643090-289D-487D-BCA8-685EA2210480}.Debug|x64.ActiveCfg = Debug|x64
+ {4E643090-289D-487D-BCA8-685EA2210480}.Debug|x64.Build.0 = Debug|x64
{4E643090-289D-487D-BCA8-685EA2210480}.Release|Win32.ActiveCfg = Release|Win32
{4E643090-289D-487D-BCA8-685EA2210480}.Release|Win32.Build.0 = Release|Win32
+ {4E643090-289D-487D-BCA8-685EA2210480}.Release|x64.ActiveCfg = Release|x64
+ {4E643090-289D-487D-BCA8-685EA2210480}.Release|x64.Build.0 = Release|x64
{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Debug|Win32.ActiveCfg = Debug|Win32
{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Debug|Win32.Build.0 = Debug|Win32
+ {0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Debug|x64.ActiveCfg = Debug|x64
+ {0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Debug|x64.Build.0 = Debug|x64
{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Release|Win32.ActiveCfg = Release|Win32
{0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Release|Win32.Build.0 = Release|Win32
+ {0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Release|x64.ActiveCfg = Release|x64
+ {0CBDD939-F0C9-4887-8C7E-9E645C34FF94}.Release|x64.Build.0 = Release|x64
{29D6A4E9-5A39-4CD3-8A24-348A34832405}.Debug|Win32.ActiveCfg = Debug|Win32
{29D6A4E9-5A39-4CD3-8A24-348A34832405}.Debug|Win32.Build.0 = Debug|Win32
+ {29D6A4E9-5A39-4CD3-8A24-348A34832405}.Debug|x64.ActiveCfg = Debug|x64
+ {29D6A4E9-5A39-4CD3-8A24-348A34832405}.Debug|x64.Build.0 = Debug|x64
{29D6A4E9-5A39-4CD3-8A24-348A34832405}.Release|Win32.ActiveCfg = Release|Win32
{29D6A4E9-5A39-4CD3-8A24-348A34832405}.Release|Win32.Build.0 = Release|Win32
+ {29D6A4E9-5A39-4CD3-8A24-348A34832405}.Release|x64.ActiveCfg = Release|x64
+ {29D6A4E9-5A39-4CD3-8A24-348A34832405}.Release|x64.Build.0 = Release|x64
{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Debug|Win32.ActiveCfg = Debug|Win32
{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Debug|Win32.Build.0 = Debug|Win32
+ {B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Debug|x64.ActiveCfg = Debug|x64
+ {B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Debug|x64.Build.0 = Debug|x64
{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Release|Win32.ActiveCfg = Release|Win32
{B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Release|Win32.Build.0 = Release|Win32
+ {B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Release|x64.ActiveCfg = Release|x64
+ {B8A895EA-C8DE-4235-B4B4-06889BBBDC93}.Release|x64.Build.0 = Release|x64
+ {D133C05E-87A6-48C6-A703-188A83B82400}.Debug|Win32.ActiveCfg = Debug|Win32
+ {D133C05E-87A6-48C6-A703-188A83B82400}.Debug|Win32.Build.0 = Debug|Win32
+ {D133C05E-87A6-48C6-A703-188A83B82400}.Debug|x64.ActiveCfg = Debug|Win32
+ {D133C05E-87A6-48C6-A703-188A83B82400}.Release|Win32.ActiveCfg = Release|Win32
+ {D133C05E-87A6-48C6-A703-188A83B82400}.Release|Win32.Build.0 = Release|Win32
+ {D133C05E-87A6-48C6-A703-188A83B82400}.Release|x64.ActiveCfg = Release|Win32
+ {A4E14611-05DC-40A1-815B-DA30CA167C9B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {A4E14611-05DC-40A1-815B-DA30CA167C9B}.Debug|Win32.Build.0 = Debug|Win32
+ {A4E14611-05DC-40A1-815B-DA30CA167C9B}.Debug|x64.ActiveCfg = Debug|Win32
+ {A4E14611-05DC-40A1-815B-DA30CA167C9B}.Release|Win32.ActiveCfg = Release|Win32
+ {A4E14611-05DC-40A1-815B-DA30CA167C9B}.Release|Win32.Build.0 = Release|Win32
+ {A4E14611-05DC-40A1-815B-DA30CA167C9B}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Windows Build/paho-mqtt3a/paho-mqtt3a.vcxproj b/Windows Build/paho-mqtt3a/paho-mqtt3a.vcxproj
index 105982a6..86b9b49b 100644
--- a/Windows Build/paho-mqtt3a/paho-mqtt3a.vcxproj
+++ b/Windows Build/paho-mqtt3a/paho-mqtt3a.vcxproj
@@ -5,10 +5,18 @@
Debug
Win32
+
+ Debug
+ x64
+
Release
Win32
+
+ Release
+ x64
+
{B479B6EF-787D-4716-912A-E0F6F7BDA7A9}
@@ -22,6 +30,12 @@
Unicode
v120
+
+ DynamicLibrary
+ true
+ Unicode
+ v120
+
DynamicLibrary
false
@@ -29,23 +43,42 @@
Unicode
v120
+
+ DynamicLibrary
+ false
+ true
+ Unicode
+ v120
+
+
+
+
+
+
+
true
+
+ true
+
false
$(SolutionDir)..\build\output\
+
+ false
+
@@ -61,6 +94,21 @@
ws2_32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_WINDOWS;_USRDLL;PAHOMQTT3A_EXPORTS;%(PreprocessorDefinitions)
+ 4996
+
+
+ Windows
+ true
+ ws2_32.lib;%(AdditionalDependencies)
+
+
Level3
@@ -80,6 +128,25 @@
ws2_32.lib;%(AdditionalDependencies)
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_WINDOWS;_USRDLL;PAHOMQTT3A_EXPORTS;%(PreprocessorDefinitions)
+ 4996
+
+
+ Windows
+ true
+ true
+ true
+ ws2_32.lib;%(AdditionalDependencies)
+
+
diff --git a/Windows Build/paho-mqtt3as/paho-mqtt3as.vcxproj b/Windows Build/paho-mqtt3as/paho-mqtt3as.vcxproj
index f23b42cf..bd00e971 100644
--- a/Windows Build/paho-mqtt3as/paho-mqtt3as.vcxproj
+++ b/Windows Build/paho-mqtt3as/paho-mqtt3as.vcxproj
@@ -5,10 +5,18 @@
Debug
Win32
+
+ Debug
+ x64
+
Release
Win32
+
+ Release
+ x64
+
{DEF21D1B-CB65-4A78-805F-CF421249EB83}
@@ -22,6 +30,12 @@
v120
Unicode
+
+ DynamicLibrary
+ true
+ v120
+ Unicode
+
DynamicLibrary
false
@@ -29,23 +43,42 @@
true
Unicode
+
+ DynamicLibrary
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
true
+
+ true
+
false
$(SolutionDir)..\build\output\
+
+ false
+
NotUsing
@@ -62,6 +95,22 @@
$(OpenSSLDir)\lib;%(AdditionalLibraryDirectories)
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;_DEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)
+ 4996
+ $(OpenSSLDir)\include;%(AdditionalIncludeDirectories)
+
+
+ Windows
+ true
+ ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)
+ $(OpenSSLDir)\out32dll;%(AdditionalLibraryDirectories)
+
+
Level3
@@ -82,6 +131,26 @@
$(OpenSSLDir)\lib;%(AdditionalLibraryDirectories)
+
+
+ Level3
+ NotUsing
+ MaxSpeed
+ true
+ true
+ WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;NDEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)
+ 4996
+ $(OpenSSLDir)\include;%(AdditionalIncludeDirectories)
+
+
+ Windows
+ false
+ true
+ true
+ ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)
+ $(OpenSSLDir)\out32dll;%(AdditionalLibraryDirectories)
+
+
@@ -131,4 +200,4 @@
-
+
\ No newline at end of file
diff --git a/Windows Build/paho-mqtt3c/paho-mqtt3c.vcxproj b/Windows Build/paho-mqtt3c/paho-mqtt3c.vcxproj
index 2c52e344..f1bfb381 100644
--- a/Windows Build/paho-mqtt3c/paho-mqtt3c.vcxproj
+++ b/Windows Build/paho-mqtt3c/paho-mqtt3c.vcxproj
@@ -5,10 +5,18 @@
Debug
Win32
+
+ Debug
+ x64
+
Release
Win32
+
+ Release
+ x64
+
{172F8995-C780-44A1-996C-C7949B4DB35A}
@@ -22,6 +30,12 @@
Unicode
v120
+
+ DynamicLibrary
+ true
+ Unicode
+ v120
+
DynamicLibrary
false
@@ -29,23 +43,42 @@
Unicode
v120
+
+ DynamicLibrary
+ false
+ true
+ Unicode
+ v120
+
+
+
+
+
+
+
true
+
+ true
+
false
$(SolutionDir)..\build\output\
+
+ false
+
NotUsing
@@ -60,6 +93,20 @@
ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32;_DEBUG;_WINDOWS;_USRDLL;PAHOMQTT3C_EXPORTS;%(PreprocessorDefinitions)
+ 4996
+
+
+ Windows
+ true
+ ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
Level3
@@ -78,6 +125,24 @@
ws2_32.lib;%(AdditionalDependencies)
+
+
+ Level3
+ NotUsing
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_WINDOWS;_USRDLL;PAHOMQTT3C_EXPORTS;%(PreprocessorDefinitions)
+ 4996
+
+
+ Windows
+ true
+ true
+ true
+ ws2_32.lib;%(AdditionalDependencies)
+
+
diff --git a/Windows Build/paho-mqtt3cs/paho-mqtt3cs.vcxproj b/Windows Build/paho-mqtt3cs/paho-mqtt3cs.vcxproj
old mode 100644
new mode 100755
index d41c0f62..d570c23e
--- a/Windows Build/paho-mqtt3cs/paho-mqtt3cs.vcxproj
+++ b/Windows Build/paho-mqtt3cs/paho-mqtt3cs.vcxproj
@@ -1,134 +1,203 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {17F07F98-AA5F-4373-9877-992A341D650A}
- Win32Proj
- pahomqtt3as
-
-
-
- DynamicLibrary
- true
- v120
- Unicode
-
-
- DynamicLibrary
- false
- v120
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
- $(SolutionDir)..\build\output\
-
-
-
- NotUsing
- Level3
- Disabled
- WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;_DEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)
- 4996
- $(OpenSSLDir)\include;%(AdditionalIncludeDirectories)
-
-
- Windows
- true
- ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)
- $(OpenSSLDir)\lib;%(AdditionalLibraryDirectories)
-
-
-
-
- Level3
- NotUsing
- MaxSpeed
- true
- true
- WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;NDEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)
- 4996
- $(OpenSSLDir)\include;%(AdditionalIncludeDirectories)
-
-
- Windows
- false
- true
- true
- ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)
- $(OpenSSLDir)\lib;%(AdditionalLibraryDirectories)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {17F07F98-AA5F-4373-9877-992A341D650A}
+ Win32Proj
+ pahomqtt3as
+
+
+
+ DynamicLibrary
+ true
+ v120
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v120
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v120
+ true
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+ $(SolutionDir)..\build\output\
+
+
+ false
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;_DEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)
+ 4996
+ $(OpenSSLDir)\include;%(AdditionalIncludeDirectories)
+
+
+ Windows
+ true
+ ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)
+ $(OpenSSLDir)\lib;%(AdditionalLibraryDirectories)
+
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;_DEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)
+ 4996
+ $(OpenSSLDir)\include;%(AdditionalIncludeDirectories)
+
+
+ Windows
+ true
+ ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)
+ $(OpenSSLDir)\out32dll;%(AdditionalLibraryDirectories)
+
+
+
+
+ Level3
+ NotUsing
+ MaxSpeed
+ true
+ true
+ WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;NDEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)
+ 4996
+ $(OpenSSLDir)\include;%(AdditionalIncludeDirectories)
+
+
+ Windows
+ false
+ true
+ true
+ ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)
+ $(OpenSSLDir)\lib;%(AdditionalLibraryDirectories)
+
+
+
+
+ Level3
+ NotUsing
+ MaxSpeed
+ true
+ true
+ WIN32_LEAN_AND_MEAN;OPENSSL;WIN32;NDEBUG;_WINDOWS;_USRDLL;PAHOMQTT3AS_EXPORTS;%(PreprocessorDefinitions)
+ 4996
+ $(OpenSSLDir)\include;%(AdditionalIncludeDirectories)
+
+
+ Windows
+ false
+ true
+ true
+ ws2_32.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)
+ $(OpenSSLDir)\out32dll;%(AdditionalLibraryDirectories)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Windows Build/stdoutsub/stdoutsub.vcxproj b/Windows Build/stdoutsub/stdoutsub.vcxproj
index 66dabf58..9f679a09 100644
--- a/Windows Build/stdoutsub/stdoutsub.vcxproj
+++ b/Windows Build/stdoutsub/stdoutsub.vcxproj
@@ -5,15 +5,24 @@
Debug
Win32
+
+ Debug
+ x64
+
Release
Win32
+
+ Release
+ x64
+
{DFDF6238-DA97-4474-84C2-D313E8B985AE}
Win32Proj
- stdoutsub
+ paho-cs-sub
+ paho-cs-sub
@@ -22,6 +31,12 @@
Unicode
v120
+
+ Application
+ true
+ Unicode
+ v120
+
Application
false
@@ -29,23 +44,42 @@
Unicode
v120
+
+ Application
+ false
+ true
+ Unicode
+ v120
+
+
+
+
+
+
+
true
+
+ true
+
false
$(SolutionDir)..\build\output\samples\
+
+ false
+
@@ -63,6 +97,23 @@
paho-mqtt3c.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ $(SolutionDir)\x64\$(Configuration)\
+ paho-mqtt3c.lib;%(AdditionalDependencies)
+
+
Level3
@@ -84,13 +135,39 @@
$(SolutionDir)..\build\output\
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ true
+ true
+ paho-mqtt3c.lib;%(AdditionalDependencies)
+ $(SolutionDir)\x64\$(Configuration)\
+
+
-
+
+
+
+ {17f07f98-aa5f-4373-9877-992a341d650a}
+
+
diff --git a/Windows Build/stdoutsub/stdoutsub.vcxproj.filters b/Windows Build/stdoutsub/stdoutsub.vcxproj.filters
index 5bc7eaa8..1cfc2b20 100644
--- a/Windows Build/stdoutsub/stdoutsub.vcxproj.filters
+++ b/Windows Build/stdoutsub/stdoutsub.vcxproj.filters
@@ -15,7 +15,7 @@
-
+
Source Files
diff --git a/Windows Build/stdoutsuba/stdoutsuba.vcxproj b/Windows Build/stdoutsuba/stdoutsuba.vcxproj
index 673b87bd..dd5b3461 100644
--- a/Windows Build/stdoutsuba/stdoutsuba.vcxproj
+++ b/Windows Build/stdoutsuba/stdoutsuba.vcxproj
@@ -5,15 +5,24 @@
Debug
Win32
+
+ Debug
+ x64
+
Release
Win32
+
+ Release
+ x64
+
{AF322561-C692-43D3-8502-CC1E6CD2869A}
Win32Proj
- stdoutsuba
+ paho-cs-pub
+ paho-cs-pub
@@ -22,6 +31,12 @@
Unicode
v120
+
+ Application
+ true
+ Unicode
+ v120
+
Application
false
@@ -29,23 +44,42 @@
Unicode
v120
+
+ Application
+ false
+ true
+ Unicode
+ v120
+
+
+
+
+
+
+
true
+
+ true
+
false
$(SolutionDir)..\build\output\samples\
+
+ false
+
@@ -59,10 +93,27 @@
Console
true
- paho-mqtt3a.lib;%(AdditionalDependencies)
+ paho-mqtt3c.lib;%(AdditionalDependencies)
$(SolutionDir)\Debug
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ paho-mqtt3a.lib;%(AdditionalDependencies)
+ $(SolutionDir)\x64\$(Configuration)
+
+
Level3
@@ -80,12 +131,33 @@
true
true
true
- paho-mqtt3a.lib;%(AdditionalDependencies)
+ paho-mqtt3c.lib;%(AdditionalDependencies)
$(SolutionDir)..\build\output\
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ true
+ true
+ paho-mqtt3a.lib;%(AdditionalDependencies)
+ $(SolutionDir)\x64\$(Configuration)
+
+
-
+
diff --git a/Windows Build/stdoutsuba/stdoutsuba.vcxproj.filters b/Windows Build/stdoutsuba/stdoutsuba.vcxproj.filters
index 817e9d87..69fd52a5 100644
--- a/Windows Build/stdoutsuba/stdoutsuba.vcxproj.filters
+++ b/Windows Build/stdoutsuba/stdoutsuba.vcxproj.filters
@@ -15,7 +15,7 @@
-
+
Source Files
diff --git a/Windows Build/test1/test1.vcxproj b/Windows Build/test1/test1.vcxproj
old mode 100644
new mode 100755
index f5199108..cf260770
--- a/Windows Build/test1/test1.vcxproj
+++ b/Windows Build/test1/test1.vcxproj
@@ -1,95 +1,172 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {4E643090-289D-487D-BCA8-685EA2210480}
- Win32Proj
- test1
-
-
-
- Application
- true
- v120
- Unicode
-
-
- Application
- false
- v120
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
- $(SolutionDir)..\build\output\test\
-
-
-
-
-
- Level3
- Disabled
- WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Level3
-
-
- MaxSpeed
- true
- true
- _WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- true
- $(SolutionDir)\..\src
- 4996
-
-
- Console
- true
- true
- true
- $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
- ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {4E643090-289D-487D-BCA8-685EA2210480}
+ Win32Proj
+ test1
+
+
+
+ Application
+ true
+ v120
+ Unicode
+
+
+ Application
+ true
+ v120
+ Unicode
+
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+ $(SolutionDir)..\build\output\test\
+
+
+ false
+
+
+
+
+
+ Level3
+ Disabled
+ _WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ $(SolutionDir)\Debug\;%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ Level3
+ Disabled
+ _WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ $(SolutionDir)\x64\$(Configuration)
+ ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ _WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ true
+ true
+ $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ _WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ true
+ true
+ $(SolutionDir)\x64\$(Configuration);%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Windows Build/test2/test2.vcxproj b/Windows Build/test2/test2.vcxproj
new file mode 100644
index 00000000..33a0a14f
--- /dev/null
+++ b/Windows Build/test2/test2.vcxproj
@@ -0,0 +1,105 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {A4E14611-05DC-40A1-815B-DA30CA167C9B}
+ Win32Proj
+ test2
+
+
+
+ Application
+ true
+ v120
+ Unicode
+
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(SolutionDir)..\build\output\test\
+
+
+ false
+ $(SolutionDir)..\build\output\test\
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ NotUsing
+ MaxSpeed
+ true
+ true
+ WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ true
+ true
+ $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3c.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Windows Build/test2/test2.vcxproj.filters b/Windows Build/test2/test2.vcxproj.filters
new file mode 100644
index 00000000..79e09c43
--- /dev/null
+++ b/Windows Build/test2/test2.vcxproj.filters
@@ -0,0 +1,45 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+
\ No newline at end of file
diff --git a/Windows Build/test3/test3.vcxproj b/Windows Build/test3/test3.vcxproj
old mode 100644
new mode 100755
index 75b69d52..da82d3ef
--- a/Windows Build/test3/test3.vcxproj
+++ b/Windows Build/test3/test3.vcxproj
@@ -1,95 +1,177 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {0CBDD939-F0C9-4887-8C7E-9E645C34FF94}
- Win32Proj
- test1
-
-
-
- Application
- true
- v120
- Unicode
-
-
- Application
- false
- v120
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
- $(SolutionDir)..\build\output\test\
-
-
-
-
-
- Level3
- Disabled
- WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Level3
-
-
- MaxSpeed
- true
- true
- _WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- true
- $(SolutionDir)\..\src
- 4996
-
-
- Console
- true
- true
- true
- $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
- ws2_32.lib;paho-mqtt3cs.lib;%(AdditionalDependencies)
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {0CBDD939-F0C9-4887-8C7E-9E645C34FF94}
+ Win32Proj
+ test1
+
+
+
+ Application
+ true
+ v120
+ Unicode
+
+
+ Application
+ true
+ v120
+ Unicode
+
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+ $(SolutionDir)..\build\output\test\
+
+
+ false
+
+
+
+
+
+ Level3
+ Disabled
+ _WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3cs.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ Level3
+ Disabled
+ _WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ $(SolutionDir)\x64\$(Configuration)
+ ws2_32.lib;paho-mqtt3cs.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ _WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ true
+ true
+ $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3cs.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ _WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ true
+ true
+ $(SolutionDir)\x64\$(Configuration)
+ ws2_32.lib;paho-mqtt3cs.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
+
+
+ {17f07f98-aa5f-4373-9877-992a341d650a}
+
+
+
+
+
\ No newline at end of file
diff --git a/Windows Build/test4/test4.vcxproj b/Windows Build/test4/test4.vcxproj
old mode 100644
new mode 100755
index 67b7d3c5..323a7519
--- a/Windows Build/test4/test4.vcxproj
+++ b/Windows Build/test4/test4.vcxproj
@@ -1,95 +1,172 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {29D6A4E9-5A39-4CD3-8A24-348A34832405}
- Win32Proj
- test1
-
-
-
- Application
- true
- v120
- Unicode
-
-
- Application
- false
- v120
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
- $(SolutionDir)..\build\output\test\
-
-
-
-
-
- Level3
- Disabled
- WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Level3
-
-
- MaxSpeed
- true
- true
- _WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- true
- $(SolutionDir)\..\src
- 4996
-
-
- Console
- true
- true
- true
- $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
- ws2_32.lib;paho-mqtt3a.lib;%(AdditionalDependencies)
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {29D6A4E9-5A39-4CD3-8A24-348A34832405}
+ Win32Proj
+ test1
+
+
+
+ Application
+ true
+ v120
+ Unicode
+
+
+ Application
+ true
+ v120
+ Unicode
+
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+ $(SolutionDir)..\build\output\test\
+
+
+ false
+
+
+
+
+
+ Level3
+ Disabled
+ _WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3a.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ Level3
+ Disabled
+ _WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ $(SolutionDir)\x64\$(Configuration)
+ ws2_32.lib;paho-mqtt3a.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ _WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ true
+ true
+ $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3a.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ _WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ true
+ true
+ $(SolutionDir)\x64\$(Configuration)
+ ws2_32.lib;paho-mqtt3a.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Windows Build/test5/test5.vcxproj b/Windows Build/test5/test5.vcxproj
old mode 100644
new mode 100755
index 588fa354..1a506eab
--- a/Windows Build/test5/test5.vcxproj
+++ b/Windows Build/test5/test5.vcxproj
@@ -1,95 +1,172 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {B8A895EA-C8DE-4235-B4B4-06889BBBDC93}
- Win32Proj
- test1
-
-
-
- Application
- true
- v120
- Unicode
-
-
- Application
- false
- v120
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
- $(SolutionDir)..\build\output\test\
-
-
-
-
-
- Level3
- Disabled
- WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Level3
-
-
- MaxSpeed
- true
- true
- WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- true
- $(SolutionDir)\..\src
- 4996
-
-
- Console
- true
- true
- true
- $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
- ws2_32.lib;paho-mqtt3as.lib;%(AdditionalDependencies)
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {B8A895EA-C8DE-4235-B4B4-06889BBBDC93}
+ Win32Proj
+ test1
+
+
+
+ Application
+ true
+ v120
+ Unicode
+
+
+ Application
+ true
+ v120
+ Unicode
+
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+ $(SolutionDir)..\build\output\test\
+
+
+ false
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3as.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ $(SolutionDir)\x64\$(Configuration)
+ ws2_32.lib;paho-mqtt3as.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ true
+ true
+ $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3as.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ true
+ true
+ $(SolutionDir)\x64\$(Configuration)
+ ws2_32.lib;paho-mqtt3as.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Windows Build/test9/test9.vcxproj b/Windows Build/test9/test9.vcxproj
new file mode 100644
index 00000000..796709d0
--- /dev/null
+++ b/Windows Build/test9/test9.vcxproj
@@ -0,0 +1,98 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {D133C05E-87A6-48C6-A703-188A83B82400}
+ Win32Proj
+ test9
+
+
+
+ Application
+ true
+ v120
+ Unicode
+
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(SolutionDir)..\build\output\test\
+
+
+ false
+ $(SolutionDir)..\build\output\test\
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3a.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32_LEAN_AND_MEAN;_WINDOWS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ $(SolutionDir)\..\src
+ 4996
+
+
+ Console
+ true
+ true
+ true
+ $(SolutionDir)..\build\output\;%(AdditionalLibraryDirectories)
+ ws2_32.lib;paho-mqtt3a.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Windows Build/test9/test9.vcxproj.filters b/Windows Build/test9/test9.vcxproj.filters
new file mode 100644
index 00000000..dc608bff
--- /dev/null
+++ b/Windows Build/test9/test9.vcxproj.filters
@@ -0,0 +1,30 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+
\ No newline at end of file
diff --git a/build.xml b/build.xml
index 19a9dd11..ca0a550f 100644
--- a/build.xml
+++ b/build.xml
@@ -1,4 +1,4 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cmake/toolchain.linux-arm11.cmake b/cmake/toolchain.linux-arm11.cmake
new file mode 100644
index 00000000..4965ff7c
--- /dev/null
+++ b/cmake/toolchain.linux-arm11.cmake
@@ -0,0 +1,10 @@
+# path to compiler and utilities
+# specify the cross compiler
+SET(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
+
+# Name of the target platform
+SET(CMAKE_SYSTEM_NAME Linux)
+SET(CMAKE_SYSTEM_PROCESSOR arm)
+
+# Version of the system
+SET(CMAKE_SYSTEM_VERSION 1)
diff --git a/cmake/toolchain.win32.cmake b/cmake/toolchain.win32.cmake
new file mode 100644
index 00000000..05e72540
--- /dev/null
+++ b/cmake/toolchain.win32.cmake
@@ -0,0 +1,15 @@
+# Name of the target platform
+SET(CMAKE_SYSTEM_NAME Windows)
+
+# Version of the system
+SET(CMAKE_SYSTEM_VERSION 1)
+
+# specify the cross compiler
+SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
+SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
+SET(CMAKE_RC_COMPILER_ENV_VAR "RC")
+SET(CMAKE_RC_COMPILER "")
+SET(CMAKE_SHARED_LINKER_FLAGS
+ "-fdata-sections -ffunction-sections -Wl,--enable-stdcall-fixup -static-libgcc -static -lpthread" CACHE STRING "" FORCE)
+SET(CMAKE_EXE_LINKER_FLAGS
+ "-fdata-sections -ffunction-sections -Wl,--enable-stdcall-fixup -static-libgcc -static -lpthread" CACHE STRING "" FORCE)
diff --git a/cmake/toolchain.win64.cmake b/cmake/toolchain.win64.cmake
new file mode 100644
index 00000000..98afef18
--- /dev/null
+++ b/cmake/toolchain.win64.cmake
@@ -0,0 +1,15 @@
+# Name of the target platform
+SET(CMAKE_SYSTEM_NAME Windows)
+
+# Version of the system
+SET(CMAKE_SYSTEM_VERSION 1)
+
+# specify the cross compiler
+SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
+SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
+SET(CMAKE_RC_COMPILER_ENV_VAR "RC")
+SET(CMAKE_RC_COMPILER "")
+SET(CMAKE_SHARED_LINKER_FLAGS
+ "-fdata-sections -ffunction-sections -Wl,--enable-stdcall-fixup -static-libgcc -static -lpthread" CACHE STRING "" FORCE)
+SET(CMAKE_EXE_LINKER_FLAGS
+ "-fdata-sections -ffunction-sections -Wl,--enable-stdcall-fixup -static-libgcc -static -lpthread" CACHE STRING "" FORCE)
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
new file mode 100644
index 00000000..06e4c5d8
--- /dev/null
+++ b/doc/CMakeLists.txt
@@ -0,0 +1,40 @@
+#*******************************************************************************
+# Copyright (c) 2015 logi.cals GmbH
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# and Eclipse Distribution License v1.0 which accompany this distribution.
+#
+# The Eclipse Public License is available at
+# http://www.eclipse.org/legal/epl-v10.html
+# and the Eclipse Distribution License is available at
+# http://www.eclipse.org/org/documents/edl-v10.php.
+#
+# Contributors:
+# Rainer Poisel - initial version
+#*******************************************************************************/
+
+# Note: on OS X you should install XCode and the associated command-line tools
+
+### documentation settings
+FIND_PACKAGE(Doxygen)
+IF(NOT DOXYGEN_FOUND)
+ message(FATAL_ERROR "Doxygen is needed to build the documentation.")
+ENDIF()
+SET(DOXYTARGETS)
+FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc)
+FOREACH(DOXYFILE_SRC DoxyfileV3ClientAPI;DoxyfileV3AsyncAPI;DoxyfileV3ClientInternal)
+ SET(DOXYFILE_IN ${DOXYFILE_SRC}.in)
+ SET(DOXYFILE ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE_SRC})
+
+ CONFIGURE_FILE(${DOXYFILE_IN} ${DOXYFILE} @ONLY)
+ ADD_CUSTOM_TARGET(${DOXYFILE_SRC}.target
+ COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMENT "Generating API documentation with Doxygen"
+ VERBATIM
+ )
+ SET(DOXYTARGETS ${DOXYTARGETS} ${DOXYFILE_SRC}.target)
+ENDFOREACH(DOXYFILE_SRC)
+ADD_CUSTOM_TARGET(doc ALL DEPENDS ${DOXYTARGETS})
+INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc DESTINATION share)
diff --git a/doc/DoxyfileV3AsyncAPI.in b/doc/DoxyfileV3AsyncAPI.in
new file mode 100644
index 00000000..e2ed5aee
--- /dev/null
+++ b/doc/DoxyfileV3AsyncAPI.in
@@ -0,0 +1,1804 @@
+# Doxyfile 1.8.1.2
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a hash (#) is considered a comment and will be ignored.
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ").
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or sequence of words) that should
+# identify the project. Note that if you do not use Doxywizard you need
+# to put quotes around the project name if it contains spaces.
+
+PROJECT_NAME = "Paho Asynchronous MQTT C Client Library"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER =
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF =
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is
+# included in the documentation. The maximum height of the logo should not
+# exceed 55 pixels and the maximum width should not exceed 200 pixels.
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO = "@PROJECT_SOURCE_DIR@/doc/pahologo.png"
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = "@CMAKE_CURRENT_BINARY_DIR@/doc/MQTTAsync/"
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH = /Users/dimitri/doxygen/mail/1.5.7/doxywizard/
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful if your file system
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding
+# "class=itcl::class" will allow you to use the command class in the
+# itcl::class meaning.
+
+TCL_SUBST =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this
+# tag. The format is ext=language, where ext is a file extension, and language
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all
+# comments according to the Markdown format, which allows for more readable
+# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you
+# can mix doxygen, HTML, and XML commands with Markdown formatting.
+# Disable only in case of backward compatibilities issues.
+
+MARKDOWN_SUPPORT = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also makes the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
+# unions are shown inside the group in which they are included (e.g. using
+# @ingroup) instead of on a separate page (for HTML and Man pages) or
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
+# unions with only public data fields will be shown inline in the documentation
+# of the scope in which they are defined (i.e. file, namespace, or group
+# documentation), provided this scope is documented. If set to NO (the default),
+# structs, classes, and unions are shown on a separate page (for HTML and Man
+# pages) or section (for LaTeX and RTF).
+
+INLINE_SIMPLE_STRUCTS = NO
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penalty.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will roughly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+SYMBOL_CACHE_SIZE = 0
+
+# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
+# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
+# their name and scope. Since this can be an expensive process and often the
+# same symbol appear multiple times in the code, doxygen keeps a cache of
+# pre-resolved symbols. If the cache is too small doxygen will become slower.
+# If the cache is too large, memory is wasted. The cache size is given by this
+# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+LOOKUP_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation.
+
+EXTRACT_PACKAGE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespaces are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = YES
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = NO
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
+# do proper type resolution of all parameters of a function it will reject a
+# match between the prototype and the implementation of a member function even
+# if there is only one candidate or it is obvious which candidate to choose
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS = MQTTAsync_main
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or macro consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and macros in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command , where is the value of
+# the FILE_VERSION_FILTER tag, and is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option.
+# You can optionally specify a file name after the option, if omitted
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE =
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files
+# containing the references data. This must be a list of .bib files. The
+# .bib extension is automatically appended if omitted. Using this command
+# requires the bibtex tool to be installed. See also
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
+# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this
+# feature you need bibtex and perl available in the search path.
+
+CITE_BIB_FILES =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@/src
+INPUT = @PROJECT_SOURCE_DIR@/src/MQTTAsync.h \
+ @PROJECT_SOURCE_DIR@/src/MQTTClientPersistence.h
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
+# *.f90 *.f *.for *.vhd *.vhdl
+
+FILE_PATTERNS =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command , where
+# is the value of the INPUT_FILTER tag, and is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty or if
+# non of the patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
+# and it is also possible to disable source filtering for a specific pattern
+# using *.ext= (so without naming a filter). This option only has effect when
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS =
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C, C++ and Fortran comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header. Note that when using a custom header you are responsible
+# for the proper inclusion of any scripts and style sheets that doxygen
+# needs, which is dependent on the configuration options used.
+# It is advised to generate a default header using "doxygen -w html
+# header.html footer.html stylesheet.css YourConfigFile" and then modify
+# that header. Note that the header is subject to change so you typically
+# have to redo this when upgrading to a newer version of doxygen or when
+# changing the value of configuration settings such as GENERATE_TREEVIEW!
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# style sheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
+# Doxygen will adjust the colors in the style sheet and background images
+# according to this color. Hue is specified as an angle on a colorwheel,
+# see http://en.wikipedia.org/wiki/Hue for more information.
+# For instance the value 0 represents red, 60 is yellow, 120 is green,
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
+# the colors in the HTML output. For a value of 0 the output will use
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
+# the luminance component of the colors in the HTML output. Values below
+# 100 gradually make the output lighter, whereas values above 100 make
+# the output darker. The value divided by 100 is the actual gamma applied,
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded.
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of
+# entries shown in the various tree structured indices initially; the user
+# can expand and collapse entries dynamically later on. Doxygen will expand
+# the tree to such a level that at most the specified number of entries are
+# visible (unless a fully collapsed tree already exceeds this amount).
+# So setting the number of entries 1 will produce a full collapsed tree by
+# default. 0 is a special value representing an infinite number of entries
+# and will result in a full expanded tree by default.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
+# that can be used as input for Qt's qhelpgenerator to generate a
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE =
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
+# add. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see
+#
+# Qt Help Project / Custom Filters.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's
+# filter section matches.
+#
+# Qt Help Project / Filter Attributes.
+
+QHP_SECT_FILTER_ATTRS =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+# will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
+# the help appears.
+
+GENERATE_ECLIPSEHELP = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)
+# at top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it. Since the tabs have the same information as the
+# navigation tree you can set this option to NO if you already set
+# GENERATE_TREEVIEW to YES.
+
+DISABLE_INDEX = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+# Since the tree basically has the same information as the tab index you
+# could consider to set DISABLE_INDEX to NO when enabling this option.
+
+GENERATE_TREEVIEW = NONE
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML
+# documentation. Note that a value of 0 will completely suppress the enum
+# values from appearing in the overview section.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW = NO
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are
+# not supported properly for IE 6.0, but are supported on all modern browsers.
+# Note that when changing this option you need to delete any form_*.png files
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
+# (see http://www.mathjax.org) which uses client side Javascript for the
+# rendering instead of using prerendered bitmaps. Use this if you do not
+# have LaTeX installed or if you want to formulas look prettier in the HTML
+# output. When enabled you may also need to install MathJax separately and
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX = NO
+
+# When MathJax is enabled you need to specify the location relative to the
+# HTML output directory using the MATHJAX_RELPATH option. The destination
+# directory should contain the MathJax.js script. For instance, if the mathjax
+# directory is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to
+# the MathJax Content Delivery Network so you can quickly see the result without
+# installing MathJax.
+# However, it is strongly recommended to install a local
+# copy of MathJax from http://www.mathjax.org before deployment.
+
+MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension
+# names that should be enabled during MathJax rendering.
+
+MATHJAX_EXTENSIONS =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
+# (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a PHP enabled web server instead of at the web client
+# using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server
+# based approach is that it scales better to large projects and allows
+# full text search. The disadvantages are that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
+# the generated latex document. The footer should contain everything after
+# the last chapter. If it is left blank doxygen will generate a
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
+# http://en.wikipedia.org/wiki/BibTeX for more info.
+
+LATEX_BIB_STYLE = plain
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load style sheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = YES
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED = __attribute__(x)=
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition that
+# overrules the definition found in the source code.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all references to function-like macros
+# that are alone on a line, have an all uppercase name, and do not end with a
+# semicolon, because these will confuse the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. For each
+# tag file the location of the external documentation should be added. The
+# format of a tag file without this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths
+# or URLs. Note that each tag file must have a unique name (where the name does
+# NOT include the path). If a tag file is not located in the directory in which
+# doxygen is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option also works with HAVE_DOT disabled, but it is recommended to
+# install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS = NO
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
+# allowed to run in parallel. When set to 0 (the default) doxygen will
+# base this on the number of processors available in the system. You can set it
+# explicitly to a value larger than 0 to get control over the balance
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS = 0
+
+# By default doxygen will use the Helvetica font for all dot files that
+# doxygen generates. When you want a differently looking font you can specify
+# the font name using DOT_FONTNAME. You need to make sure dot is able to find
+# the font, which can be done by putting it in a standard location or by setting
+# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
+# directory containing the font.
+
+DOT_FONTNAME = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the Helvetica font.
+# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to
+# set the path where dot can find it.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside
+# the class node. If there are many fields or methods and many nodes the
+# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
+# threshold limits the number of items for each type to make the size more
+# managable. Set this to 0 for no limit. Note that the threshold may be
+# exceeded by 50% before the limit is enforced.
+
+UML_LIMIT_NUM_FIELDS = 10
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = YES
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = YES
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will generate a graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are svg, png, jpg, or gif.
+# If left blank png will be used. If you choose svg you need to set
+# HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible in IE 9+ (other browsers do not have this requirement).
+
+DOT_IMAGE_FORMAT = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+# Note that this requires a modern browser other than Internet Explorer.
+# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you
+# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible. Older versions of IE do not have SVG support.
+
+INTERACTIVE_SVG = NO
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the
+# \mscfile command).
+
+MSCFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
diff --git a/doc/DoxyfileV3ClientAPI.in b/doc/DoxyfileV3ClientAPI.in
new file mode 100644
index 00000000..482542fd
--- /dev/null
+++ b/doc/DoxyfileV3ClientAPI.in
@@ -0,0 +1,1804 @@
+# Doxyfile 1.8.1.2
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a hash (#) is considered a comment and will be ignored.
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ").
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or sequence of words) that should
+# identify the project. Note that if you do not use Doxywizard you need
+# to put quotes around the project name if it contains spaces.
+
+PROJECT_NAME = "Paho MQTT C Client Library"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER =
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF =
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is
+# included in the documentation. The maximum height of the logo should not
+# exceed 55 pixels and the maximum width should not exceed 200 pixels.
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO = "@PROJECT_SOURCE_DIR@/doc/pahologo.png"
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = "@CMAKE_CURRENT_BINARY_DIR@/doc/MQTTClient/"
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH = /Users/dimitri/doxygen/mail/1.5.7/doxywizard/
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful if your file system
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding
+# "class=itcl::class" will allow you to use the command class in the
+# itcl::class meaning.
+
+TCL_SUBST =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this
+# tag. The format is ext=language, where ext is a file extension, and language
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all
+# comments according to the Markdown format, which allows for more readable
+# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you
+# can mix doxygen, HTML, and XML commands with Markdown formatting.
+# Disable only in case of backward compatibilities issues.
+
+MARKDOWN_SUPPORT = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also makes the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
+# unions are shown inside the group in which they are included (e.g. using
+# @ingroup) instead of on a separate page (for HTML and Man pages) or
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
+# unions with only public data fields will be shown inline in the documentation
+# of the scope in which they are defined (i.e. file, namespace, or group
+# documentation), provided this scope is documented. If set to NO (the default),
+# structs, classes, and unions are shown on a separate page (for HTML and Man
+# pages) or section (for LaTeX and RTF).
+
+INLINE_SIMPLE_STRUCTS = NO
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penalty.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will roughly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+SYMBOL_CACHE_SIZE = 0
+
+# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
+# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
+# their name and scope. Since this can be an expensive process and often the
+# same symbol appear multiple times in the code, doxygen keeps a cache of
+# pre-resolved symbols. If the cache is too small doxygen will become slower.
+# If the cache is too large, memory is wasted. The cache size is given by this
+# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+LOOKUP_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation.
+
+EXTRACT_PACKAGE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespaces are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = YES
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = NO
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
+# do proper type resolution of all parameters of a function it will reject a
+# match between the prototype and the implementation of a member function even
+# if there is only one candidate or it is obvious which candidate to choose
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS = MQTTClient_main
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or macro consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and macros in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command , where is the value of
+# the FILE_VERSION_FILTER tag, and is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option.
+# You can optionally specify a file name after the option, if omitted
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE =
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files
+# containing the references data. This must be a list of .bib files. The
+# .bib extension is automatically appended if omitted. Using this command
+# requires the bibtex tool to be installed. See also
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
+# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this
+# feature you need bibtex and perl available in the search path.
+
+CITE_BIB_FILES =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@/src
+INPUT = @PROJECT_SOURCE_DIR@/src/MQTTClient.h \
+ @PROJECT_SOURCE_DIR@/src/MQTTClientPersistence.h
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
+# *.f90 *.f *.for *.vhd *.vhdl
+
+FILE_PATTERNS =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command , where
+# is the value of the INPUT_FILTER tag, and is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty or if
+# non of the patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
+# and it is also possible to disable source filtering for a specific pattern
+# using *.ext= (so without naming a filter). This option only has effect when
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS =
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C, C++ and Fortran comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header. Note that when using a custom header you are responsible
+# for the proper inclusion of any scripts and style sheets that doxygen
+# needs, which is dependent on the configuration options used.
+# It is advised to generate a default header using "doxygen -w html
+# header.html footer.html stylesheet.css YourConfigFile" and then modify
+# that header. Note that the header is subject to change so you typically
+# have to redo this when upgrading to a newer version of doxygen or when
+# changing the value of configuration settings such as GENERATE_TREEVIEW!
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# style sheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
+# Doxygen will adjust the colors in the style sheet and background images
+# according to this color. Hue is specified as an angle on a colorwheel,
+# see http://en.wikipedia.org/wiki/Hue for more information.
+# For instance the value 0 represents red, 60 is yellow, 120 is green,
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
+# the colors in the HTML output. For a value of 0 the output will use
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
+# the luminance component of the colors in the HTML output. Values below
+# 100 gradually make the output lighter, whereas values above 100 make
+# the output darker. The value divided by 100 is the actual gamma applied,
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded.
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of
+# entries shown in the various tree structured indices initially; the user
+# can expand and collapse entries dynamically later on. Doxygen will expand
+# the tree to such a level that at most the specified number of entries are
+# visible (unless a fully collapsed tree already exceeds this amount).
+# So setting the number of entries 1 will produce a full collapsed tree by
+# default. 0 is a special value representing an infinite number of entries
+# and will result in a full expanded tree by default.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
+# that can be used as input for Qt's qhelpgenerator to generate a
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE =
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
+# add. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see
+#
+# Qt Help Project / Custom Filters.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's
+# filter section matches.
+#
+# Qt Help Project / Filter Attributes.
+
+QHP_SECT_FILTER_ATTRS =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+# will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
+# the help appears.
+
+GENERATE_ECLIPSEHELP = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)
+# at top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it. Since the tabs have the same information as the
+# navigation tree you can set this option to NO if you already set
+# GENERATE_TREEVIEW to YES.
+
+DISABLE_INDEX = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+# Since the tree basically has the same information as the tab index you
+# could consider to set DISABLE_INDEX to NO when enabling this option.
+
+GENERATE_TREEVIEW = NONE
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML
+# documentation. Note that a value of 0 will completely suppress the enum
+# values from appearing in the overview section.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW = NO
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are
+# not supported properly for IE 6.0, but are supported on all modern browsers.
+# Note that when changing this option you need to delete any form_*.png files
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
+# (see http://www.mathjax.org) which uses client side Javascript for the
+# rendering instead of using prerendered bitmaps. Use this if you do not
+# have LaTeX installed or if you want to formulas look prettier in the HTML
+# output. When enabled you may also need to install MathJax separately and
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX = NO
+
+# When MathJax is enabled you need to specify the location relative to the
+# HTML output directory using the MATHJAX_RELPATH option. The destination
+# directory should contain the MathJax.js script. For instance, if the mathjax
+# directory is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to
+# the MathJax Content Delivery Network so you can quickly see the result without
+# installing MathJax.
+# However, it is strongly recommended to install a local
+# copy of MathJax from http://www.mathjax.org before deployment.
+
+MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension
+# names that should be enabled during MathJax rendering.
+
+MATHJAX_EXTENSIONS =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
+# (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a PHP enabled web server instead of at the web client
+# using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server
+# based approach is that it scales better to large projects and allows
+# full text search. The disadvantages are that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
+# the generated latex document. The footer should contain everything after
+# the last chapter. If it is left blank doxygen will generate a
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
+# http://en.wikipedia.org/wiki/BibTeX for more info.
+
+LATEX_BIB_STYLE = plain
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load style sheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = YES
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED = __attribute__(x)=
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition that
+# overrules the definition found in the source code.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all references to function-like macros
+# that are alone on a line, have an all uppercase name, and do not end with a
+# semicolon, because these will confuse the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. For each
+# tag file the location of the external documentation should be added. The
+# format of a tag file without this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths
+# or URLs. Note that each tag file must have a unique name (where the name does
+# NOT include the path). If a tag file is not located in the directory in which
+# doxygen is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option also works with HAVE_DOT disabled, but it is recommended to
+# install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS = NO
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
+# allowed to run in parallel. When set to 0 (the default) doxygen will
+# base this on the number of processors available in the system. You can set it
+# explicitly to a value larger than 0 to get control over the balance
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS = 0
+
+# By default doxygen will use the Helvetica font for all dot files that
+# doxygen generates. When you want a differently looking font you can specify
+# the font name using DOT_FONTNAME. You need to make sure dot is able to find
+# the font, which can be done by putting it in a standard location or by setting
+# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
+# directory containing the font.
+
+DOT_FONTNAME = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the Helvetica font.
+# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to
+# set the path where dot can find it.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside
+# the class node. If there are many fields or methods and many nodes the
+# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
+# threshold limits the number of items for each type to make the size more
+# managable. Set this to 0 for no limit. Note that the threshold may be
+# exceeded by 50% before the limit is enforced.
+
+UML_LIMIT_NUM_FIELDS = 10
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = YES
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = YES
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will generate a graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are svg, png, jpg, or gif.
+# If left blank png will be used. If you choose svg you need to set
+# HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible in IE 9+ (other browsers do not have this requirement).
+
+DOT_IMAGE_FORMAT = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+# Note that this requires a modern browser other than Internet Explorer.
+# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you
+# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible. Older versions of IE do not have SVG support.
+
+INTERACTIVE_SVG = NO
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the
+# \mscfile command).
+
+MSCFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
diff --git a/doc/DoxyfileV3ClientInternal b/doc/DoxyfileV3ClientInternal
index 22a0fc5f..58236394 100644
--- a/doc/DoxyfileV3ClientInternal
+++ b/doc/DoxyfileV3ClientInternal
@@ -667,6 +667,7 @@ WARN_LOGFILE =
INPUT = "."
+
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
# also the default input encoding. Doxygen uses libiconv (or the iconv built
diff --git a/doc/DoxyfileV3ClientInternal.in b/doc/DoxyfileV3ClientInternal.in
new file mode 100644
index 00000000..802651a5
--- /dev/null
+++ b/doc/DoxyfileV3ClientInternal.in
@@ -0,0 +1,1852 @@
+# Doxyfile 1.8.1.2
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a hash (#) is considered a comment and will be ignored.
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ").
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or sequence of words) that should
+# identify the project. Note that if you do not use Doxywizard you need
+# to put quotes around the project name if it contains spaces.
+
+PROJECT_NAME = "MQTT C Client Libraries Internals"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER =
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF =
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is
+# included in the documentation. The maximum height of the logo should not
+# exceed 55 pixels and the maximum width should not exceed 200 pixels.
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO = "@PROJECT_SOURCE_DIR@/doc/pahologo.png"
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = "@CMAKE_CURRENT_BINARY_DIR@/doc/MQTTClient_internal/"
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful if your file system
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = YES
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding
+# "class=itcl::class" will allow you to use the command class in the
+# itcl::class meaning.
+
+TCL_SUBST =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this
+# tag. The format is ext=language, where ext is a file extension, and language
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all
+# comments according to the Markdown format, which allows for more readable
+# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you
+# can mix doxygen, HTML, and XML commands with Markdown formatting.
+# Disable only in case of backward compatibilities issues.
+
+MARKDOWN_SUPPORT = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also makes the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
+# unions are shown inside the group in which they are included (e.g. using
+# @ingroup) instead of on a separate page (for HTML and Man pages) or
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
+# unions with only public data fields will be shown inline in the documentation
+# of the scope in which they are defined (i.e. file, namespace, or group
+# documentation), provided this scope is documented. If set to NO (the default),
+# structs, classes, and unions are shown on a separate page (for HTML and Man
+# pages) or section (for LaTeX and RTF).
+
+INLINE_SIMPLE_STRUCTS = NO
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penalty.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will roughly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+SYMBOL_CACHE_SIZE = 0
+
+# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
+# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
+# their name and scope. Since this can be an expensive process and often the
+# same symbol appear multiple times in the code, doxygen keeps a cache of
+# pre-resolved symbols. If the cache is too small doxygen will become slower.
+# If the cache is too large, memory is wasted. The cache size is given by this
+# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+LOOKUP_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = YES
+
+# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation.
+
+EXTRACT_PACKAGE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespaces are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
+# do proper type resolution of all parameters of a function it will reject a
+# match between the prototype and the implementation of a member function even
+# if there is only one candidate or it is obvious which candidate to choose
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS = MQTTClient_internal
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or macro consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and macros in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command , where is the value of
+# the FILE_VERSION_FILTER tag, and is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option.
+# You can optionally specify a file name after the option, if omitted
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE =
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files
+# containing the references data. This must be a list of .bib files. The
+# .bib extension is automatically appended if omitted. Using this command
+# requires the bibtex tool to be installed. See also
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
+# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this
+# feature you need bibtex and perl available in the search path.
+
+CITE_BIB_FILES =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@/src
+INPUT = @PROJECT_SOURCE_DIR@/src
+
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
+# *.f90 *.f *.for *.vhd *.vhdl
+
+FILE_PATTERNS = *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.d \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.idl \
+ *.odl \
+ *.cs \
+ *.php \
+ *.php3 \
+ *.inc \
+ *.m \
+ *.mm \
+ *.dox \
+ *.py \
+ *.f90 \
+ *.f \
+ *.vhd \
+ *.vhdl \
+ *.C \
+ *.CC \
+ *.C++ \
+ *.II \
+ *.I++ \
+ *.H \
+ *.HH \
+ *.H++ \
+ *.CS \
+ *.PHP \
+ *.PHP3 \
+ *.M \
+ *.MM \
+ *.PY \
+ *.F90 \
+ *.F \
+ *.VHD \
+ *.VHDL \
+ *.c
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command , where
+# is the value of the INPUT_FILTER tag, and is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty or if
+# non of the patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
+# and it is also possible to disable source filtering for a specific pattern
+# using *.ext= (so without naming a filter). This option only has effect when
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS =
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C, C++ and Fortran comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header. Note that when using a custom header you are responsible
+# for the proper inclusion of any scripts and style sheets that doxygen
+# needs, which is dependent on the configuration options used.
+# It is advised to generate a default header using "doxygen -w html
+# header.html footer.html stylesheet.css YourConfigFile" and then modify
+# that header. Note that the header is subject to change so you typically
+# have to redo this when upgrading to a newer version of doxygen or when
+# changing the value of configuration settings such as GENERATE_TREEVIEW!
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# style sheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
+# Doxygen will adjust the colors in the style sheet and background images
+# according to this color. Hue is specified as an angle on a colorwheel,
+# see http://en.wikipedia.org/wiki/Hue for more information.
+# For instance the value 0 represents red, 60 is yellow, 120 is green,
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
+# the colors in the HTML output. For a value of 0 the output will use
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
+# the luminance component of the colors in the HTML output. Values below
+# 100 gradually make the output lighter, whereas values above 100 make
+# the output darker. The value divided by 100 is the actual gamma applied,
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded.
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of
+# entries shown in the various tree structured indices initially; the user
+# can expand and collapse entries dynamically later on. Doxygen will expand
+# the tree to such a level that at most the specified number of entries are
+# visible (unless a fully collapsed tree already exceeds this amount).
+# So setting the number of entries 1 will produce a full collapsed tree by
+# default. 0 is a special value representing an infinite number of entries
+# and will result in a full expanded tree by default.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
+# that can be used as input for Qt's qhelpgenerator to generate a
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
+# add. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see
+#
+# Qt Help Project / Custom Filters.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's
+# filter section matches.
+#
+# Qt Help Project / Filter Attributes.
+
+QHP_SECT_FILTER_ATTRS =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+# will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
+# the help appears.
+
+GENERATE_ECLIPSEHELP = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)
+# at top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it. Since the tabs have the same information as the
+# navigation tree you can set this option to NO if you already set
+# GENERATE_TREEVIEW to YES.
+
+DISABLE_INDEX = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+# Since the tree basically has the same information as the tab index you
+# could consider to set DISABLE_INDEX to NO when enabling this option.
+
+GENERATE_TREEVIEW = NONE
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML
+# documentation. Note that a value of 0 will completely suppress the enum
+# values from appearing in the overview section.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW = NO
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are
+# not supported properly for IE 6.0, but are supported on all modern browsers.
+# Note that when changing this option you need to delete any form_*.png files
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
+# (see http://www.mathjax.org) which uses client side Javascript for the
+# rendering instead of using prerendered bitmaps. Use this if you do not
+# have LaTeX installed or if you want to formulas look prettier in the HTML
+# output. When enabled you may also need to install MathJax separately and
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX = NO
+
+# When MathJax is enabled you need to specify the location relative to the
+# HTML output directory using the MATHJAX_RELPATH option. The destination
+# directory should contain the MathJax.js script. For instance, if the mathjax
+# directory is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to
+# the MathJax Content Delivery Network so you can quickly see the result without
+# installing MathJax.
+# However, it is strongly recommended to install a local
+# copy of MathJax from http://www.mathjax.org before deployment.
+
+MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension
+# names that should be enabled during MathJax rendering.
+
+MATHJAX_EXTENSIONS =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
+# (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a PHP enabled web server instead of at the web client
+# using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server
+# based approach is that it scales better to large projects and allows
+# full text search. The disadvantages are that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
+# the generated latex document. The footer should contain everything after
+# the last chapter. If it is left blank doxygen will generate a
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
+# http://en.wikipedia.org/wiki/BibTeX for more info.
+
+LATEX_BIB_STYLE = plain
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load style sheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition that
+# overrules the definition found in the source code.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all references to function-like macros
+# that are alone on a line, have an all uppercase name, and do not end with a
+# semicolon, because these will confuse the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. For each
+# tag file the location of the external documentation should be added. The
+# format of a tag file without this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths
+# or URLs. Note that each tag file must have a unique name (where the name does
+# NOT include the path). If a tag file is not located in the directory in which
+# doxygen is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option also works with HAVE_DOT disabled, but it is recommended to
+# install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS = NO
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = YES
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
+# allowed to run in parallel. When set to 0 (the default) doxygen will
+# base this on the number of processors available in the system. You can set it
+# explicitly to a value larger than 0 to get control over the balance
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS = 0
+
+# By default doxygen will use the Helvetica font for all dot files that
+# doxygen generates. When you want a differently looking font you can specify
+# the font name using DOT_FONTNAME. You need to make sure dot is able to find
+# the font, which can be done by putting it in a standard location or by setting
+# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
+# directory containing the font.
+
+DOT_FONTNAME = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the Helvetica font.
+# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to
+# set the path where dot can find it.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = NO
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside
+# the class node. If there are many fields or methods and many nodes the
+# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
+# threshold limits the number of items for each type to make the size more
+# managable. Set this to 0 for no limit. Note that the threshold may be
+# exceeded by 50% before the limit is enforced.
+
+UML_LIMIT_NUM_FIELDS = 10
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = YES
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will generate a graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are svg, png, jpg, or gif.
+# If left blank png will be used. If you choose svg you need to set
+# HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible in IE 9+ (other browsers do not have this requirement).
+
+DOT_IMAGE_FORMAT = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+# Note that this requires a modern browser other than Internet Explorer.
+# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you
+# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible. Older versions of IE do not have SVG support.
+
+INTERACTIVE_SVG = NO
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the
+# \mscfile command).
+
+MSCFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 1000
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = YES
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 00000000..1faaa922
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,97 @@
+#*******************************************************************************
+# Copyright (c) 2015 logi.cals GmbH
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# and Eclipse Distribution License v1.0 which accompany this distribution.
+#
+# The Eclipse Public License is available at
+# http://www.eclipse.org/legal/epl-v10.html
+# and the Eclipse Distribution License is available at
+# http://www.eclipse.org/org/documents/edl-v10.php.
+#
+# Contributors:
+# Rainer Poisel - initial version
+#*******************************************************************************/
+
+# Note: on OS X you should install XCode and the associated command-line tools
+
+## compilation/linkage settings
+INCLUDE_DIRECTORIES(
+ .
+ ${CMAKE_BINARY_DIR}
+ )
+
+CONFIGURE_FILE(VersionInfo.h.in
+ ${CMAKE_BINARY_DIR}/VersionInfo.h
+ @ONLY
+ )
+
+SET(common_src
+ MQTTProtocolClient.c
+ Clients.c
+ utf-8.c
+ StackTrace.c
+ MQTTPacket.c
+ MQTTPacketOut.c
+ Messages.c
+ Tree.c
+ Socket.c
+ Log.c
+ MQTTPersistence.c
+ Thread.c
+ MQTTProtocolOut.c
+ MQTTPersistenceDefault.c
+ SocketBuffer.c
+ Heap.c
+ LinkedList.c
+ )
+
+IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
+ SET(LIBS_SYSTEM ws2_32)
+ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
+ SET(LIBS_SYSTEM dl)
+ENDIF()
+
+ADD_EXECUTABLE(MQTTVersion MQTTVersion.c)
+ADD_LIBRARY(paho-mqtt3c SHARED ${common_src} MQTTClient.c)
+ADD_LIBRARY(paho-mqtt3a SHARED ${common_src} MQTTAsync.c)
+TARGET_LINK_LIBRARIES(paho-mqtt3c pthread ${LIBS_SYSTEM})
+TARGET_LINK_LIBRARIES(paho-mqtt3a pthread ${LIBS_SYSTEM})
+TARGET_LINK_LIBRARIES(MQTTVersion paho-mqtt3a paho-mqtt3c ${LIBS_SYSTEM})
+SET_TARGET_PROPERTIES(
+ paho-mqtt3c paho-mqtt3a PROPERTIES
+ VERSION ${CLIENT_VERSION}
+ SOVERSION ${PAHO_VERSION_MAJOR})
+INSTALL(TARGETS paho-mqtt3c paho-mqtt3a MQTTVersion
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib)
+INSTALL(FILES MQTTAsync.h MQTTClient.h MQTTClientPersistence.h
+ DESTINATION include)
+
+IF (PAHO_WITH_SSL)
+ SET(OPENSSL_LIB_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL libraries")
+ SET(OPENSSL_INC_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL includes")
+ SET(OPENSSL_LIBRARIES ssl crypto)
+ LINK_DIRECTORIES(
+ ${OPENSSL_LIB_SEARCH_PATH}
+ )
+ INCLUDE_DIRECTORIES(
+ ${OPENSSL_INC_SEARCH_PATH}
+ )
+ ADD_LIBRARY(paho-mqtt3cs SHARED ${common_src} MQTTClient.c SSLSocket.c)
+ ADD_LIBRARY(paho-mqtt3as SHARED ${common_src} MQTTAsync.c SSLSocket.c)
+ TARGET_LINK_LIBRARIES(paho-mqtt3cs pthread ${OPENSSL_LIBRARIES} ${LIBS_SYSTEM})
+ TARGET_LINK_LIBRARIES(paho-mqtt3as pthread ${OPENSSL_LIBRARIES} ${LIBS_SYSTEM})
+ SET_TARGET_PROPERTIES(
+ paho-mqtt3cs paho-mqtt3as PROPERTIES
+ VERSION ${CLIENT_VERSION}
+ SOVERSION ${PAHO_VERSION_MAJOR})
+ INSTALL(TARGETS paho-mqtt3cs
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib)
+ INSTALL(TARGETS paho-mqtt3as
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib)
+ENDIF()
+
diff --git a/src/Heap.c b/src/Heap.c
old mode 100644
new mode 100755
index 89da7992..3e946161
--- a/src/Heap.c
+++ b/src/Heap.c
@@ -62,7 +62,7 @@ typedef struct
char* file; /**< the name of the source file where the storage was allocated */
int line; /**< the line no in the source file where it was allocated */
void* ptr; /**< pointer to the allocated storage */
- int size; /**< size of the allocated storage */
+ size_t size; /**< size of the allocated storage */
} storageElement;
static Tree heap; /**< Tree that holds the allocation records */
@@ -75,7 +75,7 @@ static char* errmsg = "Memory allocation error";
* @param size the size actually needed
* @return the rounded up size
*/
-int Heap_roundup(int size)
+size_t Heap_roundup(size_t size)
{
static int multsize = 4*sizeof(int);
@@ -139,8 +139,8 @@ void Heap_check(char* string, void* ptr)
void* mymalloc(char* file, int line, size_t size)
{
storageElement* s = NULL;
- int space = sizeof(storageElement);
- int filenamelen = strlen(file)+1;
+ size_t space = sizeof(storageElement);
+ size_t filenamelen = strlen(file)+1;
Thread_lock_mutex(heap_mutex);
size = Heap_roundup(size);
@@ -180,7 +180,7 @@ void* mymalloc(char* file, int line, size_t size)
}
-void checkEyecatchers(char* file, int line, void* p, int size)
+void checkEyecatchers(char* file, int line, void* p, size_t size)
{
int *sp = (int*)p;
char *cp = (char*)p;
@@ -282,8 +282,8 @@ void *myrealloc(char* file, int line, void* p, size_t size)
Log(LOG_ERROR, 13, "Failed to reallocate heap item at file %s line %d", file, line);
else
{
- int space = sizeof(storageElement);
- int filenamelen = strlen(file)+1;
+ size_t space = sizeof(storageElement);
+ size_t filenamelen = strlen(file)+1;
checkEyecatchers(file, line, p, s->size);
size = Heap_roundup(size);
@@ -393,7 +393,7 @@ heap_info* Heap_get_info()
int HeapDumpString(FILE* file, char* str)
{
int rc = 0;
- int len = str ? strlen(str) + 1 : 0; /* include the trailing null */
+ size_t len = str ? strlen(str) + 1 : 0; /* include the trailing null */
if (fwrite(&(str), sizeof(char*), 1, file) != 1)
rc = -1;
diff --git a/src/Heap.h b/src/Heap.h
old mode 100644
new mode 100755
index ac5572db..06494c44
--- a/src/Heap.h
+++ b/src/Heap.h
@@ -56,8 +56,8 @@
*/
typedef struct
{
- int current_size; /**< current size of the heap in bytes */
- int max_size; /**< max size the heap has reached in bytes */
+ size_t current_size; /**< current size of the heap in bytes */
+ size_t max_size; /**< max size the heap has reached in bytes */
} heap_info;
diff --git a/src/LinkedList.c b/src/LinkedList.c
old mode 100644
new mode 100755
index 7efdae68..603a2ccf
--- a/src/LinkedList.c
+++ b/src/LinkedList.c
@@ -67,7 +67,7 @@ List* ListInitialize(void)
* @param newel the ListElement to be used in adding the new item
* @param size the size of the element
*/
-void ListAppendNoMalloc(List* aList, void* content, ListElement* newel, int size)
+void ListAppendNoMalloc(List* aList, void* content, ListElement* newel, size_t size)
{ /* for heap use */
newel->content = content;
newel->next = NULL;
@@ -88,7 +88,7 @@ void ListAppendNoMalloc(List* aList, void* content, ListElement* newel, int size
* @param content the list item content itself
* @param size the size of the element
*/
-void ListAppend(List* aList, void* content, int size)
+void ListAppend(List* aList, void* content, size_t size)
{
ListElement* newel = malloc(sizeof(ListElement));
ListAppendNoMalloc(aList, content, newel, size);
@@ -103,7 +103,7 @@ void ListAppend(List* aList, void* content, int size)
* @param index the position in the list. If NULL, this function is equivalent
* to ListAppend.
*/
-void ListInsert(List* aList, void* content, int size, ListElement* index)
+void ListInsert(List* aList, void* content, size_t size, ListElement* index)
{
ListElement* newel = malloc(sizeof(ListElement));
@@ -359,7 +359,8 @@ void ListEmpty(List* aList)
aList->first = first->next;
free(first);
}
- aList->count = aList->size = 0;
+ aList->count = 0;
+ aList->size = 0;
aList->current = aList->first = aList->last = NULL;
}
diff --git a/src/LinkedList.h b/src/LinkedList.h
old mode 100644
new mode 100755
index e6888d42..b6a99a47
--- a/src/LinkedList.h
+++ b/src/LinkedList.h
@@ -13,11 +13,14 @@
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
* Ian Craggs - updates for the async client
+ * Ian Craggs - change size types from int to size_t
*******************************************************************************/
#if !defined(LINKEDLIST_H)
#define LINKEDLIST_H
+#include // for size_t definition
+
/*BE
defm defList(T)
@@ -66,16 +69,16 @@ typedef struct
ListElement *first, /**< first element in the list */
*last, /**< last element in the list */
*current; /**< current element in the list, for iteration */
- int count, /**< no of items */
- size; /**< heap storage used */
+ int count; /**< no of items */
+ size_t size; /**< heap storage used */
} List;
void ListZero(List*);
List* ListInitialize(void);
-void ListAppend(List* aList, void* content, int size);
-void ListAppendNoMalloc(List* aList, void* content, ListElement* newel, int size);
-void ListInsert(List* aList, void* content, int size, ListElement* index);
+void ListAppend(List* aList, void* content, size_t size);
+void ListAppendNoMalloc(List* aList, void* content, ListElement* newel, size_t size);
+void ListInsert(List* aList, void* content, size_t size, ListElement* index);
int ListRemove(List* aList, void* content);
int ListRemoveItem(List* aList, void* content, int(*callback)(void*, void*));
diff --git a/src/MQTTAsync.c b/src/MQTTAsync.c
old mode 100644
new mode 100755
index d15ae0da..f475c27b
--- a/src/MQTTAsync.c
+++ b/src/MQTTAsync.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corp.
+ * Copyright (c) 2009, 2016 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -24,6 +24,12 @@
* Ian Craggs - fix for bug 442400: reconnecting after network cable unplugged
* Ian Craggs - fix for bug 444934 - incorrect free in freeCommand1
* Ian Craggs - fix for bug 445891 - assigning msgid is not thread safe
+ * Ian Craggs - fix for bug 465369 - longer latency than expected
+ * Ian Craggs - fix for bug 444103 - success/failure callbacks not invoked
+ * Ian Craggs - fix for bug 484363 - segfault in getReadySocket
+ * Ian Craggs - automatic reconnect and offline buffering (send while disconnected)
+ * Ian Craggs - fix for bug 472250
+ * Ian Craggs - fix for bug 486548
*******************************************************************************/
/**
@@ -52,12 +58,15 @@
#define URI_TCP "tcp://"
-#define BUILD_TIMESTAMP "##MQTTCLIENT_BUILD_TAG##"
-#define CLIENT_VERSION "##MQTTCLIENT_VERSION_TAG##"
+#include "VersionInfo.h"
char* client_timestamp_eye = "MQTTAsyncV3_Timestamp " BUILD_TIMESTAMP;
char* client_version_eye = "MQTTAsyncV3_Version " CLIENT_VERSION;
+#if !defined(min)
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
extern Sockets s;
static ClientStates ClientState =
@@ -82,6 +91,7 @@ static thread_id_type sendThread_id = 0,
#if defined(WIN32) || defined(WIN64)
static mutex_type mqttasync_mutex = NULL;
+static mutex_type socket_mutex = NULL;
static mutex_type mqttcommand_mutex = NULL;
static sem_type send_sem = NULL;
extern mutex_type stack_mutex;
@@ -108,6 +118,7 @@ BOOL APIENTRY DllMain(HANDLE hModule,
stack_mutex = CreateMutex(NULL, 0, NULL);
heap_mutex = CreateMutex(NULL, 0, NULL);
log_mutex = CreateMutex(NULL, 0, NULL);
+ socket_mutex = CreateMutex(NULL, 0, NULL);
}
case DLL_THREAD_ATTACH:
Log(TRACE_MAX, -1, "DLL thread attach");
@@ -121,8 +132,13 @@ BOOL APIENTRY DllMain(HANDLE hModule,
#else
static pthread_mutex_t mqttasync_mutex_store = PTHREAD_MUTEX_INITIALIZER;
static mutex_type mqttasync_mutex = &mqttasync_mutex_store;
+
+static pthread_mutex_t socket_mutex_store = PTHREAD_MUTEX_INITIALIZER;
+static mutex_type socket_mutex = &socket_mutex_store;
+
static pthread_mutex_t mqttcommand_mutex_store = PTHREAD_MUTEX_INITIALIZER;
static mutex_type mqttcommand_mutex = &mqttcommand_mutex_store;
+
static cond_type_struct send_cond_store = { PTHREAD_COND_INITIALIZER, PTHREAD_MUTEX_INITIALIZER };
static cond_type send_cond = &send_cond_store;
@@ -137,6 +153,13 @@ void MQTTAsync_init()
printf("MQTTAsync: error %d initializing async_mutex\n", rc);
if ((rc = pthread_mutex_init(mqttcommand_mutex, &attr)) != 0)
printf("MQTTAsync: error %d initializing command_mutex\n", rc);
+ if ((rc = pthread_mutex_init(socket_mutex, &attr)) != 0)
+ printf("MQTTClient: error %d initializing socket_mutex\n", rc);
+
+ if ((rc = pthread_cond_init(&send_cond->cond, NULL)) != 0)
+ printf("MQTTAsync: error %d initializing send_cond cond\n", rc);
+ if ((rc = pthread_mutex_init(&send_cond->mutex, &attr)) != 0)
+ printf("MQTTAsync: error %d initializing send_cond mutex\n", rc);
}
#define WINAPI
@@ -252,9 +275,6 @@ typedef struct
} dis;
struct
{
- int timeout;
- int serverURIcount;
- char** serverURIs;
int currentURI;
int MQTTVersion; /**< current MQTT version being used to connect */
} conn;
@@ -273,9 +293,14 @@ typedef struct MQTTAsync_struct
MQTTAsync_messageArrived* ma;
MQTTAsync_deliveryComplete* dc;
void* context; /* the context to be associated with the main callbacks*/
+
+ MQTTAsync_connected* connected;
+ void* connected_context; /* the context to be associated with the connected callback*/
- MQTTAsync_command connect; /* Connect operation properties */
- MQTTAsync_command disconnect; /* Disconnect operation properties */
+ /* Each time connect is called, we store the options that were used. These are reused in
+ any call to reconnect, or an automatic reconnect attempt */
+ MQTTAsync_command connect; /* Connect operation properties */
+ MQTTAsync_command disconnect; /* Disconnect operation properties */
MQTTAsync_command* pending_write; /* Is there a socket write pending? */
List* responses;
@@ -283,6 +308,23 @@ typedef struct MQTTAsync_struct
MQTTPacket* pack;
+ /* added for offline buffering */
+ MQTTAsync_createOptions* createOptions;
+ int shouldBeConnected;
+
+ /* added for automatic reconnect */
+ int automaticReconnect;
+ int minRetryInterval;
+ int maxRetryInterval;
+ int serverURIcount;
+ char** serverURIs;
+ int connectTimeout;
+
+ int currentInterval;
+ START_TIME_TYPE lastConnectionFailedTime;
+ int retrying;
+ int reconnectNow;
+
} MQTTAsyncs;
@@ -341,20 +383,24 @@ void MQTTAsync_unlock_mutex(mutex_type amutex)
}
+/*
+ Check whether there are any more connect options. If not then we are finished
+ with connect attempts.
+*/
int MQTTAsync_checkConn(MQTTAsync_command* command, MQTTAsyncs* client)
{
- int rc;
+ int rc;
- FUNC_ENTRY;
- rc = command->details.conn.currentURI < command->details.conn.serverURIcount ||
- (command->details.conn.MQTTVersion == 4 && client->c->MQTTVersion == MQTTVERSION_DEFAULT);
- FUNC_EXIT_RC(rc);
- return rc;
+ FUNC_ENTRY;
+ rc = command->details.conn.currentURI < client->serverURIcount ||
+ (command->details.conn.MQTTVersion == 4 && client->c->MQTTVersion == MQTTVERSION_DEFAULT);
+ FUNC_EXIT_RC(rc);
+ return rc;
}
-int MQTTAsync_create(MQTTAsync* handle, const char* serverURI, const char* clientId,
- int persistence_type, void* persistence_context)
+int MQTTAsync_createWithOptions(MQTTAsync* handle, const char* serverURI, const char* clientId,
+ int persistence_type, void* persistence_context, MQTTAsync_createOptions* options)
{
int rc = 0;
MQTTAsyncs *m = NULL;
@@ -374,6 +420,12 @@ int MQTTAsync_create(MQTTAsync* handle, const char* serverURI, const char* clien
goto exit;
}
+ if (options && (strncmp(options->struct_id, "MQCO", 4) != 0 || options->struct_version != 0))
+ {
+ rc = MQTTASYNC_BAD_STRUCTURE;
+ goto exit;
+ }
+
if (!initialized)
{
#if defined(HEAP_H)
@@ -414,6 +466,13 @@ int MQTTAsync_create(MQTTAsync* handle, const char* serverURI, const char* clien
m->c->messageQueue = ListInitialize();
m->c->clientID = MQTTStrdup(clientId);
+ m->shouldBeConnected = 0;
+ if (options)
+ {
+ m->createOptions = malloc(sizeof(MQTTAsync_createOptions));
+ memcpy(m->createOptions, options, sizeof(MQTTAsync_createOptions));
+ }
+
#if !defined(NO_PERSISTENCE)
rc = MQTTPersistence_create(&(m->c->persistence), persistence_type, persistence_context);
if (rc == 0)
@@ -435,6 +494,14 @@ exit:
}
+int MQTTAsync_create(MQTTAsync* handle, const char* serverURI, const char* clientId,
+ int persistence_type, void* persistence_context)
+{
+ return MQTTAsync_createWithOptions(handle, serverURI, clientId, persistence_type,
+ persistence_context, NULL);
+}
+
+
void MQTTAsync_terminate(void)
{
FUNC_ENTRY;
@@ -508,7 +575,7 @@ int MQTTAsync_persistCommand(MQTTAsync_queuedCommand* qcmd)
for (i = 0; i < command->details.sub.count; ++i)
{
bufs[bufindex] = command->details.sub.topics[i];
- lens[bufindex++] = strlen(command->details.sub.topics[i]) + 1;
+ lens[bufindex++] = (int)strlen(command->details.sub.topics[i]) + 1;
bufs[bufindex] = &command->details.sub.qoss[i];
lens[bufindex++] = sizeof(command->details.sub.qoss[i]);
}
@@ -533,7 +600,7 @@ int MQTTAsync_persistCommand(MQTTAsync_queuedCommand* qcmd)
for (i = 0; i < command->details.unsub.count; ++i)
{
bufs[bufindex] = command->details.unsub.topics[i];
- lens[bufindex++] = strlen(command->details.unsub.topics[i]) + 1;
+ lens[bufindex++] = (int)strlen(command->details.unsub.topics[i]) + 1;
}
sprintf(key, "%s%d", PERSISTENCE_COMMAND_KEY, ++aclient->command_seqno);
break;
@@ -551,7 +618,7 @@ int MQTTAsync_persistCommand(MQTTAsync_queuedCommand* qcmd)
lens[bufindex++] = sizeof(command->token);
bufs[bufindex] = command->details.pub.destinationName;
- lens[bufindex++] = strlen(command->details.pub.destinationName) + 1;
+ lens[bufindex++] = (int)strlen(command->details.pub.destinationName) + 1;
bufs[bufindex] = &command->details.pub.payloadlen;
lens[bufindex++] = sizeof(command->details.pub.payloadlen);
@@ -588,7 +655,8 @@ MQTTAsync_queuedCommand* MQTTAsync_restoreCommand(char* buffer, int buflen)
MQTTAsync_command* command = NULL;
MQTTAsync_queuedCommand* qcommand = NULL;
char* ptr = buffer;
- int i, data_size;
+ int i;
+ size_t data_size;
FUNC_ENTRY;
qcommand = malloc(sizeof(MQTTAsync_queuedCommand));
@@ -626,7 +694,7 @@ MQTTAsync_queuedCommand* MQTTAsync_restoreCommand(char* buffer, int buflen)
for (i = 0; i < command->details.unsub.count; ++i)
{
- int data_size = strlen(ptr) + 1;
+ size_t data_size = strlen(ptr) + 1;
command->details.unsub.topics[i] = malloc(data_size);
strcpy(command->details.unsub.topics[i], ptr);
@@ -760,7 +828,9 @@ int MQTTAsync_addCommand(MQTTAsync_queuedCommand* command, int command_size)
}
MQTTAsync_unlock_mutex(mqttcommand_mutex);
#if !defined(WIN32) && !defined(WIN64)
- Thread_signal_cond(send_cond);
+ rc = Thread_signal_cond(send_cond);
+ if (rc != 0)
+ Log(LOG_ERROR, 0, "Error %d from signal cond", rc);
#else
if (!Thread_check_sem(send_sem))
Thread_post_sem(send_sem);
@@ -770,6 +840,63 @@ int MQTTAsync_addCommand(MQTTAsync_queuedCommand* command, int command_size)
}
+void MQTTAsync_startConnectRetry(MQTTAsyncs* m)
+{
+ if (m->automaticReconnect && m->shouldBeConnected)
+ {
+ m->lastConnectionFailedTime = MQTTAsync_start_clock();
+ if (m->retrying)
+ m->currentInterval = min(m->currentInterval * 2, m->maxRetryInterval);
+ else
+ {
+ m->currentInterval = m->minRetryInterval;
+ m->retrying = 1;
+ }
+ }
+}
+
+
+int MQTTAsync_reconnect(MQTTAsync handle)
+{
+ int rc = MQTTASYNC_FAILURE;
+ MQTTAsyncs* m = handle;
+
+ FUNC_ENTRY;
+ MQTTAsync_lock_mutex(mqttasync_mutex);
+
+ if (m->automaticReconnect)
+ {
+ if (m->shouldBeConnected)
+ {
+ m->reconnectNow = 1;
+ if (m->retrying == 0)
+ {
+ m->currentInterval = m->minRetryInterval;
+ m->retrying = 1;
+ }
+ rc = MQTTASYNC_SUCCESS;
+ }
+ }
+ else
+ {
+ /* to reconnect, put the connect command to the head of the command queue */
+ MQTTAsync_queuedCommand* conn = malloc(sizeof(MQTTAsync_queuedCommand));
+ memset(conn, '\0', sizeof(MQTTAsync_queuedCommand));
+ conn->client = m;
+ conn->command = m->connect;
+ /* make sure that the version attempts are restarted */
+ if (m->c->MQTTVersion == MQTTVERSION_DEFAULT)
+ conn->command.details.conn.MQTTVersion = 0;
+ MQTTAsync_addCommand(conn, sizeof(m->connect));
+ rc = MQTTASYNC_SUCCESS;
+ }
+
+ MQTTAsync_unlock_mutex(mqttasync_mutex);
+ FUNC_EXIT_RC(rc);
+ return rc;
+}
+
+
void MQTTAsync_checkDisconnect(MQTTAsync handle, MQTTAsync_command* command)
{
MQTTAsyncs* m = handle;
@@ -780,12 +907,16 @@ void MQTTAsync_checkDisconnect(MQTTAsync handle, MQTTAsync_command* command)
{
int was_connected = m->c->connected;
MQTTAsync_closeSession(m->c);
- if (command->details.dis.internal && m->cl && was_connected)
+ if (command->details.dis.internal)
{
- Log(TRACE_MIN, -1, "Calling connectionLost for client %s", m->c->clientID);
- (*(m->cl))(m->context, NULL);
+ if (m->cl && was_connected)
+ {
+ Log(TRACE_MIN, -1, "Calling connectionLost for client %s", m->c->clientID);
+ (*(m->cl))(m->context, NULL);
+ }
+ MQTTAsync_startConnectRetry(m);
}
- else if (!command->details.dis.internal && command->onSuccess)
+ else if (command->onSuccess)
{
Log(TRACE_MIN, -1, "Calling disconnect complete for client %s", m->c->clientID);
(*(command->onSuccess))(command->context, NULL);
@@ -823,17 +954,14 @@ void MQTTProtocol_checkPendingWrites()
}
-void MQTTAsync_freeConnect(MQTTAsync_command command)
+void MQTTAsync_freeServerURIs(MQTTAsyncs* m)
{
- if (command.type == CONNECT)
- {
- int i;
+ int i;
- for (i = 0; i < command.details.conn.serverURIcount; ++i)
- free(command.details.conn.serverURIs[i]);
- if (command.details.conn.serverURIs)
- free(command.details.conn.serverURIs);
- }
+ for (i = 0; i < m->serverURIcount; ++i)
+ free(m->serverURIs[i]);
+ if (m->serverURIs)
+ free(m->serverURIs);
}
@@ -927,7 +1055,7 @@ void MQTTAsync_writeComplete(int socket)
}
-void MQTTAsync_processCommand()
+int MQTTAsync_processCommand()
{
int rc = 0;
MQTTAsync_queuedCommand* command = NULL;
@@ -988,20 +1116,21 @@ void MQTTAsync_processCommand()
{
char* serverURI = command->client->serverURI;
- if (command->command.details.conn.serverURIcount > 0)
+ if (command->client->serverURIcount > 0)
{
if (command->client->c->MQTTVersion == MQTTVERSION_DEFAULT)
{
- if (command->command.details.conn.MQTTVersion == 3)
+ if (command->command.details.conn.MQTTVersion == MQTTVERSION_3_1)
{
command->command.details.conn.currentURI++;
- command->command.details.conn.MQTTVersion = 4;
- }
+ command->command.details.conn.MQTTVersion = MQTTVERSION_DEFAULT;
+ }
}
else
command->command.details.conn.currentURI++;
- serverURI = command->command.details.conn.serverURIs[command->command.details.conn.currentURI];
-
+
+ serverURI = command->client->serverURIs[command->command.details.conn.currentURI];
+
if (strncmp(URI_TCP, serverURI, strlen(URI_TCP)) == 0)
serverURI += strlen(URI_TCP);
#if defined(OPENSSL)
@@ -1140,6 +1269,7 @@ void MQTTAsync_processCommand()
{
MQTTAsync_disconnectOptions opts = MQTTAsync_disconnectOptions_initializer;
MQTTAsync_disconnect(command->client, &opts); /* not "internal" because we don't want to call connection lost */
+ command->client->shouldBeConnected = 1; /* as above call is not "internal" we need to reset this */
}
else
MQTTAsync_disconnect_internal(command->client, 0);
@@ -1157,7 +1287,6 @@ void MQTTAsync_processCommand()
Log(TRACE_MIN, -1, "Calling command failure for client %s", command->client->c->clientID);
(*(command->command.onFailure))(command->command.context, NULL);
}
- MQTTAsync_freeConnect(command->command);
MQTTAsync_freeCommand(command); /* free up the command if necessary */
}
}
@@ -1166,7 +1295,9 @@ void MQTTAsync_processCommand()
exit:
MQTTAsync_unlock_mutex(mqttasync_mutex);
- FUNC_EXIT;
+ rc = (command != NULL);
+ FUNC_EXIT_RC(rc);
+ return rc;
}
@@ -1192,7 +1323,7 @@ void MQTTAsync_checkTimeouts()
MQTTAsyncs* m = (MQTTAsyncs*)(current->content);
/* check connect timeout */
- if (m->c->connect_state != 0 && MQTTAsync_elapsed(m->connect.start_time) > (m->connect.details.conn.timeout * 1000))
+ if (m->c->connect_state != 0 && MQTTAsync_elapsed(m->connect.start_time) > (m->connectTimeout * 1000))
{
if (MQTTAsync_checkConn(&m->connect, m))
{
@@ -1210,12 +1341,17 @@ void MQTTAsync_checkTimeouts()
else
{
MQTTAsync_closeSession(m->c);
- MQTTAsync_freeConnect(m->connect);
if (m->connect.onFailure)
{
+ MQTTAsync_failureData data;
+
+ data.token = 0;
+ data.code = MQTTASYNC_FAILURE;
+ data.message = "TCP connect timeout";
Log(TRACE_MIN, -1, "Calling connect failure for client %s", m->c->clientID);
- (*(m->connect.onFailure))(m->connect.context, NULL);
+ (*(m->connect.onFailure))(m->connect.context, &data);
}
+ MQTTAsync_startConnectRetry(m);
}
continue;
}
@@ -1245,6 +1381,24 @@ void MQTTAsync_checkTimeouts()
}
for (i = 0; i < timed_out_count; ++i)
ListRemoveHead(m->responses); /* remove the first response in the list */
+
+ if (m->automaticReconnect && m->retrying)
+ {
+ if (m->reconnectNow || MQTTAsync_elapsed(m->lastConnectionFailedTime) > (m->currentInterval * 1000))
+ {
+ /* to reconnect put the connect command to the head of the command queue */
+ MQTTAsync_queuedCommand* conn = malloc(sizeof(MQTTAsync_queuedCommand));
+ memset(conn, '\0', sizeof(MQTTAsync_queuedCommand));
+ conn->client = m;
+ conn->command = m->connect;
+ /* make sure that the version attempts are restarted */
+ if (m->c->MQTTVersion == MQTTVERSION_DEFAULT)
+ conn->command.details.conn.MQTTVersion = 0;
+ Log(TRACE_MIN, -1, "Automatically attempting to reconnect");
+ MQTTAsync_addCommand(conn, sizeof(m->connect));
+ m->reconnectNow = 0;
+ }
+ }
}
MQTTAsync_unlock_mutex(mqttasync_mutex);
exit:
@@ -1265,13 +1419,10 @@ thread_return_type WINAPI MQTTAsync_sendThread(void* n)
while (commands->count > 0)
{
- int before = commands->count;
- MQTTAsync_processCommand();
- if (before == commands->count)
+ if (MQTTAsync_processCommand() == 0)
break; /* no commands were processed, so go into a wait */
}
#if !defined(WIN32) && !defined(WIN64)
- rc = Thread_wait_cond(send_cond, 1);
if ((rc = Thread_wait_cond(send_cond, 1)) != 0 && rc != ETIMEDOUT)
Log(LOG_ERROR, -1, "Error %d waiting for condition variable", rc);
#else
@@ -1320,11 +1471,26 @@ void MQTTAsync_removeResponsesAndCommands(MQTTAsyncs* m)
FUNC_ENTRY;
if (m->responses)
{
- ListElement* elem = NULL;
+ ListElement* cur_response = NULL;
- while (ListNextElement(m->responses, &elem))
+ while (ListNextElement(m->responses, &cur_response))
{
- MQTTAsync_freeCommand1((MQTTAsync_queuedCommand*) (elem->content));
+ MQTTAsync_queuedCommand* command = (MQTTAsync_queuedCommand*)(cur_response->content);
+
+ if (command->command.onFailure)
+ {
+ MQTTAsync_failureData data;
+
+ data.token = command->command.token;
+ data.code = MQTTASYNC_OPERATION_INCOMPLETE; /* interrupted return code */
+ data.message = NULL;
+
+ Log(TRACE_MIN, -1, "Calling %s failure for client %s",
+ MQTTPacket_name(command->command.type), m->c->clientID);
+ (*(command->command.onFailure))(command->command.context, &data);
+ }
+
+ MQTTAsync_freeCommand1(command);
count++;
}
}
@@ -1337,12 +1503,26 @@ void MQTTAsync_removeResponsesAndCommands(MQTTAsyncs* m)
ListNextElement(commands, &next);
while (current)
{
- MQTTAsync_queuedCommand* cmd = (MQTTAsync_queuedCommand*)(current->content);
+ MQTTAsync_queuedCommand* command = (MQTTAsync_queuedCommand*)(current->content);
- if (cmd->client == m)
+ if (command->client == m)
{
- ListDetach(commands, cmd);
- MQTTAsync_freeCommand(cmd);
+ ListDetach(commands, command);
+
+ if (command->command.onFailure)
+ {
+ MQTTAsync_failureData data;
+
+ data.token = command->command.token;
+ data.code = MQTTASYNC_OPERATION_INCOMPLETE; /* interrupted return code */
+ data.message = NULL;
+
+ Log(TRACE_MIN, -1, "Calling %s failure for client %s",
+ MQTTPacket_name(command->command.type), m->c->clientID);
+ (*(command->command.onFailure))(command->command.context, &data);
+ }
+
+ MQTTAsync_freeCommand(command);
count++;
}
current = next;
@@ -1384,6 +1564,9 @@ void MQTTAsync_destroy(MQTTAsync* handle)
if (m->serverURI)
free(m->serverURI);
+ if (m->createOptions)
+ free(m->createOptions);
+ MQTTAsync_freeServerURIs(m);
if (!ListRemove(handles, m))
Log(LOG_ERROR, -1, "free error");
*handle = NULL;
@@ -1425,6 +1608,7 @@ int MQTTAsync_completeConnection(MQTTAsyncs* m, MQTTPacket* pack)
Log(LOG_PROTOCOL, 1, NULL, m->c->net.socket, m->c->clientID, connack->rc);
if ((rc = connack->rc) == MQTTASYNC_SUCCESS)
{
+ m->retrying = 0;
m->c->connected = 1;
m->c->good = 1;
m->c->connect_state = 0;
@@ -1446,6 +1630,12 @@ int MQTTAsync_completeConnection(MQTTAsyncs* m, MQTTPacket* pack)
}
free(connack);
m->pack = NULL;
+#if !defined(WIN32) && !defined(WIN64)
+ Thread_signal_cond(send_cond);
+#else
+ if (!Thread_check_sem(send_sem))
+ Thread_post_sem(send_sem);
+#endif
}
FUNC_EXIT_RC(rc);
return rc;
@@ -1538,22 +1728,29 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n)
if (rc == MQTTASYNC_SUCCESS)
{
- if (m->connect.details.conn.serverURIcount > 0)
+ if (m->serverURIcount > 0)
Log(TRACE_MIN, -1, "Connect succeeded to %s",
- m->connect.details.conn.serverURIs[m->connect.details.conn.currentURI]);
- MQTTAsync_freeConnect(m->connect);
+ m->serverURIs[m->connect.details.conn.currentURI]);
+ int onSuccess = (m->connect.onSuccess != NULL); /* save setting of onSuccess callback */
if (m->connect.onSuccess)
{
MQTTAsync_successData data;
memset(&data, '\0', sizeof(data));
Log(TRACE_MIN, -1, "Calling connect success for client %s", m->c->clientID);
- if (m->connect.details.conn.serverURIcount > 0)
- data.alt.connect.serverURI = m->connect.details.conn.serverURIs[m->connect.details.conn.currentURI];
+ if (m->serverURIcount > 0)
+ data.alt.connect.serverURI = m->serverURIs[m->connect.details.conn.currentURI];
else
data.alt.connect.serverURI = m->serverURI;
data.alt.connect.MQTTVersion = m->connect.details.conn.MQTTVersion;
data.alt.connect.sessionPresent = sessionPresent;
(*(m->connect.onSuccess))(m->connect.context, &data);
+ m->connect.onSuccess = NULL; /* don't accidentally call it again */
+ }
+ if (m->connected)
+ {
+ Log(TRACE_MIN, -1, "Calling connected for client %s", m->c->clientID);
+ char* reason = (onSuccess) ? "connect onSuccess called" : "automatic reconnect";
+ (*(m->connected))(m->connected_context, reason);
}
}
else
@@ -1574,7 +1771,6 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n)
else
{
MQTTAsync_closeSession(m->c);
- MQTTAsync_freeConnect(m->connect);
if (m->connect.onFailure)
{
MQTTAsync_failureData data;
@@ -1585,6 +1781,7 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n)
Log(TRACE_MIN, -1, "Calling connect failure for client %s", m->c->clientID);
(*(m->connect.onFailure))(m->connect.context, &data);
}
+ MQTTAsync_startConnectRetry(m);
}
}
}
@@ -1758,6 +1955,28 @@ int MQTTAsync_setCallbacks(MQTTAsync handle, void* context,
}
+int MQTTAsync_setConnected(MQTTAsync handle, void* context, MQTTAsync_connected* connected)
+{
+ int rc = MQTTASYNC_SUCCESS;
+ MQTTAsyncs* m = handle;
+
+ FUNC_ENTRY;
+ MQTTAsync_lock_mutex(mqttasync_mutex);
+
+ if (m == NULL || m->c->connect_state != 0)
+ rc = MQTTASYNC_FAILURE;
+ else
+ {
+ m->connected_context = context;
+ m->connected = connected;
+ }
+
+ MQTTAsync_unlock_mutex(mqttasync_mutex);
+ FUNC_EXIT_RC(rc);
+ return rc;
+}
+
+
void MQTTAsync_closeOnly(Clients* client)
{
FUNC_ENTRY;
@@ -1767,10 +1986,12 @@ void MQTTAsync_closeOnly(Clients* client)
{
if (client->connected)
MQTTPacket_send_disconnect(&client->net, client->clientID);
+ Thread_lock_mutex(socket_mutex);
#if defined(OPENSSL)
SSLSocket_close(&client->net);
#endif
Socket_close(client->net.socket);
+ Thread_unlock_mutex(socket_mutex);
client->net.socket = 0;
#if defined(OPENSSL)
client->net.ssl = NULL;
@@ -1833,16 +2054,13 @@ int MQTTAsync_cleanSession(Clients* client)
}
-
-
-
int MQTTAsync_deliverMessage(MQTTAsyncs* m, char* topicName, size_t topicLen, MQTTAsync_message* mm)
{
int rc;
Log(TRACE_MIN, -1, "Calling messageArrived for client %s, queue depth %d",
m->c->clientID, m->c->messageQueue->count);
- rc = (*(m->ma))(m->context, topicName, topicLen, mm);
+ rc = (*(m->ma))(m->context, topicName, (int)topicLen, mm);
/* if 0 (false) is returned by the callback then it failed, so we don't remove the message from
* the queue, and it will be retried later. If 1 is returned then the message data may have been freed,
* so we must be careful how we use it.
@@ -1924,9 +2142,7 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
goto exit;
}
- if (strncmp(options->struct_id, "MQTC", 4) != 0 ||
- (options->struct_version != 0 && options->struct_version != 1 && options->struct_version != 2 &&
- options->struct_version != 3))
+ if (strncmp(options->struct_id, "MQTC", 4) != 0 || options->struct_version < 0 || options->struct_version > 4)
{
rc = MQTTASYNC_BAD_STRUCTURE;
goto exit;
@@ -1962,6 +2178,7 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
m->connect.onSuccess = options->onSuccess;
m->connect.onFailure = options->onFailure;
m->connect.context = options->context;
+ m->connectTimeout = options->connectTimeout;
tostop = 0;
if (sendThread_state != STARTING && sendThread_state != RUNNING)
@@ -1982,10 +2199,16 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
m->c->keepAliveInterval = options->keepAliveInterval;
m->c->cleansession = options->cleansession;
m->c->maxInflightMessages = options->maxInflight;
- if (options->struct_version == 3)
+ if (options->struct_version >= 3)
m->c->MQTTVersion = options->MQTTVersion;
else
m->c->MQTTVersion = 0;
+ if (options->struct_version >= 4)
+ {
+ m->automaticReconnect = options->automaticReconnect;
+ m->minRetryInterval = options->minRetryInterval;
+ m->maxRetryInterval = options->maxRetryInterval;
+ }
if (m->c->will)
{
@@ -2042,6 +2265,20 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
m->c->username = options->username;
m->c->password = options->password;
m->c->retryInterval = options->retryInterval;
+ m->shouldBeConnected = 1;
+
+ m->connectTimeout = options->connectTimeout;
+
+ MQTTAsync_freeServerURIs(m);
+ if (options->struct_version >= 2 && options->serverURIcount > 0)
+ {
+ int i;
+
+ m->serverURIcount = options->serverURIcount;
+ m->serverURIs = malloc(options->serverURIcount * sizeof(char*));
+ for (i = 0; i < options->serverURIcount; ++i)
+ m->serverURIs[i] = MQTTStrdup(options->serverURIs[i]);
+ }
/* Add connect request to operation queue */
conn = malloc(sizeof(MQTTAsync_queuedCommand));
@@ -2052,20 +2289,9 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
conn->command.onSuccess = options->onSuccess;
conn->command.onFailure = options->onFailure;
conn->command.context = options->context;
- conn->command.details.conn.timeout = options->connectTimeout;
-
- if (options->struct_version >= 2 && options->serverURIcount > 0)
- {
- int i;
-
- conn->command.details.conn.serverURIcount = options->serverURIcount;
- conn->command.details.conn.serverURIs = malloc(options->serverURIcount * sizeof(char*));
- for (i = 0; i < options->serverURIcount; ++i)
- conn->command.details.conn.serverURIs[i] = MQTTStrdup(options->serverURIs[i]);
- conn->command.details.conn.currentURI = 0;
- }
}
conn->command.type = CONNECT;
+ conn->command.details.conn.currentURI = 0;
rc = MQTTAsync_addCommand(conn, sizeof(conn));
exit:
@@ -2086,6 +2312,8 @@ int MQTTAsync_disconnect1(MQTTAsync handle, const MQTTAsync_disconnectOptions* o
rc = MQTTASYNC_FAILURE;
goto exit;
}
+ if (!internal)
+ m->shouldBeConnected = 0;
if (m->c->connected == 0)
{
rc = MQTTASYNC_DISCONNECTED;
@@ -2346,6 +2574,22 @@ int MQTTAsync_unsubscribe(MQTTAsync handle, const char* topic, MQTTAsync_respons
}
+int MQTTAsync_countBufferedMessages(MQTTAsyncs* m)
+{
+ ListElement* current = NULL;
+ int count = 0;
+
+ while (ListNextElement(commands, ¤t))
+ {
+ MQTTAsync_queuedCommand* cmd = (MQTTAsync_queuedCommand*)(current->content);
+
+ if (cmd->client == m && cmd->command.type == PUBLISH)
+ count++;
+ }
+ return count;
+}
+
+
int MQTTAsync_send(MQTTAsync handle, const char* destinationName, int payloadlen, void* payload,
int qos, int retained, MQTTAsync_responseOptions* response)
{
@@ -2357,7 +2601,8 @@ int MQTTAsync_send(MQTTAsync handle, const char* destinationName, int payloadlen
FUNC_ENTRY;
if (m == NULL || m->c == NULL)
rc = MQTTASYNC_FAILURE;
- else if (m->c->connected == 0)
+ else if (m->c->connected == 0 && (m->createOptions == NULL ||
+ m->createOptions->sendWhileDisconnected == 0 || m->shouldBeConnected == 0))
rc = MQTTASYNC_DISCONNECTED;
else if (!UTF8_validateString(destinationName))
rc = MQTTASYNC_BAD_UTF8_STRING;
@@ -2365,6 +2610,8 @@ int MQTTAsync_send(MQTTAsync handle, const char* destinationName, int payloadlen
rc = MQTTASYNC_BAD_QOS;
else if (qos > 0 && (msgid = MQTTAsync_assignMsgId(m)) == 0)
rc = MQTTASYNC_NO_MORE_MSGIDS;
+ else if (m->createOptions && (MQTTAsync_countBufferedMessages(m) >= m->createOptions->maxBufferedMessages))
+ rc = MQTTASYNC_MAX_BUFFERED_MESSAGES;
if (rc != MQTTASYNC_SUCCESS)
goto exit;
@@ -2540,12 +2787,17 @@ exit:
else
{
MQTTAsync_closeSession(m->c);
- MQTTAsync_freeConnect(m->connect);
if (m->connect.onFailure)
{
+ MQTTAsync_failureData data;
+
+ data.token = 0;
+ data.code = MQTTASYNC_FAILURE;
+ data.message = "TCP/TLS connect failure";
Log(TRACE_MIN, -1, "Calling connect failure for client %s", m->c->clientID);
- (*(m->connect.onFailure))(m->connect.context, NULL);
+ (*(m->connect.onFailure))(m->connect.context, &data);
}
+ MQTTAsync_startConnectRetry(m);
}
}
FUNC_EXIT_RC(rc);
@@ -2558,7 +2810,6 @@ MQTTPacket* MQTTAsync_cycle(int* sock, unsigned long timeout, int* rc)
struct timeval tp = {0L, 0L};
static Ack ack;
MQTTPacket* pack = NULL;
- static int nosockets_count = 0;
FUNC_ENTRY;
if (timeout > 0L)
@@ -2571,21 +2822,12 @@ MQTTPacket* MQTTAsync_cycle(int* sock, unsigned long timeout, int* rc)
if ((*sock = SSLSocket_getPendingRead()) == -1)
{
#endif
+ Thread_lock_mutex(socket_mutex);
/* 0 from getReadySocket indicates no work to do, -1 == error, but can happen normally */
*sock = Socket_getReadySocket(0, &tp);
+ Thread_unlock_mutex(socket_mutex);
if (!tostop && *sock == 0 && (tp.tv_sec > 0L || tp.tv_usec > 0L))
- {
MQTTAsync_sleep(100L);
-#if 0
- if (s.clientsds->count == 0)
- {
- if (++nosockets_count == 50) /* 5 seconds with no sockets */
- tostop = 1;
- }
-#endif
- }
- else
- nosockets_count = 0;
#if defined(OPENSSL)
}
#endif
@@ -2620,12 +2862,17 @@ MQTTPacket* MQTTAsync_cycle(int* sock, unsigned long timeout, int* rc)
else
{
MQTTAsync_closeSession(m->c);
- MQTTAsync_freeConnect(m->connect);
if (m->connect.onFailure)
{
+ MQTTAsync_failureData data;
+
+ data.token = 0;
+ data.code = MQTTASYNC_FAILURE;
+ data.message = "TCP connect completion failure";
Log(TRACE_MIN, -1, "Calling connect failure for client %s", m->c->clientID);
- (*(m->connect.onFailure))(m->connect.context, NULL);
+ (*(m->connect.onFailure))(m->connect.context, &data);
}
+ MQTTAsync_startConnectRetry(m);
}
}
}
diff --git a/src/MQTTAsync.h b/src/MQTTAsync.h
index 579ea80d..fc977de4 100644
--- a/src/MQTTAsync.h
+++ b/src/MQTTAsync.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corp.
+ * Copyright (c) 2009, 2016 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -15,6 +15,8 @@
* Ian Craggs, Allan Stockdill-Mander - SSL connections
* Ian Craggs - multiple server connection support
* Ian Craggs - MQTT 3.1.1 support
+ * Ian Craggs - fix for bug 444103 - success/failure callbacks not invoked
+ * Ian Craggs - automatic reconnect and offline buffering (send while disconnected)
*******************************************************************************/
/********************************************************************/
@@ -23,7 +25,7 @@
* @cond MQTTAsync_main
* @mainpage Asynchronous MQTT client library for C
*
- * © Copyright IBM Corp. 2009, 2015
+ * © Copyright IBM Corp. 2009, 2016
*
* @brief An Asynchronous MQTT client library for C.
*
@@ -149,6 +151,14 @@
* Return code: All 65535 MQTT msgids are being used
*/
#define MQTTASYNC_NO_MORE_MSGIDS -10
+/**
+ * Return code: the request is being discarded when not complete
+ */
+#define MQTTASYNC_OPERATION_INCOMPLETE -11
+/**
+ * Return code: no more messages can be buffered
+ */
+#define MQTTASYNC_MAX_BUFFERED_MESSAGES -12
/**
* Default MQTT version to connect with. Use 3.1.1 then fall back to 3.1
@@ -312,6 +322,23 @@ typedef void MQTTAsync_deliveryComplete(void* context, MQTTAsync_token token);
*/
typedef void MQTTAsync_connectionLost(void* context, char* cause);
+
+/**
+ * This is a callback function, which will be called when the client
+ * library successfully connects. This is superfluous when the connection
+ * is made in response to a MQTTAsync_connect call, because the onSuccess
+ * callback can be used. It is intended for use when automatic reconnect
+ * is enabled, so that when a reconnection attempt succeeds in the background,
+ * the application is notified and can take any required actions.
+ * @param context A pointer to the context value originally passed to
+ * MQTTAsync_setCallbacks(), which contains any application-specific context.
+ * @param cause The reason for the disconnection.
+ * Currently, cause is always set to NULL.
+ */
+typedef void MQTTAsync_connected(void* context, char* cause);
+
+
+
/** The data returned on completion of an unsuccessful API call in the response callback onFailure. */
typedef struct
{
@@ -435,6 +462,32 @@ typedef struct
*/
DLLExport int MQTTAsync_setCallbacks(MQTTAsync handle, void* context, MQTTAsync_connectionLost* cl,
MQTTAsync_messageArrived* ma, MQTTAsync_deliveryComplete* dc);
+
+
+/**
+ * Sets the MQTTAsync_connected() callback function for a client.
+ * @param handle A valid client handle from a successful call to
+ * MQTTAsync_create().
+ * @param context A pointer to any application-specific context. The
+ * the context pointer is passed to each of the callback functions to
+ * provide access to the context information in the callback.
+ * @param co A pointer to an MQTTAsync_connected() callback
+ * function. NULL removes the callback setting.
+ * @return ::MQTTASYNC_SUCCESS if the callbacks were correctly set,
+ * ::MQTTASYNC_FAILURE if an error occurred.
+ */
+DLLExport int MQTTAsync_setConnected(MQTTAsync handle, void* context, MQTTAsync_connected* co);
+
+
+/**
+ * Reconnects a client with the previously used connect options. Connect
+ * must have previously been called for this to work.
+ * @param handle A valid client handle from a successful call to
+ * MQTTAsync_create().
+ * @return ::MQTTASYNC_SUCCESS if the callbacks were correctly set,
+ * ::MQTTASYNC_FAILURE if an error occurred.
+ */
+DLLExport int MQTTAsync_reconnect(MQTTAsync handle);
/**
@@ -483,6 +536,24 @@ DLLExport int MQTTAsync_setCallbacks(MQTTAsync handle, void* context, MQTTAsync_
DLLExport int MQTTAsync_create(MQTTAsync* handle, const char* serverURI, const char* clientId,
int persistence_type, void* persistence_context);
+typedef struct
+{
+ /** The eyecatcher for this structure. must be MQCO. */
+ const char struct_id[4];
+ /** The version number of this structure. Must be 0 */
+ int struct_version;
+ /** Whether to allow messages to be sent when the client library is not connected. */
+ int sendWhileDisconnected;
+ /** the maximum number of messages allowed to be buffered while not connected. */
+ int maxBufferedMessages;
+} MQTTAsync_createOptions;
+
+#define MQTTAsync_createOptions_initializer { {'M', 'Q', 'C', 'O'}, 0, 0, 100 }
+
+
+DLLExport int MQTTAsync_createWithOptions(MQTTAsync* handle, const char* serverURI, const char* clientId,
+ int persistence_type, void* persistence_context, MQTTAsync_createOptions* options);
+
/**
* MQTTAsync_willOptions defines the MQTT "Last Will and Testament" (LWT) settings for
* the client. In the event that a client unexpectedly loses its connection to
@@ -578,10 +649,11 @@ typedef struct
{
/** The eyecatcher for this structure. must be MQTC. */
const char struct_id[4];
- /** The version number of this structure. Must be 0, 1 or 2.
+ /** The version number of this structure. Must be 0, 1, 2, 3 or 4.
* 0 signifies no SSL options and no serverURIs
* 1 signifies no serverURIs
* 2 signifies no MQTTVersion
+ * 3 signifies no automatic reconnect options
*/
int struct_version;
/** The "keep alive" interval, measured in seconds, defines the maximum time
@@ -690,10 +762,23 @@ typedef struct
* MQTTVERSION_3_1_1 (4) = only try version 3.1.1
*/
int MQTTVersion;
+ /**
+ * Reconnect automatically in the case of a connection being lost?
+ */
+ int automaticReconnect;
+ /**
+ * Minimum retry interval in seconds. Doubled on each failed retry.
+ */
+ int minRetryInterval;
+ /**
+ * Maximum retry interval in seconds. The doubling stops here on failed retries.
+ */
+ int maxRetryInterval;
} MQTTAsync_connectOptions;
-#define MQTTAsync_connectOptions_initializer { {'M', 'Q', 'T', 'C'}, 3, 60, 1, 10, NULL, NULL, NULL, 30, 0, NULL, NULL, NULL, NULL, 0, NULL, 0}
+#define MQTTAsync_connectOptions_initializer { {'M', 'Q', 'T', 'C'}, 4, 60, 1, 10, NULL, NULL, NULL, 30, 0,\
+NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 1, 60}
/**
* This function attempts to connect a previously-created client (see
@@ -908,10 +993,29 @@ DLLExport int MQTTAsync_sendMessage(MQTTAsync handle, const char* destinationNam
*/
DLLExport int MQTTAsync_getPendingTokens(MQTTAsync handle, MQTTAsync_token **tokens);
+/**
+ * Tests whether a request corresponding to a token is complete.
+ *
+ * @param handle A valid client handle from a successful call to
+ * MQTTAsync_create().
+ * @param token An ::MQTTAsync_token associated with a request.
+ * @return 1 if the request has been completed, 0 if not.
+ */
#define MQTTASYNC_TRUE 1
-DLLExport int MQTTAsync_isComplete(MQTTAsync handle, MQTTAsync_token dt);
+DLLExport int MQTTAsync_isComplete(MQTTAsync handle, MQTTAsync_token token);
-DLLExport int MQTTAsync_waitForCompletion(MQTTAsync handle, MQTTAsync_token dt, unsigned long timeout);
+
+/**
+ * Waits for a request corresponding to a token to complete.
+ *
+ * @param handle A valid client handle from a successful call to
+ * MQTTAsync_create().
+ * @param token An ::MQTTAsync_token associated with a request.
+ * @param timeout the maximum time to wait for completion, in milliseconds
+ * @return ::MQTTASYNC_SUCCESS if the request has been completed in the time allocated,
+ * ::MQTTASYNC_FAILURE if not.
+ */
+DLLExport int MQTTAsync_waitForCompletion(MQTTAsync handle, MQTTAsync_token token, unsigned long timeout);
/**
@@ -1007,10 +1111,20 @@ DLLExport MQTTAsync_nameValue* MQTTAsync_getVersionInfo();
* The client application runs on several threads.
* Processing of handshaking and maintaining
* the network connection is performed in the background.
+ * This API is thread safe: functions may be called by multiple application
+ * threads.
* Notifications of status and message reception are provided to the client
* application using callbacks registered with the library by the call to
* MQTTAsync_setCallbacks() (see MQTTAsync_messageArrived(),
* MQTTAsync_connectionLost() and MQTTAsync_deliveryComplete()).
+ * In addition, some functions allow success and failure callbacks to be set
+ * for individual requests, in the ::MQTTAsync_responseOptions structure. Applications
+ * can be written as a chain of callback functions. Note that it is a theoretically
+ * possible but unlikely event, that a success or failure callback could be called
+ * before function requesting the callback has returned. In this case the token
+ * delivered in the callback would not yet be known to the application program (see
+ * Race condition for MQTTAsync_token in MQTTAsync.c
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=444093)
*
* @page wildcard Subscription wildcards
* Every MQTT message includes a topic that classifies it. MQTT servers use
diff --git a/src/MQTTClient.c b/src/MQTTClient.c
index 0511d58c..b26bd06c 100644
--- a/src/MQTTClient.c
+++ b/src/MQTTClient.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corp.
+ * Copyright (c) 2009, 2015 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -26,6 +26,9 @@
* Rong Xiang, Ian Craggs - C++ compatibility
* Ian Craggs - fix for bug 443724 - stack corruption
* Ian Craggs - fix for bug 447672 - simultaneous access to socket structure
+ * Ian Craggs - fix for bug 459791 - deadlock in WaitForCompletion for bad client
+ * Ian Craggs - fix for bug 474905 - insufficient synchronization for subscribe, unsubscribe, connect
+ * Ian Craggs - make it clear that yield and receive are not intended for multi-threaded mode (bug 474748)
*******************************************************************************/
/**
@@ -59,8 +62,7 @@
#define URI_TCP "tcp://"
-#define BUILD_TIMESTAMP "##MQTTCLIENT_BUILD_TAG##"
-#define CLIENT_VERSION "##MQTTCLIENT_VERSION_TAG##"
+#include "VersionInfo.h"
char* client_timestamp_eye = "MQTTClientV3_Timestamp " BUILD_TIMESTAMP;
char* client_version_eye = "MQTTClientV3_Version " CLIENT_VERSION;
@@ -78,6 +80,9 @@ MQTTProtocol state;
#if defined(WIN32) || defined(WIN64)
static mutex_type mqttclient_mutex = NULL;
static mutex_type socket_mutex = NULL;
+static mutex_type subscribe_mutex = NULL;
+static mutex_type unsubscribe_mutex = NULL;
+static mutex_type connect_mutex = NULL;
extern mutex_type stack_mutex;
extern mutex_type heap_mutex;
extern mutex_type log_mutex;
@@ -92,6 +97,9 @@ BOOL APIENTRY DllMain(HANDLE hModule,
if (mqttclient_mutex == NULL)
{
mqttclient_mutex = CreateMutex(NULL, 0, NULL);
+ subscribe_mutex = CreateMutex(NULL, 0, NULL);
+ unsubscribe_mutex = CreateMutex(NULL, 0, NULL);
+ connect_mutex = CreateMutex(NULL, 0, NULL);
stack_mutex = CreateMutex(NULL, 0, NULL);
heap_mutex = CreateMutex(NULL, 0, NULL);
log_mutex = CreateMutex(NULL, 0, NULL);
@@ -109,9 +117,19 @@ BOOL APIENTRY DllMain(HANDLE hModule,
#else
static pthread_mutex_t mqttclient_mutex_store = PTHREAD_MUTEX_INITIALIZER;
static mutex_type mqttclient_mutex = &mqttclient_mutex_store;
+
static pthread_mutex_t socket_mutex_store = PTHREAD_MUTEX_INITIALIZER;
static mutex_type socket_mutex = &socket_mutex_store;
+static pthread_mutex_t subscribe_mutex_store = PTHREAD_MUTEX_INITIALIZER;
+static mutex_type subscribe_mutex = &subscribe_mutex_store;
+
+static pthread_mutex_t unsubscribe_mutex_store = PTHREAD_MUTEX_INITIALIZER;
+static mutex_type unsubscribe_mutex = &unsubscribe_mutex_store;
+
+static pthread_mutex_t connect_mutex_store = PTHREAD_MUTEX_INITIALIZER;
+static mutex_type connect_mutex = &connect_mutex_store;
+
void MQTTClient_init()
{
pthread_mutexattr_t attr;
@@ -123,6 +141,12 @@ void MQTTClient_init()
printf("MQTTClient: error %d initializing client_mutex\n", rc);
if ((rc = pthread_mutex_init(socket_mutex, &attr)) != 0)
printf("MQTTClient: error %d initializing socket_mutex\n", rc);
+ if ((rc = pthread_mutex_init(subscribe_mutex, &attr)) != 0)
+ printf("MQTTClient: error %d initializing subscribe_mutex\n", rc);
+ if ((rc = pthread_mutex_init(unsubscribe_mutex, &attr)) != 0)
+ printf("MQTTClient: error %d initializing unsubscribe_mutex\n", rc);
+ if ((rc = pthread_mutex_init(connect_mutex, &attr)) != 0)
+ printf("MQTTClient: error %d initializing connect_mutex\n", rc);
}
#define WINAPI
@@ -509,11 +533,7 @@ thread_return_type WINAPI MQTTClient_run(void* n)
if (rc == SOCKET_ERROR)
{
if (m->c->connected)
- {
- Thread_unlock_mutex(mqttclient_mutex);
MQTTClient_disconnect_internal(m, 0);
- Thread_lock_mutex(mqttclient_mutex);
- }
else
{
if (m->c->connect_state == 2 && !Thread_check_sem(m->connect_sem))
@@ -933,11 +953,7 @@ exit:
}
}
else
- {
- Thread_unlock_mutex(mqttclient_mutex);
- MQTTClient_disconnect1(handle, 0, 0, (MQTTVersion == 3)); /* not "internal" because we don't want to call connection lost */
- Thread_lock_mutex(mqttclient_mutex);
- }
+ MQTTClient_disconnect1(handle, 0, 0, (MQTTVersion == 3)); /* don't want to call connection lost */
FUNC_EXIT_RC(rc);
return rc;
}
@@ -1039,6 +1055,7 @@ int MQTTClient_connect(MQTTClient handle, MQTTClient_connectOptions* options)
int rc = SOCKET_ERROR;
FUNC_ENTRY;
+ Thread_lock_mutex(connect_mutex);
Thread_lock_mutex(mqttclient_mutex);
if (options == NULL)
@@ -1113,12 +1130,16 @@ exit:
m->c->will = NULL;
}
Thread_unlock_mutex(mqttclient_mutex);
+ Thread_unlock_mutex(connect_mutex);
FUNC_EXIT_RC(rc);
return rc;
}
-int MQTTClient_disconnect1(MQTTClient handle, int timeout, int internal, int stop)
+/**
+ * mqttclient_mutex must be locked when you call this function, if multi threaded
+ */
+int MQTTClient_disconnect1(MQTTClient handle, int timeout, int call_connection_lost, int stop)
{
MQTTClients* m = handle;
START_TIME_TYPE start;
@@ -1126,8 +1147,6 @@ int MQTTClient_disconnect1(MQTTClient handle, int timeout, int internal, int sto
int was_connected = 0;
FUNC_ENTRY;
- Thread_lock_mutex(mqttclient_mutex);
-
if (m == NULL || m->c == NULL)
{
rc = MQTTCLIENT_FAILURE;
@@ -1166,23 +1185,28 @@ int MQTTClient_disconnect1(MQTTClient handle, int timeout, int internal, int sto
exit:
if (stop)
MQTTClient_stop();
- if (internal && m->cl && was_connected)
+ if (call_connection_lost && m->cl && was_connected)
{
Log(TRACE_MIN, -1, "Calling connectionLost for client %s", m->c->clientID);
Thread_start(connectionLost_call, m);
}
- Thread_unlock_mutex(mqttclient_mutex);
FUNC_EXIT_RC(rc);
return rc;
}
+/**
+ * mqttclient_mutex must be locked when you call this function, if multi threaded
+ */
int MQTTClient_disconnect_internal(MQTTClient handle, int timeout)
{
return MQTTClient_disconnect1(handle, timeout, 1, 1);
}
+/**
+ * mqttclient_mutex must be locked when you call this function, if multi threaded
+ */
void MQTTProtocol_closeSession(Clients* c, int sendwill)
{
MQTTClient_disconnect_internal((MQTTClient)c->context, 0);
@@ -1191,7 +1215,12 @@ void MQTTProtocol_closeSession(Clients* c, int sendwill)
int MQTTClient_disconnect(MQTTClient handle, int timeout)
{
- return MQTTClient_disconnect1(handle, timeout, 0, 1);
+ int rc = 0;
+
+ Thread_lock_mutex(mqttclient_mutex);
+ rc = MQTTClient_disconnect1(handle, timeout, 0, 1);
+ Thread_unlock_mutex(mqttclient_mutex);
+ return rc;
}
@@ -1213,13 +1242,14 @@ int MQTTClient_isConnected(MQTTClient handle)
int MQTTClient_subscribeMany(MQTTClient handle, int count, char* const* topic, int* qos)
{
MQTTClients* m = handle;
- List* topics = ListInitialize();
- List* qoss = ListInitialize();
+ List* topics = NULL;
+ List* qoss = NULL;
int i = 0;
int rc = MQTTCLIENT_FAILURE;
int msgid = 0;
FUNC_ENTRY;
+ Thread_lock_mutex(subscribe_mutex);
Thread_lock_mutex(mqttclient_mutex);
if (m == NULL || m->c == NULL)
@@ -1252,6 +1282,8 @@ int MQTTClient_subscribeMany(MQTTClient handle, int count, char* const* topic, i
goto exit;
}
+ topics = ListInitialize();
+ qoss = ListInitialize();
for (i = 0; i < count; i++)
{
ListAppend(topics, topic[i], strlen(topic[i]));
@@ -1287,16 +1319,13 @@ int MQTTClient_subscribeMany(MQTTClient handle, int count, char* const* topic, i
}
if (rc == SOCKET_ERROR)
- {
- Thread_unlock_mutex(mqttclient_mutex);
MQTTClient_disconnect_internal(handle, 0);
- Thread_lock_mutex(mqttclient_mutex);
- }
else if (rc == TCPSOCKET_COMPLETE)
rc = MQTTCLIENT_SUCCESS;
exit:
Thread_unlock_mutex(mqttclient_mutex);
+ Thread_unlock_mutex(subscribe_mutex);
FUNC_EXIT_RC(rc);
return rc;
}
@@ -1319,12 +1348,13 @@ int MQTTClient_subscribe(MQTTClient handle, const char* topic, int qos)
int MQTTClient_unsubscribeMany(MQTTClient handle, int count, char* const* topic)
{
MQTTClients* m = handle;
- List* topics = ListInitialize();
+ List* topics = NULL;
int i = 0;
int rc = SOCKET_ERROR;
int msgid = 0;
FUNC_ENTRY;
+ Thread_lock_mutex(unsubscribe_mutex);
Thread_lock_mutex(mqttclient_mutex);
if (m == NULL || m->c == NULL)
@@ -1351,6 +1381,7 @@ int MQTTClient_unsubscribeMany(MQTTClient handle, int count, char* const* topic)
goto exit;
}
+ topics = ListInitialize();
for (i = 0; i < count; i++)
ListAppend(topics, topic[i], strlen(topic[i]));
rc = MQTTProtocol_unsubscribe(m->c, topics, msgid);
@@ -1373,14 +1404,11 @@ int MQTTClient_unsubscribeMany(MQTTClient handle, int count, char* const* topic)
}
if (rc == SOCKET_ERROR)
- {
- Thread_unlock_mutex(mqttclient_mutex);
MQTTClient_disconnect_internal(handle, 0);
- Thread_lock_mutex(mqttclient_mutex);
- }
exit:
Thread_unlock_mutex(mqttclient_mutex);
+ Thread_unlock_mutex(unsubscribe_mutex);
FUNC_EXIT_RC(rc);
return rc;
}
@@ -1477,9 +1505,7 @@ int MQTTClient_publish(MQTTClient handle, const char* topicName, int payloadlen,
if (rc == SOCKET_ERROR)
{
- Thread_unlock_mutex(mqttclient_mutex);
MQTTClient_disconnect_internal(handle, 0);
- Thread_lock_mutex(mqttclient_mutex);
/* Return success for qos > 0 as the send will be retried automatically */
rc = (qos > 0) ? MQTTCLIENT_SUCCESS : MQTTCLIENT_FAILURE;
}
@@ -1721,7 +1747,8 @@ int MQTTClient_receive(MQTTClient handle, char** topicName, int* topicLen, MQTTC
MQTTClients* m = handle;
FUNC_ENTRY;
- if (m == NULL || m->c == NULL)
+ if (m == NULL || m->c == NULL
+ || running) /* receive is not meant to be called in a multi-thread environment */
{
rc = MQTTCLIENT_FAILURE;
goto exit;
@@ -1775,7 +1802,7 @@ void MQTTClient_yield(void)
int rc = 0;
FUNC_ENTRY;
- if (running)
+ if (running) /* yield is not meant to be called in a multi-thread environment */
{
MQTTClient_sleep(timeout);
goto exit;
@@ -1786,12 +1813,14 @@ void MQTTClient_yield(void)
{
int sock = -1;
MQTTClient_cycle(&sock, (timeout > elapsed) ? timeout - elapsed : 0L, &rc);
+ Thread_lock_mutex(mqttclient_mutex);
if (rc == SOCKET_ERROR && ListFindItem(handles, &sock, clientSockCompare))
{
MQTTClients* m = (MQTTClient)(handles->current->content);
if (m->c->connect_state != -2)
MQTTClient_disconnect_internal(m, 0);
}
+ Thread_unlock_mutex(mqttclient_mutex);
elapsed = MQTTClient_elapsed(start);
}
while (elapsed < timeout);
diff --git a/src/MQTTClient.h b/src/MQTTClient.h
index 21b74d7b..de6e87b3 100644
--- a/src/MQTTClient.h
+++ b/src/MQTTClient.h
@@ -33,7 +33,9 @@
*
* Both libraries are designed to be sparing in the use of threads. So multiple client objects are
* handled by one or two threads, with a select call in Socket_getReadySocket(), used to determine
- * when a socket has incoming data.
+ * when a socket has incoming data. This API is thread safe: functions may be called by multiple application
+ * threads, with the exception of ::MQTTClient_yield and ::MQTTClient_receive, which are intended
+ * for single threaded environments only.
*
* @endcond
* @cond MQTTClient_main
@@ -47,6 +49,7 @@
* totally asynchronous API where no calls block, which is especially suitable
* for use in windowed environments, see the
* MQTT C Client Asynchronous API Documentation.
+ * The MQTTClient API is not thread safe, whereas the MQTTAsync API is.
*
* An MQTT client application connects to MQTT-capable servers.
* A typical client is responsible for collecting information from a telemetry
@@ -936,7 +939,7 @@ DLLExport void MQTTClient_destroy(MQTTClient* handle);
* (see @ref qos) message has been successfully delivered, the application
* must call the MQTTClient_waitForCompletion() function. An example showing
* synchronous publication is shown in @ref pubsync. Receiving messages in
- * synchronous mode uses the MQTTClient_receive() function. Client applicaitons
+ * synchronous mode uses the MQTTClient_receive() function. Client applications
* must call either MQTTClient_receive() or MQTTClient_yield() relatively
* frequently in order to allow processing of acknowledgements and the MQTT
* "pings" that keep the network connection to the server alive.
@@ -949,6 +952,8 @@ DLLExport void MQTTClient_destroy(MQTTClient* handle);
* application using callbacks registered with the library by the call to
* MQTTClient_setCallbacks() (see MQTTClient_messageArrived(),
* MQTTClient_connectionLost() and MQTTClient_deliveryComplete()).
+ * This API is not thread safe however - it is not possible to call it from multiple
+ * threads without synchronization. You can use the MQTTAsync API for that.
*
* @page wildcard Subscription wildcards
* Every MQTT message includes a topic that classifies it. MQTT servers use
diff --git a/src/MQTTPacket.c b/src/MQTTPacket.c
old mode 100644
new mode 100755
index be8f80fb..3c58b724
--- a/src/MQTTPacket.c
+++ b/src/MQTTPacket.c
@@ -96,10 +96,10 @@ void* MQTTPacket_Factory(networkHandles* net, int* error)
{
char* data = NULL;
static Header header;
- int remaining_length, ptype;
- size_t remaining_length_new;
+ size_t remaining_length;
+ int ptype;
void* pack = NULL;
- int actual_len = 0;
+ size_t actual_len = 0;
FUNC_ENTRY;
*error = SOCKET_ERROR; /* indicate whether an error occurred, or not */
@@ -148,9 +148,8 @@ void* MQTTPacket_Factory(networkHandles* net, int* error)
char *buf = malloc(10);
buf[0] = header.byte;
buf0len = 1 + MQTTPacket_encode(&buf[1], remaining_length);
- remaining_length_new = remaining_length;
*error = MQTTPersistence_put(net->socket, buf, buf0len, 1,
- &data, &remaining_length_new, header.bits.type, ((Publish *)pack)->msgId, 1);
+ &data, &remaining_length, header.bits.type, ((Publish *)pack)->msgId, 1);
free(buf);
}
#endif
@@ -174,7 +173,8 @@ exit:
*/
int MQTTPacket_send(networkHandles* net, Header header, char* buffer, size_t buflen, int free)
{
- int rc, buf0len;
+ int rc;
+ size_t buf0len;
char *buf;
FUNC_ENTRY;
@@ -220,7 +220,8 @@ int MQTTPacket_send(networkHandles* net, Header header, char* buffer, size_t buf
*/
int MQTTPacket_sends(networkHandles* net, Header header, int count, char** buffers, size_t* buflens, int* frees)
{
- int i, rc, buf0len, total = 0;
+ int i, rc;
+ size_t buf0len, total = 0;
char *buf;
FUNC_ENTRY;
@@ -261,7 +262,7 @@ int MQTTPacket_sends(networkHandles* net, Header header, int count, char** buffe
* @param length the length to be encoded
* @return the number of bytes written to buffer
*/
-int MQTTPacket_encode(char* buf, int length)
+int MQTTPacket_encode(char* buf, size_t length)
{
int rc = 0;
@@ -286,7 +287,7 @@ int MQTTPacket_encode(char* buf, int length)
* @param value the decoded length returned
* @return the number of bytes read from the socket
*/
-int MQTTPacket_decode(networkHandles* net, int* value)
+int MQTTPacket_decode(networkHandles* net, size_t* value)
{
int rc = SOCKET_ERROR;
char c;
@@ -429,8 +430,8 @@ void writeInt(char** pptr, int anInt)
*/
void writeUTF(char** pptr, const char* string)
{
- int len = strlen(string);
- writeInt(pptr, len);
+ size_t len = strlen(string);
+ writeInt(pptr, (int)len);
memcpy(*pptr, string, len);
*pptr += len;
}
@@ -497,7 +498,7 @@ void* MQTTPacket_publish(unsigned char aHeader, char* data, size_t datalen)
else
pack->msgId = 0;
pack->payload = curdata;
- pack->payloadlen = datalen-(curdata-data);
+ pack->payloadlen = (int)(datalen-(curdata-data));
exit:
FUNC_EXIT;
return pack;
@@ -691,7 +692,7 @@ int MQTTPacket_send_publish(Publish* pack, int dup, int qos, int retained, netwo
writeInt(&ptr, pack->msgId);
ptr = topiclen;
- writeInt(&ptr, lens[1]);
+ writeInt(&ptr, (int)lens[1]);
rc = MQTTPacket_sends(net, header, 4, bufs, lens, frees);
if (rc != TCPSOCKET_INTERRUPTED)
free(buf);
@@ -703,7 +704,7 @@ int MQTTPacket_send_publish(Publish* pack, int dup, int qos, int retained, netwo
size_t lens[3] = {2, strlen(pack->topic), pack->payloadlen};
int frees[3] = {1, 0, 0};
- writeInt(&ptr, lens[1]);
+ writeInt(&ptr, (int)lens[1]);
rc = MQTTPacket_sends(net, header, 3, bufs, lens, frees);
}
if (rc != TCPSOCKET_INTERRUPTED)
diff --git a/src/MQTTPacket.h b/src/MQTTPacket.h
old mode 100644
new mode 100755
index 538e9b0f..01ebd2cb
--- a/src/MQTTPacket.h
+++ b/src/MQTTPacket.h
@@ -216,8 +216,8 @@ typedef Ack Pubrel;
typedef Ack Pubcomp;
typedef Ack Unsuback;
-int MQTTPacket_encode(char* buf, int length);
-int MQTTPacket_decode(networkHandles* net, int* value);
+int MQTTPacket_encode(char* buf, size_t length);
+int MQTTPacket_decode(networkHandles* net, size_t* value);
int readInt(char** pptr);
char* readUTF(char** pptr, char* enddata);
unsigned char readChar(char** pptr);
diff --git a/src/MQTTPacketOut.c b/src/MQTTPacketOut.c
old mode 100644
new mode 100755
index 9cae93ff..dff34545
--- a/src/MQTTPacketOut.c
+++ b/src/MQTTPacketOut.c
@@ -51,13 +51,13 @@ int MQTTPacket_send_connect(Clients* client, int MQTTVersion)
packet.header.byte = 0;
packet.header.bits.type = CONNECT;
- len = ((MQTTVersion == 3) ? 12 : 10) + strlen(client->clientID)+2;
+ len = ((MQTTVersion == 3) ? 12 : 10) + (int)strlen(client->clientID)+2;
if (client->will)
- len += strlen(client->will->topic)+2 + strlen(client->will->msg)+2;
+ len += (int)strlen(client->will->topic)+2 + (int)strlen(client->will->msg)+2;
if (client->username)
- len += strlen(client->username)+2;
+ len += (int)strlen(client->username)+2;
if (client->password)
- len += strlen(client->password)+2;
+ len += (int)strlen(client->password)+2;
ptr = buf = malloc(len);
if (MQTTVersion == 3)
@@ -179,7 +179,7 @@ int MQTTPacket_send_subscribe(List* topics, List* qoss, int msgid, int dup, netw
datalen = 2 + topics->count * 3; // utf length + char qos == 3
while (ListNextElement(topics, &elem))
- datalen += strlen((char*)(elem->content));
+ datalen += (int)strlen((char*)(elem->content));
ptr = data = malloc(datalen);
writeInt(&ptr, msgid);
@@ -252,7 +252,7 @@ int MQTTPacket_send_unsubscribe(List* topics, int msgid, int dup, networkHandles
datalen = 2 + topics->count * 2; // utf length == 2
while (ListNextElement(topics, &elem))
- datalen += strlen((char*)(elem->content));
+ datalen += (int)strlen((char*)(elem->content));
ptr = data = malloc(datalen);
writeInt(&ptr, msgid);
diff --git a/src/MQTTPersistence.c b/src/MQTTPersistence.c
old mode 100644
new mode 100755
index 10f965ce..9bc3d99c
--- a/src/MQTTPersistence.c
+++ b/src/MQTTPersistence.c
@@ -350,13 +350,13 @@ int MQTTPersistence_put(int socket, char* buf0, size_t buf0len, int count,
{
key = malloc(MESSAGE_FILENAME_LENGTH + 1);
nbufs = 1 + count;
- lens = (int *) malloc(nbufs * sizeof(int));
+ lens = (int *)malloc(nbufs * sizeof(int));
bufs = (char **)malloc(nbufs * sizeof(char *));
- lens[0] = buf0len;
+ lens[0] = (int)buf0len;
bufs[0] = buf0;
for (i = 0; i < count; i++)
{
- lens[i+1] = buflens[i];
+ lens[i+1] = (int)buflens[i];
bufs[i+1] = buffers[i];
}
@@ -512,7 +512,7 @@ int MQTTPersistence_persistQueueEntry(Clients* aclient, MQTTPersistence_qEntry*
lens[bufindex++] = sizeof(qe->msg->msgid);
bufs[bufindex] = qe->topicName;
- lens[bufindex++] = strlen(qe->topicName) + 1;
+ lens[bufindex++] = (int)strlen(qe->topicName) + 1;
bufs[bufindex] = &qe->topicLen;
lens[bufindex++] = sizeof(qe->topicLen);
@@ -564,7 +564,7 @@ MQTTPersistence_qEntry* MQTTPersistence_restoreQueueEntry(char* buffer, size_t b
qe->msg->msgid = *(int*)ptr;
ptr += sizeof(int);
- data_size = strlen(ptr) + 1;
+ data_size = (int)strlen(ptr) + 1;
qe->topicName = malloc(data_size);
strcpy(qe->topicName, ptr);
ptr += data_size;
diff --git a/src/MQTTPersistenceDefault.c b/src/MQTTPersistenceDefault.c
old mode 100644
new mode 100755
index 90e1c8b8..0f4f163c
--- a/src/MQTTPersistenceDefault.c
+++ b/src/MQTTPersistenceDefault.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corp.
+ * Copyright (c) 2009, 2016 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -13,6 +13,7 @@
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
* Ian Craggs - async client updates
+ * Ian Craggs - fix for bug 484496
*******************************************************************************/
/**
@@ -73,8 +74,8 @@ int pstopen(void **handle, const char* clientID, const char* serverURI, void* co
/* Note that serverURI=address:port, but ":" not allowed in Windows directories */
perserverURI = malloc(strlen(serverURI) + 1);
strcpy(perserverURI, serverURI);
- ptraux = strstr(perserverURI, ":");
- *ptraux = '-' ;
+ while ((ptraux = strstr(perserverURI, ":")) != NULL)
+ *ptraux = '-' ;
/* consider '/' + '-' + '\0' */
clientDir = malloc(strlen(dataDir) + strlen(clientID) + strlen(perserverURI) + 3);
@@ -148,8 +149,8 @@ int pstput(void* handle, char* key, int bufcount, char* buffers[], int buflens[]
char *clientDir = handle;
char *file;
FILE *fp;
- int bytesWritten = 0;
- int bytesTotal = 0;
+ size_t bytesWritten = 0,
+ bytesTotal = 0;
int i;
FUNC_ENTRY;
@@ -169,14 +170,14 @@ int pstput(void* handle, char* key, int bufcount, char* buffers[], int buflens[]
for(i=0; irefcount = 1;
- *len = strlen(publish->topic)+1;
+ *len = (int)strlen(publish->topic)+1;
if (Heap_findItem(publish->topic))
p->topic = publish->topic;
else
diff --git a/src/MQTTProtocolOut.c b/src/MQTTProtocolOut.c
old mode 100644
new mode 100755
index c9d0d103..b754c79d
--- a/src/MQTTProtocolOut.c
+++ b/src/MQTTProtocolOut.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corp.
+ * Copyright (c) 2009, 2016 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -16,6 +16,7 @@
* Ian Craggs - fix for buffer overflow in addressPort bug #433290
* Ian Craggs - MQTT 3.1.1 support
* Rong Xiang, Ian Craggs - C++ compatibility
+ * Ian Craggs - fix for bug 479376
*******************************************************************************/
/**
@@ -45,7 +46,7 @@ char* MQTTProtocol_addressPort(const char* uri, int* port)
{
char* colon_pos = strrchr(uri, ':'); /* reverse find to allow for ':' in IPv6 addresses */
char* buf = (char*)uri;
- int len;
+ size_t len;
FUNC_ENTRY;
if (uri[0] == '[')
@@ -56,7 +57,7 @@ char* MQTTProtocol_addressPort(const char* uri, int* port)
if (colon_pos)
{
- int addr_len = colon_pos - uri;
+ size_t addr_len = colon_pos - uri;
buf = malloc(addr_len + 1);
*port = atoi(colon_pos + 1);
MQTTStrncpy(buf, uri, addr_len+1);
@@ -102,7 +103,7 @@ int MQTTProtocol_connect(const char* ip_address, Clients* aClient, int MQTTVersi
#if defined(OPENSSL)
if (ssl)
{
- if (SSLSocket_setSocketForSSL(&aClient->net, aClient->sslopts) != 1)
+ if (SSLSocket_setSocketForSSL(&aClient->net, aClient->sslopts) == 1)
{
rc = SSLSocket_connect(aClient->net.ssl, aClient->net.socket);
if (rc == -1)
diff --git a/src/MQTTVersion.c b/src/MQTTVersion.c
old mode 100644
new mode 100755
index 32be1b3c..6976e7c5
--- a/src/MQTTVersion.c
+++ b/src/MQTTVersion.c
@@ -71,7 +71,7 @@ char* FindString(char* filename, char* eyecatcher_input)
memset(value, 0, 100);
if ((infile = fopen(filename, "rb")) != NULL)
{
- int buflen = strlen(eyecatcher);
+ size_t buflen = strlen(eyecatcher);
char* buffer = (char*) malloc(buflen);
int count = 0;
int c = fgetc(infile);
diff --git a/src/SSLSocket.c b/src/SSLSocket.c
old mode 100644
new mode 100755
index 20e09337..e05fcbe2
--- a/src/SSLSocket.c
+++ b/src/SSLSocket.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corp.
+ * Copyright (c) 2009, 2016 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -14,6 +14,8 @@
* Ian Craggs, Allan Stockdill-Mander - initial implementation
* Ian Craggs - fix for bug #409702
* Ian Craggs - allow compilation for OpenSSL < 1.0
+ * Ian Craggs - fix for bug #453883
+ * Ian Craggs - fix for bug #480363, issue 13
*******************************************************************************/
/**
@@ -294,7 +296,7 @@ int pem_passwd_cb(char* buf, int size, int rwflag, void* userdata)
{
strncpy(buf, (char*)(userdata), size);
buf[size-1] = '\0';
- rc = strlen(buf);
+ rc = (int)strlen(buf);
}
FUNC_EXIT_RC(rc);
return rc;
@@ -353,7 +355,6 @@ void SSL_destroy_mutex(ssl_mutex_type* mutex)
rc = CloseHandle(*mutex);
#else
rc = pthread_mutex_destroy(mutex);
- free(mutex);
#endif
FUNC_EXIT_RC(rc);
}
@@ -382,10 +383,13 @@ extern unsigned long SSLThread_id(void)
extern void SSLLocks_callback(int mode, int n, const char *file, int line)
{
- if (mode & CRYPTO_LOCK)
- SSL_lock_mutex(&sslLocks[n]);
- else
- SSL_unlock_mutex(&sslLocks[n]);
+ if (sslLocks)
+ {
+ if (mode & CRYPTO_LOCK)
+ SSL_lock_mutex(&sslLocks[n]);
+ else
+ SSL_unlock_mutex(&sslLocks[n]);
+ }
}
int SSLSocket_initialize()
@@ -442,7 +446,19 @@ exit:
void SSLSocket_terminate()
{
FUNC_ENTRY;
- free(sslLocks);
+ EVP_cleanup();
+ ERR_free_strings();
+ CRYPTO_set_locking_callback(NULL);
+ if (sslLocks)
+ {
+ int i = 0;
+
+ for (i = 0; i < CRYPTO_num_locks(); i++)
+ {
+ SSL_destroy_mutex(&sslLocks[i]);
+ }
+ free(sslLocks);
+ }
FUNC_EXIT;
}
@@ -628,7 +644,7 @@ exit:
* @param actual_len the actual number of bytes read
* @return completion code
*/
-char *SSLSocket_getdata(SSL* ssl, int socket, int bytes, int* actual_len)
+char *SSLSocket_getdata(SSL* ssl, int socket, size_t bytes, size_t* actual_len)
{
int rc;
char* buf;
@@ -642,7 +658,7 @@ char *SSLSocket_getdata(SSL* ssl, int socket, int bytes, int* actual_len)
buf = SocketBuffer_getQueuedData(socket, bytes, actual_len);
- if ((rc = SSL_read(ssl, buf + (*actual_len), (size_t)(bytes - (*actual_len)))) < 0)
+ if ((rc = SSL_read(ssl, buf + (*actual_len), (int)(bytes - (*actual_len)))) < 0)
{
rc = SSLSocket_error("SSL_read - getdata", ssl, socket, rc);
if (rc != SSL_ERROR_WANT_READ && rc != SSL_ERROR_WANT_WRITE)
@@ -714,9 +730,9 @@ int SSLSocket_putdatas(SSL* ssl, int socket, char* buf0, size_t buf0len, int cou
int sslerror;
FUNC_ENTRY;
- iovec.iov_len = buf0len;
+ iovec.iov_len = (ULONG)buf0len;
for (i = 0; i < count; i++)
- iovec.iov_len += buflens[i];
+ iovec.iov_len += (ULONG)buflens[i];
ptr = iovec.iov_base = (char *)malloc(iovec.iov_len);
memcpy(ptr, buf0, buf0len);
diff --git a/src/SSLSocket.h b/src/SSLSocket.h
old mode 100644
new mode 100755
index 465361fc..74dc1fcb
--- a/src/SSLSocket.h
+++ b/src/SSLSocket.h
@@ -34,7 +34,7 @@ int SSLSocket_initialize();
void SSLSocket_terminate();
int SSLSocket_setSocketForSSL(networkHandles* net, MQTTClient_SSLOptions* opts);
int SSLSocket_getch(SSL* ssl, int socket, char* c);
-char *SSLSocket_getdata(SSL* ssl, int socket, int bytes, int* actual_len);
+char *SSLSocket_getdata(SSL* ssl, int socket, size_t bytes, size_t* actual_len);
int SSLSocket_close(networkHandles* net);
int SSLSocket_putdatas(SSL* ssl, int socket, char* buf0, size_t buf0len, int count, char** buffers, size_t* buflens, int* frees);
diff --git a/src/Socket.c b/src/Socket.c
old mode 100644
new mode 100755
index 8475ae2b..536fb054
--- a/src/Socket.c
+++ b/src/Socket.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corp.
+ * Copyright (c) 2009, 2016 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -13,6 +13,7 @@
* Contributors:
* Ian Craggs - initial implementation and documentation
* Ian Craggs - async client updates
+ * Ian Craggs - fix for bug 484496
*******************************************************************************/
/**
@@ -328,7 +329,7 @@ exit:
* @param actual_len the actual number of bytes read
* @return completion code
*/
-char *Socket_getdata(int socket, int bytes, int* actual_len)
+char *Socket_getdata(int socket, size_t bytes, size_t* actual_len)
{
int rc;
char* buf;
@@ -342,7 +343,7 @@ char *Socket_getdata(int socket, int bytes, int* actual_len)
buf = SocketBuffer_getQueuedData(socket, bytes, actual_len);
- if ((rc = recv(socket, buf + (*actual_len), (size_t)(bytes - (*actual_len)), 0)) == SOCKET_ERROR)
+ if ((rc = recv(socket, buf + (*actual_len), (int)(bytes - (*actual_len)), 0)) == SOCKET_ERROR)
{
rc = Socket_error("recv - getdata", socket);
if (rc != EAGAIN && rc != EWOULDBLOCK)
@@ -438,7 +439,8 @@ int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** bu
unsigned long bytes = 0L;
iobuf iovecs[5];
int frees1[5];
- int rc = TCPSOCKET_INTERRUPTED, i, total = buf0len;
+ int rc = TCPSOCKET_INTERRUPTED, i;
+ size_t total = buf0len;
FUNC_ENTRY;
if (!Socket_noPendingWrites(socket))
@@ -452,12 +454,12 @@ int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** bu
total += buflens[i];
iovecs[0].iov_base = buf0;
- iovecs[0].iov_len = buf0len;
+ iovecs[0].iov_len = (ULONG)buf0len;
frees1[0] = 1;
for (i = 0; i < count; i++)
{
iovecs[i+1].iov_base = buffers[i];
- iovecs[i+1].iov_len = buflens[i];
+ iovecs[i+1].iov_len = (ULONG)buflens[i];
frees1[i+1] = frees[i];
}
@@ -600,6 +602,7 @@ int Socket_new(char* addr, int port, int* sock)
FUNC_ENTRY;
*sock = -1;
+ memset(&address6, '\0', sizeof(address6));
if (addr[0] == '[')
++addr;
@@ -608,34 +611,30 @@ int Socket_new(char* addr, int port, int* sock)
{
struct addrinfo* res = result;
- /* prefer ip4 addresses */
while (res)
- {
- if (res->ai_family == AF_INET)
- {
- result = res;
+ { /* prefer ip4 addresses */
+ if (res->ai_family == AF_INET || res->ai_next == NULL)
break;
- }
res = res->ai_next;
}
- if (result == NULL)
+ if (res == NULL)
rc = -1;
else
#if defined(AF_INET6)
- if (result->ai_family == AF_INET6)
+ if (res->ai_family == AF_INET6)
{
address6.sin6_port = htons(port);
address6.sin6_family = family = AF_INET6;
- address6.sin6_addr = ((struct sockaddr_in6*)(result->ai_addr))->sin6_addr;
+ memcpy(&address6.sin6_addr, &((struct sockaddr_in6*)(res->ai_addr))->sin6_addr, sizeof(address6.sin6_addr));
}
else
#endif
- if (result->ai_family == AF_INET)
+ if (res->ai_family == AF_INET)
{
address.sin_port = htons(port);
address.sin_family = family = AF_INET;
- address.sin_addr = ((struct sockaddr_in*)(result->ai_addr))->sin_addr;
+ address.sin_addr = ((struct sockaddr_in*)(res->ai_addr))->sin_addr;
}
else
rc = -1;
@@ -649,7 +648,7 @@ int Socket_new(char* addr, int port, int* sock)
Log(LOG_ERROR, -1, "%s is not a valid IP address", addr);
else
{
- *sock = socket(family, type, 0);
+ *sock = (int)socket(family, type, 0);
if (*sock == INVALID_SOCKET)
rc = Socket_error("socket", *sock);
else
@@ -733,8 +732,8 @@ int Socket_continueWrite(int socket)
else if (pw->bytes < curbuflen + pw->iovecs[i].iov_len)
{ /* if previously written length is in the middle of the buffer we are currently looking at,
add some of the buffer */
- int offset = pw->bytes - curbuflen;
- iovecs1[++curbuf].iov_len = pw->iovecs[i].iov_len - offset;
+ size_t offset = pw->bytes - curbuflen;
+ iovecs1[++curbuf].iov_len = pw->iovecs[i].iov_len - (ULONG)offset;
iovecs1[curbuf].iov_base = pw->iovecs[i].iov_base + offset;
break;
}
diff --git a/src/Socket.h b/src/Socket.h
old mode 100644
new mode 100755
index b991fe25..e1ab2912
--- a/src/Socket.h
+++ b/src/Socket.h
@@ -51,6 +51,7 @@
#include
#include
#include
+#define ULONG size_t
#endif
/** socket operation completed successfully */
@@ -114,7 +115,7 @@ void Socket_outInitialize(void);
void Socket_outTerminate(void);
int Socket_getReadySocket(int more_work, struct timeval *tp);
int Socket_getch(int socket, char* c);
-char *Socket_getdata(int socket, int bytes, int* actual_len);
+char *Socket_getdata(int socket, size_t bytes, size_t* actual_len);
int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** buffers, size_t* buflens, int* frees);
void Socket_close(int socket);
int Socket_new(char* addr, int port, int* socket);
diff --git a/src/SocketBuffer.c b/src/SocketBuffer.c
old mode 100644
new mode 100755
index 2a45b3d7..e4ce756f
--- a/src/SocketBuffer.c
+++ b/src/SocketBuffer.c
@@ -73,7 +73,8 @@ void SocketBuffer_newDefQ(void)
def_queue = malloc(sizeof(socket_queue));
def_queue->buflen = 1000;
def_queue->buf = malloc(def_queue->buflen);
- def_queue->socket = def_queue->index = def_queue->buflen = def_queue->datalen = 0;
+ def_queue->socket = def_queue->index = 0;
+ def_queue->buflen = def_queue->datalen = 0;
}
@@ -130,7 +131,10 @@ void SocketBuffer_cleanup(int socket)
ListRemove(queues, queues->current->content);
}
if (def_queue->socket == socket)
- def_queue->socket = def_queue->index = def_queue->headerlen = def_queue->datalen = 0;
+ {
+ def_queue->socket = def_queue->index = 0;
+ def_queue->headerlen = def_queue->datalen = 0;
+ }
FUNC_EXIT;
}
@@ -142,7 +146,7 @@ void SocketBuffer_cleanup(int socket)
* @param actual_len the actual length returned
* @return the actual data
*/
-char* SocketBuffer_getQueuedData(int socket, int bytes, int* actual_len)
+char* SocketBuffer_getQueuedData(int socket, size_t bytes, size_t* actual_len)
{
socket_queue* queue = NULL;
@@ -215,7 +219,7 @@ exit:
* @param socket the socket to get queued data for
* @param actual_len the actual length of data that was read
*/
-void SocketBuffer_interrupted(int socket, int actual_len)
+void SocketBuffer_interrupted(int socket, size_t actual_len)
{
socket_queue* queue = NULL;
@@ -249,7 +253,8 @@ char* SocketBuffer_complete(int socket)
def_queue = queue;
ListDetach(queues, queue);
}
- def_queue->socket = def_queue->index = def_queue->headerlen = def_queue->datalen = 0;
+ def_queue->socket = def_queue->index = 0;
+ def_queue->headerlen = def_queue->datalen = 0;
FUNC_EXIT;
return def_queue->buf;
}
@@ -271,7 +276,8 @@ void SocketBuffer_queueChar(int socket, char c)
else if (def_queue->socket == 0)
{
def_queue->socket = socket;
- def_queue->index = def_queue->datalen = 0;
+ def_queue->index = 0;
+ def_queue->datalen = 0;
}
else if (def_queue->socket != socket)
{
@@ -302,9 +308,9 @@ void SocketBuffer_queueChar(int socket, char c)
* @param bytes actual data length that was written
*/
#if defined(OPENSSL)
-void SocketBuffer_pendingWrite(int socket, SSL* ssl, int count, iobuf* iovecs, int* frees, int total, int bytes)
+void SocketBuffer_pendingWrite(int socket, SSL* ssl, int count, iobuf* iovecs, int* frees, size_t total, size_t bytes)
#else
-void SocketBuffer_pendingWrite(int socket, int count, iobuf* iovecs, int* frees, int total, int bytes)
+void SocketBuffer_pendingWrite(int socket, int count, iobuf* iovecs, int* frees, size_t total, size_t bytes)
#endif
{
int i = 0;
diff --git a/src/SocketBuffer.h b/src/SocketBuffer.h
old mode 100644
new mode 100755
index 47c3f198..f7702dc8
--- a/src/SocketBuffer.h
+++ b/src/SocketBuffer.h
@@ -37,20 +37,22 @@
typedef struct
{
int socket;
- int index, headerlen;
+ unsigned int index;
+ size_t headerlen;
char fixed_header[5]; /**< header plus up to 4 length bytes */
- int buflen, /**< total length of the buffer */
+ size_t buflen, /**< total length of the buffer */
datalen; /**< current length of data in buf */
char* buf;
} socket_queue;
typedef struct
{
- int socket, total, count;
+ int socket, count;
+ size_t total;
#if defined(OPENSSL)
SSL* ssl;
#endif
- unsigned long bytes;
+ size_t bytes;
iobuf iovecs[5];
int frees[5];
} pending_writes;
@@ -64,16 +66,16 @@ typedef struct
void SocketBuffer_initialize(void);
void SocketBuffer_terminate(void);
void SocketBuffer_cleanup(int socket);
-char* SocketBuffer_getQueuedData(int socket, int bytes, int* actual_len);
+char* SocketBuffer_getQueuedData(int socket, size_t bytes, size_t* actual_len);
int SocketBuffer_getQueuedChar(int socket, char* c);
-void SocketBuffer_interrupted(int socket, int actual_len);
+void SocketBuffer_interrupted(int socket, size_t actual_len);
char* SocketBuffer_complete(int socket);
void SocketBuffer_queueChar(int socket, char c);
#if defined(OPENSSL)
-void SocketBuffer_pendingWrite(int socket, SSL* ssl, int count, iobuf* iovecs, int* frees, int total, int bytes);
+void SocketBuffer_pendingWrite(int socket, SSL* ssl, int count, iobuf* iovecs, int* frees, size_t total, size_t bytes);
#else
-void SocketBuffer_pendingWrite(int socket, int count, iobuf* iovecs, int* frees, int total, int bytes);
+void SocketBuffer_pendingWrite(int socket, int count, iobuf* iovecs, int* frees, size_t total, size_t bytes);
#endif
pending_writes* SocketBuffer_getWrite(int socket);
int SocketBuffer_writeComplete(int socket);
diff --git a/src/Thread.h b/src/Thread.h
index 0485088c..6da5ab48 100644
--- a/src/Thread.h
+++ b/src/Thread.h
@@ -20,7 +20,7 @@
#define THREAD_H
#if defined(WIN32) || defined(WIN64)
- #include
+ #include
#define thread_type HANDLE
#define thread_id_type DWORD
#define thread_return_type DWORD
diff --git a/src/Tree.c b/src/Tree.c
old mode 100644
new mode 100755
index d3aafc4d..b8c719ca
--- a/src/Tree.c
+++ b/src/Tree.c
@@ -189,7 +189,7 @@ void TreeBalanceAfterAdd(Tree* aTree, Node* curnode, int index)
* @param content the list item content itself
* @param size the size of the element
*/
-void* TreeAddByIndex(Tree* aTree, void* content, int size, int index)
+void* TreeAddByIndex(Tree* aTree, void* content, size_t size, int index)
{
Node* curparent = NULL;
Node* curnode = aTree->index[index].root;
@@ -249,7 +249,7 @@ void* TreeAddByIndex(Tree* aTree, void* content, int size, int index)
}
-void* TreeAdd(Tree* aTree, void* content, int size)
+void* TreeAdd(Tree* aTree, void* content, size_t size)
{
void* rc = NULL;
int i;
@@ -399,7 +399,7 @@ void* TreeRemoveNodeIndex(Tree* aTree, Node* curnode, int index)
{
Node* redundant = curnode;
Node* curchild = NULL;
- int size = curnode->size;
+ size_t size = curnode->size;
void* content = curnode->content;
/* if the node to remove has 0 or 1 children, it can be removed without involving another node */
diff --git a/src/Tree.h b/src/Tree.h
old mode 100644
new mode 100755
index 40a39a36..3d8c2f72
--- a/src/Tree.h
+++ b/src/Tree.h
@@ -18,6 +18,8 @@
#if !defined(TREE_H)
#define TREE_H
+#include // for size_t definition
+
/*BE
defm defTree(T) // macro to define a tree
@@ -63,7 +65,7 @@ typedef struct NodeStruct
struct NodeStruct *parent, /**< pointer to parent tree node, in case we need it */
*child[2]; /**< pointers to child tree nodes 0 = left, 1 = right */
void* content; /**< pointer to element content */
- int size; /**< size of content */
+ size_t size; /**< size of content */
unsigned int red : 1;
} Node;
@@ -78,9 +80,9 @@ typedef struct
Node *root; /**< root node pointer */
int (*compare)(void*, void*, int); /**< comparison function */
} index[2];
- int indexes, /**< no of indexes into tree */
- count, /**< no of items */
- size; /**< heap storage used */
+ int indexes, /**< no of indexes into tree */
+ count; /**< no of items */
+ size_t size; /**< heap storage used */
unsigned int heap_tracking : 1; /**< switch on heap tracking for this tree? */
unsigned int allow_duplicates : 1; /**< switch to allow duplicate entries */
} Tree;
@@ -90,7 +92,7 @@ Tree* TreeInitialize(int(*compare)(void*, void*, int));
void TreeInitializeNoMalloc(Tree* aTree, int(*compare)(void*, void*, int));
void TreeAddIndex(Tree* aTree, int(*compare)(void*, void*, int));
-void* TreeAdd(Tree* aTree, void* content, int size);
+void* TreeAdd(Tree* aTree, void* content, size_t size);
void* TreeRemove(Tree* aTree, void* content);
diff --git a/src/VersionInfo.h.in b/src/VersionInfo.h.in
new file mode 100644
index 00000000..5b91bf3a
--- /dev/null
+++ b/src/VersionInfo.h.in
@@ -0,0 +1,7 @@
+#ifndef VERSIONINFO_H
+#define VERSIONINFO_H
+
+#define BUILD_TIMESTAMP "@BUILD_TIMESTAMP@"
+#define CLIENT_VERSION "@CLIENT_VERSION@"
+
+#endif /* VERSIONINFO_H */
diff --git a/src/samples/CMakeLists.txt b/src/samples/CMakeLists.txt
new file mode 100644
index 00000000..b51056ae
--- /dev/null
+++ b/src/samples/CMakeLists.txt
@@ -0,0 +1,61 @@
+#*******************************************************************************
+# Copyright (c) 2015, 2016 logi.cals GmbH
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# and Eclipse Distribution License v1.0 which accompany this distribution.
+#
+# The Eclipse Public License is available at
+# http://www.eclipse.org/legal/epl-v10.html
+# and the Eclipse Distribution License is available at
+# http://www.eclipse.org/org/documents/edl-v10.php.
+#
+# Contributors:
+# Rainer Poisel - initial version
+# Ian Craggs - update sample names
+#*******************************************************************************/
+
+# Note: on OS X you should install XCode and the associated command-line tools
+
+## compilation/linkage settings
+INCLUDE_DIRECTORIES(
+ .
+ ${CMAKE_SOURCE_DIR}/src
+ ${CMAKE_BINARY_DIR}
+ )
+
+# sample files c
+ADD_EXECUTABLE(paho_c_pub paho_c_pub.c)
+ADD_EXECUTABLE(paho_c_sub paho_c_sub.c)
+ADD_EXECUTABLE(paho_cs_pub paho_cs_pub.c)
+ADD_EXECUTABLE(paho_cs_sub paho_cs_sub.c)
+
+TARGET_LINK_LIBRARIES(paho_c_pub paho-mqtt3a)
+TARGET_LINK_LIBRARIES(paho_c_sub paho-mqtt3a)
+TARGET_LINK_LIBRARIES(paho_cs_pub paho-mqtt3c)
+TARGET_LINK_LIBRARIES(paho_cs_sub paho-mqtt3c)
+
+ADD_EXECUTABLE(MQTTAsync_subscribe MQTTAsync_subscribe.c)
+ADD_EXECUTABLE(MQTTAsync_publish MQTTAsync_publish.c)
+ADD_EXECUTABLE(MQTTClient_subscribe MQTTClient_subscribe.c)
+ADD_EXECUTABLE(MQTTClient_publish MQTTClient_publish.c)
+ADD_EXECUTABLE(MQTTClient_publish_async MQTTClient_publish_async.c)
+
+TARGET_LINK_LIBRARIES(MQTTAsync_subscribe paho-mqtt3a)
+TARGET_LINK_LIBRARIES(MQTTAsync_publish paho-mqtt3a)
+TARGET_LINK_LIBRARIES(MQTTClient_subscribe paho-mqtt3c)
+TARGET_LINK_LIBRARIES(MQTTClient_publish paho-mqtt3c)
+TARGET_LINK_LIBRARIES(MQTTClient_publish_async paho-mqtt3c)
+
+INSTALL(TARGETS paho_c_sub
+ paho_c_pub
+ paho_cs_sub
+ paho_cs_pub
+ MQTTAsync_subscribe
+ MQTTAsync_publish
+ MQTTClient_subscribe
+ MQTTClient_publish
+ MQTTClient_publish_async
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib)
+
diff --git a/src/samples/MQTTAsync_publish.c b/src/samples/MQTTAsync_publish.c
index 2d07a8dd..7554810f 100644
--- a/src/samples/MQTTAsync_publish.c
+++ b/src/samples/MQTTAsync_publish.c
@@ -21,6 +21,8 @@
#if !defined(WIN32)
#include
+#else
+#include
#endif
#define ADDRESS "tcp://m2m.eclipse.org:1883"
@@ -75,7 +77,7 @@ void onSend(void* context, MQTTAsync_successData* response)
if ((rc = MQTTAsync_disconnect(client, &opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start sendMessage, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
}
@@ -108,7 +110,7 @@ void onConnect(void* context, MQTTAsync_successData* response)
if ((rc = MQTTAsync_sendMessage(client, TOPIC, &pubmsg, &opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start sendMessage, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
}
@@ -133,7 +135,7 @@ int main(int argc, char* argv[])
if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start connect, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
printf("Waiting for publication of %s\n"
diff --git a/src/samples/MQTTAsync_subscribe.c b/src/samples/MQTTAsync_subscribe.c
index 02acfaf3..6b20490f 100644
--- a/src/samples/MQTTAsync_subscribe.c
+++ b/src/samples/MQTTAsync_subscribe.c
@@ -21,6 +21,8 @@
#if !defined(WIN32)
#include
+#else
+#include
#endif
#define ADDRESS "tcp://localhost:1883"
@@ -124,7 +126,7 @@ void onConnect(void* context, MQTTAsync_successData* response)
if ((rc = MQTTAsync_subscribe(client, TOPIC, QOS, &opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start subscribe, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
}
@@ -151,7 +153,7 @@ int main(int argc, char* argv[])
if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start connect, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
while (!subscribed)
@@ -173,7 +175,7 @@ int main(int argc, char* argv[])
if ((rc = MQTTAsync_disconnect(client, &disc_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start disconnect, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
while (!disc_finished)
#if defined(WIN32)
diff --git a/src/samples/pubsync.c b/src/samples/MQTTClient_publish.c
similarity index 98%
rename from src/samples/pubsync.c
rename to src/samples/MQTTClient_publish.c
index 231190cf..ed5d594b 100644
--- a/src/samples/pubsync.c
+++ b/src/samples/MQTTClient_publish.c
@@ -42,7 +42,7 @@ int main(int argc, char* argv[])
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
printf("Failed to connect, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
pubmsg.payload = PAYLOAD;
pubmsg.payloadlen = strlen(PAYLOAD);
diff --git a/src/samples/pubasync.c b/src/samples/MQTTClient_publish_async.c
similarity index 99%
rename from src/samples/pubasync.c
rename to src/samples/MQTTClient_publish_async.c
index 0120667f..49046e92 100644
--- a/src/samples/pubasync.c
+++ b/src/samples/MQTTClient_publish_async.c
@@ -78,7 +78,7 @@ int main(int argc, char* argv[])
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
printf("Failed to connect, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
pubmsg.payload = PAYLOAD;
pubmsg.payloadlen = strlen(PAYLOAD);
diff --git a/src/samples/subasync.c b/src/samples/MQTTClient_subscribe.c
similarity index 98%
rename from src/samples/subasync.c
rename to src/samples/MQTTClient_subscribe.c
index eaeda932..90680510 100644
--- a/src/samples/subasync.c
+++ b/src/samples/MQTTClient_subscribe.c
@@ -77,7 +77,7 @@ int main(int argc, char* argv[])
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
printf("Failed to connect, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
printf("Subscribing to topic %s\nfor client %s using QoS%d\n\n"
"Press Q to quit\n\n", TOPIC, CLIENTID, QOS);
diff --git a/src/samples/stdinpuba.c b/src/samples/paho_c_pub.c
similarity index 65%
rename from src/samples/stdinpuba.c
rename to src/samples/paho_c_pub.c
index c6da70c9..bd26fe4d 100644
--- a/src/samples/stdinpuba.c
+++ b/src/samples/paho_c_pub.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 IBM Corp.
+ * Copyright (c) 2012, 2016 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -12,6 +12,7 @@
*
* Contributors:
* Ian Craggs - initial contribution
+ * Guilherme Maciel Ferreira - add keep alive option
*******************************************************************************/
/*
@@ -27,8 +28,9 @@
--port 1883
--qos 0
--delimiters \n
- --clientid stdin_publisher
+ --clientid stdin-publisher-async
--maxdatalen 100
+ --keepalive 10
--userid none
--password none
@@ -54,31 +56,6 @@
volatile int toStop = 0;
-void usage()
-{
- printf("MQTT stdin publisher\n");
- printf("Usage: stdinpub topicname , where options are:\n");
- printf(" --host (default is localhost)\n");
- printf(" --port (default is 1883)\n");
- printf(" --qos (default is 0)\n");
- printf(" --retained (default is off)\n");
- printf(" --delimiter (default is \\n)");
- printf(" --clientid (default is hostname+timestamp)");
- printf(" --maxdatalen 100\n");
- printf(" --username none\n");
- printf(" --password none\n");
- exit(-1);
-}
-
-
-
-void cfinish(int sig)
-{
- signal(SIGINT, NULL);
- toStop = 1;
-}
-
-
struct
{
char* clientid;
@@ -90,12 +67,39 @@ struct
char* password;
char* host;
char* port;
- int verbose;
+ int verbose;
+ int keepalive;
} opts =
{
- "publisher", "\n", 100, 0, 0, NULL, NULL, "localhost", "1883", 0
+ "stdin-publisher-async", "\n", 100, 0, 0, NULL, NULL, "localhost", "1883", 0, 10
};
+
+void usage(void)
+{
+ printf("MQTT stdin publisher\n");
+ printf("Usage: stdinpub topicname , where options are:\n");
+ printf(" --host (default is %s)\n", opts.host);
+ printf(" --port (default is %s)\n", opts.port);
+ printf(" --qos (default is %d)\n", opts.qos);
+ printf(" --retained (default is %s)\n", opts.retained ? "on" : "off");
+ printf(" --delimiter (default is \\n)\n");
+ printf(" --clientid (default is %s)\n", opts.clientid);
+ printf(" --maxdatalen (default is %d)\n", opts.maxdatalen);
+ printf(" --username none\n");
+ printf(" --password none\n");
+ printf(" --keepalive (default is 10 seconds)\n");
+ exit(EXIT_FAILURE);
+}
+
+
+
+void cfinish(int sig)
+{
+ signal(SIGINT, NULL);
+ toStop = 1;
+}
+
void getopts(int argc, char** argv);
int messageArrived(void* context, char* topicName, int topicLen, MQTTAsync_message* m)
@@ -114,11 +118,15 @@ void onDisconnect(void* context, MQTTAsync_successData* response)
static int connected = 0;
+void myconnect(MQTTAsync* client);
void onConnectFailure(void* context, MQTTAsync_failureData* response)
{
- printf("Connect failed, rc %d\n", response ? -1 : response->code);
+ printf("Connect failed, rc %d\n", response ? response->code : -1);
connected = -1;
+
+ MQTTAsync client = (MQTTAsync)context;
+ myconnect(client);
}
@@ -131,7 +139,6 @@ void onConnect(void* context, MQTTAsync_successData* response)
connected = 1;
}
-
void myconnect(MQTTAsync* client)
{
MQTTAsync_connectOptions conn_opts = MQTTAsync_connectOptions_initializer;
@@ -139,7 +146,7 @@ void myconnect(MQTTAsync* client)
int rc = 0;
printf("Connecting\n");
- conn_opts.keepAliveInterval = 10;
+ conn_opts.keepAliveInterval = opts.keepalive;
conn_opts.cleansession = 1;
conn_opts.username = opts.username;
conn_opts.password = opts.password;
@@ -148,18 +155,13 @@ void myconnect(MQTTAsync* client)
conn_opts.context = client;
ssl_opts.enableServerCertAuth = 0;
conn_opts.ssl = &ssl_opts;
+ conn_opts.automaticReconnect = 1;
connected = 0;
if ((rc = MQTTAsync_connect(*client, &conn_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start connect, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
- while (connected == 0)
- #if defined(WIN32)
- Sleep(100);
- #else
- usleep(10000L);
- #endif
}
@@ -201,124 +203,16 @@ void connectionLost(void* context, char* cause)
if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start connect, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
}
-#if !defined(_WINDOWS)
- #include
- #include
- #include
- #include
-#else
-#include
-#include
-#define MAXHOSTNAMELEN 256
-#define EAGAIN WSAEWOULDBLOCK
-#define EINTR WSAEINTR
-#define EINPROGRESS WSAEINPROGRESS
-#define EWOULDBLOCK WSAEWOULDBLOCK
-#define ENOTCONN WSAENOTCONN
-#define ECONNRESET WSAECONNRESET
-#define setenv(a, b, c) _putenv_s(a, b)
-#endif
-
-
-#if !defined(SOCKET_ERROR)
-#define SOCKET_ERROR -1
-#endif
-
-
-typedef struct
-{
- int socket;
- time_t lastContact;
-#if defined(OPENSSL)
- SSL* ssl;
- SSL_CTX* ctx;
-#endif
-} networkHandles;
-
-
-typedef struct
-{
- char* clientID; /**< the string id of the client */
- char* username; /**< MQTT v3.1 user name */
- char* password; /**< MQTT v3.1 password */
- unsigned int cleansession : 1; /**< MQTT clean session flag */
- unsigned int connected : 1; /**< whether it is currently connected */
- unsigned int good : 1; /**< if we have an error on the socket we turn this off */
- unsigned int ping_outstanding : 1;
- int connect_state : 4;
- networkHandles net;
-/* ... */
-} Clients;
-
-
-typedef struct MQTTAsync_struct
-{
- char* serverURI;
- int ssl;
- Clients* c;
-
- /* "Global", to the client, callback definitions */
- MQTTAsync_connectionLost* cl;
- MQTTAsync_messageArrived* ma;
- MQTTAsync_deliveryComplete* dc;
- void* context; /* the context to be associated with the main callbacks*/
- #if 0
- MQTTAsync_command connect; /* Connect operation properties */
- MQTTAsync_command disconnect; /* Disconnect operation properties */
- MQTTAsync_command* pending_write; /* Is there a socket write pending? */
-
- List* responses;
- unsigned int command_seqno;
-
- MQTTPacket* pack;
-#endif
-} MQTTAsyncs;
-
-int test6_socket_error(char* aString, int sock)
-{
-#if defined(WIN32)
- int errno;
-#endif
-
-#if defined(WIN32)
- errno = WSAGetLastError();
-#endif
- if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS && errno != EWOULDBLOCK)
- {
- if (strcmp(aString, "shutdown") != 0 || (errno != ENOTCONN && errno != ECONNRESET))
- printf("Socket error %d in %s for socket %d", errno, aString, sock);
- }
- return errno;
-}
-
-
-int test6_socket_close(int socket)
-{
- int rc;
-
-#if defined(WIN32)
- if (shutdown(socket, SD_BOTH) == SOCKET_ERROR)
- test6_socket_error("shutdown", socket);
- if ((rc = closesocket(socket)) == SOCKET_ERROR)
- test6_socket_error("close", socket);
-#else
- if (shutdown(socket, SHUT_RDWR) == SOCKET_ERROR)
- test6_socket_error("shutdown", socket);
- if ((rc = close(socket)) == SOCKET_ERROR)
- test6_socket_error("close", socket);
-#endif
- return rc;
-}
-
int main(int argc, char** argv)
{
MQTTAsync_disconnectOptions disc_opts = MQTTAsync_disconnectOptions_initializer;
MQTTAsync_responseOptions pub_opts = MQTTAsync_responseOptions_initializer;
+ MQTTAsync_createOptions create_opts = MQTTAsync_createOptions_initializer;
MQTTAsync client;
char* topic = NULL;
char* buffer = NULL;
@@ -337,7 +231,8 @@ int main(int argc, char** argv)
topic = argv[1];
printf("Using topic %s\n", topic);
- rc = MQTTAsync_create(&client, url, opts.clientid, MQTTCLIENT_PERSISTENCE_NONE, NULL);
+ create_opts.sendWhileDisconnected = 1;
+ rc = MQTTAsync_createWithOptions(&client, url, opts.clientid, MQTTCLIENT_PERSISTENCE_NONE, NULL, &create_opts);
signal(SIGINT, cfinish);
signal(SIGTERM, cfinish);
@@ -371,19 +266,9 @@ int main(int argc, char** argv)
pub_opts.onFailure = onPublishFailure;
do
{
- published = 0;
rc = MQTTAsync_send(client, topic, data_len, buffer, opts.qos, opts.retained, &pub_opts);
- while (published == 0)
- #if defined(WIN32)
- Sleep(100);
- #else
- usleep(1000L);
- #endif
- if (published == -1)
- myconnect(&client);
- test6_socket_close(((MQTTAsyncs*)client)->c->net.socket);
}
- while (published != 1);
+ while (rc != MQTTASYNC_SUCCESS);
}
printf("Stopping\n");
@@ -394,7 +279,7 @@ int main(int argc, char** argv)
if ((rc = MQTTAsync_disconnect(client, &disc_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start disconnect, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
while (!disconnected)
@@ -404,9 +289,9 @@ int main(int argc, char** argv)
usleep(10000L);
#endif
- MQTTAsync_destroy(&client);
+ MQTTAsync_destroy(&client);
- return 0;
+ return EXIT_SUCCESS;
}
void getopts(int argc, char** argv)
@@ -484,6 +369,13 @@ void getopts(int argc, char** argv)
else
usage();
}
+ else if (strcmp(argv[count], "--keepalive") == 0)
+ {
+ if (++count < argc)
+ opts.keepalive = atoi(argv[count]);
+ else
+ usage();
+ }
count++;
}
diff --git a/src/samples/stdoutsuba.c b/src/samples/paho_c_sub.c
similarity index 88%
rename from src/samples/stdoutsuba.c
rename to src/samples/paho_c_sub.c
index 37eb4269..4c820b60 100644
--- a/src/samples/stdoutsuba.c
+++ b/src/samples/paho_c_sub.c
@@ -13,6 +13,7 @@
* Contributors:
* Ian Craggs - initial contribution
* Ian Craggs - fix for bug 413429 - connectionLost not called
+ * Guilherme Maciel Ferreira - add keep alive option
*******************************************************************************/
/*
@@ -29,7 +30,9 @@
--port 1883
--qos 2
--delimiter \n
- --clientid stdout_subscriber
+ --clientid stdout-subscriber-async
+ --showtopics off
+ --keepalive 10
--userid none
--password none
@@ -45,7 +48,7 @@
#if defined(WIN32)
-#include
+#include
#define sleep Sleep
#else
#include
@@ -70,33 +73,35 @@ void cfinish(int sig)
struct
{
char* clientid;
- int nodelimiter;
+ int nodelimiter;
char delimiter;
int qos;
char* username;
char* password;
char* host;
char* port;
- int showtopics;
+ int showtopics;
+ int keepalive;
} opts =
{
- "stdout-subscriber", 1, '\n', 2, NULL, NULL, "localhost", "1883", 0
+ "stdout-subscriber-async", 1, '\n', 2, NULL, NULL, "localhost", "1883", 0, 10
};
-void usage()
+void usage(void)
{
printf("MQTT stdout subscriber\n");
printf("Usage: stdoutsub topicname , where options are:\n");
- printf(" --host (default is localhost)\n");
- printf(" --port (default is 1883)\n");
- printf(" --qos (default is 2)\n");
+ printf(" --host (default is %s)\n", opts.host);
+ printf(" --port (default is %s)\n", opts.port);
+ printf(" --qos (default is %d)\n", opts.qos);
printf(" --delimiter (default is no delimiter)\n");
- printf(" --clientid (default is hostname+timestamp)\n");
+ printf(" --clientid (default is %s)\n", opts.clientid);
printf(" --username none\n");
printf(" --password none\n");
printf(" --showtopics (default is on if the topic has a wildcard, else off)\n");
- exit(-1);
+ printf(" --keepalive (default is 10 seconds)\n");
+ exit(EXIT_FAILURE);
}
@@ -184,6 +189,13 @@ void getopts(int argc, char** argv)
else
usage();
}
+ else if (strcmp(argv[count], "--keepalive") == 0)
+ {
+ if (++count < argc)
+ opts.keepalive = atoi(argv[count]);
+ else
+ usage();
+ }
count++;
}
@@ -201,7 +213,7 @@ int messageArrived(void *context, char *topicName, int topicLen, MQTTAsync_messa
fflush(stdout);
MQTTAsync_freeMessage(&message);
MQTTAsync_free(topicName);
- return 1;
+ return 1;
}
@@ -247,7 +259,7 @@ void onConnect(void* context, MQTTAsync_successData* response)
if ((rc = MQTTAsync_subscribe(client, topic, opts.qos, &ropts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start subscribe, return code %d\n", rc);
- finished = 1;
+ finished = 1;
}
}
@@ -296,7 +308,7 @@ int main(int argc, char** argv)
signal(SIGINT, cfinish);
signal(SIGTERM, cfinish);
- conn_opts.keepAliveInterval = 10;
+ conn_opts.keepAliveInterval = opts.keepalive;
conn_opts.cleansession = 1;
conn_opts.username = opts.username;
conn_opts.password = opts.password;
@@ -306,7 +318,7 @@ int main(int argc, char** argv)
if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start connect, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
while (!subscribed)
@@ -330,10 +342,10 @@ int main(int argc, char** argv)
if ((rc = MQTTAsync_disconnect(client, &disc_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start disconnect, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
- while (!disconnected)
+ while (!disconnected)
#if defined(WIN32)
Sleep(100);
#else
@@ -343,7 +355,7 @@ int main(int argc, char** argv)
exit:
MQTTAsync_destroy(&client);
- return 0;
+ return EXIT_SUCCESS;
}
diff --git a/src/samples/pahopub.c b/src/samples/paho_cs_pub.c
similarity index 98%
rename from src/samples/pahopub.c
rename to src/samples/paho_cs_pub.c
index e2866ab1..db52efb5 100644
--- a/src/samples/pahopub.c
+++ b/src/samples/paho_cs_pub.c
@@ -55,7 +55,7 @@
volatile int toStop = 0;
-void usage()
+void usage(void)
{
printf("MQTT stdin publisher\n");
printf("Usage: stdinpub topicname , where options are:\n");
@@ -68,7 +68,7 @@ void usage()
printf(" --maxdatalen 100\n");
printf(" --username none\n");
printf(" --password none\n");
- exit(-1);
+ exit(EXIT_FAILURE);
}
@@ -78,7 +78,7 @@ void myconnect(MQTTClient* client, MQTTClient_connectOptions* opts)
if (MQTTClient_connect(*client, opts) != 0)
{
printf("Failed to connect\n");
- exit(-1);
+ exit(EXIT_FAILURE);
}
printf("Connected\n");
}
@@ -194,7 +194,7 @@ int main(int argc, char** argv)
MQTTClient_destroy(&client);
- return 0;
+ return EXIT_SUCCESS;
}
void getopts(int argc, char** argv)
diff --git a/src/samples/stdoutsub.c b/src/samples/paho_cs_sub.c
similarity index 82%
rename from src/samples/stdoutsub.c
rename to src/samples/paho_cs_sub.c
index b6477b6e..49ed8300 100644
--- a/src/samples/stdoutsub.c
+++ b/src/samples/paho_cs_sub.c
@@ -13,6 +13,7 @@
* Contributors:
* Ian Craggs - initial contribution
* Ian Craggs - change delimiter option from char to string
+ * Guilherme Maciel Ferreira - add keep alive option
*******************************************************************************/
/*
@@ -29,7 +30,9 @@
--port 1883
--qos 2
--delimiter \n
- --clientid stdout_subscriber
+ --clientid stdout-subscriber
+ --showtopics off
+ --keepalive 10
--userid none
--password none
@@ -44,7 +47,7 @@
#if defined(WIN32)
-#include
+#include
#define sleep Sleep
#else
#include
@@ -55,19 +58,38 @@
volatile int toStop = 0;
-void usage()
+struct opts_struct
+{
+ char* clientid;
+ int nodelimiter;
+ char* delimiter;
+ int qos;
+ char* username;
+ char* password;
+ char* host;
+ char* port;
+ int showtopics;
+ int keepalive;
+} opts =
+{
+ "stdout-subscriber", 0, "\n", 2, NULL, NULL, "localhost", "1883", 0, 10
+};
+
+
+void usage(void)
{
printf("MQTT stdout subscriber\n");
printf("Usage: stdoutsub topicname , where options are:\n");
- printf(" --host (default is localhost)\n");
- printf(" --port (default is 1883)\n");
- printf(" --qos (default is 2)\n");
+ printf(" --host (default is %s)\n", opts.host);
+ printf(" --port (default is %s)\n", opts.port);
+ printf(" --qos (default is %d)\n", opts.qos);
printf(" --delimiter (default is \\n)\n");
- printf(" --clientid (default is hostname+timestamp)\n");
+ printf(" --clientid (default is %s)\n", opts.clientid);
printf(" --username none\n");
printf(" --password none\n");
- printf(" --showtopics (default is on if the topic has a wildcard, else off)\n");
- exit(-1);
+ printf(" --showtopics (default is on if the topic has a wildcard, else off)\n");
+ printf(" --keepalive (default is %d seconds)\n", opts.keepalive);
+ exit(EXIT_FAILURE);
}
@@ -77,7 +99,7 @@ void myconnect(MQTTClient* client, MQTTClient_connectOptions* opts)
if ((rc = MQTTClient_connect(*client, opts)) != 0)
{
printf("Failed to connect, return code %d\n", rc);
- exit(-1);
+ exit(EXIT_FAILURE);
}
}
@@ -88,23 +110,6 @@ void cfinish(int sig)
toStop = 1;
}
-
-struct opts_struct
-{
- char* clientid;
- int nodelimiter;
- char* delimiter;
- int qos;
- char* username;
- char* password;
- char* host;
- char* port;
- int showtopics;
-} opts =
-{
- "stdout-subscriber", 0, "\n", 2, NULL, NULL, "localhost", "1883", 0
-};
-
void getopts(int argc, char** argv);
int main(int argc, char** argv)
@@ -120,9 +125,9 @@ int main(int argc, char** argv)
topic = argv[1];
- if (strchr(topic, '#') || strchr(topic, '+'))
+ if (strchr(topic, '#') || strchr(topic, '+'))
opts.showtopics = 1;
- if (opts.showtopics)
+ if (opts.showtopics)
printf("topic is %s\n", topic);
getopts(argc, argv);
@@ -133,7 +138,7 @@ int main(int argc, char** argv)
signal(SIGINT, cfinish);
signal(SIGTERM, cfinish);
- conn_opts.keepAliveInterval = 10;
+ conn_opts.keepAliveInterval = opts.keepalive;
conn_opts.reliable = 0;
conn_opts.cleansession = 1;
conn_opts.username = opts.username;
@@ -154,7 +159,7 @@ int main(int argc, char** argv)
{
if (opts.showtopics)
printf("%s\t", topicName);
- if (opts.nodelimiter)
+ if (opts.nodelimiter)
printf("%.*s", message->payloadlen, (char*)message->payload);
else
printf("%.*s%s", message->payloadlen, (char*)message->payload, opts.delimiter);
@@ -170,9 +175,9 @@ int main(int argc, char** argv)
MQTTClient_disconnect(client, 0);
- MQTTClient_destroy(&client);
+ MQTTClient_destroy(&client);
- return 0;
+ return EXIT_SUCCESS;
}
void getopts(int argc, char** argv)
@@ -253,6 +258,13 @@ void getopts(int argc, char** argv)
else
usage();
}
+ else if (strcmp(argv[count], "--keepalive") == 0)
+ {
+ if (++count < argc)
+ opts.keepalive = atoi(argv[count]);
+ else
+ usage();
+ }
count++;
}
diff --git a/src/samples/stdinpub.c b/src/samples/stdinpub.c
deleted file mode 100644
index 9330fe02..00000000
--- a/src/samples/stdinpub.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 IBM Corp.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution.
- *
- * The Eclipse Public License is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Ian Craggs - initial contribution
- *******************************************************************************/
-
- /*
- stdin publisher
-
- compulsory parameters:
-
- --topic topic to publish on
-
- defaulted parameters:
-
- --host localhost
- --port 1883
- --qos 0
- --delimiters \n
- --clientid stdin_publisher
- --maxdatalen 100
-
- --userid none
- --password none
-
-*/
-
-#include "MQTTClient.h"
-#include "MQTTClientPersistence.h"
-
-#include
-#include
-#include
-
-
-#if defined(WIN32)
-#include
-#define sleep Sleep
-#else
-#include
-#include
-#endif
-
-
-volatile int toStop = 0;
-
-
-void usage()
-{
- printf("MQTT stdin publisher\n");
- printf("Usage: stdinpub topicname , where options are:\n");
- printf(" --host (default is localhost)\n");
- printf(" --port (default is 1883)\n");
- printf(" --qos (default is 0)\n");
- printf(" --retained (default is off)\n");
- printf(" --delimiter (default is \\n)");
- printf(" --clientid (default is hostname+timestamp)");
- printf(" --maxdatalen 100\n");
- printf(" --username none\n");
- printf(" --password none\n");
- exit(-1);
-}
-
-
-void myconnect(MQTTClient* client, MQTTClient_connectOptions* opts)
-{
- printf("Connecting\n");
- if (MQTTClient_connect(*client, opts) != 0)
- {
- printf("Failed to connect\n");
- exit(-1);
- }
-}
-
-
-void cfinish(int sig)
-{
- signal(SIGINT, NULL);
- toStop = 1;
-}
-
-
-struct
-{
- char* clientid;
- char* delimiter;
- int maxdatalen;
- int qos;
- int retained;
- char* username;
- char* password;
- char* host;
- char* port;
- int verbose;
-} opts =
-{
- "publisher", "\n", 100, 0, 0, NULL, NULL, "localhost", "1883", 0
-};
-
-void getopts(int argc, char** argv);
-
-int messageArrived(void* context, char* topicName, int topicLen, MQTTClient_message* m)
-{
- /* not expecting any messages */
- return 1;
-}
-
-int main(int argc, char** argv)
-{
- MQTTClient client;
- MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
- char* topic = NULL;
- char* buffer = NULL;
- int rc = 0;
- char url[100];
-
- if (argc < 2)
- usage();
-
- getopts(argc, argv);
-
- sprintf(url, "%s:%s", opts.host, opts.port);
- if (opts.verbose)
- printf("URL is %s\n", url);
-
- topic = argv[1];
- printf("Using topic %s\n", topic);
-
- rc = MQTTClient_create(&client, url, opts.clientid, MQTTCLIENT_PERSISTENCE_NONE, NULL);
-
- signal(SIGINT, cfinish);
- signal(SIGTERM, cfinish);
-
- rc = MQTTClient_setCallbacks(client, NULL, NULL, messageArrived, NULL);
-
- conn_opts.keepAliveInterval = 10;
- conn_opts.reliable = 0;
- conn_opts.cleansession = 1;
- conn_opts.username = opts.username;
- conn_opts.password = opts.password;
-
- myconnect(&client, &conn_opts);
-
- buffer = malloc(opts.maxdatalen);
-
- while (!toStop)
- {
- int data_len = 0;
- int delim_len = 0;
-
- delim_len = strlen(opts.delimiter);
- do
- {
- buffer[data_len++] = getchar();
- if (data_len > delim_len)
- {
- //printf("comparing %s %s\n", opts.delimiter, &buffer[data_len - delim_len]);
- if (strncmp(opts.delimiter, &buffer[data_len - delim_len], delim_len) == 0)
- break;
- }
- } while (data_len < opts.maxdatalen);
-
- if (opts.verbose)
- printf("Publishing data of length %d\n", data_len);
- rc = MQTTClient_publish(client, topic, data_len, buffer, opts.qos, opts.retained, NULL);
- if (rc != 0)
- {
- myconnect(&client, &conn_opts);
- rc = MQTTClient_publish(client, topic, data_len, buffer, opts.qos, opts.retained, NULL);
- }
- if (opts.qos > 0)
- MQTTClient_yield();
- }
-
- printf("Stopping\n");
-
- free(buffer);
-
- MQTTClient_disconnect(client, 0);
-
- MQTTClient_destroy(&client);
-
- return 0;
-}
-
-void getopts(int argc, char** argv)
-{
- int count = 2;
-
- while (count < argc)
- {
- if (strcmp(argv[count], "--retained") == 0)
- opts.retained = 1;
- if (strcmp(argv[count], "--verbose") == 0)
- opts.verbose = 1;
- else if (strcmp(argv[count], "--qos") == 0)
- {
- if (++count < argc)
- {
- if (strcmp(argv[count], "0") == 0)
- opts.qos = 0;
- else if (strcmp(argv[count], "1") == 0)
- opts.qos = 1;
- else if (strcmp(argv[count], "2") == 0)
- opts.qos = 2;
- else
- usage();
- }
- else
- usage();
- }
- else if (strcmp(argv[count], "--host") == 0)
- {
- if (++count < argc)
- opts.host = argv[count];
- else
- usage();
- }
- else if (strcmp(argv[count], "--port") == 0)
- {
- if (++count < argc)
- opts.port = argv[count];
- else
- usage();
- }
- else if (strcmp(argv[count], "--clientid") == 0)
- {
- if (++count < argc)
- opts.clientid = argv[count];
- else
- usage();
- }
- else if (strcmp(argv[count], "--username") == 0)
- {
- if (++count < argc)
- opts.username = argv[count];
- else
- usage();
- }
- else if (strcmp(argv[count], "--password") == 0)
- {
- if (++count < argc)
- opts.password = argv[count];
- else
- usage();
- }
- else if (strcmp(argv[count], "--maxdatalen") == 0)
- {
- if (++count < argc)
- opts.maxdatalen = atoi(argv[count]);
- else
- usage();
- }
- else if (strcmp(argv[count], "--delimiter") == 0)
- {
- if (++count < argc)
- opts.delimiter = argv[count];
- else
- usage();
- }
- count++;
- }
-
-}
-
diff --git a/src/utf-8.c b/src/utf-8.c
index 04097deb..af5e3847 100755
--- a/src/utf-8.c
+++ b/src/utf-8.c
@@ -153,7 +153,7 @@ int UTF8_validateString(const char* string)
int rc = 0;
FUNC_ENTRY;
- rc = UTF8_validate(strlen(string), string);
+ rc = UTF8_validate((int)strlen(string), string);
FUNC_EXIT_RC(rc);
return rc;
}
diff --git a/test/MQTTV311.py b/test/MQTTV311.py
new file mode 100644
index 00000000..0faa9f70
--- /dev/null
+++ b/test/MQTTV311.py
@@ -0,0 +1,920 @@
+"""
+*******************************************************************
+ Copyright (c) 2013, 2014 IBM Corp.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ and Eclipse Distribution License v1.0 which accompany this distribution.
+
+ The Eclipse Public License is available at
+ http://www.eclipse.org/legal/epl-v10.html
+ and the Eclipse Distribution License is available at
+ http://www.eclipse.org/org/documents/edl-v10.php.
+
+ Contributors:
+ Ian Craggs - initial implementation and/or documentation
+*******************************************************************
+"""
+
+"""
+
+Assertions are used to validate incoming data, but are omitted from outgoing packets. This is
+so that the tests that use this package can send invalid data for error testing.
+
+"""
+
+import logging
+
+logger = logging.getLogger("mqttsas")
+
+# Low-level protocol interface
+
+class MQTTException(Exception):
+ pass
+
+
+# Message types
+CONNECT, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL, \
+PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK, \
+PINGREQ, PINGRESP, DISCONNECT = range(1, 15)
+
+packetNames = [ "reserved", \
+"Connect", "Connack", "Publish", "Puback", "Pubrec", "Pubrel", \
+"Pubcomp", "Subscribe", "Suback", "Unsubscribe", "Unsuback", \
+"Pingreq", "Pingresp", "Disconnect"]
+
+classNames = [ "reserved", \
+"Connects", "Connacks", "Publishes", "Pubacks", "Pubrecs", "Pubrels", \
+"Pubcomps", "Subscribes", "Subacks", "Unsubscribes", "Unsubacks", \
+"Pingreqs", "Pingresps", "Disconnects"]
+
+
+def MessageType(byte):
+ if byte != None:
+ rc = byte[0] >> 4
+ else:
+ rc = None
+ return rc
+
+
+def getPacket(aSocket):
+ "receive the next packet"
+ buf = aSocket.recv(1) # get the first byte fixed header
+ if buf == b"":
+ return None
+ if str(aSocket).find("[closed]") != -1:
+ closed = True
+ else:
+ closed = False
+ if closed:
+ return None
+ # now get the remaining length
+ multiplier = 1
+ remlength = 0
+ while 1:
+ next = aSocket.recv(1)
+ while len(next) == 0:
+ next = aSocket.recv(1)
+ buf += next
+ digit = buf[-1]
+ remlength += (digit & 127) * multiplier
+ if digit & 128 == 0:
+ break
+ multiplier *= 128
+ # receive the remaining length if there is any
+ rest = bytes([])
+ if remlength > 0:
+ while len(rest) < remlength:
+ rest += aSocket.recv(remlength-len(rest))
+ assert len(rest) == remlength
+ return buf + rest
+
+
+class FixedHeaders:
+
+ def __init__(self, aMessageType):
+ self.MessageType = aMessageType
+ self.DUP = False
+ self.QoS = 0
+ self.RETAIN = False
+ self.remainingLength = 0
+
+ def __eq__(self, fh):
+ return self.MessageType == fh.MessageType and \
+ self.DUP == fh.DUP and \
+ self.QoS == fh.QoS and \
+ self.RETAIN == fh.RETAIN # and \
+ # self.remainingLength == fh.remainingLength
+
+ def __repr__(self):
+ "return printable representation of our data"
+ return classNames[self.MessageType]+'(DUP='+repr(self.DUP)+ \
+ ", QoS="+repr(self.QoS)+", Retain="+repr(self.RETAIN)
+
+ def pack(self, length):
+ "pack data into string buffer ready for transmission down socket"
+ buffer = bytes([(self.MessageType << 4) | (self.DUP << 3) |\
+ (self.QoS << 1) | self.RETAIN])
+ self.remainingLength = length
+ buffer += self.encode(length)
+ return buffer
+
+ def encode(self, x):
+ assert 0 <= x <= 268435455
+ buffer = b''
+ while 1:
+ digit = x % 128
+ x //= 128
+ if x > 0:
+ digit |= 0x80
+ buffer += bytes([digit])
+ if x == 0:
+ break
+ return buffer
+
+ def unpack(self, buffer):
+ "unpack data from string buffer into separate fields"
+ b0 = buffer[0]
+ self.MessageType = b0 >> 4
+ self.DUP = ((b0 >> 3) & 0x01) == 1
+ self.QoS = (b0 >> 1) & 0x03
+ self.RETAIN = (b0 & 0x01) == 1
+ (self.remainingLength, bytes) = self.decode(buffer[1:])
+ return bytes + 1 # length of fixed header
+
+ def decode(self, buffer):
+ multiplier = 1
+ value = 0
+ bytes = 0
+ while 1:
+ bytes += 1
+ digit = buffer[0]
+ buffer = buffer[1:]
+ value += (digit & 127) * multiplier
+ if digit & 128 == 0:
+ break
+ multiplier *= 128
+ return (value, bytes)
+
+
+def writeInt16(length):
+ return bytes([length // 256, length % 256])
+
+def readInt16(buf):
+ return buf[0]*256 + buf[1]
+
+def writeUTF(data):
+ # data could be a string, or bytes. If string, encode into bytes with utf-8
+ return writeInt16(len(data)) + (data if type(data) == type(b"") else bytes(data, "utf-8"))
+
+def readUTF(buffer, maxlen):
+ if maxlen >= 2:
+ length = readInt16(buffer)
+ else:
+ raise MQTTException("Not enough data to read string length")
+ maxlen -= 2
+ if length > maxlen:
+ raise MQTTException("Length delimited string too long")
+ buf = buffer[2:2+length].decode("utf-8")
+ logger.info("[MQTT-4.7.3-2] topic names and filters not include null")
+ zz = buf.find("\x00") # look for null in the UTF string
+ if zz != -1:
+ raise MQTTException("[MQTT-1.5.3-2] Null found in UTF data "+buf)
+ for c in range (0xD800, 0xDFFF):
+ zz = buf.find(chr(c)) # look for D800-DFFF in the UTF string
+ if zz != -1:
+ raise MQTTException("[MQTT-1.5.3-1] D800-DFFF found in UTF data "+buf)
+ if buf.find("\uFEFF") != -1:
+ logger.info("[MQTT-1.5.3-3] U+FEFF in UTF string")
+ return buf
+
+def writeBytes(buffer):
+ return writeInt16(len(buffer)) + buffer
+
+def readBytes(buffer):
+ length = readInt16(buffer)
+ return buffer[2:2+length]
+
+
+class Packets:
+
+ def pack(self):
+ buffer = self.fh.pack(0)
+ return buffer
+
+ def __repr__(self):
+ return repr(self.fh)
+
+ def __eq__(self, packet):
+ return self.fh == packet.fh if packet else False
+
+
+class Connects(Packets):
+
+ def __init__(self, buffer = None):
+ self.fh = FixedHeaders(CONNECT)
+
+ # variable header
+ self.ProtocolName = "MQTT"
+ self.ProtocolVersion = 4
+ self.CleanSession = True
+ self.WillFlag = False
+ self.WillQoS = 0
+ self.WillRETAIN = 0
+ self.KeepAliveTimer = 30
+ self.usernameFlag = False
+ self.passwordFlag = False
+
+ # Payload
+ self.ClientIdentifier = "" # UTF-8
+ self.WillTopic = None # UTF-8
+ self.WillMessage = None # binary
+ self.username = None # UTF-8
+ self.password = None # binary
+
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ connectFlags = bytes([(self.CleanSession << 1) | (self.WillFlag << 2) | \
+ (self.WillQoS << 3) | (self.WillRETAIN << 5) | \
+ (self.usernameFlag << 6) | (self.passwordFlag << 7)])
+ buffer = writeUTF(self.ProtocolName) + bytes([self.ProtocolVersion]) + \
+ connectFlags + writeInt16(self.KeepAliveTimer)
+ buffer += writeUTF(self.ClientIdentifier)
+ if self.WillFlag:
+ buffer += writeUTF(self.WillTopic)
+ buffer += writeBytes(self.WillMessage)
+ if self.usernameFlag:
+ buffer += writeUTF(self.username)
+ if self.passwordFlag:
+ buffer += writeBytes(self.password)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == CONNECT
+
+ try:
+ fhlen = self.fh.unpack(buffer)
+ packlen = fhlen + self.fh.remainingLength
+ assert len(buffer) >= packlen, "buffer length %d packet length %d" % (len(buffer), packlen)
+ curlen = fhlen # points to after header + remaining length
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1] QoS was not 0, was %d" % self.fh.QoS
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+
+ self.ProtocolName = readUTF(buffer[curlen:], packlen - curlen)
+ curlen += len(self.ProtocolName) + 2
+ assert self.ProtocolName == "MQTT", "Wrong protocol name %s" % self.ProtocolName
+
+ self.ProtocolVersion = buffer[curlen]
+ curlen += 1
+
+ connectFlags = buffer[curlen]
+ assert (connectFlags & 0x01) == 0, "[MQTT-3.1.2-3] reserved connect flag must be 0"
+ self.CleanSession = ((connectFlags >> 1) & 0x01) == 1
+ self.WillFlag = ((connectFlags >> 2) & 0x01) == 1
+ self.WillQoS = (connectFlags >> 3) & 0x03
+ self.WillRETAIN = (connectFlags >> 5) & 0x01
+ self.passwordFlag = ((connectFlags >> 6) & 0x01) == 1
+ self.usernameFlag = ((connectFlags >> 7) & 0x01) == 1
+ curlen +=1
+
+ if self.WillFlag:
+ assert self.WillQoS in [0, 1, 2], "[MQTT-3.1.2-14] will qos must not be 3"
+ else:
+ assert self.WillQoS == 0, "[MQTT-3.1.2-13] will qos must be 0, if will flag is false"
+ assert self.WillRETAIN == False, "[MQTT-3.1.2-14] will retain must be false, if will flag is false"
+
+ self.KeepAliveTimer = readInt16(buffer[curlen:])
+ curlen += 2
+ logger.info("[MQTT-3.1.3-3] Clientid must be present, and first field")
+ logger.info("[MQTT-3.1.3-4] Clientid must be Unicode, and between 0 and 65535 bytes long")
+ self.ClientIdentifier = readUTF(buffer[curlen:], packlen - curlen)
+ curlen += len(self.ClientIdentifier) + 2
+
+ if self.WillFlag:
+ self.WillTopic = readUTF(buffer[curlen:], packlen - curlen)
+ curlen += len(self.WillTopic) + 2
+ self.WillMessage = readBytes(buffer[curlen:])
+ curlen += len(self.WillMessage) + 2
+ logger.info("[[MQTT-3.1.2-9] will topic and will message fields must be present")
+ else:
+ self.WillTopic = self.WillMessage = None
+
+ if self.usernameFlag:
+ assert len(buffer) > curlen+2, "Buffer too short to read username length"
+ self.username = readUTF(buffer[curlen:], packlen - curlen)
+ curlen += len(self.username) + 2
+ logger.info("[MQTT-3.1.2-19] username must be in payload if user name flag is 1")
+ else:
+ logger.info("[MQTT-3.1.2-18] username must not be in payload if user name flag is 0")
+ assert self.passwordFlag == False, "[MQTT-3.1.2-22] password flag must be 0 if username flag is 0"
+
+ if self.passwordFlag:
+ assert len(buffer) > curlen+2, "Buffer too short to read password length"
+ self.password = readBytes(buffer[curlen:])
+ curlen += len(self.password) + 2
+ logger.info("[MQTT-3.1.2-21] password must be in payload if password flag is 0")
+ else:
+ logger.info("[MQTT-3.1.2-20] password must not be in payload if password flag is 0")
+
+ if self.WillFlag and self.usernameFlag and self.passwordFlag:
+ logger.info("[MQTT-3.1.3-1] clientid, will topic, will message, username and password all present")
+
+ assert curlen == packlen, "Packet is wrong length curlen %d != packlen %d"
+ except:
+ logger.exception("[MQTT-3.1.4-1] server must validate connect packet and close connection without connack if it does not conform")
+ raise
+
+
+
+ def __repr__(self):
+ buf = repr(self.fh)+", ProtocolName="+str(self.ProtocolName)+", ProtocolVersion=" +\
+ repr(self.ProtocolVersion)+", CleanSession="+repr(self.CleanSession) +\
+ ", WillFlag="+repr(self.WillFlag)+", KeepAliveTimer=" +\
+ repr(self.KeepAliveTimer)+", ClientId="+str(self.ClientIdentifier) +\
+ ", usernameFlag="+repr(self.usernameFlag)+", passwordFlag="+repr(self.passwordFlag)
+ if self.WillFlag:
+ buf += ", WillQoS=" + repr(self.WillQoS) +\
+ ", WillRETAIN=" + repr(self.WillRETAIN) +\
+ ", WillTopic='"+ self.WillTopic +\
+ "', WillMessage='"+str(self.WillMessage)+"'"
+ if self.username:
+ buf += ", username="+self.username
+ if self.password:
+ buf += ", password="+str(self.password)
+ return buf+")"
+
+ def __eq__(self, packet):
+ rc = Packets.__eq__(self, packet) and \
+ self.ProtocolName == packet.ProtocolName and \
+ self.ProtocolVersion == packet.ProtocolVersion and \
+ self.CleanSession == packet.CleanSession and \
+ self.WillFlag == packet.WillFlag and \
+ self.KeepAliveTimer == packet.KeepAliveTimer and \
+ self.ClientIdentifier == packet.ClientIdentifier and \
+ self.WillFlag == packet.WillFlag
+ if rc and self.WillFlag:
+ rc = self.WillQoS == packet.WillQoS and \
+ self.WillRETAIN == packet.WillRETAIN and \
+ self.WillTopic == packet.WillTopic and \
+ self.WillMessage == packet.WillMessage
+ return rc
+
+
+class Connacks(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, ReturnCode=0):
+ self.fh = FixedHeaders(CONNACK)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ self.flags = 0
+ self.returnCode = ReturnCode
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = bytes([self.flags, self.returnCode])
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 4
+ assert MessageType(buffer) == CONNACK
+ self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 2, "Connack packet is wrong length %d" % self.fh.remainingLength
+ assert buffer[2] in [0, 1], "Connect Acknowledge Flags"
+ self.returnCode = buffer[3]
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+
+ def __repr__(self):
+ return repr(self.fh)+", Session present="+str((self.flags & 0x01) == 1)+", ReturnCode="+repr(self.returnCode)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.returnCode == packet.returnCode
+
+
+class Disconnects(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False):
+ self.fh = FixedHeaders(DISCONNECT)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ if buffer != None:
+ self.unpack(buffer)
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == DISCONNECT
+ self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 0, "Disconnect packet is wrong length %d" % self.fh.remainingLength
+ logger.info("[MQTT-3.14.1-1] disconnect reserved bits must be 0")
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+
+ def __repr__(self):
+ return repr(self.fh)+")"
+
+
+class Publishes(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0, TopicName="", Payload=b""):
+ self.fh = FixedHeaders(PUBLISH)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.topicName = TopicName
+ self.messageIdentifier = MsgId
+ # payload
+ self.data = Payload
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeUTF(self.topicName)
+ if self.fh.QoS != 0:
+ buffer += writeInt16(self.messageIdentifier)
+ buffer += self.data
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PUBLISH
+ fhlen = self.fh.unpack(buffer)
+ assert self.fh.QoS in [0, 1, 2], "QoS in Publish must be 0, 1, or 2"
+ packlen = fhlen + self.fh.remainingLength
+ assert len(buffer) >= packlen
+ curlen = fhlen
+ try:
+ self.topicName = readUTF(buffer[fhlen:], packlen - curlen)
+ except UnicodeDecodeError:
+ logger.info("[MQTT-3.3.2-1] topic name in publish must be utf-8")
+ raise
+ curlen += len(self.topicName) + 2
+ if self.fh.QoS != 0:
+ self.messageIdentifier = readInt16(buffer[curlen:])
+ logger.info("[MQTT-2.3.1-1] packet indentifier must be in publish if QoS is 1 or 2")
+ curlen += 2
+ assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
+ else:
+ logger.info("[MQTT-2.3.1-5] no packet indentifier in publish if QoS is 0")
+ self.messageIdentifier = 0
+ self.data = buffer[curlen:fhlen + self.fh.remainingLength]
+ if self.fh.QoS == 0:
+ assert self.fh.DUP == False, "[MQTT-2.1.2-4]"
+ return fhlen + self.fh.remainingLength
+
+ def __repr__(self):
+ rc = repr(self.fh)
+ if self.fh.QoS != 0:
+ rc += ", MsgId="+repr(self.messageIdentifier)
+ rc += ", TopicName="+repr(self.topicName)+", Payload="+repr(self.data)+")"
+ return rc
+
+ def __eq__(self, packet):
+ rc = Packets.__eq__(self, packet) and \
+ self.topicName == packet.topicName and \
+ self.data == packet.data
+ if rc and self.fh.QoS != 0:
+ rc = self.messageIdentifier == packet.messageIdentifier
+ return rc
+
+
+class Pubacks(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
+ self.fh = FixedHeaders(PUBACK)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PUBACK
+ fhlen = self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 2, "Puback packet is wrong length %d" % self.fh.remainingLength
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1] Puback reserved bits must be 0"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1] Puback reserved bits must be 0"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Puback reserved bits must be 0"
+ return fhlen + 2
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId "+repr(self.messageIdentifier)
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier
+
+
+class Pubrecs(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
+ self.fh = FixedHeaders(PUBREC)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PUBREC
+ fhlen = self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 2, "Pubrec packet is wrong length %d" % self.fh.remainingLength
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1] Pubrec reserved bits must be 0"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1] Pubrec reserved bits must be 0"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Pubrec reserved bits must be 0"
+ return fhlen + 2
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier
+
+
+class Pubrels(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=1, Retain=False, MsgId=0):
+ self.fh = FixedHeaders(PUBREL)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PUBREL
+ fhlen = self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 2, "Pubrel packet is wrong length %d" % self.fh.remainingLength
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP should be False in PUBREL"
+ assert self.fh.QoS == 1, "[MQTT-2.1.2-1] QoS should be 1 in PUBREL"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] RETAIN should be False in PUBREL"
+ logger.info("[MQTT-3.6.1-1] bits in fixed header for pubrel are ok")
+ return fhlen + 2
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier
+
+
+class Pubcomps(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
+ self.fh = FixedHeaders(PUBCOMP)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PUBCOMP
+ fhlen = self.fh.unpack(buffer)
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ assert self.fh.remainingLength == 2, "Pubcomp packet is wrong length %d" % self.fh.remainingLength
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP should be False in Pubcomp"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1] QoS should be 0 in Pubcomp"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Retain should be false in Pubcomp"
+ return fhlen + 2
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier
+
+
+class Subscribes(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=1, Retain=False, MsgId=0, Data=[]):
+ self.fh = FixedHeaders(SUBSCRIBE)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ # payload - list of topic, qos pairs
+ self.data = Data[:]
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ for d in self.data:
+ buffer += writeUTF(d[0]) + bytes([d[1]])
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == SUBSCRIBE
+ fhlen = self.fh.unpack(buffer)
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ logger.info("[MQTT-2.3.1-1] packet indentifier must be in subscribe")
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
+ leftlen = self.fh.remainingLength - 2
+ self.data = []
+ while leftlen > 0:
+ topic = readUTF(buffer[-leftlen:], leftlen)
+ leftlen -= len(topic) + 2
+ qos = buffer[-leftlen]
+ assert qos in [0, 1, 2], "[MQTT-3-8.3-2] reserved bits must be zero"
+ leftlen -= 1
+ self.data.append((topic, qos))
+ assert len(self.data) > 0, "[MQTT-3.8.3-1] at least one topic, qos pair must be in subscribe"
+ assert leftlen == 0
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP must be false in subscribe"
+ assert self.fh.QoS == 1, "[MQTT-2.1.2-1] QoS must be 1 in subscribe"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] RETAIN must be false in subscribe"
+ return fhlen + self.fh.remainingLength
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+\
+ ", Data="+repr(self.data)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier and \
+ self.data == packet.data
+
+
+class Subacks(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0, Data=[]):
+ self.fh = FixedHeaders(SUBACK)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ # payload - list of qos
+ self.data = Data[:]
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ for d in self.data:
+ buffer += bytes([d])
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == SUBACK
+ fhlen = self.fh.unpack(buffer)
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ leftlen = self.fh.remainingLength - 2
+ self.data = []
+ while leftlen > 0:
+ qos = buffer[-leftlen]
+ assert qos in [0, 1, 2, 0x80], "[MQTT-3.9.3-2] return code in QoS must be 0, 1, 2 or 0x80"
+ leftlen -= 1
+ self.data.append(qos)
+ assert leftlen == 0
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP should be false in suback"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1] QoS should be 0 in suback"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Retain should be false in suback"
+ return fhlen + self.fh.remainingLength
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+\
+ ", Data="+repr(self.data)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier and \
+ self.data == packet.data
+
+
+class Unsubscribes(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=1, Retain=False, MsgId=0, Data=[]):
+ self.fh = FixedHeaders(UNSUBSCRIBE)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ # payload - list of topics
+ self.data = Data[:]
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ for d in self.data:
+ buffer += writeUTF(d)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == UNSUBSCRIBE
+ fhlen = self.fh.unpack(buffer)
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ logger.info("[MQTT-2.3.1-1] packet indentifier must be in unsubscribe")
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
+ leftlen = self.fh.remainingLength - 2
+ self.data = []
+ while leftlen > 0:
+ topic = readUTF(buffer[-leftlen:], leftlen)
+ leftlen -= len(topic) + 2
+ self.data.append(topic)
+ assert leftlen == 0
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 1, "[MQTT-2.1.2-1]"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+ logger.info("[MQTT-3-10.1-1] fixed header bits are 0,0,1,0")
+ return fhlen + self.fh.remainingLength
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+\
+ ", Data="+repr(self.data)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier and \
+ self.data == packet.data
+
+
+class Unsubacks(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
+ self.fh = FixedHeaders(UNSUBACK)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == UNSUBACK
+ fhlen = self.fh.unpack(buffer)
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+ return fhlen + self.fh.remainingLength
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier
+
+
+class Pingreqs(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False):
+ self.fh = FixedHeaders(PINGREQ)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ if buffer != None:
+ self.unpack(buffer)
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PINGREQ
+ fhlen = self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 0
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+ return fhlen
+
+ def __repr__(self):
+ return repr(self.fh)+")"
+
+
+class Pingresps(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False):
+ self.fh = FixedHeaders(PINGRESP)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ if buffer != None:
+ self.unpack(buffer)
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PINGRESP
+ fhlen = self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 0
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+ return fhlen
+
+ def __repr__(self):
+ return repr(self.fh)+")"
+
+classes = [None, Connects, Connacks, Publishes, Pubacks, Pubrecs,
+ Pubrels, Pubcomps, Subscribes, Subacks, Unsubscribes,
+ Unsubacks, Pingreqs, Pingresps, Disconnects]
+
+def unpackPacket(buffer):
+ if MessageType(buffer) != None:
+ packet = classes[MessageType(buffer)]()
+ packet.unpack(buffer)
+ else:
+ packet = None
+ return packet
+
+if __name__ == "__main__":
+ fh = FixedHeaders(CONNECT)
+ tests = [0, 56, 127, 128, 8888, 16383, 16384, 65535, 2097151, 2097152,
+ 20555666, 268435454, 268435455]
+ for x in tests:
+ try:
+ assert x == fh.decode(fh.encode(x))[0]
+ except AssertionError:
+ print("Test failed for x =", x, fh.decode(fh.encode(x)))
+ try:
+ fh.decode(fh.encode(268435456))
+ print("Error")
+ except AssertionError:
+ pass
+
+ for packet in classes[1:]:
+ before = str(packet())
+ after = str(unpackPacket(packet().pack()))
+ try:
+ assert before == after
+ except:
+ print("before:", before, "\nafter:", after)
+ print("End")
+
diff --git a/test/MQTTV3112.py b/test/MQTTV3112.py
new file mode 100644
index 00000000..eb0155de
--- /dev/null
+++ b/test/MQTTV3112.py
@@ -0,0 +1,923 @@
+"""
+*******************************************************************
+ Copyright (c) 2013, 2014 IBM Corp.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ and Eclipse Distribution License v1.0 which accompany this distribution.
+
+ The Eclipse Public License is available at
+ http://www.eclipse.org/legal/epl-v10.html
+ and the Eclipse Distribution License is available at
+ http://www.eclipse.org/org/documents/edl-v10.php.
+
+ Contributors:
+ Ian Craggs - initial implementation and/or documentation
+*******************************************************************
+"""
+from __future__ import print_function
+
+"""
+
+Assertions are used to validate incoming data, but are omitted from outgoing packets. This is
+so that the tests that use this package can send invalid data for error testing.
+
+"""
+
+
+import logging
+
+logger = logging.getLogger("mqttsas")
+
+# Low-level protocol interface
+
+class MQTTException(Exception):
+ pass
+
+
+# Message types
+CONNECT, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL, \
+PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK, \
+PINGREQ, PINGRESP, DISCONNECT = range(1, 15)
+
+packetNames = [ "reserved", \
+"Connect", "Connack", "Publish", "Puback", "Pubrec", "Pubrel", \
+"Pubcomp", "Subscribe", "Suback", "Unsubscribe", "Unsuback", \
+"Pingreq", "Pingresp", "Disconnect"]
+
+classNames = [ "reserved", \
+"Connects", "Connacks", "Publishes", "Pubacks", "Pubrecs", "Pubrels", \
+"Pubcomps", "Subscribes", "Subacks", "Unsubscribes", "Unsubacks", \
+"Pingreqs", "Pingresps", "Disconnects"]
+
+
+def MessageType(byte):
+ if byte != None:
+ rc = ord(byte[0]) >> 4
+ else:
+ rc = None
+ return rc
+
+
+def getPacket(aSocket):
+ "receive the next packet"
+ buf = aSocket.recv(1) # get the first byte fixed header
+ if buf == b"":
+ return None
+ if str(aSocket).find("[closed]") != -1:
+ closed = True
+ else:
+ closed = False
+ if closed:
+ return None
+ # now get the remaining length
+ multiplier = 1
+ remlength = 0
+ while 1:
+ next = aSocket.recv(1)
+ while len(next) == 0:
+ next = aSocket.recv(1)
+ buf += next
+ digit = ord(buf[-1])
+ remlength += (digit & 127) * multiplier
+ if digit & 128 == 0:
+ break
+ multiplier *= 128
+ # receive the remaining length if there is any
+ rest = ''
+ if remlength > 0:
+ while len(rest) < remlength:
+ rest += aSocket.recv(remlength-len(rest))
+ assert len(rest) == remlength
+ return buf + rest
+
+
+class FixedHeaders:
+
+ def __init__(self, aMessageType):
+ self.MessageType = aMessageType
+ self.DUP = False
+ self.QoS = 0
+ self.RETAIN = False
+ self.remainingLength = 0
+
+ def __eq__(self, fh):
+ return self.MessageType == fh.MessageType and \
+ self.DUP == fh.DUP and \
+ self.QoS == fh.QoS and \
+ self.RETAIN == fh.RETAIN # and \
+ # self.remainingLength == fh.remainingLength
+
+ def __repr__(self):
+ "return printable representation of our data"
+ return classNames[self.MessageType]+'(DUP='+repr(self.DUP)+ \
+ ", QoS="+repr(self.QoS)+", Retain="+repr(self.RETAIN)
+
+ def pack(self, length):
+ "pack data into string buffer ready for transmission down socket"
+ buffer = bytes([(self.MessageType << 4) | (self.DUP << 3) |\
+ (self.QoS << 1) | self.RETAIN])
+ self.remainingLength = length
+ buffer += self.encode(length)
+ return buffer
+
+ def encode(self, x):
+ assert 0 <= x <= 268435455
+ buffer = b''
+ while 1:
+ digit = x % 128
+ x //= 128
+ if x > 0:
+ digit |= 0x80
+ buffer += bytes([digit])
+ if x == 0:
+ break
+ return buffer
+
+ def unpack(self, buffer):
+ "unpack data from string buffer into separate fields"
+ b0 = ord(buffer[0])
+ self.MessageType = b0 >> 4
+ self.DUP = ((b0 >> 3) & 0x01) == 1
+ self.QoS = (b0 >> 1) & 0x03
+ self.RETAIN = (b0 & 0x01) == 1
+ (self.remainingLength, bytes) = self.decode(buffer[1:])
+ return bytes + 1 # length of fixed header
+
+ def decode(self, buffer):
+ multiplier = 1
+ value = 0
+ bytes = 0
+ while 1:
+ bytes += 1
+ digit = ord(buffer[0])
+ buffer = buffer[1:]
+ value += (digit & 127) * multiplier
+ if digit & 128 == 0:
+ break
+ multiplier *= 128
+ return (value, bytes)
+
+
+def writeInt16(length):
+ return bytes([length // 256, length % 256])
+
+def readInt16(buf):
+ return ord(buf[0])*256 + ord(buf[1])
+
+def writeUTF(data):
+ # data could be a string, or bytes. If string, encode into bytes with utf-8
+ return writeInt16(len(data)) + (data if type(data) == type(b"") else bytes(data, "utf-8"))
+
+def readUTF(buffer, maxlen):
+ if maxlen >= 2:
+ length = readInt16(buffer)
+ else:
+ raise MQTTException("Not enough data to read string length")
+ maxlen -= 2
+ if length > maxlen:
+ raise MQTTException("Length delimited string too long")
+ buf = buffer[2:2+length].decode("utf-8")
+ logger.info("[MQTT-4.7.3-2] topic names and filters not include null")
+ zz = buf.find("\x00") # look for null in the UTF string
+ if zz != -1:
+ raise MQTTException("[MQTT-1.5.3-2] Null found in UTF data "+buf)
+ """for c in range (0xD800, 0xDFFF):
+ zz = buf.find(chr(c)) # look for D800-DFFF in the UTF string
+ if zz != -1:
+ raise MQTTException("[MQTT-1.5.3-1] D800-DFFF found in UTF data "+buf)
+ """
+ if buf.find("\uFEFF") != -1:
+ logger.info("[MQTT-1.5.3-3] U+FEFF in UTF string")
+ return buf
+
+def writeBytes(buffer):
+ return writeInt16(len(buffer)) + buffer
+
+def readBytes(buffer):
+ length = readInt16(buffer)
+ return buffer[2:2+length]
+
+
+class Packets:
+
+ def pack(self):
+ buffer = self.fh.pack(0)
+ return buffer
+
+ def __repr__(self):
+ return repr(self.fh)
+
+ def __eq__(self, packet):
+ return self.fh == packet.fh if packet else False
+
+
+class Connects(Packets):
+
+ def __init__(self, buffer = None):
+ self.fh = FixedHeaders(CONNECT)
+
+ # variable header
+ self.ProtocolName = "MQTT"
+ self.ProtocolVersion = 4
+ self.CleanSession = True
+ self.WillFlag = False
+ self.WillQoS = 0
+ self.WillRETAIN = 0
+ self.KeepAliveTimer = 30
+ self.usernameFlag = False
+ self.passwordFlag = False
+
+ # Payload
+ self.ClientIdentifier = "" # UTF-8
+ self.WillTopic = None # UTF-8
+ self.WillMessage = None # binary
+ self.username = None # UTF-8
+ self.password = None # binary
+
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ connectFlags = bytes([(self.CleanSession << 1) | (self.WillFlag << 2) | \
+ (self.WillQoS << 3) | (self.WillRETAIN << 5) | \
+ (self.usernameFlag << 6) | (self.passwordFlag << 7)])
+ buffer = writeUTF(self.ProtocolName) + bytes([self.ProtocolVersion]) + \
+ connectFlags + writeInt16(self.KeepAliveTimer)
+ buffer += writeUTF(self.ClientIdentifier)
+ if self.WillFlag:
+ buffer += writeUTF(self.WillTopic)
+ buffer += writeBytes(self.WillMessage)
+ if self.usernameFlag:
+ buffer += writeUTF(self.username)
+ if self.passwordFlag:
+ buffer += writeBytes(self.password)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == CONNECT
+
+ try:
+ fhlen = self.fh.unpack(buffer)
+ packlen = fhlen + self.fh.remainingLength
+ assert len(buffer) >= packlen, "buffer length %d packet length %d" % (len(buffer), packlen)
+ curlen = fhlen # points to after header + remaining length
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1] QoS was not 0, was %d" % self.fh.QoS
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+
+ self.ProtocolName = readUTF(buffer[curlen:], packlen - curlen)
+ curlen += len(self.ProtocolName) + 2
+ assert self.ProtocolName == "MQTT", "Wrong protocol name %s" % self.ProtocolName
+
+ self.ProtocolVersion = ord(buffer[curlen])
+ curlen += 1
+
+ connectFlags = ord(buffer[curlen])
+ assert (connectFlags & 0x01) == 0, "[MQTT-3.1.2-3] reserved connect flag must be 0"
+ self.CleanSession = ((connectFlags >> 1) & 0x01) == 1
+ self.WillFlag = ((connectFlags >> 2) & 0x01) == 1
+ self.WillQoS = (connectFlags >> 3) & 0x03
+ self.WillRETAIN = (connectFlags >> 5) & 0x01
+ self.passwordFlag = ((connectFlags >> 6) & 0x01) == 1
+ self.usernameFlag = ((connectFlags >> 7) & 0x01) == 1
+ curlen +=1
+
+ if self.WillFlag:
+ assert self.WillQoS in [0, 1, 2], "[MQTT-3.1.2-14] will qos must not be 3"
+ else:
+ assert self.WillQoS == 0, "[MQTT-3.1.2-13] will qos must be 0, if will flag is false"
+ assert self.WillRETAIN == False, "[MQTT-3.1.2-14] will retain must be false, if will flag is false"
+
+ self.KeepAliveTimer = readInt16(buffer[curlen:])
+ curlen += 2
+ logger.info("[MQTT-3.1.3-3] Clientid must be present, and first field")
+ logger.info("[MQTT-3.1.3-4] Clientid must be Unicode, and between 0 and 65535 bytes long")
+ self.ClientIdentifier = readUTF(buffer[curlen:], packlen - curlen)
+ curlen += len(self.ClientIdentifier) + 2
+
+ if self.WillFlag:
+ self.WillTopic = readUTF(buffer[curlen:], packlen - curlen)
+ curlen += len(self.WillTopic) + 2
+ self.WillMessage = readBytes(buffer[curlen:])
+ curlen += len(self.WillMessage) + 2
+ logger.info("[[MQTT-3.1.2-9] will topic and will message fields must be present")
+ else:
+ self.WillTopic = self.WillMessage = None
+
+ if self.usernameFlag:
+ assert len(buffer) > curlen+2, "Buffer too short to read username length"
+ self.username = readUTF(buffer[curlen:], packlen - curlen)
+ curlen += len(self.username) + 2
+ logger.info("[MQTT-3.1.2-19] username must be in payload if user name flag is 1")
+ else:
+ logger.info("[MQTT-3.1.2-18] username must not be in payload if user name flag is 0")
+ assert self.passwordFlag == False, "[MQTT-3.1.2-22] password flag must be 0 if username flag is 0"
+
+ if self.passwordFlag:
+ assert len(buffer) > curlen+2, "Buffer too short to read password length"
+ self.password = readBytes(buffer[curlen:])
+ curlen += len(self.password) + 2
+ logger.info("[MQTT-3.1.2-21] password must be in payload if password flag is 0")
+ else:
+ logger.info("[MQTT-3.1.2-20] password must not be in payload if password flag is 0")
+
+ if self.WillFlag and self.usernameFlag and self.passwordFlag:
+ logger.info("[MQTT-3.1.3-1] clientid, will topic, will message, username and password all present")
+
+ assert curlen == packlen, "Packet is wrong length curlen %d != packlen %d"
+ except:
+ logger.exception("[MQTT-3.1.4-1] server must validate connect packet and close connection without connack if it does not conform")
+ raise
+
+
+
+ def __repr__(self):
+ buf = repr(self.fh)+", ProtocolName="+str(self.ProtocolName)+", ProtocolVersion=" +\
+ repr(self.ProtocolVersion)+", CleanSession="+repr(self.CleanSession) +\
+ ", WillFlag="+repr(self.WillFlag)+", KeepAliveTimer=" +\
+ repr(self.KeepAliveTimer)+", ClientId="+str(self.ClientIdentifier) +\
+ ", usernameFlag="+repr(self.usernameFlag)+", passwordFlag="+repr(self.passwordFlag)
+ if self.WillFlag:
+ buf += ", WillQoS=" + repr(self.WillQoS) +\
+ ", WillRETAIN=" + repr(self.WillRETAIN) +\
+ ", WillTopic='"+ self.WillTopic +\
+ "', WillMessage='"+str(self.WillMessage)+"'"
+ if self.username:
+ buf += ", username="+self.username
+ if self.password:
+ buf += ", password="+str(self.password)
+ return buf+")"
+
+ def __eq__(self, packet):
+ rc = Packets.__eq__(self, packet) and \
+ self.ProtocolName == packet.ProtocolName and \
+ self.ProtocolVersion == packet.ProtocolVersion and \
+ self.CleanSession == packet.CleanSession and \
+ self.WillFlag == packet.WillFlag and \
+ self.KeepAliveTimer == packet.KeepAliveTimer and \
+ self.ClientIdentifier == packet.ClientIdentifier and \
+ self.WillFlag == packet.WillFlag
+ if rc and self.WillFlag:
+ rc = self.WillQoS == packet.WillQoS and \
+ self.WillRETAIN == packet.WillRETAIN and \
+ self.WillTopic == packet.WillTopic and \
+ self.WillMessage == packet.WillMessage
+ return rc
+
+
+class Connacks(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, ReturnCode=0):
+ self.fh = FixedHeaders(CONNACK)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ self.flags = 0
+ self.returnCode = ReturnCode
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = bytes([self.flags, self.returnCode])
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 4
+ assert MessageType(buffer) == CONNACK
+ self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 2, "Connack packet is wrong length %d" % self.fh.remainingLength
+ assert ord(buffer[2]) in [0, 1], "Connect Acknowledge Flags"
+ self.returnCode = ord(buffer[3])
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+
+ def __repr__(self):
+ return repr(self.fh)+", Session present="+str((self.flags & 0x01) == 1)+", ReturnCode="+repr(self.returnCode)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.returnCode == packet.returnCode
+
+
+class Disconnects(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False):
+ self.fh = FixedHeaders(DISCONNECT)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ if buffer != None:
+ self.unpack(buffer)
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == DISCONNECT
+ self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 0, "Disconnect packet is wrong length %d" % self.fh.remainingLength
+ logger.info("[MQTT-3.14.1-1] disconnect reserved bits must be 0")
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+
+ def __repr__(self):
+ return repr(self.fh)+")"
+
+
+class Publishes(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0, TopicName="", Payload=b""):
+ self.fh = FixedHeaders(PUBLISH)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.topicName = TopicName
+ self.messageIdentifier = MsgId
+ # payload
+ self.data = Payload
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeUTF(self.topicName)
+ if self.fh.QoS != 0:
+ buffer += writeInt16(self.messageIdentifier)
+ buffer += self.data
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PUBLISH
+ fhlen = self.fh.unpack(buffer)
+ assert self.fh.QoS in [0, 1, 2], "QoS in Publish must be 0, 1, or 2"
+ packlen = fhlen + self.fh.remainingLength
+ assert len(buffer) >= packlen
+ curlen = fhlen
+ try:
+ self.topicName = readUTF(buffer[fhlen:], packlen - curlen)
+ except UnicodeDecodeError:
+ logger.info("[MQTT-3.3.2-1] topic name in publish must be utf-8")
+ raise
+ curlen += len(self.topicName) + 2
+ if self.fh.QoS != 0:
+ self.messageIdentifier = readInt16(buffer[curlen:])
+ logger.info("[MQTT-2.3.1-1] packet indentifier must be in publish if QoS is 1 or 2")
+ curlen += 2
+ assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
+ else:
+ logger.info("[MQTT-2.3.1-5] no packet indentifier in publish if QoS is 0")
+ self.messageIdentifier = 0
+ self.data = buffer[curlen:fhlen + self.fh.remainingLength]
+ if self.fh.QoS == 0:
+ assert self.fh.DUP == False, "[MQTT-2.1.2-4]"
+ return fhlen + self.fh.remainingLength
+
+ def __repr__(self):
+ rc = repr(self.fh)
+ if self.fh.QoS != 0:
+ rc += ", MsgId="+repr(self.messageIdentifier)
+ rc += ", TopicName="+repr(self.topicName)+", Payload="+repr(self.data)+")"
+ return rc
+
+ def __eq__(self, packet):
+ rc = Packets.__eq__(self, packet) and \
+ self.topicName == packet.topicName and \
+ self.data == packet.data
+ if rc and self.fh.QoS != 0:
+ rc = self.messageIdentifier == packet.messageIdentifier
+ return rc
+
+
+class Pubacks(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
+ self.fh = FixedHeaders(PUBACK)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PUBACK
+ fhlen = self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 2, "Puback packet is wrong length %d" % self.fh.remainingLength
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1] Puback reserved bits must be 0"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1] Puback reserved bits must be 0"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Puback reserved bits must be 0"
+ return fhlen + 2
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId "+repr(self.messageIdentifier)
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier
+
+
+class Pubrecs(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
+ self.fh = FixedHeaders(PUBREC)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PUBREC
+ fhlen = self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 2, "Pubrec packet is wrong length %d" % self.fh.remainingLength
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1] Pubrec reserved bits must be 0"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1] Pubrec reserved bits must be 0"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Pubrec reserved bits must be 0"
+ return fhlen + 2
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier
+
+
+class Pubrels(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=1, Retain=False, MsgId=0):
+ self.fh = FixedHeaders(PUBREL)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PUBREL
+ fhlen = self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 2, "Pubrel packet is wrong length %d" % self.fh.remainingLength
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP should be False in PUBREL"
+ assert self.fh.QoS == 1, "[MQTT-2.1.2-1] QoS should be 1 in PUBREL"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] RETAIN should be False in PUBREL"
+ logger.info("[MQTT-3.6.1-1] bits in fixed header for pubrel are ok")
+ return fhlen + 2
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier
+
+
+class Pubcomps(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
+ self.fh = FixedHeaders(PUBCOMP)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PUBCOMP
+ fhlen = self.fh.unpack(buffer)
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ assert self.fh.remainingLength == 2, "Pubcomp packet is wrong length %d" % self.fh.remainingLength
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP should be False in Pubcomp"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1] QoS should be 0 in Pubcomp"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Retain should be false in Pubcomp"
+ return fhlen + 2
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier
+
+
+class Subscribes(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=1, Retain=False, MsgId=0, Data=[]):
+ self.fh = FixedHeaders(SUBSCRIBE)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ # payload - list of topic, qos pairs
+ self.data = Data[:]
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ for d in self.data:
+ buffer += writeUTF(d[0]) + bytes([d[1]])
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == SUBSCRIBE
+ fhlen = self.fh.unpack(buffer)
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ logger.info("[MQTT-2.3.1-1] packet indentifier must be in subscribe")
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
+ leftlen = self.fh.remainingLength - 2
+ self.data = []
+ while leftlen > 0:
+ topic = readUTF(buffer[-leftlen:], leftlen)
+ leftlen -= len(topic) + 2
+ qos = ord(buffer[-leftlen])
+ assert qos in [0, 1, 2], "[MQTT-3-8.3-2] reserved bits must be zero"
+ leftlen -= 1
+ self.data.append((topic, qos))
+ assert len(self.data) > 0, "[MQTT-3.8.3-1] at least one topic, qos pair must be in subscribe"
+ assert leftlen == 0
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP must be false in subscribe"
+ assert self.fh.QoS == 1, "[MQTT-2.1.2-1] QoS must be 1 in subscribe"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] RETAIN must be false in subscribe"
+ return fhlen + self.fh.remainingLength
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+\
+ ", Data="+repr(self.data)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier and \
+ self.data == packet.data
+
+
+class Subacks(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0, Data=[]):
+ self.fh = FixedHeaders(SUBACK)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ # payload - list of qos
+ self.data = Data[:]
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ for d in self.data:
+ buffer += bytes([d])
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == SUBACK
+ fhlen = self.fh.unpack(buffer)
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ leftlen = self.fh.remainingLength - 2
+ self.data = []
+ while leftlen > 0:
+ qos = buffer[-leftlen]
+ assert qos in [0, 1, 2, 0x80], "[MQTT-3.9.3-2] return code in QoS must be 0, 1, 2 or 0x80"
+ leftlen -= 1
+ self.data.append(qos)
+ assert leftlen == 0
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1] DUP should be false in suback"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1] QoS should be 0 in suback"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1] Retain should be false in suback"
+ return fhlen + self.fh.remainingLength
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+\
+ ", Data="+repr(self.data)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier and \
+ self.data == packet.data
+
+
+class Unsubscribes(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=1, Retain=False, MsgId=0, Data=[]):
+ self.fh = FixedHeaders(UNSUBSCRIBE)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ # payload - list of topics
+ self.data = Data[:]
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ for d in self.data:
+ buffer += writeUTF(d)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == UNSUBSCRIBE
+ fhlen = self.fh.unpack(buffer)
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ logger.info("[MQTT-2.3.1-1] packet indentifier must be in unsubscribe")
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
+ leftlen = self.fh.remainingLength - 2
+ self.data = []
+ while leftlen > 0:
+ topic = readUTF(buffer[-leftlen:], leftlen)
+ leftlen -= len(topic) + 2
+ self.data.append(topic)
+ assert leftlen == 0
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 1, "[MQTT-2.1.2-1]"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+ logger.info("[MQTT-3-10.1-1] fixed header bits are 0,0,1,0")
+ return fhlen + self.fh.remainingLength
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+\
+ ", Data="+repr(self.data)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier and \
+ self.data == packet.data
+
+
+class Unsubacks(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False, MsgId=0):
+ self.fh = FixedHeaders(UNSUBACK)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ # variable header
+ self.messageIdentifier = MsgId
+ if buffer != None:
+ self.unpack(buffer)
+
+ def pack(self):
+ buffer = writeInt16(self.messageIdentifier)
+ buffer = self.fh.pack(len(buffer)) + buffer
+ return buffer
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == UNSUBACK
+ fhlen = self.fh.unpack(buffer)
+ assert len(buffer) >= fhlen + self.fh.remainingLength
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.messageIdentifier > 0, "[MQTT-2.3.1-1] packet indentifier must be > 0"
+ self.messageIdentifier = readInt16(buffer[fhlen:])
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+ return fhlen + self.fh.remainingLength
+
+ def __repr__(self):
+ return repr(self.fh)+", MsgId="+repr(self.messageIdentifier)+")"
+
+ def __eq__(self, packet):
+ return Packets.__eq__(self, packet) and \
+ self.messageIdentifier == packet.messageIdentifier
+
+
+class Pingreqs(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False):
+ self.fh = FixedHeaders(PINGREQ)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ if buffer != None:
+ self.unpack(buffer)
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PINGREQ
+ fhlen = self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 0
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+ return fhlen
+
+ def __repr__(self):
+ return repr(self.fh)+")"
+
+
+class Pingresps(Packets):
+
+ def __init__(self, buffer=None, DUP=False, QoS=0, Retain=False):
+ self.fh = FixedHeaders(PINGRESP)
+ self.fh.DUP = DUP
+ self.fh.QoS = QoS
+ self.fh.Retain = Retain
+ if buffer != None:
+ self.unpack(buffer)
+
+ def unpack(self, buffer):
+ assert len(buffer) >= 2
+ assert MessageType(buffer) == PINGRESP
+ fhlen = self.fh.unpack(buffer)
+ assert self.fh.remainingLength == 0
+ assert self.fh.DUP == False, "[MQTT-2.1.2-1]"
+ assert self.fh.QoS == 0, "[MQTT-2.1.2-1]"
+ assert self.fh.RETAIN == False, "[MQTT-2.1.2-1]"
+ return fhlen
+
+ def __repr__(self):
+ return repr(self.fh)+")"
+
+classes = [None, Connects, Connacks, Publishes, Pubacks, Pubrecs,
+ Pubrels, Pubcomps, Subscribes, Subacks, Unsubscribes,
+ Unsubacks, Pingreqs, Pingresps, Disconnects]
+
+def unpackPacket(buffer):
+ if MessageType(buffer) != None:
+ packet = classes[MessageType(buffer)]()
+ packet.unpack(buffer)
+ else:
+ packet = None
+ return packet
+
+if __name__ == "__main__":
+ fh = FixedHeaders(CONNECT)
+ tests = [0, 56, 127, 128, 8888, 16383, 16384, 65535, 2097151, 2097152,
+ 20555666, 268435454, 268435455]
+ for x in tests:
+ try:
+ assert x == fh.decode(fh.encode(x))[0]
+ except AssertionError:
+ print("Test failed for x =", x, fh.decode(fh.encode(x)))
+ try:
+ fh.decode(fh.encode(268435456))
+ print("Error")
+ except AssertionError:
+ pass
+
+ for packet in classes[1:]:
+ before = str(packet())
+ after = str(unpackPacket(packet().pack()))
+ try:
+ assert before == after
+ except:
+ print("before:", before, "\nafter:", after)
+ print("End")
+
diff --git a/test/mqttsas.py b/test/mqttsas.py
new file mode 100755
index 00000000..02c3104f
--- /dev/null
+++ b/test/mqttsas.py
@@ -0,0 +1,115 @@
+"""
+*******************************************************************
+ Copyright (c) 2013, 2016 IBM Corp.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ and Eclipse Distribution License v1.0 which accompany this distribution.
+
+ The Eclipse Public License is available at
+ http://www.eclipse.org/legal/epl-v10.html
+ and the Eclipse Distribution License is available at
+ http://www.eclipse.org/org/documents/edl-v10.php.
+
+ Contributors:
+ Ian Craggs - initial implementation and/or documentation
+*******************************************************************
+"""
+
+# Trace MQTT traffic
+import MQTTV311 as MQTTV3
+
+import socket, sys, select, traceback, datetime, os, socketserver
+
+logging = True
+myWindow = None
+
+
+def timestamp():
+ now = datetime.datetime.now()
+ return now.strftime('%Y%m%d %H%M%S')+str(float("."+str(now.microsecond)))[1:]
+
+
+class MyHandler(socketserver.StreamRequestHandler):
+
+ def handle(self):
+ if not hasattr(self, "ids"):
+ self.ids = {}
+ if not hasattr(self, "versions"):
+ self.versions = {}
+ inbuf = True
+ i = o = e = None
+ try:
+ clients = self.request
+ brokers = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ brokers.connect((brokerhost, brokerport))
+ while inbuf != None:
+ (i, o, e) = select.select([clients, brokers], [], [])
+ for s in i:
+ if s == clients:
+ inbuf = MQTTV3.getPacket(clients) # get one packet
+ if inbuf == None:
+ break
+ try:
+ packet = MQTTV3.unpackPacket(inbuf)
+ if packet.fh.MessageType == MQTTV3.PUBLISH and \
+ packet.topicName == "MQTTSAS topic" and \
+ packet.data == b"TERMINATE":
+ print("Terminating client", self.ids[id(clients)])
+ brokers.close()
+ clients.close()
+ break
+ elif packet.fh.MessageType == MQTTV3.CONNECT:
+ self.ids[id(clients)] = packet.ClientIdentifier
+ self.versions[id(clients)] = 3
+ print(timestamp() , "C to S", self.ids[id(clients)], repr(packet))
+ print([hex(b) for b in inbuf])
+ print(inbuf)
+ except:
+ traceback.print_exc()
+ brokers.send(inbuf) # pass it on
+ elif s == brokers:
+ inbuf = MQTTV3.getPacket(brokers) # get one packet
+ if inbuf == None:
+ break
+ try:
+ print(timestamp(), "S to C", self.ids[id(clients)], repr(MQTTV3.unpackPacket(inbuf)))
+ except:
+ traceback.print_exc()
+ clients.send(inbuf)
+ print(timestamp()+" client "+self.ids[id(clients)]+" connection closing")
+ except:
+ print(repr((i, o, e)), repr(inbuf))
+ traceback.print_exc()
+ if id(clients) in self.ids.keys():
+ del self.ids[id(clients)]
+ elif id(clients) in self.versions.keys():
+ del self.versions[id(clients)]
+
+class ThreadingTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
+ pass
+
+def run():
+ global brokerhost, brokerport
+ myhost = 'localhost'
+ if len(sys.argv) > 1:
+ brokerhost = sys.argv[1]
+ else:
+ brokerhost = 'localhost'
+
+ if len(sys.argv) > 2:
+ brokerport = int(sys.argv[2])
+ else:
+ brokerport = 1883
+
+ if brokerhost == myhost:
+ myport = brokerport + 1
+ else:
+ myport = 1883
+
+ print("Listening on port", str(myport)+", broker on port", brokerport)
+ s = ThreadingTCPServer(("", myport), MyHandler)
+ s.serve_forever()
+
+if __name__ == "__main__":
+ run()
diff --git a/test/mqttsas2.py b/test/mqttsas2.py
new file mode 100755
index 00000000..b1c7c9f5
--- /dev/null
+++ b/test/mqttsas2.py
@@ -0,0 +1,117 @@
+"""
+*******************************************************************
+ Copyright (c) 2013, 2016 IBM Corp.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ and Eclipse Distribution License v1.0 which accompany this distribution.
+
+ The Eclipse Public License is available at
+ http://www.eclipse.org/legal/epl-v10.html
+ and the Eclipse Distribution License is available at
+ http://www.eclipse.org/org/documents/edl-v10.php.
+
+ Contributors:
+ Ian Craggs - initial implementation and/or documentation
+*******************************************************************
+"""
+from __future__ import print_function
+
+# Trace MQTT traffic
+import MQTTV3112 as MQTTV3
+
+import socket, sys, select, traceback, datetime, os
+import SocketServer as socketserver
+
+logging = True
+myWindow = None
+
+
+def timestamp():
+ now = datetime.datetime.now()
+ return now.strftime('%Y%m%d %H%M%S')+str(float("."+str(now.microsecond)))[1:]
+
+
+class MyHandler(socketserver.StreamRequestHandler):
+
+ def handle(self):
+ if not hasattr(self, "ids"):
+ self.ids = {}
+ if not hasattr(self, "versions"):
+ self.versions = {}
+ inbuf = True
+ i = o = e = None
+ try:
+ clients = self.request
+ brokers = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ brokers.connect((brokerhost, brokerport))
+ while inbuf != None:
+ (i, o, e) = select.select([clients, brokers], [], [])
+ for s in i:
+ if s == clients:
+ inbuf = MQTTV3.getPacket(clients) # get one packet
+ if inbuf == None:
+ break
+ try:
+ packet = MQTTV3.unpackPacket(inbuf)
+ if packet.fh.MessageType == MQTTV3.PUBLISH and \
+ packet.topicName == "MQTTSAS topic" and \
+ packet.data == b"TERMINATE":
+ print("Terminating client", self.ids[id(clients)])
+ brokers.close()
+ clients.close()
+ break
+ elif packet.fh.MessageType == MQTTV3.CONNECT:
+ self.ids[id(clients)] = packet.ClientIdentifier
+ self.versions[id(clients)] = 3
+ print(timestamp() , "C to S", self.ids[id(clients)], repr(packet))
+ #print([hex(b) for b in inbuf])
+ #print(inbuf)
+ except:
+ traceback.print_exc()
+ brokers.send(inbuf) # pass it on
+ elif s == brokers:
+ inbuf = MQTTV3.getPacket(brokers) # get one packet
+ if inbuf == None:
+ break
+ try:
+ print(timestamp(), "S to C", self.ids[id(clients)], repr(MQTTV3.unpackPacket(inbuf)))
+ except:
+ traceback.print_exc()
+ clients.send(inbuf)
+ print(timestamp()+" client "+self.ids[id(clients)]+" connection closing")
+ except:
+ print(repr((i, o, e)), repr(inbuf))
+ traceback.print_exc()
+ if id(clients) in self.ids.keys():
+ del self.ids[id(clients)]
+ elif id(clients) in self.versions.keys():
+ del self.versions[id(clients)]
+
+class ThreadingTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
+ pass
+
+def run():
+ global brokerhost, brokerport
+ myhost = 'localhost'
+ if len(sys.argv) > 1:
+ brokerhost = sys.argv[1]
+ else:
+ brokerhost = 'localhost'
+
+ if len(sys.argv) > 2:
+ brokerport = int(sys.argv[2])
+ else:
+ brokerport = 1883
+
+ if brokerhost == myhost:
+ myport = brokerport + 1
+ else:
+ myport = 1883
+
+ print("Listening on port", str(myport)+", broker on port", brokerport)
+ s = ThreadingTCPServer(("", myport), MyHandler)
+ s.serve_forever()
+
+if __name__ == "__main__":
+ run()
diff --git a/test/python/mqttasync_module.c b/test/python/mqttasync_module.c
new file mode 100644
index 00000000..f7dc6ff0
--- /dev/null
+++ b/test/python/mqttasync_module.c
@@ -0,0 +1,1026 @@
+#include
+
+#include "MQTTAsync.h"
+#include "LinkedList.h"
+
+static PyObject *MqttV3Error;
+
+
+static PyObject* mqttv3_create(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ char* serverURI;
+ char* clientId;
+ int persistence_option = MQTTCLIENT_PERSISTENCE_DEFAULT;
+ PyObject *pyoptions = NULL, *temp;
+ MQTTAsync_createOptions options = MQTTAsync_createOptions_initializer;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "ss|iO", &serverURI, &clientId,
+ &persistence_option, &pyoptions))
+ return NULL;
+
+ if (persistence_option != MQTTCLIENT_PERSISTENCE_DEFAULT
+ && persistence_option != MQTTCLIENT_PERSISTENCE_NONE)
+ {
+ PyErr_SetString(PyExc_TypeError, "persistence must be DEFAULT or NONE");
+ return NULL;
+ }
+
+ if (pyoptions)
+ {
+
+ if (!PyDict_Check(pyoptions))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "Create options parameter must be a dictionary");
+ return NULL;
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "sendWhileDisconnected"))
+ != NULL)
+ {
+ if (PyInt_Check(temp))
+ options.sendWhileDisconnected = (int) PyInt_AsLong(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "sendWhileDisconnected value must be int");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "maxBufferedMessages"))
+ != NULL)
+ {
+ if (PyInt_Check(temp))
+ options.maxBufferedMessages = (int) PyInt_AsLong(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "maxBufferedMessages value must be int");
+ return NULL;
+ }
+ }
+ rc = MQTTAsync_createWithOptions(&c, serverURI, clientId, persistence_option, NULL, &options);
+ }
+ else
+ rc = MQTTAsync_create(&c, serverURI, clientId, persistence_option, NULL);
+
+
+ return Py_BuildValue("ik", rc, c);
+}
+
+
+static List* callbacks = NULL;
+static List* connected_callbacks = NULL;
+
+enum msgTypes
+{
+ CONNECT, PUBLISH, SUBSCRIBE, SUBSCRIBE_MANY, UNSUBSCRIBE
+};
+
+typedef struct
+{
+ MQTTAsync c;
+ PyObject *context;
+ PyObject *cl, *ma, *dc;
+} CallbackEntry;
+
+
+typedef struct
+{
+ MQTTAsync c;
+ PyObject *context;
+ PyObject *co;
+} ConnectedEntry;
+
+
+int clientCompare(void* a, void* b)
+{
+ CallbackEntry* e = (CallbackEntry*) a;
+ return e->c == (MQTTAsync) b;
+}
+
+
+int connectedCompare(void* a, void* b)
+{
+ ConnectedEntry* e = (ConnectedEntry*) a;
+ return e->c == (MQTTAsync) b;
+}
+
+
+void connected(void* context, char* cause)
+{
+ /* call the right Python function, using the context */
+ PyObject *arglist;
+ PyObject *result;
+ ConnectedEntry* e = context;
+ PyGILState_STATE gstate;
+
+ gstate = PyGILState_Ensure();
+ arglist = Py_BuildValue("Os", e->context, cause);
+ result = PyEval_CallObject(e->co, arglist);
+ Py_DECREF(arglist);
+ PyGILState_Release(gstate);
+}
+
+
+void connectionLost(void* context, char* cause)
+{
+ /* call the right Python function, using the context */
+ PyObject *arglist;
+ PyObject *result;
+ CallbackEntry* e = context;
+ PyGILState_STATE gstate;
+
+ gstate = PyGILState_Ensure();
+ arglist = Py_BuildValue("Os", e->context, cause);
+ result = PyEval_CallObject(e->cl, arglist);
+ Py_DECREF(arglist);
+ PyGILState_Release(gstate);
+}
+
+
+int messageArrived(void* context, char* topicName, int topicLen,
+ MQTTAsync_message* message)
+{
+ PyObject *result = NULL;
+ CallbackEntry* e = context;
+ int rc = -99;
+ PyGILState_STATE gstate;
+
+ gstate = PyGILState_Ensure();
+ if (topicLen == 0)
+ result = PyObject_CallFunction(e->ma, "Os{ss#sisisisi}", e->context,
+ topicName, "payload", message->payload, message->payloadlen,
+ "qos", message->qos, "retained", message->retained, "dup",
+ message->dup, "msgid", message->msgid);
+ else
+ result = PyObject_CallFunction(e->ma, "Os#{ss#sisisisi}", e->context,
+ topicName, topicLen, "payload", message->payload,
+ message->payloadlen, "qos", message->qos, "retained",
+ message->retained, "dup", message->dup, "msgid",
+ message->msgid);
+ if (result)
+ {
+ if (PyInt_Check(result))
+ rc = (int) PyInt_AsLong(result);
+ Py_DECREF(result);
+ }
+ PyGILState_Release(gstate);
+ MQTTAsync_free(topicName);
+ MQTTAsync_freeMessage(&message);
+ return rc;
+}
+
+
+void deliveryComplete(void* context, MQTTAsync_token dt)
+{
+ PyObject *arglist;
+ PyObject *result;
+ CallbackEntry* e = context;
+ PyGILState_STATE gstate;
+
+ gstate = PyGILState_Ensure();
+ arglist = Py_BuildValue("Oi", e->context, dt);
+ result = PyEval_CallObject(e->dc, arglist);
+ Py_DECREF(arglist);
+ PyGILState_Release(gstate);
+}
+
+
+static PyObject* mqttv3_setcallbacks(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ CallbackEntry* e = NULL;
+ int rc;
+
+ e = malloc(sizeof(CallbackEntry));
+
+ if (!PyArg_ParseTuple(args, "kOOOO", &c, (PyObject**) &e->context, &e->cl,
+ &e->ma, &e->dc))
+ return NULL;
+ e->c = c;
+
+ if ((e->cl != Py_None && !PyCallable_Check(e->cl))
+ || (e->ma != Py_None && !PyCallable_Check(e->ma))
+ || (e->dc != Py_None && !PyCallable_Check(e->dc)))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "3rd, 4th and 5th parameters must be callable or None");
+ return NULL;
+ }
+
+ Py_BEGIN_ALLOW_THREADS
+ rc = MQTTAsync_setCallbacks(c, e, connectionLost, messageArrived, deliveryComplete);
+ Py_END_ALLOW_THREADS
+
+ if (rc == MQTTASYNC_SUCCESS)
+ {
+ ListElement* temp = NULL;
+ if ((temp = ListFindItem(callbacks, c, clientCompare)) != NULL)
+ {
+ ListDetach(callbacks, temp->content);
+ free(temp->content);
+ }
+ ListAppend(callbacks, e, sizeof(e));
+ Py_XINCREF(e->cl);
+ Py_XINCREF(e->ma);
+ Py_XINCREF(e->dc);
+ Py_XINCREF(e->context);
+ }
+
+ return Py_BuildValue("i", rc);
+}
+
+
+static PyObject* mqttv3_setconnected(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ ConnectedEntry* e = NULL;
+ int rc;
+
+ e = malloc(sizeof(ConnectedEntry));
+
+ if (!PyArg_ParseTuple(args, "kOO", &c, (PyObject**) &e->context, &e->co))
+ return NULL;
+ e->c = c;
+
+ if (e->co != Py_None && !PyCallable_Check(e->co))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "3rd parameter must be callable or None");
+ return NULL;
+ }
+
+ Py_BEGIN_ALLOW_THREADS
+ rc = MQTTAsync_setConnected(c, e, connected);
+ Py_END_ALLOW_THREADS
+
+ if (rc == MQTTASYNC_SUCCESS)
+ {
+ ListElement* temp = NULL;
+ if ((temp = ListFindItem(connected_callbacks, c, connectedCompare)) != NULL)
+ {
+ ListDetach(connected_callbacks, temp->content);
+ free(temp->content);
+ }
+ ListAppend(connected_callbacks, e, sizeof(e));
+ Py_XINCREF(e->co);
+ Py_XINCREF(e->context);
+ }
+
+ return Py_BuildValue("i", rc);
+}
+
+
+typedef struct
+{
+ MQTTAsync c;
+ PyObject *context;
+ PyObject *onSuccess, *onFailure;
+ enum msgTypes msgType;
+} ResponseEntry;
+
+
+void onSuccess(void* context, MQTTAsync_successData* response)
+{
+ PyObject *result = NULL;
+ ResponseEntry* e = context;
+ PyGILState_STATE gstate;
+
+ gstate = PyGILState_Ensure();
+ switch (e->msgType)
+ {
+ case CONNECT:
+ result = PyObject_CallFunction(e->onSuccess, "O{sisiss}", (e->context) ? e->context : Py_None,
+ "MQTTVersion", response->alt.connect.MQTTVersion,
+ "sessionPresent", response->alt.connect.sessionPresent,
+ "serverURI", response->alt.connect.serverURI);
+ break;
+
+ case PUBLISH:
+ result = PyObject_CallFunction(e->onSuccess, "O{si ss s{ss# sisi}}", (e->context) ? e->context : Py_None,
+ "token", response->token,
+ "destinationName", response->alt.pub.destinationName,
+ "message",
+ "payload", response->alt.pub.message.payload,
+ response->alt.pub.message.payloadlen,
+ "qos", response->alt.pub.message.qos,
+ "retained", response->alt.pub.message.retained);
+ break;
+
+ case SUBSCRIBE:
+ result = PyObject_CallFunction(e->onSuccess, "O{sisi}", (e->context) ? e->context : Py_None,
+ "token", response->token,
+ "qos", response->alt.qos);
+ break;
+
+ case SUBSCRIBE_MANY:
+ result = PyObject_CallFunction(e->onSuccess, "O{sis[i]}", (e->context) ? e->context : Py_None,
+ "token", response->token,
+ "qosList", response->alt.qosList[0]);
+ break;
+
+ case UNSUBSCRIBE:
+ result = PyObject_CallFunction(e->onSuccess, "O{si}", (e->context) ? e->context : Py_None,
+ "token", response->token);
+ break;
+ }
+ if (result)
+ {
+ Py_DECREF(result);
+ printf("decrementing reference count for result\n");
+ }
+ PyGILState_Release(gstate);
+ free(e);
+}
+
+
+void onFailure(void* context, MQTTAsync_failureData* response)
+{
+ PyObject *result = NULL;
+ PyObject *arglist = NULL;
+ ResponseEntry* e = context;
+ PyGILState_STATE gstate;
+
+ gstate = PyGILState_Ensure();
+
+ // TODO: convert response into Python structure
+ if (e->context)
+ arglist = Py_BuildValue("OO", e->context, response);
+ else
+ arglist = Py_BuildValue("OO", Py_None, response);
+
+ result = PyEval_CallObject(e->onFailure, arglist);
+ Py_DECREF(arglist);
+ PyGILState_Release(gstate);
+ free(e);
+}
+
+
+/* return true if ok, false otherwise */
+int getResponseOptions(MQTTAsync c, PyObject *pyoptions, MQTTAsync_responseOptions* responseOptions,
+ enum msgTypes msgType)
+{
+ PyObject *temp = NULL;
+
+ if (!pyoptions)
+ return 1;
+
+ if (!PyDict_Check(pyoptions))
+ {
+ PyErr_SetString(PyExc_TypeError, "Response options must be a dictionary");
+ return 0;
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "onSuccess")) != NULL)
+ {
+ if (PyCallable_Check(temp)) /* temp points to Python function */
+ responseOptions->onSuccess = (MQTTAsync_onSuccess*)temp;
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "onSuccess value must be callable");
+ return 0;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "onFailure")) != NULL)
+ {
+ if (PyCallable_Check(temp))
+ responseOptions->onFailure = (MQTTAsync_onFailure*)temp;
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "onFailure value must be callable");
+ return 0;
+ }
+ }
+
+ responseOptions->context = PyDict_GetItemString(pyoptions, "context");
+
+ if (responseOptions->onFailure || responseOptions->onSuccess)
+ {
+ ResponseEntry* r = malloc(sizeof(ResponseEntry));
+ r->c = c;
+ r->context = responseOptions->context;
+ responseOptions->context = r;
+ r->onSuccess = (PyObject*)responseOptions->onSuccess;
+ responseOptions->onSuccess = onSuccess;
+ r->onFailure = (PyObject*)responseOptions->onFailure;
+ responseOptions->onFailure = onFailure;
+ r->msgType = msgType;
+ }
+
+ return 1; /* not an error, if we get here */
+}
+
+
+static PyObject* mqttv3_connect(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ PyObject *pyoptions = NULL, *temp;
+ MQTTAsync_connectOptions connectOptions = MQTTAsync_connectOptions_initializer;
+ MQTTAsync_willOptions willOptions = MQTTAsync_willOptions_initializer;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "k|O", &c, &pyoptions))
+ return NULL;
+
+ if (!pyoptions)
+ goto skip;
+
+ if (!PyDict_Check(pyoptions))
+ {
+ PyErr_SetString(PyExc_TypeError, "2nd parameter must be a dictionary");
+ return NULL;
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "onSuccess")) != NULL)
+ {
+ if (PyCallable_Check(temp)) /* temp points to Python function */
+ connectOptions.onSuccess = (MQTTAsync_onSuccess*)temp;
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "onSuccess value must be callable");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "onFailure")) != NULL)
+ {
+ if (PyCallable_Check(temp))
+ connectOptions.onFailure = (MQTTAsync_onFailure*)temp;
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "onFailure value must be callable");
+ return NULL;
+ }
+ }
+
+ connectOptions.context = PyDict_GetItemString(pyoptions, "context");
+
+ if (connectOptions.onFailure || connectOptions.onSuccess)
+ {
+ ResponseEntry* r = malloc(sizeof(ResponseEntry));
+ r->c = c;
+ r->context = connectOptions.context;
+ connectOptions.context = r;
+ r->onSuccess = (PyObject*)connectOptions.onSuccess;
+ connectOptions.onSuccess = onSuccess;
+ r->onFailure = (PyObject*)connectOptions.onFailure;
+ connectOptions.onFailure = onFailure;
+ r->msgType = CONNECT;
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "keepAliveInterval")) != NULL)
+ {
+ if (PyInt_Check(temp))
+ connectOptions.keepAliveInterval = (int) PyInt_AsLong(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "keepAliveLiveInterval value must be int");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "cleansession")) != NULL)
+ {
+ if (PyInt_Check(temp))
+ connectOptions.cleansession = (int) PyInt_AsLong(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "cleansession value must be int");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "will")) != NULL)
+ {
+ if (PyDict_Check(temp))
+ {
+ PyObject *wtemp = NULL;
+ if ((wtemp = PyDict_GetItemString(temp, "topicName")) == NULL)
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "will topicName value must be set");
+ return NULL;
+ }
+ else
+ {
+ if (PyString_Check(wtemp))
+ willOptions.topicName = PyString_AsString(wtemp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "will topicName value must be string");
+ return NULL;
+ }
+ }
+ if ((wtemp = PyDict_GetItemString(temp, "message")) == NULL)
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "will message value must be set");
+ return NULL;
+ }
+ else
+ {
+ if (PyString_Check(wtemp))
+ willOptions.message = PyString_AsString(wtemp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "will message value must be string");
+ return NULL;
+ }
+ }
+ if ((wtemp = PyDict_GetItemString(temp, "retained")) != NULL)
+ {
+ if (PyInt_Check(wtemp))
+ willOptions.retained = (int) PyInt_AsLong(wtemp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "will retained value must be int");
+ return NULL;
+ }
+ }
+ if ((wtemp = PyDict_GetItemString(temp, "qos")) != NULL)
+ {
+ if (PyInt_Check(wtemp))
+ willOptions.qos = (int) PyInt_AsLong(wtemp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "will qos value must be int");
+ return NULL;
+ }
+ }
+ connectOptions.will = &willOptions;
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "will value must be dictionary");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "username")) != NULL)
+ {
+ if (PyString_Check(temp))
+ connectOptions.username = PyString_AsString(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "username value must be string");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "password")) != NULL)
+ {
+ if (PyString_Check(temp))
+ connectOptions.username = PyString_AsString(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "password value must be string");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "automaticReconnect")) != NULL)
+ {
+ if (PyInt_Check(temp))
+ connectOptions.automaticReconnect = (int) PyInt_AsLong(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "automatic reconnect value must be int");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "minRetryInterval")) != NULL)
+ {
+ if (PyInt_Check(temp))
+ connectOptions.minRetryInterval = (int) PyInt_AsLong(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "minRetryInterval value must be int");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "maxRetryInterval")) != NULL)
+ {
+ if (PyInt_Check(temp))
+ connectOptions.maxRetryInterval = (int) PyInt_AsLong(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "maxRetryInterval value must be int");
+ return NULL;
+ }
+ }
+
+skip:
+ Py_BEGIN_ALLOW_THREADS
+ rc = MQTTAsync_connect(c, &connectOptions);
+ Py_END_ALLOW_THREADS
+ return Py_BuildValue("i", rc);
+}
+
+
+static PyObject* mqttv3_disconnect(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ MQTTAsync_disconnectOptions options = MQTTAsync_disconnectOptions_initializer;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "k|i", &c, &options.timeout))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS
+ rc = MQTTAsync_disconnect(c, &options);
+ Py_END_ALLOW_THREADS
+ return Py_BuildValue("i", rc);
+}
+
+
+static PyObject* mqttv3_isConnected(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "k", &c))
+ return NULL;
+ Py_BEGIN_ALLOW_THREADS
+ rc = MQTTAsync_isConnected(c);
+ Py_END_ALLOW_THREADS
+ return Py_BuildValue("i", rc);
+}
+
+
+static PyObject* mqttv3_subscribe(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ MQTTAsync_responseOptions response = MQTTAsync_responseOptions_initializer;
+ PyObject *pyoptions = NULL;
+ char* topic;
+ int qos = 2;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "ks|iO", &c, &topic, &qos, &pyoptions))
+ return NULL;
+
+ if (!getResponseOptions(c, pyoptions, &response, SUBSCRIBE))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS;
+ rc = MQTTAsync_subscribe(c, topic, qos, &response);
+ Py_END_ALLOW_THREADS;
+ return Py_BuildValue("i", rc);
+}
+
+
+static PyObject* mqttv3_subscribeMany(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ MQTTAsync_responseOptions response = MQTTAsync_responseOptions_initializer;
+ PyObject* topicList;
+ PyObject* qosList;
+ PyObject *pyoptions = NULL;
+
+ int count;
+ char** topics;
+ int* qoss;
+
+ int i, rc = 0;
+
+ if (!PyArg_ParseTuple(args, "kOO|O", &c, &topicList, &qosList, &pyoptions))
+ return NULL;
+
+ if (!getResponseOptions(c, pyoptions, &response, SUBSCRIBE))
+ return NULL;
+
+ if (!PySequence_Check(topicList) || !PySequence_Check(qosList))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "3rd and 4th parameters must be sequences");
+ return NULL;
+ }
+
+ if ((count = PySequence_Length(topicList)) != PySequence_Length(qosList))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "3rd and 4th parameters must be sequences of the same length");
+ return NULL;
+ }
+
+ topics = malloc(count * sizeof(char*));
+ for (i = 0; i < count; ++i)
+ topics[i] = PyString_AsString(PySequence_GetItem(topicList, i));
+
+ qoss = malloc(count * sizeof(int));
+ for (i = 0; i < count; ++i)
+ qoss[i] = (int) PyInt_AsLong(PySequence_GetItem(qosList, i));
+
+ Py_BEGIN_ALLOW_THREADS
+ rc = MQTTAsync_subscribeMany(c, count, topics, qoss, &response);
+ Py_END_ALLOW_THREADS
+
+ for (i = 0; i < count; ++i)
+ PySequence_SetItem(qosList, i, PyInt_FromLong((long) qoss[i]));
+
+ free(topics);
+ free(qoss);
+
+ if (rc == MQTTASYNC_SUCCESS)
+ return Py_BuildValue("iO", rc, qosList);
+ else
+ return Py_BuildValue("i", rc);
+}
+
+
+static PyObject* mqttv3_unsubscribe(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ MQTTAsync_responseOptions response = MQTTAsync_responseOptions_initializer;
+ PyObject *pyoptions = NULL;
+ char* topic;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "ks|O", &c, &topic, &pyoptions))
+ return NULL;
+
+ if (!getResponseOptions(c, pyoptions, &response, UNSUBSCRIBE))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS
+ rc = MQTTAsync_unsubscribe(c, topic, &response);
+ Py_END_ALLOW_THREADS
+ return Py_BuildValue("i", rc);
+}
+
+
+static PyObject* mqttv3_unsubscribeMany(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ MQTTAsync_responseOptions response = MQTTAsync_responseOptions_initializer;
+ PyObject* topicList;
+ PyObject *pyoptions = NULL;
+
+ int count;
+ char** topics;
+
+ int i, rc = 0;
+
+ if (!PyArg_ParseTuple(args, "kO|O", &c, &topicList, &pyoptions))
+ return NULL;
+
+ if (!getResponseOptions(c, pyoptions, &response, UNSUBSCRIBE))
+ return NULL;
+
+ if (!PySequence_Check(topicList))
+ {
+ PyErr_SetString(PyExc_TypeError, "3rd parameter must be sequences");
+ return NULL;
+ }
+
+ count = PySequence_Length(topicList);
+ topics = malloc(count * sizeof(char*));
+ for (i = 0; i < count; ++i)
+ topics[i] = PyString_AsString(PySequence_GetItem(topicList, i));
+
+ Py_BEGIN_ALLOW_THREADS
+ rc = MQTTAsync_unsubscribeMany(c, count, topics, &response);
+ Py_END_ALLOW_THREADS
+
+ free(topics);
+
+ return Py_BuildValue("i", rc);
+}
+
+
+static PyObject* mqttv3_send(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ char* destinationName;
+ int payloadlen;
+ void* payload;
+ int qos = 0;
+ int retained = 0;
+ MQTTAsync_responseOptions response = MQTTAsync_responseOptions_initializer;
+ PyObject *pyoptions = NULL;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "kss#|iiO", &c, &destinationName, &payload,
+ &payloadlen, &qos, &retained, &pyoptions))
+ return NULL;
+
+ if (!getResponseOptions(c, pyoptions, &response, PUBLISH))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS
+ rc = MQTTAsync_send(c, destinationName, payloadlen, payload, qos, retained, &response);
+ Py_END_ALLOW_THREADS
+
+ if (rc == MQTTASYNC_SUCCESS && qos > 0)
+ return Py_BuildValue("ii", rc, response);
+ else
+ return Py_BuildValue("i", rc);
+}
+
+
+static PyObject* mqttv3_sendMessage(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ char* destinationName;
+ PyObject *message, *temp;
+ MQTTAsync_message msg = MQTTAsync_message_initializer;
+ MQTTAsync_responseOptions response = MQTTAsync_responseOptions_initializer;
+ PyObject *pyoptions = NULL;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "ksO|O", &c, &destinationName, &message, &pyoptions))
+ return NULL;
+
+ if (!getResponseOptions(c, pyoptions, &response, PUBLISH))
+ return NULL;
+
+ if (!PyDict_Check(message))
+ {
+ PyErr_SetString(PyExc_TypeError, "3rd parameter must be a dictionary");
+ return NULL;
+ }
+
+ if ((temp = PyDict_GetItemString(message, "payload")) == NULL)
+ {
+ PyErr_SetString(PyExc_TypeError, "dictionary must have payload key");
+ return NULL;
+ }
+
+ if (PyString_Check(temp))
+ PyString_AsStringAndSize(temp, (char**) &msg.payload,
+ (Py_ssize_t*) &msg.payloadlen);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "payload value must be string");
+ return NULL;
+ }
+
+ if ((temp = PyDict_GetItemString(message, "qos")) == NULL)
+ msg.qos = (int) PyInt_AsLong(temp);
+
+ if ((temp = PyDict_GetItemString(message, "retained")) == NULL)
+ msg.retained = (int) PyInt_AsLong(temp);
+
+ Py_BEGIN_ALLOW_THREADS
+ rc = MQTTAsync_sendMessage(c, destinationName, &msg, &response);
+ Py_END_ALLOW_THREADS
+
+ if (rc == MQTTASYNC_SUCCESS && msg.qos > 0)
+ return Py_BuildValue("ii", rc, response);
+ else
+ return Py_BuildValue("i", rc);
+}
+
+
+static PyObject* mqttv3_waitForCompletion(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ unsigned long timeout = 1000L;
+ MQTTAsync_token dt;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "ki|i", &c, &dt, &timeout))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS
+ rc = MQTTAsync_waitForCompletion(c, dt, timeout);
+ Py_END_ALLOW_THREADS
+
+ return Py_BuildValue("i", rc);
+}
+
+
+static PyObject* mqttv3_getPendingTokens(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ MQTTAsync_token* tokens;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "k", &c))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS
+ rc = MQTTAsync_getPendingTokens(c, &tokens);
+ Py_END_ALLOW_THREADS
+
+ if (rc == MQTTASYNC_SUCCESS)
+ {
+ int i = 0;
+ PyObject* dts = PyList_New(0);
+
+ while (tokens[i] != -1)
+ PyList_Append(dts, PyInt_FromLong((long) tokens[i]));
+
+ return Py_BuildValue("iO", rc, dts);
+ }
+ else
+ return Py_BuildValue("i", rc);
+}
+
+
+static PyObject* mqttv3_destroy(PyObject* self, PyObject *args)
+{
+ MQTTAsync c;
+ ListElement* temp = NULL;
+
+ if (!PyArg_ParseTuple(args, "k", &c))
+ return NULL;
+
+ if ((temp = ListFindItem(callbacks, c, clientCompare)) != NULL)
+ {
+ ListDetach(callbacks, temp->content);
+ free(temp->content);
+ }
+
+ if ((temp = ListFindItem(connected_callbacks, c, connectedCompare)) != NULL)
+ {
+ ListDetach(connected_callbacks, temp->content);
+ free(temp->content);
+ }
+
+ MQTTAsync_destroy(&c);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyMethodDef MqttV3Methods[] =
+ {
+ { "create", mqttv3_create, METH_VARARGS, "Create an MQTTv3 client." },
+ { "setcallbacks", mqttv3_setcallbacks, METH_VARARGS,
+ "Sets the callback functions for a particular client." },
+ { "setconnected", mqttv3_setconnected, METH_VARARGS,
+ "Sets the connected callback function for a particular client." },
+ { "connect", mqttv3_connect, METH_VARARGS,
+ "Connects to a server using the specified options." },
+ { "disconnect", mqttv3_disconnect, METH_VARARGS,
+ "Disconnects from a server." },
+ { "isConnected", mqttv3_isConnected, METH_VARARGS,
+ "Determines if this client is currently connected to the server." },
+ { "subscribe", mqttv3_subscribe, METH_VARARGS,
+ "Subscribe to the given topic." },
+ { "subscribeMany", mqttv3_subscribeMany, METH_VARARGS,
+ "Subscribe to the given topics." },
+ { "unsubscribe", mqttv3_unsubscribe, METH_VARARGS,
+ "Unsubscribe from the given topic." },
+ { "unsubscribeMany", mqttv3_unsubscribeMany, METH_VARARGS,
+ "Unsubscribe from the given topics." },
+ { "send", mqttv3_send, METH_VARARGS,
+ "Publish a message to the given topic." },
+ { "sendMessage", mqttv3_sendMessage, METH_VARARGS,
+ "Publish a message to the given topic." },
+ { "waitForCompletion", mqttv3_waitForCompletion, METH_VARARGS,
+ "Waits for the completion of the delivery of the message represented by a delivery token." },
+ { "getPendingTokens", mqttv3_getPendingTokens, METH_VARARGS,
+ "Returns the tokens pending of completion." },
+ { "destroy", mqttv3_destroy, METH_VARARGS,
+ "Free memory allocated to a MQTT client. It is the opposite to create." },
+ { NULL, NULL, 0, NULL } /* Sentinel */
+ };
+
+
+PyMODINIT_FUNC initpaho_mqtt3a(void)
+{
+ PyObject *m;
+
+ PyEval_InitThreads();
+
+ callbacks = ListInitialize();
+ connected_callbacks = ListInitialize();
+
+ m = Py_InitModule("paho_mqtt3a", MqttV3Methods);
+ if (m == NULL)
+ return;
+
+ MqttV3Error = PyErr_NewException("paho_mqtt3a.error", NULL, NULL);
+ Py_INCREF(MqttV3Error);
+ PyModule_AddObject(m, "error", MqttV3Error);
+
+ PyModule_AddIntConstant(m, "SUCCESS", MQTTASYNC_SUCCESS);
+ PyModule_AddIntConstant(m, "FAILURE", MQTTASYNC_FAILURE);
+ PyModule_AddIntConstant(m, "DISCONNECTED", MQTTASYNC_DISCONNECTED);
+ PyModule_AddIntConstant(m, "MAX_MESSAGES_INFLIGHT", MQTTASYNC_MAX_MESSAGES_INFLIGHT);
+ PyModule_AddIntConstant(m, "BAD_UTF8_STRING", MQTTASYNC_BAD_UTF8_STRING);
+ PyModule_AddIntConstant(m, "BAD_NULL_PARAMETER", MQTTASYNC_NULL_PARAMETER);
+ PyModule_AddIntConstant(m, "BAD_TOPICNAME_TRUNCATED", MQTTASYNC_TOPICNAME_TRUNCATED);
+ PyModule_AddIntConstant(m, "PERSISTENCE_DEFAULT", MQTTCLIENT_PERSISTENCE_DEFAULT);
+ PyModule_AddIntConstant(m, "PERSISTENCE_NONE", MQTTCLIENT_PERSISTENCE_NONE);
+ PyModule_AddIntConstant(m, "PERSISTENCE_USER", MQTTCLIENT_PERSISTENCE_USER);
+ PyModule_AddIntConstant(m, "PERSISTENCE_ERROR",
+ MQTTCLIENT_PERSISTENCE_ERROR);
+}
diff --git a/test/python/mqttclient_module.c b/test/python/mqttclient_module.c
new file mode 100644
index 00000000..1879b9c0
--- /dev/null
+++ b/test/python/mqttclient_module.c
@@ -0,0 +1,693 @@
+#include
+
+#include "MQTTClient.h"
+#include "LinkedList.h"
+
+static PyObject *MqttV3Error;
+
+static PyObject* mqttv3_create(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ char* serverURI;
+ char* clientId;
+ int persistence_option = MQTTCLIENT_PERSISTENCE_DEFAULT;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "ss|i", &serverURI, &clientId,
+ &persistence_option))
+ return NULL;
+
+ if (persistence_option != MQTTCLIENT_PERSISTENCE_DEFAULT
+ && persistence_option != MQTTCLIENT_PERSISTENCE_NONE)
+ {
+ PyErr_SetString(PyExc_TypeError, "persistence must be DEFAULT or NONE");
+ return NULL;
+ }
+
+ rc = MQTTClient_create(&c, serverURI, clientId, persistence_option, NULL);
+
+ printf("create MQTTClient pointer %p\n", c);
+
+ return Py_BuildValue("ik", rc, c);
+}
+
+static List* callbacks = NULL;
+
+typedef struct
+{
+ MQTTClient c;
+ PyObject *context;
+ PyObject *cl, *ma, *dc;
+} CallbackEntry;
+
+int clientCompare(void* a, void* b)
+{
+ CallbackEntry* e = (CallbackEntry*) a;
+ return e->c == (MQTTClient) b;
+}
+
+void connectionLost(void* context, char* cause)
+{
+ /* call the right Python function, using the context */
+ PyObject *arglist;
+ PyObject *result;
+ CallbackEntry* e = context;
+ PyGILState_STATE gstate;
+
+ gstate = PyGILState_Ensure();
+ arglist = Py_BuildValue("Os", e->context, cause);
+ result = PyEval_CallObject(e->cl, arglist);
+ Py_DECREF(arglist);
+ PyGILState_Release(gstate);
+}
+
+int messageArrived(void* context, char* topicName, int topicLen,
+ MQTTClient_message* message)
+{
+ PyObject *result = NULL;
+ CallbackEntry* e = context;
+ int rc = -99;
+ PyGILState_STATE gstate;
+
+ //printf("messageArrived %s %s %d %.*s\n", PyString_AsString(e->context), topicName, topicLen,
+ // message->payloadlen, (char*)message->payload);
+
+ gstate = PyGILState_Ensure();
+ if (topicLen == 0)
+ result = PyEval_CallFunction(e->ma, "Os{ss#sisisisi}", e->context,
+ topicName, "payload", message->payload, message->payloadlen,
+ "qos", message->qos, "retained", message->retained, "dup",
+ message->dup, "msgid", message->msgid);
+ else
+ result = PyEval_CallFunction(e->ma, "Os#{ss#sisisisi}", e->context,
+ topicName, topicLen, "payload", message->payload,
+ message->payloadlen, "qos", message->qos, "retained",
+ message->retained, "dup", message->dup, "msgid",
+ message->msgid);
+ if (result)
+ {
+ if (PyInt_Check(result))
+ rc = (int) PyInt_AsLong(result);
+ Py_DECREF(result);
+ }
+ PyGILState_Release(gstate);
+ MQTTClient_free(topicName);
+ MQTTClient_freeMessage(&message);
+ return rc;
+}
+
+void deliveryComplete(void* context, MQTTClient_deliveryToken dt)
+{
+ PyObject *arglist;
+ PyObject *result;
+ CallbackEntry* e = context;
+ PyGILState_STATE gstate;
+
+ gstate = PyGILState_Ensure();
+ arglist = Py_BuildValue("Oi", e->context, dt);
+ result = PyEval_CallObject(e->dc, arglist);
+ Py_DECREF(arglist);
+ PyGILState_Release(gstate);
+}
+
+static PyObject* mqttv3_setcallbacks(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ CallbackEntry* e = NULL;
+ int rc;
+
+ e = malloc(sizeof(CallbackEntry));
+
+ if (!PyArg_ParseTuple(args, "kOOOO", &c, (PyObject**) &e->context, &e->cl,
+ &e->ma, &e->dc))
+ return NULL;
+ e->c = c;
+
+ printf("setCallbacks MQTTClient pointer %p\n", c);
+
+ if ((e->cl != Py_None && !PyCallable_Check(e->cl))
+ || (e->ma != Py_None && !PyCallable_Check(e->ma))
+ || (e->dc != Py_None && !PyCallable_Check(e->dc)))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "3rd, 4th and 5th parameters must be callable or None");
+ return NULL;
+ }
+
+ Py_BEGIN_ALLOW_THREADS rc = MQTTClient_setCallbacks(c, e, connectionLost,
+ messageArrived, deliveryComplete);
+ Py_END_ALLOW_THREADS
+
+ if (rc == MQTTCLIENT_SUCCESS)
+ {
+ ListElement* temp = NULL;
+ if ((temp = ListFindItem(callbacks, c, clientCompare)) != NULL)
+ {
+ ListDetach(callbacks, temp->content);
+ free(temp->content);
+ }
+ ListAppend(callbacks, e, sizeof(e));
+ Py_XINCREF(e->cl);
+ Py_XINCREF(e->ma);
+ Py_XINCREF(e->dc);
+ Py_XINCREF(e->context);
+ }
+
+ return Py_BuildValue("i", rc);
+}
+
+static PyObject* mqttv3_connect(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ PyObject *pyoptions = NULL, *temp;
+ MQTTClient_connectOptions options = MQTTClient_connectOptions_initializer;
+ MQTTClient_willOptions woptions = MQTTClient_willOptions_initializer;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "k|O", &c, &pyoptions))
+ return NULL;
+
+ printf("connect MQTTClient pointer %p\n", c);
+ if (!pyoptions)
+ goto skip;
+
+ if (!PyDict_Check(pyoptions))
+ {
+ PyErr_SetString(PyExc_TypeError, "2nd parameter must be a dictionary");
+ return NULL;
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "keepAliveInterval")) != NULL)
+ {
+ if (PyInt_Check(temp))
+ options.keepAliveInterval = (int) PyInt_AsLong(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "keepAliveLiveInterval value must be int");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "cleansession")) != NULL)
+ {
+ if (PyInt_Check(temp))
+ options.cleansession = (int) PyInt_AsLong(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "cleansession value must be int");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "reliable")) != NULL)
+ {
+ if (PyInt_Check(temp))
+ options.reliable = (int) PyInt_AsLong(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "reliable value must be int");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "will")) != NULL)
+ {
+ if (PyDict_Check(temp))
+ {
+ PyObject *wtemp = NULL;
+ if ((wtemp = PyDict_GetItemString(temp, "topicName")) == NULL)
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "will topicName value must be set");
+ return NULL;
+ }
+ else
+ {
+ if (PyString_Check(wtemp))
+ woptions.topicName = PyString_AsString(wtemp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "will topicName value must be string");
+ return NULL;
+ }
+ }
+ if ((wtemp = PyDict_GetItemString(temp, "message")) == NULL)
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "will message value must be set");
+ return NULL;
+ }
+ else
+ {
+ if (PyString_Check(wtemp))
+ woptions.message = PyString_AsString(wtemp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "will message value must be string");
+ return NULL;
+ }
+ }
+ if ((wtemp = PyDict_GetItemString(temp, "retained")) != NULL)
+ {
+ if (PyInt_Check(wtemp))
+ woptions.retained = (int) PyInt_AsLong(wtemp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "will retained value must be int");
+ return NULL;
+ }
+ }
+ if ((wtemp = PyDict_GetItemString(temp, "qos")) != NULL)
+ {
+ if (PyInt_Check(wtemp))
+ woptions.qos = (int) PyInt_AsLong(wtemp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "will qos value must be int");
+ return NULL;
+ }
+ }
+ options.will = &woptions;
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "will value must be dictionary");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "username")) != NULL)
+ {
+ if (PyString_Check(temp))
+ options.username = PyString_AsString(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "username value must be string");
+ return NULL;
+ }
+ }
+
+ if ((temp = PyDict_GetItemString(pyoptions, "password")) != NULL)
+ {
+ if (PyString_Check(temp))
+ options.username = PyString_AsString(temp);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "password value must be string");
+ return NULL;
+ }
+ }
+
+ skip: Py_BEGIN_ALLOW_THREADS rc = MQTTClient_connect(c, &options);
+ Py_END_ALLOW_THREADS
+ return Py_BuildValue("i", rc);
+}
+
+static PyObject* mqttv3_disconnect(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ int timeout = 0;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "k|i", &c, &timeout))
+ return NULL;
+ Py_BEGIN_ALLOW_THREADS rc = MQTTClient_disconnect(c, timeout);
+ Py_END_ALLOW_THREADS
+ return Py_BuildValue("i", rc);
+}
+
+static PyObject* mqttv3_isConnected(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "k", &c))
+ return NULL;
+ Py_BEGIN_ALLOW_THREADS rc = MQTTClient_isConnected(c);
+ Py_END_ALLOW_THREADS
+ return Py_BuildValue("i", rc);
+}
+
+static PyObject* mqttv3_subscribe(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ char* topic;
+ int qos = 2;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "ks|i", &c, &topic, &qos))
+ return NULL;
+ Py_BEGIN_ALLOW_THREADS rc = MQTTClient_subscribe(c, topic, qos);
+ Py_END_ALLOW_THREADS
+ return Py_BuildValue("i", rc);
+}
+
+static PyObject* mqttv3_subscribeMany(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ PyObject* topicList;
+ PyObject* qosList;
+
+ int count;
+ char** topics;
+ int* qoss;
+
+ int i, rc = 0;
+
+ if (!PyArg_ParseTuple(args, "kOO", &c, &topicList, &qosList))
+ return NULL;
+
+ if (!PySequence_Check(topicList) || !PySequence_Check(qosList))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "3rd and 4th parameters must be sequences");
+ return NULL;
+ }
+
+ if ((count = PySequence_Length(topicList)) != PySequence_Length(qosList))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "3rd and 4th parameters must be sequences of the same length");
+ return NULL;
+ }
+
+ topics = malloc(count * sizeof(char*));
+ for (i = 0; i < count; ++i)
+ topics[i] = PyString_AsString(PySequence_GetItem(topicList, i));
+
+ qoss = malloc(count * sizeof(int));
+ for (i = 0; i < count; ++i)
+ qoss[i] = (int) PyInt_AsLong(PySequence_GetItem(qosList, i));
+
+ Py_BEGIN_ALLOW_THREADS rc = MQTTClient_subscribeMany(c, count, topics,
+ qoss);
+ Py_END_ALLOW_THREADS
+
+ for (i = 0; i < count; ++i)
+ PySequence_SetItem(qosList, i, PyInt_FromLong((long) qoss[i]));
+
+ free(topics);
+ free(qoss);
+
+ if (rc == MQTTCLIENT_SUCCESS)
+ return Py_BuildValue("iO", rc, qosList);
+ else
+ return Py_BuildValue("i", rc);
+}
+
+static PyObject* mqttv3_unsubscribe(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ char* topic;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "ks", &c, &topic))
+ return NULL;
+ Py_BEGIN_ALLOW_THREADS rc = MQTTClient_unsubscribe(c, topic);
+ Py_END_ALLOW_THREADS
+ return Py_BuildValue("i", rc);
+}
+
+static PyObject* mqttv3_unsubscribeMany(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ PyObject* topicList;
+
+ int count;
+ char** topics;
+
+ int i, rc = 0;
+
+ if (!PyArg_ParseTuple(args, "kOO", &c, &topicList))
+ return NULL;
+
+ if (!PySequence_Check(topicList))
+ {
+ PyErr_SetString(PyExc_TypeError, "3rd parameter must be sequences");
+ return NULL;
+ }
+
+ count = PySequence_Length(topicList);
+ topics = malloc(count * sizeof(char*));
+ for (i = 0; i < count; ++i)
+ topics[i] = PyString_AsString(PySequence_GetItem(topicList, i));
+
+ Py_BEGIN_ALLOW_THREADS rc = MQTTClient_unsubscribeMany(c, count, topics);
+ Py_END_ALLOW_THREADS
+
+ free( topics);
+
+ return Py_BuildValue("i", rc);
+}
+
+static PyObject* mqttv3_publish(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ char* topicName;
+ int payloadlen;
+ void* payload;
+ int qos = 0;
+ int retained = 0;
+ MQTTClient_deliveryToken dt;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "kss#|ii", &c, &topicName, &payload,
+ &payloadlen, &qos, &retained))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS rc = MQTTClient_publish(c, topicName, payloadlen,
+ payload, qos, retained, &dt);
+ Py_END_ALLOW_THREADS
+
+ if (rc == MQTTCLIENT_SUCCESS && qos > 0)
+ return Py_BuildValue("ii", rc, dt);
+ else
+ return Py_BuildValue("i", rc);
+}
+
+static PyObject* mqttv3_publishMessage(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ char* topicName;
+ PyObject *message, *temp;
+ MQTTClient_message msg = MQTTClient_message_initializer;
+ MQTTClient_deliveryToken dt;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "ksO", &c, &topicName, &message))
+ return NULL;
+
+ if (!PyDict_Check(message))
+ {
+ PyErr_SetString(PyExc_TypeError, "3rd parameter must be a dictionary");
+ return NULL;
+ }
+
+ if ((temp = PyDict_GetItemString(message, "payload")) == NULL)
+ {
+ PyErr_SetString(PyExc_TypeError, "dictionary must have payload key");
+ return NULL;
+ }
+
+ if (PyString_Check(temp))
+ PyString_AsStringAndSize(temp, (char**) &msg.payload,
+ (Py_ssize_t*) &msg.payloadlen);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "payload value must be string");
+ return NULL;
+ }
+
+ if ((temp = PyDict_GetItemString(message, "qos")) == NULL)
+ msg.qos = (int) PyInt_AsLong(temp);
+
+ if ((temp = PyDict_GetItemString(message, "retained")) == NULL)
+ msg.retained = (int) PyInt_AsLong(temp);
+
+ Py_BEGIN_ALLOW_THREADS rc = MQTTClient_publishMessage(c, topicName, &msg,
+ &dt);
+ Py_END_ALLOW_THREADS
+
+ if (rc == MQTTCLIENT_SUCCESS && msg.qos > 0)
+ return Py_BuildValue("ii", rc, dt);
+ else
+ return Py_BuildValue("i", rc);
+}
+
+static PyObject* mqttv3_waitForCompletion(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ unsigned long timeout = 1000L;
+ MQTTClient_deliveryToken dt;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "ki|i", &c, &dt, &timeout))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS rc = MQTTClient_waitForCompletion(c, dt, timeout);
+ Py_END_ALLOW_THREADS
+
+ return Py_BuildValue("i", rc);
+}
+
+static PyObject* mqttv3_getPendingDeliveryTokens(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ MQTTClient_deliveryToken* tokens;
+ int rc;
+
+ if (!PyArg_ParseTuple(args, "k", &c))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS rc = MQTTClient_getPendingDeliveryTokens(c, &tokens);
+ Py_END_ALLOW_THREADS
+
+ if (rc == MQTTCLIENT_SUCCESS)
+ {
+ int i = 0;
+ PyObject* dts = PyList_New(0);
+
+ while (tokens[i] != -1)
+ PyList_Append(dts, PyInt_FromLong((long) tokens[i]));
+
+ return Py_BuildValue("iO", rc, dts);
+ }
+ else
+ return Py_BuildValue("i", rc);
+}
+
+static PyObject* mqttv3_yield(PyObject* self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS
+ MQTTClient_yield();
+ Py_END_ALLOW_THREADS
+
+ Py_INCREF( Py_None);
+ return Py_None;
+}
+
+static PyObject* mqttv3_receive(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ unsigned long timeout = 1000L;
+ int rc;
+ PyObject* temp = NULL;
+
+ char* topicName;
+ int topicLen;
+ MQTTClient_message* message;
+
+ if (!PyArg_ParseTuple(args, "k|k", &c, &timeout))
+ return NULL;
+ Py_BEGIN_ALLOW_THREADS rc = MQTTClient_receive(c, &topicName, &topicLen,
+ &message, timeout);
+ Py_END_ALLOW_THREADS
+ if (message)
+ {
+ temp = Py_BuildValue("is#{ss#sisisisi}", rc, topicName, topicLen,
+ "payload", message->payload, message->payloadlen, "qos",
+ message->qos, "retained", message->retained, "dup",
+ message->dup, "msgid", message->msgid);
+ free(topicName);
+ MQTTClient_freeMessage(&message);
+ }
+ else
+ temp = Py_BuildValue("iz", rc, NULL);
+
+ return temp;
+}
+
+static PyObject* mqttv3_destroy(PyObject* self, PyObject *args)
+{
+ MQTTClient c;
+ ListElement* temp = NULL;
+
+ if (!PyArg_ParseTuple(args, "k", &c))
+ return NULL;
+
+ if ((temp = ListFindItem(callbacks, c, clientCompare)) != NULL)
+ {
+ ListDetach(callbacks, temp->content);
+ free(temp->content);
+ }
+
+ MQTTClient_destroy(&c);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMethodDef MqttV3Methods[] =
+ {
+ { "create", mqttv3_create, METH_VARARGS, "Create an MQTTv3 client." },
+ { "setcallbacks", mqttv3_setcallbacks, METH_VARARGS,
+ "Sets the callback functions for a particular client." },
+ { "connect", mqttv3_connect, METH_VARARGS,
+ "Connects to a server using the specified options." },
+ { "disconnect", mqttv3_disconnect, METH_VARARGS,
+ "Disconnects from a server." },
+ { "isConnected", mqttv3_isConnected, METH_VARARGS,
+ "Determines if this client is currently connected to the server." },
+ { "subscribe", mqttv3_subscribe, METH_VARARGS,
+ "Subscribe to the given topic." },
+ { "subscribeMany", mqttv3_subscribeMany, METH_VARARGS,
+ "Subscribe to the given topics." },
+ { "unsubscribe", mqttv3_unsubscribe, METH_VARARGS,
+ "Unsubscribe from the given topic." },
+ { "unsubscribeMany", mqttv3_unsubscribeMany, METH_VARARGS,
+ "Unsubscribe from the given topics." },
+ { "publish", mqttv3_publish, METH_VARARGS,
+ "Publish a message to the given topic." },
+ { "publishMessage", mqttv3_publishMessage, METH_VARARGS,
+ "Publish a message to the given topic." },
+ { "waitForCompletion", mqttv3_waitForCompletion, METH_VARARGS,
+ "Waits for the completion of the delivery of the message represented by a delivery token." },
+ { "getPendingDeliveryTokens", mqttv3_getPendingDeliveryTokens,
+ METH_VARARGS,
+ "Returns the delivery tokens pending of completion." },
+ { "yield", mqttv3_yield, METH_VARARGS,
+ "Single-thread keep alive but don't receive message." },
+ { "receive", mqttv3_receive, METH_VARARGS,
+ "Single-thread receive message if available." },
+ { "destroy", mqttv3_destroy, METH_VARARGS,
+ "Free memory allocated to a MQTT client. It is the opposite to create." },
+ { NULL, NULL, 0, NULL } /* Sentinel */
+ };
+
+PyMODINIT_FUNC initpaho_mqtt3c(void)
+{
+ PyObject *m;
+
+ PyEval_InitThreads();
+
+ callbacks = ListInitialize();
+
+ m = Py_InitModule("paho_mqtt3c", MqttV3Methods);
+ if (m == NULL)
+ return;
+
+ MqttV3Error = PyErr_NewException("paho_mqtt3c.error", NULL, NULL);
+ Py_INCREF(MqttV3Error);
+ PyModule_AddObject(m, "error", MqttV3Error);
+
+ PyModule_AddIntConstant(m, "SUCCESS", MQTTCLIENT_SUCCESS);
+ PyModule_AddIntConstant(m, "FAILURE", MQTTCLIENT_FAILURE);
+ PyModule_AddIntConstant(m, "DISCONNECTED", MQTTCLIENT_DISCONNECTED);
+ PyModule_AddIntConstant(m, "MAX_MESSAGES_INFLIGHT", MQTTCLIENT_MAX_MESSAGES_INFLIGHT);
+ PyModule_AddIntConstant(m, "BAD_UTF8_STRING", MQTTCLIENT_BAD_UTF8_STRING);
+ PyModule_AddIntConstant(m, "BAD_NULL_PARAMETER", MQTTCLIENT_NULL_PARAMETER);
+ PyModule_AddIntConstant(m, "BAD_TOPICNAME_TRUNCATED", MQTTCLIENT_TOPICNAME_TRUNCATED);
+ PyModule_AddIntConstant(m, "PERSISTENCE_DEFAULT", MQTTCLIENT_PERSISTENCE_DEFAULT);
+ PyModule_AddIntConstant(m, "PERSISTENCE_NONE", MQTTCLIENT_PERSISTENCE_NONE);
+ PyModule_AddIntConstant(m, "PERSISTENCE_USER", MQTTCLIENT_PERSISTENCE_USER);
+ PyModule_AddIntConstant(m, "PERSISTENCE_ERROR",
+ MQTTCLIENT_PERSISTENCE_ERROR);
+}
diff --git a/test/python/setup.py b/test/python/setup.py
new file mode 100644
index 00000000..05c7f60b
--- /dev/null
+++ b/test/python/setup.py
@@ -0,0 +1,20 @@
+from distutils.core import setup, Extension
+
+paho_mqtt3c = Extension('paho_mqtt3c',
+ define_macros = [('NO_HEAP_TRACKING', '1')],
+ sources = ['mqttclient_module.c', '../../src/LinkedList.c'],
+ libraries = ['paho-mqtt3c'],
+ library_dirs = ['../../build/output'],
+ include_dirs = ['../../src'])
+
+paho_mqtt3a = Extension('paho_mqtt3a',
+ define_macros = [('NO_HEAP_TRACKING', '1')],
+ sources = ['mqttasync_module.c', '../../src/LinkedList.c'],
+ libraries = ['paho-mqtt3a'],
+ library_dirs = ['../../build/output'],
+ include_dirs = ['../../src'])
+
+setup (name = 'EclipsePahoMQTTClient',
+ version = '1.0',
+ description = 'Binding to the Eclipse Paho C clients',
+ ext_modules = [paho_mqtt3c, paho_mqtt3a])
diff --git a/test/python/test1.py b/test/python/test1.py
new file mode 100644
index 00000000..4f177be0
--- /dev/null
+++ b/test/python/test1.py
@@ -0,0 +1,52 @@
+import paho_mqtt3c as mqttv3, time, random
+
+print dir(mqttv3)
+
+host = "localhost"
+clientid = "myclientid"
+noclients = 4
+
+def deliveryComplete(context, msgid):
+ print "deliveryComplete", msgid
+
+def connectionLost(context, cause):
+ print "connectionLost"
+ print "rc from reconnect is", mqttv3.connect(self.client)
+
+def messageArrived(context, topicName, message):
+ print "clientid", context
+ print "topicName", topicName
+ print "message", message
+ return 1
+
+print messageArrived
+
+myclientid = None
+clients = []
+for i in range(noclients):
+ myclientid = clientid+str(i)
+ rc, client = mqttv3.create("tcp://"+host+":1883", myclientid)
+ print "client is", hex(client)
+ print "rc from create is", rc
+ print "rc from setcallbacks is", mqttv3.setcallbacks(client, client, connectionLost, messageArrived, deliveryComplete)
+ print "client is", hex(client)
+ print "rc from connect is", mqttv3.connect(client, {})
+ clients.append(client)
+
+for client in clients:
+ print "rc from subscribe is", mqttv3.subscribe(client, "$SYS/#")
+
+for client in clients:
+ print "rc from publish is", mqttv3.publish(client, "a topic", "a message")
+ print "rc from publish is", mqttv3.publish(client, "a topic", "a message", 1)
+ print "rc from publish is", mqttv3.publish(client, "a topic", "a message", 2)
+
+print "about to sleep"
+time.sleep(10)
+print "finished sleeping"
+
+for client in clients:
+ print "rc from isConnected is", mqttv3.isConnected(client)
+ print "rc from disconnect is", mqttv3.disconnect(client)
+ mqttv3.destroy(client)
+
diff --git a/test/python/test2.py b/test/python/test2.py
new file mode 100644
index 00000000..48e7fb9e
--- /dev/null
+++ b/test/python/test2.py
@@ -0,0 +1,73 @@
+import paho_mqtt3a as mqttv3, time, random
+import contextlib
+
+print dir(mqttv3)
+
+hostname = "localhost"
+clientid = "myclientid"
+topic = "test2_topic"
+
+def deliveryComplete(context, msgid):
+ print "deliveryComplete", msgid
+
+def connectionLost(context, cause):
+ print "connectionLost"
+ print "rc from reconnect is", mqttv3.connect(self.client)
+
+def messageArrived(context, topicName, message):
+ print "messageArrived", message
+ #print "clientid", context
+ #print "topicName", topicName
+ return 1
+
+def onSuccess(context, successData):
+ print "onSuccess for", context["clientid"], context["state"], successData
+ responseOptions = {"context": context, "onSuccess": onSuccess, "onFailure" : onFailure}
+ #responseOptions = {"context": context}
+ if context["state"] == "connecting":
+ context["state"] = "subscribing"
+ print "rc from subscribe is", mqttv3.subscribe(client, topic, 2, responseOptions)
+ elif context["state"] == "subscribing":
+ context["state"] = "publishing qos 0"
+ print "rc from publish is", mqttv3.send(client, topic, "a QoS 0 message", 0, 0, responseOptions)
+ elif context["state"] == "publishing qos 0":
+ context["state"] = "publishing qos 1"
+ print "rc from publish is", mqttv3.send(client, topic, "a QoS 1 message", 1, 0, responseOptions)
+ elif context["state"] == "publishing qos 1":
+ context["state"] = "publishing qos 2"
+ print "rc from publish is", mqttv3.send(client, topic, "a QoS 2 message", 2, 0, responseOptions)
+ elif context["state"] == "publishing qos 2":
+ context["state"] = "finished"
+ print "leaving onSuccess"
+
+def onFailure(context, failureData):
+ print "onFailure for", context["clientid"]
+ context["state"] = "finished"
+
+noclients = 1
+myclientid = None
+clients = []
+for i in range(noclients):
+ myclientid = clientid+str(i)
+ rc, client = mqttv3.create("tcp://"+hostname+":1883", myclientid)
+ #print "client is", hex(client)
+ print "rc from create is", rc
+ print "rc from setcallbacks is", mqttv3.setcallbacks(client, client, connectionLost, messageArrived, deliveryComplete)
+
+ context = {"client" : client, "clientid" : clientid, "state" : "connecting"}
+
+ print "rc from connect is", mqttv3.connect(client, {"context": context, "onSuccess": onSuccess, "onFailure": onFailure})
+
+ clients.append(context)
+
+while [x for x in clients if x["state"] != "finished"]:
+ print [x for x in clients if x["state"] != "finished"]
+ time.sleep(1)
+
+for client in clients:
+ if mqttv3.isConnected(client["client"]):
+ print "rc from disconnect is", mqttv3.disconnect(client["client"], 1000)
+ time.sleep(1)
+ mqttv3.destroy(client["client"])
+ print "after destroy"
+
diff --git a/test/python/test_offline.py b/test/python/test_offline.py
new file mode 100644
index 00000000..bed2fe40
--- /dev/null
+++ b/test/python/test_offline.py
@@ -0,0 +1,83 @@
+import paho_mqtt3a as mqttv3, time, random
+import contextlib
+
+print dir(mqttv3)
+
+hostname = "localhost"
+clientid = "myclientid"
+topic = "test2_topic"
+
+def deliveryComplete(context, msgid):
+ print "deliveryComplete", msgid
+
+def connectionLost(context, cause):
+ print "connectionLost", cause
+ client = context
+ responseOptions = {"context": context, "onSuccess": onSuccess, "onFailure" : onFailure}
+ print "rc from publish while disconnected is", mqttv3.send(client, topic, "message while disconnected", 2, 0, responseOptions)
+
+def messageArrived(context, topicName, message):
+ print "messageArrived", message
+ #print "clientid", context
+ #print "topicName", topicName
+ return 1
+
+def connected(context, cause):
+ print "connected", cause
+
+def onSuccess(context, successData):
+ print "onSuccess for", context["clientid"], context["state"], successData
+ responseOptions = {"context": context, "onSuccess": onSuccess, "onFailure" : onFailure}
+ if context["state"] == "connecting":
+ context["state"] = "subscribing"
+ print "rc from subscribe is", mqttv3.subscribe(client, topic, 2, responseOptions)
+ elif context["state"] == "subscribing":
+ context["state"] = "publishing qos 0"
+ print "rc from publish is", mqttv3.send(client, topic, "a QoS 0 message", 0, 0, responseOptions)
+ elif context["state"] == "publishing qos 0":
+ context["state"] = "publishing qos 1"
+ print "rc from publish is", mqttv3.send(client, topic, "a QoS 1 message", 1, 0, responseOptions)
+ elif context["state"] == "publishing qos 1":
+ context["state"] = "publishing qos 2"
+ print "rc from publish is", mqttv3.send(client, topic, "a QoS 2 message", 2, 0, responseOptions)
+ elif context["state"] == "publishing qos 2":
+ context["state"] = "finished"
+ print "leaving onSuccess"
+
+def onFailure(context, failureData):
+ print "onFailure for", context["clientid"]
+ context["state"] = "finished"
+
+noclients = 1
+myclientid = None
+clients = []
+for i in range(noclients):
+ myclientid = clientid+str(i)
+ rc, client = mqttv3.create("tcp://"+hostname+":1883", myclientid, mqttv3.PERSISTENCE_DEFAULT, {"sendWhileDisconnected" : 1})
+ #print "client is", hex(client)
+ print "rc from create is", rc
+ print "rc from setcallbacks is", mqttv3.setcallbacks(client, client, connectionLost, messageArrived, deliveryComplete)
+
+ print "rc from setconnected is", mqttv3.setconnected(client, client, connected)
+
+
+ context = {"client" : client, "clientid" : clientid, "state" : "connecting"}
+
+ print "rc from connect is", mqttv3.connect(client, {"cleansession" : 0, "automaticReconnect": 1, "context": context, "onSuccess": onSuccess, "onFailure": onFailure})
+
+ clients.append(context)
+
+while [x for x in clients if x["state"] != "finished"]:
+ print [x for x in clients if x["state"] != "finished"]
+ time.sleep(1)
+
+print "waiting for 60 seconds"
+time.sleep(60)
+
+for client in clients:
+ if mqttv3.isConnected(client["client"]):
+ print "rc from disconnect is", mqttv3.disconnect(client["client"], 1000)
+ time.sleep(1)
+ mqttv3.destroy(client["client"])
+ print "after destroy"
+
diff --git a/test/test2.c b/test/test2.c
new file mode 100644
index 00000000..71ce135a
--- /dev/null
+++ b/test/test2.c
@@ -0,0 +1,709 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2016 IBM Corp.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Ian Craggs - initial API and implementation and/or initial documentation
+ * Ian Craggs - fix thread id display
+ *******************************************************************************/
+
+/**
+ * @file
+ * Multi-threaded tests for the MQ Telemetry MQTT C client
+ */
+
+#include "MQTTClient.h"
+#include "Thread.h"
+#include
+#include
+
+#if !defined(_WINDOWS)
+ #include
+ #include
+ #include
+ #include
+ #define WINAPI
+#else
+#include
+#include
+#define MAXHOSTNAMELEN 256
+#define EAGAIN WSAEWOULDBLOCK
+#define EINTR WSAEINTR
+#define EINPROGRESS WSAEINPROGRESS
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define ENOTCONN WSAENOTCONN
+#define ECONNRESET WSAECONNRESET
+#define setenv(a, b, c) _putenv_s(a, b)
+#endif
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+void usage()
+{
+ printf("help!!\n");
+ exit(-1);
+}
+
+struct Options
+{
+ char* connection; /**< connection to system under test. */
+ char** haconnections;
+ int hacount;
+ int verbose;
+ int test_no;
+ int MQTTVersion;
+ int iterations;
+} options =
+{
+ "tcp://m2m.eclipse.org:1883",
+ NULL,
+ 0,
+ 0,
+ 0,
+ MQTTVERSION_DEFAULT,
+ 1,
+};
+
+void getopts(int argc, char** argv)
+{
+ int count = 1;
+
+ while (count < argc)
+ {
+ if (strcmp(argv[count], "--test_no") == 0)
+ {
+ if (++count < argc)
+ options.test_no = atoi(argv[count]);
+ else
+ usage();
+ }
+ else if (strcmp(argv[count], "--connection") == 0)
+ {
+ if (++count < argc)
+ {
+ options.connection = argv[count];
+ printf("\nSetting connection to %s\n", options.connection);
+ }
+ else
+ usage();
+ }
+ else if (strcmp(argv[count], "--haconnections") == 0)
+ {
+ if (++count < argc)
+ {
+ char* tok = strtok(argv[count], " ");
+ options.hacount = 0;
+ options.haconnections = malloc(sizeof(char*) * 5);
+ while (tok)
+ {
+ options.haconnections[options.hacount] = malloc(strlen(tok) + 1);
+ strcpy(options.haconnections[options.hacount], tok);
+ options.hacount++;
+ tok = strtok(NULL, " ");
+ }
+ }
+ else
+ usage();
+ }
+ else if (strcmp(argv[count], "--MQTTversion") == 0)
+ {
+ if (++count < argc)
+ {
+ options.MQTTVersion = atoi(argv[count]);
+ printf("setting MQTT version to %d\n", options.MQTTVersion);
+ }
+ else
+ usage();
+ }
+ else if (strcmp(argv[count], "--iterations") == 0)
+ {
+ if (++count < argc)
+ options.iterations = atoi(argv[count]);
+ else
+ usage();
+ }
+ else if (strcmp(argv[count], "--verbose") == 0)
+ {
+ options.verbose = 1;
+ printf("\nSetting verbose on\n");
+ }
+ count++;
+ }
+}
+
+
+#define LOGA_DEBUG 0
+#define LOGA_INFO 1
+#include
+#include
+#include
+void MyLog(int LOGA_level, char* format, ...)
+{
+ static char msg_buf[256];
+ va_list args;
+ struct timeb ts;
+
+ struct tm *timeinfo;
+
+ if (LOGA_level == LOGA_DEBUG && options.verbose == 0)
+ return;
+
+ ftime(&ts);
+ timeinfo = localtime(&ts.time);
+ strftime(msg_buf, 80, "%Y%m%d %H%M%S", timeinfo);
+
+ sprintf(&msg_buf[strlen(msg_buf)], ".%.3hu ", ts.millitm);
+
+ va_start(args, format);
+ vsnprintf(&msg_buf[strlen(msg_buf)], sizeof(msg_buf) - strlen(msg_buf), format, args);
+ va_end(args);
+
+ printf("%s\n", msg_buf);
+ fflush(stdout);
+}
+
+
+#if defined(WIN32) || defined(_WINDOWS)
+#define mqsleep(A) Sleep(1000*A)
+#define START_TIME_TYPE DWORD
+static DWORD start_time = 0;
+START_TIME_TYPE start_clock(void)
+{
+ return GetTickCount();
+}
+#elif defined(AIX)
+#define mqsleep sleep
+#define START_TIME_TYPE struct timespec
+START_TIME_TYPE start_clock(void)
+{
+ static struct timespec start;
+ clock_gettime(CLOCK_REALTIME, &start);
+ return start;
+}
+#else
+#define mqsleep sleep
+#define START_TIME_TYPE struct timeval
+/* TODO - unused - remove? static struct timeval start_time; */
+START_TIME_TYPE start_clock(void)
+{
+ struct timeval start_time;
+ gettimeofday(&start_time, NULL);
+ return start_time;
+}
+#endif
+
+
+#if defined(WIN32)
+long elapsed(START_TIME_TYPE start_time)
+{
+ return GetTickCount() - start_time;
+}
+#elif defined(AIX)
+#define assert(a)
+long elapsed(struct timespec start)
+{
+ struct timespec now, res;
+
+ clock_gettime(CLOCK_REALTIME, &now);
+ ntimersub(now, start, res);
+ return (res.tv_sec)*1000L + (res.tv_nsec)/1000000L;
+}
+#else
+long elapsed(START_TIME_TYPE start_time)
+{
+ struct timeval now, res;
+
+ gettimeofday(&now, NULL);
+ timersub(&now, &start_time, &res);
+ return (res.tv_sec)*1000 + (res.tv_usec)/1000;
+}
+#endif
+
+
+#define assert(a, b, c, d) myassert(__FILE__, __LINE__, a, b, c, d)
+#define assert1(a, b, c, d, e) myassert(__FILE__, __LINE__, a, b, c, d, e)
+
+int tests = 0;
+int failures = 0;
+FILE* xml;
+START_TIME_TYPE global_start_time;
+char output[3000];
+char* cur_output = output;
+
+
+void write_test_result()
+{
+ long duration = elapsed(global_start_time);
+
+ fprintf(xml, " time=\"%ld.%.3ld\" >\n", duration / 1000, duration % 1000);
+ if (cur_output != output)
+ {
+ fprintf(xml, "%s", output);
+ cur_output = output;
+ }
+ fprintf(xml, "\n");
+}
+
+
+void myassert(char* filename, int lineno, char* description, int value, char* format, ...)
+{
+ ++tests;
+ if (!value)
+ {
+ va_list args;
+
+ ++failures;
+ MyLog(LOGA_INFO, "Assertion failed, file %s, line %d, description: %s\n", filename, lineno, description);
+
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+
+ cur_output += sprintf(cur_output, "file %s, line %d \n",
+ description, filename, lineno);
+ }
+ else
+ MyLog(LOGA_DEBUG, "Assertion succeeded, file %s, line %d, description: %s", filename, lineno, description);
+}
+
+
+#if defined(WIN32) || defined(WIN64)
+mutex_type deliveryCompleted_mutex = NULL;
+#else
+pthread_mutex_t deliveryCompleted_mutex_store = PTHREAD_MUTEX_INITIALIZER;
+mutex_type deliveryCompleted_mutex = &deliveryCompleted_mutex_store;
+#endif
+
+void lock_mutex(mutex_type amutex)
+{
+ int rc = Thread_lock_mutex(amutex);
+ if (rc != 0)
+ MyLog(LOGA_INFO, "Error %s locking mutex", strerror(rc));
+}
+
+void unlock_mutex(mutex_type amutex)
+{
+ int rc = Thread_unlock_mutex(amutex);
+ if (rc != 0)
+ MyLog(LOGA_INFO, "Error %s unlocking mutex", strerror(rc));
+}
+
+
+/*********************************************************************
+
+Test1: multiple threads to single client object
+
+*********************************************************************/
+volatile int test1_arrivedcount = 0;
+volatile int test1_arrivedcount_qos[3] = {0, 0, 0};
+volatile int test1_deliveryCompleted = 0;
+MQTTClient_message test1_pubmsg_check = MQTTClient_message_initializer;
+
+
+void test1_deliveryComplete(void* context, MQTTClient_deliveryToken dt)
+{
+ lock_mutex(deliveryCompleted_mutex);
+ MyLog(LOGA_DEBUG, "Delivery complete for token %d", dt);
+ ++test1_deliveryCompleted;
+ unlock_mutex(deliveryCompleted_mutex);
+}
+
+int test1_messageArrived(void* context, char* topicName, int topicLen, MQTTClient_message* m)
+{
+ ++(test1_arrivedcount_qos[m->qos]);
+ ++test1_arrivedcount;
+
+ MyLog(LOGA_DEBUG, "messageArrived: %d message received on topic %s is %.*s.",
+ test1_arrivedcount, topicName, m->payloadlen, (char*)(m->payload));
+ if (test1_pubmsg_check.payloadlen != m->payloadlen ||
+ memcmp(m->payload, test1_pubmsg_check.payload, m->payloadlen) != 0)
+ {
+ failures++;
+ MyLog(LOGA_INFO, "Error: wrong data received lengths %d %d\n", test1_pubmsg_check.payloadlen, m->payloadlen);
+ }
+ MQTTClient_free(topicName);
+ MQTTClient_freeMessage(&m);
+ return 1;
+}
+
+
+struct thread_parms
+{
+ MQTTClient* c;
+ int qos;
+ char* test_topic;
+};
+
+static int iterations = 50;
+
+thread_return_type WINAPI test1_sendAndReceive(void* n)
+{
+ MQTTClient_deliveryToken dt;
+ int i = 0;
+ int rc = 0;
+ int wait_seconds = 30;
+ MQTTClient_message test1_pubmsg = MQTTClient_message_initializer;
+ int subsqos = 2;
+
+ struct thread_parms *parms = n;
+ MQTTClient* c = parms->c;
+ int qos = parms->qos;
+ char* test_topic = parms->test_topic;
+
+ rc = MQTTClient_subscribe(c, test_topic, subsqos);
+ assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
+
+ MyLog(LOGA_INFO, "Thread %u, %d messages at QoS %d", Thread_getid(), iterations, qos);
+ test1_pubmsg.payload = test1_pubmsg_check.payload;
+ test1_pubmsg.payloadlen = test1_pubmsg_check.payloadlen;
+ test1_pubmsg.retained = 0;
+ test1_pubmsg.qos = qos;
+
+ for (i = 1; i <= iterations; ++i)
+ {
+ if (i % 10 == 0)
+ rc = MQTTClient_publish(c, test_topic, test1_pubmsg.payloadlen, test1_pubmsg.payload,
+ qos, test1_pubmsg.retained, &dt);
+ else
+ rc = MQTTClient_publishMessage(c, test_topic, &test1_pubmsg, &dt);
+ assert("Good rc from publish", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
+
+ #if defined(WIN32)
+ Sleep(100);
+ #else
+ usleep(100000L);
+ #endif
+
+ wait_seconds = 30;
+ while ((test1_arrivedcount_qos[qos] < i) && (wait_seconds-- > 0))
+ {
+ MyLog(LOGA_DEBUG, "Arrived %d count %d", test1_arrivedcount_qos[qos], i);
+ #if defined(WIN32)
+ Sleep(1000);
+ #else
+ usleep(1000000L);
+ #endif
+ }
+ assert("Message Arrived", wait_seconds > 0,
+ "Timed out waiting for message %d\n", i);
+ }
+
+#if defined(_WINDOWS)
+ return 0;
+#else
+ return NULL;
+#endif
+}
+
+
+int test1(struct Options options)
+{
+ MQTTClient c;
+ MQTTClient_connectOptions opts = MQTTClient_connectOptions_initializer;
+ MQTTClient_willOptions wopts = MQTTClient_willOptions_initializer;
+ int rc = 0;
+ char* test_topic = "C client test1";
+
+ fprintf(xml, "message = "will message";
+ opts.will->qos = 1;
+ opts.will->retained = 0;
+ opts.will->topicName = "will topic";
+ opts.will = NULL;
+
+ MyLog(LOGA_DEBUG, "Connecting");
+ rc = MQTTClient_connect(c, &opts);
+ assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
+ if (rc != MQTTCLIENT_SUCCESS)
+ goto exit;
+
+ test1_pubmsg_check.payload = "a much longer message that we can shorten to the extent that we need to";
+ test1_pubmsg_check.payloadlen = 27;
+ test1_deliveryCompleted = test1_arrivedcount = 0;
+
+ struct thread_parms parms0 = {c, 0, test_topic};
+ Thread_start(test1_sendAndReceive, (void*)&parms0);
+
+ struct thread_parms parms1 = {c, 1, test_topic};
+ Thread_start(test1_sendAndReceive, (void*)&parms1);
+
+ struct thread_parms parms2 = {c, 2, test_topic};
+ Thread_start(test1_sendAndReceive, (void*)&parms2);
+
+ /* MQTT servers can send a message to a subscriber before the server has
+ completed the QoS 2 handshake with the publisher. For QoS 1 and 2,
+ allow time for the final delivery complete callback before checking
+ that all expected callbacks have been made */
+
+ int wait_seconds = 90;
+ while (((test1_arrivedcount < iterations*3) || (test1_deliveryCompleted < iterations*2)) && (wait_seconds-- > 0))
+ {
+ #if defined(WIN32)
+ Sleep(1000);
+ #else
+ usleep(1000000L);
+ #endif
+ }
+ assert("Arrived count == 150", test1_arrivedcount == iterations*3, "arrivedcount was %d", test1_arrivedcount);
+ assert("All Deliveries Complete", test1_deliveryCompleted == iterations*2,
+ "Number of deliveryCompleted callbacks was %d\n", test1_deliveryCompleted);
+
+ MyLog(LOGA_DEBUG, "Stopping\n");
+
+ rc = MQTTClient_unsubscribe(c, test_topic);
+ assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
+ rc = MQTTClient_disconnect(c, 0);
+ assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
+
+ /* Just to make sure we can connect again */
+ rc = MQTTClient_connect(c, &opts);
+ assert("Connect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
+ rc = MQTTClient_disconnect(c, 0);
+ assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
+
+ MQTTClient_destroy(&c);
+
+exit:
+ MyLog(LOGA_INFO, "TEST1: test %s. %d tests run, %d failures.",
+ (failures == 0) ? "passed" : "failed", tests, failures);
+ write_test_result();
+ return failures;
+}
+
+
+/*********************************************************************
+
+Test2: multiple client objects used from multiple threads
+
+*********************************************************************/
+volatile int test2_arrivedcount = 0;
+
+volatile int test2_deliveryCompleted = 0;
+
+MQTTClient_message test2_pubmsg = MQTTClient_message_initializer;
+
+void test2_deliveryComplete(void* context, MQTTClient_deliveryToken dt)
+{
+ lock_mutex(deliveryCompleted_mutex);
+ MyLog(LOGA_DEBUG, "Delivery complete for token %d", dt);
+ ++test2_deliveryCompleted;
+ unlock_mutex(deliveryCompleted_mutex);
+}
+
+int test2_messageArrived(void* context, char* topicName, int topicLen, MQTTClient_message* m)
+{
+ ++test2_arrivedcount;
+ MyLog(LOGA_DEBUG, "Callback: %d message received on topic %s is %.*s.",
+ test2_arrivedcount, topicName, m->payloadlen, (char*)(m->payload));
+ if (test2_pubmsg.payloadlen != m->payloadlen ||
+ memcmp(m->payload, test2_pubmsg.payload, m->payloadlen) != 0)
+ {
+ failures++;
+ MyLog(LOGA_INFO, "Error: wrong data received lengths %d %d\n", test2_pubmsg.payloadlen, m->payloadlen);
+ }
+ MQTTClient_free(topicName);
+ MQTTClient_freeMessage(&m);
+ return 1;
+}
+
+
+void test2_sendAndReceive(MQTTClient* c, int qos, char* test_topic)
+{
+ MQTTClient_deliveryToken dt;
+ int i = 0;
+ int iterations = 50;
+ int rc = 0;
+ int wait_seconds = 0;
+
+ test2_deliveryCompleted = 0;
+
+ MyLog(LOGA_INFO, "%d messages at QoS %d", iterations, qos);
+ test2_pubmsg.payload = "a much longer message that we can shorten to the extent that we need to";
+ test2_pubmsg.payloadlen = 27;
+ test2_pubmsg.qos = qos;
+ test2_pubmsg.retained = 0;
+
+ for (i = 1; i <= iterations; ++i)
+ {
+ if (i % 10 == 0)
+ rc = MQTTClient_publish(c, test_topic, test2_pubmsg.payloadlen, test2_pubmsg.payload,
+ test2_pubmsg.qos, test2_pubmsg.retained, NULL);
+ else
+ rc = MQTTClient_publishMessage(c, test_topic, &test2_pubmsg, &dt);
+ assert("Good rc from publish", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
+
+ #if defined(WIN32)
+ Sleep(100);
+ #else
+ usleep(100000L);
+ #endif
+
+ wait_seconds = 10;
+ while ((test2_arrivedcount < i) && (wait_seconds-- > 0))
+ {
+ MyLog(LOGA_DEBUG, "Arrived %d count %d", test2_arrivedcount, i);
+ #if defined(WIN32)
+ Sleep(1000);
+ #else
+ usleep(1000000L);
+ #endif
+ }
+ assert("Message Arrived", wait_seconds > 0,
+ "Time out waiting for message %d\n", i );
+ }
+ if (qos > 0)
+ {
+ /* MQ Telemetry can send a message to a subscriber before the server has
+ completed the QoS 2 handshake with the publisher. For QoS 1 and 2,
+ allow time for the final delivery complete callback before checking
+ that all expected callbacks have been made */
+ wait_seconds = 40;
+ while ((test2_deliveryCompleted < iterations) && (wait_seconds-- > 0))
+ {
+ MyLog(LOGA_DEBUG, "Delivery Completed %d count %d", test2_deliveryCompleted, i);
+ #if defined(WIN32)
+ Sleep(1000);
+ #else
+ usleep(1000000L);
+ #endif
+ }
+ assert("All Deliveries Complete", test2_deliveryCompleted == iterations,
+ "Number of deliveryCompleted callbacks was %d\n",
+ test2_deliveryCompleted);
+ }
+}
+
+
+int test2(struct Options options)
+{
+ char* testname = "test2";
+ int subsqos = 2;
+ /* TODO - usused - remove ? MQTTClient_deliveryToken* dt = NULL; */
+ MQTTClient c;
+ MQTTClient_connectOptions opts = MQTTClient_connectOptions_initializer;
+ int rc = 0;
+ char* test_topic = "C client test2";
+
+ fprintf(xml, "\n", (int)(ARRAY_SIZE(tests) - 1));
+
+ setenv("MQTT_C_CLIENT_TRACE", "ON", 1);
+ setenv("MQTT_C_CLIENT_TRACE_LEVEL", "ERROR", 1);
+
+ getopts(argc, argv);
+
+ for (i = 0; i < options.iterations; ++i)
+ {
+ if (options.test_no == 0)
+ { /* run all the tests */
+ for (options.test_no = 1; options.test_no < ARRAY_SIZE(tests); ++options.test_no)
+ rc += tests[options.test_no](options); /* return number of failures. 0 = test succeeded */
+ }
+ else
+ rc = tests[options.test_no](options); /* run just the selected test */
+ }
+
+ if (rc == 0)
+ MyLog(LOGA_INFO, "verdict pass");
+ else
+ MyLog(LOGA_INFO, "verdict fail");
+
+ fprintf(xml, "\n");
+ fclose(xml);
+ return rc;
+}
diff --git a/test/test4.c b/test/test4.c
index 31edbf48..c2d51378 100644
--- a/test/test4.c
+++ b/test/test4.c
@@ -13,6 +13,7 @@
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
* Ian Craggs - MQTT 3.1.1 support
+ * Ian Craggs - test8 - failure callbacks
*******************************************************************************/
@@ -22,12 +23,6 @@
*/
-/*
-#if !defined(_RTSHEADER)
- #include
-#endif
-*/
-
#include "MQTTAsync.h"
#include
#include
@@ -1329,7 +1324,7 @@ int test7(struct Options options)
rc = MQTTAsync_send(c, test_topic, pubmsg.payloadlen, pubmsg.payload, pubmsg.qos, pubmsg.retained, &ropts);
MyLog(LOGA_DEBUG, "Token was %d", ropts.token);
rc = MQTTAsync_isComplete(c, ropts.token);
- assert("0 rc from isComplete", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+ /*assert("0 rc from isComplete", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);*/
rc = MQTTAsync_waitForCompletion(c, ropts.token, 5000L);
assert("Good rc from waitForCompletion", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
rc = MQTTAsync_isComplete(c, ropts.token);
@@ -1440,6 +1435,258 @@ exit:
+/*********************************************************************
+
+Test8: Incomplete commands and requests
+
+*********************************************************************/
+
+char* test8_topic = "C client test8";
+int test8_messageCount = 0;
+int test8_subscribed = 0;
+int test8_publishFailures = 0;
+
+void test8_onPublish(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+
+ MyLog(LOGA_DEBUG, "In publish onSuccess callback %p token %d", c, response->token);
+
+}
+
+void test8_onPublishFailure(void* context, MQTTAsync_failureData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MyLog(LOGA_DEBUG, "In onPublish failure callback %p", c);
+
+ assert("Response code should be interrupted", response->code == MQTTASYNC_OPERATION_INCOMPLETE,
+ "rc was %d", response->code);
+
+ test8_publishFailures++;
+}
+
+
+void test8_onDisconnectFailure(void* context, MQTTAsync_failureData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MyLog(LOGA_DEBUG, "In onDisconnect failure callback %p", c);
+
+ assert("Successful disconnect", 0, "disconnect failed", 0);
+
+ test_finished = 1;
+}
+
+
+void test8_onDisconnect(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MyLog(LOGA_DEBUG, "In onDisconnect callback %p", c);
+ test_finished = 1;
+}
+
+
+void test8_onSubscribe(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+
+ MyLog(LOGA_DEBUG, "In subscribe onSuccess callback %p granted qos %d", c, response->alt.qos);
+
+ test8_subscribed = 1;
+}
+
+
+void test8_onConnect(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+ int rc;
+
+ MyLog(LOGA_DEBUG, "In connect onSuccess callback, context %p", context);
+ opts.onSuccess = test8_onSubscribe;
+ opts.context = c;
+
+ rc = MQTTAsync_subscribe(c, test8_topic, 2, &opts);
+ assert("Good rc from subscribe", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+ if (rc != MQTTASYNC_SUCCESS)
+ test_finished = 1;
+}
+
+int test8_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync_message* message)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ static int message_count = 0;
+
+ MyLog(LOGA_DEBUG, "Test8: received message id %d", message->msgid);
+
+ test8_messageCount++;
+
+ MQTTAsync_freeMessage(&message);
+ MQTTAsync_free(topicName);
+
+ return 1;
+}
+
+
+int test8(struct Options options)
+{
+ int subsqos = 2;
+ MQTTAsync c;
+ MQTTAsync_connectOptions opts = MQTTAsync_connectOptions_initializer;
+ int rc = 0;
+ MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+ MQTTAsync_responseOptions ropts = MQTTAsync_responseOptions_initializer;
+ MQTTAsync_disconnectOptions dopts = MQTTAsync_disconnectOptions_initializer;
+ MQTTAsync_token* tokens = NULL;
+ int msg_count = 6;
+
+ MyLog(LOGA_INFO, "Starting test 8 - incomplete commands");
+ fprintf(xml, " 0", test8_publishFailures > 0,
+ "test8_publishFailures = %d", test8_publishFailures);
+
+ /* Now elicit failure callbacks on destroy */
+
+ test8_subscribed = test8_publishFailures = 0;
+
+ MyLog(LOGA_DEBUG, "Connecting");
+ opts.cleansession = 0;
+ opts.onSuccess = test8_onConnect;
+ rc = MQTTAsync_connect(c, &opts);
+ rc = 0;
+ assert("Good rc from connect", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+ if (rc != MQTTASYNC_SUCCESS)
+ goto exit;
+
+ while (!test8_subscribed)
+ #if defined(WIN32)
+ Sleep(100);
+ #else
+ usleep(10000L);
+ #endif
+
+ i = 0;
+ pubmsg.qos = 2;
+ ropts.onSuccess = test8_onPublish;
+ ropts.onFailure = test8_onPublishFailure;
+ ropts.context = c;
+ for (i = 0; i < msg_count; ++i)
+ {
+ pubmsg.payload = "a much longer message that we can shorten to the extent that we need to payload up to 11";
+ pubmsg.payloadlen = 11;
+ pubmsg.qos = (pubmsg.qos == 2) ? 1 : 2; /* alternate */
+ pubmsg.retained = 0;
+ rc = MQTTAsync_sendMessage(c, test8_topic, &pubmsg, &ropts);
+ assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+ }
+ /* disconnect immediately without completing the commands */
+ dopts.timeout = 0;
+ dopts.onSuccess = test8_onDisconnect;
+ dopts.context = c;
+ rc = MQTTAsync_disconnect(c, &dopts); /* now there should be incomplete commands */
+ assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+
+ while (!test_finished)
+ #if defined(WIN32)
+ Sleep(100);
+ #else
+ usleep(10000L);
+ #endif
+ test_finished = 0;
+
+ rc = MQTTAsync_getPendingTokens(c, &tokens);
+ assert("getPendingTokens rc == 0", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+ assert("should get some tokens back", tokens != NULL, "tokens was %p", tokens);
+ MQTTAsync_free(tokens);
+
+ assert("test8_publishFailures == 0", test8_publishFailures == 0,
+ "test8_publishFailures = %d", test8_publishFailures);
+
+ MQTTAsync_destroy(&c);
+
+ assert("test8_publishFailures > 0", test8_publishFailures > 0,
+ "test8_publishFailures = %d", test8_publishFailures);
+
+exit:
+ MyLog(LOGA_INFO, "TEST8: test %s. %d tests run, %d failures.",
+ (failures == 0) ? "passed" : "failed", tests, failures);
+ write_test_result();
+ return failures;
+}
+
+
+
void trace_callback(enum MQTTASYNC_TRACE_LEVELS level, char* message)
{
printf("Trace : %d, %s\n", level, message);
@@ -1451,7 +1698,7 @@ void trace_callback(enum MQTTASYNC_TRACE_LEVELS level, char* message)
int main(int argc, char** argv)
{
int rc = 0;
- int (*tests[])() = {NULL, test1, test2, test3, test4, test5, test6, test7}; /* indexed starting from 1 */
+ int (*tests[])() = {NULL, test1, test2, test3, test4, test5, test6, test7, test8}; /* indexed starting from 1 */
MQTTAsync_nameValue* info;
int i;
diff --git a/test/test9.c b/test/test9.c
new file mode 100644
index 00000000..e17cb232
--- /dev/null
+++ b/test/test9.c
@@ -0,0 +1,1690 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2016 IBM Corp.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Ian Craggs - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+
+/**
+ * @file
+ * Offline buffering and automatic reconnect tests for the MQ Telemetry Asynchronous MQTT C client
+ *
+ */
+
+
+#include "MQTTAsync.h"
+#include
+#include
+#include "Thread.h"
+
+#if !defined(_WINDOWS)
+ #include
+ #include
+ #include
+ #include
+#else
+#include
+#include
+#define MAXHOSTNAMELEN 256
+#define EAGAIN WSAEWOULDBLOCK
+#define EINTR WSAEINTR
+#define EINPROGRESS WSAEINPROGRESS
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define ENOTCONN WSAENOTCONN
+#define ECONNRESET WSAECONNRESET
+#endif
+
+char unique[50]; // unique suffix/prefix to add to clientid/topic etc
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+void usage()
+{
+ printf("help!!\n");
+ exit(-1);
+}
+
+struct Options
+{
+ char* connection; /**< connection to system under test. */
+ char* proxy_connection; /**< connection to proxy */
+ int verbose;
+ int test_no;
+} options =
+{
+ "iot.eclipse.org:1883",
+ "localhost:1883",
+ 0,
+ 0,
+};
+
+void getopts(int argc, char** argv)
+{
+ int count = 1;
+
+ while (count < argc)
+ {
+ if (strcmp(argv[count], "--test_no") == 0)
+ {
+ if (++count < argc)
+ options.test_no = atoi(argv[count]);
+ else
+ usage();
+ }
+ else if (strcmp(argv[count], "--connection") == 0)
+ {
+ if (++count < argc)
+ options.connection = argv[count];
+ else
+ usage();
+ }
+ else if (strcmp(argv[count], "--verbose") == 0)
+ options.verbose = 1;
+ count++;
+ }
+}
+
+
+#define LOGA_DEBUG 0
+#define LOGA_INFO 1
+#include
+#include
+#include
+void MyLog(int LOGA_level, char* format, ...)
+{
+ static char msg_buf[256];
+ va_list args;
+ struct timeb ts;
+
+ struct tm *timeinfo;
+
+ if (LOGA_level == LOGA_DEBUG && options.verbose == 0)
+ return;
+
+ ftime(&ts);
+ timeinfo = localtime(&ts.time);
+ strftime(msg_buf, 80, "%Y%m%d %H%M%S", timeinfo);
+
+ sprintf(&msg_buf[strlen(msg_buf)], ".%.3hu ", ts.millitm);
+
+ va_start(args, format);
+ vsnprintf(&msg_buf[strlen(msg_buf)], sizeof(msg_buf) - strlen(msg_buf),
+ format, args);
+ va_end(args);
+
+ printf("%s\n", msg_buf);
+ fflush(stdout);
+}
+
+void MySleep(long milliseconds)
+{
+#if defined(WIN32) || defined(WIN64)
+ Sleep(milliseconds);
+#else
+ usleep(milliseconds*1000);
+#endif
+}
+
+#if defined(WIN32) || defined(_WINDOWS)
+#define START_TIME_TYPE DWORD
+static DWORD start_time = 0;
+START_TIME_TYPE start_clock(void)
+{
+ return GetTickCount();
+}
+#elif defined(AIX)
+#define START_TIME_TYPE struct timespec
+START_TIME_TYPE start_clock(void)
+{
+ static struct timespec start;
+ clock_gettime(CLOCK_REALTIME, &start);
+ return start;
+}
+#else
+#define START_TIME_TYPE struct timeval
+/* TODO - unused - remove? static struct timeval start_time; */
+START_TIME_TYPE start_clock(void)
+{
+ struct timeval start_time;
+ gettimeofday(&start_time, NULL);
+ return start_time;
+}
+#endif
+
+#if defined(WIN32)
+long elapsed(START_TIME_TYPE start_time)
+{
+ return GetTickCount() - start_time;
+}
+#elif defined(AIX)
+#define assert(a)
+long elapsed(struct timespec start)
+{
+ struct timespec now, res;
+
+ clock_gettime(CLOCK_REALTIME, &now);
+ ntimersub(now, start, res);
+ return (res.tv_sec)*1000L + (res.tv_nsec)/1000000L;
+}
+#else
+long elapsed(START_TIME_TYPE start_time)
+{
+ struct timeval now, res;
+
+ gettimeofday(&now, NULL);
+ timersub(&now, &start_time, &res);
+ return (res.tv_sec) * 1000 + (res.tv_usec) / 1000;
+}
+#endif
+
+#define assert(a, b, c, d) myassert(__FILE__, __LINE__, a, b, c, d)
+#define assert1(a, b, c, d, e) myassert(__FILE__, __LINE__, a, b, c, d, e)
+
+#define MAXMSGS 30;
+
+int tests = 0;
+int failures = 0;
+FILE* xml;
+START_TIME_TYPE global_start_time;
+char output[3000];
+char* cur_output = output;
+
+
+void write_test_result()
+{
+ long duration = elapsed(global_start_time);
+
+ fprintf(xml, " time=\"%ld.%.3ld\" >\n", duration / 1000, duration % 1000);
+ if (cur_output != output)
+ {
+ fprintf(xml, "%s", output);
+ cur_output = output;
+ }
+ fprintf(xml, "\n");
+}
+
+void myassert(char* filename, int lineno, char* description, int value,
+ char* format, ...)
+{
+ ++tests;
+ if (!value)
+ {
+ va_list args;
+
+ ++failures;
+ MyLog(LOGA_INFO, "Assertion failed, file %s, line %d, description: %s", filename,
+ lineno, description);
+
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+
+ cur_output += sprintf(cur_output, "file %s, line %d \n",
+ description, filename, lineno);
+ }
+ else
+ MyLog(LOGA_DEBUG, "Assertion succeeded, file %s, line %d, description: %s",
+ filename, lineno, description);
+}
+
+/*********************************************************************
+
+ Tests: offline buffering - sending messages while disconnected
+
+ 1. send some messages while disconnected, check that they are sent
+ 2. repeat test 1 using serverURIs
+ 3. repeat test 1 using auto reconnect
+ 4. repeat test 2 using auto reconnect
+ 5. check max-buffered
+ 6. check auto-reconnect parms alter behaviour as expected
+
+ Tests: automatic reconnect
+
+ - check that connected() is called
+ - check that reconnect() causes reconnect attempt
+ - check that reconnect() fails if no connect has been previously attempted
+
+ *********************************************************************/
+
+
+
+
+/*********************************************************************
+
+ Test1: offline buffering - sending messages while disconnected
+
+ 1. call connect
+ 2. use proxy to disconnect the client
+ 3. while the client is disconnected, send more messages
+ 4. when the client reconnects, check that those messages are sent
+
+ *********************************************************************/
+
+int test1_will_message_received = 0;
+int test1_messages_received = 0;
+
+int test1_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync_message* message)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ static int message_count = 0;
+
+ MyLog(LOGA_DEBUG, "Message received on topic %s, \"%.*s\"", topicName, message->payloadlen, message->payload);
+
+ if (memcmp(message->payload, "will message", message->payloadlen) == 0)
+ test1_will_message_received = 1;
+ else
+ test1_messages_received++;
+
+ MQTTAsync_freeMessage(&message);
+ MQTTAsync_free(topicName);
+
+ return 1;
+}
+
+int test1Finished = 0;
+
+int test1OnFailureCalled = 0;
+
+void test1cOnFailure(void* context, MQTTAsync_failureData* response)
+{
+ MyLog(LOGA_DEBUG, "In connect onFailure callback, context %p", context);
+
+ test1OnFailureCalled++;
+ test1Finished = 1;
+}
+
+void test1dOnFailure(void* context, MQTTAsync_failureData* response)
+{
+ MyLog(LOGA_DEBUG, "In connect onFailure callback, context %p", context);
+
+ test1OnFailureCalled++;
+ test1Finished = 1;
+}
+
+void test1cOnConnect(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+ MyLog(LOGA_DEBUG, "In connect onSuccess callback for client d, context %p\n", context);
+ MQTTAsync c = (MQTTAsync)context;
+ int rc;
+
+ /* send a message to the proxy to break the connection */
+ pubmsg.payload = "TERMINATE";
+ pubmsg.payloadlen = strlen(pubmsg.payload);
+ pubmsg.qos = 0;
+ pubmsg.retained = 0;
+ rc = MQTTAsync_sendMessage(c, "MQTTSAS topic", &pubmsg, NULL);
+ assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+}
+
+
+int test1dReady = 0;
+char willTopic[100];
+char test_topic[50];
+
+void test1donSubscribe(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MyLog(LOGA_DEBUG, "In subscribe onSuccess callback for client d, %p granted qos %d", c, response->alt.qos);
+ test1dReady = 1;
+}
+
+
+void test1dOnConnect(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+ int rc;
+ int qoss[2] = {2, 2};
+ char* topics[2] = {willTopic, test_topic};
+
+ MyLog(LOGA_DEBUG, "In connect onSuccess callback for client c, context %p\n", context);
+ opts.onSuccess = test1donSubscribe;
+ opts.context = c;
+
+ rc = MQTTAsync_subscribeMany(c, 2, topics, qoss, &opts);
+ assert("Good rc from subscribe", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+ if (rc != MQTTASYNC_SUCCESS)
+ test1Finished = 1;
+}
+
+int test1c_connected = 0;
+
+void test1cConnected(void* context, char* cause)
+{
+ MQTTAsync c = (MQTTAsync)context;
+
+ MyLog(LOGA_DEBUG, "In connected callback for client c, context %p\n", context);
+ test1c_connected = 1;
+}
+
+
+int test1(struct Options options)
+{
+ char* testname = "test1";
+ int subsqos = 2;
+ MQTTAsync c, d;
+ MQTTAsync_connectOptions opts = MQTTAsync_connectOptions_initializer;
+ MQTTAsync_willOptions wopts = MQTTAsync_willOptions_initializer;
+ MQTTAsync_createOptions createOptions = MQTTAsync_createOptions_initializer;
+ int rc = 0;
+ int count = 0;
+ char clientidc[50];
+ char clientidd[50];
+ int i = 0;
+ MQTTAsync_token *tokens;
+
+ sprintf(willTopic, "paho-test9-1-%s", unique);
+ sprintf(clientidc, "paho-test9-1-c-%s", unique);
+ sprintf(clientidd, "paho-test9-1-d-%s", unique);
+ sprintf(test_topic, "paho-test9-1-test topic %s", unique);
+
+ test1Finished = 0;
+ failures = 0;
+ MyLog(LOGA_INFO, "Starting Offline buffering 1 - messages while disconnected");
+ fprintf(xml, "message = "will message";
+ opts.will->qos = 1;
+ opts.will->retained = 0;
+ opts.will->topicName = willTopic;
+ opts.onSuccess = test1cOnConnect;
+ opts.onFailure = test1cOnFailure;
+ opts.context = c;
+ opts.cleansession = 0;
+
+ MyLog(LOGA_DEBUG, "Connecting client c");
+ rc = MQTTAsync_connect(c, &opts);
+ assert("Good rc from connect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ if (rc != MQTTASYNC_SUCCESS)
+ {
+ failures++;
+ goto exit;
+ }
+
+ /* wait for will message */
+ while (!test1_will_message_received && ++count < 10000)
+ MySleep(100);
+
+ MyLog(LOGA_DEBUG, "Now we can send some messages to be buffered");
+
+ test1c_connected = 0;
+ /* send some messages. Then reconnect (check connected callback), and check that those messages are received */
+ for (i = 0; i < 3; ++i)
+ {
+ char buf[50];
+
+ MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+ MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+ sprintf(buf, "QoS %d message", i);
+ pubmsg.payload = buf;
+ pubmsg.payloadlen = strlen(pubmsg.payload) + 1;
+ pubmsg.qos = i;
+ pubmsg.retained = 0;
+ rc = MQTTAsync_sendMessage(c, test_topic, &pubmsg, &opts);
+ assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ }
+
+ rc = MQTTAsync_getPendingTokens(c, &tokens);
+ assert("Good rc from getPendingTokens", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ i = 0;
+ if (tokens)
+ {
+ while (tokens[i] != -1)
+ ++i;
+ MQTTAsync_free(tokens);
+ }
+ assert("Number of getPendingTokens should be 3", i == 3, "i was %d ", i);
+
+ rc = MQTTAsync_reconnect(c);
+ assert("Good rc from reconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+ /* wait for client to be reconnected */
+ while (!test1c_connected == 0 && ++count < 10000)
+ MySleep(100);
+
+ /* wait for success or failure callback */
+ while (test1_messages_received < 3 && ++count < 10000)
+ MySleep(100);
+
+ rc = MQTTAsync_getPendingTokens(c, &tokens);
+ assert("Good rc from getPendingTokens", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ i = 0;
+ if (tokens)
+ {
+ while (tokens[i] != -1)
+ ++i;
+ MQTTAsync_free(tokens);
+ }
+ assert("Number of getPendingTokens should be 0", i == 0, "i was %d ", i);
+
+ rc = MQTTAsync_disconnect(c, NULL);
+ assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+ rc = MQTTAsync_disconnect(d, NULL);
+ assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+exit:
+ MQTTAsync_destroy(&c);
+ MQTTAsync_destroy(&d);
+ MyLog(LOGA_INFO, "%s: test %s. %d tests run, %d failures.",
+ (failures == 0) ? "passed" : "failed", testname, tests, failures);
+ write_test_result();
+ return failures;
+}
+
+
+/*********************************************************************
+
+ Test2: offline buffering - sending messages while disconnected
+
+ 1. call connect
+ 2. use proxy to disconnect the client
+ 3. while the client is disconnected, send more messages
+ 4. when the client reconnects, check that those messages are sent
+
+ *********************************************************************/
+
+int test2_will_message_received = 0;
+int test2_messages_received = 0;
+
+int test2_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync_message* message)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ static int message_count = 0;
+
+ MyLog(LOGA_DEBUG, "Message received on topic %s, \"%.*s\"", topicName, message->payloadlen, message->payload);
+
+ if (memcmp(message->payload, "will message", message->payloadlen) == 0)
+ test2_will_message_received = 1;
+ else
+ test2_messages_received++;
+
+ MQTTAsync_freeMessage(&message);
+ MQTTAsync_free(topicName);
+
+ return 1;
+}
+
+int test2Finished = 0;
+
+int test2OnFailureCalled = 0;
+
+void test2cOnFailure(void* context, MQTTAsync_failureData* response)
+{
+ MyLog(LOGA_DEBUG, "In connect onFailure callback, context %p", context);
+
+ test2OnFailureCalled++;
+ test2Finished = 1;
+}
+
+void test2dOnFailure(void* context, MQTTAsync_failureData* response)
+{
+ MyLog(LOGA_DEBUG, "In connect onFailure callback, context %p", context);
+
+ test2OnFailureCalled++;
+ test2Finished = 1;
+}
+
+void test2cOnConnect(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+ MyLog(LOGA_DEBUG, "In connect onSuccess callback for client d, context %p\n", context);
+ MQTTAsync c = (MQTTAsync)context;
+ int rc;
+
+ /* send a message to the proxy to break the connection */
+ pubmsg.payload = "TERMINATE";
+ pubmsg.payloadlen = strlen(pubmsg.payload);
+ pubmsg.qos = 0;
+ pubmsg.retained = 0;
+ rc = MQTTAsync_sendMessage(c, "MQTTSAS topic", &pubmsg, NULL);
+ assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+}
+
+
+int test2dReady = 0;
+char willTopic[100];
+char test_topic[50];
+
+void test2donSubscribe(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MyLog(LOGA_DEBUG, "In subscribe onSuccess callback for client d, %p granted qos %d", c, response->alt.qos);
+ test2dReady = 1;
+}
+
+
+void test2dOnConnect(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+ int rc;
+ int qoss[2] = {2, 2};
+ char* topics[2] = {willTopic, test_topic};
+
+ MyLog(LOGA_DEBUG, "In connect onSuccess callback for client c, context %p\n", context);
+ opts.onSuccess = test2donSubscribe;
+ opts.context = c;
+
+ rc = MQTTAsync_subscribeMany(c, 2, topics, qoss, &opts);
+ assert("Good rc from subscribe", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+ if (rc != MQTTASYNC_SUCCESS)
+ test2Finished = 1;
+}
+
+int test2c_connected = 0;
+
+void test2cConnected(void* context, char* cause)
+{
+ MQTTAsync c = (MQTTAsync)context;
+
+ MyLog(LOGA_DEBUG, "In connected callback for client c, context %p\n", context);
+ test2c_connected = 1;
+}
+
+
+int test2(struct Options options)
+{
+ char* testname = "test2";
+ int subsqos = 2;
+ MQTTAsync c, d;
+ MQTTAsync_connectOptions opts = MQTTAsync_connectOptions_initializer;
+ MQTTAsync_willOptions wopts = MQTTAsync_willOptions_initializer;
+ MQTTAsync_createOptions createOptions = MQTTAsync_createOptions_initializer;
+ int rc = 0;
+ int count = 0;
+ char clientidc[50];
+ char clientidd[50];
+ int i = 0;
+ MQTTAsync_token *tokens;
+ char *URIs[2] = {"rubbish", options.proxy_connection};
+
+ sprintf(willTopic, "paho-test9-2-%s", unique);
+ sprintf(clientidc, "paho-test9-2-c-%s", unique);
+ sprintf(clientidd, "paho-test9-2-d-%s", unique);
+ sprintf(test_topic, "paho-test9-2-test topic %s", unique);
+
+ test2Finished = 0;
+ failures = 0;
+ MyLog(LOGA_INFO, "Starting Offline buffering 2 - messages while disconnected with serverURIs");
+ fprintf(xml, "message = "will message";
+ opts.will->qos = 1;
+ opts.will->retained = 0;
+ opts.will->topicName = willTopic;
+ opts.onSuccess = test2cOnConnect;
+ opts.onFailure = test2cOnFailure;
+ opts.context = c;
+ opts.cleansession = 0;
+ opts.serverURIs = URIs;
+ opts.serverURIcount = 2;
+
+ MyLog(LOGA_DEBUG, "Connecting client c");
+ rc = MQTTAsync_connect(c, &opts);
+ assert("Good rc from connect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ if (rc != MQTTASYNC_SUCCESS)
+ {
+ failures++;
+ goto exit;
+ }
+
+ /* wait for will message */
+ while (!test2_will_message_received && ++count < 10000)
+ MySleep(100);
+
+ MyLog(LOGA_DEBUG, "Now we can send some messages to be buffered");
+
+ test2c_connected = 0;
+ /* send some messages. Then reconnect (check connected callback), and check that those messages are received */
+ for (i = 0; i < 3; ++i)
+ {
+ char buf[50];
+
+ MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+ MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+ sprintf(buf, "QoS %d message", i);
+ pubmsg.payload = buf;
+ pubmsg.payloadlen = strlen(pubmsg.payload) + 1;
+ pubmsg.qos = i;
+ pubmsg.retained = 0;
+ rc = MQTTAsync_sendMessage(c, test_topic, &pubmsg, &opts);
+ assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ }
+
+ rc = MQTTAsync_getPendingTokens(c, &tokens);
+ assert("Good rc from getPendingTokens", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ i = 0;
+ if (tokens)
+ {
+ while (tokens[i] != -1)
+ ++i;
+ MQTTAsync_free(tokens);
+ }
+ assert("Number of getPendingTokens should be 3", i == 3, "i was %d ", i);
+
+ rc = MQTTAsync_reconnect(c);
+ assert("Good rc from reconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+ /* wait for client to be reconnected */
+ while (!test2c_connected == 0 && ++count < 10000)
+ MySleep(100);
+
+ /* wait for success or failure callback */
+ while (test2_messages_received < 3 && ++count < 10000)
+ MySleep(100);
+
+ rc = MQTTAsync_getPendingTokens(c, &tokens);
+ assert("Good rc from getPendingTokens", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ i = 0;
+ if (tokens)
+ {
+ while (tokens[i] != -1)
+ ++i;
+ MQTTAsync_free(tokens);
+ }
+ assert("Number of getPendingTokens should be 0", i == 0, "i was %d ", i);
+
+ rc = MQTTAsync_disconnect(c, NULL);
+ assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+ rc = MQTTAsync_disconnect(d, NULL);
+ assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+exit:
+ MQTTAsync_destroy(&c);
+ MQTTAsync_destroy(&d);
+ MyLog(LOGA_INFO, "%s: test %s. %d tests run, %d failures.",
+ (failures == 0) ? "passed" : "failed", testname, tests, failures);
+ write_test_result();
+ return failures;
+}
+
+/*********************************************************************
+
+ test3: offline buffering - sending messages while disconnected
+
+ 1. call connect
+ 2. use proxy to disconnect the client
+ 3. while the client is disconnected, send more messages
+ 4. when the client auto reconnects, check that those messages are sent
+
+ *********************************************************************/
+
+int test3_will_message_received = 0;
+int test3_messages_received = 0;
+
+int test3_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync_message* message)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ static int message_count = 0;
+
+ MyLog(LOGA_DEBUG, "Message received on topic %s, \"%.*s\"", topicName, message->payloadlen, message->payload);
+
+ if (memcmp(message->payload, "will message", message->payloadlen) == 0)
+ test3_will_message_received = 1;
+ else
+ test3_messages_received++;
+
+ MQTTAsync_freeMessage(&message);
+ MQTTAsync_free(topicName);
+
+ return 1;
+}
+
+int test3Finished = 0;
+
+int test3OnFailureCalled = 0;
+
+void test3cOnFailure(void* context, MQTTAsync_failureData* response)
+{
+ MyLog(LOGA_DEBUG, "In connect onFailure callback, context %p", context);
+
+ test3OnFailureCalled++;
+ test3Finished = 1;
+}
+
+void test3dOnFailure(void* context, MQTTAsync_failureData* response)
+{
+ MyLog(LOGA_DEBUG, "In connect onFailure callback, context %p", context);
+
+ test3OnFailureCalled++;
+ test3Finished = 1;
+}
+
+void test3cOnConnect(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+ MyLog(LOGA_DEBUG, "In connect onSuccess callback for client d, context %p\n", context);
+ MQTTAsync c = (MQTTAsync)context;
+ int rc;
+
+ /* send a message to the proxy to break the connection */
+ pubmsg.payload = "TERMINATE";
+ pubmsg.payloadlen = strlen(pubmsg.payload);
+ pubmsg.qos = 0;
+ pubmsg.retained = 0;
+ rc = MQTTAsync_sendMessage(c, "MQTTSAS topic", &pubmsg, NULL);
+ assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+}
+
+
+int test3dReady = 0;
+char willTopic[100];
+char test_topic[50];
+
+void test3donSubscribe(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MyLog(LOGA_DEBUG, "In subscribe onSuccess callback for client d, %p granted qos %d", c, response->alt.qos);
+ test3dReady = 1;
+}
+
+
+void test3dOnConnect(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+ int rc;
+ int qoss[2] = {2, 2};
+ char* topics[2] = {willTopic, test_topic};
+
+ MyLog(LOGA_DEBUG, "In connect onSuccess callback for client c, context %p\n", context);
+ opts.onSuccess = test3donSubscribe;
+ opts.context = c;
+
+ rc = MQTTAsync_subscribeMany(c, 2, topics, qoss, &opts);
+ assert("Good rc from subscribe", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+ if (rc != MQTTASYNC_SUCCESS)
+ test3Finished = 1;
+}
+
+int test3c_connected = 0;
+
+void test3cConnected(void* context, char* cause)
+{
+ MQTTAsync c = (MQTTAsync)context;
+
+ MyLog(LOGA_DEBUG, "In connected callback for client c, context %p\n", context);
+ test3c_connected = 1;
+}
+
+
+int test3(struct Options options)
+{
+ char* testname = "test3";
+ int subsqos = 2;
+ MQTTAsync c, d;
+ MQTTAsync_connectOptions opts = MQTTAsync_connectOptions_initializer;
+ MQTTAsync_willOptions wopts = MQTTAsync_willOptions_initializer;
+ MQTTAsync_createOptions createOptions = MQTTAsync_createOptions_initializer;
+ int rc = 0;
+ int count = 0;
+ char clientidc[50];
+ char clientidd[50];
+ int i = 0;
+ MQTTAsync_token *tokens;
+
+ sprintf(willTopic, "paho-test9-3-%s", unique);
+ sprintf(clientidc, "paho-test9-3-c-%s", unique);
+ sprintf(clientidd, "paho-test9-3-d-%s", unique);
+ sprintf(test_topic, "paho-test9-3-test topic %s", unique);
+
+ test3Finished = 0;
+ failures = 0;
+ MyLog(LOGA_INFO, "Starting Offline buffering 3 - messages while disconnected");
+ fprintf(xml, "message = "will message";
+ opts.will->qos = 1;
+ opts.will->retained = 0;
+ opts.will->topicName = willTopic;
+ opts.onSuccess = test3cOnConnect;
+ opts.onFailure = test3cOnFailure;
+ opts.context = c;
+ opts.cleansession = 0;
+ opts.automaticReconnect = 1;
+
+ MyLog(LOGA_DEBUG, "Connecting client c");
+ rc = MQTTAsync_connect(c, &opts);
+ assert("Good rc from connect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ if (rc != MQTTASYNC_SUCCESS)
+ {
+ failures++;
+ goto exit;
+ }
+
+ /* wait for will message */
+ while (!test3_will_message_received && ++count < 10000)
+ MySleep(100);
+
+ MyLog(LOGA_DEBUG, "Now we can send some messages to be buffered");
+
+ test3c_connected = 0;
+ /* send some messages. Then reconnect (check connected callback), and check that those messages are received */
+ for (i = 0; i < 3; ++i)
+ {
+ char buf[50];
+
+ MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+ MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+ sprintf(buf, "QoS %d message", i);
+ pubmsg.payload = buf;
+ pubmsg.payloadlen = strlen(pubmsg.payload) + 1;
+ pubmsg.qos = i;
+ pubmsg.retained = 0;
+ rc = MQTTAsync_sendMessage(c, test_topic, &pubmsg, &opts);
+ assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ }
+
+ rc = MQTTAsync_getPendingTokens(c, &tokens);
+ assert("Good rc from getPendingTokens", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ i = 0;
+ if (tokens)
+ {
+ while (tokens[i] != -1)
+ ++i;
+ MQTTAsync_free(tokens);
+ }
+ assert("Number of getPendingTokens should be 3", i == 3, "i was %d ", i);
+
+ /* wait for client to be reconnected */
+ while (!test3c_connected == 0 && ++count < 10000)
+ MySleep(100);
+
+ /* wait for success or failure callback */
+ while (test3_messages_received < 3 && ++count < 10000)
+ MySleep(100);
+
+ rc = MQTTAsync_getPendingTokens(c, &tokens);
+ assert("Good rc from getPendingTokens", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ i = 0;
+ if (tokens)
+ {
+ while (tokens[i] != -1)
+ ++i;
+ MQTTAsync_free(tokens);
+ }
+ assert("Number of getPendingTokens should be 0", i == 0, "i was %d ", i);
+
+
+ rc = MQTTAsync_disconnect(c, NULL);
+ assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+ rc = MQTTAsync_disconnect(d, NULL);
+ assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+exit:
+ MQTTAsync_destroy(&c);
+ MQTTAsync_destroy(&d);
+ MyLog(LOGA_INFO, "%s: test %s. %d tests run, %d failures.",
+ (failures == 0) ? "passed" : "failed", testname, tests, failures);
+ write_test_result();
+ return failures;
+}
+
+/*********************************************************************
+
+ test4: offline buffering - sending messages while disconnected
+
+ 1. call connect
+ 2. use proxy to disconnect the client
+ 3. while the client is disconnected, send more messages
+ 4. when the client auto reconnects, check that those messages are sent
+
+ *********************************************************************/
+
+int test4_will_message_received = 0;
+int test4_messages_received = 0;
+
+int test4_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync_message* message)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ static int message_count = 0;
+
+ MyLog(LOGA_DEBUG, "Message received on topic %s, \"%.*s\"", topicName, message->payloadlen, message->payload);
+
+ if (memcmp(message->payload, "will message", message->payloadlen) == 0)
+ test4_will_message_received = 1;
+ else
+ test4_messages_received++;
+
+ MQTTAsync_freeMessage(&message);
+ MQTTAsync_free(topicName);
+
+ return 1;
+}
+
+int test4Finished = 0;
+
+int test4OnFailureCalled = 0;
+
+void test4cOnFailure(void* context, MQTTAsync_failureData* response)
+{
+ MyLog(LOGA_DEBUG, "In connect onFailure callback, context %p", context);
+
+ test4OnFailureCalled++;
+ test4Finished = 1;
+}
+
+void test4dOnFailure(void* context, MQTTAsync_failureData* response)
+{
+ MyLog(LOGA_DEBUG, "In connect onFailure callback, context %p", context);
+
+ test4OnFailureCalled++;
+ test4Finished = 1;
+}
+
+void test4cOnConnect(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+ MyLog(LOGA_DEBUG, "In connect onSuccess callback for client d, context %p\n", context);
+ MQTTAsync c = (MQTTAsync)context;
+ int rc;
+
+ /* send a message to the proxy to break the connection */
+ pubmsg.payload = "TERMINATE";
+ pubmsg.payloadlen = strlen(pubmsg.payload);
+ pubmsg.qos = 0;
+ pubmsg.retained = 0;
+ rc = MQTTAsync_sendMessage(c, "MQTTSAS topic", &pubmsg, NULL);
+ assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+}
+
+
+int test4dReady = 0;
+char willTopic[100];
+char test_topic[50];
+
+void test4donSubscribe(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MyLog(LOGA_DEBUG, "In subscribe onSuccess callback for client d, %p granted qos %d", c, response->alt.qos);
+ test4dReady = 1;
+}
+
+
+void test4dOnConnect(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+ int rc;
+ int qoss[2] = {2, 2};
+ char* topics[2] = {willTopic, test_topic};
+
+ MyLog(LOGA_DEBUG, "In connect onSuccess callback for client c, context %p\n", context);
+ opts.onSuccess = test4donSubscribe;
+ opts.context = c;
+
+ rc = MQTTAsync_subscribeMany(c, 2, topics, qoss, &opts);
+ assert("Good rc from subscribe", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+ if (rc != MQTTASYNC_SUCCESS)
+ test4Finished = 1;
+}
+
+int test4c_connected = 0;
+
+void test4cConnected(void* context, char* cause)
+{
+ MQTTAsync c = (MQTTAsync)context;
+
+ MyLog(LOGA_DEBUG, "In connected callback for client c, context %p\n", context);
+ test4c_connected = 1;
+}
+
+
+int test4(struct Options options)
+{
+ char* testname = "test4";
+ int subsqos = 2;
+ MQTTAsync c, d;
+ MQTTAsync_connectOptions opts = MQTTAsync_connectOptions_initializer;
+ MQTTAsync_willOptions wopts = MQTTAsync_willOptions_initializer;
+ MQTTAsync_createOptions createOptions = MQTTAsync_createOptions_initializer;
+ int rc = 0;
+ int count = 0;
+ char clientidc[50];
+ char clientidd[50];
+ int i = 0;
+ MQTTAsync_token *tokens;
+ char *URIs[2] = {"rubbish", options.proxy_connection};
+
+ sprintf(willTopic, "paho-test9-4-%s", unique);
+ sprintf(clientidc, "paho-test9-4-c-%s", unique);
+ sprintf(clientidd, "paho-test9-4-d-%s", unique);
+ sprintf(test_topic, "paho-test9-4-test topic %s", unique);
+
+ test4Finished = 0;
+ failures = 0;
+ MyLog(LOGA_INFO, "Starting Offline buffering 4 - messages while disconnected with serverURIs");
+ fprintf(xml, "message = "will message";
+ opts.will->qos = 1;
+ opts.will->retained = 0;
+ opts.will->topicName = willTopic;
+ opts.onSuccess = test4cOnConnect;
+ opts.onFailure = test4cOnFailure;
+ opts.context = c;
+ opts.cleansession = 0;
+ opts.serverURIs = URIs;
+ opts.serverURIcount = 2;
+ opts.automaticReconnect = 1;
+
+ MyLog(LOGA_DEBUG, "Connecting client c");
+ rc = MQTTAsync_connect(c, &opts);
+ assert("Good rc from connect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ if (rc != MQTTASYNC_SUCCESS)
+ {
+ failures++;
+ goto exit;
+ }
+
+ /* wait for will message */
+ while (!test4_will_message_received && ++count < 10000)
+ MySleep(100);
+
+ MyLog(LOGA_DEBUG, "Now we can send some messages to be buffered");
+
+ test4c_connected = 0;
+ /* send some messages. Then reconnect (check connected callback), and check that those messages are received */
+ for (i = 0; i < 3; ++i)
+ {
+ char buf[50];
+
+ MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+ MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+ sprintf(buf, "QoS %d message", i);
+ pubmsg.payload = buf;
+ pubmsg.payloadlen = strlen(pubmsg.payload) + 1;
+ pubmsg.qos = i;
+ pubmsg.retained = 0;
+ rc = MQTTAsync_sendMessage(c, test_topic, &pubmsg, &opts);
+ assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ }
+
+ rc = MQTTAsync_getPendingTokens(c, &tokens);
+ assert("Good rc from getPendingTokens", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ i = 0;
+ if (tokens)
+ {
+ while (tokens[i] != -1)
+ ++i;
+ MQTTAsync_free(tokens);
+ }
+ assert("Number of getPendingTokens should be 3", i == 3, "i was %d ", i);
+
+ /* wait for client to be reconnected */
+ while (!test4c_connected == 0 && ++count < 10000)
+ MySleep(100);
+
+ /* wait for success or failure callback */
+ while (test4_messages_received < 3 && ++count < 10000)
+ MySleep(100);
+
+ rc = MQTTAsync_getPendingTokens(c, &tokens);
+ assert("Good rc from getPendingTokens", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ i = 0;
+ if (tokens)
+ {
+ while (tokens[i] != -1)
+ ++i;
+ MQTTAsync_free(tokens);
+ }
+ assert("Number of getPendingTokens should be 0", i == 0, "i was %d ", i);
+
+ rc = MQTTAsync_disconnect(c, NULL);
+ assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+ rc = MQTTAsync_disconnect(d, NULL);
+ assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+exit:
+ MQTTAsync_destroy(&c);
+ MQTTAsync_destroy(&d);
+ MyLog(LOGA_INFO, "%s: test %s. %d tests run, %d failures.",
+ (failures == 0) ? "passed" : "failed", testname, tests, failures);
+ write_test_result();
+ return failures;
+}
+
+
+/*********************************************************************
+
+ test5: offline buffering - check max buffered
+
+ 1. call connect
+ 2. use proxy to disconnect the client
+ 3. while the client is disconnected, send more messages
+ 4. when the client reconnects, check that those messages are sent
+
+ *********************************************************************/
+
+int test5_will_message_received = 0;
+int test5_messages_received = 0;
+
+int test5_messageArrived(void* context, char* topicName, int topicLen, MQTTAsync_message* message)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ static int message_count = 0;
+
+ MyLog(LOGA_DEBUG, "Message received on topic %s, \"%.*s\"", topicName, message->payloadlen, message->payload);
+
+ if (memcmp(message->payload, "will message", message->payloadlen) == 0)
+ test5_will_message_received = 1;
+ else
+ test5_messages_received++;
+
+ MQTTAsync_freeMessage(&message);
+ MQTTAsync_free(topicName);
+
+ return 1;
+}
+
+int test5Finished = 0;
+
+int test5OnFailureCalled = 0;
+
+void test5cOnFailure(void* context, MQTTAsync_failureData* response)
+{
+ MyLog(LOGA_DEBUG, "In connect onFailure callback, context %p", context);
+
+ test5OnFailureCalled++;
+ test5Finished = 1;
+}
+
+void test5dOnFailure(void* context, MQTTAsync_failureData* response)
+{
+ MyLog(LOGA_DEBUG, "In connect onFailure callback, context %p", context);
+
+ test5OnFailureCalled++;
+ test5Finished = 1;
+}
+
+void test5cOnConnect(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+ MyLog(LOGA_DEBUG, "In connect onSuccess callback for client d, context %p\n", context);
+ MQTTAsync c = (MQTTAsync)context;
+ int rc;
+
+ /* send a message to the proxy to break the connection */
+ pubmsg.payload = "TERMINATE";
+ pubmsg.payloadlen = strlen(pubmsg.payload);
+ pubmsg.qos = 0;
+ pubmsg.retained = 0;
+ rc = MQTTAsync_sendMessage(c, "MQTTSAS topic", &pubmsg, NULL);
+ assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+}
+
+
+int test5dReady = 0;
+char willTopic[100];
+char test_topic[50];
+
+void test5donSubscribe(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MyLog(LOGA_DEBUG, "In subscribe onSuccess callback for client d, %p granted qos %d", c, response->alt.qos);
+ test5dReady = 1;
+}
+
+
+void test5dOnConnect(void* context, MQTTAsync_successData* response)
+{
+ MQTTAsync c = (MQTTAsync)context;
+ MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+ int rc;
+ int qoss[2] = {2, 2};
+ char* topics[2] = {willTopic, test_topic};
+
+ MyLog(LOGA_DEBUG, "In connect onSuccess callback for client c, context %p\n", context);
+ opts.onSuccess = test5donSubscribe;
+ opts.context = c;
+
+ rc = MQTTAsync_subscribeMany(c, 2, topics, qoss, &opts);
+ assert("Good rc from subscribe", rc == MQTTASYNC_SUCCESS, "rc was %d", rc);
+ if (rc != MQTTASYNC_SUCCESS)
+ test5Finished = 1;
+}
+
+int test5c_connected = 0;
+
+void test5cConnected(void* context, char* cause)
+{
+ MQTTAsync c = (MQTTAsync)context;
+
+ MyLog(LOGA_DEBUG, "In connected callback for client c, context %p\n", context);
+ test5c_connected = 1;
+}
+
+
+int test5(struct Options options)
+{
+ char* testname = "test5";
+ int subsqos = 2;
+ MQTTAsync c, d;
+ MQTTAsync_connectOptions opts = MQTTAsync_connectOptions_initializer;
+ MQTTAsync_willOptions wopts = MQTTAsync_willOptions_initializer;
+ MQTTAsync_createOptions createOptions = MQTTAsync_createOptions_initializer;
+ int rc = 0;
+ int count = 0;
+ char clientidc[50];
+ char clientidd[50];
+ int i = 0;
+ MQTTAsync_token *tokens;
+
+ sprintf(willTopic, "paho-test9-5-%s", unique);
+ sprintf(clientidc, "paho-test9-5-c-%s", unique);
+ sprintf(clientidd, "paho-test9-5-d-%s", unique);
+ sprintf(test_topic, "paho-test9-5-test topic %s", unique);
+
+ test5Finished = 0;
+ failures = 0;
+ MyLog(LOGA_INFO, "Starting Offline buffering 5 - max buffered");
+ fprintf(xml, "message = "will message";
+ opts.will->qos = 1;
+ opts.will->retained = 0;
+ opts.will->topicName = willTopic;
+ opts.onSuccess = test5cOnConnect;
+ opts.onFailure = test5cOnFailure;
+ opts.context = c;
+ opts.cleansession = 0;
+
+ MyLog(LOGA_DEBUG, "Connecting client c");
+ rc = MQTTAsync_connect(c, &opts);
+ assert("Good rc from connect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ if (rc != MQTTASYNC_SUCCESS)
+ {
+ failures++;
+ goto exit;
+ }
+
+ /* wait for will message */
+ while (!test5_will_message_received && ++count < 10000)
+ MySleep(100);
+
+ MyLog(LOGA_DEBUG, "Now we can send some messages to be buffered");
+
+ test5c_connected = 0;
+ /* send some messages. Then reconnect (check connected callback), and check that those messages are received */
+ for (i = 0; i < 5; ++i)
+ {
+ char buf[50];
+
+ MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+ MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+ sprintf(buf, "QoS %d message", i);
+ pubmsg.payload = buf;
+ pubmsg.payloadlen = strlen(pubmsg.payload) + 1;
+ pubmsg.qos = i % 3;
+ pubmsg.retained = 0;
+ rc = MQTTAsync_sendMessage(c, test_topic, &pubmsg, &opts);
+ if (i <= 2)
+ assert("Good rc from sendMessage", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ else
+ assert("Bad rc from sendMessage", rc == MQTTASYNC_MAX_BUFFERED_MESSAGES, "rc was %d ", rc);
+ }
+
+ rc = MQTTAsync_getPendingTokens(c, &tokens);
+ assert("Good rc from getPendingTokens", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ i = 0;
+ if (tokens)
+ {
+ while (tokens[i] != -1)
+ ++i;
+ MQTTAsync_free(tokens);
+ }
+ assert("Number of getPendingTokens should be 3", i == 3, "i was %d ", i);
+
+ rc = MQTTAsync_reconnect(c);
+ assert("Good rc from reconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+ /* wait for client to be reconnected */
+ while (!test5c_connected == 0 && ++count < 10000)
+ MySleep(100);
+
+ /* wait for success or failure callback */
+ while (test5_messages_received < 3 && ++count < 10000)
+ MySleep(100);
+
+ rc = MQTTAsync_getPendingTokens(c, &tokens);
+ assert("Good rc from getPendingTokens", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+ i = 0;
+ if (tokens)
+ {
+ while (tokens[i] != -1)
+ ++i;
+ MQTTAsync_free(tokens);
+ }
+ assert("Number of getPendingTokens should be 0", i == 0, "i was %d ", i);
+
+ rc = MQTTAsync_disconnect(c, NULL);
+ assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+ rc = MQTTAsync_disconnect(d, NULL);
+ assert("Good rc from disconnect", rc == MQTTASYNC_SUCCESS, "rc was %d ", rc);
+
+exit:
+ MQTTAsync_destroy(&c);
+ MQTTAsync_destroy(&d);
+ MyLog(LOGA_INFO, "%s: test %s. %d tests run, %d failures.",
+ (failures == 0) ? "passed" : "failed", testname, tests, failures);
+ write_test_result();
+ return failures;
+}
+
+
+void handleTrace(enum MQTTASYNC_TRACE_LEVELS level, char* message)
+{
+ printf("%s\n", message);
+}
+
+
+int main(int argc, char** argv)
+{
+ int* numtests = &tests;
+ int rc = 0;
+ int (*tests[])() = { NULL, test1, test2, test3, test4, test5};
+
+ sprintf(unique, "%u", rand());
+ MyLog(LOGA_INFO, "Random prefix/suffix is %s", unique);
+
+ xml = fopen("TEST-test9.xml", "w");
+ fprintf(xml, "\n", ARRAY_SIZE(tests) - 1);
+
+ MQTTAsync_setTraceCallback(handleTrace);
+ getopts(argc, argv);
+
+ if (options.test_no == 0)
+ { /* run all the tests */
+ for (options.test_no = 1; options.test_no < ARRAY_SIZE(tests); ++options.test_no)
+ {
+ failures = 0;
+ MQTTAsync_setTraceLevel(MQTTASYNC_TRACE_ERROR);
+ rc += tests[options.test_no](options); /* return number of failures. 0 = test succeeded */
+ }
+ }
+ else
+ {
+ MQTTAsync_setTraceLevel(MQTTASYNC_TRACE_ERROR);
+ rc = tests[options.test_no](options); /* run just the selected test */
+ }
+
+ MyLog(LOGA_INFO, "Total tests run: %d", *numtests);
+ if (rc == 0)
+ MyLog(LOGA_INFO, "verdict pass");
+ else
+ MyLog(LOGA_INFO, "verdict fail");
+
+ fprintf(xml, "\n");
+ fclose(xml);
+
+ return rc;
+}
+