struct refresh_info {
struct entry_list *entries;
int verbose;
+ unsigned int regex_present:1;
regex_t filter;
};
void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry)
{
- /* if there is an entry (and not the special flag value), remove/free it */
- if (entry && (entry != (typeof(entry)) -1)) {
- AST_LIST_LOCK(&entry_list);
- AST_LIST_REMOVE(&entry_list, entry, list);
- AST_LIST_UNLOCK(&entry_list);
- free(entry);
- };
+ if (!entry)
+ return;
+
+ AST_LIST_LOCK(&entry_list);
+ AST_LIST_REMOVE(&entry_list, entry, list);
+ AST_LIST_UNLOCK(&entry_list);
+ free(entry);
}
int ast_dnsmgr_lookup(const char *name, struct in_addr *result, struct ast_dnsmgr_entry **dnsmgr)
if ((hp = ast_gethostbyname(name, &ahp)))
memcpy(result, hp->h_addr, sizeof(result));
- /* flag value to indicate no manager was allocated */
- *dnsmgr = (typeof(*dnsmgr)) -1;
+ return 0;
} else {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_2 "adding manager for '%s'\n", name);
*dnsmgr = ast_dnsmgr_get(name, result);
+ return !*dnsmgr;
}
-
- return !*dnsmgr;
}
static void *do_refresh(void *data)
ast_verbose(VERBOSE_PREFIX_2 "Refreshing DNS lookups.\n");
AST_LIST_LOCK(info->entries);
AST_LIST_TRAVERSE(info->entries, entry, list) {
- if (info->filter.used && regexec(&info->filter, entry->name, 0, NULL, 0))
+ if (info->regex_present && regexec(&info->filter, entry->name, 0, NULL, 0))
continue;
if (info->verbose && (option_verbose > 2))
if (argc == 3) {
if (regcomp(&info.filter, argv[2], REG_EXTENDED | REG_NOSUB))
return RESULT_SHOWUSAGE;
+ else
+ info.regex_present = 1;
}
refresh_list(&info);
- if (info.filter.used)
+ if (info.regex_present)
regfree(&info.filter);
return 0;
ast_sched_del(sched, refresh_sched);
if ((config = ast_config_load("dnsmgr.conf"))) {
- if ((enabled_value = ast_variable_retrieve(config, "general", "enabled"))) {
+ if ((enabled_value = ast_variable_retrieve(config, "general", "enable"))) {
enabled = ast_true(enabled_value);
}
if ((interval_value = ast_variable_retrieve(config, "general", "refreshinterval"))) {