1 /*
2 * Copyright (C) 2007 Colin DIDIER
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #include <string.h>
19 #include "loudmouth/loudmouth.h"
20
21 LmMessageNode *
lm_find_node(LmMessageNode * node,const char * name,const char * attribute,const char * value)22 lm_find_node(LmMessageNode *node, const char *name,
23 const char *attribute, const char *value)
24 {
25 LmMessageNode *l;
26 const char *v;
27
28 g_return_val_if_fail(name != NULL, NULL);
29 g_return_val_if_fail(attribute != NULL, NULL);
30 g_return_val_if_fail(value != NULL, NULL);
31 if (node == NULL)
32 return NULL;
33 for (l = node->children; l != NULL; l = l->next)
34 if (strcmp(l->name, name) == 0) {
35 v = lm_message_node_get_attribute(l, attribute);
36 if (v != NULL && strcmp(value, v) == 0)
37 return l;
38 }
39 return NULL;
40 }
41