X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=platform%2Fexample%2Ffunctions%2F_PDCLIB%2Fstdinit.c;h=160dac3440412b9d84a31b1b89c5280ec7ff05c4;hb=b42a534f135f12fe47a6bc343bb6cc2c0e973198;hp=f83bc4fd236ea7c566e6442b0117449c4516987c;hpb=09ff30533049a7dc3dfcbe615b8d7859d0d4aefc;p=pdclib.old diff --git a/platform/example/functions/_PDCLIB/stdinit.c b/platform/example/functions/_PDCLIB/stdinit.c index f83bc4f..160dac3 100644 --- a/platform/example/functions/_PDCLIB/stdinit.c +++ b/platform/example/functions/_PDCLIB/stdinit.c @@ -18,17 +18,19 @@ /* In a POSIX system, stdin / stdout / stderr are equivalent to the (int) file descriptors 0, 1, and 2 respectively. */ -#if 0 -/* FIXME: Disabled for initial stdio.h development. */ /* TODO: This is proof-of-concept, requires finetuning. */ -static struct _PDCLIB_file_t _PDCLIB_sin = { 0, { 0, 0 }, 0, 0, 0, /* mbstate, */ 0 }; -static struct _PDCLIB_file_t _PDCLIB_sout = { 1, { 0, 0 }, 0, 0, 0, /* mbstate, */ 0 }; -static struct _PDCLIB_file_t _PDCLIB_serr = { 2, { 0, 0 }, 0, 0, 0, /* mbstate, */ 0 }; +static char _PDCLIB_sin_buffer[BUFSIZ]; +static char _PDCLIB_sout_buffer[BUFSIZ]; +static char _PDCLIB_serr_buffer[BUFSIZ]; + +/* FIXME: serr should handle one character. Buffering on out / in? */ +static struct _PDCLIB_file_t _PDCLIB_serr = { 2, { 0 }, _PDCLIB_serr_buffer, BUFSIZ, 0, _IONBF, /* mbstate, */ NULL }; +static struct _PDCLIB_file_t _PDCLIB_sout = { 1, { 0 }, _PDCLIB_sout_buffer, BUFSIZ, 0, _IOLBF, /* mbstate, */ &_PDCLIB_serr }; +static struct _PDCLIB_file_t _PDCLIB_sin = { 0, { 0 }, _PDCLIB_sin_buffer, BUFSIZ, 0, _IOLBF, /* mbstate, */ &_PDCLIB_sout }; struct _PDCLIB_file_t * stdin = &_PDCLIB_sin; struct _PDCLIB_file_t * stdout = &_PDCLIB_sout; struct _PDCLIB_file_t * stderr = &_PDCLIB_serr; -#endif #endif