summaryrefslogtreecommitdiffstats
path: root/src/plist.c
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 /src/plist.c
parentc39685d3a87858e7ad8ada0da2798aaf670969b4 (diff)
downloadlibplist-3f0dfcf5f77659877f57c00f307ed46a96d0d0d1.tar.gz
libplist-3f0dfcf5f77659877f57c00f307ed46a96d0d0d1.tar.bz2
complete find function to take length into account.
Diffstat (limited to 'src/plist.c')
-rw-r--r--src/plist.c10
1 files changed, 5 insertions, 5 deletions
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)
135 return (plist_t) g_node_prev_sibling((GNode *) node); 135 return (plist_t) g_node_prev_sibling((GNode *) node);
136} 136}
137 137
138char compare_node_value(plist_type type, plist_data_t data, void *value) 138char compare_node_value(plist_type type, plist_data_t data, void *value, uint64_t length)
139{ 139{
140 char res = FALSE; 140 char res = FALSE;
141 switch (type) { 141 switch (type) {
@@ -156,7 +156,7 @@ char compare_node_value(plist_type type, plist_data_t data, void *value)
156 res = !wcscmp(data->unicodeval, ((wchar_t *) value)); 156 res = !wcscmp(data->unicodeval, ((wchar_t *) value));
157 break; 157 break;
158 case PLIST_DATA: 158 case PLIST_DATA:
159 res = !strcmp(data->buff, ((char *) value)); 159 res = memcmp(data->buff,(char*) value, length );
160 break; 160 break;
161 case PLIST_ARRAY: 161 case PLIST_ARRAY:
162 case PLIST_DICT: 162 case PLIST_DICT:
@@ -167,7 +167,7 @@ char compare_node_value(plist_type type, plist_data_t data, void *value)
167 return res; 167 return res;
168} 168}
169 169
170plist_t plist_find_node(plist_t plist, plist_type type, void *value) 170plist_t plist_find_node(plist_t plist, plist_type type, void *value, uint64_t length)
171{ 171{
172 if (!plist) 172 if (!plist)
173 return NULL; 173 return NULL;
@@ -177,11 +177,11 @@ plist_t plist_find_node(plist_t plist, plist_type type, void *value)
177 177
178 plist_data_t data = plist_get_data(current); 178 plist_data_t data = plist_get_data(current);
179 179
180 if (data->type == type && compare_node_value(type, data, value)) { 180 if (data->type == type && data->length == length && compare_node_value(type, data, value, length)) {
181 return current; 181 return current;
182 } 182 }
183 if (data->type == PLIST_DICT || data->type == PLIST_ARRAY) { 183 if (data->type == PLIST_DICT || data->type == PLIST_ARRAY) {
184 plist_t sub = plist_find_node(current, type, value); 184 plist_t sub = plist_find_node(current, type, value, length);
185 if (sub) 185 if (sub)
186 return sub; 186 return sub;
187 } 187 }