comparison src/cjr_print.sml @ 1094:db52c32dbe42

All three current protocols work with move to using uw_app
author Adam Chlipala <adamc@hcoop.net>
date Sun, 27 Dec 2009 10:37:24 -0500
parents 0657e5adc938
children 72670131dace
comparison
equal deleted inserted replaced
1093:8d3aa6c7cee0 1094:db52c32dbe42
2602 scripts (Settings.getScripts ()) 2602 scripts (Settings.getScripts ())
2603 in 2603 in
2604 string scripts 2604 string scripts
2605 end, 2605 end,
2606 string "\");", 2606 string "\");",
2607 newline,
2608 string "uw_set_url_prefix(ctx, \"",
2609 string (Settings.getUrlPrefix ()),
2610 string "\");",
2611 newline]), 2607 newline]),
2612 string "uw_set_needs_push(ctx, ", 2608 string "uw_set_needs_push(ctx, ",
2613 string (case side of 2609 string (case side of
2614 ServerAndPullAndPush => "1" 2610 ServerAndPullAndPush => "1"
2615 | _ => "0"), 2611 | _ => "0"),
2704 acc, 2700 acc,
2705 string "))"])) 2701 string "))"]))
2706 NONE cookies 2702 NONE cookies
2707 2703
2708 fun makeChecker (name, rules : Settings.rule list) = 2704 fun makeChecker (name, rules : Settings.rule list) =
2709 box [string "int ", 2705 box [string "static int ",
2710 string name, 2706 string name,
2711 string "(const char *s) {", 2707 string "(const char *s) {",
2712 newline, 2708 newline,
2713 box [p_list_sep (box []) 2709 box [p_list_sep (box [])
2714 (fn rule => 2710 (fn rule =>
2770 newline, 2766 newline,
2771 string "void uw_db_init(uw_context ctx) { };", 2767 string "void uw_db_init(uw_context ctx) { };",
2772 newline, 2768 newline,
2773 string "int uw_db_begin(uw_context ctx) { return 0; };", 2769 string "int uw_db_begin(uw_context ctx) { return 0; };",
2774 newline, 2770 newline,
2771 string "void uw_db_close(uw_context ctx) { };",
2772 newline,
2775 string "int uw_db_commit(uw_context ctx) { return 0; };", 2773 string "int uw_db_commit(uw_context ctx) { return 0; };",
2776 newline, 2774 newline,
2777 string "int uw_db_rollback(uw_context ctx) { return 0; };"], 2775 string "int uw_db_rollback(uw_context ctx) { return 0; };"],
2778 newline, 2776 newline,
2779 newline, 2777 newline,
2780 2778
2781 string "const char *uw_url_prefix = \"",
2782 string (Settings.getUrlPrefix ()),
2783 string "\";",
2784 newline,
2785 newline,
2786
2787 string "static const char begin_xhtml[] = \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\" ?>\\n<!DOCTYPE html PUBLIC \\\"-//W3C//DTD XHTML 1.0 Transitional//EN\\\" \\\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\\\">\\n<html xmlns=\\\"http://www.w3.org/1999/xhtml\\\" xml:lang=\\\"en\\\" lang=\\\"en\\\">\";", 2779 string "static const char begin_xhtml[] = \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\" ?>\\n<!DOCTYPE html PUBLIC \\\"-//W3C//DTD XHTML 1.0 Transitional//EN\\\" \\\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\\\">\\n<html xmlns=\\\"http://www.w3.org/1999/xhtml\\\" xml:lang=\\\"en\\\" lang=\\\"en\\\">\";",
2788 newline, 2780 newline,
2789 newline, 2781 newline,
2790 2782
2791 p_list_sep newline (fn x => x) pds, 2783 p_list_sep newline (fn x => x) pds,
2792 newline, 2784 newline,
2793 string "int uw_inputs_len = ", 2785 newline,
2794 string (Int.toString (SM.foldl Int.max 0 fnums + 1)), 2786 string "static int uw_input_num(const char *name) {",
2795 string ";",
2796 newline,
2797 string "int uw_timeout = ",
2798 string (Int.toString (Settings.getTimeout ())),
2799 string ";",
2800 newline,
2801 newline,
2802 string "int uw_input_num(char *name) {",
2803 newline, 2787 newline,
2804 makeSwitch (fnums, 0), 2788 makeSwitch (fnums, 0),
2805 string "}", 2789 string "}",
2806 newline, 2790 newline,
2807 newline, 2791 newline,
2814 2798
2815 string "extern void uw_sign(const char *in, char *out);", 2799 string "extern void uw_sign(const char *in, char *out);",
2816 newline, 2800 newline,
2817 string "extern int uw_hash_blocksize;", 2801 string "extern int uw_hash_blocksize;",
2818 newline, 2802 newline,
2819 string "uw_Basis_string uw_cookie_sig(uw_context ctx) {", 2803 string "static uw_Basis_string uw_cookie_sig(uw_context ctx) {",
2820 newline, 2804 newline,
2821 box [string "uw_Basis_string r = uw_malloc(ctx, uw_hash_blocksize);", 2805 box [string "uw_Basis_string r = uw_malloc(ctx, uw_hash_blocksize);",
2822 newline, 2806 newline,
2823 string "uw_sign(", 2807 string "uw_sign(",
2824 case cookieCode of 2808 case cookieCode of
2830 newline], 2814 newline],
2831 string "}", 2815 string "}",
2832 newline, 2816 newline,
2833 newline, 2817 newline,
2834 2818
2835 string "void uw_handle(uw_context ctx, char *request) {", 2819 string "static void uw_handle(uw_context ctx, char *request) {",
2836 newline, 2820 newline,
2837 string "if (!strcmp(request, \"", 2821 string "if (!strcmp(request, \"",
2838 string (OS.Path.joinDirFile {dir = Settings.getUrlPrefix (), 2822 string (OS.Path.joinDirFile {dir = Settings.getUrlPrefix (),
2839 file = "app.js"}), 2823 file = "app.js"}),
2840 string "\")) {", 2824 string "\")) {",
2854 string "}", 2838 string "}",
2855 newline, 2839 newline,
2856 newline, 2840 newline,
2857 2841
2858 if hasDb then 2842 if hasDb then
2859 box [string "void uw_expunger(uw_context ctx, uw_Basis_client cli) {", 2843 box [string "static void uw_expunger(uw_context ctx, uw_Basis_client cli) {",
2860 newline, 2844 newline,
2861 box [p_enamed env (!expunge), 2845 box [p_enamed env (!expunge),
2862 string "(ctx, cli);", 2846 string "(ctx, cli);",
2863 newline], 2847 newline],
2864 string "}", 2848 string "}",
2865 newline, 2849 newline,
2866 newline, 2850 newline,
2867 2851
2868 string "void uw_initializer(uw_context ctx) {", 2852 string "static void uw_initializer(uw_context ctx) {",
2869 newline, 2853 newline,
2870 box [p_list_sep (box []) (fn e => box [p_exp env e, 2854 box [p_list_sep (box []) (fn e => box [p_exp env e,
2871 string ";", 2855 string ";",
2872 newline]) initializers, 2856 newline]) initializers,
2873 p_enamed env (!initialize), 2857 p_enamed env (!initialize),
2874 string "(ctx, uw_unit_v);", 2858 string "(ctx, uw_unit_v);",
2875 newline], 2859 newline],
2876 string "}", 2860 string "}",
2877 newline] 2861 newline]
2878 else 2862 else
2879 box [string "void uw_expunger(uw_context ctx, uw_Basis_client cli) { };", 2863 box [string "static void uw_expunger(uw_context ctx, uw_Basis_client cli) { };",
2880 newline, 2864 newline,
2881 string "void uw_initializer(uw_context ctx) { };", 2865 string "static void uw_initializer(uw_context ctx) { };",
2882 newline]] 2866 newline],
2867
2868 string "uw_app uw_application = {",
2869 p_list_sep (box [string ",", newline]) string
2870 [Int.toString (SM.foldl Int.max 0 fnums + 1),
2871 Int.toString (Settings.getTimeout ()),
2872 "\"" ^ Settings.getUrlPrefix () ^ "\"",
2873 "uw_client_init", "uw_initializer", "uw_expunger",
2874 "uw_db_init", "uw_db_begin", "uw_db_commit", "uw_db_rollback", "uw_db_close",
2875 "uw_handle",
2876 "uw_input_num", "uw_cookie_sig", "uw_check_url", "uw_check_mime"],
2877 string "};",
2878 newline]
2883 end 2879 end
2884 2880
2885 fun p_sql env (ds, _) = 2881 fun p_sql env (ds, _) =
2886 let 2882 let
2887 val (pps, _) = ListUtil.foldlMap 2883 val (pps, _) = ListUtil.foldlMap