aboutsummaryrefslogtreecommitdiffstats
path: root/printf.h
diff options
context:
space:
mode:
authorMarco Paland <marco@paland.com>2018-05-15 12:14:51 +0200
committerMarco Paland <marco@paland.com>2018-05-15 12:14:51 +0200
commit24c460b977c014076821a36b2dae574893cebb85 (patch)
tree9308d0871a9dbf727392ac1bf2390c1e1906c3ac /printf.h
parentd12e52be4c207bb3b8a35f512b2cddf8deb3ceaf (diff)
downloadprintf-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.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/printf.h b/printf.h
index 37dbd54..c0ba2ae 100644
--- a/printf.h
+++ b/printf.h
@@ -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