2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2006, Digium, Inc.
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.
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.
19 * \brief Simple module check function
20 * \author Olle E. Johansson, Edvina.net
24 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
29 #include <sys/types.h>
32 #include "asterisk/module.h"
33 #include "asterisk/channel.h"
34 #include "asterisk/pbx.h"
35 #include "asterisk/logger.h"
36 #include "asterisk/utils.h"
37 #include "asterisk/app.h"
38 #include "asterisk/module.h"
40 static int ifmodule_read(struct ast_channel *chan, char *cmd, char *data,
41 char *buf, size_t len)
48 if (ast_module_check(data))
51 ast_copy_string(buf, ret, len);
56 static struct ast_custom_function ifmodule_function = {
58 .synopsis = "Checks if an Asterisk module is loaded in memory",
59 .syntax = "IFMODULE(<modulename.so>)",
60 .read = ifmodule_read,
61 .desc = "Checks if a module is loaded. Use the full module name\n"
62 "as shown by the list in \"module list\". \n"
63 "Returns \"1\" if module exists in memory, otherwise \"0\".\n",
67 static int unload_module(void)
69 return ast_custom_function_unregister(&ifmodule_function);
72 static int load_module(void)
74 return ast_custom_function_register(&ifmodule_function);
77 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Checks if Asterisk module is loaded in memory");