#include <string.h>
#include <assert.h>
-
-
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#define DEFAULT_NCACN_HTTP_TIMEOUT (60 * 1000)
-#undef ARRAYSIZE
-#define ARRAYSIZE(a) (sizeof((a)) / sizeof((a)[0]))
-
WINE_DEFAULT_DEBUG_CHANNEL(rpc);
#ifdef __REACTOS__ /* FIXME: Inspect */
return r;
}
+#ifdef __REACTOS__
static char *ncacn_pipe_name(const char *server, const char *endpoint)
+#else
+static char *ncacn_pipe_name(const char *endpoint)
+#endif
{
+#ifdef __REACTOS__
static const char prefix[] = "\\\\";
static const char local[] = ".";
char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
+#else
+ static const char prefix[] = "\\\\.";
+#endif
char *pipe_name;
+
+#ifdef __REACTOS__
DWORD bufLen = ARRAYSIZE(ComputerName);
GetComputerNameA(ComputerName, &bufLen);
if (server == NULL || *server == 0 || stricmp(ComputerName, server) == 0)
server = local;
+#endif
/* protseq=ncacn_np: named pipes */
+#ifdef __REACTOS__
pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(server) + strlen(endpoint));
strcpy(pipe_name, prefix);
strcat(pipe_name, server);
strcat(pipe_name, endpoint);
+#else
+ pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
+ strcat(strcpy(pipe_name, prefix), endpoint);
+#endif
return pipe_name;
}
if (npc->pipe)
return RPC_S_OK;
+#ifdef __REACTOS__
pname = ncacn_pipe_name(Connection->NetworkAddr, Connection->Endpoint);
+#else
+ pname = ncacn_pipe_name(Connection->Endpoint);
+#endif
r = rpcrt4_conn_open_pipe(Connection, pname, FALSE);
I_RpcFree(pname);
if (r != RPC_S_OK)
return r;
+#ifdef __REACTOS__
((RpcConnection_np*)Connection)->listen_pipe = ncacn_pipe_name(NULL, Connection->Endpoint);
+#else
+ ((RpcConnection_np*)Connection)->listen_pipe = ncacn_pipe_name(Connection->Endpoint);
+#endif
r = rpcrt4_conn_create_pipe(Connection);
EnterCriticalSection(&protseq->cs);
char *pipe_name;
RPC_STATUS status;
+#ifdef __REACTOS__
pipe_name = ncacn_pipe_name(NULL, endpoint);
+#else
+ pipe_name = ncacn_pipe_name(endpoint);
+#endif
status = is_pipe_listening(pipe_name);
I_RpcFree(pipe_name);
return status;
static const WCHAR wszRpcProxy[] = {'R','p','c','P','r','o','x','y','=',0};
static const WCHAR wszHttpProxy[] = {'H','t','t','p','P','r','o','x','y','=',0};
- if (!strncmpiW(option, wszRpcProxy, sizeof(wszRpcProxy)/sizeof(wszRpcProxy[0])-1))
+ if (!strncmpiW(option, wszRpcProxy, ARRAY_SIZE(wszRpcProxy)-1))
{
- const WCHAR *value_start = option + sizeof(wszRpcProxy)/sizeof(wszRpcProxy[0])-1;
+ const WCHAR *value_start = option + ARRAY_SIZE(wszRpcProxy)-1;
const WCHAR *value_end;
const WCHAR *p;
TRACE("RpcProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
servername = RPCRT4_strndupW(value_start, value_end-value_start);
}
- else if (!strncmpiW(option, wszHttpProxy, sizeof(wszHttpProxy)/sizeof(wszHttpProxy[0])-1))
+ else if (!strncmpiW(option, wszHttpProxy, ARRAY_SIZE(wszHttpProxy)-1))
{
- const WCHAR *value_start = option + sizeof(wszHttpProxy)/sizeof(wszHttpProxy[0])-1;
+ const WCHAR *value_start = option + ARRAY_SIZE(wszHttpProxy)-1;
const WCHAR *value_end;
value_end = strchrW(option, ',');
{
static const WCHAR fmtW[] =
{'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','u','\r','\n',0};
- WCHAR header[sizeof(fmtW) / sizeof(fmtW[0]) + 10];
+ WCHAR header[ARRAY_SIZE(fmtW) + 10];
sprintfW(header, fmtW, len);
if ((HttpAddRequestHeadersW(request, header, -1, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD))) return RPC_S_OK;
}
auth_schemes[] =
{
- { basicW, ARRAYSIZE(basicW) - 1, RPC_C_HTTP_AUTHN_SCHEME_BASIC },
- { ntlmW, ARRAYSIZE(ntlmW) - 1, RPC_C_HTTP_AUTHN_SCHEME_NTLM },
- { passportW, ARRAYSIZE(passportW) - 1, RPC_C_HTTP_AUTHN_SCHEME_PASSPORT },
- { digestW, ARRAYSIZE(digestW) - 1, RPC_C_HTTP_AUTHN_SCHEME_DIGEST },
- { negotiateW, ARRAYSIZE(negotiateW) - 1, RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE }
+ { basicW, ARRAY_SIZE(basicW) - 1, RPC_C_HTTP_AUTHN_SCHEME_BASIC },
+ { ntlmW, ARRAY_SIZE(ntlmW) - 1, RPC_C_HTTP_AUTHN_SCHEME_NTLM },
+ { passportW, ARRAY_SIZE(passportW) - 1, RPC_C_HTTP_AUTHN_SCHEME_PASSPORT },
+ { digestW, ARRAY_SIZE(digestW) - 1, RPC_C_HTTP_AUTHN_SCHEME_DIGEST },
+ { negotiateW, ARRAY_SIZE(negotiateW) - 1, RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE }
};
-static const unsigned int num_auth_schemes = sizeof(auth_schemes)/sizeof(auth_schemes[0]);
static DWORD auth_scheme_from_header( const WCHAR *header )
{
unsigned int i;
- for (i = 0; i < num_auth_schemes; i++)
+ for (i = 0; i < ARRAY_SIZE(auth_schemes); i++)
{
if (!strncmpiW( header, auth_schemes[i].str, auth_schemes[i].len ) &&
(header[auth_schemes[i].len] == ' ' || !header[auth_schemes[i].len])) return auth_schemes[i].scheme;
static const WCHAR basicW[] = {'B','a','s','i','c',' '};
static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',' '};
static const WCHAR ntlmW[] = {'N','T','L','M',' '};
- int scheme_len, auth_len = sizeof(authW) / sizeof(authW[0]), len = ((data_len + 2) * 4) / 3;
+ int scheme_len, auth_len = ARRAY_SIZE(authW), len = ((data_len + 2) * 4) / 3;
const WCHAR *scheme_str;
WCHAR *header, *ptr;
RPC_STATUS status = RPC_S_SERVER_UNAVAILABLE;
{
case RPC_C_HTTP_AUTHN_SCHEME_BASIC:
scheme_str = basicW;
- scheme_len = sizeof(basicW) / sizeof(basicW[0]);
+ scheme_len = ARRAY_SIZE(basicW);
break;
case RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE:
scheme_str = negotiateW;
- scheme_len = sizeof(negotiateW) / sizeof(negotiateW[0]);
+ scheme_len = ARRAY_SIZE(negotiateW);
break;
case RPC_C_HTTP_AUTHN_SCHEME_NTLM:
scheme_str = ntlmW;
- scheme_len = sizeof(ntlmW) / sizeof(ntlmW[0]);
+ scheme_len = ARRAY_SIZE(ntlmW);
break;
default:
ERR("unknown scheme %u\n", scheme);
if (!url)
return RPC_S_OUT_OF_MEMORY;
memcpy(url, wszRpcProxyPrefix, sizeof(wszRpcProxyPrefix));
- MultiByteToWideChar(CP_ACP, 0, Connection->NetworkAddr, -1, url+sizeof(wszRpcProxyPrefix)/sizeof(wszRpcProxyPrefix[0])-1, strlen(Connection->NetworkAddr)+1);
+ MultiByteToWideChar(CP_ACP, 0, Connection->NetworkAddr, -1, url+ARRAY_SIZE(wszRpcProxyPrefix)-1,
+ strlen(Connection->NetworkAddr)+1);
strcatW(url, wszColon);
MultiByteToWideChar(CP_ACP, 0, Connection->Endpoint, -1, url+strlenW(url), strlen(Connection->Endpoint)+1);
const struct protseq_ops *rpcrt4_get_protseq_ops(const char *protseq)
{
unsigned int i;
- for(i=0; i<ARRAYSIZE(protseq_list); i++)
+ for(i = 0; i < ARRAY_SIZE(protseq_list); i++)
if (!strcmp(protseq_list[i].name, protseq))
return &protseq_list[i];
return NULL;
static const struct connection_ops *rpcrt4_get_conn_protseq_ops(const char *protseq)
{
unsigned int i;
- for(i=0; i<ARRAYSIZE(conn_protseq_list); i++)
+ for(i = 0; i < ARRAY_SIZE(conn_protseq_list); i++)
if (!strcmp(conn_protseq_list[i].name, protseq))
return &conn_protseq_list[i];
return NULL;
/* server-only */
if (connection->server_binding) RPCRT4_ReleaseBinding(connection->server_binding);
+ else if (connection->assoc) RpcAssoc_ConnectionReleased(connection->assoc);
if (connection->wait_release) SetEvent(connection->wait_release);
(floor4->count_lhs != sizeof(floor4->protid)))
return EPT_S_NOT_REGISTERED;
- for(i = 0; i < ARRAYSIZE(conn_protseq_list); i++)
+ for(i = 0; i < ARRAY_SIZE(conn_protseq_list); i++)
if ((protocol_floor->protid == conn_protseq_list[i].epm_protocols[0]) &&
(floor4->protid == conn_protseq_list[i].epm_protocols[1]))
{
TRACE("(%p)\n", protseqs);
- *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned short*)*ARRAYSIZE(protseq_list)));
+ *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned short*)*ARRAY_SIZE(protseq_list)));
if (!*protseqs)
goto end;
pvector = *protseqs;
pvector->Count = 0;
- for (i = 0; i < ARRAYSIZE(protseq_list); i++)
+ for (i = 0; i < ARRAY_SIZE(protseq_list); i++)
{
pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, (strlen(protseq_list[i].name)+1)*sizeof(unsigned short));
if (pvector->Protseq[i] == NULL)
TRACE("(%p)\n", protseqs);
- *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned char*)*ARRAYSIZE(protseq_list)));
+ *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned char*)*ARRAY_SIZE(protseq_list)));
if (!*protseqs)
goto end;
pvector = *protseqs;
pvector->Count = 0;
- for (i = 0; i < ARRAYSIZE(protseq_list); i++)
+ for (i = 0; i < ARRAY_SIZE(protseq_list); i++)
{
pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, strlen(protseq_list[i].name)+1);
if (pvector->Protseq[i] == NULL)