ReactOS 0.4.16-dev-329-g9223134
twain32_main.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "twain.h"
#include "twain_i.h"
#include "wine/debug.h"
Include dependency graph for twain32_main.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (twain)
 
BOOL WINAPI DllMain (HINSTANCE hinstance, DWORD reason, LPVOID reserved)
 
static activeDSTWAIN_LookupSource (const TW_IDENTITY *pDest)
 
static TW_UINT16 TWAIN_SourceManagerHandler (pTW_IDENTITY pOrigin, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData)
 
TW_UINT16 WINAPI DSM_Entry (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, TW_UINT32 DG, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData)
 

Variables

TW_UINT16 DSM_twCC
 
activeDSactiveSources
 
HINSTANCE DSM_hinstance
 

Function Documentation

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstance,
DWORD  reason,
LPVOID  reserved 
)

Definition at line 36 of file twain32_main.c.

37{
38 TRACE("%p,%x,%p\n", hinstance, reason, reserved);
39
40 switch (reason)
41 {
44 DSM_hinstance = hinstance;
45 break;
47 break;
48 }
49 return TRUE;
50}
#define TRUE
Definition: types.h:120
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
r reserved
Definition: btrfs.c:3006
#define TRACE(s)
Definition: solgame.cpp:4
HINSTANCE DSM_hinstance
Definition: twain32_main.c:34

◆ DSM_Entry()

TW_UINT16 WINAPI DSM_Entry ( pTW_IDENTITY  pOrigin,
pTW_IDENTITY  pDest,
TW_UINT32  DG,
TW_UINT16  DAT,
TW_UINT16  MSG,
TW_MEMREF  pData 
)

Definition at line 152 of file twain32_main.c.

158{
159 TW_UINT16 twRC = TWRC_SUCCESS; /* Return Code */
160
161 TRACE("(DG=%d DAT=%d MSG=%d)\n", DG, DAT, MSG);
162
163 if (DG == DG_CONTROL && DAT == DAT_NULL)
164 {
165 activeDS *pSource = TWAIN_LookupSource (pOrigin);
166 if (!pSource)
167 {
168 ERR("No source associated with pSource %p\n", pDest);
170 return TWRC_FAILURE;
171 }
172
173 return TWAIN_ControlNull (pOrigin, pDest, pSource, MSG, pData);
174 }
175
176 if (pDest)
177 {
178 activeDS *pSource = TWAIN_LookupSource (pDest);
179 /* This operation's destination is a source */
180
181 if (!pSource) {
182 ERR("No source associated with pDest %p\n", pDest);
184 return TWRC_FAILURE;
185 }
186
187 if (DG == DG_CONTROL && DAT == DAT_EVENT && MSG == MSG_PROCESSEVENT)
188 {
189 twRC = TWAIN_ProcessEvent(pOrigin, pSource, pData);
190 if (twRC == TWRC_DSEVENT)
191 return twRC;
192 }
193
194 if (DG == DG_CONTROL && DAT == DAT_USERINTERFACE &&
196 pData != NULL)
197 {
198 pSource->ui_window = ((TW_USERINTERFACE*)pData)->hParent;
199 }
200
202 TRACE("Forwarding %d/%d/%d/%p to DS.\n", DG, DAT, MSG, pData);
203 twRC = pSource->dsEntry(pOrigin, DG, DAT, MSG, pData);
204 TRACE("return value is %d\n", twRC);
205 return twRC;
206 }
207 switch (DG)
208 {
209 case DG_CONTROL:
210 twRC = TWAIN_SourceManagerHandler (pOrigin, DAT, MSG, pData);
211 break;
212 default:
213 FIXME("The DSM does not handle DG %d\n", DG);
215 twRC = TWRC_FAILURE;
216 }
217 return twRC;
218}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
TW_UINT16 TWAIN_ProcessEvent(pTW_IDENTITY pOrigin, activeDS *pSource, TW_MEMREF pData)
Definition: dsm_ctrl.c:162
TW_UINT16 TWAIN_ControlNull(pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, activeDS *pSource, TW_UINT16 MSG, TW_MEMREF pData)
Definition: dsm_ctrl.c:120
HWND ui_window
Definition: twain_i.h:44
DSENTRYPROC dsEntry
Definition: twain_i.h:42
static TW_UINT16 TWAIN_SourceManagerHandler(pTW_IDENTITY pOrigin, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData)
Definition: twain32_main.c:64
TW_UINT16 DSM_twCC
Definition: twain32_main.c:32
static activeDS * TWAIN_LookupSource(const TW_IDENTITY *pDest)
Definition: twain32_main.c:54
#define TWRC_FAILURE
Definition: twain.h:1665
#define DAT_NULL
Definition: twain.h:1331
#define MSG_ENABLEDSUIONLY
Definition: twain.h:1416
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define TWRC_DSEVENT
Definition: twain.h:1668
unsigned short TW_UINT16
Definition: twain.h:119
TW_UINT32 DG
Definition: twain.h:1827
#define TWRC_SUCCESS
Definition: twain.h:1664
#define DAT_EVENT
Definition: twain.h:1336
#define TWCC_BADDEST
Definition: twain.h:1688
#define TWCC_BADPROTOCOL
Definition: twain.h:1685
#define MSG_ENABLEDS
Definition: twain.h:1415
#define DAT_USERINTERFACE
Definition: twain.h:1343
#define DG_CONTROL
Definition: twain.h:1311
#define TWCC_SUCCESS
Definition: twain.h:1678
TW_UINT32 TW_UINT16 DAT
Definition: twain.h:1828
#define MSG_PROCESSEVENT
Definition: twain.h:1419

◆ TWAIN_LookupSource()

static activeDS * TWAIN_LookupSource ( const TW_IDENTITY pDest)
static

Definition at line 54 of file twain32_main.c.

55{
56 activeDS *pSource;
57
58 for (pSource = activeSources; pSource; pSource = pSource->next)
59 if (pSource->identity.Id == pDest->Id)
60 break;
61 return pSource;
62}
TW_UINT32 Id
Definition: twain.h:257
struct tagActiveDS * next
Definition: twain_i.h:39
TW_IDENTITY identity
Definition: twain_i.h:40
activeDS * activeSources
Definition: twain32_main.c:33

Referenced by DSM_Entry().

◆ TWAIN_SourceManagerHandler()

static TW_UINT16 TWAIN_SourceManagerHandler ( pTW_IDENTITY  pOrigin,
TW_UINT16  DAT,
TW_UINT16  MSG,
TW_MEMREF  pData 
)
static

Definition at line 64 of file twain32_main.c.

69{
71
72 switch (DAT)
73 {
74 case DAT_IDENTITY:
75 switch (MSG)
76 {
77 case MSG_CLOSEDS:
78 twRC = TWAIN_CloseDS (pOrigin, pData);
79 break;
80
81 case MSG_GETDEFAULT:
82 twRC = TWAIN_IdentityGetDefault (pOrigin, pData);
83 break;
84
85 case MSG_GETFIRST:
86 twRC = TWAIN_IdentityGetFirst (pOrigin, pData);
87 break;
88
89 case MSG_GETNEXT:
90 twRC = TWAIN_IdentityGetNext (pOrigin, pData);
91 break;
92
93 case MSG_OPENDS:
94 twRC = TWAIN_OpenDS (pOrigin, pData);
95 break;
96
97 case MSG_USERSELECT:
98 twRC = TWAIN_UserSelect (pOrigin, pData);
99 break;
100
101 default:
102 /* Unrecognized operation triplet */
103 twRC = TWRC_FAILURE;
105 WARN("unrecognized operation triplet\n");
106 break;
107 }
108 break;
109
110 case DAT_PARENT:
111 switch (MSG)
112 {
113 case MSG_CLOSEDSM:
114 twRC = TWAIN_CloseDSM (pOrigin, pData);
115 break;
116
117 case MSG_OPENDSM:
118 twRC = TWAIN_OpenDSM (pOrigin, pData);
119 break;
120
121 default:
122 /* Unrecognized operation triplet */
123 twRC = TWRC_FAILURE;
125 WARN("unrecognized operation triplet\n");
126 }
127 break;
128
129 case DAT_STATUS:
130 if (MSG == MSG_GET) {
131 twRC = TWAIN_GetDSMStatus (pOrigin, pData);
132 } else {
133 twRC = TWRC_FAILURE;
135 WARN("unrecognized operation triplet\n");
136 }
137 break;
138
139 default:
140 twRC = TWRC_FAILURE;
142 WARN("unrecognized operation triplet\n");
143 break;
144 }
145
146 return twRC;
147}
#define WARN(fmt,...)
Definition: precomp.h:61
TW_UINT16 TWAIN_CloseDS(pTW_IDENTITY pOrigin, TW_MEMREF pData)
Definition: dsm_ctrl.c:200
TW_UINT16 TWAIN_IdentityGetDefault(pTW_IDENTITY pOrigin, TW_MEMREF pData)
Definition: dsm_ctrl.c:234
TW_UINT16 TWAIN_IdentityGetFirst(pTW_IDENTITY pOrigin, TW_MEMREF pData)
Definition: dsm_ctrl.c:249
TW_UINT16 TWAIN_UserSelect(pTW_IDENTITY pOrigin, TW_MEMREF pData)
Definition: dsm_ctrl.c:428
TW_UINT16 TWAIN_GetDSMStatus(pTW_IDENTITY pOrigin, TW_MEMREF pData)
Definition: dsm_ctrl.c:505
TW_UINT16 TWAIN_IdentityGetNext(pTW_IDENTITY pOrigin, TW_MEMREF pData)
Definition: dsm_ctrl.c:266
TW_UINT16 TWAIN_OpenDS(pTW_IDENTITY pOrigin, TW_MEMREF pData)
Definition: dsm_ctrl.c:280
TW_UINT16 TWAIN_CloseDSM(pTW_IDENTITY pOrigin, TW_MEMREF pData)
Definition: dsm_ctrl.c:455
TW_UINT16 TWAIN_OpenDSM(pTW_IDENTITY pOrigin, TW_MEMREF pData)
Definition: dsm_ctrl.c:484
#define MSG_GETFIRST
Definition: twain.h:1388
#define MSG_GETDEFAULT
Definition: twain.h:1387
#define DAT_IDENTITY
Definition: twain.h:1337
#define MSG_OPENDS
Definition: twain.h:1409
#define MSG_CLOSEDS
Definition: twain.h:1410
#define MSG_CLOSEDSM
Definition: twain.h:1406
#define MSG_OPENDSM
Definition: twain.h:1405
#define MSG_USERSELECT
Definition: twain.h:1411
#define DAT_PARENT
Definition: twain.h:1338
#define MSG_GET
Definition: twain.h:1385
#define DAT_STATUS
Definition: twain.h:1342
#define MSG_GETNEXT
Definition: twain.h:1389

Referenced by DSM_Entry().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( twain  )

Variable Documentation

◆ activeSources

activeDS* activeSources

Definition at line 33 of file twain32_main.c.

Referenced by TWAIN_CloseDS(), TWAIN_CloseDSM(), TWAIN_LookupSource(), and TWAIN_OpenDS().

◆ DSM_hinstance

HINSTANCE DSM_hinstance

Definition at line 34 of file twain32_main.c.

Referenced by DllMain(), and TWAIN_UserSelect().

◆ DSM_twCC