2 * This file is in the public domain.
6 #define QUERY_MAXLEN 1025 /* including NUL */
21 #define ATTR_PRINTF(A, B) __attribute__((__format__ (printf, A, B)))
24 __dead void (*fatal)(int, const char *, ...) ATTR_PRINTF(2, 3);
25 __dead void (*fatalx)(int, const char *, ...) ATTR_PRINTF(2, 3);
26 void (*warn)(const char *, ...) ATTR_PRINTF(1, 2);
27 void (*warnx)(const char *, ...) ATTR_PRINTF(1, 2);
28 void (*info)(const char *, ...) ATTR_PRINTF(1, 2);
29 void (*debug)(const char *, ...) ATTR_PRINTF(1, 2);
32 extern const struct logger *logger;
33 #define fatal(...) logger->fatal(1, __VA_ARGS__)
34 #define fatalx(...) logger->fatalx(1, __VA_ARGS__)
35 #define log_warn(...) logger->warn(__VA_ARGS__)
36 #define log_warnx(...) logger->warnx(__VA_ARGS__)
37 #define log_info(...) logger->info(__VA_ARGS__)
38 #define log_debug(...) logger->debug(__VA_ARGS__)
41 #define DPRINTF log_debug
43 #define DPRINTF(...) do {} while (0)
49 struct fcgi *clt_fcgi;
50 char *clt_server_name;
51 char *clt_script_name;
58 SPLAY_ENTRY(client) clt_nodes;
60 SPLAY_HEAD(client_tree, client);
65 struct client_tree fcg_clients;
66 struct bufferevent *fcg_bev;
77 SPLAY_ENTRY(fcgi) fcg_nodes;
79 SPLAY_HEAD(fcgi_tree, fcgi);
83 struct event env_sockev;
84 struct event env_pausev;
85 struct fcgi_tree env_fcgi_socks;
87 struct sqlite3 *env_db;
88 struct sqlite3_stmt *env_query;
92 int fcgi_end_request(struct client *, int);
93 int fcgi_abort_request(struct client *);
94 void fcgi_accept(int, short, void *);
95 void fcgi_read(struct bufferevent *, void *);
96 void fcgi_write(struct bufferevent *, void *);
97 void fcgi_error(struct bufferevent *, short, void *);
98 void fcgi_free(struct fcgi *);
99 int clt_putc(struct client *, char);
100 int clt_puts(struct client *, const char *);
101 int clt_putsan(struct client *, const char *);
102 int clt_write_bufferevent(struct client *, struct bufferevent *);
103 int clt_flush(struct client *);
104 int clt_write(struct client *, const uint8_t *, size_t);
105 int clt_printf(struct client *, const char *, ...)
106 __attribute__((__format__(printf, 2, 3)))
107 __attribute__((__nonnull__(2)));
108 int fcgi_cmp(struct fcgi *, struct fcgi *);
109 int fcgi_client_cmp(struct client *, struct client *);
112 extern const char *tmpl_head;
113 extern const char *tmpl_search;
114 extern const char *tmpl_search_header;
115 extern const char *tmpl_foot;
118 int server_main(const char *);
119 int server_handle(struct env *, struct client *);
120 void server_client_free(struct client *);
122 SPLAY_PROTOTYPE(client_tree, client, clt_nodes, fcgi_client_cmp);
123 SPLAY_PROTOTYPE(fcgi_tree, fcgi, fcg_nodes, fcgi_cmp);