From 5935dd0447e2f1e590b081225b7b58f9cd9b94c4 Mon Sep 17 00:00:00 2001 From: Dima Krasner Date: Wed, 8 Nov 2023 18:21:02 +0200 Subject: [PATCH] cleanup --- finger.c | 2 +- gopher.c | 2 +- socket.c | 5 ----- spartan.c | 2 +- tcp.c | 5 +++++ 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/finger.c b/finger.c index 9da3277..dad88cf 100644 --- a/finger.c +++ b/finger.c @@ -48,4 +48,4 @@ static void *finger_download(const Selector *sel, URL *url, char **mime, Parser } -const Protocol finger = {"finger", "79", tcp_read, tcp_peek, socket_error, socket_close, finger_download}; +const Protocol finger = {"finger", "79", tcp_read, tcp_peek, socket_error, tcp_close, finger_download}; diff --git a/gopher.c b/gopher.c index 9cfe6c9..79ec2d2 100644 --- a/gopher.c +++ b/gopher.c @@ -142,4 +142,4 @@ static void *gopher_download(const Selector *sel, URL *url, char **mime, Parser } -const Protocol gopher = {"gopher", "70", tcp_read, tcp_peek, socket_error, socket_close, gopher_download}; +const Protocol gopher = {"gopher", "70", tcp_read, tcp_peek, socket_error, tcp_close, gopher_download}; diff --git a/socket.c b/socket.c index 5338db5..575bacf 100644 --- a/socket.c +++ b/socket.c @@ -26,8 +26,3 @@ static int socket_error(const URL *url, void *c, int err) { else error(0, "failed to download `%s`: %s", url->url, strerror(errno)); return 1; } - - -static void socket_close(void *c) { - close((int)(intptr_t)c); -} diff --git a/spartan.c b/spartan.c index e334079..0d1270f 100644 --- a/spartan.c +++ b/spartan.c @@ -110,4 +110,4 @@ static void *spartan_download(const Selector *sel, URL *url, char **mime, Parser } -const Protocol spartan = {"spartan", "300", tcp_read, tcp_peek, socket_error, socket_close, spartan_download}; +const Protocol spartan = {"spartan", "300", tcp_read, tcp_peek, socket_error, tcp_close, spartan_download}; diff --git a/tcp.c b/tcp.c index ed657f5..8519410 100644 --- a/tcp.c +++ b/tcp.c @@ -29,6 +29,11 @@ static int tcp_peek(void *c, void *buffer, int length) { } +static void tcp_close(void *c) { + close((int)(intptr_t)c); +} + + static ssize_t sendall(int sockfd, const void *buf, size_t len, int flags) { ssize_t sent = 0, total; for (total = 0; total < (ssize_t)len && (sent = send(sockfd, (char *)buf + total, len - total, flags)) > 0; total += sent);