Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of azure_c_shared_utility by
Revision 1:9190c0f4d23a, committed 2016-04-24
- Comitter:
- AzureIoTClient
- Date:
- Sun Apr 24 16:41:14 2016 -0700
- Parent:
- 0:fa2de1b79154
- Child:
- 2:20b88da3e604
- Commit message:
- 1.0.5
Changed in this revision
--- a/azure_c_shared_utility/iot_logging.h Fri Apr 08 12:01:36 2016 -0700
+++ b/azure_c_shared_utility/iot_logging.h Sun Apr 24 16:41:14 2016 -0700
@@ -21,12 +21,17 @@
#define LOG_LINE 0x01
-#define LogInfo(...) (void)printf("Info: " __VA_ARGS__)
+//Adding a do while(0) to force the user to add ; after LogInfo and LogError.
+#if defined _MSC_VER
+#define LogInfo(FORMAT, ...) do{(void)fprintf(stdout,"Info: " FORMAT "\r\n", __VA_ARGS__); }while(0)
+#else
+#define LogInfo(FORMAT, ...) do{(void)fprintf(stdout,"Info: " FORMAT "\r\n", ##__VA_ARGS__); }while(0)
+#endif
#if defined _MSC_VER
-#define LogError(FORMAT, ...) { time_t t = time(NULL); (void)fprintf(stderr,"Error: Time:%.24s File:%s Func:%s Line:%d " FORMAT, ctime(&t), __FILE__, __FUNCDNAME__, __LINE__, __VA_ARGS__); }
+#define LogError(FORMAT, ...) do{ time_t t = time(NULL); (void)fprintf(stderr,"Error: Time:%.24s File:%s Func:%s Line:%d " FORMAT "\r\n", ctime(&t), __FILE__, __FUNCDNAME__, __LINE__, __VA_ARGS__); }while(0)
#else
-#define LogError(FORMAT, ...) { time_t t = time(NULL); (void)fprintf(stderr,"Error: Time:%.24s File:%s Func:%s Line:%d " FORMAT, ctime(&t), __FILE__, __func__, __LINE__, ##__VA_ARGS__); }
+#define LogError(FORMAT, ...) do{ time_t t = time(NULL); (void)fprintf(stderr,"Error: Time:%.24s File:%s Func:%s Line:%d " FORMAT "\r\n", ctime(&t), __FILE__, __func__, __LINE__, ##__VA_ARGS__); }while(0)
#endif
#ifdef __cplusplus
--- a/azure_c_shared_utility/socketio.h Fri Apr 08 12:01:36 2016 -0700
+++ b/azure_c_shared_utility/socketio.h Sun Apr 24 16:41:14 2016 -0700
@@ -21,6 +21,8 @@
void* accepted_socket;
} SOCKETIO_CONFIG;
+#define RECEIVE_BYTES_VALUE 64
+
extern CONCRETE_IO_HANDLE socketio_create(void* io_create_parameters, LOGGER_LOG logger_log);
extern void socketio_destroy(CONCRETE_IO_HANDLE socket_io);
extern int socketio_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_io_open_complete_context, ON_BYTES_RECEIVED on_bytes_received, void* on_bytes_received_context, ON_IO_ERROR on_io_error, void* on_io_error_context);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/azure_c_shared_utility/uniqueid.h Sun Apr 24 16:41:14 2016 -0700
@@ -0,0 +1,29 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef UNIQUEID_H
+#define UNIQUEID_H
+
+#include "azure_c_shared_utility/macro_utils.h"
+
+#ifdef __cplusplus
+#include <cstddef>
+extern "C" {
+#else
+#include <stddef.h>
+#endif
+
+#define UNIQUEID_RESULT_VALUES \
+ UNIQUEID_OK, \
+ UNIQUEID_INVALID_ARG, \
+ UNIQUEID_ERROR
+
+ DEFINE_ENUM(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES)
+
+ extern UNIQUEID_RESULT UniqueId_Generate(char* uid, size_t bufferSize);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* UNIQUEID_H */
--- a/base64.c Fri Apr 08 12:01:36 2016 -0700
+++ b/base64.c Sun Apr 24 16:41:14 2016 -0700
@@ -180,14 +180,14 @@
if ((lengthOfSource % 4) == 1)
{
/*Codes_SRS_BASE64_06_011: [If the source string has an invalid length for a base 64 encoded string then Base64_Decode shall return NULL.]*/
- LogError("Invalid length Base64 string!\r\n");
+ LogError("Invalid length Base64 string!");
}
else
{
if ((result = BUFFER_new()) == NULL)
{
/*Codes_SRS_BASE64_06_010: [If there is any memory allocation failure during the decode then Base64_Decode shall return NULL.]*/
- LogError("Could not create a buffer to decoding.\r\n");
+ LogError("Could not create a buffer to decoding.");
}
else
{
@@ -198,7 +198,7 @@
if (BUFFER_pre_build(result, sizeOfOutputBuffer) != 0)
{
/*Codes_SRS_BASE64_06_010: [If there is any memory allocation failure during the decode then Base64_Decode shall return NULL.]*/
- LogError("Could not prebuild a buffer for base 64 decoding.\r\n");
+ LogError("Could not prebuild a buffer for base 64 decoding.");
BUFFER_delete(result);
result = NULL;
}
@@ -227,7 +227,7 @@
if (encoded == NULL)
{
result = NULL;
- LogError("Base64_Encode:: Allocation failed.\r\n");
+ LogError("Base64_Encode:: Allocation failed.");
}
else
{
@@ -288,7 +288,7 @@
if (result == NULL)
{
free(encoded);
- LogError("Base64_Encode:: Allocation failed for return value.\r\n");
+ LogError("Base64_Encode:: Allocation failed for return value.");
}
}
return result;
@@ -328,7 +328,7 @@
if (input == NULL)
{
result = NULL;
- LogError("Base64_Encode:: NULL input\r\n");
+ LogError("Base64_Encode:: NULL input");
}
else
{
@@ -338,7 +338,7 @@
(BUFFER_size(input, &inputSize) != 0))
{
result = NULL;
- LogError("Base64_Encode:: BUFFER_routines failure.\r\n");
+ LogError("Base64_Encode:: BUFFER_routines failure.");
}
else
{
--- a/constmap.c Fri Apr 08 12:01:36 2016 -0700
+++ b/constmap.c Sun Apr 24 16:41:14 2016 -0700
@@ -21,7 +21,7 @@
DEFINE_REFCOUNT_TYPE(CONSTMAP_HANDLE_DATA);
-#define LOG_CONSTMAP_ERROR(result) LogError("result = %s\r\n", ENUM_TO_STRING(CONSTMAP_RESULT, (result)));
+#define LOG_CONSTMAP_ERROR(result) LogError("result = %s", ENUM_TO_STRING(CONSTMAP_RESULT, (result)));
CONSTMAP_HANDLE ConstMap_Create(MAP_HANDLE sourceMap)
{
--- a/gballoc.c Fri Apr 08 12:01:36 2016 -0700
+++ b/gballoc.c Sun Apr 24 16:41:14 2016 -0700
@@ -88,7 +88,7 @@
else if (LOCK_OK != Lock(gballocThreadSafeLock))
{
/* Codes_SRS_GBALLOC_01_048: [If acquiring the lock fails, gballoc_malloc shall return NULL.] */
- LogError("Failed to get the Lock.\r\n");
+ LogError("Failed to get the Lock.");
result = NULL;
}
else
@@ -143,7 +143,7 @@
else if (LOCK_OK != Lock(gballocThreadSafeLock))
{
/* Codes_SRS_GBALLOC_01_046: [If acquiring the lock fails, gballoc_calloc shall return NULL.] */
- LogError("Failed to get the Lock.\r\n");
+ LogError("Failed to get the Lock.");
result = NULL;
}
else
@@ -200,7 +200,7 @@
else if (LOCK_OK != Lock(gballocThreadSafeLock))
{
/* Codes_SRS_GBALLOC_01_047: [If acquiring the lock fails, gballoc_realloc shall return NULL.] */
- LogError("Failed to get the Lock.\r\n");
+ LogError("Failed to get the Lock.");
result = NULL;
}
else
@@ -293,7 +293,7 @@
else if (LOCK_OK != Lock(gballocThreadSafeLock))
{
/* Codes_SRS_GBALLOC_01_049: [If acquiring the lock fails, gballoc_free shall do nothing.] */
- LogError("Failed to get the Lock.\r\n");
+ LogError("Failed to get the Lock.");
}
else
{
@@ -327,7 +327,7 @@
/* Codes_SRS_GBALLOC_01_019: [When the ptr pointer cannot be found in the pointers tracked by gballoc, gballoc_free shall not free any memory.] */
/* could not find the allocation */
- LogError("Could not free allocation for address %p (not found)\r\n", ptr);
+ LogError("Could not free allocation for address %p (not found)", ptr);
}
(void)Unlock(gballocThreadSafeLock);
}
@@ -340,14 +340,14 @@
/* Codes_SRS_GBALLOC_01_038: [If gballoc was not initialized gballoc_getMaximumMemoryUsed shall return MAX_INT_SIZE.] */
if (gballocState != GBALLOC_STATE_INIT)
{
- LogError("gballoc is not initialized.\r\n");
+ LogError("gballoc is not initialized.");
result = SIZE_MAX;
}
/* Codes_SRS_GBALLOC_01_034: [gballoc_getMaximumMemoryUsed shall ensure thread safety by using the lock created by gballoc_Init.] */
else if (LOCK_OK != Lock(gballocThreadSafeLock))
{
/* Codes_SRS_GBALLOC_01_050: [If the lock cannot be acquired, gballoc_getMaximumMemoryUsed shall return SIZE_MAX.] */
- LogError("Failed to get the Lock.\r\n");
+ LogError("Failed to get the Lock.");
result = SIZE_MAX;
}
else
@@ -367,14 +367,14 @@
/* Codes_SRS_GBALLOC_01_044: [If gballoc was not initialized gballoc_getCurrentMemoryUsed shall return SIZE_MAX.] */
if (gballocState != GBALLOC_STATE_INIT)
{
- LogError("gballoc is not initialized.\r\n");
+ LogError("gballoc is not initialized.");
result = SIZE_MAX;
}
/* Codes_SRS_GBALLOC_01_036: [gballoc_getCurrentMemoryUsed shall ensure thread safety by using the lock created by gballoc_Init.]*/
else if (LOCK_OK != Lock(gballocThreadSafeLock))
{
/* Codes_SRS_GBALLOC_01_051: [If the lock cannot be acquired, gballoc_getCurrentMemoryUsed shall return SIZE_MAX.] */
- LogError("Failed to get the Lock.\r\n");
+ LogError("Failed to get the Lock.");
result = SIZE_MAX;
}
else
--- a/httpapi_mbed.cpp Fri Apr 08 12:01:36 2016 -0700
+++ b/httpapi_mbed.cpp Sun Apr 24 16:41:14 2016 -0700
@@ -38,7 +38,7 @@
time_t ctTime;
ctTime = time(NULL);
HTTPAPI_RESULT result;
- LogInfo("HTTAPI_Init::Time is now (UTC) %s\r\n", ctime(&ctTime));
+ LogInfo("HTTAPI_Init::Time is now (UTC) %s", ctime(&ctTime));
result = HTTPAPI_OK;
@@ -59,7 +59,7 @@
handle = new HTTP_HANDLE_DATA();
if (strcpy_s(handle->host, MAX_HOSTNAME, hostName) != 0)
{
- LogError("HTTPAPI_CreateConnection::Could not strcpy_s\r\n");
+ LogError("HTTPAPI_CreateConnection::Could not strcpy_s");
delete handle;
handle = NULL;
}
@@ -70,7 +70,7 @@
}
else
{
- LogInfo("HTTPAPI_CreateConnection:: null hostName parameter\r\n");
+ LogInfo("HTTPAPI_CreateConnection:: null hostName parameter");
}
return (HTTP_HANDLE)handle;
@@ -84,7 +84,7 @@
{
if (h->con.is_connected())
{
- LogInfo("HTTPAPI_CloseConnection h->con.close(); to %s\r\n", h->host);
+ LogInfo("HTTPAPI_CloseConnection h->con.close(); to %s", h->host);
h->con.close();
}
if (h->certificate)
@@ -190,7 +190,7 @@
HTTPHeaders_GetHeaderCount(httpHeadersHandle, &headersCount) != HTTP_HEADERS_OK)
{
result = HTTPAPI_INVALID_ARG;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@@ -204,7 +204,7 @@
(!con->load_certificate((const unsigned char*)httpHandle->certificate, strlen(httpHandle->certificate) + 1)))
{
result = HTTPAPI_ERROR;
- LogError("Could not load certificate (result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("Could not load certificate (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@@ -212,7 +212,7 @@
if (con->connect(httpHandle->host, 443) != 0)
{
result = HTTPAPI_ERROR;
- LogError("Could not connect (result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("Could not connect (result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
}
@@ -222,13 +222,13 @@
|| ret >= sizeof(buf))
{
result = HTTPAPI_STRING_PROCESSING_ERROR;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
if (con->send_all(buf, strlen(buf)) < 0)
{
result = HTTPAPI_SEND_REQUEST_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@@ -239,20 +239,20 @@
if (HTTPHeaders_GetHeader(httpHeadersHandle, i, &header) != HTTP_HEADERS_OK)
{
result = HTTPAPI_HTTP_HEADERS_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
if (con->send_all(header, strlen(header)) < 0)
{
result = HTTPAPI_SEND_REQUEST_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
free(header);
goto exit;
}
if (con->send_all("\r\n", 2) < 0)
{
result = HTTPAPI_SEND_REQUEST_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
free(header);
goto exit;
}
@@ -263,7 +263,7 @@
if (con->send_all("\r\n", 2) < 0)
{
result = HTTPAPI_SEND_REQUEST_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@@ -273,7 +273,7 @@
if (con->send_all((char*)content, contentLength) < 0)
{
result = HTTPAPI_SEND_REQUEST_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
}
@@ -282,7 +282,7 @@
if (readLine(con, buf, sizeof(buf)) < 0)
{
result = HTTPAPI_READ_DATA_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@@ -290,9 +290,9 @@
if (sscanf(buf, "HTTP/%*d.%*d %d %*[^\r\n]", &ret) != 1)
{
//Cannot match string, error
- LogInfo("HTTPAPI_ExecuteRequest::Not a correct HTTP answer=%s\r\n", buf);
+ LogInfo("HTTPAPI_ExecuteRequest::Not a correct HTTP answer=%s", buf);
result = HTTPAPI_READ_DATA_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
if (statusCode)
@@ -302,7 +302,7 @@
if (readLine(con, buf, sizeof(buf)) < 0)
{
result = HTTPAPI_READ_DATA_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@@ -316,7 +316,7 @@
if (sscanf(buf + CHAR_COUNT(ContentLength), " %d", &bodyLength) != 1)
{
result = HTTPAPI_READ_DATA_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
}
@@ -338,7 +338,7 @@
if (readLine(con, buf, sizeof(buf)) < 0)
{
result = HTTPAPI_READ_DATA_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
}
@@ -353,20 +353,20 @@
if (BUFFER_pre_build(responseContent, bodyLength) != 0)
{
result = HTTPAPI_ALLOC_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (BUFFER_content(responseContent, &receivedContent) != 0)
{
(void)BUFFER_unbuild(responseContent);
result = HTTPAPI_ALLOC_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
if (readChunk(con, (char*)receivedContent, bodyLength) < 0)
{
result = HTTPAPI_READ_DATA_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
else
@@ -395,14 +395,14 @@
if (readLine(con, buf, sizeof(buf)) < 0) // read [length in hex]/r/n
{
result = HTTPAPI_READ_DATA_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
if (sscanf(buf, "%x", &chunkSize) != 1) // chunkSize is length of next line (/r/n is not counted)
{
//Cannot match string, error
result = HTTPAPI_RECEIVE_RESPONSE_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
@@ -415,7 +415,7 @@
(void)BUFFER_unbuild(responseContent);
result = HTTPAPI_READ_DATA_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
break;
@@ -429,20 +429,20 @@
(void)BUFFER_unbuild(responseContent);
result = HTTPAPI_ALLOC_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
else if (BUFFER_content(responseContent, &receivedContent) != 0)
{
(void)BUFFER_unbuild(responseContent);
result = HTTPAPI_ALLOC_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
}
if (readChunk(con, (char*)receivedContent + size, chunkSize) < 0)
{
result = HTTPAPI_READ_DATA_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
}
@@ -451,7 +451,7 @@
if (skipN(con, chunkSize, buf, sizeof(buf)) < 0)
{
result = HTTPAPI_READ_DATA_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
}
@@ -460,7 +460,7 @@
|| buf[0] != '\r' || buf[1] != '\n') // skip /r/n
{
result = HTTPAPI_READ_DATA_FAILED;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTPAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTPAPI_RESULT, result));
goto exit;
}
size += chunkSize;
@@ -483,7 +483,7 @@
)
{
result = HTTPAPI_INVALID_ARG;
- LogError("invalid parameter (NULL) passed to HTTPAPI_SetOption\r\n");
+ LogError("invalid parameter (NULL) passed to HTTPAPI_SetOption");
}
else if (strcmp("TrustedCerts", optionName) == 0)
{
@@ -498,7 +498,7 @@
if (h->certificate == NULL)
{
result = HTTPAPI_ERROR;
- LogError("unable to allocate certificate memory in HTTPAPI_SetOption\r\n");
+ LogError("unable to allocate certificate memory in HTTPAPI_SetOption");
}
else
{
@@ -509,7 +509,7 @@
else
{
result = HTTPAPI_INVALID_ARG;
- LogError("unknown option %s\r\n", optionName);
+ LogError("unknown option %s", optionName);
}
return result;
}
@@ -524,7 +524,7 @@
)
{
result = HTTPAPI_INVALID_ARG;
- LogError("invalid argument(NULL) passed to HTTPAPI_CloneOption\r\n");
+ LogError("invalid argument(NULL) passed to HTTPAPI_CloneOption");
}
else if (strcmp("TrustedCerts", optionName) == 0)
{
@@ -533,7 +533,7 @@
if (tempCert == NULL)
{
result = HTTPAPI_INVALID_ARG;
- LogError("unable to allocate certificate memory in HTTPAPI_CloneOption\r\n");
+ LogError("unable to allocate certificate memory in HTTPAPI_CloneOption");
}
else
{
@@ -545,7 +545,7 @@
else
{
result = HTTPAPI_INVALID_ARG;
- LogError("unknown option %s\r\n", optionName);
+ LogError("unknown option %s", optionName);
}
return result;
}
--- a/httpapiex.c Fri Apr 08 12:01:36 2016 -0700
+++ b/httpapiex.c Sun Apr 24 16:41:14 2016 -0700
@@ -29,7 +29,7 @@
DEFINE_ENUM_STRINGS(HTTPAPIEX_RESULT, HTTPAPIEX_RESULT_VALUES);
-#define LOG_HTTAPIEX_ERROR() LogError("error code = %s\r\n", ENUM_TO_STRING(HTTPAPIEX_RESULT, result))
+#define LOG_HTTAPIEX_ERROR() LogError("error code = %s", ENUM_TO_STRING(HTTPAPIEX_RESULT, result))
HTTPAPIEX_HANDLE HTTPAPIEX_Create(const char* hostName)
{
@@ -37,7 +37,7 @@
/*Codes_SRS_HTTPAPIEX_02_001: [If parameter hostName is NULL then HTTPAPIEX_Create shall return NULL.]*/
if (hostName == NULL)
{
- LogError("invalid (NULL) parameter\r\n");
+ LogError("invalid (NULL) parameter");
result = NULL;
}
else
@@ -46,7 +46,7 @@
HTTPAPIEX_HANDLE_DATA* handleData = (HTTPAPIEX_HANDLE_DATA*)malloc(sizeof(HTTPAPIEX_HANDLE_DATA));
if (handleData == NULL)
{
- LogError("malloc failed.\r\n");
+ LogError("malloc failed.");
result = NULL;
}
else
@@ -56,7 +56,7 @@
if (handleData->hostName == NULL)
{
free(handleData);
- LogError("unable to STRING_construct\r\n");
+ LogError("unable to STRING_construct");
result = NULL;
}
else
@@ -108,7 +108,7 @@
if (*toBeUsedRequestHttpHeadersHandle == NULL)
{
result = __LINE__;
- LogError("unable to HTTPHeaders_Alloc\r\n");
+ LogError("unable to HTTPHeaders_Alloc");
}
else
{
@@ -212,7 +212,7 @@
if (buildBufferIfNotExist(requestContent, isOriginalRequestContent, toBeUsedRequestContent) != 0)
{
result = __LINE__;
- LogError("unable to build the request content\r\n");
+ LogError("unable to build the request content");
}
else
{
@@ -224,7 +224,7 @@
{
BUFFER_delete(*toBeUsedRequestContent);
}
- LogError("unable to build the request http headers handle\r\n");
+ LogError("unable to build the request http headers handle");
}
else
{
@@ -263,7 +263,7 @@
{
HTTPHeaders_Free(*toBeUsedRequestHttpHeadersHandle);
}
- LogError("unable to build response content\r\n");
+ LogError("unable to build response content");
}
else
{
@@ -285,7 +285,7 @@
{
HTTPHeaders_Free(*toBeUsedResponseHttpHeadersHandle);
}
- LogError("unable to build response content\r\n");
+ LogError("unable to build response content");
}
else
{
@@ -400,7 +400,7 @@
HTTPAPIEX_SAVED_OPTION* option = VECTOR_element(handleData->savedOptions, i);
if (HTTPAPI_SetOption(handleData->httpHandle, option->optionName, option->value) != HTTPAPI_OK)
{
- LogError("HTTPAPI_SetOption failed when called for option %s\r\n", option->optionName);
+ LogError("HTTPAPI_SetOption failed when called for option %s", option->optionName);
}
}
goOn = true;
@@ -473,7 +473,7 @@
} while (handleData->k >= 0);
/*Codes_SRS_HTTPAPIEX_02_029: [Otherwise, HTTAPIEX_ExecuteRequest shall return HTTPAPIEX_RECOVERYFAILED.] */
result = HTTPAPIEX_RECOVERYFAILED;
- LogError("unable to recover sending to a working state\r\n");
+ LogError("unable to recover sending to a working state");
out:;
/*in all cases, unbuild the temporaries*/
if (isOriginalRequestContent == false)
@@ -565,7 +565,7 @@
newOption.value = value;
if (VECTOR_push_back(handleData->savedOptions, &newOption, 1) != 0)
{
- LogError("unable to VECTOR_push_back\r\n");
+ LogError("unable to VECTOR_push_back");
free((void*)newOption.optionName);
free((void*)value);
result = __LINE__;
--- a/httpapiexsas.c Fri Apr 08 12:01:36 2016 -0700
+++ b/httpapiexsas.c Sun Apr 24 16:41:14 2016 -0700
@@ -33,17 +33,17 @@
if (key == NULL)
{
/*Codes_SRS_HTTPAPIEXSAS_06_001: [If the parameter key is NULL then HTTPAPIEX_SAS_Create shall return NULL.]*/
- LogError("No key passed to HTTPAPIEX_SAS_Create.\r\n");
+ LogError("No key passed to HTTPAPIEX_SAS_Create.");
}
else if (uriResource == NULL)
{
/*Codes_SRS_HTTPAPIEXSAS_06_002: [If the parameter uriResource is NULL then HTTPAPIEX_SAS_Create shall return NULL.]*/
- LogError("No uri resource passed to HTTPAPIEX_SAS_Create.\r\n");
+ LogError("No uri resource passed to HTTPAPIEX_SAS_Create.");
}
else if (keyName == NULL)
{
/*Codes_SRS_HTTPAPIEXSAS_06_003: [If the parameter keyName is NULL then HTTPAPIEX_SAS_Create shall return NULL.]*/
- LogError("No key name passed to HTTPAPIEX_SAS_Create.\r\n");
+ LogError("No key name passed to HTTPAPIEX_SAS_Create.");
}
else
{
@@ -59,7 +59,7 @@
((state->keyName = STRING_clone(keyName)) == NULL))
{
/*Codes_SRS_HTTPAPIEXSAS_06_004: [If there are any other errors in the instantiation of this handle then HTTPAPIEX_SAS_Create shall return NULL.]*/
- LogError("Unable to clone the arguments.\r\n");
+ LogError("Unable to clone the arguments.");
HTTPAPIEX_SAS_Destroy(state);
}
else
@@ -112,7 +112,7 @@
/*Codes_SRS_HTTPAPIEXSAS_06_019: [If the value of currentTime is (time_t)-1 is then fallthrough.]*/
if (currentTime == (time_t)-1)
{
- LogError("Time does not appear to be working.\r\n");
+ LogError("Time does not appear to be working.");
}
else
{
@@ -126,14 +126,14 @@
if (HTTPHeaders_ReplaceHeaderNameValuePair(requestHttpHeadersHandle, "Authorization", STRING_c_str(newSASToken)) != HTTP_HEADERS_OK)
{
/*Codes_SRS_HTTPAPIEXSAS_06_014: [If the result of the invocation of HTTPHeaders_ReplaceHeaderNameValuePair is NOT HTTP_HEADERS_OK then fallthrough.]*/
- LogError("Unable to replace the old SAS Token.\r\n");
+ LogError("Unable to replace the old SAS Token.");
}
/*Codes_SRS_HTTPAPIEXSAS_06_015: [STRING_delete(newSASToken) will be invoked.]*/
STRING_delete(newSASToken);
}
else
{
- LogError("Unable to create a new SAS token.\r\n");
+ LogError("Unable to create a new SAS token.");
}
}
}
--- a/httpheaders.c Fri Apr 08 12:01:36 2016 -0700
+++ b/httpheaders.c Sun Apr 24 16:41:14 2016 -0700
@@ -34,7 +34,7 @@
if (result == NULL)
{
- LogError("malloc failed\r\n");
+ LogError("malloc failed");
}
else
{
@@ -42,7 +42,7 @@
result->headers = Map_Create(NULL);
if (result->headers == NULL)
{
- LogError("Map_Create failed\r\n");
+ LogError("Map_Create failed");
free(result);
result = NULL;
}
@@ -86,7 +86,7 @@
)
{
result = HTTP_HEADERS_INVALID_ARG;
- LogError("invalid arg (NULL) , result= %s\r\n", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
+ LogError("invalid arg (NULL) , result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@@ -105,7 +105,7 @@
if (i < nameLen)
{
result = HTTP_HEADERS_INVALID_ARG;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@@ -125,7 +125,7 @@
{
/*Codes_SRS_HTTP_HEADERS_99_015:[ The function shall return HTTP_HEADERS_ALLOC_FAILED when an internal request to allocate memory fails.]*/
result = HTTP_HEADERS_ALLOC_FAILED;
- LogError("failed to malloc , result= %s\r\n", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
+ LogError("failed to malloc , result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@@ -139,7 +139,7 @@
{
/*Codes_SRS_HTTP_HEADERS_99_015:[ The function shall return HTTP_HEADERS_ALLOC_FAILED when an internal request to allocate memory fails.]*/
result = HTTP_HEADERS_ERROR;
- LogError("failed to Map_AddOrUpdate, result= %s\r\n", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
+ LogError("failed to Map_AddOrUpdate, result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@@ -156,7 +156,7 @@
{
/*Codes_SRS_HTTP_HEADERS_99_015:[ The function shall return HTTP_HEADERS_ALLOC_FAILED when an internal request to allocate memory fails.]*/
result = HTTP_HEADERS_ALLOC_FAILED;
- LogError("failed to Map_AddOrUpdate, result= %s\r\n", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
+ LogError("failed to Map_AddOrUpdate, result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@@ -213,7 +213,7 @@
(headerCount == NULL))
{
result = HTTP_HEADERS_INVALID_ARG;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@@ -225,7 +225,7 @@
{
/*Codes_SRS_HTTP_HEADERS_99_037:[ The function shall return HTTP_HEADERS_ERROR when an internal error occurs.]*/
result = HTTP_HEADERS_ERROR;
- LogError("Map_GetInternals failed, result= %s\r\n", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
+ LogError("Map_GetInternals failed, result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@@ -250,7 +250,7 @@
)
{
result = HTTP_HEADERS_INVALID_ARG;
- LogError("invalid arg (NULL), result= %s\r\n", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
+ LogError("invalid arg (NULL), result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
/*Codes_SRS_HTTP_HEADERS_99_029:[ The function shall return HTTP_HEADERS_INVALID_ARG if index is not valid (for example, out of range) for the currently stored headers.]*/
else
@@ -263,7 +263,7 @@
{
/*Codes_SRS_HTTP_HEADERS_99_034:[ The function shall return HTTP_HEADERS_ERROR when an internal error occurs]*/
result = HTTP_HEADERS_ERROR;
- LogError("Map_GetInternals failed, result= %s\r\n", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
+ LogError("Map_GetInternals failed, result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@@ -271,7 +271,7 @@
if (index >= headerCount)
{
result = HTTP_HEADERS_INVALID_ARG;
- LogError("index out of bounds, result= %s\r\n", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
+ LogError("index out of bounds, result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
@@ -280,7 +280,7 @@
{
/*Codes_SRS_HTTP_HEADERS_99_034:[ The function shall return HTTP_HEADERS_ERROR when an internal error occurs]*/
result = HTTP_HEADERS_ERROR;
- LogError("unable to malloc, result= %s\r\n", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
+ LogError("unable to malloc, result= %s", ENUM_TO_STRING(HTTP_HEADERS_RESULT, result));
}
else
{
--- a/lock_rtx_mbed.cpp Fri Apr 08 12:01:36 2016 -0700
+++ b/lock_rtx_mbed.cpp Sun Apr 24 16:41:14 2016 -0700
@@ -28,7 +28,7 @@
{
/*Tests_SRS_LOCK_99_007:[ This API on NULL handle passed returns LOCK_ERROR]*/
result = LOCK_ERROR;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(LOCK_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(LOCK_RESULT, result));
}
else
{
@@ -42,7 +42,7 @@
{
/*Tests_SRS_LOCK_99_006:[ This API on error should return LOCK_ERROR]*/
result = LOCK_ERROR;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(LOCK_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(LOCK_RESULT, result));
}
}
return result;
@@ -54,7 +54,7 @@
{
/*Tests_SRS_LOCK_99_011:[ This API on NULL handle passed returns LOCK_ERROR]*/
result = LOCK_ERROR;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(LOCK_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(LOCK_RESULT, result));
}
else
{
@@ -68,7 +68,7 @@
{
/*Tests_SRS_LOCK_99_010:[ This API on error should return LOCK_ERROR]*/
result = LOCK_ERROR;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(LOCK_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(LOCK_RESULT, result));
}
}
return result;
@@ -81,7 +81,7 @@
{
/*Tests_SRS_LOCK_99_013:[ This API on NULL handle passed returns LOCK_ERROR]*/
result = LOCK_ERROR;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(LOCK_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(LOCK_RESULT, result));
}
else
{
--- a/map.c Fri Apr 08 12:01:36 2016 -0700
+++ b/map.c Sun Apr 24 16:41:14 2016 -0700
@@ -21,7 +21,7 @@
MAP_FILTER_CALLBACK mapFilterCallback;
}MAP_HANDLE_DATA;
-#define LOG_MAP_ERROR LogError("result = %s\r\n", ENUM_TO_STRING(MAP_RESULT, result));
+#define LOG_MAP_ERROR LogError("result = %s", ENUM_TO_STRING(MAP_RESULT, result));
MAP_HANDLE Map_Create(MAP_FILTER_CALLBACK mapFilterFunc)
{
@@ -106,7 +106,7 @@
{
/*Codes_SRS_MAP_02_038: [Map_Clone returns NULL if parameter handle is NULL.]*/
result = NULL;
- LogError("invalid arg to Map_Clone (NULL)\r\n");
+ LogError("invalid arg to Map_Clone (NULL)");
}
else
{
@@ -116,7 +116,7 @@
{
/*Codes_SRS_MAP_02_047: [If during cloning, any operation fails, then Map_Clone shall return NULL.] */
/*do nothing, proceed to return it, this is an error case*/
- LogError("unable to malloc\r\n");
+ LogError("unable to malloc");
}
else
{
@@ -134,14 +134,14 @@
if( (result->keys = Map_CloneVector((const char* const*)handleData->keys, handleData->count))==NULL)
{
/*Codes_SRS_MAP_02_047: [If during cloning, any operation fails, then Map_Clone shall return NULL.] */
- LogError("unable to clone keys\r\n");
+ LogError("unable to clone keys");
free(result);
result = NULL;
}
else if ((result->values = Map_CloneVector((const char* const*)handleData->values, handleData->count)) == NULL)
{
/*Codes_SRS_MAP_02_047: [If during cloning, any operation fails, then Map_Clone shall return NULL.] */
- LogError("unable to clone values\r\n");
+ LogError("unable to clone values");
size_t i;
for (i = 0; i < result->count; i++)
{
@@ -167,7 +167,7 @@
char** newKeys = (char**)realloc(handleData->keys, (handleData->count + 1) * sizeof(char*));
if (newKeys == NULL)
{
- LogError("realloc error\r\n");
+ LogError("realloc error");
result = __LINE__;
}
else
@@ -178,7 +178,7 @@
newValues = (char**)realloc(handleData->values, (handleData->count + 1) * sizeof(char*));
if (newValues == NULL)
{
- LogError("realloc error\r\n");
+ LogError("realloc error");
if (handleData->count == 0) /*avoiding an implementation defined behavior */
{
free(handleData->keys);
@@ -189,7 +189,7 @@
char** undoneKeys = (char**)realloc(handleData->keys, (handleData->count) * sizeof(char*));
if (undoneKeys == NULL)
{
- LogError("CATASTROPHIC error, unable to undo through realloc to a smaller size\r\n");
+ LogError("CATASTROPHIC error, unable to undo through realloc to a smaller size");
}
else
{
@@ -227,7 +227,7 @@
char** undoneKeys = (char**)realloc(handleData->keys, sizeof(char*)* (handleData->count - 1));
if (undoneKeys == NULL)
{
- LogError("CATASTROPHIC error, unable to undo through realloc to a smaller size\r\n");
+ LogError("CATASTROPHIC error, unable to undo through realloc to a smaller size");
}
else
{
@@ -237,7 +237,7 @@
undoneValues = (char**)realloc(handleData->values, sizeof(char*)* (handleData->count - 1));
if (undoneValues == NULL)
{
- LogError("CATASTROPHIC error, unable to undo through realloc to a smaller size\r\n");
+ LogError("CATASTROPHIC error, unable to undo through realloc to a smaller size");
}
else
{
@@ -306,7 +306,7 @@
if (mallocAndStrcpy_s(&(handleData->keys[handleData->count - 1]), key) != 0)
{
Map_DecreaseStorageKeysValues(handleData);
- LogError("unable to mallocAndStrcpy_s\r\n");
+ LogError("unable to mallocAndStrcpy_s");
result = __LINE__;
}
else
@@ -315,7 +315,7 @@
{
free(handleData->keys[handleData->count - 1]);
Map_DecreaseStorageKeysValues(handleData);
- LogError("unable to mallocAndStrcpy_s\r\n");
+ LogError("unable to mallocAndStrcpy_s");
result = __LINE__;
}
else
@@ -538,7 +538,7 @@
)
{
result = NULL;
- LogError("invalid parameter to Map_GetValueFromKey\r\n");
+ LogError("invalid parameter to Map_GetValueFromKey");
}
else
{
--- a/sastoken.c Fri Apr 08 12:01:36 2016 -0700
+++ b/sastoken.c Sun Apr 24 16:41:14 2016 -0700
@@ -32,7 +32,7 @@
(scope == NULL) ||
(keyName == NULL))
{
- LogError("Invalid Parameter to SASToken_Create. handle key: %p, handle scope: %p, handle keyName: %p\r\n", key, scope, keyName);
+ LogError("Invalid Parameter to SASToken_Create. handle key: %p, handle scope: %p, handle keyName: %p", key, scope, keyName);
}
else
{
@@ -41,14 +41,14 @@
if ((decodedKey = Base64_Decoder(STRING_c_str(key))) == NULL)
{
/*Codes_SRS_SASTOKEN_06_030: [If there is an error in the decoding then SASToken_Create shall return NULL.]*/
- LogError("Unable to decode the key for generating the SAS.\r\n");
+ LogError("Unable to decode the key for generating the SAS.");
}
else
{
/*Codes_SRS_SASTOKEN_06_026: [If the conversion to string form fails for any reason then SASToken_Create shall return NULL.]*/
if (size_tToString(tokenExpirationTime, sizeof(tokenExpirationTime), expiry) != 0)
{
- LogError("For some reason converting seconds to a string failed. No SAS can be generated.\r\n");
+ LogError("For some reason converting seconds to a string failed. No SAS can be generated.");
}
else
{
@@ -58,7 +58,7 @@
((toBeHashed = STRING_new()) == NULL) ||
((result = STRING_new()) == NULL))
{
- LogError("Unable to allocate memory to prepare SAS token.\r\n");
+ LogError("Unable to allocate memory to prepare SAS token.");
}
else
{
@@ -69,7 +69,7 @@
(STRING_concat(toBeHashed, "\n") != 0) ||
(STRING_concat(toBeHashed, tokenExpirationTime) != 0))
{
- LogError("Unable to build the input to the HMAC to prepare SAS token.\r\n");
+ LogError("Unable to build the input to the HMAC to prepare SAS token.");
STRING_delete(result);
result = NULL;
}
@@ -102,7 +102,7 @@
(STRING_concat(result, "&skn=") != 0) ||
(STRING_concat_with_STRING(result, keyName) != 0))
{
- LogError("Unable to build the SAS token.\r\n");
+ LogError("Unable to build the SAS token.");
STRING_delete(result);
result = NULL;
}
--- a/socketio_mbed.c Fri Apr 08 12:01:36 2016 -0700
+++ b/socketio_mbed.c Sun Apr 24 16:41:14 2016 -0700
@@ -12,8 +12,10 @@
#include "azure_c_shared_utility/socketio.h"
#include "azure_c_shared_utility/list.h"
#include "azure_c_shared_utility/tcpsocketconnection_c.h"
+#include "azure_c_shared_utility/iot_logging.h"
#define UNABLE_TO_COMPLETE -2
+#define MBED_RECEIVE_BYTES_VALUE 128
typedef enum IO_STATE_TAG
{
@@ -401,15 +403,24 @@
while (received > 0)
{
- unsigned char recv_bytes[128];
- received = tcpsocketconnection_receive(socket_io_instance->tcp_socket_connection, (char*)recv_bytes, sizeof(recv_bytes));
- if (received > 0)
+ unsigned char* recv_bytes = malloc(MBED_RECEIVE_BYTES_VALUE);
+ if (recv_bytes == NULL)
+ {
+ LogError("Socketio_Failure: NULL allocating input buffer.");
+ indicate_error(socket_io_instance);
+ }
+ else
{
- if (socket_io_instance->on_bytes_received != NULL)
+ received = tcpsocketconnection_receive(socket_io_instance->tcp_socket_connection, (char*)recv_bytes, MBED_RECEIVE_BYTES_VALUE);
+ if (received > 0)
{
- /* explictly ignoring here the result of the callback */
- (void)socket_io_instance->on_bytes_received(socket_io_instance->on_bytes_received_context, recv_bytes, received);
+ if (socket_io_instance->on_bytes_received != NULL)
+ {
+ /* explictly ignoring here the result of the callback */
+ (void)socket_io_instance->on_bytes_received(socket_io_instance->on_bytes_received_context, recv_bytes, received);
+ }
}
+ free(recv_bytes);
}
}
}
--- a/string_tokenizer.c Fri Apr 08 12:01:36 2016 -0700
+++ b/string_tokenizer.c Sun Apr 24 16:41:14 2016 -0700
@@ -32,7 +32,7 @@
/* Codes_SRS_STRING_04_001: [STRING_TOKENIZER_create shall return an NULL STRING_TOKENIZER_HANDLE if parameter handle is NULL] */
if (handle == NULL)
{
- LogError("Invalid Argument. Handle cannot be NULL.\r\n");
+ LogError("Invalid Argument. Handle cannot be NULL.");
result = NULL;
}
else
@@ -52,17 +52,17 @@
/* Codes_SRS_STRING_07_001: [STRING_TOKENIZER_create shall return an NULL STRING_TOKENIZER_HANDLE if parameter input is NULL] */
if (input == NULL)
{
- LogError("Invalid Argument. Handle cannot be NULL.\r\n");
+ LogError("Invalid Argument. Handle cannot be NULL.");
result = NULL;
}
/* Codes_SRS_STRING_07_002: [STRING_TOKENIZER_create shall allocate a new STRING_TOKENIZER_HANDLE having the content of the STRING_HANDLE copied and current position pointing at the beginning of the string] */
else if ((result = (STRING_TOKEN*)malloc(sizeof(STRING_TOKEN))) == NULL)
{
- LogError("Memory Allocation failed. Cannot allocate STRING_TOKENIZER.\r\n");
+ LogError("Memory Allocation failed. Cannot allocate STRING_TOKENIZER.");
}
else if ((mallocAndStrcpy_s(&inputStringToMalloc, input)) != 0)
{
- LogError("Memory Allocation Failed. Cannot allocate and copy string Content.\r\n");
+ LogError("Memory Allocation Failed. Cannot allocate and copy string Content.");
free(result);
result = NULL;
}
@@ -98,7 +98,7 @@
}
else if (delimitterSize == 0)
{
- LogError("Empty delimiters parameter.\r\n");
+ LogError("Empty delimiters parameter.");
result = __LINE__;
}
else
@@ -169,7 +169,7 @@
//copy here the string to output.
if (STRING_copy_n(output, token->currentPos, amountOfCharactersToCopy) != 0)
{
- LogError("Problem copying token to output String.\r\n");
+ LogError("Problem copying token to output String.");
result = __LINE__;
}
else
--- a/strings.c Fri Apr 08 12:01:36 2016 -0700
+++ b/strings.c Sun Apr 24 16:41:14 2016 -0700
@@ -180,7 +180,7 @@
{
/*Codes_SRS_STRING_02_011: [If source is NULL then STRING_new_JSON shall return NULL.] */
result = NULL;
- LogError("invalid arg (NULL)\r\n");
+ LogError("invalid arg (NULL)");
}
else
{
@@ -216,21 +216,21 @@
if (i < vlen)
{
result = NULL;
- LogError("invalid character in input string\r\n");
+ LogError("invalid character in input string");
}
else
{
if ((result = (STRING*)malloc(sizeof(STRING))) == NULL)
{
/*Codes_SRS_STRING_02_021: [If the complete JSON representation cannot be produced, then STRING_new_JSON shall fail and return NULL.] */
- LogError("malloc failure\r\n");
+ LogError("malloc failure");
}
else if ((result->s = (char*)malloc(vlen + 5 * nControlCharacters + nEscapeCharacters + 3)) == NULL)
{
/*Codes_SRS_STRING_02_021: [If the complete JSON representation cannot be produced, then STRING_new_JSON shall fail and return NULL.] */
free(result);
result = NULL;
- LogError("malloc failed\r\n");
+ LogError("malloc failed");
}
else
{
@@ -549,7 +549,7 @@
if (psz == NULL)
{
result = NULL;
- LogError("invalid arg (NULL)\r\n");
+ LogError("invalid arg (NULL)");
}
else
{
@@ -558,7 +558,7 @@
if (n > len)
{
result = NULL;
- LogError("invalig arg (n is bigger than the size of the string)\r\n");
+ LogError("invalig arg (n is bigger than the size of the string)");
}
else
{
--- a/threadapi_rtx_mbed.cpp Fri Apr 08 12:01:36 2016 -0700
+++ b/threadapi_rtx_mbed.cpp Sun Apr 24 16:41:14 2016 -0700
@@ -45,7 +45,7 @@
(func == NULL))
{
result = THREADAPI_INVALID_ARG;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(THREADAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
}
else
{
@@ -71,13 +71,13 @@
else
{
result = THREADAPI_NO_MEMORY;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(THREADAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
}
}
else
{
result = THREADAPI_NO_MEMORY;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(THREADAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
}
}
@@ -102,13 +102,13 @@
else
{
result = THREADAPI_ERROR;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(THREADAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
}
}
else
{
result = THREADAPI_INVALID_ARG;
- LogError("(result = %s)\r\n", ENUM_TO_STRING(THREADAPI_RESULT, result));
+ LogError("(result = %s)", ENUM_TO_STRING(THREADAPI_RESULT, result));
}
return result;
}
--- a/tlsio_wolfssl.c Fri Apr 08 12:01:36 2016 -0700
+++ b/tlsio_wolfssl.c Sun Apr 24 16:41:14 2016 -0700
@@ -545,6 +545,10 @@
result = 0;
}
}
+ else if (tls_io_instance->socket_io == NULL)
+ {
+ result = __LINE__;
+ }
else
{
result = xio_setoption(tls_io_instance->socket_io, optionName, value);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/uniqueid_stub.c Sun Apr 24 16:41:14 2016 -0700
@@ -0,0 +1,76 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#include <stdlib.h>
+#include <stdint.h>
+#include "azure_c_shared_utility/uniqueid.h"
+#include "azure_c_shared_utility/iot_logging.h"
+#include <time.h>
+
+DEFINE_ENUM_STRINGS(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES);
+
+static const char tochar[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+static void generate128BitUUID(unsigned char* arrayOfByte)
+{
+ size_t arrayIndex;
+
+ for (arrayIndex = 0; arrayIndex < 16; arrayIndex++)
+ {
+ arrayOfByte[arrayIndex] = (unsigned char)rand();
+ }
+
+ //
+ // Stick in the version field for random uuid.
+ //
+ arrayOfByte[7] &= 0x0f; //clear the bit field
+ arrayOfByte[7] |= 0x40; //set the ones we care about
+
+ //
+ // Stick in the variant field for the random uuid.
+ //
+ arrayOfByte[8] &= 0xf3; // Clear
+ arrayOfByte[8] |= 0x08; // Set
+
+}
+
+// TODO: The User will need to call srand before calling this function
+UNIQUEID_RESULT UniqueId_Generate(char* uid, size_t len)
+{
+ UNIQUEID_RESULT result;
+ unsigned char arrayOfChar[16];
+
+ /* Codes_SRS_UNIQUEID_07_002: [If uid is NULL then UniqueId_Generate shall return UNIQUEID_INVALID_ARG] */
+ /* Codes_SRS_UNIQUEID_07_003: [If len is less then 37 then UniqueId_Generate shall return UNIQUEID_INVALID_ARG] */
+ if (uid == NULL || len < 37)
+ {
+ result = UNIQUEID_INVALID_ARG;
+ LogError("Buffer Size is Null or length is less then 37 bytes");
+ }
+ else
+ {
+ size_t arrayIndex;
+ size_t shiftCount;
+ size_t characterPosition = 0;
+
+ /* Codes_SRS_UNIQUEID_07_001: [UniqueId_Generate shall create a unique Id 36 character long string.] */
+ generate128BitUUID(arrayOfChar);
+ for (arrayIndex = 0; arrayIndex < 16; arrayIndex++)
+ {
+ for (shiftCount = 0; shiftCount <= 1; shiftCount++)
+ {
+ char hexChar = tochar[arrayOfChar[arrayIndex] & 0xf];
+ if ((characterPosition == 8) || (characterPosition == 13) || (characterPosition == 18) || (characterPosition == 23))
+ {
+ uid[characterPosition] = '-';
+ characterPosition++;
+ }
+ uid[characterPosition] = hexChar;
+ characterPosition++;
+ arrayOfChar[arrayIndex] = arrayOfChar[arrayIndex] >> 4;
+ }
+ }
+ uid[characterPosition] = 0;
+ result = UNIQUEID_OK;
+ }
+ return result;
+}
--- a/urlencode.c Fri Apr 08 12:01:36 2016 -0700
+++ b/urlencode.c Sun Apr 24 16:41:14 2016 -0700
@@ -311,7 +311,7 @@
{
/*Codes_SRS_URL_ENCODE_06_001: [If input is NULL then URL_Encode will return NULL.]*/
result = NULL;
- LogError("URL_Encode:: NULL input\r\n");
+ LogError("URL_Encode:: NULL input");
}
else
{
@@ -330,7 +330,7 @@
{
/*Codes_SRS_URL_ENCODE_06_002: [If an error occurs during the encoding of input then URL_Encode will return NULL.]*/
result = NULL;
- LogError("URL_Encode:: MALLOC failure on encode.\r\n");
+ LogError("URL_Encode:: MALLOC failure on encode.");
}
else
{
--- a/wolfssl_connection.cpp Fri Apr 08 12:01:36 2016 -0700
+++ b/wolfssl_connection.cpp Sun Apr 24 16:41:14 2016 -0700
@@ -91,27 +91,27 @@
if(sslContext == NULL)
{
- LogError("NULL SSL context\r\n");
+ LogError("NULL SSL context");
result = __LINE__;
}
else
{
if (init_socket(SOCK_STREAM) < 0)
{
- LogError("init_socket failed\r\n");
+ LogError("init_socket failed");
result = __LINE__;
}
else
{
if (set_address(host, port) != 0)
{
- LogError("set_address failed\r\n");
+ LogError("set_address failed");
result = __LINE__;
}
else if (lwip_connect(_sock_fd, (const struct sockaddr *) &_remoteHost, sizeof(_remoteHost)) < 0)
{
close();
- LogError("lwip_connect failed\r\n");
+ LogError("lwip_connect failed");
result = __LINE__;
}
else
@@ -122,7 +122,7 @@
ssl = wolfSSL_new(sslContext);
if(ssl == NULL)
{
- LogError("wolfssl new error\r\n");
+ LogError("wolfssl new error");
result = __LINE__;
}
else
@@ -132,7 +132,7 @@
result = wolfSSL_connect(ssl);
if (result != SSL_SUCCESS)
{
- LogError("wolfssl connect error=%d\r\n", result);
+ LogError("wolfssl connect error=%d", result);
result = __LINE__;
}
else
@@ -220,7 +220,7 @@
if (sslContext == NULL)
{
- LogError("NULL SSL context\r\n");
+ LogError("NULL SSL context");
result = false;
}
else
