1 | /*- |
---|
2 | * Code created by modifying iscanf.c which has following copyright. |
---|
3 | * |
---|
4 | * Copyright (c) 1990 The Regents of the University of California. |
---|
5 | * All rights reserved. |
---|
6 | * |
---|
7 | * Redistribution and use in source and binary forms are permitted |
---|
8 | * provided that the above copyright notice and this paragraph are |
---|
9 | * duplicated in all such forms and that any documentation, |
---|
10 | * advertising materials, and other materials related to such |
---|
11 | * distribution and use acknowledge that the software was developed |
---|
12 | * by the University of California, Berkeley. The name of the |
---|
13 | * University may not be used to endorse or promote products derived |
---|
14 | * from this software without specific prior written permission. |
---|
15 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
---|
16 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
---|
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
---|
18 | */ |
---|
19 | |
---|
20 | /* |
---|
21 | FUNCTION |
---|
22 | <<viscanf>>, <<vfiscanf>>, <<vsiscanf>>---format argument list |
---|
23 | |
---|
24 | INDEX |
---|
25 | viscanf |
---|
26 | INDEX |
---|
27 | _viscanf_r |
---|
28 | INDEX |
---|
29 | vfiscanf |
---|
30 | INDEX |
---|
31 | _vfiscanf_r |
---|
32 | INDEX |
---|
33 | vsiscanf |
---|
34 | INDEX |
---|
35 | _vsiscanf_r |
---|
36 | |
---|
37 | SYNOPSIS |
---|
38 | #include <stdio.h> |
---|
39 | #include <stdarg.h> |
---|
40 | int viscanf(const char *<[fmt]>, va_list <[list]>); |
---|
41 | int vfiscanf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); |
---|
42 | int vsiscanf(const char *<[str]>, const char *<[fmt]>, va_list <[list]>); |
---|
43 | |
---|
44 | int _viscanf_r(struct _reent *<[reent]>, const char *<[fmt]>, |
---|
45 | va_list <[list]>); |
---|
46 | int _vfiscanf_r(struct _reent *<[reent]>, FILE *<[fp]>, const char *<[fmt]>, |
---|
47 | va_list <[list]>); |
---|
48 | int _vsiscanf_r(struct _reent *<[reent]>, const char *<[str]>, |
---|
49 | const char *<[fmt]>, va_list <[list]>); |
---|
50 | |
---|
51 | DESCRIPTION |
---|
52 | <<viscanf>>, <<vfiscanf>>, and <<vsiscanf>> are (respectively) variants |
---|
53 | of <<iscanf>>, <<fiscanf>>, and <<siscanf>>. They differ only in |
---|
54 | allowing their caller to pass the variable argument list as a |
---|
55 | <<va_list>> object (initialized by <<va_start>>) rather than |
---|
56 | directly accepting a variable number of arguments. |
---|
57 | |
---|
58 | RETURNS |
---|
59 | The return values are consistent with the corresponding functions: |
---|
60 | <<viscanf>> returns the number of input fields successfully scanned, |
---|
61 | converted, and stored; the return value does not include scanned |
---|
62 | fields which were not stored. |
---|
63 | |
---|
64 | If <<viscanf>> attempts to read at end-of-file, the return value |
---|
65 | is <<EOF>>. |
---|
66 | |
---|
67 | If no fields were stored, the return value is <<0>>. |
---|
68 | |
---|
69 | The routines <<_viscanf_r>>, <<_vfiscanf_f>>, and <<_vsiscanf_r>> are |
---|
70 | reentrant versions which take an additional first parameter which points to the |
---|
71 | reentrancy structure. |
---|
72 | |
---|
73 | PORTABILITY |
---|
74 | These are newlib extensions. |
---|
75 | |
---|
76 | Supporting OS subroutines required: |
---|
77 | */ |
---|
78 | |
---|
79 | #include <_ansi.h> |
---|
80 | #include <reent.h> |
---|
81 | #include <stdio.h> |
---|
82 | #include <stdarg.h> |
---|
83 | #include "local.h" |
---|
84 | |
---|
85 | #ifndef _REENT_ONLY |
---|
86 | |
---|
87 | int |
---|
88 | viscanf (const char *fmt, |
---|
89 | va_list ap) |
---|
90 | { |
---|
91 | struct _reent *reent = _REENT; |
---|
92 | |
---|
93 | _REENT_SMALL_CHECK_INIT (reent); |
---|
94 | return __svfiscanf_r (reent, _stdin_r (reent), fmt, ap); |
---|
95 | } |
---|
96 | |
---|
97 | #endif /* !_REENT_ONLY */ |
---|
98 | |
---|
99 | int |
---|
100 | _viscanf_r (struct _reent *ptr, |
---|
101 | const char *fmt, |
---|
102 | va_list ap) |
---|
103 | { |
---|
104 | _REENT_SMALL_CHECK_INIT (ptr); |
---|
105 | return __svfiscanf_r (ptr, _stdin_r (ptr), fmt, ap); |
---|
106 | } |
---|
107 | |
---|