diff options
Diffstat (limited to 'mcon/U/d_strerror.U')
-rw-r--r-- | mcon/U/d_strerror.U | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/mcon/U/d_strerror.U b/mcon/U/d_strerror.U new file mode 100644 index 0000000..72124c8 --- /dev/null +++ b/mcon/U/d_strerror.U @@ -0,0 +1,117 @@ +?RCS: $Id: d_strerror.U,v 3.0.1.3 1994/05/13 15:20:27 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.3 1994/05/13 15:20:27 ram +?RCS: patch27: now uses new macro support for cleaner Strerror def +?RCS: +?RCS: Revision 3.0.1.2 1994/05/06 14:58:26 ram +?RCS: patch23: renamed strerror into Strerror to protect name space (ADO) +?RCS: +?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 holds what Strerrr is defined as to translate an error +?S: code condition into an error message string. It could be 'strerror' +?S: or a more complex macro emulating strrror with sys_errlist[], or the +?S: "unknown" string when both strerror and sys_errlist are missing. +?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:#define Strerror(e) $d_strerrm +?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='strerror(e)' + 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='strerror(e)' + 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='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])' +else + echo 'strerror() and sys_errlist[] NOT found.' >&4 + d_strerror="$undef" + d_syserrlst="$undef" + d_strerrm='"unknown"' +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 + |