1 /** 2 ****************************************************************************** 3 * @file stm32_tiny_vsnprintf.h 4 * @author MCD Application Team 5 * @brief Header for tiny_vsnprintf.c module 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2019 STMicroelectronics. 10 * All rights reserved. 11 * 12 * This software is licensed under terms that can be found in the LICENSE file 13 * in the root directory of this software component. 14 * If no LICENSE file comes with this software, it is provided AS-IS. 15 * 16 ****************************************************************************** 17 */ 18 19 /* Define to prevent recursive inclusion -------------------------------------*/ 20 #ifndef __STM32_TINY_VSNPRINTF_H__ 21 #define __STM32_TINY_VSNPRINTF_H__ 22 23 #ifdef __cplusplus 24 extern "C" 25 { 26 #endif 27 /* Includes ------------------------------------------------------------------*/ 28 #include <stdarg.h> 29 #include <string.h> 30 /* Exported types ------------------------------------------------------------*/ 31 /* Exported constants --------------------------------------------------------*/ 32 /* External variables --------------------------------------------------------*/ 33 /* Exported functions ------------------------------------------------------- */ 34 35 /** 36 * @brief Tiny implementation of vsnprintf() like function 37 * 38 * It has been adapted so that: 39 * - Tiny implementation, when defining TINY_PRINTF, is available. In such as case, 40 * not all the format are available. Instead, only %02X, %x, %d, %u, %s and %c are available. 41 * %f,, %+, %#, %- and others are excluded 42 * - Provide a snprintf like implementation. The size of the buffer is provided, 43 * and the length of the filled buffer is returned (not including the final '\0' char). 44 * The string may be truncated 45 * @param Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of 46 * at least n characters. 47 * @param Maximum number of bytes to be used in the buffer. The generated string has a length of at 48 * most n-1, leaving space for the additional terminating null character. 49 * @param C string that contains a format string that follows the same specifications as format 50 * in printf (see printf for details). 51 * @param A value identifying a variable arguments list initialized with va_start. 52 * @retval The number of written char (note that this is different from vsnprintf() 53 */ 54 int tiny_vsnprintf_like(char *buf, const int size, const char *fmt, va_list args); 55 56 #ifdef __cplusplus 57 } 58 #endif 59 60 #endif /* __STM32_TINY_VSNPRINTF_H__ */ 61