home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************/
- /* Module name: chandler.c */
- /* Date: 10 Oct 87; 25 Nov 87 */
- /* Environment: Turbo C 1.0 */
- /* Author: Synchronistic Software (Was it JUST a coincidence?) */
- /* Notice: Public Domain: The following conditions apply to use: */
- /* 1) No fee shall be charged for distribution. */
- /* 2) Modifications may be made, but authorship information */
- /* for all contributing authors shall be retained. */
- /* 3) This code may not be included as part of a commercial */
- /* package. */
- /* This program is provided AS IS without any warranty, expressed or */
- /* implied, including, but not limited to, fitness for a particular */
- /* purpose. */
- /*********************************************************************/
- static char *__ATH__ =
- "@(#)chandler() v1.1 (25Nov87): Public Domain (P) 1987 Synchronistic Software";
-
- #include <stdio.h>
- #include <dos.h>
-
- int __CriticalError; /* Set to 1 when routine entered */
- int __CritErrIGNORE = 0; /* Ignores errors when true */
-
- /* REFERENCE: Armbrust, Steven; and Forgeron, Ted. Programmer's */
- /* Reference Manual for IBM Personal Computers. Homewood, Illinois: */
- /* Dow Jones-Irwin, 1986. */
- static char *error_type[] = {
- /* 0x00 */ "attempt to write to a write-protected disk$",
- /* 0x01 */ "undefined unit/drive$",
- /* 0x02 */ "drive not ready$",
- /* 0x03 */ "unknown command$",
- /* 0x04 */ "CRC data error occurred$",
- /* 0x05 */ "bad request structure length$",
- /* 0x06 */ "seek error occurred$",
- /* 0x07 */ "unknown medial type$",
- /* 0x08 */ "requested sector not located$",
- /* 0x09 */ "printer out of paper$",
- /* 0x0a */ "general write fault occurred$",
- /* 0x0b */ "general read fault occurred$",
- /* 0x0c */ "general failure occurred$"
- };
-
- static struct dev_header {
- unsigned char junk1[4];
- unsigned int attrib;
- unsigned char junk2[4];
- char name[8];
- };
-
- #define OUTSTR(msg) bdosptr( 0x09, msg, 0x00 )
- #define OUTCH(ch) bdos( 0x02, ch, 0x00 )
-
- #pragma warn -par
- int chandler( int errval, int ax, int bp, int si )
- {
- static char buf[25];
- static struct dev_header far *header;
- static unsigned char drive;
- register int i;
-
- __CriticalError = 1;
- header = MK_FP( bp, si );
- drive = ax & 0x00ff;
-
- if (__CritErrIGNORE) {
- if ( (ax & 0x8000) && !(header->attrib & 0x8000) ) {
- OUTSTR( "Cannot access FAT! Aborting.\n\r$" );
- hardresume( 2 );
- }
- hardretn( -1 );
- }
-
- OUTSTR( "Critical Error: $" );
- if (errval <= 0x0c) {
- OUTSTR( error_type[errval] );
- } else {
- sprintf( buf, "unknown error 0x%02x$", errval );
- OUTSTR( buf );
- }
-
- if (ax & 0x8000) { /* Not a disk error (may be a FAT error) */
- if (header->attrib & 0x8000) { /* Character device error */
- OUTSTR( " (device $" );
- for (i = 0; i < 8; i++)
- OUTCH( header->name[i] );
- OUTSTR( ")$" );
- } else { /* FAT error */
- sprintf( buf, " (drive %c)$", 'A' + drive );
- OUTSTR( buf );
- OUTSTR( "; cannot access FAT, aborting\n\r$" );
- hardresume( 2 );
- }
- } else { /* Disk error */
- sprintf( buf, " (drive %c)$", 'A' + drive );
- OUTSTR( buf );
- }
- OUTSTR( "\n\r$" );
-
- /* Try to fail the system call. If DOS doesn't like this it aborts. */
- hardretn( -1 );
- }
- #pragma warn .par
-