home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / UNIX / ARCHIE / CLIENTS / XARCHIE3.TAR / xarchie-2.0.1 / syserr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-22  |  1.6 KB  |  64 lines

  1. /*
  2.  * syserr.c : Routines for system errors (like perror()). This puts
  3.  *    together an error string based on errno (if the system has
  4.  *    errno) and then calls the interface function alert0() to
  5.  *    display it.
  6.  *
  7.  * George Ferguson, ferguson@cs.rochester.edu, 23 Apr 1993.
  8.  *
  9.  * Compile-time parameters (config.h)
  10.  *    HAVE_STRERROR:   ANSI function strerror() exists
  11.  *    HAVE_SYSERRLIST: char *sys_errlist[] exists
  12.  *    HAVE_ERRNO:      int errno exists (it better!)
  13.  */
  14. #include <stdio.h>
  15. #include "config.h"
  16.  
  17. #ifdef HAVE_ERRNO
  18. #include <errno.h>
  19. # ifndef MSDOS
  20.   extern int errno;        /* MSDOS doesn't like this, apparently */
  21. # endif /* !MSDOS */
  22. #else /* !NO_ERRNO */
  23. int errno;            /* Make our own, pretty useless */
  24. #endif /* !NO_ERRNO */
  25.  
  26. #ifdef HAVE_STRERROR
  27. /* This is the same as NeedFunctionPrototypes for an X file */
  28. #if defined(FUNCPROTO) || __STDC__ || defined(__cplusplus) || defined(c_plusplus)
  29.    extern char *strerror(int);
  30. # else
  31.    extern char *strerror();
  32. # endif /* !NeedFunctionPrototypes */
  33. #else /* !HAVE_STRERROR */
  34. # ifdef HAVE_SYS_ERRLIST
  35.    extern char *sys_errlist[];
  36. # endif /* !NO_ERRLIST */
  37. #endif /* !HAVE_STRERROR */
  38.  
  39. extern void alert0();        /* Function to display the error message */
  40.  
  41. /*    -    -    -    -    -    -    -    -    */
  42.  
  43. void
  44. sysError(str)
  45. char *str;
  46. {
  47.     char buf[256];
  48.  
  49. #ifdef HAVE_STRERROR
  50.     sprintf(buf,"%s: %s",str,strerror(errno));
  51. #else
  52. #ifdef HAVE_ERRLIST
  53.     sprintf(buf,"%s: %s",str,sys_errlist[errno]);
  54. #else
  55. #ifdef HAVE_ERRNO
  56.     sprintf(buf,"%s: Errno = %d",str,errno);
  57. #else
  58.     sprintf(buf,"%s: System error.");
  59. #endif /* !NO_ERRNO */
  60. #endif /* !NO_ERRLIST */
  61. #endif /* !HAVE_STRERROR */
  62.     alert0(buf);
  63. }
  64.