summaryrefslogtreecommitdiff
path: root/getgbook.c
diff options
context:
space:
mode:
authorNick White <hg@njw.me.uk>2011-07-16 14:28:14 +0100
committerNick White <hg@njw.me.uk>2011-07-16 14:28:14 +0100
commitbe94666290ee3530a7aae0e85f3fa52fc29bc62e (patch)
tree9a4294c40c2d0cb404cac1f9d40f3302dcb50bd8 /getgbook.c
parent5c67237f618de1b8f9b780a0f9ea6bb2ef84d20c (diff)
added gettofile function, other cleanups
Diffstat (limited to 'getgbook.c')
-rw-r--r--getgbook.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/getgbook.c b/getgbook.c
index 358d8c3..fe4ccd1 100644
--- a/getgbook.c
+++ b/getgbook.c
@@ -43,7 +43,7 @@ char *getbookid(char *isbn)
bookid = malloc(sizeof(char *) * BOOKID_LEN);
- if((buf = get("books.google.com", url)) == NULL)
+ if(!get("books.google.com", url, &buf))
return NULL;
if((c = strstr(buf,"<dc:identifier>")) == NULL)
@@ -62,7 +62,7 @@ char *getpageurl(char *bookid, char *pg)
snprintf(url, URLMAX, "/books?id=%s&pg=%s&jscmd=click3", bookid, pg);
- if((buf = get("books.google.com", url)) == NULL)
+ if(!get("books.google.com", url, &buf))
return NULL;
snprintf(m, 80, "\"pid\":\"%s\"", pg);
@@ -105,10 +105,12 @@ int main(int argc, char *argv[])
printf("bookid is %s\n", bookid);
strncpy(pg, "PA2", 12);
- if((url = getpageurl(bookid, pg)) != NULL)
- printf("page %s url is %s\n", pg, url);
- else
+ if((url = getpageurl(bookid, pg)) == NULL)
fprintf(stderr, "Could not find page %s\n", pg);
+ else {
+ printf("page %s url is %s\n", pg, url);
+ gettofile(url, "test.png");
+ }
}
free(bookid);