chiark / gitweb /
- * bug_if_query_done feature for debugging (SHOULD BE TAKEN OUT FOR RELEASE)
[adns.git] / src / internal.h
index 02951a625ea92bdffe380b61d2616dde893562e2..c7667382babd3adfec53dfde1e92e641c387c5d8 100644 (file)
@@ -58,6 +58,7 @@ typedef unsigned char byte;
 
 #define DNS_PORT 53
 #define DNS_MAXUDP 512
+#define DNS_MAXLABEL 63
 #define DNS_MAXDOMAIN 255
 #define DNS_HDRSIZE 12
 #define DNS_IDOFFSET 0
@@ -288,10 +289,10 @@ struct adns__state {
     server_ok, server_broken
   } tcpstate;
   struct timeval tcptimeout;
-  /* This will have tv_sec==0 if it is not valid.
-   * It will always be valid if tcpstate _connecting.
-   * When _ok, it will be nonzero if we are idle
-   * (ie, tcpw queue is empty) and counting down.
+  /* This will have tv_sec==0 if it is not valid.  It will always be
+   * valid if tcpstate _connecting.  When _ok, it will be nonzero if
+   * we are idle (ie, tcpw queue is empty), in which case it is the
+   * absolute time when we will close the connection.
    */
   struct sigaction stdsigpipe;
   sigset_t stdsigmask;
@@ -677,22 +678,15 @@ void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc);
 
 /* Useful static inline functions: */
 
-static inline void timevaladd(struct timeval *tv_io, long ms) {
-  struct timeval tmp;
-  assert(ms>=0);
-  tmp= *tv_io;
-  tmp.tv_usec += (ms%1000)*1000000;
-  tmp.tv_sec += ms/1000;
-  if (tmp.tv_usec >= 1000000) { tmp.tv_sec++; tmp.tv_usec -= 1000; }
-  *tv_io= tmp;
-}
-
 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_domainunquoted(int c) {
+  return ctype_alpha(c) || ctype_digit(c) || (strchr("-_/+",c) != 0);
+}
 
 static inline int errno_resources(int e) { return e==ENOMEM || e==ENOBUFS; }