mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
Use strnstr implementation from FreeBSD if not provided by OS
This commit is contained in:
parent
2f3441b40a
commit
5f07fe8cbb
@ -991,7 +991,7 @@ AS_IF([test "$enable_tcp_fastopen" = "yes"],
|
||||
#
|
||||
# Check for some other useful functions that are not ever-present.
|
||||
#
|
||||
AC_CHECK_FUNCS([strlcpy strlcat])
|
||||
AC_CHECK_FUNCS([strlcpy strlcat strnstr])
|
||||
|
||||
#
|
||||
# Check for readline support
|
||||
|
@ -31,6 +31,11 @@ size_t
|
||||
strlcat(char *dst, const char *src, size_t size);
|
||||
#endif /* if !defined(HAVE_STRLCAT) */
|
||||
|
||||
#if !defined(HAVE_STRNSTR)
|
||||
char *
|
||||
strnstr(const char *s, const char *find, size_t slen);
|
||||
#endif /* if !defined(HAVE_STRNSTR) */
|
||||
|
||||
int
|
||||
isc_string_strerror_r(int errnum, char *buf, size_t buflen);
|
||||
|
||||
|
@ -12,9 +12,15 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Chris Torek.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -109,6 +115,28 @@ strlcat(char *dst, const char *src, size_t size) {
|
||||
}
|
||||
#endif /* !defined(HAVE_STRLCAT) */
|
||||
|
||||
#if !defined(HAVE_STRNSTR)
|
||||
char *
|
||||
strnstr(const char *s, const char *find, size_t slen) {
|
||||
char c, sc;
|
||||
size_t len;
|
||||
|
||||
if ((c = *find++) != '\0') {
|
||||
len = strlen(find);
|
||||
do {
|
||||
do {
|
||||
if (slen-- < 1 || (sc = *s++) == '\0')
|
||||
return (NULL);
|
||||
} while (sc != c);
|
||||
if (len > slen)
|
||||
return (NULL);
|
||||
} while (strncmp(s, find, len) != 0);
|
||||
s--;
|
||||
}
|
||||
return ((char *)s);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
isc_string_strerror_r(int errnum, char *buf, size_t buflen) {
|
||||
return (strerror_r(errnum, buf, buflen));
|
||||
|
Loading…
x
Reference in New Issue
Block a user