source: trunk/libs/newlib/src/newlib/libc/stdio/viscanf.c @ 577

Last change on this file since 577 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 3.1 KB
Line 
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/*
21FUNCTION
22<<viscanf>>, <<vfiscanf>>, <<vsiscanf>>---format argument list
23
24INDEX
25        viscanf
26INDEX
27        _viscanf_r
28INDEX
29        vfiscanf
30INDEX
31        _vfiscanf_r
32INDEX
33        vsiscanf
34INDEX
35        _vsiscanf_r
36
37SYNOPSIS
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
51DESCRIPTION
52<<viscanf>>, <<vfiscanf>>, and <<vsiscanf>> are (respectively) variants
53of <<iscanf>>, <<fiscanf>>, and <<siscanf>>.  They differ only in
54allowing their caller to pass the variable argument list as a
55<<va_list>> object (initialized by <<va_start>>) rather than
56directly accepting a variable number of arguments.
57
58RETURNS
59The return values are consistent with the corresponding functions:
60<<viscanf>> returns the number of input fields successfully scanned,
61converted, and stored; the return value does not include scanned
62fields which were not stored. 
63
64If <<viscanf>> attempts to read at end-of-file, the return value
65is <<EOF>>.
66
67If no fields were stored, the return value is <<0>>.
68
69The routines <<_viscanf_r>>, <<_vfiscanf_f>>, and <<_vsiscanf_r>> are
70reentrant versions which take an additional first parameter which points to the
71reentrancy structure.
72
73PORTABILITY
74These are newlib extensions.
75
76Supporting 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
87int
88viscanf (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
99int
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
Note: See TracBrowser for help on using the repository browser.