mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-29 04:21:26 +01:00
14f102eacc
Although this code is in contrib/ there is no active upstream. Reviewed by: brooks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36047
41 lines
763 B
C
41 lines
763 B
C
/*
|
|
* Replace %m by system error message.
|
|
*
|
|
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
|
*/
|
|
|
|
#ifndef lint
|
|
static char sccsid[] = "@(#) percent_m.c 1.1 94/12/28 17:42:37";
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
|
|
#ifndef SYS_ERRLIST_DEFINED
|
|
extern char *sys_errlist[];
|
|
extern int sys_nerr;
|
|
#endif
|
|
|
|
#include "mystdarg.h"
|
|
|
|
char *percent_m(char *obuf, char *ibuf)
|
|
{
|
|
char *bp = obuf;
|
|
char *cp = ibuf;
|
|
|
|
while (*bp = *cp)
|
|
if (*cp == '%' && cp[1] == 'm') {
|
|
if (errno < sys_nerr && errno > 0) {
|
|
strcpy(bp, sys_errlist[errno]);
|
|
} else {
|
|
sprintf(bp, "Unknown error %d", errno);
|
|
}
|
|
bp += strlen(bp);
|
|
cp += 2;
|
|
} else {
|
|
bp++, cp++;
|
|
}
|
|
return (obuf);
|
|
}
|