aboutsummaryrefslogtreecommitdiffstats
path: root/io
diff options
context:
space:
mode:
Diffstat (limited to 'io')
-rw-r--r--io/asprintf.c10
-rw-r--r--io/aswprintf.c11
-rw-r--r--io/fgets.c15
-rw-r--r--io/fgetws.c15
-rw-r--r--io/fprintf.c10
-rw-r--r--io/fputs.c11
-rw-r--r--io/fputws.c11
-rw-r--r--io/fscanf.c10
-rw-r--r--io/fwprinf.c10
-rw-r--r--io/fwscanf.c10
-rw-r--r--io/getchar.c3
-rw-r--r--io/gets.c18
-rw-r--r--io/getwchar.c4
-rw-r--r--io/io.h54
-rw-r--r--io/meson.build43
-rw-r--r--io/perror.c10
-rw-r--r--io/printf.c10
-rw-r--r--io/putchar.c6
-rw-r--r--io/puts.c10
-rw-r--r--io/putwchar.c7
-rw-r--r--io/rewind.c4
-rw-r--r--io/scanf.c10
-rw-r--r--io/setbuf.c8
-rw-r--r--io/snprintf.c10
-rw-r--r--io/sprintf.c10
-rw-r--r--io/sscanf.c10
-rw-r--r--io/swprintf.c11
-rw-r--r--io/swscanf.c10
-rw-r--r--io/vasprintf.c18
-rw-r--r--io/vaswprintf.c18
-rw-r--r--io/vprintf.c6
-rw-r--r--io/vscanf.c6
-rw-r--r--io/vsprintf.c7
-rw-r--r--io/vwprintf.c6
-rw-r--r--io/vwscanf.c6
-rw-r--r--io/wprinf.c10
-rw-r--r--io/wrap/feof.c11
-rw-r--r--io/wrap/fgetc.c4
-rw-r--r--io/wrap/fgetwc.c4
-rw-r--r--io/wrap/fputc.c7
-rw-r--r--io/wrap/fputwc.c7
-rw-r--r--io/wrap/io.h56
-rw-r--r--io/wrap/meson.build16
-rw-r--r--io/wrap/setvbuf.c8
-rw-r--r--io/wrap/stdstream.c16
-rw-r--r--io/wrap/vfprintf.c7
-rw-r--r--io/wrap/vfscanf.c7
-rw-r--r--io/wrap/vfwprinf.c8
-rw-r--r--io/wrap/vfwscanf.c8
-rw-r--r--io/wrap/vsnprintf.c9
-rw-r--r--io/wrap/vsscanf.c8
-rw-r--r--io/wrap/vswprintf.c9
-rw-r--r--io/wrap/vswscanf.c9
-rw-r--r--io/wscanf.c10
54 files changed, 632 insertions, 0 deletions
diff --git a/io/asprintf.c b/io/asprintf.c
new file mode 100644
index 0000000..5a4a641
--- /dev/null
+++ b/io/asprintf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int asprintf(char **string, char const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = vasprintf(string, format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/aswprintf.c b/io/aswprintf.c
new file mode 100644
index 0000000..d65094e
--- /dev/null
+++ b/io/aswprintf.c
@@ -0,0 +1,11 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+
+int aswprintf(wchar_t **string, wchar_t const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = vaswprintf(string, format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/fgets.c b/io/fgets.c
new file mode 100644
index 0000000..69cd1be
--- /dev/null
+++ b/io/fgets.c
@@ -0,0 +1,15 @@
+#include "io.h"
+#include <errno.h>
+
+char* fgets(char *restrict string, int size, FILE *restrict stream)
+{
+ int character = 0;
+ for(int i=0;character == '\n' || i < size -1;i++){
+ character = _fgetc_wrap(stream);
+ if(character == _eof_wrap){
+ return NULL;
+ }
+ }
+
+ return string;
+}
diff --git a/io/fgetws.c b/io/fgetws.c
new file mode 100644
index 0000000..69cd1be
--- /dev/null
+++ b/io/fgetws.c
@@ -0,0 +1,15 @@
+#include "io.h"
+#include <errno.h>
+
+char* fgets(char *restrict string, int size, FILE *restrict stream)
+{
+ int character = 0;
+ for(int i=0;character == '\n' || i < size -1;i++){
+ character = _fgetc_wrap(stream);
+ if(character == _eof_wrap){
+ return NULL;
+ }
+ }
+
+ return string;
+}
diff --git a/io/fprintf.c b/io/fprintf.c
new file mode 100644
index 0000000..d8a3480
--- /dev/null
+++ b/io/fprintf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int fprintf(FILE *stream, char const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = _vfprintf_wrap(stream, format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/fputs.c b/io/fputs.c
new file mode 100644
index 0000000..f121253
--- /dev/null
+++ b/io/fputs.c
@@ -0,0 +1,11 @@
+#include "io.h"
+#include <errno.h>
+
+int fputs(char const *restrict string, FILE *restrict stream)
+{
+
+ for (size_t i = 0; string[i]; ++i) {
+ if(_fputc_wrap(string[i], stream)==_eof_wrap){return _eof_wrap;};
+ }
+ return 0;
+}
diff --git a/io/fputws.c b/io/fputws.c
new file mode 100644
index 0000000..f121253
--- /dev/null
+++ b/io/fputws.c
@@ -0,0 +1,11 @@
+#include "io.h"
+#include <errno.h>
+
+int fputs(char const *restrict string, FILE *restrict stream)
+{
+
+ for (size_t i = 0; string[i]; ++i) {
+ if(_fputc_wrap(string[i], stream)==_eof_wrap){return _eof_wrap;};
+ }
+ return 0;
+}
diff --git a/io/fscanf.c b/io/fscanf.c
new file mode 100644
index 0000000..575a5f5
--- /dev/null
+++ b/io/fscanf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int fscanf(FILE *stream, char const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = _vfscanf_wrap(stream, format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/fwprinf.c b/io/fwprinf.c
new file mode 100644
index 0000000..a382ccb
--- /dev/null
+++ b/io/fwprinf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int fwprintf(FILE *stream, wchar_t const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = _vfwprintf_wrap(stream, format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/fwscanf.c b/io/fwscanf.c
new file mode 100644
index 0000000..f731b5b
--- /dev/null
+++ b/io/fwscanf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int fwscanf(FILE *stream, wchar_t const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = _vfwscanf_wrap(stream, format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/getchar.c b/io/getchar.c
new file mode 100644
index 0000000..57d26c4
--- /dev/null
+++ b/io/getchar.c
@@ -0,0 +1,3 @@
+#include "io.h"
+
+int getchar(void) { return _fgetc_wrap(_stdstream_wrap(stream_input)); }
diff --git a/io/gets.c b/io/gets.c
new file mode 100644
index 0000000..0309181
--- /dev/null
+++ b/io/gets.c
@@ -0,0 +1,18 @@
+#include "io.h"
+#include <errno.h>
+
+char* gets(char *string)
+{
+ size_t i='\0';
+ for(int character = 0;character == '\n';i++){
+ character = getchar();
+ if(character == _eof_wrap){
+ return NULL;
+ }
+ string[i]=character;
+ }
+
+ string[++i]='\0';
+
+ return string;
+}
diff --git a/io/getwchar.c b/io/getwchar.c
new file mode 100644
index 0000000..a949a48
--- /dev/null
+++ b/io/getwchar.c
@@ -0,0 +1,4 @@
+#define NEED_WINT
+#include "io.h"
+
+wint_t getwchar(void) { return fgetwc(_stdstream_wrap(stream_input)); }
diff --git a/io/io.h b/io/io.h
new file mode 100644
index 0000000..488f589
--- /dev/null
+++ b/io/io.h
@@ -0,0 +1,54 @@
+#if !defined(IO_H)
+ #define IO_H
+
+ #include <stdarg.h>
+ #include <stddef.h>
+
+ #if __STDC_HOSTED__ == 1
+ #include "wrap/io.h"
+
+extern void setbuf(FILE *restrict, char *restrict);
+extern void rewind(FILE *);
+
+extern int getchar(void);
+extern int putchar(int);
+extern int puts(char const *restrict);
+extern int fputs(char const *restrict,FILE *restrict);
+
+ #if defined(NEED_WINT)
+extern wint_t getwchar(void);
+extern wint_t putwchar(wchar_t);
+ #endif
+
+extern void perror(char const *);
+
+extern int fprintf(FILE *, char const *restrict, ...);
+extern int printf(char const *restrict, ...);
+extern int snprintf(char *, size_t, char const *restrict, ...);
+extern int asprintf(char **restrict, char const *restrict, ...);
+extern int sprintf(char *, char const *restrict, ...);
+extern int vprintf(char const *restrict, va_list);
+extern int vsprintf(char *, char const *restrict, va_list);
+extern int vasprintf(char **restrict, char const *restrict, va_list);
+extern int fwprintf(FILE *, wchar_t const *restrict, ...);
+extern int wprintf(wchar_t const *restrict, ...);
+extern int swprintf(wchar_t *, size_t, wchar_t const *restrict, ...);
+extern int aswprintf(wchar_t **restrict, wchar_t const *restrict,
+ ...);
+extern int vwprintf(wchar_t const *restrict, va_list);
+extern int vaswprintf(wchar_t **restrict, wchar_t const *restrict,
+ va_list);
+
+extern int fscanf(FILE *, char const *restrict, ...);
+extern int scanf(char const *restrict, ...);
+extern int sscanf(char const *restrict, char const *restrict, ...);
+extern int vscanf(char const *restrict, va_list);
+extern int fwscanf(FILE *, wchar_t const *restrict, ...);
+extern int swscanf(wchar_t const *restrict, wchar_t const *restrict,
+ ...);
+extern int vwscanf(wchar_t const *restrict, va_list);
+extern int wscanf(wchar_t const *restrict, ...);
+
+ #endif
+
+#endif
diff --git a/io/meson.build b/io/meson.build
new file mode 100644
index 0000000..a815a56
--- /dev/null
+++ b/io/meson.build
@@ -0,0 +1,43 @@
+if is_hosted == 1
+subdir('wrap')
+sources += files(
+'io.h',
+'printf.c',
+'fprintf.c',
+'snprintf.c',
+'asprintf.c',
+'sprintf.c',
+'vprintf.c',
+'vsprintf.c',
+'wprinf.c',
+'fwprinf.c',
+'aswprintf.c',
+'swprintf.c',
+'vwprintf.c',
+'vaswprintf.c',
+'perror.c',
+'setbuf.c',
+'fread.c',
+'fwrite.c',
+'gets.c',
+'fgets.c',
+'getws.c',
+'fgetws.c',
+'getchar.c',
+'getwchar.c',
+'puts.c'
+'fputs.c'
+'putws.c'
+'fputws.c'
+'putchar.c',
+'putwchar.c',
+'scanf.c',
+'vwscanf.c',
+'vscanf.c',
+'swscanf.c',
+'sscanf.c',
+'fwscanf.c',
+'fscanf.c',
+'wscanf.c'
+)
+endif
diff --git a/io/perror.c b/io/perror.c
new file mode 100644
index 0000000..df8a09f
--- /dev/null
+++ b/io/perror.c
@@ -0,0 +1,10 @@
+#include "io.h"
+#include <errno.h>
+#include <string.h>
+
+void perror(char const *string)
+{
+
+ fprintf(_stdstream_wrap(stream_error), "%s: %s", string,
+ strerror(errno));
+}
diff --git a/io/printf.c b/io/printf.c
new file mode 100644
index 0000000..da4036d
--- /dev/null
+++ b/io/printf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int printf(char const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = vprintf(format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/putchar.c b/io/putchar.c
new file mode 100644
index 0000000..ecba6dc
--- /dev/null
+++ b/io/putchar.c
@@ -0,0 +1,6 @@
+#include "io.h"
+
+int putchar(int character)
+{
+ return _fputc_wrap(character, _stdstream_wrap(stream_output));
+}
diff --git a/io/puts.c b/io/puts.c
new file mode 100644
index 0000000..26c477f
--- /dev/null
+++ b/io/puts.c
@@ -0,0 +1,10 @@
+#include "io.h"
+#include <errno.h>
+
+int puts(char const *string)
+{
+ if (fputs(string, _stdstream_wrap(stream_output)) == _eof_wrap) {
+ return _eof_wrap;
+ }
+ return putchar('\n');
+}
diff --git a/io/putwchar.c b/io/putwchar.c
new file mode 100644
index 0000000..c4fdf47
--- /dev/null
+++ b/io/putwchar.c
@@ -0,0 +1,7 @@
+#define NEED_WINT
+#include "io.h"
+
+wint_t putwchar(wchar_t character)
+{
+ return fputwc(character, _stdstream_wrap(stream_output));
+}
diff --git a/io/rewind.c b/io/rewind.c
new file mode 100644
index 0000000..9e0d2ee
--- /dev/null
+++ b/io/rewind.c
@@ -0,0 +1,4 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+
+void rewind(FILE *stream) { fseek(stream, 0L, SEEK_SET); }
diff --git a/io/scanf.c b/io/scanf.c
new file mode 100644
index 0000000..51f6c10
--- /dev/null
+++ b/io/scanf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int scanf(char const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = vscanf(format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/setbuf.c b/io/setbuf.c
new file mode 100644
index 0000000..f401770
--- /dev/null
+++ b/io/setbuf.c
@@ -0,0 +1,8 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+
+void setbuf(FILE *restrict file, char *restrict buffer)
+{
+ (buffer == NULL) ? _setvbuf_wrap(file, NULL, _IONBF, 0)
+ : _setvbuf_wrap(file, buffer, _IOFBF, BUFSIZ);
+}
diff --git a/io/snprintf.c b/io/snprintf.c
new file mode 100644
index 0000000..c2a8f66
--- /dev/null
+++ b/io/snprintf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int snprintf(char *string, size_t max_size, char const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = _vsnprintf_wrap(string, max_size, format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/sprintf.c b/io/sprintf.c
new file mode 100644
index 0000000..cac6d80
--- /dev/null
+++ b/io/sprintf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int sprintf(char *string, char const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = vsprintf(string, format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/sscanf.c b/io/sscanf.c
new file mode 100644
index 0000000..0490a41
--- /dev/null
+++ b/io/sscanf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int sscanf(char const *restrict string, char const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = _vsscanf_wrap(string, format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/swprintf.c b/io/swprintf.c
new file mode 100644
index 0000000..6021dec
--- /dev/null
+++ b/io/swprintf.c
@@ -0,0 +1,11 @@
+#include "io.h"
+
+int swprintf(wchar_t *string, size_t max_size, wchar_t const *restrict format,
+ ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = _vswprintf_wrap(string, max_size, format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/swscanf.c b/io/swscanf.c
new file mode 100644
index 0000000..4605b26
--- /dev/null
+++ b/io/swscanf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int swscanf(wchar_t const *restrict string, wchar_t const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = _vswscanf_wrap(string, format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/vasprintf.c b/io/vasprintf.c
new file mode 100644
index 0000000..24f9332
--- /dev/null
+++ b/io/vasprintf.c
@@ -0,0 +1,18 @@
+#include "../memory.h"
+#include "io.h"
+
+int vasprintf(char **string, char const *restrict format, va_list arg)
+{
+ va_list tmp;
+ va_copy(tmp, arg);
+ int lenght = _vsnprintf_wrap(NULL, 0, format, tmp);
+ va_end(tmp);
+ if (lenght < 0) {
+ return 1;
+ }
+ *string = reallocarray(NULL, (size_t)lenght + 1, sizeof *string);
+ if (*string == NULL) {
+ return 1;
+ }
+ return _vsnprintf_wrap(*string, (size_t)lenght + 1, format, arg);
+}
diff --git a/io/vaswprintf.c b/io/vaswprintf.c
new file mode 100644
index 0000000..8568dfd
--- /dev/null
+++ b/io/vaswprintf.c
@@ -0,0 +1,18 @@
+#include "../memory.h"
+#include "io.h"
+
+int vaswprintf(wchar_t **string, wchar_t const *restrict format, va_list arg)
+{
+ va_list tmp;
+ va_copy(tmp, arg);
+ int lenght = _vswprintf_wrap(NULL, 0, format, tmp);
+ va_end(tmp);
+ if (lenght < 0) {
+ return 1;
+ }
+ *string = reallocarray(NULL, (size_t)lenght + 1, sizeof *string);
+ if (*string == NULL) {
+ return 1;
+ }
+ return _vswprintf_wrap(*string, (size_t)lenght + 1, format, arg);
+}
diff --git a/io/vprintf.c b/io/vprintf.c
new file mode 100644
index 0000000..406332e
--- /dev/null
+++ b/io/vprintf.c
@@ -0,0 +1,6 @@
+#include "io.h"
+
+int vprintf(char const *restrict format, va_list arg)
+{
+ return _vfprintf_wrap(_stdstream_wrap(stream_output), format, arg);
+}
diff --git a/io/vscanf.c b/io/vscanf.c
new file mode 100644
index 0000000..edeeacd
--- /dev/null
+++ b/io/vscanf.c
@@ -0,0 +1,6 @@
+#include "io.h"
+
+int vscanf(char const *restrict format, va_list arg)
+{
+ return _vfscanf_wrap(_stdstream_wrap(stream_input), format, arg);
+}
diff --git a/io/vsprintf.c b/io/vsprintf.c
new file mode 100644
index 0000000..e260f77
--- /dev/null
+++ b/io/vsprintf.c
@@ -0,0 +1,7 @@
+#include "io.h"
+#include <limits.h>
+
+int vsprintf(char *string, char const *restrict format, va_list arg)
+{
+ return _vsnprintf_wrap(string, INT_MAX, format, arg);
+}
diff --git a/io/vwprintf.c b/io/vwprintf.c
new file mode 100644
index 0000000..12d1fd6
--- /dev/null
+++ b/io/vwprintf.c
@@ -0,0 +1,6 @@
+#include "io.h"
+
+int vwprintf(wchar_t const *restrict format, va_list arg)
+{
+ return _vfwprintf_wrap(_stdstream_wrap(stream_output), format, arg);
+}
diff --git a/io/vwscanf.c b/io/vwscanf.c
new file mode 100644
index 0000000..9b74b2f
--- /dev/null
+++ b/io/vwscanf.c
@@ -0,0 +1,6 @@
+#include "io.h"
+
+int vwscanf(wchar_t const *restrict format, va_list arg)
+{
+ return _vfwscanf_wrap(_stdstream_wrap(stream_input), format, arg);
+}
diff --git a/io/wprinf.c b/io/wprinf.c
new file mode 100644
index 0000000..f441eda
--- /dev/null
+++ b/io/wprinf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int wprintf(wchar_t const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = vwprintf(format, arg);
+ va_end(arg);
+ return lenght;
+}
diff --git a/io/wrap/feof.c b/io/wrap/feof.c
new file mode 100644
index 0000000..6e4b42d
--- /dev/null
+++ b/io/wrap/feof.c
@@ -0,0 +1,11 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+#include <stdio.h>
+#include <wchar.h>
+
+int const _eof_wrap = EOF;
+wint_t const _weof_wrap = WEOF;
+
+int _feof_wrap(FILE *stream){
+ return feof(stream);
+}
diff --git a/io/wrap/fgetc.c b/io/wrap/fgetc.c
new file mode 100644
index 0000000..5c4de47
--- /dev/null
+++ b/io/wrap/fgetc.c
@@ -0,0 +1,4 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+
+int _fgetc_wrap(FILE *stream) { return getc(stream); }
diff --git a/io/wrap/fgetwc.c b/io/wrap/fgetwc.c
new file mode 100644
index 0000000..0b854e1
--- /dev/null
+++ b/io/wrap/fgetwc.c
@@ -0,0 +1,4 @@
+#define NEED_WINT
+#include "io.h"
+
+wint_t _fgetwc_wrap(FILE *stream) { return getc(stream); }
diff --git a/io/wrap/fputc.c b/io/wrap/fputc.c
new file mode 100644
index 0000000..5075f5b
--- /dev/null
+++ b/io/wrap/fputc.c
@@ -0,0 +1,7 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+
+int _fputc_wrap(int character, FILE *stream)
+{
+ return fputc(character, stream);
+}
diff --git a/io/wrap/fputwc.c b/io/wrap/fputwc.c
new file mode 100644
index 0000000..5075f5b
--- /dev/null
+++ b/io/wrap/fputwc.c
@@ -0,0 +1,7 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+
+int _fputc_wrap(int character, FILE *stream)
+{
+ return fputc(character, stream);
+}
diff --git a/io/wrap/io.h b/io/wrap/io.h
new file mode 100644
index 0000000..dc5a306
--- /dev/null
+++ b/io/wrap/io.h
@@ -0,0 +1,56 @@
+#if !defined(IO_WRAP_H)
+ #define IO_WRAP_H
+
+ #include <stdarg.h>
+ #include <stddef.h>
+
+ #if __STDC_HOSTED__ == 1
+
+ #if defined(NEED_WINT)
+ #include <wchar.h>
+ #define NO_OPAQUE_TYPE
+
+ #endif
+
+ #if defined(NO_OPAQUE_TYPE)
+ #include <stdio.h>
+ #else
+typedef struct {
+ char file;
+} FILE;
+ #endif
+
+#if defined(NEED_WINT)
+extern wint_t const weof;
+
+extern wint_t _fgetwc_wrap(FILE *);
+extern wint_t _fputwc_wrap(wint_t, FILE *);
+#endif
+
+extern int const _eof_wrap;
+
+extern int _feof_wrap(FILE *stream);
+
+extern int _setvbuf_wrap(FILE *restrict file, char *restrict buffer, int mode,
+ size_t size);
+
+extern int _fgetc_wrap(FILE *);
+extern int _fputc_wrap(int, FILE *);
+
+extern int _vfprintf_wrap(FILE *, char const *restrict, va_list);
+extern int _vsnprintf_wrap(char *, size_t, char const *restrict, va_list);
+extern int _vfwprintf_wrap(FILE *, wchar_t const *restrict, va_list);
+extern int _vswprintf_wrap(wchar_t *, size_t, wchar_t const *restrict, va_list);
+
+int _vfscanf_wrap(FILE *, char const *restrict, va_list);
+int _vsscanf_wrap(char const *restrict, char const *restrict, va_list);
+int _vfwscanf_wrap(FILE *, wchar_t const *restrict, va_list);
+int _vswscanf_wrap(wchar_t const *restrict, wchar_t const *restrict, va_list);
+
+enum stdstream_list { stream_input, stream_output, stream_error };
+
+FILE *_stdstream_wrap(enum stdstream_list);
+
+ #endif
+
+#endif
diff --git a/io/wrap/meson.build b/io/wrap/meson.build
new file mode 100644
index 0000000..10b47a2
--- /dev/null
+++ b/io/wrap/meson.build
@@ -0,0 +1,16 @@
+sources += files(
+'io.h',
+'fgetc.c',
+'fputc.c',
+'stdstream.c',
+'feof.c',
+'vsnprintf.c',
+'vfprintf.c',
+'setvbuf.c',
+'vfwprinf.c',
+'vswprintf.c',
+'vswscanf.c',
+'vsscanf.c',
+'vfwscanf.c',
+'vfscanf.c',
+)
diff --git a/io/wrap/setvbuf.c b/io/wrap/setvbuf.c
new file mode 100644
index 0000000..bd411d5
--- /dev/null
+++ b/io/wrap/setvbuf.c
@@ -0,0 +1,8 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+
+int _setvbuf_wrap(FILE *restrict file, char *restrict buffer, int mode,
+ size_t size)
+{
+ return setvbuf(file, buffer, mode, size);
+}
diff --git a/io/wrap/stdstream.c b/io/wrap/stdstream.c
new file mode 100644
index 0000000..0cc86a1
--- /dev/null
+++ b/io/wrap/stdstream.c
@@ -0,0 +1,16 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+#include <stdio.h>
+
+FILE *_stdstream_wrap(enum stdstream_list streams)
+{
+ switch (streams) {
+ case stream_input:
+ return stdin;
+ case stream_output:
+ return stdout;
+ case stream_error:
+ return stderr;
+ }
+ return NULL;
+}
diff --git a/io/wrap/vfprintf.c b/io/wrap/vfprintf.c
new file mode 100644
index 0000000..ae49dc3
--- /dev/null
+++ b/io/wrap/vfprintf.c
@@ -0,0 +1,7 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+
+int _vfprintf_wrap(FILE *stream, char const *restrict format, va_list arg)
+{
+ return vfprintf(stream, format, arg);
+}
diff --git a/io/wrap/vfscanf.c b/io/wrap/vfscanf.c
new file mode 100644
index 0000000..21181e1
--- /dev/null
+++ b/io/wrap/vfscanf.c
@@ -0,0 +1,7 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+
+int _vfscanf_wrap(FILE *stream, char const *restrict format, va_list arg)
+{
+ return vfscanf(stream, format, arg);
+}
diff --git a/io/wrap/vfwprinf.c b/io/wrap/vfwprinf.c
new file mode 100644
index 0000000..02e6e03
--- /dev/null
+++ b/io/wrap/vfwprinf.c
@@ -0,0 +1,8 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+#include <wchar.h>
+
+int _vfwprintf_wrap(FILE *stream, wchar_t const *restrict format, va_list arg)
+{
+ return vfwprintf(stream, format, arg);
+}
diff --git a/io/wrap/vfwscanf.c b/io/wrap/vfwscanf.c
new file mode 100644
index 0000000..86b884c
--- /dev/null
+++ b/io/wrap/vfwscanf.c
@@ -0,0 +1,8 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+#include <wchar.h>
+
+int _vfwscanf_wrap(FILE *stream, wchar_t const *restrict format, va_list arg)
+{
+ return vfwscanf(stream, format, arg);
+}
diff --git a/io/wrap/vsnprintf.c b/io/wrap/vsnprintf.c
new file mode 100644
index 0000000..efe2f85
--- /dev/null
+++ b/io/wrap/vsnprintf.c
@@ -0,0 +1,9 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+#include <wchar.h>
+
+int _vsnprintf_wrap(char *string, size_t max_size, char const *restrict format,
+ va_list arg)
+{
+ return vsnprintf(string, max_size, format, arg);
+}
diff --git a/io/wrap/vsscanf.c b/io/wrap/vsscanf.c
new file mode 100644
index 0000000..dd2bdb8
--- /dev/null
+++ b/io/wrap/vsscanf.c
@@ -0,0 +1,8 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+
+int _vsscanf_wrap(char const *restrict string, char const *restrict format,
+ va_list arg)
+{
+ return vsscanf(string, format, arg);
+}
diff --git a/io/wrap/vswprintf.c b/io/wrap/vswprintf.c
new file mode 100644
index 0000000..8046634
--- /dev/null
+++ b/io/wrap/vswprintf.c
@@ -0,0 +1,9 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+#include <wchar.h>
+
+int _vswprintf_wrap(wchar_t *string, size_t max_size,
+ wchar_t const *restrict format, va_list arg)
+{
+ return vswprintf(string, max_size, format, arg);
+}
diff --git a/io/wrap/vswscanf.c b/io/wrap/vswscanf.c
new file mode 100644
index 0000000..675596a
--- /dev/null
+++ b/io/wrap/vswscanf.c
@@ -0,0 +1,9 @@
+#define NO_OPAQUE_TYPE
+#include "io.h"
+#include <wchar.h>
+
+int _vswscanf_wrap(wchar_t const *restrict string,
+ wchar_t const *restrict format, va_list arg)
+{
+ return vswscanf(string, format, arg);
+}
diff --git a/io/wscanf.c b/io/wscanf.c
new file mode 100644
index 0000000..beb021a
--- /dev/null
+++ b/io/wscanf.c
@@ -0,0 +1,10 @@
+#include "io.h"
+
+int wscanf(wchar_t const *restrict format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ int lenght = vwscanf(format, arg);
+ va_end(arg);
+ return lenght;
+}