diff options
Diffstat (limited to 'io/wrap')
-rw-r--r-- | io/wrap/feof.c | 11 | ||||
-rw-r--r-- | io/wrap/fgetc.c | 4 | ||||
-rw-r--r-- | io/wrap/fgetwc.c | 4 | ||||
-rw-r--r-- | io/wrap/fputc.c | 7 | ||||
-rw-r--r-- | io/wrap/fputwc.c | 7 | ||||
-rw-r--r-- | io/wrap/io.h | 56 | ||||
-rw-r--r-- | io/wrap/meson.build | 16 | ||||
-rw-r--r-- | io/wrap/setvbuf.c | 8 | ||||
-rw-r--r-- | io/wrap/stdstream.c | 16 | ||||
-rw-r--r-- | io/wrap/vfprintf.c | 7 | ||||
-rw-r--r-- | io/wrap/vfscanf.c | 7 | ||||
-rw-r--r-- | io/wrap/vfwprinf.c | 8 | ||||
-rw-r--r-- | io/wrap/vfwscanf.c | 8 | ||||
-rw-r--r-- | io/wrap/vsnprintf.c | 9 | ||||
-rw-r--r-- | io/wrap/vsscanf.c | 8 | ||||
-rw-r--r-- | io/wrap/vswprintf.c | 9 | ||||
-rw-r--r-- | io/wrap/vswscanf.c | 9 |
17 files changed, 194 insertions, 0 deletions
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); +} |