+#if defined(_PDCLIB_OSFD_T)\r
+ _PDCLIB_OSFD_T osfd;\r
+#endif\r
+ void * pointer;\r
+ _PDCLIB_uintptr_t uval;\r
+ _PDCLIB_intptr_t sval; \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
+/* 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( _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( _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( _PDCLIB_file_t * stream, \r
+ _PDCLIB_int_fast64_t offset, int whence );\r
+\r
+/* File backend I/O operations\r
+ *\r
+ * PDCLib will call through to these methods as needed to implement the stdio\r
+ * functions.\r
+ */\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
+ * Returns true if bytes were read successfully; on end of file, returns\r
+ * true with *numBytesRead == 0.\r
+ *\r
+ * On error, returns false and sets errno appropriately. *numBytesRead is\r
+ * ignored in this situation.\r
+ */\r
+ _PDCLIB_bool (*read)( _PDCLIB_fd_t self, \r
+ void * buf, \r
+ _PDCLIB_size_t length, \r
+ _PDCLIB_size_t * numBytesRead );\r
+\r
+ /*! Write length bytes to the file from buf; returning the number of bytes\r
+ * actually written in *numBytesWritten\r
+ *\r
+ * Returns true if bytes were written successfully. On error, returns false\r
+ * and setss errno appropriately (as with read, *numBytesWritten is \r
+ * ignored)\r
+ */\r
+ _PDCLIB_bool (*write)( _PDCLIB_fd_t self, const void * buf, \r
+ _PDCLIB_size_t length, _PDCLIB_size_t * numBytesWritten );\r
+\r
+ /* Seek to the file offset specified by offset, from location whence, which\r
+ * may be one of the standard constants SEEK_SET/SEEK_CUR/SEEK_END\r
+ */\r
+ _PDCLIB_bool (*seek)( _PDCLIB_fd_t self, _PDCLIB_int_fast64_t offset, \r
+ int whence, _PDCLIB_int_fast64_t *newPos );\r
+\r
+ void (*close)( _PDCLIB_fd_t self );\r
+\r
+ /*! Behaves as read does, except for wide characters. Both length and \r
+ * *numCharsRead represent counts of characters, not bytes.\r
+ *\r
+ * This function is optional; if missing, PDCLib will buffer the character\r
+ * data as bytes and perform translation directly into the user's buffers.\r
+ * It is useful if your backend can directly take wide characters (for \r
+ * example, the Windows console)\r
+ */\r
+ _PDCLIB_bool (*wread)( _PDCLIB_fd_t self, _PDCLIB_wchar_t * buf, \r
+ _PDCLIB_size_t length, _PDCLIB_size_t * numCharsRead );\r
+\r
+ /* Behaves as write does, except for wide characters. As with wread, both\r
+ * length and *numCharsWritten are character counts.\r
+ *\r
+ * This function is also optional; if missing, PDCLib will buffer the \r
+ * character data as bytes and do translation directly from the user's \r
+ * buffers. You only need to implement this if your backend can directly \r
+ * take wide characters (for example, the Windows console)\r
+ */\r
+ _PDCLIB_bool (*wwrite)( _PDCLIB_fd_t self, const _PDCLIB_wchar_t * buf, \r
+ _PDCLIB_size_t length, _PDCLIB_size_t * numCharsWritten );\r