Define NULL if it's not defined already.
[wine] / include / rpcndr.h
1 /*
2  * Copyright (C) 2000 Francois Gouget
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #ifndef __RPCNDR_H_VERSION__
20 /* FIXME: What version?   Perhaps something is better than nothing, however incorrect */
21 #define __RPCNDR_H_VERSION__ ( 399 )
22 #endif
23
24 #ifndef __WINE_RPCNDR_H
25 #define __WINE_RPCNDR_H
26
27 #include "basetsd.h"
28 #include "rpcdcep.h"
29
30 /* stupid #if can't handle casts... this __stupidity 
31    is just a workaround for that limitation */
32
33 #define __NDR_CHAR_REP_MASK  0x000fL
34 #define __NDR_INT_REP_MASK   0x00f0L
35 #define __NDR_FLOAT_REP_MASK 0xff00L
36
37 #define __NDR_IEEE_FLOAT     0x0000L
38 #define __NDR_VAX_FLOAT      0x0100L
39 #define __NDR_IBM_FLOAT      0x0300L
40
41 #define __NDR_ASCII_CHAR     0x0000L
42 #define __NDR_EBCDIC_CHAR    0x0001L
43
44 #define __NDR_LITTLE_ENDIAN  0x0010L
45 #define __NDR_BIG_ENDIAN     0x0000L
46
47 /* Mac's are special */
48 #if defined(__RPC_MAC__)
49   #define __NDR_LOCAL_DATA_REPRESENTATION \
50     (__NDR_IEEE_FLOAT | __NDR_ASCII_CHAR | __NDR_BIG_ENDIAN)
51 #else
52   #define __NDR_LOCAL_DATA_REPRESENTATION \
53     (__NDR_IEEE_FLOAT | __NDR_ASCII_CHAR | __NDR_LITTLE_ENDIAN)
54 #endif
55
56 #define __NDR_LOCAL_ENDIAN \
57   (__NDR_LOCAL_DATA_REPRESENTATION & __NDR_INT_REP_MASK)
58
59 /* for convenience, define NDR_LOCAL_IS_BIG_ENDIAN iff it is */
60 #if __NDR_LOCAL_ENDIAN == __NDR_BIG_ENDIAN
61   #define NDR_LOCAL_IS_BIG_ENDIAN
62 #elif __NDR_LOCAL_ENDIAN == __NDR_LITTLE_ENDIAN
63   #undef NDR_LOCAL_IS_BIG_ENDIAN
64 #else
65   #error alien NDR_LOCAL_ENDIAN - Greg botched the defines again, please report
66 #endif
67
68 /* finally, do the casts like Microsoft */
69
70 #define NDR_CHAR_REP_MASK             ((unsigned long) __NDR_CHAR_REP_MASK)
71 #define NDR_INT_REP_MASK              ((unsigned long) __NDR_INT_REP_MASK)
72 #define NDR_FLOAT_REP_MASK            ((unsigned long) __NDR_FLOAT_REP_MASK)
73 #define NDR_IEEE_FLOAT                ((unsigned long) __NDR_IEEE_FLOAT)
74 #define NDR_VAX_FLOAT                 ((unsigned long) __NDR_VAX_FLOAT)
75 #define NDR_IBM_FLOAT                 ((unsigned long) __NDR_IBM_FLOAT)
76 #define NDR_ASCII_CHAR                ((unsigned long) __NDR_ASCII_CHAR)
77 #define NDR_EBCDIC_CHAR               ((unsigned long) __NDR_EBCDIC_CHAR)
78 #define NDR_LITTLE_ENDIAN             ((unsigned long) __NDR_LITTLE_ENDIAN)
79 #define NDR_BIG_ENDIAN                ((unsigned long) __NDR_BIG_ENDIAN)
80 #define NDR_LOCAL_DATA_REPRESENTATION ((unsigned long) __NDR_LOCAL_DATA_REPRESENTATION)
81 #define NDR_LOCAL_ENDIAN              ((unsigned long) __NDR_LOCAL_ENDIAN)
82
83
84 #define TARGET_IS_NT50_OR_LATER 1
85 #define TARGET_IS_NT40_OR_LATER 1
86 #define TARGET_IS_NT351_OR_WIN95_OR_LATER 1
87
88 typedef unsigned char byte;
89 #define hyper __int64
90 #define MIDL_uhyper unsigned __int64
91 /* 'boolean' tend to conflict, let's call it _wine_boolean */
92 typedef unsigned char _wine_boolean;
93 /* typedef _wine_boolean boolean; */
94
95 #define __RPC_CALLEE WINAPI
96 #define RPC_VAR_ENTRY WINAPIV
97
98 typedef struct
99 {
100   void *pad[2];
101   void *userContext;
102 } *NDR_SCONTEXT;
103
104 #define NDRSContextValue(hContext) (&(hContext)->userContext)
105 #define cbNDRContext 20
106
107 typedef void (__RPC_USER *NDR_RUNDOWN)(void *context);
108 typedef void (__RPC_USER *NDR_NOTIFY_ROUTINE)(void);
109 typedef void (__RPC_USER *NDR_NOTIFY2_ROUTINE)(_wine_boolean flag);
110
111 #define DECLSPEC_UUID(x)
112 #define MIDL_INTERFACE(x)   struct
113
114 struct _MIDL_STUB_MESSAGE;
115 struct _MIDL_STUB_DESC;
116 struct _FULL_PTR_XLAT_TABLES;
117
118 typedef void (__RPC_USER *EXPR_EVAL)(struct _MIDL_STUB_MESSAGE *);
119 typedef const unsigned char *PFORMAT_STRING;
120
121 typedef struct
122 {
123   long Dimension;
124   unsigned long *BufferConformanceMark;
125   unsigned long *BufferVarianceMark;
126   unsigned long *MaxCountArray;
127   unsigned long *OffsetArray;
128   unsigned long *ActualCountArray;
129 } ARRAY_INFO, *PARRAY_INFO;
130
131 typedef struct _NDR_PIPE_DESC *PNDR_PIPE_DESC;
132 typedef struct _NDR_PIPE_MESSAGE *PNDR_PIPE_MESSAGE;
133 typedef struct _NDR_ASYNC_MESSAGE *PNDR_ASYNC_MESSAGE;
134 typedef struct _NDR_CORRELATION_INFO *PNDR_CORRELATION_INFO;
135
136 #include "pshpack4.h"
137 typedef struct _MIDL_STUB_MESSAGE
138 {
139   PRPC_MESSAGE RpcMsg;
140   unsigned char *Buffer;
141   unsigned char *BufferStart;
142   unsigned char *BufferEnd;
143   unsigned char *BufferMark;
144   unsigned long BufferLength;
145   unsigned long MemorySize;
146   unsigned char *Memory;
147   int IsClient;
148   int ReuseBuffer;
149   unsigned char *AllocAllNodesMemory;
150   unsigned char *AllocAllNodesMemoryEnd;
151   int IgnoreEmbeddedPointers;
152   unsigned char *PointerBufferMark;
153   unsigned char fBufferValid;
154   unsigned char Unused;
155   ULONG_PTR MaxCount;
156   unsigned long Offset;
157   unsigned long ActualCount;
158   void * (__RPC_API *pfnAllocate)(size_t);
159   void (__RPC_API *pfnFree)(void *);
160   unsigned char *StackTop;
161   unsigned char *pPresentedType;
162   unsigned char *pTransmitType;
163   handle_t SavedHandle;
164   const struct _MIDL_STUB_DESC *StubDesc;
165   struct _FULL_PTR_XLAT_TABLES *FullPtrXlatTables;
166   unsigned long FullPtrRefId;
167   unsigned long ulUnused1;
168   int fInDontFree:1;
169   int fDontCallFreeInst:1;
170   int fInOnlyParam:1;
171   int fHasReturn:1;
172   int fHasExtensions:1;
173   int fHasNewCorrDesc:1;
174   int fUnused:10;
175   unsigned long dwDestContext;
176   void *pvDestContext;
177   NDR_SCONTEXT *SavedContextHandles;
178   long ParamNumber;
179   struct IRpcChannelBuffer *pRpcChannelBuffer;
180   PARRAY_INFO pArrayInfo;
181   unsigned long *SizePtrCountArray;
182   unsigned long *SizePtrOffsetArray;
183   unsigned long *SizePtrLengthArray;
184   void *pArgQueue;
185   unsigned long dwStubPhase;
186   PNDR_PIPE_DESC pPipeDesc;
187   PNDR_ASYNC_MESSAGE pAsyncMsg;
188   PNDR_CORRELATION_INFO pCorrInfo;
189   unsigned char *pCorrMemory;
190   void *pMemoryList;
191   ULONG_PTR w2kReserved[5];
192 } MIDL_STUB_MESSAGE, *PMIDL_STUB_MESSAGE;
193 #include "poppack.h"
194
195 typedef struct _GENERIC_BINDING_ROUTINE_PAIR GENERIC_BINDING_ROUTINE_PAIR, *PGENERIC_BINDING_ROUTINE_PAIR;
196
197 typedef struct __GENERIC_BINDING_INFO GENERIC_BINDING_INFO, *PGENERIC_BINDING_INFO;
198
199 typedef struct _XMIT_ROUTINE_QUINTUPLE XMIT_ROUTINE_QUINTUPLE, *PXMIT_ROUTINE_QUINTUPLE;
200
201 typedef struct _USER_MARSHAL_ROUTINE_QUADRUPLE USER_MARSHAL_ROUTINE_QUADRUPLE;
202
203 typedef struct _MALLOC_FREE_STRUCT MALLOC_FREE_STRUCT;
204
205 typedef struct _COMM_FAULT_OFFSETS COMM_FAULT_OFFSETS;
206
207 typedef struct _MIDL_STUB_DESC
208 {
209   void *RpcInterfaceInformation;
210   void * (__RPC_API *pfnAllocate)(size_t);
211   void (__RPC_API *pfnFree)(void *);
212   union {
213     handle_t *pAutoHandle;
214     handle_t *pPrimitiveHandle;
215     PGENERIC_BINDING_INFO pGenericBindingInfo;
216   } IMPLICIT_HANDLE_INFO;
217   const NDR_RUNDOWN *apfnNdrRundownRoutines;
218   const GENERIC_BINDING_ROUTINE_PAIR *aGenericBindingRoutinePairs;
219   const EXPR_EVAL *apfnExprEval;
220   const XMIT_ROUTINE_QUINTUPLE *aXmitQuintuple;
221   const unsigned char *pFormatTypes;
222   int fCheckBounds;
223   unsigned long Version;
224   MALLOC_FREE_STRUCT *pMallocFreeStruct;
225   long MIDLVersion;
226   const COMM_FAULT_OFFSETS *CommFaultOffsets;
227   const USER_MARSHAL_ROUTINE_QUADRUPLE *aUserMarshalQuadruple;
228   const NDR_NOTIFY_ROUTINE *NotifyRoutineTable;
229   ULONG_PTR mFlags;
230   ULONG_PTR Reserved3;
231   ULONG_PTR Reserved4;
232   ULONG_PTR Reserved5;
233 } MIDL_STUB_DESC;
234 typedef const MIDL_STUB_DESC *PMIDL_STUB_DESC;
235
236 typedef struct _MIDL_FORMAT_STRING
237 {
238   short Pad;
239 #if defined(__GNUC__)
240   unsigned char Format[0];
241 #else
242   unsigned char Format[1];
243 #endif
244 } MIDL_FORMAT_STRING;
245
246 typedef void (__RPC_API *STUB_THUNK)( PMIDL_STUB_MESSAGE );
247
248 typedef long (__RPC_API *SERVER_ROUTINE)();
249
250 typedef struct _MIDL_SERVER_INFO_
251 {
252   PMIDL_STUB_DESC pStubDesc;
253   const SERVER_ROUTINE *DispatchTable;
254   PFORMAT_STRING ProcString;
255   const unsigned short *FmtStringOffset;
256   const STUB_THUNK *ThunkTable;
257   PFORMAT_STRING LocalFormatTypes;
258   PFORMAT_STRING LocalProcString;
259   const unsigned short *LocalFmtStringOffset;
260 } MIDL_SERVER_INFO, *PMIDL_SERVER_INFO;
261
262 typedef struct _MIDL_STUBLESS_PROXY_INFO
263 {
264   PMIDL_STUB_DESC pStubDesc;
265   PFORMAT_STRING ProcFormatString;
266   const unsigned short *FormatStringOffset;
267   PFORMAT_STRING LocalFormatTypes;
268   PFORMAT_STRING LocalProcStrings;
269   const unsigned short *LocalFmtStringOffset;
270 } MIDL_STUBLESS_PROXY_INFO, *PMIDL_STUBLESS_PROXY_INFO;
271
272 typedef union _CLIENT_CALL_RETURN
273 {
274   void *Pointer;
275   LONG_PTR Simple;
276 } CLIENT_CALL_RETURN;
277
278 typedef enum {
279   STUB_UNMARSHAL,
280   STUB_CALL_SERVER,
281   STUB_MARSHAL,
282   STUB_CALL_SERVER_NO_HRESULT
283 } STUB_PHASE;
284
285 typedef enum {
286   PROXY_CALCSIZE,
287   PROXY_GETBUFFER,
288   PROXY_MARSHAL,
289   PROXY_SENDRECEIVE,
290   PROXY_UNMARSHAL
291 } PROXY_PHASE;
292
293 struct IRpcStubBuffer;
294
295 RPCRTAPI void RPC_ENTRY
296   NdrSimpleTypeMarshall( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, unsigned char FormatChar );
297 RPCRTAPI void RPC_ENTRY
298   NdrSimpleTypeUnmarshall( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, unsigned char FormatChar );
299
300 /* while MS declares each prototype separately, I prefer to use macros for this kind of thing instead */
301 #define SIMPLE_TYPE_MARSHAL(type) \
302 RPCRTAPI unsigned char* RPC_ENTRY \
303   Ndr##type##Marshall( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat ); \
304 RPCRTAPI unsigned char* RPC_ENTRY \
305   Ndr##type##Unmarshall( PMIDL_STUB_MESSAGE pStubMsg, unsigned char** ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc ); \
306 RPCRTAPI void RPC_ENTRY \
307   Ndr##type##BufferSize( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat ); \
308 RPCRTAPI unsigned long RPC_ENTRY \
309   Ndr##type##MemorySize( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat );
310
311 #define TYPE_MARSHAL(type) \
312   SIMPLE_TYPE_MARSHAL(type) \
313 RPCRTAPI void RPC_ENTRY \
314   Ndr##type##Free( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat );
315
316 TYPE_MARSHAL(Pointer)
317 TYPE_MARSHAL(SimpleStruct)
318 TYPE_MARSHAL(ConformantStruct)
319 TYPE_MARSHAL(ConformantVaryingStruct)
320 TYPE_MARSHAL(ComplexStruct)
321 TYPE_MARSHAL(FixedArray)
322 TYPE_MARSHAL(ConformantArray)
323 TYPE_MARSHAL(ConformantVaryingArray)
324 TYPE_MARSHAL(VaryingArray)
325 TYPE_MARSHAL(ComplexArray)
326 TYPE_MARSHAL(EncapsulatedUnion)
327 TYPE_MARSHAL(NonEncapsulatedUnion)
328 TYPE_MARSHAL(ByteCountPointer)
329 TYPE_MARSHAL(XmitOrRepAs)
330 TYPE_MARSHAL(UserMarshal)
331 TYPE_MARSHAL(InterfacePointer)
332
333 SIMPLE_TYPE_MARSHAL(ConformantString)
334 SIMPLE_TYPE_MARSHAL(NonConformantString)
335
336 #undef TYPE_MARSHAL
337 #undef SIMPLE_TYPE_MARSHAL
338
339 RPCRTAPI void RPC_ENTRY
340   NdrConvert2( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, long NumberParams );
341 RPCRTAPI void RPC_ENTRY
342   NdrConvert( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat );
343
344 LONG_PTR /* CLIENT_CALL_RETURN */ RPC_VAR_ENTRY
345   NdrClientCall2( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ... );
346 LONG_PTR /* CLIENT_CALL_RETURN */ RPC_VAR_ENTRY
347   NdrClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ... );
348
349 RPCRTAPI void RPC_ENTRY
350   NdrServerCall2( PRPC_MESSAGE pRpcMsg );
351 RPCRTAPI void RPC_ENTRY
352   NdrServerCall( PRPC_MESSAGE pRpcMsg );
353
354 RPCRTAPI long RPC_ENTRY
355   NdrStubCall2( struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, LPDWORD pdwStubPhase );
356 RPCRTAPI long RPC_ENTRY
357   NdrStubCall( struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, LPDWORD pdwStubPhase );
358
359 RPCRTAPI void* RPC_ENTRY
360   NdrOleAllocate( size_t Size );
361 RPCRTAPI void RPC_ENTRY
362   NdrOleFree( void* NodeToFree );
363
364 RPCRTAPI void RPC_ENTRY
365   NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE pStubMsg, 
366                           PMIDL_STUB_DESC pStubDesc, unsigned int ProcNum );
367 RPCRTAPI unsigned char* RPC_ENTRY
368   NdrServerInitializeNew( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg, PMIDL_STUB_DESC pStubDesc );  
369 RPCRTAPI unsigned char* RPC_ENTRY
370   NdrGetBuffer( MIDL_STUB_MESSAGE *stubmsg, unsigned long buflen, RPC_BINDING_HANDLE handle );
371 RPCRTAPI void RPC_ENTRY
372   NdrFreeBuffer( MIDL_STUB_MESSAGE *pStubMsg );
373 RPCRTAPI unsigned char* RPC_ENTRY
374   NdrSendReceive( MIDL_STUB_MESSAGE *stubmsg, unsigned char *buffer );
375
376 #endif /*__WINE_RPCNDR_H */