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
359a9f4a
Commit
359a9f4a
authored
May 01, 2017
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some cppcheck complaint fixes #36
parent
2ac34c25
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
69 additions
and
62 deletions
+69
-62
Clients.h
src/Clients.h
+1
-1
MQTTAsync.c
src/MQTTAsync.c
+1
-1
MQTTAsync.h
src/MQTTAsync.h
+6
-6
MQTTClient.h
src/MQTTClient.h
+9
-9
MQTTPersistence.c
src/MQTTPersistence.c
+1
-1
MQTTPersistenceDefault.c
src/MQTTPersistenceDefault.c
+3
-2
MQTTVersion.c
src/MQTTVersion.c
+29
-23
MQTTAsync_publish.c
src/samples/MQTTAsync_publish.c
+3
-3
MQTTAsync_subscribe.c
src/samples/MQTTAsync_subscribe.c
+4
-4
MQTTClient_publish.c
src/samples/MQTTClient_publish.c
+4
-4
MQTTClient_publish_async.c
src/samples/MQTTClient_publish_async.c
+4
-4
MQTTClient_subscribe.c
src/samples/MQTTClient_subscribe.c
+4
-4
No files found.
src/Clients.h
View file @
359a9f4a
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#include <time.h>
#include <time.h>
#if defined(OPENSSL)
#if defined(OPENSSL)
#if defined(WIN32) || defined(WIN64)
#if defined(WIN32) || defined(WIN64)
#include
"winsock2.h"
#include
<winsock2.h>
#endif
#endif
#include <openssl/ssl.h>
#include <openssl/ssl.h>
#endif
#endif
...
...
src/MQTTAsync.c
View file @
359a9f4a
...
@@ -567,7 +567,7 @@ static int MQTTAsync_unpersistCommand(MQTTAsync_queuedCommand* qcmd)
...
@@ -567,7 +567,7 @@ static int MQTTAsync_unpersistCommand(MQTTAsync_queuedCommand* qcmd)
char
key
[
PERSISTENCE_MAX_KEY_LENGTH
+
1
];
char
key
[
PERSISTENCE_MAX_KEY_LENGTH
+
1
];
FUNC_ENTRY
;
FUNC_ENTRY
;
sprintf
(
key
,
"%s%
d
"
,
PERSISTENCE_COMMAND_KEY
,
qcmd
->
seqno
);
sprintf
(
key
,
"%s%
u
"
,
PERSISTENCE_COMMAND_KEY
,
qcmd
->
seqno
);
if
((
rc
=
qcmd
->
client
->
c
->
persistence
->
premove
(
qcmd
->
client
->
c
->
phandle
,
key
))
!=
0
)
if
((
rc
=
qcmd
->
client
->
c
->
persistence
->
premove
(
qcmd
->
client
->
c
->
phandle
,
key
))
!=
0
)
Log
(
LOG_ERROR
,
0
,
"Error %d removing command from persistence"
,
rc
);
Log
(
LOG_ERROR
,
0
,
"Error %d removing command from persistence"
,
rc
);
FUNC_EXIT_RC
(
rc
);
FUNC_EXIT_RC
(
rc
);
...
...
src/MQTTAsync.h
View file @
359a9f4a
...
@@ -1229,9 +1229,9 @@ DLLExport MQTTAsync_nameValue* MQTTAsync_getVersionInfo(void);
...
@@ -1229,9 +1229,9 @@ DLLExport MQTTAsync_nameValue* MQTTAsync_getVersionInfo(void);
* @page publish Publication example
* @page publish Publication example
@code
@code
#include
"stdio.h"
#include
<stdio.h>
#include
"stdlib.h"
#include
<stdlib.h>
#include
"string.h"
#include
<string.h>
#include "MQTTAsync.h"
#include "MQTTAsync.h"
#define ADDRESS "tcp://localhost:1883"
#define ADDRESS "tcp://localhost:1883"
...
@@ -1364,9 +1364,9 @@ int main(int argc, char* argv[])
...
@@ -1364,9 +1364,9 @@ int main(int argc, char* argv[])
* @endcode
* @endcode
* @page subscribe Subscription example
* @page subscribe Subscription example
@code
@code
#include
"stdio.h"
#include
<stdio.h>
#include
"stdlib.h"
#include
<stdlib.h>
#include
"string.h"
#include
<string.h>
#include "MQTTAsync.h"
#include "MQTTAsync.h"
#define ADDRESS "tcp://localhost:1883"
#define ADDRESS "tcp://localhost:1883"
...
...
src/MQTTClient.h
View file @
359a9f4a
...
@@ -1054,9 +1054,9 @@ DLLExport void MQTTClient_destroy(MQTTClient* handle);
...
@@ -1054,9 +1054,9 @@ DLLExport void MQTTClient_destroy(MQTTClient* handle);
* of messages occurs.
* of messages occurs.
* @page pubsync Synchronous publication example
* @page pubsync Synchronous publication example
@code
@code
#include
"stdio.h"
#include
<stdio.h>
#include
"stdlib.h"
#include
<stdlib.h>
#include
"string.h"
#include
<string.h>
#include "MQTTClient.h"
#include "MQTTClient.h"
#define ADDRESS "tcp://localhost:1883"
#define ADDRESS "tcp://localhost:1883"
...
@@ -1103,9 +1103,9 @@ int main(int argc, char* argv[])
...
@@ -1103,9 +1103,9 @@ int main(int argc, char* argv[])
*
*
* @page pubasync Asynchronous publication example
* @page pubasync Asynchronous publication example
@code{.c}
@code{.c}
#include
"stdio.h"
#include
<stdio.h>
#include
"stdlib.h"
#include
<stdlib.h>
#include
"string.h"
#include
<string.h>
#include "MQTTClient.h"
#include "MQTTClient.h"
#define ADDRESS "tcp://localhost:1883"
#define ADDRESS "tcp://localhost:1883"
...
@@ -1187,9 +1187,9 @@ int main(int argc, char* argv[])
...
@@ -1187,9 +1187,9 @@ int main(int argc, char* argv[])
* @endcode
* @endcode
* @page subasync Asynchronous subscription example
* @page subasync Asynchronous subscription example
@code
@code
#include
"stdio.h"
#include
<stdio.h>
#include
"stdlib.h"
#include
<stdlib.h>
#include
"string.h"
#include
<string.h>
#include "MQTTClient.h"
#include "MQTTClient.h"
#define ADDRESS "tcp://localhost:1883"
#define ADDRESS "tcp://localhost:1883"
...
...
src/MQTTPersistence.c
View file @
359a9f4a
...
@@ -479,7 +479,7 @@ int MQTTPersistence_unpersistQueueEntry(Clients* client, MQTTPersistence_qEntry*
...
@@ -479,7 +479,7 @@ int MQTTPersistence_unpersistQueueEntry(Clients* client, MQTTPersistence_qEntry*
char
key
[
PERSISTENCE_MAX_KEY_LENGTH
+
1
];
char
key
[
PERSISTENCE_MAX_KEY_LENGTH
+
1
];
FUNC_ENTRY
;
FUNC_ENTRY
;
sprintf
(
key
,
"%s%
d
"
,
PERSISTENCE_QUEUE_KEY
,
qe
->
seqno
);
sprintf
(
key
,
"%s%
u
"
,
PERSISTENCE_QUEUE_KEY
,
qe
->
seqno
);
if
((
rc
=
client
->
persistence
->
premove
(
client
->
phandle
,
key
))
!=
0
)
if
((
rc
=
client
->
persistence
->
premove
(
client
->
phandle
,
key
))
!=
0
)
Log
(
LOG_ERROR
,
0
,
"Error %d removing qEntry from persistence"
,
rc
);
Log
(
LOG_ERROR
,
0
,
"Error %d removing qEntry from persistence"
,
rc
);
FUNC_EXIT_RC
(
rc
);
FUNC_EXIT_RC
(
rc
);
...
...
src/MQTTPersistenceDefault.c
View file @
359a9f4a
...
@@ -99,16 +99,17 @@ int pstopen(void **handle, const char* clientID, const char* serverURI, void* co
...
@@ -99,16 +99,17 @@ int pstopen(void **handle, const char* clientID, const char* serverURI, void* co
while
(
(
pToken
!=
NULL
)
&&
(
rc
==
0
)
)
while
(
(
pToken
!=
NULL
)
&&
(
rc
==
0
)
)
{
{
/* Append the next directory level and try to create it */
/* Append the next directory level and try to create it */
sprintf
(
pCrtDirName
,
"%s/%s"
,
pCrtDirName
,
pToken
);
strcat
(
pCrtDirName
,
"/"
);
strcat
(
pCrtDirName
,
pToken
);
rc
=
pstmkdir
(
pCrtDirName
);
rc
=
pstmkdir
(
pCrtDirName
);
pToken
=
strtok_r
(
NULL
,
"
\\
/"
,
&
save_ptr
);
pToken
=
strtok_r
(
NULL
,
"
\\
/"
,
&
save_ptr
);
}
}
*
handle
=
clientDir
;
*
handle
=
clientDir
;
free
(
perserverURI
);
free
(
pTokDirName
);
free
(
pTokDirName
);
free
(
pCrtDirName
);
free
(
pCrtDirName
);
free
(
perserverURI
);
FUNC_EXIT_RC
(
rc
);
FUNC_EXIT_RC
(
rc
);
return
rc
;
return
rc
;
...
...
src/MQTTVersion.c
View file @
359a9f4a
...
@@ -51,12 +51,12 @@
...
@@ -51,12 +51,12 @@
* */
* */
char
*
libraries
[]
=
{
"paho-mqtt3c"
,
"paho-mqtt3cs"
,
"paho-mqtt3a"
,
"paho-mqtt3as"
};
static
const
char
*
libraries
[]
=
{
"paho-mqtt3c"
,
"paho-mqtt3cs"
,
"paho-mqtt3a"
,
"paho-mqtt3as"
};
char
*
eyecatchers
[]
=
{
"MQTTAsyncV3_Version"
,
"MQTTAsyncV3_Timestamp"
,
static
const
char
*
eyecatchers
[]
=
{
"MQTTAsyncV3_Version"
,
"MQTTAsyncV3_Timestamp"
,
"MQTTClientV3_Version"
,
"MQTTClientV3_Timestamp"
};
"MQTTClientV3_Version"
,
"MQTTClientV3_Timestamp"
};
char
*
FindString
(
char
*
filename
,
char
*
eyecatcher_input
);
char
*
FindString
(
char
*
filename
,
c
onst
c
har
*
eyecatcher_input
);
int
printVersionInfo
(
MQTTAsync_nameValue
*
info
);
int
printVersionInfo
(
MQTTAsync_nameValue
*
info
);
int
loadandcall
(
char
*
libname
);
int
loadandcall
(
char
*
libname
);
void
printEyecatchers
(
char
*
filename
);
void
printEyecatchers
(
char
*
filename
);
...
@@ -68,43 +68,49 @@ void printEyecatchers(char* filename);
...
@@ -68,43 +68,49 @@ void printEyecatchers(char* filename);
* @param eyecatcher_input the eyecatcher string to look for
* @param eyecatcher_input the eyecatcher string to look for
* @return the value found - "" if not found
* @return the value found - "" if not found
*/
*/
char
*
FindString
(
char
*
filename
,
char
*
eyecatcher_input
)
char
*
FindString
(
char
*
filename
,
c
onst
c
har
*
eyecatcher_input
)
{
{
FILE
*
infile
=
NULL
;
FILE
*
infile
=
NULL
;
static
char
value
[
100
];
static
char
value
[
100
];
char
*
eyecatcher
=
eyecatcher_input
;
c
onst
c
har
*
eyecatcher
=
eyecatcher_input
;
memset
(
value
,
0
,
100
);
memset
(
value
,
0
,
100
);
if
((
infile
=
fopen
(
filename
,
"rb"
))
!=
NULL
)
if
((
infile
=
fopen
(
filename
,
"rb"
))
!=
NULL
)
{
{
size_t
buflen
=
strlen
(
eyecatcher
);
size_t
buflen
=
strlen
(
eyecatcher
);
char
*
buffer
=
(
char
*
)
malloc
(
buflen
);
char
*
buffer
=
(
char
*
)
malloc
(
buflen
);
int
count
=
0
;
int
c
=
fgetc
(
infile
);
while
(
feof
(
infile
)
==
0
)
if
(
buffer
!=
NULL
)
{
{
buffer
[
count
++
]
=
c
;
int
c
=
fgetc
(
infile
);
if
(
memcmp
(
eyecatcher
,
buffer
,
buflen
)
==
0
)
while
(
feof
(
infile
)
==
0
)
{
{
char
*
ptr
=
value
;
int
count
=
0
;
c
=
fgetc
(
infile
);
/* skip space */
buffer
[
count
++
]
=
c
;
c
=
fgetc
(
infile
);
if
(
memcmp
(
eyecatcher
,
buffer
,
buflen
)
==
0
)
while
(
isprint
(
c
))
{
{
*
ptr
++
=
c
;
char
*
ptr
=
value
;
c
=
fgetc
(
infile
);
/* skip space */
c
=
fgetc
(
infile
);
c
=
fgetc
(
infile
);
while
(
isprint
(
c
))
{
*
ptr
++
=
c
;
c
=
fgetc
(
infile
);
}
break
;
}
}
break
;
if
(
count
==
buflen
)
}
{
if
(
count
==
buflen
)
memmove
(
buffer
,
&
buffer
[
1
],
buflen
-
1
);
{
count
--
;
memmove
(
buffer
,
&
buffer
[
1
],
buflen
-
1
);
}
c
ount
--
;
c
=
fgetc
(
infile
)
;
}
}
c
=
fgetc
(
infile
);
free
(
buffer
);
}
}
free
(
buffer
);
fclose
(
infile
);
}
}
return
value
;
return
value
;
}
}
...
...
src/samples/MQTTAsync_publish.c
View file @
359a9f4a
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
* Ian Craggs - initial contribution
* Ian Craggs - initial contribution
*******************************************************************************/
*******************************************************************************/
#include
"stdio.h"
#include
<stdio.h>
#include
"stdlib.h"
#include
<stdlib.h>
#include
"string.h"
#include
<string.h>
#include "MQTTAsync.h"
#include "MQTTAsync.h"
#if !defined(WIN32)
#if !defined(WIN32)
...
...
src/samples/MQTTAsync_subscribe.c
View file @
359a9f4a
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2012, 201
3
IBM Corp.
* Copyright (c) 2012, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
* Ian Craggs - initial contribution
* Ian Craggs - initial contribution
*******************************************************************************/
*******************************************************************************/
#include
"stdio.h"
#include
<stdio.h>
#include
"stdlib.h"
#include
<stdlib.h>
#include
"string.h"
#include
<string.h>
#include "MQTTAsync.h"
#include "MQTTAsync.h"
#if !defined(WIN32)
#if !defined(WIN32)
...
...
src/samples/MQTTClient_publish.c
View file @
359a9f4a
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2012, 201
3
IBM Corp.
* Copyright (c) 2012, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
* Ian Craggs - initial contribution
* Ian Craggs - initial contribution
*******************************************************************************/
*******************************************************************************/
#include
"stdio.h"
#include
<stdio.h>
#include
"stdlib.h"
#include
<stdlib.h>
#include
"string.h"
#include
<string.h>
#include "MQTTClient.h"
#include "MQTTClient.h"
#define ADDRESS "tcp://localhost:1883"
#define ADDRESS "tcp://localhost:1883"
...
...
src/samples/MQTTClient_publish_async.c
View file @
359a9f4a
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2012, 201
3
IBM Corp.
* Copyright (c) 2012, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
* Ian Craggs - initial contribution
* Ian Craggs - initial contribution
*******************************************************************************/
*******************************************************************************/
#include
"stdio.h"
#include
<stdio.h>
#include
"stdlib.h"
#include
<stdlib.h>
#include
"string.h"
#include
<string.h>
#include "MQTTClient.h"
#include "MQTTClient.h"
#define ADDRESS "tcp://localhost:1883"
#define ADDRESS "tcp://localhost:1883"
...
...
src/samples/MQTTClient_subscribe.c
View file @
359a9f4a
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2012, 201
3
IBM Corp.
* Copyright (c) 2012, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
* Ian Craggs - initial contribution
* Ian Craggs - initial contribution
*******************************************************************************/
*******************************************************************************/
#include
"stdio.h"
#include
<stdio.h>
#include
"stdlib.h"
#include
<stdlib.h>
#include
"string.h"
#include
<string.h>
#include "MQTTClient.h"
#include "MQTTClient.h"
#define ADDRESS "tcp://localhost:1883"
#define ADDRESS "tcp://localhost:1883"
...
...
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