🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #1881

Critical error interrupt handler

#1881
From: Michael Rice
Date: Wed, 15 Aug 1990 07:12
74 lines
3653 bytes
Hello!  I am trying to write a critical error interrupt handler (INT 24)
for my Turbo C program.  I am having a bit of a problem.  I have used the
example in the "Turbo C Bible" as a skeleton, but I am not having too much
luck.  I assume I am somewhere re-entering DOS in the handler which is
illegal, but I don't see where and there isn't much I can to to debug it.
In the example they use the printf and getch functions so I assume I can
use these.  What else could be the problem?  I did have some success using
the hardretn function instead of the hardresume, but this doesn't allow me
to retry or abort.  The computer just seems to lock-up when I try the 'r'
for retry.  Any ideas?  I used harderr(harderror_handler) to initialize the
handler.   As I understand it, returning a 1 from this handler (in AX) makes
DOS retry the command that caused the error and continue.  Returning 2 aborts
the program and returns to DOS through INT 22.  (Though there is some
discussion that this may not work.. It doesn't seem to work when I type 'A'
to the Abort,Retry,Fail message either.)

Any clarifications or help would be appreciated in email or through the net.
Thanks.  Here is the code, which is pretty self-explanatory even without
comments:


#include <stdio.h>
#include <dos.h>
#include <conio.h>

#define DRIVE_NOT_READY  0x02
#define OUT_OF_PAPER     0x09
#define WRITE_ERROR      0x0A

#define HARDERR_ABORT    0x02
#define HARDERR_RETRY    0x01

int harderror_handler(int errorcode,
		      int deverror,
		      int bpval,
		      int sival)
{
  unsigned far *devhdr;
  char dletter,response;

  devhdr = MK_FP((unsigned)bpval, (unsigned)sival);

  switch(errorcode & 0xff)
  {
    case DRIVE_NOT_READY: dletter = 'A' + (deverror & 0xff);
                          printf("ERROR: Drive %c is not ready.",dletter);
                          printf(" [R]etry or [A]bort to DOS?\n");
                          do {
                            response = getch();
			  } while ( !(response == 'r' || response == 'a'));

                          switch(response)
                          {
                          case 'r' : hardresume(HARDERR_RETRY);
                                     break;
                          case 'a' : hardresume(HARDERR_ABORT);
                                     break;
                          }
                          break;
    case OUT_OF_PAPER   : printf("Put paper in printer, then press any ");
                          printf("key\n");
                          getch();
                          hardresume(HARDERR_RETRY);
                          break;
    case WRITE_ERROR    : printf("Write Error.  Turn Printer ON, ");
                          printf("then press any key:\n");
                          getch();
                          hardresume(HARDERR_RETRY);
                          break;
    default             : printf("Unknown Critical Error. Aborting...");
                          hardresume(HARDERR_ABORT);
                          break;
  }
}
Technical Details
Message-ID: <1990Aug15.071209.15432@caen.engin.umich.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!caen!bluejay.engin.umich.edu!mrice

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!caen!bluejay.engin.umich.edu!mrice
From: mrice@caen.engin.umich.edu (Michael Rice)
Newsgroups: comp.os.msdos.programmer
Subject: Critical error interrupt handler
Summary: Turbo C INTERRUPT 24 handler
Keywords: Interrupt 24 Turbo C Critical Hardware Error
Message-ID: <1990Aug15.071209.15432@caen.engin.umich.edu>
Date: 15 Aug 90 07:12:09 GMT
Sender: news@caen.engin.umich.edu (CAEN Netnews)
Organization: University of Michigan Engineering, Ann Arbor
Lines: 74