static ShadowStatus_t validateAssembleTopicParameters()

in source/shadow.c [303:349]


static ShadowStatus_t validateAssembleTopicParameters( ShadowTopicStringType_t topicType,
                                                       const char * pThingName,
                                                       uint8_t thingNameLength,
                                                       const char * pShadowName,
                                                       uint8_t shadowNameLength,
                                                       const char * pTopicBuffer,
                                                       const uint16_t * pOutLength )
{
    ShadowStatus_t shadowStatus = SHADOW_BAD_PARAMETER;

    if( ( pTopicBuffer == NULL ) ||
        ( pThingName == NULL ) ||
        ( thingNameLength == 0U ) ||
        ( ( pShadowName == NULL ) && ( shadowNameLength > 0U ) ) ||
        ( topicType >= ShadowTopicStringTypeMaxNum ) ||
        ( pOutLength == NULL ) )
    {
        LogError( ( "Invalid input parameters pTopicBuffer: %p, pThingName: %p, thingNameLength: %u,\
                    pShadowName: %p, shadowNameLength: %u, topicType: %d, pOutLength: %p.",
                    ( void * ) pTopicBuffer,
                    ( void * ) pThingName,
                    ( unsigned int ) thingNameLength,
                    ( void * ) pShadowName,
                    ( unsigned int ) shadowNameLength,
                    ( int ) topicType,
                    ( void * ) pOutLength ) );
    }
    else if( thingNameLength > SHADOW_THINGNAME_MAX_LENGTH )
    {
        LogError( ( "Invalid thingNamelength. Thing name length of %u exceeds maximum allowed length %u.",
                    ( unsigned int ) thingNameLength,
                    ( unsigned int ) SHADOW_THINGNAME_MAX_LENGTH ) );
    }
    else if( shadowNameLength > SHADOW_NAME_MAX_LENGTH )
    {
        LogError( ( "Invalid shadowNameLength. Shadow name length of %u exceeds maximum allowed length %u.",
                    ( unsigned int ) shadowNameLength,
                    ( unsigned int ) SHADOW_NAME_MAX_LENGTH ) );
    }
    else
    {
        /* Validations passed .*/
        shadowStatus = SHADOW_SUCCESS;
    }

    return shadowStatus;
}