00001
00002
00003 #ifndef BASE_DNS_H
00004 #define BASE_DNS_H
00005
00006 #ifdef _WIN32
00007 #define WIN32_LEAN_AND_MEAN
00008 #include <winsock2.h>
00009 #else
00010 #if defined(__APPLE__) && defined(__MACH__)
00011 #define BIND_8_COMPAT
00012 #endif
00013 #include <resolv.h>
00014 #endif
00015 #include "IOException.h"
00016
00017 namespace base {
00019
00023 class PPBASE_EXPORT DNS {
00024 public:
00026 DNS();
00027
00029 ~DNS();
00030
00032
00035 int errcode() const;
00036
00038
00042 bool existsARecord(const String &host);
00043
00045
00049 bool existsDomain(const String &domain);
00050
00052
00056 bool existsHost(const String &host);
00057
00059
00063 bool existsMX(const String &host);
00064
00066
00072 bool existsRecord(const String &domain, int *types, int ntypes);
00073
00075
00078 bool failed() const;
00079
00081
00084 String fqdn();
00085
00087
00090 String hostname();
00091
00098 bool isValidEmailAddr(const String &email);
00099
00101
00105 String lookup(const String &ipaddr);
00106
00108
00112 String resolve(const String &host);
00113
00114 private:
00115 #ifdef _WIN32
00116 int _err;
00117 #else
00118 struct __res_state _rs;
00119 #endif
00120
00121 DISALLOW_COPY_CONSTRUCTOR_AND_ASSIGNMENT(DNS);
00122 };
00123 }
00124
00125 #endif