call out non-ASCII
[ghsmtp.git] / SRS.cpp
blob5114d9ee9007a3710f2b8baa8439d8fb4a2fd724
1 #include "SRS.hpp"
3 #include <srs2.h>
5 #include <glog/logging.h>
7 #include "SRS.ipp"
9 SRS::SRS()
10 : srs_(srs_new())
12 CHECK_NOTNULL(srs_);
13 add_secret(srs_secret);
16 SRS::~SRS() { srs_free(srs_); }
18 std::string SRS::forward(char const* sender, char const* alias) const
20 if (!*sender)
21 return sender;
22 char buf[1024]; // will be of size at most strlen(sender) + strlen(alias) + 64
23 CHECK_EQ(srs_forward(srs_, buf, sizeof(buf), sender, alias), SRS_SUCCESS);
24 return std::string(buf);
27 std::string SRS::reverse(char const* sender) const
29 if (!*sender)
30 return sender;
31 char buf[1024]; // no longer than sender
32 CHECK_EQ(srs_reverse(srs_, buf, sizeof(buf), sender), SRS_SUCCESS)
33 << "sender == " << sender;
34 return std::string(buf);
37 void SRS::add_secret(char const* secret) { srs_add_secret(srs_, secret); }