2 * JBP (Jim Peterson <jspeter@birch.ee.vt.edu>): Lots of stubs needed for
15 int CallTo32_LargeStack( int (*func
)(), int nbargs
, ...)
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],
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
);
41 WORD
CallTo16_word_ ( FARPROC func
, WORD arg
) { return func(arg
); }
43 /* typedef void* ATOM; */
44 /* ATOM GlobalAddAtom(char *n) */
46 /* return strdup(n); */
48 /* GlobalDeleteAtom(ATOM n) */
52 /* GlobalFindAtom(char*n) */
54 /* fprintf(stderr,"JBP: GlobalFindAtom() ignored.\n"); */
57 /* char *GlobalGetAtomName(ATOM a) */
62 void GlobalFreeAll(HANDLE owner
)
64 fprintf(stderr
,"JBP: GlobalFreeAll() ignored.\n");
67 SEGPTR
WIN16_GlobalLock(HGLOBAL h
)
77 int IsValidHLOCAL(HLOCAL handle
)
79 return *(handle
-1) + *(handle
-2) == 0; /* Valid HLOCAL's sum to 0 */
82 /***********************************************************************
86 HLOCAL
LOCAL_Free( WORD ds
, HLOCAL handle
)
88 if (!IsValidHLOCAL(handle
)) return handle
; /* couldn't free it */
94 /***********************************************************************
98 HLOCAL
LOCAL_Alloc( WORD ds
, WORD flags
, WORD size
)
102 handle
= malloc(size
+ 2*sizeof(WORD
));
110 /***********************************************************************
114 HLOCAL
LOCAL_ReAlloc( WORD ds
, HLOCAL handle
, WORD size
, WORD flags
)
118 if(!IsValidHLOCAL(handle
))return 0;
119 newhandle
= realloc(handle
-2, size
+2*sizeof(WORD
));
121 *(newhandle
-2) = size
;
122 *(newhandle
-1) = -size
;
127 /***********************************************************************
130 WORD
LOCAL_Lock( WORD ds
, HLOCAL handle
)
132 if(!IsValidHLOCAL(handle
))return 0;
137 /***********************************************************************
140 BOOL
LOCAL_Unlock( WORD ds
, HLOCAL handle
)
146 /***********************************************************************
150 WORD
LOCAL_Size( WORD ds
, HLOCAL handle
)
156 HLOCAL
LOCAL_Free( WORD ds
, HLOCAL handle
)
158 fprintf(stderr
,"JBP: LOCAL_*() ignored.\n");
162 HLOCAL
LOCAL_Alloc( WORD ds
, WORD flags
, WORD size
)
164 fprintf(stderr
,"JBP: LOCAL_*() ignored.\n");
168 HLOCAL
LOCAL_ReAlloc( WORD ds
, HLOCAL handle
, WORD size
, WORD flags
)
170 fprintf(stderr
,"JBP: LOCAL_*() ignored.\n");
174 WORD
LOCAL_Lock( WORD ds
, HLOCAL handle
)
176 fprintf(stderr
,"JBP: LOCAL_*() ignored.\n");
180 BOOL
LOCAL_Unlock( WORD ds
, HLOCAL handle
)
182 fprintf(stderr
,"JBP: LOCAL_*() ignored.\n");
186 WORD
LOCAL_Size( WORD ds
, HLOCAL handle
)
188 fprintf(stderr
,"JBP: LOCAL_*() ignored.\n");
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
)
206 dprintf_global( stddeb
, "GLOBAL_Alloc: %ld flags=%04x\n", size
, flags
);
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 */
217 if ((flags
& GMEM_DDESHARE
) && Options
.ipc
)
218 ptr
= DDE_malloc(flags
, size
, &shmdata
);
220 #endif /* CONFIG_IPC */
221 ptr
= malloc( size
);
224 /* Allocate the selector(s) */
226 handle
= GLOBAL_CreateBlock( flags
, ptr
, size
, hOwner
,
227 isCode
, is32Bit
, isReadOnly
, &shmdata
);
234 if (flags
& GMEM_ZEROINIT
) memset( ptr
, 0, size
);
238 HGLOBAL
GLOBAL_CreateBlock( WORD flags
, void *ptr
, DWORD size
,
239 HGLOBAL hOwner
, BOOL isCode
,
240 BOOL is32Bit
, BOOL isReadOnly
,
243 fprintf(stderr
,"JBP: GLOBAL_CreateBlock() faked.\n");
247 BOOL
GLOBAL_FreeBlock( HGLOBAL handle
)
249 fprintf(stderr
,"JBP: GLOBAL_FreeBlock() ignored.\n");
253 DWORD
GlobalHandle(WORD a
)
255 fprintf(stderr
,"JBP: GlobalHandle() ignored.\n");
259 void *RELAY32_GetEntryPoint(char *dll_name
, char *item
, int hint
)
261 fprintf(stderr
,"JBP: RELAY32_GetEntryPoint() ignored.\n");
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");
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
);