kernel - Change bundirty() location in I/O sequence
[dragonfly.git] / contrib / tcp_wrappers / percent_m.c
blob2a0a3635628d801366b83d98485a0046b3eeea22
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 <string.h>
11 #ifndef SYS_ERRLIST_DEFINED
12 extern char *sys_errlist[];
13 extern int sys_nerr;
14 #endif
16 #include "mystdarg.h"
18 char *percent_m(obuf, ibuf)
19 char *obuf;
20 char *ibuf;
22 char *bp = obuf;
23 char *cp = ibuf;
25 while ((*bp = *cp) != 0)
26 if (*cp == '%' && cp[1] == 'm') {
27 if (errno < sys_nerr && errno > 0) {
28 strcpy(bp, sys_errlist[errno]);
29 } else {
30 sprintf(bp, "Unknown error %d", errno);
32 bp += strlen(bp);
33 cp += 2;
34 } else {
35 bp++, cp++;
37 return (obuf);