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