Added the long-awaited ${if match_ip condition.
[exim.git] / src / src / match.c
index 7c30e056c8ab86d6beea6493f2b28ada96706f4d..18f1a3791ee401ca138513436a687f34e1430d6e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/match.c,v 1.3 2005/01/04 10:00:42 ph10 Exp $ */
+/* $Cambridge: exim/src/src/match.c,v 1.6 2005/06/22 10:17:23 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -630,9 +630,11 @@ while ((sss = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL)
             store_pool = POOL_PERM;
             p = store_get(sizeof(namedlist_cacheblock));
             p->key = string_copy(get_check_key(arg, type));
+
+
+            p->data = (*valueptr == NULL)? NULL : string_copy(*valueptr);
             store_pool = old_pool;
 
-            p->data = *valueptr;
             p->next = nb->cache_data;
             nb->cache_data = p;
             if (*valueptr != NULL)
@@ -695,8 +697,9 @@ while ((sss = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL)
         case DEFER:
         goto DEFER_RETURN;
 
-        /* The ERROR return occurs only when checking hosts, when either a
-        forward or reverse lookup has failed. The error string gives details of
+        /* The ERROR return occurs when checking hosts, when either a forward
+        or reverse lookup has failed. It can also occur in a match_ip list if a
+        non-IP address item is encountered. The error string gives details of
         which it was. */
 
         case ERROR:
@@ -932,7 +935,7 @@ error = error;  /* Keep clever compilers from complaining */
 DEBUG(D_lists) debug_printf("address match: subject=%s pattern=%s\n",
   subject, pattern);
 
-/* Handle a regular expression, which must match the entire incoming address. 
+/* Handle a regular expression, which must match the entire incoming address.
 This may be the empty address. */
 
 if (*pattern == '^')
@@ -947,7 +950,7 @@ for (s = pattern; isalnum(*s) || *s == '-'; s++);
 if (*s == '*') s++;
 if (*s == '@') s++;
 
-/* If it is a straight lookup, do a lookup for the whole address. This may be 
+/* If it is a straight lookup, do a lookup for the whole address. This may be
 the empty address. Partial matching doesn't make sense here, so we ignore it,
 but write a panic log entry. However, *@ matching will be honoured. */
 
@@ -960,8 +963,8 @@ if (*s == ';')
     valueptr);
   }
 
-/* For the remaining cases, an empty subject matches only an empty pattern, 
-because other patterns expect to have a local part and a domain to match 
+/* For the remaining cases, an empty subject matches only an empty pattern,
+because other patterns expect to have a local part and a domain to match
 against. */
 
 if (*subject == 0) return (*pattern == 0)? OK : FAIL;