Category : C Source Code
Archive   : SNIP1292.ZIP
Filename : ISRAMDSK.C

 
Output of file : ISRAMDSK.C contained in archive : SNIP1292.ZIP
/*
** isRamDsk() - Determine if a drive is a RAM disk
**
** Call with drive letter ('a' - 'z', 'A' - 'Z')
**
** Returns TRUE, FALSE, or ERROR
**
** Uses ABSDISKC.C, ABSDISK.ASM, and DOS5BOOT.H from SNIPPETS
** (Note: The relevent parts of the structure in DOS5BOOT.H are
** also applicable to lower version numbers of DOS)
**
** Public domain by Bob Stout
*/

#include
#include
#include "dos5boot.h"

typedef enum {ERROR = -1, FALSE, TRUE} LOGICAL;

LOGICAL isRamDsk(unsigned char drive)
{
union REGS regs;
B_REC buffer;

regs.x.ax = 0x4408; /* Not if removable */
regs.h.bl = toupper(drive) - '@';
intdos(®s, ®s);
if (0 == regs.x.ax)
return FALSE;
if (AbsDiskRead(toupper(drive) - 'A', 1, 0, &buffer))
return ERROR;
return (1 == buffer.bsFATs);
}

#ifdef TEST

#include
#include

int main(int argc, char *argv[])
{
if (2 > argc)
{
puts("Syntax: ISRAMDSK drive_letter");
return EXIT_FAILURE;
}
printf("Drive %c: is%s a RAM drive\n", toupper(*argv[1]),
isRamDsk(*argv[1]) ? "" : " not");
return EXIT_SUCCESS;
}

#endif /* TEST */


  3 Responses to “Category : C Source Code
Archive   : SNIP1292.ZIP
Filename : ISRAMDSK.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/