src/query.c: Remove flag hacking from adns_submit.
[adns] / src / internal.h
index 40da52d..f5f185e 100644 (file)
@@ -72,6 +72,8 @@ typedef unsigned char byte;
 #define DNS_INADDR_ARPA "in-addr", "arpa"
 #define DNS_IP6_ARPA "ip6", "arpa"
 
+#define MAX_ADDRSTRLEN 64
+
 #define STRINGIFY(x) REALLY_STRINGIFY(x)
 #define REALLY_STRINGIFY(x) #x
 
@@ -93,8 +95,6 @@ typedef enum {
 } dns_rcode;
 
 enum {
-  adns__qf_senddirect = 0x00100000,/* don't call the `query_send' type hook */
-  adns__qf_nosend     = 0x00200000,/* don't send the query when submitting */
   adns__qf_addr_answer= 0x01000000,/* addr query received an answer */
   adns__qf_addr_cname = 0x02000000 /* addr subquery performed on cname */
 };
@@ -203,6 +203,11 @@ typedef struct typeinfo {
    * stuff.)  May be 0 to mean nothing needs to be done.
    */
 
+  int (*getrrsz)(adns_rrtype type);
+  /* Return the output resource-record element size; if this is null, then
+   * the rrsz member can be used.
+   */
+
   void (*query_send)(adns_query qu, struct timeval now);
   /* Send the query to nameservers, and hook it into the appropriate queue.
    * Normal behaviour is to call adns__query_send, but this can be overridden
@@ -235,10 +240,19 @@ union maxalign {
 typedef struct {
   void *ext;
   void (*callback)(adns_query parent, adns_query child);
+
   union {
     struct afinfo_addr ptr_parent_addr;
     adns_rr_hostaddr *hostaddr;
-  } info;
+  } pinfo; /* state for use by parent's callback function */
+
+  union {
+    struct {
+      unsigned want, have;
+    } addr;
+  } tinfo; /* type-specific state for the query itself: zero-init if you
+           * don't know better. */
+
 } qcontext;
 
 struct adns__query {
@@ -397,7 +411,9 @@ int adns__setnonblock(adns_state ads, int fd); /* => errno value */
 
 /* From general.c: */
 
-const char *adns__sockaddr_ntoa(struct sockaddr *sa, size_t n);
+const char *adns__sockaddr_ntoa(struct sockaddr *sa, size_t n, char *buf);
+/* Buffer must be at least MAX_ADDRSTRLEN bytes long. */
+
 void adns__vlprintf(adns_state ads, const char *fmt, va_list al);
 void adns__lprintf(adns_state ads, const char *fmt,
                   ...) PRINTFFORMAT(2,3);