8597553
commit 037751179905c7d6d624f287029237565465fa9a
8597553
Author: Florian Weimer <fweimer@redhat.com>
8597553
Date:   Fri Jun 30 11:31:54 2017 +0200
8597553
8597553
    resolv: Move res_query, res_search res_querydomain, hostalias
8597553
    
8597553
    From res_data.c to query.c
8597553
8597553
diff --git a/resolv/res_data.c b/resolv/res_data.c
8597553
index b790b4b725bc9edd..5e7688c706bf8e99 100644
8597553
--- a/resolv/res_data.c
8597553
+++ b/resolv/res_data.c
8597553
@@ -15,35 +15,7 @@
8597553
  * SOFTWARE.
8597553
  */
8597553
 
8597553
-#include <sys/types.h>
8597553
-#include <sys/param.h>
8597553
-#include <sys/socket.h>
8597553
-#include <sys/time.h>
8597553
-
8597553
-#include <netinet/in.h>
8597553
-#include <arpa/inet.h>
8597553
-#include <arpa/nameser.h>
8597553
-
8597553
-#include <ctype.h>
8597553
-#include <netdb.h>
8597553
 #include <resolv.h>
8597553
-#include <stdio.h>
8597553
-#include <stdlib.h>
8597553
-#include <string.h>
8597553
-#include <unistd.h>
8597553
-
8597553
-int
8597553
-res_query(const char *name,	/* domain name */
8597553
-	  int class, int type,	/* class and type of query */
8597553
-	  u_char *answer,	/* buffer to put answer */
8597553
-	  int anslen)		/* size of answer buffer */
8597553
-{
8597553
-	if (__res_maybe_init (&_res, 1) == -1) {
8597553
-		RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
8597553
-		return (-1);
8597553
-	}
8597553
-	return (res_nquery(&_res, name, class, type, answer, anslen));
8597553
-}
8597553
 
8597553
 void
8597553
 res_close(void) {
8597553
@@ -60,55 +32,3 @@ res_close(void) {
8597553
 	   did it and it would be done implicitly on shutdown.  */
8597553
 	__res_iclose(&_res, false);
8597553
 }
8597553
-
8597553
-int
8597553
-res_search(const char *name,	/* domain name */
8597553
-	   int class, int type,	/* class and type of query */
8597553
-	   u_char *answer,	/* buffer to put answer */
8597553
-	   int anslen)		/* size of answer */
8597553
-{
8597553
-	if (__res_maybe_init (&_res, 1) == -1) {
8597553
-		RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
8597553
-		return (-1);
8597553
-	}
8597553
-
8597553
-	return (res_nsearch(&_res, name, class, type, answer, anslen));
8597553
-}
8597553
-
8597553
-int
8597553
-res_querydomain(const char *name,
8597553
-		const char *domain,
8597553
-		int class, int type,	/* class and type of query */
8597553
-		u_char *answer,		/* buffer to put answer */
8597553
-		int anslen)		/* size of answer */
8597553
-{
8597553
-	if (__res_maybe_init (&_res, 1) == -1) {
8597553
-		RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
8597553
-		return (-1);
8597553
-	}
8597553
-
8597553
-	return (res_nquerydomain(&_res, name, domain,
8597553
-				 class, type,
8597553
-				 answer, anslen));
8597553
-}
8597553
-
8597553
-const char *
8597553
-hostalias(const char *name) {
8597553
-	static char abuf[MAXDNAME];
8597553
-
8597553
-	return (res_hostalias(&_res, name, abuf, sizeof abuf));
8597553
-}
8597553
-libresolv_hidden_def (hostalias)
8597553
-
8597553
-
8597553
-
8597553
-#include <shlib-compat.h>
8597553
-
8597553
-#if SHLIB_COMPAT(libresolv, GLIBC_2_0, GLIBC_2_2)
8597553
-# undef res_query
8597553
-# undef res_querydomain
8597553
-# undef res_search
8597553
-weak_alias (__res_query, res_query);
8597553
-weak_alias (__res_querydomain, res_querydomain);
8597553
-weak_alias (__res_search, res_search);
8597553
-#endif
8597553
diff --git a/resolv/res_query.c b/resolv/res_query.c
8597553
index 0ca3a650282ec7f0..5312c8e729c39516 100644
8597553
--- a/resolv/res_query.c
8597553
+++ b/resolv/res_query.c
8597553
@@ -78,7 +78,7 @@
8597553
 #include <stdio.h>
8597553
 #include <stdlib.h>
8597553
 #include <string.h>
8597553
-#include <resolv/resolv-internal.h>
8597553
+#include <shlib-compat.h>
8597553
 
8597553
 /* Options.  Leave them on. */
8597553
 /* #undef DEBUG */
8597553
@@ -319,6 +319,18 @@ res_nquery(res_state statp,
8597553
 }
8597553
 libresolv_hidden_def (res_nquery)
8597553
 
8597553
+int
8597553
+res_query (const char *name, int class, int type,
8597553
+	   unsigned char *answer, int anslen)
8597553
+{
8597553
+  if (__res_maybe_init (&_res, 1) == -1)
8597553
+    {
8597553
+      RES_SET_H_ERRNO (&_res, NETDB_INTERNAL);
8597553
+      return -1;
8597553
+    }
8597553
+  return res_nquery (&_res, name, class, type, answer, anslen);
8597553
+}
8597553
+
8597553
 /*
8597553
  * Formulate a normal query, send, and retrieve answer in supplied buffer.
8597553
  * Return the size of the response on success, -1 on error.
8597553
@@ -545,6 +557,19 @@ res_nsearch(res_state statp,
8597553
 }
8597553
 libresolv_hidden_def (res_nsearch)
8597553
 
8597553
+int
8597553
+res_search (const char *name, int class, int type,
8597553
+	    unsigned char *answer, int anslen)
8597553
+{
8597553
+  if (__res_maybe_init (&_res, 1) == -1)
8597553
+    {
8597553
+      RES_SET_H_ERRNO (&_res, NETDB_INTERNAL);
8597553
+      return -1;
8597553
+    }
8597553
+
8597553
+  return res_nsearch (&_res, name, class, type, answer, anslen);
8597553
+}
8597553
+
8597553
 /*
8597553
  * Perform a call on res_query on the concatenation of name and domain.
8597553
  */
8597553
@@ -610,6 +635,19 @@ res_nquerydomain(res_state statp,
8597553
 }
8597553
 libresolv_hidden_def (res_nquerydomain)
8597553
 
8597553
+int
8597553
+res_querydomain (const char *name, const char *domain, int class, int type,
8597553
+		 unsigned char *answer, int anslen)
8597553
+{
8597553
+  if (__res_maybe_init (&_res, 1) == -1)
8597553
+    {
8597553
+      RES_SET_H_ERRNO (&_res, NETDB_INTERNAL);
8597553
+      return -1;
8597553
+    }
8597553
+
8597553
+  return res_nquerydomain (&_res, name, domain, class, type, answer, anslen);
8597553
+}
8597553
+
8597553
 const char *
8597553
 res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) {
8597553
 	char *file, *cp1, *cp2;
8597553
@@ -647,3 +685,20 @@ res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) {
8597553
 	return (NULL);
8597553
 }
8597553
 libresolv_hidden_def (res_hostalias)
8597553
+
8597553
+const char *
8597553
+hostalias (const char *name)
8597553
+{
8597553
+  static char abuf[MAXDNAME];
8597553
+  return res_hostalias (&_res, name, abuf, sizeof abuf);
8597553
+}
8597553
+libresolv_hidden_def (hostalias)
8597553
+
8597553
+#if SHLIB_COMPAT (libresolv, GLIBC_2_0, GLIBC_2_2)
8597553
+# undef res_query
8597553
+# undef res_querydomain
8597553
+# undef res_search
8597553
+weak_alias (__res_query, res_query);
8597553
+weak_alias (__res_querydomain, res_querydomain);
8597553
+weak_alias (__res_search, res_search);
8597553
+#endif