From: Mark Wooding Date: Tue, 15 Apr 2014 13:39:15 +0000 (+0100) Subject: zone.lisp: Change `zone-parse-records' interface to be more useful. X-Git-Url: https://git.distorted.org.uk/~mdw/zone/commitdiff_plain/8fcf1ae3524d2c7d914997b32c24ca697ab5a303 zone.lisp: Change `zone-parse-records' interface to be more useful. Now it returns a list of the processed records rather than appending them to a zone object. --- diff --git a/zone.lisp b/zone.lisp index f03b9dd..73f3f0f 100644 --- a/zone.lisp +++ b/zone.lisp @@ -536,27 +536,20 @@ ,@body))) ',type))))) -(defun zone-parse-records (zone records) - "Parse the body of a zone form. - - ZONE is the zone object; RECORDS is the body of the form." - (let ((zname (zone-name zone))) - (with-collection (rec) - (flet ((parse-record (zr) - (let ((func (or (get (zr-type zr) 'zone-parse) - (error "No parser for record ~A." - (zr-type zr)))) - (name (and (zr-name zr) (stringify (zr-name zr))))) - (funcall func - name - zname - (zr-data zr) - (zr-ttl zr) - rec)))) - (zone-process-records records - (zone-default-ttl zone) - #'parse-record)) - (setf (zone-records zone) (nconc (zone-records zone) rec))))) +(export 'zone-parse-records) +(defun zone-parse-records (zname ttl records) + "Parse a sequence of RECORDS and return a list of raw records. + + The records are parsed relative to the zone name ZNAME, and using the + given default TTL." + (collecting (rec) + (flet ((parse-record (zr) + (let ((func (or (get (zr-type zr) 'zone-parse) + (error "No parser for record ~A." + (zr-type zr)))) + (name (and (zr-name zr) (stringify (zr-name zr))))) + (funcall func name zname (zr-data zr) (zr-ttl zr) rec)))) + (zone-process-records records ttl #'parse-record)))) (export 'zone-parse) (defun zone-parse (zf) @@ -571,12 +564,10 @@ ((NAME*) ZONE-RECORD*) | SYM ARGS" (multiple-value-bind (zname ttl soa) (zone-parse-head (car zf)) - (let ((zone (make-zone :name zname - :default-ttl ttl - :soa soa - :records nil))) - (zone-parse-records zone (cdr zf)) - zone))) + (make-zone :name zname + :default-ttl ttl + :soa soa + :records (zone-parse-records zname ttl (cdr zf))))) (export 'zone-create) (defun zone-create (zf)