/src/dovecot/src/lib-smtp/smtp-reply.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef SMTP_REPLY_H |
2 | | #define SMTP_REPLY_H |
3 | | |
4 | | struct smtp_reply_enhanced_code { |
5 | | /* x:class, y:subject, z:detail; |
6 | | x==0 means no enhanced code present |
7 | | x==9 means invalid/missing enhanced code in reply |
8 | | */ |
9 | | unsigned int x, y, z; |
10 | | }; |
11 | | |
12 | | struct smtp_reply { |
13 | | unsigned int status; |
14 | | |
15 | | struct smtp_reply_enhanced_code enhanced_code; |
16 | | |
17 | | const char *const *text_lines; |
18 | | }; |
19 | | |
20 | | #define SMTP_REPLY_ENH_CODE(x, y, z) \ |
21 | 0 | (const struct smtp_reply_enhanced_code){(x), (y), (z)} |
22 | | #define SMTP_REPLY_ENH_CODE_NONE SMTP_REPLY_ENH_CODE(0, 0, 0) |
23 | | |
24 | | static inline bool |
25 | | smtp_reply_has_enhanced_code(const struct smtp_reply *reply) |
26 | 0 | { |
27 | 0 | return reply->enhanced_code.x > 1 && reply->enhanced_code.x < 6; |
28 | 0 | } Unexecuted instantiation: smtp-server-reply.c:smtp_reply_has_enhanced_code Unexecuted instantiation: smtp-server-command.c:smtp_reply_has_enhanced_code Unexecuted instantiation: smtp-server-recipient.c:smtp_reply_has_enhanced_code Unexecuted instantiation: smtp-server-connection.c:smtp_reply_has_enhanced_code Unexecuted instantiation: smtp-reply.c:smtp_reply_has_enhanced_code Unexecuted instantiation: smtp-reply-parser.c:smtp_reply_has_enhanced_code Unexecuted instantiation: smtp-server-cmd-rcpt.c:smtp_reply_has_enhanced_code Unexecuted instantiation: smtp-server-cmd-xclient.c:smtp_reply_has_enhanced_code |
29 | | |
30 | | static inline bool |
31 | | smtp_reply_is_success(const struct smtp_reply *reply) |
32 | 0 | { |
33 | 0 | return ((reply->status / 100) == 2); |
34 | 0 | } Unexecuted instantiation: smtp-server-reply.c:smtp_reply_is_success Unexecuted instantiation: smtp-server-command.c:smtp_reply_is_success Unexecuted instantiation: smtp-server-recipient.c:smtp_reply_is_success Unexecuted instantiation: smtp-server-connection.c:smtp_reply_is_success Unexecuted instantiation: smtp-reply.c:smtp_reply_is_success Unexecuted instantiation: smtp-reply-parser.c:smtp_reply_is_success Unexecuted instantiation: smtp-server-cmd-rcpt.c:smtp_reply_is_success Unexecuted instantiation: smtp-server-cmd-xclient.c:smtp_reply_is_success |
35 | | |
36 | | static inline bool |
37 | | smtp_reply_is_remote(const struct smtp_reply *reply) |
38 | 0 | { |
39 | 0 | return (reply->status >= 200 && reply->status < 560); |
40 | 0 | } Unexecuted instantiation: smtp-server-reply.c:smtp_reply_is_remote Unexecuted instantiation: smtp-server-command.c:smtp_reply_is_remote Unexecuted instantiation: smtp-server-recipient.c:smtp_reply_is_remote Unexecuted instantiation: smtp-server-connection.c:smtp_reply_is_remote Unexecuted instantiation: smtp-reply.c:smtp_reply_is_remote Unexecuted instantiation: smtp-reply-parser.c:smtp_reply_is_remote Unexecuted instantiation: smtp-server-cmd-rcpt.c:smtp_reply_is_remote Unexecuted instantiation: smtp-server-cmd-xclient.c:smtp_reply_is_remote |
41 | | |
42 | | static inline bool |
43 | | smtp_reply_is_temp_fail(const struct smtp_reply *reply) |
44 | 0 | { |
45 | 0 | return ((reply->status / 100) == 4); |
46 | 0 | } Unexecuted instantiation: smtp-server-reply.c:smtp_reply_is_temp_fail Unexecuted instantiation: smtp-server-command.c:smtp_reply_is_temp_fail Unexecuted instantiation: smtp-server-recipient.c:smtp_reply_is_temp_fail Unexecuted instantiation: smtp-server-connection.c:smtp_reply_is_temp_fail Unexecuted instantiation: smtp-reply.c:smtp_reply_is_temp_fail Unexecuted instantiation: smtp-reply-parser.c:smtp_reply_is_temp_fail Unexecuted instantiation: smtp-server-cmd-rcpt.c:smtp_reply_is_temp_fail Unexecuted instantiation: smtp-server-cmd-xclient.c:smtp_reply_is_temp_fail |
47 | | |
48 | | static inline bool ATTR_NULL(3) |
49 | | smtp_reply_code_equals(const struct smtp_reply *reply, unsigned int status, |
50 | | const struct smtp_reply_enhanced_code enhanced_code) |
51 | 0 | { |
52 | 0 | if (reply->status != status) |
53 | 0 | return FALSE; |
54 | 0 | if (reply->enhanced_code.x != enhanced_code.x || |
55 | 0 | reply->enhanced_code.y != enhanced_code.y || |
56 | 0 | reply->enhanced_code.z != enhanced_code.z) |
57 | 0 | return FALSE; |
58 | 0 | return TRUE; |
59 | 0 | } Unexecuted instantiation: smtp-server-reply.c:smtp_reply_code_equals Unexecuted instantiation: smtp-server-command.c:smtp_reply_code_equals Unexecuted instantiation: smtp-server-recipient.c:smtp_reply_code_equals Unexecuted instantiation: smtp-server-connection.c:smtp_reply_code_equals Unexecuted instantiation: smtp-reply.c:smtp_reply_code_equals Unexecuted instantiation: smtp-reply-parser.c:smtp_reply_code_equals Unexecuted instantiation: smtp-server-cmd-rcpt.c:smtp_reply_code_equals Unexecuted instantiation: smtp-server-cmd-xclient.c:smtp_reply_code_equals |
60 | | |
61 | | void smtp_reply_init(struct smtp_reply *reply, unsigned int status, |
62 | | const char *text); |
63 | | void smtp_reply_printf(struct smtp_reply *reply, unsigned int status, |
64 | | const char *format, ...) ATTR_FORMAT(3, 4); |
65 | | |
66 | | const char * |
67 | | smtp_reply_get_enh_code(const struct smtp_reply *reply); |
68 | | const char *const * |
69 | | smtp_reply_get_text_lines_omit_prefix(const struct smtp_reply *reply); |
70 | | |
71 | | /* Write the SMTP reply as a sequence of lines according to the SMTP syntax, |
72 | | each terminated by CRLF. */ |
73 | | void smtp_reply_write(string_t *out, const struct smtp_reply *reply); |
74 | | /* Write the SMTP reply as a single line without CRLF, even when it consists |
75 | | of multiple lines. This function cannot be used with internal client error |
76 | | replies (status code >= 560). */ |
77 | | void smtp_reply_write_one_line(string_t *out, const struct smtp_reply *reply); |
78 | | /* Create a log line from the SMTP reply. This also properly handles internal |
79 | | client error replies (status_code >= 560). */ |
80 | | const char *smtp_reply_log(const struct smtp_reply *reply); |
81 | | /* Returns the message of the reply as a single line without status codes and |
82 | | without CRLF. |
83 | | */ |
84 | | const char *smtp_reply_get_message(const struct smtp_reply *reply); |
85 | | |
86 | | void smtp_reply_copy(pool_t pool, struct smtp_reply *dst, |
87 | | const struct smtp_reply *src); |
88 | | struct smtp_reply *smtp_reply_clone(pool_t pool, |
89 | | const struct smtp_reply *src); |
90 | | |
91 | | /* Set standard reply fields in provided pass-through event */ |
92 | | void smtp_reply_add_to_event(const struct smtp_reply *reply, |
93 | | struct event_passthrough *e); |
94 | | |
95 | | #endif |