headers/main.c: Update to new handler interface

This commit is contained in:
Xavier Del Campo Romero 2023-11-20 17:05:21 +01:00
parent b94f76033f
commit bc1d77983a
Signed by: xavi
GPG Key ID: 84FF3612A9BF43F2
1 changed files with 11 additions and 2 deletions

View File

@ -44,7 +44,6 @@ static int on_length(const unsigned long long len,
int main(int argc, char *argv[])
{
int ret = EXIT_FAILURE;
const short port = 8080;
const struct handler_cfg cfg =
{
.length = on_length,
@ -67,12 +66,22 @@ int main(int argc, char *argv[])
goto end;
}
if (handler_listen(h, port))
unsigned short port;
if (handler_listen(h, 0, &port))
{
fprintf(stderr, "%s: handler_listen failed\n", __func__);
goto end;
}
printf("Listening on port %hu\n", port);
if (handler_loop(h))
{
fprintf(stderr, "%s: handler_loop failed\n", __func__);
goto end;
}
ret = EXIT_SUCCESS;
end: