1 /*
2  * ----------------------------------------------------------------
3  * strsignal function
4  * ----------------------------------------------------------------
5  * Copyright (C) 1997-2009 Jonas Kvinge
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  * $Id: nlstrsignal.c 54 2009-03-18 18:23:29Z jonasio $
21  *
22  */
23 
24 #define NLSTRSIGNAL_C
25 
26 #define _GNU_SOURCE
27 
28 #define NEED_SYS_TYPES_H 1		/* Extra types */
29 #define NEED_SYS_PARAM_H 1		/* Some systems need this */
30 #define NEED_LIMITS_H 0			/* Kernel limits */
31 #define NEED_STDARG_H 0			/* va_list, etc */
32 #define NEED_ERRNO_H 0			/* errno */
33 #define NEED_CTYPE_H 0			/* isdigit(), etc */
34 #define NEED_NETINET_IN_H 0		/* in_addr, sockaddr_in, etc */
35 #define NEED_ARPA_INET_H 0		/* inet_ntoa(), inet_aton(), etc */
36 #define NEED_STDIO_H 1			/* Standard C UNIX functions */
37 #define NEED_STDLIB_H 1			/* malloc(), exit(), atoi(), etc */
38 #define NEED_TIME_H 0			/* time(), etc */
39 #define NEED_SYSCTL_H 0			/* sysctl(), etc */
40 #define NEED_SYS_STAT_H 0		/* chmod(), mkdir(), etc */
41 #define NEED_SYS_UIO_H 0		/* iovec, etc */
42 #define NEED_FCNTL_H 1			/* open(), creat(), fcntl(), etc */
43 #define NEED_SYS_IOCTL_H 0		/* ioctl(), etc */
44 #define NEED_SYS_FILIO_H 0		/* Solaris need this for ioctl(), etc */
45 #define NEED_UNISTD_H 1			/* Unix standard functions */
46 #define NEED_STRING_H 1			/* C string functions */
47 #define NEED_SIGNAL_H 0			/* Signal functions */
48 #define NEED_SYS_SOCKET_H 0		/* Socket functions */
49 #define NEED_NETDB_H 0			/* Network database functions */
50 #define NEED_ARPA_NAMESER_H 0		/* Nameserver definitions */
51 #define NEED_GETUSERPW_HEADERS 0 	/* Functions to retrive system passwords */
52 
53 #include "includes.h"
54 #include "nlstrsignal.h"
55 
56 #if HAVE_STRSIGNAL && !HAVE_DECL_STRSIGNAL
57   char *strsignal(int sig);
58 #endif
59 
60 /* VARIABLES - JONAS (22.06.2002) */
61 
62 char STRSIGNAL[STRSIGNALSIZE+1] = "";
63 
64 /* NLSTRSIGNAL FUNCTION - JONAS (22.06.2002) */
65 
nlstrsignal(unsigned short int Signal)66 const char *nlstrsignal(unsigned short int Signal) {
67 
68 #if HAVE_STRSIGNAL
69   return(strsignal(Signal));
70 #else
71   snprintf(STRSIGNAL, STRSIGNALSIZE, "Signal %d", Signal);
72   return(STRSIGNAL);
73 #endif
74 
75 }
76 
77