/* */ #ifndef _D_ASYNC_NAME_RESOLVER_H_ #define _D_ASYNC_NAME_RESOLVER_H_ #include "common.h" #include "SharedHandle.h" #include "a2netcompat.h" #include #include #ifdef __cplusplus extern "C" { #endif #include #ifdef __cplusplus } /* end of extern "C" */ #endif namespace aria2 { class AsyncNameResolver { #ifdef HAVE_LIBCARES1_5 friend void callback(void* arg, int status, int timeouts, struct hostent* host); #else friend void callback(void* arg, int status, struct hostent* host); #endif // HAVE_LIBCARES1_5 public: enum STATUS { STATUS_READY, STATUS_QUERYING, STATUS_SUCCESS, STATUS_ERROR, }; private: STATUS status; ares_channel channel; std::deque _resolvedAddresses; std::string error; std::string _hostname; public: AsyncNameResolver(); ~AsyncNameResolver(); void resolve(const std::string& name); const std::deque& getResolvedAddresses() const; const std::string& getError() const; STATUS getStatus() const; int getFds(fd_set* rfdsPtr, fd_set* wfdsPtr) const; void process(fd_set* rfdsPtr, fd_set* wfdsPtr); #ifdef HAVE_LIBCARES int getsock(sock_t* sockets) const; void process(ares_socket_t readfd, ares_socket_t writefd); #endif // HAVE_LIBCARES bool operator==(const AsyncNameResolver& resolver) const; void setAddr(const std::string& addrString); void reset(); const std::string& getHostname() const; }; } // namespace aria2 #endif // _D_ASYNC_NAME_RESOLVER_H_