static int __ast_http_post_load(int reload) { struct ast_config *cfg; struct ast_variable *v; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; cfg = ast_config_load2("http.conf", "http", config_flags); if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { return 0; } if (reload) { ast_http_uri_unlink_all_with_key(__FILE__); } if (cfg) { for (v = ast_variable_browse(cfg, "general"); v; v = v->next) { if (!strcasecmp(v->name, "prefix")) { ast_copy_string(prefix, v->value, sizeof(prefix)); if (prefix[strlen(prefix)] == '/') { prefix[strlen(prefix)] = '\0'; } } } for (v = ast_variable_browse(cfg, "post_mappings"); v; v = v->next) { struct ast_http_uri *urih; struct ast_str *ds; if (!(urih = ast_calloc(sizeof(*urih), 1))) { ast_config_destroy(cfg); return -1; } if (!(ds = ast_str_create(32))) { ast_free(urih); ast_config_destroy(cfg); return -1; } urih->description = ast_strdup("HTTP POST mapping"); urih->uri = ast_strdup(v->name); ast_str_set(&ds, 0, "%s", v->value); urih->data = ds; urih->has_subtree = 0; urih->supports_get = 0; urih->supports_post = 1; urih->callback = http_post_callback; urih->key = __FILE__; urih->mallocd = urih->dmallocd = 1; ast_http_uri_link(urih); } ast_config_destroy(cfg); } return 0; }
static int unload_module(void) { ast_http_uri_unlink_all_with_key(__FILE__); return 0; }