mirror of
https://github.com/sheumann/DiskBrowser.git
synced 2024-11-25 17:43:15 +00:00
999b6130a4
There are only a few minor code changes, and nothing that should have an effect on functionality. This is basically just rearranging the code.
39 lines
1.0 KiB
C
39 lines
1.0 KiB
C
#ifdef __ORCAC__
|
|
#pragma noroot
|
|
#endif
|
|
|
|
#include <string.h>
|
|
#include "jsonutil.h"
|
|
|
|
json_value *findEntryInObject(json_value *obj, json_char *name, json_type type) {
|
|
if (obj == NULL || obj->type != json_object)
|
|
return NULL;
|
|
json_object_entry *entry = obj->u.object.values;
|
|
for (unsigned int i = 0; i < obj->u.object.length; i++,entry++) {
|
|
if (entry->name_length != strlen(name)) {
|
|
continue;
|
|
}
|
|
if (memcmp(name, entry->name, entry->name_length) == 0) {
|
|
if (entry->value->type == type)
|
|
return entry->value;
|
|
else
|
|
return NULL;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
|
|
boolean processArray(json_value *arr, json_type member_type, boolean (*f)(json_value*)) {
|
|
if (arr == NULL || arr->type != json_array)
|
|
return false;
|
|
for (unsigned int i = 0; i < arr->u.array.length; i++) {
|
|
json_value *v = arr->u.array.values[i];
|
|
if (v->type != member_type)
|
|
continue;
|
|
if (f(v) == false)
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|