comparison src/c/cgi.c @ 1997:c93fbd139732

Define uw_loggers structure, allow FFI code to access it
author Sergey Mironov <grrwlf@gmail.com>
date Wed, 26 Feb 2014 08:21:52 +0000
parents 9f3597979e98
children
comparison
equal deleted inserted replaced
1996:582ea3a4d622 1997:c93fbd139732
58 } 58 }
59 59
60 static void log_debug(void *data, const char *fmt, ...) { 60 static void log_debug(void *data, const char *fmt, ...) {
61 } 61 }
62 62
63 static uw_loggers ls = {NULL, log_error, log_debug};
64
63 int main(int argc, char *argv[]) { 65 int main(int argc, char *argv[]) {
64 uw_context ctx = uw_request_new_context(0, &uw_application, NULL, log_error, log_debug); 66 uw_context ctx = uw_request_new_context(0, &uw_application, &ls);
65 uw_request_context rc = uw_new_request_context(); 67 uw_request_context rc = uw_new_request_context();
66 request_result rr; 68 request_result rr;
67 char *method = getenv("REQUEST_METHOD"), 69 char *method = getenv("REQUEST_METHOD"),
68 *path = getenv("SCRIPT_NAME"), *path_info = getenv("PATH_INFO"), 70 *path = getenv("SCRIPT_NAME"), *path_info = getenv("PATH_INFO"),
69 *query_string = getenv("QUERY_STRING"); 71 *query_string = getenv("QUERY_STRING");
106 } 108 }
107 109
108 uw_set_on_success(""); 110 uw_set_on_success("");
109 uw_set_headers(ctx, get_header, NULL); 111 uw_set_headers(ctx, get_header, NULL);
110 uw_set_env(ctx, get_env, NULL); 112 uw_set_env(ctx, get_env, NULL);
111 uw_request_init(&uw_application, NULL, log_error, log_debug); 113 uw_request_init(&uw_application, &ls);
112 114
113 body[body_pos] = 0; 115 body[body_pos] = 0;
114 rr = uw_request(rc, ctx, method, path, query_string, body, body_pos, 116 rr = uw_request(rc, ctx, method, path, query_string, body, body_pos,
115 on_success, on_failure, 117 on_success, on_failure,
116 NULL, log_error, log_debug, 118 NULL, log_error, log_debug,