From 1768210ea43a1a692f844f7497940ec7d3f28d3c Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Thu, 23 Nov 2023 00:04:28 +0100 Subject: [PATCH] Upgrade to new libweb interface Recent commits from libweb brought a few breaking changes. The one below affected slcl, so it had to be updated according to the new interface: commit 98f5f52461b0c1ab1ee3331722bd32e2db9e1d41 Author: Xavier Del Campo Date: Thu Nov 16 12:23:08 2023 +0100 Split handler_loop from handler_listen Some applications might set up a struct handler object to listen on any port i.e., 0, but still need a way to determine which port number was eventually selected by the implementation. Therefore, handler_listen has been reduced to the server initialization bit, whereas the main loop has been split into its own function, namely handler_loop. Because of these changes, it no longer made sense for libweb to write the selected port to standard output, as this is something now applications can do on their own. --- libweb | 2 +- main.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libweb b/libweb index b71a617..dec953e 160000 --- a/libweb +++ b/libweb @@ -1 +1 @@ -Subproject commit b71a6174e12b4709acaf8bc151938ba12d2a54f6 +Subproject commit dec953e4f4af89149685c7463c422ccca6174cb8 diff --git a/main.c b/main.c index 0c7be51..3f712d6 100644 --- a/main.c +++ b/main.c @@ -1325,7 +1325,7 @@ static int upload(const struct http_payload *const p, fprintf(stderr, "%s: auth_cookie failed\n", __func__); return page_forbidden(r); } - else if (p->u.post.expect_continue) + else if (p->expect_continue) { *r = (const struct http_response) { @@ -2089,11 +2089,21 @@ int main(int argc, char *argv[]) .user = a }; + unsigned short outport; + if (!(h = handler_alloc(&cfg)) || add_urls(h, a) - || handler_listen(h, port)) + || handler_listen(h, port, &outport)) goto end; + printf("Listening on port %hu\n", outport); + + if (handler_loop(h)) + { + fprintf(stderr, "%s: handler_loop failed\n", __func__); + goto end; + } + ret = EXIT_SUCCESS; end: