| version 1.9, 2002/02/25 18:45:56 |
version 1.10, 2002/04/08 20:57:35 |
| Line 43 cfg_cfgfile_get_next_opt(con) |
|
| Line 43 cfg_cfgfile_get_next_opt(con) |
|
| if (con->fhandle == NULL) |
if (con->fhandle == NULL) |
| return CFG_ERROR_FILE_NOT_FOUND; |
return CFG_ERROR_FILE_NOT_FOUND; |
| |
|
| if (con->begin_pos > 0 && |
if (con->flags & CFG_FILE_LINE_USAGE) { |
| fseek(con->fhandle, con->begin_pos, SEEK_SET) != 0) |
if (con->begin_pos > 0) { |
| return CFG_ERROR_SEEK_ERROR; |
con->cur_idx = 0; |
| |
con->cur_idx_tmp = 1; |
| |
|
| |
while (con->cur_idx_tmp < con->begin_pos) { |
| |
switch (fgetc(con->fhandle)) { |
| |
case EOF: |
| |
return CFG_ERROR_SEEK_ERROR; |
| |
case '\n': |
| |
con->cur_idx_tmp++; |
| |
} |
| |
} |
| |
} |
| |
} |
| |
else { |
| |
if (con->begin_pos > 0 && |
| |
fseek(con->fhandle, con->begin_pos, SEEK_SET) != 0) |
| |
return CFG_ERROR_SEEK_ERROR; |
| |
} |
| } |
} |
| |
|
| while (1) { |
while (1) { |
| |
if (con->flags & CFG_FILE_LINE_USAGE) { |
| |
con->cur_idx += con->cur_idx_tmp; |
| |
con->cur_idx_tmp = 0; |
| |
} |
| |
|
| ret = get_multi_line(con, &buf); |
ret = get_multi_line(con, &buf); |
| |
|
| if (ret != CFG_OK) { |
if (ret != CFG_OK) { |
| Line 66 cfg_cfgfile_get_next_opt(con) |
|
| Line 88 cfg_cfgfile_get_next_opt(con) |
|
| } |
} |
| } |
} |
| |
|
| if (feof(con->fhandle)) { |
if ((con->end_pos > 0 && cfg_get_cur_idx(con) > con->end_pos) |
| |
|| feof(con->fhandle)) { |
| if (buf != NULL) |
if (buf != NULL) |
| free(buf); |
free(buf); |
| |
|
| Line 122 get_multi_line(con, buf) |
|
| Line 145 get_multi_line(con, buf) |
|
| if (my_buf != NULL) |
if (my_buf != NULL) |
| free(my_buf); |
free(my_buf); |
| |
|
| con->cur_idx = ftell(con->fhandle); // not neccessary stuff |
|
| my_buf = dynamic_fgets(con->fhandle); |
my_buf = dynamic_fgets(con->fhandle); |
| if (my_buf == NULL) { |
if (my_buf == NULL) { |
| if (feof(con->fhandle)) |
if (feof(con->fhandle)) |
| Line 131 get_multi_line(con, buf) |
|
| Line 153 get_multi_line(con, buf) |
|
| return CFG_ERROR_NOMEM; |
return CFG_ERROR_NOMEM; |
| } |
} |
| |
|
| { // not neccessary stuff |
str_trim(my_buf); |
| int my_buf_size = strlen(my_buf); |
|
| str_left_trim(my_buf); |
|
| con->cur_idx += my_buf_size - strlen(my_buf); |
|
| |
|
| str_right_trim(my_buf); |
|
| } |
|
| |
|
| |
/* Is empty line or comment? */ |
| if (strlen(my_buf) == 0 |
if (strlen(my_buf) == 0 |
| || strdyn_str(my_buf, con->comment_prefix) == my_buf) { |
|| strdyn_str(my_buf, con->comment_prefix) == my_buf) { |
| |
|
| |
if (con->flags & CFG_FILE_LINE_USAGE) |
| |
con->cur_idx++; |
| |
|
| if (state == 0) |
if (state == 0) |
| continue; |
continue; |
| else |
else |
| break; |
break; |
| } |
} |
| |
else { |
| |
if (con->flags & CFG_FILE_LINE_USAGE) |
| |
con->cur_idx_tmp++; |
| |
} |
| |
|
| /* Multi line detection. */ |
/* Multi line detection. */ |
| { |
{ |