Mercurial > pidgin
comparison libgaim/xmlnode.c @ 15203:f814b2df9cce
[gaim-migrate @ 17993]
Blocking on Google Talk. Our Privacy API sucks so bad that even with no prior support for blocking in Jabber, this has no interface changes. If someone wanted to implement the deprecated Jabber privacy lists API, though, that would be ok by me.
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Thu, 14 Dec 2006 04:56:54 +0000 |
| parents | 50f263712df1 |
| children | c65def04fb44 |
comparison
equal
deleted
inserted
replaced
| 15202:b8ae75fa8d67 | 15203:f814b2df9cce |
|---|---|
| 140 } | 140 } |
| 141 sibling = attr_node; | 141 sibling = attr_node; |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 | |
| 146 void | |
| 147 xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns) | |
| 148 { | |
| 149 xmlnode *attr_node, *sibling = NULL; | |
| 150 | |
| 151 g_return_if_fail(node != NULL); | |
| 152 g_return_if_fail(attr != NULL); | |
| 153 | |
| 154 for(attr_node = node->child; attr_node; attr_node = attr_node->next) | |
| 155 { | |
| 156 if(attr_node->type == XMLNODE_TYPE_ATTRIB && | |
| 157 !strcmp(attr_node->name, attr) && | |
| 158 !strcmp(attr_node->xmlns, xmlns)) { | |
| 159 if(node->child == attr_node) { | |
| 160 node->child = attr_node->next; | |
| 161 } else if (node->lastchild == attr_node) { | |
| 162 node->lastchild = sibling; | |
| 163 } else { | |
| 164 sibling->next = attr_node->next; | |
| 165 } | |
| 166 xmlnode_free(attr_node); | |
| 167 return; | |
| 168 } | |
| 169 sibling = attr_node; | |
| 170 } | |
| 171 } | |
| 172 | |
| 145 void | 173 void |
| 146 xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value) | 174 xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value) |
| 147 { | 175 { |
| 148 xmlnode *attrib_node; | 176 xmlnode *attrib_node; |
| 149 | 177 |
| 158 attrib_node->data = g_strdup(value); | 186 attrib_node->data = g_strdup(value); |
| 159 | 187 |
| 160 xmlnode_insert_child(node, attrib_node); | 188 xmlnode_insert_child(node, attrib_node); |
| 161 } | 189 } |
| 162 | 190 |
| 191 void | |
| 192 xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value) | |
| 193 { | |
| 194 xmlnode *attrib_node; | |
| 195 | |
| 196 g_return_if_fail(node != NULL); | |
| 197 g_return_if_fail(attr != NULL); | |
| 198 g_return_if_fail(value != NULL); | |
| 199 | |
| 200 xmlnode_remove_attrib_with_namespace(node, attr, xmlns); | |
| 201 | |
| 202 attrib_node = new_node(attr, XMLNODE_TYPE_ATTRIB); | |
| 203 | |
| 204 attrib_node->data = g_strdup(value); | |
| 205 attrib_node->xmlns = g_strdup(xmlns); | |
| 206 | |
| 207 xmlnode_insert_child(node, attrib_node); | |
| 208 } | |
| 209 | |
| 163 const char * | 210 const char * |
| 164 xmlnode_get_attrib(xmlnode *node, const char *attr) | 211 xmlnode_get_attrib(xmlnode *node, const char *attr) |
| 165 { | 212 { |
| 166 xmlnode *x; | 213 xmlnode *x; |
| 167 | 214 |
| 172 return x->data; | 219 return x->data; |
| 173 } | 220 } |
| 174 } | 221 } |
| 175 | 222 |
| 176 return NULL; | 223 return NULL; |
| 224 } | |
| 225 | |
| 226 const char * | |
| 227 xmlnode_get_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns) | |
| 228 { | |
| 229 xmlnode *x; | |
| 230 | |
| 231 g_return_val_if_fail(node != NULL, NULL); | |
| 232 | |
| 233 for(x = node->child; x; x = x->next) { | |
| 234 if(x->type == XMLNODE_TYPE_ATTRIB && | |
| 235 !strcmp(attr, x->name) && !strcmp(x->xmlns, xmlns)) { | |
| 236 return x->data; | |
| 237 } | |
| 238 } | |
| 239 | |
| 240 return NULL; | |
| 177 } | 241 } |
| 178 | 242 |
| 179 | 243 |
| 180 void xmlnode_set_namespace(xmlnode *node, const char *xmlns) | 244 void xmlnode_set_namespace(xmlnode *node, const char *xmlns) |
| 181 { | 245 { |
