summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Make_bc5.mak31
-rw-r--r--src/Make_cyg_ming.mak26
-rw-r--r--src/Make_mvc.mak37
-rwxr-xr-xsrc/auto/configure44
-rw-r--r--src/channel.c187
-rw-r--r--src/config.aap.in2
-rw-r--r--src/config.h.in3
-rw-r--r--src/config.mk.in2
-rw-r--r--src/configure.in33
-rw-r--r--src/eval.c3
-rw-r--r--src/feature.h8
-rw-r--r--src/gui_w32.c6
-rw-r--r--src/macros.h2
-rw-r--r--src/netbeans.c30
-rw-r--r--src/os_mswin.c2
-rw-r--r--src/os_unix.c45
-rw-r--r--src/proto.h3
-rw-r--r--src/proto/channel.pro8
-rw-r--r--src/proto/netbeans.pro1
-rw-r--r--src/ui.c2
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h18
22 files changed, 410 insertions, 85 deletions
diff --git a/src/Make_bc5.mak b/src/Make_bc5.mak
index 8dcb6e8b4..cb48ce05a 100644
--- a/src/Make_bc5.mak
+++ b/src/Make_bc5.mak
@@ -86,9 +86,12 @@
# (BIG for WIN32, SMALL for DOS16)
# WINVER 0x0400 or 0x0500: minimum Win32 version to support (0x0400)
# CSCOPE no or yes: include support for Cscope interface (yes)
-# NETBEANS no or yes: include support for Netbeans interface (yes if GUI
+# NETBEANS no or yes: include support for Netbeans interface; also
+# requires CHANNEL (yes if GUI
# is yes)
# NBDEBUG no or yes: include support for debugging Netbeans interface (no)
+# CHANNEL no or yes: include support for inter process communication (yes
+# if GUI is yes)
# XPM define to path to XPM dir to get support for loading XPM images.
### BOR: root of the BC installation
@@ -137,6 +140,11 @@ CSCOPE = yes
NETBEANS = yes
!endif
+### CHANNEL: yes to enable inter process communication, no to disable it
+!if ("$(CHANNEL)"=="") && ("$(GUI)"=="yes")
+CHANNEL = yes
+!endif
+
### LUA: uncomment this line if you want lua support in vim
# LUA=c:\lua
@@ -466,6 +474,7 @@ LINK2 = -aa
RESFILE = vim.res
!else
!undef NETBEANS
+!undef CHANNEL
!undef XPM
!undef VIMDLL
!if ("$(DEBUG)"=="yes")
@@ -488,12 +497,21 @@ RESFILE = vim.res
!endif
!if ("$(NETBEANS)"=="yes")
+!if ("$(CHANNEL)"!="yes")
+# cannot use Netbeans without CHANNEL
+NETBEANS = no
+!else
DEFINES = $(DEFINES) -DFEAT_NETBEANS_INTG
!if ("$(NBDEBUG)"=="yes")
DEFINES = $(DEFINES) -DNBDEBUG
NBDEBUG_DEP = nbdebug.h nbdebug.c
!endif
!endif
+!endif
+
+!if ("$(CHANNEL)"=="yes")
+DEFINES = $(DEFINES) -DFEAT_CHANNEL
+!endif
!ifdef XPM
!if ("$(GUI)"=="yes")
@@ -673,6 +691,11 @@ vimobj = $(vimobj) \
$(OBJDIR)\netbeans.obj
!endif
+!if ("$(CHANNEL)"=="yes")
+vimobj = $(vimobj) \
+ $(OBJDIR)\channel.obj
+!endif
+
!ifdef XPM
vimobj = $(vimobj) \
$(OBJDIR)\xpm_w32.obj
@@ -748,6 +771,9 @@ MSG = $(MSG) CSCOPE
!if ("$(NETBEANS)"=="yes")
MSG = $(MSG) NETBEANS
!endif
+!if ("$(CHANNEL)"=="yes")
+MSG = $(MSG) CHANNEL
+!endif
!ifdef XPM
MSG = $(MSG) XPM
!endif
@@ -1029,6 +1055,9 @@ $(OBJDIR)\xpm_w32.obj: xpm_w32.c xpm.lib
$(OBJDIR)\netbeans.obj: netbeans.c $(NBDEBUG_DEP)
$(CC) $(CCARG) $(CC1) $(CC2)$@ netbeans.c
+$(OBJDIR)\channel.obj: channel.c
+ $(CC) $(CCARG) $(CC1) $(CC2)$@ channel.c
+
$(OBJDIR)\vim.res: vim.rc version.h tools.bmp tearoff.bmp \
vim.ico vim_error.ico vim_alert.ico vim_info.ico vim_quest.ico
$(BRC) -fo$(OBJDIR)\vim.res -i $(BOR)\include -w32 -r vim.rc @&&|
diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak
index 7c7acbd4b..5c7332e1c 100644
--- a/src/Make_cyg_ming.mak
+++ b/src/Make_cyg_ming.mak
@@ -64,8 +64,10 @@ WINVER = 0x0500
endif
# Set to yes to enable Cscope support.
CSCOPE=yes
-# Set to yes to enable Netbeans support.
+# Set to yes to enable Netbeans support (requires CHANNEL).
NETBEANS=$(GUI)
+# Set to yes to enable inter process communication.
+CHANNEL=$(GUI)
# Link against the shared version of libstdc++ by default. Set
@@ -526,6 +528,10 @@ endif
endif
endif
+ifeq ($(CHANNEL),yes)
+DEFINES += -DFEAT_CHANNEL
+endif
+
# DirectWrite (DirectX)
ifeq ($(DIRECTX),yes)
# Only allow DirectWrite for a GUI build.
@@ -667,13 +673,28 @@ endif
ifeq ($(CSCOPE),yes)
OBJ += $(OUTDIR)/if_cscope.o
endif
+
ifeq ($(NETBEANS),yes)
+ifneq ($(CHANNEL),yes)
+# Cannot use Netbeans without CHANNEL
+NETBEANS=no
+else
# Only allow NETBEANS for a GUI build.
ifeq (yes, $(GUI))
OBJ += $(OUTDIR)/netbeans.o
LIB += -lwsock32
endif
endif
+endif
+
+ifeq ($(CHANNEL),yes)
+OBJ += $(OUTDIR)/channel.o
+ifneq ($(NETBEANS),yes)
+LIB += -lwsock32
+endif
+endif
+endif
+
ifeq ($(DIRECTX),yes)
# Only allow DIRECTX for a GUI build.
ifeq (yes, $(GUI))
@@ -866,6 +887,9 @@ if_perl.c: if_perl.xs typemap
$(OUTDIR)/netbeans.o: netbeans.c $(INCL) $(NBDEBUG_INCL) $(NBDEBUG_SRC)
$(CC) -c $(CFLAGS) netbeans.c -o $(OUTDIR)/netbeans.o
+$(OUTDIR)/channel.o: channel.c $(INCL)
+ $(CC) -c $(CFLAGS) channel.c -o $(OUTDIR)/channel.o
+
$(OUTDIR)/regexp.o: regexp.c regexp_nfa.c $(INCL)
$(CC) -c $(CFLAGS) regexp.c -o $(OUTDIR)/regexp.o
diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
index c009aa977..c34a63ed6 100644
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -96,6 +96,13 @@
# PostScript printing: POSTSCRIPT=yes (default is no)
#
# Netbeans Support: NETBEANS=[yes or no] (default is yes if GUI is yes)
+# Requires CHANNEL.
+#
+# Netbeans Debugging Support: NBDEBUG=[yes or no] (should be no, yes
+# doesn't work)
+#
+# Inter process communication: CHANNEL=[yes or no] (default is yes if GUI
+# is yes)
#
# XPM Image Support: XPM=[path to XPM directory]
# Default is "xpm", using the files included in the distribution.
@@ -114,9 +121,6 @@
# yes: Write a normal mapfile.
# lines: Write a mapfile with line numbers (only for VC6 and later)
#
-# Netbeans Debugging Support: NBDEBUG=[yes or no] (should be no, yes
-# doesn't work)
-#
# Static Code Analysis: ANALYZE=yes (works with VS2012 only)
#
# You can combine any of these interfaces
@@ -290,9 +294,13 @@ CSCOPE_DEFS = -DFEAT_CSCOPE
NETBEANS = $(GUI)
!endif
-# Only allow NETBEANS and XPM for a GUI build.
+!ifndef CHANNEL
+CHANNEL = $(GUI)
+!endif
+
+# Only allow NETBEANS and XPM for a GUI build and CHANNEL.
!if "$(GUI)" == "yes"
-!if "$(NETBEANS)" == "yes"
+!if "$(NETBEANS)" == "yes" && "$(CHANNEL)" == "yes"
# NETBEANS - Include support for Netbeans integration
NETBEANS_PRO = proto/netbeans.pro
NETBEANS_OBJ = $(OBJDIR)/netbeans.obj
@@ -333,6 +341,14 @@ XPM_INC = -I $(XPM)\include -I $(XPM)\..\include
!endif
!endif
+!if "$(CHANNEL)" == "yes"
+CHANNEL_PRO = proto/channel.pro
+CHANNEL_OBJ = $(OBJDIR)/channel.obj
+CHANNEL_DEFS = -DFEAT_CHANNEL
+
+NETBEANS_LIB = WSock32.lib
+!endif
+
# Set which version of the CRT to use
!if defined(USE_MSVCRT)
# CVARS = $(cvarsdll)
@@ -365,7 +381,7 @@ WINVER = 0x0400
#VIMRUNTIMEDIR = somewhere
CFLAGS = -c /W3 /nologo $(CVARS) -I. -Iproto -DHAVE_PATHDEF -DWIN32 \
- $(SNIFF_DEFS) $(CSCOPE_DEFS) $(NETBEANS_DEFS) \
+ $(SNIFF_DEFS) $(CSCOPE_DEFS) $(NETBEANS_DEFS) $(CHANNEL_DEFS) \
$(NBDEBUG_DEFS) $(XPM_DEFS) \
$(DEFINES) -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) \
/Fo$(OUTDIR)/
@@ -1005,12 +1021,12 @@ all: $(VIM).exe \
$(VIM).exe: $(OUTDIR) $(OBJ) $(GUI_OBJ) $(OLE_OBJ) $(OLE_IDL) $(MZSCHEME_OBJ) \
$(LUA_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(PYTHON3_OBJ) $(RUBY_OBJ) $(TCL_OBJ) \
- $(SNIFF_OBJ) $(CSCOPE_OBJ) $(NETBEANS_OBJ) $(XPM_OBJ) \
+ $(SNIFF_OBJ) $(CSCOPE_OBJ) $(NETBEANS_OBJ) $(CHANNEL_OBJ) $(XPM_OBJ) \
version.c version.h
$(CC) $(CFLAGS) version.c
$(link) $(LINKARGS1) -out:$(VIM).exe $(OBJ) $(GUI_OBJ) $(OLE_OBJ) \
$(LUA_OBJ) $(MZSCHEME_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(PYTHON3_OBJ) $(RUBY_OBJ) \
- $(TCL_OBJ) $(SNIFF_OBJ) $(CSCOPE_OBJ) $(NETBEANS_OBJ) \
+ $(TCL_OBJ) $(SNIFF_OBJ) $(CSCOPE_OBJ) $(NETBEANS_OBJ) $(CHANNEL_OBJ) \
$(XPM_OBJ) $(OUTDIR)\version.obj $(LINKARGS2)
if exist $(VIM).exe.manifest mt.exe -nologo -manifest $(VIM).exe.manifest -updateresource:$(VIM).exe;1
@@ -1227,6 +1243,8 @@ $(OUTDIR)/mbyte.obj: $(OUTDIR) mbyte.c $(INCL)
$(OUTDIR)/netbeans.obj: $(OUTDIR) netbeans.c $(NBDEBUG_SRC) $(INCL)
+$(OUTDIR)/channel.obj: $(OUTDIR) channel.c $(INCL)
+
$(OUTDIR)/normal.obj: $(OUTDIR) normal.c $(INCL)
$(OUTDIR)/option.obj: $(OUTDIR) option.c $(INCL)
@@ -1362,7 +1380,8 @@ proto.h: \
proto/ui.pro \
proto/undo.pro \
proto/window.pro \
- $(NETBEANS_PRO)
+ $(NETBEANS_PRO) \
+ $(CHANNEL_PRO)
.SUFFIXES: .cod .i
diff --git a/src/auto/configure b/src/auto/configure
index 96e50935e..7ba3cc452 100755
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -656,6 +656,8 @@ XMKMF
xmkmfpath
SNIFF_OBJ
SNIFF_SRC
+CHANNEL_OBJ
+CHANNEL_SRC
NETBEANS_OBJ
NETBEANS_SRC
WORKSHOP_OBJ
@@ -810,6 +812,7 @@ with_ruby_command
enable_cscope
enable_workshop
enable_netbeans
+enable_channel
enable_sniff
enable_multibyte
enable_hangulinput
@@ -1473,6 +1476,7 @@ Optional Features:
--enable-cscope Include cscope interface.
--enable-workshop Include Sun Visual Workshop support.
--disable-netbeans Disable NetBeans integration support.
+ --disable-channel Disable process communication support.
--enable-sniff Include Sniff interface.
--enable-multibyte Include multibyte editing support.
--enable-hangulinput Include Hangul input support.
@@ -7227,6 +7231,29 @@ fi
if test "$enable_netbeans" = "yes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --disable-channel argument" >&5
+$as_echo_n "checking --disable-channel argument... " >&6; }
+# Check whether --enable-channel was given.
+if test "${enable_channel+set}" = set; then :
+ enableval=$enable_channel;
+else
+ enable_channel="yes"
+fi
+
+if test "$enable_channel" = "yes"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+
+if test "$enable_netbeans" = "yes" -o "$enable_channel" = "yes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5
$as_echo_n "checking for socket in -lsocket... " >&6; }
if ${ac_cv_lib_socket_socket+:} false; then :
@@ -7317,8 +7344,8 @@ _ACEOF
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiling netbeans integration is possible" >&5
-$as_echo_n "checking whether compiling netbeans integration is possible... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiling with process communication is possible" >&5
+$as_echo_n "checking whether compiling with process communication is possible... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7358,13 +7385,10 @@ if ac_fn_c_try_link "$LINENO"; then :
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }; enable_netbeans="no"
+$as_echo "no" >&6; }; enable_netbeans="no"; enable_channel="no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
fi
if test "$enable_netbeans" = "yes"; then
$as_echo "#define FEAT_NETBEANS_INTG 1" >>confdefs.h
@@ -7374,6 +7398,14 @@ if test "$enable_netbeans" = "yes"; then
NETBEANS_OBJ="objects/netbeans.o"
fi
+if test "$enable_channel" = "yes"; then
+ $as_echo "#define FEAT_CHANNEL 1" >>confdefs.h
+
+ CHANNEL_SRC="channel.c"
+
+ CHANNEL_OBJ="objects/channel.o"
+
+fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-sniff argument" >&5
$as_echo_n "checking --enable-sniff argument... " >&6; }
diff --git a/src/channel.c b/src/channel.c
new file mode 100644
index 000000000..a108d7e7c
--- /dev/null
+++ b/src/channel.c
@@ -0,0 +1,187 @@
+/* vi:set ts=8 sts=4 sw=4:
+ *
+ * VIM - Vi IMproved by Bram Moolenaar
+ *
+ * Do ":help uganda" in Vim to read copying and usage conditions.
+ * Do ":help credits" in Vim to see a list of people who contributed.
+ */
+
+/*
+ * Implements communication through a socket or any file handle.
+ */
+
+#include "vim.h"
+
+#if defined(FEAT_CHANNEL) || defined(PROTO)
+
+typedef struct {
+ sock_T ch_fd;
+ int ch_idx;
+} channel_T;
+
+static channel_T *channels = NULL;
+static int channel_count = 0;
+
+/*
+ * Add a new channel slot, return the index.
+ * Returns -1 if out of space.
+ */
+ static int
+add_channel(void)
+{
+ int idx;
+ channel_T *new_channels;
+
+ if (channels != NULL)
+ for (idx = 0; idx < channel_count; ++idx)
+ if (channels[idx].ch_fd < 0)
+ /* re-use a closed channel slot */
+ return idx;
+ if (channel_count == MAX_OPEN_CHANNELS)
+ return -1;
+ new_channels = (channel_T *)alloc(sizeof(channel_T) * channel_count + 1);
+ if (new_channels == NULL)
+ return -1;
+ if (channels != NULL)
+ mch_memmove(new_channels, channels, sizeof(channel_T) * channel_count);
+ channels = new_channels;
+ channels[channel_count].ch_fd = (sock_T)-1;
+
+ return channel_count++;
+}
+
+#if defined(FEAT_NETBEANS_INTG) || defined(PROTO)
+static int netbeans_channel = -1;
+
+/*
+ * Add the netbeans socket to the channels.
+ * Return the channel index.
+ */
+ int
+channel_add_netbeans(sock_T fd)
+{
+ int idx = add_channel();
+
+ if (idx >= 0)
+ {
+ channels[idx].ch_fd = fd;
+ netbeans_channel = idx;
+ }
+ return idx;
+}
+
+ void
+channel_remove_netbeans()
+{
+ channels[netbeans_channel].ch_fd = (sock_T)-1;
+ netbeans_channel = -1;
+}
+#endif
+
+ static void
+channel_read(int idx)
+{
+# ifdef FEAT_NETBEANS_INTG
+ if (idx == netbeans_channel)
+ netbeans_read();
+ else
+# endif
+ {
+ ; /* TODO: read */
+ }
+}
+
+#if (defined(UNIX) && !defined(HAVE_SELECT)) || defined(PROTO)
+/*
+ * Add open channels to the poll struct.
+ * Return the adjusted struct index.
+ * The type of "fds" is hidden to avoid problems with the function proto.
+ */
+ int
+channel_poll_setup(int nfd_in, void *fds_in)
+{
+ int nfd = nfd_in;
+ int i;
+ struct pollfd *fds = fds_in;
+
+ for (i = 0; i < channel_count; ++i)
+ if (channels[i].ch_fd >= 0)
+ {
+ channels[i].ch_idx = nfd;
+ fds[nfd].fd = channels[i].ch_fd;
+ fds[nfd].events = POLLIN;
+ nfd++;
+ }
+ else
+ channels[i].ch_idx = -1;
+
+ return nfd;
+}
+
+/*
+ * The type of "fds" is hidden to avoid problems with the function proto.
+ */
+ int
+channel_poll_check(int ret_in, void *fds_in)
+{
+ int ret = ret_in;
+ int i;
+ struct pollfd *fds = fds_in;
+
+ for (i = 0; i < channel_count; ++i)
+ if (ret > 0 && channels[i].ch_idx != -1
+ && fds[channels[i].ch_idx].revents & POLLIN)
+ {
+ channel_read(i);
+ --ret;
+ }
+
+ return ret;
+}
+#endif /* UNIX && !HAVE_SELECT */
+
+#if (defined(UNIX) && defined(HAVE_SELECT)) || defined(PROTO)
+/*
+ * The type of "rfds" is hidden to avoid problems with the function proto.
+ */
+ int
+channel_select_setup(int maxfd_in, void *rfds_in)
+{
+ int maxfd = maxfd_in;
+ int i;
+ fd_set *rfds = rfds_in;
+
+ for (i = 0; i < channel_count; ++i)
+ if (channels[i].ch_fd >= 0)
+ {
+ FD_SET(channels[i].ch_fd, rfds);
+ if (maxfd < channels[i].ch_fd)
+ maxfd = channels[i].ch_fd;
+ }
+
+ return maxfd;
+}
+
+/*
+ * The type of "rfds" is hidden to avoid problems with the function proto.
+ */
+ int
+channel_select_check(int ret_in, void *rfds_in)
+{
+ int ret = ret_in;
+ int i;
+ fd_set *rfds = rfds_in;
+
+ for (i = 0; i < channel_count; ++i)
+ if (ret > 0 && channels[i].ch_fd >= 0
+ && FD_ISSET(channels[i].ch_fd, rfds))
+ {
+ channel_read(i);
+ --ret;
+ }
+
+ return ret;
+}
+#endif /* UNIX && HAVE_SELECT */
+
+#endif /* FEAT_CHANNEL */
diff --git a/src/config.aap.in b/src/config.aap.in
index d398a193a..819276fee 100644
--- a/src/config.aap.in
+++ b/src/config.aap.in
@@ -65,6 +65,8 @@ WORKSHOP_OBJ = @WORKSHOP_OBJ@
NETBEANS_SRC = @NETBEANS_SRC@
NETBEANS_OBJ = @NETBEANS_OBJ@
+CHANNEL_SRC = @CHANNEL_SRC@
+CHANNEL_OBJ = @CHANNEL_OBJ@
RUBY = @vi_cv_path_ruby@
RUBY_SRC = @RUBY_SRC@
diff --git a/src/config.h.in b/src/config.h.in
index d4fd50a37..9807bd23e 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -435,6 +435,9 @@
/* Define if you want to include NetBeans integration. */
#undef FEAT_NETBEANS_INTG
+/* Define if you want to include process communication. */
+#undef FEAT_CHANNEL
+
/* Define default global runtime path */
#undef RUNTIME_GLOBAL
diff --git a/src/config.mk.in b/src/config.mk.in
index 9e16d1325..5f7f1d58c 100644
--- a/src/config.mk.in
+++ b/src/config.mk.in
@@ -89,6 +89,8 @@ WORKSHOP_OBJ = @WORKSHOP_OBJ@
NETBEANS_SRC = @NETBEANS_SRC@
NETBEANS_OBJ = @NETBEANS_OBJ@
+CHANNEL_SRC = @CHANNEL_SRC@
+CHANNEL_OBJ = @CHANNEL_OBJ@
RUBY = @vi_cv_path_ruby@
RUBY_SRC = @RUBY_SRC@
diff --git a/src/configure.in b/src/configure.in
index 4bb49a70a..90a17ac84 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -1938,10 +1938,30 @@ AC_ARG_ENABLE(netbeans,
, [enable_netbeans="yes"])
if test "$enable_netbeans" = "yes"; then
AC_MSG_RESULT(no)
+else
+ AC_MSG_RESULT(yes)
+fi
+
+AC_MSG_CHECKING(--disable-channel argument)
+AC_ARG_ENABLE(channel,
+ [ --disable-channel Disable process communication support.],
+ , [enable_channel="yes"])
+if test "$enable_channel" = "yes"; then
+ AC_MSG_RESULT(no)
+else
+ if test "$enable_netbeans" = "yes"; then
+ AC_MSG_RESULT(yes, netbeans also disabled)
+ enable_netbeans="no"
+ else
+ AC_MSG_RESULT(yes)
+ fi
+fi
+
+if "$enable_channel" = "yes"; then
dnl On Solaris we need the socket and nsl library.
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, gethostbyname)
- AC_MSG_CHECKING(whether compiling netbeans integration is possible)
+ AC_MSG_CHECKING(whether compiling with process communication is possible)
AC_TRY_LINK([
#include <stdio.h>
#include <stdlib.h>
@@ -1967,9 +1987,7 @@ if test "$enable_netbeans" = "yes"; then
(void)connect(1, (struct sockaddr *)&server, sizeof(server));
],
AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no); enable_netbeans="no")
-else
- AC_MSG_RESULT(yes)
+ AC_MSG_RESULT(no); enable_netbeans="no"; enable_channel="no")
fi
if test "$enable_netbeans" = "yes"; then
AC_DEFINE(FEAT_NETBEANS_INTG)
@@ -1978,6 +1996,13 @@ if test "$enable_netbeans" = "yes"; then
NETBEANS_OBJ="objects/netbeans.o"
AC_SUBST(NETBEANS_OBJ)
fi
+if test "$enable_channel" = "yes"; then
+ AC_DEFINE(FEAT_CHANNEL)
+ CHANNEL_SRC="channel.c"
+ AC_SUBST(CHANNEL_SRC)
+ CHANNEL_OBJ="objects/channel.o"
+ AC_SUBST(CHANNEL_OBJ)
+fi
AC_MSG_CHECKING(--enable-sniff argument)
AC_ARG_ENABLE(sniff,
diff --git a/src/eval.c b/src/eval.c
index 860bc358e..d08269fc9 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -13083,6 +13083,9 @@ f_has(argvars, rettv)
#ifdef FEAT_BYTEOFF
"byte_offset",
#endif
+#ifdef FEAT_CHANNEL
+ "channel",
+#endif
#ifdef FEAT_CINDENT
"cindent",
#endif
diff --git a/src/feature.h b/src/feature.h
index 5de0fcec3..dd18394c5 100644
--- a/src/feature.h
+++ b/src/feature.h
@@ -1237,6 +1237,7 @@
* +sniff Sniff interface: "--enable-sniff"
* +sun_workshop Sun Workshop integration
* +netbeans_intg Netbeans integration
+ * +channel Inter process communication
*/
/*
@@ -1261,6 +1262,13 @@
#endif
/*
+ * The Channel feature requires +eval.
+ */
+#if !defined(FEAT_EVAL) && defined(FEAT_CHANNEL)
+# undef FEAT_CHANNEL
+#endif
+
+/*
* +signs Allow signs to be displayed to the left of text lines.
* Adds the ":sign" command.
*/
diff --git a/src/gui_w32.c b/src/gui_w32.c
index db0a9d5bf..ecc1fab41 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -553,7 +553,7 @@ typedef BOOL (WINAPI *TGetMonitorInfo)(_HMONITOR, _MONITORINFO *);
static TMonitorFromWindow pMonitorFromWindow = NULL;
static TGetMonitorInfo pGetMonitorInfo = NULL;
static HANDLE user32_lib = NULL;
-#ifdef FEAT_NETBEANS_INTG
+#ifdef FEAT_CHANNEL
int WSInitialized = FALSE; /* WinSock is initialized */
#endif
/*
@@ -5048,12 +5048,14 @@ netbeans_draw_multisign_indicator(int row)
SetPixel(s_hdc, x+3, y++, gui.currFgColor);
SetPixel(s_hdc, x+2, y, gui.currFgColor);
}
+#endif
+#if defined(FEAT_CHANNEL) || defined(PROTO)
/*
* Initialize the Winsock dll.
*/
void
-netbeans_init_winsock()
+channel_init_winsock()
{
WSADATA wsaData;
int wsaerr;
diff --git a/src/macros.h b/src/macros.h
index c4d27f80d..ec0cdc3f9 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -317,6 +317,6 @@
# define PLINES_NOFILL(x) plines(x)
#endif
-#if defined(FEAT_NETBEANS_INTG) || defined(FEAT_CLIENTSERVER)
+#if defined(FEAT_CHANNEL) || defined(FEAT_CLIENTSERVER)
# define MESSAGE_QUEUE
#endif
diff --git a/src/netbeans.c b/src/netbeans.c
index 2c1522767..14f274df1 100644
--- a/src/netbeans.c
+++ b/src/netbeans.c
@@ -106,13 +106,7 @@ static void nb_free __ARGS((void));
# define NB_HAS_GUI (gui.in_use || gui.starting)
#endif
-#ifdef WIN64
-typedef __int64 NBSOCK;
-#else
-typedef int NBSOCK;
-#endif
-
-static NBSOCK nbsock = -1; /* socket fd for Netbeans connection */
+static sock_T nbsock = -1; /* socket fd for Netbeans connection */
#define NETBEANS_OPEN (nbsock != -1)
#ifdef FEAT_GUI_X11
@@ -175,6 +169,7 @@ nb_close_socket(void)
sock_close(nbsock);
nbsock = -1;
+ channel_remove_netbeans();
}
/*
@@ -243,8 +238,7 @@ netbeans_connect(char *params, int doabort)
if (*params == '=')
{
/* "=fname": Read info from specified file. */
- if (getConnInfo(params + 1, &hostname, &address, &password)
- == FAIL)
+ if (getConnInfo(params + 1, &hostname, &address, &password) == FAIL)
return FAIL;
}
else
@@ -312,13 +306,13 @@ netbeans_connect(char *params, int doabort)
goto theend; /* out of memory */
#ifdef FEAT_GUI_W32
- netbeans_init_winsock();
+ channel_init_winsock();
#endif
#ifdef INET_SOCKETS
port = atoi(address);
- if ((sd = (NBSOCK)socket(AF_INET, SOCK_STREAM, 0)) == (NBSOCK)-1)
+ if ((sd = (sock_T)socket(AF_INET, SOCK_STREAM, 0)) == (sock_T)-1)
{
nbdebug(("error in socket() in netbeans_connect()\n"));
PERROR("socket() in netbeans_connect()");
@@ -358,7 +352,7 @@ netbeans_connect(char *params, int doabort)
{
sock_close(sd);
#ifdef INET_SOCKETS
- if ((sd = (NBSOCK)socket(AF_INET, SOCK_STREAM, 0)) == (NBSOCK)-1)
+ if ((sd = (sock_T)socket(AF_INET, SOCK_STREAM, 0)) == (sock_T)-1)
{
SOCK_ERRNO;
nbdebug(("socket()#2 in netbeans_connect()\n"));
@@ -423,6 +417,7 @@ netbeans_connect(char *params, int doabort)
}
nbsock = sd;
+ channel_add_netbeans(nbsock);
vim_snprintf(buf, sizeof(buf), "AUTH %s\n", password);
nb_send(buf, "netbeans_connect");
@@ -2954,7 +2949,7 @@ netbeans_beval_cb(
#endif
/*
- * Return TRUE when the netbeans connection is closed.
+ * Return TRUE when the netbeans connection is active.
*/
int
netbeans_active(void)
@@ -2962,15 +2957,6 @@ netbeans_active(void)
return NETBEANS_OPEN;
}
-/*
- * Return netbeans file descriptor.
- */
- int
-netbeans_filedesc(void)
-{
- return nbsock;
-}
-
#if defined(FEAT_GUI) || defined(PROTO)
/*
* Register our file descriptor with the gui event handling system.
diff --git a/src/os_mswin.c b/src/os_mswin.c
index 698c210f4..ed7aa834d 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -231,7 +231,7 @@ mch_exit(int r)
# ifdef FEAT_OLE
UninitOLE();
# endif
-# ifdef FEAT_NETBEANS_INTG
+# ifdef FEAT_CHANNEL
if (WSInitialized)
{
WSInitialized = FALSE;
diff --git a/src/os_unix.c b/src/os_unix.c
index d2e1c79bd..0a73c8894 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5189,9 +5189,6 @@ RealWaitForChar(fd, msec, check_for_gpm)
int *check_for_gpm UNUSED;
{
int ret;
-#ifdef FEAT_NETBEANS_INTG
- int nb_fd = netbeans_filedesc();
-#endif
#if defined(FEAT_XCLIPBOARD) || defined(USE_XSMP) || defined(FEAT_MZSCHEME)
static int busy = FALSE;
@@ -5241,7 +5238,7 @@ RealWaitForChar(fd, msec, check_for_gpm)
# endif
#endif
#ifndef HAVE_SELECT
- struct pollfd fds[6];
+ struct pollfd fds[6 + MAX_OPEN_CHANNELS];
int nfd;
# ifdef FEAT_XCLIPBOARD
int xterm_idx = -1;
@@ -5252,9 +5249,6 @@ RealWaitForChar(fd, msec, check_for_gpm)
# ifdef USE_XSMP
int xsmp_idx = -1;
# endif
-# ifdef FEAT_NETBEANS_INTG
- int nb_idx = -1;
-# endif
int towait = (int)msec;
# ifdef FEAT_MZSCHEME
@@ -5306,14 +5300,8 @@ RealWaitForChar(fd, msec, check_for_gpm)
nfd++;
}
# endif
-#ifdef FEAT_NETBEANS_INTG
- if (nb_fd != -1)
- {
- nb_idx = nfd;
- fds[nfd].fd = nb_fd;
- fds[nfd].events = POLLIN;
- nfd++;
- }
+#ifdef FEAT_CHANNEL
+ nfd = channel_poll_setup(nfd, &fds);
#endif
ret = poll(fds, nfd, towait);
@@ -5368,12 +5356,9 @@ RealWaitForChar(fd, msec, check_for_gpm)
finished = FALSE; /* Try again */
}
# endif
-#ifdef FEAT_NETBEANS_INTG
- if (ret > 0 && nb_idx != -1 && fds[nb_idx].revents & POLLIN)
- {
- netbeans_read();
- --ret;
- }
+#ifdef FEAT_CHANNEL
+ if (ret > 0)
+ ret = channel_poll_check(ret, &fds);
#endif
@@ -5462,13 +5447,8 @@ select_eintr:
maxfd = xsmp_icefd;
}
# endif
-# ifdef FEAT_NETBEANS_INTG
- if (nb_fd != -1)
- {
- FD_SET(nb_fd, &rfds);
- if (maxfd < nb_fd)
- maxfd = nb_fd;
- }
+# ifdef FEAT_CHANNEL
+ maxfd = channel_select_setup(maxfd, &rfds);
# endif
ret = select(maxfd + 1, &rfds, NULL, &efds, tvp);
@@ -5556,12 +5536,9 @@ select_eintr:
}
}
# endif
-#ifdef FEAT_NETBEANS_INTG
- if (ret > 0 && nb_fd != -1 && FD_ISSET(nb_fd, &rfds))
- {
- netbeans_read();
- --ret;
- }
+#ifdef FEAT_CHANNEL
+ if (ret > 0)
+ ret = channel_select_check(ret, &rfds);
#endif
#endif /* HAVE_SELECT */
diff --git a/src/proto.h b/src/proto.h
index 5f52a314b..7a48dc973 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -209,6 +209,9 @@ void qsort __ARGS((void *base, size_t elm_count, size_t elm_size, int (*cmp)(con
# ifdef FEAT_NETBEANS_INTG
# include "netbeans.pro"
# endif
+# ifdef FEAT_CHANNEL
+# include "channel.pro"
+# endif
# ifdef FEAT_GUI
# include "gui.pro"
diff --git a/src/proto/channel.pro b/src/proto/channel.pro
new file mode 100644
index 000000000..d2e9b3a37
--- /dev/null
+++ b/src/proto/channel.pro
@@ -0,0 +1,8 @@
+/* channel.c */
+int channel_add_netbeans(sock_T fd);
+void channel_remove_netbeans(void);
+int channel_poll_setup(int nfd_in, void *fds_in);
+int channel_poll_check(int ret_in, void *fds_in);
+int channel_select_setup(int maxfd_in, void *rfds_in);
+int channel_select_check(int ret_in, void *rfds_in);
+/* vim: set ft=c : */
diff --git a/src/proto/netbeans.pro b/src/proto/netbeans.pro
index 7805baf20..c7e1f0688 100644
--- a/src/proto/netbeans.pro
+++ b/src/proto/netbeans.pro
@@ -9,7 +9,6 @@ void ex_nbkey(exarg_T *eap);
void ex_nbstart(exarg_T *eap);
void netbeans_beval_cb(BalloonEval *beval, int state);
int netbeans_active(void);
-int netbeans_filedesc(void);
void netbeans_gui_register(void);
void netbeans_open(char *params, int doabort);
void netbeans_send_disconnect(void);
diff --git a/src/ui.c b/src/ui.c
index f622f0418..9bcf80b3f 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -1562,7 +1562,7 @@ clip_gen_owner_exists(cbd)
* descriptions which would otherwise overflow. The buffer is considered full
* when only this extra space (or part of it) remains.
*/
-#if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG) \
+#if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_CHANNEL) \
|| defined(FEAT_CLIENTSERVER)
/*
* Sun WorkShop and NetBeans stuff debugger commands into the input buffer.
diff --git a/src/version.c b/src/version.c
index 1ea136d0b..61bc28495 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1169,
+/**/
1168,
/**/
1167,
diff --git a/src/vim.h b/src/vim.h
index 90a5353c3..e7a5f5842 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -1929,8 +1929,8 @@ typedef int proftime_T; /* dummy for function prototypes */
# ifdef FEAT_OLE
# define WM_OLE (WM_APP+0)
# endif
-# ifdef FEAT_NETBEANS_INTG
- /* message for Netbeans socket event */
+# ifdef FEAT_CHANNEL
+ /* message for channel socket event */
# define WM_NETBEANS (WM_APP+1)
# endif
# endif
@@ -1979,6 +1979,14 @@ typedef int VimClipboard; /* This is required for the prototypes. */
# define stat(a,b) (access(a,0) ? -1 : stat(a,b))
#endif
+#ifdef FEAT_CHANNEL
+# ifdef WIN64
+typedef __int64 sock_T;
+# else
+typedef int sock_T;
+# endif
+#endif
+
#include "ex_cmds.h" /* Ex command defines */
#include "proto.h" /* function prototypes */
@@ -2312,4 +2320,10 @@ typedef int VimClipboard; /* This is required for the prototypes. */
# define SET_NO_HLSEARCH(flag) no_hlsearch = (flag)
#endif
+#ifdef FEAT_CHANNEL
+# define MAX_OPEN_CHANNELS 10
+#else
+# define MAX_OPEN_CHANNELS 0
+#endif
+
#endif /* VIM__H */