in source/jobs.c [606:659]
JobsStatus_t Jobs_MatchTopic( char * topic,
size_t length,
const char * thingName,
uint16_t thingNameLength,
JobsTopic_t * outApi,
char ** outJobId,
uint16_t * outJobIdLength )
{
JobsStatus_t ret = JobsBadParameter;
JobsTopic_t api = JobsInvalidTopic;
char * jobId = NULL;
uint16_t jobIdLength = 0U;
if( ( topic != NULL ) && ( outApi != NULL ) && checkThingParams() && ( length > 0U ) )
{
ret = JobsNoMatch;
if( ( length > JOBS_API_COMMON_LENGTH( thingNameLength ) ) &&
( length < JOBS_API_MAX_LENGTH( thingNameLength ) ) )
{
char * prefix = topic;
char * name = &prefix[ JOBS_API_PREFIX_LENGTH ];
char * bridge = &name[ thingNameLength ];
/* check the shortest match first */
if( ( strnEquals( bridge, JOBS_API_BRIDGE, JOBS_API_BRIDGE_LENGTH ) == JobsSuccess ) &&
( strnEquals( prefix, JOBS_API_PREFIX, JOBS_API_PREFIX_LENGTH ) == JobsSuccess ) &&
( strnEquals( name, thingName, thingNameLength ) == JobsSuccess ) )
{
char * tail = &bridge[ JOBS_API_BRIDGE_LENGTH ];
size_t tailLength = length - JOBS_API_COMMON_LENGTH( thingNameLength );
ret = matchApi( tail, tailLength, &api, &jobId, &jobIdLength );
}
}
}
if( outApi != NULL )
{
*outApi = api;
}
if( outJobId != NULL )
{
*outJobId = jobId;
}
if( outJobIdLength != NULL )
{
*outJobIdLength = jobIdLength;
}
return ret;
}