2 * Copyright (c) 2022 Omar Polo <op@omarpolo.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #define GEMINI_MAXLEN 1025 /* including NUL */
21 #define DPRINTF log_debug
23 #define DPRINTF(x...) do {} while (0)
41 struct fcgi *clt_fcgi;
42 char *clt_server_name;
43 char *clt_script_name;
48 struct template *clt_tp;
53 SPLAY_ENTRY(client) clt_nodes;
55 SPLAY_HEAD(client_tree, client);
60 struct client_tree fcg_clients;
61 struct bufferevent *fcg_bev;
72 SPLAY_ENTRY(fcgi) fcg_nodes;
74 SPLAY_HEAD(fcgi_tree, fcgi);
78 struct event env_sockev;
79 struct event env_pausev;
80 struct fcgi_tree env_fcgi_socks;
82 struct sqlite3 *env_db;
83 struct sqlite3_stmt *env_qsearch;
84 struct sqlite3_stmt *env_qfullpkgpath;
85 struct sqlite3_stmt *env_qcats;
86 struct sqlite3_stmt *env_qbycat;
90 int fcgi_end_request(struct client *, int);
91 int fcgi_abort_request(struct client *);
92 void fcgi_accept(int, short, void *);
93 void fcgi_read(struct bufferevent *, void *);
94 void fcgi_write(struct bufferevent *, void *);
95 void fcgi_error(struct bufferevent *, short, void *);
96 void fcgi_free(struct fcgi *);
97 int clt_putc(struct client *, char);
98 int clt_puts(struct client *, const char *);
99 int clt_write_bufferevent(struct client *, struct bufferevent *);
100 int clt_flush(struct client *);
101 int clt_write(struct client *, const uint8_t *, size_t);
102 int clt_printf(struct client *, const char *, ...)
103 __attribute__((__format__(printf, 2, 3)))
104 __attribute__((__nonnull__(2)));
106 int clt_tp_puts(struct template *, const char *);
107 int clt_tp_putc(struct template *, int);
109 int fcgi_cmp(struct fcgi *, struct fcgi *);
110 int fcgi_client_cmp(struct client *, struct client *);
113 int server_main(const char *);
114 int server_handle(struct env *, struct client *);
115 void server_client_free(struct client *);
119 int tp_home(struct template *);
122 SPLAY_PROTOTYPE(client_tree, client, clt_nodes, fcgi_client_cmp);
123 SPLAY_PROTOTYPE(fcgi_tree, fcgi, fcg_nodes, fcgi_cmp);