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 #:mdw.sys-base #: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 (defun directory-exists-p (name)
38 ;; Make a pathname for NAME which has the right form for a directory.
40 (let ((path (pathname name)))
41 (if (null (pathname-name path))
43 (make-pathname :directory
44 (append (or (pathname-directory path)
46 (list (pathname-name path)))
51 ;; Now check that it exists.
52 #+clisp (and (ext:probe-directory dirpath) (truename dirpath))
53 #-clisp (probe-file dirpath)))
55 (eval-when (:compile-toplevel :load-toplevel)
56 (defopthandler dir (var arg) ()
57 (let ((path (directory-exists-p arg)))
59 (not (pathname-name path)))
61 (option-parse-error "path `~A' doesn't name a directory." arg)))))
64 :version "1.0.0" :usage "ZONEDEF..."
65 :help "Generates BIND zone files from Lisp descriptions."
66 :options (options help-options
68 (#\f "feature" (:arg "KEYWORD")
69 (list *features* 'keyword)
70 "Insert KEYWORD in *features* list.")
71 (#\s "subnet" (:arg "NET")
72 (list zone:*preferred-subnets*)
73 "Designate NET as a preferred subnet.")
75 (#\d "directory" (:arg "DIRECTORY")
76 (dir *zone-output-path*)
77 "Write zone and serial files to DIRECTORY.")
78 (#\F "format" (:arg "FORMAT")
82 (generic-function-methods
85 (method-specializers method)
89 (eql-specializer-object
91 "Format to use for output.")
92 (#\z "zone" (:arg "NAME") (list opt-zones)
93 "Write information about zone NAME.")))
96 (set-command-line-arguments)
97 (with-unix-error-reporting ()
99 (unless (option-parse-try
102 (when (zerop (length rest))
103 (option-parse-error "no files to read"))
107 (let ((*package* (make-package "ZONE.SCRATCH"
108 :use '(#:common-lisp #:net #:zone))))
109 (load f :verbose nil :print nil :if-does-not-exist :error)
110 (delete-package *package*)))
111 (zone-save opt-zones :format opt-format))))
113 ;;;----- That's all, folks --------------------------------------------------