Release 951003
[wine/multimedia.git] / toolkit / miscstubs.c
blob5db9016bb0d93cd2eec1727710e196eccedb7a76
1 /*
2 * JBP (Jim Peterson <jspeter@birch.ee.vt.edu>): Lots of stubs needed for
3 * libwine.a.
4 */
6 #include <stdarg.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include "dde_mem.h"
11 #include "windows.h"
12 #include "global.h"
13 #include "debug.h"
15 int CallTo32_LargeStack( int (*func)(), int nbargs, ...)
17 va_list arglist;
18 int i,a[32];
20 va_start(arglist,nbargs);
22 for(i=0; i<nbargs; i++) a[i]=va_arg(arglist,int);
24 switch(nbargs) /* Ewww... Icky. But what can I do? */
26 case 5: return func(a[0],a[1],a[2],a[3],a[4]);
27 case 6: return func(a[0],a[1],a[2],a[3],a[4],a[5]);
28 case 8: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]);
29 case 10: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],
30 a[7],a[8],a[9]);
31 case 11: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],
32 a[7],a[8],a[9],a[10]);
33 case 14: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],
34 a[7],a[8],a[9],a[10],a[11],a[12],a[13]);
35 default: fprintf(stderr,"JBP: CallTo32_LargeStack called with unsupported "
36 "number of arguments (%d). Ignored.\n",nbargs);
37 return 0;
41 WORD CallTo16_word_ ( FARPROC func, WORD arg ) { return func(arg); }
43 /* typedef void* ATOM; */
44 /* ATOM GlobalAddAtom(char *n) */
45 /* { */
46 /* return strdup(n); */
47 /* } */
48 /* GlobalDeleteAtom(ATOM n) */
49 /* { */
50 /* free(n); */
51 /* } */
52 /* GlobalFindAtom(char*n) */
53 /* { */
54 /* fprintf(stderr,"JBP: GlobalFindAtom() ignored.\n"); */
55 /* return 0; */
56 /* } */
57 /* char *GlobalGetAtomName(ATOM a) */
58 /* { */
59 /* return a; */
60 /* } */
62 void GlobalFreeAll(HANDLE owner)
64 fprintf(stderr,"JBP: GlobalFreeAll() ignored.\n");
67 SEGPTR WIN16_GlobalLock(HGLOBAL h)
69 return (SEGPTR)h;
74 #if 0
75 typedef WORD* HLOCAL;
77 int IsValidHLOCAL(HLOCAL handle)
79 return *(handle-1) + *(handle-2) == 0; /* Valid HLOCAL's sum to 0 */
82 /***********************************************************************
83 * LOCAL_Free
86 HLOCAL LOCAL_Free( WORD ds, HLOCAL handle )
88 if (!IsValidHLOCAL(handle)) return handle; /* couldn't free it */
89 free(handle-2);
90 return 0;
94 /***********************************************************************
95 * LOCAL_Alloc
98 HLOCAL LOCAL_Alloc( WORD ds, WORD flags, WORD size )
100 HLOCAL handle;
102 handle = malloc(size + 2*sizeof(WORD));
103 handle += 2;
104 *(handle-2) = size;
105 *(handle-1) = -size;
106 return handle;
110 /***********************************************************************
111 * LOCAL_ReAlloc
114 HLOCAL LOCAL_ReAlloc( WORD ds, HLOCAL handle, WORD size, WORD flags )
116 HLOCAL newhandle;
118 if(!IsValidHLOCAL(handle))return 0;
119 newhandle = realloc(handle-2, size+2*sizeof(WORD));
120 newhandle += 2;
121 *(newhandle-2) = size;
122 *(newhandle-1) = -size;
123 return newhandle;
127 /***********************************************************************
128 * LOCAL_Lock
130 WORD LOCAL_Lock( WORD ds, HLOCAL handle )
132 if(!IsValidHLOCAL(handle))return 0;
133 return handle;
137 /***********************************************************************
138 * LOCAL_Unlock
140 BOOL LOCAL_Unlock( WORD ds, HLOCAL handle )
142 return TRUE;
146 /***********************************************************************
147 * LOCAL_Size
150 WORD LOCAL_Size( WORD ds, HLOCAL handle )
152 return *(handle-2);
154 #endif
156 HLOCAL LOCAL_Free( WORD ds, HLOCAL handle )
158 fprintf(stderr,"JBP: LOCAL_*() ignored.\n");
159 return 0;
162 HLOCAL LOCAL_Alloc( WORD ds, WORD flags, WORD size )
164 fprintf(stderr,"JBP: LOCAL_*() ignored.\n");
165 return 0;
168 HLOCAL LOCAL_ReAlloc( WORD ds, HLOCAL handle, WORD size, WORD flags )
170 fprintf(stderr,"JBP: LOCAL_*() ignored.\n");
171 return 0;
174 WORD LOCAL_Lock( WORD ds, HLOCAL handle )
176 fprintf(stderr,"JBP: LOCAL_*() ignored.\n");
177 return 0;
180 BOOL LOCAL_Unlock( WORD ds, HLOCAL handle )
182 fprintf(stderr,"JBP: LOCAL_*() ignored.\n");
183 return 1;
186 WORD LOCAL_Size( WORD ds, HLOCAL handle )
188 fprintf(stderr,"JBP: LOCAL_*() ignored.\n");
189 return 0;
192 void FarSetOwner(HANDLE a, WORD b)
194 fprintf(stderr,"JBP: FarSetOwner() ignored.\n");
197 #define GLOBAL_MAX_ALLOC_SIZE 0x00ff0000 /* Largest allocation is 16M - 64K */
199 HGLOBAL GLOBAL_Alloc( WORD flags, DWORD size, HGLOBAL hOwner,
200 BOOL isCode, BOOL is32Bit, BOOL isReadOnly )
202 void *ptr;
203 HGLOBAL handle;
204 SHMDATA shmdata;
206 dprintf_global( stddeb, "GLOBAL_Alloc: %ld flags=%04x\n", size, flags );
208 /* Fixup the size */
210 if (size >= GLOBAL_MAX_ALLOC_SIZE - 0x1f) return 0;
211 if (size == 0) size = 0x20;
212 else size = (size + 0x1f) & ~0x1f;
214 /* Allocate the linear memory */
216 #ifdef CONFIG_IPC
217 if ((flags & GMEM_DDESHARE) && Options.ipc)
218 ptr = DDE_malloc(flags, size, &shmdata);
219 else
220 #endif /* CONFIG_IPC */
221 ptr = malloc( size );
222 if (!ptr) return 0;
224 /* Allocate the selector(s) */
226 handle = GLOBAL_CreateBlock( flags, ptr, size, hOwner,
227 isCode, is32Bit, isReadOnly, &shmdata);
228 if (!handle)
230 free( ptr );
231 return 0;
234 if (flags & GMEM_ZEROINIT) memset( ptr, 0, size );
235 return handle;
238 HGLOBAL GLOBAL_CreateBlock( WORD flags, void *ptr, DWORD size,
239 HGLOBAL hOwner, BOOL isCode,
240 BOOL is32Bit, BOOL isReadOnly,
241 SHMDATA *shmdata)
243 fprintf(stderr,"JBP: GLOBAL_CreateBlock() faked.\n");
244 return ptr;
247 BOOL GLOBAL_FreeBlock( HGLOBAL handle )
249 fprintf(stderr,"JBP: GLOBAL_FreeBlock() ignored.\n");
250 return 1;
253 DWORD GlobalHandle(WORD a)
255 fprintf(stderr,"JBP: GlobalHandle() ignored.\n");
256 return 0;
259 void *RELAY32_GetEntryPoint(char *dll_name, char *item, int hint)
261 fprintf(stderr,"JBP: RELAY32_GetEntryPoint() ignored.\n");
262 return NULL;
265 extern LRESULT AboutDlgProc(HWND,UINT,WPARAM,LPARAM);
266 extern LRESULT ButtonWndProc(HWND,UINT,WPARAM,LPARAM);
267 extern LRESULT CARET_Callback(HWND,UINT,WPARAM,LPARAM);
268 extern LRESULT ColorDlgProc(HWND,UINT,WPARAM,LPARAM);
269 extern LRESULT ComboBoxWndProc(HWND,UINT,WPARAM,LPARAM);
270 extern LRESULT ComboLBoxWndProc(HWND,UINT,WPARAM,LPARAM);
271 extern LRESULT DesktopWndProc(HWND,UINT,WPARAM,LPARAM);
272 extern LRESULT EditWndProc(HWND,UINT,WPARAM,LPARAM);
273 extern LRESULT FileOpenDlgProc(HWND,UINT,WPARAM,LPARAM);
274 extern LRESULT FileSaveDlgProc(HWND,UINT,WPARAM,LPARAM);
275 extern LRESULT FindTextDlgProc(HWND,UINT,WPARAM,LPARAM);
276 extern LRESULT ListBoxWndProc(HWND,UINT,WPARAM,LPARAM);
277 extern LRESULT MDIClientWndProc(HWND,UINT,WPARAM,LPARAM);
278 extern LRESULT PopupMenuWndProc(HWND,UINT,WPARAM,LPARAM);
279 extern LRESULT PrintDlgProc(HWND,UINT,WPARAM,LPARAM);
280 extern LRESULT PrintSetupDlgProc(HWND,UINT,WPARAM,LPARAM);
281 extern LRESULT ReplaceTextDlgProc(HWND,UINT,WPARAM,LPARAM);
282 extern LRESULT ScrollBarWndProc(HWND,UINT,WPARAM,LPARAM);
283 extern LRESULT StaticWndProc(HWND,UINT,WPARAM,LPARAM);
284 extern LRESULT SystemMessageBoxProc(HWND,UINT,WPARAM,LPARAM);
285 extern LRESULT TASK_Reschedule(HWND,UINT,WPARAM,LPARAM);
287 LRESULT ErrorProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
289 fprintf(stderr,"ERROR: ErrorProc() called!\n");
290 return 0;
293 /***********************************************************************
294 * GetWndProcEntry16 (not a Windows API function)
296 * Return an entry point from the WINPROCS dll.
298 WNDPROC GetWndProcEntry16( char *name )
300 #define MAP_STR_TO_PROC(str,proc) if(!strcmp(name,str))return proc
301 MAP_STR_TO_PROC("AboutDlgProc",AboutDlgProc);
302 MAP_STR_TO_PROC("ButtonWndProc",ButtonWndProc);
303 MAP_STR_TO_PROC("CARET_Callback",CARET_Callback);
304 MAP_STR_TO_PROC("ColorDlgProc",ColorDlgProc);
305 MAP_STR_TO_PROC("ComboBoxWndProc",ComboBoxWndProc);
306 MAP_STR_TO_PROC("ComboLBoxWndProc",ComboLBoxWndProc);
307 MAP_STR_TO_PROC("DefDlgProc",DefDlgProc);
308 MAP_STR_TO_PROC("DesktopWndProc",DesktopWndProc);
309 MAP_STR_TO_PROC("EditWndProc",EditWndProc);
310 MAP_STR_TO_PROC("FileOpenDlgProc",FileOpenDlgProc);
311 MAP_STR_TO_PROC("FileSaveDlgProc",FileSaveDlgProc);
312 MAP_STR_TO_PROC("FindTextDlgProc",FindTextDlgProc);
313 MAP_STR_TO_PROC("ListBoxWndProc",ListBoxWndProc);
314 MAP_STR_TO_PROC("MDIClientWndProc",MDIClientWndProc);
315 MAP_STR_TO_PROC("PopupMenuWndProc",PopupMenuWndProc);
316 MAP_STR_TO_PROC("PrintDlgProc",PrintDlgProc);
317 MAP_STR_TO_PROC("PrintSetupDlgProc",PrintSetupDlgProc);
318 MAP_STR_TO_PROC("ReplaceTextDlgProc",ReplaceTextDlgProc);
319 MAP_STR_TO_PROC("ScrollBarWndProc",ScrollBarWndProc);
320 MAP_STR_TO_PROC("StaticWndProc",StaticWndProc);
321 MAP_STR_TO_PROC("SystemMessageBoxProc",SystemMessageBoxProc);
322 MAP_STR_TO_PROC("TASK_Reschedule",TASK_Reschedule);
323 return ErrorProc;