examples/google_voice_assistant/main/wmfwparse.cpp
/*
*  Function:  ExtractStringData
*
*  @brief  Extracts and saves string data from an algorithm information block
*
* Extracts and saves string data from Algorithm Information Data Blocks in WMFW files
*
*  @param  buffer				Pointer that we allocate and save the string data to
*  @param  length				Non-padded string length reported by AlgorithmInfo block
*  @param  numLengthBytes		Number of bytes used to store the length data
*  @param  paddedStringLength	Pointer to location for storing the calculated padded string length
*
*
*/
ExtractStringData
@brief  Extracts and saves string data from an algorithm information block

Extracts and saves string data from Algorithm Information Data Blocks in WMFW files

@param  buffer                                Pointer that we allocate and save the string data to
@param  length                                Non-padded string length reported by AlgorithmInfo block
@param  numLengthBytes                Number of bytes used to store the length data
@param  paddedStringLength    Pointer to location for storing the calculated padded string length
ExtractStringData @brief Extracts and saves string data from an algorithm information block Extracts and saves string data from Algorithm Information Data Blocks in WMFW files @param buffer Pointer that we allocate and save the string data to @param length Non - padded string length reported by AlgorithmInfo block @param numLengthBytes Number of bytes used to store the length data @param paddedStringLength Pointer to location for storing the calculated padded string length
int ExtractStringData(unsigned char ** outputBuffer, unsigned char ** inputBuffer, unsigned int stringLength, unsigned int numLengthBytes, unsigned int *paddedStringLength)
{
	int status = WMFW_SUCCESS;
	*paddedStringLength = ((stringLength + numLengthBytes + 3) & ~0x03) - numLengthBytes;
	if (stringLength > 0)
	{
		*outputBuffer = (unsigned char *)malloc(stringLength + 1);
		if (!*outputBuffer)
		{
			status = WMFW_OUT_OF_MEMORY;
			return status;
		}
		for (unsigned int i = 0; i < stringLength; i++)
		{
			(*outputBuffer)[i] = (*inputBuffer)[i];
		}
		(*outputBuffer)[stringLength] = '\0';
	}
	return status;
}
int ExtractStringData ( unsigned char * * outputBuffer , unsigned char * * inputBuffer , unsigned int stringLength , unsigned int numLengthBytes , unsigned int * paddedStringLength ) { int status = WMFW_SUCCESS ; * paddedStringLength = ( ( stringLength + numLengthBytes + 3 ) & ~ 0x03 ) - numLengthBytes ; if ( stringLength > 0 ) { * outputBuffer = ( unsigned char * ) malloc ( stringLength + 1 ) ; if ( ! * outputBuffer ) { status = WMFW_OUT_OF_MEMORY ; return status ; } for ( unsigned int i = 0 ; i < stringLength ; i ++ ) { ( * outputBuffer ) [ i ] = ( * inputBuffer ) [ i ] ; } ( * outputBuffer ) [ stringLength ] = ' \0 ' ; } return status ; }
Function:  ExtractStringData
@brief  Extracts and saves string data from an algorithm information block
Function : ExtractStringData @brief Extracts and saves string data from an algorithm information block
// Length must be at least 3 bytes long and padded such that the name ends on a 4-byte boundary. // Print out lengths for debug use if required //printf("\tString Length: %d bytes\n", stringLength); //printf("\tString Name Length: %d bytes\n", *paddedStringLength); // Extract string to outputBuffer