/* Define to 1 if you have the `strlcpy' function. */
#undef HAVE_STRLCPY
+/* Define to 1 if you have the `strnstr' function. */
+#undef HAVE_STRNSTR
+
/* Define to 1 if you have the `sysconf' function. */
#undef HAVE_SYSCONF
#
# Check for some other useful functions that are not ever-present.
#
-for ac_func in strlcpy strlcat
+for ac_func in strlcpy strlcat strnstr
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
#
# Check for some other useful functions that are not ever-present.
#
-AC_CHECK_FUNCS([strlcpy strlcat])
+AC_CHECK_FUNCS([strlcpy strlcat strnstr])
AC_SUBST(READLINE_LIB)
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);
*/
/*
+ * 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:
#include <string.h>
#include <isc/string.h> /* IWYU pragma: keep */
+#include <isc/util.h>
#if !defined(HAVE_STRLCPY)
size_t
}
#endif /* !defined(HAVE_STRLCAT) */
+#if !defined(HAVE_STRNSTR)
+char *
+strnstr(const char *s, const char *find, size_t slen) {
+ char c, sc, *r;
+ 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--;
+ }
+ DE_CONST(s, r);
+ return (r);
+}
+#endif
+
int
isc_string_strerror_r(int errnum, char *buf, size_t buflen) {
#if defined(_WIN32) || defined(_WIN64)