diff options
author | Marco Paland <marco@paland.com> | 2018-05-15 12:14:51 +0200 |
---|---|---|
committer | Marco Paland <marco@paland.com> | 2018-05-15 12:14:51 +0200 |
commit | 24c460b977c014076821a36b2dae574893cebb85 (patch) | |
tree | 9308d0871a9dbf727392ac1bf2390c1e1906c3ac /printf.h | |
parent | d12e52be4c207bb3b8a35f512b2cddf8deb3ceaf (diff) | |
download | printf-24c460b977c014076821a36b2dae574893cebb85.tar.gz printf-24c460b977c014076821a36b2dae574893cebb85.tar.bz2 printf-24c460b977c014076821a36b2dae574893cebb85.zip |
feat(printf): added new oprintf() function
Write formatted output directly to given output function
Diffstat (limited to 'printf.h')
-rw-r--r-- | printf.h | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -60,7 +60,7 @@ int printf(const char* format, ...); /**
* Tiny sprintf implementation
- * Due to security reasons (buffer overflow) YOU SHOULD CONSIDER USING SNPRINTF INSTEAD!
+ * Due to security reasons (buffer overflow) YOU SHOULD CONSIDER USING (V)SNPRINTF INSTEAD!
* \param buffer A pointer to the buffer where to store the formatted string. MUST be big enough to store the output!
* \param format A string that specifies the format of the output
* \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character
@@ -80,6 +80,16 @@ int snprintf(char* buffer, size_t count, const char* format, ...); int vsnprintf(char* buffer, size_t count, const char* format, va_list va);
+/**
+ * printf with output function
+ * You may use this as dynamic alternative to printf() with its fixed _putchar() output
+ * \param out An output function which takes one character
+ * \param format A string that specifies the format of the output
+ * \return The number of characters that are sent to the output function, not counting the terminating null character
+ */
+int oprintf(void (*out)(char character), const char* format, ...);
+
+
#ifdef __cplusplus
}
#endif
|