00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "asterisk.h"
00025
00026 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 89521 $")
00027
00028 #include "asterisk/module.h"
00029 #include "asterisk/pbx.h"
00030
00031 static int ifmodule_read(struct ast_channel *chan, const char *cmd, char *data,
00032 char *buf, size_t len)
00033 {
00034 char *ret = "0";
00035
00036 *buf = '\0';
00037
00038 if (data)
00039 if (ast_module_check(data))
00040 ret = "1";
00041
00042 ast_copy_string(buf, ret, len);
00043
00044 return 0;
00045 }
00046
00047 static struct ast_custom_function ifmodule_function = {
00048 .name = "IFMODULE",
00049 .synopsis = "Checks if an Asterisk module is loaded in memory",
00050 .syntax = "IFMODULE(<modulename.so>)",
00051 .read = ifmodule_read,
00052 .desc = "Checks if a module is loaded. Use the full module name\n"
00053 "as shown by the list in \"module list\". \n"
00054 "Returns \"1\" if module exists in memory, otherwise \"0\".\n",
00055 };
00056
00057
00058 static int unload_module(void)
00059 {
00060 return ast_custom_function_unregister(&ifmodule_function);
00061 }
00062
00063 static int load_module(void)
00064 {
00065 return ast_custom_function_register(&ifmodule_function);
00066 }
00067
00068 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Checks if Asterisk module is loaded in memory");