annotate include/types.h @ 1388:3913cbfd72e9

String processing optimizations
author Adam Chlipala <adam@chlipala.net>
date Tue, 11 Jan 2011 14:03:54 -0500
parents 44a12a321150
children 4a6f84092399
rev   line source
adamc@764 1 #ifndef URWEB_TYPES_H
adamc@764 2 #define URWEB_TYPES_H
adamc@764 3
adamc@436 4 #include <time.h>
adamc@914 5 #include <unistd.h>
adamc@1115 6 #include <stdint.h>
adamc@436 7
adamc@311 8 typedef long long uw_Basis_int;
adamc@311 9 typedef double uw_Basis_float;
adamc@311 10 typedef char* uw_Basis_string;
adamc@821 11 typedef char uw_Basis_char;
adam@1365 12 typedef struct {
adam@1365 13 time_t seconds;
adam@1365 14 unsigned microseconds;
adam@1365 15 } uw_Basis_time;
adamc@737 16 typedef struct {
adamc@737 17 size_t size;
adamc@737 18 char *data;
adamc@737 19 } uw_Basis_blob;
adamc@102 20
adamc@311 21 struct __uws_0 {
adamc@102 22 };
adamc@102 23
adamc@311 24 typedef struct __uws_0 uw_unit;
adamc@311 25 typedef uw_unit uw_Basis_unit;
adamc@117 26
adamc@311 27 typedef enum uw_Basis_bool { uw_Basis_False, uw_Basis_True } uw_Basis_bool;
adamc@186 28
adamc@311 29 typedef struct uw_context *uw_context;
adamc@117 30
adamc@311 31 typedef uw_Basis_string uw_Basis_xhtml;
adamc@311 32 typedef uw_Basis_string uw_Basis_page;
adamc@757 33 typedef uw_Basis_string uw_Basis_xbody;
adamc@721 34 typedef uw_Basis_string uw_Basis_css_class;
adamc@682 35
adamc@682 36 typedef unsigned uw_Basis_client;
adamc@682 37 typedef struct {
adamc@682 38 unsigned cli, chn;
adamc@682 39 } uw_Basis_channel;
adamc@167 40
adamc@737 41 typedef struct uw_Basis_file {
adamc@740 42 uw_Basis_string name, type;
adamc@737 43 uw_Basis_blob data;
adamc@737 44 } uw_Basis_file;
adamc@737 45
adam@1347 46 typedef struct uw_Basis_postBody {
adam@1347 47 uw_Basis_string type, data;
adam@1347 48 } uw_Basis_postBody;
adam@1347 49
adam@1370 50 typedef uw_Basis_string uw_Basis_queryString;
adam@1370 51
adamc@1065 52 typedef enum { SUCCESS, FATAL, BOUNDED_RETRY, UNLIMITED_RETRY, RETURN_INDIRECTLY } failure_kind;
adamc@295 53
adamc@853 54 typedef enum { SERVED, KEEP_OPEN, FAILED } request_result;
adamc@853 55
adamc@756 56 typedef struct input *uw_input;
adamc@295 57
adamc@295 58 #define INTS_MAX 50
adamc@295 59 #define FLOATS_MAX 100
adamc@436 60 #define TIMES_MAX 100
adamc@668 61
adamc@771 62 typedef void (*uw_callback)(void *);
adam@1327 63 typedef void (*uw_callback_with_retry)(void *, int will_retry);
adamc@856 64 typedef void (*uw_logger)(void*, const char *fmt, ...);
adamc@771 65
adamc@1094 66 typedef struct {
adam@1349 67 void (*callback)(uw_context);
adam@1349 68 unsigned int period;
adam@1349 69 } uw_periodic;
adam@1349 70
adam@1349 71 typedef struct {
adamc@1094 72 int inputs_len, timeout;
adamc@1094 73 char *url_prefix;
adamc@1094 74
adamc@1094 75 void (*client_init)();
adamc@1094 76 void (*initializer)(uw_context);
adamc@1094 77 void (*expunger)(uw_context, uw_Basis_client);
adamc@1094 78
adamc@1094 79 void (*db_init)(uw_context);
adamc@1094 80 int (*db_begin)(uw_context);
adamc@1094 81 int (*db_commit)(uw_context);
adamc@1094 82 int (*db_rollback)(uw_context);
adamc@1094 83 void (*db_close)(uw_context);
adamc@1094 84
adamc@1094 85 void (*handle)(uw_context, char *);
adamc@1094 86
adamc@1094 87 int (*input_num)(const char*);
adamc@1094 88 uw_Basis_string (*cookie_sig)(uw_context);
adamc@1094 89 int (*check_url)(const char *);
adamc@1094 90 int (*check_mime)(const char *);
adam@1294 91
adam@1294 92 void (*on_error)(uw_context, char *);
adam@1349 93
adam@1349 94 uw_periodic *periodics; // 0-terminated array
adamc@1094 95 } uw_app;
adamc@1094 96
adam@1294 97 #define ERROR_BUF_LEN 1024
adam@1294 98
adam@1369 99 typedef struct {
adam@1369 100 size_t max;
adam@1369 101 char *start, *front, *back;
adam@1369 102 } uw_buffer;
adam@1369 103
adamc@764 104 #endif