summaryrefslogtreecommitdiff
path: root/include/types.h
blob: ac70c34f73a301f36d0724cac3dc923cfd679ec1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef URWEB_TYPES_H
#define URWEB_TYPES_H

#include <time.h>
#include <unistd.h>
#include <stdint.h>

typedef long long uw_Basis_int;
typedef double uw_Basis_float;
typedef char* uw_Basis_string;
typedef char uw_Basis_char;
typedef time_t uw_Basis_time;
typedef struct {
  size_t size;
  char *data;
} uw_Basis_blob;

struct __uws_0 {
};

typedef struct __uws_0 uw_unit;
typedef uw_unit uw_Basis_unit;

typedef enum uw_Basis_bool { uw_Basis_False, uw_Basis_True } uw_Basis_bool;

typedef struct uw_context *uw_context;

typedef uw_Basis_string uw_Basis_xhtml;
typedef uw_Basis_string uw_Basis_page;
typedef uw_Basis_string uw_Basis_xbody;
typedef uw_Basis_string uw_Basis_css_class;

typedef unsigned uw_Basis_client;
typedef struct {
  unsigned cli, chn;
} uw_Basis_channel;

typedef struct uw_Basis_file {
  uw_Basis_string name, type;
  uw_Basis_blob data;
} uw_Basis_file;

typedef enum { SUCCESS, FATAL, BOUNDED_RETRY, UNLIMITED_RETRY, RETURN_INDIRECTLY } failure_kind;

typedef enum { SERVED, KEEP_OPEN, FAILED } request_result;

typedef struct input *uw_input;

#define INTS_MAX 50
#define FLOATS_MAX 100
#define TIMES_MAX 100

typedef void (*uw_callback)(void *);
typedef void (*uw_logger)(void*, const char *fmt, ...);

typedef struct {
  int inputs_len, timeout;
  char *url_prefix;

  void (*client_init)();
  void (*initializer)(uw_context);
  void (*expunger)(uw_context, uw_Basis_client);

  void (*db_init)(uw_context);
  int (*db_begin)(uw_context);
  int (*db_commit)(uw_context);
  int (*db_rollback)(uw_context);
  void (*db_close)(uw_context);

  void (*handle)(uw_context, char *);

  int (*input_num)(const char*);
  uw_Basis_string (*cookie_sig)(uw_context);
  int (*check_url)(const char *);
  int (*check_mime)(const char *);

  void (*on_error)(uw_context, char *);
} uw_app;

#define ERROR_BUF_LEN 1024

#endif