Thread View: comp.os.msdos.programmer
3 messages
3 total messages
Started by Michael Rice
Wed, 15 Aug 1990 07:12
Critical error interrupt handler
Author: Michael Rice
Date: Wed, 15 Aug 1990 07:12
Date: Wed, 15 Aug 1990 07:12
74 lines
3653 bytes
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;
}
}
Re: Critical error interrupt handler
Author: Robert McGwier
Date: Wed, 15 Aug 1990 14:51
Date: Wed, 15 Aug 1990 14:51
19 lines
1179 bytes
1179 bytes
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.
----------------------------------------------------------------------------
Re: Critical error interrupt handler
Author: Michael Rice
Date: Wed, 15 Aug 1990 17:31
Date: Wed, 15 Aug 1990 17:31
20 lines
1471 bytes
1471 bytes
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.
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads