Move repeated test pattern to server_test_type

Use static function to test similar checks in multiple places.
diff --git a/src/forward.c b/src/forward.c
index 8b1698b..fcc5972 100644
--- a/src/forward.c
+++ b/src/forward.c
@@ -284,6 +284,14 @@
 }
 #endif
 
+static int server_test_type(const struct server *server,
+			    const char *domain, int type, int extratype)
+{
+  return (type == (server->flags & (SERV_TYPE | extratype)) &&
+      (type != SERV_HAS_DOMAIN || hostname_isequal(domain, server->domain)) &&
+      !(server->flags & (SERV_LITERAL_ADDRESS | SERV_LOOP)));
+}
+
 static int forward_query(int udpfd, union mysockaddr *udpaddr,
 			 union all_addr *dst_addr, unsigned int dst_iface,
 			 struct dns_header *header, size_t plen, time_t now, 
@@ -538,9 +546,7 @@
 	     domain may be NULL, in which case server->domain 
 	     must be NULL also. */
 	  
-	  if (type == (start->flags & SERV_TYPE) &&
-	      (type != SERV_HAS_DOMAIN || hostname_isequal(domain, start->domain)) &&
-	      !(start->flags & (SERV_LITERAL_ADDRESS | SERV_LOOP)) &&
+	  if (server_test_type(start, domain, type, 0) &&
 	      ((fd = allocate_rfd(&forward->rfds, start)) != -1))
 	    {
 	      
@@ -1076,9 +1082,7 @@
 			  
 			  while (1)
 			    {
-			      if (type == (start->flags & (SERV_TYPE | SERV_DO_DNSSEC)) &&
-				  ((type & SERV_TYPE) != SERV_HAS_DOMAIN || hostname_isequal(domain, start->domain)) &&
-				  !(start->flags & (SERV_LITERAL_ADDRESS | SERV_LOOP)))
+			      if (server_test_type(start, domain, type, 0))
 				{
 				  new_server = start;
 				  if (server == start)
@@ -1662,9 +1666,7 @@
 		}
 	    }
 	  
-	  if (type != (server->flags & (SERV_TYPE | SERV_DO_DNSSEC)) ||
-	      (type == SERV_HAS_DOMAIN && !hostname_isequal(domain, server->domain)) ||
-	      (server->flags & (SERV_LITERAL_ADDRESS | SERV_LOOP)))
+	  if (!server_test_type(server, domain, type, SERV_DO_DNSSEC))
 	    continue;
 
 	retry:
@@ -1976,9 +1978,7 @@
 			}
 		      
 		      /* server for wrong domain */
-		      if (type != (last_server->flags & SERV_TYPE) ||
-			  (type == SERV_HAS_DOMAIN && !hostname_isequal(domain, last_server->domain)) ||
-			  (last_server->flags & (SERV_LITERAL_ADDRESS | SERV_LOOP)))
+		      if (!server_test_type(last_server, domain, type, 0))
 			continue;
 
 		    retry: