commit 600cfbed28e68094a263a77fac14d18bbe829213
parent a8f3425f16aa4dc1ce56b45b5ad5e8bdde8fc866
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Wed, 6 Jan 2021 23:19:40 -0800
Pass `timeout` as a parameter net.c functions
This makes the functions more useful and proper.
Diffstat:
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/command.c b/command.c
@@ -100,10 +100,10 @@ cextern(int argc, char **argv, int ino, char **item)
}
LOCAL int
-timid_gopher(char **addr, char *path, int bin)
+timid_gopher(char **addr, char *path, int bin, int timeout)
{
if (!exists(path))
- return gopher(addr, path, bin);
+ return gopher(addr, path, bin, timeout);
warn(EEXIST, "'%s'", path);
return 1;
}
@@ -128,7 +128,7 @@ cfetch(int argc, char **argv, int ino, char **item)
}
bin = **item == '0' ? 0 : 1;
- if (timid_gopher(itemtoaddr(item), path, bin))
+ if (timid_gopher(itemtoaddr(item), path, bin, timeout))
return NEXT;
warn(0, "%s: '%s%s' > '%s'", *argv, item[GI_HOST], item[GI_PATH], path);
return PASS;
diff --git a/main.c b/main.c
@@ -234,7 +234,7 @@ gawk(char **addr)
if (exists(cache)) {
mycache = 0;
} else {
- if (gopher(addr, cache, 0) == 1)
+ if (gopher(addr, cache, 0, timeout) == 1)
return ERROR;
mycache = 1;
}
diff --git a/net.c b/net.c
@@ -114,7 +114,7 @@ recvbin(int s, FILE *output)
}
int
-gph_recvto(int sock, char const *path, int bin)
+gph_recvto(int sock, char const *path, int bin, int timeout)
{
FILE *fp;
int status;
@@ -140,7 +140,7 @@ gph_recvto(int sock, char const *path, int bin)
}
int
-gopher(char **addr, char const *path, int bin)
+gopher(char **addr, char const *path, int bin, int timeout)
{
int sock;
@@ -149,7 +149,7 @@ gopher(char **addr, char const *path, int bin)
return 1;
if (gph_send(sock, addr[AR_PATH]) != 0 ||
- gph_recvto(sock, path, bin) != 0) {
+ gph_recvto(sock, path, bin, timeout) != 0) {
close(sock);
return 1;
}
diff --git a/net.h b/net.h
@@ -1,7 +1,7 @@
#ifndef _net_h
#define _net_h
-int gopher(char **, char const *, int);
+int gopher(char **, char const *, int, int);
int resolve(char const *, char const *, int);
#endif /* _net_h */