Mercurial > urweb
comparison include/urweb/types_cpp.h @ 1881:a5b08bdfa450
New header file scheme to support FFI code in either of C or C++ [based on suggestion by Ron de Bruijn]
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Fri, 11 Oct 2013 17:15:28 -0400 |
parents | |
children | 6745eafff617 |
comparison
equal
deleted
inserted
replaced
1880:0354df1b6849 | 1881:a5b08bdfa450 |
---|---|
1 #ifndef URWEB_TYPES_CPP_H | |
2 #define URWEB_TYPES_CPP_H | |
3 | |
4 #include <time.h> | |
5 #include <unistd.h> | |
6 #include <stdint.h> | |
7 | |
8 typedef long long uw_Basis_int; | |
9 typedef double uw_Basis_float; | |
10 typedef char* uw_Basis_string; | |
11 typedef char uw_Basis_char; | |
12 typedef struct { | |
13 time_t seconds; | |
14 unsigned microseconds; | |
15 } uw_Basis_time; | |
16 typedef struct { | |
17 size_t size; | |
18 char *data; | |
19 } uw_Basis_blob; | |
20 | |
21 typedef int uw_unit; | |
22 typedef uw_unit uw_Basis_unit; | |
23 | |
24 typedef enum uw_Basis_bool { uw_Basis_False, uw_Basis_True } uw_Basis_bool; | |
25 | |
26 typedef uw_Basis_string uw_Basis_xhtml; | |
27 typedef uw_Basis_string uw_Basis_page; | |
28 typedef uw_Basis_string uw_Basis_xbody; | |
29 typedef uw_Basis_string uw_Basis_css_class; | |
30 | |
31 typedef unsigned uw_Basis_client; | |
32 typedef struct { | |
33 unsigned cli, chn; | |
34 } uw_Basis_channel; | |
35 | |
36 typedef struct { | |
37 int context; | |
38 unsigned long long source; | |
39 } uw_Basis_source; | |
40 | |
41 typedef struct uw_Basis_file { | |
42 uw_Basis_string name, type; | |
43 uw_Basis_blob data; | |
44 } uw_Basis_file; | |
45 | |
46 typedef struct uw_Basis_postBody { | |
47 uw_Basis_string type, data; | |
48 size_t len; | |
49 } uw_Basis_postBody; | |
50 | |
51 typedef uw_Basis_string uw_Basis_queryString; | |
52 | |
53 typedef struct { | |
54 uw_Basis_string name, value, remaining; | |
55 } uw_Basis_postField; | |
56 | |
57 typedef enum { SUCCESS, FATAL, BOUNDED_RETRY, UNLIMITED_RETRY, RETURN_INDIRECTLY } failure_kind; | |
58 | |
59 typedef enum { SERVED, KEEP_OPEN, FAILED } request_result; | |
60 | |
61 #define INTS_MAX 50 | |
62 #define FLOATS_MAX 100 | |
63 #define TIMES_MAX 100 | |
64 | |
65 typedef void (*uw_callback)(void *); | |
66 typedef void (*uw_callback_with_retry)(void *, int will_retry); | |
67 typedef void (*uw_logger)(void*, const char *fmt, ...); | |
68 | |
69 struct uw_context; | |
70 | |
71 typedef struct { | |
72 void (*callback)(struct uw_context *); | |
73 unsigned int period; | |
74 } uw_periodic; | |
75 | |
76 typedef struct { | |
77 int inputs_len, timeout; | |
78 char *url_prefix; | |
79 | |
80 void (*client_init)(); | |
81 void (*initializer)(struct uw_context *); | |
82 void (*expunger)(struct uw_context *, uw_Basis_client); | |
83 | |
84 void (*db_init)(struct uw_context *); | |
85 int (*db_begin)(struct uw_context *); | |
86 int (*db_commit)(struct uw_context *); | |
87 int (*db_rollback)(struct uw_context *); | |
88 void (*db_close)(struct uw_context *); | |
89 | |
90 void (*handle)(struct uw_context *, char *); | |
91 | |
92 int (*input_num)(const char*); | |
93 uw_Basis_string (*cookie_sig)(struct uw_context *); | |
94 int (*check_url)(const char *); | |
95 int (*check_mime)(const char *); | |
96 int (*check_requestHeader)(const char *); | |
97 int (*check_responseHeader)(const char *); | |
98 int (*check_envVar)(const char *); | |
99 | |
100 void (*on_error)(struct uw_context *, char *); | |
101 | |
102 uw_periodic *periodics; // 0-terminated array | |
103 | |
104 uw_Basis_string time_format; | |
105 } uw_app; | |
106 | |
107 #define ERROR_BUF_LEN 1024 | |
108 | |
109 typedef struct { | |
110 size_t max; | |
111 char *start, *front, *back; | |
112 } uw_buffer; | |
113 | |
114 #endif |