#ifndef EVAPP_H #define EVAPP_H #include #include #include #include #include /* MUST MATCH API.H */ #define EVAPP_URIMAP_EXACT 1 #define EVAPP_URIMAP_PREFIX 2 #define EVAPP_VERSION "0.0.1" struct evapp_context; typedef struct evapp_context evapp_ctx; struct evapp_urimap { TAILQ_ENTRY(evapp_urimap) entries; short type; /* 1: prefix, 2: exact */ char *uri; void (*handler)(struct evapp_context*); }; TAILQ_HEAD (evapp_urimapq, evapp_urimap); typedef struct evapp_db_index { TAILQ_ENTRY(evapp_db_index) entries; char *field; char *file; char *type; int (*callback)(DB*, const DBT*, const DBT*, DBT*); DB *p; } evapp_db_index; TAILQ_HEAD (evapp_db_indexq, evapp_db_index); struct evapp_db { TAILQ_ENTRY(evapp_db) entries; char *name; char *file; DB *p; bool (*load)(evapp_ctx *ctx, u_int64_t id, HDF **hdf); bool (*save)(evapp_ctx *ctx, u_int64_t id, HDF *hdf); bool (*del)(evapp_ctx *ctx, u_int64_t id); bool (*validate)(evapp_ctx *ctx, HDF *hdf); bool (*hdf)(evapp_ctx *ctx, void *data, size_t len, HDF **hdf); bool (*hdf_template)(evapp_ctx *ctx, HDF **hdf); bool (*cleanup)(void); struct evapp_db_indexq indices; }; TAILQ_HEAD (evapp_dbq, evapp_db); struct evapp_context { void *state; /* app-specific state */ char *name; struct evbuffer *response; struct evhttp_request *request; /* Application settings */ char *default_domain; /* This mode is used to disable secure cookies and other * debug mode items */ bool debug_mode; bool default_templates; bool xsrf_protection; bool scaffold; struct event_base *event_base; struct evhttp *server; struct evapp_urimapq maps; struct evapp_dbq dbs; DB_ENV *dbenv; }; #endif