bool ConstMap_ContainsKey(CONSTMAP_HANDLE handle, const char* key ) { bool keyExists = false; if (handle == NULL) { /*Codes_SRS_CONSTMAP_17_024: [If parameter handle or key are NULL then ConstMap_ContainsKey shall return false.]*/ LOG_CONSTMAP_ERROR(CONSTMAP_INVALIDARG); } else { if (key == NULL) { LOG_CONSTMAP_ERROR(CONSTMAP_INVALIDARG); } else { /*Codes_SRS_CONSTMAP_17_025: [Otherwise if a key exists then ConstMap_ContainsKey shall return true.]*/ MAP_RESULT mapResult = Map_ContainsKey(((CONSTMAP_HANDLE_DATA *)handle)->map, key, &keyExists); if (mapResult != MAP_OK) { /*Codes_SRS_CONSTMAP_17_026: [If a key doesn't exist, then ConstMap_ContainsKey shall return false.]*/ keyExists = false; LOG_CONSTMAP_ERROR(ConstMap_ErrorConvert(mapResult)); } } } return keyExists; }
const char* IoTHubMessage_GetProperty(IOTHUB_MESSAGE_HANDLE msg_handle, const char* key) { const char* result; if (msg_handle == NULL || key == NULL) { LogError("invalid parameter (NULL) to IoTHubMessage_GetProperty iotHubMessageHandle=%p, key=%p", msg_handle, key); result = NULL; } else { bool key_exists = false; // The return value is not neccessary, just check the key_exist variable if ((Map_ContainsKey(msg_handle->properties, key, &key_exists) == MAP_OK) && key_exists) { result = Map_GetValueFromKey(msg_handle->properties, key); } else { result = NULL; } } return result; }