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 HANDLE exit_event;
|
||||||
static SERVICE_STATUS_HANDLE service_handle;
|
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_protseq[] = IROT_PROTSEQ;
|
||||||
static unsigned short irot_endpoint[] = IROT_ENDPOINT;
|
static unsigned short irot_endpoint[] = IROT_ENDPOINT;
|
||||||
static unsigned short epm_protseq[] = {'n','c','a','c','n','_','n','p',0};
|
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_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_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 unsigned short epm_endpoint_lrpc[] = {'e','p','m','a','p','p','e','r',0};
|
||||||
RPC_STATUS status;
|
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);
|
for (i = 0, j = 0; i < ARRAY_SIZE(ifspecs); ++i, j = i)
|
||||||
if (status != RPC_S_OK)
|
{
|
||||||
return status;
|
status = RpcServerRegisterIf(ifspecs[i], NULL, NULL);
|
||||||
status = RpcServerRegisterIf(Irot_v0_2_s_ifspec, NULL, NULL);
|
if (status != RPC_S_OK)
|
||||||
if (status != RPC_S_OK)
|
goto fail;
|
||||||
{
|
}
|
||||||
RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = RpcServerUseProtseqEpW(epm_protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
|
for (i = 0; i < ARRAY_SIZE(protseqs); ++i)
|
||||||
epm_endpoint, NULL);
|
{
|
||||||
if (status != RPC_S_OK)
|
status = RpcServerUseProtseqEpW(protseqs[i].protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
|
||||||
goto fail;
|
protseqs[i].endpoint, NULL);
|
||||||
|
if (status != RPC_S_OK)
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
status = RpcServerUseProtseqEpW(epm_protseq_lrpc, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
|
status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE);
|
||||||
epm_endpoint_lrpc, NULL);
|
if (status != RPC_S_OK)
|
||||||
if (status != RPC_S_OK)
|
goto fail;
|
||||||
goto fail;
|
|
||||||
|
|
||||||
status = RpcServerUseProtseqEpW(irot_protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
|
return RPC_S_OK;
|
||||||
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;
|
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE);
|
for (i = 0; i < j; ++i)
|
||||||
RpcServerUnregisterIf(Irot_v0_2_s_ifspec, NULL, FALSE);
|
RpcServerUnregisterIf(ifspecs[i], NULL, FALSE);
|
||||||
return FALSE;
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context )
|
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 )
|
static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
|
||||||
{
|
{
|
||||||
SERVICE_STATUS status;
|
SERVICE_STATUS status;
|
||||||
|
RPC_STATUS ret;
|
||||||
|
|
||||||
TRACE( "starting service\n" );
|
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 );
|
exit_event = CreateEventW( NULL, TRUE, FALSE, NULL );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue