Mercurial > urweb
diff src/cjr_print.sml @ 770:c125df6fabfc
Runtime URL and MIME type filtering
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 02 May 2009 18:20:15 -0400 |
parents | df09c95085f8 |
children | 7394368a5cad |
line wrap: on
line diff
--- a/src/cjr_print.sml Sat May 02 13:37:52 2009 -0400 +++ b/src/cjr_print.sml Sat May 02 18:20:15 2009 -0400 @@ -3176,6 +3176,34 @@ 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 <stdio.h>", newline, @@ -3218,6 +3246,12 @@ 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,