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
|
/***************************************************************
MPU-SCANF.C
This file contains public formatted input functions for
LIBMPUIO library.
PART OF : MPUIO - library .
Copyright (C) 2000 - 2026 by Andrey V.Kosteltsev.
All Rights Reserved.
***************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <libmpuio.h>
#include <mpu-symbols.h>
#include <mpu-libio.h>
/***************************************************************
Read formatted input from STREAM using a va_list.
***************************************************************/
int
mpu_vfscanf( mpu_FILE *stream, const __mpu_char16_t *format, va_list args )
{
return( __mpu_IO_vfscanf( stream, format, args ) );
} /* End of mpu_vfscanf() */
/***************************************************************
Read formatted input from STREAM.
***************************************************************/
int
mpu_fscanf( mpu_FILE *stream, const __mpu_char16_t *format, ... )
{
va_list args;
int ret;
va_start( args, format );
ret = mpu_vfscanf( stream, format, args );
va_end( args );
return( ret );
} /* End of mpu_fscanf() */
/***************************************************************
Read formatted input from mpu_stdin using a va_list.
***************************************************************/
int
mpu_vscanf( const __mpu_char16_t *format, va_list args )
{
return( mpu_vfscanf( mpu_stdin, format, args ) );
} /* End of mpu_vscanf() */
/***************************************************************
Read formatted input from mpu_stdin.
***************************************************************/
int
mpu_scanf( const __mpu_char16_t *format, ... )
{
va_list args;
int ret;
va_start( args, format );
ret = mpu_vscanf( format, args );
va_end( args );
return( ret );
} /* End of mpu_scanf() */
/***************************************************************
Read formatted input from STREAM using a va_list without
locking STREAM.
***************************************************************/
int
mpu_vfscanf_unlocked( mpu_FILE *stream, const __mpu_char16_t *format,
va_list args )
{
return( __mpu_IO_vfscanf_unlocked( stream, format, args ) );
} /* End of mpu_vfscanf_unlocked() */
/***************************************************************
Read formatted input from STREAM without locking STREAM.
***************************************************************/
int
mpu_fscanf_unlocked( mpu_FILE *stream, const __mpu_char16_t *format, ... )
{
va_list args;
int ret;
va_start( args, format );
ret = mpu_vfscanf_unlocked( stream, format, args );
va_end( args );
return( ret );
} /* End of mpu_fscanf_unlocked() */
/***************************************************************
Read formatted input from mpu_stdin using a va_list without
locking the standard input stream.
***************************************************************/
int
mpu_vscanf_unlocked( const __mpu_char16_t *format, va_list args )
{
return( mpu_vfscanf_unlocked( mpu_stdin, format, args ) );
} /* End of mpu_vscanf_unlocked() */
/***************************************************************
Read formatted input from mpu_stdin without locking it.
***************************************************************/
int
mpu_scanf_unlocked( const __mpu_char16_t *format, ... )
{
va_list args;
int ret;
va_start( args, format );
ret = mpu_vscanf_unlocked( format, args );
va_end( args );
return( ret );
} /* End of mpu_scanf_unlocked() */
/***************************************************************
Read formatted input from a NUL-terminated UCS-2 string using
a va_list. No UTF-8 conversion is performed for string input.
***************************************************************/
int
mpu_vsscanf( const __mpu_char16_t *string, const __mpu_char16_t *format,
va_list args )
{
mpu_FILE *stream;
size_t length = 0;
int ret;
if( string == (const __mpu_char16_t *)0 ||
format == (const __mpu_char16_t *)0 )
{
errno = EINVAL;
return( mpu_EOF );
}
while( string[length] ) ++length;
stream = __mpu_IO_str_open_readonly( string, length );
if( stream == (mpu_FILE *)0 ) return( mpu_EOF );
ret = __mpu_IO_vfscanf( stream, format, args );
mpu_fclose( stream );
return( ret );
} /* End of mpu_vsscanf() */
/***************************************************************
Read formatted input from a NUL-terminated UCS-2 string.
***************************************************************/
int
mpu_sscanf( const __mpu_char16_t *string, const __mpu_char16_t *format, ... )
{
va_list args;
int ret;
va_start( args, format );
ret = mpu_vsscanf( string, format, args );
va_end( args );
return( ret );
} /* End of mpu_sscanf() */
|