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