diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-11-23 00:04:28 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-11-23 00:06:09 +0100 |
| commit | 1768210ea43a1a692f844f7497940ec7d3f28d3c (patch) | |
| tree | e1a1ba4a6948e5dca4bc0a29909cf97f1970463f /main.c | |
| parent | daffea4660560f7420e57ecc40b29f6ef3c46f98 (diff) | |
| download | slcl-1768210ea43a1a692f844f7497940ec7d3f28d3c.tar.gz | |
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 <xavier.delcampo@midokura.com>
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.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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,10 +2089,20 @@ 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; |
