summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2008-12-13 17:06:06 +0100
committerGravatar Jonathan Beck2008-12-13 17:06:06 +0100
commit3f0dfcf5f77659877f57c00f307ed46a96d0d0d1 (patch)
tree7e6eff5dc890087e1a906addcc018fbfba61ae6d
parentc39685d3a87858e7ad8ada0da2798aaf670969b4 (diff)
downloadlibplist-3f0dfcf5f77659877f57c00f307ed46a96d0d0d1.tar.gz
libplist-3f0dfcf5f77659877f57c00f307ed46a96d0d0d1.tar.bz2
complete find function to take length into account.
-rw-r--r--include/plist/plist.h2
-rw-r--r--src/plist.c10
2 files changed, 6 insertions, 6 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h
index 4469f06..b6335f5 100644
--- a/include/plist/plist.h
+++ b/include/plist/plist.h
@@ -60,7 +60,7 @@ plist_t plist_get_first_child(plist_t node);
plist_t plist_get_next_sibling(plist_t node);
plist_t plist_get_prev_sibling(plist_t node);
-plist_t plist_find_node(plist_t plist, plist_type type, void *value);
+plist_t plist_find_node(plist_t plist, plist_type type, void *value, uint64_t length);
void plist_get_type_and_value(plist_t node, plist_type * type, void *value, uint64_t * length);
//import and export functions
diff --git a/src/plist.c b/src/plist.c
index ca80c74..81cdfc5 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -135,7 +135,7 @@ plist_t plist_get_prev_sibling(plist_t node)
return (plist_t) g_node_prev_sibling((GNode *) node);
}
-char compare_node_value(plist_type type, plist_data_t data, void *value)
+char compare_node_value(plist_type type, plist_data_t data, void *value, uint64_t length)
{
char res = FALSE;
switch (type) {
@@ -156,7 +156,7 @@ char compare_node_value(plist_type type, plist_data_t data, void *value)
res = !wcscmp(data->unicodeval, ((wchar_t *) value));
break;
case PLIST_DATA:
- res = !strcmp(data->buff, ((char *) value));
+ res = memcmp(data->buff,(char*) value, length );
break;
case PLIST_ARRAY:
case PLIST_DICT:
@@ -167,7 +167,7 @@ char compare_node_value(plist_type type, plist_data_t data, void *value)
return res;
}
-plist_t plist_find_node(plist_t plist, plist_type type, void *value)
+plist_t plist_find_node(plist_t plist, plist_type type, void *value, uint64_t length)
{
if (!plist)
return NULL;
@@ -177,11 +177,11 @@ plist_t plist_find_node(plist_t plist, plist_type type, void *value)
plist_data_t data = plist_get_data(current);
- if (data->type == type && compare_node_value(type, data, value)) {
+ if (data->type == type && data->length == length && compare_node_value(type, data, value, length)) {
return current;
}
if (data->type == PLIST_DICT || data->type == PLIST_ARRAY) {
- plist_t sub = plist_find_node(current, type, value);
+ plist_t sub = plist_find_node(current, type, value, length);
if (sub)
return sub;
}