summary refs log tree commit diff stats
path: root/src/common/plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/plugin.c')
-rw-r--r--src/common/plugin.c359
1 files changed, 46 insertions, 313 deletions
diff --git a/src/common/plugin.c b/src/common/plugin.c
index 0da3523c..2e30b955 100644
--- a/src/common/plugin.c
+++ b/src/common/plugin.c
@@ -209,17 +209,9 @@ xchat_dummy (xchat_plugin *ph)
 }
 
 #ifdef WIN32
-#ifdef XCHAT_PLUGIN_COMPAT
 static int
 xchat_read_fd (xchat_plugin *ph, GIOChannel *source, char *buf, int *len)
 {
-	return hexchat_read_fd (ph, source, buf, len);
-}
-#endif
-
-static int
-hexchat_read_fd (xchat_plugin *ph, GIOChannel *source, char *buf, int *len)
-{
 	GError *error = NULL;
 
 	g_io_channel_set_buffered (source, FALSE);
@@ -255,7 +247,6 @@ plugin_add (session *sess, char *filename, void *handle, void *init_func,
 	if (!fake)
 	{
 		/* win32 uses these because it doesn't have --export-dynamic! */
-#ifdef XCHAT_PLUGIN_COMPAT
 		pl->xchat_hook_command = xchat_hook_command;
 		pl->xchat_hook_server = xchat_hook_server;
 		pl->xchat_hook_print = xchat_hook_print;
@@ -291,48 +282,12 @@ plugin_add (session *sess, char *filename, void *handle, void *init_func,
 		pl->xchat_send_modes = xchat_send_modes;
 		pl->xchat_strip = xchat_strip;
 		pl->xchat_free = xchat_free;
-#endif /* XCHAT_PLUGIN_COMPAT */
-		pl->hexchat_hook_command = hexchat_hook_command;
-		pl->hexchat_hook_server = hexchat_hook_server;
-		pl->hexchat_hook_print = hexchat_hook_print;
-		pl->hexchat_hook_timer = hexchat_hook_timer;
-		pl->hexchat_hook_fd = hexchat_hook_fd;
-		pl->hexchat_unhook = hexchat_unhook;
-		pl->hexchat_print = hexchat_print;
-		pl->hexchat_printf = hexchat_printf;
-		pl->hexchat_command = hexchat_command;
-		pl->hexchat_commandf = hexchat_commandf;
-		pl->hexchat_nickcmp = hexchat_nickcmp;
-		pl->hexchat_set_context = hexchat_set_context;
-		pl->hexchat_find_context = hexchat_find_context;
-		pl->hexchat_get_context = hexchat_get_context;
-		pl->hexchat_get_info = hexchat_get_info;
-		pl->hexchat_get_prefs = hexchat_get_prefs;
-		pl->hexchat_list_get = hexchat_list_get;
-		pl->hexchat_list_free = hexchat_list_free;
-		pl->hexchat_list_fields = hexchat_list_fields;
-		pl->hexchat_list_str = hexchat_list_str;
-		pl->hexchat_list_next = hexchat_list_next;
-		pl->hexchat_list_int = hexchat_list_int;
-		pl->hexchat_plugingui_add = hexchat_plugingui_add;
-		pl->hexchat_plugingui_remove = hexchat_plugingui_remove;
-		pl->hexchat_emit_print = hexchat_emit_print;
-#ifdef WIN32
-		pl->hexchat_read_fd = (void *) hexchat_read_fd;
-#else
-		pl->hexchat_read_fd = hexchat_dummy;
-#endif
-		pl->hexchat_list_time = hexchat_list_time;
-		pl->hexchat_gettext = hexchat_gettext;
-		pl->hexchat_send_modes = hexchat_send_modes;
-		pl->hexchat_strip = hexchat_strip;
-		pl->hexchat_free = hexchat_free;
-		pl->hexchat_pluginpref_set_str = hexchat_pluginpref_set_str;
-		pl->hexchat_pluginpref_get_str = hexchat_pluginpref_get_str;
-		pl->hexchat_pluginpref_set_int = hexchat_pluginpref_set_int;
-		pl->hexchat_pluginpref_get_int = hexchat_pluginpref_get_int;
-		pl->hexchat_pluginpref_delete = hexchat_pluginpref_delete;
-		pl->hexchat_pluginpref_list = hexchat_pluginpref_list;
+		pl->xchat_pluginpref_set_str = xchat_pluginpref_set_str;
+		pl->xchat_pluginpref_get_str = xchat_pluginpref_get_str;
+		pl->xchat_pluginpref_set_int = xchat_pluginpref_set_int;
+		pl->xchat_pluginpref_get_int = xchat_pluginpref_get_int;
+		pl->xchat_pluginpref_delete = xchat_pluginpref_delete;
+		pl->xchat_pluginpref_list = xchat_pluginpref_list;
 
 		/* incase new plugins are loaded on older xchat */
 		pl->xchat_dummy4 = xchat_dummy;
@@ -867,231 +822,9 @@ plugin_show_help (session *sess, char *cmd)
 /* ===== these are the functions plugins actually call ===== */
 /* ========================================================= */
 
-#ifdef XCHAT_PLUGIN_COMPAT
 void *
 xchat_unhook (xchat_plugin *ph, xchat_hook *hook)
 {
-	return hexchat_unhook (ph, hook);
-}
-
-xchat_hook *
-xchat_hook_command (xchat_plugin *ph, const char *name, int pri, xchat_cmd_cb *callb, const char *help_text, void *userdata)
-{
-	return hexchat_hook_command (ph, name, pri, callb, help_text, userdata);
-}
-
-xchat_hook *
-xchat_hook_server (xchat_plugin *ph, const char *name, int pri, xchat_serv_cb *callb, void *userdata)
-{
-	return hexchat_hook_server (ph, name, pri, callb, userdata);
-}
-
-xchat_hook *
-xchat_hook_print (xchat_plugin *ph, const char *name, int pri, xchat_print_cb *callb, void *userdata)
-{
-	return hexchat_hook_print (ph, name, pri, callb, userdata);
-}
-
-xchat_hook *
-xchat_hook_timer (xchat_plugin *ph, int timeout, xchat_timer_cb *callb, void *userdata)
-{
-	return hexchat_hook_timer (ph, timeout, callb, userdata);
-}
-
-xchat_hook *
-xchat_hook_fd (xchat_plugin *ph, int fd, int flags, xchat_fd_cb *callb, void *userdata)
-{
-	return hexchat_hook_fd (ph, fd, flags, callb, userdata);
-}
-
-void
-xchat_print (xchat_plugin *ph, const char *text)
-{
-	hexchat_print (ph, text);
-}
-
-void
-xchat_printf (xchat_plugin *ph, const char *format, ...)
-{
-	va_list args;
-	char *buf;
-
-	va_start (args, format);
-	buf = g_strdup_vprintf (format, args);
-	va_end (args);
-
-	hexchat_print (ph, buf);
-	g_free (buf);
-}
-
-void
-xchat_command (xchat_plugin *ph, const char *command)
-{
-	hexchat_command (ph, command);
-}
-
-void
-xchat_commandf (xchat_plugin *ph, const char *format, ...)
-{
-	va_list args;
-	char *buf;
-
-	va_start (args, format);
-	buf = g_strdup_vprintf (format, args);
-	va_end (args);
-
-	hexchat_command (ph, buf);
-	g_free (buf);
-}
-
-int
-xchat_nickcmp (xchat_plugin *ph, const char *s1, const char *s2)
-{
-	return hexchat_nickcmp (ph, s1, s2);
-}
-
-xchat_context *
-xchat_get_context (xchat_plugin *ph)
-{
-	return hexchat_get_context (ph);
-}
-
-int
-xchat_set_context (xchat_plugin *ph, xchat_context *context)
-{
-	return hexchat_set_context (ph, context);
-}
-
-xchat_context *
-xchat_find_context (xchat_plugin *ph, const char *servname, const char *channel)
-{
-	return hexchat_find_context (ph, servname, channel);
-}
-
-const char *
-xchat_get_info (xchat_plugin *ph, const char *id)
-{
-	return hexchat_get_info (ph, id);
-}
-
-int
-xchat_get_prefs (xchat_plugin *ph, const char *name, const char **string, int *integer)
-{
-	return hexchat_get_prefs (ph, name, string, integer);
-}
-
-xchat_list *
-xchat_list_get (xchat_plugin *ph, const char *name)
-{
-	return hexchat_list_get (ph, name);
-}
-
-void
-xchat_list_free (xchat_plugin *ph, xchat_list *xlist)
-{
-	hexchat_list_free (ph, xlist);
-}
-
-int
-xchat_list_next (xchat_plugin *ph, xchat_list *xlist)
-{
-	return hexchat_list_next (ph, xlist);
-}
-
-const char * const *
-xchat_list_fields (xchat_plugin *ph, const char *name)
-{
-	return hexchat_list_fields (ph, name);
-}
-
-time_t
-xchat_list_time (xchat_plugin *ph, xchat_list *xlist, const char *name)
-{
-	return hexchat_list_time (ph, xlist, name);
-}
-
-const char *
-xchat_list_str (xchat_plugin *ph, xchat_list *xlist, const char *name)
-{
-	return hexchat_list_str (ph, xlist, name);
-}
-
-int
-xchat_list_int (xchat_plugin *ph, xchat_list *xlist, const char *name)
-{
-	return hexchat_list_int (ph, xlist, name);
-}
-
-void *
-xchat_plugingui_add (xchat_plugin *ph, const char *filename,
-							const char *name, const char *desc,
-							const char *version, char *reserved)
-{
-	return hexchat_plugingui_add (ph, filename, name, desc, version, reserved);
-}
-
-void
-xchat_plugingui_remove (xchat_plugin *ph, void *handle)
-{
-	hexchat_plugingui_remove (ph, handle);
-}
-
-int
-xchat_emit_print (xchat_plugin *ph, const char *event_name, ...)
-{
-	va_list args;
-	/* currently only 4 because no events use more than 4.
-		This can be easily expanded without breaking the API. */
-	char *argv[4] = {NULL, NULL, NULL, NULL};
-	int i = 0;
-
-	va_start (args, event_name);
-	while (1)
-	{
-		argv[i] = va_arg (args, char *);
-		if (!argv[i])
-			break;
-		i++;
-		if (i >= 4)
-			break;
-	}
-
-	i = text_emit_by_name ((char *)event_name, ph->context, argv[0], argv[1],
-								  argv[2], argv[3]);
-	va_end (args);
-
-	return i;
-}
-
-char *
-xchat_gettext (xchat_plugin *ph, const char *msgid)
-{
-	return hexchat_gettext (ph, msgid);
-}
-
-void
-xchat_send_modes (xchat_plugin *ph, const char **targets, int ntargets, int modes_per_line, char sign, char mode)
-{
-	hexchat_send_modes (ph, targets, ntargets, modes_per_line, sign, mode);
-}
-
-char *
-xchat_strip (xchat_plugin *ph, const char *str, int len, int flags)
-{
-	return hexchat_strip (ph, str, len, flags);
-}
-
-void
-xchat_free (xchat_plugin *ph, void *ptr)
-{
-	hexchat_free (ph, ptr);
-}
-
-#endif /* XCHAT_PLUGIN_COMPAT */
-
-void *
-hexchat_unhook (xchat_plugin *ph, xchat_hook *hook)
-{
 	/* perl.c trips this */
 	if (!g_slist_find (hook_list, hook) || hook->type == HOOK_DELETED)
 		return NULL;
@@ -1113,7 +846,7 @@ hexchat_unhook (xchat_plugin *ph, xchat_hook *hook)
 }
 
 xchat_hook *
-hexchat_hook_command (xchat_plugin *ph, const char *name, int pri,
+xchat_hook_command (xchat_plugin *ph, const char *name, int pri,
 						  xchat_cmd_cb *callb, const char *help_text, void *userdata)
 {
 	return plugin_add_hook (ph, HOOK_COMMAND, pri, name, help_text, callb, 0,
@@ -1121,28 +854,28 @@ hexchat_hook_command (xchat_plugin *ph, const char *name, int pri,
 }
 
 xchat_hook *
-hexchat_hook_server (xchat_plugin *ph, const char *name, int pri,
+xchat_hook_server (xchat_plugin *ph, const char *name, int pri,
 						 xchat_serv_cb *callb, void *userdata)
 {
 	return plugin_add_hook (ph, HOOK_SERVER, pri, name, 0, callb, 0, userdata);
 }
 
 xchat_hook *
-hexchat_hook_print (xchat_plugin *ph, const char *name, int pri,
+xchat_hook_print (xchat_plugin *ph, const char *name, int pri,
 						xchat_print_cb *callb, void *userdata)
 {
 	return plugin_add_hook (ph, HOOK_PRINT, pri, name, 0, callb, 0, userdata);
 }
 
 xchat_hook *
-hexchat_hook_timer (xchat_plugin *ph, int timeout, xchat_timer_cb *callb,
+xchat_hook_timer (xchat_plugin *ph, int timeout, xchat_timer_cb *callb,
 					   void *userdata)
 {
 	return plugin_add_hook (ph, HOOK_TIMER, 0, 0, 0, callb, timeout, userdata);
 }
 
 xchat_hook *
-hexchat_hook_fd (xchat_plugin *ph, int fd, int flags,
+xchat_hook_fd (xchat_plugin *ph, int fd, int flags,
 					xchat_fd_cb *callb, void *userdata)
 {
 	xchat_hook *hook;
@@ -1156,7 +889,7 @@ hexchat_hook_fd (xchat_plugin *ph, int fd, int flags,
 }
 
 void
-hexchat_print (xchat_plugin *ph, const char *text)
+xchat_print (xchat_plugin *ph, const char *text)
 {
 	if (!is_session (ph->context))
 	{
@@ -1168,7 +901,7 @@ hexchat_print (xchat_plugin *ph, const char *text)
 }
 
 void
-hexchat_printf (xchat_plugin *ph, const char *format, ...)
+xchat_printf (xchat_plugin *ph, const char *format, ...)
 {
 	va_list args;
 	char *buf;
@@ -1182,7 +915,7 @@ hexchat_printf (xchat_plugin *ph, const char *format, ...)
 }
 
 void
-hexchat_command (xchat_plugin *ph, const char *command)
+xchat_command (xchat_plugin *ph, const char *command)
 {
 	char *conv;
 	int len = -1;
@@ -1200,7 +933,7 @@ hexchat_command (xchat_plugin *ph, const char *command)
 }
 
 void
-hexchat_commandf (xchat_plugin *ph, const char *format, ...)
+xchat_commandf (xchat_plugin *ph, const char *format, ...)
 {
 	va_list args;
 	char *buf;
@@ -1214,19 +947,19 @@ hexchat_commandf (xchat_plugin *ph, const char *format, ...)
 }
 
 int
-hexchat_nickcmp (xchat_plugin *ph, const char *s1, const char *s2)
+xchat_nickcmp (xchat_plugin *ph, const char *s1, const char *s2)
 {
 	return ((session *)ph->context)->server->p_cmp (s1, s2);
 }
 
 xchat_context *
-hexchat_get_context (xchat_plugin *ph)
+xchat_get_context (xchat_plugin *ph)
 {
 	return ph->context;
 }
 
 int
-hexchat_set_context (xchat_plugin *ph, xchat_context *context)
+xchat_set_context (xchat_plugin *ph, xchat_context *context)
 {
 	if (is_session (context))
 	{
@@ -1237,7 +970,7 @@ hexchat_set_context (xchat_plugin *ph, xchat_context *context)
 }
 
 xchat_context *
-hexchat_find_context (xchat_plugin *ph, const char *servname, const char *channel)
+xchat_find_context (xchat_plugin *ph, const char *servname, const char *channel)
 {
 	GSList *slist, *clist, *sessions = NULL;
 	server *serv;
@@ -1297,7 +1030,7 @@ hexchat_find_context (xchat_plugin *ph, const char *servname, const char *channe
 }
 
 const char *
-hexchat_get_info (xchat_plugin *ph, const char *id)
+xchat_get_info (xchat_plugin *ph, const char *id)
 {
 	session *sess;
 	guint32 hash;
@@ -1404,7 +1137,7 @@ hexchat_get_info (xchat_plugin *ph, const char *id)
 }
 
 int
-hexchat_get_prefs (xchat_plugin *ph, const char *name, const char **string, int *integer)
+xchat_get_prefs (xchat_plugin *ph, const char *name, const char **string, int *integer)
 {
 	int i = 0;
 
@@ -1451,7 +1184,7 @@ hexchat_get_prefs (xchat_plugin *ph, const char *name, const char **string, int
 }
 
 xchat_list *
-hexchat_list_get (xchat_plugin *ph, const char *name)
+xchat_list_get (xchat_plugin *ph, const char *name)
 {
 	xchat_list *list;
 
@@ -1499,7 +1232,7 @@ hexchat_list_get (xchat_plugin *ph, const char *name)
 }
 
 void
-hexchat_list_free (xchat_plugin *ph, xchat_list *xlist)
+xchat_list_free (xchat_plugin *ph, xchat_list *xlist)
 {
 	if (xlist->type == LIST_USERS)
 		g_slist_free (xlist->head);
@@ -1507,7 +1240,7 @@ hexchat_list_free (xchat_plugin *ph, xchat_list *xlist)
 }
 
 int
-hexchat_list_next (xchat_plugin *ph, xchat_list *xlist)
+xchat_list_next (xchat_plugin *ph, xchat_list *xlist)
 {
 	if (xlist->next == NULL)
 		return 0;
@@ -1529,7 +1262,7 @@ hexchat_list_next (xchat_plugin *ph, xchat_list *xlist)
 }
 
 const char * const *
-hexchat_list_fields (xchat_plugin *ph, const char *name)
+xchat_list_fields (xchat_plugin *ph, const char *name)
 {
 	static const char * const dcc_fields[] =
 	{
@@ -1579,7 +1312,7 @@ hexchat_list_fields (xchat_plugin *ph, const char *name)
 }
 
 time_t
-hexchat_list_time (xchat_plugin *ph, xchat_list *xlist, const char *name)
+xchat_list_time (xchat_plugin *ph, xchat_list *xlist, const char *name)
 {
 	guint32 hash = str_hash (name);
 	gpointer data;
@@ -1613,7 +1346,7 @@ hexchat_list_time (xchat_plugin *ph, xchat_list *xlist, const char *name)
 }
 
 const char *
-hexchat_list_str (xchat_plugin *ph, xchat_list *xlist, const char *name)
+xchat_list_str (xchat_plugin *ph, xchat_list *xlist, const char *name)
 {
 	guint32 hash = str_hash (name);
 	gpointer data = ph->context;
@@ -1697,7 +1430,7 @@ hexchat_list_str (xchat_plugin *ph, xchat_list *xlist, const char *name)
 }
 
 int
-hexchat_list_int (xchat_plugin *ph, xchat_list *xlist, const char *name)
+xchat_list_int (xchat_plugin *ph, xchat_list *xlist, const char *name)
 {
 	guint32 hash = str_hash (name);
 	gpointer data = ph->context;
@@ -1814,7 +1547,7 @@ hexchat_list_int (xchat_plugin *ph, xchat_list *xlist, const char *name)
 }
 
 void *
-hexchat_plugingui_add (xchat_plugin *ph, const char *filename,
+xchat_plugingui_add (xchat_plugin *ph, const char *filename,
 							const char *name, const char *desc,
 							const char *version, char *reserved)
 {
@@ -1828,7 +1561,7 @@ hexchat_plugingui_add (xchat_plugin *ph, const char *filename,
 }
 
 void
-hexchat_plugingui_remove (xchat_plugin *ph, void *handle)
+xchat_plugingui_remove (xchat_plugin *ph, void *handle)
 {
 #ifdef USE_PLUGIN
 	plugin_free (handle, FALSE, FALSE);
@@ -1836,7 +1569,7 @@ hexchat_plugingui_remove (xchat_plugin *ph, void *handle)
 }
 
 int
-hexchat_emit_print (xchat_plugin *ph, const char *event_name, ...)
+xchat_emit_print (xchat_plugin *ph, const char *event_name, ...)
 {
 	va_list args;
 	/* currently only 4 because no events use more than 4.
@@ -1863,7 +1596,7 @@ hexchat_emit_print (xchat_plugin *ph, const char *event_name, ...)
 }
 
 char *
-hexchat_gettext (xchat_plugin *ph, const char *msgid)
+xchat_gettext (xchat_plugin *ph, const char *msgid)
 {
 	/* so that plugins can use xchat's internal gettext strings. */
 	/* e.g. The EXEC plugin uses this on Windows. */
@@ -1871,7 +1604,7 @@ hexchat_gettext (xchat_plugin *ph, const char *msgid)
 }
 
 void
-hexchat_send_modes (xchat_plugin *ph, const char **targets, int ntargets, int modes_per_line, char sign, char mode)
+xchat_send_modes (xchat_plugin *ph, const char **targets, int ntargets, int modes_per_line, char sign, char mode)
 {
 	char tbuf[514];	/* modes.c needs 512 + null */
 
@@ -1879,19 +1612,19 @@ hexchat_send_modes (xchat_plugin *ph, const char **targets, int ntargets, int mo
 }
 
 char *
-hexchat_strip (xchat_plugin *ph, const char *str, int len, int flags)
+xchat_strip (xchat_plugin *ph, const char *str, int len, int flags)
 {
 	return strip_color ((char *)str, len, flags);
 }
 
 void
-hexchat_free (xchat_plugin *ph, void *ptr)
+xchat_free (xchat_plugin *ph, void *ptr)
 {
 	g_free (ptr);
 }
 
 static int
-hexchat_pluginpref_set_str_real (xchat_plugin *pl, const char *var, const char *value, int mode) /* mode: 0 = delete, 1 = save */
+xchat_pluginpref_set_str_real (xchat_plugin *pl, const char *var, const char *value, int mode) /* mode: 0 = delete, 1 = save */
 {
 	FILE *fpIn;
 	int fhOut;
@@ -2004,13 +1737,13 @@ hexchat_pluginpref_set_str_real (xchat_plugin *pl, const char *var, const char *
 }
 
 int
-hexchat_pluginpref_set_str (xchat_plugin *pl, const char *var, const char *value)
+xchat_pluginpref_set_str (xchat_plugin *pl, const char *var, const char *value)
 {
-	return hexchat_pluginpref_set_str_real (pl, var, value, 1);
+	return xchat_pluginpref_set_str_real (pl, var, value, 1);
 }
 
 int
-hexchat_pluginpref_get_str (xchat_plugin *pl, const char *var, char *dest)
+xchat_pluginpref_get_str (xchat_plugin *pl, const char *var, char *dest)
 {
 	int fh;
 	int l;
@@ -2062,20 +1795,20 @@ hexchat_pluginpref_get_str (xchat_plugin *pl, const char *var, char *dest)
 }
 
 int
-hexchat_pluginpref_set_int (xchat_plugin *pl, const char *var, int value)
+xchat_pluginpref_set_int (xchat_plugin *pl, const char *var, int value)
 {
 	char buffer[12];
 
 	sprintf (buffer, "%d", value);
-	return hexchat_pluginpref_set_str_real (pl, var, buffer, 1);
+	return xchat_pluginpref_set_str_real (pl, var, buffer, 1);
 }
 
 int
-hexchat_pluginpref_get_int (xchat_plugin *pl, const char *var)
+xchat_pluginpref_get_int (xchat_plugin *pl, const char *var)
 {
 	char buffer[12];
 
-	if (hexchat_pluginpref_get_str (pl, var, buffer))
+	if (xchat_pluginpref_get_str (pl, var, buffer))
 	{
 		return atoi (buffer);
 	}
@@ -2086,13 +1819,13 @@ hexchat_pluginpref_get_int (xchat_plugin *pl, const char *var)
 }
 
 int
-hexchat_pluginpref_delete (xchat_plugin *pl, const char *var)
+xchat_pluginpref_delete (xchat_plugin *pl, const char *var)
 {
-	return hexchat_pluginpref_set_str_real (pl, var, 0, 0);
+	return xchat_pluginpref_set_str_real (pl, var, 0, 0);
 }
 
 int
-hexchat_pluginpref_list (xchat_plugin *pl, char* dest)
+xchat_pluginpref_list (xchat_plugin *pl, char* dest)
 {
 	FILE *fpIn;
 	char confname[64];