Commit 1b61a3bf authored by Ian Craggs's avatar Ian Craggs

Merge branch 'develop' into mqttv5 - get latest fixes

parents 43dfcb2f a66faf8c
...@@ -17,10 +17,8 @@ matrix: ...@@ -17,10 +17,8 @@ matrix:
os: linux os: linux
before_install: before_install:
- openssl aes-256-cbc -K $encrypted_dcd2b299f7c9_key -iv $encrypted_dcd2b299f7c9_iv -in deploy_rsa.enc -out /tmp/deploy_rsa -d - if [ "$TRAVIS_PULL_REQUEST" = "false" -a "$TRAVIS_REPO_SLUG" = "eclipse/paho.mqtt.c" ]; then export DEPLOY=true; fi
- eval "$(ssh-agent -s)" - if [ "$DEPLOY" = "true" ]; then ./travis-setup-deploy.sh; fi
- chmod 600 /tmp/deploy_rsa
- ssh-add /tmp/deploy_rsa
- ./travis-install.sh - ./travis-install.sh
env: env:
...@@ -53,4 +51,4 @@ addons: ...@@ -53,4 +51,4 @@ addons:
after_success: after_success:
- ls -l build.paho/*.tar.gz - ls -l build.paho/*.tar.gz
- scp -o StrictHostKeyChecking=no build.paho/*.tar.gz icraggs@build.eclipse.org:../../../../shared/technology/paho/C/ - if [ "$DEPLOY" = "true" ]; then ./travis-deploy.sh; fi
...@@ -49,6 +49,8 @@ SET(PAHO_BUILD_DOCUMENTATION FALSE CACHE BOOL "Create and install the HTML based ...@@ -49,6 +49,8 @@ SET(PAHO_BUILD_DOCUMENTATION FALSE CACHE BOOL "Create and install the HTML based
SET(PAHO_BUILD_SAMPLES FALSE CACHE BOOL "Build sample programs") SET(PAHO_BUILD_SAMPLES FALSE CACHE BOOL "Build sample programs")
SET(PAHO_BUILD_DEB_PACKAGE FALSE CACHE BOOL "Build debian package") SET(PAHO_BUILD_DEB_PACKAGE FALSE CACHE BOOL "Build debian package")
SET(PAHO_ENABLE_TESTING TRUE CACHE BOOL "Build tests and run") SET(PAHO_ENABLE_TESTING TRUE CACHE BOOL "Build tests and run")
SET(PAHO_ENABLE_CPACK TRUE CACHE BOOL "Enable CPack")
ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(src)
IF(PAHO_BUILD_SAMPLES) IF(PAHO_BUILD_SAMPLES)
...@@ -59,22 +61,32 @@ IF(PAHO_BUILD_DOCUMENTATION) ...@@ -59,22 +61,32 @@ IF(PAHO_BUILD_DOCUMENTATION)
ADD_SUBDIRECTORY(doc) ADD_SUBDIRECTORY(doc)
ENDIF() ENDIF()
### packaging settings IF (PAHO_ENABLE_CPACK)
SET(CPACK_PACKAGE_VENDOR "Eclipse Paho") ### packaging settings
SET(CPACK_PACKAGE_NAME "Eclipse-Paho-MQTT-C") FILE(GLOB samples "src/samples/*.c")
INSTALL(FILES CONTRIBUTING.md epl-v10 edl-v10 README.md notice.html DESTINATION .) INSTALL(FILES ${samples} DESTINATION samples)
FILE(GLOB samples "src/samples/*.c")
INSTALL(FILES ${samples} DESTINATION samples) SET(CPACK_PACKAGE_VENDOR "Eclipse Paho")
IF (WIN32) SET(CPACK_PACKAGE_NAME "Eclipse-Paho-MQTT-C")
SET(CPACK_GENERATOR "ZIP") INSTALL(FILES CONTRIBUTING.md epl-v10 edl-v10 README.md notice.html DESTINATION .)
ELSEIF(PAHO_BUILD_DEB_PACKAGE)
SET(CPACK_GENERATOR "DEB") IF (WIN32)
CONFIGURE_FILE(${CMAKE_SCRIPTS}/CPackDebConfig.cmake.in SET(CPACK_GENERATOR "ZIP")
${CMAKE_BINARY_DIR}/CPackDebConfig.cmake @ONLY) ELSEIF(PAHO_BUILD_DEB_PACKAGE)
SET(CPACK_PROJECT_CONFIG_FILE ${CMAKE_BINARY_DIR}/CPackDebConfig.cmake) INSTALL(FILES CONTRIBUTING.md epl-v10 edl-v10 README.md notice.html DESTINATION .)
ADD_SUBDIRECTORY(debian)
SET(CPACK_GENERATOR "DEB")
CONFIGURE_FILE(${CMAKE_SCRIPTS}/CPackDebConfig.cmake.in
${CMAKE_BINARY_DIR}/CPackDebConfig.cmake @ONLY)
SET(CPACK_PROJECT_CONFIG_FILE ${CMAKE_BINARY_DIR}/CPackDebConfig.cmake)
ADD_SUBDIRECTORY(debian)
ELSE()
SET(CPACK_GENERATOR "TGZ")
ENDIF()
ELSE() ELSE()
SET(CPACK_GENERATOR "TGZ") FILE(GLOB samples "src/samples/*.c")
INSTALL(FILES ${samples} DESTINATION ${CMAKE_INSTALL_DOCDIR})
ENDIF() ENDIF()
SET(CPACK_PACKAGE_VERSION_MAJOR ${PAHO_VERSION_MAJOR}) SET(CPACK_PACKAGE_VERSION_MAJOR ${PAHO_VERSION_MAJOR})
......
...@@ -36,5 +36,10 @@ FOREACH(DOXYFILE_SRC DoxyfileV3ClientAPI;DoxyfileV3AsyncAPI;DoxyfileV3ClientInte ...@@ -36,5 +36,10 @@ FOREACH(DOXYFILE_SRC DoxyfileV3ClientAPI;DoxyfileV3AsyncAPI;DoxyfileV3ClientInte
) )
SET(DOXYTARGETS ${DOXYTARGETS} ${DOXYFILE_SRC}.target) SET(DOXYTARGETS ${DOXYTARGETS} ${DOXYFILE_SRC}.target)
ENDFOREACH(DOXYFILE_SRC) ENDFOREACH(DOXYFILE_SRC)
ADD_CUSTOM_TARGET(doc ALL DEPENDS ${DOXYTARGETS}) ADD_CUSTOM_TARGET(doc ALL DEPENDS ${DOXYTARGETS})
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc DESTINATION share) IF (PAHO_ENABLE_CPACK)
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc DESTINATION share)
ELSE()
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc DESTINATION ${CMAKE_INSTALL_DOCDIR})
ENDIF()
\ No newline at end of file
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2014 IBM Corp. * Copyright (c) 2009, 2018 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
...@@ -376,7 +376,7 @@ static void HeapScan(enum LOG_LEVELS log_level) ...@@ -376,7 +376,7 @@ static void HeapScan(enum LOG_LEVELS log_level)
{ {
storageElement* s = (storageElement*)(current->content); storageElement* s = (storageElement*)(current->content);
Log(log_level, -1, "Heap element size %d, line %d, file %s, ptr %p", s->size, s->line, s->file, s->ptr); Log(log_level, -1, "Heap element size %d, line %d, file %s, ptr %p", s->size, s->line, s->file, s->ptr);
Log(log_level, -1, " Content %*.s", (10 > current->size) ? s->size : 10, (char*)(((int*)s->ptr) + 1)); Log(log_level, -1, " Content %.*s", (10 > current->size) ? s->size : 10, (char*)(((int*)s->ptr) + 1));
#if defined(HEAP_STACK) #if defined(HEAP_STACK)
Log(log_level, -1, " Stack:\n%s", s->stack); Log(log_level, -1, " Stack:\n%s", s->stack);
#endif #endif
......
...@@ -3665,3 +3665,42 @@ MQTTAsync_nameValue* MQTTAsync_getVersionInfo(void) ...@@ -3665,3 +3665,42 @@ MQTTAsync_nameValue* MQTTAsync_getVersionInfo(void)
libinfo[i].value = NULL; libinfo[i].value = NULL;
return libinfo; return libinfo;
} }
const char* MQTTAsync_strerror(int code)
{
switch (code) {
case MQTTASYNC_SUCCESS:
return "Success";
case MQTTASYNC_FAILURE:
return "Failure";
case MQTTASYNC_PERSISTENCE_ERROR:
return "Persistence error";
case MQTTASYNC_DISCONNECTED:
return "Disconnected";
case MQTTASYNC_MAX_MESSAGES_INFLIGHT:
return "Maximum in-flight messages amount reached";
case MQTTASYNC_BAD_UTF8_STRING:
return "Invalid UTF8 string";
case MQTTASYNC_NULL_PARAMETER:
return "Invalid (NULL) parameter";
case MQTTASYNC_TOPICNAME_TRUNCATED:
return "Topic containing NULL characters has been truncated";
case MQTTASYNC_BAD_STRUCTURE:
return "Bad structure";
case MQTTASYNC_BAD_QOS:
return "Invalid QoS value";
case MQTTASYNC_NO_MORE_MSGIDS:
return "Too many pending commands";
case MQTTASYNC_OPERATION_INCOMPLETE:
return "Operation discarded before completion";
case MQTTASYNC_MAX_BUFFERED_MESSAGES:
return "No more messages can be buffered";
case MQTTASYNC_SSL_NOT_SUPPORTED:
return "SSL is not supported";
case MQTTASYNC_BAD_PROTOCOL:
return "Invalid protocole scheme";
}
return NULL;
}
...@@ -1343,6 +1343,13 @@ typedef struct ...@@ -1343,6 +1343,13 @@ typedef struct
*/ */
DLLExport MQTTAsync_nameValue* MQTTAsync_getVersionInfo(void); DLLExport MQTTAsync_nameValue* MQTTAsync_getVersionInfo(void);
/**
* Returns a pointer to the string representation of the error or NULL.
*
* Do not free after use. Returns NULL if the error code is unknown.
*/
DLLExport const char* MQTTAsync_strerror(int code);
/** /**
* @cond MQTTAsync_main * @cond MQTTAsync_main
......
...@@ -2237,6 +2237,37 @@ MQTTClient_nameValue* MQTTClient_getVersionInfo(void) ...@@ -2237,6 +2237,37 @@ MQTTClient_nameValue* MQTTClient_getVersionInfo(void)
} }
const char* MQTTClient_strerror(int code)
{
switch (code) {
case MQTTCLIENT_SUCCESS:
return "Success";
case MQTTCLIENT_FAILURE:
return "Failure";
case MQTTCLIENT_DISCONNECTED:
return "Disconnected";
case MQTTCLIENT_MAX_MESSAGES_INFLIGHT:
return "Maximum in-flight messages amount reached";
case MQTTCLIENT_BAD_UTF8_STRING:
return "Invalid UTF8 string";
case MQTTCLIENT_NULL_PARAMETER:
return "Invalid (NULL) parameter";
case MQTTCLIENT_TOPICNAME_TRUNCATED:
return "Topic containing NULL characters has been truncated";
case MQTTCLIENT_BAD_STRUCTURE:
return "Bad structure";
case MQTTCLIENT_BAD_QOS:
return "Invalid QoS value";
case MQTTCLIENT_SSL_NOT_SUPPORTED:
return "SSL is not supported";
case MQTTCLIENT_BAD_PROTOCOL:
return "Invalid protocole scheme";
}
return NULL;
}
/** /**
* See if any pending writes have been completed, and cleanup if so. * See if any pending writes have been completed, and cleanup if so.
* Cleaning up means removing any publication data that was stored because the write did * Cleaning up means removing any publication data that was stored because the write did
......
...@@ -1053,6 +1053,13 @@ DLLExport void MQTTClient_free(void* ptr); ...@@ -1053,6 +1053,13 @@ DLLExport void MQTTClient_free(void* ptr);
*/ */
DLLExport void MQTTClient_destroy(MQTTClient* handle); DLLExport void MQTTClient_destroy(MQTTClient* handle);
/**
* Returns a pointer to the string representation of the error or NULL.
*
* Do not free after use. Returns NULL if the error code is unknown.
*/
DLLExport const char* MQTTClient_strerror(int code);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial documentation
* Ian Craggs, Allan Stockdill-Mander - SSL updates * Ian Craggs, Allan Stockdill-Mander - SSL updates
* Ian Craggs - MQTT 3.1.1 support * Ian Craggs - MQTT 3.1.1 support
* Ian Craggs - fix for issue 453
* Ian Craggs - MQTT 5.0 support * Ian Craggs - MQTT 5.0 support
*******************************************************************************/ *******************************************************************************/
...@@ -183,27 +184,32 @@ int MQTTPacket_send(networkHandles* net, Header header, char* buffer, size_t buf ...@@ -183,27 +184,32 @@ int MQTTPacket_send(networkHandles* net, Header header, char* buffer, size_t buf
int rc; int rc;
size_t buf0len; size_t buf0len;
char *buf; char *buf;
int count = 0;
FUNC_ENTRY; FUNC_ENTRY;
buf = malloc(10); buf = malloc(10);
buf[0] = header.byte; buf[0] = header.byte;
buf0len = 1 + MQTTPacket_encode(&buf[1], buflen); buf0len = 1 + MQTTPacket_encode(&buf[1], buflen);
if (buffer != NULL)
count = 1;
#if !defined(NO_PERSISTENCE) #if !defined(NO_PERSISTENCE)
if (header.bits.type == PUBREL) if (header.bits.type == PUBREL)
{ {
char* ptraux = buffer; char* ptraux = buffer;
int msgId = readInt(&ptraux); int msgId = readInt(&ptraux);
rc = MQTTPersistence_put(net->socket, buf, buf0len, 1, &buffer, &buflen, rc = MQTTPersistence_put(net->socket, buf, buf0len, count, &buffer, &buflen,
header.bits.type, msgId, 0); header.bits.type, msgId, 0);
} }
#endif #endif
#if defined(OPENSSL) #if defined(OPENSSL)
if (net->ssl) if (net->ssl)
rc = SSLSocket_putdatas(net->ssl, net->socket, buf, buf0len, 1, &buffer, &buflen, &freeData); rc = SSLSocket_putdatas(net->ssl, net->socket, buf, buf0len, count, &buffer, &buflen, &freeData);
else else
#endif #endif
rc = Socket_putdatas(net->socket, buf, buf0len, 1, &buffer, &buflen, &freeData); rc = Socket_putdatas(net->socket, buf, buf0len, count, &buffer, &buflen, &freeData);
if (rc == TCPSOCKET_COMPLETE) if (rc == TCPSOCKET_COMPLETE)
time(&(net->lastSent)); time(&(net->lastSent));
......
...@@ -193,12 +193,11 @@ int MQTTPacket_send_pingreq(networkHandles* net, const char* clientID) ...@@ -193,12 +193,11 @@ int MQTTPacket_send_pingreq(networkHandles* net, const char* clientID)
{ {
Header header; Header header;
int rc = 0; int rc = 0;
size_t buflen = 0;
FUNC_ENTRY; FUNC_ENTRY;
header.byte = 0; header.byte = 0;
header.bits.type = PINGREQ; header.bits.type = PINGREQ;
rc = MQTTPacket_send(net, header, NULL, buflen,0); rc = MQTTPacket_send(net, header, NULL, 0, 0);
Log(LOG_PROTOCOL, 20, NULL, net->socket, clientID, rc); Log(LOG_PROTOCOL, 20, NULL, net->socket, clientID, rc);
FUNC_EXIT_RC(rc); FUNC_EXIT_RC(rc);
return rc; return rc;
......
...@@ -138,7 +138,7 @@ int UTF8_validate(int len, const char* data) ...@@ -138,7 +138,7 @@ int UTF8_validate(int len, const char* data)
} }
curdata = UTF8_char_validate(len, data); curdata = UTF8_char_validate(len, data);
while (curdata && (curdata < data + len)) while (curdata && (curdata < data + len))
curdata = UTF8_char_validate(len, curdata); curdata = UTF8_char_validate(data + len - curdata, curdata);
rc = curdata != NULL; rc = curdata != NULL;
exit: exit:
......
scp -o StrictHostKeyChecking=no build.paho/*.tar.gz icraggs@build.eclipse.org:../../../../shared/technology/paho/C/
openssl aes-256-cbc -K $encrypted_dcd2b299f7c9_key -iv $encrypted_dcd2b299f7c9_iv -in deploy_rsa.enc -out /tmp/deploy_rsa -d
eval "$(ssh-agent -s)"
chmod 600 /tmp/deploy_rsa
ssh-add /tmp/deploy_rsa
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment