Skip to content

Commit

Permalink
Don't try to include bsd/string.h if not present (#86)
Browse files Browse the repository at this point in the history
Closes #82 - Don't try to include bsd/string.h if not present
  • Loading branch information
jmroot authored Apr 7, 2023
1 parent ff6647d commit 0517cc9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
2 changes: 2 additions & 0 deletions python/dnet.pxd.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cdef extern from "@STRLCPY_HEADER@":
size_t strlcpy(char *dst, char *src, size_t size)
3 changes: 1 addition & 2 deletions python/dnet.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0517cc9

Please sign in to comment.