summary refs log tree commit diff stats
path: root/src/common
diff options
context:
space:
mode:
authorBerke Viktor <berkeviktor@aol.com>2011-12-11 17:34:02 +0100
committerBerke Viktor <berkeviktor@aol.com>2011-12-11 17:34:02 +0100
commit132ef6cb50201cb6ab8ab0609a88ccce62aa6a21 (patch)
tree0d47c10fa3b9789592c6513286d57a0c010b071f /src/common
parent2012320d0eed36e0461e44ac9be8cc162c135bf5 (diff)
initial patches for linux compatibility
Diffstat (limited to 'src/common')
-rw-r--r--src/common/cfgfiles.c20
-rw-r--r--src/common/chanopt.c4
-rw-r--r--src/common/ctcp.c9
-rw-r--r--src/common/dcc.c8
-rw-r--r--src/common/ignore.c4
-rw-r--r--src/common/inbound.c4
-rw-r--r--src/common/makefile.mak1
-rw-r--r--src/common/msproxy.c4
-rw-r--r--src/common/network.c4
-rw-r--r--src/common/notify.c4
-rw-r--r--src/common/outbound.c7
-rw-r--r--src/common/plugin-timer.c2
-rw-r--r--src/common/proto-irc.c4
-rw-r--r--src/common/server.c5
-rw-r--r--src/common/servlist.c4
-rw-r--r--src/common/text.c71
-rw-r--r--src/common/util.c42
-rw-r--r--src/common/util.h2
-rw-r--r--src/common/wdkutil.c27
-rw-r--r--src/common/wdkutil.h2
-rw-r--r--src/common/xchat.c4
-rw-r--r--src/common/xchat.h4
22 files changed, 195 insertions, 41 deletions
diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c
index 22ef00d7..130ad9d9 100644
--- a/src/common/cfgfiles.c
+++ b/src/common/cfgfiles.c
@@ -29,11 +29,12 @@
 #include "fe.h"
 #include "text.h"
 #include "xchatc.h"
-#include "wdkutil.h"
 
 #ifndef WIN32
+#include <unistd.h>
 #define XCHAT_DIR ".xchat2"
 #endif
+
 #define DEF_FONT "Monospace 9"
 
 void
@@ -402,7 +403,9 @@ const struct prefs vars[] = {
 	{"dcc_blocksize", P_OFFINT (dcc_blocksize), TYPE_INT},
 	{"dcc_completed_dir", P_OFFSET (dcc_completed_dir), TYPE_STR},
 	{"dcc_dir", P_OFFSET (dccdir), TYPE_STR},
-	/* {"dcc_fast_send", P_OFFINT (fastdccsend), TYPE_BOOL}, */
+#ifndef WIN32
+	{"dcc_fast_send", P_OFFINT (fastdccsend), TYPE_BOOL},
+#endif
 	{"dcc_global_max_get_cps", P_OFFINT (dcc_global_max_get_cps), TYPE_INT},
 	{"dcc_global_max_send_cps", P_OFFINT (dcc_global_max_send_cps), TYPE_INT},
 	{"dcc_ip", P_OFFSET (dcc_ip_str), TYPE_STR},
@@ -440,7 +443,9 @@ const struct prefs vars[] = {
 	{"gui_lagometer", P_OFFINT (lagometer), TYPE_INT},
 	{"gui_license", P_OFFSET (gui_license), TYPE_STR},
 	{"gui_mode_buttons", P_OFFINT (chanmodebuttons), TYPE_BOOL},
+#ifdef WIN32
 	{"gui_one_instance", P_OFFINT (gui_one_instance), TYPE_BOOL},
+#endif
 	{"gui_pane_left_size", P_OFFINT (gui_pane_left_size), TYPE_INT},
 	{"gui_pane_right_size", P_OFFINT (gui_pane_right_size), TYPE_INT},
 	{"gui_quit_dialog", P_OFFINT (gui_quit_dialog), TYPE_BOOL},
@@ -547,7 +552,9 @@ const struct prefs vars[] = {
 
 	{"tab_chans", P_OFFINT (tabchannels), TYPE_BOOL},
 	{"tab_dialogs", P_OFFINT (privmsgtab), TYPE_BOOL},
+#ifdef WIN32
 	{"tab_icons", P_OFFINT (tab_icons), TYPE_BOOL},
+#endif
 	{"tab_layout", P_OFFINT (tab_layout), TYPE_INT},
 	{"tab_new_to_front", P_OFFINT (newtabstofront), TYPE_INT},
 	{"tab_notices", P_OFFINT (notices_tabs), TYPE_BOOL},
@@ -558,14 +565,18 @@ const struct prefs vars[] = {
 	{"tab_sort", P_OFFINT (tab_sort), TYPE_BOOL},
 	{"tab_trunc", P_OFFINT (truncchans), TYPE_INT},
 	{"tab_utils", P_OFFINT (windows_as_tabs), TYPE_BOOL},
+#ifdef WIN32
 	{"tab_xp", P_OFFINT (tab_xp), TYPE_BOOL},
+#endif
 
 	{"text_auto_copy_color", P_OFFINT (autocopy_color), TYPE_BOOL},	
 	{"text_auto_copy_stamp", P_OFFINT (autocopy_stamp), TYPE_BOOL},
 	{"text_auto_copy_text", P_OFFINT (autocopy_text), TYPE_BOOL},
 	{"text_background", P_OFFSET (background), TYPE_STR},
 	{"text_color_nicks", P_OFFINT (colorednicks), TYPE_BOOL},
+#ifdef WIN32
 	{"text_emoticons", P_OFFINT (emoticons), TYPE_BOOL},
+#endif
 	{"text_font", P_OFFSET (font_normal), TYPE_STR},
 	{"text_indent", P_OFFINT (indent_nicks), TYPE_BOOL},
 	{"text_max_indent", P_OFFINT (max_auto_indent), TYPE_INT},
@@ -642,7 +653,9 @@ load_config (void)
 	prefs.indent_nicks = 1;
 	prefs.thin_separator = 1;
 	prefs._tabs_position = 2; /* 2 = left */
-	/* prefs.fastdccsend = 1; */
+#ifndef WIN32
+	prefs.fastdccsend = 1;
+#endif
 	prefs.wordwrap = 1;
 	prefs.autosave = 1;
 	prefs.autodialog = 1;
@@ -667,7 +680,6 @@ load_config (void)
 	prefs.dialog_height = 256;
 	prefs.gui_join_dialog = 1;
 	prefs.gui_quit_dialog = 1;
-	prefs.slist_skip = 1;
 	prefs.dcctimeout = 180;
 	prefs.dccstalltimeout = 60;
 	prefs.notify_timeout = 15;
diff --git a/src/common/chanopt.c b/src/common/chanopt.c
index ce37157a..f8e16e8b 100644
--- a/src/common/chanopt.c
+++ b/src/common/chanopt.c
@@ -8,6 +8,10 @@
 #include <fcntl.h>
 #include <errno.h>
 
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
 #include "xchat.h"
 
 #include "cfgfiles.h"
diff --git a/src/common/ctcp.c b/src/common/ctcp.c
index 37392372..2bb75746 100644
--- a/src/common/ctcp.c
+++ b/src/common/ctcp.c
@@ -20,6 +20,10 @@
 #include <string.h>
 #include <stdlib.h>
 
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
 #include "xchat.h"
 #include "cfgfiles.h"
 #include "util.h"
@@ -133,8 +137,13 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip,
 
 	if (!strcasecmp (msg, "VERSION") && !prefs.hidever)
 	{
+#ifdef WIN32
 		snprintf (outbuf, sizeof (outbuf), "VERSION XChat-WDK "PACKAGE_VERSION" [x%d] / %s",
 					 get_cpu_arch (), get_cpu_str ());
+#else
+		snprintf (outbuf, sizeof (outbuf), "VERSION XChat-WDK "PACKAGE_VERSION" %s",
+					 get_cpu_str ());
+#endif
 		serv->p_nctcp (serv, nick, outbuf);
 	}
 
diff --git a/src/common/dcc.c b/src/common/dcc.c
index 9375095e..d91b7e8e 100644
--- a/src/common/dcc.c
+++ b/src/common/dcc.c
@@ -40,6 +40,8 @@
 
 #ifdef WIN32
 #include <windows.h>
+#else
+#include <unistd.h>
 #endif
 
 #include "xchat.h"
@@ -56,7 +58,9 @@
 
 #ifdef USE_DCC64
 #define BIG_STR_TO_INT(x) strtoull(x,NULL,10)
+#ifdef WIN32
 #define stat _stat64
+#endif
 #else
 #define BIG_STR_TO_INT(x) strtoul(x,NULL,10)
 #endif
@@ -1983,7 +1987,9 @@ is_same_file (struct DCC *dcc, struct DCC *new_dcc)
 		return TRUE;
 
 	/* now handle case-insensitive Filesystems: HFS+, FAT */
-#ifndef WIN32
+#ifdef WIN32
+	/* warning no win32 implementation - behaviour may be unreliable */
+#else
 	/* this fstat() shouldn't really fail */
 	if ((dcc->fp == -1 ? stat (dcc->destfile_fs, &st_a) : fstat (dcc->fp, &st_a)) == -1)
 		return FALSE;
diff --git a/src/common/ignore.c b/src/common/ignore.c
index adb61f37..0ed23daa 100644
--- a/src/common/ignore.c
+++ b/src/common/ignore.c
@@ -23,6 +23,10 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
 #include "xchat.h"
 #include "ignore.h"
 #include "cfgfiles.h"
diff --git a/src/common/inbound.c b/src/common/inbound.c
index 3485dfd4..bd7252c5 100644
--- a/src/common/inbound.c
+++ b/src/common/inbound.c
@@ -23,6 +23,10 @@
 #include <sys/types.h>
 #include <time.h>
 
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
 #define WANTARPA
 #define WANTDNS
 #include "inet.h"
diff --git a/src/common/makefile.mak b/src/common/makefile.mak
index 424316c0..8b350efc 100644
--- a/src/common/makefile.mak
+++ b/src/common/makefile.mak
@@ -25,7 +25,6 @@ tree.obj \
 url.obj \
 userlist.obj \
 util.obj \
-wdkutil.obj \
 xchat.obj
 
 all: $(COMMON_OBJECTS) xchatcommon.lib dirent.lib
diff --git a/src/common/msproxy.c b/src/common/msproxy.c
index 8ad37ffc..5103233a 100644
--- a/src/common/msproxy.c
+++ b/src/common/msproxy.c
@@ -28,6 +28,10 @@
 #include <stdlib.h>
 #include <fcntl.h>
 
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
 #define WANTSOCKET
 #define WANTARPA
 #include "inet.h"
diff --git a/src/common/network.c b/src/common/network.c
index b7d9aa1f..eba24b05 100644
--- a/src/common/network.c
+++ b/src/common/network.c
@@ -23,6 +23,10 @@
 #include <stdio.h>
 #include <glib.h>
 
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
 #include "../../config.h"				  /* grab USE_IPV6 and LOOKUPD defines */
 
 #define WANTSOCKET
diff --git a/src/common/notify.c b/src/common/notify.c
index 4aa5ea17..9c6e54de 100644
--- a/src/common/notify.c
+++ b/src/common/notify.c
@@ -24,6 +24,10 @@
 #include <fcntl.h>
 #include <time.h>
 
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
 #include "xchat.h"
 #include "notify.h"
 #include "cfgfiles.h"
diff --git a/src/common/outbound.c b/src/common/outbound.c
index 917562b9..8b0432ec 100644
--- a/src/common/outbound.c
+++ b/src/common/outbound.c
@@ -30,6 +30,7 @@
 
 #ifndef WIN32
 #include <sys/wait.h>
+#include <unistd.h>
 #endif
 
 #include <time.h>
@@ -2880,6 +2881,7 @@ cmd_recv (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 	return FALSE;
 }
 
+#if 0 /* manual command for flushing prefs to disk, but we use an autosave-upon-set approach instead */
 static int
 cmd_saveconf (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 {
@@ -2894,6 +2896,7 @@ cmd_saveconf (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 
 	return TRUE;
 }
+#endif
 
 static int
 cmd_say (struct session *sess, char *tbuf, char *word[], char *word_eol[])
@@ -3647,7 +3650,9 @@ const struct commands xc_cmds[] = {
 #endif
 	{"RECV", cmd_recv, 1, 0, 1, N_("RECV <text>, send raw data to xchat, as if it was received from the irc server")},
 
-	/*{"SAVECONF", cmd_saveconf, 0, 0, 1, N_("SAVECONF, saves the current settings to disk")},*/
+#if 0
+	{"SAVECONF", cmd_saveconf, 0, 0, 1, N_("SAVECONF, saves the current settings to disk")},
+#endif
 	{"SAY", cmd_say, 0, 0, 1,
 	 N_("SAY <text>, sends the text to the object in the current window")},
 	{"SEND", cmd_send, 0, 0, 1, N_("SEND <nick> [<file>]")},
diff --git a/src/common/plugin-timer.c b/src/common/plugin-timer.c
index 2524439d..f09074a8 100644
--- a/src/common/plugin-timer.c
+++ b/src/common/plugin-timer.c
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <glib.h>
-#include "../../plugins/xchat-plugin.h"
+#include "xchat-plugin.h"
 
 #ifdef WIN32
 #define strcasecmp stricmp
diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c
index 3d45e1b0..91a57abe 100644
--- a/src/common/proto-irc.c
+++ b/src/common/proto-irc.c
@@ -24,6 +24,10 @@
 #include <ctype.h>
 #include <stdarg.h>
 
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
 #include "xchat.h"
 #include "ctcp.h"
 #include "fe.h"
diff --git a/src/common/server.c b/src/common/server.c
index f7347052..cdd67cda 100644
--- a/src/common/server.c
+++ b/src/common/server.c
@@ -36,6 +36,7 @@
 #ifndef WIN32
 #include <signal.h>
 #include <sys/wait.h>
+#include <unistd.h>
 #else
 #include <winbase.h>
 #endif
@@ -1763,7 +1764,11 @@ server_connect (server *serv, char *hostname, int port, int no_login)
 	}
 #endif
 	serv->childpid = pid;
+#ifdef WIN32
 	serv->iotag = fe_input_add (serv->childread, FIA_READ|FIA_FD, server_read_child,
+#else
+	serv->iotag = fe_input_add (serv->childread, FIA_READ, server_read_child,
+#endif
 										 serv);
 }
 
diff --git a/src/common/servlist.c b/src/common/servlist.c
index 1ca63201..a94c260a 100644
--- a/src/common/servlist.c
+++ b/src/common/servlist.c
@@ -22,6 +22,10 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
 #include "xchat.h"
 #include <glib/ghash.h>
 
diff --git a/src/common/text.c b/src/common/text.c
index fcde5870..fd5d25e9 100644
--- a/src/common/text.c
+++ b/src/common/text.c
@@ -25,6 +25,11 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 
+#ifndef WIN32
+#include <unistd.h>
+#include <sys/mman.h>
+#endif
+
 #include "xchat.h"
 #include <glib/ghash.h>
 #include "cfgfiles.h"
@@ -270,6 +275,12 @@ scrollback_load (session *sess)
 	time_t stamp;
 	int lines;
 
+#ifndef WIN32
+	char *map, *end_map;
+	struct stat statbuf;
+	const char *begin, *eol;
+#endif
+
 	if (sess->text_scrollback == SET_DEFAULT)
 	{
 		if (!prefs.text_replay)
@@ -288,6 +299,65 @@ scrollback_load (session *sess)
 	if (fh == -1)
 		return;
 
+#ifndef WIN32
+	if (fstat (fh, &statbuf) < 0)
+		return;
+
+	map = mmap (NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, fh, 0);
+	if (map == MAP_FAILED)
+		return;
+
+	end_map = map + statbuf.st_size;
+
+	lines = 0;
+	begin = map;
+	while (begin < end_map)
+	{
+		int n_bytes;
+
+		eol = memchr (begin, '\n', end_map - begin);
+
+		if (!eol)
+			eol = end_map;
+
+		n_bytes = MIN (eol - begin, sizeof (buf) - 1);
+
+		strncpy (buf, begin, n_bytes);
+
+		buf[n_bytes] = 0;
+
+		if (buf[0] == 'T')
+		{
+			if (sizeof (time_t) == 4)
+				stamp = strtoul (buf + 2, NULL, 10);
+			else
+				stamp = strtoull (buf + 2, NULL, 10); /* just incase time_t is 64 bits */
+			text = strchr (buf + 3, ' ');
+			if (text)
+			{
+				text = strip_color (text + 1, -1, STRIP_COLOR);
+				fe_print_text (sess, text, stamp);
+				g_free (text);
+			}
+			lines++;
+		}
+
+		begin = eol + 1;
+	}
+
+	sess->scrollwritten = lines;
+
+	if (lines)
+	{
+		text = ctime (&stamp);
+		text[24] = 0;	/* get rid of the \n */
+		snprintf (buf, sizeof (buf), "\n*\t%s %s\n\n", _("Loaded log from"), text);
+		fe_print_text (sess, buf, 0);
+		/*EMIT_SIGNAL (XP_TE_GENMSG, sess, "*", buf, NULL, NULL, NULL, 0);*/
+	}
+
+	munmap (map, statbuf.st_size);
+#else
 	lines = 0;
 	while (waitline (fh, buf, sizeof buf, FALSE) != -1)
 	{
@@ -318,6 +388,7 @@ scrollback_load (session *sess)
 		fe_print_text (sess, buf, 0);
 		/*EMIT_SIGNAL (XP_TE_GENMSG, sess, "*", buf, NULL, NULL, NULL, 0);*/
 	}
+#endif
 
 	close (fh);
 }
diff --git a/src/common/util.c b/src/common/util.c
index c16d41f5..ccc48657 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -27,17 +27,21 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+
 #ifdef WIN32
 #include <sys/timeb.h>
 #include <process.h>
+#include <io.h>
+#include "dirent.h"
 #else
-#include <sys/types.h>
+#include <unistd.h>
 #include <pwd.h>
 #include <sys/time.h>
 #include <sys/utsname.h>
+#include <dirent.h>
 #endif
+
 #include <fcntl.h>
-#include "dirent.h"
 #include <errno.h>
 #include "xchat.h"
 #include "xchatc.h"
@@ -1848,3 +1852,37 @@ canonalize_key (char *key)
 		}
 	}
 }
+
+int
+portable_mode ()
+{
+#ifdef WIN32
+	if ((_access( "portable-mode", 0 )) != -1)
+	{
+		return 1;
+	}
+	else
+	{
+		return 0;
+	}
+#else
+	return 0;
+#endif
+}
+
+int
+xtray_mode ()
+{
+#ifdef WIN32
+	if ((_access( "plugins/xtray.dll", 0 )) != -1)
+	{
+		return 1;
+	}
+	else
+	{
+		return 0;
+	}
+#else
+	return 0;
+#endif
+}
diff --git a/src/common/util.h b/src/common/util.h
index bee6ec3c..82d74366 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -57,5 +57,7 @@ guint32 str_hash (const char *key);
 guint32 str_ihash (const unsigned char *key);
 void safe_strcpy (char *dest, const char *src, int bytes_left);
 void canonalize_key (char *key);
+int portable_mode ();
+int xtray_mode ();
 
 #endif
diff --git a/src/common/wdkutil.c b/src/common/wdkutil.c
deleted file mode 100644
index 5bf4f0c0..00000000
--- a/src/common/wdkutil.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <io.h>
-
-int
-portable_mode ()
-{
-	if ((_access( "portable-mode", 0 )) != -1)
-	{
-		return 1;
-	}
-	else
-	{
-		return 0;
-	}
-}
-
-int
-xtray_mode ()
-{
-	if ((_access( "plugins/xtray.dll", 0 )) != -1)
-	{
-		return 1;
-	}
-	else
-	{
-		return 0;
-	}
-}
diff --git a/src/common/wdkutil.h b/src/common/wdkutil.h
deleted file mode 100644
index 2e4c693a..00000000
--- a/src/common/wdkutil.h
+++ /dev/null
@@ -1,2 +0,0 @@
-int portable_mode ();
-int xtray_mode ();
diff --git a/src/common/xchat.c b/src/common/xchat.c
index c0847a32..22c4eddb 100644
--- a/src/common/xchat.c
+++ b/src/common/xchat.c
@@ -31,6 +31,7 @@
 #else
 #include <sys/wait.h>
 #include <signal.h>
+#include <unistd.h>
 #endif
 
 #include "xchat.h"
@@ -39,7 +40,7 @@
 #include "cfgfiles.h"
 #include "chanopt.h"
 #include "ignore.h"
-#include "../../plugins/xchat-plugin.h"
+#include "xchat-plugin.h"
 #include "plugin.h"
 #include "plugin-timer.h"
 #include "notify.h"
@@ -49,7 +50,6 @@
 #include "text.h"
 #include "url.h"
 #include "xchatc.h"
-#include "wdkutil.h"
 
 #ifdef USE_OPENSSL
 #include <openssl/ssl.h>		  /* SSL_() */
diff --git a/src/common/xchat.h b/src/common/xchat.h
index 08177e20..91e2d50e 100644
--- a/src/common/xchat.h
+++ b/src/common/xchat.h
@@ -186,7 +186,9 @@ struct xchatprefs
 	int gui_usermenu;
 	int gui_join_dialog;
 	int gui_quit_dialog;
+#ifdef WIN32
 	int gui_one_instance;
+#endif
 	int dialog_left;
 	int dialog_top;
 	int dialog_width;
@@ -304,10 +306,12 @@ struct xchatprefs
 	unsigned int wait_on_exit;
 	unsigned int confmode;
 	unsigned int utf8_locale;
+#ifdef WIN32
 	unsigned int identd;
 	unsigned int emoticons;
 	unsigned int tab_icons;
 	unsigned int tab_xp;
+#endif
 
 	unsigned int ctcp_number_limit;	/*flood */
 	unsigned int ctcp_time_limit;	/*seconds of floods */