A modelling and serializer library for Microsoft Azure IoTHub client applications
Dependents: sht15_remote_monitoring f767zi_mqtt remote_monitoring simplesample_amqp ... more
This library implements a serializer library to be used in projects involving Microsoft Azure IoT Hub connectivity. The code is replicated from https://github.com/Azure/azure-iot-sdks
Diff: agenttypesystem.c
- Revision:
- 36:7d12a5386197
- Parent:
- 35:ede97b73d1bb
--- a/agenttypesystem.c Thu Jul 12 18:10:30 2018 -0700 +++ b/agenttypesystem.c Tue Sep 11 11:14:37 2018 -0700 @@ -35,7 +35,7 @@ #define PLUSINF_STRING "INF" #ifndef _HUGE_ENUF -#define _HUGE_ENUF 1e+300 /* _HUGE_ENUF*_HUGE_ENUF must overflow */ +#define _HUGE_ENUF 1e+300 /* _HUGE_ENUF*_HUGE_ENUF must overflow */ #endif /* _HUGE_ENUF */ #ifndef INFINITY @@ -182,7 +182,7 @@ else if (ValidateDate(v.dateTime.tm_year+1900, v.dateTime.tm_mon +1 , v.dateTime.tm_mday) != 0) { /*Codes_SRS_AGENT_TYPE_SYSTEM_99_092:[ The structure shall be validated to be conforming to OData specifications (odata-abnf-construction-rules, 2013), and if found invalid, AGENT_DATA_TYPES_INVALID_ARG shall be returned.]*/ - result = AGENT_DATA_TYPES_INVALID_ARG; + result = AGENT_DATA_TYPES_INVALID_ARG; } else if ( (v.dateTime.tm_hour > 23) || @@ -202,7 +202,7 @@ result = AGENT_DATA_TYPES_INVALID_ARG; } else if ( - (v.hasTimeZone) && + (v.hasTimeZone) && ( (v.timeZoneHour<-23) || (v.timeZoneHour>23) || @@ -1286,7 +1286,7 @@ AGENT_DATA_TYPES_RESULT AgentDataTypes_ToString(STRING_HANDLE destination, const AGENT_DATA_TYPE* value) { AGENT_DATA_TYPES_RESULT result; - + /*Codes_SRS_AGENT_TYPE_SYSTEM_99_015:[If destination parameter is NULL, AgentDataTypes_ToString shall return AGENT_DATA_TYPES_INVALID_ARG.]*/ if(destination == NULL) { @@ -1698,7 +1698,7 @@ } buffertemp2[pos++] = '0' + (char)(positiveValue); buffertemp2[pos++] = '\0'; - + if (STRING_concat(destination, buffertemp2) != 0) { result = AGENT_DATA_TYPES_ERROR; @@ -1741,7 +1741,7 @@ } buffertemp2[pos++] = '0' + (char)(positiveValue); buffertemp2[pos++] = '\0'; - + if (STRING_concat(destination, buffertemp2) != 0) { result = AGENT_DATA_TYPES_ERROR; @@ -2148,7 +2148,7 @@ { /*all is fine*/ } - + } MultiTree_Destroy(treeHandle); @@ -2286,7 +2286,7 @@ temp[destinationPointer++] = '='; temp[destinationPointer++] = '='; } - + /*closing quote*/ temp[destinationPointer++] = '"'; /*null terminating the string*/ @@ -2464,7 +2464,7 @@ break; } case(EDM_DOUBLE_TYPE) : - { + { dest->type = src->type; dest->value.edmDouble = src->value.edmDouble; result = AGENT_DATA_TYPES_OK; @@ -2929,7 +2929,7 @@ } } } - + } } @@ -3006,7 +3006,7 @@ } return result; - + } /*the following function does the same as sscanf(pos2, "%d", &sec)*/ @@ -3407,7 +3407,7 @@ else { size_t pos = 1; - int sign; + int sign; scanOptionalMinusSign(source, 2, &pos, &sign); if ((scanAndReadNDigitsInt(source, &pos, &year, 4) != 0) || @@ -3463,7 +3463,7 @@ size_t pos = 1; int sign; scanOptionalMinusSign(source, 2, &pos, &sign); - + if ((scanAndReadNDigitsInt(source, &pos, &year, 4) != 0) || (source[pos++] != '-') || (scanAndReadNDigitsInt(source, &pos, &month, 2) != 0) || @@ -3730,7 +3730,7 @@ result = AGENT_DATA_TYPES_ERROR; LogError("(result = %s)", ENUM_TO_STRING(AGENT_DATA_TYPES_RESULT, result)); } - else if (strncpy_s(temp, strLength - 1, source + 1, strLength - 2) != 0) + else if (memcpy(temp, source + 1, strLength - 2) == NULL) { free(temp); @@ -3739,8 +3739,8 @@ } else { + // Removes the " temp[strLength - 2] = 0; - agentData->type = EDM_STRING_TYPE; agentData->value.edmString.chars = temp; agentData->value.edmString.length = strLength - 2; @@ -3922,7 +3922,7 @@ { sourcePosition += consumed; destinationPosition += 2; - + } else if (scanbase64b8(source + sourcePosition, sourceLength - sourcePosition, &consumed, agentData->value.edmBinary.data + destinationPosition) == 0) { @@ -3931,7 +3931,7 @@ } if (source[sourcePosition++] != '"') /*if it doesn't end with " then bail out*/ - { + { free(agentData->value.edmBinary.data); agentData->value.edmBinary.data = NULL; result = AGENT_DATA_TYPES_INVALID_ARG;