summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2011-03-23 12:44:42 (GMT)
committerYang Tse <yangsita@gmail.com>2011-03-23 12:44:42 (GMT)
commit822fd0f8771d3792da0a08276ab0400b2a68f07e (patch)
treef271d9fa9eb15e8d170723ab632828656953f257
parent3abad87d88fc77295230ed8c732f24bfb05f4397 (diff)
downloadc-ares-822fd0f8771d3792da0a08276ab0400b2a68f07e.zip
c-ares-822fd0f8771d3792da0a08276ab0400b2a68f07e.tar.gz
c-ares-822fd0f8771d3792da0a08276ab0400b2a68f07e.tar.bz2
build: use getenv() replacement function for systems which lack it
-rw-r--r--Makefile.inc2
-rw-r--r--Makefile.netware1
-rw-r--r--ares_getenv.c30
-rw-r--r--ares_getenv.h26
-rw-r--r--ares_private.h5
-rw-r--r--config-dos.h1
-rw-r--r--config-win32.h3
-rw-r--r--configure.ac1
-rw-r--r--m4/cares-functions.m489
-rw-r--r--vc/cares/vc6cares.dsp8
10 files changed, 164 insertions, 2 deletions
diff --git a/Makefile.inc b/Makefile.inc
index 6a68fce..13dcb07 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -11,6 +11,7 @@ CSOURCES = ares__close_sockets.c \
ares_fds.c \
ares_free_hostent.c \
ares_free_string.c \
+ ares_getenv.c \
ares_gethostbyaddr.c \
ares_gethostbyname.c \
ares_getnameinfo.c \
@@ -47,6 +48,7 @@ HHEADERS = ares.h \
ares_build.h \
ares_data.h \
ares_dns.h \
+ ares_getenv.h \
ares_ipv6.h \
ares_library_init.h \
ares_llist.h \
diff --git a/Makefile.netware b/Makefile.netware
index 1e014ed..0cb1530 100644
--- a/Makefile.netware
+++ b/Makefile.netware
@@ -357,6 +357,7 @@ endif
@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) >> $@
diff --git a/ares_getenv.c b/ares_getenv.c
new file mode 100644
index 0000000..1b2e85d
--- /dev/null
+++ b/ares_getenv.c
@@ -0,0 +1,30 @@
+
+
+/* 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"
+#include "ares_getenv.h"
+
+#ifndef HAVE_GETENV
+
+char *ares_getenv(const char *name)
+{
+#ifdef _WIN32_WCE
+ return NULL;
+#endif
+}
+
+#endif
diff --git a/ares_getenv.h b/ares_getenv.h
new file mode 100644
index 0000000..6da6cc5
--- /dev/null
+++ b/ares_getenv.h
@@ -0,0 +1,26 @@
+#ifndef HEADER_CARES_GETENV_H
+#define HEADER_CARES_GETENV_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.
+ */
+
+#include "ares_setup.h"
+
+#ifndef HAVE_GETENV
+extern char *ares_getenv(const char *name);
+#endif
+
+#endif /* HEADER_CARES_GETENV_H */
diff --git a/ares_private.h b/ares_private.h
index bf21abd..01a79b6 100644
--- a/ares_private.h
+++ b/ares_private.h
@@ -89,6 +89,11 @@
#include "ares_ipv6.h"
#include "ares_llist.h"
+#ifndef HAVE_GETENV
+# include "ares_getenv.h"
+# define getenv(ptr) ares_getenv(ptr)
+#endif
+
#ifndef HAVE_STRDUP
# include "ares_strdup.h"
# define strdup(ptr) ares_strdup(ptr)
diff --git a/config-dos.h b/config-dos.h
index c74425e..d15a177 100644
--- a/config-dos.h
+++ b/config-dos.h
@@ -9,6 +9,7 @@
#define PACKAGE "c-ares"
#define HAVE_ERRNO_H 1
+#define HAVE_GETENV 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_IOCTLSOCKET 1
#define HAVE_IOCTLSOCKET_FIONBIO 1
diff --git a/config-win32.h b/config-win32.h
index 5d13f4c..d426c47 100644
--- a/config-win32.h
+++ b/config-win32.h
@@ -93,6 +93,9 @@
/* Define if you have the closesocket function. */
#define HAVE_CLOSESOCKET 1
+/* Define if you have the getenv function. */
+#define HAVE_GETENV 1
+
/* Define if you have the gethostname function. */
#define HAVE_GETHOSTNAME 1
diff --git a/configure.ac b/configure.ac
index 6f5f9d3..d5be61c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -524,6 +524,7 @@ CARES_CHECK_FUNC_CONNECT
CARES_CHECK_FUNC_FCNTL
CARES_CHECK_FUNC_FREEADDRINFO
CARES_CHECK_FUNC_GETADDRINFO
+CARES_CHECK_FUNC_GETENV
CARES_CHECK_FUNC_GETHOSTBYADDR
CARES_CHECK_FUNC_GETHOSTBYNAME
CARES_CHECK_FUNC_GETHOSTNAME
diff --git a/m4/cares-functions.m4 b/m4/cares-functions.m4
index 28fb1e5..bddd9b4 100644
--- a/m4/cares-functions.m4
+++ b/m4/cares-functions.m4
@@ -1,6 +1,6 @@
#***************************************************************************
#
-# Copyright (C) 2008 - 2010 by Daniel Stenberg et al
+# Copyright (C) 2008 - 2011 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
@@ -15,7 +15,7 @@
#***************************************************************************
# File version for 'aclocal' use. Keep it a single number.
-# serial 40
+# serial 41
dnl CARES_INCLUDES_ARPA_INET
@@ -1084,6 +1084,91 @@ AC_DEFUN([CARES_CHECK_FUNC_GETADDRINFO], [
])
+dnl CARES_CHECK_FUNC_GETENV
+dnl -------------------------------------------------
+dnl Verify if getenv is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable cares_disallow_getenv, then
+dnl HAVE_GETENV will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_GETENV], [
+ AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl
+ #
+ tst_links_getenv="unknown"
+ tst_proto_getenv="unknown"
+ tst_compi_getenv="unknown"
+ tst_allow_getenv="unknown"
+ #
+ AC_MSG_CHECKING([if getenv can be linked])
+ AC_LINK_IFELSE([
+ AC_LANG_FUNC_LINK_TRY([getenv])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_links_getenv="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_links_getenv="no"
+ ])
+ #
+ if test "$tst_links_getenv" = "yes"; then
+ AC_MSG_CHECKING([if getenv is prototyped])
+ AC_EGREP_CPP([getenv],[
+ $cares_includes_stdlib
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_proto_getenv="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_proto_getenv="no"
+ ])
+ fi
+ #
+ if test "$tst_proto_getenv" = "yes"; then
+ AC_MSG_CHECKING([if getenv is compilable])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $cares_includes_stdlib
+ ]],[[
+ if(0 != getenv(0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_getenv="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_getenv="no"
+ ])
+ fi
+ #
+ if test "$tst_compi_getenv" = "yes"; then
+ AC_MSG_CHECKING([if getenv usage allowed])
+ if test "x$cares_disallow_getenv" != "xyes"; then
+ AC_MSG_RESULT([yes])
+ tst_allow_getenv="yes"
+ else
+ AC_MSG_RESULT([no])
+ tst_allow_getenv="no"
+ fi
+ fi
+ #
+ AC_MSG_CHECKING([if getenv might be used])
+ if test "$tst_links_getenv" = "yes" &&
+ test "$tst_proto_getenv" = "yes" &&
+ test "$tst_compi_getenv" = "yes" &&
+ test "$tst_allow_getenv" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED(HAVE_GETENV, 1,
+ [Define to 1 if you have the getenv function.])
+ ac_cv_func_getenv="yes"
+ else
+ AC_MSG_RESULT([no])
+ ac_cv_func_getenv="no"
+ fi
+])
+
+
dnl CARES_CHECK_FUNC_GETHOSTBYADDR
dnl -------------------------------------------------
dnl Verify if gethostbyaddr is available, prototyped,
diff --git a/vc/cares/vc6cares.dsp b/vc/cares/vc6cares.dsp
index 866f6f5..dc124ff 100644
--- a/vc/cares/vc6cares.dsp
+++ b/vc/cares/vc6cares.dsp
@@ -198,6 +198,10 @@ SOURCE=..\..\ares_free_string.c
# End Source File
# Begin Source File
+SOURCE=..\..\ares_getenv.c
+# End Source File
+# Begin Source File
+
SOURCE=..\..\ares_gethostbyaddr.c
# End Source File
# Begin Source File
@@ -342,6 +346,10 @@ SOURCE=..\..\ares_dns.h
# End Source File
# Begin Source File
+SOURCE=..\..\ares_getenv.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\ares_ipv6.h
# End Source File
# Begin Source File