[RPCRT4] Import Wine commit 01290cd by Colin and Christoph: Implement RpcBindingServe...
[reactos.git] / reactos / dll / win32 / rpcrt4 / rpc_binding.c
index 9916fad..cd88568 100644 (file)
@@ -1102,7 +1102,7 @@ RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc,
 {
     RpcAuthInfo *AuthInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(*AuthInfo));
     if (!AuthInfo)
-        return ERROR_OUTOFMEMORY;
+        return RPC_S_OUT_OF_MEMORY;
 
     AuthInfo->refs = 1;
     AuthInfo->AuthnLevel = AuthnLevel;
@@ -1122,7 +1122,7 @@ RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc,
         if (!AuthInfo->nt_identity)
         {
             HeapFree(GetProcessHeap(), 0, AuthInfo);
-            return ERROR_OUTOFMEMORY;
+            return RPC_S_OUT_OF_MEMORY;
         }
 
         AuthInfo->nt_identity->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
@@ -1151,7 +1151,7 @@ RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc,
             HeapFree(GetProcessHeap(), 0, AuthInfo->nt_identity->Password);
             HeapFree(GetProcessHeap(), 0, AuthInfo->nt_identity);
             HeapFree(GetProcessHeap(), 0, AuthInfo);
-            return ERROR_OUTOFMEMORY;
+            return RPC_S_OUT_OF_MEMORY;
         }
     }
     else
@@ -1475,7 +1475,7 @@ RpcBindingInqAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR *ServerPrincName,
     {
         *ServerPrincName = (RPC_CSTR)RPCRT4_strdupWtoA(principal);
         RpcStringFreeW(&principal);
-        if (!*ServerPrincName) return ERROR_OUTOFMEMORY;
+        if (!*ServerPrincName) return RPC_S_OUT_OF_MEMORY;
     }
 
     return status;
@@ -1507,7 +1507,7 @@ RpcBindingInqAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR *ServerPrincName,
         if (bind->AuthInfo->server_principal_name)
         {
             *ServerPrincName = RPCRT4_strdupW(bind->AuthInfo->server_principal_name);
-            if (!*ServerPrincName) return ERROR_OUTOFMEMORY;
+            if (!*ServerPrincName) return RPC_S_OUT_OF_MEMORY;
         }
         else *ServerPrincName = NULL;
     }
@@ -1588,7 +1588,7 @@ RpcBindingInqAuthClientExA( RPC_BINDING_HANDLE ClientBinding, RPC_AUTHZ_HANDLE *
     if (status == RPC_S_OK && ServerPrincName)
     {
         *ServerPrincName = (RPC_CSTR)RPCRT4_strdupWtoA(principal);
-        if (!*ServerPrincName && principal) status = ERROR_OUTOFMEMORY;
+        if (!*ServerPrincName && principal) status = RPC_S_OUT_OF_MEMORY;
         RpcStringFreeW(&principal);
     }
 
@@ -1615,6 +1615,30 @@ RpcBindingInqAuthClientExW( RPC_BINDING_HANDLE ClientBinding, RPC_AUTHZ_HANDLE *
                                            AuthnSvc, AuthzSvc, Flags);
 }
 
+/***********************************************************************
+ *             RpcBindingServerFromClient (RPCRT4.@)
+ */
+RPCRTAPI RPC_STATUS RPC_ENTRY
+RpcBindingServerFromClient(RPC_BINDING_HANDLE ClientBinding, RPC_BINDING_HANDLE* ServerBinding)
+{
+    RpcBinding* bind = ClientBinding;
+    RpcBinding* NewBinding;
+
+    if (!bind)
+        bind = I_RpcGetCurrentCallHandle();
+
+    if (!bind->server)
+        return RPC_S_INVALID_BINDING;
+
+    RPCRT4_AllocBinding(&NewBinding, TRUE);
+    NewBinding->Protseq = RPCRT4_strdupA(bind->Protseq);
+    NewBinding->NetworkAddr = RPCRT4_strdupA(bind->NetworkAddr);
+
+    *ServerBinding = NewBinding;
+
+    return RPC_S_OK;
+}
+
 /***********************************************************************
  *             RpcBindingSetAuthInfoExA (RPCRT4.@)
  */
@@ -1733,7 +1757,7 @@ RpcBindingSetAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR ServerPrincName,
       else
       {
         RpcAuthInfo_Release(new_auth_info);
-        r = ERROR_OUTOFMEMORY;
+        r = RPC_S_OUT_OF_MEMORY;
       }
     }
     else
@@ -1864,7 +1888,7 @@ RpcBindingSetAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName,
       else
       {
         RpcAuthInfo_Release(new_auth_info);
-        r = ERROR_OUTOFMEMORY;
+        r = RPC_S_OUT_OF_MEMORY;
       }
     }
     else
@@ -1918,7 +1942,7 @@ RPC_STATUS WINAPI RpcBindingSetOption(RPC_BINDING_HANDLE BindingHandle, ULONG Op
         int len = MultiByteToWideChar(CP_ACP, 0, cookie->Buffer, cookie->BufferSize, NULL, 0);
         WCHAR *str;
 
-        if (!(str = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)))) return ERROR_OUTOFMEMORY;
+        if (!(str = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)))) return RPC_S_OUT_OF_MEMORY;
         MultiByteToWideChar(CP_ACP, 0, cookie->Buffer, cookie->BufferSize, str, len);
         str[len] = 0;
         HeapFree(GetProcessHeap(), 0, binding->CookieAuth);
@@ -1931,3 +1955,13 @@ RPC_STATUS WINAPI RpcBindingSetOption(RPC_BINDING_HANDLE BindingHandle, ULONG Op
     }
     return RPC_S_OK;
 }
+
+/***********************************************************************
+ *             I_RpcBindingInqLocalClientPID (RPCRT4.@)
+ */
+
+RPC_STATUS WINAPI I_RpcBindingInqLocalClientPID(RPC_BINDING_HANDLE ClientBinding, ULONG *ClientPID)
+{
+    FIXME("%p %p: stub\n", ClientBinding, ClientPID);
+    return RPC_S_INVALID_BINDING;
+}