Commit 3c1a6204 authored by Jason Madden's avatar Jason Madden

Merge pull request #767 from gevent/non-embed-build

Test non-embedded versions of libev and c-ares
parents 26f29b6c 08d41220
......@@ -39,6 +39,16 @@ c-ares/stamp-h1
c-ares/stamp-h2
c-ares/ares_build.h.orig
c-ares/ares_config.h
c-ares/.libs
c-ares/*.o
c-ares/*.lo
c-ares/*.la
c-ares/.deps
c-ares/acountry
c-ares/adig
c-ares/ahost
c-ares/Makefile
c-ares/libtool
libev/.deps
libev/Makefile
libev/config.log
......@@ -46,6 +56,11 @@ libev/config.h
libev/config.status
libev/libtool
libev/stamp-h1
libev/.libs
libev/*.lo
libev/*.la
libev/*.o
# running setup.py on PyPy
config.h
configure-output.txt
......@@ -9,6 +9,7 @@ env:
matrix:
# These are ordered to get as much diversity in the
# first group of parallel runs (4) as posible
- TASK=test-py27-noembed
- TASK=test-pypy
- TASK=lint-py27
- TASK=test-py35
......
......@@ -165,3 +165,8 @@ test-pypy: $(PYPY)
test-py27-cffi: $(PY27)
GEVENT_CORE_CFFI_ONLY=1 PYTHON=python2.7 PATH=$(BUILD_RUNTIMES)/versions/python2.7/bin:$(PATH) make develop toxtest
test-py27-noembed: $(PY27)
cd libev && ./configure && make
cd c-ares && ./configure && make
CPPFLAGS="-Ilibev -Ic-ares" LDFLAGS="-Llibev/.libs -Lc-ares/.libs" LD_LIBRARY_PATH="$(PWD)/libev/.libs:$(PWD)/c-ares/.libs" EMBED=0 GEVENT_CORE_CEXT_ONLY=1 PYTHON=python2.7 PATH=$(BUILD_RUNTIMES)/versions/python2.7/bin:$(PATH) make develop fulltoxtest
#
# Watcom / OpenWatcom / Win32 makefile for cares.
# Quick hack by Guenter; comments to: /dev/nul
#
!ifndef %watcom
!error WATCOM environment variable not set!
!else
SYS_INCL = -I$(%watcom)\h\nt -I$(%watcom)\h
SYS_LIBS = $(%watcom)\lib386\nt;$(%watcom)\lib386
!endif
!ifdef %libname
LIBNAME = $(%libname)
!else
LIBNAME = cares
!endif
TARGETS = $(LIBNAME).dll $(LIBNAME)_imp.lib $(LIBNAME).lib
DEMOS = adig.exe ahost.exe acountry.exe
CC = wcc386
LD = wlink
AR = wlib
RC = wrc
!ifdef __LOADDLL__
! loaddll wcc386 wccd386
! loaddll wpp386 wppd386
! loaddll wlib wlibd
!endif
!if $(__VERSION__) < 1250
RM = del /q /f 2>NUL
!else
RM = rm -f
!endif
MD = mkdir
RD = rmdir /q /s 2>NUL
CP = copy
CFLAGS = -3r -mf -hc -zff -zgf -zq -zm -zc -s -fr=con -w2 -fpi -oilrtfm &
-wcd=201 -bt=nt -d+ -dWIN32 -dCARES_BUILDING_LIBRARY &
-dNTDDI_VERSION=0x05010000 -I. $(SYS_INCL)
LFLAGS = option quiet, map, caseexact, eliminate
!ifdef %debug
DEBUG = -dDEBUG=1 -dDEBUGBUILD
CFLAGS += -d3 $(DEBUG)
LFLAGS += debug all
!else
CFLAGS += -d0
!endif
CFLAGS += -d_WIN32_WINNT=0x0501
#
# Change to suite.
#
!ifdef %use_watt32
CFLAGS += -dWATT32 -I$(%watt_root)\inc
!endif
OBJ_BASE = WC_Win32.obj
LINK_ARG = $(OBJ_BASE)\dyn\wlink.arg
LIB_ARG = $(OBJ_BASE)\stat\wlib.arg
# In order to process Makefile.inc wmake must be called with -u switch!
!ifneq __MAKEOPTS__ -u
!error You MUST call wmake with the -u switch!
!else
!include Makefile.inc
!endif
OBJS = $(CSOURCES:.c=.obj)
OBJS = $OBJ_DIR\$(OBJS: = $OBJ_DIR\)
#
# Use $(OBJS) as a template to generate $(OBJS_STAT) and $(OBJS_DYN).
#
OBJ_DIR = $(OBJ_BASE)\stat
OBJS_STAT = $+ $(OBJS) $-
OBJ_DIR = $(OBJ_BASE)\dyn
OBJS_DYN = $+ $(OBJS) $-
ARESBUILDH = ares_build.h
RESOURCE = $(OBJ_BASE)\dyn\cares.res
all: $(ARESBUILDH) $(OBJ_BASE) $(TARGETS) $(DEMOS) .SYMBOLIC
@echo Welcome to cares
$(OBJ_BASE):
-$(MD) $^@
-$(MD) $^@\stat
-$(MD) $^@\dyn
-$(MD) $^@\demos
$(ARESBUILDH): .EXISTSONLY
$(CP) $^@.dist $^@
$(LIBNAME).dll: $(OBJS_DYN) $(RESOURCE) $(LINK_ARG)
$(LD) name $^@ @$]@
$(LIBNAME).lib: $(OBJS_STAT) $(LIB_ARG)
$(AR) -q -b -c $^@ @$]@
adig.exe: $(OBJ_BASE)\demos\adig.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib
$(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib
ahost.exe: $(OBJ_BASE)\demos\ahost.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib
$(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib
acountry.exe: $(OBJ_BASE)\demos\acountry.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib
$(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib
clean: .SYMBOLIC
-$(RM) $(OBJS_STAT)
-$(RM) $(OBJS_DYN)
-$(RM) $(RESOURCE) $(LINK_ARG) $(LIB_ARG)
vclean realclean: clean .SYMBOLIC
-$(RM) $(TARGETS) $(LIBNAME).map
-$(RM) $(DEMOS) $(DEMOS:.exe=.map)
-$(RD) $(OBJ_BASE)\stat
-$(RD) $(OBJ_BASE)\dyn
-$(RD) $(OBJ_BASE)\demos
-$(RD) $(OBJ_BASE)
.ERASE
$(RESOURCE): cares.rc .AUTODEPEND
$(RC) $(DEBUG) -q -r -zm -I..\include $(SYS_INCL) $[@ -fo=$^@
.ERASE
.c{$(OBJ_BASE)\dyn}.obj:
$(CC) $(CFLAGS) -bd $[@ -fo=$^@
.ERASE
.c{$(OBJ_BASE)\stat}.obj:
$(CC) $(CFLAGS) -DCARES_STATICLIB $[@ -fo=$^@
.ERASE
.c{$(OBJ_BASE)\demos}.obj:
$(CC) $(CFLAGS) -DCARES_STATICLIB $[@ -fo=$^@
$(LINK_ARG): $(__MAKEFILES__)
%create $^@
@%append $^@ system nt dll
@%append $^@ file { $(OBJS_DYN) }
@%append $^@ option res=$(RESOURCE), implib=$(LIBNAME)_imp.lib
@%append $^@ $(LFLAGS)
@%append $^@ libpath $(SYS_LIBS)
# @%append $^@ library clib3r.lib
!ifdef %use_watt32
@%append $^@ library $(%watt_root)\lib\wattcpw_imp.lib
!else
@%append $^@ library ws2_32.lib
!endif
$(LIB_ARG): $(__MAKEFILES__)
%create $^@
@for %f in ($(OBJS_STAT)) do @%append $^@ +- %f
AUTOMAKE_OPTIONS = foreign nostdinc
ACLOCAL_AMFLAGS = -I m4
# Specify our include paths here, and do it relative to $(top_srcdir) and
# $(top_builddir), to ensure that these paths which belong to the library
# being currently built and tested are searched before the library which
# might possibly already be installed in the system.
#
# When using the low-level hard-hacking memory leak tracking code from
# libcurl the generated curl/curlbuild.h file must also be reachable.
# Using the libcurl lowlevel code from within c-ares library is ugly and
# only works when c-ares is built and linked with a similarly debug-build
# libcurl, but we do this anyway for convenience.
#
# $(top_builddir)/../include/curl for generated curlbuild.h included from curl.h
# $(top_builddir)/../include is for libcurl's generated curl/curlbuild.h file
# $(top_srcdir)/../include is for libcurl's external include files
# $(top_builddir)/../lib is for libcurl's generated lib/curl_config.h file
# $(top_srcdir)/../lib is for libcurl's lib/setup.h and other "private" files
# $(top_builddir) is for c-ares's generated ares_config.h file
# $(top_srcdir) is for c-ares's ares_setup.h and other "c-ares-private" files
if CURLDEBUG
AM_CPPFLAGS = -I$(top_builddir)/../include/curl \
-I$(top_builddir)/../include \
-I$(top_srcdir)/../include \
-I$(top_builddir)/../lib \
-I$(top_srcdir)/../lib \
-I$(top_builddir) \
-I$(top_srcdir)
else
AM_CPPFLAGS = -I$(top_builddir) \
-I$(top_srcdir)
endif
lib_LTLIBRARIES = libcares.la
man_MANS = $(MANPAGES)
MSVCFILES = vc/vc6aws.dsw vc/acountry/vc6acountry.dsp vc/adig/vc6adig.dsp \
vc/ahost/vc6ahost.dsp vc/cares/vc6cares.dsp vc/cares/vc6cares.dsw
if CURLDEBUG
PROGS =
else
PROGS = ahost adig acountry
endif
noinst_PROGRAMS =$(PROGS)
# adig and ahost are just sample programs and thus not mentioned with the
# regular sources and headers
EXTRA_DIST = AUTHORS CHANGES README.cares Makefile.inc Makefile.dj \
Makefile.m32 Makefile.netware Makefile.msvc Makefile.Watcom $(man_MANS) \
config-win32.h RELEASE-NOTES libcares.pc.in buildconf get_ver.awk maketgz \
TODO ares_build.h.in $(PDFPAGES) cares.rc README.msvc $(MSVCFILES) \
$(CSOURCES) $(HHEADERS) config-dos.h acountry.1 adig.1 ahost.1 INSTALL
CLEANFILES = $(PDFPAGES) $(HTMLPAGES)
DISTCLEANFILES = ares_build.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libcares.pc
CARES_VERSION_INFO = -version-info 3:0:1
# This flag accepts an argument of the form current[:revision[:age]]. So,
# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
# 1.
#
# If either revision or age are omitted, they default to 0. Also note that age
# must be less than or equal to the current interface number.
#
# Here are a set of rules to help you update your library version information:
#
# 1.Start with version information of 0:0:0 for each libtool library.
#
# 2.Update the version information only immediately before a public release of
# your software. More frequent updates are unnecessary, and only guarantee
# that the current interface number gets larger faster.
#
# 3.If the library source code has changed at all since the last update, then
# increment revision (c:r+1:a)
#
# 4.If any interfaces have been added, removed, or changed since the last
# update, increment current, and set revision to 0. (c+1:r=0:a)
#
# 5.If any interfaces have been added since the last public release, then
# increment age. (c:r:a+1)
#
# 6.If any interfaces have been removed since the last public release, then
# set age to 0. (c:r:a=0)
#
AM_LDFLAGS =
libcares_la_LDFLAGS_EXTRA =
if CARES_LT_SHLIB_USE_VERSION_INFO
libcares_la_LDFLAGS_EXTRA += $(CARES_VERSION_INFO)
endif
if CARES_LT_SHLIB_USE_NO_UNDEFINED
libcares_la_LDFLAGS_EXTRA += -no-undefined
endif
if CARES_LT_SHLIB_USE_MIMPURE_TEXT
libcares_la_LDFLAGS_EXTRA += -mimpure-text
endif
libcares_la_LDFLAGS = $(AM_LDFLAGS) $(libcares_la_LDFLAGS_EXTRA)
# Add -Werror if defined
CFLAGS += @CARES_CFLAG_EXTRAS@
if USE_CPPFLAG_CARES_STATICLIB
AM_CPPFLAGS += $(CPPFLAG_CARES_STATICLIB)
endif
libcares_la_CFLAGS_EXTRA =
libcares_la_CPPFLAGS_EXTRA = -DCARES_BUILDING_LIBRARY
if DOING_CARES_SYMBOL_HIDING
libcares_la_CFLAGS_EXTRA += $(CFLAG_CARES_SYMBOL_HIDING)
libcares_la_CPPFLAGS_EXTRA += -DCARES_SYMBOL_HIDING
endif
libcares_la_CFLAGS = $(AM_CFLAGS) $(libcares_la_CFLAGS_EXTRA)
libcares_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcares_la_CPPFLAGS_EXTRA)
# Makefile.inc provides the CSOURCES and HHEADERS defines
include Makefile.inc
libcares_la_SOURCES = $(CSOURCES) $(HHEADERS)
# where to install the c-ares headers
libcares_ladir = $(includedir)
# what headers to install on 'make install':
libcares_la_HEADERS = ares.h ares_version.h ares_dns.h \
ares_build.h ares_rules.h
ahost_SOURCES = ahost.c $(SAMPLESOURCES) $(SAMPLEHEADERS)
ahost_LDADD = $(top_builddir)/libcares.la
ahost_CFLAGS = $(AM_CFLAGS)
ahost_CPPFLAGS = $(AM_CPPFLAGS)
adig_SOURCES = adig.c $(SAMPLESOURCES) $(SAMPLEHEADERS)
adig_LDADD = $(top_builddir)/libcares.la
adig_CFLAGS = $(AM_CFLAGS)
adig_CPPFLAGS = $(AM_CPPFLAGS)
acountry_SOURCES = acountry.c $(SAMPLESOURCES) $(SAMPLEHEADERS)
acountry_LDADD = $(top_builddir)/libcares.la
acountry_CFLAGS = $(AM_CFLAGS)
acountry_CPPFLAGS = $(AM_CPPFLAGS)
SOURCEDMANDIR = man3
SOURCEDMANPAGES = ares_init.3
clean-local: clean-sourced-manpages
clean-sourced-manpages:
@srcdmandir='$(SOURCEDMANDIR)'; \
echo "rm -rf $(top_builddir)/$$srcdmandir"; \
rm -rf $(top_builddir)/$$srcdmandir
sourced-manpages: clean-sourced-manpages
@srcdmandir='$(SOURCEDMANDIR)'; \
srcdmanfiles='$(SOURCEDMANPAGES)'; \
mkdir $(top_builddir)/$$srcdmandir; \
for file in $$srcdmanfiles; do \
if test -f $(top_srcdir)/$$file; then \
echo "cp $(top_srcdir)/$$file $(top_builddir)/$$srcdmandir/$$file"; \
cp $(top_srcdir)/$$file $(top_builddir)/$$srcdmandir/$$file; \
fi; \
done
MAN2HTML = roffit --mandir=. < $< >$@
SUFFIXES = .3 .html
html: sourced-manpages $(HTMLPAGES)
.3.html:
$(MAN2HTML)
pdf: sourced-manpages $(PDFPAGES)
.3.pdf:
@(foo=`echo $@ | sed -e 's/\.[0-9]$$//g'`; \
groff -Tps -man $< >$$foo.ps; \
ps2pdf $$foo.ps $@; \
rm $$foo.ps; \
echo "converted $< to $@")
# Make files named *.dist replace the file without .dist extension
dist-hook:
find $(distdir) -name "*.dist" -exec rm {} \;
(distit=`find $(srcdir) -name "*.dist"`; \
for file in $$distit; do \
strip=`echo $$file | sed -e s/^$(srcdir)// -e s/\.dist//`; \
cp $$file $(distdir)$$strip; \
done)
#
# c-ares Makefile for djgpp/gcc/Watt-32.
# By Gisle Vanem <gvanem@broadpark.no> 2004.
#
TOPDIR = ..
DEPEND_PREREQ = ares_config.h
include ../packages/DOS/common.dj
include Makefile.inc
CFLAGS += -DWATT32 -Dselect=select_s
LDFLAGS = -s
ifeq ($(USE_CURLDEBUG),1)
EX_LIBS = ../lib/libcurl.a
OBJ_HACK = $(OBJECTS)
else
OBJ_HACK = libcares.a
endif
ifeq ($(USE_SSL),1)
EX_LIBS += $(OPENSSL_ROOT)/lib/libssl.a $(OPENSSL_ROOT)/lib/libcrypt.a
endif
ifeq ($(USE_ZLIB),1)
EX_LIBS += $(ZLIB_ROOT)/libz.a
endif
ifeq ($(USE_IDNA),1)
EX_LIBS += $(LIBIDN_ROOT)/lib/dj_obj/libidn.a -liconv
endif
EX_LIBS += $(WATT32_ROOT)/lib/libwatt.a
OBJECTS = $(addprefix $(OBJ_DIR)/, $(CSOURCES:.c=.o))
all: $(OBJ_DIR) ares_config.h libcares.a ahost.exe adig.exe acountry.exe
@echo Welcome to c-ares.
libcares.a: $(OBJECTS)
ar rs $@ $?
ares_config.h: config-dos.h
$(COPY) $^ $@
ahost.exe: ahost.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK)
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(EX_LIBS)
adig.exe: adig.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK)
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(EX_LIBS)
acountry.exe: acountry.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK)
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(EX_LIBS)
# clean generated files
#
genclean:
- $(DELETE) ares_config.h
# clean object files and subdir
#
objclean: genclean
- $(DELETE) $(OBJ_DIR)$(DS)*.o
- $(RMDIR) $(OBJ_DIR)
# clean without removing built library and programs
#
clean: objclean
- $(DELETE) depend.dj
# clean everything
#
realclean vclean: clean
- $(DELETE) libcares.a
- $(DELETE) acountry.exe
- $(DELETE) adig.exe
- $(DELETE) ahost.exe
- $(DELETE) libcares.a
-include depend.dj
This source diff could not be displayed because it is too large. You can view the blob instead.
CSOURCES = ares__close_sockets.c \
ares__get_hostent.c \
ares__read_line.c \
ares__timeval.c \
ares_cancel.c \
ares_data.c \
ares_destroy.c \
ares_expand_name.c \
ares_expand_string.c \
ares_fds.c \
ares_free_hostent.c \
ares_free_string.c \
ares_getenv.c \
ares_gethostbyaddr.c \
ares_gethostbyname.c \
ares_getnameinfo.c \
ares_getsock.c \
ares_init.c \
ares_library_init.c \
ares_llist.c \
ares_mkquery.c \
ares_create_query.c \
ares_nowarn.c \
ares_options.c \
ares_parse_a_reply.c \
ares_parse_aaaa_reply.c \
ares_parse_mx_reply.c \
ares_parse_naptr_reply.c \
ares_parse_ns_reply.c \
ares_parse_ptr_reply.c \
ares_parse_soa_reply.c \
ares_parse_srv_reply.c \
ares_parse_txt_reply.c \
ares_platform.c \
ares_process.c \
ares_query.c \
ares_search.c \
ares_send.c \
ares_strcasecmp.c \
ares_strdup.c \
ares_strerror.c \
ares_timeout.c \
ares_version.c \
ares_writev.c \
bitncmp.c \
inet_net_pton.c \
inet_ntop.c \
windows_port.c
HHEADERS = ares.h \
ares_build.h \
ares_data.h \
ares_dns.h \
ares_getenv.h \
ares_inet_net_pton.h \
ares_iphlpapi.h \
ares_ipv6.h \
ares_library_init.h \
ares_llist.h \
ares_nowarn.h \
ares_platform.h \
ares_private.h \
ares_rules.h \
ares_strcasecmp.h \
ares_strdup.h \
ares_version.h \
ares_writev.h \
bitncmp.h \
nameser.h \
ares_setup.h \
setup_once.h
MANPAGES = ares_cancel.3 \
ares_destroy.3 \
ares_destroy_options.3 \
ares_dup.3 \
ares_expand_name.3 \
ares_expand_string.3 \
ares_fds.3 \
ares_free_data.3 \
ares_free_hostent.3 \
ares_free_string.3 \
ares_get_servers.3 \
ares_gethostbyaddr.3 \
ares_gethostbyname.3 \
ares_gethostbyname_file.3 \
ares_getnameinfo.3 \
ares_getsock.3 \
ares_init.3 \
ares_init_options.3 \
ares_library_cleanup.3 \
ares_library_init.3 \
ares_mkquery.3 \
ares_create_query.3 \
ares_parse_a_reply.3 \
ares_parse_aaaa_reply.3 \
ares_parse_mx_reply.3 \
ares_parse_naptr_reply.3 \
ares_parse_ns_reply.3 \
ares_parse_ptr_reply.3 \
ares_parse_soa_reply.3 \
ares_parse_srv_reply.3 \
ares_parse_txt_reply.3 \
ares_process.3 \
ares_query.3 \
ares_save_options.3 \
ares_search.3 \
ares_send.3 \
ares_set_servers.3 \
ares_set_socket_callback.3 \
ares_strerror.3 \
ares_timeout.3 \
ares_version.3 \
ares_inet_pton.3 \
ares_inet_ntop.3
HTMLPAGES = ares_cancel.html \
ares_destroy.html \
ares_destroy_options.html \
ares_dup.html \
ares_expand_name.html \
ares_expand_string.html \
ares_fds.html \
ares_free_data.html \
ares_free_hostent.html \
ares_free_string.html \
ares_get_servers.html \
ares_gethostbyaddr.html \
ares_gethostbyname.html \
ares_gethostbyname_file.html \
ares_getnameinfo.html \
ares_getsock.html \
ares_init.html \
ares_init_options.html \
ares_library_cleanup.html \
ares_library_init.html \
ares_mkquery.html \
ares_create_query.html \
ares_parse_a_reply.html \
ares_parse_aaaa_reply.html \
ares_parse_mx_reply.html \
ares_parse_ns_reply.html \
ares_parse_ptr_reply.html \
ares_parse_soa_reply.html \
ares_parse_srv_reply.html \
ares_parse_txt_reply.html \
ares_process.html \
ares_query.html \
ares_save_options.html \
ares_search.html \
ares_send.html \
ares_set_servers.html \
ares_set_socket_callback.html \
ares_strerror.html \
ares_timeout.html \
ares_version.html \
ares_inet_pton.html \
ares_inet_ntop.html
PDFPAGES = ares_cancel.pdf \
ares_destroy.pdf \
ares_destroy_options.pdf \
ares_dup.pdf \
ares_expand_name.pdf \
ares_expand_string.pdf \
ares_fds.pdf \
ares_free_data.pdf \
ares_free_hostent.pdf \
ares_free_string.pdf \
ares_get_servers.pdf \
ares_gethostbyaddr.pdf \
ares_gethostbyname.pdf \
ares_gethostbyname_file.pdf \
ares_getnameinfo.pdf \
ares_getsock.pdf \
ares_init.pdf \
ares_init_options.pdf \
ares_library_cleanup.pdf \
ares_library_init.pdf \
ares_mkquery.pdf \
ares_create_query.pdf \
ares_parse_a_reply.pdf \
ares_parse_aaaa_reply.pdf \
ares_parse_mx_reply.pdf \
ares_parse_ns_reply.pdf \
ares_parse_ptr_reply.pdf \
ares_parse_soa_reply.pdf \
ares_parse_srv_reply.pdf \
ares_parse_txt_reply.pdf \
ares_process.pdf \
ares_query.pdf \
ares_save_options.pdf \
ares_search.pdf \
ares_send.pdf \
ares_set_servers.pdf \
ares_set_socket_callback.pdf \
ares_strerror.pdf \
ares_timeout.pdf \
ares_version.pdf \
ares_inet_pton.pdf \
ares_inet_ntop.pdf
SAMPLESOURCES = ares_getopt.c \
ares_nowarn.c \
ares_strcasecmp.c
SAMPLEHEADERS = ares_getopt.h \
ares_nowarn.h \
ares_strcasecmp.h
#############################################################
#
## Makefile for building libcares.a with MingW32 (GCC-3.2)
## Use: make -f Makefile.m32 [demos]
##
## Quick hack by Guenter; comments to: /dev/nul
#
########################################################
## Nothing more to do below this line!
LIB = libcares.a
AR = ar
CC = gcc
LD = gcc
RANLIB = ranlib
#RM = rm -f
CP = cp -afv
CFLAGS = -O2 -Wall -I.
CFLAGS += -DCARES_STATICLIB
LDFLAGS = -s
LIBS = -lwsock32
# Makefile.inc provides the CSOURCES and HHEADERS defines
include Makefile.inc
OBJLIB := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
$(LIB): $(OBJLIB)
$(AR) cru $@ $^
$(RANLIB) $@
all: $(LIB) demos
demos: adig.exe ahost.exe acountry.exe
tags:
etags *.[ch]
%.exe: %.o ares_getopt.o $(LIB)
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
$(OBJLIB): ares.h ares_dns.h ares_private.h ares_build.h ares_rules.h
.c.o:
$(CC) $(CFLAGS) -c $<
ares_build.h:
$(CP) ares_build.h.dist ares_build.h
check:
install:
${top_srcdir}/mkinstalldirs ${DESTDIR}${libdir}
${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}
${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man3
${INSTALL} -m 644 $(LIB) ${DESTDIR}${libdir}
${RANLIB} ${DESTDIR}${libdir}/$(LIB)
chmod u-w ${DESTDIR}${libdir}/$(LIB)
${INSTALL} -m 444 ${srcdir}/ares.h ${DESTDIR}${includedir}
${INSTALL} -m 444 ${srcdir}/ares_build.h ${DESTDIR}${includedir}
${INSTALL} -m 444 ${srcdir}/ares_rules.h ${DESTDIR}${includedir}
(for man in $(MANPAGES); do \
${INSTALL} -m 444 ${srcdir}/$${man} ${DESTDIR}${mandir}/man3; \
done)
clean:
$(RM) ares_getopt.o $(OBJLIB) $(LIB) adig.exe ahost.exe acountry.exe
distclean: clean
$(RM) config.cache config.log config.status Makefile
ifeq "$(wildcard ares_build.h.dist)" "ares_build.h.dist"
$(RM) ares_build.h
endif
# Copyright (C) 2009-2013 by Daniel Stenberg
#
# Permission to use, copy, modify, and distribute this
# software and its documentation for any purpose and without
# fee is hereby granted, provided that the above copyright
# notice appear in all copies and that both that copyright
# notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in
# advertising or publicity pertaining to distribution of the
# software without specific, written prior permission.
# M.I.T. makes no representations about the suitability of
# this software for any purpose. It is provided "as is"
# without express or implied warranty.
# ------------------------------------------------------------------------------
#
# Makefile for building c-ares libraries and sample programs with MSVC.
#
# Usage: nmake /f makefile.msvc CFG=<config> <target>
#
# <config> must be one of: [ lib-release | lib-debug | dll-release | dll-debug }
# <target> must be one of: [ ALL | c-ares | acountry | adig | ahost | clean }
#
# If a <target> other than ALL or clean is given, <config> becomes mandatory.
#
# If neither <config> nor <target> are specified this results in
# all targets being built for all <config> c-ares library types.
#
# This makefile must be processed from the subdir where it is located.
#
# All results are generated below a subdirectory named msvcXXX.
#
# ------------------------------------------------------------------------------
NAME = cares
# ------------------------------------------------
# c-ares static and dynamic libraries common base
# file names for release and debug configurations
# ------------------------------------------------
STA_LIB_REL = lib$(NAME)
DYN_LIB_REL = $(NAME)
STA_LIB_DBG = $(STA_LIB_REL)d
DYN_LIB_DBG = $(DYN_LIB_REL)d
# -------------------------------------------
# Base names for c-ares DLL import libraries
# -------------------------------------------
IMP_LIB_REL = $(DYN_LIB_REL)
IMP_LIB_DBG = $(DYN_LIB_DBG)
# --------------------------
# Runtime library selection
# --------------------------
RTLIB = /MD
RTLIBD = /MDd
!IF "$(RTLIBCFG)" == "static"
RTLIB = /MT
RTLIBD = /MTd
!ENDIF
# --------------------------------------------------------
# Define USE_WATT32 to 1 to use the Watt-32 tcp/ip stack,
# otherwise Winsock tcp/ip stack will be used as default.
# --------------------------------------------------------
USE_WATT32 = 0
# -------------------------------------------
# Detect NMAKE version deducing MSVC version
# -------------------------------------------
!IFNDEF _NMAKE_VER
! MESSAGE Macro _NMAKE_VER not defined.
! MESSAGE Use MSVC's NMAKE to process this makefile.
! ERROR See previous message.
!ENDIF
!IF "$(_NMAKE_VER)" == "6.00.8168.0"
CC_VERS_NUM = 60
!ELSEIF "$(_NMAKE_VER)" == "6.00.9782.0"
CC_VERS_NUM = 60
!ELSEIF "$(_NMAKE_VER)" == "7.00.8882"
CC_VERS_NUM = 70
!ELSEIF "$(_NMAKE_VER)" == "7.00.9466"
CC_VERS_NUM = 70
!ELSEIF "$(_NMAKE_VER)" == "7.00.9955"
CC_VERS_NUM = 70
!ELSEIF "$(_NMAKE_VER)" == "7.10.2240.8"
CC_VERS_NUM = 71
!ELSEIF "$(_NMAKE_VER)" == "7.10.3077"
CC_VERS_NUM = 71
!ELSEIF "$(_NMAKE_VER)" == "8.00.40607.16"
CC_VERS_NUM = 80
!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.42"
CC_VERS_NUM = 80
!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.762"
CC_VERS_NUM = 80
!ELSEIF "$(_NMAKE_VER)" == "9.00.20706.01"
CC_VERS_NUM = 90
!ELSEIF "$(_NMAKE_VER)" == "9.00.21022.08"
CC_VERS_NUM = 90
!ELSEIF "$(_NMAKE_VER)" == "9.00.30729.01"
CC_VERS_NUM = 90
!ELSEIF "$(_NMAKE_VER)" == "10.00.20506.01"
CC_VERS_NUM = 100
!ELSEIF "$(_NMAKE_VER)" == "10.00.21003.01"
CC_VERS_NUM = 100
!ELSEIF "$(_NMAKE_VER)" == "10.00.30128.01"
CC_VERS_NUM = 100
!ELSEIF "$(_NMAKE_VER)" == "10.00.30319.01"
CC_VERS_NUM = 100
!ELSEIF "$(_NMAKE_VER)" == "10.00.40219.01"
CC_VERS_NUM = 100
!ELSEIF "$(_NMAKE_VER)" == "11.00.50522.1"
CC_VERS_NUM = 110
!ELSEIF "$(_NMAKE_VER)" == "11.00.50727.1"
CC_VERS_NUM = 110
!ELSEIF "$(_NMAKE_VER)" == "11.00.51106.1"
CC_VERS_NUM = 110
!ELSEIF "$(_NMAKE_VER)" == "11.00.60315.1"
CC_VERS_NUM = 110
!ELSE
! MESSAGE Unknown value for _NMAKE_VER macro: "$(_NMAKE_VER)"
! MESSAGE Please, report this condition on the c-ares development
! MESSAGE mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/
! ERROR See previous message.
!ENDIF
CC_VERS_STR = msvc$(CC_VERS_NUM)
# ----------------------------------------------------
# Verify that current subdir is the c-ares source one
# ----------------------------------------------------
!IF ! EXIST(.\ares_init.c)
! MESSAGE Can not process Makefile.msvc from outside of c-ares source subdirectory.
! MESSAGE Change to the subdirectory where Makefile.msvc is found, and try again.
! ERROR See previous message.
!ENDIF
# ------------------------------------------------------------------
# Base subdir is the common root from which other subdirs will hang,
# the name depends on MSVC version being used when building c-ares.
# ------------------------------------------------------------------
BASE_DIR = .\$(CC_VERS_STR)
# ----------------------------------------
# Subdir holding sources for all projects
# ----------------------------------------
SRCDIR = .
# -----------------------------
# Default installation subdirs
# -----------------------------
!IFNDEF INSTALL_DIR
INSTALL_DIR = .
!ENDIF
!IFNDEF INSTALL_DIR_LIB
INSTALL_DIR_LIB = $(INSTALL_DIR)\lib
!ENDIF
!IFNDEF INSTALL_DIR_INC
INSTALL_DIR_INC = $(INSTALL_DIR)\include
!ENDIF
# -------------------------
# Configuration validation
# -------------------------
VALID_CFGSET = FALSE
!IF "$(CFG)" == "lib-release" || "$(CFG)" == "lib-debug" || \
"$(CFG)" == "dll-release" || "$(CFG)" == "dll-debug"
VALID_CFGSET = TRUE
!ENDIF
!IF "$(VALID_CFGSET)" == "FALSE" && "$(CFG)" != ""
! MESSAGE MSVC c-ares makefile
! MESSAGE
! MESSAGE Usage: nmake /f makefile.msvc CFG=<config> <target>
! MESSAGE
! MESSAGE <config> must be one of: [ lib-release | lib-debug | dll-release | dll-debug }
! MESSAGE <target> must be one of: [ ALL | c-ares | acountry | adig | ahost | clean }
! MESSAGE
! MESSAGE If a <target> other than ALL or clean is given, <config> becomes mandatory.
! MESSAGE
! MESSAGE If neither <config> nor <target> are specified this results in
! MESSAGE all targets being built for all <config> c-ares library types.
! MESSAGE
! ERROR Choose a valid configuration.
!ENDIF
# --------------------------------------------------------
# Project subdirs independent of configuration being used
# --------------------------------------------------------
CARES_DIR = $(BASE_DIR)\cares
PROG1_DIR = $(BASE_DIR)\acountry
PROG2_DIR = $(BASE_DIR)\adig
PROG3_DIR = $(BASE_DIR)\ahost
# ---------------------------------------------------
# Subdirs which are configuration dependent are only
# defined when a valid configuration has been given.
# ---------------------------------------------------
!IF "$(VALID_CFGSET)" == "TRUE"
CARES_OUTDIR = $(CARES_DIR)\$(CFG)
PROG1_OUTDIR = $(PROG1_DIR)\$(CFG)
PROG2_OUTDIR = $(PROG2_DIR)\$(CFG)
PROG3_OUTDIR = $(PROG3_DIR)\$(CFG)
CARES_OBJDIR = $(CARES_OUTDIR)\obj
PROG1_OBJDIR = $(PROG1_OUTDIR)\obj
PROG2_OBJDIR = $(PROG2_OUTDIR)\obj
PROG3_OBJDIR = $(PROG3_OUTDIR)\obj
!ELSE
!UNDEF CARES_OUTDIR
!UNDEF PROG1_OUTDIR
!UNDEF PROG2_OUTDIR
!UNDEF PROG3_OUTDIR
!UNDEF CARES_OBJDIR
!UNDEF PROG1_OBJDIR
!UNDEF PROG2_OBJDIR
!UNDEF PROG3_OBJDIR
!ENDIF
# -------------------------------------
# Settings that depend on tcp/ip stack
# -------------------------------------
!IF "$(USE_WATT32)" == "1"
CFLAGS = /UWIN32 /DWATT32 /I$(WATT_ROOT)\inc
EX_LIBS_REL = $(WATT_ROOT)\lib\wattcpvc_imp.lib
EX_LIBS_DBG = $(WATT_ROOT)\lib\wattcpvc_imp_d.lib
!ELSE
CFLAGS = /DWIN32
EX_LIBS_REL = ws2_32.lib advapi32.lib kernel32.lib
EX_LIBS_DBG = ws2_32.lib advapi32.lib kernel32.lib
!ENDIF
# -----------------------------------------
# Switches that depend on compiler version
# -----------------------------------------
!IF $(CC_VERS_NUM) == 60
PDB_NONE = /pdb:none
PDBTYPE_CONSOLIDATE = /pdbtype:consolidate
!ELSE
!UNDEF PDB_NONE
!UNDEF PDBTYPE_CONSOLIDATE
!ENDIF
!IF $(CC_VERS_NUM) <= 70
RT_ERROR_CHECKING = /GZ
!ELSE
RT_ERROR_CHECKING = /RTCsu
!ENDIF
# ----------------------------
# Assorted commands and flags
# ----------------------------
CC_CMD_REL = cl.exe /nologo $(RTLIB) /DNDEBUG /O2
CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi $(RT_ERROR_CHECKING)
CC_CFLAGS = $(CFLAGS) /I. /W3 /EHsc /FD
RC_CMD_REL = rc.exe /l 0x409 /d "NDEBUG"
RC_CMD_DBG = rc.exe /l 0x409 /d "_DEBUG"
LINK_CMD_LIB = link.exe /lib /nologo
LINK_CMD_DLL = link.exe /dll /nologo /incremental:no /fixed:no
LINK_CMD_EXE = link.exe /nologo /incremental:no /fixed:no /subsystem:console
LINK_CMD_EXE_REL = $(LINK_CMD_EXE) /release $(PDB_NONE)
LINK_CMD_EXE_DBG = $(LINK_CMD_EXE) /debug $(PDBTYPE_CONSOLIDATE)
# ---------------------------------
# Configuration dependent settings
# ---------------------------------
!IF "$(CFG)" == "lib-release"
CARES_TARGET = $(STA_LIB_REL).lib
CARES_CFLAGS = /DCARES_BUILDING_LIBRARY /DCARES_STATICLIB
CARES_LFLAGS =
SPROG_CFLAGS = /DCARES_STATICLIB
SPROG_LFLAGS = /libpath:$(CARES_OUTDIR) $(EX_LIBS_REL) $(STA_LIB_REL).lib
CARES_LINK = $(LINK_CMD_LIB)
SPROG_LINK = $(LINK_CMD_EXE_REL)
CC_CMD = $(CC_CMD_REL)
!ENDIF
!IF "$(CFG)" == "lib-debug"
CARES_TARGET = $(STA_LIB_DBG).lib
CARES_CFLAGS = /DCARES_BUILDING_LIBRARY /DCARES_STATICLIB /DDEBUGBUILD
CARES_LFLAGS =
SPROG_CFLAGS = /DCARES_STATICLIB
SPROG_LFLAGS = /libpath:$(CARES_OUTDIR) $(EX_LIBS_DBG) $(STA_LIB_DBG).lib
CARES_LINK = $(LINK_CMD_LIB)
SPROG_LINK = $(LINK_CMD_EXE_DBG)
CC_CMD = $(CC_CMD_DBG)
!ENDIF
!IF "$(CFG)" == "dll-release"
CARES_TARGET = $(DYN_LIB_REL).dll
CARES_CFLAGS = /DCARES_BUILDING_LIBRARY
CARES_LFLAGS = /release $(EX_LIBS_REL) /implib:$(CARES_OUTDIR)\$(IMP_LIB_REL).lib $(PDB_NONE)
SPROG_CFLAGS =
SPROG_LFLAGS = /libpath:$(CARES_OUTDIR) $(EX_LIBS_REL) $(IMP_LIB_REL).lib
CARES_LINK = $(LINK_CMD_DLL)
SPROG_LINK = $(LINK_CMD_EXE_REL)
CC_CMD = $(CC_CMD_REL)
USE_RES_FILE = TRUE
RC_CMD = $(RC_CMD_REL)
!ENDIF
!IF "$(CFG)" == "dll-debug"
CARES_TARGET = $(DYN_LIB_DBG).dll
CARES_CFLAGS = /DCARES_BUILDING_LIBRARY /DDEBUGBUILD
CARES_LFLAGS = /debug $(EX_LIBS_DBG) /implib:$(CARES_OUTDIR)\$(IMP_LIB_DBG).lib /pdb:$(CARES_OUTDIR)\$(DYN_LIB_DBG).pdb $(PDBTYPE_CONSOLIDATE)
SPROG_CFLAGS =
SPROG_LFLAGS = /libpath:$(CARES_OUTDIR) $(EX_LIBS_DBG) $(IMP_LIB_DBG).lib
CARES_LINK = $(LINK_CMD_DLL)
SPROG_LINK = $(LINK_CMD_EXE_DBG)
CC_CMD = $(CC_CMD_DBG)
USE_RES_FILE = TRUE
RC_CMD = $(RC_CMD_DBG)
!ENDIF
# --------------------------------------------
# Makefile.inc provides lists of source files
# --------------------------------------------
!INCLUDE .\Makefile.inc
# ----------------------------
# Build lists of object files
# ----------------------------
!IF "$(VALID_CFGSET)" == "TRUE"
!IF [ECHO CARES_OBJS=^$(CARES_OBJDIR)\$(CSOURCES: = $(CARES_OBJDIR^)\) > .\cares_objs.inc] == 0
!INCLUDE .\cares_objs.inc
!IF [DEL .\cares_objs.inc]
!ENDIF
!ELSE
!ERROR Problem generating CARES_OBJS list.
!ENDIF
CARES_OBJS = $(CARES_OBJS:.c=.obj)
!IF "$(USE_RES_FILE)" == "TRUE"
CARES_OBJS = $(CARES_OBJS) $(CARES_OBJDIR)\cares.res
!ENDIF
!IF [ECHO PROG1_OBJS=^$(PROG1_OBJDIR)\$(SAMPLESOURCES: = $(PROG1_OBJDIR^)\) > .\prog1_objs.inc] == 0
!INCLUDE .\prog1_objs.inc
!IF [DEL .\prog1_objs.inc]
!ENDIF
!ELSE
!ERROR Problem generating PROG1_OBJS list.
!ENDIF
PROG1_OBJS = $(PROG1_OBJS:.c=.obj)
PROG1_OBJS = $(PROG1_OBJS) $(PROG1_OBJDIR)\acountry.obj
!IF [ECHO PROG2_OBJS=^$(PROG2_OBJDIR)\$(SAMPLESOURCES: = $(PROG2_OBJDIR^)\) > .\prog2_objs.inc] == 0
!INCLUDE .\prog2_objs.inc
!IF [DEL .\prog2_objs.inc]
!ENDIF
!ELSE
!ERROR Problem generating PROG2_OBJS list.
!ENDIF
PROG2_OBJS = $(PROG2_OBJS:.c=.obj)
PROG2_OBJS = $(PROG2_OBJS) $(PROG2_OBJDIR)\adig.obj
!IF [ECHO PROG3_OBJS=^$(PROG3_OBJDIR)\$(SAMPLESOURCES: = $(PROG3_OBJDIR^)\) > .\prog3_objs.inc] == 0
!INCLUDE .\prog3_objs.inc
!IF [DEL .\prog3_objs.inc]
!ENDIF
!ELSE
!ERROR Problem generating PROG3_OBJS list.
!ENDIF
PROG3_OBJS = $(PROG3_OBJS:.c=.obj)
PROG3_OBJS = $(PROG3_OBJS) $(PROG3_OBJDIR)\ahost.obj
!ENDIF
# --------------------------------
# Only our custom inference rules
# --------------------------------
.SUFFIXES:
.SUFFIXES: .c .rc
{$(SRCDIR)}.rc{$(CARES_OBJDIR)}.res:
$(RC_CMD) /Fo $@ $<
{$(SRCDIR)}.c{$(CARES_OBJDIR)}.obj:
$(CC_CMD) $(CC_CFLAGS) $(CARES_CFLAGS) /Fo$@ /Fd$(@D)\ /c $<
{$(SRCDIR)}.c{$(PROG1_OBJDIR)}.obj:
$(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$@ /Fd$(@D)\ /c $<
{$(SRCDIR)}.c{$(PROG2_OBJDIR)}.obj:
$(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$@ /Fd$(@D)\ /c $<
{$(SRCDIR)}.c{$(PROG3_OBJDIR)}.obj:
$(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$@ /Fd$(@D)\ /c $<
# ------------------------------------------------------------- #
# ------------------------------------------------------------- #
# Default target when no CFG library type has been specified, #
# results in building target ALL for all c-ares library types. #
# ------------------------------------------------------------- #
# ------------------------------------------------------------- #
!IF "$(VALID_CFGSET)" == "FALSE"
ALL:
$(MAKE) /f .\Makefile.msvc CFG=lib-release ALL
$(MAKE) /f .\Makefile.msvc CFG=lib-debug ALL
$(MAKE) /f .\Makefile.msvc CFG=dll-release ALL
$(MAKE) /f .\Makefile.msvc CFG=dll-debug ALL
clean:
@-RMDIR /S /Q $(BASE_DIR) >NUL 2>&1
install:
@$(MAKE) /nologo /f .\Makefile.msvc CFG=lib-release install
@$(MAKE) /nologo /f .\Makefile.msvc CFG=lib-debug install
@$(MAKE) /nologo /f .\Makefile.msvc CFG=dll-release install
@$(MAKE) /nologo /f .\Makefile.msvc CFG=dll-debug install
!ENDIF
# ---------------------------------------------------------------------
# Targets only available when a proper CFG library type has been given
# ---------------------------------------------------------------------
!IF "$(VALID_CFGSET)" == "TRUE"
ALL: c-ares acountry adig ahost
@
c-ares: $(HHEADERS) $(CSOURCES) $(CARES_OBJDIR) $(CARES_OBJS) $(CARES_OUTDIR)
$(CARES_LINK) $(CARES_LFLAGS) /out:$(CARES_OUTDIR)\$(CARES_TARGET) $(CARES_OBJS)
! IF "$(USE_RES_FILE)" == "TRUE"
@if exist $(CARES_OUTDIR)\$(CARES_TARGET).manifest mt -nologo -manifest $(CARES_OUTDIR)\$(CARES_TARGET).manifest -outputresource:$(CARES_OUTDIR)\$(CARES_TARGET);2
! ENDIF
acountry: c-ares acountry.c $(SAMPLESOURCES) $(SAMPLEHEADERS) $(PROG1_OBJDIR) $(PROG1_OBJS) $(PROG1_OUTDIR)
$(SPROG_LINK) $(SPROG_LFLAGS) /out:$(PROG1_OUTDIR)\acountry.exe $(PROG1_OBJS)
@if exist $(PROG1_OUTDIR)\acountry.exe.manifest mt -nologo -manifest $(PROG1_OUTDIR)\acountry.exe.manifest -outputresource:$(PROG1_OUTDIR)\acountry.exe;1
adig: c-ares adig.c $(SAMPLESOURCES) $(SAMPLEHEADERS) $(PROG2_OBJDIR) $(PROG2_OBJS) $(PROG2_OUTDIR)
$(SPROG_LINK) $(SPROG_LFLAGS) /out:$(PROG2_OUTDIR)\adig.exe $(PROG2_OBJS)
@if exist $(PROG2_OUTDIR)\adig.exe.manifest mt -nologo -manifest $(PROG2_OUTDIR)\adig.exe.manifest -outputresource:$(PROG2_OUTDIR)\adig.exe;1
ahost: c-ares ahost.c $(SAMPLESOURCES) $(SAMPLEHEADERS) $(PROG3_OBJDIR) $(PROG3_OBJS) $(PROG3_OUTDIR)
$(SPROG_LINK) $(SPROG_LFLAGS) /out:$(PROG3_OUTDIR)\ahost.exe $(PROG3_OBJS)
@if exist $(PROG3_OUTDIR)\ahost.exe.manifest mt -nologo -manifest $(PROG3_OUTDIR)\ahost.exe.manifest -outputresource:$(PROG3_OUTDIR)\ahost.exe;1
$(CARES_OUTDIR): $(CARES_DIR)
@if not exist $(CARES_OUTDIR) mkdir $(CARES_OUTDIR)
$(PROG1_OUTDIR): $(PROG1_DIR)
@if not exist $(PROG1_OUTDIR) mkdir $(PROG1_OUTDIR)
$(PROG2_OUTDIR): $(PROG2_DIR)
@if not exist $(PROG2_OUTDIR) mkdir $(PROG2_OUTDIR)
$(PROG3_OUTDIR): $(PROG3_DIR)
@if not exist $(PROG3_OUTDIR) mkdir $(PROG3_OUTDIR)
$(CARES_OBJDIR): $(CARES_OUTDIR)
@if not exist $(CARES_OBJDIR) mkdir $(CARES_OBJDIR)
$(PROG1_OBJDIR): $(PROG1_OUTDIR)
@if not exist $(PROG1_OBJDIR) mkdir $(PROG1_OBJDIR)
$(PROG2_OBJDIR): $(PROG2_OUTDIR)
@if not exist $(PROG2_OBJDIR) mkdir $(PROG2_OBJDIR)
$(PROG3_OBJDIR): $(PROG3_OUTDIR)
@if not exist $(PROG3_OBJDIR) mkdir $(PROG3_OBJDIR)
clean:
@-RMDIR /S /Q $(CARES_OUTDIR) >NUL 2>&1
@-RMDIR /S /Q $(PROG1_OUTDIR) >NUL 2>&1
@-RMDIR /S /Q $(PROG2_OUTDIR) >NUL 2>&1
@-RMDIR /S /Q $(PROG3_OUTDIR) >NUL 2>&1
install:
@if not exist $(CARES_OUTDIR)\$(CARES_TARGET) \
$(MAKE) /f .\Makefile.msvc CFG=$(CFG) c-ares
@if not exist "$(INSTALL_DIR)" mkdir "$(INSTALL_DIR)"
@if not exist "$(INSTALL_DIR_LIB)" mkdir "$(INSTALL_DIR_LIB)"
@if not exist "$(INSTALL_DIR_INC)" mkdir "$(INSTALL_DIR_INC)"
@copy /y $(CARES_OUTDIR)\*.* "$(INSTALL_DIR_LIB)" >NUL
@copy /y $(SRCDIR)\ares.h "$(INSTALL_DIR_INC)" >NUL
@copy /y $(SRCDIR)\ares_build.h "$(INSTALL_DIR_INC)" >NUL
@copy /y $(SRCDIR)\ares_rules.h "$(INSTALL_DIR_INC)" >NUL
@copy /y $(SRCDIR)\ares_version.h "$(INSTALL_DIR_INC)" >NUL
@echo Installed c-ares $(CFG)
!ENDIF
$(BASE_DIR):
@if not exist $(BASE_DIR) mkdir $(BASE_DIR)
$(CARES_DIR): $(BASE_DIR)
@if not exist $(CARES_DIR) mkdir $(CARES_DIR)
$(PROG1_DIR): $(BASE_DIR)
@if not exist $(PROG1_DIR) mkdir $(PROG1_DIR)
$(PROG2_DIR): $(BASE_DIR)
@if not exist $(PROG2_DIR) mkdir $(PROG2_DIR)
$(PROG3_DIR): $(BASE_DIR)
@if not exist $(PROG3_DIR) mkdir $(PROG3_DIR)
# End of Makefile.msvc
#################################################################
#
## Makefile for building libcares (NetWare version - gnu make)
## Use: make -f Makefile.netware
##
## Comments to: Guenter Knauf http://www.gknw.de/phpbb
#
#################################################################
# Edit the path below to point to the base of your Novell NDK.
ifndef NDKBASE
NDKBASE = c:/novell
endif
ifndef INSTDIR
INSTDIR = ../ares-$(LIBCARES_VERSION_STR)-bin-nw
endif
# Edit the vars below to change NLM target settings.
TARGETS = adig.nlm ahost.nlm acountry.nlm
LTARGET = libcares.$(LIBEXT)
VERSION = $(LIBCARES_VERSION)
COPYR = $(LIBCARES_COPYRIGHT_STR)
DESCR = cURL $(subst .def,,$(notdir $@)) $(LIBCARES_VERSION_STR) - http://curl.haxx.se
MTSAFE = YES
STACK = 64000
SCREEN = none
#EXPORTS =
# Comment the line below if you dont want to load protected automatically.
#LDRING = 3
# Edit the var below to point to your lib architecture.
ifndef LIBARCH
LIBARCH = LIBC
endif
# must be equal to NDEBUG or DEBUG, CURLDEBUG
ifndef DB
DB = NDEBUG
endif
# Optimization: -O<n> or debugging: -g
ifeq ($(DB),NDEBUG)
OPT = -O2
OBJDIR = release
else
OPT = -g
OBJDIR = debug
endif
# Include the version info retrieved from curlver.h
-include $(OBJDIR)/version.inc
# The following lines defines your compiler.
ifdef CWFolder
METROWERKS = $(CWFolder)
endif
ifdef METROWERKS
# MWCW_PATH = $(subst \,/,$(METROWERKS))/Novell Support
MWCW_PATH = $(subst \,/,$(METROWERKS))/Novell Support/Metrowerks Support
CC = mwccnlm
else
CC = gcc
endif
# a native win32 awk can be downloaded from here:
# http://www.gknw.net/development/prgtools/awk-20070501.zip
AWK = awk
YACC = bison -y
CP = cp -afv
MKDIR = mkdir
# RM = rm -f
# if you want to mark the target as MTSAFE you will need a tool for
# generating the xdc data for the linker; here's a minimal tool:
# http://www.gknw.net/development/prgtools/mkxdc.zip
MPKXDC = mkxdc
# Global flags for all compilers
CFLAGS += $(OPT) -D$(DB) -DNETWARE -DHAVE_CONFIG_H -nostdinc
ifeq ($(CC),mwccnlm)
LD = mwldnlm
LDFLAGS = -nostdlib $(PRELUDE) $(OBJEXE) $(<:.def=.o) -o $@ -commandfile
AR = mwldnlm
ARFLAGS = -nostdlib -type library -o
LIBEXT = lib
#RANLIB =
CFLAGS += -msgstyle gcc -gccinc -inline off -opt nointrinsics -proc 586
CFLAGS += -relax_pointers
#CFLAGS += -w on
ifeq ($(LIBARCH),LIBC)
PRELUDE = $(SDK_LIBC)/imports/libcpre.o
CFLAGS += -align 4
else
# PRELUDE = $(SDK_CLIB)/imports/clibpre.o
# to avoid the __init_* / __deinit_* whoes dont use prelude from NDK
PRELUDE = "$(MWCW_PATH)/libraries/runtime/prelude.obj"
# CFLAGS += -include "$(MWCW_PATH)/headers/nlm_clib_prefix.h"
CFLAGS += -align 1
endif
else
LD = nlmconv
LDFLAGS = -T
AR = ar
ARFLAGS = -cq
LIBEXT = a
RANLIB = ranlib
CFLAGS += -m32
CFLAGS += -fno-builtin -fno-strict-aliasing
ifeq ($(findstring gcc,$(CC)),gcc)
CFLAGS += -fpcc-struct-return
endif
CFLAGS += -Wall # -pedantic
ifeq ($(LIBARCH),LIBC)
PRELUDE = $(SDK_LIBC)/imports/libcpre.gcc.o
else
# PRELUDE = $(SDK_CLIB)/imports/clibpre.gcc.o
# to avoid the __init_* / __deinit_* whoes dont use prelude from NDK
# http://www.gknw.net/development/mk_nlm/gcc_pre.zip
PRELUDE = $(NDK_ROOT)/pre/prelude.o
CFLAGS += -include $(NDKBASE)/nlmconv/genlm.h
endif
endif
NDK_ROOT = $(NDKBASE)/ndk
SDK_CLIB = $(NDK_ROOT)/nwsdk
SDK_LIBC = $(NDK_ROOT)/libc
ifeq ($(LIBARCH),LIBC)
INCLUDES += -I$(SDK_LIBC)/include
# INCLUDES += -I$(SDK_LIBC)/include/nks
# INCLUDES += -I$(SDK_LIBC)/include/winsock
CFLAGS += -D_POSIX_SOURCE
else
INCLUDES += -I$(SDK_CLIB)/include/nlm
# INCLUDES += -I$(SDK_CLIB)/include/nlm/obsolete
# INCLUDES += -I$(SDK_CLIB)/include
endif
ifeq ($(DB),CURLDEBUG)
INCLUDES += -I../include
endif
CFLAGS += -I. $(INCLUDES)
ifeq ($(MTSAFE),YES)
XDCOPT = -n
endif
ifeq ($(MTSAFE),NO)
XDCOPT = -u
endif
ifeq ($(findstring /sh,$(SHELL)),/sh)
DL = '
#-include $(NDKBASE)/nlmconv/ncpfs.inc
endif
# Makefile.inc provides the CSOURCES and HHEADERS defines
include Makefile.inc
OBJLIB := $(patsubst %.c,$(OBJDIR)/%.o,$(strip $(CSOURCES)))
OBJEXE = $(OBJLIB) $(OBJDIR)/ares_getopt.o
.PHONY: lib nlm prebuild dist install clean
lib: prebuild $(LTARGET)
nlm: prebuild $(TARGETS)
prebuild: $(OBJDIR) ares_build.h $(OBJDIR)/version.inc ares_config.h
install: $(INSTDIR) all
@$(CP) *.nlm $(INSTDIR)
@$(CP) ../CHANGES $(INSTDIR)
@$(CP) ../COPYING $(INSTDIR)
@$(CP) ../README $(INSTDIR)
@$(CP) ../RELEASE-NOTES $(INSTDIR)
clean:
-$(RM) $(LTARGET) $(TARGETS) ares_config.h
-$(RM) -r $(OBJDIR)
-$(RM) -r arpa
%.$(LIBEXT): $(OBJLIB)
@echo Creating $@
@-$(RM) $@
@$(AR) $(ARFLAGS) $@ $^
ifdef RANLIB
@$(RANLIB) $@
endif
%.nlm: $(OBJDIR)/%.def $(OBJDIR)/%.o $(OBJDIR)/%.xdc $(OBJEXE)
@echo Linking $@
@-$(RM) $@
@$(LD) $(LDFLAGS) $<
$(OBJDIR) $(INSTDIR):
@$(MKDIR) $@
$(OBJDIR)/%.o: %.c
# @echo Compiling $<
$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR)/version.inc: ares_version.h $(OBJDIR)
@echo Creating $@
@$(AWK) -f get_ver.awk $< > $@
$(OBJDIR)/%.xdc: Makefile.netware
@echo Creating $@
@$(MPKXDC) $(XDCOPT) $@
$(OBJDIR)/%.def: Makefile.netware
@echo Creating $@
@echo $(DL)# DEF file for linking with $(LD)$(DL) > $@
@echo $(DL)# Do not edit this file - it is created by make!$(DL) >> $@
@echo $(DL)# All your changes will be lost!!$(DL) >> $@
@echo $(DL)#$(DL) >> $@
@echo $(DL)copyright "$(COPYR)"$(DL) >> $@
@echo $(DL)description "$(DESCR)"$(DL) >> $@
@echo $(DL)version $(VERSION)$(DL) >> $@
ifdef NLMTYPE
@echo $(DL)type $(NLMTYPE)$(DL) >> $@
endif
ifdef STACK
@echo $(DL)stack $(STACK)$(DL) >> $@
endif
ifdef SCREEN
@echo $(DL)screenname "$(SCREEN)"$(DL) >> $@
else
@echo $(DL)screenname "DEFAULT"$(DL) >> $@
endif
ifeq ($(DB),DEBUG)
@echo $(DL)debug$(DL) >> $@
endif
@echo $(DL)threadname "$^"$(DL) >> $@
ifdef XDCOPT
@echo $(DL)xdcdata $(@:.def=.xdc)$(DL) >> $@
endif
ifeq ($(LDRING),0)
@echo $(DL)flag_on 16$(DL) >> $@
endif
ifeq ($(LDRING),3)
@echo $(DL)flag_on 512$(DL) >> $@
endif
ifeq ($(LIBARCH),CLIB)
@echo $(DL)start _Prelude$(DL) >> $@
@echo $(DL)exit _Stop$(DL) >> $@
@echo $(DL)import @$(SDK_CLIB)/imports/clib.imp$(DL) >> $@
@echo $(DL)import @$(SDK_CLIB)/imports/threads.imp$(DL) >> $@
@echo $(DL)import @$(SDK_CLIB)/imports/nlmlib.imp$(DL) >> $@
@echo $(DL)import @$(SDK_CLIB)/imports/socklib.imp$(DL) >> $@
@echo $(DL)module clib$(DL) >> $@
else
@echo $(DL)flag_on 64$(DL) >> $@
@echo $(DL)pseudopreemption$(DL) >> $@
@echo $(DL)start _LibCPrelude$(DL) >> $@
@echo $(DL)exit _LibCPostlude$(DL) >> $@
@echo $(DL)check _LibCCheckUnload$(DL) >> $@
@echo $(DL)import @$(SDK_LIBC)/imports/libc.imp$(DL) >> $@
@echo $(DL)import @$(SDK_LIBC)/imports/netware.imp$(DL) >> $@
@echo $(DL)module libc$(DL) >> $@
endif
ifdef MODULES
@echo $(DL)module $(MODULES)$(DL) >> $@
endif
ifdef EXPORTS
@echo $(DL)export $(EXPORTS)$(DL) >> $@
endif
ifdef IMPORTS
@echo $(DL)import $(IMPORTS)$(DL) >> $@
endif
ifeq ($(LD),nlmconv)
@echo $(DL)input $(PRELUDE)$(DL) >> $@
@echo $(DL)input $(OBJEXE)$(DL) >> $@
@echo $(DL)input $(@:.def=.o)$(DL) >> $@
@echo $(DL)output $(notdir $(@:.def=.nlm))$(DL) >> $@
endif
ares_config.h: Makefile.netware
@echo Creating $@
@echo $(DL)/* $@ for NetWare target.$(DL) > $@
@echo $(DL)** Do not edit this file - it is created by make!$(DL) >> $@
@echo $(DL)** All your changes will be lost!!$(DL) >> $@
@echo $(DL)*/$(DL) >> $@
@echo $(DL)#ifndef NETWARE$(DL) >> $@
@echo $(DL)#error This $(notdir $@) is created for NetWare platform!$(DL) >> $@
@echo $(DL)#endif$(DL) >> $@
@echo $(DL)#define VERSION "$(LIBCARES_VERSION_STR)"$(DL) >> $@
@echo $(DL)#define PACKAGE_BUGREPORT "a suitable curl mailing list => http://curl.haxx.se/mail/"$(DL) >> $@
ifeq ($(LIBARCH),CLIB)
@echo $(DL)#define OS "i586-pc-clib-NetWare"$(DL) >> $@
@echo $(DL)#define HAVE_STRICMP 1$(DL) >> $@
@echo $(DL)#define HAVE_STRNICMP 1$(DL) >> $@
@echo $(DL)#define NETDB_USE_INTERNET 1$(DL) >> $@
@echo $(DL)#define RECV_TYPE_ARG1 int$(DL) >> $@
@echo $(DL)#define RECV_TYPE_ARG2 char *$(DL) >> $@
@echo $(DL)#define RECV_TYPE_ARG3 int$(DL) >> $@
@echo $(DL)#define RECV_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define RECV_TYPE_RETV int$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG1 int$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG2 char$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG3 int$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG5 struct sockaddr$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG6 int$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_RETV int$(DL) >> $@
@echo $(DL)#define SEND_QUAL_ARG2$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG1 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG2 char *$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
@echo $(DL)#define SIZEOF_SIZE_T 4$(DL) >> $@
else
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
@echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
@echo $(DL)#define HAVE_DLOPEN 1$(DL) >> $@
@echo $(DL)#define HAVE_FTRUNCATE 1$(DL) >> $@
@echo $(DL)#define HAVE_GETTIMEOFDAY 1$(DL) >> $@
@echo $(DL)#define HAVE_INTTYPES_H 1$(DL) >> $@
@echo $(DL)#define HAVE_LONGLONG 1$(DL) >> $@
@echo $(DL)#define HAVE_STDINT_H 1$(DL) >> $@
@echo $(DL)#define HAVE_STRCASECMP 1$(DL) >> $@
@echo $(DL)#define HAVE_STRLCAT 1$(DL) >> $@
@echo $(DL)#define HAVE_STRLCPY 1$(DL) >> $@
@echo $(DL)#define HAVE_STRTOLL 1$(DL) >> $@
@echo $(DL)#define HAVE_SYS_PARAM_H 1$(DL) >> $@
@echo $(DL)#define HAVE_SYS_SELECT_H 1$(DL) >> $@
@echo $(DL)#define HAVE_TERMIOS_H 1$(DL) >> $@
@echo $(DL)#define HAVE_AF_INET6 1$(DL) >> $@
@echo $(DL)#define HAVE_PF_INET6 1$(DL) >> $@
@echo $(DL)#define HAVE_FREEADDRINFO 1$(DL) >> $@
@echo $(DL)#define HAVE_GETADDRINFO 1$(DL) >> $@
@echo $(DL)#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1$(DL) >> $@
@echo $(DL)#define HAVE_STRUCT_IN6_ADDR 1$(DL) >> $@
@echo $(DL)#define HAVE_STRUCT_SOCKADDR_IN6 1$(DL) >> $@
@echo $(DL)#define RECV_TYPE_ARG1 int$(DL) >> $@
@echo $(DL)#define RECV_TYPE_ARG2 void *$(DL) >> $@
@echo $(DL)#define RECV_TYPE_ARG3 size_t$(DL) >> $@
@echo $(DL)#define RECV_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define RECV_TYPE_RETV ssize_t$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG1 int$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG2 void$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG3 size_t$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG5 struct sockaddr$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG6 size_t$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_RETV ssize_t$(DL) >> $@
@echo $(DL)#define RECVFROM_TYPE_ARG2_IS_VOID 1$(DL) >> $@
@echo $(DL)#define SEND_QUAL_ARG2$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG1 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG2 void *$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG3 size_t$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_RETV ssize_t$(DL) >> $@
@echo $(DL)#define SIZEOF_SIZE_T 8$(DL) >> $@
@echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
endif
@echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
@echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
@echo $(DL)#define HAVE_ERRNO_H 1$(DL) >> $@
@echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
@echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
@echo $(DL)#define HAVE_GETENV 1$(DL) >> $@
@echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@
@echo $(DL)#define HAVE_GETHOSTBYNAME 1$(DL) >> $@
@echo $(DL)#define HAVE_GETHOSTNAME 1$(DL) >> $@
@echo $(DL)#define HAVE_GETPROTOBYNAME 1$(DL) >> $@
@echo $(DL)#define HAVE_GMTIME_R 1$(DL) >> $@
@echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@
@echo $(DL)#define HAVE_IOCTL 1$(DL) >> $@
@echo $(DL)#define HAVE_IOCTL_FIONBIO 1$(DL) >> $@
@echo $(DL)#define HAVE_LIMITS_H 1$(DL) >> $@
@echo $(DL)#define HAVE_LL 1$(DL) >> $@
@echo $(DL)#define HAVE_LOCALTIME_R 1$(DL) >> $@
@echo $(DL)#define HAVE_MALLOC_H 1$(DL) >> $@
@echo $(DL)#define HAVE_NETINET_IN_H 1$(DL) >> $@
@echo $(DL)#define HAVE_RECV 1$(DL) >> $@
@echo $(DL)#define HAVE_RECVFROM 1$(DL) >> $@
@echo $(DL)#define HAVE_SELECT 1$(DL) >> $@
@echo $(DL)#define HAVE_SEND 1$(DL) >> $@
@echo $(DL)#define HAVE_SETJMP_H 1$(DL) >> $@
@echo $(DL)#define HAVE_SIGNAL 1$(DL) >> $@
@echo $(DL)#define HAVE_SIGNAL_H 1$(DL) >> $@
@echo $(DL)#define HAVE_SIG_ATOMIC_T 1$(DL) >> $@
@echo $(DL)#define HAVE_SOCKET 1$(DL) >> $@
@echo $(DL)#define HAVE_STDLIB_H 1$(DL) >> $@
@echo $(DL)#define HAVE_STRDUP 1$(DL) >> $@
@echo $(DL)#define HAVE_STRFTIME 1$(DL) >> $@
@echo $(DL)#define HAVE_STRING_H 1$(DL) >> $@
@echo $(DL)#define HAVE_STRSTR 1$(DL) >> $@
@echo $(DL)#define HAVE_STRUCT_ADDRINFO 1$(DL) >> $@
@echo $(DL)#define HAVE_STRUCT_TIMEVAL 1$(DL) >> $@
@echo $(DL)#define HAVE_SYS_IOCTL_H 1$(DL) >> $@
@echo $(DL)#define HAVE_SYS_STAT_H 1$(DL) >> $@
@echo $(DL)#define HAVE_SYS_TIME_H 1$(DL) >> $@
@echo $(DL)#define HAVE_TIME_H 1$(DL) >> $@
@echo $(DL)#define HAVE_UNAME 1$(DL) >> $@
@echo $(DL)#define HAVE_UNISTD_H 1$(DL) >> $@
@echo $(DL)#define HAVE_UTIME 1$(DL) >> $@
@echo $(DL)#define HAVE_UTIME_H 1$(DL) >> $@
@echo $(DL)#define HAVE_WRITEV 1$(DL) >> $@
@echo $(DL)#define RETSIGTYPE void$(DL) >> $@
@echo $(DL)#define SIZEOF_INT 4$(DL) >> $@
@echo $(DL)#define SIZEOF_SHORT 2$(DL) >> $@
@echo $(DL)#define SIZEOF_STRUCT_IN_ADDR 4$(DL) >> $@
@echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
@echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
ifdef NW_WINSOCK
@echo $(DL)#define HAVE_CLOSESOCKET 1$(DL) >> $@
else
@echo $(DL)#define HAVE_SYS_TYPES_H 1$(DL) >> $@
@echo $(DL)#define HAVE_SYS_SOCKET_H 1$(DL) >> $@
@echo $(DL)#define HAVE_SYS_SOCKIO_H 1$(DL) >> $@
@echo $(DL)#define HAVE_NETDB_H 1$(DL) >> $@
endif
@echo $(DL)#ifdef __GNUC__$(DL) >> $@
@echo $(DL)#define HAVE_VARIADIC_MACROS_GCC 1$(DL) >> $@
@echo $(DL)#else$(DL) >> $@
@echo $(DL)#define HAVE_VARIADIC_MACROS_C99 1$(DL) >> $@
@echo $(DL)#endif$(DL) >> $@
FORCE: ;
ares_build.h: Makefile.netware FORCE
@echo Creating $@
@echo $(DL)/* $@ intended for NetWare target.$(DL) > $@
@echo $(DL)** Do not edit this file - it is created by make!$(DL) >> $@
@echo $(DL)** All your changes will be lost!!$(DL) >> $@
@echo $(DL)*/$(DL) >> $@
@echo $(DL)#ifndef NETWARE$(DL) >> $@
@echo $(DL)#error This $(notdir $@) is created for NetWare platform!$(DL) >> $@
@echo $(DL)#endif$(DL) >> $@
@echo $(DL)#ifndef __CARES_BUILD_H$(DL) >> $@
@echo $(DL)#define __CARES_BUILD_H$(DL) >> $@
ifeq ($(LIBARCH),CLIB)
@echo $(DL)#define CARES_TYPEOF_ARES_SOCKLEN_T int$(DL) >> $@
@echo $(DL)#define CARES_SIZEOF_ARES_SOCKLEN_T 4$(DL) >> $@
else
@echo $(DL)#define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int$(DL) >> $@
@echo $(DL)#define CARES_SIZEOF_ARES_SOCKLEN_T 4$(DL) >> $@
endif
@echo $(DL)#define CARES_SIZEOF_LONG 4$(DL) >> $@
@echo $(DL)typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;$(DL) >> $@
@echo $(DL)#endif /* __CARES_BUILD_H */$(DL) >> $@
/*
*
* IP-address/hostname to country converter.
*
* Problem; you want to know where IP a.b.c.d is located.
*
* Use ares_gethostbyname ("d.c.b.a.zz.countries.nerd.dk")
* and get the CNAME (host->h_name). Result will be:
* CNAME = zz<CC>.countries.nerd.dk with address 127.0.x.y (ver 1) or
* CNAME = <a.b.c.d>.zz.countries.nerd.dk with address 127.0.x.y (ver 2)
*
* The 2 letter country code is in <CC> and the ISO-3166 country
* number is in x.y (number = x*256 + y). Version 2 of the protocol is missing
* the <CC> number.
*
* Ref: http://countries.nerd.dk/more.html
*
* Written by G. Vanem <gvanem@broadpark.no> 2006, 2007
*
* NB! This program may not be big-endian aware.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#include "ares_setup.h"
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#if defined(WIN32) && !defined(WATT32)
#include <winsock.h>
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#endif
#include "ares.h"
#include "ares_getopt.h"
#include "ares_nowarn.h"
#ifndef HAVE_STRDUP
# include "ares_strdup.h"
# define strdup(ptr) ares_strdup(ptr)
#endif
#ifndef HAVE_STRCASECMP
# include "ares_strcasecmp.h"
# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
#endif
#ifndef HAVE_STRNCASECMP
# include "ares_strcasecmp.h"
# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
#endif
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
static const char *usage = "acountry [-vh?] {host|addr} ...\n";
static const char nerd_fmt[] = "%u.%u.%u.%u.zz.countries.nerd.dk";
static const char *nerd_ver1 = nerd_fmt + 14;
static const char *nerd_ver2 = nerd_fmt + 11;
static int verbose = 0;
#define TRACE(fmt) do { \
if (verbose > 0) \
printf fmt ; \
} WHILE_FALSE
static void wait_ares(ares_channel channel);
static void callback(void *arg, int status, int timeouts, struct hostent *host);
static void callback2(void *arg, int status, int timeouts, struct hostent *host);
static void find_country_from_cname(const char *cname, struct in_addr addr);
static void Abort(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
exit(1);
}
int main(int argc, char **argv)
{
ares_channel channel;
int ch, status;
#if defined(WIN32) && !defined(WATT32)
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
WSADATA wsaData;
WSAStartup(wVersionRequested, &wsaData);
#endif
status = ares_library_init(ARES_LIB_INIT_ALL);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_library_init: %s\n", ares_strerror(status));
return 1;
}
while ((ch = ares_getopt(argc, argv, "dvh?")) != -1)
switch (ch)
{
case 'd':
#ifdef WATT32
dbug_init();
#endif
break;
case 'v':
verbose++;
break;
case 'h':
case '?':
default:
Abort(usage);
}
argc -= optind;
argv += optind;
if (argc < 1)
Abort(usage);
status = ares_init(&channel);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_init: %s\n", ares_strerror(status));
return 1;
}
/* Initiate the queries, one per command-line argument. */
for ( ; *argv; argv++)
{
struct in_addr addr;
char buf[100];
/* If this fails, assume '*argv' is a host-name that
* must be resolved first
*/
if (ares_inet_pton(AF_INET, *argv, &addr) != 1)
{
ares_gethostbyname(channel, *argv, AF_INET, callback2, &addr);
wait_ares(channel);
if (addr.s_addr == INADDR_NONE)
{
printf("Failed to lookup %s\n", *argv);
continue;
}
}
sprintf(buf, nerd_fmt,
(unsigned int)(addr.s_addr >> 24),
(unsigned int)((addr.s_addr >> 16) & 255),
(unsigned int)((addr.s_addr >> 8) & 255),
(unsigned int)(addr.s_addr & 255));
TRACE(("Looking up %s...", buf));
fflush(stdout);
ares_gethostbyname(channel, buf, AF_INET, callback, buf);
}
wait_ares(channel);
ares_destroy(channel);
ares_library_cleanup();
#if defined(WIN32) && !defined(WATT32)
WSACleanup();
#endif
return 0;
}
/*
* Wait for the queries to complete.
*/
static void wait_ares(ares_channel channel)
{
for (;;)
{
struct timeval *tvp, tv;
fd_set read_fds, write_fds;
int nfds;
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
nfds = ares_fds(channel, &read_fds, &write_fds);
if (nfds == 0)
break;
tvp = ares_timeout(channel, NULL, &tv);
select(nfds, &read_fds, &write_fds, NULL, tvp);
ares_process(channel, &read_fds, &write_fds);
}
}
/*
* This is the callback used when we have the IP-address of interest.
* Extract the CNAME and figure out the country-code from it.
*/
static void callback(void *arg, int status, int timeouts, struct hostent *host)
{
const char *name = (const char*)arg;
const char *cname;
char buf[20];
(void)timeouts;
if (!host || status != ARES_SUCCESS)
{
printf("Failed to lookup %s: %s\n", name, ares_strerror(status));
return;
}
TRACE(("\nFound address %s, name %s\n",
ares_inet_ntop(AF_INET,(const char*)host->h_addr,buf,sizeof(buf)),
host->h_name));
cname = host->h_name; /* CNAME gets put here */
if (!cname)
printf("Failed to get CNAME for %s\n", name);
else
find_country_from_cname(cname, *(struct in_addr*)host->h_addr);
}
/*
* This is the callback used to obtain the IP-address of the host of interest.
*/
static void callback2(void *arg, int status, int timeouts, struct hostent *host)
{
struct in_addr *addr = (struct in_addr*) arg;
(void)timeouts;
if (!host || status != ARES_SUCCESS)
memset(addr, INADDR_NONE, sizeof(*addr));
else
memcpy(addr, host->h_addr, sizeof(*addr));
}
struct search_list {
int country_number; /* ISO-3166 country number */
char short_name[3]; /* A2 short country code */
const char *long_name; /* normal country name */
};
static const struct search_list *list_lookup(int number, const struct search_list *list, int num)
{
while (num > 0 && list->long_name)
{
if (list->country_number == number)
return (list);
num--;
list++;
}
return (NULL);
}
/*
* Ref: ftp://ftp.ripe.net/iso3166-countrycodes.txt
*/
static const struct search_list country_list[] = {
{ 4, "af", "Afghanistan" },
{ 248, "ax", "land Island" },
{ 8, "al", "Albania" },
{ 12, "dz", "Algeria" },
{ 16, "as", "American Samoa" },
{ 20, "ad", "Andorra" },
{ 24, "ao", "Angola" },
{ 660, "ai", "Anguilla" },
{ 10, "aq", "Antarctica" },
{ 28, "ag", "Antigua & Barbuda" },
{ 32, "ar", "Argentina" },
{ 51, "am", "Armenia" },
{ 533, "aw", "Aruba" },
{ 36, "au", "Australia" },
{ 40, "at", "Austria" },
{ 31, "az", "Azerbaijan" },
{ 44, "bs", "Bahamas" },
{ 48, "bh", "Bahrain" },
{ 50, "bd", "Bangladesh" },
{ 52, "bb", "Barbados" },
{ 112, "by", "Belarus" },
{ 56, "be", "Belgium" },
{ 84, "bz", "Belize" },
{ 204, "bj", "Benin" },
{ 60, "bm", "Bermuda" },
{ 64, "bt", "Bhutan" },
{ 68, "bo", "Bolivia" },
{ 70, "ba", "Bosnia & Herzegowina" },
{ 72, "bw", "Botswana" },
{ 74, "bv", "Bouvet Island" },
{ 76, "br", "Brazil" },
{ 86, "io", "British Indian Ocean Territory" },
{ 96, "bn", "Brunei Darussalam" },
{ 100, "bg", "Bulgaria" },
{ 854, "bf", "Burkina Faso" },
{ 108, "bi", "Burundi" },
{ 116, "kh", "Cambodia" },
{ 120, "cm", "Cameroon" },
{ 124, "ca", "Canada" },
{ 132, "cv", "Cape Verde" },
{ 136, "ky", "Cayman Islands" },
{ 140, "cf", "Central African Republic" },
{ 148, "td", "Chad" },
{ 152, "cl", "Chile" },
{ 156, "cn", "China" },
{ 162, "cx", "Christmas Island" },
{ 166, "cc", "Cocos Islands" },
{ 170, "co", "Colombia" },
{ 174, "km", "Comoros" },
{ 178, "cg", "Congo" },
{ 180, "cd", "Congo" },
{ 184, "ck", "Cook Islands" },
{ 188, "cr", "Costa Rica" },
{ 384, "ci", "Cote d'Ivoire" },
{ 191, "hr", "Croatia" },
{ 192, "cu", "Cuba" },
{ 196, "cy", "Cyprus" },
{ 203, "cz", "Czech Republic" },
{ 208, "dk", "Denmark" },
{ 262, "dj", "Djibouti" },
{ 212, "dm", "Dominica" },
{ 214, "do", "Dominican Republic" },
{ 218, "ec", "Ecuador" },
{ 818, "eg", "Egypt" },
{ 222, "sv", "El Salvador" },
{ 226, "gq", "Equatorial Guinea" },
{ 232, "er", "Eritrea" },
{ 233, "ee", "Estonia" },
{ 231, "et", "Ethiopia" },
{ 238, "fk", "Falkland Islands" },
{ 234, "fo", "Faroe Islands" },
{ 242, "fj", "Fiji" },
{ 246, "fi", "Finland" },
{ 250, "fr", "France" },
{ 249, "fx", "France, Metropolitan" },
{ 254, "gf", "French Guiana" },
{ 258, "pf", "French Polynesia" },
{ 260, "tf", "French Southern Territories" },
{ 266, "ga", "Gabon" },
{ 270, "gm", "Gambia" },
{ 268, "ge", "Georgia" },
{ 276, "de", "Germany" },
{ 288, "gh", "Ghana" },
{ 292, "gi", "Gibraltar" },
{ 300, "gr", "Greece" },
{ 304, "gl", "Greenland" },
{ 308, "gd", "Grenada" },
{ 312, "gp", "Guadeloupe" },
{ 316, "gu", "Guam" },
{ 320, "gt", "Guatemala" },
{ 324, "gn", "Guinea" },
{ 624, "gw", "Guinea-Bissau" },
{ 328, "gy", "Guyana" },
{ 332, "ht", "Haiti" },
{ 334, "hm", "Heard & Mc Donald Islands" },
{ 336, "va", "Vatican City" },
{ 340, "hn", "Honduras" },
{ 344, "hk", "Hong kong" },
{ 348, "hu", "Hungary" },
{ 352, "is", "Iceland" },
{ 356, "in", "India" },
{ 360, "id", "Indonesia" },
{ 364, "ir", "Iran" },
{ 368, "iq", "Iraq" },
{ 372, "ie", "Ireland" },
{ 376, "il", "Israel" },
{ 380, "it", "Italy" },
{ 388, "jm", "Jamaica" },
{ 392, "jp", "Japan" },
{ 400, "jo", "Jordan" },
{ 398, "kz", "Kazakhstan" },
{ 404, "ke", "Kenya" },
{ 296, "ki", "Kiribati" },
{ 408, "kp", "Korea (north)" },
{ 410, "kr", "Korea (south)" },
{ 414, "kw", "Kuwait" },
{ 417, "kg", "Kyrgyzstan" },
{ 418, "la", "Laos" },
{ 428, "lv", "Latvia" },
{ 422, "lb", "Lebanon" },
{ 426, "ls", "Lesotho" },
{ 430, "lr", "Liberia" },
{ 434, "ly", "Libya" },
{ 438, "li", "Liechtenstein" },
{ 440, "lt", "Lithuania" },
{ 442, "lu", "Luxembourg" },
{ 446, "mo", "Macao" },
{ 807, "mk", "Macedonia" },
{ 450, "mg", "Madagascar" },
{ 454, "mw", "Malawi" },
{ 458, "my", "Malaysia" },
{ 462, "mv", "Maldives" },
{ 466, "ml", "Mali" },
{ 470, "mt", "Malta" },
{ 584, "mh", "Marshall Islands" },
{ 474, "mq", "Martinique" },
{ 478, "mr", "Mauritania" },
{ 480, "mu", "Mauritius" },
{ 175, "yt", "Mayotte" },
{ 484, "mx", "Mexico" },
{ 583, "fm", "Micronesia" },
{ 498, "md", "Moldova" },
{ 492, "mc", "Monaco" },
{ 496, "mn", "Mongolia" },
{ 500, "ms", "Montserrat" },
{ 504, "ma", "Morocco" },
{ 508, "mz", "Mozambique" },
{ 104, "mm", "Myanmar" },
{ 516, "na", "Namibia" },
{ 520, "nr", "Nauru" },
{ 524, "np", "Nepal" },
{ 528, "nl", "Netherlands" },
{ 530, "an", "Netherlands Antilles" },
{ 540, "nc", "New Caledonia" },
{ 554, "nz", "New Zealand" },
{ 558, "ni", "Nicaragua" },
{ 562, "ne", "Niger" },
{ 566, "ng", "Nigeria" },
{ 570, "nu", "Niue" },
{ 574, "nf", "Norfolk Island" },
{ 580, "mp", "Northern Mariana Islands" },
{ 578, "no", "Norway" },
{ 512, "om", "Oman" },
{ 586, "pk", "Pakistan" },
{ 585, "pw", "Palau" },
{ 275, "ps", "Palestinian Territory" },
{ 591, "pa", "Panama" },
{ 598, "pg", "Papua New Guinea" },
{ 600, "py", "Paraguay" },
{ 604, "pe", "Peru" },
{ 608, "ph", "Philippines" },
{ 612, "pn", "Pitcairn" },
{ 616, "pl", "Poland" },
{ 620, "pt", "Portugal" },
{ 630, "pr", "Puerto Rico" },
{ 634, "qa", "Qatar" },
{ 638, "re", "Reunion" },
{ 642, "ro", "Romania" },
{ 643, "ru", "Russia" },
{ 646, "rw", "Rwanda" },
{ 659, "kn", "Saint Kitts & Nevis" },
{ 662, "lc", "Saint Lucia" },
{ 670, "vc", "Saint Vincent" },
{ 882, "ws", "Samoa" },
{ 674, "sm", "San Marino" },
{ 678, "st", "Sao Tome & Principe" },
{ 682, "sa", "Saudi Arabia" },
{ 686, "sn", "Senegal" },
{ 891, "cs", "Serbia and Montenegro" },
{ 690, "sc", "Seychelles" },
{ 694, "sl", "Sierra Leone" },
{ 702, "sg", "Singapore" },
{ 703, "sk", "Slovakia" },
{ 705, "si", "Slovenia" },
{ 90, "sb", "Solomon Islands" },
{ 706, "so", "Somalia" },
{ 710, "za", "South Africa" },
{ 239, "gs", "South Georgia" },
{ 724, "es", "Spain" },
{ 144, "lk", "Sri Lanka" },
{ 654, "sh", "St. Helena" },
{ 666, "pm", "St. Pierre & Miquelon" },
{ 736, "sd", "Sudan" },
{ 740, "sr", "Suriname" },
{ 744, "sj", "Svalbard & Jan Mayen Islands" },
{ 748, "sz", "Swaziland" },
{ 752, "se", "Sweden" },
{ 756, "ch", "Switzerland" },
{ 760, "sy", "Syrian Arab Republic" },
{ 626, "tl", "Timor-Leste" },
{ 158, "tw", "Taiwan" },
{ 762, "tj", "Tajikistan" },
{ 834, "tz", "Tanzania" },
{ 764, "th", "Thailand" },
{ 768, "tg", "Togo" },
{ 772, "tk", "Tokelau" },
{ 776, "to", "Tonga" },
{ 780, "tt", "Trinidad & Tobago" },
{ 788, "tn", "Tunisia" },
{ 792, "tr", "Turkey" },
{ 795, "tm", "Turkmenistan" },
{ 796, "tc", "Turks & Caicos Islands" },
{ 798, "tv", "Tuvalu" },
{ 800, "ug", "Uganda" },
{ 804, "ua", "Ukraine" },
{ 784, "ae", "United Arab Emirates" },
{ 826, "gb", "United Kingdom" },
{ 840, "us", "United States" },
{ 581, "um", "United States Minor Outlying Islands" },
{ 858, "uy", "Uruguay" },
{ 860, "uz", "Uzbekistan" },
{ 548, "vu", "Vanuatu" },
{ 862, "ve", "Venezuela" },
{ 704, "vn", "Vietnam" },
{ 92, "vg", "Virgin Islands (British)" },
{ 850, "vi", "Virgin Islands (US)" },
{ 876, "wf", "Wallis & Futuna Islands" },
{ 732, "eh", "Western Sahara" },
{ 887, "ye", "Yemen" },
{ 894, "zm", "Zambia" },
{ 716, "zw", "Zimbabwe" }
};
/*
* Check if start of 'str' is simply an IPv4 address.
*/
#define BYTE_OK(x) ((x) >= 0 && (x) <= 255)
static int is_addr(char *str, char **end)
{
int a0, a1, a2, a3, num, rc = 0, length = 0;
num = sscanf(str,"%3d.%3d.%3d.%3d%n",&a0,&a1,&a2,&a3,&length);
if( (num == 4) &&
BYTE_OK(a0) && BYTE_OK(a1) && BYTE_OK(a2) && BYTE_OK(a3) &&
length >= (3+4))
{
rc = 1;
*end = str + length;
}
return rc;
}
/*
* Find the country-code and name from the CNAME. E.g.:
* version 1: CNAME = zzno.countries.nerd.dk with address 127.0.2.66
* yields ccode_A" = "no" and cnumber 578 (2.66).
* version 2: CNAME = <a.b.c.d>.zz.countries.nerd.dk with address 127.0.2.66
* yields cnumber 578 (2.66). ccode_A is "";
*/
static void find_country_from_cname(const char *cname, struct in_addr addr)
{
const struct search_list *country;
char ccode_A2[3], *ccopy, *dot_4;
int cnumber, z0, z1, ver_1, ver_2;
unsigned long ip;
ip = ntohl(addr.s_addr);
z0 = TOLOWER(cname[0]);
z1 = TOLOWER(cname[1]);
ccopy = strdup(cname);
dot_4 = NULL;
ver_1 = (z0 == 'z' && z1 == 'z' && !strcasecmp(cname+4,nerd_ver1));
ver_2 = (is_addr(ccopy,&dot_4) && !strcasecmp(dot_4,nerd_ver2));
if (ver_1)
{
const char *dot = strchr(cname, '.');
if ((z0 != 'z' && z1 != 'z') || dot != cname+4)
{
printf("Unexpected CNAME %s (ver_1)\n", cname);
return;
}
}
else if (ver_2)
{
z0 = TOLOWER(dot_4[1]);
z1 = TOLOWER(dot_4[2]);
if (z0 != 'z' && z1 != 'z')
{
printf("Unexpected CNAME %s (ver_2)\n", cname);
return;
}
}
else
{
printf("Unexpected CNAME %s (ver?)\n", cname);
return;
}
if (ver_1)
{
ccode_A2[0] = (char)TOLOWER(cname[2]);
ccode_A2[1] = (char)TOLOWER(cname[3]);
ccode_A2[2] = '\0';
}
else
ccode_A2[0] = '\0';
cnumber = ip & 0xFFFF;
TRACE(("Found country-code `%s', number %d\n",
ver_1 ? ccode_A2 : "<n/a>", cnumber));
country = list_lookup(cnumber, country_list,
sizeof(country_list) / sizeof(country_list[0]));
if (!country)
printf("Name for country-number %d not found.\n", cnumber);
else
{
if (ver_1)
{
if ((country->short_name[0] != ccode_A2[0]) ||
(country->short_name[1] != ccode_A2[1]) ||
(country->short_name[2] != ccode_A2[2]))
printf("short-name mismatch; %s vs %s\n",
country->short_name, ccode_A2);
}
printf("%s (%s), number %d.\n",
country->long_name, country->short_name, cnumber);
}
free(ccopy);
}
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#include "ares_setup.h"
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#else
# include "nameser.h"
#endif
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
# include <arpa/nameser_compat.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include "ares.h"
#include "ares_dns.h"
#include "ares_getopt.h"
#include "ares_nowarn.h"
#ifndef HAVE_STRDUP
# include "ares_strdup.h"
# define strdup(ptr) ares_strdup(ptr)
#endif
#ifndef HAVE_STRCASECMP
# include "ares_strcasecmp.h"
# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
#endif
#ifndef HAVE_STRNCASECMP
# include "ares_strcasecmp.h"
# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
#endif
#ifdef WATT32
#undef WIN32 /* Redefined in MingW headers */
#endif
#ifndef T_SRV
# define T_SRV 33 /* Server selection */
#endif
#ifndef T_NAPTR
# define T_NAPTR 35 /* Naming authority pointer */
#endif
#ifndef T_DS
# define T_DS 43 /* Delegation Signer (RFC4034) */
#endif
#ifndef T_SSHFP
# define T_SSHFP 44 /* SSH Key Fingerprint (RFC4255) */
#endif
#ifndef T_RRSIG
# define T_RRSIG 46 /* Resource Record Signature (RFC4034) */
#endif
#ifndef T_NSEC
# define T_NSEC 47 /* Next Secure (RFC4034) */
#endif
#ifndef T_DNSKEY
# define T_DNSKEY 48 /* DNS Public Key (RFC4034) */
#endif
struct nv {
const char *name;
int value;
};
static const struct nv flags[] = {
{ "usevc", ARES_FLAG_USEVC },
{ "primary", ARES_FLAG_PRIMARY },
{ "igntc", ARES_FLAG_IGNTC },
{ "norecurse", ARES_FLAG_NORECURSE },
{ "stayopen", ARES_FLAG_STAYOPEN },
{ "noaliases", ARES_FLAG_NOALIASES }
};
static const int nflags = sizeof(flags) / sizeof(flags[0]);
static const struct nv classes[] = {
{ "IN", C_IN },
{ "CHAOS", C_CHAOS },
{ "HS", C_HS },
{ "ANY", C_ANY }
};
static const int nclasses = sizeof(classes) / sizeof(classes[0]);
static const struct nv types[] = {
{ "A", T_A },
{ "NS", T_NS },
{ "MD", T_MD },
{ "MF", T_MF },
{ "CNAME", T_CNAME },
{ "SOA", T_SOA },
{ "MB", T_MB },
{ "MG", T_MG },
{ "MR", T_MR },
{ "NULL", T_NULL },
{ "WKS", T_WKS },
{ "PTR", T_PTR },
{ "HINFO", T_HINFO },
{ "MINFO", T_MINFO },
{ "MX", T_MX },
{ "TXT", T_TXT },
{ "RP", T_RP },
{ "AFSDB", T_AFSDB },
{ "X25", T_X25 },
{ "ISDN", T_ISDN },
{ "RT", T_RT },
{ "NSAP", T_NSAP },
{ "NSAP_PTR", T_NSAP_PTR },
{ "SIG", T_SIG },
{ "KEY", T_KEY },
{ "PX", T_PX },
{ "GPOS", T_GPOS },
{ "AAAA", T_AAAA },
{ "LOC", T_LOC },
{ "SRV", T_SRV },
{ "AXFR", T_AXFR },
{ "MAILB", T_MAILB },
{ "MAILA", T_MAILA },
{ "NAPTR", T_NAPTR },
{ "DS", T_DS },
{ "SSHFP", T_SSHFP },
{ "RRSIG", T_RRSIG },
{ "NSEC", T_NSEC },
{ "DNSKEY", T_DNSKEY },
{ "ANY", T_ANY }
};
static const int ntypes = sizeof(types) / sizeof(types[0]);
static const char *opcodes[] = {
"QUERY", "IQUERY", "STATUS", "(reserved)", "NOTIFY",
"(unknown)", "(unknown)", "(unknown)", "(unknown)",
"UPDATEA", "UPDATED", "UPDATEDA", "UPDATEM", "UPDATEMA",
"ZONEINIT", "ZONEREF"
};
static const char *rcodes[] = {
"NOERROR", "FORMERR", "SERVFAIL", "NXDOMAIN", "NOTIMP", "REFUSED",
"(unknown)", "(unknown)", "(unknown)", "(unknown)", "(unknown)",
"(unknown)", "(unknown)", "(unknown)", "(unknown)", "NOCHANGE"
};
static void callback(void *arg, int status, int timeouts,
unsigned char *abuf, int alen);
static const unsigned char *display_question(const unsigned char *aptr,
const unsigned char *abuf,
int alen);
static const unsigned char *display_rr(const unsigned char *aptr,
const unsigned char *abuf, int alen);
static const char *type_name(int type);
static const char *class_name(int dnsclass);
static void usage(void);
static void destroy_addr_list(struct ares_addr_node *head);
static void append_addr_list(struct ares_addr_node **head,
struct ares_addr_node *node);
int main(int argc, char **argv)
{
ares_channel channel;
int c, i, optmask = ARES_OPT_FLAGS, dnsclass = C_IN, type = T_A;
int status, nfds, count;
struct ares_options options;
struct hostent *hostent;
fd_set read_fds, write_fds;
struct timeval *tvp, tv;
struct ares_addr_node *srvr, *servers = NULL;
#ifdef USE_WINSOCK
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
WSADATA wsaData;
WSAStartup(wVersionRequested, &wsaData);
#endif
status = ares_library_init(ARES_LIB_INIT_ALL);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_library_init: %s\n", ares_strerror(status));
return 1;
}
options.flags = ARES_FLAG_NOCHECKRESP;
options.servers = NULL;
options.nservers = 0;
while ((c = ares_getopt(argc, argv, "df:s:c:t:T:U:")) != -1)
{
switch (c)
{
case 'd':
#ifdef WATT32
dbug_init();
#endif
break;
case 'f':
/* Add a flag. */
for (i = 0; i < nflags; i++)
{
if (strcmp(flags[i].name, optarg) == 0)
break;
}
if (i < nflags)
options.flags |= flags[i].value;
else
usage();
break;
case 's':
/* User-specified name servers override default ones. */
srvr = malloc(sizeof(struct ares_addr_node));
if (!srvr)
{
fprintf(stderr, "Out of memory!\n");
destroy_addr_list(servers);
return 1;
}
append_addr_list(&servers, srvr);
if (ares_inet_pton(AF_INET, optarg, &srvr->addr.addr4) > 0)
srvr->family = AF_INET;
else if (ares_inet_pton(AF_INET6, optarg, &srvr->addr.addr6) > 0)
srvr->family = AF_INET6;
else
{
hostent = gethostbyname(optarg);
if (!hostent)
{
fprintf(stderr, "adig: server %s not found.\n", optarg);
destroy_addr_list(servers);
return 1;
}
switch (hostent->h_addrtype)
{
case AF_INET:
srvr->family = AF_INET;
memcpy(&srvr->addr.addr4, hostent->h_addr,
sizeof(srvr->addr.addr4));
break;
case AF_INET6:
srvr->family = AF_INET6;
memcpy(&srvr->addr.addr6, hostent->h_addr,
sizeof(srvr->addr.addr6));
break;
default:
fprintf(stderr,
"adig: server %s unsupported address family.\n", optarg);
destroy_addr_list(servers);
return 1;
}
}
/* Notice that calling ares_init_options() without servers in the
* options struct and with ARES_OPT_SERVERS set simultaneously in
* the options mask, results in an initialization with no servers.
* When alternative name servers have been specified these are set
* later calling ares_set_servers() overriding any existing server
* configuration. To prevent initial configuration with default
* servers that will be discarded later, ARES_OPT_SERVERS is set.
* If this flag is not set here the result shall be the same but
* ares_init_options() will do needless work. */
optmask |= ARES_OPT_SERVERS;
break;
case 'c':
/* Set the query class. */
for (i = 0; i < nclasses; i++)
{
if (strcasecmp(classes[i].name, optarg) == 0)
break;
}
if (i < nclasses)
dnsclass = classes[i].value;
else
usage();
break;
case 't':
/* Set the query type. */
for (i = 0; i < ntypes; i++)
{
if (strcasecmp(types[i].name, optarg) == 0)
break;
}
if (i < ntypes)
type = types[i].value;
else
usage();
break;
case 'T':
/* Set the TCP port number. */
if (!ISDIGIT(*optarg))
usage();
options.tcp_port = (unsigned short)strtol(optarg, NULL, 0);
optmask |= ARES_OPT_TCP_PORT;
break;
case 'U':
/* Set the UDP port number. */
if (!ISDIGIT(*optarg))
usage();
options.udp_port = (unsigned short)strtol(optarg, NULL, 0);
optmask |= ARES_OPT_UDP_PORT;
break;
}
}
argc -= optind;
argv += optind;
if (argc == 0)
usage();
status = ares_init_options(&channel, &options, optmask);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_init_options: %s\n",
ares_strerror(status));
return 1;
}
if(servers)
{
status = ares_set_servers(channel, servers);
destroy_addr_list(servers);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_init_options: %s\n",
ares_strerror(status));
return 1;
}
}
/* Initiate the queries, one per command-line argument. If there is
* only one query to do, supply NULL as the callback argument;
* otherwise, supply the query name as an argument so we can
* distinguish responses for the user when printing them out.
*/
if (argc == 1)
ares_query(channel, *argv, dnsclass, type, callback, (char *) NULL);
else
{
for (; *argv; argv++)
ares_query(channel, *argv, dnsclass, type, callback, *argv);
}
/* Wait for all queries to complete. */
for (;;)
{
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
nfds = ares_fds(channel, &read_fds, &write_fds);
if (nfds == 0)
break;
tvp = ares_timeout(channel, NULL, &tv);
count = select(nfds, &read_fds, &write_fds, NULL, tvp);
if (count < 0 && (status = SOCKERRNO) != EINVAL)
{
printf("select fail: %d", status);
return 1;
}
ares_process(channel, &read_fds, &write_fds);
}
ares_destroy(channel);
ares_library_cleanup();
#ifdef USE_WINSOCK
WSACleanup();
#endif
return 0;
}
static void callback(void *arg, int status, int timeouts,
unsigned char *abuf, int alen)
{
char *name = (char *) arg;
int id, qr, opcode, aa, tc, rd, ra, rcode;
unsigned int qdcount, ancount, nscount, arcount, i;
const unsigned char *aptr;
(void) timeouts;
/* Display the query name if given. */
if (name)
printf("Answer for query %s:\n", name);
/* Display an error message if there was an error, but only stop if
* we actually didn't get an answer buffer.
*/
if (status != ARES_SUCCESS)
{
printf("%s\n", ares_strerror(status));
if (!abuf)
return;
}
/* Won't happen, but check anyway, for safety. */
if (alen < HFIXEDSZ)
return;
/* Parse the answer header. */
id = DNS_HEADER_QID(abuf);
qr = DNS_HEADER_QR(abuf);
opcode = DNS_HEADER_OPCODE(abuf);
aa = DNS_HEADER_AA(abuf);
tc = DNS_HEADER_TC(abuf);
rd = DNS_HEADER_RD(abuf);
ra = DNS_HEADER_RA(abuf);
rcode = DNS_HEADER_RCODE(abuf);
qdcount = DNS_HEADER_QDCOUNT(abuf);
ancount = DNS_HEADER_ANCOUNT(abuf);
nscount = DNS_HEADER_NSCOUNT(abuf);
arcount = DNS_HEADER_ARCOUNT(abuf);
/* Display the answer header. */
printf("id: %d\n", id);
printf("flags: %s%s%s%s%s\n",
qr ? "qr " : "",
aa ? "aa " : "",
tc ? "tc " : "",
rd ? "rd " : "",
ra ? "ra " : "");
printf("opcode: %s\n", opcodes[opcode]);
printf("rcode: %s\n", rcodes[rcode]);
/* Display the questions. */
printf("Questions:\n");
aptr = abuf + HFIXEDSZ;
for (i = 0; i < qdcount; i++)
{
aptr = display_question(aptr, abuf, alen);
if (aptr == NULL)
return;
}
/* Display the answers. */
printf("Answers:\n");
for (i = 0; i < ancount; i++)
{
aptr = display_rr(aptr, abuf, alen);
if (aptr == NULL)
return;
}
/* Display the NS records. */
printf("NS records:\n");
for (i = 0; i < nscount; i++)
{
aptr = display_rr(aptr, abuf, alen);
if (aptr == NULL)
return;
}
/* Display the additional records. */
printf("Additional records:\n");
for (i = 0; i < arcount; i++)
{
aptr = display_rr(aptr, abuf, alen);
if (aptr == NULL)
return;
}
}
static const unsigned char *display_question(const unsigned char *aptr,
const unsigned char *abuf,
int alen)
{
char *name;
int type, dnsclass, status;
long len;
/* Parse the question name. */
status = ares_expand_name(aptr, abuf, alen, &name, &len);
if (status != ARES_SUCCESS)
return NULL;
aptr += len;
/* Make sure there's enough data after the name for the fixed part
* of the question.
*/
if (aptr + QFIXEDSZ > abuf + alen)
{
ares_free_string(name);
return NULL;
}
/* Parse the question type and class. */
type = DNS_QUESTION_TYPE(aptr);
dnsclass = DNS_QUESTION_CLASS(aptr);
aptr += QFIXEDSZ;
/* Display the question, in a format sort of similar to how we will
* display RRs.
*/
printf("\t%-15s.\t", name);
if (dnsclass != C_IN)
printf("\t%s", class_name(dnsclass));
printf("\t%s\n", type_name(type));
ares_free_string(name);
return aptr;
}
static const unsigned char *display_rr(const unsigned char *aptr,
const unsigned char *abuf, int alen)
{
const unsigned char *p;
int type, dnsclass, ttl, dlen, status;
long len;
char addr[46];
union {
unsigned char * as_uchar;
char * as_char;
} name;
/* Parse the RR name. */
status = ares_expand_name(aptr, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS)
return NULL;
aptr += len;
/* Make sure there is enough data after the RR name for the fixed
* part of the RR.
*/
if (aptr + RRFIXEDSZ > abuf + alen)
{
ares_free_string(name.as_char);
return NULL;
}
/* Parse the fixed part of the RR, and advance to the RR data
* field. */
type = DNS_RR_TYPE(aptr);
dnsclass = DNS_RR_CLASS(aptr);
ttl = DNS_RR_TTL(aptr);
dlen = DNS_RR_LEN(aptr);
aptr += RRFIXEDSZ;
if (aptr + dlen > abuf + alen)
{
ares_free_string(name.as_char);
return NULL;
}
/* Display the RR name, class, and type. */
printf("\t%-15s.\t%d", name.as_char, ttl);
if (dnsclass != C_IN)
printf("\t%s", class_name(dnsclass));
printf("\t%s", type_name(type));
ares_free_string(name.as_char);
/* Display the RR data. Don't touch aptr. */
switch (type)
{
case T_CNAME:
case T_MB:
case T_MD:
case T_MF:
case T_MG:
case T_MR:
case T_NS:
case T_PTR:
/* For these types, the RR data is just a domain name. */
status = ares_expand_name(aptr, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t%s.", name.as_char);
ares_free_string(name.as_char);
break;
case T_HINFO:
/* The RR data is two length-counted character strings. */
p = aptr;
len = *p;
if (p + len + 1 > aptr + dlen)
return NULL;
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t%s", name.as_char);
ares_free_string(name.as_char);
p += len;
len = *p;
if (p + len + 1 > aptr + dlen)
return NULL;
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t%s", name.as_char);
ares_free_string(name.as_char);
break;
case T_MINFO:
/* The RR data is two domain names. */
p = aptr;
status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t%s.", name.as_char);
ares_free_string(name.as_char);
p += len;
status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t%s.", name.as_char);
ares_free_string(name.as_char);
break;
case T_MX:
/* The RR data is two bytes giving a preference ordering, and
* then a domain name.
*/
if (dlen < 2)
return NULL;
printf("\t%d", (int)DNS__16BIT(aptr));
status = ares_expand_name(aptr + 2, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t%s.", name.as_char);
ares_free_string(name.as_char);
break;
case T_SOA:
/* The RR data is two domain names and then five four-byte
* numbers giving the serial number and some timeouts.
*/
p = aptr;
status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t%s.\n", name.as_char);
ares_free_string(name.as_char);
p += len;
status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t\t\t\t\t\t%s.\n", name.as_char);
ares_free_string(name.as_char);
p += len;
if (p + 20 > aptr + dlen)
return NULL;
printf("\t\t\t\t\t\t( %u %u %u %u %u )",
DNS__32BIT(p), DNS__32BIT(p+4),
DNS__32BIT(p+8), DNS__32BIT(p+12),
DNS__32BIT(p+16));
break;
case T_TXT:
/* The RR data is one or more length-counted character
* strings. */
p = aptr;
while (p < aptr + dlen)
{
len = *p;
if (p + len + 1 > aptr + dlen)
return NULL;
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t%s", name.as_char);
ares_free_string(name.as_char);
p += len;
}
break;
case T_A:
/* The RR data is a four-byte Internet address. */
if (dlen != 4)
return NULL;
printf("\t%s", ares_inet_ntop(AF_INET,aptr,addr,sizeof(addr)));
break;
case T_AAAA:
/* The RR data is a 16-byte IPv6 address. */
if (dlen != 16)
return NULL;
printf("\t%s", ares_inet_ntop(AF_INET6,aptr,addr,sizeof(addr)));
break;
case T_WKS:
/* Not implemented yet */
break;
case T_SRV:
/* The RR data is three two-byte numbers representing the
* priority, weight, and port, followed by a domain name.
*/
printf("\t%d", (int)DNS__16BIT(aptr));
printf(" %d", (int)DNS__16BIT(aptr + 2));
printf(" %d", (int)DNS__16BIT(aptr + 4));
status = ares_expand_name(aptr + 6, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t%s.", name.as_char);
ares_free_string(name.as_char);
break;
case T_NAPTR:
printf("\t%d", (int)DNS__16BIT(aptr)); /* order */
printf(" %d\n", (int)DNS__16BIT(aptr + 2)); /* preference */
p = aptr + 4;
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t\t\t\t\t\t%s\n", name.as_char);
ares_free_string(name.as_char);
p += len;
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t\t\t\t\t\t%s\n", name.as_char);
ares_free_string(name.as_char);
p += len;
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t\t\t\t\t\t%s\n", name.as_char);
ares_free_string(name.as_char);
p += len;
status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS)
return NULL;
printf("\t\t\t\t\t\t%s", name.as_char);
ares_free_string(name.as_char);
break;
case T_DS:
case T_SSHFP:
case T_RRSIG:
case T_NSEC:
case T_DNSKEY:
printf("\t[RR type parsing unavailable]");
break;
default:
printf("\t[Unknown RR; cannot parse]");
break;
}
printf("\n");
return aptr + dlen;
}
static const char *type_name(int type)
{
int i;
for (i = 0; i < ntypes; i++)
{
if (types[i].value == type)
return types[i].name;
}
return "(unknown)";
}
static const char *class_name(int dnsclass)
{
int i;
for (i = 0; i < nclasses; i++)
{
if (classes[i].value == dnsclass)
return classes[i].name;
}
return "(unknown)";
}
static void usage(void)
{
fprintf(stderr, "usage: adig [-f flag] [-s server] [-c class] "
"[-t type] [-p port] name ...\n");
exit(1);
}
static void destroy_addr_list(struct ares_addr_node *head)
{
while(head)
{
struct ares_addr_node *detached = head;
head = head->next;
free(detached);
}
}
static void append_addr_list(struct ares_addr_node **head,
struct ares_addr_node *node)
{
struct ares_addr_node *last;
node->next = NULL;
if(*head)
{
last = *head;
while(last->next)
last = last->next;
last->next = node;
}
else
*head = node;
}
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#include "ares_setup.h"
#if !defined(WIN32) || defined(WATT32)
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include "ares.h"
#include "ares_dns.h"
#include "ares_getopt.h"
#include "ares_ipv6.h"
#include "ares_nowarn.h"
#ifndef HAVE_STRDUP
# include "ares_strdup.h"
# define strdup(ptr) ares_strdup(ptr)
#endif
#ifndef HAVE_STRCASECMP
# include "ares_strcasecmp.h"
# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
#endif
#ifndef HAVE_STRNCASECMP
# include "ares_strcasecmp.h"
# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
#endif
static void callback(void *arg, int status, int timeouts, struct hostent *host);
static void usage(void);
int main(int argc, char **argv)
{
ares_channel channel;
int status, nfds, c, addr_family = AF_INET;
fd_set read_fds, write_fds;
struct timeval *tvp, tv;
struct in_addr addr4;
struct ares_in6_addr addr6;
#ifdef USE_WINSOCK
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
WSADATA wsaData;
WSAStartup(wVersionRequested, &wsaData);
#endif
status = ares_library_init(ARES_LIB_INIT_ALL);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_library_init: %s\n", ares_strerror(status));
return 1;
}
while ((c = ares_getopt(argc,argv,"dt:h")) != -1)
{
switch (c)
{
case 'd':
#ifdef WATT32
dbug_init();
#endif
break;
case 't':
if (!strcasecmp(optarg,"a"))
addr_family = AF_INET;
else if (!strcasecmp(optarg,"aaaa"))
addr_family = AF_INET6;
else
usage();
break;
case 'h':
default:
usage();
break;
}
}
argc -= optind;
argv += optind;
if (argc < 1)
usage();
status = ares_init(&channel);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_init: %s\n", ares_strerror(status));
return 1;
}
/* Initiate the queries, one per command-line argument. */
for ( ; *argv; argv++)
{
if (ares_inet_pton(AF_INET, *argv, &addr4) == 1)
{
ares_gethostbyaddr(channel, &addr4, sizeof(addr4), AF_INET, callback,
*argv);
}
else if (ares_inet_pton(AF_INET6, *argv, &addr6) == 1)
{
ares_gethostbyaddr(channel, &addr6, sizeof(addr6), AF_INET6, callback,
*argv);
}
else
{
ares_gethostbyname(channel, *argv, addr_family, callback, *argv);
}
}
/* Wait for all queries to complete. */
for (;;)
{
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
nfds = ares_fds(channel, &read_fds, &write_fds);
if (nfds == 0)
break;
tvp = ares_timeout(channel, NULL, &tv);
select(nfds, &read_fds, &write_fds, NULL, tvp);
ares_process(channel, &read_fds, &write_fds);
}
ares_destroy(channel);
ares_library_cleanup();
#ifdef USE_WINSOCK
WSACleanup();
#endif
return 0;
}
static void callback(void *arg, int status, int timeouts, struct hostent *host)
{
char **p;
(void)timeouts;
if (status != ARES_SUCCESS)
{
fprintf(stderr, "%s: %s\n", (char *) arg, ares_strerror(status));
return;
}
for (p = host->h_addr_list; *p; p++)
{
char addr_buf[46] = "??";
ares_inet_ntop(host->h_addrtype, *p, addr_buf, sizeof(addr_buf));
printf("%-32s\t%s", host->h_name, addr_buf);
#if 0
if (host->h_aliases[0])
{
int i;
printf (", Aliases: ");
for (i = 0; host->h_aliases[i]; i++)
printf("%s ", host->h_aliases[i]);
}
#endif
puts("");
}
}
static void usage(void)
{
fprintf(stderr, "usage: ahost [-t {a|aaaa}] {host|addr} ...\n");
exit(1);
}
/* ares_build.h. Generated from ares_build.h.in by configure. */
#ifndef __CARES_BUILD_H
#define __CARES_BUILD_H
/* Copyright (C) 2009 - 2013 by Daniel Stenberg et al
/* Copyright (C) 2009 by Daniel Stenberg et al
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
......@@ -19,20 +20,6 @@
/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */
/* ================================================================ */
/*
* NOTE 1:
* -------
*
* See file ares_build.h.in, run configure, and forget that this file
* exists it is only used for non-configure systems.
* But you can keep reading if you want ;-)
*
*/
/* ================================================================ */
/* NOTES FOR NON-CONFIGURE SYSTEMS */
/* ================================================================ */
/*
* NOTE 1:
* -------
......@@ -44,39 +31,20 @@
* or fixed in this file, then, report it on the c-ares development
* mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/
*
* Try to keep one section per platform, compiler and architecture,
* otherwise, if an existing section is reused for a different one and
* later on the original is adjusted, probably the piggybacking one can
* be adversely changed.
*
* In order to differentiate between platforms/compilers/architectures
* use only compiler built in predefined preprocessor symbols.
*
* This header file shall only export symbols which are 'cares' or 'CARES'
* prefixed, otherwise public name space would be polluted.
*
* NOTE 2:
* -------
*
* Right now you might be staring at file ares_build.h.dist or ares_build.h,
* this is due to the following reason: file ares_build.h.dist is renamed
* to ares_build.h when the c-ares source code distribution archive file is
* created.
*
* File ares_build.h.dist is not included in the distribution archive.
* File ares_build.h is not present in the git tree.
*
* The distributed ares_build.h file is only intended to be used on systems
* which can not run the also distributed configure script.
* Right now you might be staring at file ares_build.h.in or ares_build.h,
* this is due to the following reason:
*
* On systems capable of running the configure script, the configure process
* will overwrite the distributed ares_build.h file with one that is suitable
* and specific to the library being configured and built, which is generated
* from the ares_build.h.in template file.
*
* If you check out from git on a non-configure platform, you must run the
* appropriate buildconf* script to set up ares_build.h and other local files.
*
*/
/* ================================================================ */
......@@ -99,156 +67,45 @@
#endif
/* ================================================================ */
/* EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY */
/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */
/* ================================================================ */
#if defined(__DJGPP__) || defined(__GO32__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__SALFORDC__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__BORLANDC__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__TURBOC__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__WATCOMC__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__POCC__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__LCC__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__SYMBIAN32__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__MWERKS__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(_WIN32_WCE)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__MINGW32__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__VMS)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__OS400__)
# if defined(__ILEC400__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
# define CARES_PULL_SYS_TYPES_H 1
# define CARES_PULL_SYS_SOCKET_H 1
# endif
#elif defined(__MVS__)
# if defined(__IBMC__) || defined(__IBMCPP__)
# if defined(_ILP32)
# define CARES_SIZEOF_LONG 4
# elif defined(_LP64)
# define CARES_SIZEOF_LONG 8
# endif
# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
# define CARES_PULL_SYS_TYPES_H 1
# define CARES_PULL_SYS_SOCKET_H 1
# endif
#elif defined(__370__)
# if defined(__IBMC__) || defined(__IBMCPP__)
# if defined(_ILP32)
# define CARES_SIZEOF_LONG 4
# elif defined(_LP64)
# define CARES_SIZEOF_LONG 8
# endif
# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
# define CARES_PULL_SYS_TYPES_H 1
# define CARES_PULL_SYS_SOCKET_H 1
# endif
#elif defined(TPF)
# define CARES_SIZEOF_LONG 8
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
/* ===================================== */
/* KEEP MSVC THE PENULTIMATE ENTRY */
/* ===================================== */
#elif defined(_MSC_VER)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
/* ===================================== */
/* KEEP GENERIC GCC THE LAST ENTRY */
/* ===================================== */
#elif defined(__GNUC__)
# if defined(__ILP32__) || \
defined(__i386__) || defined(__ppc__) || defined(__arm__)
# define CARES_SIZEOF_LONG 4
# elif defined(__LP64__) || \
defined(__x86_64__) || defined(__ppc64__)
# define CARES_SIZEOF_LONG 8
/* Configure process defines this to 1 when it finds out that system */
/* header file ws2tcpip.h must be included by the external interface. */
/* #undef CARES_PULL_WS2TCPIP_H */
#ifdef CARES_PULL_WS2TCPIP_H
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
# define CARES_PULL_SYS_TYPES_H 1
# define CARES_PULL_SYS_SOCKET_H 1
#else
# error "Unknown non-configure build target!"
Error Compilation_aborted_Unknown_non_configure_build_target
# include <windows.h>
# include <winsock2.h>
# include <ws2tcpip.h>
#endif
/* CARES_PULL_SYS_TYPES_H is defined above when inclusion of header file */
/* sys/types.h is required here to properly make type definitions below. */
/* Configure process defines this to 1 when it finds out that system */
/* header file sys/types.h must be included by the external interface. */
#define CARES_PULL_SYS_TYPES_H 1
#ifdef CARES_PULL_SYS_TYPES_H
# include <sys/types.h>
#endif
/* CARES_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
/* sys/socket.h is required here to properly make type definitions below. */
/* Configure process defines this to 1 when it finds out that system */
/* header file sys/socket.h must be included by the external interface. */
#define CARES_PULL_SYS_SOCKET_H 1
#ifdef CARES_PULL_SYS_SOCKET_H
# include <sys/socket.h>
#endif
/* Data type definition of ares_socklen_t. */
/* The size of `long', as computed by sizeof. */
#define CARES_SIZEOF_LONG 8
#ifdef CARES_TYPEOF_ARES_SOCKLEN_T
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
#endif
/* Integral data type used for ares_socklen_t. */
#define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
/* The size of `ares_socklen_t', as computed by sizeof. */
#define CARES_SIZEOF_ARES_SOCKLEN_T 4
/* Data type definition of ares_socklen_t. */
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
#endif /* __CARES_BUILD_H */
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_CANCEL 3 "31 March 2004"
.SH NAME
ares_cancel \- Cancel a resolve
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B void ares_cancel(ares_channel \fIchannel\fP)
.fi
.SH DESCRIPTION
The \fBares_cancel\fP function cancels all lookups/requests made on the the
name service channel identified by \fIchannel\fP. \fBares_cancel\fP invokes
the callbacks for each pending query on the channel, passing a status of
.BR ARES_ECANCELLED .
These calls give the callbacks a chance to clean up any state which
might have been stored in their arguments. If such a callback invocation adds
a new request to the channel, that request will \fInot\fP be cancelled by the
current invocation of \fBares_cancel\fP.
.SH SEE ALSO
.BR ares_init (3)
.BR ares_destroy (3)
.SH NOTES
This function was added in c-ares 1.2.0
c-ares 1.6.0 and earlier pass a status of
.BR ARES_ETIMEOUT
instead of
.BR ARES_ECANCELLED .
.SH AUTHOR
Dirk Manske
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_CREATE_QUERY 3 "17 Aug 2012"
.SH NAME
ares_create_query \- Compose a single-question DNS query buffer
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_create_query(const char *\fIname\fP, int \fIdnsclass\fP,\
int \fItype\fP,
.B unsigned short \fIid\fP, int \fIrd\fP,\
unsigned char **\fIbuf\fP,
.B int *\fIbuflen\fP, int \fImax_udp_size\fP)
.fi
.SH DESCRIPTION
The
.B ares_create_query
function composes a DNS query with a single question.
The parameter
.I name
gives the query name as a NUL-terminated C string of period-separated
labels optionally ending with a period; periods and backslashes within
a label must be escaped with a backlash. The parameters
.I dnsclass
and
.I type
give the class and type of the query using the values defined in
.BR <arpa/nameser.h> .
The parameter
.I id
gives a 16-bit identifier for the query. The parameter
.I rd
should be nonzero if recursion is desired, zero if not. The query
will be placed in an allocated buffer, a pointer to which will be
stored in the variable pointed to by
.IR buf ,
and the length of which will be stored in the variable pointed to by
.IR buflen .
It is the caller's responsibility to free this buffer using
\fIares_free_string(3)\fP when it is no longer needed.
The parameter
.I max_udp_size
should be nonzero to activate EDNS. Usage of \fIares_create_query(3)\fP\ with
.I max_udp_size
set to zero is equivalent to \fIares_mkquery(3)\fP.
.SH RETURN VALUES
.B ares_create_query
can return any of the following values:
.TP 15
.B ARES_SUCCESS
Construction of the DNS query succeeded.
.TP 15
.B ARES_EBADNAME
The query name
.I name
could not be encoded as a domain name, either because it contained a
zero-length label or because it contained a label of more than 63
characters.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH AVAILABILITY
Added in c-ares 1.10.0
.SH SEE ALSO
.BR ares_expand_name (3),
.BR ares_free_string (3)
.SH AUTHOR
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_DESTROY 3 "7 December 2004"
.SH NAME
ares_destroy \- Destroy a resolver channel
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B void ares_destroy(ares_channel \fIchannel\fP)
.fi
.SH DESCRIPTION
The
.B ares_destroy
function destroys the name service channel identified by
.IR channel ,
freeing all memory and closing all sockets used by the channel.
.B ares_destroy
invokes the callbacks for each pending query on the channel, passing a
status of
.BR ARES_EDESTRUCTION .
These calls give the callbacks a chance to clean up any state which
might have been stored in their arguments. A callback must not add new
requests to a channel being destroyed.
.SH SEE ALSO
.BR ares_init (3),
.BR ares_cancel (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_DESTROY_OPTIONS 3 "1 June 2007"
.SH NAME
ares_destroy_options \- Destroy options initialized with ares_save_options
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B void ares_destroy_options(struct ares_options *\fIoptions\fP)
.fi
.SH DESCRIPTION
The
.B ares_destroy_options
function destroys the options struct identified by
.IR options ,
freeing all memory allocated by ares_save_options.
.SH SEE ALSO
.BR ares_save_options (3),
.BR ares_init_options (3)
.SH AUTHOR
Brad House
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright (C) 2004-2009 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_DUP 3 "26 May 2009"
.SH NAME
ares_dup \- Duplicate a resolver channel
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_dup(ares_channel *\fIdest\fP, ares_channel \fIsource\fP)
.fi
.SH DESCRIPTION
The \fBares_dup(3)\fP function duplicates an existing communications channel
for name service lookups. If it returns successfully, \fBares_dup(3)\fP will
set the variable pointed to by \fIdest\fP to a handle used to identify the
name service channel. The caller should invoke \fIares_destroy(3)\fP on the
handle when the channel is no longer needed.
The \fBares_dup_options\fP function also initializes a name service channel,
with additional options set exactly as the \fIsource\fP channel has them
configured.
.SH SEE ALSO
.BR ares_destroy(3),
.BR ares_init(3),
.BR ares_library_init(3)
.SH AVAILABILITY
ares_dup(3) was added in c-ares 1.6.0
.SH AUTHOR
Daniel Stenberg
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_EXPAND_NAME 3 "20 Nov 2009"
.SH NAME
ares_expand_name \- Expand a DNS-encoded domain name
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_expand_name(const unsigned char *\fIencoded\fP,
.B const unsigned char *\fIabuf\fP, int \fIalen\fP, char **\fIs\fP,
.B long *\fIenclen\fP)
.fi
.SH DESCRIPTION
The
.B ares_expand_name
function converts a DNS-encoded domain name to a dot-separated C
string. The argument
.I encoded
gives the beginning of the encoded domain name, and the arguments
.I abuf
and
.I alen
give the containing message buffer (necessary for the processing of
indirection pointers within the encoded domain name). The result is
placed in a NUL-terminated allocated buffer, a pointer to which is
stored in the variable pointed to by
.IR s .
The length of the encoded name is stored in the variable pointed to by
.I enclen
so that the caller can advance past the encoded domain name to read
further data in the message.
Use \fIares_free_string(3)\fP to free the allocated hostname.
.SH RETURN VALUES
.B ares_expand_name
can return any of the following values:
.TP 15
.B ARES_SUCCESS
Expansion of the encoded name succeeded.
.TP 15
.B ARES_EBADNAME
The encoded domain name was malformed and could not be expanded.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH SEE ALSO
.BR ares_mkquery (3), ares_free_string (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_EXPAND_NAME 3 "20 Nov 2009"
.SH NAME
ares_expand_string \- Expand a length encoded string
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_expand_string(const unsigned char *\fIencoded\fP,
.B const unsigned char *\fIabuf\fP, int \fIalen\fP, unsigned char **\fIs\fP,
.B long *\fIenclen\fP)
.fi
.SH DESCRIPTION
The
.B ares_expand_string
function converts a length encoded string to a NUL-terminated C
string. The argument
.I encoded
gives the beginning of the encoded string, and the arguments
.I abuf
and
.I alen
give the containing message buffer (necessary for the processing of
indirection pointers within the encoded domain name). The result is
placed in a NUL-terminated allocated buffer, a pointer to which is
stored in the variable pointed to by
.IR s .
The length of the encoded string is stored in the variable pointed to by
.I enclen
so that the caller can advance past the encoded string to read
further data in the message.
.SH RETURN VALUES
.B ares_expand_string
can return any of the following values:
.TP 15
.B ARES_SUCCESS
Expansion of the encoded string succeeded.
.TP 15
.B ARES_EBADSTR
The encoded string was malformed and could not be expanded.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH SEE ALSO
.BR ares_free_string (3)
.SH AUTHOR
Dominick Meglio
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_FDS 3 "23 July 1998"
.SH NAME
ares_fds \- Get file descriptors to select on for name service
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_fds(ares_channel \fIchannel\fP, fd_set *\fIread_fds\fP,
.B fd_set *\fIwrite_fds\fP)
.fi
.SH DESCRIPTION
The
.B ares_fds
function retrieves the set of file descriptors which the calling
application should select on for reading and writing for the
processing of name service queries pending on the name service channel
identified by
.IR channel .
File descriptors will be set in the file descriptor sets pointed to by
.I read_fds
and
.I write_fds
as appropriate. File descriptors already set in
.I read_fds
and
.I write_fds
will remain set; initialization of the file descriptor sets
(using
.BR FD_ZERO )
is the responsibility of the caller.
.SH RETURN VALUES
.B ares_fds
returns one greater than the number of the highest socket set in either
.I read_fds
or
.IR write_fds .
If no queries are active,
.B ares_fds
will return 0.
.SH SEE ALSO
.BR ares_timeout (3),
.BR ares_process (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\" Copyright (C) 2004-2010 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_FREE_DATA 3 "5 March 2010"
.SH NAME
ares_free_data \- Free data allocated by several c-ares functions
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B void ares_free_data(void *\fIdataptr\fP)
.PP
.B cc file.c -lcares
.fi
.SH DESCRIPTION
.PP
The
.B ares_free_data(3)
function frees one or more data structures allocated and returned
by several c-ares functions. Specifically the data returned by the
following list of functions must be deallocated using this function.
.TP 5
.B ares_get_servers(3)
When used to free the data returned by ares_get_servers(3) this
will free the whole linked list of ares_addr_node structures returned
by ares_get_servers(3).
.TP
.B ares_parse_srv_reply(3)
When used to free the data returned by ares_parse_srv_reply(3) this
will free the whole linked list of ares_srv_reply structures returned
by ares_parse_srv_reply(3), along with any additional storage
associated with those structures.
.TP
.B ares_parse_mx_reply(3)
When used to free the data returned by ares_parse_mx_reply(3) this
will free the whole linked list of ares_mx_reply structures returned
by ares_parse_mx_reply(3), along with any additional storage
associated with those structures.
.TP
.B ares_parse_txt_reply(3)
When used to free the data returned by ares_parse_txt_reply(3) this
will free the whole linked list of ares_txt_reply structures returned
by ares_parse_txt_reply(3), along with any additional storage
associated with those structures.
.TP
.B ares_parse_soa_reply(3)
When used to free the data returned by ares_parse_soa_reply(3) this
will free the ares_soa_reply structure, along with any additional storage
associated with those structure.
.SH RETURN VALUE
The ares_free_data() function does not return a value.
.SH AVAILABILITY
This function was first introduced in c-ares version 1.7.0.
.SH SEE ALSO
.BR ares_get_servers(3),
.BR ares_parse_srv_reply(3),
.BR ares_parse_mx_reply(3),
.BR ares_parse_txt_reply(3),
.BR ares_parse_soa_reply(3)
.SH AUTHOR
Yang Tse
.PP
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2004-2010 by Daniel Stenberg.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_FREE_HOSTENT 3 "23 July 1998"
.SH NAME
ares_free_hostent \- Free host structure allocated by ares functions
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B void ares_free_hostent(struct hostent *\fIhost\fP)
.fi
.SH DESCRIPTION
The
.I ares_free_hostent
function frees a
.B struct hostent
allocated by one of the functions \fIares_parse_a_reply(3)\fP,
\fIares_parse_aaaa_reply(3)\fP, or \fIares_parse_ptr_reply(3)\fP.
.SH NOTES
It is not necessary (and is not correct) to free the host structure passed to
the callback functions for \fIares_gethostbyname(3)\fP or
\fIares_gethostbyaddr(3)\fP. c-ares will automatically free such host
structures when the callback returns.
.SH SEE ALSO
.BR ares_parse_a_reply (3),
.BR ares_parse_aaaa_reply (3),
.BR ares_parse_ptr_reply (3),
.BR ares_parse_ns_reply (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 2000 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_FREE_STRING 3 "4 February 2004"
.SH NAME
ares_free_string \- Free strings allocated by ares functions
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B void ares_free_string(void *\fIstr\fP)
.fi
.SH DESCRIPTION
The
.I ares_free_string
function frees a string allocated by an ares function.
.SH SEE ALSO
.BR ares_mkquery (3)
.BR ares_expand_string (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 2000 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\" Copyright (C) 2008-2010 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_GET_SERVERS 3 "5 March 2010"
.SH NAME
ares_get_servers \- Retrieve name servers from an initialized ares_channel
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_get_servers(ares_channel \fIchannel\fP, struct ares_addr_node **\fIservers\fP)
.fi
.SH DESCRIPTION
The \fBares_get_servers(3)\fP function retrieves name servers configuration
from the
channel data identified by
.IR channel ,
as a linked list of ares_addr_node structs storing a pointer to the first
node at the address specified by
.IR servers .
Function caller may traverse the returned name server linked list, or may use
it directly as suitable input for the \fBares_set_servers(3)\fP function, but
shall not shrink or extend the list on its own.
Each node of the name server linked list is stored in memory dynamically
allocated and managed by c-ares. It is the caller's responsibility to free
the resulting linked list, using \fBares_free_data(3)\fP , once the caller
does not need it any longer.
This function is capable of handling IPv4 and IPv6 name server
addresses simultaneously, rendering \fBares_save_options(3)\fP with
optmask \fBARES_OPT_SERVERS\fP functionally obsolete except for
IPv4-only name server usage.
.SH RETURN VALUES
.B ares_get_servers(3)
may return any of the following values:
.TP 15
.B ARES_SUCCESS
The name servers configuration was successfuly retrieved
.TP 15
.B ARES_ENOMEM
The memory was exhausted
.TP 15
.B ARES_ENODATA
The channel data identified by
.IR channel
was invalid.
.SH SEE ALSO
.BR ares_set_servers (3),
.BR ares_init_options (3),
.BR ares_save_options(3)
.SH AVAILABILITY
ares_get_servers(3) was added in c-ares 1.7.1
.SH AUTHOR
Implementation of this function and associated library internals are based
on code, comments and feedback provided in November and December of 2008 by
Daniel Stenberg, Gregor Jasny, Phil Blundell and Yang Tse, December 2009
by Cedric Bail, February 2010 by Jakub Hrozek. On March 2010 Yang Tse
shuffled all the bits and this function popped out.
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2008-2010 by Daniel Stenberg
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_GETHOSTBYADDR 3 "24 July 1998"
.SH NAME
ares_gethostbyaddr \- Initiate a host query by address
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B typedef void (*ares_host_callback)(void *\fIarg\fP, int \fIstatus\fP,
.B int \fItimeouts\fP, struct hostent *\fIhostent\fP)
.PP
.B void ares_gethostbyaddr(ares_channel \fIchannel\fP, const void *\fIaddr\fP,
.B int \fIaddrlen\fP, int \fIfamily\fP, ares_host_callback \fIcallback\fP,
.B void *\fIarg\fP)
.fi
.SH DESCRIPTION
The
.B ares_gethostbyaddr
function initiates a host query by address on the name service channel
identified by
.IR channel .
The parameters
.I addr
and
.I addrlen
give the address as a series of bytes, and
.I family
gives the type of address. When the query is complete or has failed, the ares
library will invoke \fIcallback\fP. Completion or failure of the query may
happen immediately, or may happen during a later call to
\fIares_process(3)\fP, \fIares_destroy(3)\fP or \fIares_cancel(3)\fP.
.PP
The callback argument
.I arg
is copied from the
.B ares_gethostbyaddr
argument
.IR arg .
The callback argument
.I status
indicates whether the query succeeded and, if not, how it failed. It
may have any of the following values:
.TP 19
.B ARES_SUCCESS
The host lookup completed successfully.
.TP 19
.B ARES_ENOTIMP
The ares library does not know how to look up addresses of type
.IR family .
.TP 19
.B ARES_ENOTFOUND
The address
.I addr
was not found.
.TP 19
.B ARES_ENOMEM
Memory was exhausted.
.TP 19
.B ARES_ECANCELLED
The query was cancelled.
.TP 19
.B ARES_EDESTRUCTION
The name service channel
.I channel
is being destroyed; the query will not be completed.
.PP
The callback argument
.I timeouts
reports how many times a query timed out during the execution of the
given request.
.PP
On successful completion of the query, the callback argument
.I hostent
points to a
.B struct hostent
containing the name of the host returned by the query. The callback
need not and should not attempt to free the memory pointed to by
.IR hostent ;
the ares library will free it when the callback returns. If the query
did not complete successfully,
.I hostent
will be
.BR NULL .
.SH SEE ALSO
.BR ares_process (3),
.BR ares_gethostbyname (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_GETHOSTBYNAME 3 "25 July 1998"
.SH NAME
ares_gethostbyname \- Initiate a host query by name
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B typedef void (*ares_host_callback)(void *\fIarg\fP, int \fIstatus\fP,
.B int \fItimeouts\fP, struct hostent *\fIhostent\fP)
.PP
.B void ares_gethostbyname(ares_channel \fIchannel\fP, const char *\fIname\fP,
.B int \fIfamily\fP, ares_host_callback \fIcallback\fP, void *\fIarg\fP)
.fi
.SH DESCRIPTION
The
.B ares_gethostbyname
function initiates a host query by name on the name service channel
identified by
.IR channel .
The parameter
.I name
gives the hostname as a NUL-terminated C string, and
.I family
gives the desired type of address for the resulting host entry. When the
query is complete or has failed, the ares library will invoke \fIcallback\fP.
Completion or failure of the query may happen immediately, or may happen
during a later call to \fIares_process(3)\fP, \fIares_destroy(3)\fP or
\fIares_cancel(3)\fP.
.PP
The callback argument
.I arg
is copied from the
.B ares_gethostbyname
argument
.IR arg .
The callback argument
.I status
indicates whether the query succeeded and, if not, how it failed. It
may have any of the following values:
.TP 19
.B ARES_SUCCESS
The host lookup completed successfully.
.TP 19
.B ARES_ENOTIMP
The ares library does not know how to find addresses of type
.IR family .
.TP 19
.B ARES_EBADNAME
The hostname
.B name
is composed entirely of numbers and periods, but is not a valid
representation of an Internet address.
.TP 19
.B ARES_ENOTFOUND
The address
.I addr
was not found.
.TP 19
.B ARES_ENOMEM
Memory was exhausted.
.TP 19
.B ARES_ECANCELLED
The query was cancelled.
.TP 19
.B ARES_EDESTRUCTION
The name service channel
.I channel
is being destroyed; the query will not be completed.
.PP
The callback argument
.I timeouts
reports how many times a query timed out during the execution of the
given request.
.PP
On successful completion of the query, the callback argument
.I hostent
points to a
.B struct hostent
containing the name of the host returned by the query. The callback
need not and should not attempt to free the memory pointed to by
.IR hostent ;
the ares library will free it when the callback returns. If the query
did not complete successfully,
.I hostent
will be
.BR NULL .
.SH SEE ALSO
.BR ares_process (3),
.BR ares_gethostbyaddr (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_GETHOSTBYNAME 3 "25 July 1998"
.SH NAME
ares_gethostbyname_file \- Lookup a name in the system's hosts file
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_gethostbyname_file(ares_channel \fIchannel\fP, const char *\fIname\fP,
.B int \fIfamily\fP, struct hostent **host)
.fi
.SH DESCRIPTION
The
.B ares_gethostbyname_file
function performs a host lookup by name against the system's hosts file (or equivalent local hostname database).
The
.IR channel
parameter is required, but no asynchronous queries are performed. Instead, the
lookup is done via the same mechanism used to perform 'f' lookups
(see the
.I lookups
options field in \fIares_init_options(3)\fP).
The parameter
.I name
gives the hostname as a NUL-terminated C string, and
.I family
gives the desired type of address for the resulting host entry.
.PP
The return value indicates whether the query succeeded and, if not, how it
failed. It may have any of the following values:
.TP 19
.B ARES_SUCCESS
The host lookup completed successfully and
.I host
now points to the result (and must be freed with \fIares_free_hostent(3)\fP).
.TP 19
.B ARES_ENOTFOUND
The hostname
.I name
was not found.
.TP 19
.B ARES_EFILE
There was a file I/O error while performing the lookup.
.TP 19
.B ARES_ENOMEM
Memory was exhausted.
.PP
On successful completion of the query, the pointer pointed to by
.I host
points to a
.B struct hostent
containing the address of the host returned by the lookup. The user must
free the memory pointed to by
.IR host
when finished with it by calling \fIares_free_hostent(3)\fP. If the lookup did
not complete successfully,
.I host
will be
.BR NULL .
.SH AVAILABILITY
Added in c-ares 1.5.4
.SH SEE ALSO
.BR ares_gethostbyname (3),
.BR ares_free_hostent (3),
.BR ares_init_options (3)
.SH AUTHOR
Brad Spencer
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 2005 by Dominick Meglio.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_GETNAMEINFO 3 "1 May 2009"
.SH NAME
ares_getnameinfo \- Address-to-nodename translation in protocol-independent manner
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B typedef void (*ares_nameinfo_callback)(void *\fIarg\fP, int \fIstatus\fP,
.B int \fItimeouts\fP, char *\fInode\fP, char *\fIservice\fP)
.PP
.B void ares_getnameinfo(ares_channel \fIchannel\fP, const struct sockaddr *\fIsa\fP,
.B ares_socklen_t \fIsalen\fP, int \fIflags\fP, ares_nameinfo_callback \fIcallback\fP,
.B void *\fIarg\fP)
.fi
.SH DESCRIPTION
The
.B ares_getnameinfo
function is defined for protocol-independent address translation. The function
is a combination of \fIares_gethostbyaddr(3)\fP and \fIgetservbyport(3)\fP. The function will
translate the address either by executing a host query on the name service channel
identified by
.IR channel
or it will attempt to resolve it locally if possible.
The parameters
.I sa
and
.I len
give the address as a sockaddr structure, and
.I flags
gives the options that the function will use. Valid flags are listed below:
.TP 19
.B ARES_NI_NOFQDN
Only the nodename portion of the FQDN is returned for local hosts.
.TP 19
.B ARES_NI_NUMERICHOST
The numeric form of the hostname is returned rather than the name.
.TP 19
.B ARES_NI_NAMEREQD
An error is returned if the hostname cannot be found in the DNS.
.TP 19
.B ARES_NI_NUMERICSERV
The numeric form of the service is returned rather than the name.
.TP 19
.B ARES_NI_TCP
The service name is to be looked up for the TCP protocol.
.TP 19
.B ARES_NI_UDP
The service name is to be looked up for the UDP protocol.
.TP 19
.B ARES_NI_SCTP
The service name is to be looked up for the SCTP protocol.
.TP 19
.B ARES_NI_DCCP
The service name is to be looked up for the DCCP protocol.
.TP 19
.B ARES_NI_NUMERICSCOPE
The numeric form of the scope ID is returned rather than the name.
.TP 19
.B ARES_NI_LOOKUPHOST
A hostname lookup is being requested.
.TP 19
.B ARES_NI_LOOKUPSERVICE
A service name lookup is being requested.
.PP
When the query
is complete or has
failed, the ares library will invoke \fIcallback\fP. Completion or failure of
the query may happen immediately, or may happen during a later call to
\fIares_process(3)\fP, \fIares_destroy(3)\fP or \fIares_cancel(3)\fP.
.PP
The callback argument
.I arg
is copied from the
.B ares_getnameinfo
argument
.IR arg .
The callback argument
.I status
indicates whether the query succeeded and, if not, how it failed. It
may have any of the following values:
.TP 19
.B ARES_SUCCESS
The host lookup completed successfully.
.TP 19
.B ARES_ENOTIMP
The ares library does not know how to look up addresses of type
.IR family .
.TP 19
.B ARES_ENOTFOUND
The address
.I addr
was not found.
.TP 19
.B ARES_ENOMEM
Memory was exhausted.
.TP 19
.B ARES_ECANCELLED
The query was cancelled.
.TP 19
.B ARES_EDESTRUCTION
The name service channel
.I channel
is being destroyed; the query will not be completed.
.TP 19
.B ARES_EBADFLAGS
The
.I flags
parameter contains an illegal value.
.PP
The callback argument
.I timeouts
reports how many times a query timed out during the execution of the
given request.
.PP
On successful completion of the query, the callback argument
.I node
contains a string representing the hostname (assuming
.B ARES_NI_LOOKUPHOST
was specified). Additionally,
.I service
contains a string representing the service name (assuming
.B ARES_NI_LOOKUPSERVICE
was specified).
If the query did not complete successfully, or one of the values
was not requested,
.I node
or
.I service
will be
.BR NULL .
.SH SEE ALSO
.BR ares_process (3),
.BR ares_getaddrinfo (3)
.SH AUTHOR
Dominick Meglio
.br
Copyright 2005 by Dominick Meglio.
.\"
.\" Copyright 1998 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_GETSOCK 3 "11 March 2010"
.SH NAME
ares_getsock \- get socket descriptors to wait on
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_getsock(ares_channel \fIchannel\fP, ares_socket_t *\fIsocks\fP,
.B int \fInumsocks\fP);
.fi
.SH DESCRIPTION
The
.B ares_getsock
function retrieves the set of socket descriptors which the calling
application should wait on for reading and/or writing for the
processing of name service queries pending on the name service channel
identified by
.IR channel .
Socket descriptors will be set in the socket descriptor array pointed to by
\fIsocks\fP.
\fInumsocks\fP is the size of the given array in number of ints.
This function can only return information about up to 16 sockets. If more are
in use (however unlikely that is), they are simply not reported back.
.SH RETURN VALUES
\fBares_getsock\fP returns a bitmask for what actions to wait for on the
different sockets. The ares.h header file provides these convenience macros to
extract the information appropriately:
.nf
#define ARES_GETSOCK_MAXNUM 16 /* ares_getsock() can return info about
this many sockets */
#define ARES_GETSOCK_READABLE(bits,num) (bits & (1<< (num)))
#define ARES_GETSOCK_WRITABLE(bits,num) (bits & (1 << ((num) + \
ARES_GETSOCK_MAXNUM)))
.fi
.SH NOTES
This function was added in c-ares 1.3.1
.SH SEE ALSO
.BR ares_timeout (3),
.BR ares_fds (3),
.BR ares_process (3)
.\"
.\" Copyright (C) 2013 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_INET_NTOP 3 "17 Feb 2013"
.SH NAME
ares_inet_ntop \- convert a network format address to presentation format
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B const char *
.B ares_inet_ntop(int af, const void *src, char *dst, ares_socklen_t size);
.fi
.SH DESCRIPTION
This is a portable version with the identical functionality of the commonly
available \fIinet_ntop\fP.
The ares_inet_ntop() function converts a numeric address into a text string
suitable for presentation. The \fBaf\fP argument shall specify the family of
the address. This can be AF_INET or AF_INET6. The \fBsrc\fP argument points
to a buffer holding an IPv4 address if the af argument is AF_INET, or an IPv6
address if the af argument is AF_INET6; the address must be in network byte
order. The \fBdst\fP argument points to a buffer where the function stores the
resulting text string; it shall not be NULL. The \fBsize\fP argument specifies
the size of this buffer, which shall be large enough to hold the text string
(INET_ADDRSTRLEN (16) characters for IPv4, INET6_ADDRSTRLEN (46) characters
for IPv6).
.SH SEE ALSO
.BR ares_init(3),
.BR ares_inet_pton(3)
.SH AVAILABILITY
made properly publicly available in c-ares for real in version 1.10.0
.SH AUTHOR
Daniel Stenberg
.\"
.\" Copyright (C) 2013 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_INET_PTON 3 "17 Feb 2013"
.SH NAME
ares_inet_pton \- convert an IPv4 or IPv6 address from text to binary form
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B const char *ares_inet_pton(int af, const char *src, void *dst);
.fi
.SH DESCRIPTION
This is a portable version with the identical functionality of the commonly
available \fIinet_pton\fP.
The ares_inet_pton() function converts the address in its standard text
presentation form into its numeric binary form. The \fBaf\fP argument shall
specify the family of the address. The AF_INET and AF_INET6 address families
shall be supported. The \fBsrc\fP argument points to the string being passed
in. The \fBdst\fP argument points to a buffer into which the function stores
the numeric address; this shall be large enough to hold the numeric address
(32 bits for AF_INET, 128 bits for AF_INET6).
.SH SEE ALSO
.BR ares_init(3),
.BR ares_inet_ntop(3)
.SH AVAILABILITY
made properly publicly available in c-ares for real in version 1.10.0
.SH AUTHOR
Daniel Stenberg
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\" Copyright (C) 2004-2010 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_INIT 3 "5 March 2010"
.SH NAME
ares_init, ares_init_options \- Initialize a resolver channel
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_init(ares_channel *\fIchannelptr\fP)
.B int ares_init_options(ares_channel *\fIchannelptr\fP,
.B struct ares_options *\fIoptions\fP, int \fIoptmask\fP)
.PP
.B cc file.c -lcares
.fi
.SH DESCRIPTION
The \fBares_init\fP function initializes a communications channel for name
service lookups. If it returns successfully, \fBares_init\fP will set the
variable pointed to by \fIchannelptr\fP to a handle used to identify the name
service channel. The caller should invoke
.BR ares_destroy (3)
on the handle when the channel is no longer needed.
.PP
The \fBares_init_options\fP function also initializes a name service channel,
with additional options useful for applications requiring more control over
name service configuration. The \fIoptmask\fP parameter specifies which fields
in the structure pointed to by \fIoptions\fP are set, as follows:
.TP 18
.B ARES_OPT_FLAGS
.B int \fIflags\fP;
.br
Flags controlling the behavior of the resolver. See below for a
description of possible flag values.
.TP 18
.B ARES_OPT_TIMEOUT
.B int \fItimeout\fP;
.br
The number of seconds each name server is given to respond to a query on the
first try. (After the first try, the timeout algorithm becomes more
complicated, but scales linearly with the value of \fItimeout\fP.) The
default is five seconds. This option is being deprecated by
\fIARES_OPT_TIMEOUTMS\fP starting in c-ares 1.5.2.
.TP 18
.B ARES_OPT_TIMEOUTMS
.B int \fItimeout\fP;
.br
The number of milliseconds each name server is given to respond to a query on
the first try. (After the first try, the timeout algorithm becomes more
complicated, but scales linearly with the value of \fItimeout\fP.) The
default is five seconds. Note that this option is specified with the same
struct field as the former \fIARES_OPT_TIMEOUT\fP, it is but the option bits
that tell c-ares how to interpret the number. This option was added in c-ares
1.5.2.
.TP 18
.B ARES_OPT_TRIES
.B int \fItries\fP;
.br
The number of tries the resolver will try contacting each name server
before giving up. The default is four tries.
.TP 18
.B ARES_OPT_NDOTS
.B int \fIndots\fP;
.br
The number of dots which must be present in a domain name for it to be
queried for "as is" prior to querying for it with the default domain
extensions appended. The default value is 1 unless set otherwise by
resolv.conf or the RES_OPTIONS environment variable.
.TP 18
.B ARES_OPT_PORT
.B unsigned short \fIport\fP;
.br
The port to use for queries (both TCP and UDP), in network byte order.
The default value is 53 (in network byte order), the standard name
service port.
.TP 18
.B ARES_OPT_SERVERS
.B struct in_addr *\fIservers\fP;
.br
.B int \fInservers\fP;
.br
The list of IPv4 servers to contact, instead of the servers specified in
resolv.conf or the local named. In order to allow specification of either
IPv4 or IPv6 name servers, the
.BR ares_set_servers(3)
function must be used instead.
.TP 18
.B ARES_OPT_DOMAINS
.B char **\fIdomains\fP;
.br
.B int \fIndomains\fP;
.br
The domains to search, instead of the domains specified in resolv.conf
or the domain derived from the kernel hostname variable.
.TP 18
.B ARES_OPT_LOOKUPS
.B char *\fIlookups\fP;
.br
The lookups to perform for host queries.
.I lookups
should be set to a string of the characters "b" or "f", where "b"
indicates a DNS lookup and "f" indicates a lookup in the hosts file.
.TP 18
.B ARES_OPT_SOCK_STATE_CB
.B void (*\fIsock_state_cb\fP)(void *data, int s, int read, int write);
.br
.B void *\fIsock_state_cb_data\fP;
.br
A callback function to be invoked when a socket changes state.
.I s
will be passed the socket whose state has changed;
.I read
will be set to true if the socket should listen for read events, and
.I write
will be set to true if the socket should listen for write events.
The value of
.I sock_state_cb_data
will be passed as the
.I data
argument.
.PP
The
.I flags
field should be the bitwise or of some subset of the following values:
.TP 23
.B ARES_FLAG_USEVC
Always use TCP queries (the "virtual circuit") instead of UDP
queries. Normally, TCP is only used if a UDP query yields a truncated
result.
.TP 23
.B ARES_FLAG_PRIMARY
Only query the first server in the list of servers to query.
.TP 23
.B ARES_FLAG_IGNTC
If a truncated response to a UDP query is received, do not fall back
to TCP; simply continue on with the truncated response.
.TP 23
.B ARES_FLAG_NORECURSE
Do not set the "recursion desired" bit on outgoing queries, so that the name
server being contacted will not try to fetch the answer from other servers if
it doesn't know the answer locally. Be aware that ares will not do the
recursion for you. Recursion must be handled by the application calling ares
if \fIARES_FLAG_NORECURSE\fP is set.
.TP 23
.B ARES_FLAG_STAYOPEN
Do not close communications sockets when the number of active queries
drops to zero.
.TP 23
.B ARES_FLAG_NOSEARCH
Do not use the default search domains; only query hostnames as-is or
as aliases.
.TP 23
.B ARES_FLAG_NOALIASES
Do not honor the HOSTALIASES environment variable, which normally
specifies a file of hostname translations.
.TP 23
.B ARES_FLAG_NOCHECKRESP
Do not discard responses with the SERVFAIL, NOTIMP, or REFUSED
response code or responses whose questions don't match the questions
in the request. Primarily useful for writing clients which might be
used to test or debug name servers.
.SH RETURN VALUES
.I ares_init
or
.I ares_init_options
can return any of the following values:
.TP 14
.B ARES_SUCCESS
Initialization succeeded.
.TP 14
.B ARES_EFILE
A configuration file could not be read.
.TP 14
.B ARES_ENOMEM
The process's available memory was exhausted.
.TP 14
.B ARES_ENOTINITIALIZED
c-ares library initialization not yet performed.
.SH NOTES
When initializing from
.B /etc/resolv.conf,
.BR ares_init (3)
reads the
.I domain
and
.I search
directives to allow lookups of short names relative to the domains
specified. The
.I domain
and
.I search
directives override one another. If more that one instance of either
.I domain
or
.I search
directives is specified, the last occurence wins. For more information,
please see the
.BR resolv.conf (5)
manual page.
.SH SEE ALSO
.BR ares_destroy(3),
.BR ares_dup(3),
.BR ares_library_init(3),
.BR ares_set_servers(3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2004-2010 by Daniel Stenberg.
.so man3/ares_init.3
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\" Copyright (C) 2004-2009 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_LIBRARY_CLEANUP 3 "19 May 2009"
.SH NAME
ares_library_cleanup \- c-ares library deinitialization
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B void ares_library_cleanup(void)
.PP
.B cc file.c -lcares
.fi
.SH DESCRIPTION
.PP
The
.B ares_library_cleanup
function uninitializes the c-ares library, freeing all resources
previously acquired by \fIares_library_init(3)\fP when the library
was initialized, provided there was only one single previous call to
\fIares_library_init(3)\fP. If there was more than one previous call to
\fIares_library_init(3)\fP, this function uninitializes the c-ares
library only if it is the call matching the call to
\fIares_library_init(3)\fP which initialized the library
(usually the very first call to \fIares_library_init(3)\fP).
Other calls to \fIares_library_cleanup(3)\fP have no effect other than
decrementing an internal counter.
.PP
This function must be called when the program using c-ares will
no longer need any c-ares function. Once the program has called
\fIares_library_cleanup(3)\fP sufficiently often such that the
library is uninitialised, it shall not make any further call to any
c-ares function.
.PP
This function does not cancel any pending c-ares lookups or requests
previously done. Program must use \fIares_cancel(3)\fP for this purpose.
.PP
.B This function is not thread safe.
You have to call it once the program is about to terminate, but this call must
be done once the program has terminated every single thread that it could have
initiated. This is required to avoid potential race conditions in library
deinitialization, and also due to the fact that \fIares_library_cleanup(3)\fP
might call functions from other libraries that are thread unsafe, and could
conflict with any other thread that is already using these other libraries.
.PP
Win32/64 application DLLs shall not call \fIares_library_cleanup(3)\fP from
the DllMain function. Doing so will produce deadlocks and other problems.
.SH AVAILABILITY
This function was first introduced in c-ares version 1.7.0 along with the
definition of preprocessor symbol \fICARES_HAVE_ARES_LIBRARY_CLEANUP\fP as an
indication of the availability of this function. Reference counting in
\fIares_library_init()\fP and \fIares_library_cleanup()\fP, which requires
calls to the former function to match calls to the latter, is present since
c-ares version 1.10.0.
Earlier versions would deinitialize the library on the first call
to \fIares_library_cleanup()\fP.
.PP
Since the introduction of this function, it is absolutely mandatory to call it
for any Win32/64 program using c-ares.
.PP
Non-Win32/64 systems can still use c-ares version 1.7.0 without calling
\fIares_library_cleanup(3)\fP due to the fact that \fIcurrently\fP it is nearly
a do-nothing function on non-Win32/64 platforms.
.SH SEE ALSO
.BR ares_library_init(3),
.BR ares_cancel(3)
.SH AUTHOR
Yang Tse
.PP
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2004-2009 by Daniel Stenberg.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\" Copyright (C) 2004-2009 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_LIBRARY_INIT 3 "19 May 2009"
.SH NAME
ares_library_init \- c-ares library initialization
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_library_init(int \fIflags\fP)
.PP
.B cc file.c -lcares
.fi
.SH DESCRIPTION
.PP
The
.B ares_library_init
function performs initializations internally required by the c-ares
library that must take place before any other function provided by
c-ares can be used in a program.
.PP
This function must be called at least once within the life of a program,
before the program actually executes any other c-ares library function.
Initializations done by this function remain effective until a number of
calls to \fIares_library_cleanup(3)\fP equal to the number of calls to
this function are performed.
.PP
Successive calls to this function do nothing further, only the first
call done when c-ares is in an uninitialized state is actually
effective.
.PP
The
.I flags
parameter is a bit pattern that tells c-ares exactly which features
should be initialized, as described below. Set the desired bits by
ORing the values together. In normal operation you should specify
\fIARES_LIB_INIT_ALL\fP. Don't use any other value unless you are
familiar with it and trying to control some internal c-ares feature.
.PP
.B This function is not thread safe.
You have to call it once the program has started, but this call must be done
before the program starts any other thread. This is required to avoid
potential race conditions in library initialization, and also due to the fact
that \fIares_library_init(3)\fP might call functions from other libraries that
are thread unsafe, and could conflict with any other thread that is already
using these other libraries.
.PP
Win32/64 application DLLs shall not call \fIares_library_init(3)\fP from the
DllMain function. Doing so will produce deadlocks and other problems.
.SH FLAGS
.TP 5
.B ARES_LIB_INIT_ALL
Initialize everything possible. This sets all known bits.
.TP
.B ARES_LIB_INIT_WIN32
Initialize Win32/64 specific libraries.
.TP
.B ARES_LIB_INIT_NONE
Initialize nothing extra. This sets no bit.
.SH RETURN VALUE
Upon successful completion, ares_library_init() will return 0. Otherwise, a
non-zero error number will be returned to indicate the error. Except for
\fIares_strerror(3)\fP, you shall not call any other c-ares function upon
\fIares_library_init(3)\fP failure.
.SH AVAILABILITY
This function was first introduced in c-ares version 1.7.0 along with the
definition of preprocessor symbol \fICARES_HAVE_ARES_LIBRARY_INIT\fP as an
indication of the availability of this function. Its recursive behavior,
which requires a matching number of calls to \fIares_library_cleanup()\fP
in order to deinitialize the library, is present since c-ares version
1.10.0. Earlier versions would deinitialize the library on the first call
to \fIares_library_cleanup()\fP.
.PP
Since the introduction of this function it is absolutely mandatory to
call it for any Win32/64 program using c-ares.
.PP
Non-Win32/64 systems can still use c-ares version 1.7.0 without calling
\fIares_library_init(3)\fP due to the fact that \fIcurrently\fP it is nearly
a do-nothing function on non-Win32/64 platforms at this point.
.SH SEE ALSO
.BR ares_library_cleanup(3),
.BR ares_strerror(3)
.SH AUTHOR
Yang Tse
.PP
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2004-2009 by Daniel Stenberg.
.\"
.\" Copyright 1998, 2000 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_MKQUERY 3 "20 Nov 2009"
.SH NAME
ares_mkquery \- Compose a single-question DNS query buffer
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_mkquery(const char *\fIname\fP, int \fIdnsclass\fP, int \fItype\fP,
.B unsigned short \fIid\fP, int \fIrd\fP, unsigned char **\fIbuf\fP,
.B int *\fIbuflen\fP)
.fi
.SH DESCRIPTION
Deprecated function. See \fIares_create_query(3)\fP instead!
The
.B ares_mkquery
function composes a DNS query with a single question.
The parameter
.I name
gives the query name as a NUL-terminated C string of period-separated
labels optionally ending with a period; periods and backslashes within
a label must be escaped with a backlash. The parameters
.I dnsclass
and
.I type
give the class and type of the query using the values defined in
.BR <arpa/nameser.h> .
The parameter
.I id
gives a 16-bit identifier for the query. The parameter
.I rd
should be nonzero if recursion is desired, zero if not. The query
will be placed in an allocated buffer, a pointer to which will be
stored in the variable pointed to by
.IR buf ,
and the length of which will be stored in the variable pointed to by
.IR buflen .
It is the caller's responsibility to free this buffer using
\fIares_free_string(3)\fP when it is no longer needed.
Usage of \fIares_mkquery(3)\fP is deprecated, whereas the function is
equivalent to \fIares_create_query(3)\fP with \fBmax_udp_size\fP set to
0.
.SH RETURN VALUES
.B ares_mkquery
can return any of the following values:
.TP 15
.B ARES_SUCCESS
Construction of the DNS query succeeded.
.TP 15
.B ARES_EBADNAME
The query name
.I name
could not be encoded as a domain name, either because it contained a
zero-length label or because it contained a label of more than 63
characters.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH SEE ALSO
.BR ares_expand_name (3),
.BR ares_free_string (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998, 2000 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_PARSE_A_REPLY 3 "25 July 1998"
.SH NAME
ares_parse_a_reply \- Parse a reply to a DNS query of type A
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_parse_a_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
.B struct hostent **\fIhost\fP,
.B struct ares_addrttl *\fIaddrttls\fP, int *\fInaddrttls\fP);
.fi
.SH DESCRIPTION
The
.B ares_parse_a_reply
function parses the response to a query of type A into a
.BR "struct hostent"
and/or an array of
.BR "struct ares_addrttls" .
The parameters
.I abuf
and
.I alen
give the contents of the response. The result is stored in allocated
memory and a pointer to it stored into the variable pointed to by
.IR host ,
if host is nonnull.
It is the caller's responsibility to free the resulting host structure
using
.BR ares_free_hostent (3)
when it is no longer needed.
.PP
If
.IR addrttls
and
.IR naddrttls
are both nonnull,
then up to *naddrttls
.BR "struct ares_addrttl"
records are stored in the array pointed to by addrttls,
and then *naddrttls is set to the number of records so stored.
Note that the memory for these records is supplied by the caller.
.SH RETURN VALUES
.B ares_parse_a_reply
can return any of the following values:
.TP 15
.B ARES_SUCCESS
The response was successfully parsed.
.TP 15
.B ARES_EBADRESP
The response was malformatted.
.TP 15
.B ARES_ENODATA
The response did not contain an answer to the query.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH SEE ALSO
.BR ares_gethostbyname (3),
.BR ares_free_hostent (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 2005 by Dominick Meglio.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_PARSE_AAAA_REPLY 3 "20 Nov 2009"
.SH NAME
ares_parse_aaaa_reply \- Parse a reply to a DNS query of type AAAA
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_parse_aaaa_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
.B struct hostent **\fIhost\fP,
.B struct ares_addr6ttl *\fIaddrttls\fP, int *\fInaddrttls\fP);
.fi
.SH DESCRIPTION
The
.B ares_parse_aaaa_reply
function parses the response to a query of type AAAA into a
.BR "struct hostent"
and/or an array of
.BR "struct ares_addr6ttl" .
The parameters
.I abuf
and
.I alen
give the contents of the response. The result is stored in allocated
memory and a pointer to it stored into the variable pointed to by
.IR host ,
if host is nonnull.
It is the caller's responsibility to free the resulting host structure
using
.BR ares_free_hostent (3)
when it is no longer needed.
.PP
If
.IR addrttls
and
.IR naddrttls
are both nonnull,
then up to *naddrttls
.BR "struct ares_addr6ttl"
records are stored in the array pointed to by addrttls,
and then *naddrttls is set to the number of records so stored.
Note that the memory for these records is supplied by the caller.
.SH RETURN VALUES
.B ares_parse_aaaa_reply
can return any of the following values:
.TP 15
.B ARES_SUCCESS
The response was successfully parsed.
.TP 15
.B ARES_EBADRESP
The response was malformatted.
.TP 15
.B ARES_ENODATA
The response did not contain an answer to the query.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH SEE ALSO
.BR ares_gethostbyname (3),
.BR ares_free_hostent (3)
.SH AUTHOR
Dominick Meglio
.br
Copyright 2005 by Dominick Meglio.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_PARSE_MX_REPLY 3 "4 August 2009"
.SH NAME
ares_parse_mx_reply \- Parse a reply to a DNS query of type MX
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_parse_mx_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP,
.B struct ares_mx_reply** \fImx_out\fP);
.fi
.SH DESCRIPTION
The
.B ares_parse_mx_reply
function parses the response to a query of type MX into a
linked list of
.I struct ares_mx_reply
The parameters
.I abuf
and
.I alen
give the contents of the response. The result is stored in allocated
memory and a pointer to it stored into the variable pointed to by
.IR mx_out .
It is the caller's responsibility to free the resulting
.IR mx_out
structure when it is no longer needed using the function
.B ares_free_data
.PP
The structure
.I ares_mx_reply
contains the following fields:
.sp
.in +4n
.nf
struct ares_mx_reply {
struct ares_mx_reply *next;
char *host;
unsigned short priority;
};
.fi
.in
.PP
.SH RETURN VALUES
.B ares_parse_mx_reply
can return any of the following values:
.TP 15
.B ARES_SUCCESS
The response was successfully parsed.
.TP 15
.B ARES_EBADRESP
The response was malformatted.
.TP 15
.B ARES_ENODATA
The response did not contain an answer to the query.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH AVAILABILITY
This function was first introduced in c-ares version 1.7.2.
.SH SEE ALSO
.BR ares_query (3)
.BR ares_free_data (3)
.SH AUTHOR
Written by Jeremy Lal <kapouer@melix.org>
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_PARSE_NAPTR_REPLY 3 "23 February 2012"
.SH NAME
ares_parse_naptr_reply \- Parse a reply to a DNS query of type NAPTR
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_parse_naptr_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP,
.B struct ares_naptr_reply** \fInaptr_out\fP);
.fi
.SH DESCRIPTION
The
.B ares_parse_naptr_reply
function parses the response to a query of type NAPTR into a
linked list of
.I struct ares_naptr_reply
The parameters
.I abuf
and
.I alen
give the contents of the response. The result is stored in allocated
memory and a pointer to it stored into the variable pointed to by
.IR naptr_out .
It is the caller's responsibility to free the resulting
.IR naptr_out
structure when it is no longer needed using the function
.B ares_free_data
.PP
The structure
.I ares_naptr_reply
contains the following fields:
.sp
.in +4n
.nf
struct ares_naptr_reply {
struct ares_naptr_reply *next;
unsigned char *flags;
unsigned char *service;
unsigned char *regexp;
char *replacement;
unsigned short order;
unsigned short preference;
};
.fi
.in
.PP
.SH RETURN VALUES
.B ares_parse_naptr_reply
can return any of the following values:
.TP 15
.B ARES_SUCCESS
The response was successfully parsed.
.TP 15
.B ARES_EBADRESP
The response was malformatted.
.TP 15
.B ARES_ENODATA
The response did not contain an answer to the query.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH AVAILABILITY
This function was first introduced in c-ares version 1.7.6.
.SH SEE ALSO
.BR ares_query (3)
.BR ares_free_data (3)
.SH AUTHOR
Written by Jakub Hrozek <jhrozek@redhat.com>, on behalf of Red Hat, Inc http://www.redhat.com
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_PARSE_NS_REPLY 3 "10 February 2007"
.SH NAME
ares_parse_ns_reply \- Parse a reply to a DNS query of type NS into a hostent
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_parse_ns_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
.B struct hostent **\fIhost\fP);
.fi
.SH DESCRIPTION
The
.B ares_parse_ns_reply
function parses the response to a query of type NS into a
.BR "struct hostent" .
The parameters
.I abuf
and
.I alen
give the contents of the response. The result is stored in allocated
memory and a pointer to it stored into the variable pointed to by
.IR host .
The nameservers are stored into the
.BR aliases
field of the
.IR host
structure.
It is the caller's responsibility to free the resulting host structure
using
.BR ares_free_hostent (3)
when it is no longer needed.
.SH RETURN VALUES
.B ares_parse_ns_reply
can return any of the following values:
.TP 15
.B ARES_SUCCESS
The response was successfully parsed.
.TP 15
.B ARES_EBADRESP
The response was malformatted.
.TP 15
.B ARES_ENODATA
The response did not contain an answer to the query.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH SEE ALSO
.BR ares_query (3),
.BR ares_free_hostent (3)
.SH AUTHOR
Written by Vlad Dinulescu <vlad.dinulescu@avira.com>, on behalf of AVIRA Gmbh http://www.avira.com
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_PARSE_PTR_REPLY 3 "25 July 1998"
.SH NAME
ares_parse_ptr_reply \- Parse a reply to a DNS query of type PTR into a hostent
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_parse_ptr_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
.B const void *\fIaddr\fP, int \fIaddrlen\fP, int \fIfamily\fP,
.B struct hostent **\fIhost\fP);
.fi
.SH DESCRIPTION
The
.B ares_parse_ptr_reply
function parses the response to a query of type PTR into a
.BR "struct hostent" .
The parameters
.I abuf
and
.I alen
give the contents of the response. The parameters
.IR addr ,
.IR addrlen ,
and
.I family
specify which address was queried for; they are not used to verify the
response, merely used to fill in the address of the
.BR "struct hostent" .
The resulting
.B struct hostent
is stored in allocated memory and a pointer to it stored into the
variable pointed to by
.IR host .
It is the caller's responsibility to free the resulting host structure
using
.BR ares_free_hostent (3)
when it is no longer needed.
.SH RETURN VALUES
.B ares_parse_ptr_reply
can return any of the following values:
.TP 15
.B ARES_SUCCESS
The response was successfully parsed.
.TP 15
.B ARES_EBADRESP
The response was malformatted.
.TP 15
.B ARES_ENODATA
The response did not contain an answer to the query.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH SEE ALSO
.BR ares_gethostbyaddr (3),
.BR ares_free_hostent (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_PARSE_SOA_REPLY 3 "29 May 2012"
.SH NAME
ares_parse_soa_reply \- Parse a reply to a DNS query of type SOA
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_parse_soa_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP,
.B struct ares_soa_reply** \fIsoa_out\fP);
.fi
.SH DESCRIPTION
The
.B ares_parse_soa_reply
function parses the response to a query of type SOA into a
.IR struct\ ares_soa_reply .
The parameters
.I abuf
and
.I alen
give the contents of the response. The result is stored in allocated
memory and a pointer to it stored into the variable pointed to by
.IR soa_out .
It is the caller's responsibility to free the resulting
.IR soa_out
structure when it is no longer needed using the function
.B ares_free_data
.PP
The structure
.I ares_soa_reply
contains the following fields:
.sp
.in +4n
.nf
struct ares_soa_reply {
char *nsname;
char *hostmaster;
unsigned int serial;
unsigned int refresh;
unsigned int retry;
unsigned int expire;
unsigned int minttl;
};
.fi
.in
.PP
.SH RETURN VALUES
.B ares_parse_soa_reply
can return any of the following values:
.TP 15
.B ARES_SUCCESS
The response was successfully parsed.
.TP 15
.B ARES_EBADRESP
The response was malformatted.
.TP 15
.B ARES_ENODATA
The response did not contain an answer to the query.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH AVAILABILITY
This function was first introduced in c-ares version 1.9.0.
.SH SEE ALSO
.BR ares_query (3)
.BR ares_free_data (3)
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_PARSE_SRV_REPLY 3 "4 August 2009"
.SH NAME
ares_parse_srv_reply \- Parse a reply to a DNS query of type SRV
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_parse_srv_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP,
.B struct ares_srv_reply** \fIsrv_out\fP);
.fi
.SH DESCRIPTION
The
.B ares_parse_srv_reply
function parses the response to a query of type SRV into a
linked list of
.I struct ares_srv_reply
The parameters
.I abuf
and
.I alen
give the contents of the response. The result is stored in allocated
memory and a pointer to it stored into the variable pointed to by
.IR srv_out .
It is the caller's responsibility to free the resulting
.IR srv_out
structure when it is no longer needed using the function
.B ares_free_data
.PP
The structure
.I ares_srv_reply
contains the following fields:
.sp
.in +4n
.nf
struct ares_srv_reply {
struct ares_srv_reply *next;
unsigned short weight;
unsigned short priority;
unsigned short port;
char *host;
};
.fi
.in
.PP
.SH RETURN VALUES
.B ares_parse_srv_reply
can return any of the following values:
.TP 15
.B ARES_SUCCESS
The response was successfully parsed.
.TP 15
.B ARES_EBADRESP
The response was malformatted.
.TP 15
.B ARES_ENODATA
The response did not contain an answer to the query.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH AVAILABILITY
This function was first introduced in c-ares version 1.7.0.
.SH SEE ALSO
.BR ares_query (3)
.BR ares_free_data (3)
.SH AUTHOR
Written by Jakub Hrozek <jhrozek@redhat.com>, on behalf of Red Hat, Inc http://www.redhat.com
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_PARSE_TXT_REPLY 3 "27 October 2009"
.SH NAME
ares_parse_txt_reply \- Parse a reply to a DNS query of type TXT
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_parse_txt_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP,
.B struct ares_txt_reply **\fItxt_out\fP);
.fi
.SH DESCRIPTION
The
.B ares_parse_txt_reply
function parses the response to a query of type TXT into a
linked list (one element per sub-string) of
.I struct ares_txt_reply
The parameters
.I abuf
and
.I alen
give the contents of the response. The result is stored in allocated
memory and a pointer to it stored into the variable pointed to by
.IR txt_out .
It is the caller's responsibility to free the resulting
.IR txt_out
structure when it is no longer needed using the function
.B ares_free_data
.PP
The structure
.I ares_txt_reply
contains the following fields:
.sp
.in +4n
.nf
struct ares_txt_reply {
struct ares_txt_reply *next;
unsigned int length;
unsigned char *txt;
};
.fi
.in
.PP
.SH RETURN VALUES
.B ares_parse_txt_reply
can return any of the following values:
.TP 15
.B ARES_SUCCESS
The response was successfully parsed.
.TP 15
.B ARES_EBADRESP
The response was malformatted.
.TP 15
.B ARES_ENODATA
The response did not contain an answer to the query.
.TP 15
.B ARES_ENOMEM
Memory was exhausted.
.SH AVAILABILITY
This function was first introduced in c-ares version 1.7.0.
.SH SEE ALSO
.BR ares_query (3)
.BR ares_free_data (3)
.SH AUTHOR
Written by Jakub Hrozek <jhrozek@redhat.com>, on behalf of Red Hat, Inc http://www.redhat.com
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_PROCESS 3 "25 July 1998"
.SH NAME
ares_process \- Process events for name resolution
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B void ares_process(ares_channel \fIchannel\fP, fd_set *\fIread_fds\fP,
.B fd_set *\fIwrite_fds\fP)
.fi
.PP
.B void ares_process_fd(ares_channel \fIchannel\fP,
.B ares_socket_t \fIread_fd\fP,
.B ares_socket_t \fIwrite_fd\fP)
.fi
.SH DESCRIPTION
The \fBares_process(3)\fP function handles input/output events and timeouts
associated with queries pending on the name service channel identified by
.IR channel .
The file descriptor sets pointed to by \fIread_fds\fP and \fIwrite_fds\fP
should have file descriptors set in them according to whether the file
descriptors specified by \fIares_fds(3)\fP are ready for reading and writing.
(The easiest way to determine this information is to invoke
.B select
with a timeout no greater than the timeout given by \fIares_timeout(3)\fP ).
.PP
The
.B ares_process
function will invoke callbacks for pending queries if they complete
successfully or fail.
\fBares_process_fd(3)\fP works the same way but acts and operates only on the
specific file descriptors (sockets) you pass in to the function. Use
ARES_SOCKET_BAD for "no action". This function is of course provided to allow
users of c-ares to void select() in their applications and within c-ares.
.SS EXAMPLE
The following code fragment waits for all pending queries on a channel
to complete:
.PP
.RS
.nf
int nfds, count;
fd_set readers, writers;
struct timeval tv, *tvp;
while (1)
{
FD_ZERO(&readers);
FD_ZERO(&writers);
nfds = ares_fds(channel, &readers, &writers);
if (nfds == 0)
break;
tvp = ares_timeout(channel, NULL, &tv);
count = select(nfds, &readers, &writers, NULL, tvp);
ares_process(channel, &readers, &writers);
}
.fi
.RE
.SH SEE ALSO
.BR ares_fds (3),
.BR ares_timeout (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_QUERY 3 "24 July 1998"
.SH NAME
ares_query \- Initiate a single-question DNS query
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP,
.B int \fItimeouts\fP, unsigned char *\fIabuf\fP, int \fIalen\fP)
.PP
.B void ares_query(ares_channel \fIchannel\fP, const char *\fIname\fP,
.B int \fIdnsclass\fP, int \fItype\fP, ares_callback \fIcallback\fP,
.B void *\fIarg\fP)
.fi
.SH DESCRIPTION
The
.B ares_query
function initiates a single-question DNS query on the name service
channel identified by
.IR channel .
The parameter
.I name
gives the query name as a NUL-terminated C string of period-separated
labels optionally ending with a period; periods and backslashes within
a label must be escaped with a backslash. The parameters
.I dnsclass
and
.I type
give the class and type of the query using the values defined in
.BR <arpa/nameser.h> .
When the query is complete or has failed, the ares library will invoke
.IR callback .
Completion or failure of the query may happen immediately, or may
happen during a later call to
.BR ares_process (3)
or
.BR ares_destroy (3).
.PP
The callback argument
.I arg
is copied from the
.B ares_query
argument
.IR arg .
The callback argument
.I status
indicates whether the query succeeded and, if not, how it failed. It
may have any of the following values:
.TP 19
.B ARES_SUCCESS
The query completed successfully.
.TP 19
.B ARES_ENODATA
The query completed but contains no answers.
.TP 19
.B ARES_EFORMERR
The query completed but the server claims that the query was
malformatted.
.TP 19
.B ARES_ESERVFAIL
The query completed but the server claims to have experienced a
failure. (This code can only occur if the
.B ARES_FLAG_NOCHECKRESP
flag was specified at channel initialization time; otherwise, such
responses are ignored at the
.BR ares_send (3)
level.)
.TP 19
.B ARES_ENOTFOUND
The query completed but the queried-for domain name was not found.
.TP 19
.B ARES_ENOTIMP
The query completed but the server does not implement the operation
requested by the query. (This code can only occur if the
.B ARES_FLAG_NOCHECKRESP
flag was specified at channel initialization time; otherwise, such
responses are ignored at the
.BR ares_send (3)
level.)
.TP 19
.B ARES_EREFUSED
The query completed but the server refused the query. (This code can
only occur if the
.B ARES_FLAG_NOCHECKRESP
flag was specified at channel initialization time; otherwise, such
responses are ignored at the
.BR ares_send (3)
level.)
.TP 19
.B ARES_EBADNAME
The query name
.I name
could not be encoded as a domain name, either because it contained a
zero-length label or because it contained a label of more than 63
characters.
.TP 19
.B ARES_ETIMEOUT
No name servers responded within the timeout period.
.TP 19
.B ARES_ECONNREFUSED
No name servers could be contacted.
.TP 19
.B ARES_ENOMEM
Memory was exhausted.
.TP 19
.B ARES_ECANCELLED
The query was cancelled.
.TP 19
.B ARES_EDESTRUCTION
The name service channel
.I channel
is being destroyed; the query will not be completed.
.PP
The callback argument
.I timeouts
reports how many times a query timed out during the execution of the
given request.
.PP
If the query completed (even if there was something wrong with it, as
indicated by some of the above error codes), the callback argument
.I abuf
points to a result buffer of length
.IR alen .
If the query did not complete,
.I abuf
will be NULL and
.I alen
will be 0.
.SH SEE ALSO
.BR ares_process (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_SAVE_OPTIONS 3 "5 March 2010"
.SH NAME
ares_save_options \- Save configuration values obtained from initialized ares_channel
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_save_options(ares_channel \fIchannel\fP, struct ares_options *\fIoptions\fP, int *\fIoptmask\fP)
.fi
.SH DESCRIPTION
The \fBares_save_options(3)\fP function saves the channel data identified by
.IR channel ,
into the options struct identified by
.IR options ,
and saves the mask of options which are set to the integer
pointer (passed by reference) identified by
.IR optmask .
The resultant options and optmask are then able to be
passed directly to ares_init_options. When the options
are no longer needed, ares_destroy_options should be called
to free any associated memory.
.SH RETURN VALUES
.B ares_save_options(3)
can return any of the following values:
.TP 15
.B ARES_SUCCESS
The channel data was successfuly stored
.TP 15
.B ARES_ENOMEM
The memory was exhausted
.TP 15
.B ARES_ENODATA
The channel data identified by
.IR channel
were invalid.
.SH NOTE
Since c-ares 1.6.0 the ares_options struct has been "locked" meaning that it
won't be extended to cover new functions. This function will remain
functioning, but it can only return config data that can be represented in
this config struct, which may no longer be the complete set of config
options. \fBares_dup(3)\fP will not have that restriction.
The ares_options struct can not handle potential IPv6 name servers the
ares_channel might be configured to use. The \fBares_save_options(3)\fP function
will only return IPv4 servers, if any. In order to retrieve all name servers
an ares_channel might be using, the \fBares_get_servers(3)\fP function must be
used instead.
.SH SEE ALSO
.BR ares_destroy_options (3),
.BR ares_init_options (3),
.BR ares_get_servers (3),
.BR ares_dup (3)
.SH AVAILABILITY
ares_save_options(3) was added in c-ares 1.4.0
.SH AUTHOR
Brad House
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_SEARCH 3 "24 July 1998"
.SH NAME
ares_search \- Initiate a DNS query with domain search
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP,
.B int \fItimeouts\fP, unsigned char *\fIabuf\fP, int \fIalen\fP)
.PP
.B void ares_search(ares_channel \fIchannel\fP, const char *\fIname\fP,
.B int \fIdnsclass\fP, int \fItype\fP, ares_callback \fIcallback\fP,
.B void *\fIarg\fP)
.fi
.SH DESCRIPTION
The
.B ares_search
function initiates a series of single-question DNS queries on the name
service channel identified by
.IR channel ,
using the channel's search domains as well as a host alias file given
by the HOSTALIAS environment variable. The parameter
.I name
gives the alias name or the base of the query name as a NUL-terminated
C string of period-separated labels; if it ends with a period, the
channel's search domains will not be used. Periods and backslashes
within a label must be escaped with a backslash. The parameters
.I dnsclass
and
.I type
give the class and type of the query using the values defined in
.BR <arpa/nameser.h> .
When the query sequence is complete or has failed, the ares library
will invoke
.IR callback .
Completion or failure of the query sequence may happen immediately, or
may happen during a later call to
.BR ares_process (3)
or
.BR ares_destroy (3).
.PP
The callback argument
.I arg
is copied from the
.B ares_search
argument
.IR arg .
The callback argument
.I status
indicates whether the query sequence ended with a successful query
and, if not, how the query sequence failed. It may have any of the
following values:
.TP 19
.B ARES_SUCCESS
A query completed successfully.
.TP 19
.B ARES_ENODATA
No query completed successfully; when the query was tried without a
search domain appended, a response was returned with no answers.
.TP 19
.B ARES_EFORMERR
A query completed but the server claimed that the query was
malformatted.
.TP 19
.B ARES_ESERVFAIL
No query completed successfully; when the query was tried without a
search domain appended, the server claimed to have experienced a
failure. (This code can only occur if the
.B ARES_FLAG_NOCHECKRESP
flag was specified at channel initialization time; otherwise, such
responses are ignored at the
.BR ares_send (3)
level.)
.TP 19
.B ARES_ENOTFOUND
No query completed successfully; when the query was tried without a
search domain appended, the server reported that the queried-for
domain name was not found.
.TP 19
.B ARES_ENOTIMP
A query completed but the server does not implement the operation
requested by the query. (This code can only occur if the
.B ARES_FLAG_NOCHECKRESP
flag was specified at channel initialization time; otherwise, such
responses are ignored at the
.BR ares_send (3)
level.)
.TP 19
.B ARES_EREFUSED
A query completed but the server refused the query. (This code can
only occur returned if the
.B ARES_FLAG_NOCHECKRESP
flag was specified at channel initialization time; otherwise, such
responses are ignored at the
.BR ares_send (3)
level.)
.TP 19
.B ARES_TIMEOUT
No name servers responded to a query within the timeout period.
.TP 19
.B ARES_ECONNREFUSED
No name servers could be contacted.
.TP 19
.B ARES_ENOMEM
Memory was exhausted.
.TP 19
.B ARES_ECANCELLED
The query was cancelled.
.TP 19
.B ARES_EDESTRUCTION
The name service channel
.I channel
is being destroyed; the query will not be completed.
.PP
The callback argument
.I timeouts
reports how many times a query timed out during the execution of the
given request.
.PP
If a query completed successfully, the callback argument
.I abuf
points to a result buffer of length
.IR alen .
If the query did not complete successfully,
.I abuf
will usually be NULL and
.I alen
will usually be 0, but in some cases an unsuccessful query result may
be placed in
.IR abuf .
.SH SEE ALSO
.BR ares_process (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_SEND 3 "25 July 1998"
.SH NAME
ares_send \- Initiate a DNS query
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP,
.B int \fItimeouts\fP, unsigned char *\fIabuf\fP, int \fIalen\fP)
.PP
.B void ares_send(ares_channel \fIchannel\fP, const unsigned char *\fIqbuf\fP,
.B int \fIqlen\fP, ares_callback \fIcallback\fP, void *\fIarg\fP)
.fi
.SH DESCRIPTION
The
.B ares_send
function initiates a DNS query on the name service channel identified
by
.IR channel .
The parameters
.I qbuf
and
.I qlen
give the DNS query, which should already have been formatted according
to the DNS protocol. When the query is complete or has failed, the
ares library will invoke
.IR callback .
Completion or failure of the query may happen immediately, or may
happen during a later call to
.BR ares_process (3)
or
.BR ares_destroy (3).
.PP
The callback argument
.I arg
is copied from the
.B ares_send
argument
.IR arg .
The callback argument
.I status
indicates whether the query succeeded and, if not, how it failed. It
may have any of the following values:
.TP 19
.B ARES_SUCCESS
The query completed.
.TP 19
.B ARES_EBADQUERY
The query buffer was poorly formed (was not long enough for a DNS
header or was too long for TCP transmission).
.TP 19
.B ARES_ETIMEOUT
No name servers responded within the timeout period.
.TP 19
.B ARES_ECONNREFUSED
No name servers could be contacted.
.TP 19
.B ARES_ENOMEM
Memory was exhausted.
.TP 19
.B ARES_ECANCELLED
The query was cancelled.
.TP 19
.B ARES_EDESTRUCTION
The name service channel
.I channel
is being destroyed; the query will not be completed.
.PP
The callback argument
.I timeouts
reports how many times a query timed out during the execution of the
given request.
.PP
If the query completed, the callback argument
.I abuf
points to a result buffer of length
.IR alen .
If the query did not complete,
.I abuf
will be NULL and
.I alen
will be 0.
.PP
Unless the flag
.B ARES_FLAG_NOCHECKRESP
was set at channel initialization time,
.B ares_send
will normally ignore responses whose questions do not match the
questions in
.IR qbuf ,
as well as responses with reply codes of
.BR SERVFAIL ,
.BR NOTIMP ,
and
.BR REFUSED .
Unlike other query functions in the ares library, however,
.B ares_send
does not inspect the header of the reply packet to determine the error
status, so a callback status of
.B ARES_SUCCESS
does not reflect as much about the response as for other query
functions.
.SH SEE ALSO
.BR ares_process (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 2010 by Ben Greear <greearb@candelatech.com>
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_SET_SERVERS 3 "5 March 2010"
.SH NAME
ares_set_servers \- Initialize an ares_channel name servers configuration
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_set_servers(ares_channel \fIchannel\fP, struct ares_addr_node *\fIservers\fP)
.fi
.SH DESCRIPTION
The \fBares_set_servers(3)\fP function initializes name servers configuration
for the channel data identified by
.IR channel ,
from a
.IR servers
pointer to a linked list of ares_addr_node structs holding name servers
address data.
The name server linked list pointer argument may be the result of a previous
call to \fBares_get_servers(3)\fP or a linked list of ares_addr_node structs
setup by other means.
This function replaces any potentially previously configured name servers
with the ones given in the linked list. So, in order to configure a channel
with more than one name server all the desired ones must be specified in a
single list.
\fBares_set_servers(3)\fP does not take ownership of the linked list argument.
The caller is responsible for freeing the linked list when no longer needed.
This function is capable of handling IPv4 and IPv6 name server
addresses simultaneously, rendering \fBares_init_options(3)\fP with
optmask \fBARES_OPT_SERVERS\fP functionally obsolete except for
IPv4-only name server usage.
.SH RETURN VALUES
.B ares_set_servers(3)
may return any of the following values:
.TP 15
.B ARES_SUCCESS
The name servers configuration was successfuly initialized.
.TP 15
.B ARES_ENOMEM
The process's available memory was exhausted.
.TP 15
.B ARES_ENODATA
The channel data identified by
.IR channel
was invalid.
.TP 15
.B ARES_ENOTINITIALIZED
c-ares library initialization not yet performed.
.SH SEE ALSO
.BR ares_set_servers_csv (3),
.BR ares_get_servers (3),
.BR ares_init_options (3),
.BR ares_dup(3)
.SH AVAILABILITY
ares_set_servers(3) was added in c-ares 1.7.1
.SH AUTHOR
Implementation of this function and associated library internals are based
on code, comments and feedback provided in November and December of 2008 by
Daniel Stenberg, Gregor Jasny, Phil Blundell and Yang Tse, December 2009
by Cedric Bail, February 2010 by Jakub Hrozek. On March 2010 Yang Tse
shuffled all the bits and this function popped out.
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.br
Copyright (C) 2008-2010 by Daniel Stenberg
.\"
.TH ARES_SET_SOCKET_CALLBACK 3 "20 Nov 2009"
.SH NAME
ares_set_socket_callback \- Set a socket creation callback
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B void ares_set_socket_callback(ares_channel \fIchannel\fP,
ares_sock_create_callback \fIcallback\fP,
void *\fIuserdata\fP)
.PP
.B cc file.c -lcares
.fi
.SH DESCRIPTION
.PP
This function sets a \fIcallback\fP in the given ares channel handle. This
callback function will be invoked after the socket has been created, and
connected to the remote server. The callback must return ARES_SUCCESS if
things are fine, or use the standard ares error codes to signal errors
back. Returned errors will abort the ares operation.
.SH SEE ALSO
.BR ares_init_options (3)
.SH AVAILABILITY
ares_set_socket_callback(3) was added in c-ares 1.6.0
.SH AUTHOR
Gregor Jasny
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_STRERROR 3 "25 July 1998"
.SH NAME
ares_strerror \- Get the description of an ares library error code
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B const char *ares_strerror(int \fIcode\fP)
.fi
.SH DESCRIPTION
The
.B ares_strerror
function gets the description of the ares library error code
.IR code ,
returning the result as a NUL-terminated C string.
.SH NOTES
This function is not compatible with ares, it takes a different set of
arguments.
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_TIMEOUT 3 "25 July 1998"
.SH NAME
ares_timeout \- return maximum time to wait
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B struct timeval *ares_timeout(ares_channel \fIchannel\fP,
.B struct timeval *\fImaxtv\fP, struct timeval *\fItv\fP)
.fi
.SH DESCRIPTION
The
.B ares_timeout
function determines the maximum time for which the caller should wait before
invoking \fIares_process(3)\fP to process timeouts. The parameter
.I maxtv
specifies a existing maximum timeout, or
.B NULL
if the caller does not wish to apply a maximum timeout. The parameter
.I tv
must point to a writable buffer of type
.BR "struct timeval" .
It is valid for
.I maxtv
and
.I tv
to have the same value.
.PP
If no queries have timeouts pending sooner than the given maximum
timeout,
.B ares_timeout
returns the value of
.IR maxtv;
otherwise
.B ares_timeout
stores the appropriate timeout value into the buffer pointed to by
.I tv
and returns the value of
.IR tv .
.SH SEE ALSO
.BR ares_fds (3),
.BR ares_process (3)
.SH AUTHOR
Greg Hudson, MIT Information Systems
.br
Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Copyright 2004 by Daniel Stenberg
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_VERSION 3 "29 January 2004"
.SH NAME
ares_version \- Get the version number of the library
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B const char *ares_version(int *\fIversion\fP)
.fi
.SH DESCRIPTION
The
.B ares_version
function gets the library version as a string and optionally as an integer
stored in the
.IR version ,
argument. If you pass a NULL, no integer is attempted to be returned.
The integer is built up as 24bit number, with 8 separate bits used for major
number, minor number and patch number. This makes a version string such as
1.2.3 will be returned as the hexadecimal number 0x010203 (decimal 66051).
.SH NOTES
This function is not compatible with ares.
.SH AUTHOR
Daniel Stenberg
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2012-03-27.16; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
# 2011, 2012 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# A tabulation character.
tab=' '
# A newline character.
nl='
'
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' "$nl" < "$tmpdepfile" |
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependent.h'.
# Do two passes, one to just change these to
# '$object: dependent.h' and one to simply 'dependent.h:'.
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
# However on
# $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\':
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
# tcc 0.9.26 (FIXME still under development at the moment of writing)
# will emit a similar output, but also prepend the continuation lines
# with horizontal tabulation characters.
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form 'foo.o: dependent.h',
# or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
# Do two passes, one to just change these to
# '$object: dependent.h' and one to simply 'dependent.h:'.
sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \
< "$tmpdepfile" > "$depfile"
sed '
s/[ '"$tab"'][ '"$tab"']*/ /g
s/^ *//
s/ *\\*$//
s/^[^:]*: *//
/^$/d
/:$/d
s/$/ :/
' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mechanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test "$stat" = 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' "$nl" < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
#***************************************************************************
# Project ___ __ _ _ __ ___ ___
# / __|____ / _` | '__/ _ \/ __|
# | (_|_____| (_| | | | __/\__ \
# \___| \__,_|_| \___||___/
#
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: c-ares
URL: http://daniel.haxx.se/projects/c-ares/
Description: asynchronous DNS lookup library
Version: 1.10.0
Requires:
Requires.private:
Cflags: -I${includedir}
Libs: -L${libdir} -lcares
Libs.private:
#***************************************************************************
# Project ___ __ _ _ __ ___ ___
# / __|____ / _` | '__/ _ \/ __|
# | (_|_____| (_| | | | __/\__ \
# \___| \__,_|_| \___||___/
#
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: c-ares
URL: http://daniel.haxx.se/projects/c-ares/
Description: asynchronous DNS lookup library
Version: @VERSION@
Requires:
Requires.private:
Cflags: -I${includedir} @CPPFLAG_CARES_STATICLIB@
Libs: -L${libdir} -lcares
Libs.private: @CARES_PRIVATE_LIBS@
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -9,6 +9,9 @@ try:
from gevent import corecext as _core
except ImportError:
if os.environ.get('GEVENT_CORE_CEXT_ONLY'):
raise
# CFFI/PyPy
from gevent import corecffi as _core
......
......@@ -2,28 +2,31 @@ from __future__ import print_function
import os
import gevent
from gevent import core
from six import xrange
for count in xrange(2):
for backend in core.supported_backends():
hub = gevent.get_hub(backend, default=False)
assert hub.loop.backend == backend, (hub.loop.backend, backend)
gevent.sleep(0.001)
fileno = hub.loop.fileno()
if fileno is not None:
print('%s. Testing %r: %r' % (count, backend, hub))
os.close(fileno)
try:
gevent.sleep(0.001)
except SystemError as ex:
if '(libev)' in str(ex):
print('The error is expected: %s' % ex)
if core.LIBEV_EMBED:
# hub.loop.fileno is only defined when
# we embed libev for some reason
for count in range(2):
for backend in core.supported_backends():
hub = gevent.get_hub(backend, default=False)
assert hub.loop.backend == backend, (hub.loop.backend, backend)
gevent.sleep(0.001)
fileno = hub.loop.fileno()
if fileno is not None:
print('%s. Testing %r: %r' % (count, backend, hub))
os.close(fileno)
try:
gevent.sleep(0.001)
except SystemError as ex:
if '(libev)' in str(ex):
print('The error is expected: %s' % ex)
else:
raise
else:
raise
raise AssertionError('gevent.sleep() is expected to fail after loop fd was closed')
else:
raise AssertionError('gevent.sleep() is expected to fail after loop fd was closed')
else:
print('%s. %r lacks fileno()' % (count, backend))
hub.destroy()
assert 'destroyed' in repr(hub), repr(hub)
print('%s. %r lacks fileno()' % (count, backend))
hub.destroy()
assert 'destroyed' in repr(hub), repr(hub)
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
/*
* libev simple C++ wrapper classes
*
* Copyright (c) 2007,2008,2010 Marc Alexander Lehmann <libev@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
* CIAL, 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 OTH-
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU General Public License ("GPL") version 2 or any later version,
* in which case the provisions of the GPL are applicable instead of
* the above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use your
* version of this file under the BSD license, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete the
* provisions above, a recipient may use your version of this file under
* either the BSD or the GPL.
*/
#ifndef EVPP_H__
#define EVPP_H__
#ifdef EV_H
# include EV_H
#else
# include "ev.h"
#endif
#ifndef EV_USE_STDEXCEPT
# define EV_USE_STDEXCEPT 1
#endif
#if EV_USE_STDEXCEPT
# include <stdexcept>
#endif
namespace ev {
typedef ev_tstamp tstamp;
enum {
UNDEF = EV_UNDEF,
NONE = EV_NONE,
READ = EV_READ,
WRITE = EV_WRITE,
#if EV_COMPAT3
TIMEOUT = EV_TIMEOUT,
#endif
TIMER = EV_TIMER,
PERIODIC = EV_PERIODIC,
SIGNAL = EV_SIGNAL,
CHILD = EV_CHILD,
STAT = EV_STAT,
IDLE = EV_IDLE,
CHECK = EV_CHECK,
PREPARE = EV_PREPARE,
FORK = EV_FORK,
ASYNC = EV_ASYNC,
EMBED = EV_EMBED,
# undef ERROR // some systems stupidly #define ERROR
ERROR = EV_ERROR
};
enum
{
AUTO = EVFLAG_AUTO,
NOENV = EVFLAG_NOENV,
FORKCHECK = EVFLAG_FORKCHECK,
SELECT = EVBACKEND_SELECT,
POLL = EVBACKEND_POLL,
EPOLL = EVBACKEND_EPOLL,
KQUEUE = EVBACKEND_KQUEUE,
DEVPOLL = EVBACKEND_DEVPOLL,
PORT = EVBACKEND_PORT
};
enum
{
#if EV_COMPAT3
NONBLOCK = EVLOOP_NONBLOCK,
ONESHOT = EVLOOP_ONESHOT,
#endif
NOWAIT = EVRUN_NOWAIT,
ONCE = EVRUN_ONCE
};
enum how_t
{
ONE = EVBREAK_ONE,
ALL = EVBREAK_ALL
};
struct bad_loop
#if EV_USE_STDEXCEPT
: std::runtime_error
#endif
{
#if EV_USE_STDEXCEPT
bad_loop ()
: std::runtime_error ("libev event loop cannot be initialized, bad value of LIBEV_FLAGS?")
{
}
#endif
};
#ifdef EV_AX
# undef EV_AX
#endif
#ifdef EV_AX_
# undef EV_AX_
#endif
#if EV_MULTIPLICITY
# define EV_AX raw_loop
# define EV_AX_ raw_loop,
#else
# define EV_AX
# define EV_AX_
#endif
struct loop_ref
{
loop_ref (EV_P) throw ()
#if EV_MULTIPLICITY
: EV_AX (EV_A)
#endif
{
}
bool operator == (const loop_ref &other) const throw ()
{
#if EV_MULTIPLICITY
return EV_AX == other.EV_AX;
#else
return true;
#endif
}
bool operator != (const loop_ref &other) const throw ()
{
#if EV_MULTIPLICITY
return ! (*this == other);
#else
return false;
#endif
}
#if EV_MULTIPLICITY
bool operator == (const EV_P) const throw ()
{
return this->EV_AX == EV_A;
}
bool operator != (const EV_P) const throw ()
{
return (*this == EV_A);
}
operator struct ev_loop * () const throw ()
{
return EV_AX;
}
operator const struct ev_loop * () const throw ()
{
return EV_AX;
}
bool is_default () const throw ()
{
return EV_AX == ev_default_loop (0);
}
#endif
#if EV_COMPAT3
void loop (int flags = 0)
{
ev_run (EV_AX_ flags);
}
void unloop (how_t how = ONE) throw ()
{
ev_break (EV_AX_ how);
}
#endif
void run (int flags = 0)
{
ev_run (EV_AX_ flags);
}
void break_loop (how_t how = ONE) throw ()
{
ev_break (EV_AX_ how);
}
void post_fork () throw ()
{
ev_loop_fork (EV_AX);
}
unsigned int backend () const throw ()
{
return ev_backend (EV_AX);
}
tstamp now () const throw ()
{
return ev_now (EV_AX);
}
void ref () throw ()
{
ev_ref (EV_AX);
}
void unref () throw ()
{
ev_unref (EV_AX);
}
#if EV_FEATURE_API
unsigned int iteration () const throw ()
{
return ev_iteration (EV_AX);
}
unsigned int depth () const throw ()
{
return ev_depth (EV_AX);
}
void set_io_collect_interval (tstamp interval) throw ()
{
ev_set_io_collect_interval (EV_AX_ interval);
}
void set_timeout_collect_interval (tstamp interval) throw ()
{
ev_set_timeout_collect_interval (EV_AX_ interval);
}
#endif
// function callback
void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void *arg = 0) throw ()
{
ev_once (EV_AX_ fd, events, timeout, cb, arg);
}
// method callback
template<class K, void (K::*method)(int)>
void once (int fd, int events, tstamp timeout, K *object) throw ()
{
once (fd, events, timeout, method_thunk<K, method>, object);
}
// default method == operator ()
template<class K>
void once (int fd, int events, tstamp timeout, K *object) throw ()
{
once (fd, events, timeout, method_thunk<K, &K::operator ()>, object);
}
template<class K, void (K::*method)(int)>
static void method_thunk (int revents, void *arg)
{
(static_cast<K *>(arg)->*method)
(revents);
}
// no-argument method callback
template<class K, void (K::*method)()>
void once (int fd, int events, tstamp timeout, K *object) throw ()
{
once (fd, events, timeout, method_noargs_thunk<K, method>, object);
}
template<class K, void (K::*method)()>
static void method_noargs_thunk (int revents, void *arg)
{
(static_cast<K *>(arg)->*method)
();
}
// simpler function callback
template<void (*cb)(int)>
void once (int fd, int events, tstamp timeout) throw ()
{
once (fd, events, timeout, simpler_func_thunk<cb>);
}
template<void (*cb)(int)>
static void simpler_func_thunk (int revents, void *arg)
{
(*cb)
(revents);
}
// simplest function callback
template<void (*cb)()>
void once (int fd, int events, tstamp timeout) throw ()
{
once (fd, events, timeout, simplest_func_thunk<cb>);
}
template<void (*cb)()>
static void simplest_func_thunk (int revents, void *arg)
{
(*cb)
();
}
void feed_fd_event (int fd, int revents) throw ()
{
ev_feed_fd_event (EV_AX_ fd, revents);
}
void feed_signal_event (int signum) throw ()
{
ev_feed_signal_event (EV_AX_ signum);
}
#if EV_MULTIPLICITY
struct ev_loop* EV_AX;
#endif
};
#if EV_MULTIPLICITY
struct dynamic_loop : loop_ref
{
dynamic_loop (unsigned int flags = AUTO) throw (bad_loop)
: loop_ref (ev_loop_new (flags))
{
if (!EV_AX)
throw bad_loop ();
}
~dynamic_loop () throw ()
{
ev_loop_destroy (EV_AX);
EV_AX = 0;
}
private:
dynamic_loop (const dynamic_loop &);
dynamic_loop & operator= (const dynamic_loop &);
};
#endif
struct default_loop : loop_ref
{
default_loop (unsigned int flags = AUTO) throw (bad_loop)
#if EV_MULTIPLICITY
: loop_ref (ev_default_loop (flags))
#endif
{
if (
#if EV_MULTIPLICITY
!EV_AX
#else
!ev_default_loop (flags)
#endif
)
throw bad_loop ();
}
private:
default_loop (const default_loop &);
default_loop &operator = (const default_loop &);
};
inline loop_ref get_default_loop () throw ()
{
#if EV_MULTIPLICITY
return ev_default_loop (0);
#else
return loop_ref ();
#endif
}
#undef EV_AX
#undef EV_AX_
#undef EV_PX
#undef EV_PX_
#if EV_MULTIPLICITY
# define EV_PX loop_ref EV_A
# define EV_PX_ loop_ref EV_A_
#else
# define EV_PX
# define EV_PX_
#endif
template<class ev_watcher, class watcher>
struct base : ev_watcher
{
#if EV_MULTIPLICITY
EV_PX;
// loop set
void set (EV_P) throw ()
{
this->EV_A = EV_A;
}
#endif
base (EV_PX) throw ()
#if EV_MULTIPLICITY
: EV_A (EV_A)
#endif
{
ev_init (this, 0);
}
void set_ (const void *data, void (*cb)(EV_P_ ev_watcher *w, int revents)) throw ()
{
this->data = (void *)data;
ev_set_cb (static_cast<ev_watcher *>(this), cb);
}
// function callback
template<void (*function)(watcher &w, int)>
void set (void *data = 0) throw ()
{
set_ (data, function_thunk<function>);
}
template<void (*function)(watcher &w, int)>
static void function_thunk (EV_P_ ev_watcher *w, int revents)
{
function
(*static_cast<watcher *>(w), revents);
}
// method callback
template<class K, void (K::*method)(watcher &w, int)>
void set (K *object) throw ()
{
set_ (object, method_thunk<K, method>);
}
// default method == operator ()
template<class K>
void set (K *object) throw ()
{
set_ (object, method_thunk<K, &K::operator ()>);
}
template<class K, void (K::*method)(watcher &w, int)>
static void method_thunk (EV_P_ ev_watcher *w, int revents)
{
(static_cast<K *>(w->data)->*method)
(*static_cast<watcher *>(w), revents);
}
// no-argument callback
template<class K, void (K::*method)()>
void set (K *object) throw ()
{
set_ (object, method_noargs_thunk<K, method>);
}
template<class K, void (K::*method)()>
static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents)
{
(static_cast<K *>(w->data)->*method)
();
}
void operator ()(int events = EV_UNDEF)
{
return
ev_cb (static_cast<ev_watcher *>(this))
(static_cast<ev_watcher *>(this), events);
}
bool is_active () const throw ()
{
return ev_is_active (static_cast<const ev_watcher *>(this));
}
bool is_pending () const throw ()
{
return ev_is_pending (static_cast<const ev_watcher *>(this));
}
void feed_event (int revents) throw ()
{
ev_feed_event (EV_A_ static_cast<ev_watcher *>(this), revents);
}
};
inline tstamp now (EV_P) throw ()
{
return ev_now (EV_A);
}
inline void delay (tstamp interval) throw ()
{
ev_sleep (interval);
}
inline int version_major () throw ()
{
return ev_version_major ();
}
inline int version_minor () throw ()
{
return ev_version_minor ();
}
inline unsigned int supported_backends () throw ()
{
return ev_supported_backends ();
}
inline unsigned int recommended_backends () throw ()
{
return ev_recommended_backends ();
}
inline unsigned int embeddable_backends () throw ()
{
return ev_embeddable_backends ();
}
inline void set_allocator (void *(*cb)(void *ptr, long size) throw ()) throw ()
{
ev_set_allocator (cb);
}
inline void set_syserr_cb (void (*cb)(const char *msg) throw ()) throw ()
{
ev_set_syserr_cb (cb);
}
#if EV_MULTIPLICITY
#define EV_CONSTRUCT(cppstem,cstem) \
(EV_PX = get_default_loop ()) throw () \
: base<ev_ ## cstem, cppstem> (EV_A) \
{ \
}
#else
#define EV_CONSTRUCT(cppstem,cstem) \
() throw () \
{ \
}
#endif
/* using a template here would require quite a few more lines,
* so a macro solution was chosen */
#define EV_BEGIN_WATCHER(cppstem,cstem) \
\
struct cppstem : base<ev_ ## cstem, cppstem> \
{ \
void start () throw () \
{ \
ev_ ## cstem ## _start (EV_A_ static_cast<ev_ ## cstem *>(this)); \
} \
\
void stop () throw () \
{ \
ev_ ## cstem ## _stop (EV_A_ static_cast<ev_ ## cstem *>(this)); \
} \
\
cppstem EV_CONSTRUCT(cppstem,cstem) \
\
~cppstem () throw () \
{ \
stop (); \
} \
\
using base<ev_ ## cstem, cppstem>::set; \
\
private: \
\
cppstem (const cppstem &o); \
\
cppstem &operator =(const cppstem &o); \
\
public:
#define EV_END_WATCHER(cppstem,cstem) \
};
EV_BEGIN_WATCHER (io, io)
void set (int fd, int events) throw ()
{
int active = is_active ();
if (active) stop ();
ev_io_set (static_cast<ev_io *>(this), fd, events);
if (active) start ();
}
void set (int events) throw ()
{
int active = is_active ();
if (active) stop ();
ev_io_set (static_cast<ev_io *>(this), fd, events);
if (active) start ();
}
void start (int fd, int events) throw ()
{
set (fd, events);
start ();
}
EV_END_WATCHER (io, io)
EV_BEGIN_WATCHER (timer, timer)
void set (ev_tstamp after, ev_tstamp repeat = 0.) throw ()
{
int active = is_active ();
if (active) stop ();
ev_timer_set (static_cast<ev_timer *>(this), after, repeat);
if (active) start ();
}
void start (ev_tstamp after, ev_tstamp repeat = 0.) throw ()
{
set (after, repeat);
start ();
}
void again () throw ()
{
ev_timer_again (EV_A_ static_cast<ev_timer *>(this));
}
ev_tstamp remaining ()
{
return ev_timer_remaining (EV_A_ static_cast<ev_timer *>(this));
}
EV_END_WATCHER (timer, timer)
#if EV_PERIODIC_ENABLE
EV_BEGIN_WATCHER (periodic, periodic)
void set (ev_tstamp at, ev_tstamp interval = 0.) throw ()
{
int active = is_active ();
if (active) stop ();
ev_periodic_set (static_cast<ev_periodic *>(this), at, interval, 0);
if (active) start ();
}
void start (ev_tstamp at, ev_tstamp interval = 0.) throw ()
{
set (at, interval);
start ();
}
void again () throw ()
{
ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this));
}
EV_END_WATCHER (periodic, periodic)
#endif
#if EV_SIGNAL_ENABLE
EV_BEGIN_WATCHER (sig, signal)
void set (int signum) throw ()
{
int active = is_active ();
if (active) stop ();
ev_signal_set (static_cast<ev_signal *>(this), signum);
if (active) start ();
}
void start (int signum) throw ()
{
set (signum);
start ();
}
EV_END_WATCHER (sig, signal)
#endif
#if EV_CHILD_ENABLE
EV_BEGIN_WATCHER (child, child)
void set (int pid, int trace = 0) throw ()
{
int active = is_active ();
if (active) stop ();
ev_child_set (static_cast<ev_child *>(this), pid, trace);
if (active) start ();
}
void start (int pid, int trace = 0) throw ()
{
set (pid, trace);
start ();
}
EV_END_WATCHER (child, child)
#endif
#if EV_STAT_ENABLE
EV_BEGIN_WATCHER (stat, stat)
void set (const char *path, ev_tstamp interval = 0.) throw ()
{
int active = is_active ();
if (active) stop ();
ev_stat_set (static_cast<ev_stat *>(this), path, interval);
if (active) start ();
}
void start (const char *path, ev_tstamp interval = 0.) throw ()
{
stop ();
set (path, interval);
start ();
}
void update () throw ()
{
ev_stat_stat (EV_A_ static_cast<ev_stat *>(this));
}
EV_END_WATCHER (stat, stat)
#endif
#if EV_IDLE_ENABLE
EV_BEGIN_WATCHER (idle, idle)
void set () throw () { }
EV_END_WATCHER (idle, idle)
#endif
#if EV_PREPARE_ENABLE
EV_BEGIN_WATCHER (prepare, prepare)
void set () throw () { }
EV_END_WATCHER (prepare, prepare)
#endif
#if EV_CHECK_ENABLE
EV_BEGIN_WATCHER (check, check)
void set () throw () { }
EV_END_WATCHER (check, check)
#endif
#if EV_EMBED_ENABLE
EV_BEGIN_WATCHER (embed, embed)
void set_embed (struct ev_loop *embedded_loop) throw ()
{
int active = is_active ();
if (active) stop ();
ev_embed_set (static_cast<ev_embed *>(this), embedded_loop);
if (active) start ();
}
void start (struct ev_loop *embedded_loop) throw ()
{
set (embedded_loop);
start ();
}
void sweep ()
{
ev_embed_sweep (EV_A_ static_cast<ev_embed *>(this));
}
EV_END_WATCHER (embed, embed)
#endif
#if EV_FORK_ENABLE
EV_BEGIN_WATCHER (fork, fork)
void set () throw () { }
EV_END_WATCHER (fork, fork)
#endif
#if EV_ASYNC_ENABLE
EV_BEGIN_WATCHER (async, async)
void send () throw ()
{
ev_async_send (EV_A_ static_cast<ev_async *>(this));
}
bool async_pending () throw ()
{
return ev_async_pending (static_cast<ev_async *>(this));
}
EV_END_WATCHER (async, async)
#endif
#undef EV_PX
#undef EV_PX_
#undef EV_CONSTRUCT
#undef EV_BEGIN_WATCHER
#undef EV_END_WATCHER
}
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* libevent compatibility layer
*
* Copyright (c) 2007,2008,2009,2010,2012 Marc Alexander Lehmann <libev@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
* CIAL, 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 OTH-
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU General Public License ("GPL") version 2 or any later version,
* in which case the provisions of the GPL are applicable instead of
* the above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use your
* version of this file under the BSD license, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete the
* provisions above, a recipient may use your version of this file under
* either the BSD or the GPL.
*/
#include <stddef.h>
#include <stdlib.h>
#include <assert.h>
#ifdef EV_EVENT_H
# include EV_EVENT_H
#else
# include "event.h"
#endif
#if EV_MULTIPLICITY
# define dLOOPev struct ev_loop *loop = (struct ev_loop *)ev->ev_base
# define dLOOPbase struct ev_loop *loop = (struct ev_loop *)base
#else
# define dLOOPev
# define dLOOPbase
#endif
/* never accessed, will always be cast from/to ev_loop */
struct event_base
{
int dummy;
};
static struct event_base *ev_x_cur;
static ev_tstamp
ev_tv_get (struct timeval *tv)
{
if (tv)
{
ev_tstamp after = tv->tv_sec + tv->tv_usec * 1e-6;
return after ? after : 1e-6;
}
else
return -1.;
}
#define EVENT_STRINGIFY(s) # s
#define EVENT_VERSION(a,b) EVENT_STRINGIFY (a) "." EVENT_STRINGIFY (b)
const char *
event_get_version (void)
{
/* returns ABI, not API or library, version */
return EVENT_VERSION (EV_VERSION_MAJOR, EV_VERSION_MINOR);
}
const char *
event_get_method (void)
{
return "libev";
}
void *event_init (void)
{
#if EV_MULTIPLICITY
if (ev_x_cur)
ev_x_cur = (struct event_base *)ev_loop_new (EVFLAG_AUTO);
else
ev_x_cur = (struct event_base *)ev_default_loop (EVFLAG_AUTO);
#else
assert (("libev: multiple event bases not supported when not compiled with EV_MULTIPLICITY", !ev_x_cur));
ev_x_cur = (struct event_base *)(long)ev_default_loop (EVFLAG_AUTO);
#endif
return ev_x_cur;
}
const char *
event_base_get_method (const struct event_base *base)
{
return "libev";
}
struct event_base *
event_base_new (void)
{
#if EV_MULTIPLICITY
return (struct event_base *)ev_loop_new (EVFLAG_AUTO);
#else
assert (("libev: multiple event bases not supported when not compiled with EV_MULTIPLICITY"));
return NULL;
#endif
}
void event_base_free (struct event_base *base)
{
dLOOPbase;
#if EV_MULTIPLICITY
if (!ev_is_default_loop (loop))
ev_loop_destroy (loop);
#endif
}
int event_dispatch (void)
{
return event_base_dispatch (ev_x_cur);
}
#ifdef EV_STANDALONE
void event_set_log_callback (event_log_cb cb)
{
/* nop */
}
#endif
int event_loop (int flags)
{
return event_base_loop (ev_x_cur, flags);
}
int event_loopexit (struct timeval *tv)
{
return event_base_loopexit (ev_x_cur, tv);
}
event_callback_fn event_get_callback
(const struct event *ev)
{
return ev->ev_callback;
}
static void
ev_x_cb (struct event *ev, int revents)
{
revents &= EV_READ | EV_WRITE | EV_TIMER | EV_SIGNAL;
ev->ev_res = revents;
ev->ev_callback (ev->ev_fd, (short)revents, ev->ev_arg);
}
static void
ev_x_cb_sig (EV_P_ struct ev_signal *w, int revents)
{
struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, iosig.sig));
if (revents & EV_ERROR)
event_del (ev);
ev_x_cb (ev, revents);
}
static void
ev_x_cb_io (EV_P_ struct ev_io *w, int revents)
{
struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, iosig.io));
if ((revents & EV_ERROR) || !(ev->ev_events & EV_PERSIST))
event_del (ev);
ev_x_cb (ev, revents);
}
static void
ev_x_cb_to (EV_P_ struct ev_timer *w, int revents)
{
struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, to));
event_del (ev);
ev_x_cb (ev, revents);
}
void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg)
{
if (events & EV_SIGNAL)
ev_init (&ev->iosig.sig, ev_x_cb_sig);
else
ev_init (&ev->iosig.io, ev_x_cb_io);
ev_init (&ev->to, ev_x_cb_to);
ev->ev_base = ev_x_cur; /* not threadsafe, but it's how libevent works */
ev->ev_fd = fd;
ev->ev_events = events;
ev->ev_pri = 0;
ev->ev_callback = cb;
ev->ev_arg = arg;
ev->ev_res = 0;
ev->ev_flags = EVLIST_INIT;
}
int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv)
{
return event_base_once (ev_x_cur, fd, events, cb, arg, tv);
}
int event_add (struct event *ev, struct timeval *tv)
{
dLOOPev;
if (ev->ev_events & EV_SIGNAL)
{
if (!ev_is_active (&ev->iosig.sig))
{
ev_signal_set (&ev->iosig.sig, ev->ev_fd);
ev_signal_start (EV_A_ &ev->iosig.sig);
ev->ev_flags |= EVLIST_SIGNAL;
}
}
else if (ev->ev_events & (EV_READ | EV_WRITE))
{
if (!ev_is_active (&ev->iosig.io))
{
ev_io_set (&ev->iosig.io, ev->ev_fd, ev->ev_events & (EV_READ | EV_WRITE));
ev_io_start (EV_A_ &ev->iosig.io);
ev->ev_flags |= EVLIST_INSERTED;
}
}
if (tv)
{
ev->to.repeat = ev_tv_get (tv);
ev_timer_again (EV_A_ &ev->to);
ev->ev_flags |= EVLIST_TIMEOUT;
}
else
{
ev_timer_stop (EV_A_ &ev->to);
ev->ev_flags &= ~EVLIST_TIMEOUT;
}
ev->ev_flags |= EVLIST_ACTIVE;
return 0;
}
int event_del (struct event *ev)
{
dLOOPev;
if (ev->ev_events & EV_SIGNAL)
ev_signal_stop (EV_A_ &ev->iosig.sig);
else if (ev->ev_events & (EV_READ | EV_WRITE))
ev_io_stop (EV_A_ &ev->iosig.io);
if (ev_is_active (&ev->to))
ev_timer_stop (EV_A_ &ev->to);
ev->ev_flags = EVLIST_INIT;
return 0;
}
void event_active (struct event *ev, int res, short ncalls)
{
dLOOPev;
if (res & EV_TIMEOUT)
ev_feed_event (EV_A_ &ev->to, res & EV_TIMEOUT);
if (res & EV_SIGNAL)
ev_feed_event (EV_A_ &ev->iosig.sig, res & EV_SIGNAL);
if (res & (EV_READ | EV_WRITE))
ev_feed_event (EV_A_ &ev->iosig.io, res & (EV_READ | EV_WRITE));
}
int event_pending (struct event *ev, short events, struct timeval *tv)
{
short revents = 0;
dLOOPev;
if (ev->ev_events & EV_SIGNAL)
{
/* sig */
if (ev_is_active (&ev->iosig.sig) || ev_is_pending (&ev->iosig.sig))
revents |= EV_SIGNAL;
}
else if (ev->ev_events & (EV_READ | EV_WRITE))
{
/* io */
if (ev_is_active (&ev->iosig.io) || ev_is_pending (&ev->iosig.io))
revents |= ev->ev_events & (EV_READ | EV_WRITE);
}
if (ev->ev_events & EV_TIMEOUT || ev_is_active (&ev->to) || ev_is_pending (&ev->to))
{
revents |= EV_TIMEOUT;
if (tv)
{
ev_tstamp at = ev_now (EV_A);
tv->tv_sec = (long)at;
tv->tv_usec = (long)((at - (ev_tstamp)tv->tv_sec) * 1e6);
}
}
return events & revents;
}
int event_priority_init (int npri)
{
return event_base_priority_init (ev_x_cur, npri);
}
int event_priority_set (struct event *ev, int pri)
{
ev->ev_pri = pri;
return 0;
}
int event_base_set (struct event_base *base, struct event *ev)
{
ev->ev_base = base;
return 0;
}
int event_base_loop (struct event_base *base, int flags)
{
dLOOPbase;
return !ev_run (EV_A_ flags);
}
int event_base_dispatch (struct event_base *base)
{
return event_base_loop (base, 0);
}
static void
ev_x_loopexit_cb (int revents, void *base)
{
dLOOPbase;
ev_break (EV_A_ EVBREAK_ONE);
}
int event_base_loopexit (struct event_base *base, struct timeval *tv)
{
ev_tstamp after = ev_tv_get (tv);
dLOOPbase;
ev_once (EV_A_ -1, 0, after >= 0. ? after : 0., ev_x_loopexit_cb, (void *)base);
return 0;
}
struct ev_x_once
{
int fd;
void (*cb)(int, short, void *);
void *arg;
};
static void
ev_x_once_cb (int revents, void *arg)
{
struct ev_x_once *once = (struct ev_x_once *)arg;
once->cb (once->fd, (short)revents, once->arg);
free (once);
}
int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv)
{
struct ev_x_once *once = (struct ev_x_once *)malloc (sizeof (struct ev_x_once));
dLOOPbase;
if (!once)
return -1;
once->fd = fd;
once->cb = cb;
once->arg = arg;
ev_once (EV_A_ fd, events & (EV_READ | EV_WRITE), ev_tv_get (tv), ev_x_once_cb, (void *)once);
return 0;
}
int event_base_priority_init (struct event_base *base, int npri)
{
/*dLOOPbase;*/
return 0;
}
/*
* libevent compatibility header, only core events supported
*
* Copyright (c) 2007,2008,2010,2012 Marc Alexander Lehmann <libev@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
* CIAL, 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 OTH-
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU General Public License ("GPL") version 2 or any later version,
* in which case the provisions of the GPL are applicable instead of
* the above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use your
* version of this file under the BSD license, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete the
* provisions above, a recipient may use your version of this file under
* either the BSD or the GPL.
*/
#ifndef EVENT_H_
#define EVENT_H_
#ifdef EV_H
# include EV_H
#else
# include "ev.h"
#endif
#ifndef EVLOOP_NONBLOCK
# define EVLOOP_NONBLOCK EVRUN_NOWAIT
#endif
#ifndef EVLOOP_ONESHOT
# define EVLOOP_ONESHOT EVRUN_ONCE
#endif
#ifndef EV_TIMEOUT
# define EV_TIMEOUT EV_TIMER
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* we need sys/time.h for struct timeval only */
#if !defined (WIN32) || defined (__MINGW32__)
# include <time.h> /* mingw seems to need this, for whatever reason */
# include <sys/time.h>
#endif
struct event_base;
#define EVLIST_TIMEOUT 0x01
#define EVLIST_INSERTED 0x02
#define EVLIST_SIGNAL 0x04
#define EVLIST_ACTIVE 0x08
#define EVLIST_INTERNAL 0x10
#define EVLIST_INIT 0x80
typedef void (*event_callback_fn)(int, short, void *);
struct event
{
/* libev watchers we map onto */
union {
struct ev_io io;
struct ev_signal sig;
} iosig;
struct ev_timer to;
/* compatibility slots */
struct event_base *ev_base;
event_callback_fn ev_callback;
void *ev_arg;
int ev_fd;
int ev_pri;
int ev_res;
int ev_flags;
short ev_events;
};
event_callback_fn event_get_callback (const struct event *ev);
#define EV_READ EV_READ
#define EV_WRITE EV_WRITE
#define EV_PERSIST 0x10
#define EV_ET 0x20 /* nop */
#define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd)
#define EVENT_FD(ev) ((int) (ev)->ev_fd)
#define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT)
#define evtimer_add(ev,tv) event_add (ev, tv)
#define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data)
#define evtimer_del(ev) event_del (ev)
#define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv)
#define evtimer_initialized(ev) event_initialized (ev)
#define timeout_add(ev,tv) evtimer_add (ev, tv)
#define timeout_set(ev,cb,data) evtimer_set (ev, cb, data)
#define timeout_del(ev) evtimer_del (ev)
#define timeout_pending(ev,tv) evtimer_pending (ev, tv)
#define timeout_initialized(ev) evtimer_initialized (ev)
#define signal_add(ev,tv) event_add (ev, tv)
#define signal_set(ev,sig,cb,data) event_set (ev, sig, EV_SIGNAL | EV_PERSIST, cb, data)
#define signal_del(ev) event_del (ev)
#define signal_pending(ev,tv) event_pending (ev, EV_SIGNAL, tv)
#define signal_initialized(ev) event_initialized (ev)
const char *event_get_version (void);
const char *event_get_method (void);
void *event_init (void);
void event_base_free (struct event_base *base);
#define EVLOOP_ONCE EVLOOP_ONESHOT
int event_loop (int);
int event_loopexit (struct timeval *tv);
int event_dispatch (void);
#define _EVENT_LOG_DEBUG 0
#define _EVENT_LOG_MSG 1
#define _EVENT_LOG_WARN 2
#define _EVENT_LOG_ERR 3
typedef void (*event_log_cb)(int severity, const char *msg);
void event_set_log_callback(event_log_cb cb);
void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg);
int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv);
int event_add (struct event *ev, struct timeval *tv);
int event_del (struct event *ev);
void event_active (struct event *ev, int res, short ncalls); /* ncalls is being ignored */
int event_pending (struct event *ev, short, struct timeval *tv);
int event_priority_init (int npri);
int event_priority_set (struct event *ev, int pri);
struct event_base *event_base_new (void);
const char *event_base_get_method (const struct event_base *);
int event_base_set (struct event_base *base, struct event *ev);
int event_base_loop (struct event_base *base, int);
int event_base_loopexit (struct event_base *base, struct timeval *tv);
int event_base_dispatch (struct event_base *base);
int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv);
int event_base_priority_init (struct event_base *base, int fd);
/* next line is different in the libevent+libev version */
/*libevent-include*/
#ifdef __cplusplus
}
#endif
#endif
......@@ -215,7 +215,12 @@ def configure_ares(bext, ext):
try:
if os.path.exists('ares_config.h') and os.path.exists('ares_build.h'):
return
rc = _system(ares_configure_command)
try:
rc = _system(ares_configure_command)
except:
with open('configure-output.txt', 'r') as t:
print(t.read(), file=sys.stderr)
raise
if rc == 0 and sys.platform == 'darwin':
make_universal_header('ares_build.h', 'CARES_SIZEOF_LONG')
make_universal_header('ares_config.h', 'SIZEOF_LONG', 'SIZEOF_SIZE_T', 'SIZEOF_TIME_T')
......@@ -241,6 +246,13 @@ else:
if CARES_EMBED:
ARES.sources += expand('c-ares/*.c')
# Strip the standalone binaries that would otherwise
# cause linking issues
for bin_c in ('acountry', 'adig', 'ahost'):
try:
ARES.sources.remove('c-ares/' + bin_c + '.c')
except ValueError:
pass
ARES.configure = configure_ares
if WIN:
ARES.libraries += ['advapi32']
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment