| version 1.17, 2002/07/15 14:45:54 |
version 1.18, 2002/07/16 13:42:11 |
|
|
| * ____________________________________________________________ |
* ____________________________________________________________ |
| * |
* |
| * Developed by Ondrej Jombik <nepto@pobox.sk> |
* Developed by Ondrej Jombik <nepto@pobox.sk> |
| * and Lubomir Host <rajo@host.sk> |
* and Lubomir Host <rajo@host.sk> |
| * Copyright (c) 2001-2002 Platon SDG, http://www.platon.sk/ |
* Copyright (c) 2001-2002 Platon SDG, http://www.platon.sk/ |
| * All rights reserved. |
* All rights reserved. |
| * |
* |
| Line 62 cfg_cfgfile_get_next_opt(con) |
|
| Line 62 cfg_cfgfile_get_next_opt(con) |
|
| |
|
| con->error_code = CFG_OK; |
con->error_code = CFG_OK; |
| |
|
| |
/* Initial position seek */ |
| if (con->fhandle == NULL) { |
if (con->fhandle == NULL) { |
| con->fhandle = con->filename != NULL |
con->fhandle = con->filename != NULL |
| ? fopen(con->filename, "r") |
? fopen(con->filename, "r") |
| Line 72 cfg_cfgfile_get_next_opt(con) |
|
| Line 73 cfg_cfgfile_get_next_opt(con) |
|
| } |
} |
| |
|
| if (con->flags & CFG_FILE_LINE_POS_USAGE) { |
if (con->flags & CFG_FILE_LINE_POS_USAGE) { |
| |
/* If negative line is specified, returns seek error. |
| |
If 0 is specified, do nothing. |
| |
If number > 0 is specified make appropriate line seek. */ |
| |
if (con->begin_pos < 0) { |
| |
con->error_code = CFG_ERROR_SEEK_ERROR; |
| |
return con->error_code; |
| |
} |
| |
|
| if (con->begin_pos > 0) { |
if (con->begin_pos > 0) { |
| con->cur_idx = 0; |
con->cur_idx = 0; |
| con->cur_idx_tmp = 1; |
con->cur_idx_tmp = 0; |
| |
|
| /* Moving to begin_pos line */ |
/* Moving to begin_pos line */ |
| while (con->cur_idx_tmp < con->begin_pos) { |
while (con->cur_idx_tmp < con->begin_pos) { |
| Line 89 cfg_cfgfile_get_next_opt(con) |
|
| Line 98 cfg_cfgfile_get_next_opt(con) |
|
| } |
} |
| } |
} |
| else { |
else { |
| if (con->begin_pos > 0 && |
if (/* always do: con->begin_pos > 0 && */ |
| fseek(con->fhandle, con->begin_pos, SEEK_SET) != 0) { |
fseek(con->fhandle, con->begin_pos, SEEK_SET) != 0) { |
| con->error_code = CFG_ERROR_SEEK_ERROR; |
con->error_code = CFG_ERROR_SEEK_ERROR; |
| return con->error_code; |
return con->error_code; |
| Line 97 cfg_cfgfile_get_next_opt(con) |
|
| Line 106 cfg_cfgfile_get_next_opt(con) |
|
| } |
} |
| } |
} |
| |
|
| |
/* |
| |
* Main loop |
| |
*/ |
| while (1) { |
while (1) { |
| |
/* Updating cur_idx to set current line position */ |
| if (con->flags & CFG_FILE_LINE_POS_USAGE) { |
if (con->flags & CFG_FILE_LINE_POS_USAGE) { |
| con->cur_idx += con->cur_idx_tmp; |
con->cur_idx += con->cur_idx_tmp; |
| con->cur_idx_tmp = 0; |
con->cur_idx_tmp = 0; |
| } |
} |
| |
|
| |
/* Reading multi line and exit on error */ |
| con->error_code = get_multi_line(con, &buf); |
con->error_code = get_multi_line(con, &buf); |
| if (con->error_code != CFG_OK) { |
if (con->error_code != CFG_OK) { |
| if (buf != NULL) |
if (buf != NULL) |
| Line 111 cfg_cfgfile_get_next_opt(con) |
|
| Line 125 cfg_cfgfile_get_next_opt(con) |
|
| return con->error_code; |
return con->error_code; |
| } |
} |
| |
|
| |
/* Testing if file stop prefix was found */ |
| if (buf != NULL && con->prop[CFG_FILE_STOP_PREFIX] != NULL) { |
if (buf != NULL && con->prop[CFG_FILE_STOP_PREFIX] != NULL) { |
| if (buf == strdyn_str2(buf, |
if (buf == strdyn_str2(buf, |
| con->prop[CFG_FILE_STOP_PREFIX], NULL)) { |
con->prop[CFG_FILE_STOP_PREFIX], NULL)) { |
| Line 121 cfg_cfgfile_get_next_opt(con) |
|
| Line 136 cfg_cfgfile_get_next_opt(con) |
|
| } |
} |
| } |
} |
| |
|
| if ((con->end_pos > 0 && cfg_get_cur_idx(con) > con->end_pos) |
/* Finished? */ |
| |
if ((con->size >= 0 && cfg_get_cur_idx(con) >= con->begin_pos + con->size) |
| || feof(con->fhandle)) { |
|| feof(con->fhandle)) { |
| if (buf != NULL) |
if (buf != NULL) |
| free(buf); |
free(buf); |