* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
- * $Id: adns.h,v 1.85 2003/06/22 14:34:37 ian Exp $
+ * $Id: adns.h,v 1.88 2006/04/03 22:49:32 ian Exp $
*/
#ifndef ADNS_H_INCLUDED
#define ADNS_H_INCLUDED
#include <stdio.h>
+#include <stdarg.h>
#include <sys/types.h>
#include <sys/socket.h>
typedef struct adns__state *adns_state;
typedef struct adns__query *adns_query;
-typedef enum {
+typedef enum { /* In general, or together the desired flags: */
+ adns_if_none= 0x0000,/* no flags. nicer than 0 for some compilers */
adns_if_noenv= 0x0001,/* do not look at environment */
adns_if_noerrprint= 0x0002,/* never print to stderr (_debug overrides) */
adns_if_noserverwarn=0x0004,/* do not warn to stderr about duff servers etc */
adns_if_checkc_freq= 0x0300 /* consistency checks very frequently (slow!) */
} adns_initflags;
-typedef enum {
+typedef enum { /* In general, or together the desired flags: */
+ adns_qf_none= 0x00000000,/* no flags */
adns_qf_search= 0x00000001,/* use the searchlist */
adns_qf_usevc= 0x00000002,/* use a virtual circuit (TCP conn) */
adns_qf_owner= 0x00000004,/* fill in the owner field in the answer */
adns_r_soa_raw= 6,
adns_r_soa= adns_r_soa_raw|adns__qtf_mail822,
- adns_r_ptr_raw= 12,
+ adns_r_ptr_raw= 12, /* do not mind PTR with wrong or missing A */
adns_r_ptr= adns_r_ptr_raw|adns__qtf_deref,
adns_r_hinfo= 13,
int adns_init_strcfg(adns_state *newstate_r, adns_initflags flags,
FILE *diagfile /*0=>discard*/, const char *configtext);
+typedef void adns_logcallbackfn(adns_state ads, void *logfndata,
+ const char *fmt, va_list al);
+ /* Will be called perhaps several times for each message; when the
+ * message is complete, the string implied by fmt and al will end in
+ * a newline. Log messages start with `adns debug:' or `adns
+ * warning:' or `adns:' (for errors), or `adns debug [PID]:'
+ * etc. if adns_if_logpid is set. */
+
+int adns_init_logfn(adns_state *newstate_r, adns_initflags flags,
+ const char *configtext /*0=>use default config files*/,
+ adns_logcallbackfn *logfn /*0=>logfndata is a FILE* */,
+ void *logfndata /*0 with logfn==0 => discard*/);
+
/* Configuration:
* adns_init reads /etc/resolv.conf, which is expected to be (broadly
* speaking) in the format expected by libresolv, and then
* for adns_firsttimeout. readfds, writefds, exceptfds and maxfd_io may
* not be 0.
*
- * If now is not 0 then this will never actually do any I/O, or change
- * the fds that adns is using or the timeouts it wants. In any case
- * it won't block, and it will set the timeout to zero if a query
- * finishes in _beforeselect.
+ * If tv_mod is 0 on entry then this will never actually do any I/O,
+ * or change the fds that adns is using or the timeouts it wants. In
+ * any case it won't block, and it will set the timeout to zero if a
+ * query finishes in _beforeselect.
*/
void adns_afterselect(adns_state ads, int maxfd, const fd_set *readfds,