From 2aef693010b252e8cff0ce46a6ebf15b74c82219 Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Sun, 14 Mar 1999 17:13:19 +0000 Subject: Clean import of TCP-wrappers by Wietse Venema. Rest of build to follow. --- contrib/tcp_wrappers/percent_m.c | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 contrib/tcp_wrappers/percent_m.c (limited to 'contrib/tcp_wrappers/percent_m.c') diff --git a/contrib/tcp_wrappers/percent_m.c b/contrib/tcp_wrappers/percent_m.c new file mode 100644 index 000000000000..bb11b22dd81f --- /dev/null +++ b/contrib/tcp_wrappers/percent_m.c @@ -0,0 +1,43 @@ + /* + * Replace %m by system error message. + * + * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. + */ + +#ifndef lint +static char sccsid[] = "@(#) percent_m.c 1.1 94/12/28 17:42:37"; +#endif + +#include +#include +#include + +extern int errno; +#ifndef SYS_ERRLIST_DEFINED +extern char *sys_errlist[]; +extern int sys_nerr; +#endif + +#include "mystdarg.h" + +char *percent_m(obuf, ibuf) +char *obuf; +char *ibuf; +{ + char *bp = obuf; + char *cp = ibuf; + + while (*bp = *cp) + if (*cp == '%' && cp[1] == 'm') { + if (errno < sys_nerr && errno > 0) { + strcpy(bp, sys_errlist[errno]); + } else { + sprintf(bp, "Unknown error %d", errno); + } + bp += strlen(bp); + cp += 2; + } else { + bp++, cp++; + } + return (obuf); +} -- cgit v1.2.3