+ /* FIXME: This is ad-hoc (to make the vprintf() testdriver work), and must be checked. */
+ /* FIXME: If filename is NULL, change mode. */
+ /* TODO: This function can change wide orientation of a stream */
+ if ( filename == NULL ) return NULL;
+ if ( stream->status & _PDCLIB_WROTELAST ) fflush( stream );
+ if ( stream->status & _PDCLIB_LIBBUFFER ) free( stream->buffer );
+ _PDCLIB_close( stream->handle );
+ clearerr( stream );
+ if ( ( mode == NULL ) || ( filename[0] == '\0' ) ) return NULL;
+ if ( ( stream->status = _PDCLIB_filemode( mode ) ) == 0 ) return NULL;
+ stream->handle = _PDCLIB_open( filename, stream->status );
+ if ( ( stream->buffer = malloc( BUFSIZ ) ) == NULL ) return NULL;
+ stream->bufsize = BUFSIZ;
+ stream->bufidx = 0;
+ stream->status |= ( _PDCLIB_LIBBUFFER | _PDCLIB_VIRGINSTR );
+ /* TODO: Setting mbstate */
+ return stream;