• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src/router/dropbox_client/

Lines Matching refs:item

95 /* Parse the input text to generate a number, and populate the result into item. */
96 static const char *parse_number(cJSON *item,const char *num)
112 item->valuedouble=n;
113 item->valueint=(int)n;
114 item->valuelong=(long long int)n;
115 item->type=cJSON_Number;
119 /* Render the number nicely from the given item into a string. */
120 static char *print_number(cJSON *item)
123 double d=item->valuedouble;
124 if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN)
127 if (str) sprintf(str,"%d",item->valueint);
142 /* Parse the input text into an unescaped cstring, and populate item. */
144 static const char *parse_string(cJSON *item,const char *str)
198 item->valuestring=out;
199 item->type=cJSON_String;
238 /* Invote print_string_ptr (which is useful) on an item. */
239 static char *print_string(cJSON *item) {return print_string_ptr(item->valuestring);}
242 static const char *parse_value(cJSON *item,const char *value);
243 static char *print_value(cJSON *item,int depth,int fmt);
244 static const char *parse_array(cJSON *item,const char *value);
245 static char *print_array(cJSON *item,int depth,int fmt);
246 static const char *parse_object(cJSON *item,const char *value);
247 static char *print_object(cJSON *item,int depth,int fmt);
268 /* Render a cJSON item/entity/structure to text. */
269 char *cJSON_Print(cJSON *item) {return print_value(item,0,1);}
270 char *cJSON_PrintUnformatted(cJSON *item) {return print_value(item,0,0);}
273 static const char *parse_value(cJSON *item,const char *value)
276 if (!strncmp(value,"null",4)) { item->type=cJSON_NULL; return value+4; }
277 if (!strncmp(value,"false",5)) { item->type=cJSON_False; return value+5; }
278 if (!strncmp(value,"true",4)) { item->type=cJSON_True; item->valueint=1; return value+4; }
279 if (*value=='\"') { return parse_string(item,value); }
280 if (*value=='-' || (*value>='0' && *value<='9')) { return parse_number(item,value); }
281 if (*value=='[') { return parse_array(item,value); }
282 if (*value=='{') { return parse_object(item,value); }
288 static char *print_value(cJSON *item,int depth,int fmt)
291 if (!item) return 0;
292 switch ((item->type)&255)
297 case cJSON_Number: out=print_number(item);break;
298 case cJSON_String: out=print_string(item);break;
299 case cJSON_Array: out=print_array(item,depth,fmt);break;
300 case cJSON_Object: out=print_object(item,depth,fmt);break;
306 static const char *parse_array(cJSON *item,const char *value)
311 item->type=cJSON_Array;
315 item->child=child=cJSON_New_Item();
316 if (!item->child) return 0; /* memory fail */
334 static char *print_array(cJSON *item,int depth,int fmt)
338 cJSON *child=item->child;
348 child=item->child;
385 static const char *parse_object(cJSON *item,const char *value)
390 item->type=cJSON_Object;
394 item->child=child=cJSON_New_Item();
395 if (!item->child) return 0;
421 static char *print_object(cJSON *item,int depth,int fmt)
425 cJSON *child=item->child;
438 child=item->child;depth++;if (fmt) len+=depth;
478 /* Get Array size/item / object item. */
480 cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c=array->child; while (c && item>0) item--,c=c->next; return c;}
484 static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}
486 static cJSON *create_reference(cJSON *item) {cJSON *ref=cJSON_New_Item();if (!ref) return 0;memcpy(ref,item,sizeof(cJSON));ref->string=0;ref->type|=cJSON_IsReference;ref->next=ref->prev=0;return ref;}
488 /* Add item to array/object. */
489 void cJSON_AddItemToArray(cJSON *array, cJSON *item) {cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}}
490 void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);}
491 void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));}
492 void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
507 cJSON *cJSON_CreateNull() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}
508 cJSON *cJSON_CreateTrue() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;}
509 cJSON *cJSON_CreateFalse() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;}
510 cJSON *cJSON_CreateBool(int b) {cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;}
511 cJSON *cJSON_CreateNumber(double num) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int)num;}return item;}
512 cJSON *cJSON_CreateString(const char *string) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);}return item;}
513 cJSON *cJSON_CreateArray() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;}
514 cJSON *cJSON_CreateObject() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;}