comparison src/c/cgi.c @ 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 305bc0a431de
children 0cee0c8d8c37
comparison
equal deleted inserted replaced
1093:8d3aa6c7cee0 1094:db52c32dbe42
3 #include <string.h> 3 #include <string.h>
4 #include <stdlib.h> 4 #include <stdlib.h>
5 #include <unistd.h> 5 #include <unistd.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 7
8 #include "urweb.h"
8 #include "request.h" 9 #include "request.h"
10
11 extern uw_app uw_application;
9 12
10 static char *uppercased; 13 static char *uppercased;
11 static size_t uppercased_len; 14 static size_t uppercased_len;
12 15
13 static char *get_header(void *data, const char *h) { 16 static char *get_header(void *data, const char *h) {
49 52
50 static void log_debug(void *data, const char *fmt, ...) { 53 static void log_debug(void *data, const char *fmt, ...) {
51 } 54 }
52 55
53 int main(int argc, char *argv[]) { 56 int main(int argc, char *argv[]) {
54 uw_context ctx = uw_request_new_context(NULL, log_error, log_debug); 57 uw_context ctx = uw_request_new_context(&uw_application, NULL, log_error, log_debug);
55 uw_request_context rc = uw_new_request_context(); 58 uw_request_context rc = uw_new_request_context();
56 request_result rr; 59 request_result rr;
57 char *method = getenv("REQUEST_METHOD"), 60 char *method = getenv("REQUEST_METHOD"),
58 *path = getenv("SCRIPT_NAME"), *path_info = getenv("PATH_INFO"), 61 *path = getenv("SCRIPT_NAME"), *path_info = getenv("PATH_INFO"),
59 *query_string = getenv("QUERY_STRING"); 62 *query_string = getenv("QUERY_STRING");
95 exit(1); 98 exit(1);
96 } 99 }
97 100
98 uw_set_on_success(""); 101 uw_set_on_success("");
99 uw_set_headers(ctx, get_header, NULL); 102 uw_set_headers(ctx, get_header, NULL);
100 uw_request_init(NULL, log_error, log_debug); 103 uw_request_init(&uw_application, NULL, log_error, log_debug);
101 104
102 body[body_pos] = 0; 105 body[body_pos] = 0;
103 rr = uw_request(rc, ctx, method, path, query_string, body, body_pos, 106 rr = uw_request(rc, ctx, method, path, query_string, body, body_pos,
104 on_success, on_failure, 107 on_success, on_failure,
105 NULL, log_error, log_debug, 108 NULL, log_error, log_debug,