prevent null pointer access crashes/memory trashing.
[AROS.git] / compiler / stdc / vsscanf.c
blob822adcdf4aa472469f52d4fcf46126a4e11b42e4
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function vsscanf().
6 */
7 /* Original source from libnix */
8 #include <stdio.h>
10 static int _vsscanf_get (char ** str)
12 if (!**str)
13 return EOF;
15 return *(*str)++;
18 static int _vsscanf_unget (int c, char ** str)
20 (*str)--;
22 return c;
25 /*****************************************************************************
27 NAME */
28 #include <stdio.h>
29 #include <stdarg.h>
31 int vsscanf (
33 /* SYNOPSIS */
34 const char *str,
35 const char *format,
36 va_list args)
38 /* FUNCTION
39 Scan a string and convert it into the arguments as specified
40 by format.
42 INPUTS
43 str - Scan this string
44 format - A scanf() format string.
45 args - A list of arguments for the results
47 RESULT
48 The number of arguments converted.
50 NOTES
52 EXAMPLE
54 BUGS
56 SEE ALSO
57 scanf(), sscanf(), fscanf(), vscanf(), vfscanf()
59 INTERNALS
61 ******************************************************************************/
63 int rc;
65 rc = __vcscan (&str,
66 (void *)_vsscanf_get,
67 (void *)_vsscanf_unget,
68 format,
69 args
72 return rc;
73 } /* vsscanf */