Commit | Line | Data |
2304df62 |
1 | ?RCS: $Id: d_strerror.U,v 3.0.1.1 1994/01/24 14:08:56 ram Exp $ |
2 | ?RCS: |
3 | ?RCS: Copyright (c) 1991-1993, Raphael Manfredi |
4 | ?RCS: |
5 | ?RCS: You may redistribute only under the terms of the Artistic Licence, |
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 |
8 | ?RCS: that same Artistic Licence; a copy of which may be found at the root |
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.1 1994/01/24 14:08:56 ram |
13 | ?RCS: patch16: protected code looking for sys_errnolist[] with @if |
14 | ?RCS: patch16: added default value for d_sysernlst |
15 | ?RCS: |
16 | ?RCS: Revision 3.0 1993/08/18 12:07:35 ram |
17 | ?RCS: Baseline for dist 3.0 netwide release. |
18 | ?RCS: |
19 | ?MAKE:d_strerror d_syserrlst d_sysernlst d_strerrm: contains Csym Findhdr |
20 | ?MAKE: -pick add $@ %< |
21 | ?S:d_strerror: |
22 | ?S: This variable conditionally defines HAS_STRERROR if strerror() is |
23 | ?S: available to translate error numbers to strings. |
24 | ?S:. |
25 | ?S:d_syserrlst: |
26 | ?S: This variable conditionally defines HAS_SYS_ERRLIST if sys_errlist[] is |
27 | ?S: available to translate error numbers to strings. |
28 | ?S:. |
29 | ?S:d_sysernlst: |
30 | ?S: This variable conditionally defines HAS_SYS_ERRNOLIST if sys_errnolist[] |
31 | ?S: is available to translate error numbers to the symbolic name. |
32 | ?S:. |
33 | ?S:d_strerrm: |
34 | ?S: This variable conditionally defines strerrr as a macro if the |
35 | ?S: sys_errlist[] array is defined. |
36 | ?S:. |
37 | ?C:HAS_STRERROR (STRERROR): |
38 | ?C: This symbol, if defined, indicates that the strerror routine is |
39 | ?C: available to translate error numbers to strings. See the writeup |
40 | ?C: of Strerror() in this file before you try to define your own. |
41 | ?C:. |
42 | ?C:HAS_SYS_ERRLIST (SYSERRLIST): |
43 | ?C: This symbol, if defined, indicates that the sys_errlist array is |
44 | ?C: available to translate error numbers to strings. The extern int |
45 | ?C: sys_nerr gives the size of that table. |
46 | ?C:. |
47 | ?C:HAS_SYS_ERRNOLIST (SYSERRNOLIST): |
48 | ?C: This symbol, if defined, indicates that the sys_errnolist array is |
49 | ?C: available to translate an errno code into its symbolic name (e.g. |
50 | ?C: ENOENT). The extern int sys_nerrno gives the size of that table. |
51 | ?C:. |
52 | ?C:Strerror: |
53 | ?C: This preprocessor symbol is defined as a macro if strerror() is |
54 | ?C: not available to translate error numbers to strings but sys_errlist[] |
55 | ?C: array is there. |
56 | ?C:. |
57 | ?H:#$d_strerror HAS_STRERROR /**/ |
58 | ?H:#$d_syserrlst HAS_SYS_ERRLIST /**/ |
59 | ?H:#$d_sysernlst HAS_SYS_ERRNOLIST /**/ |
60 | ?H:?%<:#ifdef HAS_STRERROR |
61 | ?H:?%<:# define Strerror strerror |
62 | ?H:?%<:#else |
63 | ?H:#$d_strerrm Strerror(e) ((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e]) /**/ |
64 | ?H:?%<:#endif |
65 | ?H:. |
66 | ?D:d_sysernlst='' |
67 | ?T:xxx val |
68 | : see if strerror and/or sys_errlist[] exist |
69 | echo " " |
70 | if set strerror val -f d_strerror; eval $csym; $val; then |
71 | echo 'strerror() found.' >&4 |
72 | d_strerror="$define" |
73 | d_strerrm="$undef" |
74 | if set sys_errlist val -a d_syserrlst; eval $csym; $val; then |
75 | echo "(You also have sys_errlist[], so we could roll our own strerror.)" |
76 | d_syserrlst="$define" |
77 | else |
78 | echo "(Since you don't have sys_errlist[], sterror() is welcome.)" |
79 | d_syserrlst="$undef" |
80 | fi |
81 | elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \ |
82 | $contains '#[ ]*define.*strerror' "$xxx" >/dev/null 2>&1; then |
83 | echo 'strerror() found in string header.' >&4 |
84 | d_strerror="$define" |
85 | d_strerrm="$undef" |
86 | if set sys_errlist val -a d_syserrlst; eval $csym; $val; then |
87 | echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)" |
88 | d_syserrlst="$define" |
89 | else |
90 | echo "(You don't appear to have any sys_errlist[], how can this be?)" |
91 | d_syserrlst="$undef" |
92 | fi |
93 | elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then |
94 | echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4 |
95 | d_strerror="$undef" |
96 | d_syserrlst="$define" |
97 | d_strerrm="$define" |
98 | else |
99 | echo 'strerror() and sys_errlist[] NOT found.' >&4 |
100 | d_strerror="$undef" |
101 | d_syserrlst="$undef" |
102 | d_strerrm="$undef" |
103 | fi |
104 | @if d_sysernlst || HAS_SYS_ERRNOLIST |
105 | if set sys_errnolist val -a d_sysernlst; eval $csym; $val; then |
106 | echo "(Symbolic error codes can be fetched via the sys_errnolist[] array.)" |
107 | d_sysernlst="$define" |
108 | else |
109 | echo "(However, I can't extract the symbolic error code out of errno.)" |
110 | d_sysernlst="$undef" |
111 | fi |
112 | @end |
113 | |