* @brief Apply format specifiers (%d, %x, %llx, etc.) * * @param CurrentSpecifier * @param FinalBuffer * @param CurrentProcessedPositionFromStartOfFormat * @param CurrentPositionInFinalBuffer * @param Val * @param SizeOfFinalBuffer * @return VOID */
| 1329 | * @return VOID |
| 1330 | */ |
| 1331 | VOID |
| 1332 | ApplyFormatSpecifier(const CHAR * CurrentSpecifier, CHAR * FinalBuffer, PUINT32 CurrentProcessedPositionFromStartOfFormat, PUINT32 CurrentPositionInFinalBuffer, UINT64 Val, UINT32 SizeOfFinalBuffer) |
| 1333 | { |
| 1334 | UINT32 TempBufferLen = 0; |
| 1335 | CHAR TempBuffer[50 + 1] = { |
| 1336 | 0}; // Maximum uint64_t is 18446744073709551615 + 1 thus its 20 character |
| 1337 | // for maximum buffer + 1 end char null but we alloc 50 to be sure |
| 1338 | |
| 1339 | *CurrentProcessedPositionFromStartOfFormat = |
| 1340 | *CurrentProcessedPositionFromStartOfFormat + (UINT32)strlen(CurrentSpecifier); |
| 1341 | PlatformSprintf(TempBuffer, sizeof(TempBuffer), CurrentSpecifier, Val); |
| 1342 | TempBufferLen = (UINT32)strlen(TempBuffer); |
| 1343 | |
| 1344 | // |
| 1345 | // Check final buffer capacity |
| 1346 | // |
| 1347 | if (*CurrentPositionInFinalBuffer + TempBufferLen > SizeOfFinalBuffer) |
| 1348 | { |
| 1349 | // |
| 1350 | // Over passed buffer |
| 1351 | // |
| 1352 | return; |
| 1353 | } |
| 1354 | |
| 1355 | memcpy(&FinalBuffer[*CurrentPositionInFinalBuffer], TempBuffer, TempBufferLen); |
| 1356 | |
| 1357 | *CurrentPositionInFinalBuffer = *CurrentPositionInFinalBuffer + TempBufferLen; |
| 1358 | } |
| 1359 | |
| 1360 | /** |
| 1361 | * @brief Convert WCHAR* to CHAR* |
no test coverage detected