Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>dosexterr() get dos extended error values</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
dosexterr()              Get DOS Extended Error Values

 #include <dos.h>

 int               dosexterr(buffr);
 struct DOSERROR   *buffr;

    dosexterr() sets the fields of 'buffr' to the values returned by the
    MS-DOS system call 59H.  Setting buffr to the NULL pointer causes the
    function to return the value of AX, without filling in the fields of
    'buffr'.

    Returns:    The value in the AX register, (which is also set in the
                'exterror' field of 'buffr').

      Notes:    'dosexterr' is only valid for MS-DOS version 3.0 or later.

                The structure type DOSERROR is defined (in <dos.h> as:

                    struct DOSERROR {
                            int exterror;
                            char class;
                            char action;
                            char locus;
                            };

  -------------------------------- Example ---------------------------------

    The following statements try to open the file "testfile.dat". If this
    fails, and the MS-DOS version is 3.0 or later, the program prints
    extended error information.

            #include <dos.h>       /* for dosexterr() and struct DOSERROR */
            #include <fcntl.h>     /* for open() and O_RDWR */
            #include <stdio.h>     /* for printf() */
            #include <stdlib.h>    /* for _osmajor */

            struct DOSERROR   doserr;
            int fd;

            main()
            {
                if ((fd = open("testfile.dat", O_RDWR)) == -1) /* if error */
                    if (_osmajor >= 3) {  /* if DOS 3.0 or later... */
                        dosexterr(&doserr);
                        printf("error=%d, class=%d, action=%d, locus=%d\n",
                               doserr.exterror, doserr.class,
                               doserr.action, doserr.locus);
                 }
             }

See Also: perror()

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