summaryrefslogtreecommitdiff
path: root/src/stdio/vfprintf_s.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-08-16 15:55:19 -0400
committerJakob Kaivo <jkk@ung.org>2020-08-16 15:55:19 -0400
commite223e635cc53fa11e473cdbc864eb69a3da5f290 (patch)
treed481ca6fb0b7f4184f3ec259a6f9c37d76e56a26 /src/stdio/vfprintf_s.c
parent700fbd205a1a428677876d322606b9a354221892 (diff)
add skeleton of symbols from C11 LIB_EXT1
Diffstat (limited to 'src/stdio/vfprintf_s.c')
-rw-r--r--src/stdio/vfprintf_s.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/stdio/vfprintf_s.c b/src/stdio/vfprintf_s.c
new file mode 100644
index 00000000..e2d94c71
--- /dev/null
+++ b/src/stdio/vfprintf_s.c
@@ -0,0 +1,38 @@
+#include "stdio.h"
+#include "__stdio.h"
+#include <stdarg.h>
+
+/** write formatted output to a file stream **/
+int vfprintf_s(FILE * restrict stream, const char * restrict format, va_list arg)
+{
+ __C_EXT(1, 201112L);
+ va_list ap;
+ va_copy(ap, arg);
+ int len = vsnprintf(NULL, 0, format, arg);
+ char *buf = malloc(len + 1);
+ len = vsnprintf(buf, len, format, ap);
+ va_end(ap);
+ len = (int)fwrite(buf, sizeof(*buf), len, stream);
+ free(buf);
+ return len;
+}
+
+/***
+The fn(vfprintf) function is equivalent to fn(fprintf), but with a type(va_list)
+argument instead of variadic arguments. The argument arg(arg) must be
+initialized with fnmacro(va_start) prior to calling fn(vfprintf). The
+fn(vfprintf) function does not call fnmacro(va_end), so the calling function is
+responsible for this.
+***/
+
+/* UNSPECIFIED: ??? */
+/* UNDEFINED: ??? */
+/* IMPLEMENTATION: ??? */
+/* LOCALE: ??? */
+
+/* RETURN(NEG): an error occurred */
+/* RETURN: the number of characters written */
+
+/*
+CEXT1(201112)
+*/