1 ?RCS: $Id: d_strerror.U,v 3.0.1.3 1994/05/13 15:20:27 ram Exp $
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
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.
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
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)
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
22 ?RCS: Revision 3.0 1993/08/18 12:07:35 ram
23 ?RCS: Baseline for dist 3.0 netwide release.
25 ?MAKE:d_strerror d_syserrlst d_sysernlst d_strerrm: contains Csym Findhdr
26 ?MAKE: -pick add $@ %<
28 ?S: This variable conditionally defines HAS_STRERROR if strerror() is
29 ?S: available to translate error numbers to strings.
32 ?S: This variable conditionally defines HAS_SYS_ERRLIST if sys_errlist[] is
33 ?S: available to translate error numbers to strings.
36 ?S: This variable conditionally defines HAS_SYS_ERRNOLIST if sys_errnolist[]
37 ?S: is available to translate error numbers to the symbolic name.
40 ?S: This variable holds what Strerrr is defined as to translate an error
41 ?S: code condition into an error message string. It could be 'strerror'
42 ?S: or a more complex macro emulating strrror with sys_errlist[], or the
43 ?S: "unknown" string when both strerror and sys_errlist are missing.
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.
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.
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.
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[]
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
72 : see if strerror and/or sys_errlist[] exist
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,
77 ?X: because many symbols that look unixish exist in the kernel.
78 ?X: The stress is on the 'look'.
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
84 d_strerrm='strerror(e)'
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.)"
89 echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
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
96 d_strerrm='strerror(e)'
97 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
98 echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
101 echo "(You don't appear to have any sys_errlist[], how can this be?)"
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
107 d_syserrlst="$define"
108 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
110 echo 'strerror() and sys_errlist[] NOT found.' >&4
113 d_strerrm='"unknown"'
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"
121 echo "(However, I can't extract the symbolic error code out of errno.)"