AzureIoTResult_t AzureIoTMessage_PropertiesFind()

in source/azure_iot_message.c [72:102]


AzureIoTResult_t AzureIoTMessage_PropertiesFind( AzureIoTMessageProperties_t * pxMessageProperties,
                                                 const uint8_t * pucName,
                                                 uint32_t ulNameLength,
                                                 const uint8_t ** ppucOutValue,
                                                 uint32_t * pulOutValueLength )
{
    az_span xNameSpan = az_span_create( ( uint8_t * ) pucName, ( int32_t ) ulNameLength );
    az_span xOutValueSpan;
    az_result xResult;

    if( ( pxMessageProperties == NULL ) ||
        ( pucName == NULL ) || ( ulNameLength == 0 ) ||
        ( ppucOutValue == NULL ) || ( pulOutValueLength == NULL ) )
    {
        AZLogError( ( "AzureIoTMessage_PropertiesFind failed: Invalid argument" ) );
        return eAzureIoTErrorInvalidArgument;
    }

    xResult = az_iot_message_properties_find( &pxMessageProperties->_internal.xProperties,
                                              xNameSpan, &xOutValueSpan );

    if( az_result_failed( xResult ) )
    {
        return eAzureIoTErrorItemNotFound;
    }

    *ppucOutValue = az_span_ptr( xOutValueSpan );
    *pulOutValueLength = ( uint32_t ) az_span_size( xOutValueSpan );

    return eAzureIoTSuccess;
}