hier.7: Document some recently added directories.
[dragonfly.git] / contrib / tcp_wrappers / percent_m.c
blob25f444706bda1c76b4362a682f46ac35eb417e05
1 /*
2 * Replace %m by system error message.
3 *
4 * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
5 */
7 #include <stdio.h>
8 #include <errno.h>
9 #include <stdarg.h>
10 #include <string.h>
12 #ifndef SYS_ERRLIST_DEFINED
13 extern char *sys_errlist[];
14 extern int sys_nerr;
15 #endif
17 char *percent_m(obuf, ibuf)
18 char *obuf;
19 char *ibuf;
21 char *bp = obuf;
22 char *cp = ibuf;
24 while ((*bp = *cp) != 0)
25 if (*cp == '%' && cp[1] == 'm') {
26 if (errno < sys_nerr && errno > 0) {
27 strcpy(bp, sys_errlist[errno]);
28 } else {
29 sprintf(bp, "Unknown error %d", errno);
31 bp += strlen(bp);
32 cp += 2;
33 } else {
34 bp++, cp++;
36 return (obuf);