X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2F_PDCLIB_fvopen.c;h=2a5720948cd10251b4e5e07eb3ca47d7e7079fa5;hb=f9b8c76d675d875b891340021fdf0f06c2cf2812;hp=466009b04d070f069a28d1aa8899f57ff39f0cce;hpb=c5d49235e09fbd58416f10dec2799e61cf3431c8;p=pdclib diff --git a/functions/stdio/_PDCLIB_fvopen.c b/functions/stdio/_PDCLIB_fvopen.c index 466009b..2a57209 100644 --- a/functions/stdio/_PDCLIB_fvopen.c +++ b/functions/stdio/_PDCLIB_fvopen.c @@ -11,18 +11,21 @@ #ifndef REGTEST #include <_PDCLIB_glue.h> +#include <_PDCLIB_io.h> #include #include -extern struct _PDCLIB_file_t * _PDCLIB_filelist; +extern FILE * _PDCLIB_filelist; -struct _PDCLIB_file_t * _PDCLIB_fvopen( _PDCLIB_fd_t fd, - const _PDCLIB_fileops_t * ops, - int mode, - const char * _PDCLIB_restrict filename ) +FILE * _PDCLIB_fvopen( + _PDCLIB_fd_t fd, + const _PDCLIB_fileops_t *_PDCLIB_restrict ops, + int mode, + const char *_PDCLIB_restrict filename +) { size_t filename_len; - struct _PDCLIB_file_t * rc; + FILE * rc; if ( mode == NULL ) { /* Mode invalid */ @@ -36,7 +39,7 @@ struct _PDCLIB_file_t * _PDCLIB_fvopen( _PDCLIB_fd_t fd, Data buffer comes last because it might change in size ( setvbuf() ). */ filename_len = filename ? strlen( filename ) + 1 : 1; - if ( ( rc = calloc( 1, sizeof( struct _PDCLIB_file_t ) + _PDCLIB_UNGETCBUFSIZE + filename_len + BUFSIZ ) ) == NULL ) + if ( ( rc = calloc( 1, sizeof( FILE ) + _PDCLIB_UNGETCBUFSIZE + filename_len + BUFSIZ ) ) == NULL ) { /* no memory */ return NULL; @@ -51,7 +54,7 @@ struct _PDCLIB_file_t * _PDCLIB_fvopen( _PDCLIB_fd_t fd, rc->ops = ops; rc->handle = fd; /* Setting pointers into the memory block allocated above */ - rc->ungetbuf = (unsigned char *)rc + sizeof( struct _PDCLIB_file_t ); + rc->ungetbuf = (unsigned char *)rc + sizeof( FILE ); rc->filename = (char *)rc->ungetbuf + _PDCLIB_UNGETCBUFSIZE; rc->buffer = rc->filename + filename_len; /* Copying filename to FILE structure */ @@ -59,6 +62,9 @@ struct _PDCLIB_file_t * _PDCLIB_fvopen( _PDCLIB_fd_t fd, /* Initializing the rest of the structure */ rc->bufsize = BUFSIZ; rc->bufidx = 0; +#ifdef _PDCLIB_NEED_EOL_TRANSLATION + rc->bufnlexp = 0; +#endif 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