zone: New macro preferred-subnet-case.
[zone] / frontend.lisp
CommitLineData
7e282fb5 1;;; -*-lisp-*-
2;;;
3;;; $Id$
4;;;
5;;; Zone generator frontend
6;;;
7;;; (c) 2005 Straylight/Edgeware
8;;;
9
10;;;----- Licensing notice ---------------------------------------------------
11;;;
12;;; This program is free software; you can redistribute it and/or modify
13;;; it under the terms of the GNU General Public License as published by
14;;; the Free Software Foundation; either version 2 of the License, or
15;;; (at your option) any later version.
7fff3797 16;;;
7e282fb5 17;;; This program is distributed in the hope that it will be useful,
18;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;;; GNU General Public License for more details.
7fff3797 21;;;
7e282fb5 22;;; You should have received a copy of the GNU General Public License
23;;; along with this program; if not, write to the Free Software Foundation,
24;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26(defpackage #:zone.frontend
9c44003b 27 (:use #:common-lisp #:optparse #:net #:zone)
7e282fb5 28 (:export #:main))
29(in-package #:zone.frontend)
30
7e282fb5 31(defvar opt-zones nil
32 "Which zones to be emitted.")
33
122041a0
MW
34(eval-when (:compile-toplevel :load-toplevel)
35 (defopthandler dir (var arg) ()
36 (let ((path (probe-file arg)))
37 (if (and path
38 (not (pathname-name path)))
39 (setf var path)
40 (option-parse-error "path `~A' doesn't name a directory." arg)))))
41
f41a8783
MW
42(define-program
43 :version "1.0.0" :usage "ZONEDEF..."
44 :help "Generates BIND zone files from Lisp descriptions."
884a01ff 45 :options (options help-options
122041a0
MW
46 "Parsing options"
47 (#\f "feature" (:arg "KEYWORD")
48 (list *features* 'keyword)
49 "Insert KEYWORD in *features* list.")
50 (#\s "subnet" (:arg "NET")
51 (list zone:*preferred-subnets*)
52 "Designate NET as a preferred subnet.")
f41a8783 53 "Output options"
122041a0
MW
54 (#\d "directory" (:arg "DIRECTORY")
55 (dir *zone-output-path*)
56 "Write zone and serial files to DIRECTORY.")
f41a8783
MW
57 (#\z "zone" (:arg "NAME") (list opt-zones)
58 "Write information about zone NAME.")))
7e282fb5 59
60(defun main ()
61 (with-unix-error-reporting ()
ee983904 62 (let ((files nil))
7e282fb5 63 (unless (option-parse-try
f41a8783
MW
64 (do-options ()
65 (nil (rest)
66 (when (zerop (length rest))
67 (option-parse-error "no files to read"))
68 (setf files rest))))
69 (die-usage))
7e282fb5 70 (dolist (f files)
ee983904 71 (let ((*package* (make-package "ZONE.SCRATCH"
9c44003b 72 :use '(#:common-lisp #:net #:zone))))
ee983904
MW
73 (load f :verbose nil :print nil :if-does-not-exist :error)
74 (delete-package *package*)))
7e282fb5 75 (zone-save opt-zones))))
76
77;;;----- That's all, folks --------------------------------------------------