X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=postlicyd%2Fquery.h;h=1443d65e107cbad3b65a6fc14dcec674dd6d8df8;hb=e327d3786ba0371eaaff8e6ba0fe3fc39f095ae2;hp=b11991c552b0cdf77279f42b7d71ae8adfa3cf70;hpb=9b993811fe1fd208afd954e86c0bfc81a78af04f;p=apps%2Fpfixtools.git diff --git a/postlicyd/query.h b/postlicyd/query.h index b11991c..1443d65 100644 --- a/postlicyd/query.h +++ b/postlicyd/query.h @@ -38,9 +38,10 @@ #define PFIXTOOLS_QUERY_H #include "mem.h" +#include "common.h" +#include "policy_tokens.h" enum smtp_state { - SMTP_UNKNOWN, SMTP_CONNECT, SMTP_EHLO, SMTP_HELO = SMTP_EHLO, @@ -50,6 +51,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 +70,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; @@ -88,16 +95,22 @@ typedef struct query_t { const char *eoq; } query_t; -static inline query_t *query_new(void) -{ - return p_new(query_t, 1); -} +/** 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); -static inline void query_delete(query_t **query) -{ - if (*query) { - p_delete(query); - } -} +/** 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); #endif