Add strerror_ss_r to be used by syslog_ss
This commit is contained in:
parent
3a46f472fa
commit
2a1a34d545
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.23 2013/08/19 13:03:12 joerg Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.24 2017/01/12 00:35:38 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
|
||||
@ -72,4 +72,6 @@ void _malloc_postfork(void);
|
||||
|
||||
int _sys_setcontext(const ucontext_t *);
|
||||
|
||||
int strerror_r_ss(int, char *, size_t);
|
||||
|
||||
__END_DECLS
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: namespace.h,v 1.182 2016/09/24 21:31:25 christos Exp $ */
|
||||
/* $NetBSD: namespace.h,v 1.183 2017/01/12 00:35:38 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
|
||||
@ -60,6 +60,7 @@
|
||||
#define sbrk _sbrk
|
||||
#define strerror_l _strerror_l
|
||||
#define strerror_r _strerror_r
|
||||
#define strerror_r_ss _strerror_r_ss
|
||||
#define strlcat _strlcat
|
||||
#define strlcpy _strlcpy
|
||||
#define strtod_l _strtod_l
|
||||
|
@ -1,5 +1,5 @@
|
||||
# from: @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
|
||||
# $NetBSD: Makefile.inc,v 1.82 2016/10/15 14:22:00 kamil Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.83 2017/01/12 00:35:38 christos Exp $
|
||||
|
||||
# string sources
|
||||
.PATH: ${ARCHDIR}/string ${.CURDIR}/string
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
SRCS+= bm.c stpcpy.c stpncpy.c \
|
||||
strcasecmp.c strncasecmp.c strcasestr.c strcoll.c strdup.c \
|
||||
strerror.c strlcat.c strlcpy.c strnlen.c \
|
||||
strerror.c strerror_ss.c strlcat.c strlcpy.c strnlen.c \
|
||||
strmode.c strsignal.c strtok.c \
|
||||
strtok_r.c strxfrm.c __strsignal.c strerror_r.c strndup.c \
|
||||
stresep.c memrchr.c
|
||||
|
65
lib/libc/string/strerror_ss.c
Normal file
65
lib/libc/string/strerror_ss.c
Normal file
@ -0,0 +1,65 @@
|
||||
/* $NetBSD: strerror_ss.c,v 1.1 2017/01/12 00:35:38 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2017 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: strerror_ss.c,v 1.1 2017/01/12 00:35:38 christos Exp $");
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(strerror_r_ss,_strerror_r_ss)
|
||||
#endif
|
||||
|
||||
int
|
||||
strerror_r_ss(int num, char *buf, size_t len)
|
||||
{
|
||||
if (num >= 0 || num < sys_nerr)
|
||||
strlcpy(buf, sys_errlist[num], len);
|
||||
else
|
||||
snprintf_ss(buf, len, "Unknown error %d", num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef notyet
|
||||
__aconst char *
|
||||
strerror_ss(int num)
|
||||
{
|
||||
static char buf[64];
|
||||
|
||||
strerror_r_ss(num, buf, sizeof(buf));
|
||||
return buf;
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user