add more legacy functions: setlinebuf and setbuffer
authorRich Felker <dalias@aerifal.cx>
Tue, 5 Apr 2011 16:25:31 +0000 (12:25 -0400)
committerRich Felker <dalias@aerifal.cx>
Tue, 5 Apr 2011 16:25:31 +0000 (12:25 -0400)
include/stdio.h
src/stdio/setbuf.c
src/stdio/setbuffer.c [new file with mode: 0644]
src/stdio/setlinebuf.c [new file with mode: 0644]

index 186fdf2c7e569c10ab840b4a477686dab1079703..69178cc873c67df35d0d743cbd20523ee4fe03df 100644 (file)
@@ -156,6 +156,8 @@ char *cuserid(char *);
 #define off64_t off_t
 int asprintf(char **, const char *, ...);
 int vasprintf(char **, const char *, va_list);
+void setlinebuf(FILE *);
+void setbuffer(FILE *, char *, size_t);
 #endif
 
 #ifdef __cplusplus
index 205afcfe69130da23faaddc0cb0408116af15b9c..1b98d5039c1896551145e7ebe39511ef02bf70a4 100644 (file)
@@ -1,4 +1,4 @@
-#include "stdio_impl.h"
+#include <stdio.h>
 
 void setbuf(FILE *f, char *buf)
 {
diff --git a/src/stdio/setbuffer.c b/src/stdio/setbuffer.c
new file mode 100644 (file)
index 0000000..71233d2
--- /dev/null
@@ -0,0 +1,7 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+
+void setbuffer(FILE *f, char *buf, size_t size)
+{
+       setvbuf(f, buf, buf ? _IOFBF : _IONBF, size);
+}
diff --git a/src/stdio/setlinebuf.c b/src/stdio/setlinebuf.c
new file mode 100644 (file)
index 0000000..b93c4d6
--- /dev/null
@@ -0,0 +1,7 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+
+void setlinebuf(FILE *f)
+{
+       setvbuf(f, 0, _IOLBF, 0);
+}