home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tkisrc04.zip / tcl / os2 / tclPosixStr.c < prev    next >
C/C++ Source or Header  |  1998-08-07  |  27KB  |  1,175 lines

  1. /* 
  2.  * tclPosixStr.c --
  3.  *
  4.  *    This file contains procedures that generate strings
  5.  *    corresponding to various POSIX-related codes, such
  6.  *    as errno and signals.
  7.  *
  8.  * Copyright (c) 1991-1994 The Regents of the University of California.
  9.  * Copyright (c) 1994-1996 Sun Microsystems, Inc.
  10.  *
  11.  * See the file "license.terms" for information on usage and redistribution
  12.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  13.  *
  14.  * SCCS: @(#) tclPosixStr.c 1.30 96/02/08 16:33:34
  15.  */
  16.  
  17. #include "tclInt.h"
  18. #include "tclPort.h"
  19.  
  20. /*
  21.  *----------------------------------------------------------------------
  22.  *
  23.  * Tcl_ErrnoId --
  24.  *
  25.  *    Return a textual identifier for the current errno value.
  26.  *
  27.  * Results:
  28.  *    This procedure returns a machine-readable textual identifier
  29.  *    that corresponds to the current errno value (e.g. "EPERM").
  30.  *    The identifier is the same as the #define name in errno.h.
  31.  *
  32.  * Side effects:
  33.  *    None.
  34.  *
  35.  *----------------------------------------------------------------------
  36.  */
  37.  
  38. char *
  39. Tcl_ErrnoId()
  40. {
  41.     switch (errno) {
  42. #ifdef E2BIG
  43.     case E2BIG: return "E2BIG";
  44. #endif
  45. #ifdef EACCES
  46.     case EACCES: return "EACCES";
  47. #endif
  48. #ifdef EADDRINUSE
  49.     case EADDRINUSE: return "EADDRINUSE";
  50. #endif
  51. #ifdef EADDRNOTAVAIL
  52.     case EADDRNOTAVAIL: return "EADDRNOTAVAIL";
  53. #endif
  54. #ifdef EADV
  55.     case EADV: return "EADV";
  56. #endif
  57. #ifdef EAFNOSUPPORT
  58.     case EAFNOSUPPORT: return "EAFNOSUPPORT";
  59. #endif
  60. #ifdef EAGAIN
  61.     case EAGAIN: return "EAGAIN";
  62. #endif
  63. #ifdef EALIGN
  64.     case EALIGN: return "EALIGN";
  65. #endif
  66. #if defined(EALREADY) && (!defined(EBUSY) || (EALREADY != EBUSY ))
  67.     case EALREADY: return "EALREADY";
  68. #endif
  69. #ifdef EBADE
  70.     case EBADE: return "EBADE";
  71. #endif
  72. #ifdef EBADF
  73.     case EBADF: return "EBADF";
  74. #endif
  75. #ifdef EBADFD
  76.     case EBADFD: return "EBADFD";
  77. #endif
  78. #ifdef EBADMSG
  79.     case EBADMSG: return "EBADMSG";
  80. #endif
  81. #ifdef EBADR
  82.     case EBADR: return "EBADR";
  83. #endif
  84. #ifdef EBADRPC
  85.     case EBADRPC: return "EBADRPC";
  86. #endif
  87. #ifdef EBADRQC
  88.     case EBADRQC: return "EBADRQC";
  89. #endif
  90. #ifdef EBADSLT
  91.     case EBADSLT: return "EBADSLT";
  92. #endif
  93. #ifdef EBFONT
  94.     case EBFONT: return "EBFONT";
  95. #endif
  96. #ifdef EBUSY
  97.     case EBUSY: return "EBUSY";
  98. #endif
  99. #ifdef ECHILD
  100.     case ECHILD: return "ECHILD";
  101. #endif
  102. #ifdef ECHRNG
  103.     case ECHRNG: return "ECHRNG";
  104. #endif
  105. #ifdef ECOMM
  106.     case ECOMM: return "ECOMM";
  107. #endif
  108. #ifdef ECONNABORTED
  109.     case ECONNABORTED: return "ECONNABORTED";
  110. #endif
  111. #ifdef ECONNREFUSED
  112.     case ECONNREFUSED: return "ECONNREFUSED";
  113. #endif
  114. #ifdef ECONNRESET
  115.     case ECONNRESET: return "ECONNRESET";
  116. #endif
  117. #if defined(EDEADLK) && (!defined(EWOULDBLOCK) || (EDEADLK != EWOULDBLOCK))
  118.     case EDEADLK: return "EDEADLK";
  119. #endif
  120. #ifdef EDEADLOCK
  121.     case EDEADLOCK: return "EDEADLOCK";
  122. #endif
  123. #ifdef EDESTADDRREQ
  124.     case EDESTADDRREQ: return "EDESTADDRREQ";
  125. #endif
  126. #ifdef EDIRTY
  127.     case EDIRTY: return "EDIRTY";
  128. #endif
  129. #ifdef EDOM
  130.     case EDOM: return "EDOM";
  131. #endif
  132. #ifdef EDOTDOT
  133.     case EDOTDOT: return "EDOTDOT";
  134. #endif
  135. #ifdef EDQUOT
  136.     case EDQUOT: return "EDQUOT";
  137. #endif
  138. #ifdef EDUPPKG
  139.     case EDUPPKG: return "EDUPPKG";
  140. #endif
  141. #ifdef EEXIST
  142.     case EEXIST: return "EEXIST";
  143. #endif
  144. #ifdef EFAULT
  145.     case EFAULT: return "EFAULT";
  146. #endif
  147. #ifdef EFBIG
  148.     case EFBIG: return "EFBIG";
  149. #endif
  150. #ifdef EHOSTDOWN
  151.     case EHOSTDOWN: return "EHOSTDOWN";
  152. #endif
  153. #ifdef EHOSTUNREACH
  154.     case EHOSTUNREACH: return "EHOSTUNREACH";
  155. #endif
  156. #if defined(EIDRM) && (!defined(EINPROGRESS) || (EIDRM != EINPROGRESS))
  157.     case EIDRM: return "EIDRM";
  158. #endif
  159. #ifdef EINIT
  160.     case EINIT: return "EINIT";
  161. #endif
  162. #ifdef EINPROGRESS
  163.     case EINPROGRESS: return "EINPROGRESS";
  164. #endif
  165. #ifdef EINTR
  166.     case EINTR: return "EINTR";
  167. #endif
  168. #ifdef EINVAL
  169.     case EINVAL: return "EINVAL";
  170. #endif
  171. #ifdef EIO
  172.     case EIO: return "EIO";
  173. #endif
  174. #ifdef EISCONN
  175.     case EISCONN: return "EISCONN";
  176. #endif
  177. #ifdef EISDIR
  178.     case EISDIR: return "EISDIR";
  179. #endif
  180. #ifdef EISNAME
  181.     case EISNAM: return "EISNAM";
  182. #endif
  183. #ifdef ELBIN
  184.     case ELBIN: return "ELBIN";
  185. #endif
  186. #ifdef EL2HLT
  187.     case EL2HLT: return "EL2HLT";
  188. #endif
  189. #ifdef EL2NSYNC
  190.     case EL2NSYNC: return "EL2NSYNC";
  191. #endif
  192. #ifdef EL3HLT
  193.     case EL3HLT: return "EL3HLT";
  194. #endif
  195. #ifdef EL3RST
  196.     case EL3RST: return "EL3RST";
  197. #endif
  198. #ifdef ELIBACC
  199.     case ELIBACC: return "ELIBACC";
  200. #endif
  201. #ifdef ELIBBAD
  202.     case ELIBBAD: return "ELIBBAD";
  203. #endif
  204. #ifdef ELIBEXEC
  205.     case ELIBEXEC: return "ELIBEXEC";
  206. #endif
  207. #ifdef ELIBMAX
  208.     case ELIBMAX: return "ELIBMAX";
  209. #endif
  210. #ifdef ELIBSCN
  211.     case ELIBSCN: return "ELIBSCN";
  212. #endif
  213. #ifdef ELNRNG
  214.     case ELNRNG: return "ELNRNG";
  215. #endif
  216. #if defined(ELOOP) && (!defined(ENOENT) || (ELOOP != ENOENT))
  217.     case ELOOP: return "ELOOP";
  218. #endif
  219. #ifdef EMFILE
  220.     case EMFILE: return "EMFILE";
  221. #endif
  222. #ifdef EMLINK
  223.     case EMLINK: return "EMLINK";
  224. #endif
  225. #ifdef EMSGSIZE
  226.     case EMSGSIZE: return "EMSGSIZE";
  227. #endif
  228. #ifdef EMULTIHOP
  229.     case EMULTIHOP: return "EMULTIHOP";
  230. #endif
  231. #ifdef ENAMETOOLONG
  232.     case ENAMETOOLONG: return "ENAMETOOLONG";
  233. #endif
  234. #ifdef ENAVAIL
  235.     case ENAVAIL: return "ENAVAIL";
  236. #endif
  237. #ifdef ENET
  238.     case ENET: return "ENET";
  239. #endif
  240. #ifdef ENETDOWN
  241.     case ENETDOWN: return "ENETDOWN";
  242. #endif
  243. #ifdef ENETRESET
  244.     case ENETRESET: return "ENETRESET";
  245. #endif
  246. #ifdef ENETUNREACH
  247.     case ENETUNREACH: return "ENETUNREACH";
  248. #endif
  249. #ifdef ENFILE
  250.     case ENFILE: return "ENFILE";
  251. #endif
  252. #ifdef ENOANO
  253.     case ENOANO: return "ENOANO";
  254. #endif
  255. #if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR))
  256.     case ENOBUFS: return "ENOBUFS";
  257. #endif
  258. #ifdef ENOCSI
  259.     case ENOCSI: return "ENOCSI";
  260. #endif
  261. #if defined(ENODATA) && (!defined(ECONNREFUSED) || (ENODATA != ECONNREFUSED))
  262.     case ENODATA: return "ENODATA";
  263. #endif
  264. #ifdef ENODEV
  265.     case ENODEV: return "ENODEV";
  266. #endif
  267. #ifdef ENOENT
  268.     case ENOENT: return "ENOENT";
  269. #endif
  270. #ifdef ENOEXEC
  271.     case ENOEXEC: return "ENOEXEC";
  272. #endif
  273. #ifdef ENOLCK
  274.     case ENOLCK: return "ENOLCK";
  275. #endif
  276. #ifdef ENOLINK
  277.     case ENOLINK: return "ENOLINK";
  278. #endif
  279. #ifdef ENOMEM
  280.     case ENOMEM: return "ENOMEM";
  281. #endif
  282. #ifdef ENOMSG
  283.     case ENOMSG: return "ENOMSG";
  284. #endif
  285. #ifdef ENONET
  286.     case ENONET: return "ENONET";
  287. #endif
  288. #ifdef ENOPKG
  289.     case ENOPKG: return "ENOPKG";
  290. #endif
  291. #ifdef ENOPROTOOPT
  292.     case ENOPROTOOPT: return "ENOPROTOOPT";
  293. #endif
  294. #ifdef ENOSPC
  295.     case ENOSPC: return "ENOSPC";
  296. #endif
  297. #if defined(ENOSR) && (!defined(ENAMETOOLONG) || (ENAMETOOLONG != ENOSR))
  298.     case ENOSR: return "ENOSR";
  299. #endif
  300. #if defined(ENOSTR) && (!defined(ENOTTY) || (ENOTTY != ENOSTR))
  301.     case ENOSTR: return "ENOSTR";
  302. #endif
  303. #ifdef ENOSYM
  304.     case ENOSYM: return "ENOSYM";
  305. #endif
  306. #ifdef ENOSYS
  307.     case ENOSYS: return "ENOSYS";
  308. #endif
  309. #ifdef ENOTBLK
  310.     case ENOTBLK: return "ENOTBLK";
  311. #endif
  312. #ifdef ENOTCONN
  313.     case ENOTCONN: return "ENOTCONN";
  314. #endif
  315. #ifdef ENOTDIR
  316.     case ENOTDIR: return "ENOTDIR";
  317. #endif
  318. #if defined(ENOTEMPTY) && (!defined(EEXIST) || (ENOTEMPTY != EEXIST))
  319.     case ENOTEMPTY: return "ENOTEMPTY";
  320. #endif
  321. #ifdef ENOTNAM
  322.     case ENOTNAM: return "ENOTNAM";
  323. #endif
  324. #ifdef ENOTSOCK
  325.     case ENOTSOCK: return "ENOTSOCK";
  326. #endif
  327. #ifdef ENOTSUP
  328.     case ENOTSUP: return "ENOTSUP";
  329. #endif
  330. #ifdef ENOTTY
  331.     case ENOTTY: return "ENOTTY";
  332. #endif
  333. #ifdef ENOTUNIQ
  334.     case ENOTUNIQ: return "ENOTUNIQ";
  335. #endif
  336. #ifdef ENXIO
  337.     case ENXIO: return "ENXIO";
  338. #endif
  339. #ifdef EOPNOTSUPP
  340.     case EOPNOTSUPP: return "EOPNOTSUPP";
  341. #endif
  342. #ifdef EPERM
  343.     case EPERM: return "EPERM";
  344. #endif
  345. #if defined(EPFNOSUPPORT) && (!defined(ENOLCK) || (ENOLCK != EPFNOSUPPORT))
  346.     case EPFNOSUPPORT: return "EPFNOSUPPORT";
  347. #endif
  348. #ifdef EPIPE
  349.     case EPIPE: return "EPIPE";
  350. #endif
  351. #ifdef EPROCLIM
  352.     case EPROCLIM: return "EPROCLIM";
  353. #endif
  354. #ifdef EPROCUNAVAIL
  355.     case EPROCUNAVAIL: return "EPROCUNAVAIL";
  356. #endif
  357. #ifdef EPROGMISMATCH
  358.     case EPROGMISMATCH: return "EPROGMISMATCH";
  359. #endif
  360. #ifdef EPROGUNAVAIL
  361.     case EPROGUNAVAIL: return "EPROGUNAVAIL";
  362. #endif
  363. #ifdef EPROTO
  364.     case EPROTO: return "EPROTO";
  365. #endif
  366. #ifdef EPROTONOSUPPORT
  367.     case EPROTONOSUPPORT: return "EPROTONOSUPPORT";
  368. #endif
  369. #ifdef EPROTOTYPE
  370.     case EPROTOTYPE: return "EPROTOTYPE";
  371. #endif
  372. #ifdef ERANGE
  373.     case ERANGE: return "ERANGE";
  374. #endif
  375. #if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED))
  376.     case EREFUSED: return "EREFUSED";
  377. #endif
  378. #ifdef EREMCHG
  379.     case EREMCHG: return "EREMCHG";
  380. #endif
  381. #ifdef EREMDEV
  382.     case EREMDEV: return "EREMDEV";
  383. #endif
  384. #ifdef EREMOTE
  385.     case EREMOTE: return "EREMOTE";
  386. #endif
  387. #ifdef EREMOTEIO
  388.     case EREMOTEIO: return "EREMOTEIO";
  389. #endif
  390. #ifdef EREMOTERELEASE
  391.     case EREMOTERELEASE: return "EREMOTERELEASE";
  392. #endif
  393. #ifdef EROFS
  394.     case EROFS: return "EROFS";
  395. #endif
  396. #ifdef ERPCMISMATCH
  397.     case ERPCMISMATCH: return "ERPCMISMATCH";
  398. #endif
  399. #ifdef ERREMOTE
  400.     case ERREMOTE: return "ERREMOTE";
  401. #endif
  402. #ifdef ESHUTDOWN
  403.     case ESHUTDOWN: return "ESHUTDOWN";
  404. #endif
  405. #ifdef ESOCKTNOSUPPORT
  406.     case ESOCKTNOSUPPORT: return "ESOCKTNOSUPPORT";
  407. #endif
  408. #ifdef ESPIPE
  409.     case ESPIPE: return "ESPIPE";
  410. #endif
  411. #ifdef ESRCH
  412.     case ESRCH: return "ESRCH";
  413. #endif
  414. #ifdef ESRMNT
  415.     case ESRMNT: return "ESRMNT";
  416. #endif
  417. #ifdef ESTALE
  418.     case ESTALE: return "ESTALE";
  419. #endif
  420. #ifdef ESUCCESS
  421.     case ESUCCESS: return "ESUCCESS";
  422. #endif
  423. #if defined(ETIME) && (!defined(ELOOP) || (ETIME != ELOOP))
  424.     case ETIME: return "ETIME";
  425. #endif
  426. #if defined(ETIMEDOUT) && (!defined(ENOSTR) || (ETIMEDOUT != ENOSTR))
  427.     case ETIMEDOUT: return "ETIMEDOUT";
  428. #endif
  429. #ifdef ETOOMANYREFS
  430.     case ETOOMANYREFS: return "ETOOMANYREFS";
  431. #endif
  432. #ifdef ETXTBSY
  433.     case ETXTBSY: return "ETXTBSY";
  434. #endif
  435. #ifdef EUCLEAN
  436.     case EUCLEAN: return "EUCLEAN";
  437. #endif
  438. #ifdef EUNATCH
  439.     case EUNATCH: return "EUNATCH";
  440. #endif
  441. #ifdef EUSERS
  442.     case EUSERS: return "EUSERS";
  443. #endif
  444. #ifdef EVERSION
  445.     case EVERSION: return "EVERSION";
  446. #endif
  447. #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
  448.     case EWOULDBLOCK: return "EWOULDBLOCK";
  449. #endif
  450. #ifdef EXDEV
  451.     case EXDEV: return "EXDEV";
  452. #endif
  453. #ifdef EXFULL
  454.     case EXFULL: return "EXFULL";
  455. #endif
  456.     }
  457.     return "unknown error";
  458. }
  459.  
  460. /*
  461.  *----------------------------------------------------------------------
  462.  *
  463.  * Tcl_ErrnoMsg --
  464.  *
  465.  *    Return a human-readable message corresponding to a given
  466.  *    errno value.
  467.  *
  468.  * Results:
  469.  *    The return value is the standard POSIX error message for
  470.  *    errno.  This procedure is used instead of strerror because
  471.  *    strerror returns slightly different values on different
  472.  *    machines (e.g. different capitalizations), which cause
  473.  *    problems for things such as regression tests.  This procedure
  474.  *    provides messages for most standard errors, then it calls
  475.  *    strerror for things it doesn't understand.
  476.  *
  477.  * Side effects:
  478.  *    None.
  479.  *
  480.  *----------------------------------------------------------------------
  481.  */
  482.  
  483. char *
  484. Tcl_ErrnoMsg(err)
  485.     int err;            /* Error number (such as in errno variable). */
  486. {
  487.     switch (err) {
  488. #ifdef E2BIG
  489.     case E2BIG: return "argument list too long";
  490. #endif
  491. #ifdef EACCES
  492.     case EACCES: return "permission denied";
  493. #endif
  494. #ifdef EADDRINUSE
  495.     case EADDRINUSE: return "address already in use";
  496. #endif
  497. #ifdef EADDRNOTAVAIL
  498.     case EADDRNOTAVAIL: return "can't assign requested address";
  499. #endif
  500. #ifdef EADV
  501.     case EADV: return "advertise error";
  502. #endif
  503. #ifdef EAFNOSUPPORT
  504.     case EAFNOSUPPORT: return "address family not supported by protocol family";
  505. #endif
  506. #ifdef EAGAIN
  507.     case EAGAIN: return "resource temporarily unavailable";
  508. #endif
  509. #ifdef EALIGN
  510.     case EALIGN: return "EALIGN";
  511. #endif
  512. #if defined(EALREADY) && (!defined(EBUSY) || (EALREADY != EBUSY ))
  513.     case EALREADY: return "operation already in progress";
  514. #endif
  515. #ifdef EBADE
  516.     case EBADE: return "bad exchange descriptor";
  517. #endif
  518. #ifdef EBADF
  519.     case EBADF: return "bad file number";
  520. #endif
  521. #ifdef EBADFD
  522.     case EBADFD: return "file descriptor in bad state";
  523. #endif
  524. #ifdef EBADMSG
  525.     case EBADMSG: return "not a data message";
  526. #endif
  527. #ifdef EBADR
  528.     case EBADR: return "bad request descriptor";
  529. #endif
  530. #ifdef EBADRPC
  531.     case EBADRPC: return "RPC structure is bad";
  532. #endif
  533. #ifdef EBADRQC
  534.     case EBADRQC: return "bad request code";
  535. #endif
  536. #ifdef EBADSLT
  537.     case EBADSLT: return "invalid slot";
  538. #endif
  539. #ifdef EBFONT
  540.     case EBFONT: return "bad font file format";
  541. #endif
  542. #ifdef EBUSY
  543.     case EBUSY: return "mount device busy";
  544. #endif
  545. #ifdef ECHILD
  546.     case ECHILD: return "no children";
  547. #endif
  548. #ifdef ECHRNG
  549.     case ECHRNG: return "channel number out of range";
  550. #endif
  551. #ifdef ECOMM
  552.     case ECOMM: return "communication error on send";
  553. #endif
  554. #ifdef ECONNABORTED
  555.     case ECONNABORTED: return "software caused connection abort";
  556. #endif
  557. #ifdef ECONNREFUSED
  558.     case ECONNREFUSED: return "connection refused";
  559. #endif
  560. #ifdef ECONNRESET
  561.     case ECONNRESET: return "connection reset by peer";
  562. #endif
  563. #if defined(EDEADLK) && (!defined(EWOULDBLOCK) || (EDEADLK != EWOULDBLOCK))
  564.     case EDEADLK: return "resource deadlock avoided";
  565. #endif
  566. #ifdef EDEADLOCK
  567.     case EDEADLOCK: return "resource deadlock avoided";
  568. #endif
  569. #ifdef EDESTADDRREQ
  570.     case EDESTADDRREQ: return "destination address required";
  571. #endif
  572. #ifdef EDIRTY
  573.     case EDIRTY: return "mounting a dirty fs w/o force";
  574. #endif
  575. #ifdef EDOM
  576.     case EDOM: return "math argument out of range";
  577. #endif
  578. #ifdef EDOTDOT
  579.     case EDOTDOT: return "cross mount point";
  580. #endif
  581. #ifdef EDQUOT
  582.     case EDQUOT: return "disk quota exceeded";
  583. #endif
  584. #ifdef EDUPPKG
  585.     case EDUPPKG: return "duplicate package name";
  586. #endif
  587. #ifdef EEXIST
  588.     case EEXIST: return "file already exists";
  589. #endif
  590. #ifdef EFAULT
  591.     case EFAULT: return "bad address in system call argument";
  592. #endif
  593. #ifdef EFBIG
  594.     case EFBIG: return "file too large";
  595. #endif
  596. #ifdef EHOSTDOWN
  597.     case EHOSTDOWN: return "host is down";
  598. #endif
  599. #ifdef EHOSTUNREACH
  600.     case EHOSTUNREACH: return "host is unreachable";
  601. #endif
  602. #if defined(EIDRM) && (!defined(EINPROGRESS) || (EIDRM != EINPROGRESS))
  603.     case EIDRM: return "identifier removed";
  604. #endif
  605. #ifdef EINIT
  606.     case EINIT: return "initialization error";
  607. #endif
  608. #ifdef EINPROGRESS
  609.     case EINPROGRESS: return "operation now in progress";
  610. #endif
  611. #ifdef EINTR
  612.     case EINTR: return "interrupted system call";
  613. #endif
  614. #ifdef EINVAL
  615.     case EINVAL: return "invalid argument";
  616. #endif
  617. #ifdef EIO
  618.     case EIO: return "I/O error";
  619. #endif
  620. #ifdef EISCONN
  621.     case EISCONN: return "socket is already connected";
  622. #endif
  623. #ifdef EISDIR
  624.     case EISDIR: return "illegal operation on a directory";
  625. #endif
  626. #ifdef EISNAME
  627.     case EISNAM: return "is a name file";
  628. #endif
  629. #ifdef ELBIN
  630.     case ELBIN: return "ELBIN";
  631. #endif
  632. #ifdef EL2HLT
  633.     case EL2HLT: return "level 2 halted";
  634. #endif
  635. #ifdef EL2NSYNC
  636.     case EL2NSYNC: return "level 2 not synchronized";
  637. #endif
  638. #ifdef EL3HLT
  639.     case EL3HLT: return "level 3 halted";
  640. #endif
  641. #ifdef EL3RST
  642.     case EL3RST: return "level 3 reset";
  643. #endif
  644. #ifdef ELIBACC
  645.     case ELIBACC: return "can not access a needed shared library";
  646. #endif
  647. #ifdef ELIBBAD
  648.     case ELIBBAD: return "accessing a corrupted shared library";
  649. #endif
  650. #ifdef ELIBEXEC
  651.     case ELIBEXEC: return "can not exec a shared library directly";
  652. #endif
  653. #ifdef ELIBMAX
  654.     case ELIBMAX: return
  655.         "attempting to link in more shared libraries than system limit";
  656. #endif
  657. #ifdef ELIBSCN
  658.     case ELIBSCN: return ".lib section in a.out corrupted";
  659. #endif
  660. #ifdef ELNRNG
  661.     case ELNRNG: return "link number out of range";
  662. #endif
  663. #if defined(ELOOP) && (!defined(ENOENT) || (ELOOP != ENOENT))
  664.     case ELOOP: return "too many levels of symbolic links";
  665. #endif
  666. #ifdef EMFILE
  667.     case EMFILE: return "too many open files";
  668. #endif
  669. #ifdef EMLINK
  670.     case EMLINK: return "too many links";
  671. #endif
  672. #ifdef EMSGSIZE
  673.     case EMSGSIZE: return "message too long";
  674. #endif
  675. #ifdef EMULTIHOP
  676.     case EMULTIHOP: return "multihop attempted";
  677. #endif
  678. #ifdef ENAMETOOLONG
  679.     case ENAMETOOLONG: return "file name too long";
  680. #endif
  681. #ifdef ENAVAIL
  682.     case ENAVAIL: return "not available";
  683. #endif
  684. #ifdef ENET
  685.     case ENET: return "ENET";
  686. #endif
  687. #ifdef ENETDOWN
  688.     case ENETDOWN: return "network is down";
  689. #endif
  690. #ifdef ENETRESET
  691.     case ENETRESET: return "network dropped connection on reset";
  692. #endif
  693. #ifdef ENETUNREACH
  694.     case ENETUNREACH: return "network is unreachable";
  695. #endif
  696. #ifdef ENFILE
  697.     case ENFILE: return "file table overflow";
  698. #endif
  699. #ifdef ENOANO
  700.     case ENOANO: return "anode table overflow";
  701. #endif
  702. #if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR))
  703.     case ENOBUFS: return "no buffer space available";
  704. #endif
  705. #ifdef ENOCSI
  706.     case ENOCSI: return "no CSI structure available";
  707. #endif
  708. #if defined(ENODATA) && (!defined(ECONNREFUSED) || (ENODATA != ECONNREFUSED))
  709.     case ENODATA: return "no data available";
  710. #endif
  711. #ifdef ENODEV
  712.     case ENODEV: return "no such device";
  713. #endif
  714. #ifdef ENOENT
  715.     case ENOENT: return "no such file or directory";
  716. #endif
  717. #ifdef ENOEXEC
  718.     case ENOEXEC: return "exec format error";
  719. #endif
  720. #ifdef ENOLCK
  721.     case ENOLCK: return "no locks available";
  722. #endif
  723. #ifdef ENOLINK
  724.     case ENOLINK: return "link has be severed";
  725. #endif
  726. #ifdef ENOMEM
  727.     case ENOMEM: return "not enough memory";
  728. #endif
  729. #ifdef ENOMSG
  730.     case ENOMSG: return "no message of desired type";
  731. #endif
  732. #ifdef ENONET
  733.     case ENONET: return "machine is not on the network";
  734. #endif
  735. #ifdef ENOPKG
  736.     case ENOPKG: return "package not installed";
  737. #endif
  738. #ifdef ENOPROTOOPT
  739.     case ENOPROTOOPT: return "bad proocol option";
  740. #endif
  741. #ifdef ENOSPC
  742.     case ENOSPC: return "no space left on device";
  743. #endif
  744. #if defined(ENOSR) && (!defined(ENAMETOOLONG) || (ENAMETOOLONG != ENOSR))
  745.     case ENOSR: return "out of stream resources";
  746. #endif
  747. #if defined(ENOSTR) && (!defined(ENOTTY) || (ENOTTY != ENOSTR))
  748.     case ENOSTR: return "not a stream device";
  749. #endif
  750. #ifdef ENOSYM
  751.     case ENOSYM: return "unresolved symbol name";
  752. #endif
  753. #ifdef ENOSYS
  754.     case ENOSYS: return "function not implemented";
  755. #endif
  756. #ifdef ENOTBLK
  757.     case ENOTBLK: return "block device required";
  758. #endif
  759. #ifdef ENOTCONN
  760.     case ENOTCONN: return "socket is not connected";
  761. #endif
  762. #ifdef ENOTDIR
  763.     case ENOTDIR: return "not a directory";
  764. #endif
  765. #if defined(ENOTEMPTY) && (!defined(EEXIST) || (ENOTEMPTY != EEXIST))
  766.     case ENOTEMPTY: return "directory not empty";
  767. #endif
  768. #ifdef ENOTNAM
  769.     case ENOTNAM: return "not a name file";
  770. #endif
  771. #ifdef ENOTSOCK
  772.     case ENOTSOCK: return "socket operation on non-socket";
  773. #endif
  774. #ifdef ENOTSUP
  775.     case ENOTSUP: return "operation not supported";
  776. #endif
  777. #ifdef ENOTTY
  778.     case ENOTTY: return "inappropriate device for ioctl";
  779. #endif
  780. #ifdef ENOTUNIQ
  781.     case ENOTUNIQ: return "name not unique on network";
  782. #endif
  783. #ifdef ENXIO
  784.     case ENXIO: return "no such device or address";
  785. #endif
  786. #ifdef EOPNOTSUPP
  787.     case EOPNOTSUPP: return "operation not supported on socket";
  788. #endif
  789. #ifdef EPERM
  790.     case EPERM: return "not owner";
  791. #endif
  792. #if defined(EPFNOSUPPORT) && (!defined(ENOLCK) || (ENOLCK != EPFNOSUPPORT))
  793.     case EPFNOSUPPORT: return "protocol family not supported";
  794. #endif
  795. #ifdef EPIPE
  796.     case EPIPE: return "broken pipe";
  797. #endif
  798. #ifdef EPROCLIM
  799.     case EPROCLIM: return "too many processes";
  800. #endif
  801. #ifdef EPROCUNAVAIL
  802.     case EPROCUNAVAIL: return "bad procedure for program";
  803. #endif
  804. #ifdef EPROGMISMATCH
  805.     case EPROGMISMATCH: return "program version wrong";
  806. #endif
  807. #ifdef EPROGUNAVAIL
  808.     case EPROGUNAVAIL: return "RPC program not available";
  809. #endif
  810. #ifdef EPROTO
  811.     case EPROTO: return "protocol error";
  812. #endif
  813. #ifdef EPROTONOSUPPORT
  814.     case EPROTONOSUPPORT: return "protocol not suppored";
  815. #endif
  816. #ifdef EPROTOTYPE
  817.     case EPROTOTYPE: return "protocol wrong type for socket";
  818. #endif
  819. #ifdef ERANGE
  820.     case ERANGE: return "math result unrepresentable";
  821. #endif
  822. #if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED))
  823.     case EREFUSED: return "EREFUSED";
  824. #endif
  825. #ifdef EREMCHG
  826.     case EREMCHG: return "remote address changed";
  827. #endif
  828. #ifdef EREMDEV
  829.     case EREMDEV: return "remote device";
  830. #endif
  831. #ifdef EREMOTE
  832.     case EREMOTE: return "pathname hit remote file system";
  833. #endif
  834. #ifdef EREMOTEIO
  835.     case EREMOTEIO: return "remote i/o error";
  836. #endif
  837. #ifdef EREMOTERELEASE
  838.     case EREMOTERELEASE: return "EREMOTERELEASE";
  839. #endif
  840. #ifdef EROFS
  841.     case EROFS: return "read-only file system";
  842. #endif
  843. #ifdef ERPCMISMATCH
  844.     case ERPCMISMATCH: return "RPC version is wrong";
  845. #endif
  846. #ifdef ERREMOTE
  847.     case ERREMOTE: return "object is remote";
  848. #endif
  849. #ifdef ESHUTDOWN
  850.     case ESHUTDOWN: return "can't send afer socket shutdown";
  851. #endif
  852. #ifdef ESOCKTNOSUPPORT
  853.     case ESOCKTNOSUPPORT: return "socket type not supported";
  854. #endif
  855. #ifdef ESPIPE
  856.     case ESPIPE: return "invalid seek";
  857. #endif
  858. #ifdef ESRCH
  859.     case ESRCH: return "no such process";
  860. #endif
  861. #ifdef ESRMNT
  862.     case ESRMNT: return "srmount error";
  863. #endif
  864. #ifdef ESTALE
  865.     case ESTALE: return "stale remote file handle";
  866. #endif
  867. #ifdef ESUCCESS
  868.     case ESUCCESS: return "Error 0";
  869. #endif
  870. #if defined(ETIME) && (!defined(ELOOP) || (ETIME != ELOOP))
  871.     case ETIME: return "timer expired";
  872. #endif
  873. #if defined(ETIMEDOUT) && (!defined(ENOSTR) || (ETIMEDOUT != ENOSTR))
  874.     case ETIMEDOUT: return "connection timed out";
  875. #endif
  876. #ifdef ETOOMANYREFS
  877.     case ETOOMANYREFS: return "too many references: can't splice";
  878. #endif
  879. #ifdef ETXTBSY
  880.     case ETXTBSY: return "text file or pseudo-device busy";
  881. #endif
  882. #ifdef EUCLEAN
  883.     case EUCLEAN: return "structure needs cleaning";
  884. #endif
  885. #ifdef EUNATCH
  886.     case EUNATCH: return "protocol driver not attached";
  887. #endif
  888. #ifdef EUSERS
  889.     case EUSERS: return "too many users";
  890. #endif
  891. #ifdef EVERSION
  892.     case EVERSION: return "version mismatch";
  893. #endif
  894. #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
  895.     case EWOULDBLOCK: return "operation would block";
  896. #endif
  897. #ifdef EXDEV
  898.     case EXDEV: return "cross-domain link";
  899. #endif
  900. #ifdef EXFULL
  901.     case EXFULL: return "message tables full";
  902. #endif
  903.     default:
  904. #ifdef NO_STRERROR
  905.         return "unknown POSIX error";
  906. #else
  907.         return strerror(errno);
  908. #endif
  909.     }
  910. }
  911.  
  912. /*
  913.  *----------------------------------------------------------------------
  914.  *
  915.  * Tcl_SignalId --
  916.  *
  917.  *    Return a textual identifier for a signal number.
  918.  *
  919.  * Results:
  920.  *    This procedure returns a machine-readable textual identifier
  921.  *    that corresponds to sig.  The identifier is the same as the
  922.  *    #define name in signal.h.
  923.  *
  924.  * Side effects:
  925.  *    None.
  926.  *
  927.  *----------------------------------------------------------------------
  928.  */
  929.  
  930. char *
  931. Tcl_SignalId(sig)
  932.     int sig;            /* Number of signal. */
  933. {
  934.     switch (sig) {
  935. #ifdef SIGABRT
  936.     case SIGABRT: return "SIGABRT";
  937. #endif
  938. #ifdef SIGALRM
  939.     case SIGALRM: return "SIGALRM";
  940. #endif
  941. #ifdef SIGBUS
  942.     case SIGBUS: return "SIGBUS";
  943. #endif
  944. #ifdef SIGCHLD
  945.     case SIGCHLD: return "SIGCHLD";
  946. #endif
  947. #if defined(SIGCLD) && (!defined(SIGCHLD) || (SIGCLD != SIGCHLD))
  948.     case SIGCLD: return "SIGCLD";
  949. #endif
  950. #ifdef SIGCONT
  951.     case SIGCONT: return "SIGCONT";
  952. #endif
  953. #if defined(SIGEMT) && (!defined(SIGXCPU) || (SIGEMT != SIGXCPU))
  954.     case SIGEMT: return "SIGEMT";
  955. #endif
  956. #ifdef SIGFPE
  957.     case SIGFPE: return "SIGFPE";
  958. #endif
  959. #ifdef SIGHUP
  960.     case SIGHUP: return "SIGHUP";
  961. #endif
  962. #ifdef SIGILL
  963.     case SIGILL: return "SIGILL";
  964. #endif
  965. #ifdef SIGINT
  966.     case SIGINT: return "SIGINT";
  967. #endif
  968. #ifdef SIGIO
  969.     case SIGIO: return "SIGIO";
  970. #endif
  971. #if defined(SIGIOT) && (!defined(SIGABRT) || (SIGIOT != SIGABRT))
  972.     case SIGIOT: return "SIGIOT";
  973. #endif
  974. #ifdef SIGKILL
  975.     case SIGKILL: return "SIGKILL";
  976. #endif
  977. #if defined(SIGLOST) && (!defined(SIGIOT) || (SIGLOST != SIGIOT)) && (!defined(SIGURG) || (SIGLOST != SIGURG)) && (!defined(SIGPROF) || (SIGLOST != SIGPROF))
  978.     case SIGLOST: return "SIGLOST";
  979. #endif
  980. #ifdef SIGPIPE
  981.     case SIGPIPE: return "SIGPIPE";
  982. #endif
  983. #if defined(SIGPOLL) && (!defined(SIGIO) || (SIGPOLL != SIGIO))
  984.     case SIGPOLL: return "SIGPOLL";
  985. #endif
  986. #ifdef SIGPROF
  987.     case SIGPROF: return "SIGPROF";
  988. #endif
  989. #if defined(SIGPWR) && (!defined(SIGXFSZ) || (SIGPWR != SIGXFSZ))
  990.     case SIGPWR: return "SIGPWR";
  991. #endif
  992. #ifdef SIGQUIT
  993.     case SIGQUIT: return "SIGQUIT";
  994. #endif
  995. #ifdef SIGSEGV
  996.     case SIGSEGV: return "SIGSEGV";
  997. #endif
  998. #ifdef SIGSTOP
  999.     case SIGSTOP: return "SIGSTOP";
  1000. #endif
  1001. #ifdef SIGSYS
  1002.     case SIGSYS: return "SIGSYS";
  1003. #endif
  1004. #ifdef SIGTERM
  1005.     case SIGTERM: return "SIGTERM";
  1006. #endif
  1007. #ifdef SIGTRAP
  1008.     case SIGTRAP: return "SIGTRAP";
  1009. #endif
  1010. #ifdef SIGTSTP
  1011.     case SIGTSTP: return "SIGTSTP";
  1012. #endif
  1013. #ifdef SIGTTIN
  1014.     case SIGTTIN: return "SIGTTIN";
  1015. #endif
  1016. #ifdef SIGTTOU
  1017.     case SIGTTOU: return "SIGTTOU";
  1018. #endif
  1019. #if defined(SIGURG) && (!defined(SIGIO) || (SIGURG != SIGIO))
  1020.     case SIGURG: return "SIGURG";
  1021. #endif
  1022. #if defined(SIGUSR1) && (!defined(SIGIO) || (SIGUSR1 != SIGIO))
  1023.     case SIGUSR1: return "SIGUSR1";
  1024. #endif
  1025. #if defined(SIGUSR2) && (!defined(SIGURG) || (SIGUSR2 != SIGURG))
  1026.     case SIGUSR2: return "SIGUSR2";
  1027. #endif
  1028. #ifdef SIGVTALRM
  1029.     case SIGVTALRM: return "SIGVTALRM";
  1030. #endif
  1031. #ifdef SIGWINCH
  1032.     case SIGWINCH: return "SIGWINCH";
  1033. #endif
  1034. #ifdef SIGXCPU
  1035.     case SIGXCPU: return "SIGXCPU";
  1036. #endif
  1037. #ifdef SIGXFSZ
  1038.     case SIGXFSZ: return "SIGXFSZ";
  1039. #endif
  1040.     }
  1041.     return "unknown signal";
  1042. }
  1043.  
  1044. /*
  1045.  *----------------------------------------------------------------------
  1046.  *
  1047.  * Tcl_SignalMsg --
  1048.  *
  1049.  *    Return a human-readable message describing a signal.
  1050.  *
  1051.  * Results:
  1052.  *    This procedure returns a string describing sig that should
  1053.  *    make sense to a human.  It may not be easy for a machine
  1054.  *    to parse.
  1055.  *
  1056.  * Side effects:
  1057.  *    None.
  1058.  *
  1059.  *----------------------------------------------------------------------
  1060.  */
  1061.  
  1062. char *
  1063. Tcl_SignalMsg(sig)
  1064.     int sig;            /* Number of signal. */
  1065. {
  1066.     switch (sig) {
  1067. #ifdef SIGABRT
  1068.     case SIGABRT: return "SIGABRT";
  1069. #endif
  1070. #ifdef SIGALRM
  1071.     case SIGALRM: return "alarm clock";
  1072. #endif
  1073. #ifdef SIGBUS
  1074.     case SIGBUS: return "bus error";
  1075. #endif
  1076. #ifdef SIGCHLD
  1077.     case SIGCHLD: return "child status changed";
  1078. #endif
  1079. #if defined(SIGCLD) && (!defined(SIGCHLD) || (SIGCLD != SIGCHLD))
  1080.     case SIGCLD: return "child status changed";
  1081. #endif
  1082. #ifdef SIGCONT
  1083.     case SIGCONT: return "continue after stop";
  1084. #endif
  1085. #if defined(SIGEMT) && (!defined(SIGXCPU) || (SIGEMT != SIGXCPU))
  1086.     case SIGEMT: return "EMT instruction";
  1087. #endif
  1088. #ifdef SIGFPE
  1089.     case SIGFPE: return "floating-point exception";
  1090. #endif
  1091. #ifdef SIGHUP
  1092.     case SIGHUP: return "hangup";
  1093. #endif
  1094. #ifdef SIGILL
  1095.     case SIGILL: return "illegal instruction";
  1096. #endif
  1097. #ifdef SIGINT
  1098.     case SIGINT: return "interrupt";
  1099. #endif
  1100. #ifdef SIGIO
  1101.     case SIGIO: return "input/output possible on file";
  1102. #endif
  1103. #if defined(SIGIOT) && (!defined(SIGABRT) || (SIGABRT != SIGIOT))
  1104.     case SIGIOT: return "IOT instruction";
  1105. #endif
  1106. #ifdef SIGKILL
  1107.     case SIGKILL: return "kill signal";
  1108. #endif
  1109. #if defined(SIGLOST) && (!defined(SIGIOT) || (SIGLOST != SIGIOT)) && (!defined(SIGURG) || (SIGLOST != SIGURG))
  1110.     case SIGLOST: return "resource lost";
  1111. #endif
  1112. #ifdef SIGPIPE
  1113.     case SIGPIPE: return "write on pipe with no readers";
  1114. #endif
  1115. #if defined(SIGPOLL) && (!defined(SIGIO) || (SIGPOLL != SIGIO))
  1116.     case SIGPOLL: return "input/output possible on file";
  1117. #endif
  1118. #ifdef SIGPROF
  1119.     case SIGPROF: return "profiling alarm";
  1120. #endif
  1121. #if defined(SIGPWR) && (!defined(SIGXFSZ) || (SIGPWR != SIGXFSZ))
  1122.     case SIGPWR: return "power-fail restart";
  1123. #endif
  1124. #ifdef SIGQUIT
  1125.     case SIGQUIT: return "quit signal";
  1126. #endif
  1127. #ifdef SIGSEGV
  1128.     case SIGSEGV: return "segmentation violation";
  1129. #endif
  1130. #ifdef SIGSTOP
  1131.     case SIGSTOP: return "stop";
  1132. #endif
  1133. #ifdef SIGSYS
  1134.     case SIGSYS: return "bad argument to system call";
  1135. #endif
  1136. #ifdef SIGTERM
  1137.     case SIGTERM: return "software termination signal";
  1138. #endif
  1139. #ifdef SIGTRAP
  1140.     case SIGTRAP: return "trace trap";
  1141. #endif
  1142. #ifdef SIGTSTP
  1143.     case SIGTSTP: return "stop signal from tty";
  1144. #endif
  1145. #ifdef SIGTTIN
  1146.     case SIGTTIN: return "background tty read";
  1147. #endif
  1148. #ifdef SIGTTOU
  1149.     case SIGTTOU: return "background tty write";
  1150. #endif
  1151. #if defined(SIGURG) && (!defined(SIGIO) || (SIGURG != SIGIO))
  1152.     case SIGURG: return "urgent I/O condition";
  1153. #endif
  1154. #if defined(SIGUSR1) && (!defined(SIGIO) || (SIGUSR1 != SIGIO))
  1155.     case SIGUSR1: return "user-defined signal 1";
  1156. #endif
  1157. #if defined(SIGUSR2) && (!defined(SIGURG) || (SIGUSR2 != SIGURG))
  1158.     case SIGUSR2: return "user-defined signal 2";
  1159. #endif
  1160. #ifdef SIGVTALRM
  1161.     case SIGVTALRM: return "virtual time alarm";
  1162. #endif
  1163. #ifdef SIGWINCH
  1164.     case SIGWINCH: return "window changed";
  1165. #endif
  1166. #ifdef SIGXCPU
  1167.     case SIGXCPU: return "exceeded CPU time limit";
  1168. #endif
  1169. #ifdef SIGXFSZ
  1170.     case SIGXFSZ: return "exceeded file size limit";
  1171. #endif
  1172.     }
  1173.     return "unknown signal";
  1174. }
  1175.