Azure IoT common library

Dependents:   STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more

Committer:
AzureIoTClient
Date:
Sat Jan 28 09:35:22 2017 -0800
Revision:
19:2e0811512ceb
Parent:
7:1af47e3a19b6
Child:
48:81866008bba4
1.1.6

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AzureIoTClient 7:1af47e3a19b6 1 // Copyright (c) Microsoft. All rights reserved.
AzureIoTClient 7:1af47e3a19b6 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
AzureIoTClient 7:1af47e3a19b6 3
AzureIoTClient 19:2e0811512ceb 4 #include <stdlib.h>
AzureIoTClient 7:1af47e3a19b6 5 #include "azure_c_shared_utility/optionhandler.h"
AzureIoTClient 7:1af47e3a19b6 6 #include "azure_c_shared_utility/xlogging.h"
AzureIoTClient 7:1af47e3a19b6 7 #include "azure_c_shared_utility/gballoc.h"
AzureIoTClient 7:1af47e3a19b6 8 #include "azure_c_shared_utility/vector.h"
AzureIoTClient 7:1af47e3a19b6 9
AzureIoTClient 7:1af47e3a19b6 10 typedef struct OPTION_TAG
AzureIoTClient 7:1af47e3a19b6 11 {
AzureIoTClient 7:1af47e3a19b6 12 const char* name;
AzureIoTClient 7:1af47e3a19b6 13 void* storage;
AzureIoTClient 7:1af47e3a19b6 14 }OPTION;
AzureIoTClient 7:1af47e3a19b6 15
AzureIoTClient 7:1af47e3a19b6 16 typedef struct OPTIONHANDLER_HANDLE_DATA_TAG
AzureIoTClient 7:1af47e3a19b6 17 {
AzureIoTClient 7:1af47e3a19b6 18 pfCloneOption cloneOption;
AzureIoTClient 7:1af47e3a19b6 19 pfDestroyOption destroyOption;
AzureIoTClient 7:1af47e3a19b6 20 pfSetOption setOption;
AzureIoTClient 7:1af47e3a19b6 21 VECTOR_HANDLE storage;
AzureIoTClient 7:1af47e3a19b6 22 }OPTIONHANDLER_HANDLE_DATA;
AzureIoTClient 7:1af47e3a19b6 23
AzureIoTClient 19:2e0811512ceb 24 static OPTIONHANDLER_HANDLE CreateInternal(pfCloneOption cloneOption, pfDestroyOption destroyOption, pfSetOption setOption)
AzureIoTClient 19:2e0811512ceb 25 {
AzureIoTClient 19:2e0811512ceb 26 OPTIONHANDLER_HANDLE result;
AzureIoTClient 19:2e0811512ceb 27
AzureIoTClient 19:2e0811512ceb 28 result = (OPTIONHANDLER_HANDLE_DATA*)malloc(sizeof(OPTIONHANDLER_HANDLE_DATA));
AzureIoTClient 19:2e0811512ceb 29 if (result == NULL)
AzureIoTClient 19:2e0811512ceb 30 {
AzureIoTClient 19:2e0811512ceb 31 /*Codes_SRS_OPTIONHANDLER_02_004: [ Otherwise, OptionHandler_Create shall fail and return NULL. ]*/
AzureIoTClient 19:2e0811512ceb 32 LogError("unable to malloc");
AzureIoTClient 19:2e0811512ceb 33 /*return as is*/
AzureIoTClient 19:2e0811512ceb 34 }
AzureIoTClient 19:2e0811512ceb 35 else
AzureIoTClient 19:2e0811512ceb 36 {
AzureIoTClient 19:2e0811512ceb 37 /*Codes_SRS_OPTIONHANDLER_02_002: [ OptionHandler_Create shall create an empty VECTOR that will hold pairs of const char* and void*. ]*/
AzureIoTClient 19:2e0811512ceb 38 result->storage = VECTOR_create(sizeof(OPTION));
AzureIoTClient 19:2e0811512ceb 39 if (result->storage == NULL)
AzureIoTClient 19:2e0811512ceb 40 {
AzureIoTClient 19:2e0811512ceb 41 /*Codes_SRS_OPTIONHANDLER_02_004: [ Otherwise, OptionHandler_Create shall fail and return NULL. ]*/
AzureIoTClient 19:2e0811512ceb 42 LogError("unable to VECTOR_create");
AzureIoTClient 19:2e0811512ceb 43 free(result);
AzureIoTClient 19:2e0811512ceb 44 result = NULL;
AzureIoTClient 19:2e0811512ceb 45 }
AzureIoTClient 19:2e0811512ceb 46 else
AzureIoTClient 19:2e0811512ceb 47 {
AzureIoTClient 19:2e0811512ceb 48 /*Codes_SRS_OPTIONHANDLER_02_003: [ If all the operations succeed then OptionHandler_Create shall succeed and return a non-NULL handle. ]*/
AzureIoTClient 19:2e0811512ceb 49 result->cloneOption = cloneOption;
AzureIoTClient 19:2e0811512ceb 50 result->destroyOption = destroyOption;
AzureIoTClient 19:2e0811512ceb 51 result->setOption = setOption;
AzureIoTClient 19:2e0811512ceb 52 /*return as is*/
AzureIoTClient 19:2e0811512ceb 53 }
AzureIoTClient 19:2e0811512ceb 54 }
AzureIoTClient 19:2e0811512ceb 55
AzureIoTClient 19:2e0811512ceb 56 return result;
AzureIoTClient 19:2e0811512ceb 57 }
AzureIoTClient 19:2e0811512ceb 58
AzureIoTClient 19:2e0811512ceb 59 static OPTIONHANDLER_RESULT AddOptionInternal(OPTIONHANDLER_HANDLE handle, const char* name, const void* value)
AzureIoTClient 19:2e0811512ceb 60 {
AzureIoTClient 19:2e0811512ceb 61 OPTIONHANDLER_RESULT result;
AzureIoTClient 19:2e0811512ceb 62 const char* cloneOfName;
AzureIoTClient 19:2e0811512ceb 63 if (mallocAndStrcpy_s((char**)&cloneOfName, name) != 0)
AzureIoTClient 19:2e0811512ceb 64 {
AzureIoTClient 19:2e0811512ceb 65 /*Codes_SRS_OPTIONHANDLER_02_009: [ Otherwise, OptionHandler_AddProperty shall succeed and return OPTIONHANDLER_ERROR. ]*/
AzureIoTClient 19:2e0811512ceb 66 LogError("unable to clone name");
AzureIoTClient 19:2e0811512ceb 67 result = OPTIONHANDLER_ERROR;
AzureIoTClient 19:2e0811512ceb 68 }
AzureIoTClient 19:2e0811512ceb 69 else
AzureIoTClient 19:2e0811512ceb 70 {
AzureIoTClient 19:2e0811512ceb 71 /*Codes_SRS_OPTIONHANDLER_02_006: [ OptionHandler_AddProperty shall call pfCloneOption passing name and value. ]*/
AzureIoTClient 19:2e0811512ceb 72 void* cloneOfValue = handle->cloneOption(name, value);
AzureIoTClient 19:2e0811512ceb 73 if (cloneOfValue == NULL)
AzureIoTClient 19:2e0811512ceb 74 {
AzureIoTClient 19:2e0811512ceb 75 /*Codes_SRS_OPTIONHANDLER_02_009: [ Otherwise, OptionHandler_AddProperty shall succeed and return OPTIONHANDLER_ERROR. ]*/
AzureIoTClient 19:2e0811512ceb 76 LogError("unable to clone value");
AzureIoTClient 19:2e0811512ceb 77 free((void*)cloneOfName);
AzureIoTClient 19:2e0811512ceb 78 result = OPTIONHANDLER_ERROR;
AzureIoTClient 19:2e0811512ceb 79 }
AzureIoTClient 19:2e0811512ceb 80 else
AzureIoTClient 19:2e0811512ceb 81 {
AzureIoTClient 19:2e0811512ceb 82 OPTION temp;
AzureIoTClient 19:2e0811512ceb 83 temp.name = cloneOfName;
AzureIoTClient 19:2e0811512ceb 84 temp.storage = cloneOfValue;
AzureIoTClient 19:2e0811512ceb 85 /*Codes_SRS_OPTIONHANDLER_02_007: [ OptionHandler_AddProperty shall use VECTOR APIs to save the name and the newly created clone of value. ]*/
AzureIoTClient 19:2e0811512ceb 86 if (VECTOR_push_back(handle->storage, &temp, 1) != 0)
AzureIoTClient 19:2e0811512ceb 87 {
AzureIoTClient 19:2e0811512ceb 88 /*Codes_SRS_OPTIONHANDLER_02_009: [ Otherwise, OptionHandler_AddProperty shall succeed and return OPTIONHANDLER_ERROR. ]*/
AzureIoTClient 19:2e0811512ceb 89 LogError("unable to VECTOR_push_back");
AzureIoTClient 19:2e0811512ceb 90 handle->destroyOption(name, cloneOfValue);
AzureIoTClient 19:2e0811512ceb 91 free((void*)cloneOfName);
AzureIoTClient 19:2e0811512ceb 92 result = OPTIONHANDLER_ERROR;
AzureIoTClient 19:2e0811512ceb 93 }
AzureIoTClient 19:2e0811512ceb 94 else
AzureIoTClient 19:2e0811512ceb 95 {
AzureIoTClient 19:2e0811512ceb 96 /*Codes_SRS_OPTIONHANDLER_02_008: [ If all the operations succed then OptionHandler_AddProperty shall succeed and return OPTIONHANDLER_OK. ]*/
AzureIoTClient 19:2e0811512ceb 97 result = OPTIONHANDLER_OK;
AzureIoTClient 19:2e0811512ceb 98 }
AzureIoTClient 19:2e0811512ceb 99 }
AzureIoTClient 19:2e0811512ceb 100 }
AzureIoTClient 19:2e0811512ceb 101
AzureIoTClient 19:2e0811512ceb 102 return result;
AzureIoTClient 19:2e0811512ceb 103 }
AzureIoTClient 19:2e0811512ceb 104
AzureIoTClient 19:2e0811512ceb 105 static void DestroyInternal(OPTIONHANDLER_HANDLE handle)
AzureIoTClient 19:2e0811512ceb 106 {
AzureIoTClient 19:2e0811512ceb 107 /*Codes_SRS_OPTIONHANDLER_02_016: [ Otherwise, OptionHandler_Destroy shall free all used resources. ]*/
AzureIoTClient 19:2e0811512ceb 108 size_t nOptions = VECTOR_size(handle->storage), i;
AzureIoTClient 19:2e0811512ceb 109 for (i = 0; i < nOptions; i++)
AzureIoTClient 19:2e0811512ceb 110 {
AzureIoTClient 19:2e0811512ceb 111 OPTION* option = (OPTION*)VECTOR_element(handle->storage, i);
AzureIoTClient 19:2e0811512ceb 112 handle->destroyOption(option->name, option->storage);
AzureIoTClient 19:2e0811512ceb 113 free((void*)option->name);
AzureIoTClient 19:2e0811512ceb 114 }
AzureIoTClient 19:2e0811512ceb 115
AzureIoTClient 19:2e0811512ceb 116 VECTOR_destroy(handle->storage);
AzureIoTClient 19:2e0811512ceb 117 free(handle);
AzureIoTClient 19:2e0811512ceb 118 }
AzureIoTClient 19:2e0811512ceb 119
AzureIoTClient 7:1af47e3a19b6 120 OPTIONHANDLER_HANDLE OptionHandler_Create(pfCloneOption cloneOption, pfDestroyOption destroyOption, pfSetOption setOption)
AzureIoTClient 7:1af47e3a19b6 121 {
AzureIoTClient 7:1af47e3a19b6 122 /*Codes_SRS_OPTIONHANDLER_02_001: [ OptionHandler_Create shall fail and retun NULL if any parameters are NULL. ]*/
AzureIoTClient 7:1af47e3a19b6 123 OPTIONHANDLER_HANDLE_DATA* result;
AzureIoTClient 7:1af47e3a19b6 124 if (
AzureIoTClient 7:1af47e3a19b6 125 (cloneOption == NULL) ||
AzureIoTClient 7:1af47e3a19b6 126 (destroyOption == NULL) ||
AzureIoTClient 7:1af47e3a19b6 127 (setOption == NULL)
AzureIoTClient 7:1af47e3a19b6 128 )
AzureIoTClient 7:1af47e3a19b6 129 {
AzureIoTClient 7:1af47e3a19b6 130 LogError("invalid parameter = pfCloneOption cloneOption=%p, pfDestroyOption destroyOption=%p, pfSetOption setOption=%p", cloneOption, destroyOption, setOption);
AzureIoTClient 7:1af47e3a19b6 131 result = NULL;
AzureIoTClient 7:1af47e3a19b6 132 }
AzureIoTClient 7:1af47e3a19b6 133 else
AzureIoTClient 7:1af47e3a19b6 134 {
AzureIoTClient 19:2e0811512ceb 135 result = CreateInternal(cloneOption, destroyOption, setOption);
AzureIoTClient 19:2e0811512ceb 136 }
AzureIoTClient 19:2e0811512ceb 137
AzureIoTClient 19:2e0811512ceb 138 return result;
AzureIoTClient 19:2e0811512ceb 139
AzureIoTClient 19:2e0811512ceb 140 }
AzureIoTClient 19:2e0811512ceb 141
AzureIoTClient 19:2e0811512ceb 142 OPTIONHANDLER_HANDLE OptionHandler_Clone(OPTIONHANDLER_HANDLE handler)
AzureIoTClient 19:2e0811512ceb 143 {
AzureIoTClient 19:2e0811512ceb 144 OPTIONHANDLER_HANDLE_DATA* result;
AzureIoTClient 19:2e0811512ceb 145
AzureIoTClient 19:2e0811512ceb 146 if (handler == NULL)
AzureIoTClient 19:2e0811512ceb 147 {
AzureIoTClient 19:2e0811512ceb 148 /* Codes_SRS_OPTIONHANDLER_01_010: [ If `handler` is NULL, OptionHandler_Clone shall fail and return NULL. ]*/
AzureIoTClient 19:2e0811512ceb 149 LogError("NULL argument: handler");
AzureIoTClient 19:2e0811512ceb 150 result = NULL;
AzureIoTClient 19:2e0811512ceb 151 }
AzureIoTClient 19:2e0811512ceb 152 else
AzureIoTClient 19:2e0811512ceb 153 {
AzureIoTClient 19:2e0811512ceb 154 /* Codes_SRS_OPTIONHANDLER_01_001: [ `OptionHandler_Clone` shall clone an existing option handler instance. ]*/
AzureIoTClient 19:2e0811512ceb 155 /* Codes_SRS_OPTIONHANDLER_01_002: [ On success it shall return a non-NULL handle. ]*/
AzureIoTClient 19:2e0811512ceb 156 /* Codes_SRS_OPTIONHANDLER_01_003: [ `OptionHandler_Clone` shall allocate memory for the new option handler instance. ]*/
AzureIoTClient 19:2e0811512ceb 157 result = CreateInternal(handler->cloneOption, handler->destroyOption, handler->setOption);
AzureIoTClient 7:1af47e3a19b6 158 if (result == NULL)
AzureIoTClient 7:1af47e3a19b6 159 {
AzureIoTClient 19:2e0811512ceb 160 /* Codes_SRS_OPTIONHANDLER_01_004: [ If allocating memory fails, `OptionHandler_Clone` shall return NULL. ]*/
AzureIoTClient 19:2e0811512ceb 161 LogError("unable to create option handler");
AzureIoTClient 7:1af47e3a19b6 162 }
AzureIoTClient 7:1af47e3a19b6 163 else
AzureIoTClient 7:1af47e3a19b6 164 {
AzureIoTClient 19:2e0811512ceb 165 /* Codes_SRS_OPTIONHANDLER_01_005: [ `OptionHandler_Clone` shall iterate through all the options stored by the option handler to be cloned by using VECTOR's iteration mechanism. ]*/
AzureIoTClient 19:2e0811512ceb 166 size_t option_count = VECTOR_size(handler->storage);
AzureIoTClient 19:2e0811512ceb 167 size_t i;
AzureIoTClient 19:2e0811512ceb 168
AzureIoTClient 19:2e0811512ceb 169 for (i = 0; i < option_count; i++)
AzureIoTClient 7:1af47e3a19b6 170 {
AzureIoTClient 19:2e0811512ceb 171 OPTION* option = (OPTION*)VECTOR_element(handler->storage, i);
AzureIoTClient 19:2e0811512ceb 172
AzureIoTClient 19:2e0811512ceb 173 /* Codes_SRS_OPTIONHANDLER_01_006: [ For each option the option name shall be cloned by calling `mallocAndStrcpy_s`. ]*/
AzureIoTClient 19:2e0811512ceb 174 /* Codes_SRS_OPTIONHANDLER_01_007: [ For each option the value shall be cloned by using the cloning function associated with the source option handler `handler`. ]*/
AzureIoTClient 19:2e0811512ceb 175 if (AddOptionInternal(result, option->name, option->storage) != OPTIONHANDLER_OK)
AzureIoTClient 19:2e0811512ceb 176 {
AzureIoTClient 19:2e0811512ceb 177 /* Codes_SRS_OPTIONHANDLER_01_008: [ If cloning one of the option names fails, `OptionHandler_Clone` shall return NULL. ]*/
AzureIoTClient 19:2e0811512ceb 178 /* Codes_SRS_OPTIONHANDLER_01_009: [ If cloning one of the option values fails, `OptionHandler_Clone` shall return NULL. ]*/
AzureIoTClient 19:2e0811512ceb 179 LogError("Error cloning option %s", option->name);
AzureIoTClient 19:2e0811512ceb 180 break;
AzureIoTClient 19:2e0811512ceb 181 }
AzureIoTClient 7:1af47e3a19b6 182 }
AzureIoTClient 19:2e0811512ceb 183
AzureIoTClient 19:2e0811512ceb 184 if (i < option_count)
AzureIoTClient 7:1af47e3a19b6 185 {
AzureIoTClient 19:2e0811512ceb 186 DestroyInternal(result);
AzureIoTClient 19:2e0811512ceb 187 result = NULL;
AzureIoTClient 7:1af47e3a19b6 188 }
AzureIoTClient 7:1af47e3a19b6 189 }
AzureIoTClient 7:1af47e3a19b6 190 }
AzureIoTClient 19:2e0811512ceb 191
AzureIoTClient 7:1af47e3a19b6 192 return result;
AzureIoTClient 7:1af47e3a19b6 193 }
AzureIoTClient 7:1af47e3a19b6 194
AzureIoTClient 7:1af47e3a19b6 195 OPTIONHANDLER_RESULT OptionHandler_AddOption(OPTIONHANDLER_HANDLE handle, const char* name, const void* value)
AzureIoTClient 7:1af47e3a19b6 196 {
AzureIoTClient 7:1af47e3a19b6 197 OPTIONHANDLER_RESULT result;
AzureIoTClient 7:1af47e3a19b6 198 /*Codes_SRS_OPTIONHANDLER_02_001: [ OptionHandler_Create shall fail and retun NULL if any parameters are NULL. ]*/
AzureIoTClient 7:1af47e3a19b6 199 if (
AzureIoTClient 7:1af47e3a19b6 200 (handle == NULL) ||
AzureIoTClient 7:1af47e3a19b6 201 (name == NULL) ||
AzureIoTClient 7:1af47e3a19b6 202 (value == NULL)
AzureIoTClient 7:1af47e3a19b6 203 )
AzureIoTClient 7:1af47e3a19b6 204 {
AzureIoTClient 7:1af47e3a19b6 205 LogError("invalid arguments: OPTIONHANDLER_HANDLE handle=%p, const char* name=%p, void* value=%p", handle, name, value);
AzureIoTClient 7:1af47e3a19b6 206 result= OPTIONHANDLER_INVALIDARG;
AzureIoTClient 7:1af47e3a19b6 207 }
AzureIoTClient 7:1af47e3a19b6 208 else
AzureIoTClient 7:1af47e3a19b6 209 {
AzureIoTClient 19:2e0811512ceb 210 result = AddOptionInternal(handle, name, value);
AzureIoTClient 7:1af47e3a19b6 211 }
AzureIoTClient 19:2e0811512ceb 212
AzureIoTClient 7:1af47e3a19b6 213 return result;
AzureIoTClient 7:1af47e3a19b6 214 }
AzureIoTClient 7:1af47e3a19b6 215
AzureIoTClient 7:1af47e3a19b6 216 OPTIONHANDLER_RESULT OptionHandler_FeedOptions(OPTIONHANDLER_HANDLE handle, void* destinationHandle)
AzureIoTClient 7:1af47e3a19b6 217 {
AzureIoTClient 7:1af47e3a19b6 218 OPTIONHANDLER_RESULT result;
AzureIoTClient 7:1af47e3a19b6 219 /*Codes_SRS_OPTIONHANDLER_02_010: [ OptionHandler_FeedOptions shall fail and return OPTIONHANDLER_INVALIDARG if any argument is NULL. ]*/
AzureIoTClient 7:1af47e3a19b6 220 if (
AzureIoTClient 7:1af47e3a19b6 221 (handle == NULL) ||
AzureIoTClient 7:1af47e3a19b6 222 (destinationHandle == NULL)
AzureIoTClient 7:1af47e3a19b6 223 )
AzureIoTClient 7:1af47e3a19b6 224 {
AzureIoTClient 7:1af47e3a19b6 225 LogError("invalid arguments OPTIONHANDLER_HANDLE handle=%p, void* destinationHandle=%p", handle, destinationHandle);
AzureIoTClient 7:1af47e3a19b6 226 result = OPTIONHANDLER_INVALIDARG;
AzureIoTClient 7:1af47e3a19b6 227 }
AzureIoTClient 7:1af47e3a19b6 228 else
AzureIoTClient 7:1af47e3a19b6 229 {
AzureIoTClient 7:1af47e3a19b6 230 /*Codes_SRS_OPTIONHANDLER_02_011: [ Otherwise, OptionHandler_FeedOptions shall use VECTOR's iteration mechanisms to retrieve pairs of name, value (const char* and void*). ]*/
AzureIoTClient 7:1af47e3a19b6 231 size_t nOptions = VECTOR_size(handle->storage), i;
AzureIoTClient 7:1af47e3a19b6 232 for (i = 0;i < nOptions;i++)
AzureIoTClient 7:1af47e3a19b6 233 {
AzureIoTClient 7:1af47e3a19b6 234 OPTION* option = (OPTION*)VECTOR_element(handle->storage, i);
AzureIoTClient 7:1af47e3a19b6 235 /*Codes_SRS_OPTIONHANDLER_02_012: [ OptionHandler_FeedOptions shall call for every pair of name,value setOption passing destinationHandle, name and value. ]*/
AzureIoTClient 7:1af47e3a19b6 236 if (handle->setOption(destinationHandle, option->name, option->storage) != 0)
AzureIoTClient 7:1af47e3a19b6 237 {
AzureIoTClient 7:1af47e3a19b6 238 LogError("failure while trying to _SetOption");
AzureIoTClient 7:1af47e3a19b6 239 break;
AzureIoTClient 7:1af47e3a19b6 240 }
AzureIoTClient 7:1af47e3a19b6 241 }
AzureIoTClient 7:1af47e3a19b6 242
AzureIoTClient 7:1af47e3a19b6 243 if (i == nOptions)
AzureIoTClient 7:1af47e3a19b6 244 {
AzureIoTClient 7:1af47e3a19b6 245 /*Codes_SRS_OPTIONHANDLER_02_014: [ Otherwise, OptionHandler_FeedOptions shall fail and return OPTIONHANDLER_ERROR. ]*/
AzureIoTClient 7:1af47e3a19b6 246 result = OPTIONHANDLER_OK;
AzureIoTClient 7:1af47e3a19b6 247 }
AzureIoTClient 7:1af47e3a19b6 248 else
AzureIoTClient 7:1af47e3a19b6 249 {
AzureIoTClient 7:1af47e3a19b6 250 /*Codes_SRS_OPTIONHANDLER_02_013: [ If all the operations succeed then OptionHandler_FeedOptions shall succeed and return OPTIONHANDLER_OK. ]*/
AzureIoTClient 7:1af47e3a19b6 251 result = OPTIONHANDLER_ERROR;
AzureIoTClient 7:1af47e3a19b6 252 }
AzureIoTClient 7:1af47e3a19b6 253 }
AzureIoTClient 7:1af47e3a19b6 254 return result;
AzureIoTClient 7:1af47e3a19b6 255 }
AzureIoTClient 7:1af47e3a19b6 256
AzureIoTClient 7:1af47e3a19b6 257 void OptionHandler_Destroy(OPTIONHANDLER_HANDLE handle)
AzureIoTClient 7:1af47e3a19b6 258 {
AzureIoTClient 7:1af47e3a19b6 259 /*Codes_SRS_OPTIONHANDLER_02_015: [ OptionHandler_Destroy shall do nothing if parameter handle is NULL. ]*/
AzureIoTClient 7:1af47e3a19b6 260 if (handle == NULL)
AzureIoTClient 7:1af47e3a19b6 261 {
AzureIoTClient 7:1af47e3a19b6 262 LogError("invalid argument OPTIONHANDLER_HANDLE handle=%p", handle);
AzureIoTClient 7:1af47e3a19b6 263 }
AzureIoTClient 7:1af47e3a19b6 264 else
AzureIoTClient 7:1af47e3a19b6 265 {
AzureIoTClient 19:2e0811512ceb 266 DestroyInternal(handle);
AzureIoTClient 7:1af47e3a19b6 267 }
AzureIoTClient 7:1af47e3a19b6 268 }