| version 1.14, 2002/05/11 14:54:58 |
version 1.15, 2002/05/30 22:29:45 |
|
|
| |
|
| /* $Id$ */ |
/* $Id$ */ |
| |
|
| |
/* Includes {{{ */ |
| #include "config.h" |
#include "config.h" |
| |
|
| #if STDC_HEADERS |
#if STDC_HEADERS |
|
|
| |
|
| #include "cfg+.h" |
#include "cfg+.h" |
| #include "shared.h" |
#include "shared.h" |
| |
/* }}} */ |
| |
|
| |
/* Static function declarations {{{ */ |
| static int get_multi_line(const CFG_CONTEXT con, char **buf); |
static int get_multi_line(const CFG_CONTEXT con, char **buf); |
| |
/* }}} */ |
| |
|
| int |
int |
| cfg_cfgfile_get_next_opt(con) |
cfg_cfgfile_get_next_opt(con) |
| const CFG_CONTEXT con; |
const CFG_CONTEXT con; |
| { |
{ /* {{{ */ |
| char *buf; |
char *buf; |
| int ret_val; |
int ret_val; |
| |
|
| Line 71 cfg_cfgfile_get_next_opt(con) |
|
| Line 75 cfg_cfgfile_get_next_opt(con) |
|
| con->cur_idx = 0; |
con->cur_idx = 0; |
| con->cur_idx_tmp = 1; |
con->cur_idx_tmp = 1; |
| |
|
| |
/* Moving to begin_pos line */ |
| while (con->cur_idx_tmp < con->begin_pos) { |
while (con->cur_idx_tmp < con->begin_pos) { |
| switch (fgetc(con->fhandle)) { |
switch (fgetc(con->fhandle)) { |
| case EOF: |
case EOF: |
| Line 105 cfg_cfgfile_get_next_opt(con) |
|
| Line 110 cfg_cfgfile_get_next_opt(con) |
|
| return con->error_code; |
return con->error_code; |
| } |
} |
| |
|
| if (buf != NULL && con->file_stop_prefix != NULL) { |
if (buf != NULL && con->prop[CFG_FILE_STOP_PREFIX] != NULL) { |
| if (buf == strdyn_str2(buf, con->file_stop_prefix, NULL)) { |
if (buf == strdyn_str2(buf, |
| |
con->prop[CFG_FILE_STOP_PREFIX], NULL)) { |
| __cfg_free_currents(con); |
__cfg_free_currents(con); |
| con->cur_opt = buf; |
con->cur_opt = buf; |
| con->error_code = CFG_ERR_STOP_STR; |
con->error_code = CFG_ERR_STOP_STR; |
| Line 119 cfg_cfgfile_get_next_opt(con) |
|
| Line 125 cfg_cfgfile_get_next_opt(con) |
|
| if (buf != NULL) |
if (buf != NULL) |
| free(buf); |
free(buf); |
| |
|
| return con->error_code; /* allways CFG_OK */ |
return con->error_code; /* always CFG_OK */ |
| } |
} |
| |
|
| __cfg_free_currents(con); |
__cfg_free_currents(con); |
| Line 140 cfg_cfgfile_get_next_opt(con) |
|
| Line 146 cfg_cfgfile_get_next_opt(con) |
|
| } |
} |
| |
|
| return con->error_code; /* CFG_OK */ |
return con->error_code; /* CFG_OK */ |
| } |
} /* }}} */ |
| |
|
| /* |
/* |
| * get_multi_line() |
* get_multi_line() |
| Line 155 cfg_cfgfile_get_next_opt(con) |
|
| Line 161 cfg_cfgfile_get_next_opt(con) |
|
| get_multi_line(con, buf) |
get_multi_line(con, buf) |
| const CFG_CONTEXT con; |
const CFG_CONTEXT con; |
| char **buf; |
char **buf; |
| { |
{ /* {{{ */ |
| register char **ar = NULL; |
register char **ar = NULL; |
| register char *my_buf = NULL; |
register char *my_buf = NULL; |
| register int state = 0; |
register int state = 0; |
| Line 183 get_multi_line(con, buf) |
|
| Line 189 get_multi_line(con, buf) |
|
| str_trim(my_buf); |
str_trim(my_buf); |
| |
|
| /* Is empty line or comment? */ |
/* Is empty line or comment? */ |
| if (strlen(my_buf) == 0 |
if (strlen(my_buf) == 0 || strdyn_str(my_buf, |
| || strdyn_str(my_buf, con->comment_prefix) == my_buf) { |
con->prop[CFG_FILE_COMMENT_PREFIX]) == my_buf) { |
| |
|
| if (con->flags & CFG_FILE_LINE_POS_USAGE) |
if (con->flags & CFG_FILE_LINE_POS_USAGE) |
| con->cur_idx++; |
con->cur_idx++; |
| Line 205 get_multi_line(con, buf) |
|
| Line 211 get_multi_line(con, buf) |
|
| register int max_len = 0; |
register int max_len = 0; |
| register int len; |
register int len; |
| |
|
| for (pos = con->multi_line_postfix; |
for (pos = con->prop[CFG_FILE_MULTI_LINE_POSTFIX]; |
| pos != NULL && *pos != NULL; |
pos != NULL && *pos != NULL; |
| pos++) { |
pos++) { |
| |
|
| Line 251 get_multi_line(con, buf) |
|
| Line 257 get_multi_line(con, buf) |
|
| *buf = my_buf; |
*buf = my_buf; |
| |
|
| return CFG_OK; |
return CFG_OK; |
| } |
} /* }}} */ |
| |
|
| |
/* Modeline for ViM {{{ |
| |
* vim:set ts=4: |
| |
* vim600:fdm=marker fdl=0 fdc=0: |
| |
* }}} */ |
| |
|