From 1a75c8e1be58a25510642605dcd40c5c65e9c3f3 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Wed, 24 Oct 2012 21:33:02 +0200 Subject: A lot more rebranding --- src/common/Makefile.am | 16 +- src/common/cfgfiles.c | 4 +- src/common/cfgfiles.h | 2 +- src/common/chanopt.c | 4 +- src/common/common-xp.vcxproj | 8 +- src/common/common-xp.vcxproj.filters | 8 +- src/common/common.vcxproj | 8 +- src/common/common.vcxproj.filters | 8 +- src/common/ctcp.c | 4 +- src/common/dcc.c | 4 +- src/common/hexchat-plugin.h | 381 +++++++++++ src/common/hexchat.c | 1207 ++++++++++++++++++++++++++++++++++ src/common/hexchat.h | 595 +++++++++++++++++ src/common/hexchatc.h | 39 ++ src/common/identd.c | 4 +- src/common/ignore.c | 4 +- src/common/inbound.c | 4 +- src/common/modes.c | 4 +- src/common/msproxy.c | 4 +- src/common/notify.c | 4 +- src/common/outbound.c | 4 +- src/common/plugin-timer.c | 2 +- src/common/plugin.c | 6 +- src/common/proto-irc.c | 4 +- src/common/server.c | 4 +- src/common/servlist.c | 4 +- src/common/text.c | 4 +- src/common/url.c | 4 +- src/common/userlist.c | 4 +- src/common/util.c | 4 +- src/common/xchat-plugin.h | 381 ----------- src/common/xchat.c | 1207 ---------------------------------- src/common/xchat.h | 595 ----------------- src/common/xchatc.h | 39 -- src/fe-gtk/about.c | 4 +- src/fe-gtk/ascii.c | 4 +- src/fe-gtk/banlist.c | 4 +- src/fe-gtk/chanlist.c | 4 +- src/fe-gtk/chanview-tree.c | 4 +- src/fe-gtk/dccgui.c | 4 +- src/fe-gtk/editlist.c | 4 +- src/fe-gtk/fe-gtk.c | 4 +- src/fe-gtk/fkeys.c | 4 +- src/fe-gtk/gtkutil.c | 4 +- src/fe-gtk/ignoregui.c | 2 +- src/fe-gtk/joind.c | 4 +- src/fe-gtk/maingui.c | 4 +- src/fe-gtk/menu.c | 4 +- src/fe-gtk/notifygui.c | 2 +- src/fe-gtk/palette.c | 2 +- src/fe-gtk/pixmaps.c | 2 +- src/fe-gtk/plugin-tray.c | 6 +- src/fe-gtk/plugingui.c | 6 +- src/fe-gtk/rawlog.c | 4 +- src/fe-gtk/search.c | 4 +- src/fe-gtk/servlistgui.c | 4 +- src/fe-gtk/setup.c | 4 +- src/fe-gtk/sexy-spell-entry.c | 2 +- src/fe-gtk/textgui.c | 4 +- src/fe-gtk/urlgrab.c | 4 +- src/fe-gtk/userlistgui.c | 4 +- src/fe-gtk/xtext.c | 4 +- src/fe-text/fe-text.c | 4 +- 63 files changed, 2342 insertions(+), 2342 deletions(-) create mode 100644 src/common/hexchat-plugin.h create mode 100644 src/common/hexchat.c create mode 100644 src/common/hexchat.h create mode 100644 src/common/hexchatc.h delete mode 100644 src/common/xchat-plugin.h delete mode 100644 src/common/xchat.c delete mode 100644 src/common/xchat.h delete mode 100644 src/common/xchatc.h (limited to 'src') diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 830d73eb..22534bdd 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -10,6 +10,9 @@ EXTRA_DIST = \ ctcp.h \ dcc.h \ fe.h \ + hexchat.h \ + hexchatc.h \ + hexchat-plugin.h \ history.h \ identd.c \ ignore.h \ @@ -36,10 +39,7 @@ EXTRA_DIST = \ tree.h \ url.h \ userlist.h \ - util.h \ - xchat.h \ - xchatc.h \ - xchat-plugin.h + util.h if USE_OPENSSL ssl_c = ssl.c @@ -52,10 +52,10 @@ libhexchatcommon_a_LIBADD = \ endif SUBDIRS = $(dbusdir) . -libhexchatcommon_a_SOURCES = cfgfiles.c chanopt.c ctcp.c dcc.c history.c ignore.c \ - inbound.c modes.c msproxy.c network.c notify.c outbound.c \ - plugin.c plugin-timer.c proto-irc.c server.c servlist.c $(ssl_c) \ - strlutil.c text.c tree.c url.c userlist.c util.c xchat.c +libhexchatcommon_a_SOURCES = cfgfiles.c chanopt.c ctcp.c dcc.c hexchat.c \ + history.c ignore.c inbound.c modes.c msproxy.c network.c notify.c \ + outbound.c plugin.c plugin-timer.c proto-irc.c server.c servlist.c \ + $(ssl_c) strlutil.c text.c tree.c url.c userlist.c util.c libhexchatcommon_a_CFLAGS = $(LIBPROXY_CFLAGS) textevents: make-te diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 2312dada..9f3bc920 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -23,12 +23,12 @@ #include #include -#include "xchat.h" +#include "hexchat.h" #include "cfgfiles.h" #include "util.h" #include "fe.h" #include "text.h" -#include "xchatc.h" +#include "hexchatc.h" #ifdef WIN32 #include diff --git a/src/common/cfgfiles.h b/src/common/cfgfiles.h index 2cb4a4e2..9371f572 100644 --- a/src/common/cfgfiles.h +++ b/src/common/cfgfiles.h @@ -3,7 +3,7 @@ #ifndef XCHAT_CFGFILES_H #define XCHAT_CFGFILES_H -#include "xchat.h" +#include "hexchat.h" extern char *xdir_fs; extern char *xdir_utf; diff --git a/src/common/chanopt.c b/src/common/chanopt.c index 8e8b0312..d6d47fb2 100644 --- a/src/common/chanopt.c +++ b/src/common/chanopt.c @@ -14,13 +14,13 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "cfgfiles.h" #include "server.h" #include "text.h" #include "util.h" -#include "xchatc.h" +#include "hexchatc.h" static GSList *chanopt_list = NULL; diff --git a/src/common/common-xp.vcxproj b/src/common/common-xp.vcxproj index 6eec3b12..736eacb1 100644 --- a/src/common/common-xp.vcxproj +++ b/src/common/common-xp.vcxproj @@ -43,9 +43,9 @@ - - - + + + @@ -74,7 +74,7 @@ - + {87554B59-006C-4D94-9714-897B27067BA3} diff --git a/src/common/common-xp.vcxproj.filters b/src/common/common-xp.vcxproj.filters index 4940a6fd..3707caa0 100644 --- a/src/common/common-xp.vcxproj.filters +++ b/src/common/common-xp.vcxproj.filters @@ -98,13 +98,13 @@ Header Files - + Header Files - + Header Files - + Header Files @@ -193,7 +193,7 @@ Source Files - + Source Files diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj index 55116995..9bb79ac5 100644 --- a/src/common/common.vcxproj +++ b/src/common/common.vcxproj @@ -43,9 +43,9 @@ - - - + + + @@ -74,7 +74,7 @@ - + {87554B59-006C-4D94-9714-897B27067BA3} diff --git a/src/common/common.vcxproj.filters b/src/common/common.vcxproj.filters index 4940a6fd..3707caa0 100644 --- a/src/common/common.vcxproj.filters +++ b/src/common/common.vcxproj.filters @@ -98,13 +98,13 @@ Header Files - + Header Files - + Header Files - + Header Files @@ -193,7 +193,7 @@ Source Files - + Source Files diff --git a/src/common/ctcp.c b/src/common/ctcp.c index c0d1ce49..f950a901 100644 --- a/src/common/ctcp.c +++ b/src/common/ctcp.c @@ -24,7 +24,7 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "cfgfiles.h" #include "util.h" #include "modes.h" @@ -35,7 +35,7 @@ #include "text.h" #include "ctcp.h" #include "server.h" -#include "xchatc.h" +#include "hexchatc.h" static void diff --git a/src/common/dcc.c b/src/common/dcc.c index 4aa581a7..d9b1b855 100644 --- a/src/common/dcc.c +++ b/src/common/dcc.c @@ -48,7 +48,7 @@ #include #include -#include "xchat.h" +#include "hexchat.h" #include "util.h" #include "fe.h" #include "outbound.h" @@ -58,7 +58,7 @@ #include "server.h" #include "text.h" #include "url.h" -#include "xchatc.h" +#include "hexchatc.h" #ifdef USE_DCC64 #define BIG_STR_TO_INT(x) strtoull(x,NULL,10) diff --git a/src/common/hexchat-plugin.h b/src/common/hexchat-plugin.h new file mode 100644 index 00000000..43621f78 --- /dev/null +++ b/src/common/hexchat-plugin.h @@ -0,0 +1,381 @@ +/* You can distribute this header with your plugins for easy compilation */ +#ifndef HEXCHAT_PLUGIN_H +#define HEXCHAT_PLUGIN_H + +#include + +#define XCHAT_IFACE_MAJOR 1 +#define XCHAT_IFACE_MINOR 9 +#define XCHAT_IFACE_MICRO 11 +#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \ + (XCHAT_IFACE_MINOR * 100) + \ + (XCHAT_IFACE_MICRO)) + +#define XCHAT_PRI_HIGHEST 127 +#define XCHAT_PRI_HIGH 64 +#define XCHAT_PRI_NORM 0 +#define XCHAT_PRI_LOW (-64) +#define XCHAT_PRI_LOWEST (-128) + +#define XCHAT_FD_READ 1 +#define XCHAT_FD_WRITE 2 +#define XCHAT_FD_EXCEPTION 4 +#define XCHAT_FD_NOTSOCKET 8 + +#define XCHAT_EAT_NONE 0 /* pass it on through! */ +#define XCHAT_EAT_XCHAT 1 /* don't let xchat see this event */ +#define XCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */ +#define XCHAT_EAT_ALL (XCHAT_EAT_XCHAT|XCHAT_EAT_PLUGIN) /* don't let anything see this event */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xchat_plugin xchat_plugin; +typedef struct _xchat_list xchat_list; +typedef struct _xchat_hook xchat_hook; +#ifndef PLUGIN_C +typedef struct _xchat_context xchat_context; +#endif + +#ifndef PLUGIN_C +struct _xchat_plugin +{ + /* these are only used on win32 */ + xchat_hook *(*xchat_hook_command) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + xchat_hook *(*xchat_hook_server) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_print) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_timer) (xchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_fd) (xchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + void *(*xchat_unhook) (xchat_plugin *ph, + xchat_hook *hook); + void (*xchat_print) (xchat_plugin *ph, + const char *text); + void (*xchat_printf) (xchat_plugin *ph, + const char *format, ...); + void (*xchat_command) (xchat_plugin *ph, + const char *command); + void (*xchat_commandf) (xchat_plugin *ph, + const char *format, ...); + int (*xchat_nickcmp) (xchat_plugin *ph, + const char *s1, + const char *s2); + int (*xchat_set_context) (xchat_plugin *ph, + xchat_context *ctx); + xchat_context *(*xchat_find_context) (xchat_plugin *ph, + const char *servname, + const char *channel); + xchat_context *(*xchat_get_context) (xchat_plugin *ph); + const char *(*xchat_get_info) (xchat_plugin *ph, + const char *id); + int (*xchat_get_prefs) (xchat_plugin *ph, + const char *name, + const char **string, + int *integer); + xchat_list * (*xchat_list_get) (xchat_plugin *ph, + const char *name); + void (*xchat_list_free) (xchat_plugin *ph, + xchat_list *xlist); + const char * const * (*xchat_list_fields) (xchat_plugin *ph, + const char *name); + int (*xchat_list_next) (xchat_plugin *ph, + xchat_list *xlist); + const char * (*xchat_list_str) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + int (*xchat_list_int) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + void * (*xchat_plugingui_add) (xchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + void (*xchat_plugingui_remove) (xchat_plugin *ph, + void *handle); + int (*xchat_emit_print) (xchat_plugin *ph, + const char *event_name, ...); + int (*xchat_read_fd) (xchat_plugin *ph, + void *src, + char *buf, + int *len); + time_t (*xchat_list_time) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + char *(*xchat_gettext) (xchat_plugin *ph, + const char *msgid); + void (*xchat_send_modes) (xchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + char *(*xchat_strip) (xchat_plugin *ph, + const char *str, + int len, + int flags); + void (*xchat_free) (xchat_plugin *ph, + void *ptr); + int (*xchat_pluginpref_set_str) (xchat_plugin *ph, + const char *var, + const char *value); + int (*xchat_pluginpref_get_str) (xchat_plugin *ph, + const char *var, + char *dest); + int (*xchat_pluginpref_set_int) (xchat_plugin *ph, + const char *var, + int value); + int (*xchat_pluginpref_get_int) (xchat_plugin *ph, + const char *var); + int (*xchat_pluginpref_delete) (xchat_plugin *ph, + const char *var); + int (*xchat_pluginpref_list) (xchat_plugin *ph, + char *dest); +}; +#endif + + +xchat_hook * +xchat_hook_command (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + +xchat_hook * +xchat_hook_server (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + +xchat_hook * +xchat_hook_print (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + +xchat_hook * +xchat_hook_timer (xchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + +xchat_hook * +xchat_hook_fd (xchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + +void * +xchat_unhook (xchat_plugin *ph, + xchat_hook *hook); + +void +xchat_print (xchat_plugin *ph, + const char *text); + +void +xchat_printf (xchat_plugin *ph, + const char *format, ...); + +void +xchat_command (xchat_plugin *ph, + const char *command); + +void +xchat_commandf (xchat_plugin *ph, + const char *format, ...); + +int +xchat_nickcmp (xchat_plugin *ph, + const char *s1, + const char *s2); + +int +xchat_set_context (xchat_plugin *ph, + xchat_context *ctx); + +xchat_context * +xchat_find_context (xchat_plugin *ph, + const char *servname, + const char *channel); + +xchat_context * +xchat_get_context (xchat_plugin *ph); + +const char * +xchat_get_info (xchat_plugin *ph, + const char *id); + +int +xchat_get_prefs (xchat_plugin *ph, + const char *name, + const char **string, + int *integer); + +xchat_list * +xchat_list_get (xchat_plugin *ph, + const char *name); + +void +xchat_list_free (xchat_plugin *ph, + xchat_list *xlist); + +const char * const * +xchat_list_fields (xchat_plugin *ph, + const char *name); + +int +xchat_list_next (xchat_plugin *ph, + xchat_list *xlist); + +const char * +xchat_list_str (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + +int +xchat_list_int (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + +time_t +xchat_list_time (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + +void * +xchat_plugingui_add (xchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + +void +xchat_plugingui_remove (xchat_plugin *ph, + void *handle); + +int +xchat_emit_print (xchat_plugin *ph, + const char *event_name, ...); + +char * +xchat_gettext (xchat_plugin *ph, + const char *msgid); + +void +xchat_send_modes (xchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + +char * +xchat_strip (xchat_plugin *ph, + const char *str, + int len, + int flags); + +void +xchat_free (xchat_plugin *ph, + void *ptr); + +int +xchat_pluginpref_set_str (xchat_plugin *ph, + const char *var, + const char *value); + +int +xchat_pluginpref_get_str (xchat_plugin *ph, + const char *var, + char *dest); + +int +xchat_pluginpref_set_int (xchat_plugin *ph, + const char *var, + int value); +int +xchat_pluginpref_get_int (xchat_plugin *ph, + const char *var); + +int +xchat_pluginpref_delete (xchat_plugin *ph, + const char *var); + +int +xchat_pluginpref_list (xchat_plugin *ph, + char *dest); + +#if !defined(PLUGIN_C) && defined(WIN32) +#ifndef XCHAT_PLUGIN_HANDLE +#define XCHAT_PLUGIN_HANDLE (ph) +#endif +#define xchat_hook_command ((XCHAT_PLUGIN_HANDLE)->xchat_hook_command) +#define xchat_hook_server ((XCHAT_PLUGIN_HANDLE)->xchat_hook_server) +#define xchat_hook_print ((XCHAT_PLUGIN_HANDLE)->xchat_hook_print) +#define xchat_hook_timer ((XCHAT_PLUGIN_HANDLE)->xchat_hook_timer) +#define xchat_hook_fd ((XCHAT_PLUGIN_HANDLE)->xchat_hook_fd) +#define xchat_unhook ((XCHAT_PLUGIN_HANDLE)->xchat_unhook) +#define xchat_print ((XCHAT_PLUGIN_HANDLE)->xchat_print) +#define xchat_printf ((XCHAT_PLUGIN_HANDLE)->xchat_printf) +#define xchat_command ((XCHAT_PLUGIN_HANDLE)->xchat_command) +#define xchat_commandf ((XCHAT_PLUGIN_HANDLE)->xchat_commandf) +#define xchat_nickcmp ((XCHAT_PLUGIN_HANDLE)->xchat_nickcmp) +#define xchat_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_set_context) +#define xchat_find_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_context) +#define xchat_get_context ((XCHAT_PLUGIN_HANDLE)->xchat_get_context) +#define xchat_get_info ((XCHAT_PLUGIN_HANDLE)->xchat_get_info) +#define xchat_get_prefs ((XCHAT_PLUGIN_HANDLE)->xchat_get_prefs) +#define xchat_list_get ((XCHAT_PLUGIN_HANDLE)->xchat_list_get) +#define xchat_list_free ((XCHAT_PLUGIN_HANDLE)->xchat_list_free) +#define xchat_list_fields ((XCHAT_PLUGIN_HANDLE)->xchat_list_fields) +#define xchat_list_str ((XCHAT_PLUGIN_HANDLE)->xchat_list_str) +#define xchat_list_int ((XCHAT_PLUGIN_HANDLE)->xchat_list_int) +#define xchat_list_time ((XCHAT_PLUGIN_HANDLE)->xchat_list_time) +#define xchat_list_next ((XCHAT_PLUGIN_HANDLE)->xchat_list_next) +#define xchat_plugingui_add ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_add) +#define xchat_plugingui_remove ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_remove) +#define xchat_emit_print ((XCHAT_PLUGIN_HANDLE)->xchat_emit_print) +#define xchat_gettext ((XCHAT_PLUGIN_HANDLE)->xchat_gettext) +#define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) +#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) +#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) +#define xchat_pluginpref_set_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_str) +#define xchat_pluginpref_get_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_str) +#define xchat_pluginpref_set_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_int) +#define xchat_pluginpref_get_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_int) +#define xchat_pluginpref_delete ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_delete) +#define xchat_pluginpref_list ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_list) +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/common/hexchat.c b/src/common/hexchat.c new file mode 100644 index 00000000..66612a30 --- /dev/null +++ b/src/common/hexchat.c @@ -0,0 +1,1207 @@ +/* X-Chat + * Copyright (C) 1998 Peter Zelezny. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include + +#define WANTSOCKET +#include "inet.h" + +#ifdef WIN32 +#include +#else +#include +#include +#include +#endif + +#include "hexchat.h" +#include "fe.h" +#include "util.h" +#include "cfgfiles.h" +#include "chanopt.h" +#include "ignore.h" +#include "hexchat-plugin.h" +#include "plugin.h" +#include "plugin-timer.h" +#include "notify.h" +#include "server.h" +#include "servlist.h" +#include "outbound.h" +#include "text.h" +#include "url.h" +#include "hexchatc.h" + +#ifdef USE_OPENSSL +#include /* SSL_() */ +#include "ssl.h" +#endif + +#ifdef USE_MSPROXY +#include "msproxy.h" +#endif + +#ifdef USE_LIBPROXY +#include +#endif + +GSList *popup_list = 0; +GSList *button_list = 0; +GSList *dlgbutton_list = 0; +GSList *command_list = 0; +GSList *ctcp_list = 0; +GSList *replace_list = 0; +GSList *sess_list = 0; +GSList *dcc_list = 0; +GSList *ignore_list = 0; +GSList *usermenu_list = 0; +GSList *urlhandler_list = 0; +GSList *tabmenu_list = 0; + +static int in_xchat_exit = FALSE; +int xchat_is_quitting = FALSE; +/* command-line args */ +int arg_dont_autoconnect = FALSE; +int arg_skip_plugins = FALSE; +char *arg_url = NULL; +char *arg_command = NULL; +gint arg_existing = FALSE; + +#ifdef USE_DBUS +#include "dbus/dbus-client.h" +#include "dbus/dbus-plugin.h" +#endif /* USE_DBUS */ + +struct session *current_tab; +struct session *current_sess = 0; +struct hexchatprefs prefs; + +#ifdef USE_OPENSSL +SSL_CTX *ctx = NULL; +#endif + +#ifdef USE_LIBPROXY +pxProxyFactory *libproxy_factory; +#endif + +int +is_session (session * sess) +{ + return g_slist_find (sess_list, sess) ? 1 : 0; +} + +session * +find_dialog (server *serv, char *nick) +{ + GSList *list = sess_list; + session *sess; + + while (list) + { + sess = list->data; + if (sess->server == serv && sess->type == SESS_DIALOG) + { + if (!serv->p_cmp (nick, sess->channel)) + return (sess); + } + list = list->next; + } + return 0; +} + +session * +find_channel (server *serv, char *chan) +{ + session *sess; + GSList *list = sess_list; + while (list) + { + sess = list->data; + if ((!serv || serv == sess->server) && sess->type != SESS_DIALOG) + { + if (!serv->p_cmp (chan, sess->channel)) + return sess; + } + list = list->next; + } + return 0; +} + +static void +lagcheck_update (void) +{ + server *serv; + GSList *list = serv_list; + + if (!prefs.hex_gui_lagometer) + return; + + while (list) + { + serv = list->data; + if (serv->lag_sent) + fe_set_lag (serv, -1); + + list = list->next; + } +} + +void +lag_check (void) +{ + server *serv; + GSList *list = serv_list; + unsigned long tim; + char tbuf[128]; + time_t now = time (0); + int lag; + + tim = make_ping_time (); + + while (list) + { + serv = list->data; + if (serv->connected && serv->end_of_motd) + { + lag = now - serv->ping_recv; + if (prefs.hex_net_ping_timeout && lag > prefs.hex_net_ping_timeout && lag > 0) + { + sprintf (tbuf, "%d", lag); + EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL, + NULL, NULL, 0); + if (prefs.hex_net_auto_reconnect) + serv->auto_reconnect (serv, FALSE, -1); + } else + { + snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim); + serv->p_ping (serv, "", tbuf); + serv->lag_sent = tim; + fe_set_lag (serv, -1); + } + } + list = list->next; + } +} + +static int +away_check (void) +{ + session *sess; + GSList *list; + int full, sent, loop = 0; + + if (!prefs.hex_away_track || prefs.hex_away_size_max < 1) + return 1; + +doover: + /* request an update of AWAY status of 1 channel every 30 seconds */ + full = TRUE; + sent = 0; /* number of WHOs (users) requested */ + list = sess_list; + while (list) + { + sess = list->data; + + if (sess->server->connected && + sess->type == SESS_CHANNEL && + sess->channel[0] && + sess->total <= prefs.hex_away_size_max) + { + if (!sess->done_away_check) + { + full = FALSE; + + /* if we're under 31 WHOs, send another channels worth */ + if (sent < 31 && !sess->doing_who) + { + sess->done_away_check = TRUE; + sess->doing_who = TRUE; + /* this'll send a WHO #channel */ + sess->server->p_away_status (sess->server, sess->channel); + sent += sess->total; + } + } + } + + list = list->next; + } + + /* done them all, reset done_away_check to FALSE and start over */ + if (full) + { + list = sess_list; + while (list) + { + sess = list->data; + sess->done_away_check = FALSE; + list = list->next; + } + loop++; + if (loop < 2) + goto doover; + } + + return 1; +} + +static int +xchat_misc_checks (void) /* this gets called every 1/2 second */ +{ + static int count = 0; +#ifdef USE_MSPROXY + static int count2 = 0; +#endif + + count++; + + lagcheck_update (); /* every 500ms */ + + if (count % 2) + dcc_check_timeouts (); /* every 1 second */ + + if (count >= 60) /* every 30 seconds */ + { + if (prefs.hex_gui_lagometer) + lag_check (); + count = 0; + } + +#ifdef USE_MSPROXY + count2++; + if (count2 >= 720) /* 720 every 6 minutes */ + { + msproxy_keepalive (); + count2 = 0; + } +#endif + + return 1; +} + +/* executed when the first irc window opens */ + +static void +irc_init (session *sess) +{ + static int done_init = FALSE; + char buf[512]; + + if (done_init) + return; + + done_init = TRUE; + + plugin_add (sess, NULL, NULL, timer_plugin_init, NULL, NULL, FALSE); + +#ifdef USE_PLUGIN + if (!arg_skip_plugins) + plugin_auto_load (sess); /* autoload ~/.xchat *.so */ +#endif + +#ifdef USE_DBUS + plugin_add (sess, NULL, NULL, dbus_plugin_init, NULL, NULL, FALSE); +#endif + + if (prefs.hex_notify_timeout) + notify_tag = fe_timeout_add (prefs.hex_notify_timeout * 1000, + notify_checklist, 0); + + fe_timeout_add (prefs.hex_away_timeout * 1000, away_check, 0); + fe_timeout_add (500, xchat_misc_checks, 0); + + if (arg_url != NULL) + { + snprintf (buf, sizeof (buf), "server %s", arg_url); + handle_command (sess, buf, FALSE); + g_free (arg_url); /* from GOption */ + } + + if (arg_command != NULL) + { + g_free (arg_command); + } + + /* load -e ~/.xchat2/startup.txt */ + snprintf (buf, sizeof (buf), "%s/%s", get_xdir_fs (), "startup.txt"); + load_perform_file (sess, buf); +} + +static session * +session_new (server *serv, char *from, int type, int focus) +{ + session *sess; + + sess = malloc (sizeof (struct session)); + if (sess == NULL) + { + return NULL; + } + memset (sess, 0, sizeof (struct session)); + + sess->server = serv; + sess->logfd = -1; + sess->scrollfd = -1; + sess->type = type; + + sess->alert_beep = SET_DEFAULT; + sess->alert_taskbar = SET_DEFAULT; + sess->alert_tray = SET_DEFAULT; + + sess->text_hidejoinpart = SET_DEFAULT; + sess->text_logging = SET_DEFAULT; + sess->text_scrollback = SET_DEFAULT; + + if (from != NULL) + safe_strcpy (sess->channel, from, CHANLEN); + + sess_list = g_slist_prepend (sess_list, sess); + + fe_new_window (sess, focus); + + return sess; +} + +session * +new_ircwindow (server *serv, char *name, int type, int focus) +{ + session *sess; + + switch (type) + { + case SESS_SERVER: + serv = server_new (); + if (prefs.hex_gui_tab_server) + sess = session_new (serv, name, SESS_SERVER, focus); + else + sess = session_new (serv, name, SESS_CHANNEL, focus); + serv->server_session = sess; + serv->front_session = sess; + break; + case SESS_DIALOG: + sess = session_new (serv, name, type, focus); + log_open_or_close (sess); + break; + default: +/* case SESS_CHANNEL: + case SESS_NOTICES: + case SESS_SNOTICES:*/ + sess = session_new (serv, name, type, focus); + break; + } + + irc_init (sess); + scrollback_load (sess); + chanopt_load (sess); + plugin_emit_dummy_print (sess, "Open Context"); + + return sess; +} + +static void +exec_notify_kill (session * sess) +{ +#ifndef WIN32 + struct nbexec *re; + if (sess->running_exec != NULL) + { + re = sess->running_exec; + sess->running_exec = NULL; + kill (re->childpid, SIGKILL); + waitpid (re->childpid, NULL, WNOHANG); + fe_input_remove (re->iotag); + close (re->myfd); + if (re->linebuf) + free(re->linebuf); + free (re); + } +#endif +} + +static void +send_quit_or_part (session * killsess) +{ + int willquit = TRUE; + GSList *list; + session *sess; + server *killserv = killsess->server; + + /* check if this is the last session using this server */ + list = sess_list; + while (list) + { + sess = (session *) list->data; + if (sess->server == killserv && sess != killsess) + { + willquit = FALSE; + list = 0; + } else + list = list->next; + } + + if (xchat_is_quitting) + willquit = TRUE; + + if (killserv->connected) + { + if (willquit) + { + if (!killserv->sent_quit) + { + killserv->flush_queue (killserv); + server_sendquit (killsess); + killserv->sent_quit = TRUE; + } + } else + { + if (killsess->type == SESS_CHANNEL && killsess->channel[0] && + !killserv->sent_quit) + { + server_sendpart (killserv, killsess->channel, 0); + } + } + } +} + +void +session_free (session *killsess) +{ + server *killserv = killsess->server; + session *sess; + GSList *list; + + plugin_emit_dummy_print (killsess, "Close Context"); + + if (current_tab == killsess) + current_tab = NULL; + + if (killserv->server_session == killsess) + killserv->server_session = NULL; + + if (killserv->front_session == killsess) + { + /* front_session is closed, find a valid replacement */ + killserv->front_session = NULL; + list = sess_list; + while (list) + { + sess = (session *) list->data; + if (sess != killsess && sess->server == killserv) + { + killserv->front_session = sess; + if (!killserv->server_session) + killserv->server_session = sess; + break; + } + list = list->next; + } + } + + if (!killserv->server_session) + killserv->server_session = killserv->front_session; + + sess_list = g_slist_remove (sess_list, killsess); + + if (killsess->type == SESS_CHANNEL) + userlist_free (killsess); + + exec_notify_kill (killsess); + + log_close (killsess); + scrollback_close (killsess); + chanopt_save (killsess); + + send_quit_or_part (killsess); + + history_free (&killsess->history); + if (killsess->topic) + free (killsess->topic); + if (killsess->current_modes) + free (killsess->current_modes); + + fe_session_callback (killsess); + + if (current_sess == killsess) + { + current_sess = NULL; + if (sess_list) + current_sess = sess_list->data; + } + + free (killsess); + + if (!sess_list && !in_xchat_exit) + xchat_exit (); /* sess_list is empty, quit! */ + + list = sess_list; + while (list) + { + sess = (session *) list->data; + if (sess->server == killserv) + return; /* this server is still being used! */ + list = list->next; + } + + server_free (killserv); +} + +static void +free_sessions (void) +{ + GSList *list = sess_list; + + while (list) + { + fe_close_window (list->data); + list = sess_list; + } +} + + +static char defaultconf_ctcp[] = + "NAME TIME\n" "CMD nctcp %s TIME %t\n\n"\ + "NAME PING\n" "CMD nctcp %s PING %d\n\n"; + +static char defaultconf_replace[] = + "NAME teh\n" "CMD the\n\n"; +/* "NAME r\n" "CMD are\n\n"\ + "NAME u\n" "CMD you\n\n"*/ + +static char defaultconf_commands[] = + "NAME ACTION\n" "CMD me &2\n\n"\ + "NAME AME\n" "CMD allchan me &2\n\n"\ + "NAME ANICK\n" "CMD allserv nick &2\n\n"\ + "NAME AMSG\n" "CMD allchan say &2\n\n"\ + "NAME BANLIST\n" "CMD quote MODE %c +b\n\n"\ + "NAME CHAT\n" "CMD dcc chat %2\n\n"\ + "NAME DIALOG\n" "CMD query %2\n\n"\ + "NAME DMSG\n" "CMD msg =%2 &3\n\n"\ + "NAME EXIT\n" "CMD quit\n\n"\ + "NAME GREP\n" "CMD lastlog -r -- &2\n\n"\ + "NAME IGNALL\n" "CMD ignore %2!*@* ALL\n\n"\ + "NAME J\n" "CMD join &2\n\n"\ + "NAME KILL\n" "CMD quote KILL %2 :&3\n\n"\ + "NAME LEAVE\n" "CMD part &2\n\n"\ + "NAME M\n" "CMD msg &2\n\n"\ + "NAME ONOTICE\n" "CMD notice @%c &2\n\n"\ + "NAME RAW\n" "CMD quote &2\n\n"\ + "NAME SERVHELP\n" "CMD quote HELP\n\n"\ + "NAME SPING\n" "CMD ping\n\n"\ + "NAME SQUERY\n" "CMD quote SQUERY %2 :&3\n\n"\ + "NAME SSLSERVER\n" "CMD server -ssl &2\n\n"\ + "NAME SV\n" "CMD echo xchat %v %m\n\n"\ + "NAME UMODE\n" "CMD mode %n &2\n\n"\ + "NAME UPTIME\n" "CMD quote STATS u\n\n"\ + "NAME VER\n" "CMD ctcp %2 VERSION\n\n"\ + "NAME VERSION\n" "CMD ctcp %2 VERSION\n\n"\ + "NAME WALLOPS\n" "CMD quote WALLOPS :&2\n\n"\ + "NAME WII\n" "CMD quote WHOIS %2 %2\n\n"; + +static char defaultconf_urlhandlers[] = + "NAME Open Link in Opera\n" "CMD !opera -remote 'openURL(%s)'\n\n"; + +#ifdef USE_SIGACTION +/* Close and open log files on SIGUSR1. Usefull for log rotating */ + +static void +sigusr1_handler (int signal, siginfo_t *si, void *un) +{ + GSList *list = sess_list; + session *sess; + + while (list) + { + sess = list->data; + log_open_or_close (sess); + list = list->next; + } +} + +/* Execute /SIGUSR2 when SIGUSR2 received */ + +static void +sigusr2_handler (int signal, siginfo_t *si, void *un) +{ + session *sess = current_sess; + + if (sess) + handle_command (sess, "SIGUSR2", FALSE); +} +#endif + +static gint +xchat_auto_connect (gpointer userdata) +{ + servlist_auto_connect (NULL); + return 0; +} + +static void +xchat_init (void) +{ + char buf[3068]; + const char *cs = NULL; + +#ifdef WIN32 + WSADATA wsadata; + +#ifdef USE_IPV6 + if (WSAStartup(0x0202, &wsadata) != 0) + { + MessageBox (NULL, "Cannot find winsock 2.2+", "Error", MB_OK); + exit (0); + } +#else + WSAStartup(0x0101, &wsadata); +#endif /* !USE_IPV6 */ +#endif /* !WIN32 */ + +#ifdef USE_SIGACTION + struct sigaction act; + + /* ignore SIGPIPE's */ + act.sa_handler = SIG_IGN; + act.sa_flags = 0; + sigemptyset (&act.sa_mask); + sigaction (SIGPIPE, &act, NULL); + + /* Deal with SIGUSR1's & SIGUSR2's */ + act.sa_sigaction = sigusr1_handler; + act.sa_flags = 0; + sigemptyset (&act.sa_mask); + sigaction (SIGUSR1, &act, NULL); + + act.sa_sigaction = sigusr2_handler; + act.sa_flags = 0; + sigemptyset (&act.sa_mask); + sigaction (SIGUSR2, &act, NULL); +#else +#ifndef WIN32 + /* good enough for these old systems */ + signal (SIGPIPE, SIG_IGN); +#endif +#endif + + if (g_get_charset (&cs)) + prefs.utf8_locale = TRUE; + + load_text_events (); + sound_load (); + notify_load (); + ignore_load (); + + snprintf (buf, sizeof (buf), + "NAME %s~%s~\n" "CMD query %%s\n\n"\ + "NAME %s~%s~\n" "CMD send %%s\n\n"\ + "NAME %s~%s~\n" "CMD whois %%s %%s\n\n"\ + "NAME %s~%s~\n" "CMD notify -n ASK %%s\n\n"\ + "NAME %s~%s~\n" "CMD ignore %%s!*@* ALL\n\n"\ + + "NAME SUB\n" "CMD %s\n\n"\ + "NAME %s\n" "CMD op %%a\n\n"\ + "NAME %s\n" "CMD deop %%a\n\n"\ + "NAME SEP\n" "CMD \n\n"\ + "NAME %s\n" "CMD voice %%a\n\n"\ + "NAME %s\n" "CMD devoice %%a\n"\ + "NAME SEP\n" "CMD \n\n"\ + "NAME SUB\n" "CMD %s\n\n"\ + "NAME %s\n" "CMD kick %%s\n\n"\ + "NAME %s\n" "CMD ban %%s\n\n"\ + "NAME SEP\n" "CMD \n\n"\ + "NAME %s *!*@*.host\n""CMD ban %%s 0\n\n"\ + "NAME %s *!*@domain\n""CMD ban %%s 1\n\n"\ + "NAME %s *!*user@*.host\n""CMD ban %%s 2\n\n"\ + "NAME %s *!*user@domain\n""CMD ban %%s 3\n\n"\ + "NAME SEP\n" "CMD \n\n"\ + "NAME %s *!*@*.host\n""CMD kickban %%s 0\n\n"\ + "NAME %s *!*@domain\n""CMD kickban %%s 1\n\n"\ + "NAME %s *!*user@*.host\n""CMD kickban %%s 2\n\n"\ + "NAME %s *!*user@domain\n""CMD kickban %%s 3\n\n"\ + "NAME ENDSUB\n" "CMD \n\n"\ + "NAME ENDSUB\n" "CMD \n\n", + + _("_Open Dialog Window"), "gtk-go-up", + _("_Send a File"), "gtk-floppy", + _("_User Info (WhoIs)"), "gtk-info", + _("_Add to Friends List"), "gtk-add", + _("_Ignore"), "gtk-stop", + _("O_perator Actions"), + + _("Give Ops"), + _("Take Ops"), + _("Give Voice"), + _("Take Voice"), + + _("Kick/Ban"), + _("Kick"), + _("Ban"), + _("Ban"), + _("Ban"), + _("Ban"), + _("Ban"), + _("KickBan"), + _("KickBan"), + _("KickBan"), + _("KickBan")); + + list_loadconf ("popup.conf", &popup_list, buf); + + snprintf (buf, sizeof (buf), + "NAME %s\n" "CMD part\n\n" + "NAME %s\n" "CMD getstr # join \"%s\"\n\n" + "NAME %s\n" "CMD quote LINKS\n\n" + "NAME %s\n" "CMD ping\n\n" + "NAME TOGGLE %s\n" "CMD irc_hide_version\n\n", + _("Leave Channel"), + _("Join Channel..."), + _("Enter Channel to Join:"), + _("Server Links"), + _("Ping Server"), + _("Hide Version")); + list_loadconf ("usermenu.conf", &usermenu_list, buf); + + snprintf (buf, sizeof (buf), + "NAME %s\n" "CMD op %%a\n\n" + "NAME %s\n" "CMD deop %%a\n\n" + "NAME %s\n" "CMD ban %%s\n\n" + "NAME %s\n" "CMD getstr \"%s\" \"kick %%s\" \"%s\"\n\n" + "NAME %s\n" "CMD send %%s\n\n" + "NAME %s\n" "CMD query %%s\n\n", + _("Op"), + _("DeOp"), + _("Ban"), + _("Kick"), + _("bye"), + _("Enter reason to kick %s:"), + _("Sendfile"), + _("Dialog")); + list_loadconf ("buttons.conf", &button_list, buf); + + snprintf (buf, sizeof (buf), + "NAME %s\n" "CMD whois %%s %%s\n\n" + "NAME %s\n" "CMD send %%s\n\n" + "NAME %s\n" "CMD dcc chat %%s\n\n" + "NAME %s\n" "CMD clear\n\n" + "NAME %s\n" "CMD ping %%s\n\n", + _("WhoIs"), + _("Send"), + _("Chat"), + _("Clear"), + _("Ping")); + list_loadconf ("dlgbuttons.conf", &dlgbutton_list, buf); + + list_loadconf ("tabmenu.conf", &tabmenu_list, NULL); + list_loadconf ("ctcpreply.conf", &ctcp_list, defaultconf_ctcp); + list_loadconf ("commands.conf", &command_list, defaultconf_commands); + list_loadconf ("replace.conf", &replace_list, defaultconf_replace); + list_loadconf ("urlhandlers.conf", &urlhandler_list, + defaultconf_urlhandlers); + + servlist_init (); /* load server list */ + + /* if we got a URL, don't open the server list GUI */ + if (!prefs.hex_gui_slist_skip && !arg_url) + fe_serverlist_open (NULL); + + /* turned OFF via -a arg */ + if (!arg_dont_autoconnect) + { + /* do any auto connects */ + if (!servlist_have_auto ()) /* if no new windows open .. */ + { + /* and no serverlist gui ... */ + if (prefs.hex_gui_slist_skip || arg_url) + /* we'll have to open one. */ + new_ircwindow (NULL, NULL, SESS_SERVER, 0); + } else + { + fe_idle_add (xchat_auto_connect, NULL); + } + } else + { + if (prefs.hex_gui_slist_skip || arg_url) + new_ircwindow (NULL, NULL, SESS_SERVER, 0); + } +} + +void +xchat_exit (void) +{ + xchat_is_quitting = TRUE; + in_xchat_exit = TRUE; + plugin_kill_all (); + fe_cleanup (); + + save_config (); + if (prefs.save_pevents) + { + pevent_save (NULL); + } + + sound_save (); + notify_save (); + ignore_save (); + free_sessions (); + chanopt_save_all (); + servlist_cleanup (); + fe_exit (); +} + +#ifndef WIN32 + +static int +child_handler (gpointer userdata) +{ + int pid = GPOINTER_TO_INT (userdata); + + if (waitpid (pid, 0, WNOHANG) == pid) + return 0; /* remove timeout handler */ + return 1; /* keep the timeout handler */ +} + +#endif + +void +xchat_exec (const char *cmd) +{ +#ifdef WIN32 + util_exec (cmd); +#else + int pid = util_exec (cmd); + if (pid != -1) + /* zombie avoiding system. Don't ask! it has to be like this to work + with zvt (which overrides the default handler) */ + fe_timeout_add (1000, child_handler, GINT_TO_POINTER (pid)); +#endif +} + +void +xchat_execv (char * const argv[]) +{ +#ifdef WIN32 + util_execv (argv); +#else + int pid = util_execv (argv); + if (pid != -1) + /* zombie avoiding system. Don't ask! it has to be like this to work + with zvt (which overrides the default handler) */ + fe_timeout_add (1000, child_handler, GINT_TO_POINTER (pid)); +#endif +} + +#ifdef WIN32 +static void +xchat_restore_window (HWND xchat_window) +{ + /* ShowWindow (xchat_window, SW_RESTORE); another way, but works worse */ + SendMessage (xchat_window, WM_SYSCOMMAND, SC_RESTORE, 0); + SetForegroundWindow (xchat_window); +} + +BOOL CALLBACK +enum_windows_impl (HWND current_window, LPARAM lParam) +{ + TCHAR window_name[8]; + TCHAR module_path[1024]; + ZeroMemory (&window_name, sizeof (window_name)); + + if (!current_window) + { + return TRUE; + } + + GetWindowText (current_window, window_name, 8); /* name length + 1 */ + if (strcmp (window_name, "HexChat") == 0) + { + /* use a separate if block, this way we don't have to call GetWindowModuleFileName() for each hit */ + ZeroMemory (&module_path, sizeof (module_path)); + GetWindowModuleFileName (current_window, module_path, sizeof (module_path)); + + if (strstr (module_path, "hexchat.exe")) /* We've found it, stop */ + { + xchat_restore_window (current_window); + return FALSE; + } + } + + return TRUE; /* Keep searching */ + +} +#endif + +int +main (int argc, char *argv[]) +{ + int ret; + +#ifdef WIN32 + char hexchat_lang[13]; /* LC_ALL= plus 5 chars of hex_gui_lang and trailing \0 */ + HANDLE mutex; +#endif + + srand (time (0)); /* CL: do this only once! */ + + load_config (); + +#ifdef WIN32 + /* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */ + strcpy (hexchat_lang, "LC_ALL="); + + /* this must be ordered EXACTLY as langsmenu[] */ + switch (prefs.hex_gui_lang) + { + case 0: + strcat (hexchat_lang, "af"); + break; + case 1: + strcat (hexchat_lang, "sq"); + break; + case 2: + strcat (hexchat_lang, "am"); + break; + case 3: + strcat (hexchat_lang, "ast"); + break; + case 4: + strcat (hexchat_lang, "az"); + break; + case 5: + strcat (hexchat_lang, "eu"); + break; + case 6: + strcat (hexchat_lang, "be"); + break; + case 7: + strcat (hexchat_lang, "bg"); + break; + case 8: + strcat (hexchat_lang, "ca"); + break; + case 9: + strcat (hexchat_lang, "zh_CN"); + break; + case 10: + strcat (hexchat_lang, "zh_TW"); + break; + case 11: + strcat (hexchat_lang, "cs"); + break; + case 12: + strcat (hexchat_lang, "da"); + break; + case 13: + strcat (hexchat_lang, "nl"); + break; + case 14: + strcat (hexchat_lang, "en_GB"); + break; + case 15: + strcat (hexchat_lang, "en"); + break; + case 16: + strcat (hexchat_lang, "et"); + break; + case 17: + strcat (hexchat_lang, "fi"); + break; + case 18: + strcat (hexchat_lang, "fr"); + break; + case 19: + strcat (hexchat_lang, "gl"); + break; + case 20: + strcat (hexchat_lang, "de"); + break; + case 21: + strcat (hexchat_lang, "el"); + break; + case 22: + strcat (hexchat_lang, "gu"); + break; + case 23: + strcat (hexchat_lang, "hi"); + break; + case 24: + strcat (hexchat_lang, "hu"); + break; + case 25: + strcat (hexchat_lang, "id"); + break; + case 26: + strcat (hexchat_lang, "it"); + break; + case 27: + strcat (hexchat_lang, "ja"); + break; + case 28: + strcat (hexchat_lang, "kn"); + break; + case 29: + strcat (hexchat_lang, "rw"); + break; + case 30: + strcat (hexchat_lang, "ko"); + break; + case 31: + strcat (hexchat_lang, "lv"); + break; + case 32: + strcat (hexchat_lang, "lt"); + break; + case 33: + strcat (hexchat_lang, "mk"); + break; + case 34: + strcat (hexchat_lang, "ml"); + break; + case 35: + strcat (hexchat_lang, "ms"); + break; + case 36: + strcat (hexchat_lang, "nb"); + break; + case 37: + strcat (hexchat_lang, "no"); + break; + case 38: + strcat (hexchat_lang, "pl"); + break; + case 39: + strcat (hexchat_lang, "pt"); + break; + case 40: + strcat (hexchat_lang, "pt_BR"); + break; + case 41: + strcat (hexchat_lang, "pa"); + break; + case 42: + strcat (hexchat_lang, "ru"); + break; + case 43: + strcat (hexchat_lang, "sr"); + break; + case 44: + strcat (hexchat_lang, "sk"); + break; + case 45: + strcat (hexchat_lang, "sl"); + break; + case 46: + strcat (hexchat_lang, "es"); + break; + case 47: + strcat (hexchat_lang, "sv"); + break; + case 48: + strcat (hexchat_lang, "th"); + break; + case 49: + strcat (hexchat_lang, "uk"); + break; + case 50: + strcat (hexchat_lang, "vi"); + break; + case 51: + strcat (hexchat_lang, "wa"); + break; + default: + strcat (hexchat_lang, "en"); + break; + } + + putenv (hexchat_lang); + + if (prefs.hex_gui_single && !portable_mode ()) + { + DWORD error; + + mutex = CreateMutex (NULL, TRUE, "Local\\hexchat"); + error = GetLastError (); + + if (error == ERROR_ALREADY_EXISTS || mutex == NULL) + { + /* restoring the XChat window from the tray via the taskbar icon + * only works correctly when X-Tray is used, but it's not a big deal + * since you can only minimize XChat to tray via the taskbar if you + * use X-Tray*/ + if (hextray_mode ()) + { + /* FindWindow() doesn't support wildcards so we check all the open windows */ + EnumWindows (enum_windows_impl, NULL); + return 0; + } + else + { + return 1; + } + } + } +#endif + +#ifdef SOCKS + SOCKSinit (argv[0]); +#endif + + ret = fe_args (argc, argv); + if (ret != -1) + return ret; + +#ifdef USE_DBUS + xchat_remote (); +#endif + +#ifdef USE_LIBPROXY + libproxy_factory = px_proxy_factory_new(); +#endif + + fe_init (); + + xchat_init (); + + fe_main (); + +#ifdef USE_LIBPROXY + px_proxy_factory_free(libproxy_factory); +#endif + +#ifdef USE_OPENSSL + if (ctx) + _SSL_context_free (ctx); +#endif + +#ifdef USE_DEBUG + xchat_mem_list (); +#endif + +#ifdef WIN32 + WSACleanup (); + + if (prefs.hex_gui_single && !portable_mode ()) + { + ReleaseMutex (mutex); + CloseHandle (mutex); + } +#endif + + return 0; +} diff --git a/src/common/hexchat.h b/src/common/hexchat.h new file mode 100644 index 00000000..2980fc1c --- /dev/null +++ b/src/common/hexchat.h @@ -0,0 +1,595 @@ +#include "../../config.h" + +#include +#include /* need time_t */ + +#ifndef XCHAT_H +#define XCHAT_H + +#include "history.h" + +#ifndef HAVE_SNPRINTF +#define snprintf g_snprintf +#endif + +#ifndef HAVE_VSNPRINTF +#define vsnprintf _vsnprintf +#endif + +#ifdef USE_DEBUG +#define malloc(n) xchat_malloc(n, __FILE__, __LINE__) +#define realloc(n, m) xchat_realloc(n, m, __FILE__, __LINE__) +#define free(n) xchat_dfree(n, __FILE__, __LINE__) +#define strdup(n) xchat_strdup(n, __FILE__, __LINE__) +void *xchat_malloc (int size, char *file, int line); +void *xchat_strdup (char *str, char *file, int line); +void xchat_dfree (void *buf, char *file, int line); +void *xchat_realloc (char *old, int len, char *file, int line); +#endif + +#ifdef SOCKS +#ifdef __sgi +#include +#define INCLUDE_PROTOTYPES 1 +#endif +#include +#endif + +#ifdef USE_OPENSSL +#include /* SSL_() */ +#endif + +#ifdef __EMX__ /* for o/s 2 */ +#define OFLAGS O_BINARY +#define g_ascii_strcasecmp stricmp +#define g_ascii_strncasecmp strnicmp +#define PATH_MAX MAXPATHLEN +#define FILEPATH_LEN_MAX MAXPATHLEN +#endif + +/* force a 32bit CMP.L */ +#define CMPL(a, c0, c1, c2, c3) (a == (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24))) +#define WORDL(c0, c1, c2, c3) (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24)) +#define WORDW(c0, c1) (guint16)(c0 | (c1 << 8)) + +#ifdef WIN32 /* for win32 */ +#define OFLAGS O_BINARY +#define sleep(t) Sleep(t*1000) +#include +#define F_OK 0 +#define X_OK 1 +#define W_OK 2 +#define R_OK 4 +#ifndef S_ISDIR +#define S_ISDIR(m) ((m) & _S_IFDIR) +#endif +#define NETWORK_PRIVATE +#else /* for unix */ +#define OFLAGS 0 +#endif + +#define FONTNAMELEN 127 +#define PATHLEN 255 +#define DOMAINLEN 100 +#define NICKLEN 64 /* including the NULL, so 63 really */ +#define CHANLEN 300 +#define PDIWORDS 32 +#define USERNAMELEN 10 +#define HIDDEN_CHAR 8 /* invisible character for xtext */ + +#if defined(ENABLE_NLS) && !defined(_) +# include +# define _(x) gettext(x) +# ifdef gettext_noop +# define N_(String) gettext_noop (String) +# else +# define N_(String) (String) +# endif +#endif +#if !defined(_) +# define N_(String) (String) +# define _(x) (x) +#endif + +struct nbexec +{ + int myfd; + int childpid; + int tochannel; /* making this int keeps the struct 4-byte aligned */ + int iotag; + char *linebuf; + int buffill; + struct session *sess; +}; + +struct hexchatprefs +{ + /* these are the rebranded, consistent, sorted hexchat variables */ + + /* BOOLEANS */ + unsigned int hex_away_auto_unmark; + unsigned int hex_away_omit_alerts; + unsigned int hex_away_show_message; + unsigned int hex_away_show_once; + unsigned int hex_away_track; + unsigned int hex_completion_auto; + unsigned int hex_dcc_auto_chat; + unsigned int hex_dcc_auto_resume; + unsigned int hex_dcc_fast_send; + unsigned int hex_dcc_ip_from_server; + unsigned int hex_dcc_remove; + unsigned int hex_dcc_save_nick; + unsigned int hex_dcc_send_fillspaces; + unsigned int hex_gui_autoopen_chat; + unsigned int hex_gui_autoopen_dialog; + unsigned int hex_gui_autoopen_recv; + unsigned int hex_gui_autoopen_send; + unsigned int hex_gui_compact; + unsigned int hex_gui_hide_menu; + unsigned int hex_gui_input_nick; + unsigned int hex_gui_input_spell; + unsigned int hex_gui_input_style; + unsigned int hex_gui_join_dialog; + unsigned int hex_gui_mode_buttons; + unsigned int hex_gui_quit_dialog; + unsigned int hex_gui_single; + unsigned int hex_gui_slist_fav; + unsigned int hex_gui_slist_skip; + unsigned int hex_gui_tab_chans; + unsigned int hex_gui_tab_dialogs; + unsigned int hex_gui_tab_dots; + unsigned int hex_gui_tab_icons; + unsigned int hex_gui_tab_notices; + unsigned int hex_gui_tab_server; + unsigned int hex_gui_tab_sort; + unsigned int hex_gui_tab_utils; + unsigned int hex_gui_topicbar; + unsigned int hex_gui_tray; + unsigned int hex_gui_ulist_buttons; + unsigned int hex_gui_ulist_count; + unsigned int hex_gui_ulist_hide; + unsigned int hex_gui_ulist_icons; + unsigned int hex_gui_ulist_resizable; + unsigned int hex_gui_ulist_show_hosts; + unsigned int hex_gui_ulist_style; + unsigned int hex_gui_usermenu; + unsigned int hex_gui_win_modes; + unsigned int hex_gui_win_save; + unsigned int hex_gui_win_swap; + unsigned int hex_gui_win_ucount; + unsigned int hex_identd; + unsigned int hex_input_balloon_chans; + unsigned int hex_input_balloon_hilight; + unsigned int hex_input_balloon_priv; + unsigned int hex_input_beep_chans; + unsigned int hex_input_beep_hilight; + unsigned int hex_input_beep_priv; + unsigned int hex_input_filter_beep; + unsigned int hex_input_flash_chans; + unsigned int hex_input_flash_hilight; + unsigned int hex_input_flash_priv; + unsigned int hex_input_perc_ascii; + unsigned int hex_input_perc_color; + unsigned int hex_input_tray_chans; + unsigned int hex_input_tray_hilight; + unsigned int hex_input_tray_priv; + unsigned int hex_irc_auto_rejoin; + unsigned int hex_irc_conf_mode; + unsigned int hex_irc_hide_version; + unsigned int hex_irc_invisible; + unsigned int hex_irc_logging; + unsigned int hex_irc_raw_modes; + unsigned int hex_irc_servernotice; + unsigned int hex_irc_skip_motd; + unsigned int hex_irc_wallops; + unsigned int hex_irc_who_join; + unsigned int hex_irc_whois_front; + unsigned int hex_net_auto_reconnect; + unsigned int hex_net_auto_reconnectonfail; + unsigned int hex_net_proxy_auth; + unsigned int hex_net_throttle; + unsigned int hex_notify_whois_online; + unsigned int hex_perl_warnings; + unsigned int hex_stamp_log; + unsigned int hex_stamp_text; + unsigned int hex_text_autocopy_color; + unsigned int hex_text_autocopy_stamp; + unsigned int hex_text_autocopy_text; + unsigned int hex_text_color_nicks; + unsigned int hex_text_indent; + unsigned int hex_text_replay; + unsigned int hex_text_search_case_match; + unsigned int hex_text_search_backward; + unsigned int hex_text_search_highlight_all; + unsigned int hex_text_search_follow; + unsigned int hex_text_search_regexp; + unsigned int hex_text_show_marker; + unsigned int hex_text_show_sep; + unsigned int hex_text_stripcolor_msg; + unsigned int hex_text_stripcolor_replay; + unsigned int hex_text_stripcolor_topic; + unsigned int hex_text_thin_sep; + unsigned int hex_text_transparent; + unsigned int hex_text_wordwrap; + unsigned int hex_url_grabber; + unsigned int hex_url_logging; + + /* NUMBERS */ + int hex_away_size_max; + int hex_away_timeout; + int hex_completion_amount; + int hex_completion_sort; + int hex_dcc_auto_recv; + int hex_dcc_blocksize; + int hex_dcc_global_max_get_cps; + int hex_dcc_global_max_send_cps; + int hex_dcc_max_get_cps; + int hex_dcc_max_send_cps; + int hex_dcc_permissions; + int hex_dcc_port_first; + int hex_dcc_port_last; + int hex_dcc_stall_timeout; + int hex_dcc_timeout; + int hex_flood_ctcp_num; /* flood */ + int hex_flood_ctcp_time; /* seconds of floods */ + int hex_flood_msg_num; /* same deal */ + int hex_flood_msg_time; + int hex_gui_chanlist_maxusers; + int hex_gui_chanlist_minusers; + int hex_gui_dialog_height; + int hex_gui_dialog_left; + int hex_gui_dialog_top; + int hex_gui_dialog_width; + int hex_gui_lagometer; + int hex_gui_lang; + int hex_gui_pane_left_size; + int hex_gui_pane_right_size; + int hex_gui_pane_right_size_min; + int hex_gui_slist_select; + int hex_gui_tab_layout; + int hex_gui_tab_newtofront; + int hex_gui_tab_pos; + int hex_gui_tab_small; + int hex_gui_tab_trunc; + int hex_gui_throttlemeter; + int hex_gui_tray_flags; + int hex_gui_ulist_pos; + int hex_gui_ulist_sort; + int hex_gui_url_mod; + int hex_gui_win_height; + int hex_gui_win_left; + int hex_gui_win_state; + int hex_gui_win_top; + int hex_gui_win_width; + int hex_input_balloon_time; + int hex_irc_ban_type; + int hex_irc_join_delay; + int hex_net_ping_timeout; + int hex_net_proxy_port; + int hex_net_proxy_type; /* 0=disabled, 1=wingate 2=socks4, 3=socks5, 4=http */ + int hex_net_proxy_use; /* 0=all 1=IRC_ONLY 2=DCC_ONLY */ + int hex_net_reconnect_delay; + int hex_notify_timeout; + int hex_text_max_indent; + int hex_text_max_lines; + int hex_text_tint_blue; + int hex_text_tint_green; + int hex_text_tint_red; + int hex_url_grabber_limit; + + /* STRINGS */ + char hex_away_reason[256]; + char hex_completion_suffix[4]; /* Only ever holds a one-character string. */ + char hex_dcc_completed_dir[PATHLEN + 1]; + char hex_dcc_dir[PATHLEN + 1]; + char hex_dcc_ip[DOMAINLEN + 1]; + char hex_dnsprogram[72]; + char hex_gui_ulist_doubleclick[256]; + char hex_input_command_char[4]; + char hex_irc_extra_hilight[300]; + char hex_irc_id_ntext[64]; + char hex_irc_id_ytext[64]; + char hex_irc_logmask[256]; + char hex_irc_nick1[NICKLEN]; + char hex_irc_nick2[NICKLEN]; + char hex_irc_nick3[NICKLEN]; + char hex_irc_nick_hilight[300]; + char hex_irc_no_hilight[300]; + char hex_irc_part_reason[256]; + char hex_irc_quit_reason[256]; + char hex_irc_real_name[127]; + char hex_irc_user_name[127]; + char hex_net_bind_host[127]; + char hex_net_proxy_host[64]; + char hex_net_proxy_pass[32]; + char hex_net_proxy_user[32]; + char hex_sound_command[PATHLEN + 1]; + char hex_sound_dir[PATHLEN + 1]; + char hex_stamp_log_format[64]; + char hex_stamp_text_format[64]; + char hex_text_background[PATHLEN + 1]; + char hex_text_font[4 * FONTNAMELEN + 1]; + char hex_text_font_main[FONTNAMELEN + 1]; + char hex_text_font_alternative[3 * FONTNAMELEN + 1]; + char hex_text_spell_langs[64]; + + /* these are the private variables */ + guint32 local_ip; + guint32 dcc_ip; + + unsigned int wait_on_exit; /* wait for logs to be flushed to disk IF we're connected */ + unsigned int utf8_locale; + + /* Tells us if we need to save, only when they've been edited. + This is so that we continue using internal defaults (which can + change in the next release) until the user edits them. */ + unsigned int save_pevents:1; +}; + +/* Session types */ +#define SESS_SERVER 1 +#define SESS_CHANNEL 2 +#define SESS_DIALOG 3 +#define SESS_NOTICES 4 +#define SESS_SNOTICES 5 + +/* Per-Channel Settings */ +#define SET_OFF 0 +#define SET_ON 1 +#define SET_DEFAULT 2 /* use global setting */ + +/* Moved from fe-gtk for use in outbound.c as well -- */ +typedef enum gtk_xtext_search_flags_e { + case_match = 1, + backward = 2, + highlight = 4, + follow = 8, + regexp = 16 +} gtk_xtext_search_flags; + +typedef struct session +{ + /* Per-Channel Alerts */ + /* use a byte, because we need a pointer to each element */ + guint8 alert_beep; + guint8 alert_taskbar; + guint8 alert_tray; + + /* Per-Channel Settings */ + guint8 text_hidejoinpart; + guint8 text_logging; + guint8 text_scrollback; + + struct server *server; + void *usertree_alpha; /* pure alphabetical tree */ + void *usertree; /* ordered with Ops first */ + struct User *me; /* points to myself in the usertree */ + char channel[CHANLEN]; + char waitchannel[CHANLEN]; /* waiting to join channel (/join sent) */ + char willjoinchannel[CHANLEN]; /* will issue /join for this channel */ + char channelkey[64]; /* XXX correct max length? */ + int limit; /* channel user limit */ + int logfd; + int scrollfd; /* scrollback filedes */ + int scrollwritten; /* number of lines written */ + + char lastnick[NICKLEN]; /* last nick you /msg'ed */ + + struct history history; + + int ops; /* num. of ops in channel */ + int hops; /* num. of half-oped users */ + int voices; /* num. of voiced people */ + int total; /* num. of users in channel */ + + char *quitreason; + char *topic; + char *current_modes; /* free() me */ + + int mode_timeout_tag; + + struct session *lastlog_sess; + struct nbexec *running_exec; + + struct session_gui *gui; /* initialized by fe_new_window */ + struct restore_gui *res; + + int type; /* SESS_* */ + + int new_data:1; /* new data avail? (purple tab) */ + int nick_said:1; /* your nick mentioned? (blue tab) */ + int msg_said:1; /* new msg available? (red tab) */ + + int ignore_date:1; + int ignore_mode:1; + int ignore_names:1; + int end_of_names:1; + int doing_who:1; /* /who sent on this channel */ + int done_away_check:1; /* done checking for away status changes */ + gtk_xtext_search_flags lastlog_flags; +} session; + +struct msproxy_state_t +{ + gint32 clientid; + gint32 serverid; + unsigned char seq_recv; /* seq number of last packet recv. */ + unsigned char seq_sent; /* seq number of last packet sent. */ +}; + +typedef struct server +{ + /* server control operations (in server*.c) */ + void (*connect)(struct server *, char *hostname, int port, int no_login); + void (*disconnect)(struct session *, int sendquit, int err); + int (*cleanup)(struct server *); + void (*flush_queue)(struct server *); + void (*auto_reconnect)(struct server *, int send_quit, int err); + /* irc protocol functions (in proto*.c) */ + void (*p_inline)(struct server *, char *buf, int len); + void (*p_invite)(struct server *, char *channel, char *nick); + void (*p_cycle)(struct server *, char *channel, char *key); + void (*p_ctcp)(struct server *, char *to, char *msg); + void (*p_nctcp)(struct server *, char *to, char *msg); + void (*p_quit)(struct server *, char *reason); + void (*p_kick)(struct server *, char *channel, char *nick, char *reason); + void (*p_part)(struct server *, char *channel, char *reason); + void (*p_ns_identify)(struct server *, char *pass); + void (*p_ns_ghost)(struct server *, char *usname, char *pass); + void (*p_join)(struct server *, char *channel, char *key); + void (*p_join_list)(struct server *, GSList *channels, GSList *keys); + void (*p_login)(struct server *, char *user, char *realname); + void (*p_join_info)(struct server *, char *channel); + void (*p_mode)(struct server *, char *target, char *mode); + void (*p_user_list)(struct server *, char *channel); + void (*p_away_status)(struct server *, char *channel); + void (*p_whois)(struct server *, char *nicks); + void (*p_get_ip)(struct server *, char *nick); + void (*p_get_ip_uh)(struct server *, char *nick); + void (*p_set_back)(struct server *); + void (*p_set_away)(struct server *, char *reason); + void (*p_message)(struct server *, char *channel, char *text); + void (*p_action)(struct server *, char *channel, char *act); + void (*p_notice)(struct server *, char *channel, char *text); + void (*p_topic)(struct server *, char *channel, char *topic); + void (*p_list_channels)(struct server *, char *arg, int min_users); + void (*p_change_nick)(struct server *, char *new_nick); + void (*p_names)(struct server *, char *channel); + void (*p_ping)(struct server *, char *to, char *timestring); +/* void (*p_set_away)(struct server *);*/ + int (*p_raw)(struct server *, char *raw); + int (*p_cmp)(const char *s1, const char *s2); + + int port; + int sok; /* is equal to sok4 or sok6 (the one we are using) */ + int sok4; /* tcp4 socket */ + int sok6; /* tcp6 socket */ + int proxy_type; + int proxy_sok; /* Additional information for MS Proxy beast */ + int proxy_sok4; + int proxy_sok6; + struct msproxy_state_t msp_state; + int id; /* unique ID number (for plugin API) */ +#ifdef USE_OPENSSL + SSL *ssl; + int ssl_do_connect_tag; +#else + void *ssl; +#endif + int childread; + int childwrite; + int childpid; + int iotag; + int recondelay_tag; /* reconnect delay timeout */ + int joindelay_tag; /* waiting before we send JOIN */ + char hostname[128]; /* real ip number */ + char servername[128]; /* what the server says is its name */ + char password[86]; + char nick[NICKLEN]; + char linebuf[2048]; /* RFC says 512 chars including \r\n */ + char *last_away_reason; + int pos; /* current position in linebuf */ + int nickcount; + int nickservtype; /* 0=/MSG nickserv 1=/NICKSERV 2=/NS */ + + char *chantypes; /* for 005 numeric - free me */ + char *chanmodes; /* for 005 numeric - free me */ + char *nick_prefixes; /* e.g. "*@%+" */ + char *nick_modes; /* e.g. "aohv" */ + char *bad_nick_prefixes; /* for ircd that doesn't give the modes */ + int modes_per_line; /* 6 on undernet, 4 on efnet etc... */ + + void *network; /* points to entry in servlist.c or NULL! */ + + GSList *outbound_queue; + time_t next_send; /* cptr->since in ircu */ + time_t prev_now; /* previous now-time */ + int sendq_len; /* queue size */ + int lag; /* milliseconds */ + + struct session *front_session; /* front-most window/tab */ + struct session *server_session; /* server window/tab */ + + struct server_gui *gui; /* initialized by fe_new_server */ + + unsigned int ctcp_counter; /*flood */ + time_t ctcp_last_time; + + unsigned int msg_counter; /*counts the msg tab opened in a certain time */ + time_t msg_last_time; + + /*time_t connect_time;*/ /* when did it connect? */ + time_t lag_sent; + time_t ping_recv; /* when we last got a ping reply */ + time_t away_time; /* when we were marked away */ + + char *encoding; /* NULL for system */ + char *autojoin; /* list of channels & keys to join */ + + unsigned int motd_skipped:1; + unsigned int connected:1; + unsigned int connecting:1; + unsigned int no_login:1; + unsigned int skip_next_userhost:1;/* used for "get my ip from server" */ + unsigned int skip_next_whois:1; /* hide whois output */ + unsigned int inside_whois:1; + unsigned int doing_dns:1; /* /dns has been done */ + unsigned int end_of_motd:1; /* end of motd reached (logged in) */ + unsigned int sent_quit:1; /* sent a QUIT already? */ + unsigned int use_listargs:1; /* undernet and dalnet need /list >0,<10000 */ + unsigned int is_away:1; + unsigned int reconnect_away:1; /* whether to reconnect in is_away state */ + unsigned int dont_use_proxy:1; /* to proxy or not to proxy */ + unsigned int supports_watch:1; /* supports the WATCH command */ + unsigned int bad_prefix:1; /* gave us a bad PREFIX= 005 number */ + unsigned int have_namesx:1; /* 005 tokens NAMESX and UHNAMES */ + unsigned int have_uhnames:1; + unsigned int have_whox:1; /* have undernet's WHOX features */ + unsigned int have_capab:1; /* supports CAPAB (005 tells us) */ + unsigned int have_idmsg:1; /* freenode's IDENTIFY-MSG */ + unsigned int have_except:1; /* ban exemptions +e */ + unsigned int using_cp1255:1; /* encoding is CP1255/WINDOWS-1255? */ + unsigned int using_irc:1; /* encoding is "IRC" (CP1252/UTF-8 hybrid)? */ + unsigned int use_who:1; /* whether to use WHO command to get dcc_ip */ +#ifdef USE_OPENSSL + unsigned int use_ssl:1; /* is server SSL capable? */ + unsigned int accept_invalid_cert:1;/* ignore result of server's cert. verify */ +#endif +} server; + +typedef int (*cmd_callback) (struct session * sess, char *tbuf, char *word[], + char *word_eol[]); + +struct commands +{ + char *name; + cmd_callback callback; + char needserver; + char needchannel; + gint16 handle_quotes; + char *help; +}; + +struct away_msg +{ + struct server *server; + char nick[NICKLEN]; + char *message; +}; + +/* not just for popups, but used for usercommands, ctcp replies, + userlist buttons etc */ + +struct popup +{ + char *cmd; + char *name; +}; + +/* CL: get a random int in the range [0..n-1]. DON'T use rand() % n, it gives terrible results. */ +#define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n))) + +#define xchat_filename_from_utf8 g_filename_from_utf8 +#define xchat_filename_to_utf8 g_filename_to_utf8 + +#endif diff --git a/src/common/hexchatc.h b/src/common/hexchatc.h new file mode 100644 index 00000000..1d955055 --- /dev/null +++ b/src/common/hexchatc.h @@ -0,0 +1,39 @@ +#ifndef XCHAT_C_H +#define XCHAT_C_H + +extern struct hexchatprefs prefs; + +extern int xchat_is_quitting; +extern gint arg_skip_plugins; /* command-line args */ +extern gint arg_dont_autoconnect; +extern char *arg_url; +extern char *arg_command; +extern gint arg_existing; + +extern session *current_sess; +extern session *current_tab; + +extern GSList *popup_list; +extern GSList *button_list; +extern GSList *dlgbutton_list; +extern GSList *command_list; +extern GSList *ctcp_list; +extern GSList *replace_list; +extern GSList *sess_list; +extern GSList *dcc_list; +extern GSList *ignore_list; +extern GSList *usermenu_list; +extern GSList *urlhandler_list; +extern GSList *tabmenu_list; + +session * find_channel (server *serv, char *chan); +session * find_dialog (server *serv, char *nick); +session * new_ircwindow (server *serv, char *name, int type, int focus); +int is_session (session * sess); +void session_free (session *killsess); +void lag_check (void); +void xchat_exit (void); +void xchat_exec (const char *cmd); +void xchat_execv (char * const argv[]); + +#endif diff --git a/src/common/identd.c b/src/common/identd.c index 5ef5e0c6..db08ff90 100644 --- a/src/common/identd.c +++ b/src/common/identd.c @@ -1,8 +1,8 @@ /* simple identd server for xchat under win32 */ #include "inet.h" -#include "xchat.h" -#include "xchatc.h" +#include "hexchat.h" +#include "hexchatc.h" #include "text.h" static int identd_is_running = FALSE; diff --git a/src/common/ignore.c b/src/common/ignore.c index 12a2926a..b6eae41a 100644 --- a/src/common/ignore.c +++ b/src/common/ignore.c @@ -29,13 +29,13 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "ignore.h" #include "cfgfiles.h" #include "fe.h" #include "text.h" #include "util.h" -#include "xchatc.h" +#include "hexchatc.h" int ignored_ctcp = 0; /* keep a count of all we ignore */ diff --git a/src/common/inbound.c b/src/common/inbound.c index 9d39e5cd..3d42279f 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -33,7 +33,7 @@ #define WANTDNS #include "inet.h" -#include "xchat.h" +#include "hexchat.h" #include "util.h" #include "ignore.h" #include "fe.h" @@ -46,7 +46,7 @@ #include "text.h" #include "ctcp.h" #include "plugin.h" -#include "xchatc.h" +#include "hexchatc.h" void diff --git a/src/common/modes.c b/src/common/modes.c index 07a5cea4..b84b2b84 100644 --- a/src/common/modes.c +++ b/src/common/modes.c @@ -22,8 +22,8 @@ #include #include -#include "xchat.h" -#include "xchatc.h" +#include "hexchat.h" +#include "hexchatc.h" #include "modes.h" #include "server.h" #include "text.h" diff --git a/src/common/msproxy.c b/src/common/msproxy.c index 01b6120a..9febe8d0 100644 --- a/src/common/msproxy.c +++ b/src/common/msproxy.c @@ -36,9 +36,9 @@ #define WANTARPA #include "inet.h" -#include "xchat.h" +#include "hexchat.h" #include "network.h" -#include "xchatc.h" +#include "hexchatc.h" #include "server.h" #include "msproxy.h" diff --git a/src/common/notify.c b/src/common/notify.c index f9fbe121..1dff8ec7 100644 --- a/src/common/notify.c +++ b/src/common/notify.c @@ -30,14 +30,14 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "notify.h" #include "cfgfiles.h" #include "fe.h" #include "server.h" #include "text.h" #include "util.h" -#include "xchatc.h" +#include "hexchatc.h" GSList *notify_list = 0; diff --git a/src/common/outbound.c b/src/common/outbound.c index bb652aad..ed97886e 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -38,7 +38,7 @@ #include #include -#include "xchat.h" +#include "hexchat.h" #include "plugin.h" #include "ignore.h" #include "util.h" @@ -49,7 +49,7 @@ #include "notify.h" #include "inbound.h" #include "text.h" -#include "xchatc.h" +#include "hexchatc.h" #include "servlist.h" #include "server.h" #include "tree.h" diff --git a/src/common/plugin-timer.c b/src/common/plugin-timer.c index 431ce8ab..eaf6cde6 100644 --- a/src/common/plugin-timer.c +++ b/src/common/plugin-timer.c @@ -1,7 +1,7 @@ #include #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #ifdef WIN32 #define g_ascii_strcasecmp stricmp diff --git a/src/common/plugin.c b/src/common/plugin.c index 7111289c..cc626659 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -29,7 +29,7 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "fe.h" #include "util.h" #include "outbound.h" @@ -42,11 +42,11 @@ #include "text.h" #define PLUGIN_C typedef struct session xchat_context; -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #include "plugin.h" -#include "xchatc.h" +#include "hexchatc.h" /* the USE_PLUGIN define only removes libdl stuff */ diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index ed7d9a4d..8967504e 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -28,7 +28,7 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "ctcp.h" #include "fe.h" #include "ignore.h" @@ -40,7 +40,7 @@ #include "text.h" #include "outbound.h" #include "util.h" -#include "xchatc.h" +#include "hexchatc.h" #include "url.h" diff --git a/src/common/server.c b/src/common/server.c index 8c831ad0..04b955bb 100644 --- a/src/common/server.c +++ b/src/common/server.c @@ -42,12 +42,12 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "fe.h" #include "cfgfiles.h" #include "network.h" #include "notify.h" -#include "xchatc.h" +#include "hexchatc.h" #include "inbound.h" #include "outbound.h" #include "text.h" diff --git a/src/common/servlist.c b/src/common/servlist.c index 201652da..86a78ebf 100644 --- a/src/common/servlist.c +++ b/src/common/servlist.c @@ -26,7 +26,7 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include #include "cfgfiles.h" @@ -34,7 +34,7 @@ #include "server.h" #include "text.h" #include "util.h" /* token_foreach */ -#include "xchatc.h" +#include "hexchatc.h" #include "servlist.h" diff --git a/src/common/text.c b/src/common/text.c index 1076f8a0..39dd92c2 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -32,7 +32,7 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include #include "cfgfiles.h" #include "chanopt.h" @@ -41,7 +41,7 @@ #include "server.h" #include "util.h" #include "outbound.h" -#include "xchatc.h" +#include "hexchatc.h" #include "text.h" #ifdef WIN32 #include diff --git a/src/common/url.c b/src/common/url.c index 32d282db..f722ca34 100644 --- a/src/common/url.c +++ b/src/common/url.c @@ -20,8 +20,8 @@ #include #include #include -#include "xchat.h" -#include "xchatc.h" +#include "hexchat.h" +#include "hexchatc.h" #include "cfgfiles.h" #include "fe.h" #include "tree.h" diff --git a/src/common/userlist.c b/src/common/userlist.c index 2dedb997..620ed4aa 100644 --- a/src/common/userlist.c +++ b/src/common/userlist.c @@ -20,12 +20,12 @@ #include #include -#include "xchat.h" +#include "hexchat.h" #include "modes.h" #include "fe.h" #include "notify.h" #include "tree.h" -#include "xchatc.h" +#include "hexchatc.h" #include "util.h" diff --git a/src/common/util.c b/src/common/util.c index 15184250..38a87f26 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -43,8 +43,8 @@ #include #include -#include "xchat.h" -#include "xchatc.h" +#include "hexchat.h" +#include "hexchatc.h" #include #include #include "util.h" diff --git a/src/common/xchat-plugin.h b/src/common/xchat-plugin.h deleted file mode 100644 index 1b7da8fb..00000000 --- a/src/common/xchat-plugin.h +++ /dev/null @@ -1,381 +0,0 @@ -/* You can distribute this header with your plugins for easy compilation */ -#ifndef XCHAT_PLUGIN_H -#define XCHAT_PLUGIN_H - -#include - -#define XCHAT_IFACE_MAJOR 1 -#define XCHAT_IFACE_MINOR 9 -#define XCHAT_IFACE_MICRO 11 -#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \ - (XCHAT_IFACE_MINOR * 100) + \ - (XCHAT_IFACE_MICRO)) - -#define XCHAT_PRI_HIGHEST 127 -#define XCHAT_PRI_HIGH 64 -#define XCHAT_PRI_NORM 0 -#define XCHAT_PRI_LOW (-64) -#define XCHAT_PRI_LOWEST (-128) - -#define XCHAT_FD_READ 1 -#define XCHAT_FD_WRITE 2 -#define XCHAT_FD_EXCEPTION 4 -#define XCHAT_FD_NOTSOCKET 8 - -#define XCHAT_EAT_NONE 0 /* pass it on through! */ -#define XCHAT_EAT_XCHAT 1 /* don't let xchat see this event */ -#define XCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */ -#define XCHAT_EAT_ALL (XCHAT_EAT_XCHAT|XCHAT_EAT_PLUGIN) /* don't let anything see this event */ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _xchat_plugin xchat_plugin; -typedef struct _xchat_list xchat_list; -typedef struct _xchat_hook xchat_hook; -#ifndef PLUGIN_C -typedef struct _xchat_context xchat_context; -#endif - -#ifndef PLUGIN_C -struct _xchat_plugin -{ - /* these are only used on win32 */ - xchat_hook *(*xchat_hook_command) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - const char *help_text, - void *userdata); - xchat_hook *(*xchat_hook_server) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_print) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_timer) (xchat_plugin *ph, - int timeout, - int (*callback) (void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_fd) (xchat_plugin *ph, - int fd, - int flags, - int (*callback) (int fd, int flags, void *user_data), - void *userdata); - void *(*xchat_unhook) (xchat_plugin *ph, - xchat_hook *hook); - void (*xchat_print) (xchat_plugin *ph, - const char *text); - void (*xchat_printf) (xchat_plugin *ph, - const char *format, ...); - void (*xchat_command) (xchat_plugin *ph, - const char *command); - void (*xchat_commandf) (xchat_plugin *ph, - const char *format, ...); - int (*xchat_nickcmp) (xchat_plugin *ph, - const char *s1, - const char *s2); - int (*xchat_set_context) (xchat_plugin *ph, - xchat_context *ctx); - xchat_context *(*xchat_find_context) (xchat_plugin *ph, - const char *servname, - const char *channel); - xchat_context *(*xchat_get_context) (xchat_plugin *ph); - const char *(*xchat_get_info) (xchat_plugin *ph, - const char *id); - int (*xchat_get_prefs) (xchat_plugin *ph, - const char *name, - const char **string, - int *integer); - xchat_list * (*xchat_list_get) (xchat_plugin *ph, - const char *name); - void (*xchat_list_free) (xchat_plugin *ph, - xchat_list *xlist); - const char * const * (*xchat_list_fields) (xchat_plugin *ph, - const char *name); - int (*xchat_list_next) (xchat_plugin *ph, - xchat_list *xlist); - const char * (*xchat_list_str) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - int (*xchat_list_int) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - void * (*xchat_plugingui_add) (xchat_plugin *ph, - const char *filename, - const char *name, - const char *desc, - const char *version, - char *reserved); - void (*xchat_plugingui_remove) (xchat_plugin *ph, - void *handle); - int (*xchat_emit_print) (xchat_plugin *ph, - const char *event_name, ...); - int (*xchat_read_fd) (xchat_plugin *ph, - void *src, - char *buf, - int *len); - time_t (*xchat_list_time) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - char *(*xchat_gettext) (xchat_plugin *ph, - const char *msgid); - void (*xchat_send_modes) (xchat_plugin *ph, - const char **targets, - int ntargets, - int modes_per_line, - char sign, - char mode); - char *(*xchat_strip) (xchat_plugin *ph, - const char *str, - int len, - int flags); - void (*xchat_free) (xchat_plugin *ph, - void *ptr); - int (*xchat_pluginpref_set_str) (xchat_plugin *ph, - const char *var, - const char *value); - int (*xchat_pluginpref_get_str) (xchat_plugin *ph, - const char *var, - char *dest); - int (*xchat_pluginpref_set_int) (xchat_plugin *ph, - const char *var, - int value); - int (*xchat_pluginpref_get_int) (xchat_plugin *ph, - const char *var); - int (*xchat_pluginpref_delete) (xchat_plugin *ph, - const char *var); - int (*xchat_pluginpref_list) (xchat_plugin *ph, - char *dest); -}; -#endif - - -xchat_hook * -xchat_hook_command (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - const char *help_text, - void *userdata); - -xchat_hook * -xchat_hook_server (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - void *userdata); - -xchat_hook * -xchat_hook_print (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], void *user_data), - void *userdata); - -xchat_hook * -xchat_hook_timer (xchat_plugin *ph, - int timeout, - int (*callback) (void *user_data), - void *userdata); - -xchat_hook * -xchat_hook_fd (xchat_plugin *ph, - int fd, - int flags, - int (*callback) (int fd, int flags, void *user_data), - void *userdata); - -void * -xchat_unhook (xchat_plugin *ph, - xchat_hook *hook); - -void -xchat_print (xchat_plugin *ph, - const char *text); - -void -xchat_printf (xchat_plugin *ph, - const char *format, ...); - -void -xchat_command (xchat_plugin *ph, - const char *command); - -void -xchat_commandf (xchat_plugin *ph, - const char *format, ...); - -int -xchat_nickcmp (xchat_plugin *ph, - const char *s1, - const char *s2); - -int -xchat_set_context (xchat_plugin *ph, - xchat_context *ctx); - -xchat_context * -xchat_find_context (xchat_plugin *ph, - const char *servname, - const char *channel); - -xchat_context * -xchat_get_context (xchat_plugin *ph); - -const char * -xchat_get_info (xchat_plugin *ph, - const char *id); - -int -xchat_get_prefs (xchat_plugin *ph, - const char *name, - const char **string, - int *integer); - -xchat_list * -xchat_list_get (xchat_plugin *ph, - const char *name); - -void -xchat_list_free (xchat_plugin *ph, - xchat_list *xlist); - -const char * const * -xchat_list_fields (xchat_plugin *ph, - const char *name); - -int -xchat_list_next (xchat_plugin *ph, - xchat_list *xlist); - -const char * -xchat_list_str (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - -int -xchat_list_int (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - -time_t -xchat_list_time (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - -void * -xchat_plugingui_add (xchat_plugin *ph, - const char *filename, - const char *name, - const char *desc, - const char *version, - char *reserved); - -void -xchat_plugingui_remove (xchat_plugin *ph, - void *handle); - -int -xchat_emit_print (xchat_plugin *ph, - const char *event_name, ...); - -char * -xchat_gettext (xchat_plugin *ph, - const char *msgid); - -void -xchat_send_modes (xchat_plugin *ph, - const char **targets, - int ntargets, - int modes_per_line, - char sign, - char mode); - -char * -xchat_strip (xchat_plugin *ph, - const char *str, - int len, - int flags); - -void -xchat_free (xchat_plugin *ph, - void *ptr); - -int -xchat_pluginpref_set_str (xchat_plugin *ph, - const char *var, - const char *value); - -int -xchat_pluginpref_get_str (xchat_plugin *ph, - const char *var, - char *dest); - -int -xchat_pluginpref_set_int (xchat_plugin *ph, - const char *var, - int value); -int -xchat_pluginpref_get_int (xchat_plugin *ph, - const char *var); - -int -xchat_pluginpref_delete (xchat_plugin *ph, - const char *var); - -int -xchat_pluginpref_list (xchat_plugin *ph, - char *dest); - -#if !defined(PLUGIN_C) && defined(WIN32) -#ifndef XCHAT_PLUGIN_HANDLE -#define XCHAT_PLUGIN_HANDLE (ph) -#endif -#define xchat_hook_command ((XCHAT_PLUGIN_HANDLE)->xchat_hook_command) -#define xchat_hook_server ((XCHAT_PLUGIN_HANDLE)->xchat_hook_server) -#define xchat_hook_print ((XCHAT_PLUGIN_HANDLE)->xchat_hook_print) -#define xchat_hook_timer ((XCHAT_PLUGIN_HANDLE)->xchat_hook_timer) -#define xchat_hook_fd ((XCHAT_PLUGIN_HANDLE)->xchat_hook_fd) -#define xchat_unhook ((XCHAT_PLUGIN_HANDLE)->xchat_unhook) -#define xchat_print ((XCHAT_PLUGIN_HANDLE)->xchat_print) -#define xchat_printf ((XCHAT_PLUGIN_HANDLE)->xchat_printf) -#define xchat_command ((XCHAT_PLUGIN_HANDLE)->xchat_command) -#define xchat_commandf ((XCHAT_PLUGIN_HANDLE)->xchat_commandf) -#define xchat_nickcmp ((XCHAT_PLUGIN_HANDLE)->xchat_nickcmp) -#define xchat_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_set_context) -#define xchat_find_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_context) -#define xchat_get_context ((XCHAT_PLUGIN_HANDLE)->xchat_get_context) -#define xchat_get_info ((XCHAT_PLUGIN_HANDLE)->xchat_get_info) -#define xchat_get_prefs ((XCHAT_PLUGIN_HANDLE)->xchat_get_prefs) -#define xchat_list_get ((XCHAT_PLUGIN_HANDLE)->xchat_list_get) -#define xchat_list_free ((XCHAT_PLUGIN_HANDLE)->xchat_list_free) -#define xchat_list_fields ((XCHAT_PLUGIN_HANDLE)->xchat_list_fields) -#define xchat_list_str ((XCHAT_PLUGIN_HANDLE)->xchat_list_str) -#define xchat_list_int ((XCHAT_PLUGIN_HANDLE)->xchat_list_int) -#define xchat_list_time ((XCHAT_PLUGIN_HANDLE)->xchat_list_time) -#define xchat_list_next ((XCHAT_PLUGIN_HANDLE)->xchat_list_next) -#define xchat_plugingui_add ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_add) -#define xchat_plugingui_remove ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_remove) -#define xchat_emit_print ((XCHAT_PLUGIN_HANDLE)->xchat_emit_print) -#define xchat_gettext ((XCHAT_PLUGIN_HANDLE)->xchat_gettext) -#define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) -#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) -#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) -#define xchat_pluginpref_set_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_str) -#define xchat_pluginpref_get_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_str) -#define xchat_pluginpref_set_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_int) -#define xchat_pluginpref_get_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_int) -#define xchat_pluginpref_delete ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_delete) -#define xchat_pluginpref_list ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_list) -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/common/xchat.c b/src/common/xchat.c deleted file mode 100644 index d1916384..00000000 --- a/src/common/xchat.c +++ /dev/null @@ -1,1207 +0,0 @@ -/* X-Chat - * Copyright (C) 1998 Peter Zelezny. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -#include -#include -#include -#include -#include -#include - -#define WANTSOCKET -#include "inet.h" - -#ifdef WIN32 -#include -#else -#include -#include -#include -#endif - -#include "xchat.h" -#include "fe.h" -#include "util.h" -#include "cfgfiles.h" -#include "chanopt.h" -#include "ignore.h" -#include "xchat-plugin.h" -#include "plugin.h" -#include "plugin-timer.h" -#include "notify.h" -#include "server.h" -#include "servlist.h" -#include "outbound.h" -#include "text.h" -#include "url.h" -#include "xchatc.h" - -#ifdef USE_OPENSSL -#include /* SSL_() */ -#include "ssl.h" -#endif - -#ifdef USE_MSPROXY -#include "msproxy.h" -#endif - -#ifdef USE_LIBPROXY -#include -#endif - -GSList *popup_list = 0; -GSList *button_list = 0; -GSList *dlgbutton_list = 0; -GSList *command_list = 0; -GSList *ctcp_list = 0; -GSList *replace_list = 0; -GSList *sess_list = 0; -GSList *dcc_list = 0; -GSList *ignore_list = 0; -GSList *usermenu_list = 0; -GSList *urlhandler_list = 0; -GSList *tabmenu_list = 0; - -static int in_xchat_exit = FALSE; -int xchat_is_quitting = FALSE; -/* command-line args */ -int arg_dont_autoconnect = FALSE; -int arg_skip_plugins = FALSE; -char *arg_url = NULL; -char *arg_command = NULL; -gint arg_existing = FALSE; - -#ifdef USE_DBUS -#include "dbus/dbus-client.h" -#include "dbus/dbus-plugin.h" -#endif /* USE_DBUS */ - -struct session *current_tab; -struct session *current_sess = 0; -struct hexchatprefs prefs; - -#ifdef USE_OPENSSL -SSL_CTX *ctx = NULL; -#endif - -#ifdef USE_LIBPROXY -pxProxyFactory *libproxy_factory; -#endif - -int -is_session (session * sess) -{ - return g_slist_find (sess_list, sess) ? 1 : 0; -} - -session * -find_dialog (server *serv, char *nick) -{ - GSList *list = sess_list; - session *sess; - - while (list) - { - sess = list->data; - if (sess->server == serv && sess->type == SESS_DIALOG) - { - if (!serv->p_cmp (nick, sess->channel)) - return (sess); - } - list = list->next; - } - return 0; -} - -session * -find_channel (server *serv, char *chan) -{ - session *sess; - GSList *list = sess_list; - while (list) - { - sess = list->data; - if ((!serv || serv == sess->server) && sess->type != SESS_DIALOG) - { - if (!serv->p_cmp (chan, sess->channel)) - return sess; - } - list = list->next; - } - return 0; -} - -static void -lagcheck_update (void) -{ - server *serv; - GSList *list = serv_list; - - if (!prefs.hex_gui_lagometer) - return; - - while (list) - { - serv = list->data; - if (serv->lag_sent) - fe_set_lag (serv, -1); - - list = list->next; - } -} - -void -lag_check (void) -{ - server *serv; - GSList *list = serv_list; - unsigned long tim; - char tbuf[128]; - time_t now = time (0); - int lag; - - tim = make_ping_time (); - - while (list) - { - serv = list->data; - if (serv->connected && serv->end_of_motd) - { - lag = now - serv->ping_recv; - if (prefs.hex_net_ping_timeout && lag > prefs.hex_net_ping_timeout && lag > 0) - { - sprintf (tbuf, "%d", lag); - EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL, - NULL, NULL, 0); - if (prefs.hex_net_auto_reconnect) - serv->auto_reconnect (serv, FALSE, -1); - } else - { - snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim); - serv->p_ping (serv, "", tbuf); - serv->lag_sent = tim; - fe_set_lag (serv, -1); - } - } - list = list->next; - } -} - -static int -away_check (void) -{ - session *sess; - GSList *list; - int full, sent, loop = 0; - - if (!prefs.hex_away_track || prefs.hex_away_size_max < 1) - return 1; - -doover: - /* request an update of AWAY status of 1 channel every 30 seconds */ - full = TRUE; - sent = 0; /* number of WHOs (users) requested */ - list = sess_list; - while (list) - { - sess = list->data; - - if (sess->server->connected && - sess->type == SESS_CHANNEL && - sess->channel[0] && - sess->total <= prefs.hex_away_size_max) - { - if (!sess->done_away_check) - { - full = FALSE; - - /* if we're under 31 WHOs, send another channels worth */ - if (sent < 31 && !sess->doing_who) - { - sess->done_away_check = TRUE; - sess->doing_who = TRUE; - /* this'll send a WHO #channel */ - sess->server->p_away_status (sess->server, sess->channel); - sent += sess->total; - } - } - } - - list = list->next; - } - - /* done them all, reset done_away_check to FALSE and start over */ - if (full) - { - list = sess_list; - while (list) - { - sess = list->data; - sess->done_away_check = FALSE; - list = list->next; - } - loop++; - if (loop < 2) - goto doover; - } - - return 1; -} - -static int -xchat_misc_checks (void) /* this gets called every 1/2 second */ -{ - static int count = 0; -#ifdef USE_MSPROXY - static int count2 = 0; -#endif - - count++; - - lagcheck_update (); /* every 500ms */ - - if (count % 2) - dcc_check_timeouts (); /* every 1 second */ - - if (count >= 60) /* every 30 seconds */ - { - if (prefs.hex_gui_lagometer) - lag_check (); - count = 0; - } - -#ifdef USE_MSPROXY - count2++; - if (count2 >= 720) /* 720 every 6 minutes */ - { - msproxy_keepalive (); - count2 = 0; - } -#endif - - return 1; -} - -/* executed when the first irc window opens */ - -static void -irc_init (session *sess) -{ - static int done_init = FALSE; - char buf[512]; - - if (done_init) - return; - - done_init = TRUE; - - plugin_add (sess, NULL, NULL, timer_plugin_init, NULL, NULL, FALSE); - -#ifdef USE_PLUGIN - if (!arg_skip_plugins) - plugin_auto_load (sess); /* autoload ~/.xchat *.so */ -#endif - -#ifdef USE_DBUS - plugin_add (sess, NULL, NULL, dbus_plugin_init, NULL, NULL, FALSE); -#endif - - if (prefs.hex_notify_timeout) - notify_tag = fe_timeout_add (prefs.hex_notify_timeout * 1000, - notify_checklist, 0); - - fe_timeout_add (prefs.hex_away_timeout * 1000, away_check, 0); - fe_timeout_add (500, xchat_misc_checks, 0); - - if (arg_url != NULL) - { - snprintf (buf, sizeof (buf), "server %s", arg_url); - handle_command (sess, buf, FALSE); - g_free (arg_url); /* from GOption */ - } - - if (arg_command != NULL) - { - g_free (arg_command); - } - - /* load -e ~/.xchat2/startup.txt */ - snprintf (buf, sizeof (buf), "%s/%s", get_xdir_fs (), "startup.txt"); - load_perform_file (sess, buf); -} - -static session * -session_new (server *serv, char *from, int type, int focus) -{ - session *sess; - - sess = malloc (sizeof (struct session)); - if (sess == NULL) - { - return NULL; - } - memset (sess, 0, sizeof (struct session)); - - sess->server = serv; - sess->logfd = -1; - sess->scrollfd = -1; - sess->type = type; - - sess->alert_beep = SET_DEFAULT; - sess->alert_taskbar = SET_DEFAULT; - sess->alert_tray = SET_DEFAULT; - - sess->text_hidejoinpart = SET_DEFAULT; - sess->text_logging = SET_DEFAULT; - sess->text_scrollback = SET_DEFAULT; - - if (from != NULL) - safe_strcpy (sess->channel, from, CHANLEN); - - sess_list = g_slist_prepend (sess_list, sess); - - fe_new_window (sess, focus); - - return sess; -} - -session * -new_ircwindow (server *serv, char *name, int type, int focus) -{ - session *sess; - - switch (type) - { - case SESS_SERVER: - serv = server_new (); - if (prefs.hex_gui_tab_server) - sess = session_new (serv, name, SESS_SERVER, focus); - else - sess = session_new (serv, name, SESS_CHANNEL, focus); - serv->server_session = sess; - serv->front_session = sess; - break; - case SESS_DIALOG: - sess = session_new (serv, name, type, focus); - log_open_or_close (sess); - break; - default: -/* case SESS_CHANNEL: - case SESS_NOTICES: - case SESS_SNOTICES:*/ - sess = session_new (serv, name, type, focus); - break; - } - - irc_init (sess); - scrollback_load (sess); - chanopt_load (sess); - plugin_emit_dummy_print (sess, "Open Context"); - - return sess; -} - -static void -exec_notify_kill (session * sess) -{ -#ifndef WIN32 - struct nbexec *re; - if (sess->running_exec != NULL) - { - re = sess->running_exec; - sess->running_exec = NULL; - kill (re->childpid, SIGKILL); - waitpid (re->childpid, NULL, WNOHANG); - fe_input_remove (re->iotag); - close (re->myfd); - if (re->linebuf) - free(re->linebuf); - free (re); - } -#endif -} - -static void -send_quit_or_part (session * killsess) -{ - int willquit = TRUE; - GSList *list; - session *sess; - server *killserv = killsess->server; - - /* check if this is the last session using this server */ - list = sess_list; - while (list) - { - sess = (session *) list->data; - if (sess->server == killserv && sess != killsess) - { - willquit = FALSE; - list = 0; - } else - list = list->next; - } - - if (xchat_is_quitting) - willquit = TRUE; - - if (killserv->connected) - { - if (willquit) - { - if (!killserv->sent_quit) - { - killserv->flush_queue (killserv); - server_sendquit (killsess); - killserv->sent_quit = TRUE; - } - } else - { - if (killsess->type == SESS_CHANNEL && killsess->channel[0] && - !killserv->sent_quit) - { - server_sendpart (killserv, killsess->channel, 0); - } - } - } -} - -void -session_free (session *killsess) -{ - server *killserv = killsess->server; - session *sess; - GSList *list; - - plugin_emit_dummy_print (killsess, "Close Context"); - - if (current_tab == killsess) - current_tab = NULL; - - if (killserv->server_session == killsess) - killserv->server_session = NULL; - - if (killserv->front_session == killsess) - { - /* front_session is closed, find a valid replacement */ - killserv->front_session = NULL; - list = sess_list; - while (list) - { - sess = (session *) list->data; - if (sess != killsess && sess->server == killserv) - { - killserv->front_session = sess; - if (!killserv->server_session) - killserv->server_session = sess; - break; - } - list = list->next; - } - } - - if (!killserv->server_session) - killserv->server_session = killserv->front_session; - - sess_list = g_slist_remove (sess_list, killsess); - - if (killsess->type == SESS_CHANNEL) - userlist_free (killsess); - - exec_notify_kill (killsess); - - log_close (killsess); - scrollback_close (killsess); - chanopt_save (killsess); - - send_quit_or_part (killsess); - - history_free (&killsess->history); - if (killsess->topic) - free (killsess->topic); - if (killsess->current_modes) - free (killsess->current_modes); - - fe_session_callback (killsess); - - if (current_sess == killsess) - { - current_sess = NULL; - if (sess_list) - current_sess = sess_list->data; - } - - free (killsess); - - if (!sess_list && !in_xchat_exit) - xchat_exit (); /* sess_list is empty, quit! */ - - list = sess_list; - while (list) - { - sess = (session *) list->data; - if (sess->server == killserv) - return; /* this server is still being used! */ - list = list->next; - } - - server_free (killserv); -} - -static void -free_sessions (void) -{ - GSList *list = sess_list; - - while (list) - { - fe_close_window (list->data); - list = sess_list; - } -} - - -static char defaultconf_ctcp[] = - "NAME TIME\n" "CMD nctcp %s TIME %t\n\n"\ - "NAME PING\n" "CMD nctcp %s PING %d\n\n"; - -static char defaultconf_replace[] = - "NAME teh\n" "CMD the\n\n"; -/* "NAME r\n" "CMD are\n\n"\ - "NAME u\n" "CMD you\n\n"*/ - -static char defaultconf_commands[] = - "NAME ACTION\n" "CMD me &2\n\n"\ - "NAME AME\n" "CMD allchan me &2\n\n"\ - "NAME ANICK\n" "CMD allserv nick &2\n\n"\ - "NAME AMSG\n" "CMD allchan say &2\n\n"\ - "NAME BANLIST\n" "CMD quote MODE %c +b\n\n"\ - "NAME CHAT\n" "CMD dcc chat %2\n\n"\ - "NAME DIALOG\n" "CMD query %2\n\n"\ - "NAME DMSG\n" "CMD msg =%2 &3\n\n"\ - "NAME EXIT\n" "CMD quit\n\n"\ - "NAME GREP\n" "CMD lastlog -r -- &2\n\n"\ - "NAME IGNALL\n" "CMD ignore %2!*@* ALL\n\n"\ - "NAME J\n" "CMD join &2\n\n"\ - "NAME KILL\n" "CMD quote KILL %2 :&3\n\n"\ - "NAME LEAVE\n" "CMD part &2\n\n"\ - "NAME M\n" "CMD msg &2\n\n"\ - "NAME ONOTICE\n" "CMD notice @%c &2\n\n"\ - "NAME RAW\n" "CMD quote &2\n\n"\ - "NAME SERVHELP\n" "CMD quote HELP\n\n"\ - "NAME SPING\n" "CMD ping\n\n"\ - "NAME SQUERY\n" "CMD quote SQUERY %2 :&3\n\n"\ - "NAME SSLSERVER\n" "CMD server -ssl &2\n\n"\ - "NAME SV\n" "CMD echo xchat %v %m\n\n"\ - "NAME UMODE\n" "CMD mode %n &2\n\n"\ - "NAME UPTIME\n" "CMD quote STATS u\n\n"\ - "NAME VER\n" "CMD ctcp %2 VERSION\n\n"\ - "NAME VERSION\n" "CMD ctcp %2 VERSION\n\n"\ - "NAME WALLOPS\n" "CMD quote WALLOPS :&2\n\n"\ - "NAME WII\n" "CMD quote WHOIS %2 %2\n\n"; - -static char defaultconf_urlhandlers[] = - "NAME Open Link in Opera\n" "CMD !opera -remote 'openURL(%s)'\n\n"; - -#ifdef USE_SIGACTION -/* Close and open log files on SIGUSR1. Usefull for log rotating */ - -static void -sigusr1_handler (int signal, siginfo_t *si, void *un) -{ - GSList *list = sess_list; - session *sess; - - while (list) - { - sess = list->data; - log_open_or_close (sess); - list = list->next; - } -} - -/* Execute /SIGUSR2 when SIGUSR2 received */ - -static void -sigusr2_handler (int signal, siginfo_t *si, void *un) -{ - session *sess = current_sess; - - if (sess) - handle_command (sess, "SIGUSR2", FALSE); -} -#endif - -static gint -xchat_auto_connect (gpointer userdata) -{ - servlist_auto_connect (NULL); - return 0; -} - -static void -xchat_init (void) -{ - char buf[3068]; - const char *cs = NULL; - -#ifdef WIN32 - WSADATA wsadata; - -#ifdef USE_IPV6 - if (WSAStartup(0x0202, &wsadata) != 0) - { - MessageBox (NULL, "Cannot find winsock 2.2+", "Error", MB_OK); - exit (0); - } -#else - WSAStartup(0x0101, &wsadata); -#endif /* !USE_IPV6 */ -#endif /* !WIN32 */ - -#ifdef USE_SIGACTION - struct sigaction act; - - /* ignore SIGPIPE's */ - act.sa_handler = SIG_IGN; - act.sa_flags = 0; - sigemptyset (&act.sa_mask); - sigaction (SIGPIPE, &act, NULL); - - /* Deal with SIGUSR1's & SIGUSR2's */ - act.sa_sigaction = sigusr1_handler; - act.sa_flags = 0; - sigemptyset (&act.sa_mask); - sigaction (SIGUSR1, &act, NULL); - - act.sa_sigaction = sigusr2_handler; - act.sa_flags = 0; - sigemptyset (&act.sa_mask); - sigaction (SIGUSR2, &act, NULL); -#else -#ifndef WIN32 - /* good enough for these old systems */ - signal (SIGPIPE, SIG_IGN); -#endif -#endif - - if (g_get_charset (&cs)) - prefs.utf8_locale = TRUE; - - load_text_events (); - sound_load (); - notify_load (); - ignore_load (); - - snprintf (buf, sizeof (buf), - "NAME %s~%s~\n" "CMD query %%s\n\n"\ - "NAME %s~%s~\n" "CMD send %%s\n\n"\ - "NAME %s~%s~\n" "CMD whois %%s %%s\n\n"\ - "NAME %s~%s~\n" "CMD notify -n ASK %%s\n\n"\ - "NAME %s~%s~\n" "CMD ignore %%s!*@* ALL\n\n"\ - - "NAME SUB\n" "CMD %s\n\n"\ - "NAME %s\n" "CMD op %%a\n\n"\ - "NAME %s\n" "CMD deop %%a\n\n"\ - "NAME SEP\n" "CMD \n\n"\ - "NAME %s\n" "CMD voice %%a\n\n"\ - "NAME %s\n" "CMD devoice %%a\n"\ - "NAME SEP\n" "CMD \n\n"\ - "NAME SUB\n" "CMD %s\n\n"\ - "NAME %s\n" "CMD kick %%s\n\n"\ - "NAME %s\n" "CMD ban %%s\n\n"\ - "NAME SEP\n" "CMD \n\n"\ - "NAME %s *!*@*.host\n""CMD ban %%s 0\n\n"\ - "NAME %s *!*@domain\n""CMD ban %%s 1\n\n"\ - "NAME %s *!*user@*.host\n""CMD ban %%s 2\n\n"\ - "NAME %s *!*user@domain\n""CMD ban %%s 3\n\n"\ - "NAME SEP\n" "CMD \n\n"\ - "NAME %s *!*@*.host\n""CMD kickban %%s 0\n\n"\ - "NAME %s *!*@domain\n""CMD kickban %%s 1\n\n"\ - "NAME %s *!*user@*.host\n""CMD kickban %%s 2\n\n"\ - "NAME %s *!*user@domain\n""CMD kickban %%s 3\n\n"\ - "NAME ENDSUB\n" "CMD \n\n"\ - "NAME ENDSUB\n" "CMD \n\n", - - _("_Open Dialog Window"), "gtk-go-up", - _("_Send a File"), "gtk-floppy", - _("_User Info (WhoIs)"), "gtk-info", - _("_Add to Friends List"), "gtk-add", - _("_Ignore"), "gtk-stop", - _("O_perator Actions"), - - _("Give Ops"), - _("Take Ops"), - _("Give Voice"), - _("Take Voice"), - - _("Kick/Ban"), - _("Kick"), - _("Ban"), - _("Ban"), - _("Ban"), - _("Ban"), - _("Ban"), - _("KickBan"), - _("KickBan"), - _("KickBan"), - _("KickBan")); - - list_loadconf ("popup.conf", &popup_list, buf); - - snprintf (buf, sizeof (buf), - "NAME %s\n" "CMD part\n\n" - "NAME %s\n" "CMD getstr # join \"%s\"\n\n" - "NAME %s\n" "CMD quote LINKS\n\n" - "NAME %s\n" "CMD ping\n\n" - "NAME TOGGLE %s\n" "CMD irc_hide_version\n\n", - _("Leave Channel"), - _("Join Channel..."), - _("Enter Channel to Join:"), - _("Server Links"), - _("Ping Server"), - _("Hide Version")); - list_loadconf ("usermenu.conf", &usermenu_list, buf); - - snprintf (buf, sizeof (buf), - "NAME %s\n" "CMD op %%a\n\n" - "NAME %s\n" "CMD deop %%a\n\n" - "NAME %s\n" "CMD ban %%s\n\n" - "NAME %s\n" "CMD getstr \"%s\" \"kick %%s\" \"%s\"\n\n" - "NAME %s\n" "CMD send %%s\n\n" - "NAME %s\n" "CMD query %%s\n\n", - _("Op"), - _("DeOp"), - _("Ban"), - _("Kick"), - _("bye"), - _("Enter reason to kick %s:"), - _("Sendfile"), - _("Dialog")); - list_loadconf ("buttons.conf", &button_list, buf); - - snprintf (buf, sizeof (buf), - "NAME %s\n" "CMD whois %%s %%s\n\n" - "NAME %s\n" "CMD send %%s\n\n" - "NAME %s\n" "CMD dcc chat %%s\n\n" - "NAME %s\n" "CMD clear\n\n" - "NAME %s\n" "CMD ping %%s\n\n", - _("WhoIs"), - _("Send"), - _("Chat"), - _("Clear"), - _("Ping")); - list_loadconf ("dlgbuttons.conf", &dlgbutton_list, buf); - - list_loadconf ("tabmenu.conf", &tabmenu_list, NULL); - list_loadconf ("ctcpreply.conf", &ctcp_list, defaultconf_ctcp); - list_loadconf ("commands.conf", &command_list, defaultconf_commands); - list_loadconf ("replace.conf", &replace_list, defaultconf_replace); - list_loadconf ("urlhandlers.conf", &urlhandler_list, - defaultconf_urlhandlers); - - servlist_init (); /* load server list */ - - /* if we got a URL, don't open the server list GUI */ - if (!prefs.hex_gui_slist_skip && !arg_url) - fe_serverlist_open (NULL); - - /* turned OFF via -a arg */ - if (!arg_dont_autoconnect) - { - /* do any auto connects */ - if (!servlist_have_auto ()) /* if no new windows open .. */ - { - /* and no serverlist gui ... */ - if (prefs.hex_gui_slist_skip || arg_url) - /* we'll have to open one. */ - new_ircwindow (NULL, NULL, SESS_SERVER, 0); - } else - { - fe_idle_add (xchat_auto_connect, NULL); - } - } else - { - if (prefs.hex_gui_slist_skip || arg_url) - new_ircwindow (NULL, NULL, SESS_SERVER, 0); - } -} - -void -xchat_exit (void) -{ - xchat_is_quitting = TRUE; - in_xchat_exit = TRUE; - plugin_kill_all (); - fe_cleanup (); - - save_config (); - if (prefs.save_pevents) - { - pevent_save (NULL); - } - - sound_save (); - notify_save (); - ignore_save (); - free_sessions (); - chanopt_save_all (); - servlist_cleanup (); - fe_exit (); -} - -#ifndef WIN32 - -static int -child_handler (gpointer userdata) -{ - int pid = GPOINTER_TO_INT (userdata); - - if (waitpid (pid, 0, WNOHANG) == pid) - return 0; /* remove timeout handler */ - return 1; /* keep the timeout handler */ -} - -#endif - -void -xchat_exec (const char *cmd) -{ -#ifdef WIN32 - util_exec (cmd); -#else - int pid = util_exec (cmd); - if (pid != -1) - /* zombie avoiding system. Don't ask! it has to be like this to work - with zvt (which overrides the default handler) */ - fe_timeout_add (1000, child_handler, GINT_TO_POINTER (pid)); -#endif -} - -void -xchat_execv (char * const argv[]) -{ -#ifdef WIN32 - util_execv (argv); -#else - int pid = util_execv (argv); - if (pid != -1) - /* zombie avoiding system. Don't ask! it has to be like this to work - with zvt (which overrides the default handler) */ - fe_timeout_add (1000, child_handler, GINT_TO_POINTER (pid)); -#endif -} - -#ifdef WIN32 -static void -xchat_restore_window (HWND xchat_window) -{ - /* ShowWindow (xchat_window, SW_RESTORE); another way, but works worse */ - SendMessage (xchat_window, WM_SYSCOMMAND, SC_RESTORE, 0); - SetForegroundWindow (xchat_window); -} - -BOOL CALLBACK -enum_windows_impl (HWND current_window, LPARAM lParam) -{ - TCHAR window_name[8]; - TCHAR module_path[1024]; - ZeroMemory (&window_name, sizeof (window_name)); - - if (!current_window) - { - return TRUE; - } - - GetWindowText (current_window, window_name, 8); /* name length + 1 */ - if (strcmp (window_name, "HexChat") == 0) - { - /* use a separate if block, this way we don't have to call GetWindowModuleFileName() for each hit */ - ZeroMemory (&module_path, sizeof (module_path)); - GetWindowModuleFileName (current_window, module_path, sizeof (module_path)); - - if (strstr (module_path, "hexchat.exe")) /* We've found it, stop */ - { - xchat_restore_window (current_window); - return FALSE; - } - } - - return TRUE; /* Keep searching */ - -} -#endif - -int -main (int argc, char *argv[]) -{ - int ret; - -#ifdef WIN32 - char hexchat_lang[13]; /* LC_ALL= plus 5 chars of hex_gui_lang and trailing \0 */ - HANDLE mutex; -#endif - - srand (time (0)); /* CL: do this only once! */ - - load_config (); - -#ifdef WIN32 - /* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */ - strcpy (hexchat_lang, "LC_ALL="); - - /* this must be ordered EXACTLY as langsmenu[] */ - switch (prefs.hex_gui_lang) - { - case 0: - strcat (hexchat_lang, "af"); - break; - case 1: - strcat (hexchat_lang, "sq"); - break; - case 2: - strcat (hexchat_lang, "am"); - break; - case 3: - strcat (hexchat_lang, "ast"); - break; - case 4: - strcat (hexchat_lang, "az"); - break; - case 5: - strcat (hexchat_lang, "eu"); - break; - case 6: - strcat (hexchat_lang, "be"); - break; - case 7: - strcat (hexchat_lang, "bg"); - break; - case 8: - strcat (hexchat_lang, "ca"); - break; - case 9: - strcat (hexchat_lang, "zh_CN"); - break; - case 10: - strcat (hexchat_lang, "zh_TW"); - break; - case 11: - strcat (hexchat_lang, "cs"); - break; - case 12: - strcat (hexchat_lang, "da"); - break; - case 13: - strcat (hexchat_lang, "nl"); - break; - case 14: - strcat (hexchat_lang, "en_GB"); - break; - case 15: - strcat (hexchat_lang, "en"); - break; - case 16: - strcat (hexchat_lang, "et"); - break; - case 17: - strcat (hexchat_lang, "fi"); - break; - case 18: - strcat (hexchat_lang, "fr"); - break; - case 19: - strcat (hexchat_lang, "gl"); - break; - case 20: - strcat (hexchat_lang, "de"); - break; - case 21: - strcat (hexchat_lang, "el"); - break; - case 22: - strcat (hexchat_lang, "gu"); - break; - case 23: - strcat (hexchat_lang, "hi"); - break; - case 24: - strcat (hexchat_lang, "hu"); - break; - case 25: - strcat (hexchat_lang, "id"); - break; - case 26: - strcat (hexchat_lang, "it"); - break; - case 27: - strcat (hexchat_lang, "ja"); - break; - case 28: - strcat (hexchat_lang, "kn"); - break; - case 29: - strcat (hexchat_lang, "rw"); - break; - case 30: - strcat (hexchat_lang, "ko"); - break; - case 31: - strcat (hexchat_lang, "lv"); - break; - case 32: - strcat (hexchat_lang, "lt"); - break; - case 33: - strcat (hexchat_lang, "mk"); - break; - case 34: - strcat (hexchat_lang, "ml"); - break; - case 35: - strcat (hexchat_lang, "ms"); - break; - case 36: - strcat (hexchat_lang, "nb"); - break; - case 37: - strcat (hexchat_lang, "no"); - break; - case 38: - strcat (hexchat_lang, "pl"); - break; - case 39: - strcat (hexchat_lang, "pt"); - break; - case 40: - strcat (hexchat_lang, "pt_BR"); - break; - case 41: - strcat (hexchat_lang, "pa"); - break; - case 42: - strcat (hexchat_lang, "ru"); - break; - case 43: - strcat (hexchat_lang, "sr"); - break; - case 44: - strcat (hexchat_lang, "sk"); - break; - case 45: - strcat (hexchat_lang, "sl"); - break; - case 46: - strcat (hexchat_lang, "es"); - break; - case 47: - strcat (hexchat_lang, "sv"); - break; - case 48: - strcat (hexchat_lang, "th"); - break; - case 49: - strcat (hexchat_lang, "uk"); - break; - case 50: - strcat (hexchat_lang, "vi"); - break; - case 51: - strcat (hexchat_lang, "wa"); - break; - default: - strcat (hexchat_lang, "en"); - break; - } - - putenv (hexchat_lang); - - if (prefs.hex_gui_single && !portable_mode ()) - { - DWORD error; - - mutex = CreateMutex (NULL, TRUE, "Local\\hexchat"); - error = GetLastError (); - - if (error == ERROR_ALREADY_EXISTS || mutex == NULL) - { - /* restoring the XChat window from the tray via the taskbar icon - * only works correctly when X-Tray is used, but it's not a big deal - * since you can only minimize XChat to tray via the taskbar if you - * use X-Tray*/ - if (hextray_mode ()) - { - /* FindWindow() doesn't support wildcards so we check all the open windows */ - EnumWindows (enum_windows_impl, NULL); - return 0; - } - else - { - return 1; - } - } - } -#endif - -#ifdef SOCKS - SOCKSinit (argv[0]); -#endif - - ret = fe_args (argc, argv); - if (ret != -1) - return ret; - -#ifdef USE_DBUS - xchat_remote (); -#endif - -#ifdef USE_LIBPROXY - libproxy_factory = px_proxy_factory_new(); -#endif - - fe_init (); - - xchat_init (); - - fe_main (); - -#ifdef USE_LIBPROXY - px_proxy_factory_free(libproxy_factory); -#endif - -#ifdef USE_OPENSSL - if (ctx) - _SSL_context_free (ctx); -#endif - -#ifdef USE_DEBUG - xchat_mem_list (); -#endif - -#ifdef WIN32 - WSACleanup (); - - if (prefs.hex_gui_single && !portable_mode ()) - { - ReleaseMutex (mutex); - CloseHandle (mutex); - } -#endif - - return 0; -} diff --git a/src/common/xchat.h b/src/common/xchat.h deleted file mode 100644 index 2980fc1c..00000000 --- a/src/common/xchat.h +++ /dev/null @@ -1,595 +0,0 @@ -#include "../../config.h" - -#include -#include /* need time_t */ - -#ifndef XCHAT_H -#define XCHAT_H - -#include "history.h" - -#ifndef HAVE_SNPRINTF -#define snprintf g_snprintf -#endif - -#ifndef HAVE_VSNPRINTF -#define vsnprintf _vsnprintf -#endif - -#ifdef USE_DEBUG -#define malloc(n) xchat_malloc(n, __FILE__, __LINE__) -#define realloc(n, m) xchat_realloc(n, m, __FILE__, __LINE__) -#define free(n) xchat_dfree(n, __FILE__, __LINE__) -#define strdup(n) xchat_strdup(n, __FILE__, __LINE__) -void *xchat_malloc (int size, char *file, int line); -void *xchat_strdup (char *str, char *file, int line); -void xchat_dfree (void *buf, char *file, int line); -void *xchat_realloc (char *old, int len, char *file, int line); -#endif - -#ifdef SOCKS -#ifdef __sgi -#include -#define INCLUDE_PROTOTYPES 1 -#endif -#include -#endif - -#ifdef USE_OPENSSL -#include /* SSL_() */ -#endif - -#ifdef __EMX__ /* for o/s 2 */ -#define OFLAGS O_BINARY -#define g_ascii_strcasecmp stricmp -#define g_ascii_strncasecmp strnicmp -#define PATH_MAX MAXPATHLEN -#define FILEPATH_LEN_MAX MAXPATHLEN -#endif - -/* force a 32bit CMP.L */ -#define CMPL(a, c0, c1, c2, c3) (a == (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24))) -#define WORDL(c0, c1, c2, c3) (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24)) -#define WORDW(c0, c1) (guint16)(c0 | (c1 << 8)) - -#ifdef WIN32 /* for win32 */ -#define OFLAGS O_BINARY -#define sleep(t) Sleep(t*1000) -#include -#define F_OK 0 -#define X_OK 1 -#define W_OK 2 -#define R_OK 4 -#ifndef S_ISDIR -#define S_ISDIR(m) ((m) & _S_IFDIR) -#endif -#define NETWORK_PRIVATE -#else /* for unix */ -#define OFLAGS 0 -#endif - -#define FONTNAMELEN 127 -#define PATHLEN 255 -#define DOMAINLEN 100 -#define NICKLEN 64 /* including the NULL, so 63 really */ -#define CHANLEN 300 -#define PDIWORDS 32 -#define USERNAMELEN 10 -#define HIDDEN_CHAR 8 /* invisible character for xtext */ - -#if defined(ENABLE_NLS) && !defined(_) -# include -# define _(x) gettext(x) -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#endif -#if !defined(_) -# define N_(String) (String) -# define _(x) (x) -#endif - -struct nbexec -{ - int myfd; - int childpid; - int tochannel; /* making this int keeps the struct 4-byte aligned */ - int iotag; - char *linebuf; - int buffill; - struct session *sess; -}; - -struct hexchatprefs -{ - /* these are the rebranded, consistent, sorted hexchat variables */ - - /* BOOLEANS */ - unsigned int hex_away_auto_unmark; - unsigned int hex_away_omit_alerts; - unsigned int hex_away_show_message; - unsigned int hex_away_show_once; - unsigned int hex_away_track; - unsigned int hex_completion_auto; - unsigned int hex_dcc_auto_chat; - unsigned int hex_dcc_auto_resume; - unsigned int hex_dcc_fast_send; - unsigned int hex_dcc_ip_from_server; - unsigned int hex_dcc_remove; - unsigned int hex_dcc_save_nick; - unsigned int hex_dcc_send_fillspaces; - unsigned int hex_gui_autoopen_chat; - unsigned int hex_gui_autoopen_dialog; - unsigned int hex_gui_autoopen_recv; - unsigned int hex_gui_autoopen_send; - unsigned int hex_gui_compact; - unsigned int hex_gui_hide_menu; - unsigned int hex_gui_input_nick; - unsigned int hex_gui_input_spell; - unsigned int hex_gui_input_style; - unsigned int hex_gui_join_dialog; - unsigned int hex_gui_mode_buttons; - unsigned int hex_gui_quit_dialog; - unsigned int hex_gui_single; - unsigned int hex_gui_slist_fav; - unsigned int hex_gui_slist_skip; - unsigned int hex_gui_tab_chans; - unsigned int hex_gui_tab_dialogs; - unsigned int hex_gui_tab_dots; - unsigned int hex_gui_tab_icons; - unsigned int hex_gui_tab_notices; - unsigned int hex_gui_tab_server; - unsigned int hex_gui_tab_sort; - unsigned int hex_gui_tab_utils; - unsigned int hex_gui_topicbar; - unsigned int hex_gui_tray; - unsigned int hex_gui_ulist_buttons; - unsigned int hex_gui_ulist_count; - unsigned int hex_gui_ulist_hide; - unsigned int hex_gui_ulist_icons; - unsigned int hex_gui_ulist_resizable; - unsigned int hex_gui_ulist_show_hosts; - unsigned int hex_gui_ulist_style; - unsigned int hex_gui_usermenu; - unsigned int hex_gui_win_modes; - unsigned int hex_gui_win_save; - unsigned int hex_gui_win_swap; - unsigned int hex_gui_win_ucount; - unsigned int hex_identd; - unsigned int hex_input_balloon_chans; - unsigned int hex_input_balloon_hilight; - unsigned int hex_input_balloon_priv; - unsigned int hex_input_beep_chans; - unsigned int hex_input_beep_hilight; - unsigned int hex_input_beep_priv; - unsigned int hex_input_filter_beep; - unsigned int hex_input_flash_chans; - unsigned int hex_input_flash_hilight; - unsigned int hex_input_flash_priv; - unsigned int hex_input_perc_ascii; - unsigned int hex_input_perc_color; - unsigned int hex_input_tray_chans; - unsigned int hex_input_tray_hilight; - unsigned int hex_input_tray_priv; - unsigned int hex_irc_auto_rejoin; - unsigned int hex_irc_conf_mode; - unsigned int hex_irc_hide_version; - unsigned int hex_irc_invisible; - unsigned int hex_irc_logging; - unsigned int hex_irc_raw_modes; - unsigned int hex_irc_servernotice; - unsigned int hex_irc_skip_motd; - unsigned int hex_irc_wallops; - unsigned int hex_irc_who_join; - unsigned int hex_irc_whois_front; - unsigned int hex_net_auto_reconnect; - unsigned int hex_net_auto_reconnectonfail; - unsigned int hex_net_proxy_auth; - unsigned int hex_net_throttle; - unsigned int hex_notify_whois_online; - unsigned int hex_perl_warnings; - unsigned int hex_stamp_log; - unsigned int hex_stamp_text; - unsigned int hex_text_autocopy_color; - unsigned int hex_text_autocopy_stamp; - unsigned int hex_text_autocopy_text; - unsigned int hex_text_color_nicks; - unsigned int hex_text_indent; - unsigned int hex_text_replay; - unsigned int hex_text_search_case_match; - unsigned int hex_text_search_backward; - unsigned int hex_text_search_highlight_all; - unsigned int hex_text_search_follow; - unsigned int hex_text_search_regexp; - unsigned int hex_text_show_marker; - unsigned int hex_text_show_sep; - unsigned int hex_text_stripcolor_msg; - unsigned int hex_text_stripcolor_replay; - unsigned int hex_text_stripcolor_topic; - unsigned int hex_text_thin_sep; - unsigned int hex_text_transparent; - unsigned int hex_text_wordwrap; - unsigned int hex_url_grabber; - unsigned int hex_url_logging; - - /* NUMBERS */ - int hex_away_size_max; - int hex_away_timeout; - int hex_completion_amount; - int hex_completion_sort; - int hex_dcc_auto_recv; - int hex_dcc_blocksize; - int hex_dcc_global_max_get_cps; - int hex_dcc_global_max_send_cps; - int hex_dcc_max_get_cps; - int hex_dcc_max_send_cps; - int hex_dcc_permissions; - int hex_dcc_port_first; - int hex_dcc_port_last; - int hex_dcc_stall_timeout; - int hex_dcc_timeout; - int hex_flood_ctcp_num; /* flood */ - int hex_flood_ctcp_time; /* seconds of floods */ - int hex_flood_msg_num; /* same deal */ - int hex_flood_msg_time; - int hex_gui_chanlist_maxusers; - int hex_gui_chanlist_minusers; - int hex_gui_dialog_height; - int hex_gui_dialog_left; - int hex_gui_dialog_top; - int hex_gui_dialog_width; - int hex_gui_lagometer; - int hex_gui_lang; - int hex_gui_pane_left_size; - int hex_gui_pane_right_size; - int hex_gui_pane_right_size_min; - int hex_gui_slist_select; - int hex_gui_tab_layout; - int hex_gui_tab_newtofront; - int hex_gui_tab_pos; - int hex_gui_tab_small; - int hex_gui_tab_trunc; - int hex_gui_throttlemeter; - int hex_gui_tray_flags; - int hex_gui_ulist_pos; - int hex_gui_ulist_sort; - int hex_gui_url_mod; - int hex_gui_win_height; - int hex_gui_win_left; - int hex_gui_win_state; - int hex_gui_win_top; - int hex_gui_win_width; - int hex_input_balloon_time; - int hex_irc_ban_type; - int hex_irc_join_delay; - int hex_net_ping_timeout; - int hex_net_proxy_port; - int hex_net_proxy_type; /* 0=disabled, 1=wingate 2=socks4, 3=socks5, 4=http */ - int hex_net_proxy_use; /* 0=all 1=IRC_ONLY 2=DCC_ONLY */ - int hex_net_reconnect_delay; - int hex_notify_timeout; - int hex_text_max_indent; - int hex_text_max_lines; - int hex_text_tint_blue; - int hex_text_tint_green; - int hex_text_tint_red; - int hex_url_grabber_limit; - - /* STRINGS */ - char hex_away_reason[256]; - char hex_completion_suffix[4]; /* Only ever holds a one-character string. */ - char hex_dcc_completed_dir[PATHLEN + 1]; - char hex_dcc_dir[PATHLEN + 1]; - char hex_dcc_ip[DOMAINLEN + 1]; - char hex_dnsprogram[72]; - char hex_gui_ulist_doubleclick[256]; - char hex_input_command_char[4]; - char hex_irc_extra_hilight[300]; - char hex_irc_id_ntext[64]; - char hex_irc_id_ytext[64]; - char hex_irc_logmask[256]; - char hex_irc_nick1[NICKLEN]; - char hex_irc_nick2[NICKLEN]; - char hex_irc_nick3[NICKLEN]; - char hex_irc_nick_hilight[300]; - char hex_irc_no_hilight[300]; - char hex_irc_part_reason[256]; - char hex_irc_quit_reason[256]; - char hex_irc_real_name[127]; - char hex_irc_user_name[127]; - char hex_net_bind_host[127]; - char hex_net_proxy_host[64]; - char hex_net_proxy_pass[32]; - char hex_net_proxy_user[32]; - char hex_sound_command[PATHLEN + 1]; - char hex_sound_dir[PATHLEN + 1]; - char hex_stamp_log_format[64]; - char hex_stamp_text_format[64]; - char hex_text_background[PATHLEN + 1]; - char hex_text_font[4 * FONTNAMELEN + 1]; - char hex_text_font_main[FONTNAMELEN + 1]; - char hex_text_font_alternative[3 * FONTNAMELEN + 1]; - char hex_text_spell_langs[64]; - - /* these are the private variables */ - guint32 local_ip; - guint32 dcc_ip; - - unsigned int wait_on_exit; /* wait for logs to be flushed to disk IF we're connected */ - unsigned int utf8_locale; - - /* Tells us if we need to save, only when they've been edited. - This is so that we continue using internal defaults (which can - change in the next release) until the user edits them. */ - unsigned int save_pevents:1; -}; - -/* Session types */ -#define SESS_SERVER 1 -#define SESS_CHANNEL 2 -#define SESS_DIALOG 3 -#define SESS_NOTICES 4 -#define SESS_SNOTICES 5 - -/* Per-Channel Settings */ -#define SET_OFF 0 -#define SET_ON 1 -#define SET_DEFAULT 2 /* use global setting */ - -/* Moved from fe-gtk for use in outbound.c as well -- */ -typedef enum gtk_xtext_search_flags_e { - case_match = 1, - backward = 2, - highlight = 4, - follow = 8, - regexp = 16 -} gtk_xtext_search_flags; - -typedef struct session -{ - /* Per-Channel Alerts */ - /* use a byte, because we need a pointer to each element */ - guint8 alert_beep; - guint8 alert_taskbar; - guint8 alert_tray; - - /* Per-Channel Settings */ - guint8 text_hidejoinpart; - guint8 text_logging; - guint8 text_scrollback; - - struct server *server; - void *usertree_alpha; /* pure alphabetical tree */ - void *usertree; /* ordered with Ops first */ - struct User *me; /* points to myself in the usertree */ - char channel[CHANLEN]; - char waitchannel[CHANLEN]; /* waiting to join channel (/join sent) */ - char willjoinchannel[CHANLEN]; /* will issue /join for this channel */ - char channelkey[64]; /* XXX correct max length? */ - int limit; /* channel user limit */ - int logfd; - int scrollfd; /* scrollback filedes */ - int scrollwritten; /* number of lines written */ - - char lastnick[NICKLEN]; /* last nick you /msg'ed */ - - struct history history; - - int ops; /* num. of ops in channel */ - int hops; /* num. of half-oped users */ - int voices; /* num. of voiced people */ - int total; /* num. of users in channel */ - - char *quitreason; - char *topic; - char *current_modes; /* free() me */ - - int mode_timeout_tag; - - struct session *lastlog_sess; - struct nbexec *running_exec; - - struct session_gui *gui; /* initialized by fe_new_window */ - struct restore_gui *res; - - int type; /* SESS_* */ - - int new_data:1; /* new data avail? (purple tab) */ - int nick_said:1; /* your nick mentioned? (blue tab) */ - int msg_said:1; /* new msg available? (red tab) */ - - int ignore_date:1; - int ignore_mode:1; - int ignore_names:1; - int end_of_names:1; - int doing_who:1; /* /who sent on this channel */ - int done_away_check:1; /* done checking for away status changes */ - gtk_xtext_search_flags lastlog_flags; -} session; - -struct msproxy_state_t -{ - gint32 clientid; - gint32 serverid; - unsigned char seq_recv; /* seq number of last packet recv. */ - unsigned char seq_sent; /* seq number of last packet sent. */ -}; - -typedef struct server -{ - /* server control operations (in server*.c) */ - void (*connect)(struct server *, char *hostname, int port, int no_login); - void (*disconnect)(struct session *, int sendquit, int err); - int (*cleanup)(struct server *); - void (*flush_queue)(struct server *); - void (*auto_reconnect)(struct server *, int send_quit, int err); - /* irc protocol functions (in proto*.c) */ - void (*p_inline)(struct server *, char *buf, int len); - void (*p_invite)(struct server *, char *channel, char *nick); - void (*p_cycle)(struct server *, char *channel, char *key); - void (*p_ctcp)(struct server *, char *to, char *msg); - void (*p_nctcp)(struct server *, char *to, char *msg); - void (*p_quit)(struct server *, char *reason); - void (*p_kick)(struct server *, char *channel, char *nick, char *reason); - void (*p_part)(struct server *, char *channel, char *reason); - void (*p_ns_identify)(struct server *, char *pass); - void (*p_ns_ghost)(struct server *, char *usname, char *pass); - void (*p_join)(struct server *, char *channel, char *key); - void (*p_join_list)(struct server *, GSList *channels, GSList *keys); - void (*p_login)(struct server *, char *user, char *realname); - void (*p_join_info)(struct server *, char *channel); - void (*p_mode)(struct server *, char *target, char *mode); - void (*p_user_list)(struct server *, char *channel); - void (*p_away_status)(struct server *, char *channel); - void (*p_whois)(struct server *, char *nicks); - void (*p_get_ip)(struct server *, char *nick); - void (*p_get_ip_uh)(struct server *, char *nick); - void (*p_set_back)(struct server *); - void (*p_set_away)(struct server *, char *reason); - void (*p_message)(struct server *, char *channel, char *text); - void (*p_action)(struct server *, char *channel, char *act); - void (*p_notice)(struct server *, char *channel, char *text); - void (*p_topic)(struct server *, char *channel, char *topic); - void (*p_list_channels)(struct server *, char *arg, int min_users); - void (*p_change_nick)(struct server *, char *new_nick); - void (*p_names)(struct server *, char *channel); - void (*p_ping)(struct server *, char *to, char *timestring); -/* void (*p_set_away)(struct server *);*/ - int (*p_raw)(struct server *, char *raw); - int (*p_cmp)(const char *s1, const char *s2); - - int port; - int sok; /* is equal to sok4 or sok6 (the one we are using) */ - int sok4; /* tcp4 socket */ - int sok6; /* tcp6 socket */ - int proxy_type; - int proxy_sok; /* Additional information for MS Proxy beast */ - int proxy_sok4; - int proxy_sok6; - struct msproxy_state_t msp_state; - int id; /* unique ID number (for plugin API) */ -#ifdef USE_OPENSSL - SSL *ssl; - int ssl_do_connect_tag; -#else - void *ssl; -#endif - int childread; - int childwrite; - int childpid; - int iotag; - int recondelay_tag; /* reconnect delay timeout */ - int joindelay_tag; /* waiting before we send JOIN */ - char hostname[128]; /* real ip number */ - char servername[128]; /* what the server says is its name */ - char password[86]; - char nick[NICKLEN]; - char linebuf[2048]; /* RFC says 512 chars including \r\n */ - char *last_away_reason; - int pos; /* current position in linebuf */ - int nickcount; - int nickservtype; /* 0=/MSG nickserv 1=/NICKSERV 2=/NS */ - - char *chantypes; /* for 005 numeric - free me */ - char *chanmodes; /* for 005 numeric - free me */ - char *nick_prefixes; /* e.g. "*@%+" */ - char *nick_modes; /* e.g. "aohv" */ - char *bad_nick_prefixes; /* for ircd that doesn't give the modes */ - int modes_per_line; /* 6 on undernet, 4 on efnet etc... */ - - void *network; /* points to entry in servlist.c or NULL! */ - - GSList *outbound_queue; - time_t next_send; /* cptr->since in ircu */ - time_t prev_now; /* previous now-time */ - int sendq_len; /* queue size */ - int lag; /* milliseconds */ - - struct session *front_session; /* front-most window/tab */ - struct session *server_session; /* server window/tab */ - - struct server_gui *gui; /* initialized by fe_new_server */ - - unsigned int ctcp_counter; /*flood */ - time_t ctcp_last_time; - - unsigned int msg_counter; /*counts the msg tab opened in a certain time */ - time_t msg_last_time; - - /*time_t connect_time;*/ /* when did it connect? */ - time_t lag_sent; - time_t ping_recv; /* when we last got a ping reply */ - time_t away_time; /* when we were marked away */ - - char *encoding; /* NULL for system */ - char *autojoin; /* list of channels & keys to join */ - - unsigned int motd_skipped:1; - unsigned int connected:1; - unsigned int connecting:1; - unsigned int no_login:1; - unsigned int skip_next_userhost:1;/* used for "get my ip from server" */ - unsigned int skip_next_whois:1; /* hide whois output */ - unsigned int inside_whois:1; - unsigned int doing_dns:1; /* /dns has been done */ - unsigned int end_of_motd:1; /* end of motd reached (logged in) */ - unsigned int sent_quit:1; /* sent a QUIT already? */ - unsigned int use_listargs:1; /* undernet and dalnet need /list >0,<10000 */ - unsigned int is_away:1; - unsigned int reconnect_away:1; /* whether to reconnect in is_away state */ - unsigned int dont_use_proxy:1; /* to proxy or not to proxy */ - unsigned int supports_watch:1; /* supports the WATCH command */ - unsigned int bad_prefix:1; /* gave us a bad PREFIX= 005 number */ - unsigned int have_namesx:1; /* 005 tokens NAMESX and UHNAMES */ - unsigned int have_uhnames:1; - unsigned int have_whox:1; /* have undernet's WHOX features */ - unsigned int have_capab:1; /* supports CAPAB (005 tells us) */ - unsigned int have_idmsg:1; /* freenode's IDENTIFY-MSG */ - unsigned int have_except:1; /* ban exemptions +e */ - unsigned int using_cp1255:1; /* encoding is CP1255/WINDOWS-1255? */ - unsigned int using_irc:1; /* encoding is "IRC" (CP1252/UTF-8 hybrid)? */ - unsigned int use_who:1; /* whether to use WHO command to get dcc_ip */ -#ifdef USE_OPENSSL - unsigned int use_ssl:1; /* is server SSL capable? */ - unsigned int accept_invalid_cert:1;/* ignore result of server's cert. verify */ -#endif -} server; - -typedef int (*cmd_callback) (struct session * sess, char *tbuf, char *word[], - char *word_eol[]); - -struct commands -{ - char *name; - cmd_callback callback; - char needserver; - char needchannel; - gint16 handle_quotes; - char *help; -}; - -struct away_msg -{ - struct server *server; - char nick[NICKLEN]; - char *message; -}; - -/* not just for popups, but used for usercommands, ctcp replies, - userlist buttons etc */ - -struct popup -{ - char *cmd; - char *name; -}; - -/* CL: get a random int in the range [0..n-1]. DON'T use rand() % n, it gives terrible results. */ -#define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n))) - -#define xchat_filename_from_utf8 g_filename_from_utf8 -#define xchat_filename_to_utf8 g_filename_to_utf8 - -#endif diff --git a/src/common/xchatc.h b/src/common/xchatc.h deleted file mode 100644 index 1d955055..00000000 --- a/src/common/xchatc.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef XCHAT_C_H -#define XCHAT_C_H - -extern struct hexchatprefs prefs; - -extern int xchat_is_quitting; -extern gint arg_skip_plugins; /* command-line args */ -extern gint arg_dont_autoconnect; -extern char *arg_url; -extern char *arg_command; -extern gint arg_existing; - -extern session *current_sess; -extern session *current_tab; - -extern GSList *popup_list; -extern GSList *button_list; -extern GSList *dlgbutton_list; -extern GSList *command_list; -extern GSList *ctcp_list; -extern GSList *replace_list; -extern GSList *sess_list; -extern GSList *dcc_list; -extern GSList *ignore_list; -extern GSList *usermenu_list; -extern GSList *urlhandler_list; -extern GSList *tabmenu_list; - -session * find_channel (server *serv, char *chan); -session * find_dialog (server *serv, char *nick); -session * new_ircwindow (server *serv, char *name, int type, int focus); -int is_session (session * sess); -void session_free (session *killsess); -void lag_check (void); -void xchat_exit (void); -void xchat_exec (const char *cmd); -void xchat_execv (char * const argv[]); - -#endif diff --git a/src/fe-gtk/about.c b/src/fe-gtk/about.c index f63cf80e..d33c6ae3 100644 --- a/src/fe-gtk/about.c +++ b/src/fe-gtk/about.c @@ -37,9 +37,9 @@ #include #endif -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/util.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "palette.h" #include "pixmaps.h" #include "gtkutil.h" diff --git a/src/fe-gtk/ascii.c b/src/fe-gtk/ascii.c index f1adbdfc..85dcf26d 100644 --- a/src/fe-gtk/ascii.c +++ b/src/fe-gtk/ascii.c @@ -28,8 +28,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "gtkutil.h" #include "ascii.h" #include "maingui.h" diff --git a/src/fe-gtk/banlist.c b/src/fe-gtk/banlist.c index 43bc9e42..f91be2fc 100644 --- a/src/fe-gtk/banlist.c +++ b/src/fe-gtk/banlist.c @@ -37,11 +37,11 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include "../common/modes.h" #include "../common/outbound.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "gtkutil.h" #include "maingui.h" #include "banlist.h" diff --git a/src/fe-gtk/chanlist.c b/src/fe-gtk/chanlist.c index 54348565..8a431ebc 100644 --- a/src/fe-gtk/chanlist.c +++ b/src/fe-gtk/chanlist.c @@ -47,8 +47,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/outbound.h" #include "../common/util.h" diff --git a/src/fe-gtk/chanview-tree.c b/src/fe-gtk/chanview-tree.c index 5a678550..bceabc8f 100644 --- a/src/fe-gtk/chanview-tree.c +++ b/src/fe-gtk/chanview-tree.c @@ -6,8 +6,8 @@ typedef struct GtkWidget *scrollw; /* scrolledWindow */ } treeview; -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "fe-gtk.h" #include "maingui.h" diff --git a/src/fe-gtk/dccgui.c b/src/fe-gtk/dccgui.c index 737963d5..60881959 100644 --- a/src/fe-gtk/dccgui.c +++ b/src/fe-gtk/dccgui.c @@ -44,8 +44,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/fe.h" #include "../common/util.h" #include "../common/network.h" diff --git a/src/fe-gtk/editlist.c b/src/fe-gtk/editlist.c index 05be3128..2ce48ee4 100644 --- a/src/fe-gtk/editlist.c +++ b/src/fe-gtk/editlist.c @@ -37,9 +37,9 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/cfgfiles.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "../common/fe.h" #include "menu.h" #include "gtkutil.h" diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index 9272c6b3..f89bb650 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -37,12 +37,12 @@ #include #endif -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include "../common/util.h" #include "../common/text.h" #include "../common/cfgfiles.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "../common/plugin.h" #include "../common/server.h" #include "../common/url.h" diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c index 3018667d..eee48b8d 100644 --- a/src/fe-gtk/fkeys.c +++ b/src/fe-gtk/fkeys.c @@ -46,8 +46,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/fe.h" #include "../common/userlist.h" diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c index 58f7b804..8de4325d 100644 --- a/src/fe-gtk/gtkutil.c +++ b/src/fe-gtk/gtkutil.c @@ -46,11 +46,11 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include "../common/util.h" #include "../common/cfgfiles.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "gtkutil.h" #include "pixmaps.h" diff --git a/src/fe-gtk/ignoregui.c b/src/fe-gtk/ignoregui.c index 13cd8f0b..6531bd27 100644 --- a/src/fe-gtk/ignoregui.c +++ b/src/fe-gtk/ignoregui.c @@ -39,7 +39,7 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/ignore.h" #include "../common/cfgfiles.h" #include "../common/fe.h" diff --git a/src/fe-gtk/joind.c b/src/fe-gtk/joind.c index 5c591070..41f3f405 100644 --- a/src/fe-gtk/joind.c +++ b/src/fe-gtk/joind.c @@ -28,8 +28,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/server.h" #include "../common/fe.h" #include "fe-gtk.h" diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index c1b60c27..27f26d2b 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -44,10 +44,10 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include "../common/server.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "../common/outbound.h" #include "../common/inbound.h" #include "../common/plugin.h" diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index bf12f25d..572335ab 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -44,8 +44,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/outbound.h" #include "../common/ignore.h" diff --git a/src/fe-gtk/notifygui.c b/src/fe-gtk/notifygui.c index 679b3f02..7daf2484 100644 --- a/src/fe-gtk/notifygui.c +++ b/src/fe-gtk/notifygui.c @@ -38,7 +38,7 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/notify.h" #include "../common/cfgfiles.h" #include "../common/fe.h" diff --git a/src/fe-gtk/palette.c b/src/fe-gtk/palette.c index 80e0a11d..072646dd 100644 --- a/src/fe-gtk/palette.c +++ b/src/fe-gtk/palette.c @@ -31,7 +31,7 @@ #include "fe-gtk.h" #include "palette.h" -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/util.h" #include "../common/cfgfiles.h" diff --git a/src/fe-gtk/pixmaps.c b/src/fe-gtk/pixmaps.c index 4211c6f5..b7fc40e2 100644 --- a/src/fe-gtk/pixmaps.c +++ b/src/fe-gtk/pixmaps.c @@ -22,7 +22,7 @@ #include "fe-gtk.h" #include "../common/cfgfiles.h" -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include diff --git a/src/fe-gtk/plugin-tray.c b/src/fe-gtk/plugin-tray.c index 922515fe..581e9dfc 100644 --- a/src/fe-gtk/plugin-tray.c +++ b/src/fe-gtk/plugin-tray.c @@ -1,9 +1,9 @@ /* Copyright (C) 2006-2007 Peter Zelezny. */ #include -#include "../common/xchat-plugin.h" -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat-plugin.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/inbound.h" #include "../common/server.h" #include "../common/fe.h" diff --git a/src/fe-gtk/plugingui.c b/src/fe-gtk/plugingui.c index 00566533..401abfbf 100644 --- a/src/fe-gtk/plugingui.c +++ b/src/fe-gtk/plugingui.c @@ -32,15 +32,15 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #define PLUGIN_C typedef struct session xchat_context; -#include "../common/xchat-plugin.h" +#include "../common/hexchat-plugin.h" #include "../common/plugin.h" #include "../common/util.h" #include "../common/outbound.h" #include "../common/fe.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "gtkutil.h" diff --git a/src/fe-gtk/rawlog.c b/src/fe-gtk/rawlog.c index 60b359a0..945facdf 100644 --- a/src/fe-gtk/rawlog.c +++ b/src/fe-gtk/rawlog.c @@ -35,8 +35,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/server.h" #include "gtkutil.h" diff --git a/src/fe-gtk/search.c b/src/fe-gtk/search.c index f90b685d..e0839f79 100644 --- a/src/fe-gtk/search.c +++ b/src/fe-gtk/search.c @@ -34,10 +34,10 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include "../common/util.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "gtkutil.h" #include "xtext.h" #include "maingui.h" diff --git a/src/fe-gtk/servlistgui.c b/src/fe-gtk/servlistgui.c index c0c504f6..fe8aa319 100644 --- a/src/fe-gtk/servlistgui.c +++ b/src/fe-gtk/servlistgui.c @@ -32,8 +32,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/servlist.h" #include "../common/cfgfiles.h" #include "../common/fe.h" diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index 1f940d9f..a83e423a 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -8,13 +8,13 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/cfgfiles.h" #include "../common/fe.h" #include "../common/text.h" #include "../common/userlist.h" #include "../common/util.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "fe-gtk.h" #include "gtkutil.h" #include "maingui.h" diff --git a/src/fe-gtk/sexy-spell-entry.c b/src/fe-gtk/sexy-spell-entry.c index 22404855..190c62e7 100644 --- a/src/fe-gtk/sexy-spell-entry.c +++ b/src/fe-gtk/sexy-spell-entry.c @@ -41,7 +41,7 @@ #endif #include "../common/cfgfiles.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" /* * Bunch of poop to make enchant into a runtime dependency rather than a diff --git a/src/fe-gtk/textgui.c b/src/fe-gtk/textgui.c index 851ad392..7d4c38bd 100644 --- a/src/fe-gtk/textgui.c +++ b/src/fe-gtk/textgui.c @@ -36,8 +36,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/outbound.h" #include "../common/fe.h" diff --git a/src/fe-gtk/urlgrab.c b/src/fe-gtk/urlgrab.c index a5bb4e0a..68d796eb 100644 --- a/src/fe-gtk/urlgrab.c +++ b/src/fe-gtk/urlgrab.c @@ -32,8 +32,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/fe.h" #include "../common/url.h" diff --git a/src/fe-gtk/userlistgui.c b/src/fe-gtk/userlistgui.c index d4834581..e6d57891 100644 --- a/src/fe-gtk/userlistgui.c +++ b/src/fe-gtk/userlistgui.c @@ -34,12 +34,12 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/util.h" #include "../common/userlist.h" #include "../common/modes.h" #include "../common/notify.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "../common/fe.h" #include "gtkutil.h" #include "palette.h" diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c index e45d47f0..656a4c92 100644 --- a/src/fe-gtk/xtext.c +++ b/src/fe-gtk/xtext.c @@ -65,10 +65,10 @@ #include "mmx_cmod.h" #endif -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include "../common/util.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "fe-gtk.h" #include "xtext.h" #include "fkeys.h" diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c index 173ef438..0eb68dce 100644 --- a/src/fe-text/fe-text.c +++ b/src/fe-text/fe-text.c @@ -32,8 +32,8 @@ #include #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/outbound.h" #include "../common/util.h" -- cgit 1.4.1