Source code of Windows XP (NT5)
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.

197 lines
4.7 KiB

  1. // This include file is to be shared among all exe's and dll's of Rodan.
  2. #ifndef __INCLUDE_COMMON
  3. #define __INCLUDE_COMMON
  4. // And of course, DBG
  5. #ifdef DBG
  6. #ifndef DBG
  7. #define DBG 1
  8. #endif //!DBG
  9. #endif //!DBG
  10. #ifdef DBG
  11. #ifndef DBG
  12. #define DBG 1
  13. #endif //!DBG
  14. #endif //!DBG
  15. // Include WINDOWS headers
  16. #include <windows.h>
  17. #include <windowsx.h>
  18. // We really don't want these defines to mean anything
  19. #define INLINE
  20. #define EXPORT
  21. #define _loadds
  22. #define _far
  23. #define _pascal
  24. #define PUBLIC
  25. #define PRIVATE
  26. #define BLOCK
  27. // Name of function changes between Windows and WindowCE
  28. #ifdef WINCE
  29. # define CreateMappingCall CreateFileForMapping
  30. #else
  31. # define CreateMappingCall CreateFile
  32. #endif
  33. // Include support for TCHAR functions
  34. #include <tchar.h>
  35. // Include the memory management functions
  36. #include "memmgr.h"
  37. // Include the system dependent file management layer
  38. #ifndef HWX_PRODUCT
  39. # include <stdio.h>
  40. # include "util.h"
  41. BOOL LoadDynamicNumberOfSamples(wchar_t *pFileName, FILE *pFileLog);
  42. int DynamicNumberOfSamples(wchar_t);
  43. BOOL LoadNatualFrequency(wchar_t *pName, FILE *pFileLog);
  44. DWORD DenseCodeNumberOfSamples(wchar_t);
  45. BOOL GetFrequencyInfo(DWORD,wchar_t *,DWORD *);
  46. DWORD GetTotalDenseCodeSamples();
  47. DWORD GetMaxDenseCodeSamples();
  48. DWORD GetNatualFrequencyTableSize();
  49. void UnloadNatualFrequency();
  50. #endif
  51. #include "filemgr.h"
  52. // Include the common error handling stuff
  53. #include "errsys.h"
  54. // Include 'pen' stuff
  55. #include "recogp.h"
  56. // Include the math code
  57. #include "math.h"
  58. #include "mathx.h"
  59. #ifndef abs
  60. #define abs(x) ((x) < 0 ? -(x) : (x))
  61. #endif
  62. // Unicode information.
  63. #define C_UNICODE_CODE_POINTS 0x10000 // Number of Unicode code points
  64. // Include the 'Mars' stuff
  65. #include "frame.h"
  66. #include "glyph.h"
  67. // Include the stuff to access locale dependent information.
  68. #include "locale.h"
  69. // Some additional declarations for natural and training frequencies that
  70. // depend on the locale code.
  71. #ifndef HWX_PRODUCT
  72. int DynamicNumberOfSamplesFolded(LOCRUN_INFO *pLocRunInfo, wchar_t dch);
  73. DWORD DenseCodeNumberOfSamplesFolded(LOCRUN_INFO *pLocRunInfo, wchar_t dch);
  74. #endif
  75. // Include the stuff to access the unigram bigram tables.
  76. #include "unigram.h"
  77. #include "bigram.h"
  78. #include "clbigram.h"
  79. // Fundemental types and structures everybody needs to know about
  80. typedef ALC RECMASK;
  81. typedef WORD SYM;
  82. typedef SYM *LPSYM;
  83. typedef struct tagCHARSET
  84. {
  85. ALC recmask; // Specifies which character types are to be returned
  86. ALC recmaskPriority; // Specifies which character types are preferred
  87. BYTE *pbAllowedChars; // Mask of allowed characters
  88. BYTE *pbPriorityChars; // Mask of characters that are preferred
  89. } CHARSET;
  90. // Accessor functions to see if the given dense or folded code is allowed.
  91. BOOL IsAllowedChar(LOCRUN_INFO *pLocRunInfo, const CHARSET *pCS, wchar_t dch);
  92. BOOL IsPriorityChar(LOCRUN_INFO *pLocRunInfo, const CHARSET *pCS, wchar_t dch);
  93. // Sets characters in the bitmasks defined above in CHARSET.
  94. // If it is given a code which can be folded, takes care of setting
  95. // both the folded and unfolded versions. Also takes care of allocating
  96. // the bitmask if it is not already allocated.
  97. BOOL SetAllowedChar(LOCRUN_INFO *pLocRunInfo, BYTE **ppbAllowedChars, wchar_t dch);
  98. // Allocate and copy bitmask
  99. BYTE *CopyAllowedChars(LOCRUN_INFO *pLocRunInfo, BYTE *pbAllowedChars);
  100. #define MAX_ALT_LIST 20
  101. typedef struct tagALT_LIST
  102. {
  103. UINT cAlt; // Count of valid alternatives
  104. FLOAT aeScore[MAX_ALT_LIST]; // Scores for each alternatives
  105. wchar_t awchList[MAX_ALT_LIST]; // List of alternatives
  106. } ALT_LIST;
  107. extern void SortAltList(ALT_LIST *pAltList);
  108. #define HWX_SUCCESS 0
  109. #define HWX_FAILURE 1
  110. #define HWX_ERROR 2
  111. #ifdef __cplusplus
  112. extern "C"
  113. {
  114. #endif
  115. // Utility functions for tools.
  116. // Smart generation of the path given directory, locale.
  117. // Both the directory and locale are optional.
  118. void FormatPath(
  119. wchar_t *pPath,
  120. wchar_t *pRoot,
  121. wchar_t *pBaseDir,
  122. wchar_t *pLocaleName,
  123. wchar_t *pConfigName,
  124. wchar_t *pFileName
  125. );
  126. #ifdef __cplusplus
  127. }
  128. #endif
  129. // Functions for loading/mapping databases from files or resources
  130. // Structure to store information about the mapped region
  131. typedef struct tagLOAD_INFO {
  132. HANDLE hFile; // Handle to the file
  133. HANDLE hMap; // Handle to the map
  134. BYTE *pbMapping; // Pointer to the mapped region
  135. int iSize; // Size in bytes
  136. } LOAD_INFO;
  137. // Initialize the mapped information structure
  138. void InitLoadInfo(LOAD_INFO *pInfo);
  139. // Map a file into memory
  140. BYTE *DoOpenFile(LOAD_INFO *pInfo, wchar_t *pFileName);
  141. // Unmap a file from memory
  142. BOOL DoCloseFile(LOAD_INFO *pInfo);
  143. // Map a resource into memory
  144. BYTE *DoLoadResource(LOAD_INFO *pInfo, HINSTANCE hInst, int nResID, int nType);
  145. #endif // !__INCLUDE_COMMON