text: /* * [] = "@(#)strerror.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include <sys/cdefs.h> __FBSDID("$FreeBSD: src/lib/libc/string/strsignal.c,v 1.4 2002/03/21 18:44:54 obrien Exp $"); #include <stdio.h> #include <string.h> #include <signal.h> char * strsignal(num) int num; { #define UPREFIX "Unknown signal: " static char ebuf[40] = UPREFIX; /* 64-bit number + slop */ unsigned int signum; char *p, *t; char tmp[40]; signum = num; /* convert to unsigned */ if (signum < NSIG) return ((char *)sys_siglist[signum]); /* Do this by hand, so we don't link to stdio(3). */ t = tmp; if (num < 0) signum = -signum; do { *t++ = "0123456789"[signum % 10]; } while (signum /= 10); if (num < 0) *t++ = '-'; for (p = ebuf + sizeof(UPREFIX) - 1;;) { *p++ = *--t; if (t <= tmp) break; } *p = '\0'; return (ebuf); }