1 ?RCS: $Id: d_strerror.U 1 2006-08-24 12:32:52Z rmanfredi $
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, 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 4.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 if set strerror val -f d_strerror; eval $csym; $val; then
75 echo 'strerror() found.' >&4
77 d_strerrm='strerror(e)'
78 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
79 echo "(You also have sys_errlist[], so we could roll our own strerror.)"
82 echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
85 elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
86 $contains '#[ ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
87 echo 'strerror() found in string header.' >&4
89 d_strerrm='strerror(e)'
90 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
91 echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
94 echo "(You don't appear to have any sys_errlist[], how can this be?)"
97 elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
98 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
100 d_syserrlst="$define"
101 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
103 echo 'strerror() and sys_errlist[] NOT found.' >&4
106 d_strerrm='"unknown"'
108 @if d_sysernlst || HAS_SYS_ERRNOLIST
109 if set sys_errnolist val -a d_sysernlst; eval $csym; $val; then
110 echo "(Symbolic error codes can be fetched via the sys_errnolist[] array.)"
111 d_sysernlst="$define"
113 echo "(However, I can't extract the symbolic error code out of errno.)"