Obscure code.

Randy Buckland rcb at ccpv1.ncsu.edu
Wed Mar 28 23:12:15 AEST 1990


waldorf at venice.SEDD.TRW.COM (jerry waldorf) writes:
>static int scanit(str, fmt, args)
>register char *str;
>char *fmt;
>char **args;
>{
>	FILE _strbuf;

>	_strbuf._flag = _IOREAD | _IOSTRG;
>	_strbuf._ptr = _strbuf._base = (unsigned char *) str;
>	_strbuf._cnt = 0;
>	while(*str++)
>		_strbuf._cnt++;
>	_strbuf._bufsiz = _strbuf._cnt;
>	return(_doscan(&_strbuf, fmt, args));
>}

>	What exactly does this do and where do I find _doscan?

_doscan is an internal routine of {scanf, fscnaf, sscanf}. This code is
part of "sscanf". The doscan expects a FILE struct with a buffer already
read in and will scan the chars in the buffer. scanf and fscanf call it 
with different arguments and for sscanf a fake FILE struct is built to
allow it to call the same routine. _doscan will read the chars in the
buffer (the passed string) and if that is not enough, will attempt to read
more chars from the file. This will fail and doscan will return with what
it has.
Randy Buckland
North Carolina State University
(919) 737-2517
rcb at ccpv1.ncsu.edu



More information about the Comp.unix.wizards mailing list