From 514f2f58bd0ab9031b6a1bb39d88e2a4b4a618ed Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 22 Nov 2011 18:44:56 +0000 Subject: Clean up getgbook, and use redir_esc links --- getgbook.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/getgbook.c b/getgbook.c index 846dfe7..54a2d10 100644 --- a/getgbook.c +++ b/getgbook.c @@ -26,7 +26,7 @@ typedef struct { } Page; Page **pages; -int totalpages; +int numpages; char cookies[COOKIENUM][COOKIEMAX]; char bookid[STRMAX]; char *bookdir; @@ -39,13 +39,13 @@ int getpagelist() int i; Page *p; - snprintf(url, URLMAX, "/books?id=%s&printsec=frontcover", bookid); + snprintf(url, URLMAX, "/books?id=%s&printsec=frontcover&redir_esc=y", bookid); if(!get("books.google.com", url, NULL, NULL, &buf)) - return 0; + return 1; if((s = strstr(buf, "_OC_Run({\"page\":[")) == NULL) - return 0; + return 1; s+=strlen("_OC_Run({\"page\":["); for(i=0, p=pages[0];*s && iname, code, STRMAX)) { j = i; break; @@ -136,11 +139,12 @@ int getpage(Page *page) return 0; } -void searchpage(Page *page) { +int searchpage(Page *page) +{ int i, j; if(page->url[0] != '\0') - return; + return 0; for(i=0; inum); if((f = fopen(pgpath, "r")) != NULL) { fclose(f); @@ -207,7 +213,7 @@ int main(int argc, char *argv[]) sscanf(buf, "%15s", in); i = -1; if(argv[1][1] == 'c') { - for(a=0; aname, in, STRMAX) == 0) { i = a; break; @@ -215,7 +221,7 @@ int main(int argc, char *argv[]) } } else if(argv[1][1] == 'n') { sscanf(in, "%d", &n); - for(a=0; anum == n) { i = a; break; @@ -231,7 +237,7 @@ int main(int argc, char *argv[]) } } - for(i=0; i