xref: /titanic_50/usr/src/lib/libwrap/percent_m.c (revision 538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2)
1 /*
2  * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5  /*
6   * Replace %m by system error message.
7   *
8   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
9   */
10 
11 #ifndef lint
12 static char sccsid[] = "@(#) percent_m.c 1.1 94/12/28 17:42:37";
13 #endif
14 
15 #include <stdio.h>
16 #include <errno.h>
17 #include <string.h>
18 
19 extern int errno;
20 
21 #include "mystdarg.h"
22 
23 char   *percent_m(obuf, ibuf)
24 char   *obuf;
25 char   *ibuf;
26 {
27     char   *bp = obuf;
28     char   *cp = ibuf;
29 
30     while (*bp = *cp)
31 	if (*cp == '%' && cp[1] == 'm') {
32 	    strcpy(bp, strerror(errno));
33 	    bp += strlen(bp);
34 	    cp += 2;
35 	} else {
36 	    bp++, cp++;
37 	}
38     return (obuf);
39 }
40