static DefenderStatus_t extractThingNameLength()

in source/defender.c [275:302]


static DefenderStatus_t extractThingNameLength( const char * pRemainingTopic,
                                                uint16_t remainingTopicLength,
                                                uint16_t * pOutThingNameLength )
{
    DefenderStatus_t ret = DefenderNoMatch;
    uint16_t i = 0U;

    assert( pRemainingTopic != NULL );
    assert( pOutThingNameLength != NULL );

    /* Find the first forward slash. It marks the end of the thing name. */
    for( i = 0U; i < remainingTopicLength; i++ )
    {
        if( pRemainingTopic[ i ] == '/' )
        {
            break;
        }
    }

    /* Zero length thing name is not valid. */
    if( i > 0U )
    {
        *pOutThingNameLength = i;
        ret = DefenderSuccess;
    }

    return ret;
}