Add likely/unlikely macros.
[apps/pfixtools.git] / postlicyd / query.h
index b11991c..87ee01e 100644 (file)
@@ -38,9 +38,9 @@
 #define PFIXTOOLS_QUERY_H
 
 #include "mem.h"
+#include "common.h"
 
 enum smtp_state {
-    SMTP_UNKNOWN,
     SMTP_CONNECT,
     SMTP_EHLO,
     SMTP_HELO = SMTP_EHLO,
@@ -50,6 +50,8 @@ enum smtp_state {
     SMTP_END_OF_MESSAGE,
     SMTP_VRFY,
     SMTP_ETRN,
+    SMTP_count,
+    SMTP_UNKNOWN,
 };
 
 /* \see http://www.postfix.org/SMTPD_POLICY_README.html */
@@ -67,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;
@@ -100,4 +106,12 @@ static inline void query_delete(query_t **query)
     }
 }
 
+/** Parse the content of the text to fill the query.
+ * The text pointed by \p p is segmented (and modified to add
+ * a \0 at the end of each segment) and used to fill the query
+ * object.
+ */
+__attribute__((nonnull(1,2)))
+bool query_parse(query_t *query, char *p);
+
 #endif