mirror of https://github.com/getdnsapi/getdns.git
Update extensions
This commit is contained in:
parent
56ff244133
commit
13b9e74ff5
|
@ -34,6 +34,9 @@ doc:
|
||||||
test:
|
test:
|
||||||
cd src && $(MAKE) $@
|
cd src && $(MAKE) $@
|
||||||
|
|
||||||
|
example:
|
||||||
|
cd src && $(MAKE) $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
cd src && $(MAKE) $@
|
cd src && $(MAKE) $@
|
||||||
cd doc && $(MAKE) $@
|
cd doc && $(MAKE) $@
|
||||||
|
@ -65,6 +68,7 @@ $(distdir):
|
||||||
cp $(srcdir)/ltmain.sh $(distdir)
|
cp $(srcdir)/ltmain.sh $(distdir)
|
||||||
cp $(srcdir)/src/*.in $(distdir)/src
|
cp $(srcdir)/src/*.in $(distdir)/src
|
||||||
cp $(srcdir)/src/*.[ch] $(distdir)/src
|
cp $(srcdir)/src/*.[ch] $(distdir)/src
|
||||||
|
cp $(srcdir)/src/extension/*.[ch] $(distdir)/src/extension
|
||||||
cp $(srcdir)/src/getdns/*.in $(distdir)/src/getdns
|
cp $(srcdir)/src/getdns/*.in $(distdir)/src/getdns
|
||||||
cp $(srcdir)/src/getdns/*.h $(distdir)/src/getdns
|
cp $(srcdir)/src/getdns/*.h $(distdir)/src/getdns
|
||||||
cp $(srcdir)/src/test/Makefile.in $(distdir)/src/test
|
cp $(srcdir)/src/test/Makefile.in $(distdir)/src/test
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# Guess values for system-dependent variables and create Makefiles.
|
||||||
# Generated by GNU Autoconf 2.69 for getdns 0.1.0.
|
# Generated by GNU Autoconf 2.69 for getdns 0.1.0.
|
||||||
#
|
#
|
||||||
# Report bugs to <melinda.shore@nomountain.net>.
|
# Report bugs to <stub-resolver@verisignlabs.com>.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
|
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
|
||||||
|
@ -275,7 +275,7 @@ fi
|
||||||
$as_echo "$0: be upgraded to zsh 4.3.4 or later."
|
$as_echo "$0: be upgraded to zsh 4.3.4 or later."
|
||||||
else
|
else
|
||||||
$as_echo "$0: Please tell bug-autoconf@gnu.org and
|
$as_echo "$0: Please tell bug-autoconf@gnu.org and
|
||||||
$0: melinda.shore@nomountain.net about your system,
|
$0: stub-resolver@verisignlabs.com about your system,
|
||||||
$0: including any error possibly output before this
|
$0: including any error possibly output before this
|
||||||
$0: message. Then install a modern shell, or manually run
|
$0: message. Then install a modern shell, or manually run
|
||||||
$0: the script under such a shell if you do have one."
|
$0: the script under such a shell if you do have one."
|
||||||
|
@ -592,7 +592,7 @@ PACKAGE_NAME='getdns'
|
||||||
PACKAGE_TARNAME='getdns'
|
PACKAGE_TARNAME='getdns'
|
||||||
PACKAGE_VERSION='0.1.0'
|
PACKAGE_VERSION='0.1.0'
|
||||||
PACKAGE_STRING='getdns 0.1.0'
|
PACKAGE_STRING='getdns 0.1.0'
|
||||||
PACKAGE_BUGREPORT='melinda.shore@nomountain.net'
|
PACKAGE_BUGREPORT='stub-resolver@verisignlabs.com'
|
||||||
PACKAGE_URL=''
|
PACKAGE_URL=''
|
||||||
|
|
||||||
ac_unique_file="src/getdns/getdns.h"
|
ac_unique_file="src/getdns/getdns.h"
|
||||||
|
@ -634,6 +634,7 @@ ac_includes_default="\
|
||||||
|
|
||||||
ac_subst_vars='LTLIBOBJS
|
ac_subst_vars='LTLIBOBJS
|
||||||
LIBOBJS
|
LIBOBJS
|
||||||
|
have_libevent
|
||||||
DOXYGEN
|
DOXYGEN
|
||||||
INSTALL_DATA
|
INSTALL_DATA
|
||||||
INSTALL_SCRIPT
|
INSTALL_SCRIPT
|
||||||
|
@ -1386,7 +1387,7 @@ Some influential environment variables:
|
||||||
Use these variables to override the choices made by `configure' or to help
|
Use these variables to override the choices made by `configure' or to help
|
||||||
it to find libraries and programs with nonstandard names/locations.
|
it to find libraries and programs with nonstandard names/locations.
|
||||||
|
|
||||||
Report bugs to <melinda.shore@nomountain.net>.
|
Report bugs to <stub-resolver@verisignlabs.com>.
|
||||||
_ACEOF
|
_ACEOF
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
fi
|
fi
|
||||||
|
@ -10853,66 +10854,8 @@ fi
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for libraries.
|
||||||
found_all_libs=1
|
found_all_libs=1
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: Checking for dependencies libevent, ldns" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: Checking for dependencies ldns" >&5
|
||||||
$as_echo "$as_me: Checking for dependencies libevent, ldns" >&6;}
|
$as_echo "$as_me: Checking for dependencies ldns" >&6;}
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing event_loop" >&5
|
|
||||||
$as_echo_n "checking for library containing event_loop... " >&6; }
|
|
||||||
if ${ac_cv_search_event_loop+:} false; then :
|
|
||||||
$as_echo_n "(cached) " >&6
|
|
||||||
else
|
|
||||||
ac_func_search_save_LIBS=$LIBS
|
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
||||||
/* end confdefs.h. */
|
|
||||||
|
|
||||||
/* Override any GCC internal prototype to avoid an error.
|
|
||||||
Use char because int might match the return type of a GCC
|
|
||||||
builtin and then its argument prototype would still apply. */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
#endif
|
|
||||||
char event_loop ();
|
|
||||||
int
|
|
||||||
main ()
|
|
||||||
{
|
|
||||||
return event_loop ();
|
|
||||||
;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_ACEOF
|
|
||||||
for ac_lib in '' event_core event; do
|
|
||||||
if test -z "$ac_lib"; then
|
|
||||||
ac_res="none required"
|
|
||||||
else
|
|
||||||
ac_res=-l$ac_lib
|
|
||||||
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
|
|
||||||
fi
|
|
||||||
if ac_fn_c_try_link "$LINENO"; then :
|
|
||||||
ac_cv_search_event_loop=$ac_res
|
|
||||||
fi
|
|
||||||
rm -f core conftest.err conftest.$ac_objext \
|
|
||||||
conftest$ac_exeext
|
|
||||||
if ${ac_cv_search_event_loop+:} false; then :
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if ${ac_cv_search_event_loop+:} false; then :
|
|
||||||
|
|
||||||
else
|
|
||||||
ac_cv_search_event_loop=no
|
|
||||||
fi
|
|
||||||
rm conftest.$ac_ext
|
|
||||||
LIBS=$ac_func_search_save_LIBS
|
|
||||||
fi
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_event_loop" >&5
|
|
||||||
$as_echo "$ac_cv_search_event_loop" >&6; }
|
|
||||||
ac_res=$ac_cv_search_event_loop
|
|
||||||
if test "$ac_res" != no; then :
|
|
||||||
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
|
|
||||||
|
|
||||||
else
|
|
||||||
found_all_libs=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ldns_dname_new_frm_str in -lldns" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ldns_dname_new_frm_str in -lldns" >&5
|
||||||
$as_echo_n "checking for ldns_dname_new_frm_str in -lldns... " >&6; }
|
$as_echo_n "checking for ldns_dname_new_frm_str in -lldns... " >&6; }
|
||||||
if ${ac_cv_lib_ldns_ldns_dname_new_frm_str+:} false; then :
|
if ${ac_cv_lib_ldns_ldns_dname_new_frm_str+:} false; then :
|
||||||
|
@ -11200,6 +11143,63 @@ _ACEOF
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
have_libevent=1
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing event_loop" >&5
|
||||||
|
$as_echo_n "checking for library containing event_loop... " >&6; }
|
||||||
|
if ${ac_cv_search_event_loop+:} false; then :
|
||||||
|
$as_echo_n "(cached) " >&6
|
||||||
|
else
|
||||||
|
ac_func_search_save_LIBS=$LIBS
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
/* Override any GCC internal prototype to avoid an error.
|
||||||
|
Use char because int might match the return type of a GCC
|
||||||
|
builtin and then its argument prototype would still apply. */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
#endif
|
||||||
|
char event_loop ();
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
return event_loop ();
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
for ac_lib in '' event_core event; do
|
||||||
|
if test -z "$ac_lib"; then
|
||||||
|
ac_res="none required"
|
||||||
|
else
|
||||||
|
ac_res=-l$ac_lib
|
||||||
|
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
|
||||||
|
fi
|
||||||
|
if ac_fn_c_try_link "$LINENO"; then :
|
||||||
|
ac_cv_search_event_loop=$ac_res
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext \
|
||||||
|
conftest$ac_exeext
|
||||||
|
if ${ac_cv_search_event_loop+:} false; then :
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if ${ac_cv_search_event_loop+:} false; then :
|
||||||
|
|
||||||
|
else
|
||||||
|
ac_cv_search_event_loop=no
|
||||||
|
fi
|
||||||
|
rm conftest.$ac_ext
|
||||||
|
LIBS=$ac_func_search_save_LIBS
|
||||||
|
fi
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_event_loop" >&5
|
||||||
|
$as_echo "$ac_cv_search_event_loop" >&6; }
|
||||||
|
ac_res=$ac_cv_search_event_loop
|
||||||
|
if test "$ac_res" != no; then :
|
||||||
|
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
|
||||||
|
|
||||||
|
$as_echo "#define HAVE_LIBEVENT 1" >>confdefs.h
|
||||||
|
|
||||||
for ac_func in event_base_new event_base_free
|
for ac_func in event_base_new event_base_free
|
||||||
do :
|
do :
|
||||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||||
|
@ -11213,6 +11213,11 @@ fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
have_libevent=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ac_config_files="$ac_config_files Makefile src/Makefile src/getdns/Makefile src/example/Makefile src/test/Makefile doc/Makefile"
|
ac_config_files="$ac_config_files Makefile src/Makefile src/getdns/Makefile src/example/Makefile src/test/Makefile doc/Makefile"
|
||||||
|
|
||||||
|
@ -11788,7 +11793,7 @@ $config_headers
|
||||||
Configuration commands:
|
Configuration commands:
|
||||||
$config_commands
|
$config_commands
|
||||||
|
|
||||||
Report bugs to <melinda.shore@nomountain.net>."
|
Report bugs to <stub-resolver@verisignlabs.com>."
|
||||||
|
|
||||||
_ACEOF
|
_ACEOF
|
||||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||||
|
|
17
configure.ac
17
configure.ac
|
@ -6,7 +6,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
AC_PREREQ([2.56])
|
AC_PREREQ([2.56])
|
||||||
AC_INIT([getdns], [0.1.0], [melinda.shore@nomountain.net])
|
AC_INIT([getdns], [0.1.0], [stub-resolver@verisignlabs.com])
|
||||||
AC_CONFIG_SRCDIR([src/getdns/getdns.h])
|
AC_CONFIG_SRCDIR([src/getdns/getdns.h])
|
||||||
# AM_INIT_AUTOMAKE
|
# AM_INIT_AUTOMAKE
|
||||||
# LT_INIT
|
# LT_INIT
|
||||||
|
@ -128,8 +128,7 @@ fi
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for libraries.
|
||||||
found_all_libs=1
|
found_all_libs=1
|
||||||
AC_MSG_NOTICE([Checking for dependencies libevent, ldns])
|
AC_MSG_NOTICE([Checking for dependencies ldns])
|
||||||
AC_SEARCH_LIBS([event_loop], [event_core event], [], [found_all_libs=0])
|
|
||||||
AC_CHECK_LIB([ldns], [ldns_dname_new_frm_str], [], [found_all_libs=0])
|
AC_CHECK_LIB([ldns], [ldns_dname_new_frm_str], [], [found_all_libs=0])
|
||||||
AC_CHECK_LIB([idn], [idna_to_ascii_8z], [], [found_all_libs=0])
|
AC_CHECK_LIB([idn], [idna_to_ascii_8z], [], [found_all_libs=0])
|
||||||
|
|
||||||
|
@ -163,16 +162,22 @@ AC_TYPE_UINT32_T
|
||||||
AC_TYPE_UINT64_T
|
AC_TYPE_UINT64_T
|
||||||
AC_TYPE_UINT8_T
|
AC_TYPE_UINT8_T
|
||||||
|
|
||||||
AC_CHECK_FUNCS([event_base_new event_base_free])
|
have_libevent=1
|
||||||
AH_BOTTOM([
|
AC_SEARCH_LIBS([event_loop],
|
||||||
|
[event_core event],
|
||||||
|
[AC_DEFINE([HAVE_LIBEVENT], [1], [Define to 1 to enable the libevent extension])]
|
||||||
|
[AC_CHECK_FUNCS([event_base_new event_base_free])]
|
||||||
|
[AH_BOTTOM([
|
||||||
#ifndef HAVE_EVENT_BASE_FREE
|
#ifndef HAVE_EVENT_BASE_FREE
|
||||||
#define event_base_free(x) /* nop */
|
#define event_base_free(x) /* nop */
|
||||||
#endif
|
#endif
|
||||||
#ifndef HAVE_EVENT_BASE_NEW
|
#ifndef HAVE_EVENT_BASE_NEW
|
||||||
#define event_base_new event_init
|
#define event_base_new event_init
|
||||||
#endif
|
#endif
|
||||||
])
|
])],
|
||||||
|
[have_libevent=0])
|
||||||
|
|
||||||
|
AC_SUBST(have_libevent)
|
||||||
AC_CONFIG_FILES([Makefile src/Makefile src/getdns/Makefile src/example/Makefile src/test/Makefile doc/Makefile])
|
AC_CONFIG_FILES([Makefile src/Makefile src/getdns/Makefile src/example/Makefile src/test/Makefile doc/Makefile])
|
||||||
if [ test -n "$DOXYGEN" ]
|
if [ test -n "$DOXYGEN" ]
|
||||||
then AC_CONFIG_FILES([src/Doxyfile])
|
then AC_CONFIG_FILES([src/Doxyfile])
|
||||||
|
|
|
@ -20,6 +20,7 @@ exec_prefix = @exec_prefix@
|
||||||
bindir = @bindir@
|
bindir = @bindir@
|
||||||
libdir = @libdir@
|
libdir = @libdir@
|
||||||
includedir = @includedir@
|
includedir = @includedir@
|
||||||
|
have_libevent = @have_libevent@
|
||||||
# datarootdir is here to please some checkers
|
# datarootdir is here to please some checkers
|
||||||
datarootdir=@datarootdir@
|
datarootdir=@datarootdir@
|
||||||
INSTALL = @INSTALL@
|
INSTALL = @INSTALL@
|
||||||
|
@ -33,7 +34,11 @@ CFLAGS=@CFLAGS@ -Wall -I$(srcdir)/ -I/usr/local/include -std=c99
|
||||||
LDFLAGS=@LDFLAGS@ @LIBS@
|
LDFLAGS=@LDFLAGS@ @LIBS@
|
||||||
GETDNS_OBJ=sync.lo context.lo list.lo dict.lo convert.lo general.lo \
|
GETDNS_OBJ=sync.lo context.lo list.lo dict.lo convert.lo general.lo \
|
||||||
hostname.lo service.lo request-internal.lo validate_dnssec.lo \
|
hostname.lo service.lo request-internal.lo validate_dnssec.lo \
|
||||||
util-internal.lo getdns_error.lo extension_libevent.lo
|
util-internal.lo getdns_error.lo
|
||||||
|
|
||||||
|
ifeq ($(have_libevent),1)
|
||||||
|
GETDNS_OBJ += extension/libevent.lo
|
||||||
|
endif
|
||||||
|
|
||||||
.SUFFIXES: .c .o .a .lo .h
|
.SUFFIXES: .c .o .a .lo .h
|
||||||
|
|
||||||
|
@ -46,27 +51,32 @@ GETDNS_OBJ=sync.lo context.lo list.lo dict.lo convert.lo general.lo \
|
||||||
default: all
|
default: all
|
||||||
|
|
||||||
all: libgetdns.la
|
all: libgetdns.la
|
||||||
cd test && $(MAKE) $@
|
|
||||||
cd example && $(MAKE) $@
|
|
||||||
|
|
||||||
install: libgetdns.la
|
install: libgetdns.la
|
||||||
$(INSTALL) -m 755 -d $(DESTDIR)$(includedir)
|
$(INSTALL) -m 755 -d $(DESTDIR)$(includedir)
|
||||||
$(INSTALL) -m 755 -d $(DESTDIR)$(includedir)/getdns
|
$(INSTALL) -m 755 -d $(DESTDIR)$(includedir)/getdns
|
||||||
$(INSTALL) -m 644 $(srcdir)/getdns/getdns.h $(DESTDIR)$(includedir)/getdns/getdns.h
|
$(INSTALL) -m 644 $(srcdir)/getdns/getdns.h $(DESTDIR)$(includedir)/getdns/getdns.h
|
||||||
|
ifeq ($(have_libevent),1)
|
||||||
|
$(INSTALL) -m 644 $(srcdir)/getdns/getdns.h $(DESTDIR)$(includedir)/getdns/
|
||||||
|
endif
|
||||||
$(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
|
$(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
|
||||||
$(LIBTOOL) --mode=install cp libgetdns.la $(DESTDIR)$(libdir)
|
$(LIBTOOL) --mode=install cp libgetdns.la $(DESTDIR)$(libdir)
|
||||||
$(LIBTOOL) --mode=finish $(DESTDIR)$(libdir)
|
$(LIBTOOL) --mode=finish $(DESTDIR)$(libdir)
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -f $(DESTDIR)$(includedir)/getdns/getdns.h
|
rm -rf $(DESTDIR)$(includedir)/getdns
|
||||||
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libgetdns.la
|
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libgetdns.la
|
||||||
|
|
||||||
libgetdns.la: $(GETDNS_OBJ)
|
libgetdns.la: $(GETDNS_OBJ)
|
||||||
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ $(GETDNS_OBJ) $(LDFLAGS) -rpath $(libdir) -version-info $(libversion) -no-undefined
|
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ $(GETDNS_OBJ) $(LDFLAGS) -rpath $(libdir) -version-info $(libversion) -no-undefined
|
||||||
|
|
||||||
test: libgetdns.la
|
test:
|
||||||
cd test && $(MAKE) $@
|
cd test && $(MAKE) $@
|
||||||
|
|
||||||
|
example:
|
||||||
|
cd example && $(MAKE) $@
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
cd test && $(MAKE) $@
|
cd test && $(MAKE) $@
|
||||||
cd example && $(MAKE) $@
|
cd example && $(MAKE) $@
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
#undef HAVE_INTTYPES_H
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
|
/* Define to 1 to enable the libevent extension */
|
||||||
|
#undef HAVE_LIBEVENT
|
||||||
|
|
||||||
/* Define to 1 if you have the `idn' library (-lidn). */
|
/* Define to 1 if you have the `idn' library (-lidn). */
|
||||||
#undef HAVE_LIBIDN
|
#undef HAVE_LIBIDN
|
||||||
|
|
||||||
|
|
|
@ -291,6 +291,9 @@ getdns_context_create_with_extended_memory_functions(
|
||||||
result->edns_version = 0;
|
result->edns_version = 0;
|
||||||
result->edns_do_bit = 0;
|
result->edns_do_bit = 0;
|
||||||
|
|
||||||
|
result->extension = NULL;
|
||||||
|
result->extension_data = NULL;
|
||||||
|
|
||||||
if (set_from_os) {
|
if (set_from_os) {
|
||||||
if (GETDNS_RETURN_GOOD != set_os_defaults(result)) {
|
if (GETDNS_RETURN_GOOD != set_os_defaults(result)) {
|
||||||
getdns_context_destroy(result);
|
getdns_context_destroy(result);
|
||||||
|
@ -1142,4 +1145,36 @@ getdns_bindata_destroy(struct mem_funcs *mfs,
|
||||||
GETDNS_FREE(*mfs, bindata->data);
|
GETDNS_FREE(*mfs, bindata->data);
|
||||||
GETDNS_FREE(*mfs, bindata);
|
GETDNS_FREE(*mfs, bindata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getdns_return_t
|
||||||
|
getdns_extension_detach_eventloop(struct getdns_context* context)
|
||||||
|
{
|
||||||
|
RETURN_IF_NULL(context, GETDNS_RETURN_BAD_CONTEXT);
|
||||||
|
getdns_return_t r = GETDNS_RETURN_GOOD;
|
||||||
|
if (context->extension) {
|
||||||
|
r = context->extension->cleanup_data(context, context->extension_data);
|
||||||
|
if (r != GETDNS_RETURN_GOOD) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
context->extension = NULL;
|
||||||
|
context->extension_data = NULL;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
getdns_return_t
|
||||||
|
getdns_extension_set_eventloop(struct getdns_context* context,
|
||||||
|
getdns_eventloop_extension* extension, void* extension_data)
|
||||||
|
{
|
||||||
|
RETURN_IF_NULL(context, GETDNS_RETURN_BAD_CONTEXT);
|
||||||
|
RETURN_IF_NULL(extension, GETDNS_RETURN_INVALID_PARAMETER);
|
||||||
|
getdns_return_t r = getdns_extension_detach_eventloop(context);
|
||||||
|
if (r != GETDNS_RETURN_GOOD) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
context->extension = extension;
|
||||||
|
context->extension_data = extension_data;
|
||||||
|
return GETDNS_RETURN_GOOD;
|
||||||
|
}
|
||||||
|
|
||||||
/* getdns_context.c */
|
/* getdns_context.c */
|
||||||
|
|
|
@ -75,6 +75,18 @@ struct getdns_context {
|
||||||
* outbound requests -> transaction to getdns_dns_req
|
* outbound requests -> transaction to getdns_dns_req
|
||||||
*/
|
*/
|
||||||
struct ldns_rbtree_t *outbound_requests;
|
struct ldns_rbtree_t *outbound_requests;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Event loop extension functions
|
||||||
|
* These structs are static and should never be freed
|
||||||
|
* since they are just a collection of function pointers
|
||||||
|
*/
|
||||||
|
getdns_eventloop_extension* extension;
|
||||||
|
/*
|
||||||
|
* Extension data that will be freed by the functions
|
||||||
|
* in the extension struct
|
||||||
|
*/
|
||||||
|
void* extension_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** internal functions **/
|
/** internal functions **/
|
||||||
|
@ -104,4 +116,8 @@ void getdns_bindata_destroy(
|
||||||
struct mem_funcs *mfs,
|
struct mem_funcs *mfs,
|
||||||
struct getdns_bindata *bindata);
|
struct getdns_bindata *bindata);
|
||||||
|
|
||||||
|
/* extension stuff */
|
||||||
|
getdns_return_t getdns_extension_set_eventloop(struct getdns_context* context,
|
||||||
|
getdns_eventloop_extension* extension, void* extension_data);
|
||||||
|
|
||||||
#endif /* _GETDNS_CONTEXT_H_ */
|
#endif /* _GETDNS_CONTEXT_H_ */
|
||||||
|
|
|
@ -17,7 +17,7 @@ VPATH = @srcdir@
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=@CFLAGS@ -Wall -I$(srcdir)/ -I$(srcdir)/../ -I/usr/local/include -std=c99
|
CFLAGS=@CFLAGS@ -Wall -I$(srcdir)/ -I$(srcdir)/../ -I/usr/local/include -std=c99
|
||||||
LDFLAGS=@LDFLAGS@ -L. -L.. -L/usr/local/lib
|
LDFLAGS=@LDFLAGS@ -L. -L.. -L$(srcdir)/../ -L/usr/local/lib
|
||||||
LDLIBS=-lgetdns @LIBS@
|
LDLIBS=-lgetdns @LIBS@
|
||||||
PROGRAMS=example-all-functions example-simple-answers example-tree example-synchronous example-reverse
|
PROGRAMS=example-all-functions example-simple-answers example-tree example-synchronous example-reverse
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <getdns/getdns.h>
|
#include <getdns/getdns.h>
|
||||||
|
#include <getdns/getdns_ext_libevent.h>
|
||||||
#ifdef HAVE_EVENT2_EVENT_H
|
#ifdef HAVE_EVENT2_EVENT_H
|
||||||
#include <event2/event.h>
|
#include <event2/event.h>
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* \brief Public interfaces to getdns, include in your application to use getdns API.
|
||||||
|
*
|
||||||
|
* This source was taken from the original pseudo-implementation by
|
||||||
|
* Paul Hoffman.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013, NLNet Labs, Versign, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the <organization> nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <getdns/getdns_ext_libevent.h>
|
||||||
|
#include "config.h"
|
||||||
|
#include "context.h"
|
||||||
|
#ifdef HAVE_EVENT2_EVENT_H
|
||||||
|
# include <event2/event.h>
|
||||||
|
#else
|
||||||
|
# include <event.h>
|
||||||
|
# define evutil_socket_t int
|
||||||
|
# define event_free free
|
||||||
|
# define evtimer_new(b, cb, arg) event_new((b), -1, 0, (cb), (arg))
|
||||||
|
#endif
|
||||||
|
#define RETURN_IF_NULL(ptr, code) if(ptr == NULL) return code;
|
||||||
|
|
||||||
|
#ifndef HAVE_EVENT2_EVENT_H
|
||||||
|
static struct event *
|
||||||
|
event_new(struct event_base *b, evutil_socket_t fd, short ev, void* cb, void *arg)
|
||||||
|
{
|
||||||
|
struct event* e = (struct event*)calloc(1, sizeof(struct event));
|
||||||
|
if(!e) return NULL;
|
||||||
|
event_set(e, fd, ev, cb, arg);
|
||||||
|
event_base_set(b, e);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
#endif /* no event2 */
|
||||||
|
|
||||||
|
/* extension info */
|
||||||
|
struct event_data {
|
||||||
|
struct event* event;
|
||||||
|
struct event_base* event_base;
|
||||||
|
};
|
||||||
|
|
||||||
|
static getdns_return_t getdns_libevent_cleanup(struct getdns_context* context, void* data) {
|
||||||
|
struct event_data *edata = (struct event_data*) data;
|
||||||
|
event_del(edata->event);
|
||||||
|
event_free(edata->event);
|
||||||
|
free(edata);
|
||||||
|
return GETDNS_RETURN_GOOD;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getdns_eventloop_extension LIBEVENT_EXT = {
|
||||||
|
getdns_libevent_cleanup
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void getdns_libevent_cb(evutil_socket_t fd, short what, void *userarg) {
|
||||||
|
struct getdns_context* context = (struct getdns_context*) userarg;
|
||||||
|
getdns_context_process_async(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* getdns_extension_set_libevent_base
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
getdns_return_t
|
||||||
|
getdns_extension_set_libevent_base(struct getdns_context *context,
|
||||||
|
struct event_base * this_event_base)
|
||||||
|
{
|
||||||
|
RETURN_IF_NULL(context, GETDNS_RETURN_BAD_CONTEXT);
|
||||||
|
RETURN_IF_NULL(this_event_base, GETDNS_RETURN_INVALID_PARAMETER);
|
||||||
|
/* TODO: cleanup current extension base */
|
||||||
|
getdns_return_t r = getdns_extension_detach_eventloop(context);
|
||||||
|
if (r != GETDNS_RETURN_GOOD) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
int fd = getdns_context_fd(context);
|
||||||
|
struct event* getdns_event = event_new(this_event_base, fd, EV_READ | EV_PERSIST, getdns_libevent_cb, context);
|
||||||
|
if (!getdns_event) {
|
||||||
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
|
}
|
||||||
|
event_add(getdns_event, NULL);
|
||||||
|
|
||||||
|
/* TODO: use context functs? */
|
||||||
|
struct event_data* ev_data = (struct event_data*) malloc(sizeof(struct event_data));
|
||||||
|
if (!ev_data) {
|
||||||
|
/* cleanup */
|
||||||
|
event_del(getdns_event);
|
||||||
|
event_free(getdns_event);
|
||||||
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
|
}
|
||||||
|
ev_data->event = getdns_event;
|
||||||
|
ev_data->event_base = this_event_base;
|
||||||
|
|
||||||
|
return getdns_extension_set_eventloop(context, &LIBEVENT_EXT, ev_data);
|
||||||
|
} /* getdns_extension_set_libevent_base */
|
|
@ -1,47 +0,0 @@
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "context.h"
|
|
||||||
#ifdef HAVE_EVENT2_EVENT_H
|
|
||||||
# include <event2/event.h>
|
|
||||||
#else
|
|
||||||
# include <event.h>
|
|
||||||
# define evutil_socket_t int
|
|
||||||
# define event_free free
|
|
||||||
# define evtimer_new(b, cb, arg) event_new((b), -1, 0, (cb), (arg))
|
|
||||||
#endif
|
|
||||||
#define RETURN_IF_NULL(ptr, code) if(ptr == NULL) return code;
|
|
||||||
|
|
||||||
#ifndef HAVE_EVENT2_EVENT_H
|
|
||||||
static struct event *
|
|
||||||
event_new(struct event_base *b, evutil_socket_t fd, short ev, void* cb, void *arg)
|
|
||||||
{
|
|
||||||
struct event* e = (struct event*)calloc(1, sizeof(struct event));
|
|
||||||
if(!e) return NULL;
|
|
||||||
event_set(e, fd, ev, cb, arg);
|
|
||||||
event_base_set(b, e);
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
#endif /* no event2 */
|
|
||||||
|
|
||||||
void getdns_libevent_cb(evutil_socket_t fd, short what, void *userarg) {
|
|
||||||
struct getdns_context* context = (struct getdns_context*) userarg;
|
|
||||||
getdns_context_process_async(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* getdns_extension_set_libevent_base
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
getdns_return_t
|
|
||||||
getdns_extension_set_libevent_base(struct getdns_context *context,
|
|
||||||
struct event_base * this_event_base)
|
|
||||||
{
|
|
||||||
RETURN_IF_NULL(context, GETDNS_RETURN_BAD_CONTEXT);
|
|
||||||
RETURN_IF_NULL(this_event_base, GETDNS_RETURN_INVALID_PARAMETER);
|
|
||||||
/* TODO: cleanup current extension base */
|
|
||||||
int fd = getdns_context_fd(context);
|
|
||||||
struct event *getdns_event = event_new(this_event_base, fd, EV_READ | EV_PERSIST, getdns_libevent_cb, context);
|
|
||||||
event_add(getdns_event, NULL);
|
|
||||||
|
|
||||||
return GETDNS_RETURN_GOOD;
|
|
||||||
} /* getdns_extension_set_libevent_base */
|
|
|
@ -244,7 +244,6 @@ getdns_general_ub(struct getdns_context *context,
|
||||||
getdns_callback_t callbackfn)
|
getdns_callback_t callbackfn)
|
||||||
{
|
{
|
||||||
/* timeout */
|
/* timeout */
|
||||||
struct timeval tv;
|
|
||||||
getdns_return_t gr;
|
getdns_return_t gr;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct event_base;
|
|
||||||
|
|
||||||
#define GETDNS_COMPILATION_COMMENT The API implementation should fill in something here, such as a compilation version string and date, and change it each time the API is compiled.
|
#define GETDNS_COMPILATION_COMMENT The API implementation should fill in something here, such as a compilation version string and date, and change it each time the API is compiled.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -881,19 +879,15 @@ getdns_context_set_extended_memory_functions(struct getdns_context *context,
|
||||||
void (*free) (void *userarg, void *ptr)
|
void (*free) (void *userarg, void *ptr)
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Extension - refactor to abstract async evt loop */
|
/* Extension */
|
||||||
/* For libevent, which we are using for these examples */
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_extension_set_libevent_base(struct getdns_context *context,
|
getdns_extension_detach_eventloop(struct getdns_context* context);
|
||||||
struct event_base *this_event_base);
|
|
||||||
|
|
||||||
/* get the fd */
|
/* get the fd */
|
||||||
int getdns_context_fd(struct getdns_context* context);
|
int getdns_context_fd(struct getdns_context* context);
|
||||||
/* process async reqs */
|
/* process async reqs */
|
||||||
getdns_return_t getdns_context_process_async(struct getdns_context* context);
|
getdns_return_t getdns_context_process_async(struct getdns_context* context);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* \brief Public interfaces to getdns, include in your application to use getdns API.
|
||||||
|
*
|
||||||
|
* This source was taken from the original pseudo-implementation by
|
||||||
|
* Paul Hoffman.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013, NLNet Labs, Versign, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the <organization> nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GETDNS_EXT_LIBEVENT_H
|
||||||
|
#define GETDNS_EXT_LIBEVENT_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <getdns/getdns.h>
|
||||||
|
|
||||||
|
struct event_base;
|
||||||
|
|
||||||
|
/* For libevent, which we are using for these examples */
|
||||||
|
getdns_return_t
|
||||||
|
getdns_extension_set_libevent_base(struct getdns_context *context,
|
||||||
|
struct event_base *this_event_base);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -17,7 +17,7 @@ VPATH = @srcdir@
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=@CFLAGS@ -Wall -I$(srcdir)/ -I$(srcdir)/../ -I/usr/local/include -std=c99 $(cflags)
|
CFLAGS=@CFLAGS@ -Wall -I$(srcdir)/ -I$(srcdir)/../ -I/usr/local/include -std=c99 $(cflags)
|
||||||
LDFLAGS=@LDFLAGS@ -L. -L.. -L/usr/local/lib
|
LDFLAGS=@LDFLAGS@ -L. -L.. -L$(srcdir)/../ -L/usr/local/lib
|
||||||
LDLIBS=-lgetdns @LIBS@ -lcheck
|
LDLIBS=-lgetdns @LIBS@ -lcheck
|
||||||
PROGRAMS=tests_dict tests_list tests_stub_async tests_stub_sync check_getdns
|
PROGRAMS=tests_dict tests_list tests_stub_async tests_stub_sync check_getdns
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ this_callbackfn(struct getdns_context *this_context,
|
||||||
"The callback got a callback_type of %d. Exiting.",
|
"The callback got a callback_type of %d. Exiting.",
|
||||||
this_callback_type);
|
this_callback_type);
|
||||||
getdns_dict_destroy(this_response);
|
getdns_dict_destroy(this_response);
|
||||||
|
getdns_extension_detach_eventloop(this_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -236,6 +236,14 @@ getdns_dns_req *dns_req_new(struct getdns_context *context,
|
||||||
|
|
||||||
void dns_req_free(getdns_dns_req * req);
|
void dns_req_free(getdns_dns_req * req);
|
||||||
|
|
||||||
|
|
||||||
|
/* extensions */
|
||||||
|
typedef getdns_return_t (*getdns_eventloop_cleanup_t)(struct getdns_context* context, void* data);
|
||||||
|
typedef struct getdns_eventloop_extension {
|
||||||
|
getdns_eventloop_cleanup_t cleanup_data;
|
||||||
|
} getdns_eventloop_extension;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* types-internal.h */
|
/* types-internal.h */
|
||||||
|
|
Loading…
Reference in New Issue