Azure IoT common library
Dependents: STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more
connection_string_parser.c@21:b92006c5b9ff, 2017-02-24 (annotated)
- Committer:
- AzureIoTClient
- Date:
- Fri Feb 24 14:01:41 2017 -0800
- Revision:
- 21:b92006c5b9ff
- Parent:
- 18:6d8a413a4d9a
- Child:
- 31:6a55d47aea41
1.1.8
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Azure.IoT.Build | 16:18e7ebd42bb2 | 1 | // Copyright (c) Microsoft. All rights reserved. |
Azure.IoT.Build | 16:18e7ebd42bb2 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
Azure.IoT.Build | 16:18e7ebd42bb2 | 3 | |
Azure.IoT.Build | 16:18e7ebd42bb2 | 4 | #include "azure_c_shared_utility/connection_string_parser.h" |
Azure.IoT.Build | 16:18e7ebd42bb2 | 5 | #include "azure_c_shared_utility/map.h" |
Azure.IoT.Build | 16:18e7ebd42bb2 | 6 | #include "azure_c_shared_utility/strings.h" |
Azure.IoT.Build | 16:18e7ebd42bb2 | 7 | #include "azure_c_shared_utility/string_tokenizer.h" |
Azure.IoT.Build | 16:18e7ebd42bb2 | 8 | #include <stdbool.h> |
AzureIoTClient | 21:b92006c5b9ff | 9 | #include "azure_c_shared_utility/optimize_size.h" |
Azure.IoT.Build | 16:18e7ebd42bb2 | 10 | #include "azure_c_shared_utility/xlogging.h" |
Azure.IoT.Build | 16:18e7ebd42bb2 | 11 | |
AzureIoTClient | 18:6d8a413a4d9a | 12 | |
AzureIoTClient | 18:6d8a413a4d9a | 13 | MAP_HANDLE connectionstringparser_parse_from_char(const char* connection_string) |
AzureIoTClient | 18:6d8a413a4d9a | 14 | { |
AzureIoTClient | 18:6d8a413a4d9a | 15 | MAP_HANDLE result; |
AzureIoTClient | 18:6d8a413a4d9a | 16 | STRING_HANDLE connString = NULL; |
AzureIoTClient | 18:6d8a413a4d9a | 17 | |
AzureIoTClient | 18:6d8a413a4d9a | 18 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_020: [connectionstringparser_parse_from_char shall create a STRING_HANDLE from the connection_string passed in as argument and parse it using the connectionstringparser_parse.]*/ |
AzureIoTClient | 18:6d8a413a4d9a | 19 | if ((connString = STRING_construct(connection_string)) == NULL) |
AzureIoTClient | 18:6d8a413a4d9a | 20 | { |
AzureIoTClient | 18:6d8a413a4d9a | 21 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_021: [If connectionstringparser_parse_from_char get error creating a STRING_HANDLE, it shall return NULL.]*/ |
AzureIoTClient | 18:6d8a413a4d9a | 22 | LogError("Error constructing connection String"); |
AzureIoTClient | 18:6d8a413a4d9a | 23 | result = NULL; |
AzureIoTClient | 18:6d8a413a4d9a | 24 | } |
AzureIoTClient | 18:6d8a413a4d9a | 25 | else |
AzureIoTClient | 18:6d8a413a4d9a | 26 | { |
AzureIoTClient | 18:6d8a413a4d9a | 27 | result = connectionstringparser_parse(connString); |
AzureIoTClient | 18:6d8a413a4d9a | 28 | } |
AzureIoTClient | 18:6d8a413a4d9a | 29 | |
AzureIoTClient | 18:6d8a413a4d9a | 30 | return result; |
AzureIoTClient | 18:6d8a413a4d9a | 31 | } |
AzureIoTClient | 18:6d8a413a4d9a | 32 | |
AzureIoTClient | 18:6d8a413a4d9a | 33 | |
Azure.IoT.Build | 16:18e7ebd42bb2 | 34 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_001: [connectionstringparser_parse shall parse all key value pairs from the connection_string passed in as argument and return a new map that holds the key/value pairs.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 35 | MAP_HANDLE connectionstringparser_parse(STRING_HANDLE connection_string) |
Azure.IoT.Build | 16:18e7ebd42bb2 | 36 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 37 | MAP_HANDLE result; |
Azure.IoT.Build | 16:18e7ebd42bb2 | 38 | |
Azure.IoT.Build | 16:18e7ebd42bb2 | 39 | if (connection_string == NULL) |
Azure.IoT.Build | 16:18e7ebd42bb2 | 40 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 41 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_002: [If connection_string is NULL then connectionstringparser_parse shall fail and return NULL.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 42 | result = NULL; |
AzureIoTClient | 18:6d8a413a4d9a | 43 | LogError("NULL connection string passed to tokenizer."); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 44 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 45 | else |
Azure.IoT.Build | 16:18e7ebd42bb2 | 46 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 47 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_003: [connectionstringparser_parse shall create a STRING tokenizer to be used for parsing the connection string, by calling STRING_TOKENIZER_create.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 48 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_004: [connectionstringparser_parse shall start scanning at the beginning of the connection string.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 49 | STRING_TOKENIZER_HANDLE tokenizer = STRING_TOKENIZER_create(connection_string); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 50 | if (tokenizer == NULL) |
Azure.IoT.Build | 16:18e7ebd42bb2 | 51 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 52 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_015: [If STRING_TOKENIZER_create fails, connectionstringparser_parse shall fail and return NULL.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 53 | result = NULL; |
AzureIoTClient | 18:6d8a413a4d9a | 54 | LogError("Error creating STRING tokenizer."); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 55 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 56 | else |
Azure.IoT.Build | 16:18e7ebd42bb2 | 57 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 58 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_016: [2 STRINGs shall be allocated in order to hold the to be parsed key and value tokens.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 59 | STRING_HANDLE token_key_string = STRING_new(); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 60 | if (token_key_string == NULL) |
Azure.IoT.Build | 16:18e7ebd42bb2 | 61 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 62 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_017: [If allocating the STRINGs fails connectionstringparser_parse shall fail and return NULL.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 63 | result = NULL; |
AzureIoTClient | 18:6d8a413a4d9a | 64 | LogError("Error creating key token STRING."); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 65 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 66 | else |
Azure.IoT.Build | 16:18e7ebd42bb2 | 67 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 68 | STRING_HANDLE token_value_string = STRING_new(); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 69 | if (token_value_string == NULL) |
Azure.IoT.Build | 16:18e7ebd42bb2 | 70 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 71 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_017: [If allocating the STRINGs fails connectionstringparser_parse shall fail and return NULL.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 72 | result = NULL; |
AzureIoTClient | 18:6d8a413a4d9a | 73 | LogError("Error creating value token STRING."); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 74 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 75 | else |
Azure.IoT.Build | 16:18e7ebd42bb2 | 76 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 77 | result = Map_Create(NULL); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 78 | if (result == NULL) |
Azure.IoT.Build | 16:18e7ebd42bb2 | 79 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 80 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_018: [If creating the result map fails, then connectionstringparser_parse shall return NULL.] */ |
AzureIoTClient | 18:6d8a413a4d9a | 81 | LogError("Error creating Map."); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 82 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 83 | else |
Azure.IoT.Build | 16:18e7ebd42bb2 | 84 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 85 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_005: [The following actions shall be repeated until parsing is complete:] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 86 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_006: [connectionstringparser_parse shall find a token (the key of the key/value pair) delimited by the `=` character, by calling STRING_TOKENIZER_get_next_token.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 87 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_007: [If STRING_TOKENIZER_get_next_token fails, parsing shall be considered complete.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 88 | while (STRING_TOKENIZER_get_next_token(tokenizer, token_key_string, "=") == 0) |
Azure.IoT.Build | 16:18e7ebd42bb2 | 89 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 90 | bool is_error = false; |
Azure.IoT.Build | 16:18e7ebd42bb2 | 91 | |
Azure.IoT.Build | 16:18e7ebd42bb2 | 92 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_008: [connectionstringparser_parse shall find a token (the value of the key/value pair) delimited by the `;` character, by calling STRING_TOKENIZER_get_next_token.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 93 | if (STRING_TOKENIZER_get_next_token(tokenizer, token_value_string, ";") != 0) |
Azure.IoT.Build | 16:18e7ebd42bb2 | 94 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 95 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_009: [If STRING_TOKENIZER_get_next_token fails, connectionstringparser_parse shall fail and return NULL (freeing the allocated result map).] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 96 | is_error = true; |
AzureIoTClient | 18:6d8a413a4d9a | 97 | LogError("Error reading value token from the connection string."); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 98 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 99 | else |
Azure.IoT.Build | 16:18e7ebd42bb2 | 100 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 101 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_011: [The C strings for the key and value shall be extracted from the previously parsed STRINGs by using STRING_c_str.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 102 | const char* token = STRING_c_str(token_key_string); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 103 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_013: [If STRING_c_str fails then connectionstringparser_parse shall fail and return NULL (freeing the allocated result map).] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 104 | if ((token == NULL) || |
Azure.IoT.Build | 16:18e7ebd42bb2 | 105 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_019: [If the key length is zero then connectionstringparser_parse shall fail and return NULL (freeing the allocated result map).] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 106 | (strlen(token) == 0)) |
Azure.IoT.Build | 16:18e7ebd42bb2 | 107 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 108 | is_error = true; |
AzureIoTClient | 18:6d8a413a4d9a | 109 | LogError("The key token is NULL or empty."); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 110 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 111 | else |
Azure.IoT.Build | 16:18e7ebd42bb2 | 112 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 113 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_011: [The C strings for the key and value shall be extracted from the previously parsed STRINGs by using STRING_c_str.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 114 | const char* value = STRING_c_str(token_value_string); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 115 | if (value == NULL) |
Azure.IoT.Build | 16:18e7ebd42bb2 | 116 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 117 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_013: [If STRING_c_str fails then connectionstringparser_parse shall fail and return NULL (freeing the allocated result map).] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 118 | is_error = true; |
AzureIoTClient | 18:6d8a413a4d9a | 119 | LogError("Could not get C string for value token."); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 120 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 121 | else |
Azure.IoT.Build | 16:18e7ebd42bb2 | 122 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 123 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_010: [The key and value shall be added to the result map by using Map_Add.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 124 | if (Map_Add(result, token, value) != 0) |
Azure.IoT.Build | 16:18e7ebd42bb2 | 125 | { |
Azure.IoT.Build | 16:18e7ebd42bb2 | 126 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_012: [If Map_Add fails connectionstringparser_parse shall fail and return NULL (freeing the allocated result map).] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 127 | is_error = true; |
AzureIoTClient | 18:6d8a413a4d9a | 128 | LogError("Could not add the key/value pair to the result map."); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 129 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 130 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 131 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 132 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 133 | |
Azure.IoT.Build | 16:18e7ebd42bb2 | 134 | if (is_error) |
Azure.IoT.Build | 16:18e7ebd42bb2 | 135 | { |
AzureIoTClient | 18:6d8a413a4d9a | 136 | LogError("Error parsing connection string."); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 137 | Map_Destroy(result); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 138 | result = NULL; |
Azure.IoT.Build | 16:18e7ebd42bb2 | 139 | break; |
Azure.IoT.Build | 16:18e7ebd42bb2 | 140 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 141 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 142 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 143 | |
Azure.IoT.Build | 16:18e7ebd42bb2 | 144 | STRING_delete(token_value_string); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 145 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 146 | |
Azure.IoT.Build | 16:18e7ebd42bb2 | 147 | STRING_delete(token_key_string); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 148 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 149 | |
Azure.IoT.Build | 16:18e7ebd42bb2 | 150 | /* Codes_SRS_CONNECTIONSTRINGPARSER_01_014: [After the parsing is complete the previously allocated STRINGs and STRING tokenizer shall be freed by calling STRING_TOKENIZER_destroy.] */ |
Azure.IoT.Build | 16:18e7ebd42bb2 | 151 | STRING_TOKENIZER_destroy(tokenizer); |
Azure.IoT.Build | 16:18e7ebd42bb2 | 152 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 153 | } |
Azure.IoT.Build | 16:18e7ebd42bb2 | 154 | |
Azure.IoT.Build | 16:18e7ebd42bb2 | 155 | return result; |
Azure.IoT.Build | 16:18e7ebd42bb2 | 156 | } |
AzureIoTClient | 18:6d8a413a4d9a | 157 | |
AzureIoTClient | 18:6d8a413a4d9a | 158 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_022: [connectionstringparser_splitHostName_from_char shall split the provided hostName in name and suffix.]*/ |
AzureIoTClient | 18:6d8a413a4d9a | 159 | int connectionstringparser_splitHostName_from_char(const char* hostName, STRING_HANDLE nameString, STRING_HANDLE suffixString) |
AzureIoTClient | 18:6d8a413a4d9a | 160 | { |
AzureIoTClient | 18:6d8a413a4d9a | 161 | int result; |
AzureIoTClient | 18:6d8a413a4d9a | 162 | const char* runHostName = hostName; |
AzureIoTClient | 18:6d8a413a4d9a | 163 | |
AzureIoTClient | 18:6d8a413a4d9a | 164 | if ((hostName == NULL) || ((*hostName) == '\0') || ((*hostName) == '.') || (nameString == NULL) || (suffixString == NULL)) |
AzureIoTClient | 18:6d8a413a4d9a | 165 | { |
AzureIoTClient | 21:b92006c5b9ff | 166 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_026: [If the hostName is NULL, connectionstringparser_splitHostName_from_char shall return __FAILURE__.]*/ |
AzureIoTClient | 21:b92006c5b9ff | 167 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_027: [If the hostName is an empty string, connectionstringparser_splitHostName_from_char shall return __FAILURE__.]*/ |
AzureIoTClient | 21:b92006c5b9ff | 168 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_028: [If the nameString is NULL, connectionstringparser_splitHostName_from_char shall return __FAILURE__.]*/ |
AzureIoTClient | 21:b92006c5b9ff | 169 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_029: [If the suffixString is NULL, connectionstringparser_splitHostName_from_char shall return __FAILURE__.]*/ |
AzureIoTClient | 21:b92006c5b9ff | 170 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_030: [If the hostName is not a valid host name, connectionstringparser_splitHostName_from_char shall return __FAILURE__.]*/ |
AzureIoTClient | 21:b92006c5b9ff | 171 | result = __FAILURE__; |
AzureIoTClient | 18:6d8a413a4d9a | 172 | } |
AzureIoTClient | 18:6d8a413a4d9a | 173 | else |
AzureIoTClient | 18:6d8a413a4d9a | 174 | { |
AzureIoTClient | 18:6d8a413a4d9a | 175 | while ((*runHostName) != '\0') |
AzureIoTClient | 18:6d8a413a4d9a | 176 | { |
AzureIoTClient | 18:6d8a413a4d9a | 177 | if ((*runHostName) == '.') |
AzureIoTClient | 18:6d8a413a4d9a | 178 | { |
AzureIoTClient | 18:6d8a413a4d9a | 179 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_023: [connectionstringparser_splitHostName_from_char shall copy all characters, from the beginning of the hostName to the first `.` to the nameString.]*/ |
AzureIoTClient | 18:6d8a413a4d9a | 180 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_024: [connectionstringparser_splitHostName_from_char shall copy all characters, from the first `.` to the end of the hostName, to the suffixString.]*/ |
AzureIoTClient | 18:6d8a413a4d9a | 181 | runHostName++; |
AzureIoTClient | 18:6d8a413a4d9a | 182 | break; |
AzureIoTClient | 18:6d8a413a4d9a | 183 | } |
AzureIoTClient | 18:6d8a413a4d9a | 184 | runHostName++; |
AzureIoTClient | 18:6d8a413a4d9a | 185 | } |
AzureIoTClient | 18:6d8a413a4d9a | 186 | |
AzureIoTClient | 18:6d8a413a4d9a | 187 | if ((*runHostName) == '\0') |
AzureIoTClient | 18:6d8a413a4d9a | 188 | { |
AzureIoTClient | 21:b92006c5b9ff | 189 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_030: [If the hostName is not a valid host name, connectionstringparser_splitHostName_from_char shall return __FAILURE__.]*/ |
AzureIoTClient | 21:b92006c5b9ff | 190 | result = __FAILURE__; |
AzureIoTClient | 18:6d8a413a4d9a | 191 | } |
AzureIoTClient | 18:6d8a413a4d9a | 192 | else |
AzureIoTClient | 18:6d8a413a4d9a | 193 | { |
AzureIoTClient | 18:6d8a413a4d9a | 194 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_023: [connectionstringparser_splitHostName_from_char shall copy all characters, from the beginning of the hostName to the first `.` to the nameString.]*/ |
AzureIoTClient | 18:6d8a413a4d9a | 195 | if (STRING_copy_n(nameString, hostName, runHostName - hostName - 1) != 0) |
AzureIoTClient | 18:6d8a413a4d9a | 196 | { |
AzureIoTClient | 21:b92006c5b9ff | 197 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_031: [If connectionstringparser_splitHostName_from_char get error copying the name to the nameString, it shall return __FAILURE__.]*/ |
AzureIoTClient | 21:b92006c5b9ff | 198 | result = __FAILURE__; |
AzureIoTClient | 18:6d8a413a4d9a | 199 | } |
AzureIoTClient | 18:6d8a413a4d9a | 200 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_024: [connectionstringparser_splitHostName_from_char shall copy all characters, from the first `.` to the end of the hostName, to the suffixString.]*/ |
AzureIoTClient | 18:6d8a413a4d9a | 201 | else if (STRING_copy(suffixString, runHostName) != 0) |
AzureIoTClient | 18:6d8a413a4d9a | 202 | { |
AzureIoTClient | 21:b92006c5b9ff | 203 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_032: [If connectionstringparser_splitHostName_from_char get error copying the suffix to the suffixString, it shall return __FAILURE__.]*/ |
AzureIoTClient | 21:b92006c5b9ff | 204 | result = __FAILURE__; |
AzureIoTClient | 18:6d8a413a4d9a | 205 | } |
AzureIoTClient | 18:6d8a413a4d9a | 206 | else |
AzureIoTClient | 18:6d8a413a4d9a | 207 | { |
AzureIoTClient | 18:6d8a413a4d9a | 208 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_025: [If connectionstringparser_splitHostName_from_char get success splitting the hostName, it shall return 0.]*/ |
AzureIoTClient | 18:6d8a413a4d9a | 209 | result = 0; |
AzureIoTClient | 18:6d8a413a4d9a | 210 | } |
AzureIoTClient | 18:6d8a413a4d9a | 211 | } |
AzureIoTClient | 18:6d8a413a4d9a | 212 | } |
AzureIoTClient | 18:6d8a413a4d9a | 213 | |
AzureIoTClient | 18:6d8a413a4d9a | 214 | return result; |
AzureIoTClient | 18:6d8a413a4d9a | 215 | } |
AzureIoTClient | 18:6d8a413a4d9a | 216 | |
AzureIoTClient | 18:6d8a413a4d9a | 217 | |
AzureIoTClient | 18:6d8a413a4d9a | 218 | int connectionstringparser_splitHostName(STRING_HANDLE hostNameString, STRING_HANDLE nameString, STRING_HANDLE suffixString) |
AzureIoTClient | 18:6d8a413a4d9a | 219 | { |
AzureIoTClient | 18:6d8a413a4d9a | 220 | int result; |
AzureIoTClient | 18:6d8a413a4d9a | 221 | |
AzureIoTClient | 18:6d8a413a4d9a | 222 | if (hostNameString == NULL) |
AzureIoTClient | 18:6d8a413a4d9a | 223 | { |
AzureIoTClient | 21:b92006c5b9ff | 224 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_034: [If the hostNameString is NULL, connectionstringparser_splitHostName shall return __FAILURE__.]*/ |
AzureIoTClient | 21:b92006c5b9ff | 225 | result = __FAILURE__; |
AzureIoTClient | 18:6d8a413a4d9a | 226 | } |
AzureIoTClient | 18:6d8a413a4d9a | 227 | else |
AzureIoTClient | 18:6d8a413a4d9a | 228 | { |
AzureIoTClient | 18:6d8a413a4d9a | 229 | /* Codes_SRS_CONNECTIONSTRINGPARSER_21_033: [connectionstringparser_splitHostName shall convert the hostNameString to a connection_string passed in as argument, and call connectionstringparser_splitHostName_from_char.]*/ |
AzureIoTClient | 18:6d8a413a4d9a | 230 | result = connectionstringparser_splitHostName_from_char(STRING_c_str(hostNameString), nameString, suffixString); |
AzureIoTClient | 18:6d8a413a4d9a | 231 | } |
AzureIoTClient | 18:6d8a413a4d9a | 232 | |
AzureIoTClient | 18:6d8a413a4d9a | 233 | return result; |
AzureIoTClient | 18:6d8a413a4d9a | 234 | } |