comparison src/settings.sml @ 769:efceae06df17

allow/deny working in Mono_opt
author Adam Chlipala <adamc@hcoop.net>
date Sat, 02 May 2009 13:37:52 -0400
parents 3b7e46790fa7
children c125df6fabfc
comparison
equal deleted inserted replaced
768:3b7e46790fa7 769:efceae06df17
189 end 189 end
190 in 190 in
191 rew (!rewrites) 191 rew (!rewrites)
192 end 192 end
193 193
194 val url = ref ([] : rule list)
195 val mime = ref ([] : rule list)
196
197 fun setUrlRules ls = url := ls
198 fun setMimeRules ls = mime := ls
199
200 fun check f rules s =
201 let
202 fun chk (ls : rule list) =
203 case ls of
204 [] => false
205 | rule :: ls =>
206 let
207 val matches =
208 case #kind rule of
209 Exact => #pattern rule = s
210 | Prefix => String.isPrefix (#pattern rule) s
211 in
212 if matches then
213 case #action rule of
214 Allow => true
215 | Deny => false
216 else
217 chk ls
218 end
219 in
220 f s andalso chk (!rules)
221 end
222
223 val checkUrl = check (fn _ => true) url
224 val checkMime = check
225 (CharVector.all (fn ch => Char.isAlphaNum ch orelse ch = #"/" orelse ch = #"-" orelse ch = #"."))
226 mime
227
194 end 228 end