summaryrefslogtreecommitdiff
path: root/getgbook.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 /getgbook.c
parent3a1a5d42d6d019d63736960c8b9aea27f9a0315d (diff)
Simplify http get code
Diffstat (limited to 'getgbook.c')
-rw-r--r--getgbook.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/getgbook.c b/getgbook.c
index bb809d4..ae47993 100644
--- a/getgbook.c
+++ b/getgbook.c
@@ -33,13 +33,8 @@ pgtype pgtypes[] = {
char *getbookid(char *isbn)
{
char url[URLMAX];
- int i;
- FILE *srv;
char *buf, *bookid, *c;
- i = dial("books.google.com", "80");
- srv = fdopen(i, "r+");
-
/* NOTE: new api returns json, and looks like this:
* http://www.googleapis.com/books/v1/volumes?q=isbn:1589235126
* (this needs https, which we don't yet support) */
@@ -48,7 +43,7 @@ char *getbookid(char *isbn)
bookid = malloc(sizeof(char *) * BOOKID_LEN);
- if((buf = get(srv, "books.google.com", url)) == NULL)
+ if((buf = get("books.google.com", url)) == NULL)
return NULL;
if((c = strstr(buf,"<dc:identifier>")) == NULL)
@@ -63,16 +58,12 @@ char *getbookid(char *isbn)
char *getpageurl(char *bookid, char *pg)
{
char url[URLMAX];
- int i, l;
- FILE *srv;
+ int l;
char *buf, *c, *d, m[80], *pageurl;
- i = dial("books.google.com", "80");
- srv = fdopen(i, "r+");
-
snprintf(url, URLMAX, "/books?id=%s&pg=%s&jscmd=click3", bookid, pg);
- if((buf = get(srv, "books.google.com", url)) == NULL)
+ if((buf = get("books.google.com", url)) == NULL)
return NULL;
snprintf(m, 80, "\"pid\":\"%s\"", pg);