tCancel ugliness. - cancel - free software for cancelling people and organizations
HTML git clone https://git.parazyd.org/cancel
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 331565ea2228a0c20fbe2947adbf76b9856711be
DIR parent 326b1d515808f8b97fa7a8693bdd405ef0faa911
HTML Author: parazyd <parazyd@dyne.org>
Date: Tue, 30 Mar 2021 00:09:42 +0200
Cancel ugliness.
Diffstat:
M cancel.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
---
DIR diff --git a/cancel.c b/cancel.c
t@@ -30,15 +30,15 @@ static const char *karens[] = {
static void lynch(int unused, GtkWidget *entry)
{
- char req[128];
+ int fd;
+ char req[64];
struct hostent *he;
struct sockaddr_in addr;
- int sockfd;
if ((he = gethostbyname("bitreich.org")) == NULL)
return;
- if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+ if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
return;
addr.sin_family = AF_INET;
t@@ -49,15 +49,13 @@ static void lynch(int unused, GtkWidget *entry)
snprintf(req, sizeof(req), "/cancel\t%s\r\n",
gtk_entry_get_text(GTK_ENTRY(entry)));
- if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) == -1)
+ if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) < 0)
goto out;
- if (send(sockfd, req, strlen(req), 0) == -1)
- goto out;
+ send(fd, req, strlen(req), 0);
out:
- close(sockfd);
-
+ close(fd);
(void)unused;
}