00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __TRIPLET_H
00022 #define __TRIPLET_H
00023
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027 #include <iostream>
00028 #include <string>
00029
00030 #include <stdexcept>
00031
00032 #include "read.h"
00033 #include "defs.h"
00034
00035 #ifdef HAVE_SYS_SOCKET_H
00036 #include <sys/socket.h>
00037 #endif
00038
00039
00040
00046 class Triplet
00047 {
00048 public:
00049 typedef enum {
00050 TM_sender,
00051 TM_recipient,
00052 TM_client,
00053 TM_resolved,
00054 TM_quotedweakclient
00055 }TripletMember;
00056 Triplet(const Reader& reader);
00057 Triplet(const std::string& client,const std::string& sender,const std::string& recipient,
00058 const std::string& client_numeric="");
00059 const std::string& getClientAddress() const { return _client_address; }
00061 const std::string& getClientAddressNumeric() const { return _client_address_numeric; }
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00094 const std::string getClientAddressNumericStr(const char sep='.',unsigned size=0) const;
00095
00097 const std::string getClientAddressNumericStrSQL(const std::string& sep,const std::string& base,
00098 unsigned start,const std::string& afterstart,unsigned mult,unsigned size) const;
00099
00103 const std::string getResolved() const { return _resolved; }
00104
00105 const std::string& getResolveError() const { return _not_resolved; }
00106 const std::string& getSender() const { return _sender; }
00107 const std::string& getRecipient() const { return _recipient; }
00109 const std::string& getQuotedWeakClient() const { return _weakclient; }
00110
00111 const std::string& getMember(TripletMember m) const throw (std::out_of_range){
00112 switch(m) {
00113 case TM_sender:
00114 return _sender;
00115 case TM_recipient:
00116 return _recipient;
00117 case TM_client:
00118 return _client_address;
00119 case TM_resolved:
00120 return _resolved;
00121 case TM_quotedweakclient:
00122 return getQuotedWeakClient();
00123 default:
00124 throw std::out_of_range( "Triplet::getMember out of range" );
00125 }
00126 }
00127 private:
00131 void _init();
00132
00134 std::string _client_address;
00136 std::string _sender;
00138 std::string _recipient;
00141 std::string _resolved;
00143 std::string _client_address_numeric;
00145 std::string _not_resolved;
00147 std::string _weakclient;
00148 };
00149 class WLCompare
00150 {
00151 public:
00152 const char* _compareWith;
00153 const char* _compareOp;
00154 Triplet::TripletMember _tripletMember;
00155 const char* _compareBinder;
00156 };
00157 typedef WLCompare WLCompares[MAX_WL_COMPARES];
00158
00159 #endif
00160