Mike McCormack : rpcrt4: Use a separate function to open each protseq.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Apr 20 08:46:04 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 0ee6f59cc02c6e092049f235b440eca46a215a4d
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=0ee6f59cc02c6e092049f235b440eca46a215a4d

Author: Mike McCormack <mike at codeweavers.com>
Date:   Thu Apr 20 19:52:26 2006 +0900

rpcrt4: Use a separate function to open each protseq.

---

 dlls/rpcrt4/rpc_binding.c |   82 ++++++++++++++++++++++++++-------------------
 1 files changed, 47 insertions(+), 35 deletions(-)

diff --git a/dlls/rpcrt4/rpc_binding.c b/dlls/rpcrt4/rpc_binding.c
index 9b3e705..792adcf 100644
--- a/dlls/rpcrt4/rpc_binding.c
+++ b/dlls/rpcrt4/rpc_binding.c
@@ -190,48 +190,60 @@ static RPC_STATUS rpcrt4_open_pipe(RpcCo
   return RPC_S_OK;
 }
 
-RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection)
+static RPC_STATUS rpcrt4_ncalrpc_open(RpcConnection* Connection)
 {
-  RPC_STATUS r = RPC_S_OK;
+  static LPCSTR prefix = "\\\\.\\pipe\\lrpc\\";
+  RPC_STATUS r;
+  LPSTR pname;
+
+  /* protseq=ncalrpc: supposed to use NT LPC ports,
+   * but we'll implement it with named pipes for now */
+  pname = HeapAlloc(GetProcessHeap(), 0, strlen(prefix) + strlen(Connection->Endpoint) + 1);
+  strcat(strcpy(pname, prefix), Connection->Endpoint);
+
+  if (Connection->server)
+    r = rpcrt4_connect_pipe(Connection, pname);
+  else
+    r = rpcrt4_open_pipe(Connection, pname, TRUE);
+  HeapFree(GetProcessHeap(), 0, pname);
+
+  return r;
+}
+
+static RPC_STATUS rpcrt4_ncacn_np_open(RpcConnection* Connection)
+{
+  static LPCSTR prefix = "\\\\.";
+  RPC_STATUS r;
+  LPSTR pname;
+
+  /* protseq=ncacn_np: named pipes */
+  pname = HeapAlloc(GetProcessHeap(), 0, strlen(prefix) + strlen(Connection->Endpoint) + 1);
+  strcat(strcpy(pname, prefix), Connection->Endpoint);
+  if (Connection->server)
+    r = rpcrt4_connect_pipe(Connection, pname);
+  else
+    r = rpcrt4_open_pipe(Connection, pname, FALSE);
+  HeapFree(GetProcessHeap(), 0, pname);
+
+  return r;
+}
 
+RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection)
+{
   TRACE("(Connection == ^%p)\n", Connection);
 
   /* already connected? */
   if (Connection->conn)
-     return r;
+     return RPC_S_OK;
 
-  /* protseq=ncalrpc: supposed to use NT LPC ports,
-   * but we'll implement it with named pipes for now */
-  if (strcmp(Connection->Protseq, "ncalrpc") == 0) {
-    static LPCSTR prefix = "\\\\.\\pipe\\lrpc\\";
-    LPSTR pname;
-    pname = HeapAlloc(GetProcessHeap(), 0, strlen(prefix) + strlen(Connection->Endpoint) + 1);
-    strcat(strcpy(pname, prefix), Connection->Endpoint);
-
-    if (Connection->server)
-      r = rpcrt4_connect_pipe(Connection, pname);
-    else
-      r = rpcrt4_open_pipe(Connection, pname, TRUE);
-    HeapFree(GetProcessHeap(), 0, pname);
-  }
-  /* protseq=ncacn_np: named pipes */
-  else if (strcmp(Connection->Protseq, "ncacn_np") == 0) {
-    static LPCSTR prefix = "\\\\.";
-    LPSTR pname;
-    pname = HeapAlloc(GetProcessHeap(), 0, strlen(prefix) + strlen(Connection->Endpoint) + 1);
-    strcat(strcpy(pname, prefix), Connection->Endpoint);
-    if (Connection->server)
-      r = rpcrt4_connect_pipe(Connection, pname);
-    else
-      r = rpcrt4_open_pipe(Connection, pname, FALSE);
-    HeapFree(GetProcessHeap(), 0, pname);
-  }
-  else {
-    ERR("protseq %s not supported\n", Connection->Protseq);
-    r = RPC_S_PROTSEQ_NOT_SUPPORTED;
-  }
- 
-  return r;
+  if (strcmp(Connection->Protseq, "ncalrpc") == 0) 
+    return rpcrt4_ncalrpc_open(Connection);
+
+  if (strcmp(Connection->Protseq, "ncacn_np") == 0) 
+    return rpcrt4_ncacn_np_open(Connection);
+
+  ERR("protseq %s not supported\n", Connection->Protseq);
+  return RPC_S_PROTSEQ_NOT_SUPPORTED;
 }
 
 RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection)




More information about the wine-cvs mailing list