1 1.5 sevan /* $NetBSD: percent_m.c,v 1.5 2018/01/23 21:06:26 sevan Exp $ */ 2 1.2 christos 3 1.1 cjs /* 4 1.1 cjs * Replace %m by system error message. 5 1.1 cjs * 6 1.1 cjs * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. 7 1.1 cjs */ 8 1.1 cjs 9 1.2 christos #include <sys/cdefs.h> 10 1.1 cjs #ifndef lint 11 1.2 christos #if 0 12 1.1 cjs static char sccsid[] = "@(#) percent_m.c 1.1 94/12/28 17:42:37"; 13 1.2 christos #else 14 1.5 sevan __RCSID("$NetBSD: percent_m.c,v 1.5 2018/01/23 21:06:26 sevan Exp $"); 15 1.2 christos #endif 16 1.1 cjs #endif 17 1.1 cjs 18 1.1 cjs #include <stdio.h> 19 1.1 cjs #include <errno.h> 20 1.1 cjs #include <string.h> 21 1.1 cjs 22 1.1 cjs #ifndef SYS_ERRLIST_DEFINED 23 1.1 cjs extern char *sys_errlist[]; 24 1.1 cjs extern int sys_nerr; 25 1.1 cjs #endif 26 1.1 cjs 27 1.1 cjs #include "mystdarg.h" 28 1.2 christos #include "percent_m.h" 29 1.1 cjs 30 1.5 sevan char *percent_m(char *obuf, const char *ibuf) 31 1.1 cjs { 32 1.1 cjs char *bp = obuf; 33 1.2 christos const char *cp = ibuf; 34 1.1 cjs 35 1.2 christos while ((*bp = *cp) != '\0') 36 1.1 cjs if (*cp == '%' && cp[1] == 'm') { 37 1.3 kleink strcpy(bp, strerror(errno)); 38 1.1 cjs bp += strlen(bp); 39 1.1 cjs cp += 2; 40 1.1 cjs } else { 41 1.1 cjs bp++, cp++; 42 1.1 cjs } 43 1.1 cjs return (obuf); 44 1.1 cjs } 45