+size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer )\r
+{\r
+StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
+size_t xReturn, xBytesAvailable, xOriginalTail;\r
+configMESSAGE_BUFFER_LENGTH_TYPE xTempReturn;\r
+\r
+ configASSERT( pxStreamBuffer );\r
+\r
+ /* Ensure the stream buffer is being used as a message buffer. */\r
+ if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )\r
+ {\r
+ xBytesAvailable = prvBytesInBuffer( pxStreamBuffer );\r
+ if( xBytesAvailable > sbBYTES_TO_STORE_MESSAGE_LENGTH )\r
+ {\r
+ /* The number of bytes available is greater than the number of bytes\r
+ required to hold the length of the next message, so another message\r
+ is available. Return its length without removing the length bytes\r
+ from the buffer. A copy of the tail is stored so the buffer can be\r
+ returned to its prior state as the message is not actually being\r
+ removed from the buffer. */\r
+ xOriginalTail = pxStreamBuffer->xTail;\r
+ ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempReturn, sbBYTES_TO_STORE_MESSAGE_LENGTH, xBytesAvailable );\r
+ xReturn = ( size_t ) xTempReturn;\r
+ pxStreamBuffer->xTail = xOriginalTail;\r
+ }\r
+ else\r
+ {\r
+ /* The minimum amount of bytes in a message buffer is\r
+ ( sbBYTES_TO_STORE_MESSAGE_LENGTH + 1 ), so if xBytesAvailable is\r
+ less than sbBYTES_TO_STORE_MESSAGE_LENGTH the only other valid\r
+ value is 0. */\r
+ configASSERT( xBytesAvailable == 0 );\r
+ xReturn = 0;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ xReturn = 0;\r
+ }\r
+\r
+ return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r