diff src/netbeans.c @ 7743:6069f43cea4e v7.4.1169

commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 24 20:36:41 2016 +0100 patch 7.4.1169 Problem: The socket I/O is intertwined with the netbeans code. Solution: Start refactoring the netbeans communication to split off the socket I/O. Add the +channel feature.
author Christian Brabandt <cb@256bit.org>
date Sun, 24 Jan 2016 20:45:05 +0100
parents 1886f2863437
children 15e67f90b9b2
line wrap: on
line diff
--- 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 doabo
     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 doabo
 	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 doabo
 	{
 	    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 doabo
     }
 
     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.