53 memset(cfg, 0,
sizeof(*cfg));
56 if (!(f = fopen(path,
"r"))) {
64 if ((f = fopen(path,
"r")) == 0) {
72 if ((cfg->sectno != last) && !strcmp(cfg->section, file_path)) {
73 cfg->lockto = cfg->sectno;
79 memset(cfg, 0,
sizeof(*cfg));
98 memset(cfg, 0,
sizeof(*cfg));
108 if ( !cfg->path[0] ){
115 if (!fgets(cfg->buf,
sizeof(cfg->buf), cfg->file)) {
121 if (**var ==
'[' && (end = strchr(*var,
']')) != 0) {
129 if (cfg->lockto > -1 && cfg->sectno != cfg->lockto) {
144 if (**var ==
'#' || **var ==
';' || **var ==
'\n' || **var ==
'\r') {
148 if (!strncmp(*var,
"__END__", 7)) {
152 if ((end = strchr(*var,
'#')) != 0 || (end = strchr(*var,
';')) != 0) {
155 }
else if ((end = strchr(*var,
'\n')) != 0) {
156 if (*(end - 1) ==
'\r') {
163 while ((*p ==
' ' || *p ==
'\t') && p != end) {
169 if ((*val = strchr(*var,
'=')) == 0) {
177 if (*(*val) ==
'>') {
182 while ((*p ==
' ' || *p ==
'\t') && p != *var) {
188 while ((*p ==
' ' || *p ==
'\t') && p != end) {
void switch_config_close_file(switch_config_t *cfg)
Close a previously opened configuration file.
typedefSWITCH_BEGIN_EXTERN_C struct switch_config switch_config_t
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
#define SWITCH_PATH_SEPARATOR
char * switch_copy_string(_Out_z_cap_(dst_size) char *dst, _In_z_ const char *src, _In_ switch_size_t dst_size)
switch_directories SWITCH_GLOBAL_dirs
const char *const const char *const path
static switch_bool_t switch_is_file_path(const char *file)
int switch_config_open_file(switch_config_t *cfg, char *file_path)
Open a configuration file.
#define switch_set_string(_dst, _src)
Basic Configuration File Parser.
int switch_config_next_pair(switch_config_t *cfg, char **var, char **val)
Retrieve next name/value pair from configuration file.