changeset 311:9ad92047a499

Rename 'lw' prefixes to 'uw'
author Adam Chlipala <adamc@hcoop.net>
date Sun, 07 Sep 2008 15:40:42 -0400
parents 0aee86b8a6d6
children f387d12193ba
files include/types.h include/urweb.h src/c/driver.c src/c/urweb.c src/cjr_print.sml src/monoize.sml
diffstat 6 files changed, 434 insertions(+), 434 deletions(-) [+]
line wrap: on
line diff
--- a/include/types.h	Sun Sep 07 15:35:08 2008 -0400
+++ b/include/types.h	Sun Sep 07 15:40:42 2008 -0400
@@ -1,19 +1,19 @@
-typedef long long lw_Basis_int;
-typedef double lw_Basis_float;
-typedef char* lw_Basis_string;
+typedef long long uw_Basis_int;
+typedef double uw_Basis_float;
+typedef char* uw_Basis_string;
 
-struct __lws_0 {
+struct __uws_0 {
 };
 
-typedef struct __lws_0 lw_unit;
-typedef lw_unit lw_Basis_unit;
+typedef struct __uws_0 uw_unit;
+typedef uw_unit uw_Basis_unit;
 
-typedef enum lw_Basis_bool { lw_Basis_False, lw_Basis_True } lw_Basis_bool;
+typedef enum uw_Basis_bool { uw_Basis_False, uw_Basis_True } uw_Basis_bool;
 
-typedef struct lw_context *lw_context;
+typedef struct uw_context *uw_context;
 
-typedef lw_Basis_string lw_Basis_xhtml;
-typedef lw_Basis_string lw_Basis_page;
+typedef uw_Basis_string uw_Basis_xhtml;
+typedef uw_Basis_string uw_Basis_page;
 
 
 typedef enum { SUCCESS, FATAL, BOUNDED_RETRY, UNLIMITED_RETRY } failure_kind;
--- a/include/urweb.h	Sun Sep 07 15:35:08 2008 -0400
+++ b/include/urweb.h	Sun Sep 07 15:40:42 2008 -0400
@@ -2,85 +2,85 @@
 
 #include "types.h"
 
-int lw_really_send(int sock, void *buf, ssize_t len);
+int uw_really_send(int sock, void *buf, ssize_t len);
 
-extern lw_unit lw_unit_v;
+extern uw_unit uw_unit_v;
 
-lw_context lw_init(size_t page_len, size_t heap_len);
-void lw_set_db(lw_context, void*);
-void *lw_get_db(lw_context);
-void lw_free(lw_context);
-void lw_reset(lw_context);
-void lw_reset_keep_request(lw_context);
-void lw_reset_keep_error_message(lw_context);
+uw_context uw_init(size_t page_len, size_t heap_len);
+void uw_set_db(uw_context, void*);
+void *uw_get_db(uw_context);
+void uw_free(uw_context);
+void uw_reset(uw_context);
+void uw_reset_keep_request(uw_context);
+void uw_reset_keep_error_message(uw_context);
 
-failure_kind lw_begin_init(lw_context);
-failure_kind lw_begin(lw_context, char *path);
+failure_kind uw_begin_init(uw_context);
+failure_kind uw_begin(uw_context, char *path);
 
-__attribute__((noreturn)) void lw_error(lw_context, failure_kind, const char *fmt, ...);
-char *lw_error_message(lw_context);
+__attribute__((noreturn)) void uw_error(uw_context, failure_kind, const char *fmt, ...);
+char *uw_error_message(uw_context);
 
-void *lw_malloc(lw_context, size_t);
-int lw_send(lw_context, int sock);
+void *uw_malloc(uw_context, size_t);
+int uw_send(uw_context, int sock);
 
-void lw_set_input(lw_context, char *name, char *value);
-char *lw_get_input(lw_context, int name);
-char *lw_get_optional_input(lw_context, int name);
+void uw_set_input(uw_context, char *name, char *value);
+char *uw_get_input(uw_context, int name);
+char *uw_get_optional_input(uw_context, int name);
 
-void lw_write(lw_context, const char*);
+void uw_write(uw_context, const char*);
 
-char *lw_Basis_htmlifyInt(lw_context, lw_Basis_int);
-char *lw_Basis_htmlifyFloat(lw_context, lw_Basis_float);
-char *lw_Basis_htmlifyString(lw_context, lw_Basis_string);
-char *lw_Basis_htmlifyBool(lw_context, lw_Basis_bool);
+char *uw_Basis_htmlifyInt(uw_context, uw_Basis_int);
+char *uw_Basis_htmlifyFloat(uw_context, uw_Basis_float);
+char *uw_Basis_htmlifyString(uw_context, uw_Basis_string);
+char *uw_Basis_htmlifyBool(uw_context, uw_Basis_bool);
 
-void lw_Basis_htmlifyInt_w(lw_context, lw_Basis_int);
-void lw_Basis_htmlifyFloat_w(lw_context, lw_Basis_float);
-void lw_Basis_htmlifyString_w(lw_context, lw_Basis_string);
-void lw_Basis_htmlifyBool_w(lw_context, lw_Basis_bool);
+void uw_Basis_htmlifyInt_w(uw_context, uw_Basis_int);
+void uw_Basis_htmlifyFloat_w(uw_context, uw_Basis_float);
+void uw_Basis_htmlifyString_w(uw_context, uw_Basis_string);
+void uw_Basis_htmlifyBool_w(uw_context, uw_Basis_bool);
 
-char *lw_Basis_attrifyInt(lw_context, lw_Basis_int);
-char *lw_Basis_attrifyFloat(lw_context, lw_Basis_float);
-char *lw_Basis_attrifyString(lw_context, lw_Basis_string);
+char *uw_Basis_attrifyInt(uw_context, uw_Basis_int);
+char *uw_Basis_attrifyFloat(uw_context, uw_Basis_float);
+char *uw_Basis_attrifyString(uw_context, uw_Basis_string);
 
-void lw_Basis_attrifyInt_w(lw_context, lw_Basis_int);
-void lw_Basis_attrifyFloat_w(lw_context, lw_Basis_float);
-void lw_Basis_attrifyString_w(lw_context, lw_Basis_string);
+void uw_Basis_attrifyInt_w(uw_context, uw_Basis_int);
+void uw_Basis_attrifyFloat_w(uw_context, uw_Basis_float);
+void uw_Basis_attrifyString_w(uw_context, uw_Basis_string);
 
 
-char *lw_Basis_urlifyInt(lw_context, lw_Basis_int);
-char *lw_Basis_urlifyFloat(lw_context, lw_Basis_float);
-char *lw_Basis_urlifyString(lw_context, lw_Basis_string);
-char *lw_Basis_urlifyBool(lw_context, lw_Basis_bool);
+char *uw_Basis_urlifyInt(uw_context, uw_Basis_int);
+char *uw_Basis_urlifyFloat(uw_context, uw_Basis_float);
+char *uw_Basis_urlifyString(uw_context, uw_Basis_string);
+char *uw_Basis_urlifyBool(uw_context, uw_Basis_bool);
 
-void lw_Basis_urlifyInt_w(lw_context, lw_Basis_int);
-void lw_Basis_urlifyFloat_w(lw_context, lw_Basis_float);
-void lw_Basis_urlifyString_w(lw_context, lw_Basis_string);
-void lw_Basis_urlifyBool_w(lw_context, lw_Basis_bool);
+void uw_Basis_urlifyInt_w(uw_context, uw_Basis_int);
+void uw_Basis_urlifyFloat_w(uw_context, uw_Basis_float);
+void uw_Basis_urlifyString_w(uw_context, uw_Basis_string);
+void uw_Basis_urlifyBool_w(uw_context, uw_Basis_bool);
 
-lw_Basis_int lw_Basis_unurlifyInt(lw_context, char **);
-lw_Basis_float lw_Basis_unurlifyFloat(lw_context, char **);
-lw_Basis_string lw_Basis_unurlifyString(lw_context, char **);
-lw_Basis_bool lw_Basis_unurlifyBool(lw_context, char **);
+uw_Basis_int uw_Basis_unurlifyInt(uw_context, char **);
+uw_Basis_float uw_Basis_unurlifyFloat(uw_context, char **);
+uw_Basis_string uw_Basis_unurlifyString(uw_context, char **);
+uw_Basis_bool uw_Basis_unurlifyBool(uw_context, char **);
 
-lw_Basis_string lw_Basis_strcat(lw_context, lw_Basis_string, lw_Basis_string);
-lw_Basis_string lw_Basis_strdup(lw_context, lw_Basis_string);
+uw_Basis_string uw_Basis_strcat(uw_context, uw_Basis_string, uw_Basis_string);
+uw_Basis_string uw_Basis_strdup(uw_context, uw_Basis_string);
 
-lw_Basis_string lw_Basis_sqlifyInt(lw_context, lw_Basis_int);
-lw_Basis_string lw_Basis_sqlifyFloat(lw_context, lw_Basis_float);
-lw_Basis_string lw_Basis_sqlifyString(lw_context, lw_Basis_string);
-lw_Basis_string lw_Basis_sqlifyBool(lw_context, lw_Basis_bool);
+uw_Basis_string uw_Basis_sqlifyInt(uw_context, uw_Basis_int);
+uw_Basis_string uw_Basis_sqlifyFloat(uw_context, uw_Basis_float);
+uw_Basis_string uw_Basis_sqlifyString(uw_context, uw_Basis_string);
+uw_Basis_string uw_Basis_sqlifyBool(uw_context, uw_Basis_bool);
 
-char *lw_Basis_ensqlBool(lw_Basis_bool);
+char *uw_Basis_ensqlBool(uw_Basis_bool);
 
-lw_Basis_string lw_Basis_intToString(lw_context, lw_Basis_int);
-lw_Basis_string lw_Basis_floatToString(lw_context, lw_Basis_float);
-lw_Basis_string lw_Basis_boolToString(lw_context, lw_Basis_bool);
+uw_Basis_string uw_Basis_intToString(uw_context, uw_Basis_int);
+uw_Basis_string uw_Basis_floatToString(uw_context, uw_Basis_float);
+uw_Basis_string uw_Basis_boolToString(uw_context, uw_Basis_bool);
 
-lw_Basis_int *lw_Basis_stringToInt(lw_context, lw_Basis_string);
-lw_Basis_float *lw_Basis_stringToFloat(lw_context, lw_Basis_string);
-lw_Basis_bool *lw_Basis_stringToBool(lw_context, lw_Basis_string);
+uw_Basis_int *uw_Basis_stringToInt(uw_context, uw_Basis_string);
+uw_Basis_float *uw_Basis_stringToFloat(uw_context, uw_Basis_string);
+uw_Basis_bool *uw_Basis_stringToBool(uw_context, uw_Basis_string);
 
-lw_Basis_int lw_Basis_stringToInt_error(lw_context, lw_Basis_string);
-lw_Basis_float lw_Basis_stringToFloat_error(lw_context, lw_Basis_string);
-lw_Basis_bool lw_Basis_stringToBool_error(lw_context, lw_Basis_string);
+uw_Basis_int uw_Basis_stringToInt_error(uw_context, uw_Basis_string);
+uw_Basis_float uw_Basis_stringToFloat_error(uw_context, uw_Basis_string);
+uw_Basis_bool uw_Basis_stringToBool_error(uw_context, uw_Basis_string);
--- a/src/c/driver.c	Sun Sep 07 15:35:08 2008 -0400
+++ b/src/c/driver.c	Sun Sep 07 15:40:42 2008 -0400
@@ -9,9 +9,9 @@
 
 #include "urweb.h"
 
-int lw_port = 8080;
-int lw_backlog = 10;
-int lw_bufsize = 1024;
+int uw_port = 8080;
+int uw_backlog = 10;
+int uw_bufsize = 1024;
 
 typedef struct node {
   int fd;
@@ -53,39 +53,39 @@
 
 static void *worker(void *data) {
   int me = *(int *)data, retries_left = MAX_RETRIES;;
-  lw_context ctx = lw_init(1024, 1024);
+  uw_context ctx = uw_init(1024, 1024);
   
   while (1) {
-    failure_kind fk = lw_begin_init(ctx);
+    failure_kind fk = uw_begin_init(ctx);
 
     if (fk == SUCCESS) {
-      lw_db_init(ctx);
+      uw_db_init(ctx);
       printf("Database connection initialized.\n");
       break;
     } else if (fk == BOUNDED_RETRY) {
       if (retries_left) {
-        printf("Initialization error triggers bounded retry: %s\n", lw_error_message(ctx));
+        printf("Initialization error triggers bounded retry: %s\n", uw_error_message(ctx));
         --retries_left;
       } else {
-        printf("Fatal initialization error (out of retries): %s\n", lw_error_message(ctx));
-        lw_free(ctx);
+        printf("Fatal initialization error (out of retries): %s\n", uw_error_message(ctx));
+        uw_free(ctx);
         return NULL;
       }
     } else if (fk == UNLIMITED_RETRY)
-      printf("Initialization error triggers unlimited retry: %s\n", lw_error_message(ctx));
+      printf("Initialization error triggers unlimited retry: %s\n", uw_error_message(ctx));
     else if (fk == FATAL) {
-      printf("Fatal initialization error: %s\n", lw_error_message(ctx));
-      lw_free(ctx);
+      printf("Fatal initialization error: %s\n", uw_error_message(ctx));
+      uw_free(ctx);
       return NULL;
     } else {
-      printf("Unknown lw_handle return code!\n");
-      lw_free(ctx);
+      printf("Unknown uw_handle return code!\n");
+      uw_free(ctx);
       return NULL;
     }
   }
 
   while (1) {
-    char buf[lw_bufsize+1], *back = buf, *s;
+    char buf[uw_bufsize+1], *back = buf, *s;
     int sock;
 
     pthread_mutex_lock(&queue_mutex);
@@ -98,7 +98,7 @@
 
     while (1) {
       unsigned retries_left = MAX_RETRIES;
-      int r = recv(sock, back, lw_bufsize - (back - buf), 0);
+      int r = recv(sock, back, uw_bufsize - (back - buf), 0);
 
       if (r < 0) {
         fprintf(stderr, "Recv failed\n");
@@ -159,10 +159,10 @@
 
             if (value = strchr(name, '=')) {
               *value++ = 0;
-              lw_set_input(ctx, name, value);
+              uw_set_input(ctx, name, value);
             }
             else
-              lw_set_input(ctx, name, "");
+              uw_set_input(ctx, name, "");
           }
         }
 
@@ -171,57 +171,57 @@
         while (1) {
           failure_kind fk;
 
-          lw_write(ctx, "HTTP/1.1 200 OK\r\n");
-          lw_write(ctx, "Content-type: text/html\r\n\r\n");
-          lw_write(ctx, "<html>");
+          uw_write(ctx, "HTTP/1.1 200 OK\r\n");
+          uw_write(ctx, "Content-type: text/html\r\n\r\n");
+          uw_write(ctx, "<html>");
 
-          fk = lw_begin(ctx, path);
+          fk = uw_begin(ctx, path);
           if (fk == SUCCESS) {
-            lw_write(ctx, "</html>");
+            uw_write(ctx, "</html>");
             break;
           } else if (fk == BOUNDED_RETRY) {
             if (retries_left) {
-              printf("Error triggers bounded retry: %s\n", lw_error_message(ctx));
+              printf("Error triggers bounded retry: %s\n", uw_error_message(ctx));
               --retries_left;
             }
             else {
-              printf("Fatal error (out of retries): %s\n", lw_error_message(ctx));
+              printf("Fatal error (out of retries): %s\n", uw_error_message(ctx));
 
-              lw_reset_keep_error_message(ctx);
-              lw_write(ctx, "HTTP/1.1 500 Internal Server Error\n\r");
-              lw_write(ctx, "Content-type: text/plain\r\n\r\n");
-              lw_write(ctx, "Fatal error (out of retries): ");
-              lw_write(ctx, lw_error_message(ctx));
-              lw_write(ctx, "\n");
+              uw_reset_keep_error_message(ctx);
+              uw_write(ctx, "HTTP/1.1 500 Internal Server Error\n\r");
+              uw_write(ctx, "Content-type: text/plain\r\n\r\n");
+              uw_write(ctx, "Fatal error (out of retries): ");
+              uw_write(ctx, uw_error_message(ctx));
+              uw_write(ctx, "\n");
             }
           } else if (fk == UNLIMITED_RETRY)
-            printf("Error triggers unlimited retry: %s\n", lw_error_message(ctx));
+            printf("Error triggers unlimited retry: %s\n", uw_error_message(ctx));
           else if (fk == FATAL) {
-            printf("Fatal error: %s\n", lw_error_message(ctx));
+            printf("Fatal error: %s\n", uw_error_message(ctx));
 
-            lw_reset_keep_error_message(ctx);
-            lw_write(ctx, "HTTP/1.1 500 Internal Server Error\n\r");
-            lw_write(ctx, "Content-type: text/plain\r\n\r\n");
-            lw_write(ctx, "Fatal error: ");
-            lw_write(ctx, lw_error_message(ctx));
-            lw_write(ctx, "\n");
+            uw_reset_keep_error_message(ctx);
+            uw_write(ctx, "HTTP/1.1 500 Internal Server Error\n\r");
+            uw_write(ctx, "Content-type: text/plain\r\n\r\n");
+            uw_write(ctx, "Fatal error: ");
+            uw_write(ctx, uw_error_message(ctx));
+            uw_write(ctx, "\n");
 
             break;
           } else {
-            printf("Unknown lw_handle return code!\n");
+            printf("Unknown uw_handle return code!\n");
 
-            lw_reset_keep_request(ctx);
-            lw_write(ctx, "HTTP/1.1 500 Internal Server Error\n\r");
-            lw_write(ctx, "Content-type: text/plain\r\n\r\n");
-            lw_write(ctx, "Unknown lw_handle return code!\n");
+            uw_reset_keep_request(ctx);
+            uw_write(ctx, "HTTP/1.1 500 Internal Server Error\n\r");
+            uw_write(ctx, "Content-type: text/plain\r\n\r\n");
+            uw_write(ctx, "Unknown uw_handle return code!\n");
 
             break;
           }
 
-          lw_reset_keep_request(ctx);
+          uw_reset_keep_request(ctx);
         }
 
-        lw_send(ctx, sock);
+        uw_send(ctx, sock);
 
         printf("Done with client.\n\n");
         break;
@@ -229,7 +229,7 @@
     }
 
     close(sock);
-    lw_reset(ctx);
+    uw_reset(ctx);
   }
 }
 
@@ -266,7 +266,7 @@
   }
 
   my_addr.sin_family = AF_INET;         // host byte order
-  my_addr.sin_port = htons(lw_port);    // short, network byte order
+  my_addr.sin_port = htons(uw_port);    // short, network byte order
   my_addr.sin_addr.s_addr = INADDR_ANY; // auto-fill with my IP
   memset(my_addr.sin_zero, '\0', sizeof my_addr.sin_zero);
 
@@ -275,14 +275,14 @@
     return 1;
   }
 
-  if (listen(sockfd, lw_backlog) < 0) {
+  if (listen(sockfd, uw_backlog) < 0) {
     fprintf(stderr, "Socket listen failed\n");
     return 1;
   }
 
   sin_size = sizeof their_addr;
 
-  printf("Listening on port %d....\n", lw_port);
+  printf("Listening on port %d....\n", uw_port);
 
   for (i = 0; i < nthreads; ++i) {
     pthread_t thread;    
--- a/src/c/urweb.c	Sun Sep 07 15:35:08 2008 -0400
+++ b/src/c/urweb.c	Sun Sep 07 15:40:42 2008 -0400
@@ -7,11 +7,11 @@
 
 #include "types.h"
 
-lw_unit lw_unit_v = {};
+uw_unit uw_unit_v = {};
 
 #define ERROR_BUF_LEN 1024
 
-struct lw_context {
+struct uw_context {
   char *page, *page_front, *page_back;
   char *heap, *heap_front, *heap_back;
   char **inputs;
@@ -23,10 +23,10 @@
   char error_message[ERROR_BUF_LEN];
 };
 
-extern int lw_inputs_len;
+extern int uw_inputs_len;
 
-lw_context lw_init(size_t page_len, size_t heap_len) {
-  lw_context ctx = malloc(sizeof(struct lw_context));
+uw_context uw_init(size_t page_len, size_t heap_len) {
+  uw_context ctx = malloc(sizeof(struct uw_context));
 
   ctx->page_front = ctx->page = malloc(page_len);
   ctx->page_back = ctx->page_front + page_len;
@@ -34,7 +34,7 @@
   ctx->heap_front = ctx->heap = malloc(heap_len);
   ctx->heap_back = ctx->heap_front + heap_len;
 
-  ctx->inputs = calloc(lw_inputs_len, sizeof(char *));
+  ctx->inputs = calloc(uw_inputs_len, sizeof(char *));
 
   ctx->db = NULL;
 
@@ -43,60 +43,60 @@
   return ctx;
 }
 
-void lw_set_db(lw_context ctx, void *db) {
+void uw_set_db(uw_context ctx, void *db) {
   ctx->db = db;
 }
 
-void *lw_get_db(lw_context ctx) {
+void *uw_get_db(uw_context ctx) {
   return ctx->db;
 }
 
-void lw_free(lw_context ctx) {
+void uw_free(uw_context ctx) {
   free(ctx->page);
   free(ctx->heap);
   free(ctx->inputs);
   free(ctx);
 }
 
-void lw_reset_keep_request(lw_context ctx) {
+void uw_reset_keep_request(uw_context ctx) {
   ctx->page_front = ctx->page;
   ctx->heap_front = ctx->heap;
 
   ctx->error_message[0] = 0;
 }
 
-void lw_reset_keep_error_message(lw_context ctx) {
+void uw_reset_keep_error_message(uw_context ctx) {
   ctx->page_front = ctx->page;
   ctx->heap_front = ctx->heap;
 }
 
-void lw_reset(lw_context ctx) {
-  lw_reset_keep_request(ctx);
-  memset(ctx->inputs, 0, lw_inputs_len * sizeof(char *));
+void uw_reset(uw_context ctx) {
+  uw_reset_keep_request(ctx);
+  memset(ctx->inputs, 0, uw_inputs_len * sizeof(char *));
 }
 
-void lw_db_init(lw_context);
-void lw_handle(lw_context, char *);
+void uw_db_init(uw_context);
+void uw_handle(uw_context, char *);
 
-failure_kind lw_begin_init(lw_context ctx) {
+failure_kind uw_begin_init(uw_context ctx) {
   int r = setjmp(ctx->jmp_buf);
 
   if (r == 0)
-    lw_db_init(ctx);
+    uw_db_init(ctx);
 
   return r;
 }
 
-failure_kind lw_begin(lw_context ctx, char *path) {
+failure_kind uw_begin(uw_context ctx, char *path) {
   int r = setjmp(ctx->jmp_buf);
 
   if (r == 0)
-    lw_handle(ctx, path);
+    uw_handle(ctx, path);
 
   return r;
 }
 
-__attribute__((noreturn)) void lw_error(lw_context ctx, failure_kind fk, const char *fmt, ...) {
+__attribute__((noreturn)) void uw_error(uw_context ctx, failure_kind fk, const char *fmt, ...) {
   va_list ap;
   va_start(ap, fmt);
 
@@ -105,45 +105,45 @@
   longjmp(ctx->jmp_buf, fk);
 }
 
-char *lw_error_message(lw_context ctx) {
+char *uw_error_message(uw_context ctx) {
   return ctx->error_message;
 }
 
-int lw_input_num(char*);
+int uw_input_num(char*);
 
-void lw_set_input(lw_context ctx, char *name, char *value) {
-  int n = lw_input_num(name);
+void uw_set_input(uw_context ctx, char *name, char *value) {
+  int n = uw_input_num(name);
 
   if (n < 0)
-    lw_error(ctx, FATAL, "Bad input name %s", name);
+    uw_error(ctx, FATAL, "Bad input name %s", name);
 
-  if (n >= lw_inputs_len)
-    lw_error(ctx, FATAL, "For input name %s, index %d is out of range", name, n);
+  if (n >= uw_inputs_len)
+    uw_error(ctx, FATAL, "For input name %s, index %d is out of range", name, n);
 
   ctx->inputs[n] = value;
 
   //printf("[%d] %s = %s\n", n, name, value);
 }
 
-char *lw_get_input(lw_context ctx, int n) {
+char *uw_get_input(uw_context ctx, int n) {
   if (n < 0)
-    lw_error(ctx, FATAL, "Negative input index %d", n);
-  if (n >= lw_inputs_len)
-    lw_error(ctx, FATAL, "Out-of-bounds input index %d", n);
+    uw_error(ctx, FATAL, "Negative input index %d", n);
+  if (n >= uw_inputs_len)
+    uw_error(ctx, FATAL, "Out-of-bounds input index %d", n);
   //printf("[%d] = %s\n", n, ctx->inputs[n]);
   return ctx->inputs[n];
 }
 
-char *lw_get_optional_input(lw_context ctx, int n) {
+char *uw_get_optional_input(uw_context ctx, int n) {
   if (n < 0)
-    lw_error(ctx, FATAL, "Negative input index %d", n);
-  if (n >= lw_inputs_len)
-    lw_error(ctx, FATAL, "Out-of-bounds input index %d", n);
+    uw_error(ctx, FATAL, "Negative input index %d", n);
+  if (n >= uw_inputs_len)
+    uw_error(ctx, FATAL, "Out-of-bounds input index %d", n);
   printf("[%d] = %s\n", n, ctx->inputs[n]);
   return (ctx->inputs[n] == NULL ? "" : ctx->inputs[n]);
 }
 
-static void lw_check_heap(lw_context ctx, size_t extra) {
+static void uw_check_heap(uw_context ctx, size_t extra) {
   if (ctx->heap_back - ctx->heap_front < extra) {
     size_t desired = ctx->heap_back - ctx->heap_front + extra, next;
     char *new_heap;
@@ -156,24 +156,24 @@
 
     if (new_heap != ctx->heap) {
       ctx->heap = new_heap;
-      lw_error(ctx, UNLIMITED_RETRY, "Couldn't allocate new heap chunk contiguously");
+      uw_error(ctx, UNLIMITED_RETRY, "Couldn't allocate new heap chunk contiguously");
     }
 
     ctx->heap = new_heap;
   }
 }
 
-void *lw_malloc(lw_context ctx, size_t len) {
+void *uw_malloc(uw_context ctx, size_t len) {
   void *result;
 
-  lw_check_heap(ctx, len);
+  uw_check_heap(ctx, len);
 
   result = ctx->heap_front;
   ctx->heap_front += len;
   return result;
 }
 
-int lw_really_send(int sock, const void *buf, ssize_t len) {
+int uw_really_send(int sock, const void *buf, ssize_t len) {
   while (len > 0) {
     ssize_t n = send(sock, buf, len, 0);
 
@@ -187,11 +187,11 @@
   return 0;
 }
 
-int lw_send(lw_context ctx, int sock) {
-  return lw_really_send(sock, ctx->page, ctx->page_front - ctx->page);
+int uw_send(uw_context ctx, int sock) {
+  return uw_really_send(sock, ctx->page, ctx->page_front - ctx->page);
 }
 
-static void lw_check(lw_context ctx, size_t extra) {
+static void uw_check(uw_context ctx, size_t extra) {
   size_t desired = ctx->page_back - ctx->page_front + extra, next;
   char *new_page;
 
@@ -203,52 +203,52 @@
   ctx->page = new_page;
 }
 
-static void lw_writec_unsafe(lw_context ctx, char c) {
+static void uw_writec_unsafe(uw_context ctx, char c) {
   *(ctx->page_front)++ = c;
 }
 
-void lw_writec(lw_context ctx, char c) {
-  lw_check(ctx, 1);
-  lw_writec_unsafe(ctx, c);
+void uw_writec(uw_context ctx, char c) {
+  uw_check(ctx, 1);
+  uw_writec_unsafe(ctx, c);
 }
 
-static void lw_write_unsafe(lw_context ctx, const char* s) {
+static void uw_write_unsafe(uw_context ctx, const char* s) {
   int len = strlen(s);
   memcpy(ctx->page_front, s, len);
   ctx->page_front += len;
 }
 
-void lw_write(lw_context ctx, const char* s) {
-  lw_check(ctx, strlen(s) + 1);
-  lw_write_unsafe(ctx, s);
+void uw_write(uw_context ctx, const char* s) {
+  uw_check(ctx, strlen(s) + 1);
+  uw_write_unsafe(ctx, s);
   *ctx->page_front = 0;
 }
 
 
-char *lw_Basis_attrifyInt(lw_context ctx, lw_Basis_int n) {
+char *uw_Basis_attrifyInt(uw_context ctx, uw_Basis_int n) {
   char *result;
   int len;
-  lw_check_heap(ctx, INTS_MAX);
+  uw_check_heap(ctx, INTS_MAX);
   result = ctx->heap_front;
   sprintf(result, "%lld%n", n, &len);
   ctx->heap_front += len+1;
   return result;
 }
 
-char *lw_Basis_attrifyFloat(lw_context ctx, lw_Basis_float n) {
+char *uw_Basis_attrifyFloat(uw_context ctx, uw_Basis_float n) {
   char *result;
   int len;
-  lw_check_heap(ctx, FLOATS_MAX);
+  uw_check_heap(ctx, FLOATS_MAX);
   result = ctx->heap_front;
   sprintf(result, "%g%n", n, &len);
   ctx->heap_front += len+1;
   return result;
 }
 
-char *lw_Basis_attrifyString(lw_context ctx, lw_Basis_string s) {
+char *uw_Basis_attrifyString(uw_context ctx, uw_Basis_string s) {
   int len = strlen(s);
   char *result, *p;
-  lw_check_heap(ctx, len * 6 + 1);
+  uw_check_heap(ctx, len * 6 + 1);
 
   result = p = ctx->heap_front;
 
@@ -276,73 +276,73 @@
   return result;
 }
 
-static void lw_Basis_attrifyInt_w_unsafe(lw_context ctx, lw_Basis_int n) {
+static void uw_Basis_attrifyInt_w_unsafe(uw_context ctx, uw_Basis_int n) {
   int len;
 
   sprintf(ctx->page_front, "%lld%n", n, &len);
   ctx->page_front += len;
 }
 
-void lw_Basis_attrifyInt_w(lw_context ctx, lw_Basis_int n) {
-  lw_check(ctx, INTS_MAX);
-  lw_Basis_attrifyInt_w_unsafe(ctx, n);
+void uw_Basis_attrifyInt_w(uw_context ctx, uw_Basis_int n) {
+  uw_check(ctx, INTS_MAX);
+  uw_Basis_attrifyInt_w_unsafe(ctx, n);
 }
 
-void lw_Basis_attrifyFloat_w(lw_context ctx, lw_Basis_float n) {
+void uw_Basis_attrifyFloat_w(uw_context ctx, uw_Basis_float n) {
   int len;
 
-  lw_check(ctx, FLOATS_MAX);
+  uw_check(ctx, FLOATS_MAX);
   sprintf(ctx->page_front, "%g%n", n, &len);
   ctx->page_front += len;
 }
 
-void lw_Basis_attrifyString_w(lw_context ctx, lw_Basis_string s) {
-  lw_check(ctx, strlen(s) * 6);
+void uw_Basis_attrifyString_w(uw_context ctx, uw_Basis_string s) {
+  uw_check(ctx, strlen(s) * 6);
 
   for (; *s; s++) {
     char c = *s;
 
     if (c == '"')
-      lw_write_unsafe(ctx, "&quot;");
+      uw_write_unsafe(ctx, "&quot;");
     else if (c == '&')
-      lw_write_unsafe(ctx, "&amp;");
+      uw_write_unsafe(ctx, "&amp;");
     else if (isprint(c))
-      lw_writec_unsafe(ctx, c);
+      uw_writec_unsafe(ctx, c);
     else {
-      lw_write_unsafe(ctx, "&#");
-      lw_Basis_attrifyInt_w_unsafe(ctx, c);
-      lw_writec_unsafe(ctx, ';');
+      uw_write_unsafe(ctx, "&#");
+      uw_Basis_attrifyInt_w_unsafe(ctx, c);
+      uw_writec_unsafe(ctx, ';');
     }
   }
 }
 
 
-char *lw_Basis_urlifyInt(lw_context ctx, lw_Basis_int n) {
+char *uw_Basis_urlifyInt(uw_context ctx, uw_Basis_int n) {
   int len;
   char *r;
 
-  lw_check_heap(ctx, INTS_MAX);
+  uw_check_heap(ctx, INTS_MAX);
   r = ctx->heap_front;
   sprintf(r, "%lld%n", n, &len);
   ctx->heap_front += len+1;
   return r;
 }
 
-char *lw_Basis_urlifyFloat(lw_context ctx, lw_Basis_float n) {
+char *uw_Basis_urlifyFloat(uw_context ctx, uw_Basis_float n) {
   int len;
   char *r;
 
-  lw_check_heap(ctx, FLOATS_MAX);
+  uw_check_heap(ctx, FLOATS_MAX);
   r = ctx->heap_front;
   sprintf(r, "%g%n", n, &len);
   ctx->heap_front += len+1;
   return r;
 }
 
-char *lw_Basis_urlifyString(lw_context ctx, lw_Basis_string s) {
+char *uw_Basis_urlifyString(uw_context ctx, uw_Basis_string s) {
   char *r, *p;
 
-  lw_check_heap(ctx, strlen(s) * 3 + 1);
+  uw_check_heap(ctx, strlen(s) * 3 + 1);
 
   for (r = p = ctx->heap_front; *s; s++) {
     char c = *s;
@@ -362,43 +362,43 @@
   return r;
 }
 
-char *lw_Basis_urlifyBool(lw_context ctx, lw_Basis_bool b) {
-  if (b == lw_Basis_False)
+char *uw_Basis_urlifyBool(uw_context ctx, uw_Basis_bool b) {
+  if (b == uw_Basis_False)
     return "0";
   else
     return "1";
 }
 
-static void lw_Basis_urlifyInt_w_unsafe(lw_context ctx, lw_Basis_int n) {
+static void uw_Basis_urlifyInt_w_unsafe(uw_context ctx, uw_Basis_int n) {
   int len;
 
   sprintf(ctx->page_front, "%lld%n", n, &len);
   ctx->page_front += len;
 }
 
-void lw_Basis_urlifyInt_w(lw_context ctx, lw_Basis_int n) {
-  lw_check(ctx, INTS_MAX);
-  lw_Basis_urlifyInt_w_unsafe(ctx, n);
+void uw_Basis_urlifyInt_w(uw_context ctx, uw_Basis_int n) {
+  uw_check(ctx, INTS_MAX);
+  uw_Basis_urlifyInt_w_unsafe(ctx, n);
 }
 
-void lw_Basis_urlifyFloat_w(lw_context ctx, lw_Basis_float n) {
+void uw_Basis_urlifyFloat_w(uw_context ctx, uw_Basis_float n) {
   int len;
 
-  lw_check(ctx, FLOATS_MAX);
+  uw_check(ctx, FLOATS_MAX);
   sprintf(ctx->page_front, "%g%n", n, &len);
   ctx->page_front += len;
 }
 
-void lw_Basis_urlifyString_w(lw_context ctx, lw_Basis_string s) {
-  lw_check(ctx, strlen(s) * 3);
+void uw_Basis_urlifyString_w(uw_context ctx, uw_Basis_string s) {
+  uw_check(ctx, strlen(s) * 3);
 
   for (; *s; s++) {
     char c = *s;
 
     if (c == ' ')
-      lw_writec_unsafe(ctx, '+');
+      uw_writec_unsafe(ctx, '+');
     else if (isalnum(c))
-      lw_writec_unsafe(ctx, c);
+      uw_writec_unsafe(ctx, c);
     else {
       sprintf(ctx->page_front, "%%%02X", c);
       ctx->page_front += 3;
@@ -406,15 +406,15 @@
   }
 }
 
-void lw_Basis_urlifyBool_w(lw_context ctx, lw_Basis_bool b) {
-  if (b == lw_Basis_False)
-    lw_writec(ctx, '0');
+void uw_Basis_urlifyBool_w(uw_context ctx, uw_Basis_bool b) {
+  if (b == uw_Basis_False)
+    uw_writec(ctx, '0');
   else
-    lw_writec(ctx, '1');
+    uw_writec(ctx, '1');
 }
 
 
-static char *lw_unurlify_advance(char *s) {
+static char *uw_unurlify_advance(char *s) {
   char *new_s = strchr(s, '/');
 
   if (new_s)
@@ -425,25 +425,25 @@
   return new_s;
 }
 
-lw_Basis_int lw_Basis_unurlifyInt(lw_context ctx, char **s) {
-  char *new_s = lw_unurlify_advance(*s);
-  lw_Basis_int r;
+uw_Basis_int uw_Basis_unurlifyInt(uw_context ctx, char **s) {
+  char *new_s = uw_unurlify_advance(*s);
+  uw_Basis_int r;
 
   r = atoll(*s);
   *s = new_s;
   return r;
 }
 
-lw_Basis_float lw_Basis_unurlifyFloat(lw_context ctx, char **s) {
-  char *new_s = lw_unurlify_advance(*s);
-  lw_Basis_float r;
+uw_Basis_float uw_Basis_unurlifyFloat(uw_context ctx, char **s) {
+  char *new_s = uw_unurlify_advance(*s);
+  uw_Basis_float r;
 
   r = atof(*s);
   *s = new_s;
   return r;
 }
 
-static lw_Basis_string lw_unurlifyString_to(lw_context ctx, char *r, char *s) {
+static uw_Basis_string uw_unurlifyString_to(uw_context ctx, char *r, char *s) {
   char *s1, *s2;
   int n;
 
@@ -456,11 +456,11 @@
       break;
     case '%':
       if (s2[1] == 0)
-        lw_error(ctx, FATAL, "Missing first character of escaped URL byte");
+        uw_error(ctx, FATAL, "Missing first character of escaped URL byte");
       if (s2[2] == 0)
-        lw_error(ctx, FATAL, "Missing second character of escaped URL byte");
+        uw_error(ctx, FATAL, "Missing second character of escaped URL byte");
       if (sscanf(s2+1, "%02X", &n) != 1)
-        lw_error(ctx, FATAL, "Invalid escaped URL byte starting at: %s", s2);
+        uw_error(ctx, FATAL, "Invalid escaped URL byte starting at: %s", s2);
       *s1 = n;
       s2 += 2;
       break;
@@ -472,76 +472,76 @@
   return s1;
 }
 
-lw_Basis_bool lw_Basis_unurlifyBool(lw_context ctx, char **s) {
-  char *new_s = lw_unurlify_advance(*s);
-  lw_Basis_bool r;
+uw_Basis_bool uw_Basis_unurlifyBool(uw_context ctx, char **s) {
+  char *new_s = uw_unurlify_advance(*s);
+  uw_Basis_bool r;
   
   if (*s[0] == 0 || !strcmp(*s, "0") || !strcmp(*s, "off"))
-    r = lw_Basis_False;
+    r = uw_Basis_False;
   else
-    r = lw_Basis_True;
+    r = uw_Basis_True;
 
   *s = new_s;
   return r;
 }
 
-lw_Basis_string lw_Basis_unurlifyString(lw_context ctx, char **s) {
-  char *new_s = lw_unurlify_advance(*s);
+uw_Basis_string uw_Basis_unurlifyString(uw_context ctx, char **s) {
+  char *new_s = uw_unurlify_advance(*s);
   char *r, *s1, *s2;
   int len, n;
 
   len = strlen(*s);
-  lw_check_heap(ctx, len + 1);
+  uw_check_heap(ctx, len + 1);
 
   r = ctx->heap_front;
-  ctx->heap_front = lw_unurlifyString_to(ctx, ctx->heap_front, *s);
+  ctx->heap_front = uw_unurlifyString_to(ctx, ctx->heap_front, *s);
   *s = new_s;
   return r;
 }
 
 
-char *lw_Basis_htmlifyInt(lw_context ctx, lw_Basis_int n) {
+char *uw_Basis_htmlifyInt(uw_context ctx, uw_Basis_int n) {
   int len;
   char *r;
 
-  lw_check_heap(ctx, INTS_MAX);
+  uw_check_heap(ctx, INTS_MAX);
   r = ctx->heap_front;
   sprintf(r, "%lld%n", n, &len);
   ctx->heap_front += len+1;
   return r;
 }
 
-void lw_Basis_htmlifyInt_w(lw_context ctx, lw_Basis_int n) {
+void uw_Basis_htmlifyInt_w(uw_context ctx, uw_Basis_int n) {
   int len;
 
-  lw_check(ctx, INTS_MAX);
+  uw_check(ctx, INTS_MAX);
   sprintf(ctx->page_front, "%lld%n", n, &len);
   ctx->page_front += len;
 }
 
-char *lw_Basis_htmlifyFloat(lw_context ctx, lw_Basis_float n) {
+char *uw_Basis_htmlifyFloat(uw_context ctx, uw_Basis_float n) {
   int len;
   char *r;
 
-  lw_check_heap(ctx, FLOATS_MAX);
+  uw_check_heap(ctx, FLOATS_MAX);
   r = ctx->heap_front;
   sprintf(r, "%g%n", n, &len);
   ctx->heap_front += len+1;
   return r;
 }
 
-void lw_Basis_htmlifyFloat_w(lw_context ctx, lw_Basis_float n) {
+void uw_Basis_htmlifyFloat_w(uw_context ctx, uw_Basis_float n) {
   int len;
 
-  lw_check(ctx, FLOATS_MAX);
+  uw_check(ctx, FLOATS_MAX);
   sprintf(ctx->page_front, "%g%n", n, &len);
   ctx->page_front += len;
 }
 
-char *lw_Basis_htmlifyString(lw_context ctx, lw_Basis_string s) {
+char *uw_Basis_htmlifyString(uw_context ctx, uw_Basis_string s) {
   char *r, *s2;
 
-  lw_check_heap(ctx, strlen(s) * 5 + 1);
+  uw_check_heap(ctx, strlen(s) * 5 + 1);
 
   for (r = s2 = ctx->heap_front; *s; s++) {
     char c = *s;
@@ -571,55 +571,55 @@
   return r;
 }
 
-void lw_Basis_htmlifyString_w(lw_context ctx, lw_Basis_string s) {
-  lw_check(ctx, strlen(s) * 5);
+void uw_Basis_htmlifyString_w(uw_context ctx, uw_Basis_string s) {
+  uw_check(ctx, strlen(s) * 5);
 
   for (; *s; s++) {
     char c = *s;
 
     switch (c) {
     case '<':
-      lw_write_unsafe(ctx, "&lt;");
+      uw_write_unsafe(ctx, "&lt;");
       break;
     case '&':
-      lw_write_unsafe(ctx, "&amp;");
+      uw_write_unsafe(ctx, "&amp;");
       break;
     default:
       if (isprint(c))
-        lw_writec_unsafe(ctx, c);
+        uw_writec_unsafe(ctx, c);
       else {
-        lw_write_unsafe(ctx, "&#");
-        lw_Basis_attrifyInt_w_unsafe(ctx, c);
-        lw_writec_unsafe(ctx, ';');
+        uw_write_unsafe(ctx, "&#");
+        uw_Basis_attrifyInt_w_unsafe(ctx, c);
+        uw_writec_unsafe(ctx, ';');
       }
     }
   }
 }
 
-lw_Basis_string lw_Basis_htmlifyBool(lw_context ctx, lw_Basis_bool b) {
-  if (b == lw_Basis_False)
+uw_Basis_string uw_Basis_htmlifyBool(uw_context ctx, uw_Basis_bool b) {
+  if (b == uw_Basis_False)
     return "False";
   else
     return "True";
 }
 
-void lw_Basis_htmlifyBool_w(lw_context ctx, lw_Basis_bool b) {
-  if (b == lw_Basis_False) {
-    lw_check(ctx, 6);
+void uw_Basis_htmlifyBool_w(uw_context ctx, uw_Basis_bool b) {
+  if (b == uw_Basis_False) {
+    uw_check(ctx, 6);
     strcpy(ctx->page_front, "False");
     ctx->page_front += 5;
   } else {
-    lw_check(ctx, 5);
+    uw_check(ctx, 5);
     strcpy(ctx->page_front, "True");
     ctx->page_front += 4;
   }
 }
 
-lw_Basis_string lw_Basis_strcat(lw_context ctx, lw_Basis_string s1, lw_Basis_string s2) {
+uw_Basis_string uw_Basis_strcat(uw_context ctx, uw_Basis_string s1, uw_Basis_string s2) {
   int len = strlen(s1) + strlen(s2) + 1;
   char *s;
 
-  lw_check_heap(ctx, len);
+  uw_check_heap(ctx, len);
 
   s = ctx->heap_front;
 
@@ -630,11 +630,11 @@
   return s;
 }
 
-lw_Basis_string lw_Basis_strdup(lw_context ctx, lw_Basis_string s1) {
+uw_Basis_string uw_Basis_strdup(uw_context ctx, uw_Basis_string s1) {
   int len = strlen(s1) + 1;
   char *s;
 
-  lw_check_heap(ctx, len);
+  uw_check_heap(ctx, len);
 
   s = ctx->heap_front;
 
@@ -645,22 +645,22 @@
 }
 
 
-char *lw_Basis_sqlifyInt(lw_context ctx, lw_Basis_int n) {
+char *uw_Basis_sqlifyInt(uw_context ctx, uw_Basis_int n) {
   int len;
   char *r;
 
-  lw_check_heap(ctx, INTS_MAX + 6);
+  uw_check_heap(ctx, INTS_MAX + 6);
   r = ctx->heap_front;
   sprintf(r, "%lld::int8%n", n, &len);
   ctx->heap_front += len+1;
   return r;
 }
 
-char *lw_Basis_sqlifyFloat(lw_context ctx, lw_Basis_float n) {
+char *uw_Basis_sqlifyFloat(uw_context ctx, uw_Basis_float n) {
   int len;
   char *r;
 
-  lw_check_heap(ctx, FLOATS_MAX + 8);
+  uw_check_heap(ctx, FLOATS_MAX + 8);
   r = ctx->heap_front;
   sprintf(r, "%g::float8%n", n, &len);
   ctx->heap_front += len+1;
@@ -668,10 +668,10 @@
 }
 
 
-lw_Basis_string lw_Basis_sqlifyString(lw_context ctx, lw_Basis_string s) {
+uw_Basis_string uw_Basis_sqlifyString(uw_context ctx, uw_Basis_string s) {
   char *r, *s2;
 
-  lw_check_heap(ctx, strlen(s) * 2 + 10);
+  uw_check_heap(ctx, strlen(s) * 2 + 10);
 
   r = s2 = ctx->heap_front;
   *s2++ = 'E';
@@ -704,80 +704,80 @@
   return r;
 }
 
-char *lw_Basis_sqlifyBool(lw_context ctx, lw_Basis_bool b) {
-  if (b == lw_Basis_False)
+char *uw_Basis_sqlifyBool(uw_context ctx, uw_Basis_bool b) {
+  if (b == uw_Basis_False)
     return "FALSE";
   else
     return "TRUE";
 }
 
-char *lw_Basis_ensqlBool(lw_Basis_bool b) {
-  static lw_Basis_int true = 1;
-  static lw_Basis_int false = 0;
+char *uw_Basis_ensqlBool(uw_Basis_bool b) {
+  static uw_Basis_int true = 1;
+  static uw_Basis_int false = 0;
 
-  if (b == lw_Basis_False)
+  if (b == uw_Basis_False)
     return (char *)&false;
   else
     return (char *)&true;
 }
 
-lw_Basis_string lw_Basis_intToString(lw_context ctx, lw_Basis_int n) {
+uw_Basis_string uw_Basis_intToString(uw_context ctx, uw_Basis_int n) {
   int len;
   char *r;
 
-  lw_check_heap(ctx, INTS_MAX);
+  uw_check_heap(ctx, INTS_MAX);
   r = ctx->heap_front;
   sprintf(r, "%lld%n", n, &len);
   ctx->heap_front += len+1;
   return r;
 }
 
-lw_Basis_string lw_Basis_floatToString(lw_context ctx, lw_Basis_float n) {
+uw_Basis_string uw_Basis_floatToString(uw_context ctx, uw_Basis_float n) {
   int len;
   char *r;
 
-  lw_check_heap(ctx, FLOATS_MAX);
+  uw_check_heap(ctx, FLOATS_MAX);
   r = ctx->heap_front;
   sprintf(r, "%g%n", n, &len);
   ctx->heap_front += len+1;
   return r;
 }
 
-lw_Basis_string lw_Basis_boolToString(lw_context ctx, lw_Basis_bool b) {
-  if (b == lw_Basis_False)
+uw_Basis_string uw_Basis_boolToString(uw_context ctx, uw_Basis_bool b) {
+  if (b == uw_Basis_False)
     return "False";
   else
     return "True";
 }
 
 
-lw_Basis_int *lw_Basis_stringToInt(lw_context ctx, lw_Basis_string s) {
+uw_Basis_int *uw_Basis_stringToInt(uw_context ctx, uw_Basis_string s) {
   char *endptr;
-  lw_Basis_int n = strtoll(s, &endptr, 10);
+  uw_Basis_int n = strtoll(s, &endptr, 10);
 
   if (*s != '\0' && *endptr == '\0') {
-    lw_Basis_int *r = lw_malloc(ctx, sizeof(lw_Basis_int));
+    uw_Basis_int *r = uw_malloc(ctx, sizeof(uw_Basis_int));
     *r = n;
     return r;
   } else
     return NULL;
 }
 
-lw_Basis_float *lw_Basis_stringToFloat(lw_context ctx, lw_Basis_string s) {
+uw_Basis_float *uw_Basis_stringToFloat(uw_context ctx, uw_Basis_string s) {
   char *endptr;
-  lw_Basis_float n = strtod(s, &endptr);
+  uw_Basis_float n = strtod(s, &endptr);
 
   if (*s != '\0' && *endptr == '\0') {
-    lw_Basis_float *r = lw_malloc(ctx, sizeof(lw_Basis_float));
+    uw_Basis_float *r = uw_malloc(ctx, sizeof(uw_Basis_float));
     *r = n;
     return r;
   } else
     return NULL;
 }
 
-lw_Basis_bool *lw_Basis_stringToBool(lw_context ctx, lw_Basis_string s) {
-  static lw_Basis_bool true = lw_Basis_True;
-  static lw_Basis_bool false = lw_Basis_False;
+uw_Basis_bool *uw_Basis_stringToBool(uw_context ctx, uw_Basis_string s) {
+  static uw_Basis_bool true = uw_Basis_True;
+  static uw_Basis_bool false = uw_Basis_False;
 
   if (!strcasecmp (s, "True"))
     return &true;
@@ -787,31 +787,31 @@
     return NULL;
 }
 
-lw_Basis_int lw_Basis_stringToInt_error(lw_context ctx, lw_Basis_string s) {
+uw_Basis_int uw_Basis_stringToInt_error(uw_context ctx, uw_Basis_string s) {
   char *endptr;
-  lw_Basis_int n = strtoll(s, &endptr, 10);
+  uw_Basis_int n = strtoll(s, &endptr, 10);
 
   if (*s != '\0' && *endptr == '\0')
     return n;
   else
-    lw_error(ctx, FATAL, "Can't parse int: %s", s);
+    uw_error(ctx, FATAL, "Can't parse int: %s", s);
 }
 
-lw_Basis_float lw_Basis_stringToFloat_error(lw_context ctx, lw_Basis_string s) {
+uw_Basis_float uw_Basis_stringToFloat_error(uw_context ctx, uw_Basis_string s) {
   char *endptr;
-  lw_Basis_float n = strtod(s, &endptr);
+  uw_Basis_float n = strtod(s, &endptr);
 
   if (*s != '\0' && *endptr == '\0')
     return n;
   else
-    lw_error(ctx, FATAL, "Can't parse float: %s", s);
+    uw_error(ctx, FATAL, "Can't parse float: %s", s);
 }
 
-lw_Basis_bool lw_Basis_stringToBool_error(lw_context ctx, lw_Basis_string s) {
+uw_Basis_bool uw_Basis_stringToBool_error(uw_context ctx, uw_Basis_string s) {
   if (!strcasecmp(s, "T") || !strcasecmp (s, "True"))
-    return lw_Basis_True;
+    return uw_Basis_True;
   else if (!strcasecmp(s, "F") || !strcasecmp (s, "False"))
-    return lw_Basis_False;
+    return uw_Basis_False;
   else
-    lw_error(ctx, FATAL, "Can't parse bool: %s", s);
+    uw_error(ctx, FATAL, "Can't parse bool: %s", s);
 }
--- a/src/cjr_print.sml	Sun Sep 07 15:35:08 2008 -0400
+++ b/src/cjr_print.sml	Sun Sep 07 15:40:42 2008 -0400
@@ -68,13 +68,13 @@
                                            string ")"])
       | TRecord i => box [string "struct",
                           space,
-                          string "__lws_",
+                          string "__uws_",
                           string (Int.toString i)]
       | TDatatype (Enum, n, _) =>
         (box [string "enum",
               space,
-              string ("__lwe_" ^ #1 (E.lookupDatatype env n) ^ "_" ^ Int.toString n)]
-         handle CjrEnv.UnboundNamed _ => string ("__lwd_UNBOUND__" ^ Int.toString n))
+              string ("__uwe_" ^ #1 (E.lookupDatatype env n) ^ "_" ^ Int.toString n)]
+         handle CjrEnv.UnboundNamed _ => string ("__uwd_UNBOUND__" ^ Int.toString n))
       | TDatatype (Option, n, xncs) =>
         (case ListUtil.search #3 (!xncs) of
              NONE => raise Fail "CjrPrint: TDatatype marked Option has no constructor with an argument"
@@ -87,9 +87,9 @@
       | TDatatype (Default, n, _) =>
         (box [string "struct",
               space,
-              string ("__lwd_" ^ #1 (E.lookupDatatype env n) ^ "_" ^ Int.toString n ^ "*")]
-         handle CjrEnv.UnboundNamed _ => string ("__lwd_UNBOUND__" ^ Int.toString n))
-      | TFfi (m, x) => box [string "lw_", string m, string "_", string x]
+              string ("__uwd_" ^ #1 (E.lookupDatatype env n) ^ "_" ^ Int.toString n ^ "*")]
+         handle CjrEnv.UnboundNamed _ => string ("__uwd_UNBOUND__" ^ Int.toString n))
+      | TFfi (m, x) => box [string "uw_", string m, string "_", string x]
       | TOption t =>
         (case #1 t of
              TDatatype _ => p_typ' par env t
@@ -99,16 +99,16 @@
 
 and p_typ env = p_typ' false env
 
-fun p_rel env n = string ("__lwr_" ^ #1 (E.lookupERel env n) ^ "_" ^ Int.toString (E.countERels env - n - 1))
-    handle CjrEnv.UnboundRel _ => string ("__lwr_UNBOUND_" ^ Int.toString (E.countERels env - n - 1))
+fun p_rel env n = string ("__uwr_" ^ #1 (E.lookupERel env n) ^ "_" ^ Int.toString (E.countERels env - n - 1))
+    handle CjrEnv.UnboundRel _ => string ("__uwr_UNBOUND_" ^ Int.toString (E.countERels env - n - 1))
 
 fun p_enamed env n =
-    string ("__lwn_" ^ #1 (E.lookupENamed env n) ^ "_" ^ Int.toString n)
-    handle CjrEnv.UnboundNamed _ => string ("__lwn_UNBOUND_" ^ Int.toString n)
+    string ("__uwn_" ^ #1 (E.lookupENamed env n) ^ "_" ^ Int.toString n)
+    handle CjrEnv.UnboundNamed _ => string ("__uwn_UNBOUND_" ^ Int.toString n)
 
 fun p_con_named env n =
-    string ("__lwc_" ^ #1 (E.lookupConstructor env n) ^ "_" ^ Int.toString n)
-    handle CjrEnv.UnboundNamed _ => string ("__lwc_UNBOUND_" ^ Int.toString n)
+    string ("__uwc_" ^ #1 (E.lookupConstructor env n) ^ "_" ^ Int.toString n)
+    handle CjrEnv.UnboundNamed _ => string ("__uwc_UNBOUND_" ^ Int.toString n)
 
 fun p_pat_preamble env (p, _) =
     case p of
@@ -116,7 +116,7 @@
                   env)
       | PVar (x, t) => (box [p_typ env t,
                              space,
-                             string "__lwr_",
+                             string "__uwr_",
                              string x,
                              string "_",
                              string (Int.toString (E.countERels env)),
@@ -139,14 +139,14 @@
 fun p_patCon env pc =
     case pc of
         PConVar n => p_con_named env n
-      | PConFfi {mod = m, con, ...} => string ("lw_" ^ m ^ "_" ^ con)
+      | PConFfi {mod = m, con, ...} => string ("uw_" ^ m ^ "_" ^ con)
 
 fun p_pat (env, exit, depth) (p, _) =
     case p of
         PWild =>
         (box [], env)
       | PVar (x, t) =>
-        (box [string "__lwr_",
+        (box [string "__uwr_",
               string x,
               string "_",
               string (Int.toString (E.countERels env)),
@@ -198,10 +198,10 @@
                                           let
                                               val (x, to, _) = E.lookupConstructor env n
                                           in
-                                              ("lw_" ^ x, to)
+                                              ("uw_" ^ x, to)
                                           end
                                         | PConFfi {mod = m, con, arg, ...} =>
-                                          ("lw_" ^ m ^ "_" ^ con, arg)
+                                          ("uw_" ^ m ^ "_" ^ con, arg)
 
                         val t = case to of
                                     NONE => raise Fail "CjrPrint: Constructor mismatch"
@@ -286,7 +286,7 @@
                                                        space,
                                                        string "disc",
                                                        string (Int.toString depth),
-                                                       string ".__lwf_",
+                                                       string ".__uwf_",
                                                        string x,
                                                        string ";",
                                                        newline,
@@ -379,21 +379,21 @@
             val (x, _, dn) = E.lookupConstructor env n
             val (dx, _) = E.lookupDatatype env dn
         in
-            ("__lwd_" ^ dx ^ "_" ^ Int.toString dn,
-             "__lwc_" ^ x ^ "_" ^ Int.toString n,
-             "lw_" ^ x)
+            ("__uwd_" ^ dx ^ "_" ^ Int.toString dn,
+             "__uwc_" ^ x ^ "_" ^ Int.toString n,
+             "uw_" ^ x)
         end
       | PConFfi {mod = m, datatyp, con, ...} =>
-        ("lw_" ^ m ^ "_" ^ datatyp,
-         "lw_" ^ m ^ "_" ^ con,
-         "lw_" ^ con)
+        ("uw_" ^ m ^ "_" ^ datatyp,
+         "uw_" ^ m ^ "_" ^ con,
+         "uw_" ^ con)
 
 fun p_unsql env (tAll as (t, loc)) e =
     case t of
-        TFfi ("Basis", "int") => box [string "lw_Basis_stringToInt_error(ctx, ", e, string ")"]
-      | TFfi ("Basis", "float") => box [string "lw_Basis_stringToFloat_error(ctx, ", e, string ")"]
-      | TFfi ("Basis", "string") => box [string "lw_Basis_strdup(ctx, ", e, string ")"]
-      | TFfi ("Basis", "bool") => box [string "lw_Basis_stringToBool_error(ctx, ", e, string ")"]
+        TFfi ("Basis", "int") => box [string "uw_Basis_stringToInt_error(ctx, ", e, string ")"]
+      | TFfi ("Basis", "float") => box [string "uw_Basis_stringToFloat_error(ctx, ", e, string ")"]
+      | TFfi ("Basis", "string") => box [string "uw_Basis_strdup(ctx, ", e, string ")"]
+      | TFfi ("Basis", "bool") => box [string "uw_Basis_stringToBool_error(ctx, ", e, string ")"]
       | _ => (ErrorMsg.errorAt loc "Don't know how to unmarshal type from SQL";
               Print.eprefaces' [("Type", p_typ env tAll)];
               string "ERROR")
@@ -406,10 +406,10 @@
 
 fun p_sql_type t =
     string (case t of
-                Int => "lw_Basis_int"
-              | Float => "lw_Basis_float"
-              | String => "lw_Basis_string"
-              | Bool => "lw_Basis_bool")
+                Int => "uw_Basis_int"
+              | Float => "uw_Basis_float"
+              | String => "uw_Basis_string"
+              | Bool => "uw_Basis_bool")
 
 fun getPargs (e, _) =
     case e of
@@ -425,17 +425,17 @@
 
 fun p_ensql t e =
     case t of
-        Int => box [string "lw_Basis_attrifyInt(ctx, ", e, string ")"]
-      | Float => box [string "lw_Basis_attrifyFloat(ctx, ", e, string ")"]
+        Int => box [string "uw_Basis_attrifyInt(ctx, ", e, string ")"]
+      | Float => box [string "uw_Basis_attrifyFloat(ctx, ", e, string ")"]
       | String => e
       | Bool => box [string "(", e, string " ? \"TRUE\" : \"FALSE\")"]
 
 fun p_ensql_len t e =
     case t of
-        Int => string "sizeof(lw_Basis_int)"
-      | Float => string "sizeof(lw_Basis_float)"
+        Int => string "sizeof(uw_Basis_int)"
+      | Float => string "sizeof(uw_Basis_float)"
       | String => box [string "strlen(", e, string ")"]
-      | Bool => string "sizeof(lw_Basis_bool)"
+      | Bool => string "sizeof(uw_Basis_bool)"
 
 fun p_exp' par env (e, loc) =
     case e of
@@ -465,7 +465,7 @@
                           space,
                           string "=",
                           space,
-                          string "lw_malloc(ctx, sizeof(",
+                          string "uw_malloc(ctx, sizeof(",
                           p_typ env t,
                           string "));",
                           newline,
@@ -493,7 +493,7 @@
                  space,
                  string "=",
                  space,
-                 string "lw_malloc(ctx, sizeof(struct ",
+                 string "uw_malloc(ctx, sizeof(struct ",
                  string xd,
                  string "));",
                  newline,
@@ -531,7 +531,7 @@
                        space,
                        string "=",
                        space,
-                       string "lw_malloc(ctx, sizeof(",
+                       string "uw_malloc(ctx, sizeof(",
                        p_typ env t,
                        string "));",
                        newline,
@@ -545,7 +545,7 @@
                        newline,
                        string "})"])
 
-      | EFfi (m, x) => box [string "lw_", string m, string "_", string x]
+      | EFfi (m, x) => box [string "uw_", string m, string "_", string x]
       | EError (e, t) =>
         box [string "({",
              newline,
@@ -553,7 +553,7 @@
              space,
              string "tmp;",
              newline,
-             string "lw_error(ctx, FATAL, \"",
+             string "uw_error(ctx, FATAL, \"",
              string (ErrorMsg.spanToString loc),
              string ": %s\", ",
              p_exp env e,
@@ -562,7 +562,7 @@
              string "tmp;",
              newline,
              string "})"]
-      | EFfiApp (m, x, es) => box [string "lw_",
+      | EFfiApp (m, x, es) => box [string "uw_",
                                    string m,
                                    string "_",
                                    string x,
@@ -589,7 +589,7 @@
                                  space,
                                  string "struct",
                                  space,
-                                 string ("__lws_" ^ Int.toString i),
+                                 string ("__uws_" ^ Int.toString i),
                                  space,
                                  string "tmp",
                                  space,
@@ -605,7 +605,7 @@
                                  string "})" ]
       | EField (e, x) =>
         box [p_exp' true env e,
-             string ".__lwf_",
+             string ".__uwf_",
              string x]
 
       | ECase (e, pes, {disc, result}) =>
@@ -665,7 +665,7 @@
                  string "result;",
                  newline,
                  body,
-                 string "lw_error(ctx, FATAL, \"",
+                 string "uw_error(ctx, FATAL, \"",
                  string (ErrorMsg.spanToString loc),
                  string ": pattern match failure\");",
                  newline,
@@ -677,9 +677,9 @@
                  string "})"]
         end
 
-      | EWrite e => box [string "(lw_write(ctx, ",
+      | EWrite e => box [string "(uw_write(ctx, ",
                          p_exp env e,
-                         string "), lw_unit_v)"]
+                         string "), uw_unit_v)"]
 
       | ESeq (e1, e2) => box [string "(",
                               p_exp env e1,
@@ -691,7 +691,7 @@
                                     newline,
                                     p_typ env t,
                                     space,
-                                    string "__lwr_",
+                                    string "__uwr_",
                                     string x,
                                     string "_",
                                     string (Int.toString (E.countERels env)),
@@ -708,16 +708,16 @@
 
       | EQuery {exps, tables, rnum, state, query, body, initial, prepared} =>
         let
-            val exps = map (fn (x, t) => ("__lwf_" ^ x, t)) exps
+            val exps = map (fn (x, t) => ("__uwf_" ^ x, t)) exps
             val tables = ListUtil.mapConcat (fn (x, xts) =>
-                                                map (fn (x', t) => ("__lwf_" ^ x ^ ".__lwf_" ^ x', t)) xts)
+                                                map (fn (x', t) => ("__uwf_" ^ x ^ ".__uwf_" ^ x', t)) xts)
                                             tables
                                                                                               
             val outputs = exps @ tables
         in
             box [string "({",
                  newline,
-                 string "PGconn *conn = lw_get_db(ctx);",
+                 string "PGconn *conn = uw_get_db(ctx);",
                  newline,
                  case prepared of
                      NONE => box [string "char *query = ",
@@ -766,7 +766,7 @@
                  string "PGresult *res = ",
                  case prepared of
                      NONE => string "PQexecParams(conn, query, 0, NULL, NULL, NULL, NULL, 0);"
-                   | SOME n => box [string "PQexecPrepared(conn, \"lw",
+                   | SOME n => box [string "PQexecPrepared(conn, \"uw",
                                     string (Int.toString n),
                                     string "\", ",
                                     string (Int.toString (length (getPargs query))),
@@ -774,7 +774,7 @@
                  newline,
                  newline,
 
-                 string "if (res == NULL) lw_error(ctx, FATAL, \"Out of memory allocating query result.\");",
+                 string "if (res == NULL) uw_error(ctx, FATAL, \"Out of memory allocating query result.\");",
                  newline,
                  newline,
 
@@ -782,7 +782,7 @@
                  newline,
                  box [string "PQclear(res);",
                       newline,
-                      string "lw_error(ctx, FATAL, \"",
+                      string "uw_error(ctx, FATAL, \"",
                       string (ErrorMsg.spanToString loc),
                       string ": Query failed:\\n%s\\n%s\", ",
                       case prepared of
@@ -800,16 +800,16 @@
                  newline,
                  box [string "struct",
                       space,
-                      string "__lws_",
+                      string "__uws_",
                       string (Int.toString rnum),
                       space,
-                      string "__lwr_r_",
+                      string "__uwr_r_",
                       string (Int.toString (E.countERels env)),
                       string ";",
                       newline,
                       p_typ env state,
                       space,
-                      string "__lwr_acc_",
+                      string "__uwr_acc_",
                       string (Int.toString (E.countERels env + 1)),
                       space,
                       string "=",
@@ -820,7 +820,7 @@
 
                       p_list_sepi (box []) (fn i =>
                                             fn (proj, t) =>
-                                               box [string "__lwr_r_",
+                                               box [string "__uwr_r_",
                                                     string (Int.toString (E.countERels env)),
                                                     string ".",
                                                     string proj,
@@ -860,7 +860,7 @@
       | EDml {dml, prepared} =>
         box [string "({",
              newline,
-             string "PGconn *conn = lw_get_db(ctx);",
+             string "PGconn *conn = uw_get_db(ctx);",
              newline,
              case prepared of
                  NONE => box [string "char *dml = ",
@@ -900,7 +900,7 @@
              string "PGresult *res = ",
              case prepared of
                  NONE => string "PQexecParams(conn, dml, 0, NULL, NULL, NULL, NULL, 0);"
-               | SOME n => box [string "PQexecPrepared(conn, \"lw",
+               | SOME n => box [string "PQexecPrepared(conn, \"uw",
                                 string (Int.toString n),
                                 string "\", ",
                                 string (Int.toString (length (getPargs dml))),
@@ -908,7 +908,7 @@
              newline,
              newline,
 
-             string "if (res == NULL) lw_error(ctx, FATAL, \"Out of memory allocating DML result.\");",
+             string "if (res == NULL) uw_error(ctx, FATAL, \"Out of memory allocating DML result.\");",
              newline,
              newline,
 
@@ -916,7 +916,7 @@
              newline,
              box [string "PQclear(res);",
                   newline,
-                  string "lw_error(ctx, FATAL, \"",
+                  string "uw_error(ctx, FATAL, \"",
                   string (ErrorMsg.spanToString loc),
                   string ": DML failed:\\n%s\\n%s\", ",
                   case prepared of
@@ -930,7 +930,7 @@
 
              string "PQclear(res);",
              newline,
-             string "lw_unit_v;",
+             string "uw_unit_v;",
              newline,
              string "})"]
 
@@ -945,10 +945,10 @@
              space,
              p_typ env ran,
              space,
-             string ("__lwn_" ^ fx ^ "_" ^ Int.toString n),
+             string ("__uwn_" ^ fx ^ "_" ^ Int.toString n),
              string "(",
              p_list_sep (box [string ",", space]) (fn x => x)
-                        (string "lw_context ctx" :: ListUtil.mapi (fn (i, (_, dom)) =>
+                        (string "uw_context ctx" :: ListUtil.mapi (fn (i, (_, dom)) =>
                                                                       box [p_typ env dom,
                                                                            space,
                                                                            p_rel env' (nargs - i - 1)]) args),
@@ -971,13 +971,13 @@
         in
             box [string "struct",
                  space,
-                 string ("__lws_" ^ Int.toString n),
+                 string ("__uws_" ^ Int.toString n),
                  space,
                  string "{",
                  newline,
                  p_list_sep (box []) (fn (x, t) => box [p_typ env t,
                                                         space,
-                                                        string "__lwf_",
+                                                        string "__uwf_",
                                                         string x,
                                                         string ";",
                                                         newline]) xts,
@@ -986,11 +986,11 @@
       | DDatatype (Enum, x, n, xncs) =>
         box [string "enum",
              space,
-             string ("__lwe_" ^ x ^ "_" ^ Int.toString n),
+             string ("__uwe_" ^ x ^ "_" ^ Int.toString n),
              space,
              string "{",
              space,
-             p_list_sep (box [string ",", space]) (fn (x, n, _) => string ("__lwc_" ^ x ^ "_" ^ Int.toString n)) xncs,
+             p_list_sep (box [string ",", space]) (fn (x, n, _) => string ("__uwc_" ^ x ^ "_" ^ Int.toString n)) xncs,
              space,
              string "};"]
       | DDatatype (Option, _, _, _) => box []
@@ -1001,24 +1001,24 @@
         in
             box [string "enum",
                  space,
-                 string ("__lwe_" ^ x ^ "_" ^ Int.toString n),
+                 string ("__uwe_" ^ x ^ "_" ^ Int.toString n),
                  space,
                  string "{",
                  space,
-                 p_list_sep (box [string ",", space]) (fn (x, n, _) => string ("__lwc_" ^ x ^ "_" ^ Int.toString n)) xncs,
+                 p_list_sep (box [string ",", space]) (fn (x, n, _) => string ("__uwc_" ^ x ^ "_" ^ Int.toString n)) xncs,
                  space,
                  string "};",
                  newline,
                  newline,
                  string "struct",
                  space,
-                 string ("__lwd_" ^ x ^ "_" ^ Int.toString n),
+                 string ("__uwd_" ^ x ^ "_" ^ Int.toString n),
                  space,
                  string "{",
                  newline,
                  string "enum",
                  space,
-                 string ("__lwe_" ^ x ^ "_" ^ Int.toString n),
+                 string ("__uwe_" ^ x ^ "_" ^ Int.toString n),
                  space,
                  string "tag;",
                  newline,
@@ -1030,7 +1030,7 @@
                                 newline,
                                 p_list_sep newline (fn (x, n, t) => box [p_typ env t,
                                                                          space,
-                                                                         string ("lw_" ^ x),
+                                                                         string ("uw_" ^ x),
                                                                          string ";"]) xncsArgs,
                                 newline,
                                 string "}",
@@ -1045,7 +1045,7 @@
       | DVal (x, n, t, e) =>
         box [p_typ env t,
              space,
-             string ("__lwn_" ^ x ^ "_" ^ Int.toString n),
+             string ("__uwn_" ^ x ^ "_" ^ Int.toString n),
              space,
              string "=",
              space,
@@ -1061,8 +1061,8 @@
                                              space,
                                              p_typ env ran,
                                              space,
-                                             string ("__lwn_" ^ fx ^ "_" ^ Int.toString n),
-                                             string "(lw_context,",
+                                             string ("__uwn_" ^ fx ^ "_" ^ Int.toString n),
+                                             string "(uw_context,",
                                              space,
                                              p_list_sep (box [string ",", space])
                                                         (fn (_, dom) => p_typ env dom) args,
@@ -1075,18 +1075,18 @@
                               string x,
                               string " */",
                               newline]
-      | DDatabase s => box [string "static void lw_db_validate(lw_context);",
+      | DDatabase s => box [string "static void uw_db_validate(uw_context);",
                             newline,
-                            string "static void lw_db_prepare(lw_context);",
+                            string "static void uw_db_prepare(uw_context);",
                             newline,
                             newline,
-                            string "void lw_db_init(lw_context ctx) {",
+                            string "void uw_db_init(uw_context ctx) {",
                             newline,
                             string "PGconn *conn = PQconnectdb(\"",
                             string (String.toString s),
                             string "\");",
                             newline,
-                            string "if (conn == NULL) lw_error(ctx, BOUNDED_RETRY, ",
+                            string "if (conn == NULL) uw_error(ctx, BOUNDED_RETRY, ",
                             string "\"libpq can't allocate a connection.\");",
                             newline,
                             string "if (PQstatus(conn) != CONNECTION_OK) {",
@@ -1099,38 +1099,38 @@
                                  newline,
                                  string "PQfinish(conn);",
                                  newline,
-                                 string "lw_error(ctx, BOUNDED_RETRY, ",
+                                 string "uw_error(ctx, BOUNDED_RETRY, ",
                                  string "\"Connection to Postgres server failed: %s\", msg);"],
                             newline,
                             string "}",
                             newline,
-                            string "lw_set_db(ctx, conn);",
+                            string "uw_set_db(ctx, conn);",
                             newline,
-                            string "lw_db_validate(ctx);",
+                            string "uw_db_validate(ctx);",
                             newline,
-                            string "lw_db_prepare(ctx);",
+                            string "uw_db_prepare(ctx);",
                             newline,
                             string "}",
                             newline,
                             newline,
-                            string "void lw_db_close(lw_context ctx) {",
+                            string "void uw_db_close(uw_context ctx) {",
                             newline,
-                            string "PQfinish(lw_get_db(ctx));",
+                            string "PQfinish(uw_get_db(ctx));",
                             newline,
                             string "}",
                             newline]
 
       | DPreparedStatements ss =>
-        box [string "static void lw_db_prepare(lw_context ctx) {",
+        box [string "static void uw_db_prepare(uw_context ctx) {",
              newline,
-             string "PGconn *conn = lw_get_db(ctx);",
+             string "PGconn *conn = uw_get_db(ctx);",
              newline,
              string "PGresult *res;",
              newline,
              newline,
 
              p_list_sepi newline (fn i => fn (s, n) =>
-                                             box [string "res = PQprepare(conn, \"lw",
+                                             box [string "res = PQprepare(conn, \"uw",
                                                   string (Int.toString i),
                                                   string "\", \"",
                                                   string (String.toString s),
@@ -1150,7 +1150,7 @@
                                                        newline,
                                                        string "PQfinish(conn);",
                                                        newline,
-                                                       string "lw_error(ctx, FATAL, \"Unable to create prepared statement:\\n",
+                                                       string "uw_error(ctx, FATAL, \"Unable to create prepared statement:\\n",
                                                        string (String.toString s),
                                                        string "\\n%s\", msg);",
                                                        newline],
@@ -1314,9 +1314,9 @@
 
         fun unurlify (t, loc) =
             case t of
-                TFfi (m, t) => string ("lw_" ^ m ^ "_unurlify" ^ capitalize t ^ "(ctx, &request)")
+                TFfi (m, t) => string ("uw_" ^ m ^ "_unurlify" ^ capitalize t ^ "(ctx, &request)")
 
-              | TRecord 0 => string "lw_unit_v"
+              | TRecord 0 => string "uw_unit_v"
               | TRecord i =>
                 let
                     val xts = E.lookupStruct env i
@@ -1335,7 +1335,7 @@
                                            newline]) xts),
                          string "struct",
                          space,
-                         string "__lws_",
+                         string "__uws_",
                          string (Int.toString i),
                          space,
                          string "tmp",
@@ -1359,7 +1359,7 @@
 
                     fun doEm xncs =
                         case xncs of
-                            [] => string ("(lw_error(ctx, FATAL, \"Error unurlifying datatype " ^ x ^ "\"), (enum __lwe_"
+                            [] => string ("(uw_error(ctx, FATAL, \"Error unurlifying datatype " ^ x ^ "\"), (enum __uwe_"
                                           ^ x ^ "_" ^ Int.toString i ^ ")0)")
                           | (x', n, to) :: rest =>
                             box [string "((!strncmp(request, \"",
@@ -1370,7 +1370,7 @@
                                  string (Int.toString (size x')),
                                  string "] == 0 || request[",
                                  string (Int.toString (size x')),
-                                 string ("] == '/')) ? __lwc_" ^ x' ^ "_" ^ Int.toString n),
+                                 string ("] == '/')) ? __uwc_" ^ x' ^ "_" ^ Int.toString n),
                                  space,
                                  string ":",
                                  space,
@@ -1434,7 +1434,7 @@
                                        space,
                                        string "=",
                                        space,
-                                       string "lw_malloc(ctx, sizeof(",
+                                       string "uw_malloc(ctx, sizeof(",
                                        p_typ env t,
                                        string "));",
                                        newline,
@@ -1452,7 +1452,7 @@
                          newline,
                          string ":",
                          space,
-                         string ("(lw_error(ctx, FATAL, \"Error unurlifying datatype " ^ x ^ "\"), NULL))))")]
+                         string ("(uw_error(ctx, FATAL, \"Error unurlifying datatype " ^ x ^ "\"), NULL))))")]
                 end                     
 
               | TDatatype (Default, i, _) =>
@@ -1461,7 +1461,7 @@
 
                     fun doEm xncs =
                         case xncs of
-                            [] => string ("(lw_error(ctx, FATAL, \"Error unurlifying datatype " ^ x ^ "\"), NULL)")
+                            [] => string ("(uw_error(ctx, FATAL, \"Error unurlifying datatype " ^ x ^ "\"), NULL)")
                           | (x', n, to) :: rest =>
                             box [string "((!strncmp(request, \"",
                                  string x',
@@ -1475,9 +1475,9 @@
                                  newline,
                                  string "struct",
                                  space,
-                                 string ("__lwd_" ^ x ^ "_" ^ Int.toString i),
+                                 string ("__uwd_" ^ x ^ "_" ^ Int.toString i),
                                  space,
-                                 string "*tmp = lw_malloc(ctx, sizeof(struct __lwd_",
+                                 string "*tmp = uw_malloc(ctx, sizeof(struct __uwd_",
                                  string x,
                                  string "_",
                                  string (Int.toString i),
@@ -1487,7 +1487,7 @@
                                  space,
                                  string "=",
                                  space,
-                                 string ("__lwc_" ^ x' ^ "_" ^ Int.toString n),
+                                 string ("__uwc_" ^ x' ^ "_" ^ Int.toString n),
                                  string ";",
                                  newline,
                                  string "request",
@@ -1501,7 +1501,7 @@
                                  newline,
                                  case to of
                                      NONE => box []
-                                   | SOME t => box [string "tmp->data.lw_",
+                                   | SOME t => box [string "tmp->data.uw_",
                                                     string x',
                                                     space,
                                                     string "=",
@@ -1539,7 +1539,7 @@
                                 (List.take (ts, length ts - 2),
                                  box [box (map (fn (x, t) => box [p_typ env t,
                                                                   space,
-                                                                  string "lw_input_",
+                                                                  string "uw_input_",
                                                                   string x,
                                                                   string ";",
                                                                   newline]) xts),
@@ -1554,7 +1554,7 @@
                                                                    (TFfi ("Basis", "bool"), _) => "optional_"
                                                                  | _ => ""
                                                    in
-                                                       box [string "request = lw_get_",
+                                                       box [string "request = uw_get_",
                                                             string f,
                                                             string "input(ctx, ",
                                                             string (Int.toString n),
@@ -1570,7 +1570,7 @@
                                                             newline,
                                                             string "}",
                                                             newline,
-                                                            string "lw_input_",
+                                                            string "uw_input_",
                                                             string x,
                                                             space,
                                                             string "=",
@@ -1579,14 +1579,14 @@
                                                             string ";",
                                                             newline]
                                                    end) xts),
-                                      string "struct __lws_",
+                                      string "struct __uws_",
                                       string (Int.toString i),
                                       space,
-                                      string "lw_inputs",
+                                      string "uw_inputs",
                                       space,
                                       string "= {",
                                       newline,
-                                      box (map (fn (x, _) => box [string "lw_input_",
+                                      box (map (fn (x, _) => box [string "uw_input_",
                                                                   string x,
                                                                   string ",",
                                                                   newline]) xts),
@@ -1594,7 +1594,7 @@
                                       newline],
                                  box [string ",",
                                       space,
-                                      string "lw_inputs"])
+                                      string "uw_inputs"])
                             end
 
                           | _ => raise Fail "CjrPrint: Last argument to an action isn't a record"
@@ -1635,7 +1635,7 @@
                                      (string "ctx"
                                       :: ListUtil.mapi (fn (i, _) => string ("arg" ^ Int.toString i)) ts),
                           inputsVar,
-                          string ", lw_unit_v);",
+                          string ", uw_unit_v);",
                           newline,
                           string "return;",
                           newline,
@@ -1651,9 +1651,9 @@
                                        | _ => NONE) ds
 
         val validate =
-            box [string "static void lw_db_validate(lw_context ctx) {",
+            box [string "static void uw_db_validate(uw_context ctx) {",
                  newline,
-                 string "PGconn *conn = lw_get_db(ctx);",
+                 string "PGconn *conn = uw_get_db(ctx);",
                  newline,
                  string "PGresult *res;",
                  newline,
@@ -1669,7 +1669,7 @@
                                                             "') AND (",
                                                             String.concatWith " OR "
                                                               (map (fn (x, t) =>
-                                                                       String.concat ["(attname = 'lw_",
+                                                                       String.concat ["(attname = 'uw_",
                                                                                       CharVector.map
                                                                                           Char.toLower x,
                                                                                       "' AND atttypid = (SELECT oid FROM pg_type",
@@ -1691,7 +1691,7 @@
                                          newline,
                                          box [string "PQfinish(conn);",
                                               newline,
-                                              string "lw_error(ctx, FATAL, \"Out of memory allocating query result.\");",
+                                              string "uw_error(ctx, FATAL, \"Out of memory allocating query result.\");",
                                               newline],
                                          string "}",
                                          newline,
@@ -1708,7 +1708,7 @@
                                               newline,
                                               string "PQfinish(conn);",
                                               newline,
-                                              string "lw_error(ctx, FATAL, \"Query failed:\\n",
+                                              string "uw_error(ctx, FATAL, \"Query failed:\\n",
                                               string q,
                                               string "\\n%s\", msg);",
                                               newline],
@@ -1721,7 +1721,7 @@
                                               newline,
                                               string "PQfinish(conn);",
                                               newline,
-                                              string "lw_error(ctx, FATAL, \"Table '",
+                                              string "uw_error(ctx, FATAL, \"Table '",
                                               string s,
                                               string "' does not exist.\");",
                                               newline],
@@ -1740,7 +1740,7 @@
                                          newline,
                                          box [string "PQfinish(conn);",
                                               newline,
-                                              string "lw_error(ctx, FATAL, \"Out of memory allocating query result.\");",
+                                              string "uw_error(ctx, FATAL, \"Out of memory allocating query result.\");",
                                               newline],
                                          string "}",
                                          newline,
@@ -1757,7 +1757,7 @@
                                               newline,
                                               string "PQfinish(conn);",
                                               newline,
-                                              string "lw_error(ctx, FATAL, \"Query failed:\\n",
+                                              string "uw_error(ctx, FATAL, \"Query failed:\\n",
                                               string q',
                                               string "\\n%s\", msg);",
                                               newline],
@@ -1772,7 +1772,7 @@
                                               newline,
                                               string "PQfinish(conn);",
                                               newline,
-                                              string "lw_error(ctx, FATAL, \"Table '",
+                                              string "uw_error(ctx, FATAL, \"Table '",
                                               string s,
                                               string "' has the wrong column types.\");",
                                               newline],
@@ -1792,7 +1792,7 @@
                                          newline,
                                          box [string "PQfinish(conn);",
                                               newline,
-                                              string "lw_error(ctx, FATAL, \"Out of memory allocating query result.\");",
+                                              string "uw_error(ctx, FATAL, \"Out of memory allocating query result.\");",
                                               newline],
                                          string "}",
                                          newline,
@@ -1809,7 +1809,7 @@
                                               newline,
                                               string "PQfinish(conn);",
                                               newline,
-                                              string "lw_error(ctx, FATAL, \"Query failed:\\n",
+                                              string "uw_error(ctx, FATAL, \"Query failed:\\n",
                                               string q'',
                                               string "\\n%s\", msg);",
                                               newline],
@@ -1824,7 +1824,7 @@
                                               newline,
                                               string "PQfinish(conn);",
                                               newline,
-                                              string "lw_error(ctx, FATAL, \"Table '",
+                                              string "uw_error(ctx, FATAL, \"Table '",
                                               string s,
                                               string "' has extra columns.\");",
                                               newline],
@@ -1850,18 +1850,18 @@
              newline,
              p_list_sep newline (fn x => x) pds,
              newline,
-             string "int lw_inputs_len = ",
+             string "int uw_inputs_len = ",
              string (Int.toString (SM.foldl Int.max 0 fnums + 1)),
              string ";",
              newline,
              newline,
-             string "int lw_input_num(char *name) {",
+             string "int uw_input_num(char *name) {",
              newline,
              makeSwitch (fnums, 0),
              string "}",
              newline,
              newline,
-             string "void lw_handle(lw_context ctx, char *request) {",
+             string "void uw_handle(uw_context ctx, char *request) {",
              newline,
              p_list_sep newline (fn x => x) pds',
              newline,
@@ -1883,7 +1883,7 @@
                                                  string s,
                                                  string "(",
                                                  p_list (fn (x, t) =>
-                                                            box [string "lw_",
+                                                            box [string "uw_",
                                                                  string (CharVector.map Char.toLower x),
                                                                  space,
                                                                  p_sqltype env t,
--- a/src/monoize.sml	Sun Sep 07 15:35:08 2008 -0400
+++ b/src/monoize.sml	Sun Sep 07 15:40:42 2008 -0400
@@ -615,7 +615,7 @@
                                           strcat loc [sc "INSERT INTO ",
                                                       (L'.ERel 1, loc),
                                                       sc " (",
-                                                      strcatComma loc (map (fn (x, _) => sc ("lw_" ^ x)) fields),
+                                                      strcatComma loc (map (fn (x, _) => sc ("uw_" ^ x)) fields),
                                                       sc ") VALUES (",
                                                       strcatComma loc (map (fn (x, _) =>
                                                                                (L'.EField ((L'.ERel 0, loc),
@@ -641,7 +641,7 @@
                                                                 (L'.ERel 1, loc),
                                                                 sc " AS T SET ",
                                                                 strcatComma loc (map (fn (x, _) =>
-                                                                                         strcat loc [sc ("lw_" ^ x
+                                                                                         strcat loc [sc ("uw_" ^ x
                                                                                                          ^ " = "),
                                                                                                      (L'.EField
                                                                                                           ((L'.ERel 2,
@@ -801,7 +801,7 @@
                                                             @ map (fn (x, xts) =>
                                                                       strcatComma loc
                                                                                   (map (fn (x', _) =>
-                                                                                           sc (x ^ ".lw_" ^ x'))
+                                                                                           sc (x ^ ".uw_" ^ x'))
                                                                                        xts)) stables),
                                            sc " FROM ",
                                            strcatComma loc (map (fn (x, _) => strcat loc [(L'.EField (gf "From", x), loc),
@@ -828,7 +828,7 @@
                                                strcatComma loc (map (fn (x, xts) =>
                                                                         strcatComma loc
                                                                                     (map (fn (x', _) =>
-                                                                                             sc (x ^ ".lw_" ^ x'))
+                                                                                             sc (x ^ ".uw_" ^ x'))
                                                                                          xts)) grouped)
                                                ],
 
@@ -1049,7 +1049,7 @@
                _), _),
               _), _),
              (L.CName tab, _)), _),
-            (L.CName field, _)) => ((L'.EPrim (Prim.String (tab ^ ".lw_" ^ field)), loc), fm)
+            (L.CName field, _)) => ((L'.EPrim (Prim.String (tab ^ ".uw_" ^ field)), loc), fm)
 
           | L.ECApp (
             (L.ECApp (
@@ -1604,7 +1604,7 @@
             let
                 val t = (L.CFfi ("Basis", "string"), loc)
                 val t' = (L'.TFfi ("Basis", "string"), loc)
-                val s = "lw_" ^ s
+                val s = "uw_" ^ s
                 val e = (L'.EPrim (Prim.String s), loc)
 
                 val xts = map (fn (x, t) => (monoName env x, monoType env t)) xts