home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcl2-73c.zip / tcl7.3 / compat / strerror.c < prev    next >
C/C++ Source or Header  |  1993-10-28  |  12KB  |  485 lines

  1. /* 
  2.  * strerror.c --
  3.  *
  4.  *    Source code for the "strerror" library routine.
  5.  *
  6.  * Copyright (c) 1991-1993 The Regents of the University of California.
  7.  * All rights reserved.
  8.  *
  9.  * Permission is hereby granted, without written agreement and without
  10.  * license or royalty fees, to use, copy, modify, and distribute this
  11.  * software and its documentation for any purpose, provided that the
  12.  * above copyright notice and the following two paragraphs appear in
  13.  * all copies of this software.
  14.  * 
  15.  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  16.  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  17.  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  18.  * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19.  *
  20.  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  21.  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  22.  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  23.  * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  24.  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  25.  */
  26.  
  27. #ifndef lint
  28. static char rcsid[] = "$Header: /user6/ouster/tcl/compat/RCS/strerror.c,v 1.8 93/10/28 16:32:16 ouster Exp $ SPRITE (Berkeley)";
  29. #endif /* not lint */
  30.  
  31. #include "tclInt.h"
  32. #include "tclUnix.h"
  33.  
  34. extern int sys_nerr;
  35. extern char *sys_errlist[];
  36. /*
  37.  *----------------------------------------------------------------------
  38.  *
  39.  * strerror --
  40.  *
  41.  *    Map an integer error number into a printable string.
  42.  *
  43.  * Results:
  44.  *    The return value is a pointer to a string describing
  45.  *    error.  The first character of string isn't capitalized.
  46.  *
  47.  * Side effects:
  48.  *    Each call to this procedure may overwrite the value returned
  49.  *    by the previous call.
  50.  *
  51.  *----------------------------------------------------------------------
  52.  */
  53.  
  54. char *
  55. strerror(error)
  56.     int error;            /* Integer identifying error (must be
  57.                  * one of the officially-defined Sprite
  58.                  * errors, as defined in errno.h). */
  59. {
  60.     static char msg[50];
  61.  
  62. #ifndef NO_SYS_ERRLIST
  63.     if ((error <= sys_nerr) && (error > 0)) {
  64.     return sys_errlist[error];
  65.     }
  66. #else
  67.     switch (error) {
  68. #ifdef E2BIG
  69.     case E2BIG: return "argument list too long";
  70. #endif
  71. #ifdef EACCES
  72.     case EACCES: return "permission denied";
  73. #endif
  74. #ifdef EADDRINUSE
  75.     case EADDRINUSE: return "address already in use";
  76. #endif
  77. #ifdef EADDRNOTAVAIL
  78.     case EADDRNOTAVAIL: return "can't assign requested address";
  79. #endif
  80. #ifdef EADV
  81.     case EADV: return "advertise error";
  82. #endif
  83. #ifdef EAFNOSUPPORT
  84.     case EAFNOSUPPORT: return "address family not supported by protocol family";
  85. #endif
  86. #ifdef EAGAIN
  87.     case EAGAIN: return "no more processes";
  88. #endif
  89. #ifdef EALIGN
  90.     case EALIGN: return "EALIGN";
  91. #endif
  92. #ifdef EALREADY
  93.     case EALREADY: return "operation already in progress";
  94. #endif
  95. #ifdef EBADE
  96.     case EBADE: return "bad exchange descriptor";
  97. #endif
  98. #ifdef EBADF
  99.     case EBADF: return "bad file number";
  100. #endif
  101. #ifdef EBADFD
  102.     case EBADFD: return "file descriptor in bad state";
  103. #endif
  104. #ifdef EBADMSG
  105.     case EBADMSG: return "not a data message";
  106. #endif
  107. #ifdef EBADR
  108.     case EBADR: return "bad request descriptor";
  109. #endif
  110. #ifdef EBADRPC
  111.     case EBADRPC: return "RPC structure is bad";
  112. #endif
  113. #ifdef EBADRQC
  114.     case EBADRQC: return "bad request code";
  115. #endif
  116. #ifdef EBADSLT
  117.     case EBADSLT: return "invalid slot";
  118. #endif
  119. #ifdef EBFONT
  120.     case EBFONT: return "bad font file format";
  121. #endif
  122. #ifdef EBUSY
  123.     case EBUSY: return "mount device busy";
  124. #endif
  125. #ifdef ECHILD
  126.     case ECHILD: return "no children";
  127. #endif
  128. #ifdef ECHRNG
  129.     case ECHRNG: return "channel number out of range";
  130. #endif
  131. #ifdef ECOMM
  132.     case ECOMM: return "communication error on send";
  133. #endif
  134. #ifdef ECONNABORTED
  135.     case ECONNABORTED: return "software caused connection abort";
  136. #endif
  137. #ifdef ECONNREFUSED
  138.     case ECONNREFUSED: return "connection refused";
  139. #endif
  140. #ifdef ECONNRESET
  141.     case ECONNRESET: return "connection reset by peer";
  142. #endif
  143. #if defined(EDEADLK) && (!defined(EWOULDBLOCK) || (EDEADLK != EWOULDBLOCK))
  144.     case EDEADLK: return "resource deadlock avoided";
  145. #endif
  146. #ifdef EDEADLOCK
  147.     case EDEADLOCK: return "resource deadlock avoided";
  148. #endif
  149. #ifdef EDESTADDRREQ
  150.     case EDESTADDRREQ: return "destination address required";
  151. #endif
  152. #ifdef EDIRTY
  153.     case EDIRTY: return "mounting a dirty fs w/o force";
  154. #endif
  155. #ifdef EDOM
  156.     case EDOM: return "math argument out of range";
  157. #endif
  158. #ifdef EDOTDOT
  159.     case EDOTDOT: return "cross mount point";
  160. #endif
  161. #ifdef EDQUOT
  162.     case EDQUOT: return "disk quota exceeded";
  163. #endif
  164. #ifdef EDUPPKG
  165.     case EDUPPKG: return "duplicate package name";
  166. #endif
  167. #ifdef EEXIST
  168.     case EEXIST: return "file already exists";
  169. #endif
  170. #ifdef EFAULT
  171.     case EFAULT: return "bad address in system call argument";
  172. #endif
  173. #ifdef EFBIG
  174.     case EFBIG: return "file too large";
  175. #endif
  176. #ifdef EHOSTDOWN
  177.     case EHOSTDOWN: return "host is down";
  178. #endif
  179. #ifdef EHOSTUNREACH
  180.     case EHOSTUNREACH: return "host is unreachable";
  181. #endif
  182. #ifdef EIDRM
  183.     case EIDRM: return "identifier removed";
  184. #endif
  185. #ifdef EINIT
  186.     case EINIT: return "initialization error";
  187. #endif
  188. #ifdef EINPROGRESS
  189.     case EINPROGRESS: return "operation now in progress";
  190. #endif
  191. #ifdef EINTR
  192.     case EINTR: return "interrupted system call";
  193. #endif
  194. #ifdef EINVAL
  195.     case EINVAL: return "invalid argument";
  196. #endif
  197. #ifdef EIO
  198.     case EIO: return "I/O error";
  199. #endif
  200. #ifdef EISCONN
  201.     case EISCONN: return "socket is already connected";
  202. #endif
  203. #ifdef EISDIR
  204.     case EISDIR: return "illegal operation on a directory";
  205. #endif
  206. #ifdef EISNAME
  207.     case EISNAM: return "is a name file";
  208. #endif
  209. #ifdef ELBIN
  210.     case ELBIN: return "ELBIN";
  211. #endif
  212. #ifdef EL2HLT
  213.     case EL2HLT: return "level 2 halted";
  214. #endif
  215. #ifdef EL2NSYNC
  216.     case EL2NSYNC: return "level 2 not synchronized";
  217. #endif
  218. #ifdef EL3HLT
  219.     case EL3HLT: return "level 3 halted";
  220. #endif
  221. #ifdef EL3RST
  222.     case EL3RST: return "level 3 reset";
  223. #endif
  224. #ifdef ELIBACC
  225.     case ELIBACC: return "can not access a needed shared library";
  226. #endif
  227. #ifdef ELIBBAD
  228.     case ELIBBAD: return "accessing a corrupted shared library";
  229. #endif
  230. #ifdef ELIBEXEC
  231.     case ELIBEXEC: return "can not exec a shared library directly";
  232. #endif
  233. #ifdef ELIBMAX
  234.     case ELIBMAX: return
  235.         "attempting to link in more shared libraries than system limit";
  236. #endif
  237. #ifdef ELIBSCN
  238.     case ELIBSCN: return ".lib section in a.out corrupted";
  239. #endif
  240. #ifdef ELNRNG
  241.     case ELNRNG: return "link number out of range";
  242. #endif
  243. #ifdef ELOOP
  244.     case ELOOP: return "too many levels of symbolic links";
  245. #endif
  246. #ifdef EMFILE
  247.     case EMFILE: return "too many open files";
  248. #endif
  249. #ifdef EMLINK
  250.     case EMLINK: return "too many links";
  251. #endif
  252. #ifdef EMSGSIZE
  253.     case EMSGSIZE: return "message too long";
  254. #endif
  255. #ifdef EMULTIHOP
  256.     case EMULTIHOP: return "multihop attempted";
  257. #endif
  258. #ifdef ENAMETOOLONG
  259.     case ENAMETOOLONG: return "file name too long";
  260. #endif
  261. #ifdef ENAVAIL
  262.     case ENAVAIL: return "not available";
  263. #endif
  264. #ifdef ENET
  265.     case ENET: return "ENET";
  266. #endif
  267. #ifdef ENETDOWN
  268.     case ENETDOWN: return "network is down";
  269. #endif
  270. #ifdef ENETRESET
  271.     case ENETRESET: return "network dropped connection on reset";
  272. #endif
  273. #ifdef ENETUNREACH
  274.     case ENETUNREACH: return "network is unreachable";
  275. #endif
  276. #ifdef ENFILE
  277.     case ENFILE: return "file table overflow";
  278. #endif
  279. #ifdef ENOANO
  280.     case ENOANO: return "anode table overflow";
  281. #endif
  282. #if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR))
  283.     case ENOBUFS: return "no buffer space available";
  284. #endif
  285. #ifdef ENOCSI
  286.     case ENOCSI: return "no CSI structure available";
  287. #endif
  288. #ifdef ENODATA
  289.     case ENODATA: return "no data available";
  290. #endif
  291. #ifdef ENODEV
  292.     case ENODEV: return "no such device";
  293. #endif
  294. #ifdef ENOENT
  295.     case ENOENT: return "no such file or directory";
  296. #endif
  297. #ifdef ENOEXEC
  298.     case ENOEXEC: return "exec format error";
  299. #endif
  300. #ifdef ENOLCK
  301.     case ENOLCK: return "no locks available";
  302. #endif
  303. #ifdef ENOLINK
  304.     case ENOLINK: return "link has be severed";
  305. #endif
  306. #ifdef ENOMEM
  307.     case ENOMEM: return "not enough memory";
  308. #endif
  309. #ifdef ENOMSG
  310.     case ENOMSG: return "no message of desired type";
  311. #endif
  312. #ifdef ENONET
  313.     case ENONET: return "machine is not on the network";
  314. #endif
  315. #ifdef ENOPKG
  316.     case ENOPKG: return "package not installed";
  317. #endif
  318. #ifdef ENOPROTOOPT
  319.     case ENOPROTOOPT: return "bad proocol option";
  320. #endif
  321. #ifdef ENOSPC
  322.     case ENOSPC: return "no space left on device";
  323. #endif
  324. #ifdef ENOSR
  325.     case ENOSR: return "out of stream resources";
  326. #endif
  327. #ifdef ENOSTR
  328.     case ENOSTR: return "not a stream device";
  329. #endif
  330. #ifdef ENOSYM
  331.     case ENOSYM: return "unresolved symbol name";
  332. #endif
  333. #ifdef ENOSYS
  334.     case ENOSYS: return "function not implemented";
  335. #endif
  336. #ifdef ENOTBLK
  337.     case ENOTBLK: return "block device required";
  338. #endif
  339. #ifdef ENOTCONN
  340.     case ENOTCONN: return "socket is not connected";
  341. #endif
  342. #ifdef ENOTDIR
  343.     case ENOTDIR: return "not a directory";
  344. #endif
  345. #ifdef ENOTEMPTY
  346.     case ENOTEMPTY: return "directory not empty";
  347. #endif
  348. #ifdef ENOTNAM
  349.     case ENOTNAM: return "not a name file";
  350. #endif
  351. #ifdef ENOTSOCK
  352.     case ENOTSOCK: return "socket operation on non-socket";
  353. #endif
  354. #ifdef ENOTTY
  355.     case ENOTTY: return "inappropriate device for ioctl";
  356. #endif
  357. #ifdef ENOTUNIQ
  358.     case ENOTUNIQ: return "name not unique on network";
  359. #endif
  360. #ifdef ENXIO
  361.     case ENXIO: return "no such device or address";
  362. #endif
  363. #ifdef EOPNOTSUPP
  364.     case EOPNOTSUPP: return "operation not supported on socket";
  365. #endif
  366. #ifdef EPERM
  367.     case EPERM: return "not owner";
  368. #endif
  369. #ifdef EPFNOSUPPORT
  370.     case EPFNOSUPPORT: return "protocol family not supported";
  371. #endif
  372. #ifdef EPIPE
  373.     case EPIPE: return "broken pipe";
  374. #endif
  375. #ifdef EPROCLIM
  376.     case EPROCLIM: return "too many processes";
  377. #endif
  378. #ifdef EPROCUNAVAIL
  379.     case EPROCUNAVAIL: return "bad procedure for program";
  380. #endif
  381. #ifdef EPROGMISMATCH
  382.     case EPROGMISMATCH: return "program version wrong";
  383. #endif
  384. #ifdef EPROGUNAVAIL
  385.     case EPROGUNAVAIL: return "RPC program not available";
  386. #endif
  387. #ifdef EPROTO
  388.     case EPROTO: return "protocol error";
  389. #endif
  390. #ifdef EPROTONOSUPPORT
  391.     case EPROTONOSUPPORT: return "protocol not suppored";
  392. #endif
  393. #ifdef EPROTOTYPE
  394.     case EPROTOTYPE: return "protocol wrong type for socket";
  395. #endif
  396. #ifdef ERANGE
  397.     case ERANGE: return "math result unrepresentable";
  398. #endif
  399. #if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED))
  400.     case EREFUSED: return "EREFUSED";
  401. #endif
  402. #ifdef EREMCHG
  403.     case EREMCHG: return "remote address changed";
  404. #endif
  405. #ifdef EREMDEV
  406.     case EREMDEV: return "remote device";
  407. #endif
  408. #ifdef EREMOTE
  409.     case EREMOTE: return "pathname hit remote file system";
  410. #endif
  411. #ifdef EREMOTEIO
  412.     case EREMOTEIO: return "remote i/o error";
  413. #endif
  414. #ifdef EREMOTERELEASE
  415.     case EREMOTERELEASE: return "EREMOTERELEASE";
  416. #endif
  417. #ifdef EROFS
  418.     case EROFS: return "read-only file system";
  419. #endif
  420. #ifdef ERPCMISMATCH
  421.     case ERPCMISMATCH: return "RPC version is wrong";
  422. #endif
  423. #ifdef ERREMOTE
  424.     case ERREMOTE: return "object is remote";
  425. #endif
  426. #ifdef ESHUTDOWN
  427.     case ESHUTDOWN: return "can't send afer socket shutdown";
  428. #endif
  429. #ifdef ESOCKTNOSUPPORT
  430.     case ESOCKTNOSUPPORT: return "socket type not supported";
  431. #endif
  432. #ifdef ESPIPE
  433.     case ESPIPE: return "invalid seek";
  434. #endif
  435. #ifdef ESRCH
  436.     case ESRCH: return "no such process";
  437. #endif
  438. #ifdef ESRMNT
  439.     case ESRMNT: return "srmount error";
  440. #endif
  441. #ifdef ESTALE
  442.     case ESTALE: return "stale remote file handle";
  443. #endif
  444. #ifdef ESUCCESS
  445.     case ESUCCESS: return "Error 0";
  446. #endif
  447. #ifdef ETIME
  448.     case ETIME: return "timer expired";
  449. #endif
  450. #ifdef ETIMEDOUT
  451.     case ETIMEDOUT: return "connection timed out";
  452. #endif
  453. #ifdef ETOOMANYREFS
  454.     case ETOOMANYREFS: return "too many references: can't splice";
  455. #endif
  456. #ifdef ETXTBSY
  457.     case ETXTBSY: return "text file or pseudo-device busy";
  458. #endif
  459. #ifdef EUCLEAN
  460.     case EUCLEAN: return "structure needs cleaning";
  461. #endif
  462. #ifdef EUNATCH
  463.     case EUNATCH: return "protocol driver not attached";
  464. #endif
  465. #ifdef EUSERS
  466.     case EUSERS: return "too many users";
  467. #endif
  468. #ifdef EVERSION
  469.     case EVERSION: return "version mismatch";
  470. #endif
  471. #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
  472.     case EWOULDBLOCK: return "operation would block";
  473. #endif
  474. #ifdef EXDEV
  475.     case EXDEV: return "cross-domain link";
  476. #endif
  477. #ifdef EXFULL
  478.     case EXFULL: return "message tables full";
  479. #endif
  480.     }
  481. #endif /* ! NO_SYS_ERRLIST */
  482.     sprintf(msg, "unknown error (%d)", error);
  483.     return msg;
  484. }
  485.