commit - 87f2b68b58fc46ff12a592474e65280ef8455aff
commit + fe40638928b636182afb03b6327afa15c80d560c
blob - dba93c368806aeb65c3a42e175d87796950ae333
blob + 5c107e28544ad469afabc31c905eef330f54eff3
--- gmid.h
+++ gmid.h
const char *vhost_default_mime(struct vhost*, const char*);
const char *vhost_index(struct vhost*, const char*);
int vhost_auto_index(struct vhost*, const char*);
-int check_path(struct client*, const char*, int*);
-void open_file(struct pollfd*, struct client*);
-void load_file(struct pollfd*, struct client*);
-void check_for_cgi(struct pollfd*, struct client*);
void mark_nonblock(int);
-void handle_handshake(struct pollfd*, struct client*);
-void handle_open_conn(struct pollfd*, struct client*);
-void start_reply(struct pollfd*, struct client*, int, const char*);
-void handle_start_reply(struct pollfd*, struct client*);
-void start_cgi(const char*, const char*, struct pollfd*, struct client*);
-void send_file(struct pollfd*, struct client*);
-void open_dir(struct pollfd*, struct client*);
-void redirect_canonical_dir(struct pollfd*, struct client*);
-void enter_handle_dirlist(struct pollfd*, struct client*);
-void handle_dirlist(struct pollfd*, struct client*);
-int read_next_dir_entry(struct client*);
-void send_directory_listing(struct pollfd*, struct client*);
-void cgi_poll_on_child(struct pollfd*, struct client*);
-void cgi_poll_on_client(struct pollfd*, struct client*);
-void handle_cgi_reply(struct pollfd*, struct client*);
-void handle_cgi(struct pollfd*, struct client*);
-void close_conn(struct pollfd*, struct client*);
-void do_accept(int, struct tls*, struct pollfd*, struct client*);
void loop(struct tls*, int, int);
/* ex.c */
blob - 7ac341221941da24e088620f3a1a63224f0dcce0
blob + 07fb904bc4bcb08f50ab7500cdacf488263b3e7e
--- server.c
+++ server.c
int connected_clients;
+static int check_path(struct client*, const char*, int*);
+static void open_file(struct pollfd*, struct client*);
+static void load_file(struct pollfd*, struct client*);
+static void check_for_cgi(struct pollfd*, struct client*);
+static void handle_handshake(struct pollfd*, struct client*);
+static void handle_open_conn(struct pollfd*, struct client*);
+static void start_reply(struct pollfd*, struct client*, int, const char*);
+static void handle_start_reply(struct pollfd*, struct client*);
+static void start_cgi(const char*, const char*, struct pollfd*, struct client*);
+static void send_file(struct pollfd*, struct client*);
+static void open_dir(struct pollfd*, struct client*);
+static void redirect_canonical_dir(struct pollfd*, struct client*);
+static void enter_handle_dirlist(struct pollfd*, struct client*);
+static void handle_dirlist(struct pollfd*, struct client*);
+static int read_next_dir_entry(struct client*);
+static void send_directory_listing(struct pollfd*, struct client*);
+static void cgi_poll_on_child(struct pollfd*, struct client*);
+static void cgi_poll_on_client(struct pollfd*, struct client*);
+static void handle_cgi_reply(struct pollfd*, struct client*);
+static void handle_cgi(struct pollfd*, struct client*);
+static void close_conn(struct pollfd*, struct client*);
+static void do_accept(int, struct tls*, struct pollfd*, struct client*);
+
const char *
vhost_lang(struct vhost *v, const char *path)
{
return v->locations[0].auto_index == 1;
}
-int
+static int
check_path(struct client *c, const char *path, int *fd)
{
struct stat sb;
return FILE_EXISTS;
}
-void
+static void
open_file(struct pollfd *fds, struct client *c)
{
switch (check_path(c, c->iri.path, &c->fd)) {
}
}
-void
+static void
load_file(struct pollfd *fds, struct client *c)
{
if ((c->len = filesize(c->fd)) == -1) {
* from the end and strip one component at a time, until either an
* executable is found or we emptied the path.
*/
-void
+static void
check_for_cgi(struct pollfd *fds, struct client *c)
{
char path[PATH_MAX];
fatal("fcntl(F_SETFL): %s", strerror(errno));
}
-void
+static void
handle_handshake(struct pollfd *fds, struct client *c)
{
struct vhost *h;
start_reply(fds, c, BAD_REQUEST, "Wrong/malformed host or missing SNI");
}
-void
+static void
handle_open_conn(struct pollfd *fds, struct client *c)
{
const char *parse_err = "invalid request";
open_file(fds, c);
}
-void
+static void
start_reply(struct pollfd *pfd, struct client *c, int code, const char *meta)
{
c->code = code;
c->meta = meta;
c->state = handle_start_reply;
- c->state(pfd, c);
+ handle_start_reply(pfd, c);
}
-void
+static void
handle_start_reply(struct pollfd *pfd, struct client *c)
{
char buf[1030]; /* status + ' ' + max reply len + \r\n\0 */
c->state(pfd, c);
}
-void
+static void
start_cgi(const char *spath, const char *relpath,
struct pollfd *fds, struct client *c)
{
fatal("cannot talk to the executor process");
}
-void
+static void
send_file(struct pollfd *fds, struct client *c)
{
ssize_t ret, len;
close_conn(fds, c);
}
-void
+static void
open_dir(struct pollfd *fds, struct client *c)
{
size_t len;
close(dirfd);
}
-void
+static void
redirect_canonical_dir(struct pollfd *fds, struct client *c)
{
size_t len;
start_reply(fds, c, TEMP_REDIRECT, c->sbuf);
}
-void
+static void
enter_handle_dirlist(struct pollfd *fds, struct client *c)
{
char b[PATH_MAX];
handle_dirlist(fds, c);
}
-void
+static void
handle_dirlist(struct pollfd *fds, struct client *c)
{
ssize_t r;
send_directory_listing(fds, c);
}
-int
+static int
read_next_dir_entry(struct client *c)
{
struct dirent *d;
return 1;
}
-void
+static void
send_directory_listing(struct pollfd *fds, struct client *c)
{
ssize_t r;
close_conn(fds, c);
}
-void
+static inline void
cgi_poll_on_child(struct pollfd *fds, struct client *c)
{
int fd;
c->fd = fd;
}
-void
+static inline void
cgi_poll_on_client(struct pollfd *fds, struct client *c)
{
int fd;
}
/* accumulate the meta line from the cgi script. */
-void
+static void
handle_cgi_reply(struct pollfd *fds, struct client *c)
{
void *buf, *e;
}
}
-void
+static void
handle_cgi(struct pollfd *fds, struct client *c)
{
ssize_t r;
close_conn(fds, c);
}
-void
+static void
close_conn(struct pollfd *pfd, struct client *c)
{
c->state = close_conn;
pfd->fd = -1;
}
-void
+static void
do_accept(int sock, struct tls *ctx, struct pollfd *fds, struct client *clients)
{
int i, fd;