chiark / gitweb /
+ * Some better source code formatting/wrapping in a few places.
authorian <ian>
Sun, 22 Jun 2003 13:01:11 +0000 (13:01 +0000)
committerian <ian>
Sun, 22 Jun 2003 13:01:11 +0000 (13:01 +0000)
@@ -10,6 +10,7 @@
+  * Some better source code formatting/wrapping in a few places.

13 files changed:
changelog
src/check.c
src/dlist.h
src/event.c
src/general.c
src/internal.h
src/parse.c
src/poll.c
src/query.c
src/reply.c
src/setup.c
src/transmit.c
src/types.c

index 3818085db40ab7e52b8c7e1720562e488a8dfe7c..39469bff9ab960d4659f01369b155f6e78bbc4ab 100644 (file)
--- a/changelog
+++ b/changelog
@@ -10,6 +10,7 @@ adns (1.1); urgency=medium
   * Added wishlist entry re configurable port no.
   * Problem with SERVFAIL in TODO.
   * Mentioned Jarle Aase's Windows port in README.html.
+  * Some better source code formatting/wrapping in a few places.
 
  --
 
index 7cca534520c78baf7885d77e2d3171949a7cc0b9..398c0917b08a26d233c1c3c33a7a8f37e3b7ac2e 100644 (file)
@@ -31,24 +31,26 @@ void adns_checkconsistency(adns_state ads, adns_query qu) {
   adns__consistency(ads,qu,cc_user);
 }
 
-#define DLIST_CHECK(list, nodevar, part, body)                                 \
-  if ((list).head) {                                                           \
-    assert(! (list).head->part back);                                          \
-    for ((nodevar)= (list).head; (nodevar); (nodevar)= (nodevar)->part next) { \
-      assert((nodevar)->part next                                              \
-            ? (nodevar) == (nodevar)->part next->part back                     \
-            : (nodevar) == (list).tail);                                       \
-      body                                                                     \
-    }                                                                          \
+#define DLIST_CHECK(list, nodevar, part, body)                 \
+  if ((list).head) {                                           \
+    assert(! (list).head->part back);                          \
+    for ((nodevar)= (list).head;                               \
+        (nodevar);                                             \
+        (nodevar)= (nodevar)->part next) {                     \
+      assert((nodevar)->part next                              \
+            ? (nodevar) == (nodevar)->part next->part back     \
+            : (nodevar) == (list).tail);                       \
+      body                                                     \
+    }                                                          \
   }
 
-#define DLIST_ASSERTON(node, nodevar, list, part)                              \
-  do {                                                                         \
-    for ((nodevar)= (list).head;                                               \
-        (nodevar) != (node);                                                   \
-        (nodevar)= (nodevar)->part next) {                                     \
-      assert((nodevar));                                                       \
-    }                                                                          \
+#define DLIST_ASSERTON(node, nodevar, list, part)      \
+  do {                                                 \
+    for ((nodevar)= (list).head;                       \
+        (nodevar) != (node);                           \
+        (nodevar)= (nodevar)->part next) {             \
+      assert((nodevar));                               \
+    }                                                  \
   } while(0)
 
 static void checkc_query_alloc(adns_state ads, adns_query qu) {
index 44bf55608e249d6cce0ee1e14b46de816a1ae2a3..76fc74c307713a0bedd25af1370c2e198ca0d5cf 100644 (file)
 #define LIST_INIT(list) ((list).head= (list).tail= 0)
 #define LINK_INIT(link) ((link).next= (link).back= 0)
 
-#define LIST_UNLINK_PART(list,node,part) \
-  do { \
+#define LIST_UNLINK_PART(list,node,part)                                   \
+  do {                                                                     \
     if ((node)->part back) (node)->part back->part next= (node)->part next; \
       else                                  (list).head= (node)->part next; \
     if ((node)->part next) (node)->part next->part back= (node)->part back; \
       else                                  (list).tail= (node)->part back; \
   } while(0)
 
-#define LIST_LINK_TAIL_PART(list,node,part) \
-  do { \
-    (node)->part next= 0; \
-    (node)->part back= (list).tail; \
-    if ((list).tail) (list).tail->part next= (node); else (list).head= (node); \
-    (list).tail= (node); \
+#define LIST_LINK_TAIL_PART(list,node,part)            \
+  do {                                                 \
+    (node)->part next= 0;                              \
+    (node)->part back= (list).tail;                    \
+    if ((list).tail) (list).tail->part next= (node);   \
+    else (list).head= (node);                          \
+    (list).tail= (node);                               \
   } while(0)
 
 #define LIST_UNLINK(list,node) LIST_UNLINK_PART(list,node,)
index f1d22dc7d9a95b6853583e008d4184c7099c3c7d..d51f9807b0dd9d2f73e1543400866f37acf2ddb6 100644 (file)
@@ -105,7 +105,10 @@ void adns__tcp_tryconnect(adns_state ads, struct timeval now) {
     assert(!ads->tcprecv_skip);
 
     proto= getprotobyname("tcp");
-    if (!proto) { adns__diag(ads,-1,0,"unable to find protocol no. for TCP !"); return; }
+    if (!proto) {
+      adns__diag(ads,-1,0,"unable to find protocol no. for TCP !");
+      return;
+    }
     fd= socket(AF_INET,SOCK_STREAM,proto->p_proto);
     if (fd<0) {
       adns__diag(ads,-1,0,"cannot create TCP socket: %s",strerror(errno));
@@ -113,7 +116,8 @@ void adns__tcp_tryconnect(adns_state ads, struct timeval now) {
     }
     r= adns__setnonblock(ads,fd);
     if (r) {
-      adns__diag(ads,-1,0,"cannot make TCP socket nonblocking: %s",strerror(r));
+      adns__diag(ads,-1,0,"cannot make TCP socket nonblocking:"
+                " %s",strerror(r));
       close(fd);
       return;
     }
@@ -317,7 +321,8 @@ int adns__pollfds(adns_state ads, struct pollfd pollfds_buf[MAX_POLLFDS]) {
     pollfds_buf[1].events= POLLOUT;
     break;
   case server_ok:
-    pollfds_buf[1].events= ads->tcpsend.used ? POLLIN|POLLOUT|POLLPRI : POLLIN|POLLPRI;
+    pollfds_buf[1].events=
+      ads->tcpsend.used ? POLLIN|POLLOUT|POLLPRI : POLLIN|POLLPRI;
     break;
   default:
     abort();
@@ -358,7 +363,8 @@ int adns_processreadable(adns_state ads, int fd, const struct timeval *now) {
        want= 2;
       }
       ads->tcprecv.used -= ads->tcprecv_skip;
-      memmove(ads->tcprecv.buf,ads->tcprecv.buf+ads->tcprecv_skip,ads->tcprecv.used);
+      memmove(ads->tcprecv.buf, ads->tcprecv.buf+ads->tcprecv_skip,
+             ads->tcprecv.used);
       ads->tcprecv_skip= 0;
       if (!adns__vbuf_ensure(&ads->tcprecv,want)) { r= ENOMEM; goto xit; }
       assert(ads->tcprecv.used <= ads->tcprecv.avail);
@@ -405,8 +411,8 @@ int adns_processreadable(adns_state ads, int fd, const struct timeval *now) {
        continue;
       }
       if (ntohs(udpaddr.sin_port) != DNS_PORT) {
-       adns__diag(ads,-1,0,"datagram received from wrong port %u (expected %u)",
-                  ntohs(udpaddr.sin_port),DNS_PORT);
+       adns__diag(ads,-1,0,"datagram received from wrong port"
+                  " %u (expected %u)", ntohs(udpaddr.sin_port),DNS_PORT);
        continue;
       }
       for (serv= 0;
@@ -484,7 +490,8 @@ xit:
   return r;
 }
   
-int adns_processexceptional(adns_state ads, int fd, const struct timeval *now) {
+int adns_processexceptional(adns_state ads, int fd,
+                           const struct timeval *now) {
   adns__consistency(ads,0,cc_entex);
   switch (ads->tcpstate) {
   case server_disconnected:
@@ -505,7 +512,8 @@ int adns_processexceptional(adns_state ads, int fd, const struct timeval *now) {
 static void fd_event(adns_state ads, int fd,
                     int revent, int pollflag,
                     int maxfd, const fd_set *fds,
-                    int (*func)(adns_state, int fd, const struct timeval *now),
+                    int (*func)(adns_state, int fd,
+                                const struct timeval *now),
                     struct timeval now, int *r_r) {
   int r;
   
@@ -516,7 +524,8 @@ static void fd_event(adns_state ads, int fd,
     if (r_r) {
       *r_r= r;
     } else {
-      adns__diag(ads,-1,0,"process fd failed after select: %s",strerror(errno));
+      adns__diag(ads,-1,0,"process fd failed after select:"
+                " %s",strerror(errno));
       adns_globalsystemfailure(ads);
     }
   }
@@ -533,9 +542,12 @@ void adns__fdevents(adns_state ads,
     fd= pollfds[i].fd;
     if (fd >= maxfd) maxfd= fd+1;
     revents= pollfds[i].revents;
-    fd_event(ads,fd, revents,POLLIN, maxfd,readfds, adns_processreadable,now,r_r);
-    fd_event(ads,fd, revents,POLLOUT, maxfd,writefds, adns_processwriteable,now,r_r);
-    fd_event(ads,fd, revents,POLLPRI, maxfd,exceptfds, adns_processexceptional,now,r_r);
+#define EV(pollfl,fds,how)  \
+    fd_event(ads,fd, revents,pollfl, maxfd,fds, adns_process##how,now,r_r)
+    EV( POLLIN,  readfds,   readable    );
+    EV( POLLOUT, writefds,  writeable   );
+    EV( POLLPRI, exceptfds, exceptional );
+#undef EV
   }
 }
 
index 0d159df18c8129464d27853651df1e4977b9840e..83232d7172dfed2a81b74fd0443d4f9dadf1179f 100644 (file)
@@ -44,7 +44,8 @@ void adns__vdiag(adns_state ads, const char *pfx, adns_initflags prevent,
   vbuf vb;
   
   if (!ads->diagfile ||
-      (!(ads->iflags & adns_if_debug) && (!prevent || (ads->iflags & prevent))))
+      (!(ads->iflags & adns_if_debug)
+       && (!prevent || (ads->iflags & prevent))))
     return;
 
   if (ads->iflags & adns_if_logpid) {
@@ -79,7 +80,8 @@ void adns__vdiag(adns_state ads, const char *pfx, adns_initflags prevent,
   fputs(aft,ads->diagfile);
 }
 
-void adns__debug(adns_state ads, int serv, adns_query qu, const char *fmt, ...) {
+void adns__debug(adns_state ads, int serv, adns_query qu,
+                const char *fmt, ...) {
   va_list al;
 
   va_start(al,fmt);
@@ -87,15 +89,18 @@ void adns__debug(adns_state ads, int serv, adns_query qu, const char *fmt, ...)
   va_end(al);
 }
 
-void adns__warn(adns_state ads, int serv, adns_query qu, const char *fmt, ...) {
+void adns__warn(adns_state ads, int serv, adns_query qu,
+               const char *fmt, ...) {
   va_list al;
 
   va_start(al,fmt);
-  adns__vdiag(ads," warning",adns_if_noerrprint|adns_if_noserverwarn,serv,qu,fmt,al);
+  adns__vdiag(ads," warning",
+             adns_if_noerrprint|adns_if_noserverwarn, serv,qu,fmt,al);
   va_end(al);
 }
 
-void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt, ...) {
+void adns__diag(adns_state ads, int serv, adns_query qu,
+               const char *fmt, ...) {
   va_list al;
 
   va_start(al,fmt);
@@ -156,10 +161,12 @@ void adns__vbuf_free(vbuf *vb) {
 /* Additional diagnostic functions */
 
 const char *adns__diag_domain(adns_state ads, int serv, adns_query qu,
-                             vbuf *vb, const byte *dgram, int dglen, int cbyte) {
+                             vbuf *vb, const byte *dgram,
+                             int dglen, int cbyte) {
   adns_status st;
 
-  st= adns__parse_domain(ads,serv,qu,vb, pdf_quoteok, dgram,dglen,&cbyte,dglen);
+  st= adns__parse_domain(ads,serv,qu,vb, pdf_quoteok,
+                        dgram,dglen,&cbyte,dglen);
   if (st == adns_s_nomemory) {
     return "<cannot report domain... out of memory>";
   }
@@ -218,36 +225,36 @@ static const struct sinfo {
   const char *abbrev;
   const char *string;
 } sinfos[]= {
-  SINFO(  ok,                  "OK"                                            ),
-
-  SINFO(  nomemory,            "Out of memory"                                 ),
-  SINFO(  unknownrrtype,       "Query not implemented in DNS library"          ),
-  SINFO(  systemfail,          "General resolver or system failure"            ),
-
-  SINFO(  timeout,             "DNS query timed out"                           ),
-  SINFO(  allservfail,         "All nameservers failed"                        ),
-  SINFO(  norecurse,           "Recursion denied by nameserver"                ),
-  SINFO(  invalidresponse,     "Nameserver sent bad response"                  ),
-  SINFO(  unknownformat,       "Nameserver used unknown format"                ),
-
-  SINFO(  rcodeservfail,       "Nameserver reports failure"                    ),
-  SINFO(  rcodeformaterror,    "Query not understood by nameserver"            ),
-  SINFO(  rcodenotimplemented, "Query not implemented by nameserver"           ),
-  SINFO(  rcoderefused,        "Query refused by nameserver"                   ),
-  SINFO(  rcodeunknown,        "Nameserver sent unknown response code"         ),
-  
-  SINFO(  inconsistent,        "Inconsistent resource records in DNS"          ),
-  SINFO(  prohibitedcname,     "DNS alias found where canonical name wanted"   ),
-  SINFO(  answerdomaininvalid, "Found syntactically invalid domain name"       ),
-  SINFO(  answerdomaintoolong, "Found overly-long domain name"                 ),
-  SINFO(  invaliddata,         "Found invalid DNS data"                        ),
-
-  SINFO(  querydomainwrong,    "Domain invalid for particular DNS query type"  ),
-  SINFO(  querydomaininvalid,  "Domain name is syntactically invalid"          ),
-  SINFO(  querydomaintoolong,  "Domain name or component is too long"          ),
-
-  SINFO(  nxdomain,            "No such domain"                                ),
-  SINFO(  nodata,              "No such data"                                  )
+  SINFO( ok,                  "OK"                                           ),
+                                                                             
+  SINFO( nomemory,            "Out of memory"                                ),
+  SINFO( unknownrrtype,       "Query not implemented in DNS library"         ),
+  SINFO( systemfail,          "General resolver or system failure"           ),
+                                                                             
+  SINFO( timeout,             "DNS query timed out"                          ),
+  SINFO( allservfail,         "All nameservers failed"                       ),
+  SINFO( norecurse,           "Recursion denied by nameserver"               ),
+  SINFO( invalidresponse,     "Nameserver sent bad response"                 ),
+  SINFO( unknownformat,       "Nameserver used unknown format"               ),
+                                                                             
+  SINFO( rcodeservfail,       "Nameserver reports failure"                   ),
+  SINFO( rcodeformaterror,    "Query not understood by nameserver"           ),
+  SINFO( rcodenotimplemented, "Query not implemented by nameserver"          ),
+  SINFO( rcoderefused,        "Query refused by nameserver"                  ),
+  SINFO( rcodeunknown,        "Nameserver sent unknown response code"        ),
+                                                                             
+  SINFO( inconsistent,        "Inconsistent resource records in DNS"         ),
+  SINFO( prohibitedcname,     "DNS alias found where canonical name wanted"  ),
+  SINFO( answerdomaininvalid, "Found syntactically invalid domain name"      ),
+  SINFO( answerdomaintoolong, "Found overly-long domain name"                ),
+  SINFO( invaliddata,         "Found invalid DNS data"                       ),
+                                                                             
+  SINFO( querydomainwrong,    "Domain invalid for particular DNS query type" ),
+  SINFO( querydomaininvalid,  "Domain name is syntactically invalid"         ),
+  SINFO( querydomaintoolong,  "Domain name or component is too long"         ),
+                                                                             
+  SINFO( nxdomain,            "No such domain"                               ),
+  SINFO( nodata,              "No such data"                                 )
 };
 
 static int si_compar(const void *key, const void *elem) {
@@ -258,7 +265,8 @@ static int si_compar(const void *key, const void *elem) {
 }
 
 static const struct sinfo *findsinfo(adns_status st) {
-  return bsearch(&st,sinfos,sizeof(sinfos)/sizeof(*sinfos),sizeof(*sinfos),si_compar);
+  return bsearch(&st,sinfos, sizeof(sinfos)/sizeof(*sinfos),
+                sizeof(*sinfos), si_compar);
 }
 
 const char *adns_strerror(adns_status st) {
@@ -307,7 +315,8 @@ static int sti_compar(const void *key, const void *elem) {
 const char *adns_errtypeabbrev(adns_status st) {
   const struct stinfo *sti;
 
-  sti= bsearch(&st,stinfos,sizeof(stinfos)/sizeof(*stinfos),sizeof(*stinfos),sti_compar);
+  sti= bsearch(&st,stinfos, sizeof(stinfos)/sizeof(*stinfos),
+              sizeof(*stinfos), sti_compar);
   return sti->abbrev;
 }
 
index 4caa9de6031c8177ffb73880f6b6bd07add6ccbc..95fb6dffef4bb5548cfb42be29184f92fa15bc52 100644 (file)
@@ -129,7 +129,8 @@ typedef struct {
    * and will not be null-terminated by convstring.
    */
 
-  adns_status (*parse)(const parseinfo *pai, int cbyte, int max, void *store_r);
+  adns_status (*parse)(const parseinfo *pai, int cbyte,
+                      int max, void *store_r);
   /* Parse one RR, in dgram of length dglen, starting at cbyte and
    * extending until at most max.
    *
@@ -141,7 +142,7 @@ typedef struct {
    * nsstart is the offset of the authority section.
    */
 
-  int (*diff_needswap)(adns_state ads, const void *datap_a, const void *datap_b);
+  int (*diff_needswap)(adns_state ads,const void *datap_a,const void *datap_b);
   /* Returns !0 if RR a should be strictly after RR b in the sort order,
    * 0 otherwise.  Must not fail.
    */
@@ -327,7 +328,7 @@ void adns__diag(adns_state ads, int serv, adns_query qu,
                const char *fmt, ...) PRINTFFORMAT(4,5);
 
 int adns__vbuf_ensure(vbuf *vb, int want);
-int adns__vbuf_appendstr(vbuf *vb, const char *data); /* does not include nul */
+int adns__vbuf_appendstr(vbuf *vb, const char *data); /* doesn't include nul */
 int adns__vbuf_append(vbuf *vb, const byte *data, int len);
 /* 1=>success, 0=>realloc failed */
 void adns__vbuf_appendq(vbuf *vb, const byte *data, int len);
@@ -335,7 +336,8 @@ void adns__vbuf_init(vbuf *vb);
 void adns__vbuf_free(vbuf *vb);
 
 const char *adns__diag_domain(adns_state ads, int serv, adns_query qu,
-                             vbuf *vb, const byte *dgram, int dglen, int cbyte);
+                             vbuf *vb,
+                             const byte *dgram, int dglen, int cbyte);
 /* Unpicks a domain in a datagram and returns a string suitable for
  * printing it as.  Never fails - if an error occurs, it will
  * return some kind of string describing the error.
@@ -374,7 +376,8 @@ adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r,
  */
 
 adns_status adns__mkquery_frdgram(adns_state ads, vbuf *vb, int *id_r,
-                                 const byte *qd_dgram, int qd_dglen, int qd_begin,
+                                 const byte *qd_dgram, int qd_dglen,
+                                 int qd_begin,
                                  adns_rrtype type, adns_queryflags flags);
 /* Same as adns__mkquery, but takes the owner domain from an existing datagram.
  * That domain must be correct and untruncated.
@@ -389,8 +392,8 @@ void adns__querysend_tcp(adns_query qu, struct timeval now);
 void adns__query_send(adns_query qu, struct timeval now);
 /* Query must be in state tosend/NONE; it will be moved to a new state,
  * and no further processing can be done on it for now.
- * (Resulting state is one of udp/timew, tcpwait/timew (if server not connected),
- *  tcpsent/timew, child/childw or done/output.)
+ * (Resulting state is one of udp/timew, tcpwait/timew (if server not
+ * connected), tcpsent/timew, child/childw or done/output.)
  * __query_send may decide to use either UDP or TCP depending whether
  * _qf_usevc is set (or has become set) and whether the query is too
  * large.
@@ -399,7 +402,8 @@ void adns__query_send(adns_query qu, struct timeval now);
 /* From query.c: */
 
 adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
-                                 const typeinfo *typei, vbuf *qumsg_vb, int id,
+                                 const typeinfo *typei, vbuf *qumsg_vb,
+                                 int id,
                                  adns_queryflags flags, struct timeval now,
                                  const qcontext *ctx);
 /* Submits a query (for internal use, called during external submits).
@@ -460,7 +464,8 @@ void *adns__alloc_preserved(adns_query qu, size_t sz);
  *  answer->cname and answer->owner are _preserved.
  */
 
-void adns__transfer_interim(adns_query from, adns_query to, void *block, size_t sz);
+void adns__transfer_interim(adns_query from, adns_query to,
+                           void *block, size_t sz);
 /* Transfers an interim allocation from one query to another, so that
  * the `to' query will have room for the data when we get to makefinal
  * and so that the free will happen when the `to' query is freed
@@ -537,7 +542,8 @@ void adns__findlabel_start(findlabel_state *fls, adns_state ads,
  * serv may be -1, qu may be null - they are for error reporting.
  */
 
-adns_status adns__findlabel_next(findlabel_state *fls, int *lablen_r, int *labstart_r);
+adns_status adns__findlabel_next(findlabel_state *fls,
+                                int *lablen_r, int *labstart_r);
 /* Then, call this one repeatedly.
  *
  * It will return adns_s_ok if all is well, and tell you the length
@@ -568,7 +574,8 @@ typedef enum {
 
 adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
                               vbuf *vb, parsedomain_flags flags,
-                              const byte *dgram, int dglen, int *cbyte_io, int max);
+                              const byte *dgram, int dglen, int *cbyte_io,
+                              int max);
 /* vb must already have been initialised; it will be reset if necessary.
  * If there is truncation, vb->used will be set to 0; otherwise
  * (if there is no error) vb will be null-terminated.
@@ -578,7 +585,8 @@ adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
  */
 
 adns_status adns__parse_domain_more(findlabel_state *fls, adns_state ads,
-                                   adns_query qu, vbuf *vb, parsedomain_flags flags,
+                                   adns_query qu, vbuf *vb,
+                                   parsedomain_flags flags,
                                    const byte *dgram);
 /* Like adns__parse_domain, but you pass it a pre-initialised findlabel_state,
  * for continuing an existing domain or some such of some kind.  Also, unlike
@@ -617,10 +625,11 @@ adns_status adns__findrr(adns_query qu, int serv,
 
 adns_status adns__findrr_anychk(adns_query qu, int serv,
                                const byte *dgram, int dglen, int *cbyte_io,
-                               int *type_r, int *class_r, unsigned long *ttl_r,
+                               int *type_r, int *class_r,
+                               unsigned long *ttl_r,
                                int *rdlen_r, int *rdstart_r,
-                               const byte *eo_dgram, int eo_dglen, int eo_cbyte,
-                               int *eo_matched_r);
+                               const byte *eo_dgram, int eo_dglen,
+                               int eo_cbyte, int *eo_matched_r);
 /* Like adns__findrr_checked, except that the datagram and
  * owner to compare with can be specified explicitly.
  *
@@ -635,7 +644,8 @@ adns_status adns__findrr_anychk(adns_query qu, int serv,
  * untruncated.
  */
 
-void adns__update_expires(adns_query qu, unsigned long ttl, struct timeval now);
+void adns__update_expires(adns_query qu, unsigned long ttl,
+                         struct timeval now);
 /* Updates the `expires' field in the query, so that it doesn't exceed
  * now + ttl.
  */
@@ -682,12 +692,16 @@ void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc);
 
 /* Useful static inline functions: */
 
-static inline int ctype_whitespace(int c) { return c==' ' || c=='\n' || c=='\t'; }
+static inline int ctype_whitespace(int c) {
+  return c==' ' || c=='\n' || c=='\t';
+}
 static inline int ctype_digit(int c) { return c>='0' && c<='9'; }
 static inline int ctype_alpha(int c) {
   return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
 }
-static inline int ctype_822special(int c) { return strchr("()<>@,;:\\\".[]",c) != 0; }
+static inline int ctype_822special(int c) {
+  return strchr("()<>@,;:\\\".[]",c) != 0;
+}
 static inline int ctype_domainunquoted(int c) {
   return ctype_alpha(c) || ctype_digit(c) || (strchr("-_/+",c) != 0);
 }
@@ -696,18 +710,18 @@ static inline int errno_resources(int e) { return e==ENOMEM || e==ENOBUFS; }
 
 /* Useful macros */
 
-#define MEM_ROUND(sz) \
-  (( ((sz)+sizeof(union maxalign)-1) / sizeof(union maxalign) ) \
+#define MEM_ROUND(sz)                                          \
+  (( ((sz)+sizeof(union maxalign)-1) / sizeof(union maxalign) )        \
    * sizeof(union maxalign) )
 
 #define GETIL_B(cb) (((dgram)[(cb)++]) & 0x0ff)
 #define GET_B(cb,tv) ((tv)= GETIL_B((cb)))
-#define GET_W(cb,tv) ((tv)=0, (tv)|=(GETIL_B((cb))<<8), (tv)|=GETIL_B(cb), (tv))
-#define GET_L(cb,tv) ( (tv)=0, \
-                      (tv)|=(GETIL_B((cb))<<24), \
-                      (tv)|=(GETIL_B((cb))<<16), \
-                      (tv)|=(GETIL_B((cb))<<8), \
-                      (tv)|=GETIL_B(cb), \
+#define GET_W(cb,tv) ((tv)=0,(tv)|=(GETIL_B((cb))<<8), (tv)|=GETIL_B(cb), (tv))
+#define GET_L(cb,tv) ( (tv)=0,                         \
+                      (tv)|=(GETIL_B((cb))<<24),       \
+                      (tv)|=(GETIL_B((cb))<<16),       \
+                      (tv)|=(GETIL_B((cb))<<8),        \
+                      (tv)|=GETIL_B(cb),               \
                       (tv) )
 
 #endif
index 73f53f79f5a8b7ae80ac2807e572a893ecea9355..7d2730aaeba0601735750824f489081c364d38ef 100644 (file)
@@ -43,7 +43,8 @@ int vbuf__append_quoted1035(vbuf *vb, const byte *buf, int len) {
        break;
       }
     }
-    if (!adns__vbuf_append(vb,buf,i) || !adns__vbuf_append(vb,qbuf,strlen(qbuf)))
+    if (!adns__vbuf_append(vb,buf,i) ||
+       !adns__vbuf_append(vb,qbuf,strlen(qbuf)))
       return 0;
     if (i<len) i++;
     buf+= i;
@@ -106,22 +107,26 @@ adns_status adns__findlabel_next(findlabel_state *fls,
   return adns_s_ok;
 
  x_badresponse: 
-  adns__diag(fls->ads,fls->serv,fls->qu,"label in domain runs beyond end of domain");
+  adns__diag(fls->ads,fls->serv,fls->qu,
+            "label in domain runs beyond end of domain");
   return adns_s_invalidresponse;
 }
 
 adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
                               vbuf *vb, adns_queryflags flags,
-                              const byte *dgram, int dglen, int *cbyte_io, int max) {
+                              const byte *dgram, int dglen, int *cbyte_io,
+                              int max) {
   findlabel_state fls;
   
-  adns__findlabel_start(&fls,ads, serv,qu, dgram,dglen,max, *cbyte_io,cbyte_io);
+  adns__findlabel_start(&fls,ads, serv,qu, dgram,dglen,max,
+                       *cbyte_io,cbyte_io);
   vb->used= 0;
   return adns__parse_domain_more(&fls,ads,qu, vb,flags,dgram);
 }
 
 adns_status adns__parse_domain_more(findlabel_state *fls, adns_state ads,
-                                   adns_query qu, vbuf *vb, parsedomain_flags flags,
+                                   adns_query qu, vbuf *vb,
+                                   parsedomain_flags flags,
                                    const byte *dgram) {
   int lablen, labstart, i, ch, first;
   adns_status st;
@@ -142,7 +147,8 @@ adns_status adns__parse_domain_more(findlabel_state *fls, adns_state ads,
        return adns_s_nomemory;
     } else {
       ch= dgram[labstart];
-      if (!ctype_alpha(ch) && !ctype_digit(ch)) return adns_s_answerdomaininvalid;
+      if (!ctype_alpha(ch) && !ctype_digit(ch))
+       return adns_s_answerdomaininvalid;
       for (i= labstart+1; i<labstart+lablen; i++) {
        ch= dgram[i];
        if (ch != '-' && !ctype_alpha(ch) && !ctype_digit(ch))
@@ -158,10 +164,11 @@ adns_status adns__parse_domain_more(findlabel_state *fls, adns_state ads,
        
 adns_status adns__findrr_anychk(adns_query qu, int serv,
                                const byte *dgram, int dglen, int *cbyte_io,
-                               int *type_r, int *class_r, unsigned long *ttl_r,
+                               int *type_r, int *class_r,
+                               unsigned long *ttl_r,
                                int *rdlen_r, int *rdstart_r,
-                               const byte *eo_dgram, int eo_dglen, int eo_cbyte,
-                               int *eo_matched_r) {
+                               const byte *eo_dgram, int eo_dglen,
+                               int eo_cbyte, int *eo_matched_r) {
   findlabel_state fls, eo_fls;
   int cbyte;
   
@@ -175,7 +182,8 @@ adns_status adns__findrr_anychk(adns_query qu, int serv,
 
   adns__findlabel_start(&fls,qu->ads, serv,qu, dgram,dglen,dglen,cbyte,&cbyte);
   if (eo_dgram) {
-    adns__findlabel_start(&eo_fls,qu->ads, -1,0, eo_dgram,eo_dglen,eo_dglen,eo_cbyte,0);
+    adns__findlabel_start(&eo_fls,qu->ads, -1,0,
+                         eo_dgram,eo_dglen,eo_dglen,eo_cbyte,0);
     mismatch= 0;
   } else {
     mismatch= 1;
index 63de431394218cce60ad25e3e5d480423ed17e80..35d08555c86c4223f36868ecb086453503d4e156 100644 (file)
@@ -32,8 +32,8 @@
 
 #ifdef HAVE_POLL
 
-int adns_beforepoll(adns_state ads, struct pollfd *fds, int *nfds_io, int *timeout_io,
-                   const struct timeval *now) {
+int adns_beforepoll(adns_state ads, struct pollfd *fds, int *nfds_io,
+                   int *timeout_io, const struct timeval *now) {
   struct timeval tv_nowbuf, tv_tobuf, *tv_to;
   int space, found, timeout_ms, r;
   struct pollfd fds_tmp[MAX_POLLFDS];
index 2bb52361720842c151ca43e73b2a2ae1c4e5ddb1..3c98040ace1ef57d02910a18259db0f6f5a90dc8 100644 (file)
@@ -43,7 +43,8 @@ static adns_query query_alloc(adns_state ads, const typeinfo *typei,
   adns_query qu;
   
   qu= malloc(sizeof(*qu));  if (!qu) return 0;
-  qu->answer= malloc(sizeof(*qu->answer));  if (!qu->answer) { free(qu); return 0; }
+  qu->answer= malloc(sizeof(*qu->answer));
+  if (!qu->answer) { free(qu); return 0; }
   
   qu->ads= ads;
   qu->state= query_tosend;
@@ -108,7 +109,8 @@ static void query_submit(adns_state ads, adns_query qu,
 }
 
 adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
-                                 const typeinfo *typei, vbuf *qumsg_vb, int id,
+                                 const typeinfo *typei, vbuf *qumsg_vb,
+                                 int id,
                                  adns_queryflags flags, struct timeval now,
                                  const qcontext *ctx) {
   adns_query qu;
@@ -178,7 +180,8 @@ void adns__search_next(adns_state ads, adns_query qu, struct timeval now) {
   free(qu->query_dgram);
   qu->query_dgram= 0; qu->query_dglen= 0;
 
-  query_simple(ads,qu, qu->search_vb.buf, qu->search_vb.used, qu->typei, qu->flags, now);
+  query_simple(ads,qu, qu->search_vb.buf, qu->search_vb.used,
+              qu->typei, qu->flags, now);
   return;
 
 x_nomemory:
@@ -285,7 +288,8 @@ int adns_submit_reverse_any(adns_state ads,
   flags &= ~adns_qf_search;
 
   if (addr->sa_family != AF_INET) return ENOSYS;
-  iaddr= (const unsigned char*) &(((const struct sockaddr_in*)addr) -> sin_addr);
+  iaddr= (const unsigned char*)
+    &(((const struct sockaddr_in*)addr) -> sin_addr);
 
   lreq= strlen(zone) + 4*4 + 1;
   if (lreq > sizeof(shortbuf)) {
@@ -310,7 +314,8 @@ int adns_submit_reverse(adns_state ads,
                        void *context,
                        adns_query *query_r) {
   if (type != adns_r_ptr && type != adns_r_ptr_raw) return EINVAL;
-  return adns_submit_reverse_any(ads,addr,"in-addr.arpa",type,flags,context,query_r);
+  return adns_submit_reverse_any(ads,addr,"in-addr.arpa",
+                                type,flags,context,query_r);
 }
 
 int adns_synchronous(adns_state ads,
@@ -365,7 +370,8 @@ void *adns__alloc_mine(adns_query qu, size_t sz) {
   return alloc_common(qu,MEM_ROUND(sz));
 }
 
-void adns__transfer_interim(adns_query from, adns_query to, void *block, size_t sz) {
+void adns__transfer_interim(adns_query from, adns_query to,
+                           void *block, size_t sz) {
   allocnode *an;
 
   if (!block) return;
@@ -457,7 +463,8 @@ void adns_cancel(adns_query qu) {
   adns__consistency(ads,0,cc_entex);
 }
 
-void adns__update_expires(adns_query qu, unsigned long ttl, struct timeval now) {
+void adns__update_expires(adns_query qu, unsigned long ttl,
+                         struct timeval now) {
   time_t max;
 
   assert(ttl <= MAXTTLBELIEVE);
@@ -473,7 +480,8 @@ static void makefinal_query(adns_query qu) {
   ans= qu->answer;
 
   if (qu->interim_allocd) {
-    ans= realloc(qu->answer, MEM_ROUND(MEM_ROUND(sizeof(*ans)) + qu->interim_allocd));
+    ans= realloc(qu->answer,
+                MEM_ROUND(MEM_ROUND(sizeof(*ans)) + qu->interim_allocd));
     if (!ans) goto x_nomem;
     qu->answer= ans;
   }
@@ -525,7 +533,8 @@ void adns__query_done(adns_query qu) {
     }
     adns__isort(ans->rrs.bytes, ans->nrrs, ans->rrsz,
                qu->vb.buf,
-               (int(*)(void*, const void*, const void*))qu->typei->diff_needswap,
+               (int(*)(void*, const void*, const void*))
+                 qu->typei->diff_needswap,
                qu->ads);
   }
 
index 2691f679d31cce4ac4b77be2ec8a05bea1e75f95..4e7f8f7aa782bf0d02aff0780d1d0ec2b0e33710 100644 (file)
@@ -47,7 +47,8 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
   parseinfo pai;
   
   if (dglen<DNS_HDRSIZE) {
-    adns__diag(ads,serv,0,"received datagram too short for message header (%d)",dglen);
+    adns__diag(ads,serv,0,"received datagram"
+              " too short for message header (%d)",dglen);
     return;
   }
   cbyte= 0;
@@ -74,7 +75,8 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
     return;
   }
   if (opcode) {
-    adns__diag(ads,serv,0,"server sent us unknown opcode %d (wanted 0=QUERY)",opcode);
+    adns__diag(ads,serv,0,"server sent us unknown opcode"
+              " %d (wanted 0=QUERY)",opcode);
     return;
   }
 
@@ -114,7 +116,8 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
   case rcode_nxdomain:
     break;
   case rcode_formaterror:
-    adns__warn(ads,serv,qu,"server cannot understand our query (Format Error)");
+    adns__warn(ads,serv,qu,"server cannot understand our query"
+              " (Format Error)");
     if (qu) adns__query_fail(qu,adns_s_rcodeformaterror);
     return;
   case rcode_servfail:
@@ -139,18 +142,20 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
     if (!qdcount) {
       adns__diag(ads,serv,0,"server sent reply without quoting our question");
     } else if (qdcount>1) {
-      adns__diag(ads,serv,0,"server claimed to answer %d questions with one message",
-                qdcount);
+      adns__diag(ads,serv,0,"server claimed to answer %d"
+                " questions with one message", qdcount);
     } else if (ads->iflags & adns_if_debug) {
       adns__vbuf_init(&tempvb);
       adns__debug(ads,serv,0,"reply not found, id %02x, query owner %s",
-                 id, adns__diag_domain(ads,serv,0,&tempvb,dgram,dglen,DNS_HDRSIZE));
+                 id, adns__diag_domain(ads,serv,0,&tempvb,
+                                       dgram,dglen,DNS_HDRSIZE));
       adns__vbuf_free(&tempvb);
     }
     return;
   }
 
-  /* We're definitely going to do something with this packet and this query now. */
+  /* We're definitely going to do something with this packet and this
+   * query now. */
   
   anstart= qu->query_dglen;
   arstart= -1;
@@ -169,14 +174,15 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
     if (rrtype == -1) goto x_truncated;
 
     if (rrclass != DNS_CLASS_IN) {
-      adns__diag(ads,serv,qu,"ignoring answer RR with wrong class %d (expected IN=%d)",
-                rrclass,DNS_CLASS_IN);
+      adns__diag(ads,serv,qu,"ignoring answer RR with wrong class %d"
+                " (expected IN=%d)", rrclass,DNS_CLASS_IN);
       continue;
     }
     if (!ownermatched) {
       if (ads->iflags & adns_if_debug) {
        adns__debug(ads,serv,qu,"ignoring RR with an unexpected owner %s",
-                   adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rrstart));
+                   adns__diag_domain(ads,serv,qu, &qu->vb,
+                                     dgram,dglen,rrstart));
       }
       continue;
     }
@@ -186,14 +192,16 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
        adns__query_fail(qu,adns_s_prohibitedcname);
        return;
       } else if (qu->cname_dgram) { /* Ignore second and subsequent CNAME(s) */
-       adns__debug(ads,serv,qu,"allegedly canonical name %s is actually alias for %s",
-                   qu->answer->cname,
-                   adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rdstart));
+       adns__debug(ads,serv,qu,"allegedly canonical name %s"
+                   " is actually alias for %s", qu->answer->cname,
+                   adns__diag_domain(ads,serv,qu, &qu->vb,
+                                     dgram,dglen,rdstart));
        adns__query_fail(qu,adns_s_prohibitedcname);
        return;
       } else if (wantedrrs) { /* Ignore CNAME(s) after RR(s). */
        adns__debug(ads,serv,qu,"ignoring CNAME (to %s) coexisting with RR",
-                   adns__diag_domain(ads,serv,qu, &qu->vb, dgram,dglen,rdstart));
+                   adns__diag_domain(ads,serv,qu, &qu->vb,
+                                     dgram,dglen,rdstart));
       } else {
        qu->cname_begin= rdstart;
        qu->cname_dglen= dglen;
@@ -205,7 +213,10 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
        if (st) { adns__query_fail(qu,st); return; }
        l= strlen(qu->vb.buf)+1;
        qu->answer->cname= adns__alloc_preserved(qu,l);
-       if (!qu->answer->cname) { adns__query_fail(qu,adns_s_nomemory); return; }
+       if (!qu->answer->cname) {
+         adns__query_fail(qu,adns_s_nomemory);
+         return;
+       }
 
        qu->cname_dgram= adns__alloc_mine(qu,dglen);
        memcpy(qu->cname_dgram,dgram,dglen);
@@ -222,7 +233,8 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
     } else if (rrtype == (qu->typei->type & adns__rrt_typemask)) {
       wantedrrs++;
     } else {
-      adns__debug(ads,serv,qu,"ignoring answer RR with irrelevant type %d",rrtype);
+      adns__debug(ads,serv,qu,"ignoring answer RR"
+                 " with irrelevant type %d",rrtype);
     }
   }
 
@@ -234,9 +246,11 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
   nsstart= cbyte;
 
   if (!wantedrrs) {
-    /* Oops, NODATA or NXDOMAIN or perhaps a referral (which would be a problem) */
+    /* Oops, NODATA or NXDOMAIN or perhaps a referral
+     * (which would be a problem) */
 
-    /* RFC2308: NODATA has _either_ a SOA _or_ _no_ NS records in authority section */
+    /* RFC2308: NODATA has _either_ a SOA _or_ _no_ NS records
+     * in authority section */
     foundsoa= 0; soattl= 0; foundns= 0;
     for (rri= 0; rri<nscount; rri++) {
       rrstart= cbyte;
@@ -246,8 +260,8 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
       if (rrtype==-1) goto x_truncated;
       if (rrclass != DNS_CLASS_IN) {
        adns__diag(ads,serv,qu,
-                  "ignoring authority RR with wrong class %d (expected IN=%d)",
-                  rrclass,DNS_CLASS_IN);
+                  "ignoring authority RR with wrong class %d"
+                  " (expected IN=%d)", rrclass,DNS_CLASS_IN);
        continue;
       }
       if (rrtype == adns_r_soa_raw) { foundsoa= 1; soattl= ttl; break; }
@@ -282,13 +296,16 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
 
     /* Bloody hell, I thought we asked for recursion ? */
     if (!flg_ra) {
-      adns__diag(ads,serv,qu,"server is not willing to do recursive lookups for us");
+      adns__diag(ads,serv,qu,"server is not willing"
+                " to do recursive lookups for us");
       adns__query_fail(qu,adns_s_norecurse);
     } else {
       if (!flg_rd)
-       adns__diag(ads,serv,qu,"server thinks we didn't ask for recursive lookup");
+       adns__diag(ads,serv,qu,"server thinks"
+                  " we didn't ask for recursive lookup");
       else
-       adns__debug(ads,serv,qu,"server claims to do recursion, but gave us a referral");
+       adns__debug(ads,serv,qu,"server claims to do recursion,"
+                   " but gave us a referral");
       adns__query_fail(qu,adns_s_invalidresponse);
     }
     return;
@@ -297,7 +314,10 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
   /* Now, we have some RRs which we wanted. */
 
   qu->answer->rrs.untyped= adns__alloc_interim(qu,qu->typei->rrsz*wantedrrs);
-  if (!qu->answer->rrs.untyped) { adns__query_fail(qu,adns_s_nomemory); return; }
+  if (!qu->answer->rrs.untyped) {
+    adns__query_fail(qu,adns_s_nomemory);
+    return;
+  }
 
   typei= qu->typei;
   cbyte= anstart;
@@ -352,7 +372,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
  x_restartquery:
   if (qu->cname_dgram) {
     st= adns__mkquery_frdgram(qu->ads,&qu->vb,&qu->id,
-                             qu->cname_dgram, qu->cname_dglen, qu->cname_begin,
+                             qu->cname_dgram,qu->cname_dglen,qu->cname_begin,
                              qu->typei->type, qu->flags);
     if (st) { adns__query_fail(qu,st); return; }
     
index 45ae0444a1e5fd7112ca0ad5e2b22848c3159dd6..c3452b0dd36d3253525707405569a3da718a380d 100644 (file)
@@ -104,7 +104,8 @@ static int nextword(const char **bufp_io, const char **word_r, int *l_r) {
   return 1;
 }
 
-static void ccf_nameserver(adns_state ads, const char *fn, int lno, const char *buf) {
+static void ccf_nameserver(adns_state ads, const char *fn,
+                          int lno, const char *buf) {
   struct in_addr ia;
   
   if (!inet_aton(buf,&ia)) {
@@ -115,7 +116,8 @@ static void ccf_nameserver(adns_state ads, const char *fn, int lno, const char *
   addserver(ads,ia);
 }
 
-static void ccf_search(adns_state ads, const char *fn, int lno, const char *buf) {
+static void ccf_search(adns_state ads, const char *fn,
+                      int lno, const char *buf) {
   const char *bufp, *word;
   char *newchars, **newptrs, **pp;
   int count, tl, l;
@@ -127,8 +129,11 @@ static void ccf_search(adns_state ads, const char *fn, int lno, const char *buf)
   tl= 0;
   while (nextword(&bufp,&word,&l)) { count++; tl += l+1; }
 
-  newptrs= malloc(sizeof(char*)*count);  if (!newptrs) { saveerr(ads,errno); return; }
-  newchars= malloc(tl);  if (!newchars) { saveerr(ads,errno); free(newptrs); return; }
+  newptrs= malloc(sizeof(char*)*count);
+  if (!newptrs) { saveerr(ads,errno); return; }
+
+  newchars= malloc(tl);
+  if (!newchars) { saveerr(ads,errno); free(newptrs); return; }
 
   bufp= buf;
   pp= newptrs;
@@ -144,7 +149,8 @@ static void ccf_search(adns_state ads, const char *fn, int lno, const char *buf)
   ads->searchlist= newptrs;
 }
 
-static void ccf_sortlist(adns_state ads, const char *fn, int lno, const char *buf) {
+static void ccf_sortlist(adns_state ads, const char *fn,
+                        int lno, const char *buf) {
   const char *word;
   char tbuf[200], *slash, *ep;
   struct in_addr base, mask;
@@ -156,7 +162,8 @@ static void ccf_sortlist(adns_state ads, const char *fn, int lno, const char *bu
   ads->nsortlist= 0;
   while (nextword(&buf,&word,&l)) {
     if (ads->nsortlist >= MAXSORTLIST) {
-      adns__diag(ads,-1,0,"too many sortlist entries, ignoring %.*s onwards",l,word);
+      adns__diag(ads,-1,0,"too many sortlist entries,"
+                " ignoring %.*s onwards",l,word);
       return;
     }
 
@@ -181,8 +188,8 @@ static void ccf_sortlist(adns_state ads, const char *fn, int lno, const char *bu
          continue;
        }
        if (base.s_addr & ~mask.s_addr) {
-         configparseerr(ads,fn,lno,
-                        "mask `%s' in sortlist overlaps address `%s'",slash,tbuf);
+         configparseerr(ads,fn,lno, "mask `%s' in sortlist"
+                        " overlaps address `%s'",slash,tbuf);
          continue;
        }
       } else {
@@ -202,8 +209,8 @@ static void ccf_sortlist(adns_state ads, const char *fn, int lno, const char *bu
       else if ((baselocal & 0x0f0000000UL) == 0x0e0000000UL)
        mask.s_addr= htonl(0x0ff000000UL); /* class C */
       else {
-       configparseerr(ads,fn,lno,
-                      "network address `%s' in sortlist is not in classed ranges,"
+       configparseerr(ads,fn,lno, "network address `%s'"
+                      " in sortlist is not in classed ranges,"
                       " must specify mask explicitly", tbuf);
        continue;
       }
@@ -215,7 +222,8 @@ static void ccf_sortlist(adns_state ads, const char *fn, int lno, const char *bu
   }
 }
 
-static void ccf_options(adns_state ads, const char *fn, int lno, const char *buf) {
+static void ccf_options(adns_state ads, const char *fn,
+                       int lno, const char *buf) {
   const char *word;
   char *ep;
   unsigned long v;
@@ -231,7 +239,8 @@ static void ccf_options(adns_state ads, const char *fn, int lno, const char *buf
     if (l>=6 && !memcmp(word,"ndots:",6)) {
       v= strtoul(word+6,&ep,10);
       if (l==6 || ep != word+l || v > INT_MAX) {
-       configparseerr(ads,fn,lno,"option `%.*s' malformed or has bad value",l,word);
+       configparseerr(ads,fn,lno,"option `%.*s' malformed"
+                      " or has bad value",l,word);
        continue;
       }
       ads->searchndots= v;
@@ -256,11 +265,13 @@ static void ccf_options(adns_state ads, const char *fn, int lno, const char *buf
   }
 }
 
-static void ccf_clearnss(adns_state ads, const char *fn, int lno, const char *buf) {
+static void ccf_clearnss(adns_state ads, const char *fn,
+                        int lno, const char *buf) {
   ads->nservers= 0;
 }
 
-static void ccf_include(adns_state ads, const char *fn, int lno, const char *buf) {
+static void ccf_include(adns_state ads, const char *fn,
+                       int lno, const char *buf) {
   if (!*buf) {
     configparseerr(ads,fn,lno,"`include' directive with no filename");
     return;
@@ -341,7 +352,8 @@ static int gl_file(adns_state ads, getline_ctx *src_io, const char *filename,
     } else if (c == EOF) {
       if (ferror(file)) {
        saveerr(ads,errno);
-       adns__diag(ads,-1,0,"%s:%d: read error: %s",filename,lno,strerror(errno));
+       adns__diag(ads,-1,0,"%s:%d: read error: %s",
+                  filename,lno,strerror(errno));
        return -1;
       }
       if (!i) return -1;
@@ -409,7 +421,8 @@ static void readconfiggeneric(adns_state ads, const char *filename,
     while (*q && !ctype_whitespace(*q)) q++;
     dirl= q-p;
     for (ccip=configcommandinfos;
-        ccip->name && !(strlen(ccip->name)==dirl && !memcmp(ccip->name,p,q-p));
+        ccip->name &&
+          !(strlen(ccip->name)==dirl && !memcmp(ccip->name,p,q-p));
         ccip++);
     if (!ccip->name) {
       adns__diag(ads,-1,0,"%s:%d: unknown configuration directive `%.*s'",
@@ -426,7 +439,8 @@ static const char *instrum_getenv(adns_state ads, const char *envvar) {
 
   value= getenv(envvar);
   if (!value) adns__debug(ads,-1,0,"environment variable %s not set",envvar);
-  else adns__debug(ads,-1,0,"environment variable %s set to `%s'",envvar,value);
+  else adns__debug(ads,-1,0,"environment variable %s"
+                  " set to `%s'",envvar,value);
   return value;
 }
 
@@ -437,7 +451,8 @@ static void readconfig(adns_state ads, const char *filename, int warnmissing) {
   if (!gl_ctx.file) {
     if (errno == ENOENT) {
       if (warnmissing)
-       adns__debug(ads,-1,0,"configuration file `%s' does not exist",filename);
+       adns__debug(ads,-1,0, "configuration file"
+                   " `%s' does not exist",filename);
       return;
     }
     saveerr(ads,errno);
@@ -451,7 +466,8 @@ static void readconfig(adns_state ads, const char *filename, int warnmissing) {
   fclose(gl_ctx.file);
 }
 
-static void readconfigtext(adns_state ads, const char *text, const char *showname) {
+static void readconfigtext(adns_state ads, const char *text,
+                          const char *showname) {
   getline_ctx gl_ctx;
   
   gl_ctx.text= text;
@@ -490,7 +506,8 @@ int adns__setnonblock(adns_state ads, int fd) {
   return 0;
 }
 
-static int init_begin(adns_state *ads_r, adns_initflags flags, FILE *diagfile) {
+static int init_begin(adns_state *ads_r, adns_initflags flags,
+                     FILE *diagfile) {
   adns_state ads;
   
   ads= malloc(sizeof(*ads)); if (!ads) return errno;
index 47785e6b57bab73c7a773a12b54630d54d789bc2..3b148227ef48f87a6cc57c3fbe28155fb6fe0aa9 100644 (file)
@@ -39,7 +39,8 @@
 #define MKQUERY_ADDW(w) (MKQUERY_ADDB(((w)>>8)&0x0ff), MKQUERY_ADDB((w)&0x0ff))
 #define MKQUERY_STOP(vb) ((vb)->used= rqp-(vb)->buf)
 
-static adns_status mkquery_header(adns_state ads, vbuf *vb, int *id_r, int qdlen) {
+static adns_status mkquery_header(adns_state ads, vbuf *vb,
+                                 int *id_r, int qdlen) {
   int id;
   byte *rqp;
   
@@ -131,7 +132,8 @@ adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r,
 }
 
 adns_status adns__mkquery_frdgram(adns_state ads, vbuf *vb, int *id_r,
-                                 const byte *qd_dgram, int qd_dglen, int qd_begin,
+                                 const byte *qd_dgram, int qd_dglen,
+                                 int qd_begin,
                                  adns_rrtype type, adns_queryflags flags) {
   byte *rqp;
   findlabel_state fls;
@@ -174,7 +176,8 @@ void adns__querysend_tcp(adns_query qu, struct timeval now) {
   length[1]= (qu->query_dglen&0x0ff);
 
   ads= qu->ads;
-  if (!adns__vbuf_ensure(&ads->tcpsend,ads->tcpsend.used+qu->query_dglen+2)) return;
+  if (!adns__vbuf_ensure(&ads->tcpsend,ads->tcpsend.used+qu->query_dglen+2))
+    return;
 
   qu->retries++;
 
@@ -208,7 +211,8 @@ void adns__querysend_tcp(adns_query qu, struct timeval now) {
     wr-= 2;
   }
   if (wr<qu->query_dglen) {
-    r= adns__vbuf_append(&ads->tcpsend,qu->query_dgram+wr,qu->query_dglen-wr); assert(r);
+    r= adns__vbuf_append(&ads->tcpsend,qu->query_dgram+wr,qu->query_dglen-wr);
+    assert(r);
   }
 }
 
@@ -247,8 +251,13 @@ void adns__query_send(adns_query qu, struct timeval now) {
   
   r= sendto(ads->udpsocket,qu->query_dgram,qu->query_dglen,0,
            (const struct sockaddr*)&servaddr,sizeof(servaddr));
-  if (r<0 && errno == EMSGSIZE) { qu->retries= 0; query_usetcp(qu,now); return; }
-  if (r<0 && errno != EAGAIN) adns__warn(ads,serv,0,"sendto failed: %s",strerror(errno));
+  if (r<0 && errno == EMSGSIZE) {
+    qu->retries= 0;
+    query_usetcp(qu,now);
+    return;
+  }
+  if (r<0 && errno != EAGAIN)
+    adns__warn(ads,serv,0,"sendto failed: %s",strerror(errno));
   
   qu->timeout= now;
   timevaladd(&qu->timeout,UDPRETRYMS);
index b1fdae79f93eefd6fd1500465e486058cbbac73c..d62bbb5cd49b487b55df857412fc1e2eae251390 100644 (file)
 
 #include "internal.h"
 
-#define R_NOMEM           return adns_s_nomemory
-#define CSP_ADDSTR(s)     do { if (!adns__vbuf_appendstr(vb,(s))) R_NOMEM; } while (0)
+#define R_NOMEM       return adns_s_nomemory
+#define CSP_ADDSTR(s) do {                     \
+    if (!adns__vbuf_appendstr(vb,(s))) R_NOMEM;        \
+  } while (0)
 
 /*
  * order of sections:
@@ -172,7 +174,8 @@ static void mf_manyistr(adns_query qu, void *datap) {
  * _txt   (pa,cs)
  */
 
-static adns_status pa_txt(const parseinfo *pai, int cbyte, int max, void *datap) {
+static adns_status pa_txt(const parseinfo *pai, int cbyte,
+                         int max, void *datap) {
   adns_rr_intstr **rrp= datap, *table, *te;
   const byte *dgram= pai->dgram;
   int ti, tc, l, startbyte;
@@ -235,7 +238,8 @@ static adns_status cs_hinfo(vbuf *vb, const void *datap) {
  * _inaddr   (pa,dip,di)
  */
 
-static adns_status pa_inaddr(const parseinfo *pai, int cbyte, int max, void *datap) {
+static adns_status pa_inaddr(const parseinfo *pai, int cbyte,
+                            int max, void *datap) {
   struct in_addr *storeto= datap;
   
   if (max-cbyte != 4) return adns_s_invaliddata;
@@ -248,7 +252,8 @@ static int search_sortlist(adns_state ads, struct in_addr ad) {
   int i;
   
   for (i=0, slp=ads->sortlist;
-       i<ads->nsortlist && !((ad.s_addr & slp->mask.s_addr) == slp->base.s_addr);
+       i<ads->nsortlist &&
+        !((ad.s_addr & slp->mask.s_addr) == slp->base.s_addr);
        i++, slp++);
   return i;
 }
@@ -263,7 +268,8 @@ static int dip_inaddr(adns_state ads, struct in_addr a, struct in_addr b) {
   return bi<ai;
 }
 
-static int di_inaddr(adns_state ads, const void *datap_a, const void *datap_b) {
+static int di_inaddr(adns_state ads,
+                    const void *datap_a, const void *datap_b) {
   const struct in_addr *ap= datap_a, *bp= datap_b;
 
   return dip_inaddr(ads,*ap,*bp);
@@ -282,7 +288,8 @@ static adns_status cs_inaddr(vbuf *vb, const void *datap) {
  * _addr   (pa,di,csp,cs)
  */
 
-static adns_status pa_addr(const parseinfo *pai, int cbyte, int max, void *datap) {
+static adns_status pa_addr(const parseinfo *pai, int cbyte,
+                          int max, void *datap) {
   adns_rr_addr *storeto= datap;
   const byte *dgram= pai->dgram;
 
@@ -367,7 +374,8 @@ static adns_status cs_domain(vbuf *vb, const void *datap) {
   return csp_domain(vb,*domainp);
 }
 
-static adns_status pa_dom_raw(const parseinfo *pai, int cbyte, int max, void *datap) {
+static adns_status pa_dom_raw(const parseinfo *pai, int cbyte,
+                             int max, void *datap) {
   char **rrp= datap;
   adns_status st;
 
@@ -382,7 +390,8 @@ static adns_status pa_dom_raw(const parseinfo *pai, int cbyte, int max, void *da
  * _host_raw   (pa)
  */
 
-static adns_status pa_host_raw(const parseinfo *pai, int cbyte, int max, void *datap) {
+static adns_status pa_host_raw(const parseinfo *pai, int cbyte,
+                              int max, void *datap) {
   char **rrp= datap;
   adns_status st;
 
@@ -406,7 +415,8 @@ static adns_status pap_findaddrs(const parseinfo *pai, adns_rr_hostaddr *ha,
   adns_status st;
   
   for (rri=0, naddrs=-1; rri<count; rri++) {
-    st= adns__findrr_anychk(pai->qu, pai->serv, pai->dgram, pai->dglen, cbyte_io,
+    st= adns__findrr_anychk(pai->qu, pai->serv, pai->dgram,
+                           pai->dglen, cbyte_io,
                            &type, &class, &ttl, &rdlen, &rdstart,
                            pai->dgram, pai->dglen, dmstart, &ownermatched);
     if (st) return st;
@@ -416,7 +426,8 @@ static adns_status pap_findaddrs(const parseinfo *pai, adns_rr_hostaddr *ha,
     if (naddrs == -1) {
       naddrs= 0;
     }
-    if (!adns__vbuf_ensure(&pai->qu->vb, (naddrs+1)*sizeof(adns_rr_addr))) R_NOMEM;
+    if (!adns__vbuf_ensure(&pai->qu->vb, (naddrs+1)*sizeof(adns_rr_addr)))
+      R_NOMEM;
     adns__update_expires(pai->qu,ttl,pai->now);
     st= pa_addr(pai, rdstart,rdstart+rdlen,
                pai->qu->vb.buf + naddrs*sizeof(adns_rr_addr));
@@ -446,7 +457,8 @@ static void icb_hostaddr(adns_query parent, adns_query child) {
   rrp->astatus= st;
   rrp->naddrs= (st>0 && st<=adns_s_max_tempfail) ? -1 : cans->nrrs;
   rrp->addrs= cans->rrs.addr;
-  adns__transfer_interim(child, parent, rrp->addrs, rrp->naddrs*sizeof(adns_rr_addr));
+  adns__transfer_interim(child, parent, rrp->addrs,
+                        rrp->naddrs*sizeof(adns_rr_addr));
 
   if (parent->children.head) {
     LIST_LINK_TAIL(ads->childw,parent);
@@ -506,7 +518,8 @@ static adns_status pap_hostaddr(const parseinfo *pai, int *cbyte_io,
   return adns_s_ok;
 }
 
-static adns_status pa_hostaddr(const parseinfo *pai, int cbyte, int max, void *datap) {
+static adns_status pa_hostaddr(const parseinfo *pai, int cbyte,
+                              int max, void *datap) {
   adns_rr_hostaddr *rrp= datap;
   adns_status st;
 
@@ -517,7 +530,8 @@ static adns_status pa_hostaddr(const parseinfo *pai, int cbyte, int max, void *d
   return adns_s_ok;
 }
 
-static int dip_hostaddr(adns_state ads, const adns_rr_hostaddr *ap, const adns_rr_hostaddr *bp) {
+static int dip_hostaddr(adns_state ads,
+                       const adns_rr_hostaddr *ap, const adns_rr_hostaddr *bp) {
   if (ap->astatus != bp->astatus) return ap->astatus;
   if (ap->astatus) return 0;
 
@@ -528,7 +542,8 @@ static int dip_hostaddr(adns_state ads, const adns_rr_hostaddr *ap, const adns_r
                    bp->addrs[0].addr.inet.sin_addr);
 }
 
-static int di_hostaddr(adns_state ads, const void *datap_a, const void *datap_b) {
+static int di_hostaddr(adns_state ads,
+                      const void *datap_a, const void *datap_b) {
   const adns_rr_hostaddr *ap= datap_a, *bp= datap_b;
 
   return dip_hostaddr(ads, ap,bp);
@@ -592,7 +607,8 @@ static adns_status cs_hostaddr(vbuf *vb, const void *datap) {
  * _mx_raw   (pa,di)
  */
 
-static adns_status pa_mx_raw(const parseinfo *pai, int cbyte, int max, void *datap) {
+static adns_status pa_mx_raw(const parseinfo *pai, int cbyte,
+                            int max, void *datap) {
   const byte *dgram= pai->dgram;
   adns_rr_intstr *rrp= datap;
   adns_status st;
@@ -621,7 +637,8 @@ static int di_mx_raw(adns_state ads, const void *datap_a, const void *datap_b) {
  * _mx   (pa,di)
  */
 
-static adns_status pa_mx(const parseinfo *pai, int cbyte, int max, void *datap) {
+static adns_status pa_mx(const parseinfo *pai, int cbyte,
+                        int max, void *datap) {
   const byte *dgram= pai->dgram;
   adns_rr_inthostaddr *rrp= datap;
   adns_status st;
@@ -713,7 +730,8 @@ static void icb_ptr(adns_query parent, adns_query child) {
   adns__query_fail(parent,adns_s_inconsistent);
 }
 
-static adns_status pa_ptr(const parseinfo *pai, int dmstart, int max, void *datap) {
+static adns_status pa_ptr(const parseinfo *pai, int dmstart,
+                         int max, void *datap) {
   static const char *(expectdomain[])= { DNS_INADDR_ARPA };
   
   char **rrp= datap;
@@ -741,15 +759,18 @@ static adns_status pa_ptr(const parseinfo *pai, int dmstart, int max, void *data
     for (i=0; i<4; i++) {
       st= adns__findlabel_next(&fls,&lablen,&labstart); assert(!st);
       if (lablen<=0 || lablen>3) return adns_s_querydomainwrong;
-      memcpy(labbuf, pai->qu->query_dgram + labstart, lablen);  labbuf[lablen]= 0;
-      ipv[3-i]= strtoul(labbuf,&ep,10);  if (*ep) return adns_s_querydomainwrong;
+      memcpy(labbuf, pai->qu->query_dgram + labstart, lablen);
+      labbuf[lablen]= 0;
+      ipv[3-i]= strtoul(labbuf,&ep,10);
+      if (*ep) return adns_s_querydomainwrong;
       if (lablen>1 && pai->qu->query_dgram[labstart]=='0')
        return adns_s_querydomainwrong;
     }
     for (i=0; i<sizeof(expectdomain)/sizeof(*expectdomain); i++) {
       st= adns__findlabel_next(&fls,&lablen,&labstart); assert(!st);
       l= strlen(expectdomain[i]);
-      if (lablen != l || memcmp(pai->qu->query_dgram + labstart, expectdomain[i], l))
+      if (lablen != l ||
+         memcmp(pai->qu->query_dgram + labstart, expectdomain[i], l))
        return adns_s_querydomainwrong;
     }
     st= adns__findlabel_next(&fls,&lablen,0); assert(!st);
@@ -806,7 +827,8 @@ static void mf_intstrpair(adns_query qu, void *datap) {
  * _hinfo   (pa)
  */
 
-static adns_status pa_hinfo(const parseinfo *pai, int cbyte, int max, void *datap) {
+static adns_status pa_hinfo(const parseinfo *pai, int cbyte,
+                           int max, void *datap) {
   adns_rr_intstrpair *rrp= datap;
   adns_status st;
   int i;
@@ -825,8 +847,8 @@ static adns_status pa_hinfo(const parseinfo *pai, int cbyte, int max, void *data
  * _mailbox   (pap,cs)
  */
 
-static adns_status pap_mailbox822(const parseinfo *pai, int *cbyte_io, int max,
-                                 char **mb_r) {
+static adns_status pap_mailbox822(const parseinfo *pai,
+                                 int *cbyte_io, int max, char **mb_r) {
   int lablen, labstart, i, needquote, c, r, neednorm;
   const unsigned char *p;
   char *str;
@@ -898,7 +920,8 @@ static adns_status csp_mailbox(vbuf *vb, const char *mailbox) {
  * _rp   (pa,cs)
  */
 
-static adns_status pa_rp(const parseinfo *pai, int cbyte, int max, void *datap) {
+static adns_status pa_rp(const parseinfo *pai, int cbyte,
+                        int max, void *datap) {
   adns_rr_strpair *rrp= datap;
   adns_status st;
 
@@ -927,7 +950,8 @@ static adns_status cs_rp(vbuf *vb, const void *datap) {
  * _soa   (pa,mf,cs)
  */
 
-static adns_status pa_soa(const parseinfo *pai, int cbyte, int max, void *datap) {
+static adns_status pa_soa(const parseinfo *pai, int cbyte,
+                         int max, void *datap) {
   adns_rr_soa *rrp= datap;
   const byte *dgram= pai->dgram;
   adns_status st;
@@ -992,31 +1016,31 @@ static void mf_flat(adns_query qu, void *data) { }
 #define FLAT_MEMB(memb) TYPESZ_M(memb), mf_flat, cs_##memb
 
 #define DEEP_TYPE(code,rrt,fmt,memb,parser,comparer,printer) \
- { adns_r_##code, rrt, fmt, TYPESZ_M(memb), mf_##memb, printer, parser, comparer }
+ { adns_r_##code, rrt,fmt,TYPESZ_M(memb), mf_##memb, printer,parser,comparer }
 #define FLAT_TYPE(code,rrt,fmt,memb,parser,comparer,printer) \
- { adns_r_##code, rrt, fmt, TYPESZ_M(memb), mf_flat, printer, parser, comparer }
+ { adns_r_##code, rrt,fmt,TYPESZ_M(memb), mf_flat,   printer,parser,comparer }
 
 static const typeinfo typeinfos[] = {
 /* Must be in ascending order of rrtype ! */
-/* mem-mgmt code  rrt     fmt     member      parser      comparer    printer       */
-                                                                                      
-FLAT_TYPE(a,      "A",     0,     inaddr,     pa_inaddr,  di_inaddr,  cs_inaddr     ),
-DEEP_TYPE(ns_raw, "NS",   "raw",  str,        pa_host_raw,0,          cs_domain     ),
-DEEP_TYPE(cname,  "CNAME", 0,     str,        pa_dom_raw, 0,          cs_domain     ),
-DEEP_TYPE(soa_raw,"SOA",  "raw",  soa,        pa_soa,     0,          cs_soa        ),
-DEEP_TYPE(ptr_raw,"PTR",  "raw",  str,        pa_host_raw,0,          cs_domain     ),
-DEEP_TYPE(hinfo,  "HINFO", 0,     intstrpair, pa_hinfo,   0,          cs_hinfo      ),
-DEEP_TYPE(mx_raw, "MX",   "raw",  intstr,     pa_mx_raw,  di_mx_raw,  cs_inthost    ),
-DEEP_TYPE(txt,    "TXT",   0,     manyistr,   pa_txt,     0,          cs_txt        ),
-DEEP_TYPE(rp_raw, "RP",   "raw",  strpair,    pa_rp,      0,          cs_rp         ),
-                                                                                      
-FLAT_TYPE(addr,   "A",  "addr",   addr,       pa_addr,    di_addr,    cs_addr       ),
-DEEP_TYPE(ns,     "NS", "+addr",  hostaddr,   pa_hostaddr,di_hostaddr,cs_hostaddr   ),
-DEEP_TYPE(ptr,    "PTR","checked",str,        pa_ptr,     0,          cs_domain     ),
-DEEP_TYPE(mx,     "MX", "+addr",  inthostaddr,pa_mx,      di_mx,      cs_inthostaddr),
-                                                                             
-DEEP_TYPE(soa,    "SOA","822",    soa,        pa_soa,     0,          cs_soa        ),
-DEEP_TYPE(rp,     "RP", "822",    strpair,    pa_rp,      0,          cs_rp         ),
+/* mem-mgmt code  rrt     fmt   member   parser      comparer  printer */
+
+FLAT_TYPE(a,      "A",     0,   inaddr,  pa_inaddr,  di_inaddr,cs_inaddr     ),
+DEEP_TYPE(ns_raw, "NS",   "raw",str,     pa_host_raw,0,        cs_domain     ),
+DEEP_TYPE(cname,  "CNAME", 0,   str,     pa_dom_raw, 0,        cs_domain     ),
+DEEP_TYPE(soa_raw,"SOA",  "raw",soa,     pa_soa,     0,        cs_soa        ),
+DEEP_TYPE(ptr_raw,"PTR",  "raw",str,     pa_host_raw,0,        cs_domain     ),
+DEEP_TYPE(hinfo,  "HINFO", 0, intstrpair,pa_hinfo,   0,        cs_hinfo      ),
+DEEP_TYPE(mx_raw, "MX",   "raw",intstr,  pa_mx_raw,  di_mx_raw,cs_inthost    ),
+DEEP_TYPE(txt,    "TXT",   0,   manyistr,pa_txt,     0,        cs_txt        ),
+DEEP_TYPE(rp_raw, "RP",   "raw",strpair, pa_rp,      0,        cs_rp         ),
+
+FLAT_TYPE(addr,   "A",  "addr", addr,    pa_addr,    di_addr,  cs_addr       ),
+DEEP_TYPE(ns,     "NS", "+addr",hostaddr,pa_hostaddr,di_hostaddr,cs_hostaddr ),
+DEEP_TYPE(ptr,    "PTR","checked",str,   pa_ptr,     0,        cs_domain     ),
+DEEP_TYPE(mx,     "MX", "+addr",inthostaddr,pa_mx,   di_mx,    cs_inthostaddr),
+                                                                             
+DEEP_TYPE(soa,    "SOA","822",  soa,     pa_soa,     0,        cs_soa        ),
+DEEP_TYPE(rp,     "RP", "822",  strpair, pa_rp,      0,        cs_rp         ),
 };
 
 const typeinfo *adns__findtype(adns_rrtype type) {