1 #pragma once
2 
3 #ifndef __TTWAINP_H__
4 #define __TTWAINP_H__
5 
6 #include "ttwain.h"
7 
8 #ifdef TTWAINLIB_MAIN
9 #define EXTERN
10 #else
11 #define EXTERN extern
12 #endif
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 typedef enum TWAINSTATE {
19   TWAIN_PRESESSION = 1, /* source manager not loaded  */
20   TWAIN_SM_LOADED,      /* source manager loaded      */
21   TWAIN_SM_OPEN,        /* source manager open	      */
22   TWAIN_SOURCE_OPEN,    /* source open but not enabled*/
23   TWAIN_SOURCE_ENABLED, /* source enabled to acquire  */
24   TWAIN_TRANSFER_READY, /* image ready to transfer    */
25   TWAIN_TRANSFERRING    /* image in transit	      */
26 } TWAINSTATE;
27 
28 #ifdef _WIN32
29 #ifdef x64
30 #define DSM_FILENAME "TWAINDSM.DLL"
31 #else
32 #define DSM_FILENAME "TWAIN_32.DLL"
33 #endif
34 #define DSM_ENTRYPOINT "DSM_Entry"
35 #else
36 #define DSM_FILENAME ""
37 #define DSM_ENTRYPOINT ""
38 #endif
39 
40 struct TRANSFER_INFO {
41   TTWAIN_TRANSFER_MECH transferMech; /*current transfer mechanism      */
42   TTWAIN_USAGE_MODE usageMode;
43   /*used by buffered memory tranfer */
44   unsigned char *memoryBuffer;
45   unsigned long memorySize;
46   /*used by native tranfer          */
47   void *hDib;
48   /*common to all the transfer mode */
49   int preferredLx;
50   int preferredLy;
51   int multiTransfer;
52   int nextImageNeedsToBeInverted;
53   int lastTransferWasOk;
54   TW_PENDINGXFERS pendingXfers;
55   int oneAtLeast;
56 };
57 
58 struct CALLBACKS {
59   TTWAIN_ONDONE_CB *onDoneCb;
60   void *onDoneArg;
61   TTWAIN_ONERROR_CB *onErrorCb;
62   void *onErrorArg;
63 };
64 
65 struct _TTWAIN_DATA__ {
66   /*HANDLE*/
67   DSMENTRYPROC DSM_Entry; /* entry point of Data Source Manager(TWAIN.DLL)*/
68   TW_INT32 hwnd32SM;      /* window handle              */
69   /*IDENTITY*/
70   TW_IDENTITY sourceId;     /* source identity structure  */
71   TW_IDENTITY appId;        /* Application Ident. for DS  */
72   TW_USERINTERFACE twainUI; /*                            */
73 
74   int initDone;
75   TWAINAVAILABLE twainAvailable;
76   TWAINSTATE twainState; /* the current twain state    */
77 
78   struct TRANSFER_INFO transferInfo;
79   struct CALLBACKS callback;
80   TW_ARRAY *supportedCaps; /* all the (exported)supported capabilities */
81   int isSupportedCapsSupported;
82 
83   int breakModalLoop;
84 
85   int UIStatus; /* Hide or Show UserInterface */
86   int modalStatus;
87 
88   TW_INT16 resultCode; /* result code for LAST error     */
89 
90   TUINT32 ErrRC; /* result & condition code        */
91   TUINT32 ErrCC; /* for LAST RECORDED error        */
92 };
93 
94 EXTERN struct _TTWAIN_DATA__ TTwainData;
95 
96 EXTERN int TTWAIN_InitVar(void);
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif
103