Category : Recently Uploaded Files
Archive   : SNIP9503.ZIP
Filename : ISFOPEN.C

 
Output of file : ISFOPEN.C contained in archive : SNIP9503.ZIP
/*
** Find out if a FILE * is valid
**
** public domain demo by Bob Stout
*/

#include

#ifdef __TURBOC__
#define STREAM_BUF _streams
#define FCNT FOPEN_MAX
#define FLAG flags
#else /* MSC, ZTC++ */
#define STREAM_BUF _iob
#define FCNT _NFILE
#define FLAG _flag
#endif

typedef enum {FALSE, TRUE} LOGICAL;

int isfopen(FILE *fp)
{
int i;

for (i = 0; i < FCNT; ++i)
{
if (0 != STREAM_BUF[i].FLAG && fp == &STREAM_BUF[i])
return TRUE;
}
return FALSE;
}

#ifdef TEST

main()
{
printf("stdout is%s valid\n", isfopen(stdout) ? "":" not");
printf("buffer #10 is%s valid\n", isfopen(&STREAM_BUF[9]) ? "":" not");
return 0;
}

#endif /*TEST */


  3 Responses to “Category : Recently Uploaded Files
Archive   : SNIP9503.ZIP
Filename : ISFOPEN.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/