/*************************************************************** LIBMPUIO.H This file contains public declarations for LIBMPUIO library. PART OF : MPUIO - library . USAGE : External only . NOTE : Internal character representation is UCS-2. External text representation is UTF-8. Copyright (C) 2000 - 2026 by Andrey V.Kosteltsev. All Rights Reserved. ***************************************************************/ #ifndef __LIB_MPUIO_H #define __LIB_MPUIO_H 1 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /************************************************************************** UTF-16/UCS-2 string-literal support. A configure-time compile test may define MPU_HAVE_UCS2_STRING_LITERALS explicitly. Otherwise recognize C11, C++11, and GNU C extension modes that provide the u"..." prefix. **************************************************************************/ #ifndef MPU_HAVE_UCS2_STRING_LITERALS # if defined( __cplusplus ) # if __cplusplus >= 201103L # define MPU_HAVE_UCS2_STRING_LITERALS 1 # else # define MPU_HAVE_UCS2_STRING_LITERALS 0 # endif # elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L # define MPU_HAVE_UCS2_STRING_LITERALS 1 # elif defined( __GNUC__ ) && !defined( __STRICT_ANSI__ ) # define MPU_HAVE_UCS2_STRING_LITERALS 1 # else # define MPU_HAVE_UCS2_STRING_LITERALS 0 # endif #endif #if MPU_HAVE_UCS2_STRING_LITERALS /* Form a native 16-bit UCS-2/UTF-16 string literal for LIBMPUIO APIs. */ # define MPU_UCS2(s) u##s #else # error "libmpuio requires u\"...\" UCS2 string literal support" #endif typedef struct __mpu_IO_FILE mpu_FILE; /* Read raw bytes from a user-defined cookie stream. */ typedef ssize_t mpu_cookie_read_function_t( void *cookie, char *buf, size_t size ); /* Write raw bytes to a user-defined cookie stream. */ typedef ssize_t mpu_cookie_write_function_t( void *cookie, const char *buf, size_t size ); /* Reposition a user-defined cookie stream and update *position. */ typedef int mpu_cookie_seek_function_t( void *cookie, off_t *position, int whence ); /* Close a user-defined cookie object. */ typedef int mpu_cookie_close_function_t( void *cookie ); typedef struct mpu_cookie_io_functions_t { mpu_cookie_read_function_t *read; mpu_cookie_write_function_t *write; mpu_cookie_seek_function_t *seek; mpu_cookie_close_function_t *close; } mpu_cookie_io_functions_t; /* Saved stream position, analogous to ISO C/glibc fpos_t. */ typedef struct __mpu_fpos_t { off_t __pos; uint32_t __state; } mpu_fpos_t; #define mpu_EOF (-1) #define MPU_IOFBF 0 #define MPU_IOLBF 1 #define MPU_IONBF 2 #define MPU_BUFSIZ 8192 #define MPU_SEEK_SET 0 #define MPU_SEEK_CUR 1 #define MPU_SEEK_END 2 /* Ordinary 8-bit C string API. */ extern __mpu_char8_t *mpu_str8cat( __mpu_char8_t *dest, const __mpu_char8_t *src ); extern __mpu_char8_t *mpu_str8chr( const __mpu_char8_t *s, int c ); extern __mpu_char8_t *mpu_str8chrnul( const __mpu_char8_t *s, int c ); extern int mpu_str8cmp( const __mpu_char8_t *s1, const __mpu_char8_t *s2 ); extern __mpu_char8_t *mpu_str8cpy( __mpu_char8_t *dest, const __mpu_char8_t *src ); extern __mpu_size_t mpu_str8cspn( const __mpu_char8_t *s, const __mpu_char8_t *reject ); extern __mpu_char8_t *mpu_str8dup( const __mpu_char8_t *s ); extern __mpu_char8_t *mpu_str8ndup( const __mpu_char8_t *s, __mpu_size_t n ); extern __mpu_size_t mpu_str8len( const __mpu_char8_t *s ); extern __mpu_char8_t *mpu_str8ncat( __mpu_char8_t *dest, const __mpu_char8_t *src, __mpu_size_t n ); extern int mpu_str8ncmp( const __mpu_char8_t *s1, const __mpu_char8_t *s2, __mpu_size_t n ); extern __mpu_char8_t *mpu_str8ncpy( __mpu_char8_t *dest, const __mpu_char8_t *src, __mpu_size_t n ); extern __mpu_size_t mpu_str8nlen( const __mpu_char8_t *s, __mpu_size_t maxlen ); extern __mpu_char8_t *mpu_str8pbrk( const __mpu_char8_t *s, const __mpu_char8_t *accept ); extern __mpu_char8_t *mpu_str8rchr( const __mpu_char8_t *s, int c ); extern __mpu_size_t mpu_str8spn( const __mpu_char8_t *s, const __mpu_char8_t *accept ); extern __mpu_char8_t *mpu_str8pcpy( __mpu_char8_t *dest, const __mpu_char8_t *src ); extern __mpu_char8_t *mpu_str8pncpy( __mpu_char8_t *dest, const __mpu_char8_t *src, __mpu_size_t n ); extern __mpu_char8_t *mpu_str8str( const __mpu_char8_t *haystack, const __mpu_char8_t *needle ); extern __mpu_char8_t *mpu_str8rstr( const __mpu_char8_t *haystack, const __mpu_char8_t *needle ); extern __mpu_char8_t *mpu_str8tok( __mpu_char8_t *s, const __mpu_char8_t *delim ); extern __mpu_char8_t *mpu_str8tok_r( __mpu_char8_t *s, const __mpu_char8_t *delim, __mpu_char8_t **saveptr ); /* Strict UCS-2 string API. */ extern __mpu_char16_t *mpu_str16cat( __mpu_char16_t *dest, const __mpu_char16_t *src ); extern __mpu_char16_t *mpu_str16chr( const __mpu_char16_t *s, __mpu_char16_t c ); extern __mpu_char16_t *mpu_str16chrnul( const __mpu_char16_t *s, __mpu_char16_t c ); extern int mpu_str16cmp( const __mpu_char16_t *s1, const __mpu_char16_t *s2 ); extern __mpu_char16_t *mpu_str16cpy( __mpu_char16_t *dest, const __mpu_char16_t *src ); extern __mpu_size_t mpu_str16cspn( const __mpu_char16_t *s, const __mpu_char16_t *reject ); extern __mpu_char16_t *mpu_str16dup( const __mpu_char16_t *s ); extern __mpu_char16_t *mpu_str16ndup( const __mpu_char16_t *s, __mpu_size_t n ); extern __mpu_size_t mpu_str16len( const __mpu_char16_t *s ); extern __mpu_char16_t *mpu_str16ncat( __mpu_char16_t *dest, const __mpu_char16_t *src, __mpu_size_t n ); extern int mpu_str16ncmp( const __mpu_char16_t *s1, const __mpu_char16_t *s2, __mpu_size_t n ); extern __mpu_char16_t *mpu_str16ncpy( __mpu_char16_t *dest, const __mpu_char16_t *src, __mpu_size_t n ); extern __mpu_size_t mpu_str16nlen( const __mpu_char16_t *s, __mpu_size_t maxlen ); extern __mpu_char16_t *mpu_str16pbrk( const __mpu_char16_t *s, const __mpu_char16_t *accept ); extern __mpu_char16_t *mpu_str16rchr( const __mpu_char16_t *s, __mpu_char16_t c ); extern __mpu_size_t mpu_str16spn( const __mpu_char16_t *s, const __mpu_char16_t *accept ); extern __mpu_char16_t *mpu_str16pcpy( __mpu_char16_t *dest, const __mpu_char16_t *src ); extern __mpu_char16_t *mpu_str16pncpy( __mpu_char16_t *dest, const __mpu_char16_t *src, __mpu_size_t n ); extern __mpu_char16_t *mpu_str16str( const __mpu_char16_t *haystack, const __mpu_char16_t *needle ); extern __mpu_char16_t *mpu_str16rstr( const __mpu_char16_t *haystack, const __mpu_char16_t *needle ); extern __mpu_char16_t *mpu_str16tok( __mpu_char16_t *s, const __mpu_char16_t *delim ); extern __mpu_char16_t *mpu_str16tok_r( __mpu_char16_t *s, const __mpu_char16_t *delim, __mpu_char16_t **saveptr ); /* UTF-8 string API. Length/count arguments are Unicode characters. */ extern const __mpu_char8_t *mpu_utf8next( const __mpu_char8_t *p ); extern const __mpu_char8_t *mpu_utf8prev( const __mpu_char8_t *start, const __mpu_char8_t *p ); extern const __mpu_char8_t *mpu_utf8last( const __mpu_char8_t *s ); extern const __mpu_char8_t *mpu_utf8get( const __mpu_char8_t *p, __mpu_char32_t *value ); extern __mpu_size_t mpu_utf8len( const __mpu_char8_t *s ); extern __mpu_size_t mpu_utf8nlen( const __mpu_char8_t *s, __mpu_size_t maxlen ); extern __mpu_size_t mpu_utf8bytes( const __mpu_char8_t *s ); extern __mpu_size_t mpu_utf8nbytes( const __mpu_char8_t *s, __mpu_size_t n ); extern int mpu_utf8valid( const __mpu_char8_t *s ); extern __mpu_size_t mpu_utf8_offset2index( const __mpu_char8_t *s, __mpu_size_t offset ); extern __mpu_size_t mpu_utf8_index2offset( const __mpu_char8_t *s, __mpu_size_t index ); extern int mpu_utf8cmp( const __mpu_char8_t *s1, const __mpu_char8_t *s2 ); extern int mpu_utf8ncmp( const __mpu_char8_t *s1, const __mpu_char8_t *s2, __mpu_size_t n ); extern __mpu_char8_t *mpu_utf8cpy( __mpu_char8_t *dest, const __mpu_char8_t *src ); extern __mpu_char8_t *mpu_utf8cat( __mpu_char8_t *dest, const __mpu_char8_t *src ); extern __mpu_char8_t *mpu_utf8ncpy( __mpu_char8_t *dest, const __mpu_char8_t *src, __mpu_size_t n ); extern __mpu_char8_t *mpu_utf8ncat( __mpu_char8_t *dest, const __mpu_char8_t *src, __mpu_size_t n ); extern __mpu_char8_t *mpu_utf8pcpy( __mpu_char8_t *dest, const __mpu_char8_t *src ); extern __mpu_char8_t *mpu_utf8pncpy( __mpu_char8_t *dest, const __mpu_char8_t *src, __mpu_size_t n ); extern __mpu_char8_t *mpu_utf8chr( const __mpu_char8_t *s, __mpu_char32_t c ); extern __mpu_char8_t *mpu_utf8chrnul( const __mpu_char8_t *s, __mpu_char32_t c ); extern __mpu_char8_t *mpu_utf8rchr( const __mpu_char8_t *s, __mpu_char32_t c ); extern __mpu_size_t mpu_utf8spn( const __mpu_char8_t *s, const __mpu_char8_t *accept ); extern __mpu_size_t mpu_utf8cspn( const __mpu_char8_t *s, const __mpu_char8_t *reject ); extern __mpu_char8_t *mpu_utf8pbrk( const __mpu_char8_t *s, const __mpu_char8_t *accept ); extern __mpu_char8_t *mpu_utf8str( const __mpu_char8_t *haystack, const __mpu_char8_t *needle ); extern __mpu_char8_t *mpu_utf8rstr( const __mpu_char8_t *haystack, const __mpu_char8_t *needle ); extern __mpu_char8_t *mpu_utf8tok( __mpu_char8_t *s, const __mpu_char8_t *delim ); extern __mpu_char8_t *mpu_utf8tok_r( __mpu_char8_t *s, const __mpu_char8_t *delim, __mpu_char8_t **saveptr ); extern __mpu_char8_t *mpu_utf8dup( const __mpu_char8_t *s ); extern __mpu_char8_t *mpu_utf8ndup( const __mpu_char8_t *s, __mpu_size_t n ); /* Explicit strict UCS-2 <-> UTF-8 conversion, analogous to wcstombs/mbstowcs. */ extern __mpu_size_t mpu_ucs2_to_utf8( __mpu_char8_t *dest, const __mpu_char16_t *src, __mpu_size_t nb ); extern __mpu_size_t mpu_utf8_to_ucs2( __mpu_char16_t *dest, const __mpu_char8_t *src, __mpu_size_t nb ); /* Standard LIBMPUIO input stream. */ extern mpu_FILE *mpu_stdin; /* Standard LIBMPUIO output stream. */ extern mpu_FILE *mpu_stdout; /* Standard LIBMPUIO diagnostic stream. */ extern mpu_FILE *mpu_stderr; /* Open a UTF-8 named file and return an MPU stream. */ extern mpu_FILE *mpu_fopen( const char *filename, const char *mode ); /* Attach an existing POSIX file descriptor to a new MPU stream. */ extern mpu_FILE *mpu_fdopen( int fd, const char *mode ); /* Reopen STREAM on FILENAME using a new stdio-style mode. */ extern mpu_FILE *mpu_freopen( const char *filename, const char *mode, mpu_FILE *stream ); /* Create an anonymous temporary read/write real-file stream. */ extern mpu_FILE *mpu_tmpfile( void ); /* Open a unidirectional shell-command pipe as a LIBMPUIO stream. */ extern mpu_FILE *mpu_popen( const char *command, const char *mode ); /* Close a stream opened by mpu_popen() and wait for its command. */ extern int mpu_pclose( mpu_FILE *stream ); /* Open a byte-oriented user callback object as a LIBMPUIO stream. */ extern mpu_FILE *mpu_fopencookie( void *cookie, const char *mode, mpu_cookie_io_functions_t io_functions ); /* Open caller-owned UCS-2 memory as a text stream; SIZE is code units. */ extern mpu_FILE *mpu_fmemopen( __mpu_char16_t *buffer, size_t size, const char *mode ); /* Open a dynamically growing UCS-2 output memory stream. */ extern mpu_FILE *mpu_open_memstream( __mpu_char16_t **buffer, size_t *size ); /* Flush and close STREAM. */ extern int mpu_fclose( mpu_FILE *stream ); /* Flush STREAM, or all output streams when STREAM is NULL. */ extern int mpu_fflush( mpu_FILE *stream ); /* Flush all currently writing line-buffered streams. */ extern void mpu_flushlbf( void ); /* Discard buffered STREAM state without backend I/O. */ extern int mpu_fpurge( mpu_FILE *stream ); /* Discard buffered STREAM state without locking it. */ extern int mpu_fpurge_unlocked( mpu_FILE *stream ); /* Convert ERRNUM diagnostic text to caller-owned strict UCS-2 storage. */ extern int mpu_strerror_r( int errnum, __mpu_char16_t *buffer, size_t size ); /* Print the current errno diagnostic to mpu_stderr. */ extern void mpu_perror( const __mpu_char16_t *prefix ); /* Flush one STREAM without locking it; STREAM must not be NULL. */ extern int mpu_fflush_unlocked( mpu_FILE *stream ); /* Read raw bytes without UTF-8/UCS-2 conversion. */ extern size_t mpu_fread( void *ptr, size_t size, size_t nmemb, mpu_FILE *stream ); /* Write raw bytes without UTF-8/UCS-2 conversion. */ extern size_t mpu_fwrite( const void *ptr, size_t size, size_t nmemb, mpu_FILE *stream ); /* Read raw bytes without locking STREAM. */ extern size_t mpu_fread_unlocked( void *ptr, size_t size, size_t nmemb, mpu_FILE *stream ); /* Write raw bytes without locking STREAM. */ extern size_t mpu_fwrite_unlocked( const void *ptr, size_t size, size_t nmemb, mpu_FILE *stream ); /* Reposition STREAM using MPU_SEEK_SET/CUR/END. */ extern int mpu_fseek( mpu_FILE *stream, off_t offset, int whence ); /* Reposition STREAM using an off_t file offset. */ extern int mpu_fseeko( mpu_FILE *stream, off_t offset, int whence ); /* Return the current STREAM position. */ extern off_t mpu_ftell( mpu_FILE *stream ); /* Return the current STREAM position as off_t. */ extern off_t mpu_ftello( mpu_FILE *stream ); /* Save STREAM position and conversion state in POS. */ extern int mpu_fgetpos( mpu_FILE *stream, mpu_fpos_t *pos ); /* Restore STREAM position and conversion state from POS. */ extern int mpu_fsetpos( mpu_FILE *stream, const mpu_fpos_t *pos ); /* Rewind STREAM to its beginning and clear EOF/error state. */ extern void mpu_rewind( mpu_FILE *stream ); /* Read one UCS-2 character; UTF-8 is decoded on file streams. */ extern int mpu_fgetc( mpu_FILE *stream ); /* Alias of mpu_fgetc(). */ extern int mpu_getc( mpu_FILE *stream ); /* Read one UCS-2 character from mpu_stdin. */ extern int mpu_getchar( void ); /* Read one UCS-2 character without locking STREAM. */ extern int mpu_fgetc_unlocked( mpu_FILE *stream ); /* Alias of mpu_fgetc_unlocked(). */ extern int mpu_getc_unlocked( mpu_FILE *stream ); /* Read one UCS-2 character from mpu_stdin without locking it. */ extern int mpu_getchar_unlocked( void ); /* Push one UCS-2 character back to STREAM. */ extern int mpu_ungetc( __mpu_char16_t c, mpu_FILE *stream ); /* Write one UCS-2 character; UTF-8 is encoded on file streams. */ extern int mpu_fputc( __mpu_char16_t c, mpu_FILE *stream ); /* Alias of mpu_fputc(). */ extern int mpu_putc( __mpu_char16_t c, mpu_FILE *stream ); /* Write one UCS-2 character to mpu_stdout. */ extern int mpu_putchar( __mpu_char16_t c ); /* Write one UCS-2 character without locking STREAM. */ extern int mpu_fputc_unlocked( __mpu_char16_t c, mpu_FILE *stream ); /* Alias of mpu_fputc_unlocked(). */ extern int mpu_putc_unlocked( __mpu_char16_t c, mpu_FILE *stream ); /* Write one UCS-2 character to mpu_stdout without locking it. */ extern int mpu_putchar_unlocked( __mpu_char16_t c ); /* Read one UCS-2 line/string of at most N-1 characters. */ extern __mpu_char16_t *mpu_fgets( __mpu_char16_t *s, int n, mpu_FILE *stream ); /* Write a NUL-terminated UCS-2 string to STREAM. */ extern int mpu_fputs( const __mpu_char16_t *s, mpu_FILE *stream ); /* Read one UCS-2 line/string without locking STREAM. */ extern __mpu_char16_t *mpu_fgets_unlocked( __mpu_char16_t *s, int n, mpu_FILE *stream ); /* Write a NUL-terminated UCS-2 string without locking STREAM. */ extern int mpu_fputs_unlocked( const __mpu_char16_t *s, mpu_FILE *stream ); /* Write a UCS-2 string and newline to mpu_stdout. */ extern int mpu_puts( const __mpu_char16_t *s ); /* Read through DELIMITER, growing *LINEPTR as required. */ extern ssize_t mpu_getdelim( __mpu_char16_t **lineptr, size_t *n, __mpu_char16_t delimiter, mpu_FILE *stream ); /* Read one line, growing *LINEPTR as required. */ extern ssize_t mpu_getline( __mpu_char16_t **lineptr, size_t *n, mpu_FILE *stream ); /* Read through DELIMITER without acquiring STREAM lock. */ extern ssize_t mpu_getdelim_unlocked( __mpu_char16_t **lineptr, size_t *n, __mpu_char16_t delimiter, mpu_FILE *stream ); /* Read one line without acquiring STREAM lock. */ extern ssize_t mpu_getline_unlocked( __mpu_char16_t **lineptr, size_t *n, mpu_FILE *stream ); /* Formatted output to STREAM using a va_list. */ extern int mpu_vfprintf( mpu_FILE *stream, const __mpu_char16_t *format, va_list args ); /* Formatted output to STREAM. */ extern int mpu_fprintf( mpu_FILE *stream, const __mpu_char16_t *format, ... ); /* Formatted output to mpu_stdout using a va_list. */ extern int mpu_vprintf( const __mpu_char16_t *format, va_list args ); /* Formatted output to mpu_stdout. */ extern int mpu_printf( const __mpu_char16_t *format, ... ); /* Formatted output to STREAM using a va_list without locking STREAM. */ extern int mpu_vfprintf_unlocked( mpu_FILE *stream, const __mpu_char16_t *format, va_list args ); /* Formatted output to STREAM without locking STREAM. */ extern int mpu_fprintf_unlocked( mpu_FILE *stream, const __mpu_char16_t *format, ... ); /* Formatted output to mpu_stdout using a va_list without locking it. */ extern int mpu_vprintf_unlocked( const __mpu_char16_t *format, va_list args ); /* Formatted output to mpu_stdout without locking it. */ extern int mpu_printf_unlocked( const __mpu_char16_t *format, ... ); /* Formatted output to an unbounded UCS-2 destination string. */ extern int mpu_vsprintf( __mpu_char16_t *string, const __mpu_char16_t *format, va_list args ); /* Formatted output to an unbounded UCS-2 destination string. */ extern int mpu_sprintf( __mpu_char16_t *string, const __mpu_char16_t *format, ... ); /* Bounded UCS-2 formatted output with snprintf count semantics. */ extern int mpu_vsnprintf( __mpu_char16_t *string, size_t size, const __mpu_char16_t *format, va_list args ); /* Bounded UCS-2 formatted output with snprintf count semantics. */ extern int mpu_snprintf( __mpu_char16_t *string, size_t size, const __mpu_char16_t *format, ... ); /* Allocate a UCS-2 string containing formatted output. */ extern int mpu_vasprintf( __mpu_char16_t **string, const __mpu_char16_t *format, va_list args ); /* Allocate a UCS-2 string containing formatted output. */ extern int mpu_asprintf( __mpu_char16_t **string, const __mpu_char16_t *format, ... ); /* Write formatted UCS-2 text as UTF-8 to an existing descriptor. */ extern int mpu_vdprintf( int fd, const __mpu_char16_t *format, va_list args ); /* Write formatted UCS-2 text as UTF-8 to an existing descriptor. */ extern int mpu_dprintf( int fd, const __mpu_char16_t *format, ... ); /* Formatted input from STREAM using a va_list. */ extern int mpu_vfscanf( mpu_FILE *stream, const __mpu_char16_t *format, va_list args ); /* Formatted input from STREAM. */ extern int mpu_fscanf( mpu_FILE *stream, const __mpu_char16_t *format, ... ); /* Formatted input from mpu_stdin using a va_list. */ extern int mpu_vscanf( const __mpu_char16_t *format, va_list args ); /* Formatted input from mpu_stdin. */ extern int mpu_scanf( const __mpu_char16_t *format, ... ); /* Formatted input from STREAM using a va_list without locking STREAM. */ extern int mpu_vfscanf_unlocked( mpu_FILE *stream, const __mpu_char16_t *format, va_list args ); /* Formatted input from STREAM without locking STREAM. */ extern int mpu_fscanf_unlocked( mpu_FILE *stream, const __mpu_char16_t *format, ... ); /* Formatted input from mpu_stdin using a va_list without locking it. */ extern int mpu_vscanf_unlocked( const __mpu_char16_t *format, va_list args ); /* Formatted input from mpu_stdin without locking it. */ extern int mpu_scanf_unlocked( const __mpu_char16_t *format, ... ); /* Formatted input from a NUL-terminated UCS-2 string using va_list. */ extern int mpu_vsscanf( const __mpu_char16_t *string, const __mpu_char16_t *format, va_list args ); /* Formatted input from a NUL-terminated UCS-2 string. */ extern int mpu_sscanf( const __mpu_char16_t *string, const __mpu_char16_t *format, ... ); /* Return the POSIX file descriptor for a real file stream. */ extern int mpu_fileno( mpu_FILE *stream ); /* Return STREAM file descriptor without acquiring its lock. */ extern int mpu_fileno_unlocked( mpu_FILE *stream ); /* Return nonzero when STREAM has reached end of input. */ extern int mpu_feof( mpu_FILE *stream ); /* Return STREAM EOF indicator without acquiring its lock. */ extern int mpu_feof_unlocked( mpu_FILE *stream ); /* Return nonzero when STREAM has an I/O error. */ extern int mpu_ferror( mpu_FILE *stream ); /* Return STREAM error indicator without acquiring its lock. */ extern int mpu_ferror_unlocked( mpu_FILE *stream ); /* Clear STREAM EOF and error indicators. */ extern void mpu_clearerr( mpu_FILE *stream ); /* Clear STREAM EOF/error indicators without acquiring its lock. */ extern void mpu_clearerr_unlocked( mpu_FILE *stream ); /* Lock STREAM for exclusive use by the calling thread. */ extern void mpu_flockfile( mpu_FILE *stream ); /* Try to lock STREAM; return zero on success and nonzero if busy. */ extern int mpu_ftrylockfile( mpu_FILE *stream ); /* Release one lock acquired on STREAM by the calling thread. */ extern void mpu_funlockfile( mpu_FILE *stream ); /* Select full/line/no buffering and optionally install BUF. */ extern int mpu_setvbuf( mpu_FILE *stream, unsigned char *buf, int mode, size_t size ); /* Select full buffering with BUF or unbuffered mode with NULL. */ extern void mpu_setbuf( mpu_FILE *stream, unsigned char *buf ); /* Select line buffering using an internally allocated buffer. */ extern void mpu_setlinebuf( mpu_FILE *stream ); #ifdef __cplusplus } #endif #endif /* __LIB_MPUIO_H */