src/xmlnode.h

Fri, 19 Mar 2004 17:34:33 +0000

author
Kevin Stange <kstange@pidgin.im>
date
Fri, 19 Mar 2004 17:34:33 +0000
changeset 8473
8acf91aaffac
parent 8262
fa907a654af9
child 9837
789d33edcda8
permissions
-rw-r--r--

[gaim-migrate @ 9206]
" You can once again show how evil you are by typing >:)
and getting it to render in spite of escaped HTML.

This patch changes around the parsing code to catch
smileys before eating just any HTML entity we bump into
on the street. We try to catch entities at the
beginning of smileys first, and if we're sure they're
not smileys, then we eat them for breakfast. The patch
also deals with eating any subsequent entities that may
appear in any smileys (like :-&) so we don't end up
with trailing leftovers. This patch description is
making me hungry.

FYI, I know this gtkimhtml is supposed to be not gaim
dependent, but both the gaim_* functions that were
preexisting and newly used in gtkimhtml code are all
non-gaim dependent utility functions from util.c, so I felt
their use was justified and acceptable." --Kevin Stange

committer: Luke Schierer <lschiere@pidgin.im>

7131
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /**
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
2 * @file xmlnode.h XML DOM functions
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * gaim
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
8046
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7642
diff changeset
6 * Gaim is the legal property of its developers, whose names are too numerous
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7642
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7642
diff changeset
8 * source distribution.
7131
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 *
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * (at your option) any later version.
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 *
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * GNU General Public License for more details.
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 *
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 */
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24 #ifndef _GAIM_XMLNODE_H_
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25 #define _GAIM_XMLNODE_H_
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
26
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
27 typedef enum _XMLNodeType
7131
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 {
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
29 XMLNODE_TYPE_TAG,
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
30 XMLNODE_TYPE_ATTRIB,
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
31 XMLNODE_TYPE_DATA
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
32 } XMLNodeType;
7131
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34 typedef struct _xmlnode
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35 {
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36 char *name;
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
37 XMLNodeType type;
7131
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38 char *data;
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39 size_t data_sz;
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40 struct _xmlnode *parent;
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41 struct _xmlnode *child;
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42 struct _xmlnode *next;
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43 } xmlnode;
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45 xmlnode *xmlnode_new(const char *name);
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46 xmlnode *xmlnode_new_child(xmlnode *parent, const char *name);
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 void xmlnode_insert_child(xmlnode *parent, xmlnode *child);
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 xmlnode *xmlnode_get_child(xmlnode *parent, const char *name);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8167
diff changeset
49 xmlnode *xmlnode_get_child_with_namespace(xmlnode *parent, const char *name, const char *xmlns);
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
50 xmlnode *xmlnode_get_next_twin(xmlnode *node);
7131
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51 void xmlnode_insert_data(xmlnode *parent, const char *data, size_t size);
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52 char *xmlnode_get_data(xmlnode *node);
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
53 void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value);
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
54 const char *xmlnode_get_attrib(xmlnode *node, const char *attr);
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
55 void xmlnode_remove_attrib(xmlnode *node, const char *attr);
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7131
diff changeset
56 char *xmlnode_to_str(xmlnode *node, int *len);
7131
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57 xmlnode *xmlnode_from_str(const char *str, size_t size);
8167
deae0da446a9 [gaim-migrate @ 8880]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
58 xmlnode *xmlnode_copy(xmlnode *src);
7131
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
59
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60 void xmlnode_free(xmlnode *node);
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
61
bde45b2e6bf3 [gaim-migrate @ 7698]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62 #endif /* _GAIM_XMLNODE_H_ */

mercurial