?X: These units are based on the ones supplied with dist-3.0 ?X: patchlevel 22. They have been changed or enhanced to work with ?X: perl5alpha. I would appreciate hearing about any changes, ?X: corrections, or enhancements. ?X: Andy Dougherty doughera@lafcol.lafayette.edu ?X: Dept. of Physics ?X: Lafayette College ?X: Easton, PA 18042-1782 ?X: Sat Apr 2 15:45:17 EST 1994 ?RCS: $Id: d_strerror.U,v 3.0.1.1 1994/01/24 14:08:56 ram Exp $ ?RCS: ?RCS: Copyright (c) 1991-1993, Raphael Manfredi ?RCS: ?RCS: You may redistribute only under the terms of the Artistic Licence, ?RCS: as specified in the README file that comes with the distribution. ?RCS: You may reuse parts of this distribution only within the terms of ?RCS: that same Artistic Licence; a copy of which may be found at the root ?RCS: of the source tree for dist 3.0. ?RCS: ?RCS: $Log: d_strerror.U,v $ ?RCS: Revision 3.0.1.1 1994/01/24 14:08:56 ram ?RCS: patch16: protected code looking for sys_errnolist[] with @if ?RCS: patch16: added default value for d_sysernlst ?RCS: ?RCS: Revision 3.0 1993/08/18 12:07:35 ram ?RCS: Baseline for dist 3.0 netwide release. ?RCS: ?MAKE:d_strerror d_syserrlst d_sysernlst d_strerrm: contains Csym Findhdr ?MAKE: -pick add $@ %< ?S:d_strerror: ?S: This variable conditionally defines HAS_STRERROR if strerror() is ?S: available to translate error numbers to strings. ?S:. ?S:d_syserrlst: ?S: This variable conditionally defines HAS_SYS_ERRLIST if sys_errlist[] is ?S: available to translate error numbers to strings. ?S:. ?S:d_sysernlst: ?S: This variable conditionally defines HAS_SYS_ERRNOLIST if sys_errnolist[] ?S: is available to translate error numbers to the symbolic name. ?S:. ?S:d_strerrm: ?S: This variable conditionally defines strerrr as a macro if the ?S: sys_errlist[] array is defined. ?S:. ?C:HAS_STRERROR (STRERROR): ?C: This symbol, if defined, indicates that the strerror routine is ?C: available to translate error numbers to strings. See the writeup ?C: of Strerror() in this file before you try to define your own. ?C:. ?C:HAS_SYS_ERRLIST (SYSERRLIST): ?C: This symbol, if defined, indicates that the sys_errlist array is ?C: available to translate error numbers to strings. The extern int ?C: sys_nerr gives the size of that table. ?C:. ?C:HAS_SYS_ERRNOLIST (SYSERRNOLIST): ?C: This symbol, if defined, indicates that the sys_errnolist array is ?C: available to translate an errno code into its symbolic name (e.g. ?C: ENOENT). The extern int sys_nerrno gives the size of that table. ?C:. ?C:Strerror: ?C: This preprocessor symbol is defined as a macro if strerror() is ?C: not available to translate error numbers to strings but sys_errlist[] ?C: array is there. ?C:. ?H:#$d_strerror HAS_STRERROR /**/ ?H:#$d_syserrlst HAS_SYS_ERRLIST /**/ ?H:#$d_sysernlst HAS_SYS_ERRNOLIST /**/ ?H:?%<:#ifdef HAS_STRERROR ?H:?%<:# define Strerror strerror ?H:?%<:#else ?H:#$d_strerrm Strerror(e) ((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e]) /**/ ?H:?%<:#endif ?H:. ?D:d_sysernlst='' ?T:xxx val : see if strerror and/or sys_errlist[] exist echo " " if set strerror val -f d_strerror; eval $csym; $val; then echo 'strerror() found.' >&4 d_strerror="$define" d_strerrm="$undef" if set sys_errlist val -a d_syserrlst; eval $csym; $val; then echo "(You also have sys_errlist[], so we could roll our own strerror.)" d_syserrlst="$define" else echo "(Since you don't have sys_errlist[], sterror() is welcome.)" d_syserrlst="$undef" fi elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \ $contains '#[ ]*define.*strerror' "$xxx" >/dev/null 2>&1; then echo 'strerror() found in string header.' >&4 d_strerror="$define" d_strerrm="$undef" if set sys_errlist val -a d_syserrlst; eval $csym; $val; then echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)" d_syserrlst="$define" else echo "(You don't appear to have any sys_errlist[], how can this be?)" d_syserrlst="$undef" fi elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4 d_strerror="$undef" d_syserrlst="$define" d_strerrm="$define" else echo 'strerror() and sys_errlist[] NOT found.' >&4 d_strerror="$undef" d_syserrlst="$undef" d_strerrm="$undef" fi @if d_sysernlst || HAS_SYS_ERRNOLIST if set sys_errnolist val -a d_sysernlst; eval $csym; $val; then echo "(Symbolic error codes can be fetched via the sys_errnolist[] array.)" d_sysernlst="$define" else echo "(However, I can't extract the symbolic error code out of errno.)" d_sysernlst="$undef" fi @end