diff 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
line wrap: on
line diff
--- a/src/cjr_print.sml	Sat Dec 26 11:56:40 2009 -0500
+++ b/src/cjr_print.sml	Sun Dec 27 10:37:24 2009 -0500
@@ -2604,10 +2604,6 @@
                                         string scripts
                                     end,
                                     string "\");",
-                                    newline,
-                                    string "uw_set_url_prefix(ctx, \"",
-                                    string (Settings.getUrlPrefix ()),
-                                    string "\");",
                                     newline]),
                      string "uw_set_needs_push(ctx, ",
                      string (case side of
@@ -2706,7 +2702,7 @@
                          NONE cookies
 
         fun makeChecker (name, rules : Settings.rule list) =
-            box [string "int ",
+            box [string "static int ",
                  string name,
                  string "(const char *s) {",
                  newline,
@@ -2772,34 +2768,22 @@
                       newline,
                       string "int uw_db_begin(uw_context ctx) { return 0; };",
                       newline,
+                      string "void uw_db_close(uw_context ctx) { };",
+                      newline,
                       string "int uw_db_commit(uw_context ctx) { return 0; };",
                       newline,
                       string "int uw_db_rollback(uw_context ctx) { return 0; };"],
              newline,
              newline,
 
-             string "const char *uw_url_prefix = \"",
-             string (Settings.getUrlPrefix ()),
-             string "\";",
-             newline,
-             newline,
-
              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\\\">\";",
              newline,
              newline,
 
              p_list_sep newline (fn x => x) pds,
              newline,
-             string "int uw_inputs_len = ",
-             string (Int.toString (SM.foldl Int.max 0 fnums + 1)),
-             string ";",
              newline,
-             string "int uw_timeout = ",
-             string (Int.toString (Settings.getTimeout ())),
-             string ";",
-             newline,
-             newline,
-             string "int uw_input_num(char *name) {",
+             string "static int uw_input_num(const char *name) {",
              newline,
              makeSwitch (fnums, 0),
              string "}",
@@ -2816,7 +2800,7 @@
              newline,
              string "extern int uw_hash_blocksize;",
              newline,
-             string "uw_Basis_string uw_cookie_sig(uw_context ctx) {",
+             string "static uw_Basis_string uw_cookie_sig(uw_context ctx) {",
              newline,
              box [string "uw_Basis_string r = uw_malloc(ctx, uw_hash_blocksize);",
                   newline,
@@ -2832,7 +2816,7 @@
              newline,
              newline,
 
-             string "void uw_handle(uw_context ctx, char *request) {",
+             string "static void uw_handle(uw_context ctx, char *request) {",
              newline,
              string "if (!strcmp(request, \"",
              string (OS.Path.joinDirFile {dir = Settings.getUrlPrefix (),
@@ -2856,7 +2840,7 @@
              newline,
 
              if hasDb then
-                 box [string "void uw_expunger(uw_context ctx, uw_Basis_client cli) {",
+                 box [string "static void uw_expunger(uw_context ctx, uw_Basis_client cli) {",
                       newline,
                       box [p_enamed env (!expunge),
                            string "(ctx, cli);",
@@ -2865,7 +2849,7 @@
                       newline,
                       newline,
 
-                      string "void uw_initializer(uw_context ctx) {",
+                      string "static void uw_initializer(uw_context ctx) {",
                       newline,
                       box [p_list_sep (box []) (fn e => box [p_exp env e,
                                                              string ";",
@@ -2876,10 +2860,22 @@
                       string "}",
                       newline]
              else
-                 box [string "void uw_expunger(uw_context ctx, uw_Basis_client cli) { };",
+                 box [string "static void uw_expunger(uw_context ctx, uw_Basis_client cli) { };",
                       newline,
-                      string "void uw_initializer(uw_context ctx) { };",
-                      newline]]
+                      string "static void uw_initializer(uw_context ctx) { };",
+                      newline],
+
+             string "uw_app uw_application = {",
+             p_list_sep (box [string ",", newline]) string
+                        [Int.toString (SM.foldl Int.max 0 fnums + 1),
+                         Int.toString (Settings.getTimeout ()),
+                         "\"" ^ Settings.getUrlPrefix () ^ "\"",
+                         "uw_client_init", "uw_initializer", "uw_expunger",
+                         "uw_db_init", "uw_db_begin", "uw_db_commit", "uw_db_rollback", "uw_db_close",
+                         "uw_handle",
+                         "uw_input_num", "uw_cookie_sig", "uw_check_url", "uw_check_mime"],
+             string "};",
+             newline]
     end
 
 fun p_sql env (ds, _) =