This commit is contained in:
Wolfgang Hottgenroth
2013-03-27 20:56:17 +01:00
parent bc4eace60d
commit 4582de6afc
7 changed files with 102 additions and 42 deletions

View File

@ -4,55 +4,25 @@
#include <sqlite3.h>
#include "Database.hpp"
#include "PostfixPolicyProtocol.hpp"
#include "ChildProt.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;
PostfixPolicyProtocol postfixPolicyProtocol;
DatabaseHandle databaseHandle("/etc/postfix/children.sqlite");
try {
postfixPolicyProtocol.processInput();
cerr << postfixPolicyProtocol.getSender() << endl;
cerr << postfixPolicyProtocol.getRecipient() << endl;
DatabaseHandle databaseHandle(DATABASE_FILE);
// SELECT id, delegate FROM child_v WHERE address = '%s'
@ -65,5 +35,5 @@ int main() {
result = "OK";
}
cout << "action=" << result << endl << endl;
postfixPolicyProtocol.sendResult(result);
}