2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Scan a stream and write the result in the parameters.
8 /* Original source from libnix */
10 #include <proto/dos.h>
17 ** If the VFSCANF_DIRECT_DOS define is set to 1, dos.library functions FGetC()
18 ** and UnGetC() are used directly, for possibly better speed. Otherwise
19 ** the clib functions fgetc/ungetc are used.
22 #define VFSCANF_DIRECT_DOS 1
24 #if VFSCANF_DIRECT_DOS
26 struct __vfscanf_handle
32 static int __getc(void *_h
);
33 static int __ungetc(int c
, void *_h
);
37 /*****************************************************************************
50 Read the scream, scan it as the format specified and write the
51 result of the conversion into the specified arguments.
54 stream - A stream to read from
55 format - A scanf() format string.
56 args - A list of arguments for the results.
59 The number of converted arguments.
71 ******************************************************************************/
73 #if VFSCANF_DIRECT_DOS
74 struct __vfscanf_handle h
;
77 h
.fdesc
= __getfdesc(stream
->fd
);
88 return __vcscan (&h
, __getc
, __ungetc
, format
, args
);
92 fdesc
= __getfdesc(stream
->fd
);
102 return __vcscan (stream
, fgetc
, ungetc
, format
, args
);
107 #if VFSCANF_DIRECT_DOS
109 static int __ungetc(int c
, void *_h
)
111 struct __vfscanf_handle
*h
= _h
;
112 /* Note: changes here might require changes in ungetc.c!! */
117 if (!UnGetC((BPTR
)h
->fdesc
->fh
, c
))
119 errno
= IoErr2errno(IoErr());
123 h
->stream
->flags
|= _STDIO_ERROR
;
127 h
->stream
->flags
|= _STDIO_EOF
;
136 static int __getc(void *_h
)
138 struct __vfscanf_handle
*h
= _h
;
141 /* Note: changes here might require changes in fgetc.c!! */
143 c
= FGetC((BPTR
)h
->fdesc
->fh
);
151 errno
= IoErr2errno(c
);
152 h
->stream
->flags
|= _STDIO_ERROR
;
156 h
->stream
->flags
|= _STDIO_EOF
;