#include #include #include #include "Database.hpp" using namespace std; class InvalidAddressTuple {}; class AddressTuple { public : AddressTuple(); const string& getSender() const { return sender; } const string& getRecipient() const { return recipient; } private: string sender; string recipient; }; AddressTuple::AddressTuple() { sender = ""; recipient = ""; while (1) { string buffer; getline(cin, buffer); if (0 == buffer.length()) break; string::size_type equalsIdx = buffer.find('='); if (string::npos != equalsIdx) { string key = buffer.substr(0, equalsIdx); string value = buffer.substr(equalsIdx+1); if ("sender" == key) sender = value; if ("recipient" ==key) recipient = value; } } if ((0 == sender.length()) || (0 == recipient.length())) throw InvalidAddressTuple(); } int main() { string result; try { AddressTuple addressTuple; cerr << addressTuple.getSender() << endl; cerr << addressTuple.getRecipient() << endl; DatabaseHandle databaseHandle("/etc/postfix/children.sqlite"); // SELECT id, delegate FROM child_v WHERE address = '%s' } catch (InvalidAddressTuple& iat) { cerr << "InvalidAddressTuple" << endl; result = "OK"; } catch (DatabaseError &de) { cerr << "DatabaseError" << endl; result = "OK"; } cout << "action=" << result << endl << endl; }