ReactOS 0.4.17-dev-934-g091855f
twain_i.h File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "twain.h"
#include "wine/list.h"
Include dependency graph for twain_i.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pending_message
 
struct  tagActiveDS
 

Typedefs

typedef struct tagActiveDS activeDS
 

Functions

TW_UINT16 TWAIN_CloseDS (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_IdentityGetDefault (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_IdentityGetFirst (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_IdentityGetNext (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_OpenDS (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_UserSelect (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_CloseDSM (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_OpenDSM (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_GetDSMStatus (pTW_IDENTITY pOrigin, TW_MEMREF pData)
 
TW_UINT16 TWAIN_ControlNull (pTW_IDENTITY pOrigin, pTW_IDENTITY pDest, activeDS *pSource, TW_UINT16 MSG, TW_MEMREF pData)
 
TW_UINT16 TWAIN_ProcessEvent (pTW_IDENTITY pOrigin, activeDS *pSource, TW_MEMREF pData)
 

Variables

TW_UINT16 DSM_twCC
 
activeDS * activeSources
 
HINSTANCE DSM_hinstance
 

Typedef Documentation

◆ activeDS

Function Documentation

◆ TWAIN_CloseDS()

TW_UINT16 TWAIN_CloseDS ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 206 of file dsm_ctrl.c.

207{
208 TW_UINT16 twRC = TWRC_SUCCESS;
209 pTW_IDENTITY pIdentity = (pTW_IDENTITY) pData;
210 activeDS *currentDS = NULL, *prevDS = NULL;
211
212 TRACE ("DG_CONTROL/DAT_IDENTITY/MSG_CLOSEDS\n");
213
214 for (currentDS = activeSources; currentDS; currentDS = currentDS->next) {
215 if (currentDS->identity.Id == pIdentity->Id)
216 break;
217 prevDS = currentDS;
218 }
219 if (!currentDS) {
221 return TWRC_FAILURE;
222 }
223 twRC = currentDS->dsEntry (pOrigin, DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, pData);
224 /* This causes crashes due to still open Windows, so leave out for now.
225 * FreeLibrary (currentDS->hmod);
226 */
227 if (prevDS)
228 prevDS->next = currentDS->next;
229 else
230 activeSources = currentDS->next;
231 HeapFree (GetProcessHeap(), 0, currentDS);
232 if (twRC == TWRC_SUCCESS)
234 else /* FIXME: unclear how to get TWCC */
236 return twRC;
237}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
#define TRACE(s)
Definition: solgame.cpp:4
TW_UINT32 Id
Definition: twain.h:257
DSENTRYPROC dsEntry
Definition: twain_i.h:42
struct tagActiveDS * next
Definition: twain_i.h:39
TW_IDENTITY identity
Definition: twain_i.h:40
TW_UINT16 DSM_twCC
Definition: twain32_main.c:32
activeDS * activeSources
Definition: twain32_main.c:33
#define TWRC_FAILURE
Definition: twain.h:1665
#define DAT_IDENTITY
Definition: twain.h:1337
#define TWCC_SEQERROR
Definition: twain.h:1687
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
#define MSG_CLOSEDS
Definition: twain.h:1410
unsigned short TW_UINT16
Definition: twain.h:119
#define TWCC_NODS
Definition: twain.h:1681
#define TWRC_SUCCESS
Definition: twain.h:1664
struct TW_IDENTITY * pTW_IDENTITY
Definition: twain.h:1762
#define DG_CONTROL
Definition: twain.h:1311
#define TWCC_SUCCESS
Definition: twain.h:1678

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_CloseDSM()

TW_UINT16 TWAIN_CloseDSM ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 460 of file dsm_ctrl.c.

461{
462 activeDS *currentDS = activeSources, *nextDS;
463
464 TRACE("DG_CONTROL/DAT_PARENT/MSG_CLOSEDSM\n");
465
466 if (DSM_initialized)
467 {
469
470 /* If there are data sources still open, close them now. */
471 while (currentDS != NULL)
472 {
473 nextDS = currentDS->next;
474 currentDS->dsEntry (pOrigin, DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, pData);
475 HeapFree (GetProcessHeap(), 0, currentDS);
476 currentDS = nextDS;
477 }
481 return TWRC_SUCCESS;
482 } else {
484 return TWRC_FAILURE;
485 }
486}
#define FALSE
Definition: types.h:117
static TW_UINT16 DSM_initialized
Definition: dsm_ctrl.c:36
static HWND DSM_parent
Definition: dsm_ctrl.c:39

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_ControlNull()

TW_UINT16 TWAIN_ControlNull ( pTW_IDENTITY  pOrigin,
pTW_IDENTITY  pDest,
activeDS *  pSource,
TW_UINT16  MSG,
TW_MEMREF  pData 
)

Definition at line 126 of file dsm_ctrl.c.

127{
128 struct pending_message *message;
129
130 TRACE ("DG_CONTROL/DAT_NULL MSG=%i\n", MSG);
131
132 if (MSG != MSG_CLOSEDSREQ &&
133 MSG != MSG_DEVICEEVENT &&
135 {
137 return TWRC_FAILURE;
138 }
139
140 message = HeapAlloc(GetProcessHeap(), 0, sizeof(*message));
141 if (!message)
142 {
144 return TWRC_FAILURE;
145 }
146
147 message->msg = MSG;
149
150 /* Delphi twain only sends us messages from one window, and it
151 doesn't even give us the real handle to that window. Other
152 applications might decide to forward messages sent to DSM_parent
153 or to the one supplied to ENABLEDS. So let's try very hard to
154 find a window that will work. */
155 if (DSM_parent)
157 if (pSource->ui_window && pSource->ui_window != DSM_parent)
158 PostMessageW(pSource->ui_window, event_message, 0, 0);
159 if (pSource->event_window && pSource->event_window != pSource->ui_window &&
160 pSource->event_window != DSM_parent)
161 PostMessageW(pSource->event_window, event_message, 0, 0);
162 PostMessageW(0, event_message, 0, 0);
163
164 return TWRC_SUCCESS;
165}
#define MSG
Definition: Mailslot.c:11
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
#define HeapAlloc
Definition: compat.h:733
static UINT event_message
Definition: dsm_ctrl.c:40
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
Definition: tftpd.h:60
struct list entry
Definition: performance.c:91
DMUS_PMSG msg
Definition: performance.c:92
HWND ui_window
Definition: twain_i.h:44
struct list pending_messages
Definition: twain_i.h:43
HWND event_window
Definition: twain_i.h:45
#define MSG_XFERREADY
Definition: twain.h:1395
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define MSG_DEVICEEVENT
Definition: twain.h:1399
#define TWCC_BADPROTOCOL
Definition: twain.h:1685
#define MSG_CLOSEDSREQ
Definition: twain.h:1396
#define TWCC_LOWMEMORY
Definition: twain.h:1680

Referenced by DSM_Entry().

◆ TWAIN_GetDSMStatus()

TW_UINT16 TWAIN_GetDSMStatus ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 510 of file dsm_ctrl.c.

511{
512 pTW_STATUS pSourceStatus = (pTW_STATUS) pData;
513
514 TRACE ("DG_CONTROL/DAT_STATUS/MSG_GET\n");
515
516 pSourceStatus->ConditionCode = DSM_twCC;
517 DSM_twCC = TWCC_SUCCESS; /* clear the condition code */
518 return TWRC_SUCCESS;
519}
TW_UINT16 ConditionCode
Definition: twain.h:352
struct TW_STATUS * pTW_STATUS

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_IdentityGetDefault()

TW_UINT16 TWAIN_IdentityGetDefault ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 240 of file dsm_ctrl.c.

241{
242 pTW_IDENTITY pSourceIdentity = (pTW_IDENTITY) pData;
243
244 TRACE("DG_CONTROL/DAT_IDENTITY/MSG_GETDEFAULT\n");
247 if (!nrdevices)
248 return TWRC_FAILURE;
249 *pSourceIdentity = devices[0].identity;
251 return TWRC_SUCCESS;
252}
static struct all_devices * devices
Definition: dsm_ctrl.c:48
static int nrdevices
Definition: dsm_ctrl.c:47
static void twain_autodetect(void)
Definition: dsm_ctrl.c:112

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_IdentityGetFirst()

TW_UINT16 TWAIN_IdentityGetFirst ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 255 of file dsm_ctrl.c.

256{
257 pTW_IDENTITY pSourceIdentity = (pTW_IDENTITY) pData;
258
259 TRACE ("DG_CONTROL/DAT_IDENTITY/MSG_GETFIRST\n");
261 if (!nrdevices) {
262 TRACE ("no entries found.\n");
264 return TWRC_FAILURE;
265 }
267 *pSourceIdentity = devices[DSM_currentDevice++].identity;
268 return TWRC_SUCCESS;
269}
static TW_UINT16 DSM_currentDevice
Definition: dsm_ctrl.c:38

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_IdentityGetNext()

TW_UINT16 TWAIN_IdentityGetNext ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 272 of file dsm_ctrl.c.

273{
274 pTW_IDENTITY pSourceIdentity = (pTW_IDENTITY) pData;
275
276 TRACE("DG_CONTROL/DAT_IDENTITY/MSG_GETNEXT\n");
279 return TWRC_ENDOFLIST;
280 }
281 *pSourceIdentity = devices[DSM_currentDevice++].identity;
282 return TWRC_SUCCESS;
283}
#define TWRC_ENDOFLIST
Definition: twain.h:1671

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_OpenDS()

TW_UINT16 TWAIN_OpenDS ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 286 of file dsm_ctrl.c.

287{
288 TW_UINT16 i = 0;
289 pTW_IDENTITY pIdentity = (pTW_IDENTITY) pData;
290 activeDS *newSource;
292
293 TRACE("DG_CONTROL/DAT_IDENTITY/MSG_OPENDS\n");
294 TRACE("pIdentity is %s\n", pIdentity->ProductName);
295 if (!DSM_initialized) {
296 FIXME("seq error\n");
298 return TWRC_FAILURE;
299 }
301 if (!nrdevices) {
302 FIXME("no devs.\n");
304 return TWRC_FAILURE;
305 }
306
307 if (pIdentity->ProductName[0] != '\0') {
308 /* Make sure the source to be opened exists in the device list */
309 for (i = 0; i<nrdevices; i++)
310 if (!strcmp (devices[i].identity.ProductName, pIdentity->ProductName))
311 break;
312 if (i == nrdevices)
313 i = 0;
314 } /* else use the first device */
315
316 /* the source is found in the device list */
317 newSource = HeapAlloc (GetProcessHeap(), 0, sizeof (activeDS));
318 if (!newSource) {
320 FIXME("Out of memory.\n");
321 return TWRC_FAILURE;
322 }
323 hmod = LoadLibraryW(devices[i].modname);
324 if (!hmod) {
325 ERR("Failed to load TWAIN Source %s\n", debugstr_w(devices[i].modname));
327 HeapFree(GetProcessHeap(), 0, newSource);
328 return TWRC_FAILURE;
329 }
330 newSource->hmod = hmod;
331 newSource->dsEntry = (DSENTRYPROC)GetProcAddress(hmod, "DS_Entry");
332 /* Assign id for the opened data source */
333 pIdentity->Id = DSM_sourceId ++;
334 if (TWRC_SUCCESS != newSource->dsEntry (pOrigin, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, pIdentity)) {
336 HeapFree(GetProcessHeap(), 0, newSource);
337 DSM_sourceId--;
338 return TWRC_FAILURE;
339 }
340 /* add the data source to an internal active source list */
341 newSource->next = activeSources;
342 newSource->identity.Id = pIdentity->Id;
343 strcpy (newSource->identity.ProductName, pIdentity->ProductName);
344 list_init(&newSource->pending_messages);
345 newSource->ui_window = NULL;
346 newSource->event_window = NULL;
347 activeSources = newSource;
349 return TWRC_SUCCESS;
350}
static void list_init(struct list_entry *head)
Definition: list.h:51
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
#define GetProcAddress(x, y)
Definition: compat.h:753
#define LoadLibraryW(x)
Definition: compat.h:747
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
static TW_UINT32 DSM_sourceId
Definition: dsm_ctrl.c:37
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define debugstr_w
Definition: kernel32.h:32
static NTSTATUS *static PWSTR CURDIR *static HMODULE hmod
Definition: security.c:104
strcpy
Definition: string.h:131
TW_STR32 ProductName
Definition: twain.h:264
HMODULE hmod
Definition: twain_i.h:41
#define TWCC_OPERATIONERROR
Definition: twain.h:1683
#define MSG_OPENDS
Definition: twain.h:1409

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_OpenDSM()

TW_UINT16 TWAIN_OpenDSM ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 489 of file dsm_ctrl.c.

490{
491 TW_UINT16 twRC = TWRC_SUCCESS;
492
493 TRACE("DG_CONTROL/DAT_PARENT/MSG_OPENDSM\n");
494 if (!DSM_initialized) {
495 event_message = RegisterWindowMessageA("WINE TWAIN_32 EVENT");
499 twRC = TWRC_SUCCESS;
500 } else {
501 /* operation invoked in invalid state */
503 twRC = TWRC_FAILURE;
504 }
506 return twRC;
507}
#define TRUE
Definition: types.h:120
HANDLE HWND
Definition: compat.h:19
UINT WINAPI RegisterWindowMessageA(_In_ LPCSTR)

Referenced by TWAIN_SourceManagerHandler().

◆ TWAIN_ProcessEvent()

TW_UINT16 TWAIN_ProcessEvent ( pTW_IDENTITY  pOrigin,
activeDS *  pSource,
TW_MEMREF  pData 
)

Definition at line 168 of file dsm_ctrl.c.

169{
170 TW_EVENT *event = (TW_EVENT*)pData;
171 MSG *msg = (MSG*)event->pEvent;
173
174 TRACE("%x,%x\n", msg->message, event_message);
175
176 if (msg->message == event_message)
177 {
178 if (!list_empty (&pSource->pending_messages))
179 {
180 struct list *entry = list_head (&pSource->pending_messages);
182 event->TWMessage = message->msg;
184 TRACE("<-- %x\n", event->TWMessage);
185 }
186 else
187 event->TWMessage = MSG_NULL;
189 }
190
191 if (msg->hwnd)
192 {
193 MSG dummy;
194 pSource->event_window = msg->hwnd;
195 if (!list_empty (&pSource->pending_messages) &&
197 {
198 PostMessageW(msg->hwnd, event_message, 0, 0);
199 }
200 }
201
202 return result;
203}
#define msg(x)
Definition: auth_time.c:54
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static int list_empty(struct list_entry *head)
Definition: list.h:58
Definition: list.h:39
GLuint64EXT * result
Definition: glext.h:11304
uint32_t entry
Definition: isohybrid.c:63
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_NOREMOVE
Definition: winuser.h:1206
Definition: filter.c:185
Definition: list.h:15
#define LIST_ENTRY(type)
Definition: queue.h:175
#define TWRC_DSEVENT
Definition: twain.h:1668
#define MSG_NULL
Definition: twain.h:1381
#define TWRC_NOTDSEVENT
Definition: twain.h:1669

Referenced by DSM_Entry().

◆ TWAIN_UserSelect()

TW_UINT16 TWAIN_UserSelect ( pTW_IDENTITY  pOrigin,
TW_MEMREF  pData 
)

Definition at line 433 of file dsm_ctrl.c.

434{
435 userselect_data param = {pOrigin, pData};
437
438 TRACE("DG_CONTROL/DAT_IDENTITY/MSG_USERSELECT SupportedGroups=0x%lx ProductName=%s\n",
439 pOrigin->SupportedGroups, wine_dbgstr_a(param.result->ProductName));
440
442
443 if (!IsWindow(parent))
444 parent = NULL;
445
448 {
449 TRACE("canceled\n");
451 return TWRC_CANCEL;
452 }
453
454 TRACE("<-- %s\n", wine_dbgstr_a(param.result->ProductName));
456 return TWRC_SUCCESS;
457}
#define DLG_USERSELECT
Definition: resource.h:22
r parent
Definition: btrfs.c:3010
static INT_PTR CALLBACK userselect_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: dsm_ctrl.c:357
GLfloat param
Definition: glext.h:5796
LONG_PTR LPARAM
Definition: minwindef.h:175
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:160
TW_UINT32 SupportedGroups
Definition: twain.h:261
HINSTANCE DSM_hinstance
Definition: twain32_main.c:34
#define TWRC_CANCEL
Definition: twain.h:1667

Referenced by TWAIN_SourceManagerHandler().

Variable Documentation

◆ activeSources

activeDS* activeSources
extern

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
extern

Definition at line 34 of file twain32_main.c.

Referenced by DllMain(), and TWAIN_UserSelect().

◆ DSM_twCC