3 ** Copyright (C) 2008 Cockos Inc
4 ** Copyright (C) 2000-2001 Nullsoft, Inc.
5 ** Author: Justin Frankel
6 ** File: asyncdns.h - JNL portable asynchronous DNS interface
7 ** License: see jnetlib.h
10 ** 1. Create JNL_AsyncDNS object, optionally with the number of cache entries.
11 ** 2. call resolve() to resolve a hostname into an address. The return value of
12 ** resolve is 0 on success (host successfully resolved), 1 on wait (meaning
13 ** try calling resolve() with the same hostname in a few hundred milliseconds
14 ** or so), or -1 on error (i.e. the host can't resolve).
15 ** 3. call reverse() to do reverse dns (ala resolve()).
24 #ifndef JNL_NO_DEFINE_INTERFACES
28 virtual ~JNL_IAsyncDNS() { }
29 virtual int resolve(const char *hostname
, unsigned int *addr
)=0; // return 0 on success, 1 on wait, -1 on unresolvable
30 virtual int reverse(unsigned int addr
, char *hostname
)=0; // return 0 on success, 1 on wait, -1 on unresolvable. hostname must be at least 256 bytes.
32 #define JNL_AsyncDNS_PARENTDEF : public JNL_IAsyncDNS
34 #define JNL_IAsyncDNS JNL_AsyncDNS
35 #define JNL_AsyncDNS_PARENTDEF
39 #ifndef JNL_NO_IMPLEMENTATION
41 class JNL_AsyncDNS JNL_AsyncDNS_PARENTDEF
44 JNL_AsyncDNS(int max_cache_entries
=64);
47 int resolve(const char *hostname
, unsigned int *addr
); // return 0 on success, 1 on wait, -1 on unresolvable
48 int reverse(unsigned int addr
, char *hostname
); // return 0 on success, 1 on wait, -1 on unresolvable. hostname must be at least 256 bytes.
53 time_t last_used
; // timestamp.
55 char mode
; // 1=reverse
63 volatile int m_thread_kill
;
66 static unsigned WINAPI
_threadfunc(void *_d
);
69 static unsigned int _threadfunc(void *_d
);
71 void makesurethreadisrunning(void);
74 #endif // !JNL_NO_IMPLEMENTATION