Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <dos.h>
    void _harderr( int (__far *funcptr)() );
    void _hardresume( int action );

Description:
    The _harderr routine installs a critical error handler (for INT 0x24) to
    handle hardware errors.  This critical error handler will call the
    function specified by funcptr when a critical error occurs (for example,
    attempting to open a file on a floppy disk when the drive door is open).
     The parameters to this function are as follows:


         int handler( unsigned deverror,
                      unsigned errcode,
                      unsigned __far *devhdr );

    The low-order byte of errcode can be one of the following values:

    0x00
        Attempt to write to a write-protected disk

    0x01
        Unknown unit

    0x02
        Drive not ready

    0x03
        Unknown command

    0x04
        CRC error in data

    0x05
        Bad drive-request structure length

    0x06
        Seek error

    0x07
        Unknown media type

    0x08
        Sector not found

    0x09
        Printer out of paper

    0x0A
        Write fault

    0x0B
        Read fault

    0x0C
        General failure

    The devhdr argument points to a device header control-block that
    contains information about the device on which the error occurred.  Your
    error handler may inspect the information in this control-block but must
    not change it.

    If the error occurred on a disk device, bit 15 of the deverror argument
    will be 0 and the deverror argument will indicate the following:

    bit 15
        0 indicates disk error

    bit 14
        not used

    bit 13
        0 indicates "Ignore" response not allowed

    bit 12
        0 indicates "Retry" response not allowed

    bit 11
        0 indicates "Fail" response not allowed

    bit 9,10
        location of error

        00
            MS-DOS

        01
            File Allocation Table (FAT)

        10
            Directory

        11
            Data area

    bit 8
        0 indicates read error, 1 indicates write error

    The low-order byte of deverror indicates the drive where the error
    occurred; (0 = drive A, 1 = drive B, etc.).

    The handler is very restricted in the type of system calls that it can
    perform.  System calls 0x01 through 0x0C, and 0x59 are the only system
    calls allowed to be issued by the handler.  Therefore, many of the
    standard C run-time functions such as stream I/O and low-level I/O
    cannot be used by the handler.  Console I/O is allowed (eg.  cprintf,
    cputs).

    The handler must indicate what action to take by returning one of the
    following values or calling  _hardresume with one of the following
    values:

    _HARDERR_IGNORE
        Ignore the error

    _HARDERR_RETRY
        Retry the operation

    _HARDERR_ABORT
        Abort the program issuing INT 0x23

    _HARDERR_FAIL
        Fail the system call that is in progress (DOS 3.0 or higher)

    See The MS-DOS Encyclopedia for more detailed information on determining
    the type of error that has occurred.

Returns:
    The _harderr routine does not return a value.

See Also:
    _chain_intr, _dos_getvect, _dos_setvect

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

    int __far critical_error_handler( unsigned deverr,
                                      unsigned errcode,
                                      unsigned far *devhdr )
      {
        cprintf( "Critical error: " );
        cprintf( "deverr=%4.4X errcode=%d\r\n",
                 deverr, errcode );
        cprintf( "devhdr = %Fp\r\n", devhdr );
        return( _HARDERR_IGNORE );
      }

    main()
      {
        FILE *fp;

        _harderr( critical_error_handler );
        fp = fopen( "a:tmp.tmp", "r" );
        printf( "fp = %p\n", fp );
      }

    produces the following:

    Critical error: deverr=1A00 errcode=2
    devhdr = 0070:01b6
    fp = 0000

Classification:
    DOS

Systems:
     _harderr - DOS

    _hardresume - DOS

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson