Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
paho.mqtt.c
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eclipse
paho.mqtt.c
Commits
b880d34f
Commit
b880d34f
authored
Mar 20, 2017
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Windows CMake build additions and corrections
parent
526ffc18
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
467 additions
and
499 deletions
+467
-499
CMakeLists.txt
CMakeLists.txt
+1
-0
cbuild.bat
cbuild.bat
+16
-0
CMakeLists.txt
src/CMakeLists.txt
+14
-3
Socket.c
src/Socket.c
+10
-11
Socket.h
src/Socket.h
+10
-3
Thread.c
src/Thread.c
+3
-2
CMakeLists.txt
src/samples/CMakeLists.txt
+4
-0
MQTTClient_publish_async.c
src/samples/MQTTClient_publish_async.c
+4
-5
paho_c_pub.c
src/samples/paho_c_pub.c
+24
-26
paho_cs_pub.c
src/samples/paho_cs_pub.c
+22
-23
CMakeLists.txt
test/CMakeLists.txt
+2
-4
test1.c
test/test1.c
+38
-46
test2.c
test/test2.c
+25
-41
test3.c
test/test3.c
+46
-53
test4.c
test/test4.c
+54
-62
test5.c
test/test5.c
+9
-17
test6.c
test/test6.c
+6
-6
test8.c
test/test8.c
+38
-47
test9.c
test/test9.c
+141
-150
No files found.
CMakeLists.txt
View file @
b880d34f
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
PROJECT
(
"paho"
C
)
PROJECT
(
"paho"
C
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 3.0
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 3.0
)
MESSAGE
(
STATUS
"CMake version: "
${
CMAKE_VERSION
}
)
MESSAGE
(
STATUS
"CMake version: "
${
CMAKE_VERSION
}
)
MESSAGE
(
STATUS
"CMake system name: "
${
CMAKE_SYSTEM_NAME
}
)
## build settings
## build settings
SET
(
PAHO_VERSION_MAJOR 1
)
SET
(
PAHO_VERSION_MAJOR 1
)
...
...
cbuild.bat
0 → 100644
View file @
b880d34f
setlocal
mkdir build.paho
cd build.paho
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
cmake -G "NMake Makefiles" -DPAHO_WITH_SSL=FALSE -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_BUILD_SAMPLES=TRUE -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=TRUE ..
nmake
cd ..
endlocal
src/CMakeLists.txt
View file @
b880d34f
...
@@ -28,6 +28,10 @@ CONFIGURE_FILE(VersionInfo.h.in
...
@@ -28,6 +28,10 @@ CONFIGURE_FILE(VersionInfo.h.in
@ONLY
@ONLY
)
)
IF
(
WIN32
)
ADD_DEFINITIONS
(
/DCMAKE_BUILD /D_CRT_SECURE_NO_DEPRECATE
)
ENDIF
()
IF
(
PAHO_WITH_SSL
)
IF
(
PAHO_WITH_SSL
)
SET
(
OPENSSL_LIB_SEARCH_PATH
""
CACHE PATH
"Directory containing OpenSSL libraries"
)
SET
(
OPENSSL_LIB_SEARCH_PATH
""
CACHE PATH
"Directory containing OpenSSL libraries"
)
SET
(
OPENSSL_INC_SEARCH_PATH
""
CACHE PATH
"Directory containing OpenSSL includes"
)
SET
(
OPENSSL_INC_SEARCH_PATH
""
CACHE PATH
"Directory containing OpenSSL includes"
)
...
@@ -95,7 +99,12 @@ SET_PROPERTY(TARGET common_obj PROPERTY POSITION_INDEPENDENT_CODE ON)
...
@@ -95,7 +99,12 @@ SET_PROPERTY(TARGET common_obj PROPERTY POSITION_INDEPENDENT_CODE ON)
IF
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"Darwin"
)
IF
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"Darwin"
)
SET_PROPERTY
(
TARGET common_obj PROPERTY
SET_PROPERTY
(
TARGET common_obj PROPERTY
COMPILE_DEFINITIONS
"OSX=1"
)
COMPILE_DEFINITIONS
"OSX=1"
)
ENDIF
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"Darwin"
)
ENDIF
()
## IF (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
## MESSAGE(STATUS "Setting secure_no_warnings")
## SET_PROPERTY(TARGET common_obj PROPERTY
## COMPILE_DEFINITIONS "_CRT_SECURE_NO_DEPRECATE")
## ENDIF ()
ADD_EXECUTABLE
(
MQTTVersion MQTTVersion.c
)
ADD_EXECUTABLE
(
MQTTVersion MQTTVersion.c
)
...
@@ -165,9 +174,11 @@ IF (PAHO_WITH_SSL)
...
@@ -165,9 +174,11 @@ IF (PAHO_WITH_SSL)
SET_PROPERTY
(
TARGET common_ssl_obj PROPERTY POSITION_INDEPENDENT_CODE ON
)
SET_PROPERTY
(
TARGET common_ssl_obj PROPERTY POSITION_INDEPENDENT_CODE ON
)
IF
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"Darwin"
)
IF
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"Darwin"
)
SET_PROPERTY
(
TARGET common_ssl_obj PROPERTY COMPILE_DEFINITIONS
"OPENSSL=1;OSX=1"
)
SET_PROPERTY
(
TARGET common_ssl_obj PROPERTY COMPILE_DEFINITIONS
"OPENSSL=1;OSX=1"
)
ELSE
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"Darwin"
)
ELSIF
(
WIN32
)
SET_PROPERTY
(
TARGET common_ssl_obj PROPERTY COMPILE_DEFINITIONS
"OPENSSL=1;_CRT_SECURE_NO_WARNINGS"
)
ELSE
()
SET_PROPERTY
(
TARGET common_ssl_obj PROPERTY COMPILE_DEFINITIONS
"OPENSSL=1"
)
SET_PROPERTY
(
TARGET common_ssl_obj PROPERTY COMPILE_DEFINITIONS
"OPENSSL=1"
)
ENDIF
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"Darwin"
)
ENDIF
()
ADD_LIBRARY
(
paho-mqtt3cs SHARED $<TARGET_OBJECTS:common_ssl_obj> MQTTClient.c SSLSocket.c
)
ADD_LIBRARY
(
paho-mqtt3cs SHARED $<TARGET_OBJECTS:common_ssl_obj> MQTTClient.c SSLSocket.c
)
ADD_LIBRARY
(
paho-mqtt3as SHARED $<TARGET_OBJECTS:common_ssl_obj> MQTTAsync.c SSLSocket.c
)
ADD_LIBRARY
(
paho-mqtt3as SHARED $<TARGET_OBJECTS:common_ssl_obj> MQTTAsync.c SSLSocket.c
)
...
...
src/Socket.c
View file @
b880d34f
...
@@ -106,7 +106,7 @@ int Socket_error(char* aString, int sock)
...
@@ -106,7 +106,7 @@ int Socket_error(char* aString, int sock)
if
(
errno
!=
EINTR
&&
errno
!=
EAGAIN
&&
errno
!=
EINPROGRESS
&&
errno
!=
EWOULDBLOCK
)
if
(
errno
!=
EINTR
&&
errno
!=
EAGAIN
&&
errno
!=
EINPROGRESS
&&
errno
!=
EWOULDBLOCK
)
{
{
if
(
strcmp
(
aString
,
"shutdown"
)
!=
0
||
(
errno
!=
ENOTCONN
&&
errno
!=
ECONNRESET
))
if
(
strcmp
(
aString
,
"shutdown"
)
!=
0
||
(
errno
!=
ENOTCONN
&&
errno
!=
ECONNRESET
))
Log
(
TRACE_MINIMUM
,
-
1
,
"Socket error %s
in %s for socket %d"
,
strerror
(
errno
)
,
aString
,
sock
);
Log
(
TRACE_MINIMUM
,
-
1
,
"Socket error %s
(%d) in %s for socket %d"
,
strerror
(
errno
),
errno
,
aString
,
sock
);
}
}
FUNC_EXIT_RC
(
errno
);
FUNC_EXIT_RC
(
errno
);
return
errno
;
return
errno
;
...
@@ -828,7 +828,7 @@ char* Socket_getaddrname(struct sockaddr* sa, int sock)
...
@@ -828,7 +828,7 @@ char* Socket_getaddrname(struct sockaddr* sa, int sock)
#if defined(WIN32) || defined(WIN64)
#if defined(WIN32) || defined(WIN64)
int
buflen
=
ADDRLEN
*
2
;
int
buflen
=
ADDRLEN
*
2
;
wchar_t
buf
[
ADDRLEN
*
2
];
wchar_t
buf
[
ADDRLEN
*
2
];
if
(
WSAAddressToString
(
sa
,
sizeof
(
struct
sockaddr_in6
),
NULL
,
buf
,
(
LPDWORD
)
&
buflen
)
==
SOCKET_ERROR
)
if
(
WSAAddressToString
W
(
sa
,
sizeof
(
struct
sockaddr_in6
),
NULL
,
buf
,
(
LPDWORD
)
&
buflen
)
==
SOCKET_ERROR
)
Socket_error
(
"WSAAddressToString"
,
sock
);
Socket_error
(
"WSAAddressToString"
,
sock
);
else
else
wcstombs
(
addr_string
,
buf
,
sizeof
(
addr_string
));
wcstombs
(
addr_string
,
buf
,
sizeof
(
addr_string
));
...
@@ -874,4 +874,3 @@ int main(int argc, char *argv[])
...
@@ -874,4 +874,3 @@ int main(int argc, char *argv[])
}
}
#endif
#endif
src/Socket.h
View file @
b880d34f
...
@@ -25,12 +25,19 @@
...
@@ -25,12 +25,19 @@
#include <ws2tcpip.h>
#include <ws2tcpip.h>
#define MAXHOSTNAMELEN 256
#define MAXHOSTNAMELEN 256
#if !defined(SSLSOCKET_H)
#if !defined(SSLSOCKET_H)
#undef EAGAIN
#define EAGAIN WSAEWOULDBLOCK
#define EAGAIN WSAEWOULDBLOCK
#undef EINTR
#define EINTR WSAEINTR
#define EINTR WSAEINTR
#undef EINPROGRESS
#define EINPROGRESS WSAEINPROGRESS
#define EINPROGRESS WSAEINPROGRESS
#undef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#undef ENOTCONN
#define ENOTCONN WSAENOTCONN
#define ENOTCONN WSAENOTCONN
#undef ECONNRESET
#define ECONNRESET WSAECONNRESET
#define ECONNRESET WSAECONNRESET
#undef ETIMEDOUT
#define ETIMEDOUT WAIT_TIMEOUT
#define ETIMEDOUT WAIT_TIMEOUT
#endif
#endif
#define ioctl ioctlsocket
#define ioctl ioctlsocket
...
...
src/Thread.c
View file @
b880d34f
...
@@ -90,6 +90,8 @@ mutex_type Thread_create_mutex(void)
...
@@ -90,6 +90,8 @@ mutex_type Thread_create_mutex(void)
FUNC_ENTRY
;
FUNC_ENTRY
;
#if defined(WIN32) || defined(WIN64)
#if defined(WIN32) || defined(WIN64)
mutex
=
CreateMutex
(
NULL
,
0
,
NULL
);
mutex
=
CreateMutex
(
NULL
,
0
,
NULL
);
if
(
mutex
==
NULL
)
rc
=
GetLastError
();
#else
#else
mutex
=
malloc
(
sizeof
(
pthread_mutex_t
));
mutex
=
malloc
(
sizeof
(
pthread_mutex_t
));
rc
=
pthread_mutex_init
(
mutex
,
NULL
);
rc
=
pthread_mutex_init
(
mutex
,
NULL
);
...
@@ -100,8 +102,7 @@ mutex_type Thread_create_mutex(void)
...
@@ -100,8 +102,7 @@ mutex_type Thread_create_mutex(void)
/**
/**
* Lock a mutex which has already been created, block until ready
* Lock a mutex which has alrea
* @param mutex the mutex
* @return completion code, 0 is success
* @return completion code, 0 is success
*/
*/
int
Thread_lock_mutex
(
mutex_type
mutex
)
int
Thread_lock_mutex
(
mutex_type
mutex
)
...
...
src/samples/CMakeLists.txt
View file @
b880d34f
...
@@ -24,6 +24,10 @@ INCLUDE_DIRECTORIES(
...
@@ -24,6 +24,10 @@ INCLUDE_DIRECTORIES(
${
CMAKE_BINARY_DIR
}
${
CMAKE_BINARY_DIR
}
)
)
IF
(
WIN32
)
ADD_DEFINITIONS
(
/DCMAKE_BUILD /D_CRT_SECURE_NO_DEPRECATE
)
ENDIF
()
# sample files c
# sample files c
ADD_EXECUTABLE
(
paho_c_pub paho_c_pub.c
)
ADD_EXECUTABLE
(
paho_c_pub paho_c_pub.c
)
ADD_EXECUTABLE
(
paho_c_sub paho_c_sub.c
)
ADD_EXECUTABLE
(
paho_c_sub paho_c_sub.c
)
...
...
src/samples/MQTTClient_publish_async.c
View file @
b880d34f
...
@@ -81,7 +81,7 @@ int main(int argc, char* argv[])
...
@@ -81,7 +81,7 @@ int main(int argc, char* argv[])
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
pubmsg
.
payload
=
PAYLOAD
;
pubmsg
.
payload
=
PAYLOAD
;
pubmsg
.
payloadlen
=
strlen
(
PAYLOAD
);
pubmsg
.
payloadlen
=
(
int
)
strlen
(
PAYLOAD
);
pubmsg
.
qos
=
QOS
;
pubmsg
.
qos
=
QOS
;
pubmsg
.
retained
=
0
;
pubmsg
.
retained
=
0
;
deliveredtoken
=
0
;
deliveredtoken
=
0
;
...
@@ -94,4 +94,3 @@ int main(int argc, char* argv[])
...
@@ -94,4 +94,3 @@ int main(int argc, char* argv[])
MQTTClient_destroy
(
&
client
);
MQTTClient_destroy
(
&
client
);
return
rc
;
return
rc
;
}
}
src/samples/paho_c_pub.c
View file @
b880d34f
...
@@ -135,7 +135,6 @@ void onConnectFailure(void* context, MQTTAsync_failureData* response)
...
@@ -135,7 +135,6 @@ void onConnectFailure(void* context, MQTTAsync_failureData* response)
void
onConnect
(
void
*
context
,
MQTTAsync_successData
*
response
)
void
onConnect
(
void
*
context
,
MQTTAsync_successData
*
response
)
{
{
MQTTAsync
client
=
(
MQTTAsync
)
context
;
MQTTAsync
client
=
(
MQTTAsync
)
context
;
int
rc
;
printf
(
"Connected
\n
"
);
printf
(
"Connected
\n
"
);
connected
=
1
;
connected
=
1
;
...
@@ -250,7 +249,7 @@ int main(int argc, char** argv)
...
@@ -250,7 +249,7 @@ int main(int argc, char** argv)
int
data_len
=
0
;
int
data_len
=
0
;
int
delim_len
=
0
;
int
delim_len
=
0
;
delim_len
=
strlen
(
opts
.
delimiter
);
delim_len
=
(
int
)
strlen
(
opts
.
delimiter
);
do
do
{
{
buffer
[
data_len
++
]
=
getchar
();
buffer
[
data_len
++
]
=
getchar
();
...
@@ -382,4 +381,3 @@ void getopts(int argc, char** argv)
...
@@ -382,4 +381,3 @@ void getopts(int argc, char** argv)
}
}
}
}
src/samples/paho_cs_pub.c
View file @
b880d34f
...
@@ -162,7 +162,7 @@ int main(int argc, char** argv)
...
@@ -162,7 +162,7 @@ int main(int argc, char** argv)
int
data_len
=
0
;
int
data_len
=
0
;
int
delim_len
=
0
;
int
delim_len
=
0
;
delim_len
=
strlen
(
opts
.
delimiter
);
delim_len
=
(
int
)
strlen
(
opts
.
delimiter
);
do
do
{
{
buffer
[
data_len
++
]
=
getchar
();
buffer
[
data_len
++
]
=
getchar
();
...
@@ -276,4 +276,3 @@ void getopts(int argc, char** argv)
...
@@ -276,4 +276,3 @@ void getopts(int argc, char** argv)
}
}
}
}
test/CMakeLists.txt
View file @
b880d34f
...
@@ -6,7 +6,7 @@ SET(MQTT_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT brok
...
@@ -6,7 +6,7 @@ SET(MQTT_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT brok
SET
(
CERTDIR $ENV{TRAVIS_BUILD_DIR}/test/ssl
)
SET
(
CERTDIR $ENV{TRAVIS_BUILD_DIR}/test/ssl
)
IF
(
WIN32
)
IF
(
WIN32
)
ADD_DEFINITIONS
(
/DCMAKE_BUILD
)
ADD_DEFINITIONS
(
/DCMAKE_BUILD
/D_CRT_SECURE_NO_WARNINGS
)
ENDIF
()
ENDIF
()
...
@@ -313,5 +313,3 @@ ADD_TEST(
...
@@ -313,5 +313,3 @@ ADD_TEST(
NAME test9-5-offline-buffering-max-buffered
NAME test9-5-offline-buffering-max-buffered
COMMAND test9
"--test_no"
"5"
"--connection"
${
MQTT_TEST_BROKER
}
"--proxy_connection"
${
MQTT_TEST_PROXY
}
COMMAND test9
"--test_no"
"5"
"--connection"
${
MQTT_TEST_BROKER
}
"--proxy_connection"
${
MQTT_TEST_PROXY
}
)
)
test/test1.c
View file @
b880d34f
...
@@ -39,16 +39,8 @@
...
@@ -39,16 +39,8 @@
#include <unistd.h>
#include <unistd.h>
#include <errno.h>
#include <errno.h>
#else
#else
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#define setenv(a, b, c) _putenv_s(a, b)
#define MAXHOSTNAMELEN 256
#define EAGAIN WSAEWOULDBLOCK
#define EINTR WSAEINTR
#define EINPROGRESS WSAEINPROGRESS
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ENOTCONN WSAENOTCONN
#define ECONNRESET WSAECONNRESET
#define setenv(a, b, c) _putenv_s(a, b)
#endif
#endif
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
...
@@ -1011,7 +1003,7 @@ int test6(struct Options options)
...
@@ -1011,7 +1003,7 @@ int test6(struct Options options)
assert
(
"Good rc from subscribe"
,
rc
==
MQTTCLIENT_SUCCESS
,
"rc was %d
\n
"
,
rc
);
assert
(
"Good rc from subscribe"
,
rc
==
MQTTCLIENT_SUCCESS
,
"rc was %d
\n
"
,
rc
);
/* now send the command which will break the connection and cause the will message to be sent */
/* now send the command which will break the connection and cause the will message to be sent */
rc
=
MQTTClient_publish
(
test6_c1
,
mqttsas_topic
,
strlen
(
"TERMINATE"
),
"TERMINATE"
,
0
,
0
,
NULL
);
rc
=
MQTTClient_publish
(
test6_c1
,
mqttsas_topic
,
(
int
)
strlen
(
"TERMINATE"
),
"TERMINATE"
,
0
,
0
,
NULL
);
assert
(
"Good rc from publish"
,
rc
==
MQTTCLIENT_SUCCESS
,
"rc was %d
\n
"
,
rc
);
assert
(
"Good rc from publish"
,
rc
==
MQTTCLIENT_SUCCESS
,
"rc was %d
\n
"
,
rc
);
MyLog
(
LOGA_INFO
,
"Waiting to receive the will message"
);
MyLog
(
LOGA_INFO
,
"Waiting to receive the will message"
);
...
...
test/test2.c
View file @
b880d34f
...
@@ -32,24 +32,8 @@
...
@@ -32,24 +32,8 @@
#include <errno.h>
#include <errno.h>
#define WINAPI
#define WINAPI
#else
#else
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#if !defined(CMAKE_BUILD)
#define setenv(a, b, c) _putenv_s(a, b)
/*
* These causes the cmake build to fail. In order to prevent affecting
* other builds, remove them only from CMAKE-related builds
*/
#include <winsock2.h>
#include <ws2tcpip.h>
#endif // CMAKE_BUILD
#define MAXHOSTNAMELEN 256
#define EAGAIN WSAEWOULDBLOCK
#define EINTR WSAEINTR
#define EINPROGRESS WSAEINPROGRESS
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ENOTCONN WSAENOTCONN
#define ECONNRESET WSAECONNRESET
#define setenv(a, b, c) _putenv_s(a, b)
#endif
#endif
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
...
...
test/test3.c
View file @
b880d34f
...
@@ -30,15 +30,8 @@
...
@@ -30,15 +30,8 @@
#include <unistd.h>
#include <unistd.h>
#include <errno.h>
#include <errno.h>
#else
#else
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#define MAXHOSTNAMELEN 256
#define MAXHOSTNAMELEN 256
#define EAGAIN WSAEWOULDBLOCK
#define EINTR WSAEINTR
#define EINPROGRESS WSAEINPROGRESS
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ENOTCONN WSAENOTCONN
#define ECONNRESET WSAECONNRESET
#define snprintf _snprintf
#define snprintf _snprintf
#define setenv(a, b, c) _putenv_s(a, b)
#define setenv(a, b, c) _putenv_s(a, b)
#endif
#endif
...
...
test/test4.c
View file @
b880d34f
...
@@ -33,15 +33,7 @@
...
@@ -33,15 +33,7 @@
#include <unistd.h>
#include <unistd.h>
#include <errno.h>
#include <errno.h>
#else
#else
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#define MAXHOSTNAMELEN 256
#define EAGAIN WSAEWOULDBLOCK
#define EINTR WSAEINTR
#define EINPROGRESS WSAEINPROGRESS
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ENOTCONN WSAENOTCONN
#define ECONNRESET WSAECONNRESET
#endif
#endif
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
...
...
test/test5.c
View file @
b880d34f
...
@@ -37,15 +37,8 @@
...
@@ -37,15 +37,8 @@
#include <unistd.h>
#include <unistd.h>
#include <errno.h>
#include <errno.h>
#else
#else
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#define MAXHOSTNAMELEN 256
#define MAXHOSTNAMELEN 256
#define EAGAIN WSAEWOULDBLOCK
#define EINTR WSAEINTR
#define EINPROGRESS WSAEINPROGRESS
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ENOTCONN WSAENOTCONN
#define ECONNRESET WSAECONNRESET
#define snprintf _snprintf
#define snprintf _snprintf
#endif
#endif
...
@@ -2071,4 +2064,3 @@ int main(int argc, char** argv)
...
@@ -2071,4 +2064,3 @@ int main(int argc, char** argv)
return
rc
;
return
rc
;
}
}
test/test6.c
View file @
b880d34f
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
#include <unistd.h>
#include <unistd.h>
#include <signal.h>
#include <signal.h>
#else
#else
#include <win
sock2
.h>
#include <win
dows
.h>
#endif
#endif
void
usage
(
void
)
void
usage
(
void
)
...
@@ -332,7 +332,7 @@ int control_send(char* message)
...
@@ -332,7 +332,7 @@ int control_send(char* message)
MQTTAsync_responseOptions
ropts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_responseOptions
ropts
=
MQTTAsync_responseOptions_initializer
;
sprintf
(
buf
,
"%s: %s"
,
opts
.
clientid
,
message
);
sprintf
(
buf
,
"%s: %s"
,
opts
.
clientid
,
message
);
rc
=
MQTTAsync_send
(
control_client
,
pub_topic
,
strlen
(
buf
),
rc
=
MQTTAsync_send
(
control_client
,
pub_topic
,
(
int
)
strlen
(
buf
),
buf
,
1
,
0
,
&
ropts
);
buf
,
1
,
0
,
&
ropts
);
MyLog
(
LOGA_DEBUG
,
"Control message sent: %s"
,
buf
);
MyLog
(
LOGA_DEBUG
,
"Control message sent: %s"
,
buf
);
...
@@ -636,7 +636,7 @@ void one_iteration(void)
...
@@ -636,7 +636,7 @@ void one_iteration(void)
sprintf
(
payload
,
"message number %d"
,
i
);
sprintf
(
payload
,
"message number %d"
,
i
);
rc
=
MQTTAsync_send
(
client
,
opts
.
topic
,
strlen
(
payload
)
+
1
,
payload
,
rc
=
MQTTAsync_send
(
client
,
opts
.
topic
,
(
int
)(
strlen
(
payload
)
+
1
)
,
payload
,
opts
.
qos
,
opts
.
retained
,
NULL
);
opts
.
qos
,
opts
.
retained
,
NULL
);
while
(
rc
!=
MQTTASYNC_SUCCESS
)
while
(
rc
!=
MQTTASYNC_SUCCESS
)
{
{
...
@@ -645,7 +645,7 @@ void one_iteration(void)
...
@@ -645,7 +645,7 @@ void one_iteration(void)
if
(
stopping
)
if
(
stopping
)
goto
exit
;
goto
exit
;
mqsleep
(
1
);
mqsleep
(
1
);
rc
=
MQTTAsync_send
(
client
,
opts
.
topic
,
strlen
(
payload
)
+
1
,
payload
,
rc
=
MQTTAsync_send
(
client
,
opts
.
topic
,
(
int
)(
strlen
(
payload
)
+
1
)
,
payload
,
opts
.
qos
,
opts
.
retained
,
NULL
);
opts
.
qos
,
opts
.
retained
,
NULL
);
}
}
}
}
...
@@ -687,7 +687,7 @@ void one_iteration(void)
...
@@ -687,7 +687,7 @@ void one_iteration(void)
ropts
.
onSuccess
=
messageSent
;
ropts
.
onSuccess
=
messageSent
;
seqno
++
;
seqno
++
;
sprintf
(
payload
,
"message number %d"
,
seqno
);
sprintf
(
payload
,
"message number %d"
,
seqno
);
rc
=
MQTTAsync_send
(
client
,
opts
.
topic
,
strlen
(
payload
)
+
1
,
payload
,
rc
=
MQTTAsync_send
(
client
,
opts
.
topic
,
(
int
)(
strlen
(
payload
)
+
1
)
,
payload
,
opts
.
qos
,
opts
.
retained
,
&
ropts
);
opts
.
qos
,
opts
.
retained
,
&
ropts
);
while
(
rc
!=
MQTTASYNC_SUCCESS
)
while
(
rc
!=
MQTTASYNC_SUCCESS
)
{
{
...
@@ -697,7 +697,7 @@ void one_iteration(void)
...
@@ -697,7 +697,7 @@ void one_iteration(void)
if
(
stopping
)
if
(
stopping
)
goto
exit
;
goto
exit
;
mqsleep
(
1
);
mqsleep
(
1
);
rc
=
MQTTAsync_send
(
client
,
opts
.
topic
,
strlen
(
payload
)
+
1
,
payload
,
rc
=
MQTTAsync_send
(
client
,
opts
.
topic
,
(
int
)(
strlen
(
payload
)
+
1
)
,
payload
,
opts
.
qos
,
opts
.
retained
,
&
ropts
);
opts
.
qos
,
opts
.
retained
,
&
ropts
);
}
}
//MyLog(LOGA_DEBUG, "Successful publish with payload %s", payload);
//MyLog(LOGA_DEBUG, "Successful publish with payload %s", payload);
...
...
test/test8.c
View file @
b880d34f
...
@@ -33,15 +33,7 @@
...
@@ -33,15 +33,7 @@
#include <unistd.h>
#include <unistd.h>
#include <errno.h>
#include <errno.h>
#else
#else
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#define MAXHOSTNAMELEN 256
#define EAGAIN WSAEWOULDBLOCK
#define EINTR WSAEINTR
#define EINPROGRESS WSAEINPROGRESS
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ENOTCONN WSAENOTCONN
#define ECONNRESET WSAECONNRESET
#endif
#endif
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
...
@@ -321,7 +313,6 @@ void test1_onConnectFailure(void* context, MQTTAsync_failureData* response)
...
@@ -321,7 +313,6 @@ void test1_onConnectFailure(void* context, MQTTAsync_failureData* response)
{
{
MQTTAsync
c
=
(
MQTTAsync
)
context
;
MQTTAsync
c
=
(
MQTTAsync
)
context
;
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
int
rc
;
MyLog
(
LOGA_DEBUG
,
"In connect onFailure callback, context %p"
,
context
);
MyLog
(
LOGA_DEBUG
,
"In connect onFailure callback, context %p"
,
context
);
...
@@ -695,7 +686,7 @@ int test3(struct Options options)
...
@@ -695,7 +686,7 @@ int test3(struct Options options)
for
(
i
=
0
;
i
<
num_clients
;
++
i
)
for
(
i
=
0
;
i
<
num_clients
;
++
i
)
MQTTAsync_destroy
(
&
clientdata
[
i
].
c
);
MQTTAsync_destroy
(
&
clientdata
[
i
].
c
);
exit:
/*exit:*/
MyLog
(
LOGA_INFO
,
"TEST3: test %s. %d tests run, %d failures."
,
MyLog
(
LOGA_INFO
,
"TEST3: test %s. %d tests run, %d failures."
,
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
...
...
test/test9.c
View file @
b880d34f
...
@@ -34,15 +34,7 @@
...
@@ -34,15 +34,7 @@
#include <unistd.h>
#include <unistd.h>
#include <errno.h>
#include <errno.h>
#else
#else
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#define MAXHOSTNAMELEN 256
#define EAGAIN WSAEWOULDBLOCK
#define EINTR WSAEINTR
#define EINPROGRESS WSAEINPROGRESS
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ENOTCONN WSAENOTCONN
#define ECONNRESET WSAECONNRESET
#endif
#endif
char
unique
[
50
];
// unique suffix/prefix to add to clientid/topic etc
char
unique
[
50
];
// unique suffix/prefix to add to clientid/topic etc
...
@@ -328,7 +320,7 @@ void test1cOnConnect(void* context, MQTTAsync_successData* response)
...
@@ -328,7 +320,7 @@ void test1cOnConnect(void* context, MQTTAsync_successData* response)
/* send a message to the proxy to break the connection */
/* send a message to the proxy to break the connection */
pubmsg
.
payload
=
"TERMINATE"
;
pubmsg
.
payload
=
"TERMINATE"
;
pubmsg
.
payloadlen
=
strlen
(
pubmsg
.
payload
);
pubmsg
.
payloadlen
=
(
int
)
strlen
(
pubmsg
.
payload
);
pubmsg
.
qos
=
0
;
pubmsg
.
qos
=
0
;
pubmsg
.
retained
=
0
;
pubmsg
.
retained
=
0
;
rc
=
MQTTAsync_sendMessage
(
c
,
"MQTTSAS topic"
,
&
pubmsg
,
NULL
);
rc
=
MQTTAsync_sendMessage
(
c
,
"MQTTSAS topic"
,
&
pubmsg
,
NULL
);
...
@@ -487,7 +479,7 @@ int test1(struct Options options)
...
@@ -487,7 +479,7 @@ int test1(struct Options options)
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
sprintf
(
buf
,
"QoS %d message"
,
i
);
sprintf
(
buf
,
"QoS %d message"
,
i
);
pubmsg
.
payload
=
buf
;
pubmsg
.
payload
=
buf
;
pubmsg
.
payloadlen
=
strlen
(
pubmsg
.
payload
)
+
1
;
pubmsg
.
payloadlen
=
(
int
)
strlen
(
pubmsg
.
payload
)
+
1
;
pubmsg
.
qos
=
i
;
pubmsg
.
qos
=
i
;
pubmsg
.
retained
=
0
;
pubmsg
.
retained
=
0
;
rc
=
MQTTAsync_sendMessage
(
c
,
test_topic
,
&
pubmsg
,
&
opts
);
rc
=
MQTTAsync_sendMessage
(
c
,
test_topic
,
&
pubmsg
,
&
opts
);
...
@@ -604,7 +596,7 @@ void test2cOnConnect(void* context, MQTTAsync_successData* response)
...
@@ -604,7 +596,7 @@ void test2cOnConnect(void* context, MQTTAsync_successData* response)
/* send a message to the proxy to break the connection */
/* send a message to the proxy to break the connection */
pubmsg
.
payload
=
"TERMINATE"
;
pubmsg
.
payload
=
"TERMINATE"
;
pubmsg
.
payloadlen
=
strlen
(
pubmsg
.
payload
);
pubmsg
.
payloadlen
=
(
int
)
strlen
(
pubmsg
.
payload
);
pubmsg
.
qos
=
0
;
pubmsg
.
qos
=
0
;
pubmsg
.
retained
=
0
;
pubmsg
.
retained
=
0
;
rc
=
MQTTAsync_sendMessage
(
c
,
"MQTTSAS topic"
,
&
pubmsg
,
NULL
);
rc
=
MQTTAsync_sendMessage
(
c
,
"MQTTSAS topic"
,
&
pubmsg
,
NULL
);
...
@@ -764,7 +756,7 @@ int test2(struct Options options)
...
@@ -764,7 +756,7 @@ int test2(struct Options options)
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
sprintf
(
buf
,
"QoS %d message"
,
i
);
sprintf
(
buf
,
"QoS %d message"
,
i
);
pubmsg
.
payload
=
buf
;
pubmsg
.
payload
=
buf
;
pubmsg
.
payloadlen
=
strlen
(
pubmsg
.
payload
)
+
1
;
pubmsg
.
payloadlen
=
(
int
)(
strlen
(
pubmsg
.
payload
)
+
1
)
;
pubmsg
.
qos
=
i
;
pubmsg
.
qos
=
i
;
pubmsg
.
retained
=
0
;
pubmsg
.
retained
=
0
;
rc
=
MQTTAsync_sendMessage
(
c
,
test_topic
,
&
pubmsg
,
&
opts
);
rc
=
MQTTAsync_sendMessage
(
c
,
test_topic
,
&
pubmsg
,
&
opts
);
...
@@ -880,7 +872,7 @@ void test3cOnConnect(void* context, MQTTAsync_successData* response)
...
@@ -880,7 +872,7 @@ void test3cOnConnect(void* context, MQTTAsync_successData* response)
/* send a message to the proxy to break the connection */
/* send a message to the proxy to break the connection */
pubmsg
.
payload
=
"TERMINATE"
;
pubmsg
.
payload
=
"TERMINATE"
;
pubmsg
.
payloadlen
=
strlen
(
pubmsg
.
payload
);
pubmsg
.
payloadlen
=
(
int
)
strlen
(
pubmsg
.
payload
);
pubmsg
.
qos
=
0
;
pubmsg
.
qos
=
0
;
pubmsg
.
retained
=
0
;
pubmsg
.
retained
=
0
;
rc
=
MQTTAsync_sendMessage
(
c
,
"MQTTSAS topic"
,
&
pubmsg
,
NULL
);
rc
=
MQTTAsync_sendMessage
(
c
,
"MQTTSAS topic"
,
&
pubmsg
,
NULL
);
...
@@ -1040,7 +1032,7 @@ int test3(struct Options options)
...
@@ -1040,7 +1032,7 @@ int test3(struct Options options)
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
sprintf
(
buf
,
"QoS %d message"
,
i
);
sprintf
(
buf
,
"QoS %d message"
,
i
);
pubmsg
.
payload
=
buf
;
pubmsg
.
payload
=
buf
;
pubmsg
.
payloadlen
=
strlen
(
pubmsg
.
payload
)
+
1
;
pubmsg
.
payloadlen
=
(
int
)(
strlen
(
pubmsg
.
payload
)
+
1
)
;
pubmsg
.
qos
=
i
;
pubmsg
.
qos
=
i
;
pubmsg
.
retained
=
0
;
pubmsg
.
retained
=
0
;
rc
=
MQTTAsync_sendMessage
(
c
,
test_topic
,
&
pubmsg
,
&
opts
);
rc
=
MQTTAsync_sendMessage
(
c
,
test_topic
,
&
pubmsg
,
&
opts
);
...
@@ -1154,7 +1146,7 @@ void test4cOnConnect(void* context, MQTTAsync_successData* response)
...
@@ -1154,7 +1146,7 @@ void test4cOnConnect(void* context, MQTTAsync_successData* response)
/* send a message to the proxy to break the connection */
/* send a message to the proxy to break the connection */
pubmsg
.
payload
=
"TERMINATE"
;
pubmsg
.
payload
=
"TERMINATE"
;
pubmsg
.
payloadlen
=
strlen
(
pubmsg
.
payload
);
pubmsg
.
payloadlen
=
(
int
)
strlen
(
pubmsg
.
payload
);
pubmsg
.
qos
=
0
;
pubmsg
.
qos
=
0
;
pubmsg
.
retained
=
0
;
pubmsg
.
retained
=
0
;
rc
=
MQTTAsync_sendMessage
(
c
,
"MQTTSAS topic"
,
&
pubmsg
,
NULL
);
rc
=
MQTTAsync_sendMessage
(
c
,
"MQTTSAS topic"
,
&
pubmsg
,
NULL
);
...
@@ -1315,7 +1307,7 @@ int test4(struct Options options)
...
@@ -1315,7 +1307,7 @@ int test4(struct Options options)
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
sprintf
(
buf
,
"QoS %d message"
,
i
);
sprintf
(
buf
,
"QoS %d message"
,
i
);
pubmsg
.
payload
=
buf
;
pubmsg
.
payload
=
buf
;
pubmsg
.
payloadlen
=
strlen
(
pubmsg
.
payload
)
+
1
;
pubmsg
.
payloadlen
=
(
int
)(
strlen
(
pubmsg
.
payload
)
+
1
)
;
pubmsg
.
qos
=
i
;
pubmsg
.
qos
=
i
;
pubmsg
.
retained
=
0
;
pubmsg
.
retained
=
0
;
rc
=
MQTTAsync_sendMessage
(
c
,
test_topic
,
&
pubmsg
,
&
opts
);
rc
=
MQTTAsync_sendMessage
(
c
,
test_topic
,
&
pubmsg
,
&
opts
);
...
@@ -1429,7 +1421,7 @@ void test5cOnConnect(void* context, MQTTAsync_successData* response)
...
@@ -1429,7 +1421,7 @@ void test5cOnConnect(void* context, MQTTAsync_successData* response)
/* send a message to the proxy to break the connection */
/* send a message to the proxy to break the connection */
pubmsg
.
payload
=
"TERMINATE"
;
pubmsg
.
payload
=
"TERMINATE"
;
pubmsg
.
payloadlen
=
strlen
(
pubmsg
.
payload
);
pubmsg
.
payloadlen
=
(
int
)
strlen
(
pubmsg
.
payload
);
pubmsg
.
qos
=
0
;
pubmsg
.
qos
=
0
;
pubmsg
.
retained
=
0
;
pubmsg
.
retained
=
0
;
rc
=
MQTTAsync_sendMessage
(
c
,
"MQTTSAS topic"
,
&
pubmsg
,
NULL
);
rc
=
MQTTAsync_sendMessage
(
c
,
"MQTTSAS topic"
,
&
pubmsg
,
NULL
);
...
@@ -1589,7 +1581,7 @@ int test5(struct Options options)
...
@@ -1589,7 +1581,7 @@ int test5(struct Options options)
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
sprintf
(
buf
,
"QoS %d message"
,
i
);
sprintf
(
buf
,
"QoS %d message"
,
i
);
pubmsg
.
payload
=
buf
;
pubmsg
.
payload
=
buf
;
pubmsg
.
payloadlen
=
strlen
(
pubmsg
.
payload
)
+
1
;
pubmsg
.
payloadlen
=
(
int
)(
strlen
(
pubmsg
.
payload
)
+
1
)
;
pubmsg
.
qos
=
i
%
3
;
pubmsg
.
qos
=
i
%
3
;
pubmsg
.
retained
=
0
;
pubmsg
.
retained
=
0
;
rc
=
MQTTAsync_sendMessage
(
c
,
test_topic
,
&
pubmsg
,
&
opts
);
rc
=
MQTTAsync_sendMessage
(
c
,
test_topic
,
&
pubmsg
,
&
opts
);
...
@@ -1664,7 +1656,7 @@ int main(int argc, char** argv)
...
@@ -1664,7 +1656,7 @@ int main(int argc, char** argv)
MyLog
(
LOGA_INFO
,
"Random prefix/suffix is %s"
,
unique
);
MyLog
(
LOGA_INFO
,
"Random prefix/suffix is %s"
,
unique
);
xml
=
fopen
(
"TEST-test9.xml"
,
"w"
);
xml
=
fopen
(
"TEST-test9.xml"
,
"w"
);
fprintf
(
xml
,
"<testsuite name=
\"
test9
\"
tests=
\"
%
lu
\"
>
\n
"
,
ARRAY_SIZE
(
tests
)
-
1
);
fprintf
(
xml
,
"<testsuite name=
\"
test9
\"
tests=
\"
%
d
\"
>
\n
"
,
(
int
)(
ARRAY_SIZE
(
tests
)
-
1
)
);
MQTTAsync_setTraceCallback
(
handleTrace
);
MQTTAsync_setTraceCallback
(
handleTrace
);
getopts
(
argc
,
argv
);
getopts
(
argc
,
argv
);
...
@@ -1695,4 +1687,3 @@ int main(int argc, char** argv)
...
@@ -1695,4 +1687,3 @@ int main(int argc, char** argv)
return
rc
;
return
rc
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment