Add query->(recipient|sender)_domain
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 4 Oct 2008 10:39:46 +0000 (12:39 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 4 Oct 2008 10:39:46 +0000 (12:39 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
postlicyd/query.c
postlicyd/query.h

index 26b590a..327c2b7 100644 (file)
@@ -72,8 +72,6 @@ bool query_parse(query_t *query, char *p)
 #define CASE(up, low)  case PTK_##up: query->low = v; v[vlen] = '\0';  break;
             CASE(HELO_NAME,           helo_name);
             CASE(QUEUE_ID,            queue_id);
-            CASE(SENDER,              sender);
-            CASE(RECIPIENT,           recipient);
             CASE(RECIPIENT_COUNT,     recipient_count);
             CASE(CLIENT_ADDRESS,      client_address);
             CASE(CLIENT_NAME,         client_name);
@@ -93,6 +91,24 @@ bool query_parse(query_t *query, char *p)
             CASE(STRESS,              stress);
 #undef CASE
 
+          case PTK_SENDER:
+            query->sender = v;
+            v[vlen] = '\0';
+            query->sender_domain = memchr(query->sender, '@', vlen);
+            if (query->sender_domain != NULL) {
+                ++query->sender_domain;
+            }
+            break;
+
+          case PTK_RECIPIENT:
+            query->recipient = v;
+            v[vlen] = '\0';
+            query->recipient_domain = memchr(query->recipient, '@', vlen);
+            if (query->recipient_domain != NULL) {
+                ++query->recipient_domain;
+            }
+            break;
+
           case PTK_REQUEST:
             PARSE_CHECK(vtk == PTK_SMTPD_ACCESS_POLICY,
                         "unexpected `request' value: %.*s", vlen, v);
index f9cd0b6..87ee01e 100644 (file)
@@ -69,6 +69,10 @@ typedef struct query_t {
     const char *reverse_client_name;
     const char *instance;
 
+    /* useful data extracted from previous ones */
+    const char *sender_domain;
+    const char *recipient_domain;
+
     /* postfix 2.2+ */
     const char *sasl_method;
     const char *sasl_username;