annotate include/urweb/types.h @ 1799:3d922a28370b

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