Keep track of per-column information inside the listview.
[wine] / dlls / rpcrt4 / ndr_midl.c
1 /*
2  * MIDL proxy/stub stuff
3  *
4  * Copyright 2002 Ove Kåven, TransGaming Technologies
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  * TODO:
21  *  - figure out whether we *really* got this right
22  *  - check for errors and throw exceptions
23  */
24
25 #include <stdio.h>
26 #include <string.h>
27
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winerror.h"
31 #include "winreg.h"
32
33 #include "wine/obj_base.h"
34 #include "wine/obj_channel.h"
35
36 #include "rpcproxy.h"
37
38 #include "wine/debug.h"
39
40 #include "cpsf.h"
41 #include "ndr_misc.h"
42
43 WINE_DEFAULT_DEBUG_CHANNEL(ole);
44
45 /***********************************************************************
46  *           NdrProxyInitialize [RPCRT4.@]
47  */
48 void WINAPI NdrProxyInitialize(void *This,
49                               PRPC_MESSAGE pRpcMsg,
50                               PMIDL_STUB_MESSAGE pStubMsg,
51                               PMIDL_STUB_DESC pStubDescriptor,
52                               unsigned int ProcNum)
53 {
54   HRESULT hr;
55
56   TRACE("(%p,%p,%p,%p,%d)\n", This, pRpcMsg, pStubMsg, pStubDescriptor, ProcNum);
57   memset(pRpcMsg, 0, sizeof(RPC_MESSAGE));
58   memset(pStubMsg, 0, sizeof(MIDL_STUB_MESSAGE));
59   pRpcMsg->ProcNum = ProcNum;
60   pRpcMsg->RpcInterfaceInformation = pStubDescriptor->RpcInterfaceInformation;
61   pStubMsg->RpcMsg = pRpcMsg;
62   pStubMsg->IsClient = 1;
63   pStubMsg->ReuseBuffer = 1;
64   pStubMsg->pfnAllocate = pStubDescriptor->pfnAllocate;
65   pStubMsg->pfnFree = pStubDescriptor->pfnFree;
66   pStubMsg->StubDesc = pStubDescriptor;
67   if (This) StdProxy_GetChannel(This, &pStubMsg->pRpcChannelBuffer);
68   if (pStubMsg->pRpcChannelBuffer) {
69     hr = IRpcChannelBuffer_GetDestCtx(pStubMsg->pRpcChannelBuffer,
70                                      &pStubMsg->dwDestContext,
71                                      &pStubMsg->pvDestContext);
72   }
73   TRACE("channel=%p\n", pStubMsg->pRpcChannelBuffer);
74 }
75
76 /***********************************************************************
77  *           NdrProxyGetBuffer [RPCRT4.@]
78  */
79 void WINAPI NdrProxyGetBuffer(void *This,
80                              PMIDL_STUB_MESSAGE pStubMsg)
81 {
82   HRESULT hr;
83   const IID *riid = NULL;
84
85   TRACE("(%p,%p)\n", This, pStubMsg);
86   pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
87   pStubMsg->dwStubPhase = PROXY_GETBUFFER;
88   hr = StdProxy_GetIID(This, &riid);
89   hr = IRpcChannelBuffer_GetBuffer(pStubMsg->pRpcChannelBuffer,
90                                   (RPCOLEMESSAGE*)pStubMsg->RpcMsg,
91                                   riid);
92   pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
93   pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
94   pStubMsg->Buffer = pStubMsg->BufferStart;
95   pStubMsg->dwStubPhase = PROXY_MARSHAL;
96 }
97
98 /***********************************************************************
99  *           NdrProxySendReceive [RPCRT4.@]
100  */
101 void WINAPI NdrProxySendReceive(void *This,
102                                PMIDL_STUB_MESSAGE pStubMsg)
103 {
104   ULONG Status = 0;
105   HRESULT hr;
106
107   TRACE("(%p,%p)\n", This, pStubMsg);
108   pStubMsg->dwStubPhase = PROXY_SENDRECEIVE;
109   hr = IRpcChannelBuffer_SendReceive(pStubMsg->pRpcChannelBuffer,
110                                     (RPCOLEMESSAGE*)pStubMsg->RpcMsg,
111                                     &Status);
112   pStubMsg->dwStubPhase = PROXY_UNMARSHAL;
113   pStubMsg->BufferLength = pStubMsg->RpcMsg->BufferLength;
114   pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
115   pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
116   pStubMsg->Buffer = pStubMsg->BufferStart;
117 }
118
119 /***********************************************************************
120  *           NdrProxyFreeBuffer [RPCRT4.@]
121  */
122 void WINAPI NdrProxyFreeBuffer(void *This,
123                               PMIDL_STUB_MESSAGE pStubMsg)
124 {
125   HRESULT hr;
126
127   TRACE("(%p,%p)\n", This, pStubMsg);
128   hr = IRpcChannelBuffer_FreeBuffer(pStubMsg->pRpcChannelBuffer,
129                                    (RPCOLEMESSAGE*)pStubMsg->RpcMsg);
130 }
131
132 /***********************************************************************
133  *           NdrStubInitialize [RPCRT4.@]
134  */
135 void WINAPI NdrStubInitialize(PRPC_MESSAGE pRpcMsg,
136                              PMIDL_STUB_MESSAGE pStubMsg,
137                              PMIDL_STUB_DESC pStubDescriptor,
138                              LPRPCCHANNELBUFFER pRpcChannelBuffer)
139 {
140   TRACE("(%p,%p,%p,%p)\n", pRpcMsg, pStubMsg, pStubDescriptor, pRpcChannelBuffer);
141   memset(pStubMsg, 0, sizeof(MIDL_STUB_MESSAGE));
142   pStubMsg->RpcMsg = pRpcMsg;
143   pStubMsg->IsClient = 0;
144   pStubMsg->ReuseBuffer = 1;
145   pStubMsg->pfnAllocate = pStubDescriptor->pfnAllocate;
146   pStubMsg->pfnFree = pStubDescriptor->pfnFree;
147   pStubMsg->StubDesc = pStubDescriptor;
148   pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;
149   pStubMsg->BufferLength = pStubMsg->RpcMsg->BufferLength;
150   pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
151   pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
152   pStubMsg->Buffer = pStubMsg->BufferStart;
153 }
154
155 /***********************************************************************
156  *           NdrStubGetBuffer [RPCRT4.@]
157  */
158 void WINAPI NdrStubGetBuffer(LPRPCSTUBBUFFER This,
159                             LPRPCCHANNELBUFFER pRpcChannelBuffer,
160                             PMIDL_STUB_MESSAGE pStubMsg)
161 {
162   TRACE("(%p,%p)\n", This, pStubMsg);
163   pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;
164   pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
165   I_RpcGetBuffer(pStubMsg->RpcMsg); /* ? */
166   pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
167   pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
168   pStubMsg->Buffer = pStubMsg->BufferStart;
169 }