changeset 7642:9008b5be4275

[gaim-migrate @ 8285] let the xmlnode stuff handle embedded NULLs (i'll need this later) committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Wed, 26 Nov 2003 17:28:13 +0000
parents a80010831ff8
children 834570cb8d86
files src/gtkblist.c src/protocols/jabber/auth.c src/protocols/jabber/buddy.c src/protocols/jabber/jabber.c src/protocols/jabber/jabber.h src/protocols/jabber/message.c src/xmlnode.c src/xmlnode.h
diffstat 8 files changed, 29 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkblist.c	Wed Nov 26 16:33:40 2003 +0000
+++ b/src/gtkblist.c	Wed Nov 26 17:28:13 2003 +0000
@@ -1113,7 +1113,7 @@
 		memcpy(&n, sd->data, sizeof(n));
 		if(gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), x, y, &path, &position)) {
 			/* if we're here, I think it means the drop is ok */	
-		GtkTreeIter iter;
+			GtkTreeIter iter;
 			GaimBlistNode *node;
 			GValue val = {0};
 			struct _gaim_gtk_blist_node *gtknode;
--- a/src/protocols/jabber/auth.c	Wed Nov 26 16:33:40 2003 +0000
+++ b/src/protocols/jabber/auth.c	Wed Nov 26 17:28:13 2003 +0000
@@ -46,7 +46,7 @@
 		if(gaim_account_get_bool(js->gc->account, "use_tls", TRUE) &&
 						gaim_ssl_is_supported()) {
 			jabber_send_raw(js,
-					"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");
+					"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>", -1);
 			return;
 		} else if(xmlnode_get_child(starttls, "required")) {
 			gaim_connection_error(js->gc, _("Server requires SSL for login"));
@@ -78,8 +78,9 @@
 	if(digest_md5) {
 		xmlnode_set_attrib(auth, "mechanism", "DIGEST-MD5");
 		js->auth_type = JABBER_AUTH_DIGEST_MD5;
-	/*
+		/*
 	} else if(plain) {
+		xmlnode_set_attrib(auth, "mechanism", "PLAIN");
 		js->auth_type = JABBER_AUTH_PLAIN;
 		*/
 	} else {
@@ -297,7 +298,8 @@
 			if(rspauth && js->expected_rspauth &&
 					!strcmp(rspauth, js->expected_rspauth)) {
 				jabber_send_raw(js,
-						"<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />");
+						"<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />",
+						-1);
 			} else {
 				gaim_connection_error(js->gc, _("Invalid challenge from server"));
 			}
@@ -358,7 +360,7 @@
 
 			buf = g_strdup_printf("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>%s</response>", enc_out);
 
-			jabber_send_raw(js, buf);
+			jabber_send_raw(js, buf, -1);
 
 			g_free(buf);
 
--- a/src/protocols/jabber/buddy.c	Wed Nov 26 16:33:40 2003 +0000
+++ b/src/protocols/jabber/buddy.c	Wed Nov 26 17:28:13 2003 +0000
@@ -422,7 +422,7 @@
 		}
 	}
 
-	p = xmlnode_to_str(vc_node);
+	p = xmlnode_to_str(vc_node, NULL);
 	xmlnode_free(vc_node);
 
 	account = gaim_connection_get_account(gc);
--- a/src/protocols/jabber/jabber.c	Wed Nov 26 16:33:40 2003 +0000
+++ b/src/protocols/jabber/jabber.c	Wed Nov 26 17:28:13 2003 +0000
@@ -56,7 +56,7 @@
 						  "version='1.0'>",
 						  js->user->domain);
 
-	jabber_send_raw(js, open_stream);
+	jabber_send_raw(js, open_stream, -1);
 
 	g_free(open_stream);
 }
@@ -215,7 +215,7 @@
 	}
 }
 
-void jabber_send_raw(JabberStream *js, const char *data)
+void jabber_send_raw(JabberStream *js, const char *data, int len)
 {
 	int ret;
 
@@ -225,9 +225,9 @@
 				js->gsc ? " (ssl)" : "", data);
 
 	if(js->gsc) {
-		ret = gaim_ssl_write(js->gsc, data, strlen(data));
+		ret = gaim_ssl_write(js->gsc, data, len == -1 ? strlen(data) : len);
 	} else {
-		ret = write(js->fd, data, strlen(data));
+		ret = write(js->fd, data, len == -1 ? strlen(data) : len);
 	}
 
 	if(ret < 0)
@@ -238,15 +238,16 @@
 void jabber_send(JabberStream *js, xmlnode *packet)
 {
 	char *txt;
+	int len;
 
-	txt = xmlnode_to_str(packet);
-	jabber_send_raw(js, txt);
+	txt = xmlnode_to_str(packet, &len);
+	jabber_send_raw(js, txt, len);
 	g_free(txt);
 }
 
 static void jabber_keepalive(GaimConnection *gc)
 {
-	jabber_send_raw(gc->proto_data, "\t");
+	jabber_send_raw(gc->proto_data, "\t", -1);
 }
 
 static void
@@ -307,7 +308,7 @@
 	js->gsc = gsc;
 
 	if(js->state == JABBER_STREAM_CONNECTING)
-		jabber_send_raw(js, "<?xml version='1.0' ?>");
+		jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
 
 	jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
 	gaim_ssl_input_add(gsc, jabber_recv_cb_ssl, gc);
@@ -328,7 +329,7 @@
 	js->fd = source;
 
 	if(js->state == JABBER_STREAM_CONNECTING)
-		jabber_send_raw(js, "<?xml version='1.0' ?>");
+		jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
 
 	jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
 	gc->inpa = gaim_input_add(js->fd, GAIM_INPUT_READ, jabber_recv_cb, gc);
@@ -722,7 +723,7 @@
 {
 	JabberStream *js = gc->proto_data;
 
-	jabber_send_raw(js, "</stream:stream>");
+	jabber_send_raw(js, "</stream:stream>", -1);
 
 	if(js->gsc) {
 		gaim_ssl_close(js->gsc);
--- a/src/protocols/jabber/jabber.h	Wed Nov 26 16:33:40 2003 +0000
+++ b/src/protocols/jabber/jabber.h	Wed Nov 26 17:28:13 2003 +0000
@@ -82,7 +82,7 @@
 
 void jabber_process_packet(JabberStream *js, xmlnode *packet);
 void jabber_send(JabberStream *js, xmlnode *data);
-void jabber_send_raw(JabberStream *js, const char *data);
+void jabber_send_raw(JabberStream *js, const char *data, int len);
 
 void jabber_stream_set_state(JabberStream *js, JabberStreamState state);
 
--- a/src/protocols/jabber/message.c	Wed Nov 26 16:33:40 2003 +0000
+++ b/src/protocols/jabber/message.c	Wed Nov 26 17:28:13 2003 +0000
@@ -278,7 +278,7 @@
 				jm->body = xmlnode_get_data(child);
 		} else if(!strcmp(child->name, "html")) {
 			if(!jm->xhtml)
-				jm->xhtml = xmlnode_to_str(child);
+				jm->xhtml = xmlnode_to_str(child, NULL);
 		} else if(!strcmp(child->name, "error")) {
 			const char *code = xmlnode_get_attrib(child, "code");
 			char *code_txt = NULL;
--- a/src/xmlnode.c	Wed Nov 26 16:33:40 2003 +0000
+++ b/src/xmlnode.c	Wed Nov 26 17:28:13 2003 +0000
@@ -233,7 +233,7 @@
 	return ret;
 }
 
-char *xmlnode_to_str(xmlnode *node)
+char *xmlnode_to_str(xmlnode *node, int *len)
 {
 	char *ret;
 	GString *text = g_string_new("");
@@ -264,12 +264,13 @@
 		for(c = node->child; c; c = c->next)
 		{
 			if(c->type == NODE_TYPE_TAG) {
-				esc = xmlnode_to_str(c);
-				g_string_append_printf(text, "%s", esc);
+				int esc_len;
+				esc = xmlnode_to_str(c, &esc_len);
+				text = g_string_append_len(text, esc, esc_len);
 				g_free(esc);
 			} else if(c->type == NODE_TYPE_DATA) {
 				esc = g_markup_escape_text(c->data, c->data_sz);
-				g_string_append_printf(text, "%s", esc);
+				text = g_string_append(text, esc);
 				g_free(esc);
 			}
 		}
@@ -282,6 +283,8 @@
 	g_free(node_name);
 
 	ret = text->str;
+	if(len)
+		*len = text->len;
 	g_string_free(text, FALSE);
 	return ret;
 }
--- a/src/xmlnode.h	Wed Nov 26 16:33:40 2003 +0000
+++ b/src/xmlnode.h	Wed Nov 26 17:28:13 2003 +0000
@@ -49,7 +49,7 @@
 void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value);
 const char *xmlnode_get_attrib(xmlnode *node, const char *attr);
 void xmlnode_remove_attrib(xmlnode *node, const char *attr);
-char *xmlnode_to_str(xmlnode *node);
+char *xmlnode_to_str(xmlnode *node, int *len);
 xmlnode *xmlnode_from_str(const char *str, size_t size);
 
 void xmlnode_free(xmlnode *node);