From 0517cc95727bfc02ac268f766ec6b448135f8929 Mon Sep 17 00:00:00 2001 From: Joshua Root Date: Fri, 7 Apr 2023 20:15:37 +1000 Subject: [PATCH] Don't try to include bsd/string.h if not present (#86) Closes #82 - Don't try to include bsd/string.h if not present --- configure.ac | 10 +++++++++- python/dnet.pxd.in | 2 ++ python/dnet.pyx | 3 +-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 python/dnet.pxd.in diff --git a/configure.ac b/configure.ac index ce111a6..20ea9ac 100644 --- a/configure.ac +++ b/configure.ac @@ -190,6 +190,13 @@ else netinet/ip_compat.h ip_fil.h netinet/ip_fil.h) AC_CHECK_HEADERS(hpsecurity.h stropts.h) fi +AC_CHECK_HEADERS(bsd/string.h) +if test "$ac_cv_header_bsd_string_h" = yes; then + STRLCPY_HEADER="bsd/string.h" +else + STRLCPY_HEADER="string.h" +fi +AC_SUBST(STRLCPY_HEADER) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -336,5 +343,6 @@ fi AC_OUTPUT([Makefile dnet-config include/Makefile include/dnet/Makefile man/Makefile src/Makefile python/Makefile python/setup.py - test/Makefile test/check/Makefile test/dnet/Makefile], + python/dnet.pxd test/Makefile test/check/Makefile + test/dnet/Makefile], [chmod 755 dnet-config]) diff --git a/python/dnet.pxd.in b/python/dnet.pxd.in new file mode 100644 index 0000000..60005da --- /dev/null +++ b/python/dnet.pxd.in @@ -0,0 +1,2 @@ +cdef extern from "@STRLCPY_HEADER@": + size_t strlcpy(char *dst, char *src, size_t size) diff --git a/python/dnet.pyx b/python/dnet.pyx index 4d9f15c..b2f5662 100644 --- a/python/dnet.pyx +++ b/python/dnet.pyx @@ -40,8 +40,7 @@ cdef extern from *: unsigned long htonl(unsigned long n) unsigned long ntohl(unsigned long n) -cdef extern from "bsd/string.h": - int strlcpy(char *dst, char *src, int size) +from dnet cimport * cdef __memcpy(char *dst, object src, int n): if PyBytes_Size(src) != n: