Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 129 lines (86 sloc) 3.542 kb
1945889 new
dancy authored
1 ;; copyright (C) 2003 Franz Inc, Oakland, CA - All rights reserved.
2 ;;
3 ;; The software, data and information contained herein are proprietary
4 ;; to, and comprise valuable trade secrets of, Franz, Inc. They are
5 ;; given in confidence by Franz, Inc. pursuant to a written license
6 ;; agreement, and may be stored and used only in accordance with the terms
7 ;; of such license.
8 ;;
9 ;; Restricted Rights Legend
10 ;; ------------------------
11 ;; Use, duplication, and disclosure of the software, data and information
12 ;; contained herein by any agency, department or entity of the U.S.
13 ;; Government are subject to restrictions of Restricted Rights for
14 ;; Commercial Software developed at private expense as specified in
15 ;; DOD FAR Supplement 52.227-7013 (c) (1) (ii), as applicable.
16 ;;
ce161d9 see ChangeLog
dancy authored
17 ;; $Id: spf.cl,v 1.3 2007/05/18 16:21:56 dancy Exp $
1945889 new
dancy authored
18
19 (in-package :user)
20
ce161d9 see ChangeLog
dancy authored
21 ;; RFC4408
433308c intermediate changes
dancy authored
22
ce161d9 see ChangeLog
dancy authored
23 (define-bnf nil nil
24 (record (version terms (:* sp))
25 #'(lambda (res)
26 (second res)))
433308c intermediate changes
dancy authored
27
ce161d9 see ChangeLog
dancy authored
28 (version "v=spf1")
1945889 new
dancy authored
29
ce161d9 see ChangeLog
dancy authored
30 (terms (:* ((:one-or-more sp) (:or directive modifier))))
1945889 new
dancy authored
31
ce161d9 see ChangeLog
dancy authored
32 (directive ((:optional qualifier) mechanism))
1945889 new
dancy authored
33
ce161d9 see ChangeLog
dancy authored
34 (qualifier (:or "+" "-" "?" "~"))
433308c intermediate changes
dancy authored
35
ce161d9 see ChangeLog
dancy authored
36 (mechanism (:or all include a mx ptr ip4 ip6 exists))
433308c intermediate changes
dancy authored
37
ce161d9 see ChangeLog
dancy authored
38 (all "all")
433308c intermediate changes
dancy authored
39
ce161d9 see ChangeLog
dancy authored
40 (include ("include" ":" domain-spec))
433308c intermediate changes
dancy authored
41
ce161d9 see ChangeLog
dancy authored
42 (a ("a" (:optional (":" domain-spec)) (:optional dual-cidr-length)))
433308c intermediate changes
dancy authored
43
ce161d9 see ChangeLog
dancy authored
44 (mx ("mx" (:optional (":" domain-spec)) (:optional dual-cidr-length)))
433308c intermediate changes
dancy authored
45
ce161d9 see ChangeLog
dancy authored
46 (ptr ("ptr" (:optional (":" domain-spec))))
433308c intermediate changes
dancy authored
47
ce161d9 see ChangeLog
dancy authored
48 (ip4 ("ip4" ":" ip4-network (:optional ip4-cidr-length)))
433308c intermediate changes
dancy authored
49
ce161d9 see ChangeLog
dancy authored
50 (ip6 ("ip6" ":" ip6-network (:optional ip6-cidr-length)))
433308c intermediate changes
dancy authored
51
ce161d9 see ChangeLog
dancy authored
52 (exists ("exists" ":" domain-spec))
433308c intermediate changes
dancy authored
53
ce161d9 see ChangeLog
dancy authored
54 (modifier (:or redirect explanation unknown-modifier))
433308c intermediate changes
dancy authored
55
ce161d9 see ChangeLog
dancy authored
56 (redirect ("redirect" "=" domain-spec))
433308c intermediate changes
dancy authored
57
ce161d9 see ChangeLog
dancy authored
58 (explanation ("exp" "=" domain-spec))
433308c intermediate changes
dancy authored
59
ce161d9 see ChangeLog
dancy authored
60 (unknown-modifier (name "=" macro-string))
433308c intermediate changes
dancy authored
61
ce161d9 see ChangeLog
dancy authored
62 (ip4-cidr-length ("/" (:one-or-more digit)))
63
64 (ip6-cidr-length ("/" (:one-or-more digit)))
65
66 (dual-cidr-length ((:optional ip4-cidr-length) (:optional ("/" ip6-cidr-length))))
433308c intermediate changes
dancy authored
67
68
ce161d9 see ChangeLog
dancy authored
69 (ip4-network (qnum "." qnum "." qnum "." qnum))
433308c intermediate changes
dancy authored
70
ce161d9 see ChangeLog
dancy authored
71 ;; simplified
72 (qnum (:one-or-more digit))
73
74 (ip6-network (:one-or-more (:or hexdig ":"))) ;; not exact
433308c intermediate changes
dancy authored
75
ce161d9 see ChangeLog
dancy authored
76 #+ignore
77 (domain-spec (macro-string domain-end))
433308c intermediate changes
dancy authored
78
ce161d9 see ChangeLog
dancy authored
79 #+ignore
80 (domain-end (:or ("." toplabel (:optional "."))
81 macro-expand))
82
83 (domain-spec macro-string)
84
85 (toplabel (:or ((:* alphanum) alpha (:* alphanum))
86 ((:one-or-more alphanum) "-" (:* (:or alphanum "-")) alphanum)))
87
88 (alphanum (:or alpha digit))
89
90 (explain-string (:* (:or macro-string sp)))
91
92 (macro-string (:* (:or macro-expand macro-literal)))
93
94 (macro-expand (:or ("%{" macro-letter transformers (:* delimiter) "}")
95 "%%" "%_" "%-"))
96
97 (macro-literal (:or (:char-range #x21 #x24) (:char-range #x26 #x7e)))
98
99 (macro-letter (:or "s" "l" "o" "d" "i" "p" "h" "c" "r" "t" "v"))
100
101 (transformers ((:* digit) (:optional "r"))
102 (lambda (res)
103 (list
104 (or (ignore-errors
105 (parse-integer
106 (list-to-delimited-string (first res) "")))
107 0)
108 (if (second res) :reverse))))
109
110 (delimiter (:or "." "-" "+" "," "/" "_" "="))
111
112 (name (alpha (:* (:or alpha digit "-" "_" ".")))
113 #'(lambda (res)
114 (concatenate 'string
115 (first res)
116 (list-to-delimited-string (second res) "")))))
117
118 (defun test-parse (string)
119 (let ((max (length string)))
120 (multiple-value-bind (ok res pos)
121 (bnf-parse-record string)
122 (if (not ok)
123 (error "Parse failed.~%"))
124 (if (/= pos max)
125 (error "Stopped parsing at: ~a~%" (subseq string pos)))
126 (pprint res)
127 t)))
128
Something went wrong with that request. Please try again.