Category : Files from Magazines
Archive   : CUJ9201.ZIP
Filename : 1001014D
Listing 5 -- the file fclose.c
/* fclose function */
#include
#include "xstdio.h"
#include "yfuns.h"
int (fclose)(FILE *str)
{ /* close a stream */
int stat = fflush(str);
if (str->_Mode & _MALBUF)
free(str->_Buf);
str->_Buf = NULL;
if (0 <= str->_Handle && _Fclose(str))
stat = EOF;
if (str->_Tmpnam)
{ /* remove temp file */
if (remove(str->_Tmpnam))
stat = EOF;
free(str->_Tmpnam);
str->_Tmpnam = NULL;
}
str->_Mode = 0;
str->_Next = &str->_Cbuf;
str->_Rend = &str->_Cbuf;
str->_Wend = &str->_Cbuf;
str->_Nback = 0;
if (str->_Mode & _MALFIL)
{ /* find _Files[i] entry and free */
size_t i;
for (i = 0; i < FOPEN_MAX; ++i)
if (_Files[i] == str)
{ /* found entry */
_Files[i] = NULL;
break;
}
free(str);
}
return (stat);
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
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/