Category : C++ Source Code
Archive   : VCCRT2.ZIP
Filename : SSCANF.C

 
Output of file : SSCANF.C contained in archive : VCCRT2.ZIP
/***
*sscanf.c - read formatted data from string
*
* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
*
*Purpose:
* defines sscanf() - reads formatted data from string
*
*******************************************************************************/

#include
#include
#include
#include
#include
#include


/***
*int sscanf(string, format, ...) - read formatted data from string
*
*Purpose:
* Reads formatted data from string into arguments. _input does the real
* work here. Sets up a FILE so file i/o operations can be used, makes
* string look like a huge buffer to it, but _filbuf will refuse to refill
* it if it is exhausted.
*
* Allocate the 'fake' _iob[] entryit statically instead of on
* the stack so that other routines can assume that _iob[] entries are in
* are in DGROUP and, thus, are near.
*
* Multi-thread: (1) Since there is no stream, this routine must never try
* to get the stream lock (i.e., there is no stream lock either). (2)
* Also, since there is only one staticly allocated 'fake' iob, we must
* lock/unlock to prevent collisions.
*
*Entry:
* char *string - string to read data from
* char *format - format string
* followed by list of pointers to storage for the data read. The number
* and type are controlled by the format string.
*
*Exit:
* returns number of fields read and assigned
*
*Exceptions:
*
*******************************************************************************/

int
sscanf (REG2 const char *string, const char *format, ...)

/*
* 'S'tring 'SCAN', 'F'ormatted
*/
{
va_list arglist;
static FILE _NEAR_ str;
REG1 FILE _NEAR_ *infile = &str;
REG2 int retval;

va_start(arglist, format);

assert(string != NULL);
assert(format != NULL);


infile->_flag = _IOREAD|_IOSTRG|_IOMYBUF;
infile->_ptr = infile->_base = (char *) string;
infile->_cnt = strlen(string);

retval = (_input(infile,(const unsigned char *)format,arglist));


return(retval);
}


  3 Responses to “Category : C++ Source Code
Archive   : VCCRT2.ZIP
Filename : SSCANF.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/