summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common.h3
-rw-r--r--src/core/core.c6
-rw-r--r--src/core/misc.c4
-rw-r--r--src/core/net-disconnect.c2
-rw-r--r--src/core/net-nonblock.c10
-rw-r--r--src/core/net-sendbuffer.c4
-rw-r--r--src/core/network.c16
-rw-r--r--src/core/network.h2
-rw-r--r--src/fe-common/core/fe-common-core.c4
-rw-r--r--src/fe-common/core/printtext.c12
-rw-r--r--src/fe-common/core/printtext.h1
-rw-r--r--src/fe-common/irc/Makefile.am1
-rw-r--r--src/fe-text/gui-entry.c32
-rw-r--r--src/fe-text/gui-printtext.c10
-rw-r--r--src/fe-text/gui-printtext.h1
-rw-r--r--src/fe-text/irssi.c17
-rw-r--r--src/perl/irc/Irc.xs1
-rw-r--r--src/perl/perl-common.c6
-rw-r--r--src/perl/ui/UI.xs17
19 files changed, 77 insertions, 72 deletions
diff --git a/src/common.h b/src/common.h
index 86a079fe..0cf951b3 100644
--- a/src/common.h
+++ b/src/common.h
@@ -34,9 +34,6 @@
# include <dirent.h>
#endif
#include <fcntl.h>
-#ifdef WIN32
-# include <win32-compat.h>
-#endif
#include <glib.h>
#ifdef HAVE_GMODULE
diff --git a/src/core/core.c b/src/core/core.c
index bbeec6f4..bf7cdd6b 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -83,7 +83,6 @@ static void sig_reload_config(int signo)
static void read_settings(void)
{
-#ifndef WIN32
static int signals[] = {
SIGINT, SIGQUIT, SIGTERM,
SIGALRM, SIGUSR1, SIGUSR2
@@ -124,7 +123,6 @@ static void read_settings(void)
settings_set_bool("override_coredump_limit", FALSE);
}
#endif
-#endif
}
static void sig_gui_dialog(const char *type, const char *text)
@@ -225,9 +223,7 @@ void core_init(void)
client_start_time = time(NULL);
modules_init();
-#ifndef WIN32
pidwait_init();
-#endif
net_disconnect_init();
signals_init();
@@ -303,9 +299,7 @@ void core_deinit(void)
signals_deinit();
net_disconnect_deinit();
-#ifndef WIN32
pidwait_deinit();
-#endif
modules_deinit();
g_free(irssi_dir);
diff --git a/src/core/misc.c b/src/core/misc.c
index 490b5a8f..aaa470f5 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -430,11 +430,7 @@ int mkpath(const char *path, int mode)
dir = g_strndup(path, (int) (p-path));
if (stat(dir, &statbuf) != 0) {
-#ifndef WIN32
if (mkdir(dir, mode) == -1)
-#else
- if (_mkdir(dir) == -1)
-#endif
{
g_free(dir);
return -1;
diff --git a/src/core/net-disconnect.c b/src/core/net-disconnect.c
index 321f79ac..6476e776 100644
--- a/src/core/net-disconnect.c
+++ b/src/core/net-disconnect.c
@@ -116,7 +116,6 @@ void net_disconnect_init(void)
void net_disconnect_deinit(void)
{
-#ifndef WIN32
NET_DISCONNECT_REC *rec;
time_t now, max;
int first, fd;
@@ -155,5 +154,4 @@ void net_disconnect_deinit(void)
first = 0;
}
}
-#endif
}
diff --git a/src/core/net-nonblock.c b/src/core/net-nonblock.c
index e637e673..d6e767b6 100644
--- a/src/core/net-nonblock.c
+++ b/src/core/net-nonblock.c
@@ -77,14 +77,11 @@ int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
{
RESOLVED_IP_REC rec;
const char *errorstr;
-#ifndef WIN32
int pid;
-#endif
int len;
g_return_val_if_fail(addr != NULL, FALSE);
-#ifndef WIN32
pid = fork();
if (pid > 0) {
/* parent */
@@ -97,7 +94,6 @@ int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
g_warning("net_connect_thread(): fork() failed! "
"Using blocking resolving");
}
-#endif
/* child */
srand(time(NULL));
@@ -138,10 +134,8 @@ int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
}
}
-#ifndef WIN32
if (pid == 0)
_exit(99);
-#endif
/* we used blocking lookup */
return 0;
@@ -157,9 +151,7 @@ int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec)
rec->host4 = NULL;
rec->host6 = NULL;
-#ifndef WIN32
fcntl(g_io_channel_unix_get_fd(pipe), F_SETFL, O_NONBLOCK);
-#endif
/* get ip+error */
if (g_io_channel_read_block(pipe, rec, sizeof(*rec)) == -1) {
@@ -201,9 +193,7 @@ void net_disconnect_nonblock(int pid)
{
g_return_if_fail(pid > 0);
-#ifndef WIN32
kill(pid, SIGKILL);
-#endif
}
static void simple_init(SIMPLE_THREAD_REC *rec, GIOChannel *handle)
diff --git a/src/core/net-sendbuffer.c b/src/core/net-sendbuffer.c
index 39257486..97fb551f 100644
--- a/src/core/net-sendbuffer.c
+++ b/src/core/net-sendbuffer.c
@@ -160,13 +160,9 @@ void net_sendbuffer_flush(NET_SENDBUF_REC *rec)
/* set the socket blocking while doing this */
handle = g_io_channel_unix_get_fd(rec->handle);
-#ifndef WIN32
fcntl(handle, F_SETFL, 0);
-#endif
while (!buffer_send(rec)) ;
-#ifndef WIN32
fcntl(handle, F_SETFL, O_NONBLOCK);
-#endif
}
/* Returns the socket handle */
diff --git a/src/core/network.c b/src/core/network.c
index bfaa47fb..0751aa95 100644
--- a/src/core/network.c
+++ b/src/core/network.c
@@ -45,11 +45,7 @@ union sockaddr_union {
GIOChannel *g_io_channel_new(int handle)
{
GIOChannel *chan;
-#ifdef WIN32
- chan = g_io_channel_win32_new_socket(handle);
-#else
chan = g_io_channel_unix_new(handle);
-#endif
g_io_channel_set_encoding(chan, NULL, NULL);
g_io_channel_set_buffered(chan, FALSE);
return chan;
@@ -188,9 +184,7 @@ GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip)
return NULL;
/* set socket options */
-#ifndef WIN32
fcntl(handle, F_SETFL, O_NONBLOCK);
-#endif
setsockopt(handle, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE, &opt, sizeof(opt));
@@ -211,11 +205,7 @@ GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip)
sin_set_port(&so, port);
ret = connect(handle, &so.sa, SIZEOF_SOCKADDR(so));
-#ifndef WIN32
if (ret < 0 && errno != EINPROGRESS)
-#else
- if (ret < 0 && WSAGetLastError() != WSAEWOULDBLOCK)
-#endif
{
int old_errno = errno;
close(handle);
@@ -238,9 +228,7 @@ GIOChannel *net_connect_unix(const char *path)
return NULL;
/* set socket options */
-#ifndef WIN32
fcntl(handle, F_SETFL, O_NONBLOCK);
-#endif
/* connect */
memset(&sa, 0, sizeof(sa));
@@ -297,9 +285,7 @@ GIOChannel *net_listen(IPADDR *my_ip, int *port)
return NULL;
/* set socket options */
-#ifndef WIN32
fcntl(handle, F_SETFL, O_NONBLOCK);
-#endif
setsockopt(handle, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE, &opt, sizeof(opt));
@@ -342,9 +328,7 @@ GIOChannel *net_accept(GIOChannel *handle, IPADDR *addr, int *port)
if (addr != NULL) sin_get_ip(&so, addr);
if (port != NULL) *port = sin_get_port(&so);
-#ifndef WIN32
fcntl(ret, F_SETFL, O_NONBLOCK);
-#endif
return g_io_channel_new(ret);
}
diff --git a/src/core/network.h b/src/core/network.h
index fa7e9675..73ac8dee 100644
--- a/src/core/network.h
+++ b/src/core/network.h
@@ -6,12 +6,10 @@
#endif
#include <sys/types.h>
-#ifndef WIN32
# include <sys/socket.h>
# include <netinet/in.h>
# include <netdb.h>
# include <arpa/inet.h>
-#endif
#ifndef AF_INET6
# ifdef PF_INET6
diff --git a/src/fe-common/core/fe-common-core.c b/src/fe-common/core/fe-common-core.c
index a15850e2..ee7f9424 100644
--- a/src/fe-common/core/fe-common-core.c
+++ b/src/fe-common/core/fe-common-core.c
@@ -168,9 +168,7 @@ void fe_common_core_init(void)
keyboard_init();
printtext_init();
formats_init();
-#ifndef WIN32
fe_exec_init();
-#endif
fe_expandos_init();
fe_help_init();
fe_ignore_init();
@@ -211,9 +209,7 @@ void fe_common_core_deinit(void)
keyboard_deinit();
printtext_deinit();
formats_deinit();
-#ifndef WIN32
fe_exec_deinit();
-#endif
fe_expandos_deinit();
fe_help_deinit();
fe_ignore_deinit();
diff --git a/src/fe-common/core/printtext.c b/src/fe-common/core/printtext.c
index 466a2825..ba6f3242 100644
--- a/src/fe-common/core/printtext.c
+++ b/src/fe-common/core/printtext.c
@@ -413,6 +413,18 @@ void printtext_gui(const char *text)
g_free(str);
}
+/* Like printtext_gui(), but don't expand % codes. */
+void printtext_gui_internal(const char *str)
+{
+ TEXT_DEST_REC dest;
+
+ g_return_if_fail(str != NULL);
+
+ memset(&dest, 0, sizeof(dest));
+
+ format_send_to_gui(&dest, str);
+}
+
static void msg_beep_check(TEXT_DEST_REC *dest)
{
if (dest->level != 0 && (dest->level & MSGLEVEL_NO_ACT) == 0 &&
diff --git a/src/fe-common/core/printtext.h b/src/fe-common/core/printtext.h
index 66ba28f4..ab8dfac1 100644
--- a/src/fe-common/core/printtext.h
+++ b/src/fe-common/core/printtext.h
@@ -23,6 +23,7 @@ void printtext_dest(TEXT_DEST_REC *dest, const char *text, ...);
/* only GUI should call these - used for printing text to somewhere else
than windows */
void printtext_gui(const char *text);
+void printtext_gui_internal(const char *str);
void printformat_module_gui(const char *module, int formatnum, ...);
void printformat_module_gui_args(const char *module, int formatnum, va_list va);
diff --git a/src/fe-common/irc/Makefile.am b/src/fe-common/irc/Makefile.am
index a5dd4c77..bf88f5cd 100644
--- a/src/fe-common/irc/Makefile.am
+++ b/src/fe-common/irc/Makefile.am
@@ -37,6 +37,7 @@ libfe_common_irc_a_SOURCES = \
pkginc_fe_common_ircdir=$(pkgincludedir)/src/fe-common/irc
pkginc_fe_common_irc_HEADERS = \
fe-irc-server.h \
+ fe-irc-channels.h \
module.h \
module-formats.h
diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c
index c7d06404..306141ec 100644
--- a/src/fe-text/gui-entry.c
+++ b/src/fe-text/gui-entry.c
@@ -26,6 +26,7 @@
#include "gui-entry.h"
#include "gui-printtext.h"
#include "term.h"
+#include "recode.h"
#undef i_toupper
#undef i_tolower
@@ -345,6 +346,33 @@ void gui_entry_set_active(GUI_ENTRY_REC *entry)
}
}
+/* Return screen length of plain string */
+static int scrlen_str(const char *str)
+{
+ int len = 0;
+ char *stripped;
+ g_return_val_if_fail(str != NULL, 0);
+
+ str = stripped = strip_codes(str);
+ if (is_utf8() && g_utf8_validate(str, -1, NULL)) {
+
+ while (*str != '\0') {
+ gunichar c;
+
+ c = g_utf8_get_char(str);
+ str = g_utf8_next_char(str);
+
+ len += unichar_isprint(c) ? mk_wcwidth(c) : 1;
+ }
+
+ } else {
+ len = strlen(str);
+ }
+
+ g_free(stripped);
+ return len;
+}
+
void gui_entry_set_prompt(GUI_ENTRY_REC *entry, const char *str)
{
int oldlen;
@@ -355,11 +383,11 @@ void gui_entry_set_prompt(GUI_ENTRY_REC *entry, const char *str)
if (str != NULL) {
g_free_not_null(entry->prompt);
entry->prompt = g_strdup(str);
- entry->promptlen = format_get_length(str);
+ entry->promptlen = scrlen_str(str);
}
if (entry->prompt != NULL)
- gui_printtext(entry->xpos, entry->ypos, entry->prompt);
+ gui_printtext_internal(entry->xpos, entry->ypos, entry->prompt);
if (entry->promptlen != oldlen) {
gui_entry_fix_cursor(entry);
diff --git a/src/fe-text/gui-printtext.c b/src/fe-text/gui-printtext.c
index d8272df5..775e6044 100644
--- a/src/fe-text/gui-printtext.c
+++ b/src/fe-text/gui-printtext.c
@@ -109,6 +109,16 @@ void gui_printtext(int xpos, int ypos, const char *str)
next_xpos = next_ypos = -1;
}
+void gui_printtext_internal(int xpos, int ypos, const char *str)
+{
+ next_xpos = xpos;
+ next_ypos = ypos;
+
+ printtext_gui_internal(str);
+
+ next_xpos = next_ypos = -1;
+}
+
void gui_printtext_after_time(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str, time_t time)
{
GUI_WINDOW_REC *gui;
diff --git a/src/fe-text/gui-printtext.h b/src/fe-text/gui-printtext.h
index 33b7ce6f..d2671497 100644
--- a/src/fe-text/gui-printtext.h
+++ b/src/fe-text/gui-printtext.h
@@ -17,6 +17,7 @@ void gui_set_default_indent(const char *name);
INDENT_FUNC get_default_indent_func(void);
void gui_printtext(int xpos, int ypos, const char *str);
+void gui_printtext_internal(int xpos, int ypos, const char *str);
void gui_printtext_after(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str);
void gui_printtext_after_time(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str, time_t time);
diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c
index b1fa5e22..cad271c9 100644
--- a/src/fe-text/irssi.c
+++ b/src/fe-text/irssi.c
@@ -271,20 +271,6 @@ static void check_files(void)
}
}
-#ifdef WIN32
-static void winsock_init(void)
-{
- WORD wVersionRequested;
- WSADATA wsaData;
-
- wVersionRequested = MAKEWORD(2, 2);
-
- if (WSAStartup(wVersionRequested, &wsaData) != 0) {
- printf("Error initializing winsock\n");
- exit(1);
- }
-}
-#endif
int main(int argc, char **argv)
{
@@ -315,9 +301,6 @@ int main(int argc, char **argv)
check_files();
-#ifdef WIN32
- winsock_init();
-#endif
#ifdef HAVE_SOCKS
SOCKSinit(argv[0]);
#endif
diff --git a/src/perl/irc/Irc.xs b/src/perl/irc/Irc.xs
index a245206c..db5c5f79 100644
--- a/src/perl/irc/Irc.xs
+++ b/src/perl/irc/Irc.xs
@@ -11,6 +11,7 @@ static void perl_irc_connect_fill_hash(HV *hv, IRC_SERVER_CONNECT_REC *conn)
static void perl_irc_server_fill_hash(HV *hv, IRC_SERVER_REC *server)
{
+ perl_irc_connect_fill_hash(hv, server->connrec);
perl_server_fill_hash(hv, (SERVER_REC *) server);
(void) hv_store(hv, "real_address", 12, new_pv(server->real_address), 0);
diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c
index dcda3bb5..d7a428e5 100644
--- a/src/perl/perl-common.c
+++ b/src/perl/perl-common.c
@@ -351,10 +351,12 @@ void perl_window_item_fill_hash(HV *hv, WI_ITEM_REC *item)
g_return_if_fail(item != NULL);
type = (char *) module_find_id_str("WINDOW ITEM TYPE", item->type);
- chat_type = (char *) chat_protocol_find_id(item->chat_type)->name;
(void) hv_store(hv, "type", 4, new_pv(type), 0);
- (void) hv_store(hv, "chat_type", 9, new_pv(chat_type), 0);
+ if (item->chat_type) {
+ chat_type = (char *) chat_protocol_find_id(item->chat_type)->name;
+ (void) hv_store(hv, "chat_type", 9, new_pv(chat_type), 0);
+ }
if (item->server != NULL) {
(void) hv_store(hv, "server", 6, iobject_bless(item->server), 0);
diff --git a/src/perl/ui/UI.xs b/src/perl/ui/UI.xs
index 9db57e98..5ac3da4e 100644
--- a/src/perl/ui/UI.xs
+++ b/src/perl/ui/UI.xs
@@ -64,6 +64,19 @@ static void perl_text_dest_fill_hash(HV *hv, TEXT_DEST_REC *dest)
(void) hv_store(hv, "hilight_color", 13, new_pv(dest->hilight_color), 0);
}
+static void perl_exec_fill_hash(HV *hv, EXEC_WI_REC *item)
+{
+ g_return_if_fail(hv != NULL);
+ g_return_if_fail(item != NULL);
+
+ perl_window_item_fill_hash(hv, (WI_ITEM_REC *) item);
+ /* we don't bless to Process here to avoid infinite recursion
+ in the simplistic script binding */
+ if (item->process != NULL) {
+ (void) hv_store(hv, "process_id", 10, newSViv(item->process->id), 0);
+ }
+}
+
static PLAIN_OBJECT_INIT_REC fe_plains[] = {
{ "Irssi::UI::Process", (PERL_OBJECT_FUNC) perl_process_fill_hash },
{ "Irssi::UI::Window", (PERL_OBJECT_FUNC) perl_window_fill_hash },
@@ -94,6 +107,10 @@ CODE:
initialized = TRUE;
irssi_add_plains(fe_plains);
+ /* window items: fe-exec */
+ irssi_add_object(module_get_uniq_id_str("WINDOW ITEM TYPE", "EXEC"),
+ 0, "Irssi::UI::Exec",
+ (PERL_OBJECT_FUNC) perl_exec_fill_hash);
perl_themes_init();
void