Release 971116
[wine] / misc / callback.c
1 /*
2  * Function callbacks for the library
3  *
4  * Copyright 1997 Alexandre Julliard
5  */
6
7 #include <assert.h>
8 #include <stdio.h>
9 #include "callback.h"
10
11 extern void TASK_Reschedule(void);  /* loader/task.c */
12
13 /**********************************************************************
14  *           CALLBACK_CallWndProc
15  */
16 static LRESULT WINAPI CALLBACK_CallWndProc( WNDPROC16 proc, HWND16 hwnd,
17                                             UINT16 msg, WPARAM16 wParam,
18                                             LPARAM lParam )
19 {
20     return proc( hwnd, msg, wParam, lParam );
21 }
22
23
24 /**********************************************************************
25  *           CALLBACK_CallRegisterProc
26  */
27 static VOID WINAPI CALLBACK_CallRegisterProc( CONTEXT *context, INT32 offset)
28 {
29     fprintf( stderr, "Cannot call a register proc in Winelib\n" );
30     assert( FALSE );
31 }
32
33
34 /**********************************************************************
35  *           CALLBACK_CallDriverProc
36  */
37 static LRESULT WINAPI CALLBACK_CallDriverProc( DRIVERPROC16 proc, DWORD dwId,
38                                                HDRVR16 hdrvr, UINT16 msg,
39                                                LPARAM lp1, LPARAM lp2 )
40 {
41     return proc( dwId, hdrvr, msg, lp1, lp2 );
42 }
43
44
45 /**********************************************************************
46  *           CALLBACK_CallDriverCallback
47  */
48 static LRESULT WINAPI CALLBACK_CallDriverCallback( FARPROC16 proc,
49                                                    HANDLE16 hDev, UINT16 msg,
50                                                    DWORD dwUser, LPARAM lp1,
51                                                    LPARAM lp2 )
52 {
53     return proc( hDev, msg, dwUser, lp1, lp2 );
54 }
55
56
57 /**********************************************************************
58  *           CALLBACK_CallTimeFuncProc
59  */
60 static LRESULT WINAPI CALLBACK_CallTimeFuncProc( FARPROC16 proc, WORD id,
61                                                  UINT16 msg, DWORD dwUser,
62                                                  LPARAM lp1, LPARAM lp2 )
63 {
64     return proc( id, msg, dwUser, lp1, lp2 );
65 }
66
67
68 /**********************************************************************
69  *           CALLBACK_CallWindowsExitProc
70  */
71 static INT16 WINAPI CALLBACK_CallWindowsExitProc( FARPROC16 proc, INT16 type)
72 {
73     return proc( type );
74 }
75
76
77 /**********************************************************************
78  *           CALLBACK_CallWordBreakProc
79  */
80 static INT16 WINAPI CALLBACK_CallWordBreakProc( EDITWORDBREAKPROC16 proc,
81                                                 SEGPTR text, INT16 word,
82                                                 INT16 len, INT16 action )
83 {
84     return proc( (LPSTR)text, word, len, action );
85 }
86
87
88 /**********************************************************************
89  *           CALLBACK_CallBootAppProc
90  */
91 static void WINAPI CALLBACK_CallBootAppProc( FARPROC16 proc, HANDLE16 module,
92                                              HFILE16 file )
93 {
94     proc( module, file );
95 }
96
97
98 /**********************************************************************
99  *           CALLBACK_CallLoadAppSegProc
100  */
101 static WORD WINAPI CALLBACK_CallLoadAppSegProc( FARPROC16 proc,
102                                                 HANDLE16 module, HFILE16 file,
103                                                 WORD seg )
104 {
105     return proc( module, file, seg );
106 }
107
108
109 /**********************************************************************
110  *           CALLBACK_CallSystemTimerProc
111  */
112 static void WINAPI CALLBACK_CallSystemTimerProc( FARPROC16 proc )
113 {
114     proc();
115 }
116
117
118 /**********************************************************************
119  *           CALLBACK_CallASPIPostProc
120  */
121 static LRESULT WINAPI CALLBACK_CallASPIPostProc( FARPROC16 proc, SEGPTR ptr )
122 {
123     return proc( ptr );
124 }
125
126 /**********************************************************************
127  *           CALLBACK_WinelibTable
128  *
129  * The callbacks function table for Winelib
130  */
131 static const CALLBACKS_TABLE CALLBACK_WinelibTable =
132 {
133     CALLBACK_CallRegisterProc,     /* CallRegisterProc */
134     TASK_Reschedule,               /* CallTaskRescheduleProc */
135     NULL,                          /* CallFrom16WndProc */
136     CALLBACK_CallWndProc,          /* CallWndProc */
137     CALLBACK_CallDriverProc,       /* CallDriverProc */
138     CALLBACK_CallDriverCallback,   /* CallDriverCallback */
139     CALLBACK_CallTimeFuncProc,     /* CallTimeFuncProc */
140     CALLBACK_CallWindowsExitProc,  /* CallWindowsExitProc */
141     CALLBACK_CallWordBreakProc,    /* CallWordBreakProc */
142     CALLBACK_CallBootAppProc,      /* CallBootAppProc */
143     CALLBACK_CallLoadAppSegProc,   /* CallLoadAppSegProc */
144     CALLBACK_CallSystemTimerProc,  /* CallSystemTimerProc */
145     CALLBACK_CallASPIPostProc,     /* CallASPIPostProc */
146     /* The graphics driver callbacks are never used in Winelib */
147     NULL,                          /* CallDrvControlProc */
148     NULL,                          /* CallDrvEnableProc */
149     NULL,                          /* CallDrvEnumDFontsProc */
150     NULL,                          /* CallDrvEnumObjProc */
151     NULL,                          /* CallDrvOutputProc */
152     NULL,                          /* CallDrvRealizeProc */
153     NULL,                          /* CallDrvStretchBltProc */
154     NULL                           /* CallDrvExtTextOutProc */
155 };
156
157 const CALLBACKS_TABLE *Callbacks = &CALLBACK_WinelibTable;