delorie.com/djgpp/doc/libc/libc_198.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

dostrerr

Syntax

 
#include <dos.h>

int dostrerr(struct DOSERROR *p_error, struct DOSERROR_str *p_str);

Description

This function accepts the extended error structure from DOS (e.g., from the returned parameter from function dosexterr, see section dosexterr) and returns the strings which describes that error structure in the structure pointed to by the second parameter. This function is a DOS analogue of the ANSI function strerror (see section strerror), and can be used to print descriptive messages corresponding to the errors described in the DOSERROR structure.

For a list of the strings returned for each error number and type, see dosexterr.

p_error must point to the following structure:

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

p_str must point to the following structure:

 
struct DOSERROR_STR {
  char *exterror_str;
  char *class_str;
  char *action_str;
  char *locus_str;
};

Return Value

If either pointer parameter is NULL, returns -1 and sets errno to EINVAL. If both parameters are not NULL, checks the value of each member of the DOSERROR parameter p_error. If each value is within the limits of valid error codes for that member, sets parameter p_str member fields with the corresponding string describing the error code. If any error code is outside of the valid values for that code, sets the corresponding p_str member to the string "Unknown error: " followed by the decimal numeric value of the error code.

Portability

ANSI/ISO C No
POSIX No

Example

 
#include <stdio.h>
#include <dos.h>

int main(void)
{
  FILE *fp;
  struct DOSERROR de;
  struct DOSERROR_STR se;

  fp = fopen("EXAMPLE.DAT","r");
  if ( fp == NULL )
  {
    puts("Unable to open file for reading.");
    dosexterr(&de);
    dostrerr(&de, &se);
    printf("Extended DOS error information:\n");
    printf("Extended error: %i : %s\n",de.exterror,se.exterror_str);
    printf("Class:          %x : %s\n",de.class,se.class_str);
    printf("Action:         %x : %s\n",de.action,se.action_str);
    printf("Error Locus:    %x : %s\n",de.locus,se.locus_str);
  }
  return 0;
}


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004