crazy api
[ghsmtp.git] / message.hpp
blob9d0f0dde2a71d70b9fa7f0c29325feceb45f40c9
1 #ifndef MESSAGE_DOT_HPP_INCLUDED
2 #define MESSAGE_DOT_HPP_INCLUDED
4 #include <iostream>
5 #include <iterator>
6 #include <optional>
7 #include <string>
8 #include <string_view>
10 #include "Mailbox.hpp"
11 #include "fs.hpp"
12 #include "iequal.hpp"
14 namespace message {
15 struct header {
16 header(std::string_view n, std::string_view v)
17 : name(n)
18 , value(v)
22 std::string as_string() const;
24 std::string_view as_view() const
26 return {name.begin(),
27 static_cast<size_t>(std::distance(name.begin(), value.end()))};
30 bool operator==(std::string_view n) const { return iequal(n, name); }
32 std::string_view name;
33 std::string_view value;
34 }; // namespace header
36 struct parsed {
37 bool parse(std::string_view input);
38 bool parse_hdr(std::string_view input);
40 std::string as_string() const;
42 bool write(std::ostream& out) const;
44 std::vector<header> headers;
46 std::string_view field_name;
47 std::string_view field_value;
49 std::string_view body;
51 // New Authentication_Results field
52 std::string ar_str;
54 // New DKIM-Signature that includes above AR
55 std::string sig_str;
57 std::vector<std::string> arc_hdrs;
60 void authentication(fs::path config_path,
61 char const* domain,
62 message::parsed& msg);
64 void dkim_check(fs::path config_path, char const* domain, message::parsed& msg);
66 bool rewrite(fs::path config_path,
67 Mailbox const& mail_from,
68 Domain const& sender,
69 message::parsed& msg);
71 void print_spf_envelope_froms(char const* domain, message::parsed& msg);
73 } // namespace message
75 #endif // MESSAGE_DOT_HPP_INCLUDED