Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
7.3 KiB

  1. #ifndef _DSLOADER__H_
  2. #define _DSLOADER__H_
  3. //
  4. // This header file defines the interface between TWAIN Source manager and
  5. // the import data source loader. An import data source loader is a
  6. // separate module loaded by the Source manager to enumerate, load, and unload
  7. // data sources not in TWAIN traditional form, ie, *.ds files in the TWAIN
  8. // subdirectory. This kind of data sources can be in any form as far as
  9. // the loader can expose them properly so that the Source
  10. // manager can access to them.
  11. // A registry entry is dedicated for the loader(only one loader is allowed,
  12. // although this may be changed in the future):
  13. // ImportDSLoader = REG_SZ : <loader full path name>
  14. //
  15. //
  16. // API names provided by the loader.
  17. //
  18. const CHAR FIND_FIRSTIMPORTDS[] = "FindFirstImportDS";
  19. const CHAR FIND_NEXTIMPORTDS[] = "FindNextImportDS";
  20. const CHAR CLOSE_FINDCONTEXT[] = "CloseFindContext";
  21. const CHAR LOAD_IMPORTDS[] = "LoadImportDS";
  22. const CHAR UNLOAD_IMPORTDS[] = "UnloadImportDS";
  23. const CHAR GET_LOADERSTATUS[] = "GetLoaderStatus";
  24. const CHAR FIND_IMPORTDSBYDEVICENAME[] = "FindImportDSByDeviceName";
  25. //
  26. // We pass the imported data source handle on every call to an imported
  27. // data source so that the loader has a way of dispatching the call
  28. // to the designated data source in case two or more data sources
  29. // share the same DS_Entry.
  30. //
  31. typedef TW_UINT16 (APIENTRY *PFNIMPORTEDDSENTRY)(HANDLE, TW_IDENTITY *,
  32. TW_UINT32, TW_UINT16, TW_UINT16, TW_MEMREF);
  33. //
  34. // Each data source has its own load/unload function. This makes it possible
  35. // for the loader to assign different loading/unloading scheme for
  36. // different data source.
  37. //
  38. typedef TW_UINT16 (APIENTRY *PFNLOAD_IMPORTDS)(LPCSTR DeviceName,
  39. DWORD DeviceFlags, HANDLE *phDS, PFNIMPORTEDDSENTRY *pDSEntry);
  40. typedef TW_UINT16 (APIENTRY *PFNUNLOAD_IMPORTDS)(HANDLE hDS);
  41. //
  42. // Data structure used to convey information about a
  43. // particular data source
  44. //
  45. typedef struct tagImportDSInfo
  46. {
  47. DWORD Size; // The size of the entire structure in bytes.
  48. CHAR DeviceName[MAX_PATH]; // The device name which uniquely
  49. // identifies a particular device
  50. // instance in a system. The content
  51. // is up to the loader.
  52. DWORD DeviceFlags; // misc flags used by the loader.
  53. // Together with DeviceName, it is required
  54. // to load a device.
  55. PFNLOAD_IMPORTDS pfnLoadDS; // Loader provided function to load this
  56. // this data source.
  57. PFNUNLOAD_IMPORTDS pfnUnloadDS; // Loader provided function to unload this data source.
  58. }IMPORT_DSINFO, *PIMPORT_DSINFO;
  59. //
  60. // Funtion prototypes for the APIs
  61. //
  62. typedef TW_UINT16 (APIENTRY *PFNFIND_FIRSTIMPORTDS)(PIMPORT_DSINFO pDSInfo, PVOID *Context);
  63. typedef TW_UINT16 (APIENTRY *PFNFIND_NEXTIMPORTDS)(PIMPORT_DSINFO pDSInfo, PVOID Context);
  64. typedef TW_UINT16 (APIENTRY *PFNCLOSE_FINDCONTEXT)(PVOID Context);
  65. typedef TW_UINT16 (APIENTRY *PFNFIND_IMPORTDSBYDEVICENAME)(PIMPORT_DSINFO pDSInfo, LPCSTR DeviceName);
  66. typedef TW_UINT16 (APIENTRY *PFNGET_LOADERSTATUS)(TW_STATUS *ptwStatus);
  67. //
  68. // This API finds the first available data source managed by the loader
  69. // Input:
  70. // pDSInfo -- the buffer to receive the first available data source
  71. // information. The structure size must be initialized.
  72. // Context -- A place holder to store the context created by this
  73. // API. It is required for FindNextImportDS.
  74. // CloseFindContext should be called to release any
  75. // resource alloated for this context.
  76. //Output:
  77. // standard TWRC_ code. If it is not TWRC_SUCCESS, a call
  78. // to GetLoaderStatus will returns the corresponding TWCC_ code.
  79. // If the API succeeded, TWRC_SUCCESS is returned.
  80. // If the API succeeded, pDSInfo is filled with the data source
  81. // information.
  82. TW_UINT16 APIENTRY FindFirstImportDS(PIMPORT_DSINFO pDSInfo,PVOID Context);
  83. //
  84. // This API finds the next available data source managed by the loader
  85. // Input:
  86. // pDSInfo -- the buffer to receive the next available data source
  87. // information. The structure size must be initialized.
  88. // Context -- The context returned by FindFirstImportDS
  89. //Output:
  90. // standard TWRC_ code. If it is not TWRC_SUCCESS, a call
  91. // to GetLoaderStatus returns the corresponding TWCC_ code.
  92. // If the API succeeded, TWRC_SUCCESS is returned.
  93. // If there are no available Data source, TWRC_ENDOFLIST is
  94. // returned. If the function succeeded, the buffer designated
  95. // by pDSInfo is filled with data source information.
  96. TW_UINT16 APIENTRY FindNextImportDS(PIMPORT_DSINFO pDSInfo,PVOID Context);
  97. //
  98. // This API closes the context information used to find the data sources
  99. // managed by the loader. The context is returned from FindFirstImportDS
  100. // API and should be releases by calling this API when the searching
  101. // is done.
  102. // Input:
  103. // Contex -- the context to be closed
  104. // Output:
  105. // standard TWRC_ error code
  106. TW_UINT16 APIENTRY CloseFindContext( PVOID Context);
  107. //
  108. // This API asks the loader to load the specific data source
  109. // idenetified by the given IMPORT_DSINFO and returns
  110. // the data source's DSEntry. Each data source can supply its own load function
  111. // or several data sources can share the same function. The choice is up
  112. // to the loader and how it load/unload the data source.
  113. // Input:
  114. // DeviceName -- the name that uniquely represent the data source
  115. // phDS -- to receive a handle to the loaded data source.
  116. // pDSEntry -- to receive the data source DSEntry
  117. // Output:
  118. // standard TWRC_.
  119. // If the data source is loaded successfully, TWRC_SUCCESS
  120. // is returned, pDSEntry is filled with the data source's
  121. // DSEntry and phDS is filled with the handle to the loaded
  122. // data source. If this api failed, NULL are returned in phDS
  123. // and pDSEntry.
  124. //
  125. TW_UINT16 APIENTRY LoadImportDS(LPCSTR DeviceName, DWORD DeviceFlags,HANDLE *phDS,
  126. PFNIMPORTEDDSENTRY *pImportDSEntry);
  127. //
  128. // This API asks the loader to unload the specific data source
  129. // The loader is free to release any resources allocated for this
  130. // data source. When the data source is needed again, it will be
  131. // loaded again.
  132. // Input:
  133. // hDS -- handle to the loaded data source obtained
  134. // from LoadImportDS API
  135. // Output:
  136. // standard TWRC_ error code
  137. TW_UINT16 APIENTRY UnloadImportDS(HANDLE hDS);
  138. //
  139. // This API finds the data source designated by the given
  140. // device name. This API is useful when the caller only
  141. // knows about a particular device name.
  142. //
  143. // Input:
  144. // pDSInfo -- buffer to receive data source info.
  145. // DeviceName -- the device name use to search
  146. // for data source
  147. // Output:
  148. // TWRC_SUCCESS if a match is found.
  149. // TWRC_ENDOFLIST if no math is found.
  150. // TWRC_ other error code.
  151. //
  152. TW_UINT16 APIENTRY FindImportDSByDeviceName(PIMPORT_DSINFO pDSInfo,LPCSTR DeviceName);
  153. //
  154. // This API returns the current loader TW_STATUS. The loader
  155. // updates its status only when the last api call to the loader
  156. // did not return TWRC_SUCCESS.
  157. // Input:
  158. // ptwStatus -- buffer to receive the status
  159. // Output:
  160. // standard TWRC_ code.
  161. //
  162. TW_UINT16 APIENTRY GetLoaderStatus(TW_STATUS *ptwStatus);
  163. #endif // #ifndef _DSLOADER__H_