mrice@caen.engin.umich.edu (Michael Rice) (08/15/90)
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; } }
mac@idacrd.UUCP (Robert McGwier) (08/15/90)
From article <1990Aug15.071209.15432@caen.engin.umich.edu>, by mrice@caen.engin.umich.edu (Michael Rice): > 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 > printf("ERROR: Drive %c is not ready.",dletter); > } Printf calls DOS. Bob -- ____________________________________________________________________________ My opinions are my own no matter | Robert W. McGwier, N4HY who I work for! ;-) | CCR, AMSAT, etc. ----------------------------------------------------------------------------
mrice@caen.engin.umich.edu (Michael Rice) (08/16/90)
In article <758@idacrd.UUCP> mac@idacrd.UUCP (Robert McGwier) writes: >From article <1990Aug15.071209.15432@caen.engin.umich.edu>, by mrice@caen.engin.umich.edu (Michael Rice): >> 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 >> printf("ERROR: Drive %c is not ready.",dletter); >> } > > > >Printf calls DOS. > I have the strange feeling that both getch() and printf may be calling DOS. I believe one can call DOS functions 00 - 0C only. If this is true I think both these could be accomplished without being illegal, but they don't seem to be. Also I am VERY disappointed in the example in the Turbo C Bible. They should at least have legal code. Thanks. >