comparison src/c/urweb.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 94529780bbcf
children cc7e5d469d1b
comparison
equal deleted inserted replaced
1996:582ea3a4d622 1997:c93fbd139732
458 458
459 int deadline; 459 int deadline;
460 460
461 void *client_data; 461 void *client_data;
462 462
463 void *logger_data; 463 uw_loggers *loggers;
464 uw_logger log_debug;
465 464
466 int isPost, hasPostBody; 465 int isPost, hasPostBody;
467 uw_Basis_postBody postBody; 466 uw_Basis_postBody postBody;
468 uw_Basis_string queryString; 467 uw_Basis_string queryString;
469 468
482 size_t uw_headers_max = SIZE_MAX; 481 size_t uw_headers_max = SIZE_MAX;
483 size_t uw_page_max = SIZE_MAX; 482 size_t uw_page_max = SIZE_MAX;
484 size_t uw_heap_max = SIZE_MAX; 483 size_t uw_heap_max = SIZE_MAX;
485 size_t uw_script_max = SIZE_MAX; 484 size_t uw_script_max = SIZE_MAX;
486 485
487 uw_context uw_init(int id, void *logger_data, uw_logger log_debug) { 486 uw_context uw_init(int id, uw_loggers *lg) {
488 uw_context ctx = malloc(sizeof(struct uw_context)); 487 uw_context ctx = malloc(sizeof(struct uw_context));
489 488
490 ctx->app = NULL; 489 ctx->app = NULL;
491 ctx->id = id; 490 ctx->id = id;
492 491
541 540
542 ctx->deadline = INT_MAX; 541 ctx->deadline = INT_MAX;
543 542
544 ctx->client_data = uw_init_client_data(); 543 ctx->client_data = uw_init_client_data();
545 544
546 ctx->logger_data = logger_data; 545 ctx->loggers = lg;
547 ctx->log_debug = log_debug;
548 546
549 ctx->isPost = ctx->hasPostBody = 0; 547 ctx->isPost = ctx->hasPostBody = 0;
550 548
551 ctx->queryString = NULL; 549 ctx->queryString = NULL;
552 550
592 ctx->db = db; 590 ctx->db = db;
593 } 591 }
594 592
595 void *uw_get_db(uw_context ctx) { 593 void *uw_get_db(uw_context ctx) {
596 return ctx->db; 594 return ctx->db;
595 }
596
597
598 uw_loggers* uw_get_loggers(struct uw_context *ctx) {
599 return ctx->loggers;
597 } 600 }
598 601
599 void uw_free(uw_context ctx) { 602 void uw_free(uw_context ctx) {
600 size_t i; 603 size_t i;
601 604
4116 fprintf(stderr, "%s\n", s); 4119 fprintf(stderr, "%s\n", s);
4117 return 0; 4120 return 0;
4118 } 4121 }
4119 4122
4120 uw_Basis_unit uw_Basis_debug(uw_context ctx, uw_Basis_string s) { 4123 uw_Basis_unit uw_Basis_debug(uw_context ctx, uw_Basis_string s) {
4121 if (ctx->log_debug) 4124 if (ctx->loggers->log_debug)
4122 ctx->log_debug(ctx->logger_data, "%s\n", s); 4125 ctx->loggers->log_debug(ctx->loggers->logger_data, "%s\n", s);
4123 else 4126 else
4124 fprintf(stderr, "%s\n", s); 4127 fprintf(stderr, "%s\n", s);
4125 return uw_unit_v; 4128 return uw_unit_v;
4126 } 4129 }
4127 4130