annotate libpurple/plugins/perl/common/XMLNode.xs @ 28875:8464e695c62b

Fixes a bad MSN bug where passwords with multi-byte utf8 characters near the 16 byte mark would cause a segmentation fault due to chopping the multi-byte character and turning the string into invalidate utf8. Thanks to Shaun Lindsay at Meebo for tracking this down and fixing it.
author Mark Doliner <mark@kingant.net>
date Wed, 04 Nov 2009 18:41:21 +0000
parents 1662dbdac18c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 #include "module.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
3 MODULE = Purple::XMLNode PACKAGE = Purple::XMLNode PREFIX = xmlnode_
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 PROTOTYPES: ENABLE
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
6 Purple::XMLNode
28297
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
7 xmlnode_copy(src)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
8 Purple::XMLNode src
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 xmlnode_free(node)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
12 Purple::XMLNode node
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
14 Purple::XMLNode
28297
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
15 xmlnode_from_str(const char *str, gssize length(str))
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
16 PROTOTYPE: $
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 const char *
28298
ba57b7deb58a Add Purple::XMLNode::get_name()
Paul Aurich <paul@darkrain42.org>
parents: 28297
diff changeset
19 xmlnode_get_name(node)
ba57b7deb58a Add Purple::XMLNode::get_name()
Paul Aurich <paul@darkrain42.org>
parents: 28297
diff changeset
20 Purple::XMLNode node
ba57b7deb58a Add Purple::XMLNode::get_name()
Paul Aurich <paul@darkrain42.org>
parents: 28297
diff changeset
21 CODE:
ba57b7deb58a Add Purple::XMLNode::get_name()
Paul Aurich <paul@darkrain42.org>
parents: 28297
diff changeset
22 RETVAL = node->name;
ba57b7deb58a Add Purple::XMLNode::get_name()
Paul Aurich <paul@darkrain42.org>
parents: 28297
diff changeset
23 OUTPUT:
ba57b7deb58a Add Purple::XMLNode::get_name()
Paul Aurich <paul@darkrain42.org>
parents: 28297
diff changeset
24 RETVAL
ba57b7deb58a Add Purple::XMLNode::get_name()
Paul Aurich <paul@darkrain42.org>
parents: 28297
diff changeset
25
ba57b7deb58a Add Purple::XMLNode::get_name()
Paul Aurich <paul@darkrain42.org>
parents: 28297
diff changeset
26 const char *
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 xmlnode_get_attrib(node, attr)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
28 Purple::XMLNode node
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 const char *attr
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
31 Purple::XMLNode
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 xmlnode_get_child(parent, name)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
33 Purple::XMLNode parent
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 const char *name
28470
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
35 PREINIT:
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
36 xmlnode *tmp;
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
37 CODE:
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
38 if (!name || *name == '\0') {
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
39 tmp = parent->child;
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
40 while (tmp && tmp->type != XMLNODE_TYPE_TAG)
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
41 tmp = tmp->next;
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
42 RETVAL = tmp;
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
43 } else
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
44 RETVAL = xmlnode_get_child(parent, name);
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
45 OUTPUT:
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
46 RETVAL
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
48 Purple::XMLNode
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 xmlnode_get_child_with_namespace(parent, name, xmlns)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
50 Purple::XMLNode parent
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 const char *name
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 const char *xmlns
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 gchar_own *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 xmlnode_get_data(node)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
56 Purple::XMLNode node
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
58 Purple::XMLNode
28470
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
59 xmlnode_get_next(node)
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
60 Purple::XMLNode node
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
61 PREINIT:
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
62 xmlnode *tmp;
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
63 CODE:
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
64 tmp = node->next;
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
65 while (tmp && tmp->type != XMLNODE_TYPE_TAG)
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
66 tmp = tmp->next;
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
67 RETVAL = tmp;
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
68 OUTPUT:
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
69 RETVAL
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
70
1662dbdac18c Add two XMLNode accessors for iterating through the children of an XMLNode.
Paul Aurich <paul@darkrain42.org>
parents: 28298
diff changeset
71 Purple::XMLNode
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 xmlnode_get_next_twin(node)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
73 Purple::XMLNode node
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 xmlnode_insert_child(parent, child)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
77 Purple::XMLNode parent
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
78 Purple::XMLNode child
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 xmlnode_insert_data(node, data, size)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
82 Purple::XMLNode node
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 const char *data
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 gssize size
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
86 Purple::XMLNode
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 xmlnode_new(class, name)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 const char *name
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 C_ARGS:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 name
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
92 Purple::XMLNode
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 xmlnode_new_child(parent, name)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
94 Purple::XMLNode parent
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 const char *name
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 xmlnode_remove_attrib(node, attr)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
99 Purple::XMLNode node
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 const char *attr
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 xmlnode_set_attrib(node, attr, value)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
104 Purple::XMLNode node
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 const char *attr
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 const char *value
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 gchar_own *
28297
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
109 xmlnode_to_formatted_str(node)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
110 Purple::XMLNode node
28297
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
111 CODE:
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
112 RETVAL = xmlnode_to_formatted_str(node, NULL);
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
113 OUTPUT:
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
114 RETVAL
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 gchar_own *
28297
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
117 xmlnode_to_str(node)
15834
2f8274ce570a Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15374
diff changeset
118 Purple::XMLNode node
28297
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
119 CODE:
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
120 RETVAL = xmlnode_to_str(node, NULL);
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
121 OUTPUT:
491af22d8a01 Fix the Perl XMLNode API so that calls don't need to explicitly pass
Etan Reisner <pidgin@unreliablesource.net>
parents: 15834
diff changeset
122 RETVAL