X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=postlicyd%2Fquery.c;h=4a4ae9ca8a80e6fb75f19bf03341efe3f5a5b1eb;hb=c00b60854ba8968b9e91da74096d913c084139c5;hp=fe370b75244e505574e71d5b4d4461d9e1848c63;hpb=c091e1809626636627a2824d6a2dfedeab3a4d24;p=apps%2Fpfixtools.git diff --git a/postlicyd/query.c b/postlicyd/query.c index fe370b7..4a4ae9c 100644 --- a/postlicyd/query.c +++ b/postlicyd/query.c @@ -38,6 +38,17 @@ #include "policy_tokens.h" #include "str.h" +const char *smtp_state_names[SMTP_count] = { + "CONNECT", + "HELO", + "MAIL", + "RCPT", + "DATA", + "END-OF-MESSAGE", + "VRFY", + "ETRN", +}; + bool query_parse(query_t *query, char *p) { #define PARSE_CHECK(expr, error, ...) \ @@ -179,6 +190,12 @@ const char *query_field_for_id(const query_t *query, postlicyd_token id) CASE(ETRN_DOMAIN, etrn_domain) CASE(STRESS, stress) #undef CASE + case PTK_PROTOCOL_NAME: + return query->esmtp ? "ESMTP" : "SMTP"; + + case PTK_PROTOCOL_STATE: + return smtp_state_names[query->state]; + default: return NULL; } } @@ -225,7 +242,7 @@ ssize_t query_format(char *dest, size_t len, const char *fmt, const query_t *que postlicyd_token tok = policy_tokenize(fmt, next_format - fmt); if (tok == PTK_UNKNOWN) { - warn("unknown field name \"%.*s\"", next_format - fmt, fmt); + warn("unknown field name \"%.*s\"", (int)(next_format - fmt), fmt); } const char *field = query == NULL ? NULL : query_field_for_id(query, tok); if (field == NULL) {