1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
|
/***************************************************************
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 <errno.h>
#include <dirent.h>
#include <locale.h>
#include <ctype.h>
#include <fcntl.h>
#include <pthread.h>
#include <inttypes.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdint.h>
#include <uchar.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <libmpu.h>
#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 */
|