/*************************************************************** MPU-LIBIO.H This file contains internal declarations for LIBMPUIO stream operations. PART OF : MPUIO - library . USAGE : Internal only . NOTE : NONE . Copyright (C) 2000 - 2026 by Andrey V.Kosteltsev. All Rights Reserved. ***************************************************************/ #ifndef __MPU_LIBIO_H #define __MPU_LIBIO_H 1 #ifdef HAVE_CONFIG_H #include #endif #include #include #define __MPU_IO_MAGIC 0x4d505549U #define __MPU_IO_NO_READS 0x00000001U #define __MPU_IO_NO_WRITES 0x00000002U #define __MPU_IO_EOF_SEEN 0x00000004U #define __MPU_IO_ERR_SEEN 0x00000008U #define __MPU_IO_USER_BUF 0x00000010U #define __MPU_IO_LINE_BUF 0x00000020U #define __MPU_IO_UNBUFFERED 0x00000040U #define __MPU_IO_READING 0x00000080U #define __MPU_IO_WRITING 0x00000100U #define __MPU_IO_APPEND 0x00000200U #define __MPU_IO_STATIC 0x00000400U #define __MPU_IO_STRING 0x00000800U #define __MPU_IO_COUNTED 0x00001000U #define __MPU_IO_MEMSTREAM 0x00002000U #define __MPU_IO_PIPE 0x00004000U #define __MPU_IO_COOKIE 0x00008000U #define __MPU_IO_NOLIST 0x00010000U struct __mpu_IO_jump_t; struct __mpu_IO_FILE { __mpu_uint32_t _magic; unsigned int _flags; int _fileno; unsigned char *_read_base; unsigned char *_read_ptr; unsigned char *_read_end; unsigned char *_write_base; unsigned char *_write_ptr; unsigned char *_write_end; unsigned char *_buf_base; unsigned char *_buf_end; pthread_mutex_t _lock; struct __mpu_IO_FILE *_next; unsigned int _pins; unsigned int _closing; void *_cookie; unsigned int _unget_count; __mpu_char16_t _unget_chars[8]; }; struct __mpu_IO_FILE_plus { struct __mpu_IO_FILE file; const struct __mpu_IO_jump_t *vtable; }; #define __MPU_IO_PLUS(STREAM) \ ((struct __mpu_IO_FILE_plus *)(void *)(STREAM)) #define __MPU_IO_JUMPS(STREAM) \ (__MPU_IO_PLUS( STREAM )->vtable) struct __mpu_IO_jump_t { int (*finish)( mpu_FILE *stream ); int (*underflow)( mpu_FILE *stream ); int (*overflow)( mpu_FILE *stream, int c ); int (*sync)( mpu_FILE *stream ); int (*setbuf)( mpu_FILE *stream, unsigned char *buf, int mode, size_t size ); off_t (*seekoff)( mpu_FILE *stream, off_t offset, int whence ); off_t (*seekpos)( mpu_FILE *stream, off_t position ); int (*flush)( mpu_FILE *stream ); int (*close)( mpu_FILE *stream ); int (*seek)( mpu_FILE *stream, off_t offset, int whence ); off_t (*tell)( mpu_FILE *stream ); int (*get_byte)( mpu_FILE *stream ); int (*put_byte)( unsigned char c, mpu_FILE *stream ); size_t (*xsgetn)( mpu_FILE *stream, void *data, size_t size ); size_t (*xsputn)( mpu_FILE *stream, const void *data, size_t size ); int (*get_char)( mpu_FILE *stream, __mpu_char16_t *wc ); int (*put_char)( __mpu_char16_t wc, mpu_FILE *stream ); }; typedef struct __mpu_IO_cookie_file { void *user_cookie; mpu_cookie_io_functions_t io; } __mpu_IO_cookie_file; typedef struct __mpu_IO_strfile { __mpu_char16_t *buffer; size_t capacity; size_t length; size_t pos; int nul_terminated; int dynamic; __mpu_char16_t **publish_buffer; size_t *publish_size; } __mpu_IO_strfile; extern pthread_mutex_t __mpu_IO_list_lock; extern mpu_FILE *__mpu_IO_list_all; extern const struct __mpu_IO_jump_t __mpu_IO_file_jumps; extern const struct __mpu_IO_jump_t __mpu_IO_str_jumps; extern const struct __mpu_IO_jump_t __mpu_IO_cookie_jumps; extern int __mpu_IO_lock_init( pthread_mutex_t *lock ); extern int __mpu_IO_parse_mode( const char *mode, unsigned int *flags, int *oflags, int for_open ); extern int __mpu_IO_valid( mpu_FILE *stream ); extern void __mpu_IO_link_in( mpu_FILE *stream ); extern void __mpu_IO_unlink_locked( mpu_FILE *stream ); extern void __mpu_IO_unlink( mpu_FILE *stream ); extern mpu_FILE *__mpu_IO_file_open( int fd, unsigned int flags ); extern int __mpu_IO_doallocbuf( mpu_FILE *stream ); extern int __mpu_IO_file_finish_unlocked( mpu_FILE *stream ); extern int __mpu_IO_file_underflow_unlocked( mpu_FILE *stream ); extern int __mpu_IO_file_overflow_unlocked( mpu_FILE *stream, int c ); extern int __mpu_IO_file_sync_unlocked( mpu_FILE *stream ); extern int __mpu_IO_file_setbuf_unlocked( mpu_FILE *stream, unsigned char *buf, int mode, size_t size ); extern off_t __mpu_IO_file_seekoff_unlocked( mpu_FILE *stream, off_t offset, int whence ); extern off_t __mpu_IO_file_seekpos_unlocked( mpu_FILE *stream, off_t position ); extern int __mpu_IO_file_flush_unlocked( mpu_FILE *stream ); extern int __mpu_IO_file_sync_input_unlocked( mpu_FILE *stream ); extern int __mpu_IO_file_get_byte_unlocked( mpu_FILE *stream ); extern int __mpu_IO_file_put_byte_unlocked( unsigned char c, mpu_FILE *stream ); extern size_t __mpu_IO_file_xsgetn_unlocked( mpu_FILE *stream, void *data, size_t size ); extern size_t __mpu_IO_file_xsputn_unlocked( mpu_FILE *stream, const void *data, size_t size ); extern int __mpu_IO_file_seek_unlocked( mpu_FILE *stream, off_t offset, int whence ); extern off_t __mpu_IO_file_tell_unlocked( mpu_FILE *stream ); extern int __mpu_IO_file_close_unlocked( mpu_FILE *stream ); extern int __mpu_IO_finish_unlocked( mpu_FILE *stream ); extern int __mpu_IO_underflow_unlocked( mpu_FILE *stream ); extern int __mpu_IO_overflow_unlocked( mpu_FILE *stream, int c ); extern int __mpu_IO_sync_unlocked( mpu_FILE *stream ); extern int __mpu_IO_setbuf_unlocked( mpu_FILE *stream, unsigned char *buf, int mode, size_t size ); extern off_t __mpu_IO_seekoff_unlocked( mpu_FILE *stream, off_t offset, int whence ); extern off_t __mpu_IO_seekpos_unlocked( mpu_FILE *stream, off_t position ); extern int __mpu_IO_flush_unlocked( mpu_FILE *stream ); extern int __mpu_IO_get_byte_unlocked( mpu_FILE *stream ); extern int __mpu_IO_put_byte_unlocked( unsigned char c, mpu_FILE *stream ); extern size_t __mpu_IO_xsgetn_unlocked( mpu_FILE *stream, void *data, size_t size ); extern size_t __mpu_IO_xsputn_unlocked( mpu_FILE *stream, const void *data, size_t size ); extern int __mpu_IO_get_char_unlocked( mpu_FILE *stream, __mpu_char16_t *wc ); extern int __mpu_IO_put_char_unlocked( __mpu_char16_t wc, mpu_FILE *stream ); extern int __mpu_IO_unget_char_unlocked( __mpu_char16_t wc, mpu_FILE *stream ); extern int __mpu_UTF8_decode_unlocked( mpu_FILE *stream, __mpu_char16_t *wc ); extern int __mpu_UTF8_encode_unlocked( __mpu_char16_t wc, mpu_FILE *stream ); extern mpu_FILE *__mpu_IO_str_open( __mpu_char16_t *buffer, size_t capacity, size_t length, unsigned int flags ); extern mpu_FILE *__mpu_IO_str_open_readonly( const __mpu_char16_t *buffer, size_t length ); extern mpu_FILE *__mpu_IO_str_open_counted( __mpu_char16_t *buffer, size_t capacity ); extern mpu_FILE *__mpu_IO_str_open_memstream( __mpu_char16_t **buffer, size_t *size, unsigned int flags ); extern int __mpu_IO_vfprintf( mpu_FILE *stream, const __mpu_char16_t *format, va_list args ); extern int __mpu_IO_vfprintf_unlocked( mpu_FILE *stream, const __mpu_char16_t *format, va_list args ); extern int __mpu_IO_vfscanf( mpu_FILE *stream, const __mpu_char16_t *format, va_list args ); extern int __mpu_IO_vfscanf_unlocked( mpu_FILE *stream, const __mpu_char16_t *format, va_list args ); #endif /* __MPU_LIBIO_H */