#ifndef EVAPP_UTIL_H #define EVAPP_UTIL_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include bool parse_cookie(evapp_ctx *ctx, struct evkeyvalq *data); bool set_cookie(evapp_ctx *ctx, struct evkeyvalq *data, const char *path, const char *domain, size_t lifetime, bool secure); enum cacheable_t { CACHE_PUBLIC, CACHE_PRIVATE, CACHE_NONE }; bool response_cacheable(evapp_ctx *ctx, enum cacheable_t type, size_t lifetime); bool parse_query(void *qbuf, size_t length, bool is_url, bool is_cookie, HDF **hdf, struct evkeyvalq *keyval); bool set_xsrf_token(evapp_ctx *ctx, HDF *hdf); bool check_xsrf(evapp_ctx *ctx, char *token); bool template_load(evapp_ctx *ctx, HDF *hdf, const char *base, const char *dbname, CSPARSE **csp); void send_response(evapp_ctx *ctx, int code, const char *code_msg, const char *http_msg, const char *msg); void send_ok(evapp_ctx *ctx, const char* msg); void send_not_found(evapp_ctx *ctx, const char* msg); void send_error(evapp_ctx *ctx, const char* msg); void send_forbidden(evapp_ctx *ctx, const char *msg); /* XXX: produces a link relevant for scaffolded apps. */ void send_created(evapp_ctx *ctx, const char *object_type, uint64_t id); // Generic CS render callback NEOERR* render_cb(void *evbuffer, char *data); bool template_render(evapp_ctx *ctx, HDF *hdf, char *prefix, char *dbname); // Grabs the last string before using rindex('/') bool get_database_from_uri(const char *uri, char *d, size_t max); bool get_last_value_as_uint64(evapp_ctx *ctx, u_int64_t *i); #endif