Merge lp:~roger.light/ubuntu/vivid/mosquitto/fix-for-1423037 into lp:ubuntu/vivid/mosquitto

Proposed by Roger Light
Status: Needs review
Proposed branch: lp:~roger.light/ubuntu/vivid/mosquitto/fix-for-1423037
Merge into: lp:ubuntu/vivid/mosquitto
Diff against target: 32988 lines (+9265/-15376)
320 files modified
.pc/applied-patches (+0/-7)
.pc/disable-bad-test.patch/test/lib/Makefile (+0/-48)
.pc/disable-in-tree-uthash.patch/src/uthash.h (+0/-948)
.pc/enable-libwrap.patch/config.mk (+0/-219)
.pc/fix-prefix.patch/config.mk (+0/-219)
.pc/install-apparmor.patch/Makefile (+0/-70)
.pc/nostrip.patch/client/Makefile (+0/-34)
.pc/nostrip.patch/lib/Makefile (+0/-99)
.pc/nostrip.patch/lib/cpp/Makefile (+0/-31)
.pc/nostrip.patch/src/Makefile (+0/-118)
.pc/pynomake.patch/config.mk (+0/-219)
CMakeLists.txt (+24/-5)
CONTRIBUTING.md (+100/-0)
ChangeLog.txt (+117/-4)
LICENSE-3rd-party.txt (+0/-666)
LICENSE.txt (+2/-54)
Makefile (+6/-5)
about.html (+41/-0)
changeset (+0/-1)
client/CMakeLists.txt (+4/-2)
client/Makefile (+11/-8)
client/client_shared.c (+957/-0)
client/client_shared.h (+97/-0)
client/pub_client.c (+66/-457)
client/sub_client.c (+83/-477)
compiling.txt (+3/-1)
config.h (+8/-1)
config.mk (+49/-22)
debian/changelog (+15/-0)
debian/control (+2/-29)
debian/copyright (+245/-20)
debian/libmosquitto1.symbols (+1/-0)
debian/libmosquittopp1.symbols (+11/-7)
debian/mosquitto.postinst (+5/-1)
debian/patches/disable-bad-test.patch (+0/-13)
debian/patches/enable-libwrap.patch (+1/-1)
debian/patches/enable-websockets.patch (+14/-0)
debian/patches/fix-prefix.patch (+2/-2)
debian/patches/install-apparmor.patch (+3/-5)
debian/patches/nostrip.patch (+8/-8)
debian/patches/pynomake.patch (+0/-14)
debian/patches/series (+1/-2)
debian/python-mosquitto.install (+0/-1)
debian/python3-mosquitto.install (+0/-1)
debian/rules (+1/-4)
edl-v10 (+31/-0)
epl-v10 (+221/-0)
examples/temperature_conversion/temperature_conversion.cpp (+4/-0)
installer/mosquitto-cygwin.nsi (+1/-10)
installer/mosquitto.nsi (+1/-10)
lib/CMakeLists.txt (+9/-2)
lib/Makefile (+23/-22)
lib/cpp/CMakeLists.txt (+1/-1)
lib/cpp/Makefile (+3/-3)
lib/cpp/mosquittopp.cpp (+29/-26)
lib/cpp/mosquittopp.h (+16/-33)
lib/jsws/mosquitto.js (+0/-363)
lib/linker.version (+9/-0)
lib/logging_mosq.c (+16/-29)
lib/logging_mosq.h (+14/-27)
lib/memory_mosq.c (+15/-28)
lib/memory_mosq.h (+14/-27)
lib/messages_mosq.c (+25/-41)
lib/messages_mosq.h (+15/-28)
lib/mosquitto.c (+178/-87)
lib/mosquitto.h (+142/-37)
lib/mosquitto_internal.h (+58/-41)
lib/mqtt3_protocol.h (+13/-26)
lib/net_mosq.c (+124/-61)
lib/net_mosq.h (+21/-33)
lib/python/Makefile (+0/-25)
lib/python/mosquitto.py (+0/-2079)
lib/python/setup.py (+0/-28)
lib/python/sub.py (+0/-66)
lib/read_handle.c (+23/-36)
lib/read_handle.h (+18/-27)
lib/read_handle_client.c (+21/-37)
lib/read_handle_shared.c (+29/-68)
lib/send_client_mosq.c (+76/-54)
lib/send_mosq.c (+32/-39)
lib/send_mosq.h (+17/-30)
lib/socks_mosq.c (+403/-0)
lib/socks_mosq.h (+23/-0)
lib/srv_mosq.c (+13/-26)
lib/thread_mosq.c (+23/-28)
lib/time_mosq.c (+13/-26)
lib/time_mosq.h (+13/-26)
lib/tls_mosq.c (+42/-28)
lib/tls_mosq.h (+13/-26)
lib/util_mosq.c (+43/-41)
lib/util_mosq.h (+21/-28)
lib/will_mosq.c (+24/-37)
lib/will_mosq.h (+15/-28)
man/Makefile (+7/-0)
man/html.xsl (+27/-0)
man/libmosquitto.3 (+4/-13)
man/libmosquitto.3.xml (+4/-16)
man/mosquitto-tls.7 (+2/-2)
man/mosquitto-tls.7.xml (+2/-2)
man/mosquitto.8 (+10/-20)
man/mosquitto.8.xml (+46/-58)
man/mosquitto.conf.5 (+139/-30)
man/mosquitto.conf.5.xml (+196/-42)
man/mosquitto_passwd.1 (+15/-10)
man/mosquitto_passwd.1.xml (+27/-14)
man/mosquitto_pub.1 (+51/-12)
man/mosquitto_pub.1.xml (+77/-17)
man/mosquitto_sub.1 (+59/-11)
man/mosquitto_sub.1.xml (+80/-16)
man/mqtt.7 (+2/-2)
man/mqtt.7.xml (+3/-3)
man/po/libmosquitto/libmosquitto.3.pot (+0/-609)
man/po/mosquitto-tls/mosquitto-tls.7.pot (+0/-140)
man/po/mosquitto.conf/mosquitto.conf.5.pot (+0/-1028)
man/po/mosquitto/mosquitto.8.pot (+0/-560)
man/po/mosquitto_pub/mosquitto_pub.1.pot (+0/-540)
man/po/mosquitto_sub/mosquitto_sub.1.pot (+0/-500)
man/po/mqtt/mqtt.7.pot (+0/-224)
mosquitto.conf (+101/-27)
notice.html (+108/-0)
readme-windows.txt (+0/-7)
readme.txt (+3/-9)
security/mosquitto.apparmor (+1/-1)
service/upstart/mosquitto.conf (+1/-1)
src/CMakeLists.txt (+29/-2)
src/Makefile (+35/-32)
src/bridge.c (+91/-84)
src/conf.c (+312/-107)
src/context.c (+84/-73)
src/database.c (+143/-140)
src/db_dump/Makefile (+2/-2)
src/db_dump/db_dump.c (+84/-70)
src/lib_load.h (+13/-26)
src/linker-macosx.syms (+1/-0)
src/linker.syms (+3/-0)
src/logging.c (+75/-36)
src/loop.c (+293/-190)
src/mosquitto.c (+146/-83)
src/mosquitto_broker.h (+112/-62)
src/mosquitto_passwd.c (+53/-41)
src/mosquitto_plugin.h (+55/-26)
src/net.c (+167/-180)
src/persist.c (+107/-116)
src/persist.h (+13/-26)
src/read_handle.c (+25/-38)
src/read_handle_client.c (+23/-39)
src/read_handle_server.c (+260/-227)
src/security.c (+50/-27)
src/security_default.c (+68/-82)
src/send_server.c (+17/-30)
src/service.c (+13/-26)
src/subs.c (+180/-151)
src/sys_tree.c (+41/-51)
src/uthash.h (+948/-0)
src/websockets.c (+596/-0)
test/broker/01-connect-anon-denied.py (+1/-3)
test/broker/01-connect-invalid-id-0-311.py (+2/-3)
test/broker/01-connect-invalid-id-0.py (+2/-3)
test/broker/01-connect-invalid-id-24.py (+0/-39)
test/broker/01-connect-invalid-id-missing.py (+2/-3)
test/broker/01-connect-invalid-protonum.py (+2/-3)
test/broker/01-connect-success.py (+2/-3)
test/broker/01-connect-uname-no-password-denied.py (+1/-3)
test/broker/01-connect-uname-password-denied.py (+1/-3)
test/broker/01-connect-uname-password-success-no-tls.conf (+3/-0)
test/broker/01-connect-uname-password-success-no-tls.pwfile (+1/-0)
test/broker/01-connect-uname-password-success-no-tls.py (+38/-0)
test/broker/01-connect-uname-password-success.py (+1/-3)
test/broker/02-subpub-qos0.py (+2/-3)
test/broker/02-subpub-qos1.py (+2/-3)
test/broker/02-subpub-qos2.py (+2/-3)
test/broker/02-subscribe-qos0.py (+2/-1)
test/broker/02-subscribe-qos1.py (+2/-3)
test/broker/02-subscribe-qos2.py (+2/-3)
test/broker/02-unsubscribe-qos0.py (+2/-3)
test/broker/02-unsubscribe-qos1.py (+2/-3)
test/broker/02-unsubscribe-qos2.py (+2/-3)
test/broker/03-publish-b2c-disconnect-qos1.py (+1/-3)
test/broker/03-publish-b2c-disconnect-qos2.py (+2/-5)
test/broker/03-publish-b2c-timeout-qos1.py (+1/-3)
test/broker/03-publish-b2c-timeout-qos2.py (+2/-5)
test/broker/03-publish-c2b-disconnect-qos2.py (+1/-6)
test/broker/03-publish-c2b-timeout-qos2.py (+1/-3)
test/broker/03-publish-qos1.py (+2/-3)
test/broker/03-publish-qos2.py (+2/-3)
test/broker/04-retain-qos0-clear.py (+2/-3)
test/broker/04-retain-qos0-fresh.py (+2/-3)
test/broker/04-retain-qos0-repeated.py (+3/-4)
test/broker/04-retain-qos0.py (+2/-3)
test/broker/04-retain-qos1-qos0.py (+2/-3)
test/broker/05-clean-session-qos1.py (+2/-3)
test/broker/06-bridge-b2br-disconnect-qos1.py (+1/-3)
test/broker/06-bridge-b2br-disconnect-qos2.py (+1/-3)
test/broker/06-bridge-br2b-disconnect-qos1.py (+1/-3)
test/broker/06-bridge-br2b-disconnect-qos2.py (+2/-5)
test/broker/06-bridge-reconnect-local-out.py (+19/-7)
test/broker/07-will-acl-denied.acl (+0/-2)
test/broker/07-will-acl-denied.conf (+0/-2)
test/broker/07-will-acl-denied.py (+0/-42)
test/broker/07-will-null-topic.py (+2/-3)
test/broker/07-will-null.py (+2/-3)
test/broker/07-will-qos0.py (+2/-3)
test/broker/08-ssl-bridge.py (+1/-3)
test/broker/08-ssl-connect-cert-auth-crl.conf (+2/-2)
test/broker/08-ssl-connect-cert-auth-crl.py (+1/-3)
test/broker/08-ssl-connect-cert-auth-expired.conf (+2/-2)
test/broker/08-ssl-connect-cert-auth-expired.py (+2/-3)
test/broker/08-ssl-connect-cert-auth-revoked.conf (+2/-2)
test/broker/08-ssl-connect-cert-auth-revoked.py (+2/-3)
test/broker/08-ssl-connect-cert-auth-without.conf (+2/-2)
test/broker/08-ssl-connect-cert-auth-without.py (+2/-3)
test/broker/08-ssl-connect-cert-auth.conf (+3/-2)
test/broker/08-ssl-connect-cert-auth.py (+1/-3)
test/broker/08-ssl-connect-identity.conf (+2/-2)
test/broker/08-ssl-connect-identity.py (+2/-3)
test/broker/08-ssl-connect-no-auth-wrong-ca.conf (+2/-2)
test/broker/08-ssl-connect-no-auth-wrong-ca.py (+2/-3)
test/broker/08-ssl-connect-no-auth.conf (+2/-2)
test/broker/08-ssl-connect-no-auth.py (+1/-3)
test/broker/08-ssl-connect-no-identity.conf (+2/-2)
test/broker/08-ssl-connect-no-identity.py (+2/-3)
test/broker/08-tls-psk-bridge.conf (+0/-2)
test/broker/08-tls-psk-bridge.conf2 (+0/-1)
test/broker/08-tls-psk-bridge.py (+5/-4)
test/broker/08-tls-psk-pub.conf (+0/-1)
test/broker/08-tls-psk-pub.py (+1/-3)
test/broker/09-plugin-auth-unpwd-fail.py (+1/-3)
test/broker/09-plugin-auth-unpwd-success.py (+1/-3)
test/broker/10-listener-mount-point.py (+1/-3)
test/broker/Makefile (+10/-4)
test/lib/01-con-discon-success.py (+2/-2)
test/lib/01-keepalive-pingreq.py (+1/-1)
test/lib/01-no-clean-session.py (+1/-1)
test/lib/01-unpwd-set.py (+1/-1)
test/lib/01-will-set.py (+1/-1)
test/lib/01-will-unpwd-set.py (+1/-1)
test/lib/02-subscribe-qos0.py (+1/-1)
test/lib/02-subscribe-qos1.py (+1/-1)
test/lib/02-subscribe-qos2.py (+1/-1)
test/lib/02-unsubscribe.py (+1/-1)
test/lib/03-publish-b2c-qos1.py (+1/-1)
test/lib/03-publish-b2c-qos2.py (+1/-1)
test/lib/03-publish-c2b-qos1-disconnect.py (+1/-1)
test/lib/03-publish-c2b-qos1-timeout.py (+1/-1)
test/lib/03-publish-c2b-qos2-disconnect.py (+2/-3)
test/lib/03-publish-c2b-qos2-timeout.py (+2/-3)
test/lib/03-publish-c2b-qos2.py (+1/-1)
test/lib/03-publish-qos0-no-payload.py (+1/-1)
test/lib/03-publish-qos0.py (+1/-1)
test/lib/04-retain-qos0.py (+1/-1)
test/lib/08-ssl-bad-cacert.py (+1/-1)
test/lib/08-ssl-connect-cert-auth-enc.py (+73/-0)
test/lib/08-ssl-connect-cert-auth.py (+1/-1)
test/lib/08-ssl-connect-no-auth.py (+1/-1)
test/lib/08-ssl-fake-cacert.py (+1/-1)
test/lib/09-util-topic-matching.py (+2/-1)
test/lib/09-util-topic-tokenise.py (+2/-1)
test/lib/Makefile (+9/-3)
test/lib/c/08-ssl-connect-cert-auth-enc.c (+53/-0)
test/lib/c/Makefile (+4/-1)
test/lib/cpp/08-ssl-connect-cert-auth-enc.cpp (+62/-0)
test/lib/cpp/Makefile (+4/-1)
test/lib/python/01-con-discon-success.test (+0/-33)
test/lib/python/01-keepalive-pingreq.test (+0/-25)
test/lib/python/01-no-clean-session.test (+0/-12)
test/lib/python/01-unpwd-set.test (+0/-13)
test/lib/python/01-will-set.test (+0/-13)
test/lib/python/01-will-unpwd-set.test (+0/-14)
test/lib/python/02-subscribe-qos0.test (+0/-35)
test/lib/python/02-subscribe-qos1.test (+0/-35)
test/lib/python/02-subscribe-qos2.test (+0/-35)
test/lib/python/02-unsubscribe.test (+0/-35)
test/lib/python/03-publish-b2c-qos1.test (+0/-45)
test/lib/python/03-publish-b2c-qos2.test (+0/-48)
test/lib/python/03-publish-c2b-qos1-disconnect.test (+0/-48)
test/lib/python/03-publish-c2b-qos1-timeout.test (+0/-44)
test/lib/python/03-publish-c2b-qos2-disconnect.test (+0/-44)
test/lib/python/03-publish-c2b-qos2-timeout.test (+0/-37)
test/lib/python/03-publish-c2b-qos2.test (+0/-36)
test/lib/python/03-publish-qos0-no-payload.test (+0/-36)
test/lib/python/03-publish-qos0.test (+0/-36)
test/lib/python/04-retain-qos0.test (+0/-27)
test/lib/python/08-ssl-bad-cacert.test (+0/-23)
test/lib/python/08-ssl-connect-cert-auth.test (+0/-37)
test/lib/python/08-ssl-connect-no-auth.test (+0/-38)
test/lib/python/08-ssl-fake-cacert.test (+0/-32)
test/lib/python/09-util-topic-matching.test (+0/-31)
test/lib/python/09-util-topic-tokenise.test (+0/-5)
test/lib/python3/01-con-discon-success.test (+0/-33)
test/lib/python3/01-keepalive-pingreq.test (+0/-25)
test/lib/python3/01-no-clean-session.test (+0/-12)
test/lib/python3/01-unpwd-set.test (+0/-13)
test/lib/python3/01-will-set.test (+0/-13)
test/lib/python3/01-will-unpwd-set.test (+0/-14)
test/lib/python3/02-subscribe-qos0.test (+0/-35)
test/lib/python3/02-subscribe-qos1.test (+0/-35)
test/lib/python3/02-subscribe-qos2.test (+0/-35)
test/lib/python3/02-unsubscribe.test (+0/-35)
test/lib/python3/03-publish-b2c-qos1.test (+0/-45)
test/lib/python3/03-publish-b2c-qos2.test (+0/-48)
test/lib/python3/03-publish-c2b-qos1-disconnect.test (+0/-48)
test/lib/python3/03-publish-c2b-qos1-timeout.test (+0/-44)
test/lib/python3/03-publish-c2b-qos2-disconnect.test (+0/-44)
test/lib/python3/03-publish-c2b-qos2-timeout.test (+0/-37)
test/lib/python3/03-publish-c2b-qos2.test (+0/-36)
test/lib/python3/03-publish-qos0-no-payload.test (+0/-36)
test/lib/python3/03-publish-qos0.test (+0/-36)
test/lib/python3/04-retain-qos0.test (+0/-27)
test/lib/python3/08-ssl-bad-cacert.test (+0/-23)
test/lib/python3/08-ssl-connect-cert-auth.test (+0/-34)
test/lib/python3/08-ssl-connect-no-auth.test (+0/-35)
test/lib/python3/08-ssl-fake-cacert.test (+0/-32)
test/lib/python3/09-util-topic-matching.test (+0/-31)
test/lib/python3/09-util-topic-tokenise.test (+0/-5)
test/mosq_test.py (+36/-0)
test/ssl/client-encrypted.crt (+59/-0)
test/ssl/client-encrypted.key (+18/-0)
test/ssl/gen.sh (+5/-0)
test/ssl/signingCA/index.txt (+1/-0)
test/ssl/signingCA/serial (+1/-1)
To merge this branch: bzr merge lp:~roger.light/ubuntu/vivid/mosquitto/fix-for-1423037
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Needs Fixing
Review via email: mp+250088@code.launchpad.net
To post a comment you must log in.
13. By Roger Light

Downgrade libwebsockets requirement to libwebsockets3.

14. By Roger Light

Upstream license has changed from BSD-3 to EPL-1.0 or EDL-1.0.

15. By Roger Light

Unapply patches.

Revision history for this message
Daniel Holbach (dholbach) wrote :

Text conflict in client/Makefile
Text conflict in config.mk
Text conflict in lib/Makefile
Text conflict in lib/cpp/Makefile
Text conflict in src/Makefile
Conflict adding file src/uthash.h. Moved existing file to src/uthash.h.moved.
Text conflict in test/lib/Makefile

review: Needs Fixing

Unmerged revisions

15. By Roger Light

Unapply patches.

14. By Roger Light

Upstream license has changed from BSD-3 to EPL-1.0 or EDL-1.0.

13. By Roger Light

Downgrade libwebsockets requirement to libwebsockets3.

12. By Roger Light

Amend changelog with bug info.

11. By Roger Light

* python3-mosquitto and python-mosquitto packages removed because the python
  module is no longer part of upstream.
* Remove unused patches.
* Added dependency on libwebsockets, uuid.

10. By Roger Light

Merge 1.4 from upstream.

9. By Roger Light

Put upstream signing key in correct place.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file '.pc/applied-patches'
2--- .pc/applied-patches 2015-01-15 14:08:09 +0000
3+++ .pc/applied-patches 1970-01-01 00:00:00 +0000
4@@ -1,7 +0,0 @@
5-disable-bad-test.patch
6-enable-libwrap.patch
7-fix-prefix.patch
8-nostrip.patch
9-pynomake.patch
10-disable-in-tree-uthash.patch
11-install-apparmor.patch
12
13=== removed directory '.pc/disable-bad-test.patch'
14=== removed directory '.pc/disable-bad-test.patch/test'
15=== removed directory '.pc/disable-bad-test.patch/test/lib'
16=== removed file '.pc/disable-bad-test.patch/test/lib/Makefile'
17--- .pc/disable-bad-test.patch/test/lib/Makefile 2014-08-16 10:52:12 +0000
18+++ .pc/disable-bad-test.patch/test/lib/Makefile 1970-01-01 00:00:00 +0000
19@@ -1,48 +0,0 @@
20-.PHONY: all test test-compile test-compile-c test-compile-cpp c cpp python python3
21-.NOTPARALLEL:
22-
23-LD_LIBRARY_PATH=../../lib
24-
25-all :
26-
27-test : c cpp python python3
28-
29-test-compile : test-compile-c test-compile-cpp
30-
31-test-compile-c :
32- $(MAKE) -C c
33-
34-test-compile-cpp :
35- $(MAKE) -C cpp
36-
37-c cpp python python3 : test-compile
38- ./01-con-discon-success.py $@/01-con-discon-success.test
39- ./01-will-set.py $@/01-will-set.test
40- ./01-unpwd-set.py $@/01-unpwd-set.test
41- ./01-will-unpwd-set.py $@/01-will-unpwd-set.test
42- ./01-no-clean-session.py $@/01-no-clean-session.test
43- ./01-keepalive-pingreq.py $@/01-keepalive-pingreq.test
44- ./02-subscribe-qos0.py $@/02-subscribe-qos0.test
45- ./02-subscribe-qos1.py $@/02-subscribe-qos1.test
46- ./02-subscribe-qos2.py $@/02-subscribe-qos2.test
47- ./02-unsubscribe.py $@/02-unsubscribe.test
48- ./03-publish-qos0.py $@/03-publish-qos0.test
49- ./03-publish-qos0-no-payload.py $@/03-publish-qos0-no-payload.test
50- ./03-publish-c2b-qos1-timeout.py $@/03-publish-c2b-qos1-timeout.test
51- ./03-publish-c2b-qos1-disconnect.py $@/03-publish-c2b-qos1-disconnect.test
52- ./03-publish-c2b-qos2.py $@/03-publish-c2b-qos2.test
53- ./03-publish-c2b-qos2-timeout.py $@/03-publish-c2b-qos2-timeout.test
54- ./03-publish-c2b-qos2-disconnect.py $@/03-publish-c2b-qos2-disconnect.test
55- ./03-publish-b2c-qos1.py $@/03-publish-b2c-qos1.test
56- ./03-publish-b2c-qos2.py $@/03-publish-b2c-qos2.test
57- ./04-retain-qos0.py $@/04-retain-qos0.test
58- ./08-ssl-connect-no-auth.py $@/08-ssl-connect-no-auth.test
59- ./08-ssl-connect-cert-auth.py $@/08-ssl-connect-cert-auth.test
60- ./08-ssl-bad-cacert.py $@/08-ssl-bad-cacert.test
61- ./08-ssl-fake-cacert.py $@/08-ssl-fake-cacert.test
62- ./09-util-topic-matching.py $@/09-util-topic-matching.test
63- ./09-util-topic-tokenise.py $@/09-util-topic-tokenise.test
64-
65-clean :
66- $(MAKE) -C c clean
67- $(MAKE) -C cpp clean
68
69=== removed directory '.pc/disable-in-tree-uthash.patch'
70=== removed directory '.pc/disable-in-tree-uthash.patch/src'
71=== removed file '.pc/disable-in-tree-uthash.patch/src/uthash.h'
72--- .pc/disable-in-tree-uthash.patch/src/uthash.h 2013-08-07 23:26:19 +0000
73+++ .pc/disable-in-tree-uthash.patch/src/uthash.h 1970-01-01 00:00:00 +0000
74@@ -1,948 +0,0 @@
75-/*
76-Copyright (c) 2003-2013, Troy D. Hanson http://troydhanson.github.com/uthash/
77-All rights reserved.
78-
79-Redistribution and use in source and binary forms, with or without
80-modification, are permitted provided that the following conditions are met:
81-
82- * Redistributions of source code must retain the above copyright
83- notice, this list of conditions and the following disclaimer.
84-
85-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
86-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
87-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
88-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
89-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
91-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
92-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
93-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
94-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
95-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96-*/
97-
98-#ifndef UTHASH_H
99-#define UTHASH_H
100-
101-#include <string.h> /* memcmp,strlen */
102-#include <stddef.h> /* ptrdiff_t */
103-#include <stdlib.h> /* exit() */
104-
105-/* These macros use decltype or the earlier __typeof GNU extension.
106- As decltype is only available in newer compilers (VS2010 or gcc 4.3+
107- when compiling c++ source) this code uses whatever method is needed
108- or, for VS2008 where neither is available, uses casting workarounds. */
109-#ifdef _MSC_VER /* MS compiler */
110-#if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */
111-#define DECLTYPE(x) (decltype(x))
112-#else /* VS2008 or older (or VS2010 in C mode) */
113-#define NO_DECLTYPE
114-#define DECLTYPE(x)
115-#endif
116-#else /* GNU, Sun and other compilers */
117-#define DECLTYPE(x) (__typeof(x))
118-#endif
119-
120-#ifdef NO_DECLTYPE
121-#define DECLTYPE_ASSIGN(dst,src) \
122-do { \
123- char **_da_dst = (char**)(&(dst)); \
124- *_da_dst = (char*)(src); \
125-} while(0)
126-#else
127-#define DECLTYPE_ASSIGN(dst,src) \
128-do { \
129- (dst) = DECLTYPE(dst)(src); \
130-} while(0)
131-#endif
132-
133-/* a number of the hash function use uint32_t which isn't defined on win32 */
134-#ifdef _MSC_VER
135-typedef unsigned int uint32_t;
136-typedef unsigned char uint8_t;
137-#else
138-#include <inttypes.h> /* uint32_t */
139-#endif
140-
141-#define UTHASH_VERSION 1.9.8
142-
143-#ifndef uthash_fatal
144-#define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */
145-#endif
146-#ifndef uthash_malloc
147-#define uthash_malloc(sz) malloc(sz) /* malloc fcn */
148-#endif
149-#ifndef uthash_free
150-#define uthash_free(ptr,sz) free(ptr) /* free fcn */
151-#endif
152-
153-#ifndef uthash_noexpand_fyi
154-#define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */
155-#endif
156-#ifndef uthash_expand_fyi
157-#define uthash_expand_fyi(tbl) /* can be defined to log expands */
158-#endif
159-
160-/* initial number of buckets */
161-#define HASH_INITIAL_NUM_BUCKETS 32 /* initial number of buckets */
162-#define HASH_INITIAL_NUM_BUCKETS_LOG2 5 /* lg2 of initial number of buckets */
163-#define HASH_BKT_CAPACITY_THRESH 10 /* expand when bucket count reaches */
164-
165-/* calculate the element whose hash handle address is hhe */
166-#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho)))
167-
168-#define HASH_FIND(hh,head,keyptr,keylen,out) \
169-do { \
170- unsigned _hf_bkt,_hf_hashv; \
171- out=NULL; \
172- if (head) { \
173- HASH_FCN(keyptr,keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \
174- if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \
175- HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], \
176- keyptr,keylen,out); \
177- } \
178- } \
179-} while (0)
180-
181-#ifdef HASH_BLOOM
182-#define HASH_BLOOM_BITLEN (1ULL << HASH_BLOOM)
183-#define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8) + ((HASH_BLOOM_BITLEN%8) ? 1:0)
184-#define HASH_BLOOM_MAKE(tbl) \
185-do { \
186- (tbl)->bloom_nbits = HASH_BLOOM; \
187- (tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \
188- if (!((tbl)->bloom_bv)) { uthash_fatal( "out of memory"); } \
189- memset((tbl)->bloom_bv, 0, HASH_BLOOM_BYTELEN); \
190- (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \
191-} while (0)
192-
193-#define HASH_BLOOM_FREE(tbl) \
194-do { \
195- uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \
196-} while (0)
197-
198-#define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8] |= (1U << ((idx)%8)))
199-#define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8] & (1U << ((idx)%8)))
200-
201-#define HASH_BLOOM_ADD(tbl,hashv) \
202- HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1)))
203-
204-#define HASH_BLOOM_TEST(tbl,hashv) \
205- HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1)))
206-
207-#else
208-#define HASH_BLOOM_MAKE(tbl)
209-#define HASH_BLOOM_FREE(tbl)
210-#define HASH_BLOOM_ADD(tbl,hashv)
211-#define HASH_BLOOM_TEST(tbl,hashv) (1)
212-#define HASH_BLOOM_BYTELEN 0
213-#endif
214-
215-#define HASH_MAKE_TABLE(hh,head) \
216-do { \
217- (head)->hh.tbl = (UT_hash_table*)uthash_malloc( \
218- sizeof(UT_hash_table)); \
219- if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \
220- memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \
221- (head)->hh.tbl->tail = &((head)->hh); \
222- (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
223- (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
224- (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \
225- (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \
226- HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \
227- if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \
228- memset((head)->hh.tbl->buckets, 0, \
229- HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \
230- HASH_BLOOM_MAKE((head)->hh.tbl); \
231- (head)->hh.tbl->signature = HASH_SIGNATURE; \
232-} while(0)
233-
234-#define HASH_ADD(hh,head,fieldname,keylen_in,add) \
235- HASH_ADD_KEYPTR(hh,head,&((add)->fieldname),keylen_in,add)
236-
237-#define HASH_REPLACE(hh,head,fieldname,keylen_in,add,replaced) \
238-do { \
239- replaced=NULL; \
240- HASH_FIND(hh,head,&((add)->fieldname),keylen_in,replaced); \
241- if (replaced!=NULL) { \
242- HASH_DELETE(hh,head,replaced); \
243- }; \
244- HASH_ADD(hh,head,fieldname,keylen_in,add); \
245-} while(0)
246-
247-#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \
248-do { \
249- unsigned _ha_bkt; \
250- (add)->hh.next = NULL; \
251- (add)->hh.key = (char*)keyptr; \
252- (add)->hh.keylen = (unsigned)keylen_in; \
253- if (!(head)) { \
254- head = (add); \
255- (head)->hh.prev = NULL; \
256- HASH_MAKE_TABLE(hh,head); \
257- } else { \
258- (head)->hh.tbl->tail->next = (add); \
259- (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \
260- (head)->hh.tbl->tail = &((add)->hh); \
261- } \
262- (head)->hh.tbl->num_items++; \
263- (add)->hh.tbl = (head)->hh.tbl; \
264- HASH_FCN(keyptr,keylen_in, (head)->hh.tbl->num_buckets, \
265- (add)->hh.hashv, _ha_bkt); \
266- HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt],&(add)->hh); \
267- HASH_BLOOM_ADD((head)->hh.tbl,(add)->hh.hashv); \
268- HASH_EMIT_KEY(hh,head,keyptr,keylen_in); \
269- HASH_FSCK(hh,head); \
270-} while(0)
271-
272-#define HASH_TO_BKT( hashv, num_bkts, bkt ) \
273-do { \
274- bkt = ((hashv) & ((num_bkts) - 1)); \
275-} while(0)
276-
277-/* delete "delptr" from the hash table.
278- * "the usual" patch-up process for the app-order doubly-linked-list.
279- * The use of _hd_hh_del below deserves special explanation.
280- * These used to be expressed using (delptr) but that led to a bug
281- * if someone used the same symbol for the head and deletee, like
282- * HASH_DELETE(hh,users,users);
283- * We want that to work, but by changing the head (users) below
284- * we were forfeiting our ability to further refer to the deletee (users)
285- * in the patch-up process. Solution: use scratch space to
286- * copy the deletee pointer, then the latter references are via that
287- * scratch pointer rather than through the repointed (users) symbol.
288- */
289-#define HASH_DELETE(hh,head,delptr) \
290-do { \
291- unsigned _hd_bkt; \
292- struct UT_hash_handle *_hd_hh_del; \
293- if ( ((delptr)->hh.prev == NULL) && ((delptr)->hh.next == NULL) ) { \
294- uthash_free((head)->hh.tbl->buckets, \
295- (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \
296- HASH_BLOOM_FREE((head)->hh.tbl); \
297- uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
298- head = NULL; \
299- } else { \
300- _hd_hh_del = &((delptr)->hh); \
301- if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \
302- (head)->hh.tbl->tail = \
303- (UT_hash_handle*)((ptrdiff_t)((delptr)->hh.prev) + \
304- (head)->hh.tbl->hho); \
305- } \
306- if ((delptr)->hh.prev) { \
307- ((UT_hash_handle*)((ptrdiff_t)((delptr)->hh.prev) + \
308- (head)->hh.tbl->hho))->next = (delptr)->hh.next; \
309- } else { \
310- DECLTYPE_ASSIGN(head,(delptr)->hh.next); \
311- } \
312- if (_hd_hh_del->next) { \
313- ((UT_hash_handle*)((ptrdiff_t)_hd_hh_del->next + \
314- (head)->hh.tbl->hho))->prev = \
315- _hd_hh_del->prev; \
316- } \
317- HASH_TO_BKT( _hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \
318- HASH_DEL_IN_BKT(hh,(head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \
319- (head)->hh.tbl->num_items--; \
320- } \
321- HASH_FSCK(hh,head); \
322-} while (0)
323-
324-
325-/* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */
326-#define HASH_FIND_STR(head,findstr,out) \
327- HASH_FIND(hh,head,findstr,strlen(findstr),out)
328-#define HASH_ADD_STR(head,strfield,add) \
329- HASH_ADD(hh,head,strfield,strlen(add->strfield),add)
330-#define HASH_REPLACE_STR(head,strfield,add,replaced) \
331- HASH_REPLACE(hh,head,strfield,strlen(add->strfield),add,replaced)
332-#define HASH_FIND_INT(head,findint,out) \
333- HASH_FIND(hh,head,findint,sizeof(int),out)
334-#define HASH_ADD_INT(head,intfield,add) \
335- HASH_ADD(hh,head,intfield,sizeof(int),add)
336-#define HASH_REPLACE_INT(head,intfield,add,replaced) \
337- HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced)
338-#define HASH_FIND_PTR(head,findptr,out) \
339- HASH_FIND(hh,head,findptr,sizeof(void *),out)
340-#define HASH_ADD_PTR(head,ptrfield,add) \
341- HASH_ADD(hh,head,ptrfield,sizeof(void *),add)
342-#define HASH_REPLACE_PTR(head,ptrfield,add) \
343- HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced)
344-#define HASH_DEL(head,delptr) \
345- HASH_DELETE(hh,head,delptr)
346-
347-/* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined.
348- * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined.
349- */
350-#ifdef HASH_DEBUG
351-#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0)
352-#define HASH_FSCK(hh,head) \
353-do { \
354- unsigned _bkt_i; \
355- unsigned _count, _bkt_count; \
356- char *_prev; \
357- struct UT_hash_handle *_thh; \
358- if (head) { \
359- _count = 0; \
360- for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \
361- _bkt_count = 0; \
362- _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \
363- _prev = NULL; \
364- while (_thh) { \
365- if (_prev != (char*)(_thh->hh_prev)) { \
366- HASH_OOPS("invalid hh_prev %p, actual %p\n", \
367- _thh->hh_prev, _prev ); \
368- } \
369- _bkt_count++; \
370- _prev = (char*)(_thh); \
371- _thh = _thh->hh_next; \
372- } \
373- _count += _bkt_count; \
374- if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \
375- HASH_OOPS("invalid bucket count %d, actual %d\n", \
376- (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \
377- } \
378- } \
379- if (_count != (head)->hh.tbl->num_items) { \
380- HASH_OOPS("invalid hh item count %d, actual %d\n", \
381- (head)->hh.tbl->num_items, _count ); \
382- } \
383- /* traverse hh in app order; check next/prev integrity, count */ \
384- _count = 0; \
385- _prev = NULL; \
386- _thh = &(head)->hh; \
387- while (_thh) { \
388- _count++; \
389- if (_prev !=(char*)(_thh->prev)) { \
390- HASH_OOPS("invalid prev %p, actual %p\n", \
391- _thh->prev, _prev ); \
392- } \
393- _prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \
394- _thh = ( _thh->next ? (UT_hash_handle*)((char*)(_thh->next) + \
395- (head)->hh.tbl->hho) : NULL ); \
396- } \
397- if (_count != (head)->hh.tbl->num_items) { \
398- HASH_OOPS("invalid app item count %d, actual %d\n", \
399- (head)->hh.tbl->num_items, _count ); \
400- } \
401- } \
402-} while (0)
403-#else
404-#define HASH_FSCK(hh,head)
405-#endif
406-
407-/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to
408- * the descriptor to which this macro is defined for tuning the hash function.
409- * The app can #include <unistd.h> to get the prototype for write(2). */
410-#ifdef HASH_EMIT_KEYS
411-#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \
412-do { \
413- unsigned _klen = fieldlen; \
414- write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \
415- write(HASH_EMIT_KEYS, keyptr, fieldlen); \
416-} while (0)
417-#else
418-#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen)
419-#endif
420-
421-/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */
422-#ifdef HASH_FUNCTION
423-#define HASH_FCN HASH_FUNCTION
424-#else
425-#define HASH_FCN HASH_JEN
426-#endif
427-
428-/* The Bernstein hash function, used in Perl prior to v5.6 */
429-#define HASH_BER(key,keylen,num_bkts,hashv,bkt) \
430-do { \
431- unsigned _hb_keylen=keylen; \
432- char *_hb_key=(char*)(key); \
433- (hashv) = 0; \
434- while (_hb_keylen--) { (hashv) = ((hashv) * 33) + *_hb_key++; } \
435- bkt = (hashv) & (num_bkts-1); \
436-} while (0)
437-
438-
439-/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at
440- * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */
441-#define HASH_SAX(key,keylen,num_bkts,hashv,bkt) \
442-do { \
443- unsigned _sx_i; \
444- char *_hs_key=(char*)(key); \
445- hashv = 0; \
446- for(_sx_i=0; _sx_i < keylen; _sx_i++) \
447- hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \
448- bkt = hashv & (num_bkts-1); \
449-} while (0)
450-
451-#define HASH_FNV(key,keylen,num_bkts,hashv,bkt) \
452-do { \
453- unsigned _fn_i; \
454- char *_hf_key=(char*)(key); \
455- hashv = 2166136261UL; \
456- for(_fn_i=0; _fn_i < keylen; _fn_i++) \
457- hashv = (hashv * 16777619) ^ _hf_key[_fn_i]; \
458- bkt = hashv & (num_bkts-1); \
459-} while(0)
460-
461-#define HASH_OAT(key,keylen,num_bkts,hashv,bkt) \
462-do { \
463- unsigned _ho_i; \
464- char *_ho_key=(char*)(key); \
465- hashv = 0; \
466- for(_ho_i=0; _ho_i < keylen; _ho_i++) { \
467- hashv += _ho_key[_ho_i]; \
468- hashv += (hashv << 10); \
469- hashv ^= (hashv >> 6); \
470- } \
471- hashv += (hashv << 3); \
472- hashv ^= (hashv >> 11); \
473- hashv += (hashv << 15); \
474- bkt = hashv & (num_bkts-1); \
475-} while(0)
476-
477-#define HASH_JEN_MIX(a,b,c) \
478-do { \
479- a -= b; a -= c; a ^= ( c >> 13 ); \
480- b -= c; b -= a; b ^= ( a << 8 ); \
481- c -= a; c -= b; c ^= ( b >> 13 ); \
482- a -= b; a -= c; a ^= ( c >> 12 ); \
483- b -= c; b -= a; b ^= ( a << 16 ); \
484- c -= a; c -= b; c ^= ( b >> 5 ); \
485- a -= b; a -= c; a ^= ( c >> 3 ); \
486- b -= c; b -= a; b ^= ( a << 10 ); \
487- c -= a; c -= b; c ^= ( b >> 15 ); \
488-} while (0)
489-
490-#define HASH_JEN(key,keylen,num_bkts,hashv,bkt) \
491-do { \
492- unsigned _hj_i,_hj_j,_hj_k; \
493- unsigned char *_hj_key=(unsigned char*)(key); \
494- hashv = 0xfeedbeef; \
495- _hj_i = _hj_j = 0x9e3779b9; \
496- _hj_k = (unsigned)keylen; \
497- while (_hj_k >= 12) { \
498- _hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) \
499- + ( (unsigned)_hj_key[2] << 16 ) \
500- + ( (unsigned)_hj_key[3] << 24 ) ); \
501- _hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) \
502- + ( (unsigned)_hj_key[6] << 16 ) \
503- + ( (unsigned)_hj_key[7] << 24 ) ); \
504- hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) \
505- + ( (unsigned)_hj_key[10] << 16 ) \
506- + ( (unsigned)_hj_key[11] << 24 ) ); \
507- \
508- HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
509- \
510- _hj_key += 12; \
511- _hj_k -= 12; \
512- } \
513- hashv += keylen; \
514- switch ( _hj_k ) { \
515- case 11: hashv += ( (unsigned)_hj_key[10] << 24 ); \
516- case 10: hashv += ( (unsigned)_hj_key[9] << 16 ); \
517- case 9: hashv += ( (unsigned)_hj_key[8] << 8 ); \
518- case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); \
519- case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); \
520- case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); \
521- case 5: _hj_j += _hj_key[4]; \
522- case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); \
523- case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); \
524- case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); \
525- case 1: _hj_i += _hj_key[0]; \
526- } \
527- HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
528- bkt = hashv & (num_bkts-1); \
529-} while(0)
530-
531-/* The Paul Hsieh hash function */
532-#undef get16bits
533-#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
534- || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
535-#define get16bits(d) (*((const uint16_t *) (d)))
536-#endif
537-
538-#if !defined (get16bits)
539-#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \
540- +(uint32_t)(((const uint8_t *)(d))[0]) )
541-#endif
542-#define HASH_SFH(key,keylen,num_bkts,hashv,bkt) \
543-do { \
544- unsigned char *_sfh_key=(unsigned char*)(key); \
545- uint32_t _sfh_tmp, _sfh_len = keylen; \
546- \
547- int _sfh_rem = _sfh_len & 3; \
548- _sfh_len >>= 2; \
549- hashv = 0xcafebabe; \
550- \
551- /* Main loop */ \
552- for (;_sfh_len > 0; _sfh_len--) { \
553- hashv += get16bits (_sfh_key); \
554- _sfh_tmp = (uint32_t)(get16bits (_sfh_key+2)) << 11 ^ hashv; \
555- hashv = (hashv << 16) ^ _sfh_tmp; \
556- _sfh_key += 2*sizeof (uint16_t); \
557- hashv += hashv >> 11; \
558- } \
559- \
560- /* Handle end cases */ \
561- switch (_sfh_rem) { \
562- case 3: hashv += get16bits (_sfh_key); \
563- hashv ^= hashv << 16; \
564- hashv ^= (uint32_t)(_sfh_key[sizeof (uint16_t)] << 18); \
565- hashv += hashv >> 11; \
566- break; \
567- case 2: hashv += get16bits (_sfh_key); \
568- hashv ^= hashv << 11; \
569- hashv += hashv >> 17; \
570- break; \
571- case 1: hashv += *_sfh_key; \
572- hashv ^= hashv << 10; \
573- hashv += hashv >> 1; \
574- } \
575- \
576- /* Force "avalanching" of final 127 bits */ \
577- hashv ^= hashv << 3; \
578- hashv += hashv >> 5; \
579- hashv ^= hashv << 4; \
580- hashv += hashv >> 17; \
581- hashv ^= hashv << 25; \
582- hashv += hashv >> 6; \
583- bkt = hashv & (num_bkts-1); \
584-} while(0)
585-
586-#ifdef HASH_USING_NO_STRICT_ALIASING
587-/* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads.
588- * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error.
589- * MurmurHash uses the faster approach only on CPU's where we know it's safe.
590- *
591- * Note the preprocessor built-in defines can be emitted using:
592- *
593- * gcc -m64 -dM -E - < /dev/null (on gcc)
594- * cc -## a.c (where a.c is a simple test file) (Sun Studio)
595- */
596-#if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86))
597-#define MUR_GETBLOCK(p,i) p[i]
598-#else /* non intel */
599-#define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 0x3) == 0)
600-#define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 0x3) == 1)
601-#define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 0x3) == 2)
602-#define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 0x3) == 3)
603-#define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL))
604-#if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__))
605-#define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24))
606-#define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16))
607-#define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8))
608-#else /* assume little endian non-intel */
609-#define MUR_THREE_ONE(p) ((((*WP(p))&0xffffff00) >> 8) | (((*(WP(p)+1))&0x000000ff) << 24))
610-#define MUR_TWO_TWO(p) ((((*WP(p))&0xffff0000) >>16) | (((*(WP(p)+1))&0x0000ffff) << 16))
611-#define MUR_ONE_THREE(p) ((((*WP(p))&0xff000000) >>24) | (((*(WP(p)+1))&0x00ffffff) << 8))
612-#endif
613-#define MUR_GETBLOCK(p,i) (MUR_PLUS0_ALIGNED(p) ? ((p)[i]) : \
614- (MUR_PLUS1_ALIGNED(p) ? MUR_THREE_ONE(p) : \
615- (MUR_PLUS2_ALIGNED(p) ? MUR_TWO_TWO(p) : \
616- MUR_ONE_THREE(p))))
617-#endif
618-#define MUR_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r))))
619-#define MUR_FMIX(_h) \
620-do { \
621- _h ^= _h >> 16; \
622- _h *= 0x85ebca6b; \
623- _h ^= _h >> 13; \
624- _h *= 0xc2b2ae35l; \
625- _h ^= _h >> 16; \
626-} while(0)
627-
628-#define HASH_MUR(key,keylen,num_bkts,hashv,bkt) \
629-do { \
630- const uint8_t *_mur_data = (const uint8_t*)(key); \
631- const int _mur_nblocks = (keylen) / 4; \
632- uint32_t _mur_h1 = 0xf88D5353; \
633- uint32_t _mur_c1 = 0xcc9e2d51; \
634- uint32_t _mur_c2 = 0x1b873593; \
635- uint32_t _mur_k1 = 0; \
636- const uint8_t *_mur_tail; \
637- const uint32_t *_mur_blocks = (const uint32_t*)(_mur_data+_mur_nblocks*4); \
638- int _mur_i; \
639- for(_mur_i = -_mur_nblocks; _mur_i; _mur_i++) { \
640- _mur_k1 = MUR_GETBLOCK(_mur_blocks,_mur_i); \
641- _mur_k1 *= _mur_c1; \
642- _mur_k1 = MUR_ROTL32(_mur_k1,15); \
643- _mur_k1 *= _mur_c2; \
644- \
645- _mur_h1 ^= _mur_k1; \
646- _mur_h1 = MUR_ROTL32(_mur_h1,13); \
647- _mur_h1 = _mur_h1*5+0xe6546b64; \
648- } \
649- _mur_tail = (const uint8_t*)(_mur_data + _mur_nblocks*4); \
650- _mur_k1=0; \
651- switch((keylen) & 3) { \
652- case 3: _mur_k1 ^= _mur_tail[2] << 16; \
653- case 2: _mur_k1 ^= _mur_tail[1] << 8; \
654- case 1: _mur_k1 ^= _mur_tail[0]; \
655- _mur_k1 *= _mur_c1; \
656- _mur_k1 = MUR_ROTL32(_mur_k1,15); \
657- _mur_k1 *= _mur_c2; \
658- _mur_h1 ^= _mur_k1; \
659- } \
660- _mur_h1 ^= (keylen); \
661- MUR_FMIX(_mur_h1); \
662- hashv = _mur_h1; \
663- bkt = hashv & (num_bkts-1); \
664-} while(0)
665-#endif /* HASH_USING_NO_STRICT_ALIASING */
666-
667-/* key comparison function; return 0 if keys equal */
668-#define HASH_KEYCMP(a,b,len) memcmp(a,b,len)
669-
670-/* iterate over items in a known bucket to find desired item */
671-#define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,out) \
672-do { \
673- if (head.hh_head) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,head.hh_head)); \
674- else out=NULL; \
675- while (out) { \
676- if ((out)->hh.keylen == keylen_in) { \
677- if ((HASH_KEYCMP((out)->hh.key,keyptr,keylen_in)) == 0) break; \
678- } \
679- if ((out)->hh.hh_next) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,(out)->hh.hh_next)); \
680- else out = NULL; \
681- } \
682-} while(0)
683-
684-/* add an item to a bucket */
685-#define HASH_ADD_TO_BKT(head,addhh) \
686-do { \
687- head.count++; \
688- (addhh)->hh_next = head.hh_head; \
689- (addhh)->hh_prev = NULL; \
690- if (head.hh_head) { (head).hh_head->hh_prev = (addhh); } \
691- (head).hh_head=addhh; \
692- if (head.count >= ((head.expand_mult+1) * HASH_BKT_CAPACITY_THRESH) \
693- && (addhh)->tbl->noexpand != 1) { \
694- HASH_EXPAND_BUCKETS((addhh)->tbl); \
695- } \
696-} while(0)
697-
698-/* remove an item from a given bucket */
699-#define HASH_DEL_IN_BKT(hh,head,hh_del) \
700- (head).count--; \
701- if ((head).hh_head == hh_del) { \
702- (head).hh_head = hh_del->hh_next; \
703- } \
704- if (hh_del->hh_prev) { \
705- hh_del->hh_prev->hh_next = hh_del->hh_next; \
706- } \
707- if (hh_del->hh_next) { \
708- hh_del->hh_next->hh_prev = hh_del->hh_prev; \
709- }
710-
711-/* Bucket expansion has the effect of doubling the number of buckets
712- * and redistributing the items into the new buckets. Ideally the
713- * items will distribute more or less evenly into the new buckets
714- * (the extent to which this is true is a measure of the quality of
715- * the hash function as it applies to the key domain).
716- *
717- * With the items distributed into more buckets, the chain length
718- * (item count) in each bucket is reduced. Thus by expanding buckets
719- * the hash keeps a bound on the chain length. This bounded chain
720- * length is the essence of how a hash provides constant time lookup.
721- *
722- * The calculation of tbl->ideal_chain_maxlen below deserves some
723- * explanation. First, keep in mind that we're calculating the ideal
724- * maximum chain length based on the *new* (doubled) bucket count.
725- * In fractions this is just n/b (n=number of items,b=new num buckets).
726- * Since the ideal chain length is an integer, we want to calculate
727- * ceil(n/b). We don't depend on floating point arithmetic in this
728- * hash, so to calculate ceil(n/b) with integers we could write
729- *
730- * ceil(n/b) = (n/b) + ((n%b)?1:0)
731- *
732- * and in fact a previous version of this hash did just that.
733- * But now we have improved things a bit by recognizing that b is
734- * always a power of two. We keep its base 2 log handy (call it lb),
735- * so now we can write this with a bit shift and logical AND:
736- *
737- * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0)
738- *
739- */
740-#define HASH_EXPAND_BUCKETS(tbl) \
741-do { \
742- unsigned _he_bkt; \
743- unsigned _he_bkt_i; \
744- struct UT_hash_handle *_he_thh, *_he_hh_nxt; \
745- UT_hash_bucket *_he_new_buckets, *_he_newbkt; \
746- _he_new_buckets = (UT_hash_bucket*)uthash_malloc( \
747- 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
748- if (!_he_new_buckets) { uthash_fatal( "out of memory"); } \
749- memset(_he_new_buckets, 0, \
750- 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
751- tbl->ideal_chain_maxlen = \
752- (tbl->num_items >> (tbl->log2_num_buckets+1)) + \
753- ((tbl->num_items & ((tbl->num_buckets*2)-1)) ? 1 : 0); \
754- tbl->nonideal_items = 0; \
755- for(_he_bkt_i = 0; _he_bkt_i < tbl->num_buckets; _he_bkt_i++) \
756- { \
757- _he_thh = tbl->buckets[ _he_bkt_i ].hh_head; \
758- while (_he_thh) { \
759- _he_hh_nxt = _he_thh->hh_next; \
760- HASH_TO_BKT( _he_thh->hashv, tbl->num_buckets*2, _he_bkt); \
761- _he_newbkt = &(_he_new_buckets[ _he_bkt ]); \
762- if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \
763- tbl->nonideal_items++; \
764- _he_newbkt->expand_mult = _he_newbkt->count / \
765- tbl->ideal_chain_maxlen; \
766- } \
767- _he_thh->hh_prev = NULL; \
768- _he_thh->hh_next = _he_newbkt->hh_head; \
769- if (_he_newbkt->hh_head) _he_newbkt->hh_head->hh_prev = \
770- _he_thh; \
771- _he_newbkt->hh_head = _he_thh; \
772- _he_thh = _he_hh_nxt; \
773- } \
774- } \
775- uthash_free( tbl->buckets, tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \
776- tbl->num_buckets *= 2; \
777- tbl->log2_num_buckets++; \
778- tbl->buckets = _he_new_buckets; \
779- tbl->ineff_expands = (tbl->nonideal_items > (tbl->num_items >> 1)) ? \
780- (tbl->ineff_expands+1) : 0; \
781- if (tbl->ineff_expands > 1) { \
782- tbl->noexpand=1; \
783- uthash_noexpand_fyi(tbl); \
784- } \
785- uthash_expand_fyi(tbl); \
786-} while(0)
787-
788-
789-/* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */
790-/* Note that HASH_SORT assumes the hash handle name to be hh.
791- * HASH_SRT was added to allow the hash handle name to be passed in. */
792-#define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn)
793-#define HASH_SRT(hh,head,cmpfcn) \
794-do { \
795- unsigned _hs_i; \
796- unsigned _hs_looping,_hs_nmerges,_hs_insize,_hs_psize,_hs_qsize; \
797- struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \
798- if (head) { \
799- _hs_insize = 1; \
800- _hs_looping = 1; \
801- _hs_list = &((head)->hh); \
802- while (_hs_looping) { \
803- _hs_p = _hs_list; \
804- _hs_list = NULL; \
805- _hs_tail = NULL; \
806- _hs_nmerges = 0; \
807- while (_hs_p) { \
808- _hs_nmerges++; \
809- _hs_q = _hs_p; \
810- _hs_psize = 0; \
811- for ( _hs_i = 0; _hs_i < _hs_insize; _hs_i++ ) { \
812- _hs_psize++; \
813- _hs_q = (UT_hash_handle*)((_hs_q->next) ? \
814- ((void*)((char*)(_hs_q->next) + \
815- (head)->hh.tbl->hho)) : NULL); \
816- if (! (_hs_q) ) break; \
817- } \
818- _hs_qsize = _hs_insize; \
819- while ((_hs_psize > 0) || ((_hs_qsize > 0) && _hs_q )) { \
820- if (_hs_psize == 0) { \
821- _hs_e = _hs_q; \
822- _hs_q = (UT_hash_handle*)((_hs_q->next) ? \
823- ((void*)((char*)(_hs_q->next) + \
824- (head)->hh.tbl->hho)) : NULL); \
825- _hs_qsize--; \
826- } else if ( (_hs_qsize == 0) || !(_hs_q) ) { \
827- _hs_e = _hs_p; \
828- if (_hs_p){ \
829- _hs_p = (UT_hash_handle*)((_hs_p->next) ? \
830- ((void*)((char*)(_hs_p->next) + \
831- (head)->hh.tbl->hho)) : NULL); \
832- } \
833- _hs_psize--; \
834- } else if (( \
835- cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_p)), \
836- DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_q))) \
837- ) <= 0) { \
838- _hs_e = _hs_p; \
839- if (_hs_p){ \
840- _hs_p = (UT_hash_handle*)((_hs_p->next) ? \
841- ((void*)((char*)(_hs_p->next) + \
842- (head)->hh.tbl->hho)) : NULL); \
843- } \
844- _hs_psize--; \
845- } else { \
846- _hs_e = _hs_q; \
847- _hs_q = (UT_hash_handle*)((_hs_q->next) ? \
848- ((void*)((char*)(_hs_q->next) + \
849- (head)->hh.tbl->hho)) : NULL); \
850- _hs_qsize--; \
851- } \
852- if ( _hs_tail ) { \
853- _hs_tail->next = ((_hs_e) ? \
854- ELMT_FROM_HH((head)->hh.tbl,_hs_e) : NULL); \
855- } else { \
856- _hs_list = _hs_e; \
857- } \
858- if (_hs_e) { \
859- _hs_e->prev = ((_hs_tail) ? \
860- ELMT_FROM_HH((head)->hh.tbl,_hs_tail) : NULL); \
861- } \
862- _hs_tail = _hs_e; \
863- } \
864- _hs_p = _hs_q; \
865- } \
866- if (_hs_tail){ \
867- _hs_tail->next = NULL; \
868- } \
869- if ( _hs_nmerges <= 1 ) { \
870- _hs_looping=0; \
871- (head)->hh.tbl->tail = _hs_tail; \
872- DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \
873- } \
874- _hs_insize *= 2; \
875- } \
876- HASH_FSCK(hh,head); \
877- } \
878-} while (0)
879-
880-/* This function selects items from one hash into another hash.
881- * The end result is that the selected items have dual presence
882- * in both hashes. There is no copy of the items made; rather
883- * they are added into the new hash through a secondary hash
884- * hash handle that must be present in the structure. */
885-#define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \
886-do { \
887- unsigned _src_bkt, _dst_bkt; \
888- void *_last_elt=NULL, *_elt; \
889- UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh=NULL; \
890- ptrdiff_t _dst_hho = ((char*)(&(dst)->hh_dst) - (char*)(dst)); \
891- if (src) { \
892- for(_src_bkt=0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \
893- for(_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \
894- _src_hh; \
895- _src_hh = _src_hh->hh_next) { \
896- _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \
897- if (cond(_elt)) { \
898- _dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \
899- _dst_hh->key = _src_hh->key; \
900- _dst_hh->keylen = _src_hh->keylen; \
901- _dst_hh->hashv = _src_hh->hashv; \
902- _dst_hh->prev = _last_elt; \
903- _dst_hh->next = NULL; \
904- if (_last_elt_hh) { _last_elt_hh->next = _elt; } \
905- if (!dst) { \
906- DECLTYPE_ASSIGN(dst,_elt); \
907- HASH_MAKE_TABLE(hh_dst,dst); \
908- } else { \
909- _dst_hh->tbl = (dst)->hh_dst.tbl; \
910- } \
911- HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \
912- HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt],_dst_hh); \
913- (dst)->hh_dst.tbl->num_items++; \
914- _last_elt = _elt; \
915- _last_elt_hh = _dst_hh; \
916- } \
917- } \
918- } \
919- } \
920- HASH_FSCK(hh_dst,dst); \
921-} while (0)
922-
923-#define HASH_CLEAR(hh,head) \
924-do { \
925- if (head) { \
926- uthash_free((head)->hh.tbl->buckets, \
927- (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \
928- HASH_BLOOM_FREE((head)->hh.tbl); \
929- uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
930- (head)=NULL; \
931- } \
932-} while(0)
933-
934-#define HASH_OVERHEAD(hh,head) \
935- (size_t)((((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \
936- ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \
937- (sizeof(UT_hash_table)) + \
938- (HASH_BLOOM_BYTELEN)))
939-
940-#ifdef NO_DECLTYPE
941-#define HASH_ITER(hh,head,el,tmp) \
942-for((el)=(head), (*(char**)(&(tmp)))=(char*)((head)?(head)->hh.next:NULL); \
943- el; (el)=(tmp),(*(char**)(&(tmp)))=(char*)((tmp)?(tmp)->hh.next:NULL))
944-#else
945-#define HASH_ITER(hh,head,el,tmp) \
946-for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL); \
947- el; (el)=(tmp),(tmp)=DECLTYPE(el)((tmp)?(tmp)->hh.next:NULL))
948-#endif
949-
950-/* obtain a count of items in the hash */
951-#define HASH_COUNT(head) HASH_CNT(hh,head)
952-#define HASH_CNT(hh,head) ((head)?((head)->hh.tbl->num_items):0)
953-
954-typedef struct UT_hash_bucket {
955- struct UT_hash_handle *hh_head;
956- unsigned count;
957-
958- /* expand_mult is normally set to 0. In this situation, the max chain length
959- * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If
960- * the bucket's chain exceeds this length, bucket expansion is triggered).
961- * However, setting expand_mult to a non-zero value delays bucket expansion
962- * (that would be triggered by additions to this particular bucket)
963- * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH.
964- * (The multiplier is simply expand_mult+1). The whole idea of this
965- * multiplier is to reduce bucket expansions, since they are expensive, in
966- * situations where we know that a particular bucket tends to be overused.
967- * It is better to let its chain length grow to a longer yet-still-bounded
968- * value, than to do an O(n) bucket expansion too often.
969- */
970- unsigned expand_mult;
971-
972-} UT_hash_bucket;
973-
974-/* random signature used only to find hash tables in external analysis */
975-#define HASH_SIGNATURE 0xa0111fe1
976-#define HASH_BLOOM_SIGNATURE 0xb12220f2
977-
978-typedef struct UT_hash_table {
979- UT_hash_bucket *buckets;
980- unsigned num_buckets, log2_num_buckets;
981- unsigned num_items;
982- struct UT_hash_handle *tail; /* tail hh in app order, for fast append */
983- ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */
984-
985- /* in an ideal situation (all buckets used equally), no bucket would have
986- * more than ceil(#items/#buckets) items. that's the ideal chain length. */
987- unsigned ideal_chain_maxlen;
988-
989- /* nonideal_items is the number of items in the hash whose chain position
990- * exceeds the ideal chain maxlen. these items pay the penalty for an uneven
991- * hash distribution; reaching them in a chain traversal takes >ideal steps */
992- unsigned nonideal_items;
993-
994- /* ineffective expands occur when a bucket doubling was performed, but
995- * afterward, more than half the items in the hash had nonideal chain
996- * positions. If this happens on two consecutive expansions we inhibit any
997- * further expansion, as it's not helping; this happens when the hash
998- * function isn't a good fit for the key domain. When expansion is inhibited
999- * the hash will still work, albeit no longer in constant time. */
1000- unsigned ineff_expands, noexpand;
1001-
1002- uint32_t signature; /* used only to find hash tables in external analysis */
1003-#ifdef HASH_BLOOM
1004- uint32_t bloom_sig; /* used only to test bloom exists in external analysis */
1005- uint8_t *bloom_bv;
1006- char bloom_nbits;
1007-#endif
1008-
1009-} UT_hash_table;
1010-
1011-typedef struct UT_hash_handle {
1012- struct UT_hash_table *tbl;
1013- void *prev; /* prev element in app order */
1014- void *next; /* next element in app order */
1015- struct UT_hash_handle *hh_prev; /* previous hh in bucket order */
1016- struct UT_hash_handle *hh_next; /* next hh in bucket order */
1017- void *key; /* ptr to enclosing struct's key */
1018- unsigned keylen; /* enclosing struct's key len */
1019- unsigned hashv; /* result of hash-fcn(key) */
1020-} UT_hash_handle;
1021-
1022-#endif /* UTHASH_H */
1023
1024=== removed directory '.pc/enable-libwrap.patch'
1025=== removed file '.pc/enable-libwrap.patch/config.mk'
1026--- .pc/enable-libwrap.patch/config.mk 2015-01-15 14:08:09 +0000
1027+++ .pc/enable-libwrap.patch/config.mk 1970-01-01 00:00:00 +0000
1028@@ -1,219 +0,0 @@
1029-# =============================================================================
1030-# User configuration section.
1031-#
1032-# Largely, these are options that are designed to make mosquitto run more
1033-# easily in restrictive environments by removing features.
1034-#
1035-# Modify the variable below to enable/disable features.
1036-#
1037-# Can also be overriden at the command line, e.g.:
1038-#
1039-# make WITH_TLS=no
1040-# =============================================================================
1041-
1042-# Uncomment to compile the broker with tcpd/libwrap support.
1043-#WITH_WRAP:=yes
1044-
1045-# Comment out to disable SSL/TLS support in the broker and client.
1046-# Disabling this will also mean that passwords must be stored in plain text. It
1047-# is strongly recommended that you only disable WITH_TLS if you are not using
1048-# password authentication at all.
1049-WITH_TLS:=yes
1050-
1051-# Comment out to disable TLS/PSK support in the broker and client. Requires
1052-# WITH_TLS=yes.
1053-# This must be disabled if using openssl < 1.0.
1054-WITH_TLS_PSK:=yes
1055-
1056-# Comment out to disable client client threading support.
1057-WITH_THREADING:=yes
1058-
1059-# Uncomment to compile the broker with strict protocol support. This means that
1060-# both the client library and the broker will be very strict about protocol
1061-# compliance on incoming data. Neither of them will return an error on
1062-# incorrect "remaining length" values if this is commented out. The old
1063-# behaviour (prior to 0.12) is equivalent to compiling with
1064-# WITH_STRICT_PROTOCOL defined and means that clients will be immediately
1065-# disconnected from the broker on non-compliance.
1066-#WITH_STRICT_PROTOCOL:=yes
1067-
1068-# Comment out to remove bridge support from the broker. This allow the broker
1069-# to connect to other brokers and subscribe/publish to topics. You probably
1070-# want to leave this included unless you want to save a very small amount of
1071-# memory size and CPU time.
1072-WITH_BRIDGE:=yes
1073-
1074-# Comment out to remove persistent database support from the broker. This
1075-# allows the broker to store retained messages and durable subscriptions to a
1076-# file periodically and on shutdown. This is usually desirable (and is
1077-# suggested by the MQTT spec), but it can be disabled if required.
1078-WITH_PERSISTENCE:=yes
1079-
1080-# Comment out to remove memory tracking support from the broker. If disabled,
1081-# mosquitto won't track heap memory usage nor export '$SYS/broker/heap/current
1082-# size', but will use slightly less memory and CPU time.
1083-WITH_MEMORY_TRACKING:=yes
1084-
1085-# Compile with database upgrading support? If disabled, mosquitto won't
1086-# automatically upgrade old database versions.
1087-# Not currently supported.
1088-#WITH_DB_UPGRADE:=yes
1089-
1090-# Comment out to remove publishing of the $SYS topic hierarchy containing
1091-# information about the broker state.
1092-WITH_SYS_TREE:=yes
1093-
1094-# Build with Python module. Comment out if Python is not installed, or required
1095-# Python modules are not available.
1096-WITH_PYTHON:=yes
1097-
1098-# Build with SRV lookup support.
1099-WITH_SRV:=yes
1100-
1101-# =============================================================================
1102-# End of user configuration
1103-# =============================================================================
1104-
1105-
1106-# Also bump lib/mosquitto.h, lib/python/setup.py, CMakeLists.txt,
1107-# installer/mosquitto.nsi, installer/mosquitto-cygwin.nsi
1108-VERSION=1.3.4
1109-TIMESTAMP:=$(shell date "+%F %T%z")
1110-
1111-# Client library SO version. Bump if incompatible API/ABI changes are made.
1112-SOVERSION=1
1113-
1114-# Man page generation requires xsltproc and docbook-xsl
1115-XSLTPROC=xsltproc
1116-# For html generation
1117-DB_HTML_XSL=man/html.xsl
1118-
1119-#MANCOUNTRIES=en_GB
1120-
1121-UNAME:=$(shell uname -s)
1122-ifeq ($(UNAME),SunOS)
1123- ifeq ($(CC),cc)
1124- CFLAGS?=-O
1125- else
1126- CFLAGS?=-Wall -ggdb -O2
1127- endif
1128-else
1129- CFLAGS?=-Wall -ggdb -O2
1130-endif
1131-
1132-LIB_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I. -I.. -I../lib
1133-LIB_CXXFLAGS:=$(LIB_CFLAGS) ${CPPFLAGS}
1134-LIB_LDFLAGS:=${LDFLAGS}
1135-
1136-BROKER_CFLAGS:=${LIB_CFLAGS} ${CPPFLAGS} -DVERSION="\"${VERSION}\"" -DTIMESTAMP="\"${TIMESTAMP}\"" -DWITH_BROKER
1137-CLIENT_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I../lib -DVERSION="\"${VERSION}\""
1138-
1139-ifeq ($(UNAME),FreeBSD)
1140- BROKER_LIBS:=-lm
1141-else
1142- BROKER_LIBS:=-ldl -lm
1143-endif
1144-LIB_LIBS:=
1145-PASSWD_LIBS:=
1146-
1147-ifeq ($(UNAME),Linux)
1148- BROKER_LIBS:=$(BROKER_LIBS) -lrt
1149- LIB_LIBS:=$(LIB_LIBS) -lrt
1150-endif
1151-
1152-CLIENT_LDFLAGS:=$(LDFLAGS) -L../lib ../lib/libmosquitto.so.${SOVERSION}
1153-
1154-ifeq ($(UNAME),SunOS)
1155- ifeq ($(CC),cc)
1156- LIB_CFLAGS:=$(LIB_CFLAGS) -xc99 -KPIC
1157- else
1158- LIB_CFLAGS:=$(LIB_CFLAGS) -fPIC
1159- endif
1160-
1161- ifeq ($(CXX),CC)
1162- LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -KPIC
1163- else
1164- LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -fPIC
1165- endif
1166-else
1167- LIB_CFLAGS:=$(LIB_CFLAGS) -fPIC
1168- LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -fPIC
1169-endif
1170-
1171-ifneq ($(UNAME),SunOS)
1172- LIB_LDFLAGS:=$(LIB_LDFLAGS) -Wl,--version-script=linker.version -Wl,-soname,libmosquitto.so.$(SOVERSION)
1173-endif
1174-
1175-ifeq ($(UNAME),QNX)
1176- BROKER_LIBS:=$(BROKER_LIBS) -lsocket
1177- LIB_LIBS:=$(LIB_LIBS) -lsocket
1178-endif
1179-
1180-ifeq ($(WITH_WRAP),yes)
1181- BROKER_LIBS:=$(BROKER_LIBS) -lwrap
1182- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_WRAP
1183-endif
1184-
1185-ifeq ($(WITH_TLS),yes)
1186- BROKER_LIBS:=$(BROKER_LIBS) -lssl -lcrypto
1187- LIB_LIBS:=$(LIB_LIBS) -lssl -lcrypto
1188- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_TLS
1189- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_TLS
1190- PASSWD_LIBS:=-lcrypto
1191- CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_TLS
1192-
1193- ifeq ($(WITH_TLS_PSK),yes)
1194- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_TLS_PSK
1195- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_TLS_PSK
1196- CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_TLS_PSK
1197- endif
1198-endif
1199-
1200-ifeq ($(WITH_THREADING),yes)
1201- LIB_LIBS:=$(LIB_LIBS) -lpthread
1202- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_THREADING
1203-endif
1204-
1205-ifeq ($(WITH_STRICT_PROTOCOL),yes)
1206- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_STRICT_PROTOCOL
1207- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_STRICT_PROTOCOL
1208-endif
1209-
1210-ifeq ($(WITH_BRIDGE),yes)
1211- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_BRIDGE
1212-endif
1213-
1214-ifeq ($(WITH_PERSISTENCE),yes)
1215- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_PERSISTENCE
1216-endif
1217-
1218-ifeq ($(WITH_MEMORY_TRACKING),yes)
1219- ifneq ($(UNAME),SunOS)
1220- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_MEMORY_TRACKING
1221- endif
1222-endif
1223-
1224-#ifeq ($(WITH_DB_UPGRADE),yes)
1225-# BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_DB_UPGRADE
1226-#endif
1227-
1228-ifeq ($(WITH_SYS_TREE),yes)
1229- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_SYS_TREE
1230-endif
1231-
1232-ifeq ($(WITH_SRV),yes)
1233- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_SRV
1234- LIB_LIBS:=$(LIB_LIBS) -lcares
1235-endif
1236-
1237-ifeq ($(UNAME),SunOS)
1238- BROKER_LIBS:=$(BROKER_LIBS) -lsocket -lnsl
1239- LIB_LIBS:=$(LIB_LIBS) -lsocket -lnsl
1240-endif
1241-
1242-
1243-INSTALL?=install
1244-prefix=/usr/local
1245-mandir=${prefix}/share/man
1246-localedir=${prefix}/share/locale
1247-STRIP?=strip
1248
1249=== removed directory '.pc/fix-prefix.patch'
1250=== removed file '.pc/fix-prefix.patch/config.mk'
1251--- .pc/fix-prefix.patch/config.mk 2015-01-15 14:08:09 +0000
1252+++ .pc/fix-prefix.patch/config.mk 1970-01-01 00:00:00 +0000
1253@@ -1,219 +0,0 @@
1254-# =============================================================================
1255-# User configuration section.
1256-#
1257-# Largely, these are options that are designed to make mosquitto run more
1258-# easily in restrictive environments by removing features.
1259-#
1260-# Modify the variable below to enable/disable features.
1261-#
1262-# Can also be overriden at the command line, e.g.:
1263-#
1264-# make WITH_TLS=no
1265-# =============================================================================
1266-
1267-# Uncomment to compile the broker with tcpd/libwrap support.
1268-WITH_WRAP:=yes
1269-
1270-# Comment out to disable SSL/TLS support in the broker and client.
1271-# Disabling this will also mean that passwords must be stored in plain text. It
1272-# is strongly recommended that you only disable WITH_TLS if you are not using
1273-# password authentication at all.
1274-WITH_TLS:=yes
1275-
1276-# Comment out to disable TLS/PSK support in the broker and client. Requires
1277-# WITH_TLS=yes.
1278-# This must be disabled if using openssl < 1.0.
1279-WITH_TLS_PSK:=yes
1280-
1281-# Comment out to disable client client threading support.
1282-WITH_THREADING:=yes
1283-
1284-# Uncomment to compile the broker with strict protocol support. This means that
1285-# both the client library and the broker will be very strict about protocol
1286-# compliance on incoming data. Neither of them will return an error on
1287-# incorrect "remaining length" values if this is commented out. The old
1288-# behaviour (prior to 0.12) is equivalent to compiling with
1289-# WITH_STRICT_PROTOCOL defined and means that clients will be immediately
1290-# disconnected from the broker on non-compliance.
1291-#WITH_STRICT_PROTOCOL:=yes
1292-
1293-# Comment out to remove bridge support from the broker. This allow the broker
1294-# to connect to other brokers and subscribe/publish to topics. You probably
1295-# want to leave this included unless you want to save a very small amount of
1296-# memory size and CPU time.
1297-WITH_BRIDGE:=yes
1298-
1299-# Comment out to remove persistent database support from the broker. This
1300-# allows the broker to store retained messages and durable subscriptions to a
1301-# file periodically and on shutdown. This is usually desirable (and is
1302-# suggested by the MQTT spec), but it can be disabled if required.
1303-WITH_PERSISTENCE:=yes
1304-
1305-# Comment out to remove memory tracking support from the broker. If disabled,
1306-# mosquitto won't track heap memory usage nor export '$SYS/broker/heap/current
1307-# size', but will use slightly less memory and CPU time.
1308-WITH_MEMORY_TRACKING:=yes
1309-
1310-# Compile with database upgrading support? If disabled, mosquitto won't
1311-# automatically upgrade old database versions.
1312-# Not currently supported.
1313-#WITH_DB_UPGRADE:=yes
1314-
1315-# Comment out to remove publishing of the $SYS topic hierarchy containing
1316-# information about the broker state.
1317-WITH_SYS_TREE:=yes
1318-
1319-# Build with Python module. Comment out if Python is not installed, or required
1320-# Python modules are not available.
1321-WITH_PYTHON:=yes
1322-
1323-# Build with SRV lookup support.
1324-WITH_SRV:=yes
1325-
1326-# =============================================================================
1327-# End of user configuration
1328-# =============================================================================
1329-
1330-
1331-# Also bump lib/mosquitto.h, lib/python/setup.py, CMakeLists.txt,
1332-# installer/mosquitto.nsi, installer/mosquitto-cygwin.nsi
1333-VERSION=1.3.4
1334-TIMESTAMP:=$(shell date "+%F %T%z")
1335-
1336-# Client library SO version. Bump if incompatible API/ABI changes are made.
1337-SOVERSION=1
1338-
1339-# Man page generation requires xsltproc and docbook-xsl
1340-XSLTPROC=xsltproc
1341-# For html generation
1342-DB_HTML_XSL=man/html.xsl
1343-
1344-#MANCOUNTRIES=en_GB
1345-
1346-UNAME:=$(shell uname -s)
1347-ifeq ($(UNAME),SunOS)
1348- ifeq ($(CC),cc)
1349- CFLAGS?=-O
1350- else
1351- CFLAGS?=-Wall -ggdb -O2
1352- endif
1353-else
1354- CFLAGS?=-Wall -ggdb -O2
1355-endif
1356-
1357-LIB_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I. -I.. -I../lib
1358-LIB_CXXFLAGS:=$(LIB_CFLAGS) ${CPPFLAGS}
1359-LIB_LDFLAGS:=${LDFLAGS}
1360-
1361-BROKER_CFLAGS:=${LIB_CFLAGS} ${CPPFLAGS} -DVERSION="\"${VERSION}\"" -DTIMESTAMP="\"${TIMESTAMP}\"" -DWITH_BROKER
1362-CLIENT_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I../lib -DVERSION="\"${VERSION}\""
1363-
1364-ifeq ($(UNAME),FreeBSD)
1365- BROKER_LIBS:=-lm
1366-else
1367- BROKER_LIBS:=-ldl -lm
1368-endif
1369-LIB_LIBS:=
1370-PASSWD_LIBS:=
1371-
1372-ifeq ($(UNAME),Linux)
1373- BROKER_LIBS:=$(BROKER_LIBS) -lrt
1374- LIB_LIBS:=$(LIB_LIBS) -lrt
1375-endif
1376-
1377-CLIENT_LDFLAGS:=$(LDFLAGS) -L../lib ../lib/libmosquitto.so.${SOVERSION}
1378-
1379-ifeq ($(UNAME),SunOS)
1380- ifeq ($(CC),cc)
1381- LIB_CFLAGS:=$(LIB_CFLAGS) -xc99 -KPIC
1382- else
1383- LIB_CFLAGS:=$(LIB_CFLAGS) -fPIC
1384- endif
1385-
1386- ifeq ($(CXX),CC)
1387- LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -KPIC
1388- else
1389- LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -fPIC
1390- endif
1391-else
1392- LIB_CFLAGS:=$(LIB_CFLAGS) -fPIC
1393- LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -fPIC
1394-endif
1395-
1396-ifneq ($(UNAME),SunOS)
1397- LIB_LDFLAGS:=$(LIB_LDFLAGS) -Wl,--version-script=linker.version -Wl,-soname,libmosquitto.so.$(SOVERSION)
1398-endif
1399-
1400-ifeq ($(UNAME),QNX)
1401- BROKER_LIBS:=$(BROKER_LIBS) -lsocket
1402- LIB_LIBS:=$(LIB_LIBS) -lsocket
1403-endif
1404-
1405-ifeq ($(WITH_WRAP),yes)
1406- BROKER_LIBS:=$(BROKER_LIBS) -lwrap
1407- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_WRAP
1408-endif
1409-
1410-ifeq ($(WITH_TLS),yes)
1411- BROKER_LIBS:=$(BROKER_LIBS) -lssl -lcrypto
1412- LIB_LIBS:=$(LIB_LIBS) -lssl -lcrypto
1413- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_TLS
1414- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_TLS
1415- PASSWD_LIBS:=-lcrypto
1416- CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_TLS
1417-
1418- ifeq ($(WITH_TLS_PSK),yes)
1419- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_TLS_PSK
1420- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_TLS_PSK
1421- CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_TLS_PSK
1422- endif
1423-endif
1424-
1425-ifeq ($(WITH_THREADING),yes)
1426- LIB_LIBS:=$(LIB_LIBS) -lpthread
1427- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_THREADING
1428-endif
1429-
1430-ifeq ($(WITH_STRICT_PROTOCOL),yes)
1431- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_STRICT_PROTOCOL
1432- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_STRICT_PROTOCOL
1433-endif
1434-
1435-ifeq ($(WITH_BRIDGE),yes)
1436- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_BRIDGE
1437-endif
1438-
1439-ifeq ($(WITH_PERSISTENCE),yes)
1440- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_PERSISTENCE
1441-endif
1442-
1443-ifeq ($(WITH_MEMORY_TRACKING),yes)
1444- ifneq ($(UNAME),SunOS)
1445- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_MEMORY_TRACKING
1446- endif
1447-endif
1448-
1449-#ifeq ($(WITH_DB_UPGRADE),yes)
1450-# BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_DB_UPGRADE
1451-#endif
1452-
1453-ifeq ($(WITH_SYS_TREE),yes)
1454- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_SYS_TREE
1455-endif
1456-
1457-ifeq ($(WITH_SRV),yes)
1458- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_SRV
1459- LIB_LIBS:=$(LIB_LIBS) -lcares
1460-endif
1461-
1462-ifeq ($(UNAME),SunOS)
1463- BROKER_LIBS:=$(BROKER_LIBS) -lsocket -lnsl
1464- LIB_LIBS:=$(LIB_LIBS) -lsocket -lnsl
1465-endif
1466-
1467-
1468-INSTALL?=install
1469-prefix=/usr/local
1470-mandir=${prefix}/share/man
1471-localedir=${prefix}/share/locale
1472-STRIP?=strip
1473
1474=== removed directory '.pc/install-apparmor.patch'
1475=== removed file '.pc/install-apparmor.patch/Makefile'
1476--- .pc/install-apparmor.patch/Makefile 2015-01-15 14:08:09 +0000
1477+++ .pc/install-apparmor.patch/Makefile 1970-01-01 00:00:00 +0000
1478@@ -1,70 +0,0 @@
1479-include config.mk
1480-
1481-DIRS=lib client src
1482-DOCDIRS=man
1483-DISTDIRS=man
1484-
1485-.PHONY : all mosquitto docs binary clean reallyclean test install uninstall dist sign copy
1486-
1487-all : mosquitto docs
1488-
1489-docs :
1490- set -e; for d in ${DOCDIRS}; do $(MAKE) -C $${d}; done
1491-
1492-binary : mosquitto
1493-
1494-mosquitto :
1495- set -e; for d in ${DIRS}; do $(MAKE) -C $${d}; done
1496-
1497-clean :
1498- set -e; for d in ${DIRS}; do $(MAKE) -C $${d} clean; done
1499- set -e; for d in ${DOCDIRS}; do $(MAKE) -C $${d} clean; done
1500- $(MAKE) -C test clean
1501-
1502-reallyclean :
1503- set -e; for d in ${DIRS}; do $(MAKE) -C $${d} reallyclean; done
1504- set -e; for d in ${DOCDIRS}; do $(MAKE) -C $${d} reallyclean; done
1505- $(MAKE) -C test reallyclean
1506- -rm -f *.orig
1507-
1508-test : mosquitto
1509- $(MAKE) -C test test
1510-
1511-install : mosquitto
1512- set -e; for d in ${DIRS}; do $(MAKE) -C $${d} install; done
1513- set -e; for d in ${DOCDIRS}; do $(MAKE) -C $${d} install; done
1514- $(INSTALL) -d ${DESTDIR}/etc/mosquitto
1515- $(INSTALL) -m 644 mosquitto.conf ${DESTDIR}/etc/mosquitto/mosquitto.conf.example
1516- $(INSTALL) -m 644 aclfile.example ${DESTDIR}/etc/mosquitto/aclfile.example
1517- $(INSTALL) -m 644 pwfile.example ${DESTDIR}/etc/mosquitto/pwfile.example
1518- $(INSTALL) -m 644 pskfile.example ${DESTDIR}/etc/mosquitto/pskfile.example
1519-
1520-uninstall :
1521- set -e; for d in ${DIRS}; do $(MAKE) -C $${d} uninstall; done
1522- rm -f ${DESTDIR}/etc/mosquitto/mosquitto.conf
1523- rm -f ${DESTDIR}/etc/mosquitto/aclfile.example
1524- rm -f ${DESTDIR}/etc/mosquitto/pwfile.example
1525- rm -f ${DESTDIR}/etc/mosquitto/pskfile.example
1526-
1527-dist : reallyclean
1528- set -e; for d in ${DISTDIRS}; do $(MAKE) -C $${d} dist; done
1529-
1530- echo $$(hg log -r . --template "{node}") > changeset
1531- mkdir -p dist/mosquitto-${VERSION}
1532- cp -r client changeset examples installer lib logo man misc security service src test ChangeLog.txt CMakeLists.txt LICENSE.txt LICENSE-3rd-party.txt Makefile compiling.txt config.h config.mk readme.txt readme-windows.txt mosquitto.conf aclfile.example pskfile.example pwfile.example dist/mosquitto-${VERSION}/
1533- cd dist; tar -zcf mosquitto-${VERSION}.tar.gz mosquitto-${VERSION}/
1534- set -e; for m in man/*.xml; \
1535- do \
1536- hfile=$$(echo $${m} | sed -e 's#man/\(.*\)\.xml#\1#' | sed -e 's/\./-/g'); \
1537- $(XSLTPROC) $(DB_HTML_XSL) $${m} > dist/$${hfile}.html; \
1538- done
1539-
1540-
1541-sign : dist
1542- cd dist; gpg --detach-sign -a mosquitto-${VERSION}.tar.gz
1543-
1544-copy : sign
1545- cd dist; scp mosquitto-${VERSION}.tar.gz mosquitto-${VERSION}.tar.gz.asc mosquitto:site/mosquitto.org/files/source/
1546- cd dist; scp *.html mosquitto:site/mosquitto.org/man/
1547- scp ChangeLog.txt mosquitto:site/mosquitto.org/
1548-
1549
1550=== removed directory '.pc/nostrip.patch'
1551=== removed directory '.pc/nostrip.patch/client'
1552=== removed file '.pc/nostrip.patch/client/Makefile'
1553--- .pc/nostrip.patch/client/Makefile 2014-08-06 00:43:39 +0000
1554+++ .pc/nostrip.patch/client/Makefile 1970-01-01 00:00:00 +0000
1555@@ -1,34 +0,0 @@
1556-include ../config.mk
1557-
1558-.PHONY: all install uninstall reallyclean clean
1559-
1560-all : mosquitto_pub mosquitto_sub
1561-
1562-mosquitto_pub : pub_client.o ../lib/libmosquitto.so.${SOVERSION}
1563- ${CC} $< -o $@ ${CLIENT_LDFLAGS}
1564-
1565-mosquitto_sub : sub_client.o ../lib/libmosquitto.so.${SOVERSION}
1566- ${CC} $< -o $@ ${CLIENT_LDFLAGS}
1567-
1568-pub_client.o : pub_client.c ../lib/libmosquitto.so.${SOVERSION}
1569- ${CC} -c $< -o $@ ${CLIENT_CFLAGS}
1570-
1571-sub_client.o : sub_client.c ../lib/libmosquitto.so.${SOVERSION}
1572- ${CC} -c $< -o $@ ${CLIENT_CFLAGS}
1573-
1574-../lib/libmosquitto.so.${SOVERSION} :
1575- $(MAKE) -C ../lib
1576-
1577-install : all
1578- $(INSTALL) -d ${DESTDIR}$(prefix)/bin
1579- $(INSTALL) -s --strip-program=$(STRIP) mosquitto_pub ${DESTDIR}${prefix}/bin/mosquitto_pub
1580- $(INSTALL) -s --strip-program=$(STRIP) mosquitto_sub ${DESTDIR}${prefix}/bin/mosquitto_sub
1581-
1582-uninstall :
1583- -rm -f ${DESTDIR}${prefix}/bin/mosquitto_pub
1584- -rm -f ${DESTDIR}${prefix}/bin/mosquitto_sub
1585-
1586-reallyclean : clean
1587-
1588-clean :
1589- -rm -f *.o mosquitto_pub mosquitto_sub
1590
1591=== removed directory '.pc/nostrip.patch/lib'
1592=== removed file '.pc/nostrip.patch/lib/Makefile'
1593--- .pc/nostrip.patch/lib/Makefile 2014-08-06 00:43:39 +0000
1594+++ .pc/nostrip.patch/lib/Makefile 1970-01-01 00:00:00 +0000
1595@@ -1,99 +0,0 @@
1596-include ../config.mk
1597-
1598-.PHONY : really clean install
1599-
1600-MOSQ_OBJS=mosquitto.o \
1601- logging_mosq.o \
1602- memory_mosq.o \
1603- messages_mosq.o \
1604- net_mosq.o \
1605- read_handle.o \
1606- read_handle_client.o \
1607- read_handle_shared.o \
1608- send_mosq.o \
1609- send_client_mosq.o \
1610- srv_mosq.o \
1611- thread_mosq.o \
1612- time_mosq.o \
1613- tls_mosq.o \
1614- util_mosq.o \
1615- will_mosq.o
1616-
1617-all : libmosquitto.so.${SOVERSION} libmosquitto.a
1618- $(MAKE) -C cpp
1619- $(MAKE) -C python
1620-
1621-install : all
1622- $(INSTALL) -d ${DESTDIR}$(prefix)/lib${LIB_SUFFIX}/
1623- $(INSTALL) -s --strip-program=$(STRIP) libmosquitto.so.${SOVERSION} ${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.so.${SOVERSION}
1624- ln -sf libmosquitto.so.${SOVERSION} ${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.so
1625- $(INSTALL) -d ${DESTDIR}${prefix}/include/
1626- $(INSTALL) mosquitto.h ${DESTDIR}${prefix}/include/mosquitto.h
1627- $(MAKE) -C cpp install
1628- $(MAKE) -C python install
1629-
1630-uninstall :
1631- -rm -f ${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.so.${SOVERSION}
1632- -rm -f ${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.so
1633- -rm -f ${DESTDIR}${prefix}/include/mosquitto.h
1634-
1635-reallyclean : clean
1636-
1637-clean :
1638- -rm -f *.o libmosquitto.so.${SOVERSION} libmosquitto.so libmosquitto.a
1639- $(MAKE) -C cpp clean
1640- $(MAKE) -C python clean
1641-
1642-libmosquitto.so.${SOVERSION} : ${MOSQ_OBJS}
1643- $(CC) -shared $(LIB_LDFLAGS) $^ -o $@ ${LIB_LIBS}
1644-
1645-libmosquitto.a : ${MOSQ_OBJS}
1646- $(AR) cr $@ $^
1647-mosquitto.o : mosquitto.c mosquitto.h
1648- $(CC) $(LIB_CFLAGS) -c $< -o $@
1649-
1650-logging_mosq.o : logging_mosq.c logging_mosq.h
1651- $(CC) $(LIB_CFLAGS) -c $< -o $@
1652-
1653-messages_mosq.o : messages_mosq.c messages_mosq.h
1654- $(CC) $(LIB_CFLAGS) -c $< -o $@
1655-
1656-memory_mosq.o : memory_mosq.c memory_mosq.h
1657- $(CC) $(LIB_CFLAGS) -c $< -o $@
1658-
1659-net_mosq.o : net_mosq.c net_mosq.h
1660- $(CC) $(LIB_CFLAGS) -c $< -o $@
1661-
1662-read_handle.o : read_handle.c read_handle.h
1663- $(CC) $(LIB_CFLAGS) -c $< -o $@
1664-
1665-read_handle_client.o : read_handle_client.c read_handle.h
1666- $(CC) $(LIB_CFLAGS) -c $< -o $@
1667-
1668-read_handle_shared.o : read_handle_shared.c read_handle.h
1669- $(CC) $(LIB_CFLAGS) -c $< -o $@
1670-
1671-send_mosq.o : send_mosq.c send_mosq.h
1672- $(CC) $(LIB_CFLAGS) -c $< -o $@
1673-
1674-send_client_mosq.o : send_client_mosq.c send_mosq.h
1675- $(CC) $(LIB_CFLAGS) -c $< -o $@
1676-
1677-srv_mosq.o : srv_mosq.c
1678- $(CC) $(LIB_CFLAGS) -c $< -o $@
1679-
1680-thread_mosq.o : thread_mosq.c
1681- $(CC) $(LIB_CFLAGS) -c $< -o $@
1682-
1683-time_mosq.o : time_mosq.c
1684- $(CC) $(LIB_CFLAGS) -c $< -o $@
1685-
1686-tls_mosq.o : tls_mosq.c
1687- $(CC) $(LIB_CFLAGS) -c $< -o $@
1688-
1689-util_mosq.o : util_mosq.c util_mosq.h
1690- $(CC) $(LIB_CFLAGS) -c $< -o $@
1691-
1692-will_mosq.o : will_mosq.c will_mosq.h
1693- $(CC) $(LIB_CFLAGS) -c $< -o $@
1694-
1695
1696=== removed directory '.pc/nostrip.patch/lib/cpp'
1697=== removed file '.pc/nostrip.patch/lib/cpp/Makefile'
1698--- .pc/nostrip.patch/lib/cpp/Makefile 2014-08-06 00:43:39 +0000
1699+++ .pc/nostrip.patch/lib/cpp/Makefile 1970-01-01 00:00:00 +0000
1700@@ -1,31 +0,0 @@
1701-include ../../config.mk
1702-
1703-ifneq ($(UNAME),SunOS)
1704- LIB_LDFLAGS:=$(LDFLAGS) -Wl,-soname,libmosquittopp.so.${SOVERSION}
1705-endif
1706-
1707-.PHONY : clean install
1708-
1709-all : libmosquittopp.so.${SOVERSION}
1710-
1711-install : all
1712- $(INSTALL) -d ${DESTDIR}$(prefix)/lib${LIB_SUFFIX}/
1713- $(INSTALL) -s --strip-program=$(STRIP) libmosquittopp.so.${SOVERSION} ${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquittopp.so.${SOVERSION}
1714- ln -sf libmosquittopp.so.${SOVERSION} ${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquittopp.so
1715- $(INSTALL) -d ${DESTDIR}${prefix}/include/
1716- $(INSTALL) mosquittopp.h ${DESTDIR}${prefix}/include/mosquittopp.h
1717-
1718-uninstall :
1719- -rm -f ${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquittopp.so.${SOVERSION}
1720- -rm -f ${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquittopp.so
1721- -rm -f ${DESTDIR}${prefix}/include/mosquittopp.h
1722-
1723-clean :
1724- -rm -f *.o libmosquittopp.so.${SOVERSION}
1725-
1726-libmosquittopp.so.${SOVERSION} : mosquittopp.o
1727- $(CXX) -shared $(LIB_LDFLAGS) $< -o $@ ../libmosquitto.so.${SOVERSION}
1728-
1729-mosquittopp.o : mosquittopp.cpp mosquittopp.h
1730- $(CXX) $(LIB_CXXFLAGS) -c $< -o $@
1731-
1732
1733=== removed directory '.pc/nostrip.patch/src'
1734=== removed file '.pc/nostrip.patch/src/Makefile'
1735--- .pc/nostrip.patch/src/Makefile 2014-08-06 00:43:39 +0000
1736+++ .pc/nostrip.patch/src/Makefile 1970-01-01 00:00:00 +0000
1737@@ -1,118 +0,0 @@
1738-include ../config.mk
1739-
1740-.PHONY: all install uninstall clean reallyclean
1741-
1742-ifeq ($(WITH_TLS),yes)
1743-all : mosquitto mosquitto_passwd
1744-else
1745-all : mosquitto
1746-endif
1747-
1748-mosquitto : mosquitto.o bridge.o conf.o context.o database.o logging.o loop.o memory_mosq.o persist.o net.o net_mosq.o read_handle.o read_handle_client.o read_handle_server.o read_handle_shared.o security.o security_default.o send_client_mosq.o send_mosq.o send_server.o service.o subs.o sys_tree.o time_mosq.o tls_mosq.o util_mosq.o will_mosq.o
1749- ${CC} $^ -o $@ ${LDFLAGS} $(BROKER_LIBS)
1750-
1751-mosquitto.o : mosquitto.c mosquitto_broker.h
1752- ${CC} $(BROKER_CFLAGS) -c $< -o $@ -DCHANGESET=\"$$(cat ../changeset)\"
1753-
1754-bridge.o : bridge.c mosquitto_broker.h
1755- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1756-
1757-conf.o : conf.c mosquitto_broker.h
1758- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1759-
1760-context.o : context.c mosquitto_broker.h
1761- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1762-
1763-database.o : database.c mosquitto_broker.h
1764- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1765-
1766-logging.o : logging.c mosquitto_broker.h
1767- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1768-
1769-loop.o : loop.c mosquitto_broker.h
1770- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1771-
1772-memory_mosq.o : ../lib/memory_mosq.c ../lib/memory_mosq.h
1773- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1774-
1775-net.o : net.c mosquitto_broker.h
1776- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1777-
1778-net_mosq.o : ../lib/net_mosq.c ../lib/net_mosq.h
1779- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1780-
1781-persist.o : persist.c persist.h mosquitto_broker.h
1782- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1783-
1784-read_handle.o : read_handle.c mosquitto_broker.h
1785- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1786-
1787-read_handle_client.o : read_handle_client.c mosquitto_broker.h
1788- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1789-
1790-read_handle_server.o : read_handle_server.c mosquitto_broker.h
1791- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1792-
1793-read_handle_shared.o : ../lib/read_handle_shared.c ../lib/read_handle.h
1794- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1795-
1796-security.o : security.c mosquitto_broker.h
1797- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1798-
1799-security_default.o : security_default.c mosquitto_broker.h
1800- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1801-
1802-send_client_mosq.o : ../lib/send_client_mosq.c ../lib/send_mosq.h
1803- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1804-
1805-send_mosq.o : ../lib/send_mosq.c ../lib/send_mosq.h
1806- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1807-
1808-send_server.o : send_server.c mosquitto_broker.h
1809- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1810-
1811-service.o : service.c mosquitto_broker.h
1812- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1813-
1814-subs.o : subs.c mosquitto_broker.h
1815- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1816-
1817-sys_tree.o : sys_tree.c mosquitto_broker.h
1818- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1819-
1820-time_mosq.o : ../lib/time_mosq.c ../lib/time_mosq.h
1821- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1822-
1823-tls_mosq.o : ../lib/tls_mosq.c
1824- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1825-
1826-util_mosq.o : ../lib/util_mosq.c ../lib/util_mosq.h
1827- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1828-
1829-will_mosq.o : ../lib/will_mosq.c ../lib/will_mosq.h
1830- ${CC} $(BROKER_CFLAGS) -c $< -o $@
1831-
1832-mosquitto_passwd : mosquitto_passwd.o
1833- ${CC} $^ -o $@ ${LDFLAGS} $(PASSWD_LIBS)
1834-
1835-mosquitto_passwd.o : mosquitto_passwd.c
1836- ${CC} $(CFLAGS) ${CPPFLAGS} -c $< -o $@
1837-
1838-install : all
1839- $(INSTALL) -d ${DESTDIR}$(prefix)/sbin
1840- $(INSTALL) -s --strip-program=$(STRIP) mosquitto ${DESTDIR}${prefix}/sbin/mosquitto
1841- $(INSTALL) mosquitto_plugin.h ${DESTDIR}${prefix}/include/mosquitto_plugin.h
1842-ifeq ($(WITH_TLS),yes)
1843- $(INSTALL) -s --strip-program=$(STRIP) mosquitto_passwd ${DESTDIR}${prefix}/bin/mosquitto_passwd
1844-endif
1845-
1846-uninstall :
1847- -rm -f ${DESTDIR}${prefix}/sbin/mosquitto
1848- -rm -f ${DESTDIR}${prefix}/include/mosquitto_plugin.h
1849- -rm -f ${DESTDIR}${prefix}/bin/mosquitto_passwd
1850-
1851-clean :
1852- -rm -f *.o mosquitto mosquitto_passwd
1853-
1854-reallyclean : clean
1855- -rm -rf *.orig *.db
1856
1857=== removed directory '.pc/pynomake.patch'
1858=== removed file '.pc/pynomake.patch/config.mk'
1859--- .pc/pynomake.patch/config.mk 2014-08-06 00:43:39 +0000
1860+++ .pc/pynomake.patch/config.mk 1970-01-01 00:00:00 +0000
1861@@ -1,219 +0,0 @@
1862-# =============================================================================
1863-# User configuration section.
1864-#
1865-# Largely, these are options that are designed to make mosquitto run more
1866-# easily in restrictive environments by removing features.
1867-#
1868-# Modify the variable below to enable/disable features.
1869-#
1870-# Can also be overriden at the command line, e.g.:
1871-#
1872-# make WITH_TLS=no
1873-# =============================================================================
1874-
1875-# Uncomment to compile the broker with tcpd/libwrap support.
1876-WITH_WRAP:=yes
1877-
1878-# Comment out to disable SSL/TLS support in the broker and client.
1879-# Disabling this will also mean that passwords must be stored in plain text. It
1880-# is strongly recommended that you only disable WITH_TLS if you are not using
1881-# password authentication at all.
1882-WITH_TLS:=yes
1883-
1884-# Comment out to disable TLS/PSK support in the broker and client. Requires
1885-# WITH_TLS=yes.
1886-# This must be disabled if using openssl < 1.0.
1887-WITH_TLS_PSK:=yes
1888-
1889-# Comment out to disable client client threading support.
1890-WITH_THREADING:=yes
1891-
1892-# Uncomment to compile the broker with strict protocol support. This means that
1893-# both the client library and the broker will be very strict about protocol
1894-# compliance on incoming data. Neither of them will return an error on
1895-# incorrect "remaining length" values if this is commented out. The old
1896-# behaviour (prior to 0.12) is equivalent to compiling with
1897-# WITH_STRICT_PROTOCOL defined and means that clients will be immediately
1898-# disconnected from the broker on non-compliance.
1899-#WITH_STRICT_PROTOCOL:=yes
1900-
1901-# Comment out to remove bridge support from the broker. This allow the broker
1902-# to connect to other brokers and subscribe/publish to topics. You probably
1903-# want to leave this included unless you want to save a very small amount of
1904-# memory size and CPU time.
1905-WITH_BRIDGE:=yes
1906-
1907-# Comment out to remove persistent database support from the broker. This
1908-# allows the broker to store retained messages and durable subscriptions to a
1909-# file periodically and on shutdown. This is usually desirable (and is
1910-# suggested by the MQTT spec), but it can be disabled if required.
1911-WITH_PERSISTENCE:=yes
1912-
1913-# Comment out to remove memory tracking support from the broker. If disabled,
1914-# mosquitto won't track heap memory usage nor export '$SYS/broker/heap/current
1915-# size', but will use slightly less memory and CPU time.
1916-WITH_MEMORY_TRACKING:=yes
1917-
1918-# Compile with database upgrading support? If disabled, mosquitto won't
1919-# automatically upgrade old database versions.
1920-# Not currently supported.
1921-#WITH_DB_UPGRADE:=yes
1922-
1923-# Comment out to remove publishing of the $SYS topic hierarchy containing
1924-# information about the broker state.
1925-WITH_SYS_TREE:=yes
1926-
1927-# Build with Python module. Comment out if Python is not installed, or required
1928-# Python modules are not available.
1929-WITH_PYTHON:=yes
1930-
1931-# Build with SRV lookup support.
1932-WITH_SRV:=yes
1933-
1934-# =============================================================================
1935-# End of user configuration
1936-# =============================================================================
1937-
1938-
1939-# Also bump lib/mosquitto.h, lib/python/setup.py, CMakeLists.txt,
1940-# installer/mosquitto.nsi, installer/mosquitto-cygwin.nsi
1941-VERSION=1.3.4
1942-TIMESTAMP:=$(shell date "+%F %T%z")
1943-
1944-# Client library SO version. Bump if incompatible API/ABI changes are made.
1945-SOVERSION=1
1946-
1947-# Man page generation requires xsltproc and docbook-xsl
1948-XSLTPROC=xsltproc
1949-# For html generation
1950-DB_HTML_XSL=man/html.xsl
1951-
1952-#MANCOUNTRIES=en_GB
1953-
1954-UNAME:=$(shell uname -s)
1955-ifeq ($(UNAME),SunOS)
1956- ifeq ($(CC),cc)
1957- CFLAGS?=-O
1958- else
1959- CFLAGS?=-Wall -ggdb -O2
1960- endif
1961-else
1962- CFLAGS?=-Wall -ggdb -O2
1963-endif
1964-
1965-LIB_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I. -I.. -I../lib
1966-LIB_CXXFLAGS:=$(LIB_CFLAGS) ${CPPFLAGS}
1967-LIB_LDFLAGS:=${LDFLAGS}
1968-
1969-BROKER_CFLAGS:=${LIB_CFLAGS} ${CPPFLAGS} -DVERSION="\"${VERSION}\"" -DTIMESTAMP="\"${TIMESTAMP}\"" -DWITH_BROKER
1970-CLIENT_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I../lib -DVERSION="\"${VERSION}\""
1971-
1972-ifeq ($(UNAME),FreeBSD)
1973- BROKER_LIBS:=-lm
1974-else
1975- BROKER_LIBS:=-ldl -lm
1976-endif
1977-LIB_LIBS:=
1978-PASSWD_LIBS:=
1979-
1980-ifeq ($(UNAME),Linux)
1981- BROKER_LIBS:=$(BROKER_LIBS) -lrt
1982- LIB_LIBS:=$(LIB_LIBS) -lrt
1983-endif
1984-
1985-CLIENT_LDFLAGS:=$(LDFLAGS) -L../lib ../lib/libmosquitto.so.${SOVERSION}
1986-
1987-ifeq ($(UNAME),SunOS)
1988- ifeq ($(CC),cc)
1989- LIB_CFLAGS:=$(LIB_CFLAGS) -xc99 -KPIC
1990- else
1991- LIB_CFLAGS:=$(LIB_CFLAGS) -fPIC
1992- endif
1993-
1994- ifeq ($(CXX),CC)
1995- LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -KPIC
1996- else
1997- LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -fPIC
1998- endif
1999-else
2000- LIB_CFLAGS:=$(LIB_CFLAGS) -fPIC
2001- LIB_CXXFLAGS:=$(LIB_CXXFLAGS) -fPIC
2002-endif
2003-
2004-ifneq ($(UNAME),SunOS)
2005- LIB_LDFLAGS:=$(LIB_LDFLAGS) -Wl,--version-script=linker.version -Wl,-soname,libmosquitto.so.$(SOVERSION)
2006-endif
2007-
2008-ifeq ($(UNAME),QNX)
2009- BROKER_LIBS:=$(BROKER_LIBS) -lsocket
2010- LIB_LIBS:=$(LIB_LIBS) -lsocket
2011-endif
2012-
2013-ifeq ($(WITH_WRAP),yes)
2014- BROKER_LIBS:=$(BROKER_LIBS) -lwrap
2015- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_WRAP
2016-endif
2017-
2018-ifeq ($(WITH_TLS),yes)
2019- BROKER_LIBS:=$(BROKER_LIBS) -lssl -lcrypto
2020- LIB_LIBS:=$(LIB_LIBS) -lssl -lcrypto
2021- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_TLS
2022- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_TLS
2023- PASSWD_LIBS:=-lcrypto
2024- CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_TLS
2025-
2026- ifeq ($(WITH_TLS_PSK),yes)
2027- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_TLS_PSK
2028- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_TLS_PSK
2029- CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_TLS_PSK
2030- endif
2031-endif
2032-
2033-ifeq ($(WITH_THREADING),yes)
2034- LIB_LIBS:=$(LIB_LIBS) -lpthread
2035- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_THREADING
2036-endif
2037-
2038-ifeq ($(WITH_STRICT_PROTOCOL),yes)
2039- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_STRICT_PROTOCOL
2040- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_STRICT_PROTOCOL
2041-endif
2042-
2043-ifeq ($(WITH_BRIDGE),yes)
2044- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_BRIDGE
2045-endif
2046-
2047-ifeq ($(WITH_PERSISTENCE),yes)
2048- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_PERSISTENCE
2049-endif
2050-
2051-ifeq ($(WITH_MEMORY_TRACKING),yes)
2052- ifneq ($(UNAME),SunOS)
2053- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_MEMORY_TRACKING
2054- endif
2055-endif
2056-
2057-#ifeq ($(WITH_DB_UPGRADE),yes)
2058-# BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_DB_UPGRADE
2059-#endif
2060-
2061-ifeq ($(WITH_SYS_TREE),yes)
2062- BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_SYS_TREE
2063-endif
2064-
2065-ifeq ($(WITH_SRV),yes)
2066- LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_SRV
2067- LIB_LIBS:=$(LIB_LIBS) -lcares
2068-endif
2069-
2070-ifeq ($(UNAME),SunOS)
2071- BROKER_LIBS:=$(BROKER_LIBS) -lsocket -lnsl
2072- LIB_LIBS:=$(LIB_LIBS) -lsocket -lnsl
2073-endif
2074-
2075-
2076-INSTALL?=install
2077-prefix=/usr
2078-mandir=${prefix}/share/man
2079-localedir=${prefix}/share/locale
2080-STRIP?=strip
2081
2082=== modified file 'CMakeLists.txt'
2083--- CMakeLists.txt 2014-08-06 00:43:39 +0000
2084+++ CMakeLists.txt 2015-02-18 20:26:49 +0000
2085@@ -1,12 +1,17 @@
2086-# This is a cmake script.
2087+# This is a cmake script. Process it with the CMake gui or command line utility
2088+# to produce makefiles / Visual Studio project files on Mac OS X and Windows.
2089+#
2090+# To configure the build options either use the CMake gui, or run the command
2091+# line utility including the "-i" option.
2092
2093 set(CMAKE_LEGACY_CYGWIN_WIN32 0)
2094
2095 project(mosquitto)
2096
2097-cmake_minimum_required(VERSION 2.6)
2098+cmake_minimum_required(VERSION 2.8)
2099+cmake_policy(SET CMP0042 NEW)
2100
2101-set (VERSION 1.3.4)
2102+set (VERSION 1.4)
2103
2104 if (WIN32)
2105 execute_process(COMMAND cmd /c echo %DATE% %TIME% OUTPUT_VARIABLE TIMESTAMP
2106@@ -26,8 +31,9 @@
2107 set (INCLUDEDIR include)
2108 set (DATAROOTDIR share)
2109 set (MANDIR man)
2110- set (SHAREDEST .)
2111- add_definitions("-D_CRT_SECURE_NO_WARNINGS")
2112+ set (SHAREDEST .)
2113+ add_definitions("-D_CRT_SECURE_NO_WARNINGS")
2114+ add_definitions("-D_CRT_NONSTDC_NO_DEPRECATE")
2115 else (WIN32)
2116 set (BINDIR bin)
2117 set (SBINDIR sbin)
2118@@ -38,6 +44,7 @@
2119 endif (${CMAKE_INSTALL_PREFIX} STREQUAL /usr)
2120
2121 set (LIBDIR lib${LIB_SUFFIX})
2122+ set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBDIR}")
2123 set (INCLUDEDIR include)
2124 set (DATAROOTDIR share)
2125 set (MANDIR ${DATAROOTDIR}/man)
2126@@ -48,16 +55,28 @@
2127 "Include SSL/TLS support?" ON)
2128 option(WITH_TLS_PSK
2129 "Include TLS-PSK support (requires WITH_TLS)?" ON)
2130+option(WITH_EC
2131+ "Include Elliptic Curve support (requires WITH_TLS)?" ON)
2132 if (${WITH_TLS} STREQUAL ON)
2133 find_package(OpenSSL REQUIRED)
2134 add_definitions("-DWITH_TLS")
2135+
2136 if (${WITH_TLS_PSK} STREQUAL ON)
2137 add_definitions("-DWITH_TLS_PSK")
2138 endif (${WITH_TLS_PSK} STREQUAL ON)
2139+
2140+ if (${WITH_EC} STREQUAL ON)
2141+ add_definitions("-DWITH_EC")
2142+ endif (${WITH_EC} STREQUAL ON)
2143 else (${WITH_TLS} STREQUAL ON)
2144 set (OPENSSL_INCLUDE_DIR "")
2145 endif (${WITH_TLS} STREQUAL ON)
2146
2147+option(WITH_SOCKS "Include SOCKS5 support?" ON)
2148+if (${WITH_SOCKS} STREQUAL ON)
2149+ add_definitions("-DWITH_SOCKS")
2150+endif (${WITH_SOCKS} STREQUAL ON)
2151+
2152 option(WITH_SRV "Include SRV lookup support?" ON)
2153
2154 # ========================================
2155
2156=== added file 'CONTRIBUTING.md'
2157--- CONTRIBUTING.md 1970-01-01 00:00:00 +0000
2158+++ CONTRIBUTING.md 2015-02-18 20:26:49 +0000
2159@@ -0,0 +1,100 @@
2160+Contributing to Mosquitto
2161+=========================
2162+
2163+Thank you for your interest in this project.
2164+
2165+Project description:
2166+--------------------
2167+
2168+The Mosquitto project has been created to provide a light weight, open-source
2169+implementation, of an MQTT broker to allow new, existing, and emerging
2170+applications for Machine-to-Machine (M2M) and Internet of Things (IoT).
2171+
2172+- https://projects.eclipse.org/projects/technology.mosquitto
2173+
2174+
2175+Source
2176+------
2177+
2178+The Mosquitto code is stored in a git repository. The URLs to access it are:
2179+
2180+ssh://<username>@git.eclipse.org:29418/mosquitto/org.eclipse.mosquitto
2181+https://<username>@git.eclipse.org/r/mosquitto/org.eclipse.mosquitto
2182+
2183+A web browsable repository is available at
2184+
2185+http://git.eclipse.org/c/mosquitto/org.eclipse.mosquitto.git
2186+
2187+Contributing a patch
2188+--------------------
2189+
2190+The Mosquitto repositories are accessed through Gerrit, the code review
2191+project, which makes it possible for anybody to clone the repository, make
2192+changes and push them back for review and eventual acceptance into the project.
2193+
2194+To do this, you must follow a few steps. The first of these are described at
2195+
2196+- https://wiki.eclipse.org/Development_Resources/Contributing_via_Git
2197+
2198+* Sign the Eclipse CLA
2199+* Use a valid commit record, including a signed-off-by entry.
2200+
2201+There are further details at
2202+
2203+- https://wiki.eclipse.org/Development_Resources/Handling_Git_Contributions
2204+
2205+Once the patch is pushed back to Gerrit, the project committers will be
2206+informed and they will undertake a review of the code. The patch may need
2207+modifying for some reason. In order to make amending commits more
2208+straightforward, the steps at
2209+https://git.eclipse.org/r/Documentation/cmd-hook-commit-msg.html should be
2210+followed. This automatically inserts a "Change-Id" entry to your commit message
2211+which allows you to amend commits and have Gerrit track them as the same
2212+change.
2213+
2214+What happens next depends on the content of the patch. If it is 100% authored
2215+by the contributor and is less than 1000 lines (and meets the needs of the
2216+project), then it can be committed to the main repository. If not, more steps
2217+are required. These are detailed in the legal process poster:
2218+
2219+- http://www.eclipse.org/legal/EclipseLegalProcessPoster.pdf
2220+
2221+Developer resources:
2222+--------------------
2223+
2224+More information regarding source code management, builds, coding standards,
2225+and other topics can be found at.
2226+
2227+- https://projects.eclipse.org/projects/technology.mosquitto/developer
2228+
2229+
2230+Contributor License Agreement:
2231+------------------------------
2232+
2233+Before your contribution can be accepted by the project, you need to create and
2234+electronically sign the Eclipse Foundation Contributor License Agreement (CLA).
2235+
2236+- http://www.eclipse.org/legal/CLA.php
2237+
2238+
2239+Contact:
2240+--------
2241+
2242+Contact the project developers via the project's "dev" list.
2243+
2244+- https://dev.eclipse.org/mailman/listinfo/mosquitto-dev
2245+
2246+
2247+Search for bugs:
2248+----------------
2249+
2250+This project uses Bugzilla to track ongoing development and issues.
2251+
2252+- https://bugs.eclipse.org/bugs/buglist.cgi?product=Mosquitto
2253+
2254+Create a new bug:
2255+-----------------
2256+
2257+Be sure to search for existing bugs before you create another one. Remember that contributions are always welcome!
2258+
2259+- https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Mosquitto
2260
2261=== modified file 'ChangeLog.txt'
2262--- ChangeLog.txt 2014-08-06 00:43:39 +0000
2263+++ ChangeLog.txt 2015-02-18 20:26:49 +0000
2264@@ -1,8 +1,120 @@
2265+1.4 - 20150218
2266+==============
2267+
2268+Important changes:
2269+- Websockets support in the broker.
2270+- Bridge behaviour on the local broker has changed due to the introduction of
2271+ the local_* options. This may affect you if you are using authentication
2272+ and/or ACLs with bridges.
2273+- The default TLS behaviour has changed to accept all of TLS v1.2, v1.1 and
2274+ v1.0, rather than only only one version of the protocol. It is still
2275+ possible to restrict a listener to a single version of TLS.
2276+- The Python client has been removed now that the Eclipse Paho Python client
2277+ has had a release.
2278+- When a durable client reconnects, its queued messages are now checked
2279+ against ACLs in case of a change in username/ACL state since it last
2280+ connected.
2281+- New use_username_as_clientid option on the broker, for preventing hijacking
2282+ of a client id.
2283+- The client library and clients now have experimental SOCKS5 support.
2284+- Wildcard TLS certificates are now supported for bridges and clients.
2285+- The clients have support for config files with default options.
2286+- Client and client libraries have support for MQTT v3.1.1.
2287+- Bridge support for MQTT v3.1.1.
2288+
2289+
2290+Broker:
2291+- Websockets support in the broker.
2292+- Add local_clientid, local_username, local_password for bridge connections to
2293+ authenticate to the local broker.
2294+- Default TLS mode now accepts TLS v1.2, v1.1 and v1.0.
2295+- Support for ECDHE-ECDSA family ciphers.
2296+- Fix bug #1324411, which could have had unexpected consequences for delayed
2297+ messages in rare circumstances.
2298+- Add support for "session present" in CONNACK messages for MQTT v3.1.1.
2299+- Remove strict protocol #ifdefs.
2300+- Change $SYS/broker/clients/active -> $SYS/broker/clients/connected
2301+- Change $SYS/broker/clients/inactive -> $SYS/broker/clients/disconnected
2302+- When a durable client reconnects, its queued messages are now checked
2303+ against ACLs in case of a change in username/ACL state since it last
2304+ connected.
2305+- libuuid is used to generate client ids, where it is available, when an MQTT
2306+ v3.1.1 client connects with a zero length client id.
2307+- Anonymous clients are no longer accidently disconnected from the broker
2308+ after a SIGHUP.
2309+- mosquitto_passwd now supports -b (batch mode) to allow the password to be
2310+ provided at the command line.
2311+- Removed $SYS/broker/changeset. This was intended for use with debugging, but
2312+ in practice is of no use.
2313+- Add support for use_username_as_clientid which can be used with
2314+ authentication to restrict ownership of client ids and hence prevent one
2315+ client disconnecting another by using the same client id.
2316+- When "require_certificate" was false, the broker was incorrectly asking for
2317+ a certificate (but not checking it). This caused problems with some clients
2318+ and has been fixed so the broker no longer asks.
2319+- When using syslog logging on non-Windows OSs, it is now possible to specify
2320+ the logging facility to one of local0-7 instead of the default "daemon".
2321+- The bridge_attempt_unsubscribe option has been added, to allow the sending
2322+ of UNSUBSCRIBE requests to be disabled for topics with "out" direction.
2323+ Closes bug #456899.
2324+- Wildcard TLS certificates are now supported for bridges.
2325+- Support for "hour" client expiration lengths for the
2326+ persistent_client_expiration option. Closes bug #425835.
2327+- Bridge support for MQTT v3.1.1.
2328+- Root privileges are now dropped after starting listeners and loading
2329+ certificates/private keys, to allow private keys to have their permissions
2330+ restricted to the root user only. Closes bug #452914.
2331+- Usernames and topics given in ACL files can now include a space. Closes bug
2332+ #431780.
2333+- Fix hang if pattern acl contains a %u but an anonymous client connect.
2334+ Closes bug #455402.
2335+- Fix man page installation with cmake. Closes bug #458843.
2336+- When using "log_dest file" the output file is now flushed periodically.
2337+
2338+Clients:
2339+- Both clients can now load default configuration options from a file.
2340+- Add -C option to mosquitto_sub to allow the client to quit after receiving a
2341+ certain count of messages. Closes bug #453850.
2342+- Add --proxy SOCKS5 support for both clients.
2343+- Pub client supports setting its keepalive. Closes bug #454852.
2344+- Add support for config files with default options.
2345+- Add support for MQTT v3.1.1.
2346+
2347+Client library:
2348+- Add experimental SOCKS5 support.
2349+- mosquitto_loop_forever now quits after a fatal error, rather than blindly
2350+ retrying.
2351+- SRV support is now not compiled in by default.
2352+- Wildcard TLS certificates are now supported.
2353+- mosquittopp now has a virtual destructor. Closes bug #452915.
2354+- Add support for MQTT v3.1.1.
2355+- Don't quit mosquitto_loop_forever() if broker not available on first
2356+ connect. Closes bug #453293, but requires more work.
2357+
2358+
2359+1.3.5 - 20141008
2360+================
2361+
2362+Broker:
2363+- Fix possible memory leak when using a topic that has a leading slash. Fixes
2364+ bug #1360985.
2365+- Fix saving persistent database on Windows.
2366+- Temporarily disable ACL checks on subscriptions when using MQTT v3.1.1. This
2367+ is due to the complexity of checking wildcard ACLs against wildcard
2368+ subscriptions. This does not have a negative impact on security because
2369+ checks are still made before a message is sent to a client.
2370+ Fixes bug #1374291.
2371+- When using -v and the broker receives a SIGHUP, verbose logging was being
2372+ disabled. This has been fixed.
2373+
2374+Client library:
2375+- Fix mutex being incorrectly passed by value. Fixes bug #1373785.
2376+
2377 1.3.4 - 20140806
2378 ================
2379
2380 Broker:
2381-- Don't ask client for certificate when require_certificate is true.
2382+- Don't ask client for certificate when require_certificate is false.
2383 - Backout incomplete functionality that was incorrectly included in 1.3.2.
2384
2385 1.3.3 - 20140801
2386@@ -11,7 +123,6 @@
2387 Broker:
2388 - Fix incorrect handling of anonymous bridges on the local broker.
2389
2390-
2391 1.3.2 - 20140713
2392 ================
2393
2394@@ -26,16 +137,17 @@
2395 - When a durable client reconnects, its queued messages are now checked
2396 against ACLs in case of a change in username/ACL state since it last
2397 connected.
2398+- Fix bug #1324411, which could have had unexpected consequences for delayed
2399+ messages in rare circumstances.
2400 - Anonymous clients are no longer accidently disconnected from the broker
2401 after a SIGHUP.
2402-- Fix bug #1324411, which could have had unexpected consequences for delayed
2403- messages in rare circumstances.
2404
2405 Client library:
2406 - Fix topic matching edge case.
2407 - Fix callback deadlocks after calling mosquitto_disconnect(), when using the
2408 threaded interfaces. Closes bug #1313725.
2409 - Fix SRV support when building with CMake.
2410+- Remove strict protocol #ifdefs.
2411
2412 General:
2413 - Use $(STRIP) for stripping binaries when installing, to allow easier cross
2414@@ -58,6 +170,7 @@
2415 - Fix compilation for WITH_THREADING=no.
2416 - Break out of select() when calling mosquitto_loop_stop().
2417 - Reject invalid un/subscriptions e.g. foo/+bar #/bar.
2418+- Add mosquitto_threaded_set().
2419
2420 Clients:
2421 - Fix keepalive value on mosquitto_pub.
2422
2423=== removed file 'LICENSE-3rd-party.txt'
2424--- LICENSE-3rd-party.txt 2013-08-07 23:26:19 +0000
2425+++ LICENSE-3rd-party.txt 1970-01-01 00:00:00 +0000
2426@@ -1,666 +0,0 @@
2427-============================================================================
2428-uthash.h license
2429-============================================================================
2430-
2431-Copyright (c) 2005-2010, Troy D. Hanson http://uthash.sourceforge.net
2432-All rights reserved.
2433-
2434-Redistribution and use in source and binary forms, with or without
2435-modification, are permitted provided that the following conditions are met:
2436-
2437- * Redistributions of source code must retain the above copyright
2438- notice, this list of conditions and the following disclaimer.
2439-
2440-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
2441-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2442-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
2443-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
2444-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2445-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2446-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2447-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
2448-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2449-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2450-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2451-
2452-
2453-
2454-============================================================================
2455-OpenSSL license
2456-============================================================================
2457-
2458- LICENSE ISSUES
2459- ==============
2460-
2461- The OpenSSL toolkit stays under a dual license, i.e. both the conditions of
2462- the OpenSSL License and the original SSLeay license apply to the toolkit.
2463- See below for the actual license texts. Actually both licenses are BSD-style
2464- Open Source licenses. In case of any license issues related to OpenSSL
2465- please contact openssl-core@openssl.org.
2466-
2467- OpenSSL License
2468- ---------------
2469-
2470-/* ====================================================================
2471- * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
2472- *
2473- * Redistribution and use in source and binary forms, with or without
2474- * modification, are permitted provided that the following conditions
2475- * are met:
2476- *
2477- * 1. Redistributions of source code must retain the above copyright
2478- * notice, this list of conditions and the following disclaimer.
2479- *
2480- * 2. Redistributions in binary form must reproduce the above copyright
2481- * notice, this list of conditions and the following disclaimer in
2482- * the documentation and/or other materials provided with the
2483- * distribution.
2484- *
2485- * 3. All advertising materials mentioning features or use of this
2486- * software must display the following acknowledgment:
2487- * "This product includes software developed by the OpenSSL Project
2488- * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
2489- *
2490- * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
2491- * endorse or promote products derived from this software without
2492- * prior written permission. For written permission, please contact
2493- * openssl-core@openssl.org.
2494- *
2495- * 5. Products derived from this software may not be called "OpenSSL"
2496- * nor may "OpenSSL" appear in their names without prior written
2497- * permission of the OpenSSL Project.
2498- *
2499- * 6. Redistributions of any form whatsoever must retain the following
2500- * acknowledgment:
2501- * "This product includes software developed by the OpenSSL Project
2502- * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
2503- *
2504- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
2505- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2506- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2507- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
2508- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2509- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2510- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2511- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2512- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
2513- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2514- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
2515- * OF THE POSSIBILITY OF SUCH DAMAGE.
2516- * ====================================================================
2517- *
2518- * This product includes cryptographic software written by Eric Young
2519- * (eay@cryptsoft.com). This product includes software written by Tim
2520- * Hudson (tjh@cryptsoft.com).
2521- *
2522- */
2523-
2524- Original SSLeay License
2525- -----------------------
2526-
2527-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
2528- * All rights reserved.
2529- *
2530- * This package is an SSL implementation written
2531- * by Eric Young (eay@cryptsoft.com).
2532- * The implementation was written so as to conform with Netscapes SSL.
2533- *
2534- * This library is free for commercial and non-commercial use as long as
2535- * the following conditions are aheared to. The following conditions
2536- * apply to all code found in this distribution, be it the RC4, RSA,
2537- * lhash, DES, etc., code; not just the SSL code. The SSL documentation
2538- * included with this distribution is covered by the same copyright terms
2539- * except that the holder is Tim Hudson (tjh@cryptsoft.com).
2540- *
2541- * Copyright remains Eric Young's, and as such any Copyright notices in
2542- * the code are not to be removed.
2543- * If this package is used in a product, Eric Young should be given attribution
2544- * as the author of the parts of the library used.
2545- * This can be in the form of a textual message at program startup or
2546- * in documentation (online or textual) provided with the package.
2547- *
2548- * Redistribution and use in source and binary forms, with or without
2549- * modification, are permitted provided that the following conditions
2550- * are met:
2551- * 1. Redistributions of source code must retain the copyright
2552- * notice, this list of conditions and the following disclaimer.
2553- * 2. Redistributions in binary form must reproduce the above copyright
2554- * notice, this list of conditions and the following disclaimer in the
2555- * documentation and/or other materials provided with the distribution.
2556- * 3. All advertising materials mentioning features or use of this software
2557- * must display the following acknowledgement:
2558- * "This product includes cryptographic software written by
2559- * Eric Young (eay@cryptsoft.com)"
2560- * The word 'cryptographic' can be left out if the rouines from the library
2561- * being used are not cryptographic related :-).
2562- * 4. If you include any Windows specific code (or a derivative thereof) from
2563- * the apps directory (application code) you must include an acknowledgement:
2564- * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
2565- *
2566- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
2567- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2568- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2569- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2570- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2571- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2572- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2573- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2574- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2575- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2576- * SUCH DAMAGE.
2577- *
2578- * The licence and distribution terms for any publically available version or
2579- * derivative of this code cannot be changed. i.e. this code cannot simply be
2580- * copied and put under another distribution licence
2581- * [including the GNU Public Licence.]
2582- */
2583-
2584-
2585-
2586-============================================================================
2587-pthreads-win32 license
2588-============================================================================
2589-
2590- GNU LESSER GENERAL PUBLIC LICENSE
2591- Version 2.1, February 1999
2592-
2593- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
2594- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2595- Everyone is permitted to copy and distribute verbatim copies
2596- of this license document, but changing it is not allowed.
2597-
2598-[This is the first released version of the Lesser GPL. It also counts
2599- as the successor of the GNU Library Public License, version 2, hence
2600- the version number 2.1.]
2601-
2602- Preamble
2603-
2604- The licenses for most software are designed to take away your
2605-freedom to share and change it. By contrast, the GNU General Public
2606-Licenses are intended to guarantee your freedom to share and change
2607-free software--to make sure the software is free for all its users.
2608-
2609- This license, the Lesser General Public License, applies to some
2610-specially designated software packages--typically libraries--of the
2611-Free Software Foundation and other authors who decide to use it. You
2612-can use it too, but we suggest you first think carefully about whether
2613-this license or the ordinary General Public License is the better
2614-strategy to use in any particular case, based on the explanations below.
2615-
2616- When we speak of free software, we are referring to freedom of use,
2617-not price. Our General Public Licenses are designed to make sure that
2618-you have the freedom to distribute copies of free software (and charge
2619-for this service if you wish); that you receive source code or can get
2620-it if you want it; that you can change the software and use pieces of
2621-it in new free programs; and that you are informed that you can do
2622-these things.
2623-
2624- To protect your rights, we need to make restrictions that forbid
2625-distributors to deny you these rights or to ask you to surrender these
2626-rights. These restrictions translate to certain responsibilities for
2627-you if you distribute copies of the library or if you modify it.
2628-
2629- For example, if you distribute copies of the library, whether gratis
2630-or for a fee, you must give the recipients all the rights that we gave
2631-you. You must make sure that they, too, receive or can get the source
2632-code. If you link other code with the library, you must provide
2633-complete object files to the recipients, so that they can relink them
2634-with the library after making changes to the library and recompiling
2635-it. And you must show them these terms so they know their rights.
2636-
2637- We protect your rights with a two-step method: (1) we copyright the
2638-library, and (2) we offer you this license, which gives you legal
2639-permission to copy, distribute and/or modify the library.
2640-
2641- To protect each distributor, we want to make it very clear that
2642-there is no warranty for the free library. Also, if the library is
2643-modified by someone else and passed on, the recipients should know
2644-that what they have is not the original version, so that the original
2645-author's reputation will not be affected by problems that might be
2646-introduced by others.
2647-
2648
2649- Finally, software patents pose a constant threat to the existence of
2650-any free program. We wish to make sure that a company cannot
2651-effectively restrict the users of a free program by obtaining a
2652-restrictive license from a patent holder. Therefore, we insist that
2653-any patent license obtained for a version of the library must be
2654-consistent with the full freedom of use specified in this license.
2655-
2656- Most GNU software, including some libraries, is covered by the
2657-ordinary GNU General Public License. This license, the GNU Lesser
2658-General Public License, applies to certain designated libraries, and
2659-is quite different from the ordinary General Public License. We use
2660-this license for certain libraries in order to permit linking those
2661-libraries into non-free programs.
2662-
2663- When a program is linked with a library, whether statically or using
2664-a shared library, the combination of the two is legally speaking a
2665-combined work, a derivative of the original library. The ordinary
2666-General Public License therefore permits such linking only if the
2667-entire combination fits its criteria of freedom. The Lesser General
2668-Public License permits more lax criteria for linking other code with
2669-the library.
2670-
2671- We call this license the "Lesser" General Public License because it
2672-does Less to protect the user's freedom than the ordinary General
2673-Public License. It also provides other free software developers Less
2674-of an advantage over competing non-free programs. These disadvantages
2675-are the reason we use the ordinary General Public License for many
2676-libraries. However, the Lesser license provides advantages in certain
2677-special circumstances.
2678-
2679- For example, on rare occasions, there may be a special need to
2680-encourage the widest possible use of a certain library, so that it becomes
2681-a de-facto standard. To achieve this, non-free programs must be
2682-allowed to use the library. A more frequent case is that a free
2683-library does the same job as widely used non-free libraries. In this
2684-case, there is little to gain by limiting the free library to free
2685-software only, so we use the Lesser General Public License.
2686-
2687- In other cases, permission to use a particular library in non-free
2688-programs enables a greater number of people to use a large body of
2689-free software. For example, permission to use the GNU C Library in
2690-non-free programs enables many more people to use the whole GNU
2691-operating system, as well as its variant, the GNU/Linux operating
2692-system.
2693-
2694- Although the Lesser General Public License is Less protective of the
2695-users' freedom, it does ensure that the user of a program that is
2696-linked with the Library has the freedom and the wherewithal to run
2697-that program using a modified version of the Library.
2698-
2699- The precise terms and conditions for copying, distribution and
2700-modification follow. Pay close attention to the difference between a
2701-"work based on the library" and a "work that uses the library". The
2702-former contains code derived from the library, whereas the latter must
2703-be combined with the library in order to run.
2704-
2705
2706- GNU LESSER GENERAL PUBLIC LICENSE
2707- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
2708-
2709- 0. This License Agreement applies to any software library or other
2710-program which contains a notice placed by the copyright holder or
2711-other authorized party saying it may be distributed under the terms of
2712-this Lesser General Public License (also called "this License").
2713-Each licensee is addressed as "you".
2714-
2715- A "library" means a collection of software functions and/or data
2716-prepared so as to be conveniently linked with application programs
2717-(which use some of those functions and data) to form executables.
2718-
2719- The "Library", below, refers to any such software library or work
2720-which has been distributed under these terms. A "work based on the
2721-Library" means either the Library or any derivative work under
2722-copyright law: that is to say, a work containing the Library or a
2723-portion of it, either verbatim or with modifications and/or translated
2724-straightforwardly into another language. (Hereinafter, translation is
2725-included without limitation in the term "modification".)
2726-
2727- "Source code" for a work means the preferred form of the work for
2728-making modifications to it. For a library, complete source code means
2729-all the source code for all modules it contains, plus any associated
2730-interface definition files, plus the scripts used to control compilation
2731-and installation of the library.
2732-
2733- Activities other than copying, distribution and modification are not
2734-covered by this License; they are outside its scope. The act of
2735-running a program using the Library is not restricted, and output from
2736-such a program is covered only if its contents constitute a work based
2737-on the Library (independent of the use of the Library in a tool for
2738-writing it). Whether that is true depends on what the Library does
2739-and what the program that uses the Library does.
2740-
2741- 1. You may copy and distribute verbatim copies of the Library's
2742-complete source code as you receive it, in any medium, provided that
2743-you conspicuously and appropriately publish on each copy an
2744-appropriate copyright notice and disclaimer of warranty; keep intact
2745-all the notices that refer to this License and to the absence of any
2746-warranty; and distribute a copy of this License along with the
2747-Library.
2748-
2749- You may charge a fee for the physical act of transferring a copy,
2750-and you may at your option offer warranty protection in exchange for a
2751-fee.
2752-
2753
2754- 2. You may modify your copy or copies of the Library or any portion
2755-of it, thus forming a work based on the Library, and copy and
2756-distribute such modifications or work under the terms of Section 1
2757-above, provided that you also meet all of these conditions:
2758-
2759- a) The modified work must itself be a software library.
2760-
2761- b) You must cause the files modified to carry prominent notices
2762- stating that you changed the files and the date of any change.
2763-
2764- c) You must cause the whole of the work to be licensed at no
2765- charge to all third parties under the terms of this License.
2766-
2767- d) If a facility in the modified Library refers to a function or a
2768- table of data to be supplied by an application program that uses
2769- the facility, other than as an argument passed when the facility
2770- is invoked, then you must make a good faith effort to ensure that,
2771- in the event an application does not supply such function or
2772- table, the facility still operates, and performs whatever part of
2773- its purpose remains meaningful.
2774-
2775- (For example, a function in a library to compute square roots has
2776- a purpose that is entirely well-defined independent of the
2777- application. Therefore, Subsection 2d requires that any
2778- application-supplied function or table used by this function must
2779- be optional: if the application does not supply it, the square
2780- root function must still compute square roots.)
2781-
2782-These requirements apply to the modified work as a whole. If
2783-identifiable sections of that work are not derived from the Library,
2784-and can be reasonably considered independent and separate works in
2785-themselves, then this License, and its terms, do not apply to those
2786-sections when you distribute them as separate works. But when you
2787-distribute the same sections as part of a whole which is a work based
2788-on the Library, the distribution of the whole must be on the terms of
2789-this License, whose permissions for other licensees extend to the
2790-entire whole, and thus to each and every part regardless of who wrote
2791-it.
2792-
2793-Thus, it is not the intent of this section to claim rights or contest
2794-your rights to work written entirely by you; rather, the intent is to
2795-exercise the right to control the distribution of derivative or
2796-collective works based on the Library.
2797-
2798-In addition, mere aggregation of another work not based on the Library
2799-with the Library (or with a work based on the Library) on a volume of
2800-a storage or distribution medium does not bring the other work under
2801-the scope of this License.
2802-
2803- 3. You may opt to apply the terms of the ordinary GNU General Public
2804-License instead of this License to a given copy of the Library. To do
2805-this, you must alter all the notices that refer to this License, so
2806-that they refer to the ordinary GNU General Public License, version 2,
2807-instead of to this License. (If a newer version than version 2 of the
2808-ordinary GNU General Public License has appeared, then you can specify
2809-that version instead if you wish.) Do not make any other change in
2810-these notices.
2811-
2812
2813- Once this change is made in a given copy, it is irreversible for
2814-that copy, so the ordinary GNU General Public License applies to all
2815-subsequent copies and derivative works made from that copy.
2816-
2817- This option is useful when you wish to copy part of the code of
2818-the Library into a program that is not a library.
2819-
2820- 4. You may copy and distribute the Library (or a portion or
2821-derivative of it, under Section 2) in object code or executable form
2822-under the terms of Sections 1 and 2 above provided that you accompany
2823-it with the complete corresponding machine-readable source code, which
2824-must be distributed under the terms of Sections 1 and 2 above on a
2825-medium customarily used for software interchange.
2826-
2827- If distribution of object code is made by offering access to copy
2828-from a designated place, then offering equivalent access to copy the
2829-source code from the same place satisfies the requirement to
2830-distribute the source code, even though third parties are not
2831-compelled to copy the source along with the object code.
2832-
2833- 5. A program that contains no derivative of any portion of the
2834-Library, but is designed to work with the Library by being compiled or
2835-linked with it, is called a "work that uses the Library". Such a
2836-work, in isolation, is not a derivative work of the Library, and
2837-therefore falls outside the scope of this License.
2838-
2839- However, linking a "work that uses the Library" with the Library
2840-creates an executable that is a derivative of the Library (because it
2841-contains portions of the Library), rather than a "work that uses the
2842-library". The executable is therefore covered by this License.
2843-Section 6 states terms for distribution of such executables.
2844-
2845- When a "work that uses the Library" uses material from a header file
2846-that is part of the Library, the object code for the work may be a
2847-derivative work of the Library even though the source code is not.
2848-Whether this is true is especially significant if the work can be
2849-linked without the Library, or if the work is itself a library. The
2850-threshold for this to be true is not precisely defined by law.
2851-
2852- If such an object file uses only numerical parameters, data
2853-structure layouts and accessors, and small macros and small inline
2854-functions (ten lines or less in length), then the use of the object
2855-file is unrestricted, regardless of whether it is legally a derivative
2856-work. (Executables containing this object code plus portions of the
2857-Library will still fall under Section 6.)
2858-
2859- Otherwise, if the work is a derivative of the Library, you may
2860-distribute the object code for the work under the terms of Section 6.
2861-Any executables containing that work also fall under Section 6,
2862-whether or not they are linked directly with the Library itself.
2863-
2864
2865- 6. As an exception to the Sections above, you may also combine or
2866-link a "work that uses the Library" with the Library to produce a
2867-work containing portions of the Library, and distribute that work
2868-under terms of your choice, provided that the terms permit
2869-modification of the work for the customer's own use and reverse
2870-engineering for debugging such modifications.
2871-
2872- You must give prominent notice with each copy of the work that the
2873-Library is used in it and that the Library and its use are covered by
2874-this License. You must supply a copy of this License. If the work
2875-during execution displays copyright notices, you must include the
2876-copyright notice for the Library among them, as well as a reference
2877-directing the user to the copy of this License. Also, you must do one
2878-of these things:
2879-
2880- a) Accompany the work with the complete corresponding
2881- machine-readable source code for the Library including whatever
2882- changes were used in the work (which must be distributed under
2883- Sections 1 and 2 above); and, if the work is an executable linked
2884- with the Library, with the complete machine-readable "work that
2885- uses the Library", as object code and/or source code, so that the
2886- user can modify the Library and then relink to produce a modified
2887- executable containing the modified Library. (It is understood
2888- that the user who changes the contents of definitions files in the
2889- Library will not necessarily be able to recompile the application
2890- to use the modified definitions.)
2891-
2892- b) Use a suitable shared library mechanism for linking with the
2893- Library. A suitable mechanism is one that (1) uses at run time a
2894- copy of the library already present on the user's computer system,
2895- rather than copying library functions into the executable, and (2)
2896- will operate properly with a modified version of the library, if
2897- the user installs one, as long as the modified version is
2898- interface-compatible with the version that the work was made with.
2899-
2900- c) Accompany the work with a written offer, valid for at
2901- least three years, to give the same user the materials
2902- specified in Subsection 6a, above, for a charge no more
2903- than the cost of performing this distribution.
2904-
2905- d) If distribution of the work is made by offering access to copy
2906- from a designated place, offer equivalent access to copy the above
2907- specified materials from the same place.
2908-
2909- e) Verify that the user has already received a copy of these
2910- materials or that you have already sent this user a copy.
2911-
2912- For an executable, the required form of the "work that uses the
2913-Library" must include any data and utility programs needed for
2914-reproducing the executable from it. However, as a special exception,
2915-the materials to be distributed need not include anything that is
2916-normally distributed (in either source or binary form) with the major
2917-components (compiler, kernel, and so on) of the operating system on
2918-which the executable runs, unless that component itself accompanies
2919-the executable.
2920-
2921- It may happen that this requirement contradicts the license
2922-restrictions of other proprietary libraries that do not normally
2923-accompany the operating system. Such a contradiction means you cannot
2924-use both them and the Library together in an executable that you
2925-distribute.
2926-
2927
2928- 7. You may place library facilities that are a work based on the
2929-Library side-by-side in a single library together with other library
2930-facilities not covered by this License, and distribute such a combined
2931-library, provided that the separate distribution of the work based on
2932-the Library and of the other library facilities is otherwise
2933-permitted, and provided that you do these two things:
2934-
2935- a) Accompany the combined library with a copy of the same work
2936- based on the Library, uncombined with any other library
2937- facilities. This must be distributed under the terms of the
2938- Sections above.
2939-
2940- b) Give prominent notice with the combined library of the fact
2941- that part of it is a work based on the Library, and explaining
2942- where to find the accompanying uncombined form of the same work.
2943-
2944- 8. You may not copy, modify, sublicense, link with, or distribute
2945-the Library except as expressly provided under this License. Any
2946-attempt otherwise to copy, modify, sublicense, link with, or
2947-distribute the Library is void, and will automatically terminate your
2948-rights under this License. However, parties who have received copies,
2949-or rights, from you under this License will not have their licenses
2950-terminated so long as such parties remain in full compliance.
2951-
2952- 9. You are not required to accept this License, since you have not
2953-signed it. However, nothing else grants you permission to modify or
2954-distribute the Library or its derivative works. These actions are
2955-prohibited by law if you do not accept this License. Therefore, by
2956-modifying or distributing the Library (or any work based on the
2957-Library), you indicate your acceptance of this License to do so, and
2958-all its terms and conditions for copying, distributing or modifying
2959-the Library or works based on it.
2960-
2961- 10. Each time you redistribute the Library (or any work based on the
2962-Library), the recipient automatically receives a license from the
2963-original licensor to copy, distribute, link with or modify the Library
2964-subject to these terms and conditions. You may not impose any further
2965-restrictions on the recipients' exercise of the rights granted herein.
2966-You are not responsible for enforcing compliance by third parties with
2967-this License.
2968-
2969
2970- 11. If, as a consequence of a court judgment or allegation of patent
2971-infringement or for any other reason (not limited to patent issues),
2972-conditions are imposed on you (whether by court order, agreement or
2973-otherwise) that contradict the conditions of this License, they do not
2974-excuse you from the conditions of this License. If you cannot
2975-distribute so as to satisfy simultaneously your obligations under this
2976-License and any other pertinent obligations, then as a consequence you
2977-may not distribute the Library at all. For example, if a patent
2978-license would not permit royalty-free redistribution of the Library by
2979-all those who receive copies directly or indirectly through you, then
2980-the only way you could satisfy both it and this License would be to
2981-refrain entirely from distribution of the Library.
2982-
2983-If any portion of this section is held invalid or unenforceable under any
2984-particular circumstance, the balance of the section is intended to apply,
2985-and the section as a whole is intended to apply in other circumstances.
2986-
2987-It is not the purpose of this section to induce you to infringe any
2988-patents or other property right claims or to contest validity of any
2989-such claims; this section has the sole purpose of protecting the
2990-integrity of the free software distribution system which is
2991-implemented by public license practices. Many people have made
2992-generous contributions to the wide range of software distributed
2993-through that system in reliance on consistent application of that
2994-system; it is up to the author/donor to decide if he or she is willing
2995-to distribute software through any other system and a licensee cannot
2996-impose that choice.
2997-
2998-This section is intended to make thoroughly clear what is believed to
2999-be a consequence of the rest of this License.
3000-
3001- 12. If the distribution and/or use of the Library is restricted in
3002-certain countries either by patents or by copyrighted interfaces, the
3003-original copyright holder who places the Library under this License may add
3004-an explicit geographical distribution limitation excluding those countries,
3005-so that distribution is permitted only in or among countries not thus
3006-excluded. In such case, this License incorporates the limitation as if
3007-written in the body of this License.
3008-
3009- 13. The Free Software Foundation may publish revised and/or new
3010-versions of the Lesser General Public License from time to time.
3011-Such new versions will be similar in spirit to the present version,
3012-but may differ in detail to address new problems or concerns.
3013-
3014-Each version is given a distinguishing version number. If the Library
3015-specifies a version number of this License which applies to it and
3016-"any later version", you have the option of following the terms and
3017-conditions either of that version or of any later version published by
3018-the Free Software Foundation. If the Library does not specify a
3019-license version number, you may choose any version ever published by
3020-the Free Software Foundation.
3021-
3022
3023- 14. If you wish to incorporate parts of the Library into other free
3024-programs whose distribution conditions are incompatible with these,
3025-write to the author to ask for permission. For software which is
3026-copyrighted by the Free Software Foundation, write to the Free
3027-Software Foundation; we sometimes make exceptions for this. Our
3028-decision will be guided by the two goals of preserving the free status
3029-of all derivatives of our free software and of promoting the sharing
3030-and reuse of software generally.
3031-
3032- NO WARRANTY
3033-
3034- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
3035-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
3036-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
3037-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
3038-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
3039-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3040-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
3041-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
3042-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
3043-
3044- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
3045-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
3046-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
3047-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
3048-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
3049-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
3050-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
3051-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
3052-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
3053-DAMAGES.
3054-
3055- END OF TERMS AND CONDITIONS
3056-
3057
3058- How to Apply These Terms to Your New Libraries
3059-
3060- If you develop a new library, and you want it to be of the greatest
3061-possible use to the public, we recommend making it free software that
3062-everyone can redistribute and change. You can do so by permitting
3063-redistribution under these terms (or, alternatively, under the terms of the
3064-ordinary General Public License).
3065-
3066- To apply these terms, attach the following notices to the library. It is
3067-safest to attach them to the start of each source file to most effectively
3068-convey the exclusion of warranty; and each file should have at least the
3069-"copyright" line and a pointer to where the full notice is found.
3070-
3071- <one line to give the library's name and a brief idea of what it does.>
3072- Copyright (C) <year> <name of author>
3073-
3074- This library is free software; you can redistribute it and/or
3075- modify it under the terms of the GNU Lesser General Public
3076- License as published by the Free Software Foundation; either
3077- version 2.1 of the License, or (at your option) any later version.
3078-
3079- This library is distributed in the hope that it will be useful,
3080- but WITHOUT ANY WARRANTY; without even the implied warranty of
3081- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3082- Lesser General Public License for more details.
3083-
3084- You should have received a copy of the GNU Lesser General Public
3085- License along with this library; if not, write to the Free Software
3086- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3087-
3088-Also add information on how to contact you by electronic and paper mail.
3089-
3090-You should also get your employer (if you work as a programmer) or your
3091-school, if any, to sign a "copyright disclaimer" for the library, if
3092-necessary. Here is a sample; alter the names:
3093-
3094- Yoyodyne, Inc., hereby disclaims all copyright interest in the
3095- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
3096-
3097- <signature of Ty Coon>, 1 April 1990
3098- Ty Coon, President of Vice
3099-
3100-That's all there is to it!
3101-
3102
3103=== modified file 'LICENSE.txt'
3104--- LICENSE.txt 2013-08-07 23:26:19 +0000
3105+++ LICENSE.txt 2015-02-18 20:26:49 +0000
3106@@ -1,54 +1,2 @@
3107-Copyright (c) 2009-2012 Roger Light <roger@atchoo.org>
3108-All rights reserved.
3109-
3110-Redistribution and use in source and binary forms, with or without
3111-modification, are permitted provided that the following conditions are met:
3112-
3113-1. Redistributions of source code must retain the above copyright notice,
3114- this list of conditions and the following disclaimer.
3115-2. Redistributions in binary form must reproduce the above copyright
3116- notice, this list of conditions and the following disclaimer in the
3117- documentation and/or other materials provided with the distribution.
3118-3. Neither the name of mosquitto nor the names of its
3119- contributors may be used to endorse or promote products derived from
3120- this software without specific prior written permission.
3121-
3122-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3123-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3124-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3125-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
3126-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3127-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3128-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3129-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3130-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3131-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3132-POSSIBILITY OF SUCH DAMAGE.
3133-
3134-
3135-
3136-
3137-
3138-uthash.h license:
3139-
3140-Copyright (c) 2005-2010, Troy D. Hanson http://uthash.sourceforge.net
3141-All rights reserved.
3142-
3143-Redistribution and use in source and binary forms, with or without
3144-modification, are permitted provided that the following conditions are met:
3145-
3146- * Redistributions of source code must retain the above copyright
3147- notice, this list of conditions and the following disclaimer.
3148-
3149-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
3150-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
3151-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
3152-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
3153-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3154-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3155-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
3156-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
3157-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3158-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3159-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3160-
3161+This project is dual licensed under the Eclipse Public License 1.0 and the
3162+Eclipse Distribution License 1.0 as described in the epl-v10 and edl-v10 files.
3163
3164=== modified file 'Makefile'
3165--- Makefile 2015-01-15 14:08:09 +0000
3166+++ Makefile 2015-02-18 20:26:49 +0000
3167@@ -6,7 +6,7 @@
3168
3169 .PHONY : all mosquitto docs binary clean reallyclean test install uninstall dist sign copy
3170
3171-all : mosquitto docs
3172+all : $(MAKE_ALL)
3173
3174 docs :
3175 set -e; for d in ${DOCDIRS}; do $(MAKE) -C $${d}; done
3176@@ -14,6 +14,10 @@
3177 binary : mosquitto
3178
3179 mosquitto :
3180+ifeq ($(UNAME),Darwin)
3181+ $(error Please compile using CMake on Mac OS X)
3182+endif
3183+
3184 set -e; for d in ${DIRS}; do $(MAKE) -C $${d}; done
3185
3186 clean :
3187@@ -38,8 +42,6 @@
3188 $(INSTALL) -m 644 aclfile.example ${DESTDIR}/etc/mosquitto/aclfile.example
3189 $(INSTALL) -m 644 pwfile.example ${DESTDIR}/etc/mosquitto/pwfile.example
3190 $(INSTALL) -m 644 pskfile.example ${DESTDIR}/etc/mosquitto/pskfile.example
3191- $(INSTALL) -d ${DESTDIR}/etc/apparmor.d
3192- $(INSTALL) -m 644 security/mosquitto.apparmor ${DESTDIR}/etc/apparmor.d/usr.sbin.mosquitto
3193
3194 uninstall :
3195 set -e; for d in ${DIRS}; do $(MAKE) -C $${d} uninstall; done
3196@@ -51,9 +53,8 @@
3197 dist : reallyclean
3198 set -e; for d in ${DISTDIRS}; do $(MAKE) -C $${d} dist; done
3199
3200- echo $$(hg log -r . --template "{node}") > changeset
3201 mkdir -p dist/mosquitto-${VERSION}
3202- cp -r client changeset examples installer lib logo man misc security service src test ChangeLog.txt CMakeLists.txt LICENSE.txt LICENSE-3rd-party.txt Makefile compiling.txt config.h config.mk readme.txt readme-windows.txt mosquitto.conf aclfile.example pskfile.example pwfile.example dist/mosquitto-${VERSION}/
3203+ cp -r client examples installer lib logo man misc security service src test about.html aclfile.example ChangeLog.txt CMakeLists.txt compiling.txt config.h config.mk CONTRIBUTING.md edl-v10 epl-v10 LICENSE.txt Makefile mosquitto.conf notice.html pskfile.example pwfile.example readme.txt readme-windows.txt dist/mosquitto-${VERSION}/
3204 cd dist; tar -zcf mosquitto-${VERSION}.tar.gz mosquitto-${VERSION}/
3205 set -e; for m in man/*.xml; \
3206 do \
3207
3208=== added file 'about.html'
3209--- about.html 1970-01-01 00:00:00 +0000
3210+++ about.html 2015-02-18 20:26:49 +0000
3211@@ -0,0 +1,41 @@
3212+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3213+<html xmlns="http://www.w3.org/1999/xhtml"><head>
3214+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
3215+<title>About</title>
3216+</head>
3217+<body lang="EN-US">
3218+<h2>About This Content</h2>
3219+
3220+<p><em>May 8, 2014</em></p>
3221+<h3>License</h3>
3222+
3223+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
3224+indicated below, the Content is provided to you under the terms and conditions of the
3225+Eclipse Public License Version 1.0 ("EPL") and Eclipse Distribution License Version 1.0 ("EDL").
3226+A copy of the EPL is available at
3227+<a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
3228+and a copy of the EDL is available at
3229+<a href="http://www.eclipse.org/org/documents/edl-v10.php">http://www.eclipse.org/org/documents/edl-v10.php</a>.
3230+For purposes of the EPL, "Program" will mean the Content.</p>
3231+
3232+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
3233+being redistributed by another party ("Redistributor") and different terms and conditions may
3234+apply to your use of any object code in the Content. Check the Redistributor's license that was
3235+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
3236+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
3237+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
3238+
3239+
3240+ <h3>Third Party Content</h3>
3241+ <p>The Content includes items that have been sourced from third parties as set out below. If you
3242+ did not receive this Content directly from the Eclipse Foundation, the following is provided
3243+ for informational purposes only, and you should look to the Redistributor's license for
3244+ terms and conditions of use.</p>
3245+ <p><em>
3246+ <strong>None</strong> <br><br>
3247+ <br><br>
3248+ </em></p>
3249+
3250+
3251+
3252+</body></html>
3253
3254=== removed file 'changeset'
3255--- changeset 2014-08-06 00:43:39 +0000
3256+++ changeset 1970-01-01 00:00:00 +0000
3257@@ -1,1 +0,0 @@
3258-abbbb585edc5b6b9bb35f2563b957144e5368037
3259
3260=== modified file 'client/CMakeLists.txt'
3261--- client/CMakeLists.txt 2014-08-06 00:43:39 +0000
3262+++ client/CMakeLists.txt 2015-02-18 20:26:49 +0000
3263@@ -2,12 +2,14 @@
3264 ${STDBOOL_H_PATH} ${STDINT_H_PATH})
3265 link_directories(${mosquitto_BINARY_DIR}/lib)
3266
3267+set(shared_src client_shared.c client_shared.h)
3268+
3269 if (${WITH_SRV} STREQUAL ON)
3270 add_definitions("-DWITH_SRV")
3271 endif (${WITH_SRV} STREQUAL ON)
3272
3273-add_executable(mosquitto_pub pub_client.c)
3274-add_executable(mosquitto_sub sub_client.c)
3275+add_executable(mosquitto_pub pub_client.c ${shared_src})
3276+add_executable(mosquitto_sub sub_client.c ${shared_src})
3277
3278 target_link_libraries(mosquitto_pub libmosquitto)
3279 target_link_libraries(mosquitto_sub libmosquitto)
3280
3281=== modified file 'client/Makefile'
3282--- client/Makefile 2014-08-06 00:43:39 +0000
3283+++ client/Makefile 2015-02-18 20:26:49 +0000
3284@@ -4,25 +4,28 @@
3285
3286 all : mosquitto_pub mosquitto_sub
3287
3288-mosquitto_pub : pub_client.o ../lib/libmosquitto.so.${SOVERSION}
3289- ${CC} $< -o $@ ${CLIENT_LDFLAGS}
3290+mosquitto_pub : pub_client.o client_shared.o
3291+ ${CROSS_COMPILE}${CC} $^ -o $@ ${CLIENT_LDFLAGS}
3292
3293-mosquitto_sub : sub_client.o ../lib/libmosquitto.so.${SOVERSION}
3294- ${CC} $< -o $@ ${CLIENT_LDFLAGS}
3295+mosquitto_sub : sub_client.o client_shared.o
3296+ ${CROSS_COMPILE}${CC} $^ -o $@ ${CLIENT_LDFLAGS}
3297
3298 pub_client.o : pub_client.c ../lib/libmosquitto.so.${SOVERSION}
3299- ${CC} -c $< -o $@ ${CLIENT_CFLAGS}
3300+ ${CROSS_COMPILE}${CC} -c $< -o $@ ${CLIENT_CFLAGS}
3301
3302 sub_client.o : sub_client.c ../lib/libmosquitto.so.${SOVERSION}
3303- ${CC} -c $< -o $@ ${CLIENT_CFLAGS}
3304+ ${CROSS_COMPILE}${CC} -c $< -o $@ ${CLIENT_CFLAGS}
3305+
3306+client_shared.o : client_shared.c client_shared.h
3307+ ${CROSS_COMPILE}${CC} -c $< -o $@ ${CLIENT_CFLAGS}
3308
3309 ../lib/libmosquitto.so.${SOVERSION} :
3310 $(MAKE) -C ../lib
3311
3312 install : all
3313 $(INSTALL) -d ${DESTDIR}$(prefix)/bin
3314- $(INSTALL) mosquitto_pub ${DESTDIR}${prefix}/bin/mosquitto_pub
3315- $(INSTALL) mosquitto_sub ${DESTDIR}${prefix}/bin/mosquitto_sub
3316+ $(INSTALL) -s --strip-program=${CROSS_COMPILE}${STRIP} mosquitto_pub ${DESTDIR}${prefix}/bin/mosquitto_pub
3317+ $(INSTALL) -s --strip-program=${CROSS_COMPILE}${STRIP} mosquitto_sub ${DESTDIR}${prefix}/bin/mosquitto_sub
3318
3319 uninstall :
3320 -rm -f ${DESTDIR}${prefix}/bin/mosquitto_pub
3321
3322=== added file 'client/client_shared.c'
3323--- client/client_shared.c 1970-01-01 00:00:00 +0000
3324+++ client/client_shared.c 2015-02-18 20:26:49 +0000
3325@@ -0,0 +1,957 @@
3326+/*
3327+Copyright (c) 2014 Roger Light <roger@atchoo.org>
3328+
3329+All rights reserved. This program and the accompanying materials
3330+are made available under the terms of the Eclipse Public License v1.0
3331+and Eclipse Distribution License v1.0 which accompany this distribution.
3332+
3333+The Eclipse Public License is available at
3334+ http://www.eclipse.org/legal/epl-v10.html
3335+and the Eclipse Distribution License is available at
3336+ http://www.eclipse.org/org/documents/edl-v10.php.
3337+
3338+Contributors:
3339+ Roger Light - initial implementation and documentation.
3340+*/
3341+
3342+
3343+#include <errno.h>
3344+#include <fcntl.h>
3345+#include <stdio.h>
3346+#include <stdlib.h>
3347+#include <string.h>
3348+#ifndef WIN32
3349+#include <unistd.h>
3350+#else
3351+#include <process.h>
3352+#include <winsock2.h>
3353+#define snprintf sprintf_s
3354+#endif
3355+
3356+#include <mosquitto.h>
3357+#include "client_shared.h"
3358+
3359+static int mosquitto__parse_socks_url(struct mosq_config *cfg, char *url);
3360+static int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, char *argv[]);
3361+
3362+void init_config(struct mosq_config *cfg)
3363+{
3364+ memset(cfg, 0, sizeof(*cfg));
3365+ cfg->port = 1883;
3366+ cfg->max_inflight = 20;
3367+ cfg->keepalive = 60;
3368+ cfg->clean_session = true;
3369+ cfg->eol = true;
3370+ cfg->protocol_version = MQTT_PROTOCOL_V31;
3371+}
3372+
3373+void client_config_cleanup(struct mosq_config *cfg)
3374+{
3375+ int i;
3376+ if(cfg->id) free(cfg->id);
3377+ if(cfg->id_prefix) free(cfg->id_prefix);
3378+ if(cfg->host) free(cfg->host);
3379+ if(cfg->file_input) free(cfg->file_input);
3380+ if(cfg->message) free(cfg->message);
3381+ if(cfg->topic) free(cfg->topic);
3382+ if(cfg->bind_address) free(cfg->bind_address);
3383+ if(cfg->username) free(cfg->username);
3384+ if(cfg->password) free(cfg->password);
3385+ if(cfg->will_topic) free(cfg->will_topic);
3386+ if(cfg->will_payload) free(cfg->will_payload);
3387+#ifdef WITH_TLS
3388+ if(cfg->cafile) free(cfg->cafile);
3389+ if(cfg->capath) free(cfg->capath);
3390+ if(cfg->certfile) free(cfg->certfile);
3391+ if(cfg->keyfile) free(cfg->keyfile);
3392+ if(cfg->ciphers) free(cfg->ciphers);
3393+ if(cfg->tls_version) free(cfg->tls_version);
3394+# ifdef WITH_TLS_PSK
3395+ if(cfg->psk) free(cfg->psk);
3396+ if(cfg->psk_identity) free(cfg->psk_identity);
3397+# endif
3398+#endif
3399+ if(cfg->topics){
3400+ for(i=0; i<cfg->topic_count; i++){
3401+ free(cfg->topics[i]);
3402+ }
3403+ free(cfg->topics);
3404+ }
3405+ if(cfg->filter_outs){
3406+ for(i=0; i<cfg->filter_out_count; i++){
3407+ free(cfg->filter_outs[i]);
3408+ }
3409+ free(cfg->filter_outs);
3410+ }
3411+#ifdef WITH_SOCKS
3412+ if(cfg->socks5_host) free(cfg->socks5_host);
3413+ if(cfg->socks5_username) free(cfg->socks5_username);
3414+ if(cfg->socks5_password) free(cfg->socks5_password);
3415+#endif
3416+}
3417+
3418+int client_config_load(struct mosq_config *cfg, int pub_or_sub, int argc, char *argv[])
3419+{
3420+ int rc;
3421+ FILE *fptr;
3422+ char line[1024];
3423+ int count;
3424+ char *loc = NULL;
3425+ int len;
3426+ char *args[3];
3427+
3428+#ifndef WIN32
3429+ char *env;
3430+#else
3431+ char env[1024];
3432+#endif
3433+ args[0] = NULL;
3434+
3435+ init_config(cfg);
3436+
3437+ /* Default config file */
3438+#ifndef WIN32
3439+ env = getenv("XDG_CONFIG_HOME");
3440+ if(env){
3441+ len = strlen(env) + strlen("/mosquitto_pub") + 1;
3442+ loc = malloc(len);
3443+ if(pub_or_sub == CLIENT_PUB){
3444+ snprintf(loc, len, "%s/mosquitto_pub", env);
3445+ }else{
3446+ snprintf(loc, len, "%s/mosquitto_sub", env);
3447+ }
3448+ loc[len-1] = '\0';
3449+ }else{
3450+ env = getenv("HOME");
3451+ if(env){
3452+ len = strlen(env) + strlen("/.config/mosquitto_pub") + 1;
3453+ loc = malloc(len);
3454+ if(pub_or_sub == CLIENT_PUB){
3455+ snprintf(loc, len, "%s/.config/mosquitto_pub", env);
3456+ }else{
3457+ snprintf(loc, len, "%s/.config/mosquitto_sub", env);
3458+ }
3459+ loc[len-1] = '\0';
3460+ }else{
3461+ fprintf(stderr, "Warning: Unable to locate configuration directory, default config not loaded.\n");
3462+ }
3463+ }
3464+
3465+#else
3466+ rc = GetEnvironmentVariable("USERPROFILE", env, 1024);
3467+ if(rc > 0 && rc < 1024){
3468+ len = strlen(env) + strlen("\\mosquitto_pub.conf") + 1;
3469+ loc = malloc(len);
3470+ if(pub_or_sub == CLIENT_PUB){
3471+ snprintf(loc, len, "%s\\mosquitto_pub.conf", env);
3472+ }else{
3473+ snprintf(loc, len, "%s\\mosquitto_sub.conf", env);
3474+ }
3475+ loc[len-1] = '\0';
3476+ }else{
3477+ fprintf(stderr, "Warning: Unable to locate configuration directory, default config not loaded.\n");
3478+ }
3479+#endif
3480+
3481+ if(loc){
3482+ fptr = fopen(loc, "rt");
3483+ if(fptr){
3484+ while(fgets(line, 1024, fptr)){
3485+ if(line[0] == '#') continue; /* Comments */
3486+
3487+ while(line[strlen(line)-1] == 10 || line[strlen(line)-1] == 13){
3488+ line[strlen(line)-1] = 0;
3489+ }
3490+ /* All offset by one "args" here, because real argc/argv has
3491+ * program name as the first entry. */
3492+ args[1] = strtok(line, " ");
3493+ if(args[1]){
3494+ args[2] = strtok(NULL, " ");
3495+ if(args[2]){
3496+ count = 3;
3497+ }else{
3498+ count = 2;
3499+ }
3500+ rc = client_config_line_proc(cfg, pub_or_sub, count, args);
3501+ if(rc){
3502+ fclose(fptr);
3503+ free(loc);
3504+ return rc;
3505+ }
3506+ }
3507+ }
3508+ fclose(fptr);
3509+ }
3510+ free(loc);
3511+ }
3512+
3513+ /* Deal with real argc/argv */
3514+ rc = client_config_line_proc(cfg, pub_or_sub, argc, argv);
3515+ if(rc) return rc;
3516+
3517+ if(cfg->will_payload && !cfg->will_topic){
3518+ fprintf(stderr, "Error: Will payload given, but no will topic given.\n");
3519+ return 1;
3520+ }
3521+ if(cfg->will_retain && !cfg->will_topic){
3522+ fprintf(stderr, "Error: Will retain given, but no will topic given.\n");
3523+ return 1;
3524+ }
3525+ if(cfg->password && !cfg->username){
3526+ if(!cfg->quiet) fprintf(stderr, "Warning: Not using password since username not set.\n");
3527+ }
3528+#ifdef WITH_TLS
3529+ if((cfg->certfile && !cfg->keyfile) || (cfg->keyfile && !cfg->certfile)){
3530+ fprintf(stderr, "Error: Both certfile and keyfile must be provided if one of them is.\n");
3531+ return 1;
3532+ }
3533+#endif
3534+#ifdef WITH_TLS_PSK
3535+ if((cfg->cafile || cfg->capath) && cfg->psk){
3536+ if(!cfg->quiet) fprintf(stderr, "Error: Only one of --psk or --cafile/--capath may be used at once.\n");
3537+ return 1;
3538+ }
3539+ if(cfg->psk && !cfg->psk_identity){
3540+ if(!cfg->quiet) fprintf(stderr, "Error: --psk-identity required if --psk used.\n");
3541+ return 1;
3542+ }
3543+#endif
3544+
3545+ if(pub_or_sub == CLIENT_SUB){
3546+ if(cfg->clean_session == false && (cfg->id_prefix || !cfg->id)){
3547+ if(!cfg->quiet) fprintf(stderr, "Error: You must provide a client id if you are using the -c option.\n");
3548+ return 1;
3549+ }
3550+ if(cfg->topic_count == 0){
3551+ if(!cfg->quiet) fprintf(stderr, "Error: You must specify a topic to subscribe to.\n");
3552+ return 1;
3553+ }
3554+ }
3555+
3556+ if(!cfg->host){
3557+ cfg->host = "localhost";
3558+ }
3559+ return MOSQ_ERR_SUCCESS;
3560+}
3561+
3562+/* Process a tokenised single line from a file or set of real argc/argv */
3563+int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, char *argv[])
3564+{
3565+ int i;
3566+
3567+ for(i=1; i<argc; i++){
3568+ if(!strcmp(argv[i], "-p") || !strcmp(argv[i], "--port")){
3569+ if(i==argc-1){
3570+ fprintf(stderr, "Error: -p argument given but no port specified.\n\n");
3571+ return 1;
3572+ }else{
3573+ cfg->port = atoi(argv[i+1]);
3574+ if(cfg->port<1 || cfg->port>65535){
3575+ fprintf(stderr, "Error: Invalid port given: %d\n", cfg->port);
3576+ return 1;
3577+ }
3578+ }
3579+ i++;
3580+ }else if(!strcmp(argv[i], "-A")){
3581+ if(i==argc-1){
3582+ fprintf(stderr, "Error: -A argument given but no address specified.\n\n");
3583+ return 1;
3584+ }else{
3585+ cfg->bind_address = strdup(argv[i+1]);
3586+ }
3587+ i++;
3588+#ifdef WITH_TLS
3589+ }else if(!strcmp(argv[i], "--cafile")){
3590+ if(i==argc-1){
3591+ fprintf(stderr, "Error: --cafile argument given but no file specified.\n\n");
3592+ return 1;
3593+ }else{
3594+ cfg->cafile = strdup(argv[i+1]);
3595+ }
3596+ i++;
3597+ }else if(!strcmp(argv[i], "--capath")){
3598+ if(i==argc-1){
3599+ fprintf(stderr, "Error: --capath argument given but no directory specified.\n\n");
3600+ return 1;
3601+ }else{
3602+ cfg->capath = strdup(argv[i+1]);
3603+ }
3604+ i++;
3605+ }else if(!strcmp(argv[i], "--cert")){
3606+ if(i==argc-1){
3607+ fprintf(stderr, "Error: --cert argument given but no file specified.\n\n");
3608+ return 1;
3609+ }else{
3610+ cfg->certfile = strdup(argv[i+1]);
3611+ }
3612+ i++;
3613+ }else if(!strcmp(argv[i], "--ciphers")){
3614+ if(i==argc-1){
3615+ fprintf(stderr, "Error: --ciphers argument given but no ciphers specified.\n\n");
3616+ return 1;
3617+ }else{
3618+ cfg->ciphers = strdup(argv[i+1]);
3619+ }
3620+ i++;
3621+#endif
3622+ }else if(!strcmp(argv[i], "-C")){
3623+ if(pub_or_sub == CLIENT_PUB){
3624+ goto unknown_option;
3625+ }else{
3626+ if(i==argc-1){
3627+ fprintf(stderr, "Error: -C argument given but no count specified.\n\n");
3628+ return 1;
3629+ }else{
3630+ cfg->msg_count = atoi(argv[i+1]);
3631+ if(cfg->msg_count < 1){
3632+ fprintf(stderr, "Error: Invalid message count \"%d\".\n\n", cfg->msg_count);
3633+ return 1;
3634+ }
3635+ }
3636+ i++;
3637+ }
3638+ }else if(!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")){
3639+ cfg->debug = true;
3640+ }else if(!strcmp(argv[i], "-f") || !strcmp(argv[i], "--file")){
3641+ if(pub_or_sub == CLIENT_SUB){
3642+ goto unknown_option;
3643+ }
3644+ if(cfg->pub_mode != MSGMODE_NONE){
3645+ fprintf(stderr, "Error: Only one type of message can be sent at once.\n\n");
3646+ return 1;
3647+ }else if(i==argc-1){
3648+ fprintf(stderr, "Error: -f argument given but no file specified.\n\n");
3649+ return 1;
3650+ }else{
3651+ cfg->pub_mode = MSGMODE_FILE;
3652+ cfg->file_input = strdup(argv[i+1]);
3653+ }
3654+ i++;
3655+ }else if(!strcmp(argv[i], "--help")){
3656+ return 2;
3657+ }else if(!strcmp(argv[i], "-h") || !strcmp(argv[i], "--host")){
3658+ if(i==argc-1){
3659+ fprintf(stderr, "Error: -h argument given but no host specified.\n\n");
3660+ return 1;
3661+ }else{
3662+ cfg->host = strdup(argv[i+1]);
3663+ }
3664+ i++;
3665+#ifdef WITH_TLS
3666+ }else if(!strcmp(argv[i], "--insecure")){
3667+ cfg->insecure = true;
3668+#endif
3669+ }else if(!strcmp(argv[i], "-i") || !strcmp(argv[i], "--id")){
3670+ if(cfg->id_prefix){
3671+ fprintf(stderr, "Error: -i and -I argument cannot be used together.\n\n");
3672+ return 1;
3673+ }
3674+ if(i==argc-1){
3675+ fprintf(stderr, "Error: -i argument given but no id specified.\n\n");
3676+ return 1;
3677+ }else{
3678+ cfg->id = strdup(argv[i+1]);
3679+ }
3680+ i++;
3681+ }else if(!strcmp(argv[i], "-I") || !strcmp(argv[i], "--id-prefix")){
3682+ if(cfg->id){
3683+ fprintf(stderr, "Error: -i and -I argument cannot be used together.\n\n");
3684+ return 1;
3685+ }
3686+ if(i==argc-1){
3687+ fprintf(stderr, "Error: -I argument given but no id prefix specified.\n\n");
3688+ return 1;
3689+ }else{
3690+ cfg->id_prefix = strdup(argv[i+1]);
3691+ }
3692+ i++;
3693+ }else if(!strcmp(argv[i], "-k") || !strcmp(argv[i], "--keepalive")){
3694+ if(i==argc-1){
3695+ fprintf(stderr, "Error: -k argument given but no keepalive specified.\n\n");
3696+ return 1;
3697+ }else{
3698+ cfg->keepalive = atoi(argv[i+1]);
3699+ if(cfg->keepalive>65535){
3700+ fprintf(stderr, "Error: Invalid keepalive given: %d\n", cfg->keepalive);
3701+ return 1;
3702+ }
3703+ }
3704+ i++;
3705+#ifdef WITH_TLS
3706+ }else if(!strcmp(argv[i], "--key")){
3707+ if(i==argc-1){
3708+ fprintf(stderr, "Error: --key argument given but no file specified.\n\n");
3709+ return 1;
3710+ }else{
3711+ cfg->keyfile = strdup(argv[i+1]);
3712+ }
3713+ i++;
3714+#endif
3715+ }else if(!strcmp(argv[i], "-l") || !strcmp(argv[i], "--stdin-line")){
3716+ if(pub_or_sub == CLIENT_SUB){
3717+ goto unknown_option;
3718+ }
3719+ if(cfg->pub_mode != MSGMODE_NONE){
3720+ fprintf(stderr, "Error: Only one type of message can be sent at once.\n\n");
3721+ return 1;
3722+ }else{
3723+ cfg->pub_mode = MSGMODE_STDIN_LINE;
3724+ }
3725+ }else if(!strcmp(argv[i], "-m") || !strcmp(argv[i], "--message")){
3726+ if(pub_or_sub == CLIENT_SUB){
3727+ goto unknown_option;
3728+ }
3729+ if(cfg->pub_mode != MSGMODE_NONE){
3730+ fprintf(stderr, "Error: Only one type of message can be sent at once.\n\n");
3731+ return 1;
3732+ }else if(i==argc-1){
3733+ fprintf(stderr, "Error: -m argument given but no message specified.\n\n");
3734+ return 1;
3735+ }else{
3736+ cfg->message = strdup(argv[i+1]);
3737+ cfg->msglen = strlen(cfg->message);
3738+ cfg->pub_mode = MSGMODE_CMD;
3739+ }
3740+ i++;
3741+ }else if(!strcmp(argv[i], "-M")){
3742+ if(i==argc-1){
3743+ fprintf(stderr, "Error: -M argument given but max_inflight not specified.\n\n");
3744+ return 1;
3745+ }else{
3746+ cfg->max_inflight = atoi(argv[i+1]);
3747+ }
3748+ i++;
3749+ }else if(!strcmp(argv[i], "-n") || !strcmp(argv[i], "--null-message")){
3750+ if(pub_or_sub == CLIENT_SUB){
3751+ goto unknown_option;
3752+ }
3753+ if(cfg->pub_mode != MSGMODE_NONE){
3754+ fprintf(stderr, "Error: Only one type of message can be sent at once.\n\n");
3755+ return 1;
3756+ }else{
3757+ cfg->pub_mode = MSGMODE_NULL;
3758+ }
3759+ }else if(!strcmp(argv[i], "-V") || !strcmp(argv[i], "--protocol-version")){
3760+ if(i==argc-1){
3761+ fprintf(stderr, "Error: --protocol-version argument given but no version specified.\n\n");
3762+ return 1;
3763+ }else{
3764+ if(!strcmp(argv[i+1], "mqttv31")){
3765+ cfg->protocol_version = MQTT_PROTOCOL_V31;
3766+ }else if(!strcmp(argv[i+1], "mqttv311")){
3767+ cfg->protocol_version = MQTT_PROTOCOL_V311;
3768+ }else{
3769+ fprintf(stderr, "Error: Invalid protocol version argument given.\n\n");
3770+ return 1;
3771+ }
3772+ i++;
3773+ }
3774+#ifdef WITH_SOCKS
3775+ }else if(!strcmp(argv[i], "--proxy")){
3776+ if(i==argc-1){
3777+ fprintf(stderr, "Error: --proxy argument given but no proxy url specified.\n\n");
3778+ return 1;
3779+ }else{
3780+ if(mosquitto__parse_socks_url(cfg, argv[i+1])){
3781+ return 1;
3782+ }
3783+ i++;
3784+ }
3785+#endif
3786+#ifdef WITH_TLS_PSK
3787+ }else if(!strcmp(argv[i], "--psk")){
3788+ if(i==argc-1){
3789+ fprintf(stderr, "Error: --psk argument given but no key specified.\n\n");
3790+ return 1;
3791+ }else{
3792+ cfg->psk = strdup(argv[i+1]);
3793+ }
3794+ i++;
3795+ }else if(!strcmp(argv[i], "--psk-identity")){
3796+ if(i==argc-1){
3797+ fprintf(stderr, "Error: --psk-identity argument given but no identity specified.\n\n");
3798+ return 1;
3799+ }else{
3800+ cfg->psk_identity = strdup(argv[i+1]);
3801+ }
3802+ i++;
3803+#endif
3804+ }else if(!strcmp(argv[i], "-q") || !strcmp(argv[i], "--qos")){
3805+ if(i==argc-1){
3806+ fprintf(stderr, "Error: -q argument given but no QoS specified.\n\n");
3807+ return 1;
3808+ }else{
3809+ cfg->qos = atoi(argv[i+1]);
3810+ if(cfg->qos<0 || cfg->qos>2){
3811+ fprintf(stderr, "Error: Invalid QoS given: %d\n", cfg->qos);
3812+ return 1;
3813+ }
3814+ }
3815+ i++;
3816+ }else if(!strcmp(argv[i], "--quiet")){
3817+ cfg->quiet = true;
3818+ }else if(!strcmp(argv[i], "-r") || !strcmp(argv[i], "--retain")){
3819+ if(pub_or_sub == CLIENT_SUB){
3820+ goto unknown_option;
3821+ }
3822+ cfg->retain = 1;
3823+ }else if(!strcmp(argv[i], "-s") || !strcmp(argv[i], "--stdin-file")){
3824+ if(pub_or_sub == CLIENT_SUB){
3825+ goto unknown_option;
3826+ }
3827+ if(cfg->pub_mode != MSGMODE_NONE){
3828+ fprintf(stderr, "Error: Only one type of message can be sent at once.\n\n");
3829+ return 1;
3830+ }else{
3831+ cfg->pub_mode = MSGMODE_STDIN_FILE;
3832+ }
3833+#ifdef WITH_SRV
3834+ }else if(!strcmp(argv[i], "-S")){
3835+ cfg->use_srv = true;
3836+#endif
3837+ }else if(!strcmp(argv[i], "-t") || !strcmp(argv[i], "--topic")){
3838+ if(i==argc-1){
3839+ fprintf(stderr, "Error: -t argument given but no topic specified.\n\n");
3840+ return 1;
3841+ }else{
3842+ if(pub_or_sub == CLIENT_PUB){
3843+ if(mosquitto_pub_topic_check(argv[i+1]) == MOSQ_ERR_INVAL){
3844+ fprintf(stderr, "Error: Invalid publish topic '%s', does it contain '+' or '#'?\n", argv[i+1]);
3845+ return 1;
3846+ }
3847+ cfg->topic = strdup(argv[i+1]);
3848+ }else{
3849+ if(mosquitto_sub_topic_check(argv[i+1]) == MOSQ_ERR_INVAL){
3850+ fprintf(stderr, "Error: Invalid subscription topic '%s', are all '+' and '#' wildcards correct?\n", argv[i+1]);
3851+ return 1;
3852+ }
3853+ cfg->topic_count++;
3854+ cfg->topics = realloc(cfg->topics, cfg->topic_count*sizeof(char *));
3855+ cfg->topics[cfg->topic_count-1] = strdup(argv[i+1]);
3856+ }
3857+ i++;
3858+ }
3859+ }else if(!strcmp(argv[i], "-T") || !strcmp(argv[i], "--filter-out")){
3860+ if(pub_or_sub == CLIENT_PUB){
3861+ goto unknown_option;
3862+ }
3863+ if(i==argc-1){
3864+ fprintf(stderr, "Error: -T argument given but no topic filter specified.\n\n");
3865+ return 1;
3866+ }else{
3867+ if(mosquitto_sub_topic_check(argv[i+1]) == MOSQ_ERR_INVAL){
3868+ fprintf(stderr, "Error: Invalid filter topic '%s', are all '+' and '#' wildcards correct?\n", argv[i+1]);
3869+ return 1;
3870+ }
3871+ cfg->filter_out_count++;
3872+ cfg->filter_outs = realloc(cfg->filter_outs, cfg->filter_out_count*sizeof(char *));
3873+ cfg->filter_outs[cfg->filter_out_count-1] = strdup(argv[i+1]);
3874+ }
3875+ i++;
3876+#ifdef WITH_TLS
3877+ }else if(!strcmp(argv[i], "--tls-version")){
3878+ if(i==argc-1){
3879+ fprintf(stderr, "Error: --tls-version argument given but no version specified.\n\n");
3880+ return 1;
3881+ }else{
3882+ cfg->tls_version = strdup(argv[i+1]);
3883+ }
3884+ i++;
3885+#endif
3886+ }else if(!strcmp(argv[i], "-u") || !strcmp(argv[i], "--username")){
3887+ if(i==argc-1){
3888+ fprintf(stderr, "Error: -u argument given but no username specified.\n\n");
3889+ return 1;
3890+ }else{
3891+ cfg->username = strdup(argv[i+1]);
3892+ }
3893+ i++;
3894+ }else if(!strcmp(argv[i], "-P") || !strcmp(argv[i], "--pw")){
3895+ if(i==argc-1){
3896+ fprintf(stderr, "Error: -P argument given but no password specified.\n\n");
3897+ return 1;
3898+ }else{
3899+ cfg->password = strdup(argv[i+1]);
3900+ }
3901+ i++;
3902+ }else if(!strcmp(argv[i], "--will-payload")){
3903+ if(i==argc-1){
3904+ fprintf(stderr, "Error: --will-payload argument given but no will payload specified.\n\n");
3905+ return 1;
3906+ }else{
3907+ cfg->will_payload = strdup(argv[i+1]);
3908+ cfg->will_payloadlen = strlen(cfg->will_payload);
3909+ }
3910+ i++;
3911+ }else if(!strcmp(argv[i], "--will-qos")){
3912+ if(i==argc-1){
3913+ fprintf(stderr, "Error: --will-qos argument given but no will QoS specified.\n\n");
3914+ return 1;
3915+ }else{
3916+ cfg->will_qos = atoi(argv[i+1]);
3917+ if(cfg->will_qos < 0 || cfg->will_qos > 2){
3918+ fprintf(stderr, "Error: Invalid will QoS %d.\n\n", cfg->will_qos);
3919+ return 1;
3920+ }
3921+ }
3922+ i++;
3923+ }else if(!strcmp(argv[i], "--will-retain")){
3924+ cfg->will_retain = true;
3925+ }else if(!strcmp(argv[i], "--will-topic")){
3926+ if(i==argc-1){
3927+ fprintf(stderr, "Error: --will-topic argument given but no will topic specified.\n\n");
3928+ return 1;
3929+ }else{
3930+ if(mosquitto_pub_topic_check(argv[i+1]) == MOSQ_ERR_INVAL){
3931+ fprintf(stderr, "Error: Invalid will topic '%s', does it contain '+' or '#'?\n", argv[i+1]);
3932+ return 1;
3933+ }
3934+ cfg->will_topic = strdup(argv[i+1]);
3935+ }
3936+ i++;
3937+ }else if(!strcmp(argv[i], "-c") || !strcmp(argv[i], "--disable-clean-session")){
3938+ if(pub_or_sub == CLIENT_PUB){
3939+ goto unknown_option;
3940+ }
3941+ cfg->clean_session = false;
3942+ }else if(!strcmp(argv[i], "-N")){
3943+ if(pub_or_sub == CLIENT_PUB){
3944+ goto unknown_option;
3945+ }
3946+ cfg->eol = false;
3947+ }else if(!strcmp(argv[i], "-R")){
3948+ if(pub_or_sub == CLIENT_PUB){
3949+ goto unknown_option;
3950+ }
3951+ cfg->no_retain = true;
3952+ }else if(!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose")){
3953+ if(pub_or_sub == CLIENT_PUB){
3954+ goto unknown_option;
3955+ }
3956+ cfg->verbose = 1;
3957+ }else{
3958+ goto unknown_option;
3959+ }
3960+ }
3961+
3962+ return MOSQ_ERR_SUCCESS;
3963+
3964+unknown_option:
3965+ fprintf(stderr, "Error: Unknown option '%s'.\n",argv[i]);
3966+ return 1;
3967+}
3968+
3969+int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg)
3970+{
3971+ int rc;
3972+
3973+ if(cfg->will_topic && mosquitto_will_set(mosq, cfg->will_topic,
3974+ cfg->will_payloadlen, cfg->will_payload, cfg->will_qos,
3975+ cfg->will_retain)){
3976+
3977+ if(!cfg->quiet) fprintf(stderr, "Error: Problem setting will.\n");
3978+ mosquitto_lib_cleanup();
3979+ return 1;
3980+ }
3981+ if(cfg->username && mosquitto_username_pw_set(mosq, cfg->username, cfg->password)){
3982+ if(!cfg->quiet) fprintf(stderr, "Error: Problem setting username and password.\n");
3983+ mosquitto_lib_cleanup();
3984+ return 1;
3985+ }
3986+#ifdef WITH_TLS
3987+ if((cfg->cafile || cfg->capath)
3988+ && mosquitto_tls_set(mosq, cfg->cafile, cfg->capath, cfg->certfile, cfg->keyfile, NULL)){
3989+
3990+ if(!cfg->quiet) fprintf(stderr, "Error: Problem setting TLS options.\n");
3991+ mosquitto_lib_cleanup();
3992+ return 1;
3993+ }
3994+ if(cfg->insecure && mosquitto_tls_insecure_set(mosq, true)){
3995+ if(!cfg->quiet) fprintf(stderr, "Error: Problem setting TLS insecure option.\n");
3996+ mosquitto_lib_cleanup();
3997+ return 1;
3998+ }
3999+# ifdef WITH_TLS_PSK
4000+ if(cfg->psk && mosquitto_tls_psk_set(mosq, cfg->psk, cfg->psk_identity, NULL)){
4001+ if(!cfg->quiet) fprintf(stderr, "Error: Problem setting TLS-PSK options.\n");
4002+ mosquitto_lib_cleanup();
4003+ return 1;
4004+ }
4005+# endif
4006+ if(cfg->tls_version && mosquitto_tls_opts_set(mosq, 1, cfg->tls_version, cfg->ciphers)){
4007+ if(!cfg->quiet) fprintf(stderr, "Error: Problem setting TLS options.\n");
4008+ mosquitto_lib_cleanup();
4009+ return 1;
4010+ }
4011+#endif
4012+ mosquitto_max_inflight_messages_set(mosq, cfg->max_inflight);
4013+#ifdef WITH_SOCKS
4014+ if(cfg->socks5_host){
4015+ rc = mosquitto_socks5_set(mosq, cfg->socks5_host, cfg->socks5_port, cfg->socks5_username, cfg->socks5_password);
4016+ if(rc){
4017+ mosquitto_lib_cleanup();
4018+ return rc;
4019+ }
4020+ }
4021+#endif
4022+ mosquitto_opts_set(mosq, MOSQ_OPT_PROTOCOL_VERSION, &(cfg->protocol_version));
4023+ return MOSQ_ERR_SUCCESS;
4024+}
4025+
4026+int client_id_generate(struct mosq_config *cfg, const char *id_base)
4027+{
4028+ int len;
4029+ char hostname[256];
4030+
4031+ if(cfg->id_prefix){
4032+ cfg->id = malloc(strlen(cfg->id_prefix)+10);
4033+ if(!cfg->id){
4034+ if(!cfg->quiet) fprintf(stderr, "Error: Out of memory.\n");
4035+ mosquitto_lib_cleanup();
4036+ return 1;
4037+ }
4038+ snprintf(cfg->id, strlen(cfg->id_prefix)+10, "%s%d", cfg->id_prefix, getpid());
4039+ }else if(!cfg->id){
4040+ hostname[0] = '\0';
4041+ gethostname(hostname, 256);
4042+ hostname[255] = '\0';
4043+ len = strlen(id_base) + strlen("/-") + 6 + strlen(hostname);
4044+ cfg->id = malloc(len);
4045+ if(!cfg->id){
4046+ if(!cfg->quiet) fprintf(stderr, "Error: Out of memory.\n");
4047+ mosquitto_lib_cleanup();
4048+ return 1;
4049+ }
4050+ snprintf(cfg->id, len, "%s/%d-%s", id_base, getpid(), hostname);
4051+ if(strlen(cfg->id) > MOSQ_MQTT_ID_MAX_LENGTH){
4052+ /* Enforce maximum client id length of 23 characters */
4053+ cfg->id[MOSQ_MQTT_ID_MAX_LENGTH] = '\0';
4054+ }
4055+ }
4056+ return MOSQ_ERR_SUCCESS;
4057+}
4058+
4059+int client_connect(struct mosquitto *mosq, struct mosq_config *cfg)
4060+{
4061+ char err[1024];
4062+ int rc;
4063+
4064+#ifdef WITH_SRV
4065+ if(cfg->use_srv){
4066+ rc = mosquitto_connect_srv(mosq, cfg->host, cfg->keepalive, cfg->bind_address);
4067+ }else{
4068+ rc = mosquitto_connect_bind(mosq, cfg->host, cfg->port, cfg->keepalive, cfg->bind_address);
4069+ }
4070+#else
4071+ rc = mosquitto_connect_bind(mosq, cfg->host, cfg->port, cfg->keepalive, cfg->bind_address);
4072+#endif
4073+ if(rc){
4074+ if(!cfg->quiet){
4075+ if(rc == MOSQ_ERR_ERRNO){
4076+#ifndef WIN32
4077+ strerror_r(errno, err, 1024);
4078+#else
4079+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errno, 0, (LPTSTR)&err, 1024, NULL);
4080+#endif
4081+ fprintf(stderr, "Error: %s\n", err);
4082+ }else{
4083+ fprintf(stderr, "Unable to connect (%d).\n", rc);
4084+ }
4085+ }
4086+ mosquitto_lib_cleanup();
4087+ return rc;
4088+ }
4089+ return MOSQ_ERR_SUCCESS;
4090+}
4091+
4092+#ifdef WITH_SOCKS
4093+/* Convert %25 -> %, %3a, %3A -> :, %40 -> @ */
4094+static int mosquitto__urldecode(char *str)
4095+{
4096+ int i, j;
4097+ int len;
4098+ if(!str) return 0;
4099+
4100+ if(!strchr(str, '%')) return 0;
4101+
4102+ len = strlen(str);
4103+ for(i=0; i<len; i++){
4104+ if(str[i] == '%'){
4105+ if(i+2 >= len){
4106+ return 1;
4107+ }
4108+ if(str[i+1] == '2' && str[i+2] == '5'){
4109+ str[i] = '%';
4110+ len -= 2;
4111+ for(j=i+1; j<len; j++){
4112+ str[j] = str[j+2];
4113+ }
4114+ str[j] = '\0';
4115+ }else if(str[i+1] == '3' && (str[i+2] == 'A' || str[i+2] == 'a')){
4116+ str[i] = ':';
4117+ len -= 2;
4118+ for(j=i+1; j<len; j++){
4119+ str[j] = str[j+2];
4120+ }
4121+ str[j] = '\0';
4122+ }else if(str[i+1] == '4' && str[i+2] == '0'){
4123+ str[i] = ':';
4124+ len -= 2;
4125+ for(j=i+1; j<len; j++){
4126+ str[j] = str[j+2];
4127+ }
4128+ str[j] = '\0';
4129+ }else{
4130+ return 1;
4131+ }
4132+ }
4133+ }
4134+ return 0;
4135+}
4136+
4137+static int mosquitto__parse_socks_url(struct mosq_config *cfg, char *url)
4138+{
4139+ char *str;
4140+ int i;
4141+ char *username = NULL, *password = NULL, *host = NULL, *port = NULL;
4142+ char *username_or_host = NULL;
4143+ int start;
4144+ int len;
4145+ bool have_auth = false;
4146+ int port_int;
4147+
4148+ if(!strncmp(url, "socks5h://", strlen("socks5h://"))){
4149+ str = url + strlen("socks5h://");
4150+ }else{
4151+ fprintf(stderr, "Error: Unsupported proxy protocol: %s\n", url);
4152+ return 1;
4153+ }
4154+
4155+ // socks5h://username:password@host:1883
4156+ // socks5h://username:password@host
4157+ // socks5h://username@host:1883
4158+ // socks5h://username@host
4159+ // socks5h://host:1883
4160+ // socks5h://host
4161+
4162+ start = 0;
4163+ for(i=0; i<strlen(str); i++){
4164+ if(str[i] == ':'){
4165+ if(i == start){
4166+ goto cleanup;
4167+ }
4168+ if(have_auth){
4169+ /* Have already seen a @ , so this must be of form
4170+ * socks5h://username[:password]@host:port */
4171+ if(host){
4172+ /* Already seen a host, must be malformed. */
4173+ goto cleanup;
4174+ }
4175+ len = i-start;
4176+ host = malloc(len + 1);
4177+ memcpy(host, &(str[start]), len);
4178+ host[len] = '\0';
4179+ start = i+1;
4180+ }else if(!username_or_host){
4181+ /* Haven't seen a @ before, so must be of form
4182+ * socks5h://host:port or
4183+ * socks5h://username:password@host[:port] */
4184+ len = i-start;
4185+ username_or_host = malloc(len + 1);
4186+ memcpy(username_or_host, &(str[start]), len);
4187+ username_or_host[len] = '\0';
4188+ start = i+1;
4189+ }
4190+ }else if(str[i] == '@'){
4191+ if(i == start){
4192+ goto cleanup;
4193+ }
4194+ have_auth = true;
4195+ if(username_or_host){
4196+ /* Must be of form socks5h://username:password@... */
4197+ username = username_or_host;
4198+ username_or_host = NULL;
4199+
4200+ len = i-start;
4201+ password = malloc(len + 1);
4202+ memcpy(password, &(str[start]), len);
4203+ password[len] = '\0';
4204+ start = i+1;
4205+ }else{
4206+ /* Haven't seen a : yet, so must be of form
4207+ * socks5h://username@... */
4208+ if(username){
4209+ /* Already got a username, must be malformed. */
4210+ goto cleanup;
4211+ }
4212+ len = i-start;
4213+ username = malloc(len + 1);
4214+ memcpy(username, &(str[start]), len);
4215+ username[len] = '\0';
4216+ start = i+1;
4217+ }
4218+ }
4219+ }
4220+
4221+ /* Deal with remainder */
4222+ if(i > start){
4223+ len = i-start;
4224+ if(host){
4225+ /* Have already seen a @ , so this must be of form
4226+ * socks5h://username[:password]@host:port */
4227+ port = malloc(len + 1);
4228+ memcpy(port, &(str[start]), len);
4229+ port[len] = '\0';
4230+ }else if(username_or_host){
4231+ /* Haven't seen a @ before, so must be of form
4232+ * socks5h://host:port */
4233+ host = username_or_host;
4234+ username_or_host = NULL;
4235+ port = malloc(len + 1);
4236+ memcpy(port, &(str[start]), len);
4237+ port[len] = '\0';
4238+ }else{
4239+ host = malloc(len + 1);
4240+ memcpy(host, &(str[start]), len);
4241+ host[len] = '\0';
4242+ }
4243+ }
4244+
4245+ if(!host){
4246+ fprintf(stderr, "Error: Invalid proxy.\n");
4247+ goto cleanup;
4248+ }
4249+
4250+ if(mosquitto__urldecode(username)){
4251+ goto cleanup;
4252+ }
4253+ if(mosquitto__urldecode(password)){
4254+ goto cleanup;
4255+ }
4256+ if(port){
4257+ port_int = atoi(port);
4258+ if(port_int < 1 || port_int > 65535){
4259+ fprintf(stderr, "Error: Invalid proxy port %d\n", port_int);
4260+ goto cleanup;
4261+ }
4262+ free(port);
4263+ }else{
4264+ port_int = 1080;
4265+ }
4266+
4267+ cfg->socks5_username = username;
4268+ cfg->socks5_password = password;
4269+ cfg->socks5_host = host;
4270+ cfg->socks5_port = port_int;
4271+
4272+ return 0;
4273+cleanup:
4274+ if(username_or_host) free(username_or_host);
4275+ if(username) free(username);
4276+ if(password) free(password);
4277+ if(host) free(host);
4278+ if(port) free(port);
4279+ return 1;
4280+}
4281+
4282+#endif
4283
4284=== added file 'client/client_shared.h'
4285--- client/client_shared.h 1970-01-01 00:00:00 +0000
4286+++ client/client_shared.h 2015-02-18 20:26:49 +0000
4287@@ -0,0 +1,97 @@
4288+/*
4289+Copyright (c) 2014 Roger Light <roger@atchoo.org>
4290+
4291+All rights reserved. This program and the accompanying materials
4292+are made available under the terms of the Eclipse Public License v1.0
4293+and Eclipse Distribution License v1.0 which accompany this distribution.
4294+
4295+The Eclipse Public License is available at
4296+ http://www.eclipse.org/legal/epl-v10.html
4297+and the Eclipse Distribution License is available at
4298+ http://www.eclipse.org/org/documents/edl-v10.php.
4299+
4300+Contributors:
4301+ Roger Light - initial implementation and documentation.
4302+*/
4303+
4304+#ifndef _CLIENT_CONFIG_H
4305+#define _CLIENT_CONFIG_H
4306+
4307+#include <stdio.h>
4308+
4309+/* pub_client.c modes */
4310+#define MSGMODE_NONE 0
4311+#define MSGMODE_CMD 1
4312+#define MSGMODE_STDIN_LINE 2
4313+#define MSGMODE_STDIN_FILE 3
4314+#define MSGMODE_FILE 4
4315+#define MSGMODE_NULL 5
4316+
4317+#define CLIENT_PUB 1
4318+#define CLIENT_SUB 2
4319+
4320+struct mosq_config {
4321+ char *id;
4322+ char *id_prefix;
4323+ int protocol_version;
4324+ int keepalive;
4325+ char *host;
4326+ int port;
4327+ int qos;
4328+ bool retain;
4329+ int pub_mode; /* pub */
4330+ char *file_input; /* pub */
4331+ char *message; /* pub */
4332+ long msglen; /* pub */
4333+ char *topic; /* pub */
4334+ char *bind_address;
4335+#ifdef WITH_SRV
4336+ bool use_srv;
4337+#endif
4338+ bool debug;
4339+ bool quiet;
4340+ unsigned int max_inflight;
4341+ char *username;
4342+ char *password;
4343+ char *will_topic;
4344+ char *will_payload;
4345+ long will_payloadlen;
4346+ int will_qos;
4347+ bool will_retain;
4348+#ifdef WITH_TLS
4349+ char *cafile;
4350+ char *capath;
4351+ char *certfile;
4352+ char *keyfile;
4353+ char *ciphers;
4354+ bool insecure;
4355+ char *tls_version;
4356+# ifdef WITH_TLS_PSK
4357+ char *psk;
4358+ char *psk_identity;
4359+# endif
4360+#endif
4361+ bool clean_session; /* sub */
4362+ char **topics; /* sub */
4363+ int topic_count; /* sub */
4364+ bool no_retain; /* sub */
4365+ char **filter_outs; /* sub */
4366+ int filter_out_count; /* sub */
4367+ bool verbose; /* sub */
4368+ bool eol; /* sub */
4369+ int msg_count; /* sub */
4370+#ifdef WITH_SOCKS
4371+ char *socks5_host;
4372+ int socks5_port;
4373+ char *socks5_username;
4374+ char *socks5_password;
4375+#endif
4376+};
4377+
4378+int client_config_load(struct mosq_config *config, int pub_or_sub, int argc, char *argv[]);
4379+void client_config_cleanup(struct mosq_config *cfg);
4380+int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg);
4381+int client_id_generate(struct mosq_config *cfg, const char *id_base);
4382+int client_connect(struct mosquitto *mosq, struct mosq_config *cfg);
4383+
4384+#endif
4385
4386=== modified file 'client/pub_client.c'
4387--- client/pub_client.c 2014-08-06 00:43:39 +0000
4388+++ client/pub_client.c 2015-02-18 20:26:49 +0000
4389@@ -1,30 +1,17 @@
4390 /*
4391 Copyright (c) 2009-2014 Roger Light <roger@atchoo.org>
4392-All rights reserved.
4393-
4394-Redistribution and use in source and binary forms, with or without
4395-modification, are permitted provided that the following conditions are met:
4396-
4397-1. Redistributions of source code must retain the above copyright notice,
4398- this list of conditions and the following disclaimer.
4399-2. Redistributions in binary form must reproduce the above copyright
4400- notice, this list of conditions and the following disclaimer in the
4401- documentation and/or other materials provided with the distribution.
4402-3. Neither the name of mosquitto nor the names of its
4403- contributors may be used to endorse or promote products derived from
4404- this software without specific prior written permission.
4405-
4406-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4407-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4408-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4409-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
4410-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
4411-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
4412-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
4413-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
4414-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4415-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4416-POSSIBILITY OF SUCH DAMAGE.
4417+
4418+All rights reserved. This program and the accompanying materials
4419+are made available under the terms of the Eclipse Public License v1.0
4420+and Eclipse Distribution License v1.0 which accompany this distribution.
4421+
4422+The Eclipse Public License is available at
4423+ http://www.eclipse.org/legal/epl-v10.html
4424+and the Eclipse Distribution License is available at
4425+ http://www.eclipse.org/org/documents/edl-v10.php.
4426+
4427+Contributors:
4428+ Roger Light - initial implementation and documentation.
4429 */
4430
4431
4432@@ -42,13 +29,7 @@
4433 #endif
4434
4435 #include <mosquitto.h>
4436-
4437-#define MSGMODE_NONE 0
4438-#define MSGMODE_CMD 1
4439-#define MSGMODE_STDIN_LINE 2
4440-#define MSGMODE_STDIN_FILE 3
4441-#define MSGMODE_FILE 4
4442-#define MSGMODE_NULL 5
4443+#include "client_shared.h"
4444
4445 #define STATUS_CONNECTING 0
4446 #define STATUS_CONNACK_RECVD 1
4447@@ -219,7 +200,7 @@
4448 mosquitto_lib_version(&major, &minor, &revision);
4449 printf("mosquitto_pub is a simple mqtt client that will publish a message on a single topic and exit.\n");
4450 printf("mosquitto_pub version %s running on libmosquitto %d.%d.%d.\n\n", VERSION, major, minor, revision);
4451- printf("Usage: mosquitto_pub [-h host] [-p port] [-q qos] [-r] {-f file | -l | -n | -m message} -t topic\n");
4452+ printf("Usage: mosquitto_pub [-h host] [-k keepalive] [-p port] [-q qos] [-r] {-f file | -l | -n | -m message} -t topic\n");
4453 #ifdef WITH_SRV
4454 printf(" [-A bind_address] [-S]\n");
4455 #else
4456@@ -237,6 +218,9 @@
4457 printf(" [--psk hex-key --psk-identity identity [--ciphers ciphers]]\n");
4458 #endif
4459 #endif
4460+#ifdef WITH_SOCKS
4461+ printf(" [--proxy socks-url]\n");
4462+#endif
4463 printf(" mosquitto_pub --help\n\n");
4464 printf(" -A : bind the outgoing socket to this host/ip address. Use to control which interface\n");
4465 printf(" the client communicates over.\n");
4466@@ -246,11 +230,13 @@
4467 printf(" -i : id to use for this client. Defaults to mosquitto_pub_ appended with the process id.\n");
4468 printf(" -I : define the client id as id_prefix appended with the process id. Useful for when the\n");
4469 printf(" broker is using the clientid_prefixes option.\n");
4470+ printf(" -k : keep alive in seconds for this client. Defaults to 60.\n");
4471 printf(" -l : read messages from stdin, sending a separate message for each line.\n");
4472 printf(" -m : message payload to send.\n");
4473 printf(" -M : the maximum inflight messages for QoS 1/2..\n");
4474 printf(" -n : send a null (zero length) message.\n");
4475 printf(" -p : network port to connect to. Defaults to 1883.\n");
4476+ printf(" -P : provide a password (requires MQTT 3.1 broker)\n");
4477 printf(" -q : quality of service level to use for all messages. Defaults to 0.\n");
4478 printf(" -r : message should be retained.\n");
4479 printf(" -s : read message from stdin, sending the entire input as a message.\n");
4480@@ -259,7 +245,8 @@
4481 #endif
4482 printf(" -t : mqtt topic to publish to.\n");
4483 printf(" -u : provide a username (requires MQTT 3.1 broker)\n");
4484- printf(" -P : provide a password (requires MQTT 3.1 broker)\n");
4485+ printf(" -V : specify the version of the MQTT protocol to use when connecting.\n");
4486+ printf(" Can be mqttv31 or mqttv311. Defaults to mqttv31.\n");
4487 printf(" --help : display this message.\n");
4488 printf(" --quiet : don't print error messages.\n");
4489 printf(" --will-payload : payload for the client Will, which is sent by the broker in case of\n");
4490@@ -282,340 +269,57 @@
4491 printf(" hostname. Using this option means that you cannot be sure that the\n");
4492 printf(" remote host is the server you wish to connect to and so is insecure.\n");
4493 printf(" Do not use this option in a production environment.\n");
4494-#ifdef WITH_TLS_PSK
4495+# ifdef WITH_TLS_PSK
4496 printf(" --psk : pre-shared-key in hexadecimal (no leading 0x) to enable TLS-PSK mode.\n");
4497 printf(" --psk-identity : client identity string for TLS-PSK mode.\n");
4498+# endif
4499 #endif
4500+#ifdef WITH_SOCKS
4501+ printf(" --proxy : SOCKS5 proxy URL of the form:\n");
4502+ printf(" socks5h://[username[:password]@]hostname[:port]\n");
4503+ printf(" Only \"none\" and \"username\" authentication is supported.\n");
4504 #endif
4505 printf("\nSee http://mosquitto.org/ for more information.\n\n");
4506 }
4507
4508 int main(int argc, char *argv[])
4509 {
4510- char *id = NULL;
4511- char *id_prefix = NULL;
4512- int i;
4513- char *host = "localhost";
4514- int port = 1883;
4515- char *bind_address = NULL;
4516- int keepalive = 60;
4517+ struct mosq_config cfg;
4518 char buf[1024];
4519- bool debug = false;
4520 struct mosquitto *mosq = NULL;
4521 int rc;
4522 int rc2;
4523- char hostname[256];
4524- char err[1024];
4525- int len;
4526- unsigned int max_inflight = 20;
4527-
4528- char *will_payload = NULL;
4529- long will_payloadlen = 0;
4530- int will_qos = 0;
4531- bool will_retain = false;
4532- char *will_topic = NULL;
4533-
4534- bool insecure = false;
4535- char *cafile = NULL;
4536- char *capath = NULL;
4537- char *certfile = NULL;
4538- char *keyfile = NULL;
4539- char *tls_version = NULL;
4540-
4541- char *psk = NULL;
4542- char *psk_identity = NULL;
4543-
4544- char *ciphers = NULL;
4545-
4546- bool use_srv = false;
4547-
4548- for(i=1; i<argc; i++){
4549- if(!strcmp(argv[i], "-p") || !strcmp(argv[i], "--port")){
4550- if(i==argc-1){
4551- fprintf(stderr, "Error: -p argument given but no port specified.\n\n");
4552- print_usage();
4553- return 1;
4554- }else{
4555- port = atoi(argv[i+1]);
4556- if(port<1 || port>65535){
4557- fprintf(stderr, "Error: Invalid port given: %d\n", port);
4558- print_usage();
4559- return 1;
4560- }
4561- }
4562- i++;
4563- }else if(!strcmp(argv[i], "-A")){
4564- if(i==argc-1){
4565- fprintf(stderr, "Error: -A argument given but no address specified.\n\n");
4566- print_usage();
4567- return 1;
4568- }else{
4569- bind_address = argv[i+1];
4570- }
4571- i++;
4572- }else if(!strcmp(argv[i], "--cafile")){
4573- if(i==argc-1){
4574- fprintf(stderr, "Error: --cafile argument given but no file specified.\n\n");
4575- print_usage();
4576- return 1;
4577- }else{
4578- cafile = argv[i+1];
4579- }
4580- i++;
4581- }else if(!strcmp(argv[i], "--capath")){
4582- if(i==argc-1){
4583- fprintf(stderr, "Error: --capath argument given but no directory specified.\n\n");
4584- print_usage();
4585- return 1;
4586- }else{
4587- capath = argv[i+1];
4588- }
4589- i++;
4590- }else if(!strcmp(argv[i], "--cert")){
4591- if(i==argc-1){
4592- fprintf(stderr, "Error: --cert argument given but no file specified.\n\n");
4593- print_usage();
4594- return 1;
4595- }else{
4596- certfile = argv[i+1];
4597- }
4598- i++;
4599- }else if(!strcmp(argv[i], "--ciphers")){
4600- if(i==argc-1){
4601- fprintf(stderr, "Error: --ciphers argument given but no ciphers specified.\n\n");
4602- print_usage();
4603- return 1;
4604- }else{
4605- ciphers = argv[i+1];
4606- }
4607- i++;
4608- }else if(!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")){
4609- debug = true;
4610- }else if(!strcmp(argv[i], "-f") || !strcmp(argv[i], "--file")){
4611- if(mode != MSGMODE_NONE){
4612- fprintf(stderr, "Error: Only one type of message can be sent at once.\n\n");
4613- print_usage();
4614- return 1;
4615- }else if(i==argc-1){
4616- fprintf(stderr, "Error: -f argument given but no file specified.\n\n");
4617- print_usage();
4618- return 1;
4619- }else{
4620- if(load_file(argv[i+1])) return 1;
4621- }
4622- i++;
4623- }else if(!strcmp(argv[i], "--help")){
4624+
4625+ rc = client_config_load(&cfg, CLIENT_PUB, argc, argv);
4626+ if(rc){
4627+ client_config_cleanup(&cfg);
4628+ if(rc == 2){
4629+ /* --help */
4630 print_usage();
4631- return 0;
4632- }else if(!strcmp(argv[i], "-h") || !strcmp(argv[i], "--host")){
4633- if(i==argc-1){
4634- fprintf(stderr, "Error: -h argument given but no host specified.\n\n");
4635- print_usage();
4636- return 1;
4637- }else{
4638- host = argv[i+1];
4639- }
4640- i++;
4641- }else if(!strcmp(argv[i], "--insecure")){
4642- insecure = true;
4643- }else if(!strcmp(argv[i], "-i") || !strcmp(argv[i], "--id")){
4644- if(id_prefix){
4645- fprintf(stderr, "Error: -i and -I argument cannot be used together.\n\n");
4646- print_usage();
4647- return 1;
4648- }
4649- if(i==argc-1){
4650- fprintf(stderr, "Error: -i argument given but no id specified.\n\n");
4651- print_usage();
4652- return 1;
4653- }else{
4654- id = argv[i+1];
4655- }
4656- i++;
4657- }else if(!strcmp(argv[i], "-I") || !strcmp(argv[i], "--id-prefix")){
4658- if(id){
4659- fprintf(stderr, "Error: -i and -I argument cannot be used together.\n\n");
4660- print_usage();
4661- return 1;
4662- }
4663- if(i==argc-1){
4664- fprintf(stderr, "Error: -I argument given but no id prefix specified.\n\n");
4665- print_usage();
4666- return 1;
4667- }else{
4668- id_prefix = argv[i+1];
4669- }
4670- i++;
4671- }else if(!strcmp(argv[i], "--key")){
4672- if(i==argc-1){
4673- fprintf(stderr, "Error: --key argument given but no file specified.\n\n");
4674- print_usage();
4675- return 1;
4676- }else{
4677- keyfile = argv[i+1];
4678- }
4679- i++;
4680- }else if(!strcmp(argv[i], "-l") || !strcmp(argv[i], "--stdin-line")){
4681- if(mode != MSGMODE_NONE){
4682- fprintf(stderr, "Error: Only one type of message can be sent at once.\n\n");
4683- print_usage();
4684- return 1;
4685- }else{
4686- mode = MSGMODE_STDIN_LINE;
4687- }
4688- }else if(!strcmp(argv[i], "-m") || !strcmp(argv[i], "--message")){
4689- if(mode != MSGMODE_NONE){
4690- fprintf(stderr, "Error: Only one type of message can be sent at once.\n\n");
4691- print_usage();
4692- return 1;
4693- }else if(i==argc-1){
4694- fprintf(stderr, "Error: -m argument given but no message specified.\n\n");
4695- print_usage();
4696- return 1;
4697- }else{
4698- message = argv[i+1];
4699- msglen = strlen(message);
4700- mode = MSGMODE_CMD;
4701- }
4702- i++;
4703- }else if(!strcmp(argv[i], "-M")){
4704- if(i==argc-1){
4705- fprintf(stderr, "Error: -M argument given but max_inflight not specified.\n\n");
4706- print_usage();
4707- return 1;
4708- }else{
4709- max_inflight = atoi(argv[i+1]);
4710- }
4711- i++;
4712- }else if(!strcmp(argv[i], "-n") || !strcmp(argv[i], "--null-message")){
4713- if(mode != MSGMODE_NONE){
4714- fprintf(stderr, "Error: Only one type of message can be sent at once.\n\n");
4715- print_usage();
4716- return 1;
4717- }else{
4718- mode = MSGMODE_NULL;
4719- }
4720- }else if(!strcmp(argv[i], "--psk")){
4721- if(i==argc-1){
4722- fprintf(stderr, "Error: --psk argument given but no key specified.\n\n");
4723- print_usage();
4724- return 1;
4725- }else{
4726- psk = argv[i+1];
4727- }
4728- i++;
4729- }else if(!strcmp(argv[i], "--psk-identity")){
4730- if(i==argc-1){
4731- fprintf(stderr, "Error: --psk-identity argument given but no identity specified.\n\n");
4732- print_usage();
4733- return 1;
4734- }else{
4735- psk_identity = argv[i+1];
4736- }
4737- i++;
4738- }else if(!strcmp(argv[i], "-q") || !strcmp(argv[i], "--qos")){
4739- if(i==argc-1){
4740- fprintf(stderr, "Error: -q argument given but no QoS specified.\n\n");
4741- print_usage();
4742- return 1;
4743- }else{
4744- qos = atoi(argv[i+1]);
4745- if(qos<0 || qos>2){
4746- fprintf(stderr, "Error: Invalid QoS given: %d\n", qos);
4747- print_usage();
4748- return 1;
4749- }
4750- }
4751- i++;
4752- }else if(!strcmp(argv[i], "--quiet")){
4753- quiet = true;
4754- }else if(!strcmp(argv[i], "-r") || !strcmp(argv[i], "--retain")){
4755- retain = 1;
4756- }else if(!strcmp(argv[i], "-s") || !strcmp(argv[i], "--stdin-file")){
4757- if(mode != MSGMODE_NONE){
4758- fprintf(stderr, "Error: Only one type of message can be sent at once.\n\n");
4759- print_usage();
4760- return 1;
4761- }else{
4762- if(load_stdin()) return 1;
4763- }
4764-#ifdef WITH_SRV
4765- }else if(!strcmp(argv[i], "-S")){
4766- use_srv = true;
4767-#endif
4768- }else if(!strcmp(argv[i], "-t") || !strcmp(argv[i], "--topic")){
4769- if(i==argc-1){
4770- fprintf(stderr, "Error: -t argument given but no topic specified.\n\n");
4771- print_usage();
4772- return 1;
4773- }else{
4774- topic = argv[i+1];
4775- }
4776- i++;
4777- }else if(!strcmp(argv[i], "--tls-version")){
4778- if(i==argc-1){
4779- fprintf(stderr, "Error: --tls-version argument given but no version specified.\n\n");
4780- print_usage();
4781- return 1;
4782- }else{
4783- tls_version = argv[i+1];
4784- }
4785- i++;
4786- }else if(!strcmp(argv[i], "-u") || !strcmp(argv[i], "--username")){
4787- if(i==argc-1){
4788- fprintf(stderr, "Error: -u argument given but no username specified.\n\n");
4789- print_usage();
4790- return 1;
4791- }else{
4792- username = argv[i+1];
4793- }
4794- i++;
4795- }else if(!strcmp(argv[i], "-P") || !strcmp(argv[i], "--pw")){
4796- if(i==argc-1){
4797- fprintf(stderr, "Error: -P argument given but no password specified.\n\n");
4798- print_usage();
4799- return 1;
4800- }else{
4801- password = argv[i+1];
4802- }
4803- i++;
4804- }else if(!strcmp(argv[i], "--will-payload")){
4805- if(i==argc-1){
4806- fprintf(stderr, "Error: --will-payload argument given but no will payload specified.\n\n");
4807- print_usage();
4808- return 1;
4809- }else{
4810- will_payload = argv[i+1];
4811- will_payloadlen = strlen(will_payload);
4812- }
4813- i++;
4814- }else if(!strcmp(argv[i], "--will-qos")){
4815- if(i==argc-1){
4816- fprintf(stderr, "Error: --will-qos argument given but no will QoS specified.\n\n");
4817- print_usage();
4818- return 1;
4819- }else{
4820- will_qos = atoi(argv[i+1]);
4821- if(will_qos < 0 || will_qos > 2){
4822- fprintf(stderr, "Error: Invalid will QoS %d.\n\n", will_qos);
4823- return 1;
4824- }
4825- }
4826- i++;
4827- }else if(!strcmp(argv[i], "--will-retain")){
4828- will_retain = true;
4829- }else if(!strcmp(argv[i], "--will-topic")){
4830- if(i==argc-1){
4831- fprintf(stderr, "Error: --will-topic argument given but no will topic specified.\n\n");
4832- print_usage();
4833- return 1;
4834- }else{
4835- will_topic = argv[i+1];
4836- }
4837- i++;
4838 }else{
4839- fprintf(stderr, "Error: Unknown option '%s'.\n",argv[i]);
4840- print_usage();
4841+ fprintf(stderr, "\nUse 'mosquitto_pub --help' to see usage.\n");
4842+ }
4843+ return 1;
4844+ }
4845+
4846+ topic = cfg.topic;
4847+ message = cfg.message;
4848+ msglen = cfg.msglen;
4849+ qos = cfg.qos;
4850+ retain = cfg.retain;
4851+ mode = cfg.pub_mode;
4852+ username = cfg.username;
4853+ password = cfg.password;
4854+ quiet = cfg.quiet;
4855+
4856+ if(cfg.pub_mode == MSGMODE_STDIN_FILE){
4857+ if(load_stdin()){
4858+ fprintf(stderr, "Error loading input from stdin.\n");
4859+ return 1;
4860+ }
4861+ }else if(cfg.file_input){
4862+ if(load_file(cfg.file_input)){
4863+ fprintf(stderr, "Error loading input file \"%s\".\n", cfg.file_input);
4864 return 1;
4865 }
4866 }
4867@@ -626,62 +330,14 @@
4868 return 1;
4869 }
4870
4871- if(will_payload && !will_topic){
4872- fprintf(stderr, "Error: Will payload given, but no will topic given.\n");
4873- print_usage();
4874- return 1;
4875- }
4876- if(will_retain && !will_topic){
4877- fprintf(stderr, "Error: Will retain given, but no will topic given.\n");
4878- print_usage();
4879- return 1;
4880- }
4881- if(password && !username){
4882- if(!quiet) fprintf(stderr, "Warning: Not using password since username not set.\n");
4883- }
4884- if((certfile && !keyfile) || (keyfile && !certfile)){
4885- fprintf(stderr, "Error: Both certfile and keyfile must be provided if one of them is.\n");
4886- print_usage();
4887- return 1;
4888- }
4889- if((cafile || capath) && psk){
4890- if(!quiet) fprintf(stderr, "Error: Only one of --psk or --cafile/--capath may be used at once.\n");
4891- return 1;
4892- }
4893- if(psk && !psk_identity){
4894- if(!quiet) fprintf(stderr, "Error: --psk-identity required if --psk used.\n");
4895- return 1;
4896- }
4897
4898 mosquitto_lib_init();
4899
4900- if(id_prefix){
4901- id = malloc(strlen(id_prefix)+10);
4902- if(!id){
4903- if(!quiet) fprintf(stderr, "Error: Out of memory.\n");
4904- mosquitto_lib_cleanup();
4905- return 1;
4906- }
4907- snprintf(id, strlen(id_prefix)+10, "%s%d", id_prefix, getpid());
4908- }else if(!id){
4909- hostname[0] = '\0';
4910- gethostname(hostname, 256);
4911- hostname[255] = '\0';
4912- len = strlen("mosqpub/-") + 6 + strlen(hostname);
4913- id = malloc(len);
4914- if(!id){
4915- if(!quiet) fprintf(stderr, "Error: Out of memory.\n");
4916- mosquitto_lib_cleanup();
4917- return 1;
4918- }
4919- snprintf(id, len, "mosqpub/%d-%s", getpid(), hostname);
4920- if(strlen(id) > MOSQ_MQTT_ID_MAX_LENGTH){
4921- /* Enforce maximum client id length of 23 characters */
4922- id[MOSQ_MQTT_ID_MAX_LENGTH] = '\0';
4923- }
4924+ if(client_id_generate(&cfg, "mosqpub")){
4925+ return 1;
4926 }
4927
4928- mosq = mosquitto_new(id, true, NULL);
4929+ mosq = mosquitto_new(cfg.id, true, NULL);
4930 if(!mosq){
4931 switch(errno){
4932 case ENOMEM:
4933@@ -694,65 +350,18 @@
4934 mosquitto_lib_cleanup();
4935 return 1;
4936 }
4937- if(debug){
4938+ if(cfg.debug){
4939 mosquitto_log_callback_set(mosq, my_log_callback);
4940 }
4941- if(will_topic && mosquitto_will_set(mosq, will_topic, will_payloadlen, will_payload, will_qos, will_retain)){
4942- if(!quiet) fprintf(stderr, "Error: Problem setting will.\n");
4943- mosquitto_lib_cleanup();
4944- return 1;
4945- }
4946- if(username && mosquitto_username_pw_set(mosq, username, password)){
4947- if(!quiet) fprintf(stderr, "Error: Problem setting username and password.\n");
4948- mosquitto_lib_cleanup();
4949- return 1;
4950- }
4951- if((cafile || capath) && mosquitto_tls_set(mosq, cafile, capath, certfile, keyfile, NULL)){
4952- if(!quiet) fprintf(stderr, "Error: Problem setting TLS options.\n");
4953- mosquitto_lib_cleanup();
4954- return 1;
4955- }
4956- if(insecure && mosquitto_tls_insecure_set(mosq, true)){
4957- if(!quiet) fprintf(stderr, "Error: Problem setting TLS insecure option.\n");
4958- mosquitto_lib_cleanup();
4959- return 1;
4960- }
4961- if(psk && mosquitto_tls_psk_set(mosq, psk, psk_identity, NULL)){
4962- if(!quiet) fprintf(stderr, "Error: Problem setting TLS-PSK options.\n");
4963- mosquitto_lib_cleanup();
4964- return 1;
4965- }
4966- if(tls_version && mosquitto_tls_opts_set(mosq, 1, tls_version, ciphers)){
4967- if(!quiet) fprintf(stderr, "Error: Problem setting TLS options.\n");
4968- mosquitto_lib_cleanup();
4969- return 1;
4970- }
4971- mosquitto_max_inflight_messages_set(mosq, max_inflight);
4972 mosquitto_connect_callback_set(mosq, my_connect_callback);
4973 mosquitto_disconnect_callback_set(mosq, my_disconnect_callback);
4974 mosquitto_publish_callback_set(mosq, my_publish_callback);
4975
4976- if(use_srv){
4977- rc = mosquitto_connect_srv(mosq, host, keepalive, bind_address);
4978- }else{
4979- rc = mosquitto_connect_bind(mosq, host, port, keepalive, bind_address);
4980- }
4981- if(rc){
4982- if(!quiet){
4983- if(rc == MOSQ_ERR_ERRNO){
4984-#ifndef WIN32
4985- strerror_r(errno, err, 1024);
4986-#else
4987- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errno, 0, (LPTSTR)&err, 1024, NULL);
4988-#endif
4989- fprintf(stderr, "Error: %s\n", err);
4990- }else{
4991- fprintf(stderr, "Unable to connect (%d).\n", rc);
4992- }
4993- }
4994- mosquitto_lib_cleanup();
4995- return rc;
4996- }
4997+ if(client_opts_set(mosq, &cfg)){
4998+ return 1;
4999+ }
5000+ rc = client_connect(mosq, &cfg);
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: