summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNick White <hg@njw.me.uk>2011-07-16 01:15:26 +0100
committerNick White <hg@njw.me.uk>2011-07-16 01:15:26 +0100
commit5f2172cc8ca50cea7d09b4a569f958a3015f33e7 (patch)
treee75a7f2ca688bd9162ee8a6c7b17039c6e3c395f /util.c
parent3a1a5d42d6d019d63736960c8b9aea27f9a0315d (diff)
Simplify http get code
Diffstat (limited to 'util.c')
-rw-r--r--util.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/util.c b/util.c
index 5c3cb23..fc5c5c5 100644
--- a/util.c
+++ b/util.c
@@ -34,17 +34,20 @@ static int dial(char *host, char *port) {
return srv;
}
-char *get(FILE *srv, char *host, char *path) {
+char *get(char *host, char *path) {
size_t l, res;
int fd, i;
char *buf, *c, *p;
+ FILE *srv;
+
+ fd = dial("books.google.com", "80");
+ srv = fdopen(fd, "r+");
fprintf(srv, "GET %s HTTP/1.0\r\nUser-Agent: getgbook-"VERSION" (not mozilla)\r\nHost: %s\r\n\r\n", path, host);
fflush(srv);
l=0;
- fd = fileno(srv);
buf = malloc(sizeof(char *) * 4096);
for(i=0; (res = read(fd, buf+l, 4096)) > 0; l+=res, i++)