rpcss: Make initialization helper easier to extend.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
88d30985dd
commit
5221825136
|
@ -37,53 +37,60 @@ static WCHAR rpcssW[] = {'R','p','c','S','s',0};
|
|||
static HANDLE exit_event;
|
||||
static SERVICE_STATUS_HANDLE service_handle;
|
||||
|
||||
static BOOL RPCSS_Initialize(void)
|
||||
static RPC_STATUS RPCSS_Initialize(void)
|
||||
{
|
||||
static unsigned short irot_protseq[] = IROT_PROTSEQ;
|
||||
static unsigned short irot_endpoint[] = IROT_ENDPOINT;
|
||||
static unsigned short epm_protseq[] = {'n','c','a','c','n','_','n','p',0};
|
||||
static unsigned short epm_endpoint[] = {'\\','p','i','p','e','\\','e','p','m','a','p','p','e','r',0};
|
||||
static unsigned short epm_protseq_lrpc[] = {'n','c','a','l','r','p','c',0};
|
||||
static unsigned short epm_endpoint_lrpc[] = {'e','p','m','a','p','p','e','r',0};
|
||||
RPC_STATUS status;
|
||||
static unsigned short irot_protseq[] = IROT_PROTSEQ;
|
||||
static unsigned short irot_endpoint[] = IROT_ENDPOINT;
|
||||
static unsigned short epm_protseq[] = {'n','c','a','c','n','_','n','p',0};
|
||||
static unsigned short epm_endpoint[] = {'\\','p','i','p','e','\\','e','p','m','a','p','p','e','r',0};
|
||||
static unsigned short epm_protseq_lrpc[] = {'n','c','a','l','r','p','c',0};
|
||||
static unsigned short epm_endpoint_lrpc[] = {'e','p','m','a','p','p','e','r',0};
|
||||
static const struct protseq_map
|
||||
{
|
||||
unsigned short *protseq;
|
||||
unsigned short *endpoint;
|
||||
} protseqs[] =
|
||||
{
|
||||
{ epm_protseq, epm_endpoint },
|
||||
{ epm_protseq_lrpc, epm_endpoint_lrpc },
|
||||
{ irot_protseq, irot_endpoint },
|
||||
};
|
||||
RPC_IF_HANDLE ifspecs[] =
|
||||
{
|
||||
epm_v3_0_s_ifspec,
|
||||
Irot_v0_2_s_ifspec,
|
||||
};
|
||||
RPC_STATUS status;
|
||||
int i, j;
|
||||
|
||||
WINE_TRACE("\n");
|
||||
WINE_TRACE("\n");
|
||||
|
||||
status = RpcServerRegisterIf(epm_v3_0_s_ifspec, NULL, NULL);
|
||||
if (status != RPC_S_OK)
|
||||
return status;
|
||||
status = RpcServerRegisterIf(Irot_v0_2_s_ifspec, NULL, NULL);
|
||||
if (status != RPC_S_OK)
|
||||
{
|
||||
RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
for (i = 0, j = 0; i < ARRAY_SIZE(ifspecs); ++i, j = i)
|
||||
{
|
||||
status = RpcServerRegisterIf(ifspecs[i], NULL, NULL);
|
||||
if (status != RPC_S_OK)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
status = RpcServerUseProtseqEpW(epm_protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
|
||||
epm_endpoint, NULL);
|
||||
if (status != RPC_S_OK)
|
||||
goto fail;
|
||||
for (i = 0; i < ARRAY_SIZE(protseqs); ++i)
|
||||
{
|
||||
status = RpcServerUseProtseqEpW(protseqs[i].protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
|
||||
protseqs[i].endpoint, NULL);
|
||||
if (status != RPC_S_OK)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
status = RpcServerUseProtseqEpW(epm_protseq_lrpc, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
|
||||
epm_endpoint_lrpc, NULL);
|
||||
if (status != RPC_S_OK)
|
||||
goto fail;
|
||||
status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE);
|
||||
if (status != RPC_S_OK)
|
||||
goto fail;
|
||||
|
||||
status = RpcServerUseProtseqEpW(irot_protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
|
||||
irot_endpoint, NULL);
|
||||
if (status != RPC_S_OK)
|
||||
goto fail;
|
||||
|
||||
status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE);
|
||||
if (status != RPC_S_OK)
|
||||
goto fail;
|
||||
|
||||
return TRUE;
|
||||
return RPC_S_OK;
|
||||
|
||||
fail:
|
||||
RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE);
|
||||
RpcServerUnregisterIf(Irot_v0_2_s_ifspec, NULL, FALSE);
|
||||
return FALSE;
|
||||
for (i = 0; i < j; ++i)
|
||||
RpcServerUnregisterIf(ifspecs[i], NULL, FALSE);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context )
|
||||
|
@ -121,10 +128,15 @@ static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, LPVOID event_
|
|||
static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
|
||||
{
|
||||
SERVICE_STATUS status;
|
||||
RPC_STATUS ret;
|
||||
|
||||
TRACE( "starting service\n" );
|
||||
|
||||
if (!RPCSS_Initialize()) return;
|
||||
if ((ret = RPCSS_Initialize()))
|
||||
{
|
||||
WARN("Failed to initialize rpc interfaces, status %d.\n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
exit_event = CreateEventW( NULL, TRUE, FALSE, NULL );
|
||||
|
||||
|
|
Loading…
Reference in New Issue