diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-07-22 15:12:20 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-07-22 15:12:20 -0400 |
commit | e8ceaa0ae216c7c85e810998ab97989e7a83c82d (patch) | |
tree | f26deeee6825b28bb3e6005523f887de3c1a79a4 /src/c/driver.c | |
parent | b1997d2e699e92e83f7130b7b4a4c5467dcdcd27 (diff) |
Simple forms work
Diffstat (limited to 'src/c/driver.c')
-rw-r--r-- | src/c/driver.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/c/driver.c b/src/c/driver.c index ac0b0c86..af3bca08 100644 --- a/src/c/driver.c +++ b/src/c/driver.c @@ -86,9 +86,11 @@ static void *worker(void *data) { *back = 0; if (s = strstr(buf, "\r\n\r\n")) { - char *cmd, *path; + char *cmd, *path, *inputs; *s = 0; + + printf("Read: %s\n", buf); if (!(s = strstr(buf, "\r\n"))) { fprintf(stderr, "No newline in buf\n"); @@ -114,9 +116,33 @@ static void *worker(void *data) { break; } + if (inputs = strchr(path, '?')) { + char *name, *value; + *inputs++ = 0; + + while (*inputs) { + name = inputs; + if (value = strchr(inputs, '=')) { + *value++ = 0; + if (inputs = strchr(value, '&')) + *inputs++ = 0; + else + inputs = strchr(value, 0); + lw_set_input(ctx, name, value); + } + else if (inputs = strchr(value, '&')) { + *inputs++ = 0; + lw_set_input(ctx, name, ""); + } + else { + inputs = strchr(value, 0); + lw_set_input(ctx, name, ""); + } + } + } + printf("Serving URI %s....\n", path); - ctx = lw_init(1024, 1024); 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>"); |