*/
#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;
-/* _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
\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
\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
#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
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
\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
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
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
/* $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.
#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 ) ) ||
/* $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.
#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 ) ) ||
#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
#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 );
#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 )
{
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 );
#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 );
#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 );
#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 )
{
}
}
-int fflush( struct _PDCLIB_file_t * stream )
+int fflush( FILE * stream )
{
flockfile( stream );
int res = fflush_unlocked(stream);
#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 )
{
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 );
#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 );
#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 )
{
}
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 );
#include <stdarg.h>\r
\r
#ifndef REGTEST\r
+#include <_PDCLIB_io.h>\r
#include <threads.h>\r
#include <stdlib.h>\r
\r
#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 )
#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;
return rc;
}
-int fprintf( struct _PDCLIB_file_t * _PDCLIB_restrict stream,
+int fprintf( FILE * _PDCLIB_restrict stream,
const char * _PDCLIB_restrict format, ... )
{
int rc;
#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 )
{
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 );
#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 )
{
}
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 );
#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 )
{
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 );
#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 );
#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 )
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 );
#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 )
{
{
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 );
#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 );
return off64;
}
-long int ftell( struct _PDCLIB_file_t * stream )
+long int ftell( FILE * stream )
{
flockfile( stream );
long int off = ftell_unlocked( stream );
#ifdef TEST
#include <_PDCLIB_test.h>
-
#include <stdlib.h>
+#ifndef REGTEST
+#include <_PDCLIB_io.h>
+#endif
int main( void )
{
#include <stdarg.h>\r
\r
#ifndef REGTEST\r
+#include <_PDCLIB_io.h>\r
#include <threads.h>\r
#include <stdlib.h>\r
\r
#include <stdarg.h>\r
\r
#ifndef REGTEST\r
+#include <_PDCLIB_io.h>\r
#include <threads.h>\r
#include <stdlib.h>\r
\r
#include <stdio.h>
#ifndef REGTEST
-
+#include <_PDCLIB_io.h>
#include <_PDCLIB_glue.h>
#include <stdbool.h>
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 )
{
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 );
#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 );
}
#include <stdio.h>
#ifndef REGTEST
-#include <_PDCLIB_glue.h>
+#include <_PDCLIB_io.h>
#include <stdint.h>
char * gets( char * s )
#include <stdio.h>
#ifndef REGTEST
-
#include <errno.h>
#include <locale.h>
#include <stdarg.h>
#ifndef REGTEST
+#include <_PDCLIB_io.h>
int printf( const char * _PDCLIB_restrict format, ... )
{
#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 );
}
#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 ) )
#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);
#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 )
{
#ifdef TEST
#include <_PDCLIB_test.h>
#include <stdlib.h>
+#ifndef REGTEST
+#include <_PDCLIB_io.h>
+#endif
int main( void )
{
#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 )
{
#ifdef TEST
#include <_PDCLIB_test.h>
-
#include <errno.h>
-
+#ifndef REGTEST
+#include <_PDCLIB_io.h>
+#endif
#define BUFFERSIZE 500
int main( void )
#ifndef REGTEST
#include <string.h>
-#include <_PDCLIB_glue.h>
+#include <_PDCLIB_io.h>
char * tmpnam( char * s )
{
#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 )
{
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 );
#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 )
{
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 )
{
#include <ctype.h>
#ifndef REGTEST
+#include <_PDCLIB_io.h>
int vfscanf_unlocked( FILE * _PDCLIB_restrict stream,
const char * _PDCLIB_restrict format,
#include <stdarg.h>
#ifndef REGTEST
+#include <_PDCLIB_io.h>
int vsnprintf( char * _PDCLIB_restrict s,
size_t n,
#ifndef REGTEST
#include <ctype.h>
+#include <_PDCLIB_io.h>
int vsscanf( const char * _PDCLIB_restrict s,
const char * _PDCLIB_restrict format,
#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.
#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
#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
#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
#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
\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
#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
-#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>
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 {
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 {
}
}
-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,
}
}
}
-#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
_PDCLIB_size_t *_PDCLIB_restrict _P_insz,
_PDCLIB_mbstate_t *_PDCLIB_restrict _P_ps
);
-} _PDCLIB_charcodec;
+};
#endif
-#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
-#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).
-#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>
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). */
/* -------------------------------------------------------------------------- */
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 */
/* -------------------------------------------------------------------------- */
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
-#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
/* 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
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
* 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
*/\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
_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
#include <stdbool.h>
#ifndef REGTEST
#include <uchar.h>
+#include <_PDCLIB_encoding.h>
static bool asciitoc32(
char32_t **restrict p_outbuf,
return true;
}
-_PDCLIB_charcodec _PDCLIB_ascii_codec = {
+_PDCLIB_charcodec_t _PDCLIB_ascii_codec = {
.__mbstoc32s = asciitoc32,
.__c32stombs = c32toascii,
};
#include <stdbool.h>
#ifndef REGTEST
#include <uchar.h>
+#include <_PDCLIB_encoding.h>
static bool latin1toc32(
char32_t **restrict p_outbuf,
return true;
}
-_PDCLIB_charcodec _PDCLIB_latin1_codec = {
+_PDCLIB_charcodec_t _PDCLIB_latin1_codec = {
.__mbstoc32s = latin1toc32,
.__c32stombs = c32tolatin1,
};
#include <stdint.h>
#include <uchar.h>
#include <assert.h>
+#include <_PDCLIB_encoding.h>
/* Use of the mbstate:
*
END_CONVERSION;
}
-_PDCLIB_charcodec _PDCLIB_utf8_codec = {
+_PDCLIB_charcodec_t _PDCLIB_utf8_codec = {
.__mbstoc32s = utf8toc32,
.__c32stombs = c32toutf8,
};
#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
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,
.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)
}
/* 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.
#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 ) )
#include <limits.h>
#ifndef REGTEST
+#include <_PDCLIB_io.h>
extern const _PDCLIB_fileops_t _PDCLIB_fileops;