1 #ifndef LIBFILEZILLA_HOSTNAME_LOOKUP_HEADER
2 #define LIBFILEZILLA_HOSTNAME_LOOKUP_HEADER
3 
4 /** \file
5  * \brief Header for the \ref fz::hostname_lookup class
6  */
7 
8 #include "libfilezilla.hpp"
9 #include "iputils.hpp"
10 #include "event_handler.hpp"
11 
12 namespace fz {
13 class FZ_PUBLIC_SYMBOL hostname_lookup
14 {
15 public:
16 	hostname_lookup(thread_pool& pool, event_handler& evt_handler);
17 	~hostname_lookup();
18 
19 	hostname_lookup(hostname_lookup const&) = delete;
20 	hostname_lookup& operator=(hostname_lookup const&) = delete;
21 
22 	/**
23 	 * \brief Looks up the passed host
24 	 *
25 	 * If family is unknown, looks up both IPv4 and IPv6 addresses, if the operating system
26 	 * is configured to resolve IPv6 addresses.
27 	 *
28 	 * If the function returns true, wait for the \ref hostname_lookup_event before you can call it again.
29 	 */
30 	bool lookup(native_string const& host, address_type family = address_type::unknown);
31 
32 	void reset();
33 
34 private:
35 	class impl;
36 	impl* impl_{};
37 };
38 
39 /// \private
40 struct hostname_lookup_event_type {};
41 
42 /// Results of hostname_lookup. On success, second argument is zero, otherwise an error code.
43 typedef simple_event<hostname_lookup_event_type, hostname_lookup*, int, std::vector<std::string>> hostname_lookup_event;
44 }
45 
46 #endif
47