home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l440 / 2.ddi / CHAP5 / EXTERR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-26  |  1.2 KB  |  58 lines

  1. /* EXTERR.C - extended error saving and restoring */
  2.  
  3. #include <stdlib.h>
  4. #include <dos.h>
  5.  
  6. #define GET_EXTERR     0x59
  7. #define SET_EXTERR     0x5d0a
  8.  
  9. #pragma pack(1)
  10.  
  11. struct   ExtErr
  12. {
  13.    unsigned int errax;
  14.    unsigned int errbx;
  15.    unsigned int errcx;
  16. };
  17.  
  18. void  GetExtErr(struct ExtErr * ErrInfo);
  19. void  SetExtErr(struct ExtErr * ErrInfo);
  20.  
  21. /*****
  22. Function: GetExtErr
  23. get extended error information
  24. *****/
  25. void GetExtErr(struct ExtErr * ErrInfo)
  26.    union  REGS regs;
  27.  
  28.    if (_osmajor >= 3)   /* only for DOS 3 and above */
  29.    {
  30.       regs.h.ah = GET_EXTERR;
  31.       regs.x.bx = 0;  /* must be zero */
  32.       intdos(®s,®s);
  33.       ErrInfo->errax = regs.x.ax;
  34.       ErrInfo->errbx = regs.x.bx;
  35.       ErrInfo->errcx = regs.x.cx;
  36.    }
  37. }
  38.  
  39. /*****
  40. Function: SetExtErr
  41. set extended error information
  42. *****/
  43. void SetExtErr(struct ExtErr near * ErrInfo)
  44.    union  REGS regs;
  45.    struct SREGS segregs;
  46.  
  47.    if (_osmajor >= 3)   /* only for DOS  3 and above */
  48.    {
  49.       regs.x.ax = SET_EXTERR;
  50.       regs.x.bx = 0;       /* must be zero */
  51.       segread(&segregs);   /* put address of err info in DS:DX */
  52.       regs.x.dx = (int) ErrInfo;
  53.       intdosx(®s,®s,&segregs);
  54.    }
  55. }
  56.