static int handle_load(int fd, int argc, char *argv[]) { if (argc != 2) return RESULT_SHOWUSAGE; if (ast_load_resource(argv[1])) { ast_cli(fd, "Unable to load module %s\n", argv[1]); return RESULT_FAILURE; } return RESULT_SUCCESS; }
static int load_module(void) { if (!ast_module_check("res_curl.so")) { if (ast_load_resource("res_curl.so") != AST_MODULE_LOAD_SUCCESS) { ast_log(LOG_ERROR, "Cannot load res_curl, so res_config_curl cannot be loaded\n"); return AST_MODULE_LOAD_DECLINE; } } if (!ast_module_check("func_curl.so")) { if (ast_load_resource("func_curl.so") != AST_MODULE_LOAD_SUCCESS) { ast_log(LOG_ERROR, "Cannot load func_curl, so res_config_curl cannot be loaded\n"); return AST_MODULE_LOAD_DECLINE; } } reload_module(); ast_config_engine_register(&curl_engine); return 0; }
static void file_ok_sel(GtkWidget *w, GtkFileSelection *fs) { char tmp[PATH_MAX]; char *module = gtk_file_selection_get_filename(fs); char buf[256]; snprintf(tmp, sizeof(tmp), "%s/", ast_config_AST_MODULE_DIR); if (!strncmp(module, (char *)tmp, strlen(tmp))) module += strlen(tmp); gdk_threads_leave(); if (ast_load_resource(module)) { snprintf(buf, sizeof(buf), "Error loading module '%s'.", module); update_statusbar(buf); } else { snprintf(buf, sizeof(buf), "Module '%s' loaded", module); update_statusbar(buf); } gdk_threads_enter(); gtk_widget_destroy(GTK_WIDGET(fs)); }
static void reload_module(void) { int res, x; char *module; char buf[256]; if (GTK_CLIST(modules)->selection) { module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (int) GTK_CLIST(modules)->selection->data); module = strdup(module); if (module) { gdk_threads_leave(); res = ast_unload_resource(module, 0); gdk_threads_enter(); if (res) { snprintf(buf, sizeof(buf), "Module '%s' is in use", module); update_statusbar(buf); } else { gdk_threads_leave(); res = ast_load_resource(module); gdk_threads_enter(); if (res) { snprintf(buf, sizeof(buf), "Error reloading module '%s'", module); } else { snprintf(buf, sizeof(buf), "Module '%s' reloaded", module); } for (x=0; x < GTK_CLIST(modules)->rows; x++) { if (!strcmp((char *)gtk_clist_get_row_data(GTK_CLIST(modules), x), module)) { gtk_clist_select_row(GTK_CLIST(modules), x, -1); break; } } update_statusbar(buf); } free(module); } } }
void ast_ari_asterisk_load_module(struct ast_variable *headers, struct ast_ari_asterisk_load_module_args *args, struct ast_ari_response *response) { enum ast_module_load_result load_result; ast_assert(response != NULL); if (ast_module_check(args->module_name)) { ast_ari_response_error( response, 409, "Conflict", "Module is already loaded"); return; } load_result = ast_load_resource(args->module_name); if (load_result == AST_MODULE_LOAD_DECLINE) { ast_ari_response_error( response, 409, "Conflict", "Module load declined"); return; } else if (load_result == AST_MODULE_LOAD_SKIP) { ast_ari_response_error( response, 409, "Conflict", "Module was skipped"); return; } else if (load_result == AST_MODULE_LOAD_FAILURE) { ast_ari_response_error( response, 409, "Conflict", "Module could not be loaded properly"); return; } ast_ari_response_no_content(response); }