static JobsStatus_t matchApi()

in source/jobs.c [467:500]


static JobsStatus_t matchApi( char * topic,
                              size_t topicLength,
                              JobsTopic_t * outApi,
                              char ** outJobId,
                              uint16_t * outJobIdLength )
{
    JobsStatus_t ret = JobsNoMatch;
    JobsTopic_t api;

    assert( ( topic != NULL ) && ( outApi != NULL ) &&
            ( outJobId != NULL ) && ( outJobIdLength != NULL ) );

    /* The first set of APIs do not have job IDs. */
    /* The api variable is bounded within contiguous values of the enum type. */
    /* coverity[misra_c_2012_rule_10_1_violation] */
    for( api = JobsJobsChanged; api < JobsDescribeSuccess; api++ )
    {
        ret = strnnEq( topic, topicLength, apiTopic[ api ], apiTopicLength[ api ] );

        if( ret == JobsSuccess )
        {
            *outApi = api;
            break;
        }
    }

    /* The remaining APIs must have a job ID. */
    if( ret == JobsNoMatch )
    {
        ret = matchIdApi( topic, topicLength, outApi, outJobId, outJobIdLength );
    }

    return ret;
}