Fri Aug 17 00:17:18 2018

Asterisk developer's documentation


res_curl.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (c) 2008, Digium, Inc.
00005  *
00006  * Tilghman Lesher <res_curl_v1@the-tilghman.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief curl resource engine
00022  *
00023  * \author Tilghman Lesher <res_curl_v1@the-tilghman.com>
00024  *
00025  * \extref Depends on the CURL library  - http://curl.haxx.se/
00026  * 
00027  */
00028 
00029 /*** MODULEINFO
00030    <support_level>core</support_level>
00031    <depend>curl</depend>
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    /* If the dependent modules are still in memory, forbid unload */
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    );

Generated on 17 Aug 2018 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1