dont use cppcodec
[ghsmtp.git] / OpenDKIM.hpp
blobb2ac20d9aa4f9c5562390d76d1acc4b261e0f5de
1 #ifndef OPENDKIM_DOT_HPP
2 #define OPENDKIM_DOT_HPP
4 #include <functional>
5 #include <string>
6 #include <string_view>
8 struct dkim_lib;
9 struct dkim;
11 namespace OpenDKIM {
13 class lib {
14 // no copy
15 lib(lib const&) = delete;
16 lib& operator=(lib const&) = delete;
18 // move
19 lib(lib&&) = default;
20 lib& operator=(lib&&) = default;
22 public:
23 void header(std::string_view header);
24 void eoh();
25 void body(std::string_view body);
26 void chunk(std::string_view chunk);
27 void eom();
29 protected:
30 lib();
31 ~lib();
33 dkim_lib* lib_{nullptr};
34 dkim* dkim_{nullptr};
35 int status_{0};
38 class sign : public lib {
39 public:
40 enum class body_type : bool {
41 binary,
42 text,
45 sign(char const* secretkey,
46 char const* selector,
47 char const* domain,
48 body_type typ = body_type::text);
50 std::string getsighdr();
53 class verify : public lib {
54 public:
55 verify();
57 bool check();
58 bool sig_syntax(std::string_view sig);
59 void foreach_sig(std::function<void(char const* domain,
60 bool passed,
61 char const* identity,
62 char const* selector,
63 char const* b)> func);
66 } // namespace OpenDKIM
68 #endif // OPENDKIM_DOT_HPP