annotate include/urweb/types.h @ 1739:c414850f206f

Add support for -boot flag, which allows in-tree execution of Ur/Web The boot flag rewrites most hardcoded paths to point to the build directory, and also forces static compilation. This is convenient for developing Ur/Web, or if you cannot 'sudo make install' Ur/Web. The following changes were made: * Header files were moved to include/urweb instead of include; this lets FFI users point their C_INCLUDE_PATH at this directory at write <urweb/urweb.h>. For internal Ur/Web executables, we simply pass -I$PATH/include/urweb as normal. * Differentiate between LIB and SRCLIB; SRCLIB is Ur and JavaScript source files, while LIB is compiled products from libtool. For in-tree compilation these live in different places. * No longer reference Config for paths; instead use Settings; these settings can be changed dynamically by Compiler.enableBoot () (TODO: add a disableBoot function.) * config.h is now generated directly in include/urweb/config.h, for consistency's sake (especially since it gets installed along with the rest of the headers!) * All of the autotools build products got updated. * The linkStatic field in protocols now only contains the name of the build product, and not the absolute path. Future users have to be careful not to reference the Settings files to early, lest they get an old version (this was the source of two bugs during development of this patch.)
author Edward Z. Yang <ezyang@mit.edu>
date Wed, 02 May 2012 17:17:57 -0400
parents
children 69daa6d70299
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;
ezyang@1739 50 } uw_Basis_postBody;
ezyang@1739 51
ezyang@1739 52 typedef uw_Basis_string uw_Basis_queryString;
ezyang@1739 53
ezyang@1739 54 typedef enum { SUCCESS, FATAL, BOUNDED_RETRY, UNLIMITED_RETRY, RETURN_INDIRECTLY } failure_kind;
ezyang@1739 55
ezyang@1739 56 typedef enum { SERVED, KEEP_OPEN, FAILED } request_result;
ezyang@1739 57
ezyang@1739 58 typedef struct input *uw_input;
ezyang@1739 59
ezyang@1739 60 #define INTS_MAX 50
ezyang@1739 61 #define FLOATS_MAX 100
ezyang@1739 62 #define TIMES_MAX 100
ezyang@1739 63
ezyang@1739 64 typedef void (*uw_callback)(void *);
ezyang@1739 65 typedef void (*uw_callback_with_retry)(void *, int will_retry);
ezyang@1739 66 typedef void (*uw_logger)(void*, const char *fmt, ...);
ezyang@1739 67
ezyang@1739 68 typedef struct {
ezyang@1739 69 void (*callback)(uw_context);
ezyang@1739 70 unsigned int period;
ezyang@1739 71 } uw_periodic;
ezyang@1739 72
ezyang@1739 73 typedef struct {
ezyang@1739 74 int inputs_len, timeout;
ezyang@1739 75 char *url_prefix;
ezyang@1739 76
ezyang@1739 77 void (*client_init)();
ezyang@1739 78 void (*initializer)(uw_context);
ezyang@1739 79 void (*expunger)(uw_context, uw_Basis_client);
ezyang@1739 80
ezyang@1739 81 void (*db_init)(uw_context);
ezyang@1739 82 int (*db_begin)(uw_context);
ezyang@1739 83 int (*db_commit)(uw_context);
ezyang@1739 84 int (*db_rollback)(uw_context);
ezyang@1739 85 void (*db_close)(uw_context);
ezyang@1739 86
ezyang@1739 87 void (*handle)(uw_context, char *);
ezyang@1739 88
ezyang@1739 89 int (*input_num)(const char*);
ezyang@1739 90 uw_Basis_string (*cookie_sig)(uw_context);
ezyang@1739 91 int (*check_url)(const char *);
ezyang@1739 92 int (*check_mime)(const char *);
ezyang@1739 93 int (*check_requestHeader)(const char *);
ezyang@1739 94 int (*check_responseHeader)(const char *);
ezyang@1739 95
ezyang@1739 96 void (*on_error)(uw_context, char *);
ezyang@1739 97
ezyang@1739 98 uw_periodic *periodics; // 0-terminated array
ezyang@1739 99
ezyang@1739 100 uw_Basis_string time_format;
ezyang@1739 101 } uw_app;
ezyang@1739 102
ezyang@1739 103 #define ERROR_BUF_LEN 1024
ezyang@1739 104
ezyang@1739 105 typedef struct {
ezyang@1739 106 size_t max;
ezyang@1739 107 char *start, *front, *back;
ezyang@1739 108 } uw_buffer;
ezyang@1739 109
ezyang@1739 110 #endif