]> pd.if.org Git - pdclib.old/commitdiff
Minimize the amount of internal definitions which get exposed via the user-visible...
authorOwen Shepherd <owen.shepherd@e43.eu>
Mon, 31 Dec 2012 14:15:18 +0000 (14:15 +0000)
committerOwen Shepherd <owen.shepherd@e43.eu>
Mon, 31 Dec 2012 14:15:18 +0000 (14:15 +0000)
61 files changed:
functions/_PDCLIB/_PDCLIB_closeall.c
functions/stdio/_PDCLIB_fillbuffer.c
functions/stdio/_PDCLIB_flushbuffer.c
functions/stdio/_PDCLIB_ftell64.c
functions/stdio/_PDCLIB_fvopen.c
functions/stdio/_PDCLIB_prepread.c
functions/stdio/_PDCLIB_prepwrite.c
functions/stdio/_PDCLIB_seek.c
functions/stdio/clearerr.c
functions/stdio/fclose.c
functions/stdio/feof.c
functions/stdio/ferror.c
functions/stdio/fflush.c
functions/stdio/fgetc.c
functions/stdio/fgetpos.c
functions/stdio/fgets.c
functions/stdio/flockfile.c
functions/stdio/fopen.c
functions/stdio/fprintf.c
functions/stdio/fputc.c
functions/stdio/fputs.c
functions/stdio/fread.c
functions/stdio/freopen.c
functions/stdio/fseek.c
functions/stdio/fsetpos.c
functions/stdio/ftell.c
functions/stdio/ftrylockfile.c
functions/stdio/funlockfile.c
functions/stdio/fwrite.c
functions/stdio/getc.c
functions/stdio/gets.c
functions/stdio/perror.c
functions/stdio/printf.c
functions/stdio/putc.c
functions/stdio/rename.c
functions/stdio/rewind.c
functions/stdio/setbuf.c
functions/stdio/setvbuf.c
functions/stdio/tmpnam.c
functions/stdio/ungetc.c
functions/stdio/vfprintf.c
functions/stdio/vfscanf.c
functions/stdio/vsnprintf.c
functions/stdio/vsscanf.c
functions/stdlib/exit.c
includes/stdio.h
includes/threads.h
includes/uchar.h
includes/wchar.h
internals/_PDCLIB_aux.h
internals/_PDCLIB_encoding.h
internals/_PDCLIB_float.h
internals/_PDCLIB_glue.h
internals/_PDCLIB_int.h
internals/_PDCLIB_io.h
opt/basecodecs/_PDCLIB_ascii.c
opt/basecodecs/_PDCLIB_latin1.c
opt/basecodecs/_PDCLIB_utf8.c
platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c
platform/posix/functions/stdio/remove.c
platform/win32/functions/_PDCLIB/_PDCLIB_stdinit.c

index 5086d0d64bb09305245cc10692cc2a291978b8a7..bc6b417f88871cb0eeb4c16dae0f58c898419a65 100644 (file)
@@ -7,14 +7,15 @@
 */
 
 #include <stdio.h>
+#include <_PDCLIB_io.h>
 
 #ifndef REGTEST
-extern struct _PDCLIB_file_t * _PDCLIB_filelist;
+extern _PDCLIB_file_t * _PDCLIB_filelist;
 
 void _PDCLIB_closeall( void )
 {
-    struct _PDCLIB_file_t * stream = _PDCLIB_filelist;
-    struct _PDCLIB_file_t * next;
+    _PDCLIB_file_t * stream = _PDCLIB_filelist;
+    _PDCLIB_file_t * next;
     while ( stream != NULL )
     {
         next = stream->next;
index dfdfe262510d858043e23bfb3a30505271bbb2f0..70df158e32fa20e18d1363736674285547e99718 100644 (file)
@@ -1,4 +1,4 @@
-/* _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream )\r
+/* _PDCLIB_fillbuffer( FILE * stream )\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
@@ -8,8 +8,9 @@
 \r
 #ifndef REGTEST\r
 #include <_PDCLIB_glue.h>\r
+#include <_PDCLIB_io.h>\r
 \r
-int _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream )\r
+int _PDCLIB_fillbuffer( FILE * stream )\r
 {\r
     size_t bytesRead;\r
     bool ok = stream->ops->read( stream->handle, stream->buffer, stream->bufsize,\r
index ffbbb4f088c88ef84767a056e3570fd7c78055a4..7ee0d93c35730aa08b1baaa28128d2e735f23f16 100644 (file)
@@ -9,8 +9,9 @@
 \r
 #ifndef REGTEST\r
 #include <_PDCLIB_glue.h>\r
+#include <_PDCLIB_io.h>\r
 \r
-int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream )\r
+int _PDCLIB_flushbuffer( FILE * stream )\r
 {\r
     if ( ! ( stream->status & _PDCLIB_FBIN ) )\r
     {\r
index e0ea368e757e35b81bcdf0d606f7a283520b8971..5be7be50692096453aa3f9f03fe1f6a53c56b56d 100644 (file)
@@ -11,8 +11,9 @@
 #include <limits.h>\r
 \r
 #ifndef REGTEST\r
+#include <_PDCLIB_io.h>\r
 \r
-uint_fast64_t _PDCLIB_ftell64_unlocked( struct _PDCLIB_file_t * stream )\r
+uint_fast64_t _PDCLIB_ftell64_unlocked( FILE * stream )\r
 {\r
     /* ftell() must take into account:\r
        - the actual *physical* offset of the file, i.e. the offset as recognized\r
@@ -38,7 +39,7 @@ uint_fast64_t _PDCLIB_ftell64_unlocked( struct _PDCLIB_file_t * stream )
     return ( stream->pos.offset - ( ( (int)stream->bufend - (int)stream->bufidx ) + (int)stream->ungetidx ) );\r
 }\r
 \r
-uint_fast64_t _PDCLIB_ftell64( struct _PDCLIB_file_t * stream )\r
+uint_fast64_t _PDCLIB_ftell64( FILE * stream )\r
 {\r
   flockfile( stream );\r
   uint_fast64_t pos = _PDCLIB_ftell64_unlocked( stream );\r
index 466009b04d070f069a28d1aa8899f57ff39f0cce..4fc98ffe610fcc86845073d7bfa6e4964a73138b 100644 (file)
 \r
 #ifndef REGTEST\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 +39,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 +54,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
index cf1c2dfe53b7948d0b68619021fd72a6062b9569..22158d561d367c95f02add73a3425d5962d9fbc5 100644 (file)
@@ -1,6 +1,6 @@
 /* $Id$ */
 
-/* _PDCLIB_prepread( struct _PDCLIB_file_t * )
+/* _PDCLIB_prepread( FILE * )
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
@@ -12,7 +12,7 @@
 #ifndef REGTEST
 #include <_PDCLIB_glue.h>
 
-int _PDCLIB_prepread( struct _PDCLIB_file_t * stream )
+int _PDCLIB_prepread( FILE * stream )
 {
     if ( ( stream->bufidx > stream->bufend ) ||
          ( stream->status & ( _PDCLIB_FWRITE | _PDCLIB_FAPPEND | _PDCLIB_ERRORFLAG | _PDCLIB_WIDESTREAM | _PDCLIB_EOFFLAG ) ) ||
index 1b1c4b526eecceee5105e9ef544aa761d2928bcc..48440e737cfb932809cdfceec9f8473eb875d296 100644 (file)
@@ -1,6 +1,6 @@
 /* $Id$ */
 
-/* _PDCLIB_prepwrite( struct _PDCLIB_file_t * )
+/* _PDCLIB_prepwrite( FILE * )
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
@@ -10,7 +10,9 @@
 #include <errno.h>
 
 #ifndef REGTEST
-int _PDCLIB_prepwrite( struct _PDCLIB_file_t * stream )
+#include <_PDCLIB_io.h>
+   
+int _PDCLIB_prepwrite( FILE * stream )
 {
     if ( ( stream->bufidx < stream->bufend ) || ( stream->ungetidx > 0 ) ||
          ( stream->status & ( _PDCLIB_FREAD | _PDCLIB_ERRORFLAG | _PDCLIB_WIDESTREAM | _PDCLIB_EOFFLAG ) ) ||
index 42c3273780fd8ec2f66027be4f9b387259c9e568..52bb032a390479999348fbd2b36537c2dc3bd13d 100644 (file)
@@ -8,8 +8,9 @@
 #include <stdint.h>\r
 #include <errno.h>\r
 #ifndef REGTEST\r
+#include <_PDCLIB_io.h>\r
 \r
-int_fast64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, \r
+int_fast64_t _PDCLIB_seek( FILE * stream, \r
                            int_fast64_t offset, \r
                            int whence )\r
 {\r
index 2b032bd21833c8ff8b7e631882b6cbd1d9339c5e..20af80f298b4a1e792e6e8de80b5cce58f4e977a 100644 (file)
@@ -9,13 +9,14 @@
 #include <stdio.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
-void clearerr_unlocked( struct _PDCLIB_file_t * stream )
+void clearerr_unlocked( FILE * stream )
 {
     stream->status &= ~( _PDCLIB_ERRORFLAG | _PDCLIB_EOFFLAG );
 }
 
-void clearerr( struct _PDCLIB_file_t * stream )
+void clearerr( FILE * stream )
 {
     flockfile( stream );
     clearerr_unlocked( stream );
index 3d9e25724f45bdf58de3ee14ba16d183af0bb0fa..945241318afe09c8012d812412621ba50e13338c 100644 (file)
 #include <errno.h>
 
 #ifndef REGTEST
-#include <_PDCLIB_glue.h>
+#include <_PDCLIB_io.h>
 #include <threads.h>
 
-extern struct _PDCLIB_file_t * _PDCLIB_filelist;
+extern FILE * _PDCLIB_filelist;
 
-int fclose( struct _PDCLIB_file_t * stream )
+int fclose( FILE * stream )
 {
-    struct _PDCLIB_file_t * current = _PDCLIB_filelist;
-    struct _PDCLIB_file_t * previous = NULL;
+    FILE * current = _PDCLIB_filelist;
+    FILE * previous = NULL;
     /* Checking that the FILE handle is actually one we had opened before. */
     while ( current != NULL )
     {
@@ -78,8 +78,8 @@ int fclose( struct _PDCLIB_file_t * stream )
 int main( void )
 {
 #ifndef REGTEST
-    struct _PDCLIB_file_t * file1;
-    struct _PDCLIB_file_t * file2;
+    FILE * file1;
+    FILE * file2;
     remove( testfile1 );
     remove( testfile2 );
     TESTCASE( _PDCLIB_filelist == stdin );
index ca43c75532bd4d06b3c83607597575faa7d25976..b37c7b94dd0bdffbf734eaba24d4aaf9a15ed384 100644 (file)
@@ -9,13 +9,14 @@
 #include <stdio.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
-int feof_unlocked( struct _PDCLIB_file_t * stream )
+int feof_unlocked( FILE * stream )
 {
     return stream->status & _PDCLIB_EOFFLAG;
 }
 
-int feof( struct _PDCLIB_file_t * stream )
+int feof( FILE * stream )
 {
     flockfile( stream );
     int eof = feof_unlocked( stream );
index 394dcda2bc7dd07dee9cad93b61dfd95ec50ddd1..f683787e567975ad8cd759b58bee255a16ddc990 100644 (file)
@@ -9,13 +9,14 @@
 #include <stdio.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
-int ferror_unlocked( struct _PDCLIB_file_t * stream )
+int ferror_unlocked( FILE * stream )
 {
     return stream->status & _PDCLIB_ERRORFLAG;
 }
 
-int ferror( struct _PDCLIB_file_t * stream )
+int ferror( FILE * stream )
 {
     flockfile( stream );
     int error = ferror_unlocked( stream );
index df458804dc3099274f024286c3c55db2091418d8..e03079fcc9c17fdf661a961b77fdbec46cbbab60 100644 (file)
@@ -9,11 +9,11 @@
 #include <stdio.h>
 
 #ifndef REGTEST
-#include <_PDCLIB_glue.h>
+#include <_PDCLIB_io.h>
 
-extern struct _PDCLIB_file_t * _PDCLIB_filelist;
+extern FILE * _PDCLIB_filelist;
 
-int fflush_unlocked( struct _PDCLIB_file_t * stream )
+int fflush_unlocked( FILE * stream )
 {
     if ( stream == NULL )
     {
@@ -39,7 +39,7 @@ int fflush_unlocked( struct _PDCLIB_file_t * stream )
     }
 }
 
-int fflush( struct _PDCLIB_file_t * stream )
+int fflush( FILE * stream )
 {
     flockfile( stream );
     int res = fflush_unlocked(stream);
index 61f52fdd4208a84a3000a1e937619d92191b85b7..56e96f5eca481fbdf88136fe42ffa5c03d29dcf5 100644 (file)
@@ -9,10 +9,9 @@
 #include <stdio.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
-#include <_PDCLIB_glue.h>
-
-int fgetc_unlocked( struct _PDCLIB_file_t * stream )
+int fgetc_unlocked( FILE * stream )
 {
     if ( _PDCLIB_prepread( stream ) == EOF )
     {
@@ -26,7 +25,7 @@ int fgetc_unlocked( struct _PDCLIB_file_t * stream )
     return n == 0 ? EOF : (unsigned char) c;
 }
 
-int fgetc( struct _PDCLIB_file_t * stream )
+int fgetc( FILE * stream )
 {
     flockfile( stream );
     int c = fgetc_unlocked( stream );
index 28352c87e9a3cd53767f2ec9ca65666ff40dc624..84014063ea18ec838130bc056a054c147417e92a 100644 (file)
@@ -9,16 +9,17 @@
 #include <stdio.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
-int fgetpos_unlocked( struct _PDCLIB_file_t * _PDCLIB_restrict stream, struct _PDCLIB_fpos_t * _PDCLIB_restrict pos )
+int fgetpos_unlocked( FILE * _PDCLIB_restrict stream, _PDCLIB_fpos_t * _PDCLIB_restrict pos )
 {
     pos->offset = stream->pos.offset + stream->bufidx - stream->ungetidx;
-    pos->status = stream->pos.status;
+    pos->mbs    = stream->pos.mbs;
     /* TODO: Add mbstate. */
     return 0;
 }
 
-int fgetpos( struct _PDCLIB_file_t * _PDCLIB_restrict stream, struct _PDCLIB_fpos_t * _PDCLIB_restrict pos )
+int fgetpos( FILE * _PDCLIB_restrict stream, _PDCLIB_fpos_t * _PDCLIB_restrict pos )
 {
     flockfile( stream );
     int res = fgetpos_unlocked( stream, pos );
index 6fbc2ef7961509b7e0c93aeae610d001f1a84f90..95103bb2ad753f8d9430a1af6be9208dea4babb3 100644 (file)
@@ -9,10 +9,9 @@
 #include <stdio.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
-#include <_PDCLIB_glue.h>
-
-char * fgets_unlocked( char * _PDCLIB_restrict s, int size, struct _PDCLIB_file_t * _PDCLIB_restrict stream )
+char * fgets_unlocked( char * _PDCLIB_restrict s, int size, FILE * _PDCLIB_restrict stream )
 {
     if ( size == 0 )
     {
@@ -36,7 +35,7 @@ char * fgets_unlocked( char * _PDCLIB_restrict s, int size, struct _PDCLIB_file_
 }
 
 char * fgets( char * _PDCLIB_restrict s, int size, 
-              struct _PDCLIB_file_t * _PDCLIB_restrict stream )
+              FILE * _PDCLIB_restrict stream )
 {
     flockfile( stream );
     char* r = fgets_unlocked( s, size, stream );
index 4e80daf589b66a2563c44b704f6ea8a5a5943e93..9167da097dcd116a44dc6efca497cc2e8a435a94 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdarg.h>\r
 \r
 #ifndef REGTEST\r
+#include <_PDCLIB_io.h>\r
 #include <threads.h>\r
 #include <stdlib.h>\r
 \r
index e806b00a2ef76c31879a2aa0a19b55b368962aa6..5bcf5d81fe95d17e9406017676d24ff6a886ebcf 100644 (file)
 #include <stdlib.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 #include <_PDCLIB_glue.h>
 #include <string.h>
 #include <errno.h>
 
-extern struct _PDCLIB_file_t * _PDCLIB_filelist;
+extern FILE * _PDCLIB_filelist;
 
 FILE * fopen( const char * _PDCLIB_restrict filename, 
               const char * _PDCLIB_restrict mode )
index 421ca5273f8e153f763c12b0b4399e1f008c1b2a..0227cd4d17ad520dfb99bc21160d060f0ccb93bb 100644 (file)
@@ -10,8 +10,9 @@
 #include <stdarg.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
-int fprintf_unlocked( struct _PDCLIB_file_t * _PDCLIB_restrict stream, 
+int fprintf_unlocked( FILE * _PDCLIB_restrict stream, 
                       const char * _PDCLIB_restrict format, ... )
 {
     int rc;
@@ -22,7 +23,7 @@ int fprintf_unlocked( struct _PDCLIB_file_t * _PDCLIB_restrict stream,
     return rc;
 }
 
-int fprintf( struct _PDCLIB_file_t * _PDCLIB_restrict stream,
+int fprintf( FILE * _PDCLIB_restrict stream,
              const char * _PDCLIB_restrict format, ... )
 {
     int rc;
index ae998eaacb0562c01070589c56f4400ae9451c8c..2aaad4fdab6fc7cdf710a6a8d7a8e983eaebdef1 100644 (file)
@@ -9,14 +9,13 @@
 #include <stdio.h>
 
 #ifndef REGTEST
-
-#include <_PDCLIB_glue.h>
+#include <_PDCLIB_io.h>
 
 /* Write the value c (cast to unsigned char) to the given stream.
    Returns c if successful, EOF otherwise.
    If a write error occurs, the error indicator of the stream is set.
 */
-int fputc_unlocked( int c, struct _PDCLIB_file_t * stream )
+int fputc_unlocked( int c, FILE * stream )
 {
     if ( _PDCLIB_prepwrite( stream ) == EOF )
     {
@@ -34,7 +33,7 @@ int fputc_unlocked( int c, struct _PDCLIB_file_t * stream )
     return c;
 }
 
-int fputc( int c, struct _PDCLIB_file_t * stream )
+int fputc( int c, FILE * stream )
 {
     flockfile( stream );
     int r = fputc_unlocked( c, stream );
index 0b1e3256f3d32153d88e7e18270b3ad942590fb5..0f92aaa7d1beaf64cec2931d4557ca949ef48a4b 100644 (file)
@@ -9,10 +9,10 @@
 #include <stdio.h>
 
 #ifndef REGTEST
-#include <_PDCLIB_glue.h>
+#include <_PDCLIB_io.h>
 
 int fputs_unlocked( const char * _PDCLIB_restrict s, 
-                    struct _PDCLIB_file_t * _PDCLIB_restrict stream )
+                    FILE * _PDCLIB_restrict stream )
 {
     if ( _PDCLIB_prepwrite( stream ) == EOF )
     {
@@ -47,7 +47,7 @@ int fputs_unlocked( const char * _PDCLIB_restrict s,
 }
 
 int fputs( const char * _PDCLIB_restrict s,
-           struct _PDCLIB_file_t * _PDCLIB_restrict stream )
+           FILE * _PDCLIB_restrict stream )
 {
     flockfile( stream );
     int r = fputs_unlocked( s, stream );
index f1ab3a9adeb84745336a2043e8d0d4c8e95a8882..a0c23c31b989990b6062d2b2d223a384d9232205 100644 (file)
@@ -9,15 +9,16 @@
 #include <stdio.h>
 
 #ifndef REGTEST
-
-#include <_PDCLIB_glue.h>
+#include <_PDCLIB_io.h>
 
 #include <stdbool.h>
 #include <string.h>
 
-size_t fread_unlocked( void * _PDCLIB_restrict ptr, 
-                       size_t size, size_t nmemb, 
-                       struct _PDCLIB_file_t * _PDCLIB_restrict stream )
+size_t fread_unlocked( 
+    void * _PDCLIB_restrict ptr, 
+    size_t size, size_t nmemb, 
+    FILE * _PDCLIB_restrict stream 
+)
 {
     if ( _PDCLIB_prepread( stream ) == EOF )
     {
@@ -37,7 +38,7 @@ size_t fread_unlocked( void * _PDCLIB_restrict ptr,
 
 size_t fread( void * _PDCLIB_restrict ptr, 
               size_t size, size_t nmemb, 
-              struct _PDCLIB_file_t * _PDCLIB_restrict stream )
+              FILE * _PDCLIB_restrict stream )
 {
     flockfile( stream );
     size_t r = fread_unlocked( ptr, size, nmemb, stream );
index 741731b9990b8b4b3dcfdbb46860812ac91afd16..c8561225378cbbfaf22ebd359a4261e7acfb4120 100644 (file)
@@ -9,15 +9,16 @@
 #include <stdio.h>
 
 #ifndef REGTEST
-
+#include <_PDCLIB_io.h>
 #include <_PDCLIB_glue.h>
 #include <stdlib.h>
 #include <string.h>
 
-struct _PDCLIB_file_t * freopen( 
-                            const char * _PDCLIB_restrict filename, 
-                            const char * _PDCLIB_restrict mode, 
-                            struct _PDCLIB_file_t * _PDCLIB_restrict stream )
+FILE * freopen( 
+    const char * _PDCLIB_restrict filename, 
+    const char * _PDCLIB_restrict mode, 
+    FILE * _PDCLIB_restrict stream 
+)
 {
     flockfile( stream );
 
index c897325509b4421e7277d8eb4f77b1dc9f5738b8..35b641610da02e0e8a686c655e8fe3c516033b72 100644 (file)
@@ -9,10 +9,9 @@
 #include <stdio.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
-#include <_PDCLIB_glue.h>
-
-int fseek_unlocked( struct _PDCLIB_file_t * stream, long loffset, int whence )
+int fseek_unlocked( FILE * stream, long loffset, int whence )
 {
     _PDCLIB_int64_t offset = loffset;
     if ( stream->status & _PDCLIB_FWRITE )
@@ -37,7 +36,7 @@ int fseek_unlocked( struct _PDCLIB_file_t * stream, long loffset, int whence )
     return ( _PDCLIB_seek( stream, offset, whence ) != EOF ) ? 0 : EOF;
 }
 
-int fseek( struct _PDCLIB_file_t * stream, long loffset, int whence )
+int fseek( FILE * stream, long loffset, int whence )
 {
     flockfile( stream );
     int r = fseek_unlocked( stream, loffset, whence );
index aa2f8e655bb4a05706cb61f6bf03abf04215b335..ed3c0a8cfc0372ffbc40fc97e403fbe9a020793a 100644 (file)
@@ -9,10 +9,10 @@
 #include <stdio.h>
 
 #ifndef REGTEST
-#include <_PDCLIB_glue.h>
+#include <_PDCLIB_io.h>
 
-int fsetpos_unlocked( struct _PDCLIB_file_t * stream, 
-                      const struct _PDCLIB_fpos_t * pos )
+int fsetpos_unlocked( FILE * stream, 
+                      const _PDCLIB_fpos_t * pos )
 {
     if ( stream->status & _PDCLIB_FWRITE )
     {
@@ -25,13 +25,13 @@ int fsetpos_unlocked( struct _PDCLIB_file_t * stream,
     {
         return EOF;
     }
-    stream->pos.status = pos->status;
-    /* TODO: Add mbstate. */
+    stream->pos.mbs = pos->mbs;
+    
     return 0;
 }
 
-int fsetpos( struct _PDCLIB_file_t * stream, 
-             const struct _PDCLIB_fpos_t * pos )
+int fsetpos( FILE * stream, 
+             const _PDCLIB_fpos_t * pos )
 {
     flockfile( stream );
     int res = fsetpos_unlocked( stream, pos );
index 74bb902407a4672dfcb3c4beacc8519b16ab11ab..441c9fc84c4d45edccd5964a943a482df0c125ca 100644 (file)
@@ -13,7 +13,7 @@
 
 #ifndef REGTEST
 
-long int ftell_unlocked( struct _PDCLIB_file_t * stream )
+long int ftell_unlocked( FILE * stream )
 {
     uint_fast64_t off64 = _PDCLIB_ftell64_unlocked( stream );
 
@@ -26,7 +26,7 @@ long int ftell_unlocked( struct _PDCLIB_file_t * stream )
     return off64;
 }
 
-long int ftell( struct _PDCLIB_file_t * stream )
+long int ftell( FILE * stream )
 {
     flockfile( stream );
     long int off = ftell_unlocked( stream );
@@ -38,8 +38,10 @@ long int ftell( struct _PDCLIB_file_t * stream )
 
 #ifdef TEST
 #include <_PDCLIB_test.h>
-
 #include <stdlib.h>
+#ifndef REGTEST
+#include <_PDCLIB_io.h>
+#endif
 
 int main( void )
 {
index cb8147abd12b591b5a0f291c0dbe7c824c26ff24..41377dae2be619db99be32c4d1a24c375b21bfb5 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdarg.h>\r
 \r
 #ifndef REGTEST\r
+#include <_PDCLIB_io.h>\r
 #include <threads.h>\r
 #include <stdlib.h>\r
 \r
index 0845aab1ab1d85899c27b7d0a6953280b80c3d0a..648a22e4d62afc4159c1736a755dd57f4ab1d8ad 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdarg.h>\r
 \r
 #ifndef REGTEST\r
+#include <_PDCLIB_io.h>\r
 #include <threads.h>\r
 #include <stdlib.h>\r
 \r
index 9ab8a0abfb1380df315f5565edd7c5b1d5a30871..9319cf764afa8d16f3315a44c620fa59440d80d5 100644 (file)
@@ -9,7 +9,7 @@
 #include <stdio.h>
 
 #ifndef REGTEST
-
+#include <_PDCLIB_io.h>
 #include <_PDCLIB_glue.h>
 
 #include <stdbool.h>
@@ -19,7 +19,7 @@
 
 size_t fwrite_unlocked( const void * _PDCLIB_restrict ptr, 
                size_t size, size_t nmemb, 
-               struct _PDCLIB_file_t * _PDCLIB_restrict stream )
+               FILE * _PDCLIB_restrict stream )
 {
     if ( _PDCLIB_prepwrite( stream ) == EOF )
     {
@@ -92,7 +92,7 @@ size_t fwrite_unlocked( const void * _PDCLIB_restrict ptr,
 
 size_t fwrite( const void * _PDCLIB_restrict ptr, 
                size_t size, size_t nmemb, 
-               struct _PDCLIB_file_t * _PDCLIB_restrict stream )
+               FILE * _PDCLIB_restrict stream )
 {
     flockfile( stream );
     size_t r = fwrite_unlocked( ptr, size, nmemb, stream );
index 9338bafaa11114266bdb01a00bc67e577a721111..e733d0b087b07368932cae511c067226de0f319e 100644 (file)
 
 #ifndef REGTEST
 
-int getc_unlocked( struct _PDCLIB_file_t * stream )
+int getc_unlocked( FILE * stream )
 {
     return fgetc_unlocked( stream );
 }
 
-int getc( struct _PDCLIB_file_t * stream )
+int getc( FILE * stream )
 {
     return fgetc( stream );
 }
index 3185396f7f2cdc0bd4e59574b6ed07a92702cd24..83a261efd6744001414b25dcf2f234afb32bccb9 100644 (file)
@@ -9,7 +9,7 @@
 #include <stdio.h>
 
 #ifndef REGTEST
-#include <_PDCLIB_glue.h>
+#include <_PDCLIB_io.h>
 #include <stdint.h>
 
 char * gets( char * s )
index 23ce68bd356cc11e997dcdabf4873b32156b2204..5a794fbaa5a22611c30a60923b97333f4c5b0c1b 100644 (file)
@@ -9,7 +9,6 @@
 #include <stdio.h>
 
 #ifndef REGTEST
-
 #include <errno.h>
 #include <locale.h>
 
index a4efd6a7015d872ddedc9bc6d3b1a3df1b93abea..a12e137d8a3a0b71a8f35e537a452d5d34e68476 100644 (file)
@@ -10,6 +10,7 @@
 #include <stdarg.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
 int printf( const char * _PDCLIB_restrict format, ... )
 {
index c1f3fc279eef8fae8b96fdb77db77829a7466fa5..6bb2e9e58ce2e9b772687e9920c42b069ddf87d1 100644 (file)
 
 #ifndef REGTEST
 
-int putc_unlocked( int c, struct _PDCLIB_file_t * stream )
+int putc_unlocked( int c, FILE * stream )
 {
     return fputc_unlocked( c, stream );
 }
 
 
-int putc( int c, struct _PDCLIB_file_t * stream )
+int putc( int c, FILE * stream )
 {
     return fputc( c, stream );
 }
index 987b78a5906cb6f1b259468953beac60f2ff126c..0ae5c6a62cfe5ebff97d9e47555c037431438674 100644 (file)
 
 #include <string.h>
 
-extern struct _PDCLIB_file_t * _PDCLIB_filelist;
+extern _PDCLIB_file_t * _PDCLIB_filelist;
 
 int rename( const char * old, const char * new )
 {
-    struct _PDCLIB_file_t * current = _PDCLIB_filelist;
+    FILE * current = _PDCLIB_filelist;
     while ( current != NULL )
     {
         if ( ( current->filename != NULL ) && ( strcmp( current->filename, old ) == 0 ) )
index 0a19155b5820428acd62c40996d8aa8b8ceaf35c..53ab51da9509b64a2fcb1567fb05a8b45de5eb45 100644 (file)
@@ -9,14 +9,15 @@
 #include <stdio.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
-void rewind_unlocked( struct _PDCLIB_file_t * stream )
+void rewind_unlocked( FILE * stream )
 {
     stream->status &= ~ _PDCLIB_ERRORFLAG;
     fseek_unlocked( stream, 0L, SEEK_SET );
 }
 
-void rewind( struct _PDCLIB_file_t * stream )
+void rewind( FILE * stream )
 {
     flockfile(stream);
     rewind_unlocked(stream);
index fe83277586bfbca905781d63a83dbd01e444ca1a..f6f6f7016790709cbcdfd469eff24d6cd2eac8e5 100644 (file)
@@ -10,7 +10,7 @@
 
 #ifndef REGTEST
 
-void setbuf( struct _PDCLIB_file_t * _PDCLIB_restrict stream, char * _PDCLIB_restrict buf )
+void setbuf( FILE * _PDCLIB_restrict stream, char * _PDCLIB_restrict buf )
 {
     if ( buf == NULL )
     {
@@ -27,6 +27,9 @@ void setbuf( struct _PDCLIB_file_t * _PDCLIB_restrict stream, char * _PDCLIB_res
 #ifdef TEST
 #include <_PDCLIB_test.h>
 #include <stdlib.h>
+#ifndef REGTEST
+#include <_PDCLIB_io.h>
+#endif
 
 int main( void )
 {
index e3f9278aed159a316ab9e3da1883ff52ee12767e..8754727056f84b7e4cbf0b0cdcd3094f79339ed6 100644 (file)
@@ -11,8 +11,9 @@
 #include <limits.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
-int setvbuf( struct _PDCLIB_file_t * _PDCLIB_restrict stream, char * _PDCLIB_restrict buf, int mode, size_t size )
+int setvbuf( FILE * _PDCLIB_restrict stream, char * _PDCLIB_restrict buf, int mode, size_t size )
 {
     switch ( mode )
     {
@@ -71,9 +72,10 @@ int setvbuf( struct _PDCLIB_file_t * _PDCLIB_restrict stream, char * _PDCLIB_res
 
 #ifdef TEST
 #include <_PDCLIB_test.h>
-
 #include <errno.h>
-
+#ifndef REGTEST
+#include <_PDCLIB_io.h>
+#endif
 #define BUFFERSIZE 500
 
 int main( void )
index a9f5385c1e0723e45eba248a1e44091a14a3553c..270109d91fdf710d87e36bce4658d718908e1d39 100644 (file)
@@ -11,7 +11,7 @@
 #ifndef REGTEST
 
 #include <string.h>
-#include <_PDCLIB_glue.h>
+#include <_PDCLIB_io.h>
 
 char * tmpnam( char * s )
 {
index 4e9388b40d7f3e83094a00331630bf8c2d832f6f..cc6d1775ae66a50218a94b64e683b56d71ef0d63 100644 (file)
@@ -9,8 +9,9 @@
 #include <stdio.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
-int ungetc_unlocked( int c, struct _PDCLIB_file_t * stream )
+int ungetc_unlocked( int c, FILE * stream )
 {
     if ( c == EOF || stream->ungetidx == _PDCLIB_UNGETCBUFSIZE )
     {
@@ -19,7 +20,7 @@ int ungetc_unlocked( int c, struct _PDCLIB_file_t * stream )
     return stream->ungetbuf[stream->ungetidx++] = (unsigned char) c;
 }
 
-int ungetc( int c, struct _PDCLIB_file_t * stream )
+int ungetc( int c, FILE * stream )
 {
     flockfile( stream );
     int r = ungetc_unlocked( c, stream );
index 18e9c4b524919abbcce8c002d111a6120699d2ff..f9562d2e137d04e37ca3fe384334f1d87674f369 100644 (file)
@@ -12,8 +12,9 @@
 #include <limits.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
-int vfprintf_unlocked( struct _PDCLIB_file_t * _PDCLIB_restrict stream, 
+int vfprintf_unlocked( FILE * _PDCLIB_restrict stream, 
                        const char * _PDCLIB_restrict format, 
                        va_list arg )
 {
@@ -49,7 +50,7 @@ int vfprintf_unlocked( struct _PDCLIB_file_t * _PDCLIB_restrict stream,
     return status.i;
 }
 
-int vfprintf( struct _PDCLIB_file_t * _PDCLIB_restrict stream, 
+int vfprintf( FILE * _PDCLIB_restrict stream, 
               const char * _PDCLIB_restrict format, 
               va_list arg )
 {
index da365bdb618eb3b2f8aa8ab74ad31b71c3c79cdc..14bba50879c557a2837e78717e7bdd73de785c87 100644 (file)
@@ -11,6 +11,7 @@
 #include <ctype.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
 int vfscanf_unlocked( FILE * _PDCLIB_restrict stream, 
                       const char * _PDCLIB_restrict format, 
index 64a06517cc1a51a45d991935a8915eb9fd9ca493..fd29580db984b072ed1d80b699b51b97d452f167 100644 (file)
@@ -10,6 +10,7 @@
 #include <stdarg.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
 int vsnprintf( char * _PDCLIB_restrict s, 
                size_t n, 
index 99b8bad20a7292e6ea4158039a6691627e2b14c4..29dd4838b6d56ccf6103fdc46d136b059892e9c0 100644 (file)
@@ -11,6 +11,7 @@
 
 #ifndef REGTEST
 #include <ctype.h>
+#include <_PDCLIB_io.h>
 
 int vsscanf( const char * _PDCLIB_restrict s, 
              const char * _PDCLIB_restrict format, 
index 2dbb35c600f37c8f9ce846f8b761ef02065708d7..48a51118b34494ce2f9532a0e3005000b4294021 100644 (file)
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
 /* TODO - "except that a function is called after any previously registered
    functions that had already been called at the time it was registered.
index 9b68d73d7f0c6a1618f34a04440b6dae0a582593..8f818968892285567b12b5d7c7e40a99d0908810 100644 (file)
@@ -8,7 +8,7 @@
 
 #ifndef _PDCLIB_STDIO_H
 #define _PDCLIB_STDIO_H _PDCLIB_STDIO_H
-#include <_PDCLIB_io.h>
+#include <_PDCLIB_int.h>
 _PDCLIB_BEGIN_EXTERN_C
 
 #ifndef _PDCLIB_SIZE_T_DEFINED
@@ -27,8 +27,8 @@ typedef _PDCLIB_size_t size_t;
 #define _IONBF 4
 
 /* The following are platform-dependant, and defined in _PDCLIB_config.h. */
-typedef struct _PDCLIB_fpos_t fpos_t;
-typedef struct _PDCLIB_file_t FILE;
+typedef _PDCLIB_fpos_t fpos_t;
+typedef _PDCLIB_file_t FILE;
 #define EOF -1
 #define BUFSIZ _PDCLIB_BUFSIZ
 #define FOPEN_MAX _PDCLIB_FOPEN_MAX
index 65021538c383e395fb38d5e817a80bfc95540855..77e39d494f77a579830cd2151ab68a55bf9a31eb 100644 (file)
@@ -1,5 +1,6 @@
 #ifndef _PDCLIB_THREADS_H\r
 #define _PDCLIB_THREADS_H\r
+#include <_PDCLIB_int.h>\r
 #include <_PDCLIB_threadconfig.h>\r
 #include <time.h>\r
 _PDCLIB_BEGIN_EXTERN_C\r
index 1419df66b128be4f3d8545f6cf241041d7482546..87b5aab27c46ae9c4509b83a81abada7a42255fe 100644 (file)
@@ -7,7 +7,7 @@
 
 #ifndef _PDCLIB_UCHAR_H
 #define _PDCLIB_UCHAR_H
-#include <_PDCLIB_encoding.h>
+#include <_PDCLIB_int.h>
 _PDCLIB_BEGIN_EXTERN_C
 
 /* This is mostly a placeholder. for now. This header will be completed by the
index e3d8e4924d548b0c99ac138088015f39cd1b38d3..0eee7a64285c5a4b248ddda6e443a9bdbf492931 100644 (file)
@@ -7,8 +7,7 @@
 \r
 #ifndef _PDCLIB_WCHAR_H\r
 #define _PDCLIB_WCHAR_H\r
-#include <_PDCLIB_io.h>\r
-#include <_PDCLIB_encoding.h>\r
+#include <_PDCLIB_int.h>\r
 _PDCLIB_BEGIN_EXTERN_C\r
 /* This is VASTLY incomplete. Functions being implemented as required by other\r
    portions of the library\r
@@ -79,38 +78,38 @@ size_t wcsftime(wchar_t *_PDCLIB_restrict s, size_t maxsize, const wchar_t *_PDC
 #endif\r
 \r
 /* Wide character I/O */\r
-int fwprintf(struct _PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, ...);\r
-int fwscanf(struct _PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, ...);\r
+int fwprintf(_PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, ...);\r
+int fwscanf(_PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, ...);\r
 int swprintf(wchar_t *_PDCLIB_restrict s, size_t n, const wchar_t *_PDCLIB_restrict format, ...);\r
 int swscanf(const wchar_t *_PDCLIB_restrict s, const wchar_t *_PDCLIB_restrict format, ...);\r
-int vfwprintf(struct _PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
-int vfwscanf(struct _PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
+int vfwprintf(_PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
+int vfwscanf(_PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
 int vswprintf(wchar_t *_PDCLIB_restrict s, size_t n, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
 int vswscanf(const wchar_t *_PDCLIB_restrict s, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
 int vwprintf(const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
 int vwscanf(const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
 int wprintf(const wchar_t *_PDCLIB_restrict format, ...);\r
 int wscanf(const wchar_t *_PDCLIB_restrict format, ...);\r
-wint_t fgetwc(struct _PDCLIB_file_t *stream);\r
-wchar_t *fgetws(wchar_t *_PDCLIB_restrict s, int n, struct _PDCLIB_file_t *_PDCLIB_restrict stream);\r
-wint_t fputwc(wchar_t c, struct _PDCLIB_file_t *stream);\r
-int fputws(const wchar_t *_PDCLIB_restrict s, struct _PDCLIB_file_t *_PDCLIB_restrict stream);\r
-int fwide(struct _PDCLIB_file_t *stream, int mode);\r
-wint_t getwc(struct _PDCLIB_file_t *stream);\r
+wint_t fgetwc(_PDCLIB_file_t *stream);\r
+wchar_t *fgetws(wchar_t *_PDCLIB_restrict s, int n, _PDCLIB_file_t *_PDCLIB_restrict stream);\r
+wint_t fputwc(wchar_t c, _PDCLIB_file_t *stream);\r
+int fputws(const wchar_t *_PDCLIB_restrict s, _PDCLIB_file_t *_PDCLIB_restrict stream);\r
+int fwide(_PDCLIB_file_t *stream, int mode);\r
+wint_t getwc(_PDCLIB_file_t *stream);\r
 wint_t getwchar(void);\r
-wint_t putwc(wchar_t c, struct _PDCLIB_file_t *stream);\r
+wint_t putwc(wchar_t c, _PDCLIB_file_t *stream);\r
 wint_t putwchar(wchar_t c);\r
-wint_t ungetwc(wint_t c, struct _PDCLIB_file_t *stream);\r
+wint_t ungetwc(wint_t c, _PDCLIB_file_t *stream);\r
 \r
 #if _PDCLIB_GNU_SOURCE\r
-wint_t getwc_unlocked(struct _PDCLIB_file_t *stream);\r
+wint_t getwc_unlocked(_PDCLIB_file_t *stream);\r
 wint_t getwchar_unlocked(void);\r
-wint_t fgetwc_unlocked(struct _PDCLIB_file_t *stream);\r
-wint_t fputwc_unlocked(wchar_t wc, struct _PDCLIB_file_t *stream);\r
-wint_t putwc_unlocked(wchar_t wc, struct _PDCLIB_file_t *stream);\r
+wint_t fgetwc_unlocked(_PDCLIB_file_t *stream);\r
+wint_t fputwc_unlocked(wchar_t wc, _PDCLIB_file_t *stream);\r
+wint_t putwc_unlocked(wchar_t wc, _PDCLIB_file_t *stream);\r
 wint_t putwchar_unlocked(wchar_t wc);\r
-wchar_t *fgetws_unlocked(wchar_t *ws, int n, struct _PDCLIB_file_t *stream);\r
-int fputws_unlocked(const wchar_t *ws, struct _PDCLIB_file_t *stream);\r
+wchar_t *fgetws_unlocked(wchar_t *ws, int n, _PDCLIB_file_t *stream);\r
+int fputws_unlocked(const wchar_t *ws, _PDCLIB_file_t *stream);\r
 #endif\r
 \r
 /* Wide character <-> Numeric conversions */\r
index c3e38d08e38e995aa5ebc316e2fb9a9c263d98da..0a31e86969f81b4f49cc649bdcc090462fcb95d3 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _PDCLIB_AUX_H
-#define _PDCLIB_AUX_H
+#ifndef __PDCLIB_AUX_H
+#define __PDCLIB_AUX_H __PDCLIB_AUX_H
 
 /* Auxiliary PDCLib code <_PDCLIB_aux.h>
 
index 0178b12f70dcf6e338770caf4e1086c8ef7a7d91..0b466c150a291789fe3a6deb7335dca59935e4af 100644 (file)
@@ -4,63 +4,27 @@
    Permission is granted to use, modify, and / or redistribute at will.
 */
 
-#ifndef _PDCLIB_ENCODING_H
-#define _PDCLIB_ENCODING_H _PDCLIB_ENCODING_H
+#ifndef __PDCLIB_ENCODING_H
+#define __PDCLIB_ENCODING_H __PDCLIB_ENCODING_H
 #include "_PDCLIB_int.h"
 
-#ifndef __cplusplus
-typedef _PDCLIB_int16_t         _PDCLIB_char16_t;
-typedef _PDCLIB_int32_t         _PDCLIB_char32_t;
-#else
-typedef char16_t                _PDCLIB_char16_t;
-typedef char32_t                _PDCLIB_char32_t;
-#endif
-
-/* -------------------------------------------------------------------------- */
-/* mbstate_t                                                                  */
-/* -------------------------------------------------------------------------- */
-
-typedef struct _PDCLIB_mbstate_t {
-    union {
-        /* Is this the best way to represent this? Is this big enough? */
-        _PDCLIB_uint64_t _St64[15];
-        _PDCLIB_uint32_t _St32[31];
-        _PDCLIB_uint16_t _St16[62];
-        unsigned char    _StUC[124];
-        signed   char    _StSC[124];
-                 char    _StC [124];
-    };
-
-    union {
-        /* c16/related functions: Surrogate storage
-         *
-         * If zero, no surrogate pending. If nonzero, surrogate.
-         */
-        _PDCLIB_uint16_t     _Surrogate;
-
-        /* Reserved for potential mbtoutf8/etc functions */
-        unsigned char        _U8[4];
-    };
-} _PDCLIB_mbstate_t;
-
-#ifdef _PDCLIB_WCHAR_IS_UCS2
 /* Must be cauued with bufsize >= 1, in != NULL, out != NULL, ps != NULL
  *
- * Converts a wchar to a UCS4 (char32_t) value. Returns
+ * Converts a UTF-16 (char16_t) to a UCS4 (char32_t) value. Returns
  *   1, 2   : Valid character (converted to UCS-4)
  *   -1     : Encoding error
  *   -2     : Partial character (only lead surrogate in buffer)
  */
-static inline int _PDCLIB_wcrtoc32(
+static inline int _PDCLIB_c16rtoc32(
             _PDCLIB_char32_t    *_PDCLIB_restrict   out, 
-    const   _PDCLIB_wchar_t     *_PDCLIB_restrict   in,
+    const   _PDCLIB_char16_t    *_PDCLIB_restrict   in,
             _PDCLIB_size_t                          bufsize,
             _PDCLIB_mbstate_t   *_PDCLIB_restrict   ps  
 )
 {
     if(ps->_Surrogate) {
         // We already have a lead surrogate
-        if(*in & ~0x3FF != 0xDC00) {
+        if((*in & ~0x3FF) != 0xDC00) {
             // Encoding error
             return -1;
         } else {
@@ -69,11 +33,11 @@ static inline int _PDCLIB_wcrtoc32(
             ps->_Surrogate = 0;
             return 1;
         }
-    } if(*in & ~0x3FF == 0xD800) {
+    } if((*in & ~0x3FF) == 0xD800) {
         // Lead surrogate
         if(bufsize >= 2) {
             // Buffer big enough
-            if(in[1] & ~0x3FF != 0xDC00) {
+            if((in[1] & ~0x3FF) != 0xDC00) {
                 // Encoding error
                 return -1;
             } else {
@@ -92,7 +56,7 @@ static inline int _PDCLIB_wcrtoc32(
     }
 }
 
-static inline _PDCLIB_size_t _PDCLIB_c32rtowc(
+static inline _PDCLIB_size_t _PDCLIB_c32rtoc16(
             _PDCLIB_wchar_t     *_PDCLIB_restrict   out,
     const   _PDCLIB_char32_t    *_PDCLIB_restrict   in,
             _PDCLIB_size_t                          bufsize,
@@ -121,32 +85,8 @@ static inline _PDCLIB_size_t _PDCLIB_c32rtowc(
         }
     }
 }
-#else
-/* Dummy implementation for when wc == c32 */
-static inline _PDCLIB_size_t _PDCLIB_wcrtoc32(
-            _PDCLIB_char32_t    *_PDCLIB_restrict   out, 
-    const   _PDCLIB_wchar_t     *_PDCLIB_restrict   in,
-            _PDCLIB_size_t                          bufsize,
-            _PDCLIB_mbstate_t   *_PDCLIB_restrict   ps  
-)
-{
-    *out = *in;
-    return 1;
-}
-
-static inline _PDCLIB_size_t _PDCLIB_c32rtowc(
-            _PDCLIB_wchar_t     *_PDCLIB_restrict   out,
-    const   _PDCLIB_char32_t    *_PDCLIB_restrict   in,
-            _PDCLIB_size_t                          bufsize,
-            _PDCLIB_mbstate_t   *_PDCLIB_restrict   ps
-)
-{
-    *out = *in;
-    return 1;
-}
-#endif
 
-typedef struct {
+struct _PDCLIB_charcodec {
     /* Reads at most *_P_insz code units from *_P_inbuf and writes the result 
      * into *_P_outbuf, writing at most *_P_outsz code units. Updates 
      * *_P_outbuf, *_P_outsz, *_P_inbuf, *_P_outsz with the resulting state
@@ -198,6 +138,6 @@ typedef struct {
         _PDCLIB_size_t          *_PDCLIB_restrict  _P_insz,
         _PDCLIB_mbstate_t       *_PDCLIB_restrict  _P_ps
     );
-} _PDCLIB_charcodec;
+};
 
 #endif
index c48d0eca6957c955a93ceceb7c7819a208bf2d18..0471a30203489e14126be6ad7d2275c75da83845 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _PDCLIB_PDCLIB_FLOAT_H\r
-#define _PDCLIB_PDCLIB_FLOAT_H _PDCLIB_PDCLIB_FLOAT_H\r
+#ifndef __PDCLIB_PDCLIB_FLOAT_H\r
+#define __PDCLIB_PDCLIB_FLOAT_H __PDCLIB_PDCLIB_FLOAT_H\r
 \r
 /* PDCLib internal floating point logic <_PDCLIB_float.h>\r
 \r
index 7f3c4fa7469c5553ffb9872e551d4cb5968da763..1d978638f8f46cce35c4c188864166b876f61b4f 100644 (file)
@@ -1,7 +1,5 @@
-#ifndef _PDCLIB_GLUE_H
-#define _PDCLIB_GLUE_H
-/* $Id$ */
-
+#ifndef __PDCLIB_GLUE_H
+#define __PDCLIB_GLUE_H __PDCLIB_GLUE_H
 /* OS glue functions declaration <_PDCLIB_glue.h>
 
    This file is part of the Public Domain C Library (PDCLib).
index c0bbe00fe58d8c7e20e8ffa1ead947e1ae77f341..64d921967de5465ce795da8beabfcf10ebe1f924 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _PDCLIB_INT_H
-#define _PDCLIB_INT_H
+#ifndef __PDCLIB_INT_H
+#define __PDCLIB_INT_H __PDCLIB_INT_H
 
 /* PDCLib internal integer logic <_PDCLIB_int.h>
 
@@ -294,36 +294,6 @@ struct _PDCLIB_exitfunc_t
     void (*func)( void );
 };
 
-/* Structures required by malloc(), realloc(), and free(). */
-struct _PDCLIB_headnode_t
-{
-    struct _PDCLIB_memnode_t * first;
-    struct _PDCLIB_memnode_t * last;
-};
-
-struct _PDCLIB_memnode_t
-{
-    _PDCLIB_size_t size;
-    struct _PDCLIB_memnode_t * next;
-};
-
-/* Status structure required by _PDCLIB_print(). */
-struct _PDCLIB_status_t
-{
-    int              base;   /* base to which the value shall be converted   */
-    _PDCLIB_int_fast32_t flags; /* flags and length modifiers                */
-    unsigned         n;      /* print: maximum characters to be written      */
-                             /* scan:  number matched conversion specifiers  */
-    unsigned         i;      /* number of characters read/written            */
-    unsigned         current;/* chars read/written in the CURRENT conversion */
-    char *           s;      /* *sprintf(): target buffer                    */
-                             /* *sscanf():  source string                    */
-    unsigned         width;  /* specified field width                        */
-    int              prec;   /* specified field precision                    */
-    struct _PDCLIB_file_t * stream; /* *fprintf() / *fscanf() stream         */
-    _PDCLIB_va_list  arg;    /* argument stack                               */
-};
-
 /* -------------------------------------------------------------------------- */
 /* Declaration of helper functions (implemented in functions/_PDCLIB).        */
 /* -------------------------------------------------------------------------- */
@@ -339,46 +309,6 @@ _PDCLIB_uintmax_t _PDCLIB_strtox_main( const char ** p, unsigned int base, _PDCL
 extern char _PDCLIB_digits[];
 extern char _PDCLIB_Xdigits[];
 
-/* The worker for all printf() type of functions. The pointer spec should point
-   to the introducing '%' of a conversion specifier. The status structure is to
-   be that of the current printf() function, of which the members n, s, stream
-   and arg will be preserved; i will be updated; and all others will be trashed
-   by the function.
-   Returns a pointer to the first character not parsed as conversion specifier.
-*/
-const char * _PDCLIB_print( const char * spec, struct _PDCLIB_status_t * status );
-
-/* The worker for all scanf() type of functions. The pointer spec should point
-   to the introducing '%' of a conversion specifier. The status structure is to
-   be that of the current scanf() function, of which the member stream will be
-   preserved; n, i, and s will be updated; and all others will be trashed by
-   the function.
-   Returns a pointer to the first character not parsed as conversion specifier,
-   or NULL in case of error.
-   FIXME: Should distinguish between matching and input error
-*/
-const char * _PDCLIB_scan( const char * spec, struct _PDCLIB_status_t * status );
-
-/* Parsing any fopen() style filemode string into a number of flags. */
-unsigned int _PDCLIB_filemode( const char * mode );
-
-/* Sanity checking and preparing of read buffer, should be called first thing 
-   by any stdio read-data function.
-   Returns 0 on success, EOF on error.
-   On error, EOF / error flags and errno are set appropriately.
-*/
-int _PDCLIB_prepread( struct _PDCLIB_file_t * stream );
-
-/* Sanity checking, should be called first thing by any stdio write-data
-   function.
-   Returns 0 on success, EOF on error.
-   On error, error flags and errno are set appropriately.
-*/
-int _PDCLIB_prepwrite( struct _PDCLIB_file_t * stream );
-
-/* Closing all streams on program exit */
-void _PDCLIB_closeall( void );
-
 /* -------------------------------------------------------------------------- */
 /* errno                                                                      */
 /* -------------------------------------------------------------------------- */
@@ -418,4 +348,75 @@ struct _PDCLIB_ctype_t
     unsigned char collation;
 };
 
+/* -------------------------------------------------------------------------- */
+/* locale / wchar / uchar                                                     */
+/* -------------------------------------------------------------------------- */
+
+#ifndef __cplusplus
+typedef _PDCLIB_int16_t         _PDCLIB_char16_t;
+typedef _PDCLIB_int32_t         _PDCLIB_char32_t;
+#else
+typedef char16_t                _PDCLIB_char16_t;
+typedef char32_t                _PDCLIB_char32_t;
+#endif
+
+typedef struct _PDCLIB_mbstate {
+    union {
+        /* Is this the best way to represent this? Is this big enough? */
+        _PDCLIB_uint64_t _St64[15];
+        _PDCLIB_uint32_t _St32[31];
+        _PDCLIB_uint16_t _St16[62];
+        unsigned char    _StUC[124];
+        signed   char    _StSC[124];
+                 char    _StC [124];
+    };
+
+    union {
+        /* c16/related functions: Surrogate storage
+         *
+         * If zero, no surrogate pending. If nonzero, surrogate.
+         */
+        _PDCLIB_uint16_t     _Surrogate;
+
+        /* Reserved for potential mbtoutf8/etc functions */
+        unsigned char        _U8[4];
+    };
+} _PDCLIB_mbstate_t;
+
+typedef struct _PDCLIB_charcodec  _PDCLIB_charcodec_t;
+typedef struct _PDCLIB_locale     _PDCLIB_locale_t;
+typedef struct lconv              _PDCLIB_lconv_t;
+
+/* -------------------------------------------------------------------------- */
+/* stdio                                                                      */
+/* -------------------------------------------------------------------------- */
+
+/* Position / status structure for getpos() / fsetpos(). */
+typedef struct _PDCLIB_fpos
+{
+    _PDCLIB_int_fast64_t offset; /* File position offset */
+    _PDCLIB_mbstate_t    mbs;    /* Multibyte parsing state */
+} _PDCLIB_fpos_t;
+
+typedef struct _PDCLIB_fileops  _PDCLIB_fileops_t;
+typedef union  _PDCLIB_fd       _PDCLIB_fd_t;
+typedef struct _PDCLIB_file     _PDCLIB_file_t; // Rename to _PDCLIB_FILE?
+
+/* Status structure required by _PDCLIB_print(). */
+struct _PDCLIB_status_t
+{
+    int              base;   /* base to which the value shall be converted   */
+    _PDCLIB_int_fast32_t flags; /* flags and length modifiers                */
+    unsigned         n;      /* print: maximum characters to be written      */
+                             /* scan:  number matched conversion specifiers  */
+    unsigned         i;      /* number of characters read/written            */
+    unsigned         current;/* chars read/written in the CURRENT conversion */
+    char *           s;      /* *sprintf(): target buffer                    */
+                             /* *sscanf():  source string                    */
+    unsigned         width;  /* specified field width                        */
+    int              prec;   /* specified field precision                    */
+    _PDCLIB_file_t * stream; /* *fprintf() / *fscanf() stream         */
+    _PDCLIB_va_list  arg;    /* argument stack                               */
+};
+
 #endif
index 2ece56ce194b4ea3b0387f099770d5ef0a001142..e4fd94ef3fce28d3d21a6e7c73ecfda57b1d8fd0 100644 (file)
@@ -1,9 +1,9 @@
-#ifndef _PDCLIB_IO_H\r
-#define _PDCLIB_IO_H\r
+#ifndef __PDCLIB_IO_H\r
+#define __PDCLIB_IO_H __PDCLIB_IO_H\r
 #include "_PDCLIB_int.h"\r
 #include "_PDCLIB_threadconfig.h"\r
 \r
-/* PDCLib internal I/O logic <_PDCLIB_int.h>\r
+/* PDCLib internal I/O logic <_PDCLIB_io.h>\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
@@ -34,7 +34,7 @@
 /* stream handle should not be free()d on close (stdin, stdout, stderr) */\r
 #define _PDCLIB_STATIC     32768u\r
 \r
-typedef union _PDCLIB_fd\r
+union _PDCLIB_fd\r
 {\r
 #if defined(_PDCLIB_OSFD_T)\r
     _PDCLIB_OSFD_T      osfd;\r
@@ -42,25 +42,68 @@ typedef union _PDCLIB_fd
     void *              pointer;\r
     _PDCLIB_uintptr_t   uval;\r
     _PDCLIB_intptr_t    sval;     \r
-} _PDCLIB_fd_t;\r
+};\r
+\r
+/******************************************************************************/\r
+/* Internal functions                                                         */\r
+/******************************************************************************/\r
+\r
+/* The worker for all printf() type of functions. The pointer spec should point\r
+   to the introducing '%' of a conversion specifier. The status structure is to\r
+   be that of the current printf() function, of which the members n, s, stream\r
+   and arg will be preserved; i will be updated; and all others will be trashed\r
+   by the function.\r
+   Returns a pointer to the first character not parsed as conversion specifier.\r
+*/\r
+const char * _PDCLIB_print( const char * spec, struct _PDCLIB_status_t * status );\r
+\r
+/* The worker for all scanf() type of functions. The pointer spec should point\r
+   to the introducing '%' of a conversion specifier. The status structure is to\r
+   be that of the current scanf() function, of which the member stream will be\r
+   preserved; n, i, and s will be updated; and all others will be trashed by\r
+   the function.\r
+   Returns a pointer to the first character not parsed as conversion specifier,\r
+   or NULL in case of error.\r
+   FIXME: Should distinguish between matching and input error\r
+*/\r
+const char * _PDCLIB_scan( const char * spec, struct _PDCLIB_status_t * status );\r
+\r
+/* Parsing any fopen() style filemode string into a number of flags. */\r
+unsigned int _PDCLIB_filemode( const char * mode );\r
+\r
+/* Sanity checking and preparing of read buffer, should be called first thing \r
+   by any stdio read-data function.\r
+   Returns 0 on success, EOF on error.\r
+   On error, EOF / error flags and errno are set appropriately.\r
+*/\r
+int _PDCLIB_prepread( _PDCLIB_file_t * stream );\r
+\r
+/* Sanity checking, should be called first thing by any stdio write-data\r
+   function.\r
+   Returns 0 on success, EOF on error.\r
+   On error, error flags and errno are set appropriately.\r
+*/\r
+int _PDCLIB_prepwrite( _PDCLIB_file_t * stream );\r
+\r
+/* Closing all streams on program exit */\r
+void _PDCLIB_closeall( void );\r
 \r
-/* Internal functions */\r
 /* Writes a stream's buffer.\r
    Returns 0 on success, EOF on write error.\r
    Sets stream error flags and errno appropriately on error.\r
 */\r
-int _PDCLIB_flushbuffer( struct _PDCLIB_file_t * stream );\r
+int _PDCLIB_flushbuffer( _PDCLIB_file_t * stream );\r
 \r
 /* Fills a stream's buffer.\r
    Returns 0 on success, EOF on read error / EOF.\r
    Sets stream EOF / error flags and errno appropriately on error.\r
 */\r
-int _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream );\r
+int _PDCLIB_fillbuffer( _PDCLIB_file_t * stream );\r
 \r
 /* Repositions within a file. Returns new offset on success,\r
    -1 / errno on error.\r
 */\r
-_PDCLIB_int_fast64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, \r
+_PDCLIB_int_fast64_t _PDCLIB_seek( _PDCLIB_file_t * stream, \r
                                   _PDCLIB_int_fast64_t offset, int whence );\r
 \r
 /* File backend I/O operations\r
@@ -68,7 +111,7 @@ _PDCLIB_int_fast64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream,
  * PDCLib will call through to these methods as needed to implement the stdio\r
  * functions.\r
  */\r
-typedef struct _PDCLIB_fileops\r
+struct _PDCLIB_fileops\r
 {\r
     /*! Read length bytes from the file into buf; returning the number of bytes\r
      *  actually read in *numBytesRead.\r
@@ -123,17 +166,10 @@ typedef struct _PDCLIB_fileops
      */\r
     _PDCLIB_bool (*wwrite)( _PDCLIB_fd_t self, const _PDCLIB_wchar_t * buf, \r
                      _PDCLIB_size_t length, _PDCLIB_size_t * numCharsWritten );\r
-} _PDCLIB_fileops_t;\r
-\r
-/* Position / status structure for getpos() / fsetpos(). */\r
-struct _PDCLIB_fpos_t\r
-{\r
-    _PDCLIB_int_fast64_t offset; /* File position offset */\r
-    int                  status; /* Multibyte parsing state (unused, reserved) */\r
 };\r
 \r
 /* FILE structure */\r
-struct _PDCLIB_file_t\r
+struct _PDCLIB_file\r
 {\r
     const _PDCLIB_fileops_t * ops;\r
     _PDCLIB_fd_t              handle;   /* OS file handle */\r
@@ -142,18 +178,18 @@ struct _PDCLIB_file_t
     _PDCLIB_size_t            bufsize;  /* Size of buffer */\r
     _PDCLIB_size_t            bufidx;   /* Index of current position in buffer */\r
     _PDCLIB_size_t            bufend;   /* Index of last pre-read character in buffer */\r
-    struct _PDCLIB_fpos_t     pos;      /* Offset and multibyte parsing state */\r
     _PDCLIB_size_t            ungetidx; /* Number of ungetc()'ed characters */\r
     unsigned char *           ungetbuf; /* ungetc() buffer */\r
     unsigned int              status;   /* Status flags; see above */\r
     /* multibyte parsing status to be added later */\r
+    _PDCLIB_fpos_t            pos;      /* Offset and multibyte parsing state */\r
     char *                    filename; /* Name the current stream has been opened with */\r
-    struct _PDCLIB_file_t *   next;     /* Pointer to next struct (internal) */\r
+    _PDCLIB_file_t *          next;     /* Pointer to next struct (internal) */\r
 };\r
 \r
 static inline _PDCLIB_size_t _PDCLIB_getchars( char * out, _PDCLIB_size_t n,\r
                                                int stopchar,\r
-                                               struct _PDCLIB_file_t * stream )\r
+                                               _PDCLIB_file_t * stream )\r
 {\r
     _PDCLIB_size_t i = 0;\r
     int c;\r
index a705a7a75b43da5b18e429b681601b0ad7d144dc..e84563f747a68b7a50ed8b3a3dfc63f6e3322dcc 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdbool.h>
 #ifndef REGTEST
 #include <uchar.h>
+#include <_PDCLIB_encoding.h>
 
 static bool asciitoc32(
     char32_t       **restrict   p_outbuf,
@@ -58,7 +59,7 @@ static bool c32toascii(
     return true;
 }
 
-_PDCLIB_charcodec _PDCLIB_ascii_codec = {
+_PDCLIB_charcodec_t _PDCLIB_ascii_codec = {
     .__mbstoc32s = asciitoc32,
     .__c32stombs = c32toascii,
 };
index f78574f4b947b79adc48fed36608097ef0897bd9..29903606db810648ad2a9b19cbd6bfc3c6945c69 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdbool.h>
 #ifndef REGTEST
 #include <uchar.h>
+#include <_PDCLIB_encoding.h>
 
 static bool latin1toc32(
     char32_t       **restrict   p_outbuf,
@@ -56,7 +57,7 @@ static bool c32tolatin1(
     return true;
 }
 
-_PDCLIB_charcodec _PDCLIB_latin1_codec = {
+_PDCLIB_charcodec_t _PDCLIB_latin1_codec = {
     .__mbstoc32s = latin1toc32,
     .__c32stombs = c32tolatin1,
 };
index 8183aef254ecd69e2126b06ea9d1d7686f2b3863..65f76e01470ba3c337382e15c322e847531ffd6d 100644 (file)
@@ -9,6 +9,7 @@
 #include <stdint.h>
 #include <uchar.h>
 #include <assert.h>
+#include <_PDCLIB_encoding.h>
 
 /* Use of the mbstate:
  *
@@ -227,7 +228,7 @@ static bool c32toutf8(
     END_CONVERSION;
 }
 
-_PDCLIB_charcodec _PDCLIB_utf8_codec = {
+_PDCLIB_charcodec_t _PDCLIB_utf8_codec = {
     .__mbstoc32s = utf8toc32,
     .__c32stombs = c32toutf8,
 };
index a3c9e8b6e2ec19025187f46c5ef0998e6c683581..4c4ba4af8cf1465f45f6ea420e6c41f9e162c866 100644 (file)
@@ -16,6 +16,7 @@
 #include <limits.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 #include <threads.h>
 
 /* In a POSIX system, stdin / stdout / stderr are equivalent to the (int) file
@@ -32,42 +33,39 @@ static unsigned char _PDCLIB_serr_ungetbuf[_PDCLIB_UNGETCBUFSIZE];
 
 extern _PDCLIB_fileops_t _PDCLIB_fileops;
 
-static struct _PDCLIB_file_t _PDCLIB_serr = { 
+static FILE _PDCLIB_serr = { 
     .ops        = &_PDCLIB_fileops, 
     .handle     = { .sval = 2 }, 
     .buffer     = _PDCLIB_serr_buffer, 
     .bufsize    = BUFSIZ, 
     .bufidx     = 0, 
     .bufend     = 0, 
-    .pos        = { 0, 0 }, 
     .ungetidx   = 0, 
     .ungetbuf   = _PDCLIB_serr_ungetbuf, 
     .status     = _IONBF | _PDCLIB_FWRITE | _PDCLIB_STATIC, 
     .filename   = NULL, 
     .next       = NULL,
 };
-static struct _PDCLIB_file_t _PDCLIB_sout = { 
+static FILE _PDCLIB_sout = { 
     .ops        = &_PDCLIB_fileops, 
     .handle     = { .sval = 1 },
     .buffer     = _PDCLIB_sout_buffer, 
     .bufsize    = BUFSIZ, 
     .bufidx     = 0, 
     .bufend     = 0, 
-    .pos        = { 0, 0 }, 
     .ungetidx   = 0, 
     .ungetbuf   = _PDCLIB_sout_ungetbuf, 
     .status     = _IOLBF | _PDCLIB_FWRITE | _PDCLIB_STATIC, 
     .filename   = NULL, 
     .next       = &_PDCLIB_serr 
 };
-static struct _PDCLIB_file_t _PDCLIB_sin  = { 
+static FILE _PDCLIB_sin  = { 
     .ops        = &_PDCLIB_fileops, 
     .handle     = { .sval = 0 }, 
     .buffer     = _PDCLIB_sin_buffer, 
     .bufsize    = BUFSIZ, 
     .bufidx     = 0, 
     .bufend     = 0, 
-    .pos        = { 0, 0 }, 
     .ungetidx   = 0, 
     .ungetbuf   = _PDCLIB_sin_ungetbuf, 
     .status     = _IOLBF | _PDCLIB_FREAD | _PDCLIB_STATIC, 
@@ -75,9 +73,9 @@ static struct _PDCLIB_file_t _PDCLIB_sin  = {
     .next       = &_PDCLIB_sout 
 };
 
-struct _PDCLIB_file_t * stdin  = &_PDCLIB_sin;
-struct _PDCLIB_file_t * stdout = &_PDCLIB_sout;
-struct _PDCLIB_file_t * stderr = &_PDCLIB_serr;
+FILE * stdin  = &_PDCLIB_sin;
+FILE * stdout = &_PDCLIB_sout;
+FILE * stderr = &_PDCLIB_serr;
 
 /* Todo: Better solution than this! */
 __attribute__((constructor)) void init_stdio(void)
@@ -88,7 +86,7 @@ __attribute__((constructor)) void init_stdio(void)
 }
 
 /* FIXME: This approach is a possible attack vector. */
-struct _PDCLIB_file_t * _PDCLIB_filelist = &_PDCLIB_sin;
+FILE * _PDCLIB_filelist = &_PDCLIB_sin;
 
 /* "C" locale - defaulting to ASCII-7.
    1 kByte (+ 4 byte) of <ctype.h> data.
index f4f63fed8f6874e875d4cc50a3cb539c541faa45..d4a018442ebc70efe2f3451b1e4d0dbe180085e6 100644 (file)
 #include <stdio.h>
 
 #ifndef REGTEST
-
+#include <_PDCLIB_io.h>
 #include <string.h>
 
-extern struct _PDCLIB_file_t * _PDCLIB_filelist;
+extern FILE * _PDCLIB_filelist;
 
 extern int unlink( const char * pathname );
 
 int remove( const char * pathname )
 {
-    struct _PDCLIB_file_t * current = _PDCLIB_filelist;
+    FILE * current = _PDCLIB_filelist;
     while ( current != NULL )
     {
         if ( ( current->filename != NULL ) && ( strcmp( current->filename, pathname ) == 0 ) )
index 6ff9608985781d1db571c0aa86b6b5a61e5383ee..1c8a7b6d549f1e340d0321390a5e2ebfc1b7cea6 100644 (file)
@@ -16,6 +16,7 @@
 #include <limits.h>
 
 #ifndef REGTEST
+#include <_PDCLIB_io.h>
 
 extern const _PDCLIB_fileops_t _PDCLIB_fileops;