lua.c
changeset 144 690b5524b895
parent 143 4232a5da1af2
child 146 04d19c9c1196
equal deleted inserted replaced
143:4232a5da1af2 144:690b5524b895
    47 
    47 
    48 /// Lua for mcabber
    48 /// Lua for mcabber
    49 /// Module provides embedded lua environment with some accessors to
    49 /// Module provides embedded lua environment with some accessors to
    50 /// mcabber functionality.
    50 /// mcabber functionality.
    51 
    51 
    52 //
       
    53 //  options
       
    54 //
       
    55 
       
    56 /// Options
    52 /// Options
    57 /// * lua_init_filename - lua script, that will be loaded at startup
    53 /// * lua_init_filename - lua script, that will be loaded at startup
    58 /// * lua_lm_debug      - if lm log handler is enabled, this option controls, whether lm log messages are dropped or passed to mcabber logging facility
    54 /// * lua_lm_debug      - if lm log handler is enabled, this option controls, whether lm log messages are dropped or passed to mcabber logging facility
    59 #define OPT_MLUA_RC       "lua_init_filename"
       
    60 #define OPT_MLUA_LM_DEBUG "lua_lm_debug"
       
    61 
    55 
    62 //
    56 //
    63 //  module description
    57 //  module description
    64 //
    58 //
    65 
    59 
    66 void mlua_init   (void);
    60 void mlua_init   (void);
    67 void mlua_uninit (void);
    61 void mlua_uninit (void);
    68 
    62 
    69 #ifdef LLM_LOG_HANDLER
    63 #ifdef LLM_LOG_HANDLER
    70 #define DESCRIPTION ( \
    64 #define DESCRIPTION ( \
    71 	"Lua scripting interface\n" \
    65 	LUA_RELEASE " scripting interface\n" \
    72 	"Options: " OPT_MLUA_RC ", " OPT_MLUA_LM_DEBUG "\n" \
    66 	"Options: " OPT_MLUA_RC ", " OPT_MLUA_LM_DEBUG "\n" \
    73 	"Command: /lua" )
    67 	"Command: /" MLUA_COMMAND_NAME )
    74 #else
    68 #else
    75 #define DESCRIPTION ( \
    69 #define DESCRIPTION ( \
    76 	"Lua scripting interface\n" \
    70 	LUA_RELEASE " scripting interface\n" \
    77 	"Options: " OPT_MLUA_RC "\n" \
    71 	"Options: " OPT_MLUA_RC "\n" \
    78 	"Command: /lua" )
    72 	"Command: /" MLUA_COMMAND_NAME )
    79 #endif
    73 #endif
    80 
    74 
    81 module_info_t info_lua = {
    75 module_info_t info_lua5_2 = {
    82 	.branch      = MCABBER_BRANCH,
    76 	.branch      = MCABBER_BRANCH,
    83 	.api         = MCABBER_API_VERSION,
    77 	.api         = MCABBER_API_VERSION,
    84 	.version     = PROJECT_VERSION,
    78 	.version     = PROJECT_VERSION,
    85 	.description = DESCRIPTION,
    79 	.description = DESCRIPTION,
    86 	.requires    = NULL,
    80 	.requires    = NULL,
  1803 			}
  1797 			}
  1804 		}
  1798 		}
  1805 	}
  1799 	}
  1806 
  1800 
  1807 #ifdef MCABBER_API_HAVE_CMD_ID
  1801 #ifdef MCABBER_API_HAVE_CMD_ID
  1808 	lua_cmdid = cmd_add ("lua", "Evaluate lua string", 0, 0, (void (*) (char *p)) do_lua, lua);
  1802 	lua_cmdid = cmd_add (MLUA_COMMAND_NAME, "Evaluate lua string", 0, 0, (void (*) (char *p)) do_lua, lua);
  1809 #else
  1803 #else
  1810 	cmd_add ("lua", "Evaluate lua string", 0, 0, (void (*) (char *p)) do_lua, lua);
  1804 	cmd_add (MLUA_COMMAND_NAME, "Evaluate lua string", 0, 0, (void (*) (char *p)) do_lua, lua);
       
  1805 #endif
       
  1806 
       
  1807 #ifdef ENABLE_LUA_ALIAS
       
  1808 	settings_set(SETTINGS_TYPE_ALIAS, "lua", MLUA_COMMAND_NAME);
  1811 #endif
  1809 #endif
  1812 
  1810 
  1813 #ifdef LLM_LOG_HANDLER
  1811 #ifdef LLM_LOG_HANDLER
  1814 	// FIXME: this should not be here.
  1812 	// FIXME: this should not be here.
  1815 	lua_lm_log_handler_id = g_log_set_handler ("lua-lm", G_LOG_LEVEL_MASK, (GLogFunc) lua_lm_log_handler, NULL);
  1813 	lua_lm_log_handler_id = g_log_set_handler ("lua-lm", G_LOG_LEVEL_MASK, (GLogFunc) lua_lm_log_handler, NULL);
  1905 
  1903 
  1906 #ifdef MCABBER_API_HAVE_CMD_ID
  1904 #ifdef MCABBER_API_HAVE_CMD_ID
  1907 		cmd_del (lua_cmdid);
  1905 		cmd_del (lua_cmdid);
  1908 		lua_cmdid = NULL;
  1906 		lua_cmdid = NULL;
  1909 #else
  1907 #else
  1910 		cmd_del ("lua");
  1908 		cmd_del (MLUA_COMMAND_NAME);
  1911 #endif
  1909 #endif
  1912 
  1910 
  1913 		lua_close (lua);
  1911 		lua_close (lua);
  1914 		lua = NULL;
  1912 		lua = NULL;
  1915 
  1913