3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
12 #include <_PDCLIB_io.h>
15 static char _PDCLIB_sin_buffer[BUFSIZ];
16 static char _PDCLIB_sout_buffer[BUFSIZ];
17 static char _PDCLIB_serr_buffer[BUFSIZ];
19 static unsigned char _PDCLIB_sin_ungetbuf[_PDCLIB_UNGETCBUFSIZE];
20 static unsigned char _PDCLIB_sout_ungetbuf[_PDCLIB_UNGETCBUFSIZE];
21 static unsigned char _PDCLIB_serr_ungetbuf[_PDCLIB_UNGETCBUFSIZE];
23 extern _PDCLIB_fileops_t _PDCLIB_fileops;
25 static FILE _PDCLIB_serr = {
26 .ops = &_PDCLIB_fileops,
27 .handle = { .pointer = NULL },
28 .buffer = _PDCLIB_serr_buffer,
33 .ungetbuf = _PDCLIB_serr_ungetbuf,
34 .status = _IONBF | _PDCLIB_FWRITE | _PDCLIB_STATIC,
38 static FILE _PDCLIB_sout = {
39 .ops = &_PDCLIB_fileops,
40 .handle = { .pointer = NULL },
41 .buffer = _PDCLIB_sout_buffer,
46 .ungetbuf = _PDCLIB_sout_ungetbuf,
47 .status = _IOLBF | _PDCLIB_FWRITE | _PDCLIB_STATIC,
51 static FILE _PDCLIB_sin = {
52 .ops = &_PDCLIB_fileops,
53 .handle = { .pointer = NULL },
54 .buffer = _PDCLIB_sin_buffer,
59 .ungetbuf = _PDCLIB_sin_ungetbuf,
60 .status = _IOLBF | _PDCLIB_FREAD | _PDCLIB_STATIC,
65 FILE * stdin = &_PDCLIB_sin;
66 FILE * stdout = &_PDCLIB_sout;
67 FILE * stderr = &_PDCLIB_serr;
69 FILE * _PDCLIB_filelist = &_PDCLIB_sin;
71 /* Todo: Better solution than this! */
72 __attribute__((constructor)) static void init_stdio(void)
74 _PDCLIB_initclocale( &_PDCLIB_global_locale );
75 mtx_init(&stdin->lock, mtx_recursive);
76 mtx_init(&stdout->lock, mtx_recursive);
77 mtx_init(&stderr->lock, mtx_recursive);
83 #include <_PDCLIB_test.h>
87 /* Testing covered by several other testdrivers using stdin / stdout /