in source/sigv4.c [947:1013]
static SigV4Status_t parseDate( const char * pDate,
size_t dateLen,
const char * pFormat,
size_t formatLen,
SigV4DateTime_t * pDateElements )
{
SigV4Status_t returnStatus = SigV4InvalidParameter;
size_t readLoc = 0U, formatIndex = 0U;
uint8_t lenToRead = 0U;
assert( pDate != NULL );
assert( pFormat != NULL );
assert( pDateElements != NULL );
( void ) dateLen;
/* Loop through the format string. */
while( ( formatIndex < formatLen ) && ( returnStatus != SigV4ISOFormattingError ) )
{
if( pFormat[ formatIndex ] == '%' )
{
/* '%' must be followed by a length and type specification. */
assert( formatIndex < formatLen - 2 );
formatIndex++;
/* Numerical value of length specifier character. */
lenToRead = ( ( uint8_t ) pFormat[ formatIndex ] - ( uint8_t ) '0' );
formatIndex++;
/* Ensure read is within buffer bounds. */
assert( readLoc + lenToRead - 1 < dateLen );
returnStatus = scanValue( pDate,
pFormat[ formatIndex ],
readLoc,
lenToRead,
pDateElements );
readLoc += lenToRead;
}
else if( pDate[ readLoc ] != pFormat[ formatIndex ] )
{
LogError( ( "Parsing error: Expected character '%c', "
"but received '%c'.",
pFormat[ formatIndex ], pDate[ readLoc ] ) );
returnStatus = SigV4ISOFormattingError;
}
else
{
readLoc++;
LogDebug( ( "Successfully matched character '%c' found in format string.",
pDate[ readLoc - 1 ] ) );
}
formatIndex++;
}
if( ( returnStatus != SigV4ISOFormattingError ) )
{
returnStatus = SigV4Success;
}
else
{
LogError( ( "Parsing Error: Date did not match expected string format." ) );
returnStatus = SigV4ISOFormattingError;
}
return returnStatus;
}