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.

333 lines
14 KiB

  1. /********************************************************************
  2. ProofBase.h - Base API definitions for CSAPI, CTAPI, & CHAPI
  3. Speller, Thesaurus, and Hyphenator
  4. Version 3.0 - all api's
  5. History:
  6. 5/97 DougP Created
  7. 12/97 DougP Copied from ProofAPI.h and Separated into tool section files
  8. The Natural Language Group maintains this file.
  9. 1997 Microsoft Corporation
  10. ********************************************************************/
  11. #if !defined(PROOFBASE_H)
  12. #define PROOFBASE_H
  13. #pragma pack(push, proofapi_h, 8) // default alignment
  14. #include "vendor.h"
  15. // you may wish to include lid.h for some convenient langid defs
  16. #if !defined(lidUnknown)
  17. # define lidUnknown 0xffff
  18. #endif
  19. /*************************************************************
  20. PART 1 - Structure Defs
  21. **************************************************************/
  22. /* -------------- Common Section (Speller, Hyphenator, and Thesaurus) --------- */
  23. /* hardcoded ordinals are the exported dll entry points */
  24. // individual def files have these as well so be sure to change them
  25. // if you change these
  26. #define idllProofVersion 20
  27. #define idllProofInit 21
  28. #define idllProofTerminate 22
  29. #define idllProofOpenLex 23
  30. #define idllProofCloseLex 24
  31. #define idllProofSetOptions 25
  32. #define idllProofGetOptions 26
  33. typedef unsigned long PTEC; // ptec
  34. /******************* Proofing Tool Error Codes ************************/
  35. /* Major Error Codes in low two bytes (WORD) of PTEC */
  36. enum {
  37. ptecNoErrors,
  38. ptecOOM, /* memory error */
  39. ptecModuleError, /* Something wrong with parameters, or state of spell module. */
  40. ptecIOErrorMainLex, /* Read,write,or share error with Main Dictionary. */
  41. ptecIOErrorUserLex, /* Read,write,or share error with User Dictionary. */
  42. ptecNotSupported, /* No support for requested operation */
  43. ptecBufferTooSmall, /* Insufficient room for return info */
  44. ptecNotFound, /* Hyphenator and Thesaurus only */
  45. ptecModuleNotLoaded, /* underlying module not loaded (Glue Dll's) */
  46. };
  47. /* Minor Error Codes in high two bytes of PTEC */
  48. /* (Not set unless major code also set) */
  49. enum {
  50. ptecModuleAlreadyBusy=128, /* For non-reentrant code */
  51. ptecInvalidID, /* Not yet inited or already terminated.*/
  52. ptecInvalidWsc, /* Illegal values in WSC struct (speller only) */
  53. ptecInvalidMainLex, /* Mdr not registered with session */
  54. ptecInvalidUserLex, /* Udr not registered with session */
  55. ptecInvalidCmd, /* Command unknown */
  56. ptecInvalidFormat, /* Specified dictionary not correct format */
  57. ptecOperNotMatchedUserLex, /* Illegal operation for user dictionary type. */
  58. ptecFileRead, /* Generic read error */
  59. ptecFileWrite, /* Generic write error */
  60. ptecFileCreate, /* Generic create error */
  61. ptecFileShare, /* Generic share error */
  62. ptecModuleNotTerminated, /* Module not able to be terminated completely.*/
  63. ptecUserLexFull, /* Could not update Udr without exceeding limit.*/
  64. ptecInvalidEntry, /* invalid chars in string(s) */
  65. ptecEntryTooLong, /* Entry too long, or invalid chars in string(s) */
  66. ptecMainLexCountExceeded, /* Too many Mdr references */
  67. ptecUserLexCountExceeded, /* Too many udr references */
  68. ptecFileOpenError, /* Generic Open error */
  69. ptecFileTooLargeError, /* Generic file too large error */
  70. ptecUserLexReadOnly, /* Attempt to add to or write RO udr */
  71. ptecProtectModeOnly, /* (obsolete) */
  72. ptecInvalidLanguage, /* requested language not available */
  73. };
  74. #define ProofMajorErr(x) LOWORD(x)
  75. #define ProofMinorErr(x) HIWORD(x)
  76. /************* Structure def macros *************
  77. Smoke and mirrors to allow initialization of some members when
  78. using C++
  79. ***********************************/
  80. #if !defined(__cplusplus)
  81. # define STRUCTUREBEGIN(x) typedef struct {
  82. # define STRUCTUREEND0(x) } x;
  83. # define STRUCTUREEND1(x, y) } x;
  84. # define STRUCTUREEND2(x, y, z) } x;
  85. # define STRUCTUREEND3(x, y, z, w) } x;
  86. #else
  87. # define STRUCTUREBEGIN(x) struct x {
  88. # define STRUCTUREEND0(x) };
  89. # define STRUCTUREEND1(x, y) public: x() : y {} };
  90. # define STRUCTUREEND2(x, y, z) public: x() : y, z {} };
  91. # define STRUCTUREEND3(x, y, z, w) public: x() : y, z, w {} };
  92. #endif
  93. typedef DWORD PROOFVERNO; // version
  94. /* Proof Information Structure - return info from ToolVersion */
  95. STRUCTUREBEGIN(PROOFINFO) // info
  96. WCHAR *pwszCopyright; /* pointer to copyright buffer -
  97. can be NULL if size is zero */
  98. PROOFVERNO versionAPI; /* API */
  99. PROOFVERNO versionVendor; /* includes buildnumber */
  100. VENDORID vendorid; /* from vendor.h */
  101. /* size of copyright buffer in chars - client sets */
  102. DWORD cchCopyright; /* no error if too small or zero */
  103. DWORD xcap; /* tool dependent */
  104. STRUCTUREEND2(PROOFINFO, pwszCopyright(0), cchCopyright(0))
  105. /* xcap is the bitwise-or of */
  106. enum {
  107. xcapNULL = 0x00000000,
  108. xcapWildCardSupport = 0x00000001, // Speller only
  109. xcapMultiLexSupport = 0x00000002,
  110. xcapUserLexSupport = 0x00000008, // a must for spellers
  111. xcapLongDefSupport = 0x00000010, // Thesaurus only
  112. xcapExampleSentenceSupport = 0x00000020, // Thesaurus only
  113. xcapLemmaSupport = 0x00000040, // Thesaurus only
  114. xcapAnagramSupport = 0x00000100, // Speller only
  115. }; // xcap
  116. typedef void * PROOFLEX; // lex
  117. typedef enum {
  118. lxtChangeOnce=0,
  119. lxtChangeAlways,
  120. lxtUser,
  121. lxtExclude,
  122. lxtMain,
  123. lxtMax,
  124. lxtIgnoreAlways=lxtUser,
  125. } PROOFLEXTYPE; // lxt
  126. // note this API does not support external user dictionaries with
  127. // Change (lxtChangeAlways or lxtChangeOnce) properties
  128. // It does support either UserLex (the norm) or Exclude types
  129. // Opening a udr with type Exclude automatically makes it apply to
  130. // the entire session
  131. STRUCTUREBEGIN(PROOFLEXIN) /* Dictionary Input Info - lxin */
  132. const WCHAR *pwszLex; // full path of dictionary to open
  133. BOOL fCreate; /* create if not already exist? (UDR's only) */
  134. PROOFLEXTYPE lxt; /* lxtMain, lxtUser, or lxtExclude (Speller UDR's only) */
  135. LANGID lidExpected; // expected LANGID of dictionary
  136. STRUCTUREEND3(PROOFLEXIN, lidExpected(lidUnknown), fCreate(TRUE), lxt(lxtMain))
  137. STRUCTUREBEGIN(PROOFLEXOUT) /* Dictionary Output Info - lxout */
  138. WCHAR *pwszCopyright; /* pointer to copyright buffer (MDR only)
  139. -- can be NULL if size (below) is zero*/
  140. PROOFLEX lex; /* id for use in subsequent calls */
  141. DWORD cchCopyright; /* client sets - no error if too small or zero */
  142. PROOFVERNO version; /* version of lexfile - includes buildnumber */
  143. BOOL fReadonly; /* set if can't be written on */
  144. LANGID lid; /* LANGID actually used */
  145. STRUCTUREEND2(PROOFLEXOUT, pwszCopyright(0), cchCopyright(0))
  146. typedef void *PROOFID; // id (or sid, hid, or tid)
  147. #define PROOFMAJORVERSION(x) (HIBYTE(HIWORD(x)))
  148. #define PROOFMINORVERSION(x) (LOBYTE(HIWORD(x)))
  149. #define PROOFMAJORMINORVERSION(x) (HIWORD(x))
  150. #define PROOFBUILDNO(x) (LOWORD(x))
  151. #define PROOFMAKEVERSION1(major, minor, buildno) (MAKELONG(buildno, MAKEWORD(minor, major)))
  152. #define PROOFMAKEVERSION(major, minor) PROOFMAKEVERSION1(major, minor, 0)
  153. #define PROOFTHISAPIVERSION PROOFMAKEVERSION(3, 0)
  154. STRUCTUREBEGIN(PROOFPARAMS) // xpar
  155. DWORD versionAPI; // API version requested
  156. STRUCTUREEND1(PROOFPARAMS, versionAPI(PROOFTHISAPIVERSION))
  157. /*************************************************************
  158. PART 2 - Function Defs
  159. **************************************************************/
  160. #if defined(__cplusplus)
  161. extern "C" {
  162. #endif
  163. /* -------------- Common Section (Speller, Hyphenator, and Thesaurus) --------------
  164. the functions in this section are for documentation only -
  165. separate versions exist for each tool.
  166. ---------------------------------------------- */
  167. // ****************************************************************
  168. // ******** PROOFVERSION ****************
  169. // This is the only routine that can be called outside of a session.
  170. // ToolInit begins a session.
  171. // The version numbers are in hex format with
  172. // the high byte representing the major version number,
  173. // the next byte the minor revision number, and the
  174. // low order bytes represent an optional build number.
  175. // For example, version 1.00 is 0x01000000. Version 2.13
  176. // is 0x020d0000. Engines that support
  177. // this API should return 0x03000000 for iAPIVersion.
  178. // The engine ID identifies the core engine creator. The list
  179. // in vendor.h identifies the possible values. For example,
  180. // the Inso derived speller returns VendorIdInso. iVendorVersion
  181. // is up to the vendor to manage and determine.
  182. // This routine may return in xcap the functionality
  183. // supported by the module. Since modules are usually
  184. // dynamically linked, the application should read the
  185. // information and verify that required functionality is
  186. // present.
  187. // PTEC WINAPI ToolVersion(ToolInfo *pInfo);
  188. typedef PTEC (WINAPI *PROOFVERSION) (PROOFINFO *pinfo);
  189. // ***********************************************************
  190. // *** ToolInit
  191. // This is the entry point for a session. With the exception
  192. // of ToolVersion, this routine must return successfully before
  193. // use of any other routines. ToolInit initializes internal
  194. // structures and resources needed for subsequent calls into the
  195. // module. For example, SpellerInit initializes the UserLex,
  196. // ChangeOnce, and ChangeAlways built-in UDR's. In general,
  197. // modules allocate and free resources as needed, transparent to
  198. // the application. pToolId is the handle to those variables.
  199. // Modules store any data from the PROOFPARAMS structure internally
  200. // and do not rely on the data in the structure remaining intact.
  201. // PTEC WINAPI ToolInit(PROOFID *pToolid, const PROOFPARAMS *pxpar);
  202. typedef PTEC (WINAPI *PROOFINIT) (PROOFID *pid, const PROOFPARAMS *pxpar);
  203. // ************************************************************
  204. // *** ToolTerminate
  205. // This function marks the end of the session. It attempts to
  206. // close all dictionaries and free up any and all other resources
  207. // allocated by the module since ToolInit.
  208. // Do not call ToolTerminate if ToolInit was not successful.
  209. // If fForce is TRUE, ToolTerminate is guaranteed to succeed. If
  210. // fForce is false, it may fail. For example, there may be errors
  211. // writing the user dictionaries out to disk. After ToolTerminate
  212. // (whether it succeeds or fails), all other module routines with
  213. // the exception of ToolTerminate and ToolVersion are unusable
  214. // until the module is successfully reinitialized using ToolInit.
  215. // If this call fails, successful re-initialization of the module
  216. // is not guaranteed on all platforms. In addition, failure to
  217. // successfully terminate each session may lock memory and file
  218. // resources in an unrecoverable way until terminate is successful.
  219. // If the terminate call fails, the main application should either
  220. // fix the problem (e.g., insert floppy in drive) and try to
  221. // terminate again, or should terminate using the fForce flag
  222. // switch.
  223. // PTEC WINAPI ToolTerminate(PROOFID id, BOOL fForce);
  224. typedef PTEC (WINAPI *PROOFTERMINATE) (PROOFID id, BOOL fForce);
  225. // *****************************************************************
  226. // *** ToolSetOptions
  227. // Set the value of an option for a tool. The value to set is in iOptVal.
  228. // PTEC WINAPI ToolSetOptions(PROOFID id, int iOptionSelect, int iOptVal);
  229. typedef PTEC (WINAPI *PROOFSETOPTIONS) (PROOFID id, DWORD iOptionSelect, const DWORD iOptVal);
  230. // *****************************************************************
  231. // *** ToolGetOptions
  232. // Get the current value of an option from a tool. Returns in *piOptVal;
  233. // PTEC WINAPI ToolGetOptions(PROOFID id, int iOptionSelect, int *piOptVal);
  234. typedef PTEC (WINAPI *PROOFGETOPTIONS) (PROOFID id, DWORD iOptionSelect, DWORD *piOptVal);
  235. // *****************************************************************
  236. // *** ToolOpenLex
  237. // The dictionary file (main or user) is opened and verified, but not
  238. // necessarily loaded.
  239. // PTEC WINAPI ToolOpenLex(PROOFID id, const PROOFLEXIN *plxin, PROOFLEXOUT *plxout);
  240. typedef PTEC (WINAPI *PROOFOPENLEX) (PROOFID id, const PROOFLEXIN *plxin, PROOFLEXOUT *plxout);
  241. // *****************************************************************
  242. // *** ToolCloseLex
  243. // Closes the specified dictionary and disassociates that dictionary
  244. // from any subsequent checks. In the case of user dictionaries,
  245. // updates the disk file (if any). If the dictionary file cannot
  246. // be updated, the call fails unless the fForce parameter is also set.
  247. // If fForce is true, ToolCloseLex is guaranteed to successfully
  248. // remove the dictionary from the dictionary list and effectively
  249. // close the file. In this case, it the file could not be updated,
  250. // the changes are lost, but the function is considered successful,
  251. // and therefore returns ptecNOERRORS.
  252. // PTEC WINAPI ToolCloseLex(PROOFID id, PROOFLEX dict, BOOL fforce);
  253. typedef PTEC (WINAPI *PROOFCLOSELEX) (PROOFID id, PROOFLEX lex, BOOL fforce);
  254. // fForce forces closing the specified user dictionary, even if the
  255. // dictionary cannot be updated. Has no meaning for main
  256. // dictionaries.
  257. /******************************** Special Glue DLL API ******************
  258. For the glue dll's (converts the API for clients to tools that use API v1 for
  259. speller, hyphenator, v2 for thesaurus), we need to set the name of the previous version
  260. DLL to use - and the code page (that it can't figure out from the LANGID)
  261. to use for any data conversion.
  262. The glue dll's use the lid to set the code page for data conversion.
  263. BOOL WINAPI ToolSetDllName(const WCHAR *pwszDllName, const UINT uCodePage);
  264. *************************************************************************/
  265. #define idllProofSetDllName 19
  266. typedef BOOL (WINAPI *PROOFSETDLLNAME)(const WCHAR *pwszDllName, const UINT uCodePage);
  267. #if defined(__cplusplus)
  268. }
  269. #endif
  270. #pragma pack(pop, proofapi_h) // restore to whatever was before
  271. #endif // PROOFBASE_H