Reload strlist and iplist resource-files only when needed.
[apps/pfixtools.git] / postlicyd / query.h
index 86e41ba..9dabfe0 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "mem.h"
 #include "common.h"
+#include "policy_tokens.h"
 
 enum smtp_state {
     SMTP_CONNECT,
@@ -54,6 +55,8 @@ enum smtp_state {
     SMTP_UNKNOWN,
 };
 
+extern const char *smtp_state_names[SMTP_count];
+
 /* \see http://www.postfix.org/SMTPD_POLICY_README.html */
 typedef struct query_t {
     unsigned state : 4;
@@ -102,4 +105,21 @@ typedef struct query_t {
 __attribute__((nonnull(1,2)))
 bool query_parse(query_t *query, char *p);
 
+/** Return the value of the field with the given name.
+ */
+__attribute__((nonnull(1,2)))
+const char *query_field_for_name(const query_t *query, const char *name);
+
+/** Returns the value of the field with the given id.
+ */
+__attribute__((nonnull))
+const char *query_field_for_id(const query_t *query, postlicyd_token id);
+
+/** Formats the given string by replacing ${field_name} with the content
+ * of the query.
+ * Unknown and empty fields are filled with (null).
+ */
+__attribute__((nonnull(3)))
+ssize_t query_format(char *dest, size_t len, const char* fmt, const query_t *query);
+
 #endif