From 2d37bf0ef2c634819293a191eff9799934b08346 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sat, 2 May 2009 18:20:15 -0400 Subject: Runtime URL and MIME type filtering --- src/cjr_print.sml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/cjr_print.sml') diff --git a/src/cjr_print.sml b/src/cjr_print.sml index 3a124ff4..cb92588d 100644 --- a/src/cjr_print.sml +++ b/src/cjr_print.sml @@ -3176,6 +3176,34 @@ fun p_file env (ds, ps) = acc, string "))"])) NONE cookies + + fun makeChecker (name, rules : Settings.rule list) = + box [string "int ", + string name, + string "(const char *s) {", + newline, + box [p_list_sep (box []) + (fn rule => + box [string "if (!str", + case #kind rule of + Settings.Exact => box [string "cmp(s, \"", + string (String.toString (#pattern rule)), + string "\"))"] + | Settings.Prefix => box [string "ncmp(s, \"", + string (String.toString (#pattern rule)), + string "\", ", + string (Int.toString (size (#pattern rule))), + string "))"], + string " return ", + string (case #action rule of + Settings.Allow => "1" + | Settings.Deny => "0"), + string ";", + newline]) rules, + string "return 0;", + newline], + string "}", + newline] in box [string "#include ", newline, @@ -3218,6 +3246,12 @@ fun p_file env (ds, ps) = string "}", newline, newline, + + makeChecker ("uw_check_url", Settings.getUrlRules ()), + newline, + + makeChecker ("uw_check_mime", Settings.getMimeRules ()), + newline, string "extern void uw_sign(const char *in, char *out);", newline, -- cgit v1.2.3