next up previous contents
Next: About this document ... Up: Hosts files Previous: IP addresses   Contents

Restricting check names

We want to make sure that the contents of the check tags are all valid, so we first need to make a list of valid checks:

(defparameter *valid-checks* '("ping" "pop3" "imap" "smtp" "http")
  "List of valid check names")

Now that we've decided what all the valid check names should be, we can change our validation code to reflect this:

 (tag "hostlist" ()
      (tag+ "host" ((attr "name" :matches-regexp "[a-zA-Z]+"))
            (tag "ip" ()
                 (pcdata :test-fn #'ip-address-p))
            (tag? "description" ()
            (tag "checks" ()
                 (tag+ "check" ()
                       (pcdata :possible-values *valid-checks*)))))
 (parse-xml-file "hosts.xml"))

Now if we try to enter something in a check tag other than ``ping'', ``pop3'', ``imap'', ``smtp'', or ``http'', validation will fail.

root 2004-10-26