home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / com / utils / elm / sources / errno.c < prev    next >
C/C++ Source or Header  |  1990-04-28  |  3KB  |  101 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: errno.c,v 4.1 90/04/28 22:42:58 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
  6.  *
  7.  *             Copyright (c) 1986, 1987 Dave Taylor
  8.  *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log:    errno.c,v $
  17.  * Revision 4.1  90/04/28  22:42:58  syd
  18.  * checkin of Elm 2.3 as of Release PL0
  19.  *
  20.  *
  21.  ******************************************************************************/
  22.  
  23. /** This routine maps error numbers to error names and error messages.
  24.     These are all directly ripped out of the include file errno.h, and
  25.     are HOPEFULLY standardized across the different breeds of Unix!!
  26.  
  27.     If (alas) yours are different, you should be able to use awk to
  28.     mangle your errno.h file quite simply...
  29.  
  30. **/
  31.  
  32. #include "headers.h"
  33.  
  34. char *err_name[] = {
  35. /* 0 */            "NOERROR", "No error status currently",
  36. /* 1 */        "EPERM",   "Not super-user",
  37. /* 2 */        "ENOENT",  "No such file or directory",
  38. /* 3 */        "ESRCH",   "No such process",
  39. /* 4 */        "EINTR",   "Interrupted system call",
  40. /* 5 */        "EIO",     "I/O error",
  41. /* 6 */        "ENXIO",   "No such device or address",
  42. /* 7 */        "E2BIG",   "Arg list too long",
  43. /* 8 */        "ENOEXEC", "Exec format error",
  44. /* 9 */        "EBADF",   "Bad file number",
  45. /* 10 */    "ECHILD",  "No children",
  46. /* 11 */    "EAGAIN",  "No more processes",
  47. /* 12 */    "ENOMEM",  "Not enough core",
  48. /* 13 */    "EACCES",  "Permission denied",
  49. /* 14 */    "EFAULT",  "Bad address",
  50. /* 15 */    "ENOTBLK", "Block device required",
  51. /* 16 */    "EBUSY",   "Mount device busy",
  52. /* 17 */    "EEXIST",  "File exists",
  53. /* 18 */    "EXDEV",   "Cross-device link",
  54. /* 19 */    "ENODEV",  "No such device",
  55. /* 20 */    "ENOTDIR", "Not a directory",
  56. /* 21 */    "EISDIR",  "Is a directory",
  57. /* 22 */    "EINVAL",  "Invalid argument",
  58. /* 23 */    "ENFILE",  "File table overflow",
  59. /* 24 */    "EMFILE",  "Too many open files",
  60. /* 25 */    "ENOTTY",  "Not a typewriter",
  61. /* 26 */    "ETXTBSY", "Text file busy",
  62. /* 27 */    "EFBIG",   "File too large",
  63. /* 28 */    "ENOSPC",  "No space left on device",
  64. /* 29 */    "ESPIPE",  "Illegal seek",
  65. /* 30 */    "EROFS",   "Read only file system",
  66. /* 31 */    "EMLINK",  "Too many links",
  67. /* 32 */    "EPIPE",   "Broken pipe",
  68. /* 33 */    "EDOM",    "Math arg out of domain of func",
  69. /* 34 */    "ERANGE",  "Math result not representable",
  70. /* 35 */    "ENOMSG",  "No message of desired type",
  71. /* 36 */    "EIDRM",   "Identifier removed"
  72.     };
  73.  
  74. char *strcpy();
  75.  
  76. char *error_name(errnumber)
  77. int errnumber;
  78. {
  79.     static char buffer[50];
  80.  
  81.     if (errnumber < 0 || errnumber > 36)
  82.       sprintf(buffer,"ERR-UNKNOWN (%d)", errnumber);
  83.     else
  84.       strcpy(buffer, err_name[2*errnumber]);
  85.  
  86.     return( (char *) buffer);
  87. }
  88.  
  89. char *error_description(errnumber)
  90. int errnumber;
  91. {
  92.     static char buffer[50];
  93.  
  94.     if (errnumber < 0 || errnumber > 36)
  95.       sprintf(buffer,"Unknown error - %d - No description", errnumber);
  96.     else
  97.       strcpy(buffer, err_name[2*errnumber + 1]);
  98.  
  99.     return ( (char *) buffer);
  100. }
  101.