changeset 2584:34812d648f72

[gaim-migrate @ 2597] heh. this was pointless. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 23 Oct 2001 08:06:09 +0000
parents ce3df2c43f46
children 4424c670021d
files plugins/chatlist.c src/gaim.h src/html.c src/protocols/toc/toc.c
diffstat 4 files changed, 25 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/chatlist.c	Tue Oct 23 04:59:46 2001 +0000
+++ b/plugins/chatlist.c	Tue Oct 23 08:06:09 2001 +0000
@@ -208,7 +208,7 @@
 
 static void refresh_list(GtkWidget *w, gpointer *m)
 {
-	grab_url("http://www.aol.com/community/chat/allchats.html", ref_list_callback, NULL);
+	grab_url("http://www.aol.com/community/chat/allchats.html", FALSE, ref_list_callback, NULL);
 }
 
 static void add_chat(GtkWidget *w, gpointer *m)
--- a/src/gaim.h	Tue Oct 23 04:59:46 2001 +0000
+++ b/src/gaim.h	Tue Oct 23 08:06:09 2001 +0000
@@ -337,7 +337,7 @@
 extern gint sort_awaymsg_list(gconstpointer, gconstpointer);
 
 /* Functions in html.c */
-extern void grab_url(char *, void (*callback)(gpointer, char *), gpointer);
+extern void grab_url(char *, gboolean, void (*callback)(gpointer, char *), gpointer);
 extern gchar *strip_html(gchar *);
 
 /* Functions in idle.c */
--- a/src/html.c	Tue Oct 23 04:59:46 2001 +0000
+++ b/src/html.c	Tue Oct 23 08:06:09 2001 +0000
@@ -117,13 +117,15 @@
 	gpointer data;
 	struct g_url *website;
 	char *url;
+	gboolean full;
 
 	int inpa;
 
 	gboolean sentreq;
+	gboolean newline;
+	gboolean startsaving;
 	char *webdata;
 	int len;
-	gboolean startsaving;
 };
 
 static void grab_url_callback(gpointer dat, gint sock, GaimInputCondition cond)
@@ -141,7 +143,8 @@
 
 	if (!gunk->sentreq) {
 		char buf[256];
-		g_snprintf(buf, sizeof(buf), "GET /%s HTTP/1.0\r\n\r\n", gunk->website->page);
+		g_snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\n\r\n", gunk->full ? "" : "/",
+			   gunk->full ? gunk->url : gunk->website->page);
 		debug_printf("Request: %s\n", buf);
 		write(sock, buf, strlen(buf));
 		fcntl(sock, F_SETFL, O_NONBLOCK);
@@ -156,17 +159,22 @@
 			return;
 		}
 
-		if (!gunk->startsaving && data == '<') {
-			if (gunk->webdata)
-				g_free(gunk->webdata);
-			gunk->webdata = NULL;
-			gunk->len = 0;
-			gunk->startsaving = 1;
+		if (!gunk->startsaving) {
+			if (data == '\r')
+				return;
+			if (data == '\n') {
+				if (gunk->newline)
+					gunk->startsaving = TRUE;
+				else
+					gunk->newline = TRUE;
+				return;
+			}
+			gunk->newline = FALSE;
+		} else {
+			gunk->len++;
+			gunk->webdata = g_realloc(gunk->webdata, gunk->len);
+			gunk->webdata[gunk->len - 1] = data;
 		}
-
-		gunk->len++;
-		gunk->webdata = g_realloc(gunk->webdata, gunk->len);
-		gunk->webdata[gunk->len - 1] = data;
 	} else if (errno != ETIMEDOUT) {
 
 		gunk->webdata = g_realloc(gunk->webdata, gunk->len + 1);
@@ -194,7 +202,7 @@
 	}
 }
 
-void grab_url(char *url, void (*callback)(gpointer, char *), gpointer data)
+void grab_url(char *url, gboolean full, void (*callback)(gpointer, char *), gpointer data)
 {
 	int sock;
 	struct grab_url_data *gunk = g_new0(struct grab_url_data, 1);
@@ -203,6 +211,7 @@
 	gunk->data = data;
 	gunk->url = g_strdup(url);
 	gunk->website = parse_url(url);
+	gunk->full = full;
 
 	if ((sock = proxy_connect(gunk->website->address, gunk->website->port,
 				  grab_url_callback, gunk)) < 0) {
--- a/src/protocols/toc/toc.c	Tue Oct 23 04:59:46 2001 +0000
+++ b/src/protocols/toc/toc.c	Tue Oct 23 08:06:09 2001 +0000
@@ -768,7 +768,7 @@
 				gc->user->proto_opt[USEROPT_AUTHPORT][0] ?
 					atoi(gc->user->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT,
 				url);
-		grab_url(tmp, toc_got_info, NULL);
+		grab_url(tmp, FALSE, toc_got_info, NULL);
 	} else if (!strcasecmp(c, "DIR_STATUS")) {
 	} else if (!strcasecmp(c, "ADMIN_NICK_STATUS")) {
 	} else if (!strcasecmp(c, "ADMIN_PASSWD_STATUS")) {