Release 951212
[wine.git] / toolkit / miscstubs.c
blobedab69edf59720e40c50d6c92e52abc41ff3fea4
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"
14 #include "xmalloc.h"
16 int CallTo32_LargeStack( int (*func)(), int nbargs, ...)
18 va_list arglist;
19 int i,a[32];
21 va_start(arglist,nbargs);
23 for(i=0; i<nbargs; i++) a[i]=va_arg(arglist,int);
25 switch(nbargs) /* Ewww... Icky. But what can I do? */
27 case 5: return func(a[0],a[1],a[2],a[3],a[4]);
28 case 6: return func(a[0],a[1],a[2],a[3],a[4],a[5]);
29 case 8: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]);
30 case 10: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],
31 a[7],a[8],a[9]);
32 case 11: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],
33 a[7],a[8],a[9],a[10]);
34 case 14: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],
35 a[7],a[8],a[9],a[10],a[11],a[12],a[13]);
36 case 17: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6],
37 a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16]);
38 default: fprintf(stderr,"JBP: CallTo32_LargeStack called with unsupported "
39 "number of arguments (%d). Ignored.\n",nbargs);
40 return 0;
44 WORD CallTo16_word_ ( FARPROC func, WORD arg ) { return func(arg); }
46 void GlobalFreeAll(HANDLE owner)
48 fprintf(stderr,"JBP: GlobalFreeAll() ignored.\n");
51 SEGPTR WIN16_GlobalLock(HGLOBAL h)
52 { return (SEGPTR)h; }
53 HLOCAL LOCAL_Free(WORD ds, HLOCAL handle)
54 { return LocalFree(handle); }
55 HLOCAL LOCAL_Alloc(WORD ds, WORD flags, WORD size)
56 { return LocalAlloc(flags,size); }
57 HLOCAL LOCAL_ReAlloc(WORD ds, HLOCAL handle, WORD size, WORD flags)
58 { return LocalReAlloc(handle,size,flags); }
59 NPVOID LOCAL_Lock( WORD ds, HLOCAL handle )
60 { return LocalLock(handle); }
61 BOOL LOCAL_Unlock( WORD ds, HLOCAL handle )
62 { return LocalUnlock(handle); }
63 WORD LOCAL_Size( WORD ds, HLOCAL handle )
64 { return LocalSize(handle); }
66 void FarSetOwner(HANDLE a, WORD b)
68 fprintf(stderr,"JBP: FarSetOwner() ignored.\n");
71 #define GLOBAL_MAX_ALLOC_SIZE 0x00ff0000 /* Largest allocation is 16M - 64K */
73 HGLOBAL GLOBAL_Alloc( WORD flags, DWORD size, HGLOBAL hOwner,
74 BOOL isCode, BOOL is32Bit, BOOL isReadOnly )
76 void *ptr;
77 HGLOBAL handle;
78 SHMDATA shmdata;
80 dprintf_global( stddeb, "GLOBAL_Alloc: %ld flags=%04x\n", size, flags );
82 /* Fixup the size */
84 if (size >= GLOBAL_MAX_ALLOC_SIZE - 0x1f) return 0;
85 if (size == 0) size = 0x20;
86 else size = (size + 0x1f) & ~0x1f;
88 /* Allocate the linear memory */
90 #ifdef CONFIG_IPC
91 if ((flags & GMEM_DDESHARE) && Options.ipc)
92 ptr = DDE_malloc(flags, size, &shmdata);
93 else
94 #endif /* CONFIG_IPC */
95 ptr = malloc( size );
96 if (!ptr) return 0;
98 /* Allocate the selector(s) */
100 handle = GLOBAL_CreateBlock( flags, ptr, size, hOwner,
101 isCode, is32Bit, isReadOnly, &shmdata);
102 if (!handle)
104 free( ptr );
105 return 0;
108 if (flags & GMEM_ZEROINIT) memset( ptr, 0, size );
109 return handle;
112 HGLOBAL GLOBAL_CreateBlock( WORD flags, void *ptr, DWORD size,
113 HGLOBAL hOwner, BOOL isCode,
114 BOOL is32Bit, BOOL isReadOnly,
115 SHMDATA *shmdata)
117 /* fprintf(stderr,"JBP: GLOBAL_CreateBlock() faked.\n");*/
118 return ptr;
121 BOOL GLOBAL_FreeBlock( HGLOBAL handle )
123 /* fprintf(stderr,"JBP: GLOBAL_FreeBlock() ignored.\n");*/
124 return 1;
127 HGLOBAL GlobalHandle(LPCVOID a)
129 fprintf(stderr,"JBP: GlobalHandle() ignored.\n");
130 return 0;
133 void *RELAY32_GetEntryPoint(char *dll_name, char *item, int hint)
135 /* fprintf(stderr,"JBP: RELAY32_GetEntryPoint() ignored.\n");*/
136 return NULL;
139 extern LRESULT AboutDlgProc(HWND,UINT,WPARAM,LPARAM);
140 extern LRESULT ButtonWndProc(HWND,UINT,WPARAM,LPARAM);
141 extern LRESULT CARET_Callback(HWND,UINT,WPARAM,LPARAM);
142 extern LRESULT ColorDlgProc(HWND,UINT,WPARAM,LPARAM);
143 extern LRESULT ComboBoxWndProc(HWND,UINT,WPARAM,LPARAM);
144 extern LRESULT ComboLBoxWndProc(HWND,UINT,WPARAM,LPARAM);
145 extern LRESULT DesktopWndProc(HWND,UINT,WPARAM,LPARAM);
146 extern LRESULT EditWndProc(HWND,UINT,WPARAM,LPARAM);
147 extern LRESULT FileOpenDlgProc(HWND,UINT,WPARAM,LPARAM);
148 extern LRESULT FileSaveDlgProc(HWND,UINT,WPARAM,LPARAM);
149 extern LRESULT FindTextDlgProc(HWND,UINT,WPARAM,LPARAM);
150 extern LRESULT ListBoxWndProc(HWND,UINT,WPARAM,LPARAM);
151 extern LRESULT MDIClientWndProc(HWND,UINT,WPARAM,LPARAM);
152 extern LRESULT PopupMenuWndProc(HWND,UINT,WPARAM,LPARAM);
153 extern LRESULT PrintDlgProc(HWND,UINT,WPARAM,LPARAM);
154 extern LRESULT PrintSetupDlgProc(HWND,UINT,WPARAM,LPARAM);
155 extern LRESULT ReplaceTextDlgProc(HWND,UINT,WPARAM,LPARAM);
156 extern LRESULT ScrollBarWndProc(HWND,UINT,WPARAM,LPARAM);
157 extern LRESULT StaticWndProc(HWND,UINT,WPARAM,LPARAM);
158 extern LRESULT SystemMessageBoxProc(HWND,UINT,WPARAM,LPARAM);
159 extern LRESULT TASK_Reschedule(HWND,UINT,WPARAM,LPARAM);
161 LRESULT ErrorProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
163 fprintf(stderr,"ERROR: ErrorProc() called!\n");
164 return 0;
167 /***********************************************************************
168 * GetWndProcEntry16 (not a Windows API function)
170 * Return an entry point from the WINPROCS dll.
172 WNDPROC GetWndProcEntry16( char *name )
174 #define MAP_STR_TO_PROC(str,proc) if(!strcmp(name,str))return proc
175 MAP_STR_TO_PROC("AboutDlgProc",AboutDlgProc);
176 MAP_STR_TO_PROC("ButtonWndProc",ButtonWndProc);
177 MAP_STR_TO_PROC("CARET_Callback",CARET_Callback);
178 MAP_STR_TO_PROC("ColorDlgProc",ColorDlgProc);
179 MAP_STR_TO_PROC("ComboBoxWndProc",ComboBoxWndProc);
180 MAP_STR_TO_PROC("ComboLBoxWndProc",ComboLBoxWndProc);
181 MAP_STR_TO_PROC("DefDlgProc",DefDlgProc);
182 MAP_STR_TO_PROC("DesktopWndProc",DesktopWndProc);
183 MAP_STR_TO_PROC("EditWndProc",EditWndProc);
184 MAP_STR_TO_PROC("FileOpenDlgProc",FileOpenDlgProc);
185 MAP_STR_TO_PROC("FileSaveDlgProc",FileSaveDlgProc);
186 MAP_STR_TO_PROC("FindTextDlgProc",FindTextDlgProc);
187 MAP_STR_TO_PROC("ListBoxWndProc",ListBoxWndProc);
188 MAP_STR_TO_PROC("MDIClientWndProc",MDIClientWndProc);
189 MAP_STR_TO_PROC("PopupMenuWndProc",PopupMenuWndProc);
190 MAP_STR_TO_PROC("PrintDlgProc",PrintDlgProc);
191 MAP_STR_TO_PROC("PrintSetupDlgProc",PrintSetupDlgProc);
192 MAP_STR_TO_PROC("ReplaceTextDlgProc",ReplaceTextDlgProc);
193 MAP_STR_TO_PROC("ScrollBarWndProc",ScrollBarWndProc);
194 MAP_STR_TO_PROC("StaticWndProc",StaticWndProc);
195 MAP_STR_TO_PROC("SystemMessageBoxProc",SystemMessageBoxProc);
196 MAP_STR_TO_PROC("TASK_Reschedule",TASK_Reschedule);
197 return ErrorProc;