3 ;;; Zone generator frontend
5 ;;; (c) 2005 Straylight/Edgeware
8 ;;;----- Licensing notice ---------------------------------------------------
10 ;;; This program is free software; you can redistribute it and/or modify
11 ;;; it under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 2 of the License, or
13 ;;; (at your option) any later version.
15 ;;; This program is distributed in the hope that it will be useful,
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with this program; if not, write to the Free Software Foundation,
22 ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 (defpackage #:zone.frontend
25 (:use #:common-lisp #:optparse #:net #:zone
29 (in-package #:zone.frontend)
32 "Which zones to be emitted.")
33 (defvar opt-format :bind
34 "Which format to use on output.")
36 (eval-when (:compile-toplevel :load-toplevel)
37 (defopthandler dir (var arg) ()
38 (let ((path (probe-file arg)))
40 (not (pathname-name path)))
42 (option-parse-error "path `~A' doesn't name a directory." arg)))))
45 :version "1.0.0" :usage "ZONEDEF..."
46 :help "Generates BIND zone files from Lisp descriptions."
47 :options (options help-options
49 (#\f "feature" (:arg "KEYWORD")
50 (list *features* 'keyword)
51 "Insert KEYWORD in *features* list.")
52 (#\s "subnet" (:arg "NET")
53 (list zone:*preferred-subnets*)
54 "Designate NET as a preferred subnet.")
56 (#\d "directory" (:arg "DIRECTORY")
57 (dir *zone-output-path*)
58 "Write zone and serial files to DIRECTORY.")
59 (#\F "format" (:arg "FORMAT")
63 (generic-function-methods
66 (method-specializers method)
70 (eql-specializer-object
72 "Format to use for output.")
73 (#\z "zone" (:arg "NAME") (list opt-zones)
74 "Write information about zone NAME.")))
77 (with-unix-error-reporting ()
79 (unless (option-parse-try
82 (when (zerop (length rest))
83 (option-parse-error "no files to read"))
87 (let ((*package* (make-package "ZONE.SCRATCH"
88 :use '(#:common-lisp #:net #:zone))))
89 (load f :verbose nil :print nil :if-does-not-exist :error)
90 (delete-package *package*)))
91 (zone-save opt-zones :format opt-format))))
93 ;;;----- That's all, folks --------------------------------------------------