static bool isThingnameTopicMatch()

in source/jobs.c [558:597]


static bool isThingnameTopicMatch( const char * topic,
                                   const size_t topicLength,
                                   const char * topicSuffix,
                                   const size_t topicSuffixLength,
                                   const char * thingName,
                                   const size_t thingNameLength )
{
    char expectedTopicBuffer[ TOPIC_BUFFER_SIZE + 1 ] = { '\0' };
    bool isMatch = true;
    size_t start = 0U;

    if( ( topic == NULL ) || ( topicLength == 0U ) )
    {
        isMatch = false;
    }
    else if( ( thingName == NULL ) || ( thingNameLength == 0U ) )
    {
        isMatch = false;
    }
    else
    {
        /* Empty MISRA body */
    }

    if( isMatch )
    {
        writePreamble( expectedTopicBuffer, &start, TOPIC_BUFFER_SIZE, thingName, ( uint16_t ) thingNameLength );
        ( void ) strnAppend( expectedTopicBuffer, &start, TOPIC_BUFFER_SIZE, topicSuffix, topicSuffixLength );

        isMatch = ( size_t ) strnlen( expectedTopicBuffer, TOPIC_BUFFER_SIZE ) ==
                  topicLength;
        isMatch = isMatch && ( strncmp( expectedTopicBuffer, topic, topicLength ) == 0 );
    }
    else
    {
        /* Empty MISRA body */
    }

    return isMatch;
}