diff src/c/urweb.c @ 1023:e46227efcbba

Bidding interface
author Adam Chlipala <adamc@hcoop.net>
date Sun, 01 Nov 2009 10:20:20 -0500
parents 16f7cb0891b6
children 7facf72aaf0a
line wrap: on
line diff
--- a/src/c/urweb.c	Sat Oct 31 15:51:50 2009 -0400
+++ b/src/c/urweb.c	Sun Nov 01 10:20:20 2009 -0500
@@ -1668,14 +1668,16 @@
   return uw_Basis_unurlifyInt(ctx, s);
 }
 
-static uw_Basis_string uw_unurlifyString_to(uw_context ctx, char *r, char *s) {
+static uw_Basis_string uw_unurlifyString_to(int fromClient, uw_context ctx, char *r, char *s) {
   char *s1, *s2 = s;
   int n;
 
-  if (*s2 == '_')
-    ++s2;
-  else if (s2[0] == '%' && s2[1] == '5' && (s2[2] == 'f' || s2[2] == 'F'))
-    s2 += 3;
+  if (!fromClient) {
+    if (*s2 == '_')
+      ++s2;
+    else if (s2[0] == '%' && s2[1] == '5' && (s2[2] == 'f' || s2[2] == 'F'))
+      s2 += 3;
+  }
 
   for (s1 = r; *s2; ++s1, ++s2) {
     char c = *s2;
@@ -1724,7 +1726,21 @@
   uw_check_heap(ctx, len + 1);
 
   r = ctx->heap.front;
-  ctx->heap.front = uw_unurlifyString_to(ctx, ctx->heap.front, *s);
+  ctx->heap.front = uw_unurlifyString_to(0, ctx, ctx->heap.front, *s);
+  *s = new_s;
+  return r;
+}
+
+uw_Basis_string uw_Basis_unurlifyString_fromClient(uw_context ctx, char **s) {
+  char *new_s = uw_unurlify_advance(*s);
+  char *r, *s1, *s2;
+  int len, n;
+
+  len = strlen(*s);
+  uw_check_heap(ctx, len + 1);
+
+  r = ctx->heap.front;
+  ctx->heap.front = uw_unurlifyString_to(1, ctx, ctx->heap.front, *s);
   *s = new_s;
   return r;
 }
@@ -1963,6 +1979,19 @@
     
 }
 
+uw_Basis_string uw_Basis_str1(uw_context ctx, uw_Basis_char ch) {
+  char *r;
+
+  uw_check_heap(ctx, 2);
+  r = ctx->heap.front;
+  r[0] = ch;
+  r[1] = 0;
+
+  ctx->heap.front += 2;
+
+  return r;
+}
+
 uw_Basis_string uw_strdup(uw_context ctx, uw_Basis_string s1) {
   int len = uw_Basis_strlen(ctx, s1) + 1;
   char *s;