in source/shadow.c [139:299]
static ShadowStatus_t validateMatchTopicParameters( const char * pTopic,
uint16_t topicLength,
const ShadowMessageType_t * pMessageType );
/**
* @brief Check if Shadow_AssembleTopicString has valid parameters.
*
* @param[in] topicType Shadow topic type.
* @param[in] pThingName Thing Name string.
* @param[in] thingNameLength Length of Thing Name string pointed to by pThingName.
* @param[in] pShadowName Shadow Name string.
* @param[in] shadowNameLength Length of Shadow Name string pointed to by pShadowName.
* @param[in] pTopicBuffer Pointer to the topic buffer.
* @param[in] pOutLength Pointer to the length of the topic created.
*
* @return Return SHADOW_SUCCESS if the parameters are valid;
* return SHADOW_BAD_PARAMETER if not.
*/
static ShadowStatus_t validateAssembleTopicParameters( ShadowTopicStringType_t topicType,
const char * pThingName,
uint8_t thingNameLength,
const char * pShadowName,
uint8_t shadowNameLength,
const char * pTopicBuffer,
const uint16_t * pOutLength );
/**
* @brief Determine if the string contains the substring.
*
* @param[in] pString Pointer to the string.
* @param[in] stringLength Length of pString.
* @param[in] pSubString Pointer to the substring.
* @param[in] subStringLength Length of pSubString.
*
* @return Return SHADOW_SUCCESS if it contains;
* return SHADOW_FAIL if not.
*/
static ShadowStatus_t containsSubString( const char * pString,
uint16_t stringLength,
const char * pSubString,
uint16_t subStringLength );
/**
* @brief Check if the Thing or Shadow Name is valid.
*
* @param[in] pString Pointer to the starting of a name.
* @param[in] stringLength Length of pString.
* @param[in] maxAllowedLength Maximum allowed length of the Thing or Shadow name.
* @param[out] pNameLength Pointer to caller-supplied memory for returning the length of the Thing or Shadow Name.
*
* @return Return SHADOW_SUCCESS if it is valid;
* return SHADOW_FAIL if it is not.
*/
static ShadowStatus_t validateName( const char * pString,
uint16_t stringLength,
uint8_t maxAllowedLength,
uint8_t * pNameLength );
/**
* @brief Extract the Shadow message type from a string.
*
* @param[in] pString Pointer to the string.
* @param[in] stringLength Length of pString.
* @param[out] pMessageType Pointer to caller-supplied memory for returning the type of the shadow message.
*
* @return Return SHADOW_SUCCESS if successfully extracted;
* return SHADOW_MESSAGE_TYPE_PARSE_FAILED if failed.
*/
static ShadowStatus_t extractShadowMessageType( const char * pString,
uint16_t stringLength,
ShadowMessageType_t * pMessageType );
/**
* @brief Extract the Thing name from a topic string.
*
* @param[in] pTopic Pointer to the topic string.
* @param[in] topicLength Length of pTopic.
* @param[in,out] pConsumedTopicLength Pointer to caller-supplied memory for returning the consumed topic length.
* @param[out] pThingNameLength Pointer to caller-supplied memory for returning the Thing name length.
*
* @return Return SHADOW_SUCCESS if successfully extracted;
* return SHADOW_THINGNAME_PARSE_FAILED if Thing name parsing fails.
*/
static ShadowStatus_t extractThingName( const char * pTopic,
uint16_t topicLength,
uint16_t * pConsumedTopicLength,
uint8_t * pThingNameLength );
/**
* @brief Extract the classic shadow root OR the named shadow root and shadow name from a topic string.
*
* @param[in] pTopic Pointer to the topic string.
* @param[in] topicLength Length of pTopic.
* @param[in,out] pConsumedTopicLength Pointer to caller-supplied memory for returning the consumed topic length.
* @param[out] pShadowNameLength Pointer to caller-supplied memory for returning the shadow name length.
*
* @return Return SHADOW_SUCCESS if successfully extracted;
* return SHADOW_ROOT_PARSE_FAILED shadow root parsing fails.
* return SHADOW_SHADOWNAME_PARSE_FAILED shadow name parsing fails.
*/
static ShadowStatus_t extractShadowRootAndName( const char * pTopic,
uint16_t topicLength,
uint16_t * pConsumedTopicLength,
uint8_t * pShadowNameLength );
/**
* @brief Get the shadow operation string for a given shadow topic type.
*
* @param[in] topicType The given shadow topic type.
*
* @return The shadow operation string for the given shadow type.
*/
static const char * getShadowOperationString( ShadowTopicStringType_t topicType );
/**
* @brief Get the shadow operation string length for a given shadow topic type.
*
* @param[in] topicType The given shadow topic type.
*
* @return The shadow operation string length for the given shadow type.
*/
static uint16_t getShadowOperationLength( ShadowTopicStringType_t topicType );
/**
* @brief Creates a shadow topic string
*
* @param[in] topicType The type of shadow topic to be constructed.
* @param[in] pThingName Pointer to the Thing name.
* @param[in] thingNameLength The length of the Thing name.
* @param[in] pShadowName Pointer to the Shadow name.
* @param[in] shadowNameLength The length of the Shadow name.
* @param[out] pTopicBuffer Pointer to caller-supplied memory for returning the constructed shadow topic string.
*/
static void createShadowTopicString( ShadowTopicStringType_t topicType,
const char * pThingName,
uint8_t thingNameLength,
const char * pShadowName,
uint8_t shadowNameLength,
char * pTopicBuffer );
/*-----------------------------------------------------------*/
static ShadowStatus_t validateMatchTopicParameters( const char * pTopic,
uint16_t topicLength,
const ShadowMessageType_t * pMessageType )
{
ShadowStatus_t shadowStatus = SHADOW_SUCCESS;
if( ( pTopic == NULL ) ||
( topicLength == 0U ) ||
( pMessageType == NULL ) )
{
shadowStatus = SHADOW_BAD_PARAMETER;
LogError( ( "Invalid input parameters pTopic: %p, topicLength: %u, pMessageType: %p.",
( void * ) pTopic,
( unsigned int ) topicLength,
( void * ) pMessageType ) );
}
return shadowStatus;
}