Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Nov 8, 2023
1 parent 844b49d commit 5935dd0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion finger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
2 changes: 1 addition & 1 deletion gopher.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
5 changes: 0 additions & 5 deletions socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion spartan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
5 changes: 5 additions & 0 deletions tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5935dd0

Please sign in to comment.