Mercurial > urweb
annotate src/c/static.c @ 2033:ea0ecd5fa9df
Add locking to enforce atomicity of message sends from one transaction
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Fri, 27 Jun 2014 14:39:31 -0400 |
parents | c93fbd139732 |
children | 8ecbd1100227 |
rev | line source |
---|---|
adam@1493 | 1 #include "config.h" |
adam@1493 | 2 |
adam@1493 | 3 #include <stdio.h> |
adam@1493 | 4 #include <stdarg.h> |
adam@1493 | 5 |
adam@1493 | 6 #include "urweb.h" |
adam@1493 | 7 |
adam@1493 | 8 extern uw_app uw_application; |
adam@1493 | 9 |
grrwlf@1997 | 10 static void log_(void *data, const char *fmt, ...) { |
adam@1493 | 11 va_list ap; |
adam@1493 | 12 va_start(ap, fmt); |
adam@1493 | 13 |
adam@1493 | 14 vprintf(fmt, ap); |
adam@1493 | 15 } |
adam@1493 | 16 |
grrwlf@1997 | 17 static uw_loggers loggers = {NULL, log_, log_}; |
grrwlf@1997 | 18 |
adam@1493 | 19 int main(int argc, char *argv[]) { |
adam@1493 | 20 uw_context ctx; |
adam@1493 | 21 failure_kind fk; |
adam@1493 | 22 |
adam@1493 | 23 if (argc != 2) { |
adam@1493 | 24 fprintf(stderr, "Pass exactly one argument: the URI to run\n"); |
adam@1493 | 25 return 1; |
adam@1493 | 26 } |
adam@1493 | 27 |
grrwlf@1997 | 28 ctx = uw_init(0, &loggers); |
adam@1493 | 29 uw_set_app(ctx, &uw_application); |
adam@1814 | 30 uw_initialize(ctx); |
adam@1493 | 31 |
adam@1498 | 32 while (1) { |
adam@1498 | 33 fk = uw_begin(ctx, argv[1]); |
adam@1498 | 34 |
adam@1498 | 35 if (fk == SUCCESS) { |
adam@1498 | 36 uw_print(ctx, 1); |
adam@1498 | 37 puts(""); |
adam@1498 | 38 return 0; |
adam@1498 | 39 } else if (fk != UNLIMITED_RETRY) { |
adam@1498 | 40 fprintf(stderr, "Error: %s\n", uw_error_message(ctx)); |
adam@1498 | 41 return 1; |
adam@1498 | 42 } |
adam@1502 | 43 |
adam@1502 | 44 uw_reset(ctx); |
adam@1493 | 45 } |
adam@1493 | 46 } |
adam@1493 | 47 |
adam@1493 | 48 void *uw_init_client_data() { |
adam@1493 | 49 return NULL; |
adam@1493 | 50 } |
adam@1493 | 51 |
adam@1493 | 52 void uw_free_client_data(void *data) { |
adam@1493 | 53 } |
adam@1493 | 54 |
adam@1493 | 55 void uw_copy_client_data(void *dst, void *src) { |
adam@1493 | 56 } |
adam@1493 | 57 |
adam@1493 | 58 void uw_do_expunge(uw_context ctx, uw_Basis_client cli, void *data) { |
adam@1493 | 59 } |
adam@1493 | 60 |
adam@1493 | 61 void uw_post_expunge(uw_context ctx, void *data) { |
adam@1493 | 62 } |
adam@1493 | 63 |
adam@1493 | 64 int uw_supports_direct_status = 0; |