constification
[exim.git] / src / src / dns.c
index f492613c4785f0e8141718cd94198ef7469316cb..79eb9360e0b1a11120dbffdf2ac43e48be8ae487 100644 (file)
@@ -257,9 +257,9 @@ Returns:     nothing
 */
 
 void
-dns_build_reverse(uschar *string, uschar *buffer)
+dns_build_reverse(const uschar *string, uschar *buffer)
 {
-uschar *p = string + Ustrlen(string);
+const uschar *p = string + Ustrlen(string);
 uschar *pp = buffer;
 
 /* Handle IPv4 address */
@@ -271,7 +271,7 @@ if (Ustrchr(string, ':') == NULL)
   int i;
   for (i = 0; i < 4; i++)
     {
-    uschar *ppp = p;
+    const uschar *ppp = p;
     while (ppp > string && ppp[-1] != '.') ppp--;
     Ustrncpy(pp, ppp, p - ppp);
     pp += p - ppp;
@@ -560,7 +560,7 @@ dns_basic_lookup(dns_answer *dnsa, const uschar *name, int type)
 {
 #ifndef STAND_ALONE
 int rc = -1;
-uschar *save;
+const uschar *save_domain;
 #endif
 res_state resp = os_get_dns_resolver_res();
 
@@ -607,9 +607,7 @@ if (check_dns_names_pattern[0] != 0 && type != T_PTR && type != T_TXT)
   const uschar *checkname = name;
   int ovector[3*(EXPAND_MAXN+1)];
 
-  if (regex_check_dns_names == NULL)
-    regex_check_dns_names =
-      regex_must_compile(check_dns_names_pattern, FALSE, TRUE);
+  dns_pattern_init();
 
   /* For an SRV lookup, skip over the first two components (the service and
   protocol names, which both start with an underscore). */
@@ -679,11 +677,11 @@ if (dnsa->answerlen < 0) switch (h_errno)
 
   /* Cut this out for various test programs */
 #ifndef STAND_ALONE
-  save = deliver_domain;
+  save_domain = deliver_domain;
   deliver_domain = string_copy(name);  /* set $domain */
-  rc = match_isinlist(name, &dns_again_means_nonexist, 0, NULL, NULL,
+  rc = match_isinlist(name, (const uschar **)&dns_again_means_nonexist, 0, NULL, NULL,
     MCL_DOMAIN, TRUE, NULL);
-  deliver_domain = save;
+  deliver_domain = save_domain;
   if (rc != OK)
     {
     DEBUG(D_dns) debug_printf("returning DNS_AGAIN\n");
@@ -757,7 +755,7 @@ Returns:                DNS_SUCCEED   successful lookup
 
 int
 dns_lookup(dns_answer *dnsa, const uschar *name, int type,
-  uschar **fully_qualified_name)
+  const uschar **fully_qualified_name)
 {
 int i;
 const uschar *orig_name = name;
@@ -876,7 +874,7 @@ Returns:                DNS_SUCCEED   successful lookup
 
 int
 dns_special_lookup(dns_answer *dnsa, const uschar *name, int type,
-  uschar **fully_qualified_name)
+  const uschar **fully_qualified_name)
 {
 if (type >= 0) return dns_lookup(dnsa, name, type, fully_qualified_name);
 
@@ -1272,6 +1270,16 @@ else
 return yield;
 }
 
+
+
+void
+dns_pattern_init(void)
+{
+if (check_dns_names_pattern[0] != 0 && !regex_check_dns_names)
+  regex_check_dns_names =
+    regex_must_compile(check_dns_names_pattern, FALSE, TRUE);
+}
+
 /* vi: aw ai sw=2
 */
 /* End of dns.c */