Dec 142017
Critical error handler for MSC and CXL 5.0.
File CRITTER1.ZIP from The Programmer’s Corner in
Category C Source Code
Critical error handler for MSC and CXL 5.0.
File Name File Size Zip Size Zip Type
CRITTER.DOC 11824 4058 deflated
CRITTER.H 254 148 deflated
CRITTERL.OBJ 2884 1758 deflated
CRITTERM.OBJ 2623 1631 deflated
CRITTERS.OBJ 2558 1615 deflated
TEST.C 667 306 deflated
TEST.EXE 20965 11810 deflated

Download File CRITTER1.ZIP Here

Contents of the CRITTER.DOC file

A Critical Error Handler
For Use with the CXL Library
Copyright 1989 by TANSTAAFL Software

1) Purpose

This product is a programmer-usable critical error handler
for programmers using the CXL 5.0 library and Microsoft C
5.x. One library call will install this error handler
for the duration of program execution. This routine
will work with any TEXT program, on a variety of supported
monitors (MDA, CGA, HGA, EGA, & VGA). This version does
handle monochrome monitors, albeit in a slightly roundabout

2) Instructions For Use

In your software, put a call in during your initialization
to install_critical(). This routine consists of two lines
of code:


The first call is a CXL call to initialize the video system,
which I assume you are already using. The second call uses
the Microsoft C routine _harderr to install the routine
named critter(). The header file critter.h contains the
function prototypes for these two functions. After this
routine is installed, all critical errors will be handled
in a much more pleasant manner than how DOS does it.
To handle a monochrome monitor, set the monochrome flag
in the video info structure. For instructions on how to
do this, look at the CXL demo software source code.

3) Critical Error Handler Theory

Critical errors are caused by hardware errors, generally
in disk drives. These errors may be minor (such as printer
out of paper, or drive door open) or fairly catastrophic
(like a scrambled FAT or dead hard disk). A critical
error can be caused by virtually any DOS call EXCEPT
interrupts 25h and 26h (Absolute Disk Read & Write).

A critical error is associated with a device, and can
be either a block device (disk drives), or a character
device (printer, keyboard, clock, etc.). Each time the
error handler is called, parameters are passed which
indicate which error occured and where it happened.

The Critter critical error handler will give the following

Error Code Write Protected Disk
Unknown Unit
Drive Not Ready
Unknown Command
CRC Error In Data
Bad Drive Request
Seek Error
Unknown Media Type
Sector Not Found
Printer Out Of Paper
Write Fault
Read Fault
General Failure
Removable Media Change

Error Cause Read Operation
Write Operation

Error Location System Area
File Allocation Table
Data Area
Internal Copy Of FAT

Other Info (char) Device Name
(block) Drive Designator

Possible responses to a critical error are Abort, Ignore,
Retry, or Fail. Not all responses are possible at all
times - it depends on the error and the version of DOS.
The Critter routine enables only those responses that
DOS will allow at the time.

4) Test Results

Unfortunately, this routine is hard to completely test.
Several easy errors can be generated. These include
the write protect error, the drive not ready error,
the paper out error, and the read & write faults.
Other errors could be tested if someone wanted to
cause them physically, such as unplugging the clock
chip or crashing the hard disk (not recommended).

5) Test Software

Included in this package is test.c and test.exe. This
code installs the error handler, then attempts to open
and WRITE to a device/file given on the command line.
So it's easy to test the drive not ready error by not
having a disk in a:, then running TEST A:TEMP. Similar
tests can be done with TEST PRN or TEST COM1. Note that
some printers (or printer cables) cannot signal an out
of paper (or power off) condition. It seems to work ok
with my Epson, but not my Star. I think it's the cable.
As for the DOS version, my research indicates that this
should work for 2.x and above. I don't think there is
any need to support 1.x anymore.

6) Files In This Archive

critter.doc (this file)
critter.h function prototypes

critters.obj small model
critterm.obj medium model
critterl.obj large model

test.c test code source
test.exe test code executable (small model)

7) Future Enhancements

This project has a fair amount of potential. I am
currently converting Critter to be a full-time TSR.
This is harder than other TSR's because DOS does some
kinky things for this interrupt that it does not do for
other interrupts. I expect the TSR version (CRITTSR)
to be finished by mid-June, with release by July. Due
to the oddities of DOS, this product will NOT support
machines with DOS in ROM.

Currently I support Microsoft C, even though CXL supports
several other compilers. I have no current plans to
support these other compilers, but if enough of you want
me to, I will (it would be a good excuse to get a copy of
Turbo C and Zortech C++).

Another planned enhancement is a "programmer's version"
that would present more information than the average user
needs. This includes the contents of the device attribute
word and (for Dos 3.x and above) the extended error codes.

I might release this handler as a "stand-alone" package,
not requiring CXL. I am currently talking about this
with the author of CXL.

8) Terms And Conditions

You may use this routine freely in any non-commercial
software you write. You may distribute this routine
freely as long as the archive file contains all of the
files mentioned above.

Developers of commercial software (software for sale)
are required to purchase an unlimited use license for
$ 50.00. This gets you the source code and the right
to use this in your commercial software products. If
your Ship To address is in Colorado, I have to charge
you sales tax. For Shareware authors, you may use
the routines here in your products for free. If you
want the source, you pay the same $ 50.00.

If you purchase source code, you can receive it on either
5 1/4 or 3 1/2 inch disks. Please indicate preference.

9) Feedback

I may be reached by the following methods for feedback:

on GENIE mail address TANSTAAFL

on Prodigy mail address NCDC07A

by phone (303) 989-7389 After 8 AM and before
10 PM MST (Thanks!). I do have an
answering machine, which has an unlimited
message length. I am generally not in
during the day (I have to work, too).

by mail Dana W. Cline
P. O. Box 260075
Lakewood, CO 80226

Feedback of all types is appreciated.

10) Disclaimer

The author claims no responsibility for any damages caused
by the use or misuse of this product. This product is
distributed "as is" with no warranty expressed or implied.
The author will not be responsible for any losses incurred,
either directly or indirectly, by the use of this product.
The author reserves the right to make modifications at any
time. Prices are subject to change without notice.

11) What is CXL?

CXL is a software library of routines to manage windows,
menus, the keyboard, strings, EMS memory, a mouse, and
much more. CXL is available for Microsoft C and several
other compilers. This software requires version 5.x of
CXL ($35 from the author). For more information, contact:

Official CXL Support BBS - (512) 590-0460 1200/2400
CompuServe - 71331,2244
Telstar BBS - (512) 822-8882 1200/2400
U.S. Mail - Mike Smedley
P.O. Box 33603
San Antonio, TX 78265-3603

Order Form TANSTAAFL Software

NAME: ______________________________________________________

COMPANY: ______________________________________________________

ADDRESS: ______________________________________________________


CITY: ______________________________________________________

STATE: ________________________ ZIP CODE: _________________

PHONE: ______________________________________________________

E-MAIL ADDRESS: _______________________________________________

WHERE DID YOU RECEIVE CRITTER? ________________________________


DISK SIZE NEEDED: ______________________________________________

COMMENTS: _____________________________________________________



Basic Registration @ $50.00 $__________
(Includes source code for Microsoft C)

Non-US Shipping @ $5.00 __________
(Payments must be in US Dollars, US bank)

TOTAL: $__________

Remit to: Dana W. Cline
P.O. Box 260075
Lakewood, CO 80226

Thanks to:

Dean McRory, for help in understanding critical
error handling.

Mike Smedley, for advice and a really excellent
C library.

Jerry Pournelle, for continually harping about
the drawbacks of MS-DOS.

Information Sources:

MS-DOS Programmers Reference, from Microsoft Press

MS_DOS Developer's Guide, from the Waite Group

Microsoft C 5.1 Manual, from Microsoft

MS-DOS Functions, from Microsoft Press

 December 14, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>