chiark / gitweb /
Copyrights now acknowledge fanf for adns. Individual file copyrights too.
[adns.git] / src / parse.c
index 842556a79ae55ff93a540597ecd4b7a70d4c3dc2..9a4e0c7483498daad8ed12180398cd31fe68dccd 100644 (file)
@@ -3,7 +3,12 @@
  * - parsing assistance functions (mainly for domains inside datagrams)
  */
 /*
- *  This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson
+ *  This file is
+ *    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
+ *    Copyright (C) 1999 Tony Finch <dot@dotat.at>
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -117,18 +122,28 @@ adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
                               const byte *dgram, int dglen, int *cbyte_io, int max) {
   findlabel_state fls;
   
-  int lablen, labstart, i, ch;
-  adns_status st;
-
   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,
+                                   const byte *dgram) {
+  int lablen, labstart, i, ch, first;
+  adns_status st;
+
+  first= 1;
   for (;;) {
-    st= adns__findlabel_next(&fls,&lablen,&labstart);
+    st= adns__findlabel_next(fls,&lablen,&labstart);
     if (st) return st;
     if (lablen<0) { vb->used=0; return adns_s_ok; }
     if (!lablen) break;
-    if (vb->used)
+    if (first) {
+      first= 0;
+    } else {
       if (!adns__vbuf_append(vb,".",1)) return adns_s_nomemory;
+    }
     if (flags & pdf_quoteok) {
       if (!vbuf__append_quoted1035(vb,dgram+labstart,lablen))
        return adns_s_nomemory;