adam@1881
|
1 #ifndef URWEB_TYPES_CPP_H
|
adam@1881
|
2 #define URWEB_TYPES_CPP_H
|
adam@1881
|
3
|
adam@1881
|
4 #include <time.h>
|
adam@1881
|
5 #include <unistd.h>
|
adam@1881
|
6 #include <stdint.h>
|
adam@1881
|
7
|
adam@1881
|
8 typedef long long uw_Basis_int;
|
adam@1881
|
9 typedef double uw_Basis_float;
|
adam@1881
|
10 typedef char* uw_Basis_string;
|
adam@1881
|
11 typedef char uw_Basis_char;
|
adam@1881
|
12 typedef struct {
|
adam@1881
|
13 time_t seconds;
|
adam@1881
|
14 unsigned microseconds;
|
adam@1881
|
15 } uw_Basis_time;
|
adam@1881
|
16 typedef struct {
|
adam@1881
|
17 size_t size;
|
adam@1881
|
18 char *data;
|
adam@1881
|
19 } uw_Basis_blob;
|
adam@1881
|
20
|
adam@1881
|
21 typedef int uw_unit;
|
adam@1881
|
22 typedef uw_unit uw_Basis_unit;
|
adam@1881
|
23
|
adam@1881
|
24 typedef enum uw_Basis_bool { uw_Basis_False, uw_Basis_True } uw_Basis_bool;
|
adam@1881
|
25
|
adam@1881
|
26 typedef uw_Basis_string uw_Basis_xhtml;
|
adam@1881
|
27 typedef uw_Basis_string uw_Basis_page;
|
adam@1881
|
28 typedef uw_Basis_string uw_Basis_xbody;
|
adam@1881
|
29 typedef uw_Basis_string uw_Basis_css_class;
|
adam@1881
|
30
|
adam@1881
|
31 typedef unsigned uw_Basis_client;
|
adam@1881
|
32 typedef struct {
|
adam@1881
|
33 unsigned cli, chn;
|
adam@1881
|
34 } uw_Basis_channel;
|
adam@1881
|
35
|
adam@1881
|
36 typedef struct {
|
adam@1881
|
37 int context;
|
adam@1881
|
38 unsigned long long source;
|
adam@1881
|
39 } uw_Basis_source;
|
adam@1881
|
40
|
adam@1881
|
41 typedef struct uw_Basis_file {
|
adam@1881
|
42 uw_Basis_string name, type;
|
adam@1881
|
43 uw_Basis_blob data;
|
adam@1881
|
44 } uw_Basis_file;
|
adam@1881
|
45
|
adam@1881
|
46 typedef struct uw_Basis_postBody {
|
adam@1881
|
47 uw_Basis_string type, data;
|
adam@1881
|
48 size_t len;
|
adam@1881
|
49 } uw_Basis_postBody;
|
adam@1881
|
50
|
adam@1881
|
51 typedef uw_Basis_string uw_Basis_queryString;
|
adam@1881
|
52
|
adam@1881
|
53 typedef struct {
|
adam@1881
|
54 uw_Basis_string name, value, remaining;
|
adam@1881
|
55 } uw_Basis_postField;
|
adam@1881
|
56
|
adam@1881
|
57 typedef enum { SUCCESS, FATAL, BOUNDED_RETRY, UNLIMITED_RETRY, RETURN_INDIRECTLY } failure_kind;
|
adam@1881
|
58
|
adam@1881
|
59 typedef enum { SERVED, KEEP_OPEN, FAILED } request_result;
|
adam@1881
|
60
|
adam@1881
|
61 #define INTS_MAX 50
|
adam@1881
|
62 #define FLOATS_MAX 100
|
adam@1881
|
63 #define TIMES_MAX 100
|
adam@1881
|
64
|
adam@1881
|
65 typedef void (*uw_callback)(void *);
|
adam@1881
|
66 typedef void (*uw_callback_with_retry)(void *, int will_retry);
|
adam@1881
|
67 typedef void (*uw_logger)(void*, const char *fmt, ...);
|
adam@1881
|
68
|
adam@1881
|
69 struct uw_context;
|
adam@1881
|
70
|
adam@1881
|
71 typedef struct {
|
adam@1881
|
72 void (*callback)(struct uw_context *);
|
adam@1881
|
73 unsigned int period;
|
adam@1881
|
74 } uw_periodic;
|
adam@1881
|
75
|
adam@1881
|
76 typedef struct {
|
adam@1881
|
77 int inputs_len, timeout;
|
adam@1881
|
78 char *url_prefix;
|
adam@1881
|
79
|
adam@1881
|
80 void (*client_init)();
|
adam@1881
|
81 void (*initializer)(struct uw_context *);
|
adam@1881
|
82 void (*expunger)(struct uw_context *, uw_Basis_client);
|
adam@1881
|
83
|
adam@1881
|
84 void (*db_init)(struct uw_context *);
|
adam@1936
|
85 int (*db_begin)(struct uw_context *, int could_write);
|
adam@1881
|
86 int (*db_commit)(struct uw_context *);
|
adam@1881
|
87 int (*db_rollback)(struct uw_context *);
|
adam@1881
|
88 void (*db_close)(struct uw_context *);
|
adam@1881
|
89
|
adam@1881
|
90 void (*handle)(struct uw_context *, char *);
|
adam@1881
|
91
|
adam@1881
|
92 int (*input_num)(const char*);
|
adam@1881
|
93 uw_Basis_string (*cookie_sig)(struct uw_context *);
|
adam@1881
|
94 int (*check_url)(const char *);
|
adam@1881
|
95 int (*check_mime)(const char *);
|
adam@1881
|
96 int (*check_requestHeader)(const char *);
|
adam@1881
|
97 int (*check_responseHeader)(const char *);
|
adam@1881
|
98 int (*check_envVar)(const char *);
|
adam@1881
|
99
|
adam@1881
|
100 void (*on_error)(struct uw_context *, char *);
|
adam@1881
|
101
|
adam@1881
|
102 uw_periodic *periodics; // 0-terminated array
|
adam@1881
|
103
|
adam@1881
|
104 uw_Basis_string time_format;
|
adam@1956
|
105
|
adam@1956
|
106 int is_html5;
|
adam@1881
|
107 } uw_app;
|
adam@1881
|
108
|
grrwlf@1997
|
109 typedef struct {
|
grrwlf@1997
|
110 /* uw_app *app; */
|
grrwlf@1997
|
111 void *logger_data;
|
grrwlf@1997
|
112 uw_logger log_error, log_debug;
|
grrwlf@1997
|
113 } uw_loggers;
|
grrwlf@1997
|
114
|
adam@1881
|
115 #define ERROR_BUF_LEN 1024
|
adam@1881
|
116
|
adam@1881
|
117 typedef struct {
|
adam@1881
|
118 size_t max;
|
adam@1881
|
119 char *start, *front, *back;
|
adam@1881
|
120 } uw_buffer;
|
adam@1881
|
121
|
adam@1881
|
122 #endif
|