diff options
| author | Xavier Del Campo <xavier.delcampo@midokura.com> | 2023-11-16 12:23:08 +0100 |
|---|---|---|
| committer | Xavier Del Campo <xavier.delcampo@midokura.com> | 2023-11-20 16:06:19 +0100 |
| commit | 98f5f52461b0c1ab1ee3331722bd32e2db9e1d41 (patch) | |
| tree | 9ef7ad87da6f857af6e82e1067c4ffb83a795035 /handler.c | |
| parent | 8280cc40b94a89fc4d22a1954478a7a55da2800c (diff) | |
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 'handler.c')
| -rw-r--r-- | handler.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -182,14 +182,20 @@ end: return ret; } -int handler_listen(struct handler *const h, const unsigned short port) +int handler_listen(struct handler *const h, const unsigned short port, + unsigned short *const outport) { - if (!(h->server = server_init(port))) + if (!(h->server = server_init(port, outport))) { fprintf(stderr, "%s: server_init failed\n", __func__); return -1; } + return 0; +} + +int handler_loop(struct handler *const h) +{ for (;;) { bool exit, io; |
