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
a5cbbbd4
Commit
a5cbbbd4
authored
Jul 27, 2017
by
Ian Craggs
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'VxWorksSupport' of
https://github.com/rpoisel/paho.mqtt.c
into develop
PR #295
parents
2d42fa7d
a16cff63
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
156 additions
and
50 deletions
+156
-50
Heap.c
src/Heap.c
+1
-2
Heap.h
src/Heap.h
+0
-1
LinkedList.c
src/LinkedList.c
+1
-2
LinkedList.h
src/LinkedList.h
+1
-1
Log.c
src/Log.c
+1
-1
MQTTAsync.c
src/MQTTAsync.c
+6
-0
MQTTAsync.h
src/MQTTAsync.h
+4
-0
MQTTClient.c
src/MQTTClient.c
+7
-0
MQTTClient.h
src/MQTTClient.h
+4
-0
MQTTClientPersistence.h
src/MQTTClientPersistence.h
+4
-0
MQTTPacketOut.c
src/MQTTPacketOut.c
+2
-2
MQTTPersistence.c
src/MQTTPersistence.c
+1
-1
MQTTPersistenceDefault.c
src/MQTTPersistenceDefault.c
+7
-2
MQTTProtocolClient.c
src/MQTTProtocolClient.c
+1
-0
MQTTProtocolOut.c
src/MQTTProtocolOut.c
+1
-0
MQTTVersion.c
src/MQTTVersion.c
+10
-1
Messages.c
src/Messages.c
+0
-1
OsWrapper.c
src/OsWrapper.c
+28
-0
OsWrapper.h
src/OsWrapper.h
+42
-0
SSLSocket.c
src/SSLSocket.c
+1
-1
Socket.c
src/Socket.c
+1
-4
Socket.h
src/Socket.h
+5
-1
SocketBuffer.c
src/SocketBuffer.c
+1
-1
Thread.c
src/Thread.c
+6
-5
Tree.c
src/Tree.c
+4
-5
Tree.h
src/Tree.h
+1
-1
MQTTAsync_publish.c
src/samples/MQTTAsync_publish.c
+2
-2
MQTTAsync_subscribe.c
src/samples/MQTTAsync_subscribe.c
+2
-3
paho_c_pub.c
src/samples/paho_c_pub.c
+4
-6
paho_c_sub.c
src/samples/paho_c_sub.c
+3
-2
paho_cs_pub.c
src/samples/paho_cs_pub.c
+2
-2
paho_cs_sub.c
src/samples/paho_cs_sub.c
+1
-1
MQTTTest_v2.c
test/MQTTTest_v2.c
+2
-2
No files found.
src/Heap.c
View file @
a5cbbbd4
...
@@ -35,7 +35,6 @@
...
@@ -35,7 +35,6 @@
char
*
Broker_recordFFDC
(
char
*
symptoms
);
char
*
Broker_recordFFDC
(
char
*
symptoms
);
#endif
/* HEAP_UNIT_TESTS */
#endif
/* HEAP_UNIT_TESTS */
#include <memory.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <stdio.h>
#include <stdio.h>
...
@@ -228,7 +227,7 @@ static int Internal_heap_unlink(char* file, int line, void* p)
...
@@ -228,7 +227,7 @@ static int Internal_heap_unlink(char* file, int line, void* p)
Log
(
TRACE_MAX
,
-
1
,
"Freeing %d bytes in heap at file %s line %d, heap use now %d bytes
\n
"
,
Log
(
TRACE_MAX
,
-
1
,
"Freeing %d bytes in heap at file %s line %d, heap use now %d bytes
\n
"
,
s
->
size
,
file
,
line
,
state
.
current_size
);
s
->
size
,
file
,
line
,
state
.
current_size
);
checkEyecatchers
(
file
,
line
,
p
,
s
->
size
);
checkEyecatchers
(
file
,
line
,
p
,
s
->
size
);
/
/free(s->ptr);
/
* free(s->ptr); */
free
(
s
->
file
);
free
(
s
->
file
);
state
.
current_size
-=
s
->
size
;
state
.
current_size
-=
s
->
size
;
TreeRemoveNodeIndex
(
&
heap
,
e
,
0
);
TreeRemoveNodeIndex
(
&
heap
,
e
,
0
);
...
...
src/Heap.h
View file @
a5cbbbd4
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
#endif
#endif
#include <stdio.h>
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
#include <stdlib.h>
#if !defined(NO_HEAP_TRACKING)
#if !defined(NO_HEAP_TRACKING)
...
...
src/LinkedList.c
View file @
a5cbbbd4
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <memory.h>
#include "Heap.h"
#include "Heap.h"
...
@@ -474,7 +473,7 @@ int main(int argc, char *argv[])
...
@@ -474,7 +473,7 @@ int main(int argc, char *argv[])
while
(
ListPrevElement
(
l
,
&
current
)
!=
NULL
)
while
(
ListPrevElement
(
l
,
&
current
)
!=
NULL
)
printf
(
"List element: %d
\n
"
,
*
((
int
*
)(
current
->
content
)));
printf
(
"List element: %d
\n
"
,
*
((
int
*
)(
current
->
content
)));
/
/if ListFindItem(l, *ip, intcompare)->content
/
* if ListFindItem(l, *ip, intcompare)->content */
printf
(
"List contents having deleted element %d:
\n
"
,
*
todelete
);
printf
(
"List contents having deleted element %d:
\n
"
,
*
todelete
);
ListRemove
(
l
,
todelete
);
ListRemove
(
l
,
todelete
);
...
...
src/LinkedList.h
View file @
a5cbbbd4
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#if !defined(LINKEDLIST_H)
#if !defined(LINKEDLIST_H)
#define LINKEDLIST_H
#define LINKEDLIST_H
#include <stdlib.h> /
/ for size_t definition
#include <stdlib.h>
/
* for size_t definition */
/*BE
/*BE
defm defList(T)
defm defList(T)
...
...
src/Log.c
View file @
a5cbbbd4
...
@@ -301,7 +301,7 @@ static char* Log_formatTraceEntry(traceEntry* cur_entry)
...
@@ -301,7 +301,7 @@ static char* Log_formatTraceEntry(traceEntry* cur_entry)
int
buf_pos
=
31
;
int
buf_pos
=
31
;
#if defined(GETTIMEOFDAY)
#if defined(GETTIMEOFDAY)
timeinfo
=
localtime
(
&
cur_entry
->
ts
.
tv_sec
);
timeinfo
=
localtime
(
(
time_t
*
)
&
cur_entry
->
ts
.
tv_sec
);
#else
#else
timeinfo
=
localtime
(
&
cur_entry
->
ts
.
time
);
timeinfo
=
localtime
(
&
cur_entry
->
ts
.
time
);
#endif
#endif
...
...
src/MQTTAsync.c
View file @
a5cbbbd4
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#define _GNU_SOURCE
/* for pthread_mutexattr_settype */
#define _GNU_SOURCE
/* for pthread_mutexattr_settype */
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#if !defined(WIN32) && !defined(WIN64)
#if !defined(WIN32) && !defined(WIN64)
#include <sys/time.h>
#include <sys/time.h>
#endif
#endif
...
@@ -58,6 +59,7 @@
...
@@ -58,6 +59,7 @@
#include "SocketBuffer.h"
#include "SocketBuffer.h"
#include "StackTrace.h"
#include "StackTrace.h"
#include "Heap.h"
#include "Heap.h"
#include "OsWrapper.h"
#define URI_TCP "tcp://"
#define URI_TCP "tcp://"
...
@@ -156,7 +158,11 @@ void MQTTAsync_init(void)
...
@@ -156,7 +158,11 @@ void MQTTAsync_init(void)
int
rc
;
int
rc
;
pthread_mutexattr_init
(
&
attr
);
pthread_mutexattr_init
(
&
attr
);
#if !defined(_WRS_KERNEL)
pthread_mutexattr_settype
(
&
attr
,
PTHREAD_MUTEX_ERRORCHECK
);
pthread_mutexattr_settype
(
&
attr
,
PTHREAD_MUTEX_ERRORCHECK
);
#else
/* #warning "no pthread_mutexattr_settype" */
#endif
if
((
rc
=
pthread_mutex_init
(
mqttasync_mutex
,
&
attr
))
!=
0
)
if
((
rc
=
pthread_mutex_init
(
mqttasync_mutex
,
&
attr
))
!=
0
)
printf
(
"MQTTAsync: error %d initializing async_mutex
\n
"
,
rc
);
printf
(
"MQTTAsync: error %d initializing async_mutex
\n
"
,
rc
);
if
((
rc
=
pthread_mutex_init
(
mqttcommand_mutex
,
&
attr
))
!=
0
)
if
((
rc
=
pthread_mutex_init
(
mqttcommand_mutex
,
&
attr
))
!=
0
)
...
...
src/MQTTAsync.h
View file @
a5cbbbd4
...
@@ -82,7 +82,9 @@
...
@@ -82,7 +82,9 @@
*/
*/
/*
/// @cond EXCLUDE
/// @cond EXCLUDE
*/
#if defined(__cplusplus)
#if defined(__cplusplus)
extern
"C"
{
extern
"C"
{
#endif
#endif
...
@@ -99,7 +101,9 @@
...
@@ -99,7 +101,9 @@
#endif
#endif
#include <stdio.h>
#include <stdio.h>
/*
/// @endcond
/// @endcond
*/
#if !defined(NO_PERSISTENCE)
#if !defined(NO_PERSISTENCE)
#include "MQTTClientPersistence.h"
#include "MQTTClientPersistence.h"
...
...
src/MQTTClient.c
View file @
a5cbbbd4
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
#define _GNU_SOURCE
/* for pthread_mutexattr_settype */
#define _GNU_SOURCE
/* for pthread_mutexattr_settype */
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#if !defined(WIN32) && !defined(WIN64)
#if !defined(WIN32) && !defined(WIN64)
#include <sys/time.h>
#include <sys/time.h>
#endif
#endif
...
@@ -65,6 +66,8 @@
...
@@ -65,6 +66,8 @@
#define URI_SSL "ssl://"
#define URI_SSL "ssl://"
#endif
#endif
#include "OsWrapper.h"
#define URI_TCP "tcp://"
#define URI_TCP "tcp://"
#include "VersionInfo.h"
#include "VersionInfo.h"
...
@@ -149,7 +152,11 @@ void MQTTClient_init(void)
...
@@ -149,7 +152,11 @@ void MQTTClient_init(void)
int
rc
;
int
rc
;
pthread_mutexattr_init
(
&
attr
);
pthread_mutexattr_init
(
&
attr
);
#if !defined(_WRS_KERNEL)
pthread_mutexattr_settype
(
&
attr
,
PTHREAD_MUTEX_ERRORCHECK
);
pthread_mutexattr_settype
(
&
attr
,
PTHREAD_MUTEX_ERRORCHECK
);
#else
/* #warning "no pthread_mutexattr_settype" */
#endif
/* !defined(_WRS_KERNEL) */
if
((
rc
=
pthread_mutex_init
(
mqttclient_mutex
,
&
attr
))
!=
0
)
if
((
rc
=
pthread_mutex_init
(
mqttclient_mutex
,
&
attr
))
!=
0
)
printf
(
"MQTTClient: error %d initializing client_mutex
\n
"
,
rc
);
printf
(
"MQTTClient: error %d initializing client_mutex
\n
"
,
rc
);
if
((
rc
=
pthread_mutex_init
(
socket_mutex
,
&
attr
))
!=
0
)
if
((
rc
=
pthread_mutex_init
(
socket_mutex
,
&
attr
))
!=
0
)
...
...
src/MQTTClient.h
View file @
a5cbbbd4
...
@@ -100,7 +100,9 @@
...
@@ -100,7 +100,9 @@
* @endcond
* @endcond
*/
*/
/*
/// @cond EXCLUDE
/// @cond EXCLUDE
*/
#if defined(__cplusplus)
#if defined(__cplusplus)
extern
"C"
{
extern
"C"
{
#endif
#endif
...
@@ -116,7 +118,9 @@
...
@@ -116,7 +118,9 @@
#endif
#endif
#include <stdio.h>
#include <stdio.h>
/*
/// @endcond
/// @endcond
*/
#if !defined(NO_PERSISTENCE)
#if !defined(NO_PERSISTENCE)
#include "MQTTClientPersistence.h"
#include "MQTTClientPersistence.h"
...
...
src/MQTTClientPersistence.h
View file @
a5cbbbd4
...
@@ -53,10 +53,14 @@
...
@@ -53,10 +53,14 @@
* may be required to diagnose a persistence mechanism failure.
* may be required to diagnose a persistence mechanism failure.
*/
*/
/*
/// @cond EXCLUDE
/// @cond EXCLUDE
*/
#if !defined(MQTTCLIENTPERSISTENCE_H)
#if !defined(MQTTCLIENTPERSISTENCE_H)
#define MQTTCLIENTPERSISTENCE_H
#define MQTTCLIENTPERSISTENCE_H
/*
/// @endcond
/// @endcond
*/
/**
/**
* This <i>persistence_type</i> value specifies the default file system-based
* This <i>persistence_type</i> value specifies the default file system-based
...
...
src/MQTTPacketOut.c
View file @
a5cbbbd4
...
@@ -178,7 +178,7 @@ int MQTTPacket_send_subscribe(List* topics, List* qoss, int msgid, int dup, netw
...
@@ -178,7 +178,7 @@ int MQTTPacket_send_subscribe(List* topics, List* qoss, int msgid, int dup, netw
header
.
bits
.
qos
=
1
;
header
.
bits
.
qos
=
1
;
header
.
bits
.
retain
=
0
;
header
.
bits
.
retain
=
0
;
datalen
=
2
+
topics
->
count
*
3
;
/
/ utf length + char qos == 3
datalen
=
2
+
topics
->
count
*
3
;
/
* utf length + char qos == 3 */
while
(
ListNextElement
(
topics
,
&
elem
))
while
(
ListNextElement
(
topics
,
&
elem
))
datalen
+=
(
int
)
strlen
((
char
*
)(
elem
->
content
));
datalen
+=
(
int
)
strlen
((
char
*
)(
elem
->
content
));
ptr
=
data
=
malloc
(
datalen
);
ptr
=
data
=
malloc
(
datalen
);
...
@@ -251,7 +251,7 @@ int MQTTPacket_send_unsubscribe(List* topics, int msgid, int dup, networkHandles
...
@@ -251,7 +251,7 @@ int MQTTPacket_send_unsubscribe(List* topics, int msgid, int dup, networkHandles
header
.
bits
.
qos
=
1
;
header
.
bits
.
qos
=
1
;
header
.
bits
.
retain
=
0
;
header
.
bits
.
retain
=
0
;
datalen
=
2
+
topics
->
count
*
2
;
/
/ utf length == 2
datalen
=
2
+
topics
->
count
*
2
;
/
* utf length == 2 */
while
(
ListNextElement
(
topics
,
&
elem
))
while
(
ListNextElement
(
topics
,
&
elem
))
datalen
+=
(
int
)
strlen
((
char
*
)(
elem
->
content
));
datalen
+=
(
int
)
strlen
((
char
*
)(
elem
->
content
));
ptr
=
data
=
malloc
(
datalen
);
ptr
=
data
=
malloc
(
datalen
);
...
...
src/MQTTPersistence.c
View file @
a5cbbbd4
...
@@ -367,7 +367,7 @@ int MQTTPersistence_put(int socket, char* buf0, size_t buf0len, int count,
...
@@ -367,7 +367,7 @@ int MQTTPersistence_put(int socket, char* buf0, size_t buf0len, int count,
bufs
[
i
+
1
]
=
buffers
[
i
];
bufs
[
i
+
1
]
=
buffers
[
i
];
}
}
/
/ key
/
* key */
if
(
scr
==
0
)
if
(
scr
==
0
)
{
/* sending */
{
/* sending */
if
(
htype
==
PUBLISH
)
/* PUBLISH QoS1 and QoS2*/
if
(
htype
==
PUBLISH
)
/* PUBLISH QoS1 and QoS2*/
...
...
src/MQTTPersistenceDefault.c
View file @
a5cbbbd4
...
@@ -29,6 +29,8 @@
...
@@ -29,6 +29,8 @@
#if !defined(NO_PERSISTENCE)
#if !defined(NO_PERSISTENCE)
#include "OsWrapper.h"
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <errno.h>
#include <errno.h>
...
@@ -54,7 +56,6 @@
...
@@ -54,7 +56,6 @@
#include "StackTrace.h"
#include "StackTrace.h"
#include "Heap.h"
#include "Heap.h"
/** Create persistence directory for the client: context/clientID-serverURI.
/** Create persistence directory for the client: context/clientID-serverURI.
* See ::Persistence_open
* See ::Persistence_open
*/
*/
...
@@ -128,7 +129,11 @@ int pstmkdir( char *pPathname )
...
@@ -128,7 +129,11 @@ int pstmkdir( char *pPathname )
{
{
#else
#else
/* Create a directory with read, write and execute access for the owner and read access for the group */
/* Create a directory with read, write and execute access for the owner and read access for the group */
#if !defined(_WRS_KERNEL)
if
(
mkdir
(
pPathname
,
S_IRWXU
|
S_IRGRP
)
!=
0
)
if
(
mkdir
(
pPathname
,
S_IRWXU
|
S_IRGRP
)
!=
0
)
#else
if
(
mkdir
(
pPathname
)
!=
0
)
#endif
/* !defined(_WRS_KERNEL) */
{
{
#endif
#endif
if
(
errno
!=
EEXIST
)
if
(
errno
!=
EEXIST
)
...
@@ -739,7 +744,7 @@ int main (int argc, char *argv[])
...
@@ -739,7 +744,7 @@ int main (int argc, char *argv[])
buflens
[
i
]
=
strlen
(
bufs
[
i
]);
buflens
[
i
]
=
strlen
(
bufs
[
i
]);
/* open */
/* open */
/
/printf("Persistence directory : %s\n", perdir);
/
* printf("Persistence directory : %s\n", perdir); */
rc
=
pstopen
((
void
**
)
&
handle
,
clientID
,
serverURI
,
perdir
);
rc
=
pstopen
((
void
**
)
&
handle
,
clientID
,
serverURI
,
perdir
);
printf
(
"%s Persistence directory for client %s : %s
\n
"
,
RC
,
clientID
,
handle
);
printf
(
"%s Persistence directory for client %s : %s
\n
"
,
RC
,
clientID
,
handle
);
...
...
src/MQTTProtocolClient.c
View file @
a5cbbbd4
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include "MQTTProtocolClient.h"
#include "MQTTProtocolClient.h"
#if !defined(NO_PERSISTENCE)
#if !defined(NO_PERSISTENCE)
...
...
src/MQTTProtocolOut.c
View file @
a5cbbbd4
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
*/
*/
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include "MQTTProtocolOut.h"
#include "MQTTProtocolOut.h"
#include "StackTrace.h"
#include "StackTrace.h"
...
...
src/MQTTVersion.c
View file @
a5cbbbd4
...
@@ -15,12 +15,14 @@
...
@@ -15,12 +15,14 @@
*******************************************************************************/
*******************************************************************************/
#include <stdio.h>
#include <stdio.h>
#if !defined(_WRS_KERNEL)
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/types.h>
#include <memory.h>
#include <ctype.h>
#include <ctype.h>
#include "MQTTAsync.h"
#include "MQTTAsync.h"
...
@@ -219,3 +221,10 @@ int main(int argc, char** argv)
...
@@ -219,3 +221,10 @@ int main(int argc, char** argv)
return
0
;
return
0
;
}
}
#else
int
main
(
void
)
{
fprintf
(
stderr
,
"This tool is not supported on this platform yet.
\n
"
);
return
1
;
}
#endif
/* !defined(_WRS_KERNEL) */
src/Messages.c
View file @
a5cbbbd4
...
@@ -26,7 +26,6 @@
...
@@ -26,7 +26,6 @@
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <string.h>
#include "Heap.h"
#include "Heap.h"
...
...
src/OsWrapper.c
0 → 100644
View file @
a5cbbbd4
/*******************************************************************************
* Copyright (c) 2016, 2017 logi.cals GmbH
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Gunter Raidl - timer support for VxWorks
* Rainer Poisel - reusability
*******************************************************************************/
#include "OsWrapper.h"
#if defined(_WRS_KERNEL)
void
usleep
(
useconds_t
useconds
)
{
struct
timespec
tv
;
tv
.
tv_sec
=
useconds
/
1000000
;
tv
.
tv_nsec
=
(
useconds
%
1000000
)
*
1000
;
nanosleep
(
&
tv
,
NULL
);
}
#endif
/* defined(_WRS_KERNEL) */
src/OsWrapper.h
0 → 100644
View file @
a5cbbbd4
/*******************************************************************************
* Copyright (c) 2016, 2017 logi.cals GmbH
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Gunter Raidl - timer support for VxWorks
* Rainer Poisel - reusability
*******************************************************************************/
#if !defined(OSWRAPPER_H)
#define OSWRAPPER_H
#if defined(_WRS_KERNEL)
#include <time.h>
#define lstat stat
typedef
unsigned
long
useconds_t
;
void
usleep
(
useconds_t
useconds
);
#define timersub(a, b, result) \
do \
{ \
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
if ((result)->tv_usec < 0) \
{ \
--(result)->tv_sec; \
(result)->tv_usec += 1000000L; \
} \
} while (0)
#endif
/* defined(_WRS_KERNEL) */
#endif
/* OSWRAPPER_H */
src/SSLSocket.c
View file @
a5cbbbd4
...
@@ -68,7 +68,7 @@ int SSLSocket_createContext(networkHandles* net, MQTTClient_SSLOptions* opts);
...
@@ -68,7 +68,7 @@ int SSLSocket_createContext(networkHandles* net, MQTTClient_SSLOptions* opts);
void
SSLSocket_destroyContext
(
networkHandles
*
net
);
void
SSLSocket_destroyContext
(
networkHandles
*
net
);
void
SSLSocket_addPendingRead
(
int
sock
);
void
SSLSocket_addPendingRead
(
int
sock
);
/
// 1 ~ we are responsible for initializing openssl; 0 ~ openssl init is done externally
/
* 1 ~ we are responsible for initializing openssl; 0 ~ openssl init is done externally */
static
int
handle_openssl_init
=
1
;
static
int
handle_openssl_init
=
1
;
static
ssl_mutex_type
*
sslLocks
=
NULL
;
static
ssl_mutex_type
*
sslLocks
=
NULL
;
static
ssl_mutex_type
sslCoreMutex
;
static
ssl_mutex_type
sslCoreMutex
;
...
...
src/Socket.c
View file @
a5cbbbd4
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include "SSLSocket.h"
#include "SSLSocket.h"
#endif
#endif
#include <errno.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <signal.h>
#include <signal.h>
...
@@ -98,10 +99,6 @@ int Socket_setnonblocking(int sock)
...
@@ -98,10 +99,6 @@ int Socket_setnonblocking(int sock)
*/
*/
int
Socket_error
(
char
*
aString
,
int
sock
)
int
Socket_error
(
char
*
aString
,
int
sock
)
{
{
#if defined(WIN32) || defined(WIN64)
int
errno
;
#endif
FUNC_ENTRY
;
FUNC_ENTRY
;
#if defined(WIN32) || defined(WIN64)
#if defined(WIN32) || defined(WIN64)
errno
=
WSAGetLastError
();
errno
=
WSAGetLastError
();
...
...
src/Socket.h
View file @
a5cbbbd4
...
@@ -45,9 +45,14 @@
...
@@ -45,9 +45,14 @@
#else
#else
#define INVALID_SOCKET SOCKET_ERROR
#define INVALID_SOCKET SOCKET_ERROR
#include <sys/socket.h>
#include <sys/socket.h>
#if !defined(_WRS_KERNEL)
#include <sys/param.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/select.h>
#include <sys/uio.h>
#else
#include <selectLib.h>
#endif
#include <netinet/in.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <arpa/inet.h>
...
@@ -57,7 +62,6 @@
...
@@ -57,7 +62,6 @@
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
#include <unistd.h>
#include <unistd.h>
#include <sys/uio.h>
#define ULONG size_t
#define ULONG size_t
#endif
#endif
...
...
src/SocketBuffer.c
View file @
a5cbbbd4
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <
memory
.h>
#include <
string
.h>
#include "Heap.h"
#include "Heap.h"
...
...
src/Thread.c
View file @
a5cbbbd4
...
@@ -45,9 +45,10 @@
...
@@ -45,9 +45,10 @@
#include <sys/stat.h>
#include <sys/stat.h>
#include <limits.h>
#include <limits.h>
#endif
#endif
#include <memory.h>
#include <stdlib.h>
#include <stdlib.h>
#include "OsWrapper.h"
/**
/**
* Start a new thread
* Start a new thread
* @param fn the function to run, must be of the correct signature
* @param fn the function to run, must be of the correct signature
...
@@ -190,10 +191,10 @@ sem_type Thread_create_sem(void)
...
@@ -190,10 +191,10 @@ sem_type Thread_create_sem(void)
FUNC_ENTRY
;
FUNC_ENTRY
;
#if defined(WIN32) || defined(WIN64)
#if defined(WIN32) || defined(WIN64)
sem
=
CreateEvent
(
sem
=
CreateEvent
(
NULL
,
/
/ default security attributes
NULL
,
/
* default security attributes */
FALSE
,
/
/ manual-reset event?
FALSE
,
/
* manual-reset event? */
FALSE
,
/
/ initial state is nonsignaled
FALSE
,
/
* initial state is nonsignaled */
NULL
/
/ object name
NULL
/
* object name */
);
);
#elif defined(OSX)
#elif defined(OSX)
sem
=
dispatch_semaphore_create
(
0L
);
sem
=
dispatch_semaphore_create
(
0L
);
...
...
src/Tree.c
View file @
a5cbbbd4
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <memory.h>
#include "Heap.h"
#include "Heap.h"
...
@@ -533,7 +532,7 @@ int TreeIntCompare(void* a, void* b, int content)
...
@@ -533,7 +532,7 @@ int TreeIntCompare(void* a, void* b, int content)
int
i
=
*
((
int
*
)
a
);
int
i
=
*
((
int
*
)
a
);
int
j
=
*
((
int
*
)
b
);
int
j
=
*
((
int
*
)
b
);
/
/printf("comparing %d %d\n", *((int*)a), *((int*)b));
/
* printf("comparing %d %d\n", *((int*)a), *((int*)b)); */
return
(
i
>
j
)
?
-
1
:
(
i
==
j
)
?
0
:
1
;
return
(
i
>
j
)
?
-
1
:
(
i
==
j
)
?
0
:
1
;
}
}
...
@@ -581,14 +580,14 @@ int traverse(Tree *t, int lookfor)
...
@@ -581,14 +580,14 @@ int traverse(Tree *t, int lookfor)
printf
(
"Traversing
\n
"
);
printf
(
"Traversing
\n
"
);
curnode
=
TreeNextElement
(
t
,
curnode
);
curnode
=
TreeNextElement
(
t
,
curnode
);
/
/printf("content int %d\n", *(int*)(curnode->content));
/
* printf("content int %d\n", *(int*)(curnode->content)); */
while
(
curnode
)
while
(
curnode
)
{
{
Node
*
prevnode
=
curnode
;
Node
*
prevnode
=
curnode
;
curnode
=
TreeNextElement
(
t
,
curnode
);
curnode
=
TreeNextElement
(
t
,
curnode
);
/
/
if (curnode)
/
*
if (curnode)
// printf("content int %d\n", *(int*)(curnode->content));
printf("content int %d\n", *(int*)(curnode->content)); */
if
(
prevnode
&&
curnode
&&
(
*
(
int
*
)(
curnode
->
content
)
<
*
(
int
*
)(
prevnode
->
content
)))
if
(
prevnode
&&
curnode
&&
(
*
(
int
*
)(
curnode
->
content
)
<
*
(
int
*
)(
prevnode
->
content
)))
{
{
printf
(
"out of order %d < %d
\n
"
,
*
(
int
*
)(
curnode
->
content
),
*
(
int
*
)(
prevnode
->
content
));
printf
(
"out of order %d < %d
\n
"
,
*
(
int
*
)(
curnode
->
content
),
*
(
int
*
)(
prevnode
->
content
));
...
...
src/Tree.h
View file @
a5cbbbd4
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
#if !defined(TREE_H)
#if !defined(TREE_H)
#define TREE_H
#define TREE_H
#include <stdlib.h> /
/ for size_t definition
#include <stdlib.h>
/
* for size_t definition */
/*BE
/*BE
defm defTree(T) // macro to define a tree
defm defTree(T) // macro to define a tree
...
...
src/samples/MQTTAsync_publish.c
View file @
a5cbbbd4
...
@@ -25,6 +25,8 @@
...
@@ -25,6 +25,8 @@
#include <windows.h>
#include <windows.h>
#endif
#endif
#include <OsWrapper.h>
#define ADDRESS "tcp://m2m.eclipse.org:1883"
#define ADDRESS "tcp://m2m.eclipse.org:1883"
#define CLIENTID "ExampleClientPub"
#define CLIENTID "ExampleClientPub"
#define TOPIC "MQTT Examples"
#define TOPIC "MQTT Examples"
...
@@ -119,8 +121,6 @@ int main(int argc, char* argv[])
...
@@ -119,8 +121,6 @@ int main(int argc, char* argv[])
{
{
MQTTAsync
client
;
MQTTAsync
client
;
MQTTAsync_connectOptions
conn_opts
=
MQTTAsync_connectOptions_initializer
;
MQTTAsync_connectOptions
conn_opts
=
MQTTAsync_connectOptions_initializer
;
MQTTAsync_message
pubmsg
=
MQTTAsync_message_initializer
;
MQTTAsync_token
token
;
int
rc
;
int
rc
;
MQTTAsync_create
(
&
client
,
ADDRESS
,
CLIENTID
,
MQTTCLIENT_PERSISTENCE_NONE
,
NULL
);
MQTTAsync_create
(
&
client
,
ADDRESS
,
CLIENTID
,
MQTTCLIENT_PERSISTENCE_NONE
,
NULL
);
...
...
src/samples/MQTTAsync_subscribe.c
View file @
a5cbbbd4
...
@@ -25,6 +25,8 @@
...
@@ -25,6 +25,8 @@
#include <windows.h>
#include <windows.h>
#endif
#endif
#include <OsWrapper.h>
#define ADDRESS "tcp://localhost:1883"
#define ADDRESS "tcp://localhost:1883"
#define CLIENTID "ExampleClientSub"
#define CLIENTID "ExampleClientSub"
#define TOPIC "MQTT Examples"
#define TOPIC "MQTT Examples"
...
@@ -111,7 +113,6 @@ void onConnect(void* context, MQTTAsync_successData* response)
...
@@ -111,7 +113,6 @@ void onConnect(void* context, MQTTAsync_successData* response)
{
{
MQTTAsync
client
=
(
MQTTAsync
)
context
;
MQTTAsync
client
=
(
MQTTAsync
)
context
;
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_message
pubmsg
=
MQTTAsync_message_initializer
;
int
rc
;
int
rc
;
printf
(
"Successful connection
\n
"
);
printf
(
"Successful connection
\n
"
);
...
@@ -137,8 +138,6 @@ int main(int argc, char* argv[])
...
@@ -137,8 +138,6 @@ int main(int argc, char* argv[])
MQTTAsync
client
;
MQTTAsync
client
;
MQTTAsync_connectOptions
conn_opts
=
MQTTAsync_connectOptions_initializer
;
MQTTAsync_connectOptions
conn_opts
=
MQTTAsync_connectOptions_initializer
;
MQTTAsync_disconnectOptions
disc_opts
=
MQTTAsync_disconnectOptions_initializer
;
MQTTAsync_disconnectOptions
disc_opts
=
MQTTAsync_disconnectOptions_initializer
;
MQTTAsync_message
pubmsg
=
MQTTAsync_message_initializer
;
MQTTAsync_token
token
;
int
rc
;
int
rc
;
int
ch
;
int
ch
;
...
...
src/samples/paho_c_pub.c
View file @
a5cbbbd4
...
@@ -41,10 +41,11 @@
...
@@ -41,10 +41,11 @@
#include <stdio.h>
#include <stdio.h>
#include <signal.h>
#include <signal.h>
#include <
memory
.h>
#include <
string
.h>
#include <stdlib.h>
#include <stdlib.h>
#if defined(WIN32)
#if defined(WIN32)
#include <windows.h>
#define sleep Sleep
#define sleep Sleep
#else
#else
#include <unistd.h>
#include <unistd.h>
...
@@ -52,6 +53,7 @@
...
@@ -52,6 +53,7 @@
#include <unistd.h>
#include <unistd.h>
#endif
#endif
#include <OsWrapper.h>
volatile
int
toStop
=
0
;
volatile
int
toStop
=
0
;
...
@@ -132,8 +134,6 @@ void onConnectFailure(void* context, MQTTAsync_failureData* response)
...
@@ -132,8 +134,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
;
printf
(
"Connected
\n
"
);
printf
(
"Connected
\n
"
);
connected
=
1
;
connected
=
1
;
}
}
...
@@ -175,8 +175,6 @@ void onPublishFailure(void* context, MQTTAsync_failureData* response)
...
@@ -175,8 +175,6 @@ void onPublishFailure(void* context, MQTTAsync_failureData* response)
void
onPublish
(
void
*
context
,
MQTTAsync_successData
*
response
)
void
onPublish
(
void
*
context
,
MQTTAsync_successData
*
response
)
{
{
MQTTAsync
client
=
(
MQTTAsync
)
context
;
published
=
1
;
published
=
1
;
}
}
...
@@ -253,7 +251,7 @@ int main(int argc, char** argv)
...
@@ -253,7 +251,7 @@ int main(int argc, char** argv)
buffer
[
data_len
++
]
=
getchar
();
buffer
[
data_len
++
]
=
getchar
();
if
(
data_len
>
delim_len
)
if
(
data_len
>
delim_len
)
{
{
/
/printf("comparing %s %s\n", opts.delimiter, &buffer[data_len - delim_len]);
/
* printf("comparing %s %s\n", opts.delimiter, &buffer[data_len - delim_len]); */
if
(
strncmp
(
opts
.
delimiter
,
&
buffer
[
data_len
-
delim_len
],
delim_len
)
==
0
)
if
(
strncmp
(
opts
.
delimiter
,
&
buffer
[
data_len
-
delim_len
],
delim_len
)
==
0
)
break
;
break
;
}
}
...
...
src/samples/paho_c_sub.c
View file @
a5cbbbd4
...
@@ -44,17 +44,19 @@
...
@@ -44,17 +44,19 @@
#include <stdio.h>
#include <stdio.h>
#include <signal.h>
#include <signal.h>
#include <
memory
.h>
#include <
string
.h>
#include <stdlib.h>
#include <stdlib.h>
#if defined(WIN32)
#if defined(WIN32)
#include <windows.h>
#define sleep Sleep
#define sleep Sleep
#else
#else
#include <sys/time.h>
#include <sys/time.h>
#include <unistd.h>
#include <unistd.h>
#endif
#endif
#include <OsWrapper.h>
volatile
int
finished
=
0
;
volatile
int
finished
=
0
;
char
*
topic
=
NULL
;
char
*
topic
=
NULL
;
...
@@ -246,7 +248,6 @@ void onConnect(void* context, MQTTAsync_successData* response)
...
@@ -246,7 +248,6 @@ void onConnect(void* context, MQTTAsync_successData* response)
{
{
MQTTAsync
client
=
(
MQTTAsync
)
context
;
MQTTAsync
client
=
(
MQTTAsync
)
context
;
MQTTAsync_responseOptions
ropts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_responseOptions
ropts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_message
pubmsg
=
MQTTAsync_message_initializer
;
int
rc
;
int
rc
;
if
(
opts
.
showtopics
)
if
(
opts
.
showtopics
)
...
...
src/samples/paho_cs_pub.c
View file @
a5cbbbd4
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
#include <stdio.h>
#include <stdio.h>
#include <signal.h>
#include <signal.h>
#include <
memory
.h>
#include <
string
.h>
#include <stdlib.h>
#include <stdlib.h>
#if defined(WIN32)
#if defined(WIN32)
...
@@ -166,7 +166,7 @@ int main(int argc, char** argv)
...
@@ -166,7 +166,7 @@ int main(int argc, char** argv)
buffer
[
data_len
++
]
=
getchar
();
buffer
[
data_len
++
]
=
getchar
();
if
(
data_len
>
delim_len
)
if
(
data_len
>
delim_len
)
{
{
/
/printf("comparing %s %s\n", opts.delimiter, &buffer[data_len - delim_len]);
/
* printf("comparing %s %s\n", opts.delimiter, &buffer[data_len - delim_len]); */
if
(
strncmp
(
opts
.
delimiter
,
&
buffer
[
data_len
-
delim_len
],
delim_len
)
==
0
)
if
(
strncmp
(
opts
.
delimiter
,
&
buffer
[
data_len
-
delim_len
],
delim_len
)
==
0
)
break
;
break
;
}
}
...
...
src/samples/paho_cs_sub.c
View file @
a5cbbbd4
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
#include <stdio.h>
#include <stdio.h>
#include <signal.h>
#include <signal.h>
#include <
memory
.h>
#include <
string
.h>
#include <stdlib.h>
#include <stdlib.h>
...
...
test/MQTTTest_v2.c
View file @
a5cbbbd4
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
*/
*/
#include <
memory
.h>
#include <
string
.h>
#include <MQTTAsync.h>
#include <MQTTAsync.h>
#include <MQTTClientPersistence.h>
#include <MQTTClientPersistence.h>
#include <signal.h>
#include <signal.h>
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
#include <sys/time.h>
#include <sys/time.h>
#if defined(WIN32)
#if defined(WIN32)
#include <
W
indows.h>
#include <
w
indows.h>
#define sleep Sleep
#define sleep Sleep
#else
#else
#include <stdlib.h>
#include <stdlib.h>
...
...
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