From da9db7bc46db0cb675635594c7c207e232a2da63 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 23 Sep 2020 14:19:28 -0400 Subject: Implement basic server event loop --- include/config.h | 2 +- include/server.h | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/config.h b/include/config.h index dec0e15..9455c2b 100644 --- a/include/config.h +++ b/include/config.h @@ -31,6 +31,6 @@ int load_config(struct gmnisrv_config *conf, const char *path); void config_finish(struct gmnisrv_config *conf); struct gmnisrv_host *gmnisrv_config_get_host( - struct gmnisrv_config *conf, const char *hostname); + struct gmnisrv_config *conf, const char *hostname); #endif diff --git a/include/server.h b/include/server.h index 8547799..ac3bcac 100644 --- a/include/server.h +++ b/include/server.h @@ -1,14 +1,18 @@ #ifndef GMNISRV_SERVER #define GMNISRV_SERVER #include +#include #define GEMINI_MAX_URL 1024 struct gmnisrv_client { + struct sockaddr addr; + socklen_t addrlen; + char buf[GEMINI_MAX_URL + 2]; size_t bufln; + int sockfd; - int respfd; }; struct gmisrv_config; @@ -18,10 +22,15 @@ struct gmnisrv_server { struct pollfd *fds; nfds_t nfds, fdsz; + // nlisten is initialized once and does not change. The fds list starts + // with this many listening sockets, then has sockets for each active + // client, up to nfds. size_t nlisten; struct gmnisrv_client *clients; size_t nclients, clientsz; + + bool run; }; int server_init(struct gmnisrv_server *server, struct gmnisrv_config *conf); -- cgit v1.2.3