Wed Jan 8 2020 09:49:50

Asterisk developer's documentation


res_curl.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (c) 2008, Digium, Inc.
5  *
6  * Tilghman Lesher <res_curl_v1@the-tilghman.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*! \file
20  *
21  * \brief curl resource engine
22  *
23  * \author Tilghman Lesher <res_curl_v1@the-tilghman.com>
24  *
25  * \extref Depends on the CURL library - http://curl.haxx.se/
26  *
27  */
28 
29 /*** MODULEINFO
30  <support_level>core</support_level>
31  <depend>curl</depend>
32  ***/
33 
34 #include "asterisk.h"
35 
36 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 340863 $")
37 
38 #include <curl/curl.h>
39 
40 #include "asterisk/module.h"
41 
42 static int unload_module(void)
43 {
44  int res = 0;
45 
46  /* If the dependent modules are still in memory, forbid unload */
47  if (ast_module_check("func_curl.so")) {
48  ast_log(LOG_ERROR, "func_curl.so (dependent module) is still loaded. Cannot unload res_curl.so\n");
49  return -1;
50  }
51 
52  if (ast_module_check("res_config_curl.so")) {
53  ast_log(LOG_ERROR, "res_config_curl.so (dependent module) is still loaded. Cannot unload res_curl.so\n");
54  return -1;
55  }
56 
57  curl_global_cleanup();
58 
59  return res;
60 }
61 
62 static int load_module(void)
63 {
64  int res = 0;
65 
66  if (curl_global_init(CURL_GLOBAL_ALL)) {
67  ast_log(LOG_ERROR, "Unable to initialize the CURL library. Cannot load res_curl\n");
69  }
70 
71  return res;
72 }
73 
75  .load = load_module,
76  .unload = unload_module,
77  .load_pri = AST_MODPRI_REALTIME_DEPEND,
78  );
Asterisk main include file. File version handling, generic pbx functions.
static int unload_module(void)
Definition: res_curl.c:42
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Definition: module.h:374
int ast_module_check(const char *name)
Check if module with the name given is loaded.
Definition: loader.c:1255
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:38
Asterisk module definitions.
static int load_module(void)
Definition: res_curl.c:62
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
Definition: asterisk.h:180