zone.lisp, frontend.lisp: New configuration-variable machinery.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 22 Dec 2014 20:32:58 +0000 (20:32 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 23 Dec 2014 11:57:32 +0000 (11:57 +0000)
Maintain a list `*zone-config*' of configuration variables, and have the
frontend rebind these around each input file.  Add
`*sshfp-pathname-defaults*' and `*dkim-pathname-defaults*' to the list.

frontend.lisp
zone.lisp

index 0764c3f..613fb21 100644 (file)
               (let ((*package* (make-package "ZONE.SCRATCH"
                                              :use '(#:common-lisp
                                                     #:net #:zone))))
-                (load f :verbose nil :print nil :if-does-not-exist :error)
-                (delete-package *package*)))
+                (progv *zone-config* (mapcar #'symbol-value *zone-config*)
+                  (load f :verbose nil :print nil :if-does-not-exist :error)
+                  (delete-package *package*))))
             (zone-save opt-zones :format opt-format)))
       (with-unix-error-reporting ()
        (unless (option-parse-try
index c800f1f..e43e017 100644 (file)
--- a/zone.lisp
+++ b/zone.lisp
 ;;;--------------------------------------------------------------------------
 ;;; Various random utilities.
 
+(export '*zone-config*)
+(defparameter *zone-config* nil
+  "A list of configuration variables.
+
+   This is for the benefit of the frontend, which will dynamically bind them
+   so that input files can override them independently.  Not intended for use
+   by users.")
+
 (defun to-integer (x)
   "Convert X to an integer in the most straightforward way."
   (floor (rational x)))
 (defvar *dkim-pathname-defaults*
   (make-pathname :directory '(:relative "keys")
                 :type "dkim"))
+(pushnew '*dkim-pathname-defaults* *zone-config*)
 
 (defzoneparse :dkim (name data rec)
   ":dkim (KEYFILE {:TAG VALUE}*)"
 
 (export '*sshfp-pathname-defaults*)
 (defvar *sshfp-pathname-defaults*
-  (make-pathname :directory '(:relative "keys")
-                :type "sshfp"))
+  (make-pathname :directory '(:relative "keys") :type "sshfp")
+  "Default pathname components for SSHFP records.")
+(pushnew '*sshfp-pathname-defaults* *zone-config*)
 
 (defzoneparse :sshfp (name data rec)
   ":sshfp { FILENAME | ((FPR :alg ALG :type HASH)*) }"