]> pd.if.org Git - pdclib/blobdiff - functions/stdio/_PDCLIB_fvopen.c
PDCLib includes with quotes, not <>.
[pdclib] / functions / stdio / _PDCLIB_fvopen.c
index 466009b04d070f069a28d1aa8899f57ff39f0cce..307d0c9cc04a38fb879005ff0f080800128934fd 100644 (file)
@@ -1,6 +1,4 @@
-/* $Id$ */\r
-\r
-/* _PDCLIB_fvopen( _PDCLIB_fd_t fd, _PDCLIB_fileops_t *  )\r
+/* _PDCLIB_fvopen( _PDCLIB_fd_t, _PDCLIB_fileops_t * )\r
 \r
    This file is part of the Public Domain C Library (PDCLib).\r
    Permission is granted to use, modify, and / or redistribute at will.\r
 #include <stdlib.h>\r
 \r
 #ifndef REGTEST\r
-#include <_PDCLIB_glue.h>\r
+#include "_PDCLIB_glue.h"\r
+#include "_PDCLIB_io.h"\r
 #include <string.h>\r
 #include <threads.h>\r
 \r
-extern struct _PDCLIB_file_t * _PDCLIB_filelist;\r
+extern FILE * _PDCLIB_filelist;\r
 \r
-struct _PDCLIB_file_t * _PDCLIB_fvopen( _PDCLIB_fd_t               fd, \r
-                                        const _PDCLIB_fileops_t *  ops,\r
-                                        int mode,\r
-                                        const char * _PDCLIB_restrict filename )\r
+FILE * _PDCLIB_fvopen(\r
+    _PDCLIB_fd_t                                    fd,\r
+    const _PDCLIB_fileops_t    *_PDCLIB_restrict    ops,\r
+    int                                             mode,\r
+    const char                  *_PDCLIB_restrict   filename\r
+)\r
 {\r
     size_t filename_len;\r
-    struct _PDCLIB_file_t * rc;\r
+    FILE * rc;\r
     if ( mode == NULL )\r
     {\r
         /* Mode invalid */\r
@@ -36,7 +37,7 @@ struct _PDCLIB_file_t * _PDCLIB_fvopen( _PDCLIB_fd_t               fd,
        Data buffer comes last because it might change in size ( setvbuf() ).\r
     */\r
     filename_len = filename ? strlen( filename ) + 1 : 1;\r
-    if ( ( rc = calloc( 1, sizeof( struct _PDCLIB_file_t ) + _PDCLIB_UNGETCBUFSIZE + filename_len + BUFSIZ ) ) == NULL )\r
+    if ( ( rc = calloc( 1, sizeof( FILE ) + _PDCLIB_UNGETCBUFSIZE + filename_len + BUFSIZ ) ) == NULL )\r
     {\r
         /* no memory */\r
         return NULL;\r
@@ -51,7 +52,7 @@ struct _PDCLIB_file_t * _PDCLIB_fvopen( _PDCLIB_fd_t               fd,
     rc->ops    = ops;\r
     rc->handle = fd;\r
     /* Setting pointers into the memory block allocated above */\r
-    rc->ungetbuf = (unsigned char *)rc + sizeof( struct _PDCLIB_file_t );\r
+    rc->ungetbuf = (unsigned char *)rc + sizeof( FILE );\r
     rc->filename = (char *)rc->ungetbuf + _PDCLIB_UNGETCBUFSIZE;\r
     rc->buffer   = rc->filename + filename_len;\r
     /* Copying filename to FILE structure */\r
@@ -59,6 +60,9 @@ struct _PDCLIB_file_t * _PDCLIB_fvopen( _PDCLIB_fd_t               fd,
     /* Initializing the rest of the structure */\r
     rc->bufsize = BUFSIZ;\r
     rc->bufidx = 0;\r
+#ifdef _PDCLIB_NEED_EOL_TRANSLATION\r
+    rc->bufnlexp = 0;\r
+#endif\r
     rc->ungetidx = 0;\r
     /* Setting buffer to _IOLBF because "when opened, a stream is fully\r
        buffered if and only if it can be determined not to refer to an\r
@@ -75,7 +79,7 @@ struct _PDCLIB_file_t * _PDCLIB_fvopen( _PDCLIB_fd_t               fd,
 #endif\r
 \r
 #ifdef TEST\r
-#include <_PDCLIB_test.h>\r
+#include "_PDCLIB_test.h"\r
 \r
 int main( void )\r
 {\r