10 int objects, keys, values, size, i;
12 object_t *currentChild;
jsmntok_t *currentKey, *currentValue;
13 object_t *children_array;
jsmntok_t *keys_array, *values_array;
14 object_t *retVal = (object_t*) malloc(
sizeof(object_t)*2);
19 printf(
"Parse Obj given NULL token or Str");
25 retVal->parent = NULL;
26 size = token->
end; i = 0; objects = 0; keys = 0; values = 0;
27 currentChild = NULL; currentKey = NULL; currentValue = NULL;
28 children_array = NULL; keys_array = NULL; values_array = NULL;
41 currentChild->parent = retVal;
51 currentChild->parent = retVal;
56 currentKey = &token[i];
61 currentValue = &token[i];
72 currentChild->parent = retVal;
76 currentValue = &token[i];
85 printf(
"Dynam Alloc error : parseobj \n");
95 printf(
"Dynam Alloc eror : parseobj \n");
98 }
else if (currentValue)
102 printf(
"Dynam Alloc eror : parseobj \n");
107 printf(
"ParseObject Error: idk");
111 }
while( (size > token[i].start) && (token[i].type > 0) );
112 retVal->values = values_array;
113 retVal->keys = keys_array;
114 retVal->children = children_array;
115 memset(&retVal[1], 0,
sizeof(object_t));
123 object_t *retVal, *temp;
125 if(obj == NULL || name == NULL)
128 for(i = 0; temp[i].name != NULL; i++)
132 if(!strcmp(temp[i].name, name) )
146 int objects, objCount, retVal, i;
151 objects = 1 +
CountMem(obj->children,
sizeof(object_t));
154 while(objCount < objects)
172 int objects, temp, children;
173 objects =
CountMem(obj->children,
sizeof(object_t));
176 while (temp < objects)
178 if(obj->children[temp].children)
190 int objects, tempInt, i;
195 objects = 1 +
CountMem(obj->children,
sizeof(object_t));
197 while(tempInt < objects)
203 printf(
"%s ", obj->name);
206 if(obj->keys && obj->values)
209 while(obj->keys[i].type && obj->values[i].type)
211 printf(
"Key : %s \n",
JsmnToString(&obj->keys[i], g_str));
212 printf(
"Value : %s \n",
JsmnToString(&obj->values[i], g_str));
215 }
else if(obj->values)
218 while(obj->values[i].type)
220 printf(
"Value : %s \n",
JsmnToString(&obj->values[i], g_str));
227 if(&obj->children[tempInt-1] < &obj->children[objects])
244 *dst = (object_t*) realloc(*dst,
sizeof(object_t)*(size+1));
251 memset(*dst, 0,
sizeof(object_t));
253 ((*dst)[size-1]).name = src->name;
254 ((*dst)[size-1]).parent = src->parent;
258 for(i = 0; i < count+1; i++)
270 for(i = 0; i < count+1; i++)
280 count =
CountMem(src->children,
sizeof(object_t ));
281 for(i = 0; i < count+1; i++)
289 memset(&(*dst)[size], 0,
sizeof(object_t));
int CopyObjectToObjectArray(object_t **dst, object_t *src, int size)
int CountMem(void *src, int size_type)
int CountObjectChildren(object_t *obj)
object_t * FindObject(object_t *obj, char *name)
char * JsmnToString(jsmntok_t *token, char *g_str)
int CountObjectMembers(object_t *obj, char *g_str)
int AllocateDynamic(void **dst, void *src, int size_type, int size)
void PrintObject(object_t *obj, char *g_str)
object_t * ParseToObject(jsmntok_t *token, char *g_str)