Release 960428
[wine/multimedia.git] / library / miscstubs.c
blob407de96303fc9e5f735f36775a0bea04bbf58a28
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 "relay32.h"
14 #include "debug.h"
15 #include "xmalloc.h"
17 int CallTo32_LargeStack( int (*func)(), int nbargs, ...)
19 va_list arglist;
20 int i,a[32];
22 va_start(arglist,nbargs);
24 for(i=0; i<nbargs; i++) a[i]=va_arg(arglist,int);
26 switch(nbargs) /* Ewww... Icky. But what can I do? */
28 case 5: return func(a[0],a[1],a[2],a[3],a[4]);
29 case 6: return func(a[0],a[1],a[2],a[3],a[4],a[5]);
30 case 8: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]);
31 case 10: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],
32 a[7],a[8],a[9]);
33 case 11: 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]);
35 case 14: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],
36 a[7],a[8],a[9],a[10],a[11],a[12],a[13]);
37 case 17: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],
38 a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16]);
39 default: fprintf(stderr,"JBP: CallTo32_LargeStack called with unsupported "
40 "number of arguments (%d). Ignored.\n",nbargs);
41 return 0;
45 WORD CallTo16_word_ ( FARPROC func, WORD arg ) { return func(arg); }
47 void GlobalFreeAll(HANDLE owner)
49 WINELIB_UNIMP("GlobalFreeAll()");
52 SEGPTR WIN16_GlobalLock(HGLOBAL h)
53 { return (SEGPTR)h; }
54 HLOCAL LOCAL_Free(WORD ds, HLOCAL handle)
55 { return LocalFree(handle); }
56 HLOCAL LOCAL_Alloc(WORD ds, WORD flags, WORD size)
57 { return LocalAlloc(flags,size); }
58 HLOCAL LOCAL_ReAlloc(WORD ds, HLOCAL handle, WORD size, WORD flags)
59 { return LocalReAlloc(handle,size,flags); }
60 LPSTR LOCAL_Lock( WORD ds, HLOCAL handle )
61 { return LocalLock(handle); }
62 BOOL LOCAL_Unlock( WORD ds, HLOCAL handle )
63 { return LocalUnlock(handle); }
64 WORD LOCAL_Size( WORD ds, HLOCAL handle )
65 { return LocalSize(handle); }
67 void FarSetOwner(HANDLE a, HANDLE b)
69 WINELIB_UNIMP("FarSetOwner()");
72 #define GLOBAL_MAX_ALLOC_SIZE 0x00ff0000 /* Largest allocation is 16M - 64K */
74 HGLOBAL GLOBAL_Alloc( WORD flags, DWORD size, HGLOBAL hOwner,
75 BOOL isCode, BOOL is32Bit, BOOL isReadOnly )
77 void *ptr;
78 HGLOBAL handle;
79 SHMDATA shmdata;
81 dprintf_global( stddeb, "GLOBAL_Alloc: %ld flags=%04x\n", size, flags );
83 /* Fixup the size */
85 if (size >= GLOBAL_MAX_ALLOC_SIZE - 0x1f) return 0;
86 if (size == 0) size = 0x20;
87 else size = (size + 0x1f) & ~0x1f;
89 /* Allocate the linear memory */
91 #ifdef CONFIG_IPC
92 if ((flags & GMEM_DDESHARE) && Options.ipc)
93 ptr = DDE_malloc(flags, size, &shmdata);
94 else
95 #endif /* CONFIG_IPC */
96 ptr = malloc( size );
97 if (!ptr) return 0;
99 /* Allocate the selector(s) */
101 handle = GLOBAL_CreateBlock( flags, ptr, size, hOwner,
102 isCode, is32Bit, isReadOnly, &shmdata);
103 if (!handle)
105 free( ptr );
106 return 0;
109 if (flags & GMEM_ZEROINIT) memset( ptr, 0, size );
110 return handle;
113 HGLOBAL GLOBAL_CreateBlock( WORD flags, const void *ptr, DWORD size,
114 HGLOBAL hOwner, BOOL isCode,
115 BOOL is32Bit, BOOL isReadOnly,
116 SHMDATA *shmdata)
118 return (HGLOBAL)ptr;
121 BOOL GLOBAL_FreeBlock( HGLOBAL handle )
123 return 1;
126 HGLOBAL GlobalHandle(LPCVOID a)
128 fprintf(stderr,"JBP: GlobalHandle() ignored.\n");
129 return 0;
132 extern LRESULT ACTIVATEAPP_callback(HWND,UINT,WPARAM,LPARAM);
133 extern LRESULT AboutDlgProc(HWND,UINT,WPARAM,LPARAM);
134 extern LRESULT ButtonWndProc(HWND,UINT,WPARAM,LPARAM);
135 extern LRESULT CARET_Callback(HWND,UINT,WPARAM,LPARAM);
136 extern LRESULT ColorDlgProc(HWND,UINT,WPARAM,LPARAM);
137 extern LRESULT ComboBoxWndProc(HWND,UINT,WPARAM,LPARAM);
138 extern LRESULT ComboLBoxWndProc(HWND,UINT,WPARAM,LPARAM);
139 extern LRESULT DesktopWndProc(HWND,UINT,WPARAM,LPARAM);
140 extern LRESULT EditWndProc(HWND,UINT,WPARAM,LPARAM);
141 extern LRESULT FileOpenDlgProc(HWND,UINT,WPARAM,LPARAM);
142 extern LRESULT FileSaveDlgProc(HWND,UINT,WPARAM,LPARAM);
143 extern LRESULT FindTextDlgProc(HWND,UINT,WPARAM,LPARAM);
144 extern LRESULT ListBoxWndProc(HWND,UINT,WPARAM,LPARAM);
145 extern LRESULT MDIClientWndProc(HWND,UINT,WPARAM,LPARAM);
146 extern LRESULT PopupMenuWndProc(HWND,UINT,WPARAM,LPARAM);
147 extern LRESULT PrintDlgProc(HWND,UINT,WPARAM,LPARAM);
148 extern LRESULT PrintSetupDlgProc(HWND,UINT,WPARAM,LPARAM);
149 extern LRESULT ReplaceTextDlgProc(HWND,UINT,WPARAM,LPARAM);
150 extern LRESULT ScrollBarWndProc(HWND,UINT,WPARAM,LPARAM);
151 extern LRESULT StaticWndProc(HWND,UINT,WPARAM,LPARAM);
152 extern LRESULT SystemMessageBoxProc(HWND,UINT,WPARAM,LPARAM);
153 extern LRESULT TASK_Reschedule(HWND,UINT,WPARAM,LPARAM);
155 LRESULT ErrorProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
157 fprintf(stderr,"ERROR: ErrorProc() called!\n");
158 return 0;
161 /***********************************************************************
162 * MODULE_GetWndProcEntry16 (not a Windows API function)
164 * Return an entry point from the WPROCS dll.
166 WNDPROC MODULE_GetWndProcEntry16( char *name )
168 #define MAP_STR_TO_PROC(str,proc) if(!strcmp(name,str))return proc
169 MAP_STR_TO_PROC("ActivateAppProc",ACTIVATEAPP_callback);
170 MAP_STR_TO_PROC("AboutDlgProc",AboutDlgProc);
171 MAP_STR_TO_PROC("ButtonWndProc",ButtonWndProc);
172 MAP_STR_TO_PROC("CARET_Callback",CARET_Callback);
173 MAP_STR_TO_PROC("ColorDlgProc",ColorDlgProc);
174 MAP_STR_TO_PROC("ComboBoxWndProc",ComboBoxWndProc);
175 MAP_STR_TO_PROC("ComboLBoxWndProc",ComboLBoxWndProc);
176 MAP_STR_TO_PROC("DefDlgProc",DefDlgProc);
177 MAP_STR_TO_PROC("DesktopWndProc",DesktopWndProc);
178 MAP_STR_TO_PROC("EditWndProc",EditWndProc);
179 MAP_STR_TO_PROC("FileOpenDlgProc",FileOpenDlgProc);
180 MAP_STR_TO_PROC("FileSaveDlgProc",FileSaveDlgProc);
181 MAP_STR_TO_PROC("FindTextDlgProc",FindTextDlgProc);
182 MAP_STR_TO_PROC("ListBoxWndProc",ListBoxWndProc);
183 MAP_STR_TO_PROC("MDIClientWndProc",MDIClientWndProc);
184 MAP_STR_TO_PROC("PopupMenuWndProc",PopupMenuWndProc);
185 MAP_STR_TO_PROC("PrintDlgProc",PrintDlgProc);
186 MAP_STR_TO_PROC("PrintSetupDlgProc",PrintSetupDlgProc);
187 MAP_STR_TO_PROC("ReplaceTextDlgProc",ReplaceTextDlgProc);
188 MAP_STR_TO_PROC("ScrollBarWndProc",ScrollBarWndProc);
189 MAP_STR_TO_PROC("StaticWndProc",StaticWndProc);
190 MAP_STR_TO_PROC("SystemMessageBoxProc",SystemMessageBoxProc);
191 MAP_STR_TO_PROC("TASK_Reschedule",TASK_Reschedule);
192 fprintf(stderr,"warning: No mapping for %s(), add one in library/miscstubs.c\n",name);
193 return ErrorProc;
196 /***********************************************************************
197 * MODULE_GetWndProcEntry32 (not a Windows API function)
199 * Return an entry point from the WPROCS32 dll.
201 WNDPROC MODULE_GetWndProcEntry32( char *name )
203 return MODULE_GetWndProcEntry16( name );
206 void DEBUG_EnterDebugger(void)