Commit | Line | Data |
---|---|---|
959f3c4c JH |
1 | ?RCS: $Id: d_strerror.U,v 3.0.1.3 1994/05/13 15:20:27 ram Exp $ |
2 | ?RCS: | |
3 | ?RCS: Copyright (c) 1991-1993, Raphael Manfredi | |
65a32477 MBT |
4 | ?RCS: |
5 | ?RCS: You may redistribute only under the terms of the Artistic License, | |
959f3c4c JH |
6 | ?RCS: as specified in the README file that comes with the distribution. |
7 | ?RCS: You may reuse parts of this distribution only within the terms of | |
65a32477 | 8 | ?RCS: that same Artistic License; a copy of which may be found at the root |
959f3c4c JH |
9 | ?RCS: of the source tree for dist 3.0. |
10 | ?RCS: | |
11 | ?RCS: $Log: d_strerror.U,v $ | |
12 | ?RCS: Revision 3.0.1.3 1994/05/13 15:20:27 ram | |
13 | ?RCS: patch27: now uses new macro support for cleaner Strerror def | |
14 | ?RCS: | |
15 | ?RCS: Revision 3.0.1.2 1994/05/06 14:58:26 ram | |
16 | ?RCS: patch23: renamed strerror into Strerror to protect name space (ADO) | |
17 | ?RCS: | |
18 | ?RCS: Revision 3.0.1.1 1994/01/24 14:08:56 ram | |
19 | ?RCS: patch16: protected code looking for sys_errnolist[] with @if | |
20 | ?RCS: patch16: added default value for d_sysernlst | |
21 | ?RCS: | |
22 | ?RCS: Revision 3.0 1993/08/18 12:07:35 ram | |
23 | ?RCS: Baseline for dist 3.0 netwide release. | |
24 | ?RCS: | |
25 | ?MAKE:d_strerror d_syserrlst d_sysernlst d_strerrm: contains Csym Findhdr | |
26 | ?MAKE: -pick add $@ %< | |
27 | ?S:d_strerror: | |
28 | ?S: This variable conditionally defines HAS_STRERROR if strerror() is | |
29 | ?S: available to translate error numbers to strings. | |
30 | ?S:. | |
31 | ?S:d_syserrlst: | |
32 | ?S: This variable conditionally defines HAS_SYS_ERRLIST if sys_errlist[] is | |
33 | ?S: available to translate error numbers to strings. | |
34 | ?S:. | |
35 | ?S:d_sysernlst: | |
36 | ?S: This variable conditionally defines HAS_SYS_ERRNOLIST if sys_errnolist[] | |
37 | ?S: is available to translate error numbers to the symbolic name. | |
38 | ?S:. | |
39 | ?S:d_strerrm: | |
65a32477 | 40 | ?S: This variable holds what Strerror is defined as to translate an error |
959f3c4c | 41 | ?S: code condition into an error message string. It could be 'strerror' |
65a32477 | 42 | ?S: or a more complex macro emulating strerror with sys_errlist[], or the |
959f3c4c JH |
43 | ?S: "unknown" string when both strerror and sys_errlist are missing. |
44 | ?S:. | |
45 | ?C:HAS_STRERROR (STRERROR): | |
46 | ?C: This symbol, if defined, indicates that the strerror routine is | |
47 | ?C: available to translate error numbers to strings. See the writeup | |
48 | ?C: of Strerror() in this file before you try to define your own. | |
49 | ?C:. | |
50 | ?C:HAS_SYS_ERRLIST (SYSERRLIST): | |
51 | ?C: This symbol, if defined, indicates that the sys_errlist array is | |
52 | ?C: available to translate error numbers to strings. The extern int | |
53 | ?C: sys_nerr gives the size of that table. | |
54 | ?C:. | |
55 | ?C:HAS_SYS_ERRNOLIST (SYSERRNOLIST): | |
56 | ?C: This symbol, if defined, indicates that the sys_errnolist array is | |
57 | ?C: available to translate an errno code into its symbolic name (e.g. | |
58 | ?C: ENOENT). The extern int sys_nerrno gives the size of that table. | |
59 | ?C:. | |
60 | ?C:Strerror: | |
61 | ?C: This preprocessor symbol is defined as a macro if strerror() is | |
62 | ?C: not available to translate error numbers to strings but sys_errlist[] | |
63 | ?C: array is there. | |
64 | ?C:. | |
65 | ?H:#$d_strerror HAS_STRERROR /**/ | |
66 | ?H:#$d_syserrlst HAS_SYS_ERRLIST /**/ | |
67 | ?H:#$d_sysernlst HAS_SYS_ERRNOLIST /**/ | |
68 | ?H:#define Strerror(e) $d_strerrm | |
69 | ?H:. | |
70 | ?D:d_sysernlst='' | |
71 | ?T:xxx val | |
72 | : see if strerror and/or sys_errlist[] exist | |
73 | echo " " | |
74 | ?X: MPE/iX needs this protection of hint values. | |
75 | ?X: Background: strerror exists in kernel but not in libc. | |
76 | ?X: Scanning the kernel for symbols would be a bad idea, however, | |
65a32477 | 77 | ?X: because many symbols that look unix-ish exist in the kernel. |
959f3c4c JH |
78 | ?X: The stress is on the 'look'. |
79 | ?X: --jhi 9/1998 | |
80 | if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then | |
81 | if set strerror val -f d_strerror; eval $csym; $val; then | |
82 | echo 'strerror() found.' >&4 | |
83 | d_strerror="$define" | |
84 | d_strerrm='strerror(e)' | |
65a32477 MBT |
85 | if set sys_errlist val -a d_syserrlst; eval $csym; $val; then |
86 | echo "(You also have sys_errlist[], so we could roll our own strerror.)" | |
959f3c4c JH |
87 | d_syserrlst="$define" |
88 | else | |
65a32477 | 89 | echo "(Since you don't have sys_errlist[], strerror() is welcome.)" |
959f3c4c JH |
90 | d_syserrlst="$undef" |
91 | fi | |
92 | elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \ | |
93 | $contains '#[ ]*define.*strerror' "$xxx" >/dev/null 2>&1; then | |
94 | echo 'strerror() found in string header.' >&4 | |
95 | d_strerror="$define" | |
96 | d_strerrm='strerror(e)' | |
65a32477 | 97 | if set sys_errlist val -a d_syserrlst; eval $csym; $val; then |
959f3c4c JH |
98 | echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)" |
99 | d_syserrlst="$define" | |
100 | else | |
101 | echo "(You don't appear to have any sys_errlist[], how can this be?)" | |
102 | d_syserrlst="$undef" | |
103 | fi | |
104 | elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then | |
105 | echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4 | |
106 | d_strerror="$undef" | |
107 | d_syserrlst="$define" | |
108 | d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])' | |
109 | else | |
110 | echo 'strerror() and sys_errlist[] NOT found.' >&4 | |
111 | d_strerror="$undef" | |
112 | d_syserrlst="$undef" | |
113 | d_strerrm='"unknown"' | |
114 | fi | |
115 | fi | |
116 | @if d_sysernlst || HAS_SYS_ERRNOLIST | |
117 | if set sys_errnolist val -a d_sysernlst; eval $csym; $val; then | |
118 | echo "(Symbolic error codes can be fetched via the sys_errnolist[] array.)" | |
119 | d_sysernlst="$define" | |
120 | else | |
121 | echo "(However, I can't extract the symbolic error code out of errno.)" | |
122 | d_sysernlst="$undef" | |
123 | fi | |
124 | @end | |
125 |