Category : Files from Magazines
Archive   : CUJ0894.ZIP
Filename : ISXPNTER.C

 
Output of file : ISXPNTER.C contained in archive : CUJ0894.ZIP
-------------------------- Listing 9: pointer to void extractor ---------

// isxpointer -- istream::operator>>(void *&)
#include
#include
#include

istream& istream::operator>>(void *& pv)
{ // extract a void *
_TRY_IO_BEGIN
if (!ipfx())
setstate(failbit);
else
{ // gather characters and convert
char ac[_MAX_INT_DIG], *ep;
const int NL = 1 +
(sizeof (void *) - 1) / sizeof (unsigned long);
union {
void *pv;
unsigned long lo[NL];
} u;
for (int i = 0; ; )
{ // gather pieces of pointer
errno = 0;
const unsigned long x =
strtoul(ac, &ep, _Getifld(ac));
if (ep == ac || errno != 0)
setstate(failbit);
else
u.lo[i] = x;
if (NL <= ++i)
break;
const int ch = rdbuf()->sbumpc();
if (ch != ':')
{ // report failure to match ':'
if (ch != EOF)
rdbuf()->sputbackc(ch);
setstate(failbit);
break;
}
}
if (good())
pv = u.pv;
}
isfx();
_CATCH_IO_END
return (*this);
}


  3 Responses to “Category : Files from Magazines
Archive   : CUJ0894.ZIP
Filename : ISXPNTER.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/