diff 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
line wrap: on
line diff
--- a/mcabber/src/hooks.c	Sat Nov 10 22:28:16 2007 +0100
+++ b/mcabber/src/hooks.c	Sat Nov 10 22:29:31 2007 +0100
@@ -31,6 +31,7 @@
 #include "settings.h"
 #include "utils.h"
 #include "utf8.h"
+#include "commands.h"
 
 static char *extcmd;
 
@@ -332,6 +333,29 @@
 }
 
 
+/* Internal commands */
+
+void hook_execute_internal(const char *hookname)
+{
+  const char *hook_command;
+  char *buf;
+  char *cmdline;
+
+  hook_command = settings_opt_get(hookname);
+  if (!hook_command)
+    return;
+
+  buf = g_strdup_printf("Running %s...", hookname);
+  scr_LogPrint(LPRINT_LOGNORM, "%s", buf);
+
+  cmdline = g_strdup_printf(mkcmdstr("%s"), hook_command);
+  process_command(hook_command, TRUE); // XXX Note: /quit won't work.
+
+  g_free(cmdline);
+  g_free(buf);
+}
+
+
 /* External commands */
 
 //  hk_ext_cmd_init()