From 0ee6f59cc02c6e092049f235b440eca46a215a4d Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Thu, 20 Apr 2006 19:52:26 +0900 Subject: [PATCH] rpcrt4: Use a separate function to open each protseq. --- dlls/rpcrt4/rpc_binding.c | 80 ++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/dlls/rpcrt4/rpc_binding.c b/dlls/rpcrt4/rpc_binding.c index 9b3e705fd17..792adcfd3eb 100644 --- a/dlls/rpcrt4/rpc_binding.c +++ b/dlls/rpcrt4/rpc_binding.c @@ -190,48 +190,60 @@ static RPC_STATUS rpcrt4_open_pipe(RpcConnection *Connection, LPCSTR pname, BOOL return RPC_S_OK; } +static RPC_STATUS rpcrt4_ncalrpc_open(RpcConnection* Connection) +{ + 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) { - RPC_STATUS r = RPC_S_OK; - 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 (strcmp(Connection->Protseq, "ncalrpc") == 0) + return rpcrt4_ncalrpc_open(Connection); - 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, "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)