/** Get the value of the current element. */ char *ReadElementValue(const char *line, const char *file, int *lineNumber) { char *buffer; char ch; int len, max; int x; len = 0; max = BLOCK_SIZE; buffer = Allocate(max + 1); for(x = 0; !IsValueEnd(line[x]); x++) { if(line[x] == '&') { x += ParseEntity(line + x, &ch, file, *lineNumber) - 1; if(ch) { buffer[len] = ch; } else { buffer[len] = line[x]; } } else { if(line[x] == '\n') { ++*lineNumber; } buffer[len] = line[x]; } ++len; if(len >= max) { max += BLOCK_SIZE; buffer = Reallocate(buffer, max + 1); } } buffer[len] = 0; Trim(buffer); return buffer; }
static inline int get_json_nullvalue(char * valuestr,char * json_str) { int i; if((json_str[0]!='n')||(json_str[0]!='N')) return -EINVAL; for(i=0;i<6;i++) { if(json_str[i]==0) return -EINVAL; if(IsValueEnd(json_str[i])) break; valuestr[i]=json_str[i]; } if(i==0) return -EINVAL; if(i==6) return -EINVAL; valuestr[i]=0; return i; }
static inline int get_json_numvalue(char * valuestr,char * json_str) { int i; int point=0; if(json_str[0]!='.') { if((json_str[0]<'0')||(json_str[0]>'9')) return -EINVAL; } for(i=0;i<1024;i++) { if(json_str[i]==0) return -EINVAL; if(IsValueEnd(json_str[i])) break; valuestr[i]=json_str[i]; } if(i==0) return -EINVAL; if(i==1024) return -EINVAL; valuestr[i]=0; return i; }