1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
8 int setvbuf( FILE * restrict stream, char * restrict buf, int mode, size_t size ) { /* TODO */ };
10 /* PDPC code - unreviewed
12 NULL + F = allocate, setup
13 NULL + L = allocate, setup
14 NULL + N = ignore, return success
17 buf + N = ignore, return success
20 int setvbuf(FILE *stream, char *buf, int mode, size_t size)
26 stream->bufTech = mode;
35 mybuf = malloc(size + 8);
48 stream->theirBuffer = 1;
51 free(stream->intBuffer);
52 stream->intBuffer = mybuf;
53 stream->fbuf = stream->intBuffer + 2;
54 *stream->fbuf++ = '\0';
55 *stream->fbuf++ = '\0';
56 stream->szfbuf = size;
57 stream->endbuf = stream->fbuf + stream->szfbuf;
58 *stream->endbuf = '\n';
59 stream->upto = stream->endbuf;
60 stream->bufTech = mode;
61 if (!stream->textMode && (stream->bufTech == _IOLBF))