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: multitree.c
- Revision:
- 11:b1327861f5e0
- Parent:
- 10:c2aee3965a83
- Child:
- 13:16e88f0cfa5f
diff -r c2aee3965a83 -r b1327861f5e0 multitree.c --- a/multitree.c Fri Apr 08 13:25:09 2016 -0700 +++ b/multitree.c Sun Apr 24 16:40:59 2016 -0700 @@ -36,7 +36,7 @@ if ((cloneFunction == NULL) || (freeFunction == NULL)) { - LogError("CloneFunction or FreeFunction is Null.\r\n"); + LogError("CloneFunction or FreeFunction is Null."); result = NULL; } else @@ -57,7 +57,7 @@ } else { - LogError("MultiTree_Create failed because malloc failed\r\n"); + LogError("MultiTree_Create failed because malloc failed"); } } @@ -115,12 +115,12 @@ { /*Codes_SRS_MULTITREE_99_024:[ if a child name is empty (such as in "/child1//child12"), MULTITREE_EMPTY_CHILD_NAME shall be returned.]*/ result = CREATELEAF_EMPTY_NAME; - LogError("(result = %s)\r\n", CreateLeaf_ResultAsString[result]); + LogError("(result = %s)", CreateLeaf_ResultAsString[result]); } else if (getChildByName(node, name) != NULL) { result = CREATELEAF_ALREADY_EXISTS; - LogError("(result = %s)\r\n", CreateLeaf_ResultAsString[result]); + LogError("(result = %s)", CreateLeaf_ResultAsString[result]); } else { @@ -128,7 +128,7 @@ if (newNode == NULL) { result = CREATELEAF_ERROR; - LogError("(result = %s)\r\n", CreateLeaf_ResultAsString[result]); + LogError("(result = %s)", CreateLeaf_ResultAsString[result]); } else { @@ -140,7 +140,7 @@ free(newNode); newNode = NULL; result = CREATELEAF_ERROR; - LogError("(result = %s)\r\n", CreateLeaf_ResultAsString[result]); + LogError("(result = %s)", CreateLeaf_ResultAsString[result]); } else { @@ -158,7 +158,7 @@ free(newNode); newNode = NULL; result = CREATELEAF_ERROR; - LogError("(result = %s)\r\n", CreateLeaf_ResultAsString[result]); + LogError("(result = %s)", CreateLeaf_ResultAsString[result]); } else { @@ -180,7 +180,7 @@ free(newNode); newNode = NULL; result = CREATELEAF_ERROR; - LogError("(result = %s)\r\n", CreateLeaf_ResultAsString[result]); + LogError("(result = %s)", CreateLeaf_ResultAsString[result]); } else { @@ -210,25 +210,25 @@ if (treeHandle == NULL) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } /*Codes_SRS_MULTITREE_99_019:[ If parameter destinationPath is NULL, MULTITREE_INVALID_ARG shall be returned.]*/ else if (destinationPath == NULL) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } /*Codes_SRS_MULTITREE_99_020:[ If parameter value is NULL, MULTITREE_INVALID_ARG shall be returned.]*/ else if (value == NULL) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } /*Codes_SRS_MULTITREE_99_050:[ If destinationPath a string with zero characters, MULTITREE_INVALID_ARG shall be returned.]*/ else if (strlen(destinationPath) == 0) { result = MULTITREE_EMPTY_CHILD_NAME; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -254,14 +254,14 @@ { /*Codes_SRS_MULTITREE_99_025:[The function shall return MULTITREE_ERROR to indicate any other error not specified here.]*/ result = MULTITREE_ERROR; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); break; } case CREATELEAF_ALREADY_EXISTS: { /*Codes_SRS_MULTITREE_99_021:[ If the node already has a value assigned to it, MULTITREE_ALREADY_HAS_A_VALUE shall be returned and the existing value shall not be changed.]*/ result = MULTITREE_ALREADY_HAS_A_VALUE; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); break; } case CREATELEAF_OK: @@ -274,7 +274,7 @@ { /*Codes_SRS_MULTITREE_99_024:[ if a child name is empty (such as in "/child1//child12"), MULTITREE_EMPTY_CHILD_NAME shall be returned.]*/ result = MULTITREE_EMPTY_CHILD_NAME; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); break; } } @@ -288,7 +288,7 @@ { /*Codes_SRS_MULTITREE_99_025:[ The function shall return MULTITREE_ERROR to indicate any other error not specified here.]*/ result = MULTITREE_ERROR; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -303,14 +303,14 @@ default: { result = MULTITREE_ERROR; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); break; } case(CREATELEAF_EMPTY_NAME): { /*Codes_SRS_MULTITREE_99_024:[ if a child name is empty (such as in "/child1//child12"), MULTITREE_EMPTY_CHILD_NAME shall be returned.]*/ result = MULTITREE_EMPTY_CHILD_NAME; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); break; } case(CREATELEAF_OK): @@ -341,7 +341,7 @@ (childHandle == NULL)) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -354,14 +354,14 @@ default: { result = MULTITREE_ERROR; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); break; } case CREATELEAF_ALREADY_EXISTS: { /* Codes_SRS_MULTITREE_99_061:[ If a child node with the same name already exists, MultiTree_AddChild shall return MULTITREE_ALREADY_HAS_A_VALUE.] */ result = MULTITREE_ALREADY_HAS_A_VALUE; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); break; } case CREATELEAF_OK: @@ -377,7 +377,7 @@ { /* Tests_SRS_MULTITREE_99_066:[ If the childName argument is an empty string, MultiTree_AddChild shall return MULTITREE_EMPTY_CHILD_NAME.] */ result = MULTITREE_EMPTY_CHILD_NAME; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); break; } } @@ -393,13 +393,13 @@ if (treeHandle == NULL) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } /*Codes_SRS_MULTITREE_99_028:[ If parameter count is NULL, the function returns MULTITREE_INVALID_ARG.]*/ else if (count == NULL) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -418,13 +418,13 @@ if (treeHandle == NULL) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } /*Codes_SRS_MULTITREE_99_033:[ If parameter childHandle is NULL, the function shall return MULTITREE_INVALID_ARG.]*/ else if (childHandle == NULL) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -433,7 +433,7 @@ if (node->nChildren <= index) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -453,13 +453,13 @@ if (treeHandle == NULL) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } /*Codes_SRS_MULTITREE_99_038:[If destination is NULL, the function shall return MULTITREE_INVALID_ARG.]*/ else if (destination == NULL) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -468,14 +468,14 @@ if (node->name == NULL) { result = MULTITREE_EMPTY_CHILD_NAME; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } /*Codes_SRS_MULTITREE_99_036:[ This function fills the buffer pointed to by parameter destination with the name of the root node of the tree designated by parameter treeHandle.]*/ else if (STRING_concat(destination, node->name)!=0) { /*Codes_SRS_MULTITREE_99_040:[ The function returns MULTITREE_ERROR to indicate any other error.]*/ result = MULTITREE_ERROR; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -498,7 +498,7 @@ (childName == NULL)) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -517,7 +517,7 @@ { /* Codes_SRS_MULTITREE_99_068:[ If the specified child is not found, MultiTree_GetChildByName shall return MULTITREE_CHILD_NOT_FOUND.] */ result = MULTITREE_CHILD_NOT_FOUND; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -538,13 +538,13 @@ if (treeHandle == NULL) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } /*Codes_SRS_MULTITREE_99_043:[ If destination is NULL, the function shall return MULTITREE_INVALID_ARG.]*/ else if (destination == NULL) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -553,7 +553,7 @@ if (node->value == NULL) { result = MULTITREE_EMPTY_VALUE; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -574,7 +574,7 @@ (value == NULL)) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -583,7 +583,7 @@ { /* Codes_SRS_MULTITREE_99_076:[ If the node already has a value then MultiTree_SetValue shall return MULTITREE_ALREADY_HAS_A_VALUE.] */ result = MULTITREE_ALREADY_HAS_A_VALUE; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -592,7 +592,7 @@ { /* Codes_SRS_MULTITREE_99_075:[ MultiTree_SetValue shall return MULTITREE_ERROR to indicate any other error.] */ result = MULTITREE_ERROR; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -651,13 +651,13 @@ (destination == NULL)) { result = MULTITREE_INVALID_ARG; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } /* Codes_SRS_MULTITREE_99_058:[ The last child designates the child that will receive the value. If a child name is empty (such as in "/child1//child12"), MULTITREE_EMPTY_CHILD_NAME shall be returned.] */ else if (strlen(leafPath) == 0) { result = MULTITREE_EMPTY_CHILD_NAME; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -677,7 +677,7 @@ { /* Codes_SRS_MULTITREE_99_069:[ If a child name is empty (such as in "/child1//child12"), MULTITREE_EMPTY_CHILD_NAME shall be returned.] */ result = MULTITREE_EMPTY_CHILD_NAME; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } else { @@ -701,14 +701,14 @@ { /* Codes_SRS_MULTITREE_99_069:[ If a child name is empty (such as in "/child1//child12"), MULTITREE_EMPTY_CHILD_NAME shall be returned.] */ result = MULTITREE_EMPTY_CHILD_NAME; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); break; } else if (childCount == 0) { /* Codes_SRS_MULTITREE_99_071:[ When the child node is not found, MultiTree_GetLeafValue shall return MULTITREE_CHILD_NOT_FOUND.] */ result = MULTITREE_CHILD_NOT_FOUND; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); break; } else @@ -727,7 +727,7 @@ { /* Codes_SRS_MULTITREE_99_071:[ When the child node is not found, MultiTree_GetLeafValue shall return MULTITREE_CHILD_NOT_FOUND.] */ result = MULTITREE_CHILD_NOT_FOUND; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); break; } else @@ -752,7 +752,7 @@ { /* Codes_SRS_MULTITREE_99_070:[ If an attempt is made to get the value for a node that does not have a value set, then MultiTree_GetLeafValue shall return MULTITREE_EMPTY_VALUE.] */ result = MULTITREE_EMPTY_VALUE; - LogError("(result = %s)\r\n", ENUM_TO_STRING(MULTITREE_RESULT, result)); + LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result)); } /*Codes_SRS_MULTITREE_99_053:[ MultiTree_GetLeafValue shall copy into the *destination argument the value of the node identified by the leafPath argument.]*/ else