home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / libg++-2.6-fsf.lha / libg++-2.6 / libiberty / strerror.c < prev    next >
C/C++ Source or Header  |  1994-02-20  |  21KB  |  824 lines

  1. /* Extended support for using errno values.
  2.    Copyright (C) 1992 Free Software Foundation, Inc.
  3.    Written by Fred Fish.  fnf@cygnus.com
  4.  
  5. This file is part of the libiberty library.
  6. Libiberty is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU Library General Public
  8. License as published by the Free Software Foundation; either
  9. version 2 of the License, or (at your option) any later version.
  10.  
  11. Libiberty is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14. Library General Public License for more details.
  15.  
  16. You should have received a copy of the GNU Library General Public
  17. License along with libiberty; see the file COPYING.LIB.  If
  18. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  19. Cambridge, MA 02139, USA.  */
  20.  
  21. #include "ansidecl.h"
  22. #include "libiberty.h"
  23.  
  24. #include "config.h"
  25.  
  26. #ifndef NEED_sys_errlist
  27. /* Note that errno.h (not sure what OS) or stdio.h (BSD 4.4, at least)
  28.    might declare sys_errlist in a way that the compiler might consider
  29.    incompatible with our later declaration, perhaps by using const
  30.    attributes.  So we hide the declaration in errno.h (if any) using a
  31.    macro. */
  32. #define sys_errlist sys_errlist__
  33. #endif
  34.  
  35. #include <stdio.h>
  36. #include <errno.h>
  37.  
  38. #ifndef NEED_sys_errlist
  39. #undef sys_errlist
  40. #endif
  41.  
  42. /*  Routines imported from standard C runtime libraries. */
  43.  
  44. #ifdef __STDC__
  45. #include <stddef.h>
  46. extern void *malloc (size_t size);                /* 4.10.3.3 */
  47. extern void *memset (void *s, int c, size_t n);            /* 4.11.6.1 */
  48. #else    /* !__STDC__ */
  49. extern char *malloc ();        /* Standard memory allocater */
  50. extern char *memset ();
  51. #endif    /* __STDC__ */
  52.  
  53. #ifndef MAX
  54. #  define MAX(a,b) ((a) > (b) ? (a) : (b))
  55. #endif
  56.  
  57. /* Translation table for errno values.  See intro(2) in most UNIX systems
  58.    Programmers Reference Manuals.
  59.  
  60.    Note that this table is generally only accessed when it is used at runtime
  61.    to initialize errno name and message tables that are indexed by errno
  62.    value.
  63.  
  64.    Not all of these errnos will exist on all systems.  This table is the only
  65.    thing that should have to be updated as new error numbers are introduced.
  66.    It's sort of ugly, but at least its portable. */
  67.  
  68. struct error_info
  69. {
  70.   int value;        /* The numeric value from <errno.h> */
  71.   const char *name;    /* The equivalent symbolic value */
  72. #ifdef NEED_sys_errlist
  73.   const char *msg;    /* Short message about this value */
  74. #endif
  75. };
  76.  
  77. #ifdef NEED_sys_errlist
  78. #   define ENTRY(value, name, msg)    {value, name, msg}
  79. #else
  80. #   define ENTRY(value, name, msg)    {value, name}
  81. #endif
  82.  
  83. static const struct error_info error_table[] =
  84. {
  85. #if defined (EPERM)
  86.   ENTRY(EPERM, "EPERM", "Not owner"),
  87. #endif
  88. #if defined (ENOENT)
  89.   ENTRY(ENOENT, "ENOENT", "No such file or directory"),
  90. #endif
  91. #if defined (ESRCH)
  92.   ENTRY(ESRCH, "ESRCH", "No such process"),
  93. #endif
  94. #if defined (EINTR)
  95.   ENTRY(EINTR, "EINTR", "Interrupted system call"),
  96. #endif
  97. #if defined (EIO)
  98.   ENTRY(EIO, "EIO", "I/O error"),
  99. #endif
  100. #if defined (ENXIO)
  101.   ENTRY(ENXIO, "ENXIO", "No such device or address"),
  102. #endif
  103. #if defined (E2BIG)
  104.   ENTRY(E2BIG, "E2BIG", "Arg list too long"),
  105. #endif
  106. #if defined (ENOEXEC)
  107.   ENTRY(ENOEXEC, "ENOEXEC", "Exec format error"),
  108. #endif
  109. #if defined (EBADF)
  110.   ENTRY(EBADF, "EBADF", "Bad file number"),
  111. #endif
  112. #if defined (ECHILD)
  113.   ENTRY(ECHILD, "ECHILD", "No child processes"),
  114. #endif
  115. #if defined (EWOULDBLOCK)    /* Put before EAGAIN, sometimes aliased */
  116.   ENTRY(EWOULDBLOCK, "EWOULDBLOCK", "Operation would block"),
  117. #endif
  118. #if defined (EAGAIN)
  119.   ENTRY(EAGAIN, "EAGAIN", "No more processes"),
  120. #endif
  121. #if defined (ENOMEM)
  122.   ENTRY(ENOMEM, "ENOMEM", "Not enough space"),
  123. #endif
  124. #if defined (EACCES)
  125.   ENTRY(EACCES, "EACCES", "Permission denied"),
  126. #endif
  127. #if defined (EFAULT)
  128.   ENTRY(EFAULT, "EFAULT", "Bad address"),
  129. #endif
  130. #if defined (ENOTBLK)
  131.   ENTRY(ENOTBLK, "ENOTBLK", "Block device required"),
  132. #endif
  133. #if defined (EBUSY)
  134.   ENTRY(EBUSY, "EBUSY", "Device busy"),
  135. #endif
  136. #if defined (EEXIST)
  137.   ENTRY(EEXIST, "EEXIST", "File exists"),
  138. #endif
  139. #if defined (EXDEV)
  140.   ENTRY(EXDEV, "EXDEV", "Cross-device link"),
  141. #endif
  142. #if defined (ENODEV)
  143.   ENTRY(ENODEV, "ENODEV", "No such device"),
  144. #endif
  145. #if defined (ENOTDIR)
  146.   ENTRY(ENOTDIR, "ENOTDIR", "Not a directory"),
  147. #endif
  148. #if defined (EISDIR)
  149.   ENTRY(EISDIR, "EISDIR", "Is a directory"),
  150. #endif
  151. #if defined (EINVAL)
  152.   ENTRY(EINVAL, "EINVAL", "Invalid argument"),
  153. #endif
  154. #if defined (ENFILE)
  155.   ENTRY(ENFILE, "ENFILE", "File table overflow"),
  156. #endif
  157. #if defined (EMFILE)
  158.   ENTRY(EMFILE, "EMFILE", "Too many open files"),
  159. #endif
  160. #if defined (ENOTTY)
  161.   ENTRY(ENOTTY, "ENOTTY", "Not a typewriter"),
  162. #endif
  163. #if defined (ETXTBSY)
  164.   ENTRY(ETXTBSY, "ETXTBSY", "Text file busy"),
  165. #endif
  166. #if defined (EFBIG)
  167.   ENTRY(EFBIG, "EFBIG", "File too large"),
  168. #endif
  169. #if defined (ENOSPC)
  170.   ENTRY(ENOSPC, "ENOSPC", "No space left on device"),
  171. #endif
  172. #if defined (ESPIPE)
  173.   ENTRY(ESPIPE, "ESPIPE", "Illegal seek"),
  174. #endif
  175. #if defined (EROFS)
  176.   ENTRY(EROFS, "EROFS", "Read-only file system"),
  177. #endif
  178. #if defined (EMLINK)
  179.   ENTRY(EMLINK, "EMLINK", "Too many links"),
  180. #endif
  181. #if defined (EPIPE)
  182.   ENTRY(EPIPE, "EPIPE", "Broken pipe"),
  183. #endif
  184. #if defined (EDOM)
  185.   ENTRY(EDOM, "EDOM", "Math argument out of domain of func"),
  186. #endif
  187. #if defined (ERANGE)
  188.   ENTRY(ERANGE, "ERANGE", "Math result not representable"),
  189. #endif
  190. #if defined (ENOMSG)
  191.   ENTRY(ENOMSG, "ENOMSG", "No message of desired type"),
  192. #endif
  193. #if defined (EIDRM)
  194.   ENTRY(EIDRM, "EIDRM", "Identifier removed"),
  195. #endif
  196. #if defined (ECHRNG)
  197.   ENTRY(ECHRNG, "ECHRNG", "Channel number out of range"),
  198. #endif
  199. #if defined (EL2NSYNC)
  200.   ENTRY(EL2NSYNC, "EL2NSYNC", "Level 2 not synchronized"),
  201. #endif
  202. #if defined (EL3HLT)
  203.   ENTRY(EL3HLT, "EL3HLT", "Level 3 halted"),
  204. #endif
  205. #if defined (EL3RST)
  206.   ENTRY(EL3RST, "EL3RST", "Level 3 reset"),
  207. #endif
  208. #if defined (ELNRNG)
  209.   ENTRY(ELNRNG, "ELNRNG", "Link number out of range"),
  210. #endif
  211. #if defined (EUNATCH)
  212.   ENTRY(EUNATCH, "EUNATCH", "Protocol driver not attached"),
  213. #endif
  214. #if defined (ENOCSI)
  215.   ENTRY(ENOCSI, "ENOCSI", "No CSI structure available"),
  216. #endif
  217. #if defined (EL2HLT)
  218.   ENTRY(EL2HLT, "EL2HLT", "Level 2 halted"),
  219. #endif
  220. #if defined (EDEADLK)
  221.   ENTRY(EDEADLK, "EDEADLK", "Deadlock condition"),
  222. #endif
  223. #if defined (ENOLCK)
  224.   ENTRY(ENOLCK, "ENOLCK", "No record locks available"),
  225. #endif
  226. #if defined (EBADE)
  227.   ENTRY(EBADE, "EBADE", "Invalid exchange"),
  228. #endif
  229. #if defined (EBADR)
  230.   ENTRY(EBADR, "EBADR", "Invalid request descriptor"),
  231. #endif
  232. #if defined (EXFULL)
  233.   ENTRY(EXFULL, "EXFULL", "Exchange full"),
  234. #endif
  235. #if defined (ENOANO)
  236.   ENTRY(ENOANO, "ENOANO", "No anode"),
  237. #endif
  238. #if defined (EBADRQC)
  239.   ENTRY(EBADRQC, "EBADRQC", "Invalid request code"),
  240. #endif
  241. #if defined (EBADSLT)
  242.   ENTRY(EBADSLT, "EBADSLT", "Invalid slot"),
  243. #endif
  244. #if defined (EDEADLOCK)
  245.   ENTRY(EDEADLOCK, "EDEADLOCK", "File locking deadlock error"),
  246. #endif
  247. #if defined (EBFONT)
  248.   ENTRY(EBFONT, "EBFONT", "Bad font file format"),
  249. #endif
  250. #if defined (ENOSTR)
  251.   ENTRY(ENOSTR, "ENOSTR", "Device not a stream"),
  252. #endif
  253. #if defined (ENODATA)
  254.   ENTRY(ENODATA, "ENODATA", "No data available"),
  255. #endif
  256. #if defined (ETIME)
  257.   ENTRY(ETIME, "ETIME", "Timer expired"),
  258. #endif
  259. #if defined (ENOSR)
  260.   ENTRY(ENOSR, "ENOSR", "Out of streams resources"),
  261. #endif
  262. #if defined (ENONET)
  263.   ENTRY(ENONET, "ENONET", "Machine is not on the network"),
  264. #endif
  265. #if defined (ENOPKG)
  266.   ENTRY(ENOPKG, "ENOPKG", "Package not installed"),
  267. #endif
  268. #if defined (EREMOTE)
  269.   ENTRY(EREMOTE, "EREMOTE", "Object is remote"),
  270. #endif
  271. #if defined (ENOLINK)
  272.   ENTRY(ENOLINK, "ENOLINK", "Link has been severed"),
  273. #endif
  274. #if defined (EADV)
  275.   ENTRY(EADV, "EADV", "Advertise error"),
  276. #endif
  277. #if defined (ESRMNT)
  278.   ENTRY(ESRMNT, "ESRMNT", "Srmount error"),
  279. #endif
  280. #if defined (ECOMM)
  281.   ENTRY(ECOMM, "ECOMM", "Communication error on send"),
  282. #endif
  283. #if defined (EPROTO)
  284.   ENTRY(EPROTO, "EPROTO", "Protocol error"),
  285. #endif
  286. #if defined (EMULTIHOP)
  287.   ENTRY(EMULTIHOP, "EMULTIHOP", "Multihop attempted"),
  288. #endif
  289. #if defined (EDOTDOT)
  290.   ENTRY(EDOTDOT, "EDOTDOT", "RFS specific error"),
  291. #endif
  292. #if defined (EBADMSG)
  293.   ENTRY(EBADMSG, "EBADMSG", "Not a data message"),
  294. #endif
  295. #if defined (ENAMETOOLONG)
  296.