home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / HARDDISK / BADCLU.ZIP / AE.ZIP / DS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-07  |  1.9 KB  |  98 lines

  1. /**********************************************************************
  2.  *  
  3.  *  ds.c
  4.  *  
  5.  *  handler for int 24H errors
  6.  *  
  7.  *********************************************************************/
  8.  
  9. #define DEEPSHIT_HANDLER
  10.  
  11. #include "ds.h"
  12.  
  13. #include <dos.h>
  14.  
  15. static char *Err[] = {
  16.     "write-protect",
  17.     "unknown unit",
  18.     "drive not ready",
  19.     "unknown command",
  20.     "data (CRC)",
  21.     "bad request structure length",
  22.     "seek",
  23.     "unknown media type",
  24.     "sector not found",
  25.     "out of paper",
  26.     "write fault",
  27.     "read fault",
  28.     "general failure"
  29. };
  30.     
  31. static char *Act[] =  {
  32.     "reading",
  33.     "writing"
  34. };
  35.     
  36. static char *Loc[] = {
  37.     "DOS area",
  38.     "File Allocation Table",
  39.     "directory",
  40.     "data area"
  41. };
  42.     
  43. static int
  44. dev_err(
  45.     int                 errval,
  46.     int                 ax,
  47.     struct devhdr far   *dh)
  48. {
  49.     return DS_FAIL;
  50. }
  51.  
  52. static int (*choose)() = 0;
  53.  
  54. static int
  55. deep_shit(
  56.     int         errval,
  57.     int         ax,
  58.     unsigned    bp,
  59.     unsigned    si)
  60. {
  61.     
  62.     if (ax < 0) {
  63.         struct devhdr far   *dh;
  64.         
  65.         dh = MK_FP(bp, si);
  66.         return dev_err(errval, ax, dh);
  67.     } else {
  68.         DS_Err_Info.drv = (ax & 0x00ff) + 'a';
  69.         DS_Err_Info.rsp = (ax & 0x3800) >> 11;
  70.         DS_Err_Info.errmsg = Err[DS_Err_Info.err = errval];
  71.         DS_Err_Info.actmsg = Act[DS_Err_Info.act = (ax & 0x0100) >> 8];
  72.         DS_Err_Info.locmsg = Loc[DS_Err_Info.loc = (ax & 0x0600) >> 9];
  73.         if (choose) 
  74.             return choose();
  75.     }
  76.     return DS_IGNORE;
  77. }
  78.  
  79. static void interrupt (*old_int_24)() = 0;
  80.  
  81. void
  82. DS_Install(int (*func)())
  83. {
  84.     if (!old_int_24)
  85.         old_int_24 = getvect(0x24);
  86.     choose = func;
  87.     harderr(deep_shit);
  88. }
  89.  
  90. void
  91. DS_Uninstall(void)
  92. {
  93.     if (old_int_24) {
  94.         setvect(0x24, old_int_24);
  95.         old_int_24 = 0;
  96.     }
  97. }
  98.