From be94666290ee3530a7aae0e85f3fa52fc29bc62e Mon Sep 17 00:00:00 2001 From: Nick White Date: Sat, 16 Jul 2011 14:28:14 +0100 Subject: added gettofile function, other cleanups --- getgbook.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'getgbook.c') 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,"")) == 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); -- cgit v1.2.3