1998-05-09 21:22:07 +04:00
|
|
|
/* $NetBSD: percent_m.c,v 1.3 1998/05/09 17:22:09 kleink Exp $ */
|
1997-10-12 01:41:34 +04:00
|
|
|
|
1997-01-11 05:06:52 +03:00
|
|
|
/*
|
|
|
|
* Replace %m by system error message.
|
|
|
|
*
|
|
|
|
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
|
|
|
*/
|
|
|
|
|
1997-10-12 01:41:34 +04:00
|
|
|
#include <sys/cdefs.h>
|
1997-01-11 05:06:52 +03:00
|
|
|
#ifndef lint
|
1997-10-12 01:41:34 +04:00
|
|
|
#if 0
|
1997-01-11 05:06:52 +03:00
|
|
|
static char sccsid[] = "@(#) percent_m.c 1.1 94/12/28 17:42:37";
|
1997-10-12 01:41:34 +04:00
|
|
|
#else
|
1998-05-09 21:22:07 +04:00
|
|
|
__RCSID("$NetBSD: percent_m.c,v 1.3 1998/05/09 17:22:09 kleink Exp $");
|
1997-10-12 01:41:34 +04:00
|
|
|
#endif
|
1997-01-11 05:06:52 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
extern int errno;
|
|
|
|
#ifndef SYS_ERRLIST_DEFINED
|
|
|
|
extern char *sys_errlist[];
|
|
|
|
extern int sys_nerr;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "mystdarg.h"
|
1997-10-12 01:41:34 +04:00
|
|
|
#include "percent_m.h"
|
1997-01-11 05:06:52 +03:00
|
|
|
|
|
|
|
char *percent_m(obuf, ibuf)
|
|
|
|
char *obuf;
|
1997-10-12 01:41:34 +04:00
|
|
|
const char *ibuf;
|
1997-01-11 05:06:52 +03:00
|
|
|
{
|
|
|
|
char *bp = obuf;
|
1997-10-12 01:41:34 +04:00
|
|
|
const char *cp = ibuf;
|
1997-01-11 05:06:52 +03:00
|
|
|
|
1997-10-12 01:41:34 +04:00
|
|
|
while ((*bp = *cp) != '\0')
|
1997-01-11 05:06:52 +03:00
|
|
|
if (*cp == '%' && cp[1] == 'm') {
|
1998-05-09 21:22:07 +04:00
|
|
|
strcpy(bp, strerror(errno));
|
1997-01-11 05:06:52 +03:00
|
|
|
bp += strlen(bp);
|
|
|
|
cp += 2;
|
|
|
|
} else {
|
|
|
|
bp++, cp++;
|
|
|
|
}
|
|
|
|
return (obuf);
|
|
|
|
}
|