res_curl.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "asterisk.h"
00035
00036 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 340863 $")
00037
00038 #include <curl/curl.h>
00039
00040 #include "asterisk/module.h"
00041
00042 static int unload_module(void)
00043 {
00044 int res = 0;
00045
00046
00047 if (ast_module_check("func_curl.so")) {
00048 ast_log(LOG_ERROR, "func_curl.so (dependent module) is still loaded. Cannot unload res_curl.so\n");
00049 return -1;
00050 }
00051
00052 if (ast_module_check("res_config_curl.so")) {
00053 ast_log(LOG_ERROR, "res_config_curl.so (dependent module) is still loaded. Cannot unload res_curl.so\n");
00054 return -1;
00055 }
00056
00057 curl_global_cleanup();
00058
00059 return res;
00060 }
00061
00062 static int load_module(void)
00063 {
00064 int res = 0;
00065
00066 if (curl_global_init(CURL_GLOBAL_ALL)) {
00067 ast_log(LOG_ERROR, "Unable to initialize the CURL library. Cannot load res_curl\n");
00068 return AST_MODULE_LOAD_DECLINE;
00069 }
00070
00071 return res;
00072 }
00073
00074 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "cURL Resource Module",
00075 .load = load_module,
00076 .unload = unload_module,
00077 .load_pri = AST_MODPRI_REALTIME_DEPEND,
00078 );