summaryrefslogtreecommitdiff
path: root/lib/libc/string
diff options
context:
space:
mode:
authorjtc <jtc@NetBSD.org>1994-08-02 05:01:20 +0000
committerjtc <jtc@NetBSD.org>1994-08-02 05:01:20 +0000
commit18ba4287c52706e4a896eb7ac1671b9ec4d30b37 (patch)
treeb2561a0af3f703ef6dfb7d79b9cc6af549ebd98f /lib/libc/string
parentda587a132a6f3da8140f166bb5d9409dcd8b5f39 (diff)
Add strsignal() function like on Solaris.
We might want to be able to retrieve a locale-specific signal description (from a message catalog) and we need a function call API for that feature.
Diffstat (limited to 'lib/libc/string')
-rw-r--r--lib/libc/string/Makefile.inc6
-rw-r--r--lib/libc/string/strsignal.360
-rw-r--r--lib/libc/string/strsignal.c55
3 files changed, 118 insertions, 3 deletions
diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc
index 69dd1271566..05eb461c6b7 100644
--- a/lib/libc/string/Makefile.inc
+++ b/lib/libc/string/Makefile.inc
@@ -1,11 +1,11 @@
# from: @(#)Makefile.inc 5.6 (Berkeley) 3/5/91
-# $Id: Makefile.inc,v 1.28 1994/07/06 04:07:53 mycroft Exp $
+# $Id: Makefile.inc,v 1.29 1994/08/02 05:01:20 jtc Exp $
# string sources
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/string ${.CURDIR}/string
SRCS+= bm.c memccpy.c strcasecmp.c strcoll.c strdup.c strerror.c \
- strftime.c strmode.c strtok.c strxfrm.c
+ strftime.c strmode.c strsignal.c strtok.c strxfrm.c
.if (${MACHINE_ARCH} == "m68k")
SRCS+= bcmp.S bcopy.S bzero.S ffs.S index.S memchr.c memcmp.S memset.S \
@@ -124,7 +124,7 @@ MAN3+= bm.0 bcmp.0 bcopy.0 bstring.0 bzero.0 ffs.0 index.0 memccpy.0 memchr.0 \
memcmp.0 memcpy.0 memmove.0 memset.0 rindex.0 strcasecmp.0 strcat.0 \
strchr.0 strcmp.0 strcoll.0 strcpy.0 strcspn.0 strerror.0 strftime.0 \
string.0 strlen.0 strmode.0 strdup.0 strpbrk.0 strrchr.0 strsep.0 \
- strspn.0 strstr.0 strtok.0 strxfrm.0 swab.0
+ strsignal.0 strspn.0 strstr.0 strtok.0 strxfrm.0 swab.0
MLINKS+=bm.3 bm_comp.3 bm.3 bm_exec.3 bm.3 bm_free.3
MLINKS+=strcasecmp.3 strncasecmp.3
diff --git a/lib/libc/string/strsignal.3 b/lib/libc/string/strsignal.3
new file mode 100644
index 00000000000..f9d828e1d30
--- /dev/null
+++ b/lib/libc/string/strsignal.3
@@ -0,0 +1,60 @@
+.\" Copyright (c) 1980, 1991 Regents of the University of California.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" the American National Standards Committee X3, on Information
+.\" Processing Systems.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" from: @(#)strerror.3 6.9 (Berkeley) 6/29/91
+.\" $Id: strsignal.3,v 1.1 1994/08/02 05:01:24 jtc Exp $
+.\"
+.Dd June 29, 1991
+.Dt STRSIGNAL 3
+.Os BSD 4
+.Sh NAME
+.Nm strsignal
+.Nd get signal description string
+.Sh SYNOPSIS
+.Fd #include <string.h>
+.Ft char *
+.Fn strsignal "int sig"
+.Sh DESCRIPTION
+The
+.Fn strsignal
+function returns a pointer to the language-dependent string describing
+a signal.
+.Pp
+The array pointed to is not to be modified by the program, but may be
+overwritten by subsequent calls to
+.Fn strsignal .
+.Sh SEE ALSO
+.Xr psignal 3 ,
+.Xr setlocale 3
diff --git a/lib/libc/string/strsignal.c b/lib/libc/string/strsignal.c
new file mode 100644
index 00000000000..3bc86be4ace
--- /dev/null
+++ b/lib/libc/string/strsignal.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+/*static char *sccsid = "from: @(#)strerror.c 5.6 (Berkeley) 5/4/91";*/
+static char *rcsid = "$Id: strsignal.c,v 1.1 1994/08/02 05:01:23 jtc Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <string.h>
+#include <signal.h>
+
+char *
+strsignal(sig)
+ int sig;
+{
+ unsigned int signum = sig;
+ static char buf[40];
+
+ if (signum < NSIG) {
+ return(sys_siglist[signum]);
+ }
+
+ sprintf(buf, "Unknown signal: %d", signum);
+ return buf;
+}