home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- *
- * ds.c
- *
- * handler for int 24H errors
- *
- *********************************************************************/
-
- #define DEEPSHIT_HANDLER
-
- #include "ds.h"
-
- #include <dos.h>
-
- static char *Err[] = {
- "write-protect",
- "unknown unit",
- "drive not ready",
- "unknown command",
- "data (CRC)",
- "bad request structure length",
- "seek",
- "unknown media type",
- "sector not found",
- "out of paper",
- "write fault",
- "read fault",
- "general failure"
- };
-
- static char *Act[] = {
- "reading",
- "writing"
- };
-
- static char *Loc[] = {
- "DOS area",
- "File Allocation Table",
- "directory",
- "data area"
- };
-
- static int
- dev_err(
- int errval,
- int ax,
- struct devhdr far *dh)
- {
- return DS_FAIL;
- }
-
- static int (*choose)() = 0;
-
- static int
- deep_shit(
- int errval,
- int ax,
- unsigned bp,
- unsigned si)
- {
-
- if (ax < 0) {
- struct devhdr far *dh;
-
- dh = MK_FP(bp, si);
- return dev_err(errval, ax, dh);
- } else {
- DS_Err_Info.drv = (ax & 0x00ff) + 'a';
- DS_Err_Info.rsp = (ax & 0x3800) >> 11;
- DS_Err_Info.errmsg = Err[DS_Err_Info.err = errval];
- DS_Err_Info.actmsg = Act[DS_Err_Info.act = (ax & 0x0100) >> 8];
- DS_Err_Info.locmsg = Loc[DS_Err_Info.loc = (ax & 0x0600) >> 9];
- if (choose)
- return choose();
- }
- return DS_IGNORE;
- }
-
- static void interrupt (*old_int_24)() = 0;
-
- void
- DS_Install(int (*func)())
- {
- if (!old_int_24)
- old_int_24 = getvect(0x24);
- choose = func;
- harderr(deep_shit);
- }
-
- void
- DS_Uninstall(void)
- {
- if (old_int_24) {
- setvect(0x24, old_int_24);
- old_int_24 = 0;
- }
- }
-