two functions now
[ghsmtp.git] / SRS.cpp
blob8bebfebfa5c4a1202f88e0e83e3cae763a71f57c
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 add_secret(srs_secret);
15 SRS::~SRS() { srs_free(srs_); }
17 std::string SRS::forward(char const* sender, char const* alias)
19 if (!*sender)
20 return sender;
21 char buf[1024]; // will be of size at most strlen(sender) + strlen(alias) + 64
22 CHECK_EQ(srs_forward(srs_, buf, sizeof(buf), sender, alias), SRS_SUCCESS);
23 return std::string(buf);
26 std::string SRS::reverse(char const* sender)
28 if (!*sender)
29 return sender;
30 char buf[1024]; // no longer than sender
31 CHECK_EQ(srs_reverse(srs_, buf, sizeof(buf), sender), SRS_SUCCESS);
32 return std::string(buf);
35 void SRS::add_secret(char const* secret) { srs_add_secret(srs_, secret); }