diff --git a/.gitignore b/.gitignore index 7dc21716..69dfe4fb 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ check_getdns_ev doc/*.3 src/getdns/getdns.h *.log +src/Doxyfile diff --git a/Makefile.in b/Makefile.in index bf85893a..bc4ae8bf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -100,6 +100,9 @@ clean: cd doc && $(MAKE) $@ rm -f *.o +depend: + cd src && $(MAKE) $@ + distclean: cd src && $(MAKE) $@ rmdir src 2>/dev/null || true diff --git a/configure b/configure index 224a1ef0..27f55f51 100755 --- a/configure +++ b/configure @@ -11700,6 +11700,21 @@ $as_echo "#define HAVE_ATTR_FORMAT 1" >>confdefs.h fi +ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" +if test "x$ac_cv_func_strlcpy" = xyes; then : + $as_echo "#define HAVE_STRLCPY 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strlcpy.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strlcpy.$ac_objext" + ;; +esac + +fi + + + diff --git a/configure.ac b/configure.ac index c8eeb2c9..8a667dac 100644 --- a/configure.ac +++ b/configure.ac @@ -404,6 +404,8 @@ if test $ac_cv_c_format_attribute = yes; then AC_DEFINE(HAVE_ATTR_FORMAT, 1, [Whether the C compiler accepts the "format" attribute]) fi +AC_REPLACE_FUNCS(strlcpy) + AH_BOTTOM([ /** Use on-board gldns */ diff --git a/src/Makefile.in b/src/Makefile.in index 14713c02..e7f6be25 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -83,6 +83,10 @@ GETDNS_OBJ=sync.lo context.lo list.lo dict.lo convert.lo general.lo \ GLDNS_OBJ=keyraw.lo gbuffer.lo wire2str.lo parse.lo parseutil.lo rrdef.lo \ str2wire.lo +LIBOBJDIR= +LIBOBJS=@LIBOBJS@ +COMPAT_OBJ=$(LIBOBJS:.o=.lo) + .SUFFIXES: .c .o .a .lo .h .c.o: @@ -91,7 +95,7 @@ GLDNS_OBJ=keyraw.lo gbuffer.lo wire2str.lo parse.lo parseutil.lo rrdef.lo \ .c.lo: $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $< -o $@ -$(GLDNS_OBJ): +$(GLDNS_OBJ) $(COMPAT_OBJ): @: $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $< -o $@ @@ -130,8 +134,8 @@ libgetdns_ext_ev.la: libgetdns.la extension/libev.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ extension/libev.lo ./.libs/libgetdns.la $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libev.symbols -libgetdns.la: $(GETDNS_OBJ) $(GLDNS_OBJ) - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ $(GETDNS_OBJ) $(GLDNS_OBJ) $(LDFLAGS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/libgetdns.symbols +libgetdns.la: $(GETDNS_OBJ) $(GLDNS_OBJ) $(COMPAT_OBJ) + $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ $(GETDNS_OBJ) $(GLDNS_OBJ) $(COMPAT_OBJ) $(LDFLAGS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/libgetdns.symbols test: FORCE @@ -185,21 +189,28 @@ Makefile: Makefile.in ../config.status configure.status: configure cd .. && ./config.status --recheck +depend: + (cd $(srcdir) ; awk 'BEGIN{P=1}{if(P)print}/^# Dependencies/{P=0}' Makefile.in > Makefile.in.new ) + (cd $(srcdir) ; gcc -MM -I. gldns/*.c compat/*.c | \ + sed -e 's?gldns/?$$(srcdir)/gldns/?g' \ + -e 's?compat/?$$(srcdir)/compat/?g' \ + -e 's!\(.*\)\.o[ :]*!\1.lo \1.o: !g' >> Makefile.in.new ) + (cd $(srcdir) ; diff Makefile.in.new Makefile.in && rm Makefile.in.new \ + || mv Makefile.in.new Makefile.in ) + .PHONY: clean test example FORCE: -# Dependencies for gldns -# ---------------------- -# Create with: gcc -MM -I. gldns/*.c|sed -e 's?gldns/?$(srcdir)/gldns/?g' -e 's!\(.*\)\.o[ :]*!\1.lo \1.o: !g' >> Makefile.in - +# Dependencies for gldns and compatibility functions +gbuffer.lo gbuffer.o: $(srcdir)/gldns/gbuffer.c config.h $(srcdir)/gldns/gbuffer.h keyraw.lo keyraw.o: $(srcdir)/gldns/keyraw.c config.h $(srcdir)/gldns/keyraw.h $(srcdir)/gldns/rrdef.h parse.lo parse.o: $(srcdir)/gldns/parse.c config.h $(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h \ $(srcdir)/gldns/gbuffer.h parseutil.lo parseutil.o: $(srcdir)/gldns/parseutil.c config.h $(srcdir)/gldns/parseutil.h rrdef.lo rrdef.o: $(srcdir)/gldns/rrdef.c config.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/parseutil.h -gbuffer.lo gbuffer.o: $(srcdir)/gldns/gbuffer.c config.h $(srcdir)/gldns/gbuffer.h str2wire.lo str2wire.o: $(srcdir)/gldns/str2wire.c config.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h \ $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h wire2str.lo wire2str.o: $(srcdir)/gldns/wire2str.c config.h $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/str2wire.h \ $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/parseutil.h $(srcdir)/gldns/gbuffer.h \ $(srcdir)/gldns/keyraw.h +strlcpy.lo strlcpy.o: $(srcdir)/compat/strlcpy.c config.h diff --git a/src/compat/strlcpy.c b/src/compat/strlcpy.c new file mode 100644 index 00000000..acd306a1 --- /dev/null +++ b/src/compat/strlcpy.c @@ -0,0 +1,57 @@ +/* from openssh 4.3p2 compat/strlcpy.c */ +/* + * Copyright (c) 1998 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* OPENBSD ORIGINAL: lib/libc/string/strlcpy.c */ + +#include +#ifndef HAVE_STRLCPY + +#include +#include + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +size_t +strlcpy(char *dst, const char *src, size_t siz) +{ + char *d = dst; + const char *s = src; + size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return(s - src - 1); /* count does not include NUL */ +} + +#endif /* !HAVE_STRLCPY */ diff --git a/src/config.h.in b/src/config.h.in index c8a709f6..2febc465 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -66,6 +66,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the `strlcpy' function. */ +#undef HAVE_STRLCPY + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H