- /* Setting pointers into the memory block allocated above */
- rc->ungetbuf = (unsigned char *)rc + sizeof( struct _PDCLIB_file_t );
- rc->filename = (char *)rc->ungetbuf + _PDCLIB_UNGETCBUFSIZE;
- rc->buffer = rc->filename + filename_len;
- /* Copying filename to FILE structure */
- strcpy( rc->filename, filename );
- /* Initializing the rest of the structure */
- rc->bufsize = BUFSIZ;
- rc->bufidx = 0;
- rc->ungetidx = 0;
- /* Setting buffer to _IOLBF because "when opened, a stream is fully
- buffered if and only if it can be determined not to refer to an
- interactive device."
- */
- rc->status |= _PDCLIB_LIBBUFFER | _IOLBF;
- /* TODO: Setting mbstate */
- /* Adding to list of open files */
- rc->next = _PDCLIB_filelist;
- _PDCLIB_filelist = rc;
- return rc;