Asterisk - The Open Source Telephony Project GIT-master-8924258
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
func_module.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 1999 - 2006, Digium, Inc.
5 *
6 * See http://www.asterisk.org for more information about
7 * the Asterisk project. Please do not directly contact
8 * any of the maintainers of this project for assistance;
9 * the project provides a web site, mailing lists and IRC
10 * channels for your use.
11 *
12 * This program is free software, distributed under the terms of
13 * the GNU General Public License Version 2. See the LICENSE file
14 * at the top of the source tree.
15 */
16
17/*! \file
18 *
19 * \brief Simple module check function
20 * \author Olle E. Johansson, Edvina.net
21 *
22 * \ingroup functions
23 */
24
25/*** MODULEINFO
26 <support_level>core</support_level>
27 ***/
28
29#include "asterisk.h"
30
31#include "asterisk/module.h"
32#include "asterisk/pbx.h"
33
34/*** DOCUMENTATION
35 <function name="IFMODULE" language="en_US">
36 <since>
37 <version>1.6.0</version>
38 </since>
39 <synopsis>
40 Checks if an Asterisk module is loaded in memory.
41 </synopsis>
42 <syntax>
43 <parameter name="modulename.so" required="true">
44 <para>Module name complete with <literal>.so</literal></para>
45 </parameter>
46 </syntax>
47 <description>
48 <para>Checks if a module is loaded. Use the full module name
49 as shown by the list in <literal>module list</literal>.
50 Returns <literal>1</literal> if module exists in memory, otherwise <literal>0</literal></para>
51 </description>
52 </function>
53 ***/
54
55static int ifmodule_read(struct ast_channel *chan, const char *cmd, char *data,
56 char *buf, size_t len)
57{
58 char *ret = "0";
59
60 *buf = '\0';
61
62 if (data)
63 if (ast_module_check(data))
64 ret = "1";
65
66 ast_copy_string(buf, ret, len);
67
68 return 0;
69}
70
72 .name = "IFMODULE",
73 .read = ifmodule_read,
74 .read_max = 2,
75};
76
77
78static int unload_module(void)
79{
81}
82
83static int load_module(void)
84{
86}
87
88AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Checks if Asterisk module is loaded in memory");
Asterisk main include file. File version handling, generic pbx functions.
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int ifmodule_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
Definition: func_module.c:55
static int load_module(void)
Definition: func_module.c:83
static int unload_module(void)
Definition: func_module.c:78
static struct ast_custom_function ifmodule_function
Definition: func_module.c:71
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Asterisk module definitions.
int ast_module_check(const char *name)
Check if module with the name given is loaded.
Definition: loader.c:2832
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:581
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
Core PBX routines and definitions.
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1559
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Definition: pbx.h:118
const char * name
Definition: pbx.h:119