in source/jobs.c [419:487]
static JobsStatus_t matchIdApi( char * topic,
size_t topicLength,
JobsTopic_t * outApi,
char ** outJobId,
uint16_t * outJobIdLength )
{
JobsStatus_t ret = JobsNoMatch;
size_t i;
char * p = topic;
size_t length = topicLength;
char * jobId = NULL;
uint16_t jobIdLength = 0U;
assert( ( topic != NULL ) && ( outApi != NULL ) &&
( outJobId != NULL ) && ( outJobIdLength != NULL ) );
for( i = 0U; i < length; i++ )
{
if( ( i > 0U ) && ( p[ i ] == '/' ) )
{
/* Save the leading job ID and its length. */
jobId = p;
jobIdLength = ( uint16_t ) i;
break;
}
}
/* Advance p to after the '/' and reduce buffer length
* for the remaining API search. */
p = &p[ jobIdLength + 1U ];
length = length - jobIdLength - 1U;
if( ( isNextJobId( jobId, jobIdLength ) == true ) ||
( isValidJobId( jobId, jobIdLength ) == true ) )
{
if( JobsSuccess == strnnEq( p, length, apiTopic[ JobsDescribeSuccess ], apiTopicLength[ JobsDescribeSuccess ] ) )
{
ret = JobsSuccess;
*outApi = JobsDescribeSuccess;
}
else if( JobsSuccess == strnnEq( p, length, apiTopic[ JobsDescribeFailed ], apiTopicLength[ JobsDescribeFailed ] ) )
{
ret = JobsSuccess;
*outApi = JobsDescribeFailed;
}
else if( JobsSuccess == strnnEq( p, length, apiTopic[ JobsUpdateSuccess ], apiTopicLength[ JobsUpdateSuccess ] ) )
{
ret = JobsSuccess;
*outApi = JobsUpdateSuccess;
}
else if( JobsSuccess == strnnEq( p, length, apiTopic[ JobsUpdateFailed ], apiTopicLength[ JobsUpdateFailed ] ) )
{
ret = JobsSuccess;
*outApi = JobsUpdateFailed;
}
else
{
/* MISRA Empty Body */
}
if( ret == JobsSuccess )
{
*outJobId = jobId;
*outJobIdLength = jobIdLength;
}
}
return ret;
}