Commit 6c40b63d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

rpcrt4: Moved formatting pipe names to helper functions.

parent 2fdccc24
......@@ -247,10 +247,21 @@ static RPC_STATUS rpcrt4_conn_open_pipe(RpcConnection *Connection, LPCSTR pname,
return RPC_S_OK;
}
static char *ncalrpc_pipe_name(const char *endpoint)
{
static const char prefix[] = "\\\\.\\pipe\\lrpc\\";
char *pipe_name;
/* protseq=ncalrpc: supposed to use NT LPC ports,
* but we'll implement it with named pipes for now */
pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
strcat(strcpy(pipe_name, prefix), endpoint);
return pipe_name;
}
static RPC_STATUS rpcrt4_ncalrpc_open(RpcConnection* Connection)
{
RpcConnection_np *npc = (RpcConnection_np *) Connection;
static const char prefix[] = "\\\\.\\pipe\\lrpc\\";
RPC_STATUS r;
LPSTR pname;
......@@ -258,10 +269,7 @@ static RPC_STATUS rpcrt4_ncalrpc_open(RpcConnection* Connection)
if (npc->pipe)
return RPC_S_OK;
/* protseq=ncalrpc: supposed to use NT LPC ports,
* but we'll implement it with named pipes for now */
pname = I_RpcAllocate(strlen(prefix) + strlen(Connection->Endpoint) + 1);
strcat(strcpy(pname, prefix), Connection->Endpoint);
pname = ncalrpc_pipe_name(Connection->Endpoint);
r = rpcrt4_conn_open_pipe(Connection, pname, TRUE);
I_RpcFree(pname);
......@@ -270,7 +278,6 @@ static RPC_STATUS rpcrt4_ncalrpc_open(RpcConnection* Connection)
static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint(RpcServerProtseq* protseq, const char *endpoint)
{
static const char prefix[] = "\\\\.\\pipe\\lrpc\\";
RPC_STATUS r;
LPSTR pname;
RpcConnection *Connection;
......@@ -291,10 +298,7 @@ static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint(RpcServerProtseq* protseq
if (r != RPC_S_OK)
return r;
/* protseq=ncalrpc: supposed to use NT LPC ports,
* but we'll implement it with named pipes for now */
pname = I_RpcAllocate(strlen(prefix) + strlen(Connection->Endpoint) + 1);
strcat(strcpy(pname, prefix), Connection->Endpoint);
pname = ncalrpc_pipe_name(Connection->Endpoint);
r = rpcrt4_conn_create_pipe(Connection, pname);
I_RpcFree(pname);
......@@ -306,10 +310,20 @@ static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint(RpcServerProtseq* protseq
return r;
}
static char *ncacn_pipe_name(const char *endpoint)
{
static const char prefix[] = "\\\\.";
char *pipe_name;
/* protseq=ncacn_np: named pipes */
pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
strcat(strcpy(pipe_name, prefix), endpoint);
return pipe_name;
}
static RPC_STATUS rpcrt4_ncacn_np_open(RpcConnection* Connection)
{
RpcConnection_np *npc = (RpcConnection_np *) Connection;
static const char prefix[] = "\\\\.";
RPC_STATUS r;
LPSTR pname;
......@@ -317,9 +331,7 @@ static RPC_STATUS rpcrt4_ncacn_np_open(RpcConnection* Connection)
if (npc->pipe)
return RPC_S_OK;
/* protseq=ncacn_np: named pipes */
pname = I_RpcAllocate(strlen(prefix) + strlen(Connection->Endpoint) + 1);
strcat(strcpy(pname, prefix), Connection->Endpoint);
pname = ncacn_pipe_name(Connection->Endpoint);
r = rpcrt4_conn_open_pipe(Connection, pname, FALSE);
I_RpcFree(pname);
......@@ -328,7 +340,6 @@ static RPC_STATUS rpcrt4_ncacn_np_open(RpcConnection* Connection)
static RPC_STATUS rpcrt4_protseq_ncacn_np_open_endpoint(RpcServerProtseq *protseq, const char *endpoint)
{
static const char prefix[] = "\\\\.";
RPC_STATUS r;
LPSTR pname;
RpcConnection *Connection;
......@@ -349,9 +360,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_np_open_endpoint(RpcServerProtseq *protse
if (r != RPC_S_OK)
return r;
/* protseq=ncacn_np: named pipes */
pname = I_RpcAllocate(strlen(prefix) + strlen(Connection->Endpoint) + 1);
strcat(strcpy(pname, prefix), Connection->Endpoint);
pname = ncacn_pipe_name(Connection->Endpoint);
r = rpcrt4_conn_create_pipe(Connection, pname);
I_RpcFree(pname);
......@@ -379,12 +388,10 @@ static RPC_STATUS rpcrt4_ncacn_np_handoff(RpcConnection *old_conn, RpcConnection
{
RPC_STATUS status;
LPSTR pname;
static const char prefix[] = "\\\\.";
rpcrt4_conn_np_handoff((RpcConnection_np *)old_conn, (RpcConnection_np *)new_conn);
pname = I_RpcAllocate(strlen(prefix) + strlen(old_conn->Endpoint) + 1);
strcat(strcpy(pname, prefix), old_conn->Endpoint);
pname = ncacn_pipe_name(old_conn->Endpoint);
status = rpcrt4_conn_create_pipe(old_conn, pname);
I_RpcFree(pname);
......@@ -395,14 +402,12 @@ static RPC_STATUS rpcrt4_ncalrpc_handoff(RpcConnection *old_conn, RpcConnection
{
RPC_STATUS status;
LPSTR pname;
static const char prefix[] = "\\\\.\\pipe\\lrpc\\";
TRACE("%s\n", old_conn->Endpoint);
rpcrt4_conn_np_handoff((RpcConnection_np *)old_conn, (RpcConnection_np *)new_conn);
pname = I_RpcAllocate(strlen(prefix) + strlen(old_conn->Endpoint) + 1);
strcat(strcpy(pname, prefix), old_conn->Endpoint);
pname = ncalrpc_pipe_name(old_conn->Endpoint);
status = rpcrt4_conn_create_pipe(old_conn, pname);
I_RpcFree(pname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment