锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
[SECTION]
key=data
key=data
key=data
key1=data2
]]>
[SECTION]
key=data
key=data
key=data
key1=data2
]]>
Row1=J ???????琚ぇ10 鐨勬浛鎹?
Row2=B
Row3=C
Row4=D
Row5=E
Row6=F
Row7=G
Row8=H
Row9=I
Row10=J ???????榪欎釜鍦版柟寮濮嬩互鍚庢病鏈夎緭鍑猴紝浣嗘槸瑕嗙洊浜?Row1 鐨勫?
Row11=K
]]>
int IniFile::parse_file(const char *section, const char *key, const char *buf,int *sec_s,int *sec_e,
int *key_s,int *key_e, int *value_s, int *value_e)
{
const char *p = buf;
int i=0;
assert(buf!=NULL);
assert(section != NULL && strlen(section));
assert(key != NULL && strlen(key));
*sec_e = *sec_s = *key_e = *key_s = *value_s = *value_e = -1;
while( !end_of_string(p[i]) ) {
//find the section
if( ( 0==i || newline(p[i-1]) ) && left_barce(p[i]) )
{
int section_start=i+1;
//find the ']'
do {
i++;
} while( !right_brace(p[i]) && !end_of_string(p[i]));
if( 0 == strncmp(p+section_start,section, i-section_start)) {
int newline_start=0;
i++;
//Skip over space char after ']'
while(isspace(p[i])) {
i++;
}
//find the section
*sec_s = section_start;
*sec_e = i;
while( ! (newline(p[i-1]) && left_barce(p[i]))
&& !end_of_string(p[i]) ) {
int j=0;
//get a new line
newline_start = i;
while( !newline(p[i]) && !end_of_string(p[i]) ) {
i++;
}
//now i is equal to end of the line
j = newline_start;
int valid = j;
if('#' != p[j]) //skip over comment
{
while(j < i && p[j]!='=') {
j++;
if(' ' != p[j] && '\t' != p[j] && '=' != p[j])
valid = j;
if('=' == p[j]) {
if(strncmp(key,p+newline_start,valid-newline_start)==0)
{
//find the key ok
*key_s = newline_start;
*key_e = j-1;
valid = j+1;
while(' ' == p[valid] || '\t' == p[valid])
valid++;
*value_s = valid;
*value_e = i;
return 1;
}
}
}
}
i++;
}
}
}
else
{
i++;
}
}
return 0;
}
]]>
榪欑=涓よ竟甯︽湁絀烘牸鎴朶t鐨勬牸寮?
int IniFile::parse_file(const char *section, const char *key, const char *buf,int *sec_s,int *sec_e,
int *key_s,int *key_e, int *value_s, int *value_e)
{
const char *p = buf;
int i=0;
assert(buf!=NULL);
assert(section != NULL && strlen(section));
assert(key != NULL && strlen(key));
*sec_e = *sec_s = *key_e = *key_s = *value_s = *value_e = -1;
while( !end_of_string(p[i]) ) {
//find the section
if( ( 0==i || newline(p[i-1]) ) && left_barce(p[i]) )
{
int section_start=i+1;
//find the ']'
do {
i++;
} while( !right_brace(p[i]) && !end_of_string(p[i]));
if( 0 == strncmp(p+section_start,section, i-section_start)) {
int newline_start=0;
i++;
//Skip over space char after ']'
while(isspace(p[i])) {
i++;
}
//find the section
*sec_s = section_start;
*sec_e = i;
while( ! (newline(p[i-1]) && left_barce(p[i]))
&& !end_of_string(p[i]) ) {
int j=0;
//get a new line
newline_start = i;
while( !newline(p[i]) && !end_of_string(p[i]) ) {
i++;
}
//now i is equal to end of the line
j = newline_start;
int valid = j;
if('#' != p[j]) //skip over comment
{
while(j < i && p[j]!='=') {
j++;
if('=' == p[j]) {
if(strncmp(key,p+newline_start,valid-newline_start)==0)
{
//find the key ok
*key_s = newline_start;
*key_e = j-1;
while(' ' == p[valid] || '\t' == p[valid])
valid++;
*value_s = valid;
*value_e = i;
return 1;
}
}
if(' ' != p[j] && '\t' != p[j])
valid = j;
}
}
i++;
}
}
}
else
{
i++;
}
}
return 0;
}
]]>
]]>
]]>
]]>