Mercurial > urweb
comparison src/c/static.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 | 2d9f831d45c9 |
children | 8ecbd1100227 |
comparison
equal
deleted
inserted
replaced
1996:582ea3a4d622 | 1997:c93fbd139732 |
---|---|
5 | 5 |
6 #include "urweb.h" | 6 #include "urweb.h" |
7 | 7 |
8 extern uw_app uw_application; | 8 extern uw_app uw_application; |
9 | 9 |
10 static void log_debug(void *data, const char *fmt, ...) { | 10 static void log_(void *data, const char *fmt, ...) { |
11 va_list ap; | 11 va_list ap; |
12 va_start(ap, fmt); | 12 va_start(ap, fmt); |
13 | 13 |
14 vprintf(fmt, ap); | 14 vprintf(fmt, ap); |
15 } | 15 } |
16 | |
17 static uw_loggers loggers = {NULL, log_, log_}; | |
16 | 18 |
17 int main(int argc, char *argv[]) { | 19 int main(int argc, char *argv[]) { |
18 uw_context ctx; | 20 uw_context ctx; |
19 failure_kind fk; | 21 failure_kind fk; |
20 | 22 |
21 if (argc != 2) { | 23 if (argc != 2) { |
22 fprintf(stderr, "Pass exactly one argument: the URI to run\n"); | 24 fprintf(stderr, "Pass exactly one argument: the URI to run\n"); |
23 return 1; | 25 return 1; |
24 } | 26 } |
25 | 27 |
26 ctx = uw_init(0, NULL, log_debug); | 28 ctx = uw_init(0, &loggers); |
27 uw_set_app(ctx, &uw_application); | 29 uw_set_app(ctx, &uw_application); |
28 uw_initialize(ctx); | 30 uw_initialize(ctx); |
29 | 31 |
30 while (1) { | 32 while (1) { |
31 fk = uw_begin(ctx, argv[1]); | 33 fk = uw_begin(ctx, argv[1]); |