home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / gnulib / libsrc98.zoo / sscanf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-23  |  829 b   |  48 lines

  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include <compiler.h>
  4.  
  5. __EXTERN int _scanf __PROTO((const char **buf, int (*get)(unsigned char **s),
  6.                 int (*unget)(int c, unsigned char **s),
  7.                 const char *fmt, va_list argp));
  8.  
  9. static int sgetc(s)
  10.     unsigned char **s;
  11.     {
  12.     register unsigned char c;
  13.  
  14.     c = *(*s)++;
  15.     return((c == '\0') ? EOF : c);
  16.     }
  17.  
  18. static int sungetc(c, s)
  19.     int c;
  20.     unsigned char **s;
  21.     {
  22.     if(c == EOF)
  23.         c = '\0';
  24.     return(*--(*s) = c);
  25.     }
  26.  
  27. #ifdef __STDC__
  28. int sscanf(const char *buf, const char *fmt, ...)
  29. #else
  30. int sscanf(buf, fmt)
  31.     const char *buf, *fmt;
  32. #endif
  33.     {
  34.     va_list argp;
  35.  
  36.     va_start(argp, fmt);
  37.     return(_scanf(&buf, sgetc, sungetc, fmt, argp));
  38.     }
  39.  
  40. int vsscanf(buf, fmt, args)
  41.         const char *buf;
  42.     const char *fmt;
  43.         va_list args;
  44.     {
  45.       return(_scanf(&buf, sgetc, sungetc, fmt, args));
  46.     }
  47.     
  48.