comparison mcabber/src/hooks.c @ 1352:61a54e172010

Add internal hooks support
author Mikael Berthe <mikael@lilotux.net>
date Sat, 10 Nov 2007 22:29:31 +0100
parents 06441b6cc23a
children 9716cf8a0726
comparison
equal deleted inserted replaced
1351:43e777a5ff06 1352:61a54e172010
29 #include "histolog.h" 29 #include "histolog.h"
30 #include "hbuf.h" 30 #include "hbuf.h"
31 #include "settings.h" 31 #include "settings.h"
32 #include "utils.h" 32 #include "utils.h"
33 #include "utf8.h" 33 #include "utf8.h"
34 #include "commands.h"
34 35
35 static char *extcmd; 36 static char *extcmd;
36 37
37 static const char *COMMAND_ME = "/me "; 38 static const char *COMMAND_ME = "/me ";
38 39
330 (msg ? msg : "")); 331 (msg ? msg : ""));
331 //hlog_write_status(NULL, 0, status); 332 //hlog_write_status(NULL, 0, status);
332 } 333 }
333 334
334 335
336 /* Internal commands */
337
338 void hook_execute_internal(const char *hookname)
339 {
340 const char *hook_command;
341 char *buf;
342 char *cmdline;
343
344 hook_command = settings_opt_get(hookname);
345 if (!hook_command)
346 return;
347
348 buf = g_strdup_printf("Running %s...", hookname);
349 scr_LogPrint(LPRINT_LOGNORM, "%s", buf);
350
351 cmdline = g_strdup_printf(mkcmdstr("%s"), hook_command);
352 process_command(hook_command, TRUE); // XXX Note: /quit won't work.
353
354 g_free(cmdline);
355 g_free(buf);
356 }
357
358
335 /* External commands */ 359 /* External commands */
336 360
337 // hk_ext_cmd_init() 361 // hk_ext_cmd_init()
338 // Initialize external command variable. 362 // Initialize external command variable.
339 // Can be called with parameter NULL to reset and free memory. 363 // Can be called with parameter NULL to reset and free memory.