Mercurial > urweb
comparison include/urweb/types.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 | 3d922a28370b |
children |
comparison
equal
deleted
inserted
replaced
1880:0354df1b6849 | 1881:a5b08bdfa450 |
---|---|
1 #ifndef URWEB_TYPES_H | 1 #ifndef URWEB_TYPES_H |
2 #define URWEB_TYPES_H | 2 #define URWEB_TYPES_H |
3 | 3 |
4 #include <time.h> | 4 #include "types_cpp.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 | 5 |
26 typedef struct uw_context *uw_context; | 6 typedef struct uw_context *uw_context; |
27 | |
28 typedef uw_Basis_string uw_Basis_xhtml; | |
29 typedef uw_Basis_string uw_Basis_page; | |
30 typedef uw_Basis_string uw_Basis_xbody; | |
31 typedef uw_Basis_string uw_Basis_css_class; | |
32 | |
33 typedef unsigned uw_Basis_client; | |
34 typedef struct { | |
35 unsigned cli, chn; | |
36 } uw_Basis_channel; | |
37 | |
38 typedef struct { | |
39 int context; | |
40 unsigned long long source; | |
41 } uw_Basis_source; | |
42 | |
43 typedef struct uw_Basis_file { | |
44 uw_Basis_string name, type; | |
45 uw_Basis_blob data; | |
46 } uw_Basis_file; | |
47 | |
48 typedef struct uw_Basis_postBody { | |
49 uw_Basis_string type, data; | |
50 size_t len; | |
51 } uw_Basis_postBody; | |
52 | |
53 typedef uw_Basis_string uw_Basis_queryString; | |
54 | |
55 typedef struct { | |
56 uw_Basis_string name, value, remaining; | |
57 } uw_Basis_postField; | |
58 | |
59 typedef enum { SUCCESS, FATAL, BOUNDED_RETRY, UNLIMITED_RETRY, RETURN_INDIRECTLY } failure_kind; | |
60 | |
61 typedef enum { SERVED, KEEP_OPEN, FAILED } request_result; | |
62 | |
63 typedef struct input *uw_input; | 7 typedef struct input *uw_input; |
64 | 8 |
65 #define INTS_MAX 50 | |
66 #define FLOATS_MAX 100 | |
67 #define TIMES_MAX 100 | |
68 | |
69 typedef void (*uw_callback)(void *); | |
70 typedef void (*uw_callback_with_retry)(void *, int will_retry); | |
71 typedef void (*uw_logger)(void*, const char *fmt, ...); | |
72 | |
73 typedef struct { | |
74 void (*callback)(uw_context); | |
75 unsigned int period; | |
76 } uw_periodic; | |
77 | |
78 typedef struct { | |
79 int inputs_len, timeout; | |
80 char *url_prefix; | |
81 | |
82 void (*client_init)(); | |
83 void (*initializer)(uw_context); | |
84 void (*expunger)(uw_context, uw_Basis_client); | |
85 | |
86 void (*db_init)(uw_context); | |
87 int (*db_begin)(uw_context); | |
88 int (*db_commit)(uw_context); | |
89 int (*db_rollback)(uw_context); | |
90 void (*db_close)(uw_context); | |
91 | |
92 void (*handle)(uw_context, char *); | |
93 | |
94 int (*input_num)(const char*); | |
95 uw_Basis_string (*cookie_sig)(uw_context); | |
96 int (*check_url)(const char *); | |
97 int (*check_mime)(const char *); | |
98 int (*check_requestHeader)(const char *); | |
99 int (*check_responseHeader)(const char *); | |
100 int (*check_envVar)(const char *); | |
101 | |
102 void (*on_error)(uw_context, char *); | |
103 | |
104 uw_periodic *periodics; // 0-terminated array | |
105 | |
106 uw_Basis_string time_format; | |
107 } uw_app; | |
108 | |
109 #define ERROR_BUF_LEN 1024 | |
110 | |
111 typedef struct { | |
112 size_t max; | |
113 char *start, *front, *back; | |
114 } uw_buffer; | |
115 | |
116 #endif | 9 #endif |