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.

389 lines
14 KiB

  1. /*************************************************
  2. * conv.h *
  3. * *
  4. * Copyright (C) 1995-1999 Microsoft Inc. *
  5. * *
  6. *************************************************/
  7. #ifndef __CONV_H
  8. #define __CONV_H
  9. #include <windows.h>
  10. #include <windowsx.h>
  11. #include <io.h>
  12. #include <stdio.h>
  13. #include <string.h>
  14. #define STRSAFE_NO_DEPRECATE
  15. #include "strsafe.h"
  16. #include "propshet.h"
  17. #ifndef ARRAYSIZE
  18. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  19. #endif
  20. //****** PlatFormID ********
  21. #define WIN95_PRC 0x00000001
  22. #define WIN95_CJK 0x00000002
  23. //****** EncodeID **********
  24. #define GBK_IME 0x00000001
  25. #define UNICODE_IME 0x00000002
  26. //****** FileFlag **********
  27. #define FFLG_SINGLEELEMENT 0x00000000
  28. #define FFLG_MULTIELEMENT 0x00000002
  29. #define FFLG_RULE 0x00000001
  30. #define FFLG_NORULE 0x00000000
  31. //****** Number of tables ******
  32. #define NUMTABLES 0x00000007
  33. //****** Version ***********
  34. #define MBVERSION "1.00"
  35. //****** Index tag *********
  36. #define TAG_DESCRIPTION 0x00000001
  37. #define TAG_RULE 0x00000002
  38. #define TAG_ENCODE 0x00000003
  39. #define TAG_CRTWORDCODE 0x00000004
  40. #define TAG_RECONVINDEX 0x00000005
  41. #define TAG_BASEDICINDEX 0x00000006
  42. #define TAG_BASEDIC 0x00000007
  43. //****** Get code direction mode ****
  44. #define GETCODEFORWARD 0x00000001
  45. #define GETCODEBACKWARD 0xffffffff
  46. //****** define error number *******
  47. #define ERR_MBNAME 1001
  48. #define ERR_FILENOTEXIST 1002
  49. #define ERR_FILENOTOPEN 1003
  50. #define ERR_OUTOFMEMORY 1004
  51. #define ERR_GLOBALLOCK 1005
  52. #define ERR_IMEUSE 1006
  53. #define ERR_MAXCODES 1101 //error:MaxCodes over 12!
  54. #define ERR_ELEMENT 1102 //error:MaxElement above MaxCodes!
  55. #define ERR_USEDCODE 1103 //error:not in {'0'~'9','a'~'z',...}
  56. #define ERR_WILDCHAR 1104 //error:WildChar in {UsedCode} !
  57. #define ERR_DESCRIPTSEG 1105
  58. #define ERR_OVERWRITE 1106
  59. #define ERR_IMENAMEENTRY 1107
  60. #define ERR_MAXCODESENTRY 1108
  61. #define ERR_ELEMENTENTRY 1109
  62. #define ERR_USEDCODEENTRY 1110
  63. #define ERR_NUMRULEENTRY 1111
  64. #define ERR_RULEHEADER 1201
  65. #define ERR_RULELOGICOPRA 1202
  66. #define ERR_RULEWORDLEN 1203
  67. #define ERR_RULEEQUAL 1204//error:not exist '='
  68. #define ERR_RULEDBCSPOS 1205//error:DBCS position not in {'1'~'9','a'~'f'}
  69. #define ERR_RULECODEPOS 1206
  70. #define ERR_RULEDIRECTMODE 1207
  71. #define ERR_NORULE 1210
  72. #define ERR_NOTDEFRULE 1211//error:not defined this length word's ruler
  73. #define ERR_RULENUM 1212
  74. #define ERR_RULESEG 1213
  75. #define ERR_DUPRULE 1214 //DUPLICATE RULE
  76. #define ERR_DBCSCODE 1301
  77. #define ERR_CODEUNITNOTEXIST 1302
  78. #define ERR_CREATECODE 1303
  79. #define ERR_CREATENOTEXIST 1304//multi-elements
  80. #define ERR_CODEEMPTY 1305//when ruler doesnot exist
  81. #define ERR_SINGLECODEWORDDOUBLE 1306
  82. #define ERR_SBCS_IN_DBCS 1307
  83. #define ERR_GB2312NOTENTIRE 1308
  84. #define ERR_USERWORDLEN 1309
  85. #define ERR_WORDNOTEXIST 1310
  86. #define ERR_TEXTSEG 1311
  87. #define ERR_TOOMANYUSERWORD 1312
  88. #define ERR_WRITEID 1401
  89. #define ERR_WRITEMAININDEX 1402
  90. #define ERR_WRITEDESCRIPT 1403
  91. #define ERR_WRITERULE 1404
  92. #define ERR_READID 1411
  93. #define ERR_READMAININDEX 1412
  94. #define ERR_READDESCRIPT 1413
  95. #define ERR_READRULE 1414
  96. #define ERR_CONVEND 1501
  97. #define ERR_RECONVEND 1502
  98. #define ERR_SORTEND 1503
  99. #define ERR_VERSION 1601
  100. #define ERR_GROUP 1602
  101. #define ERR 1
  102. #define INFO 2
  103. #define WARNING 3
  104. #define GB2312WORDNUM 6763
  105. #define NUM_OF_XGB_ENCODE 23940
  106. #define NUM_OF_CJK_ENCODE 28528
  107. #ifdef UNICODE
  108. #define NUM_OF_ENCODE NUM_OF_CJK_ENCODE
  109. #else
  110. #define NUM_OF_ENCODE NUM_OF_XGB_ENCODE
  111. #endif
  112. //CJK Unified Ideograph subset
  113. #define NUM_OF_CJK_CHINESE 20992
  114. #ifdef UNICODE
  115. #define NUMENCODEAREA 8
  116. #else
  117. #define NUMENCODEAREA 252
  118. #endif
  119. #define MAXNUMCODES 128
  120. #define MAXUSEDCODES 48
  121. #define NAMESIZE 128
  122. #define MAXCODELEN 12
  123. #define MAXREADBUFFER 0x4000
  124. #define USER_WORD_SIZE 40
  125. #define MAX_WORD_SIZE 256
  126. //#define ID_LENGTH 28
  127. #define ID_LENGTH sizeof(MAINID)
  128. #define CODEMAPOFFSET 4
  129. #define MAXUSERWORDS 1000
  130. #define GMEM_PAGESIZE 0x10000
  131. #define MbName "IME file"
  132. //#define CaptionName "���뷨������"
  133. #define ImeSubKey "System\\CurrentControlSet\\Control\\Keyboard Layouts"
  134. #define szClassName "IMEGEN"
  135. #define TplName "\\ImeGen.tpl"
  136. #define BmpExt ".BMP"
  137. #define IconExt ".ICO"
  138. #define HlpExt ".HLP"
  139. #define ImeExt ".IME"
  140. #define MbExt ".MB"
  141. #define EmbExt ".EMB"
  142. #define TxtFileExt ".TXT"
  143. #define Slope "\\"
  144. #define LayoutTextKey "layout text"
  145. #define PreImeKey "keyboard layout\\preload"
  146. #define DescriptSeg "[Description]"
  147. #define RuleSeg "[Rule]"
  148. #define TextSeg "[Text]"
  149. #define TempFile "$$$$$$$$.$$$"
  150. #define DefVer "5.0"
  151. #define DefOrgName "Microsoft"
  152. #define NUMPROPSHEET 5
  153. #define PROP_CRTIME 0
  154. #define PROP_RECONV 1
  155. #define PROP_SORT 2
  156. #define PROP_CRTWORD 3
  157. #define PROP_ABOUT 4
  158. typedef unsigned char UCHAR;
  159. typedef LPTSTR LPCREATEWORD;
  160. typedef LPTSTR LPRECONVINDEX;
  161. typedef LPDWORD LPDICINDEX;
  162. typedef LPDWORD LPNUMXYWORDS;
  163. typedef struct tagMAINID {
  164. TCHAR szVersion[4];
  165. DWORD dwLanguageID;
  166. DWORD dwEncodeID;
  167. DWORD dwFileFlag;
  168. DWORD dwNumTables;
  169. DWORD dwNumWords;
  170. } MAINID, FAR *LPMAINID;
  171. typedef struct tagMAININDEX {
  172. DWORD dwTag;
  173. DWORD dwOffset;
  174. DWORD dwLength;
  175. DWORD dwCheckSum; //Check if dwCheckSum=dwTag+dwOffset+dwLength
  176. } MAININDEX, FAR *LPMAININDEX;
  177. typedef struct tagDESCRIPTION {
  178. TCHAR szName[NAMESIZE];
  179. WORD wMaxCodes;
  180. WORD wNumCodes;
  181. TCHAR szUsedCode[MAXUSEDCODES];
  182. BYTE byMaxElement;
  183. TCHAR cWildChar;
  184. WORD wNumRules;
  185. } DESCRIPTION,FAR * LPDESCRIPTION;
  186. typedef struct tagCREATEWORDRULE {
  187. BYTE byLogicOpra;
  188. BYTE byLength;
  189. WORD wNumCodeUnits;
  190. struct CODEUNIT {
  191. DWORD dwDirectMode;
  192. WORD wDBCSPosition;
  193. WORD wCodePosition;
  194. } CodeUnit[12];
  195. } RULE,FAR *LPRULE;
  196. typedef struct tagENCODEAREA {
  197. DWORD PreCount;
  198. DWORD StartEncode;
  199. DWORD EndEncode;
  200. } ENCODEAREA,FAR *LPENCODEAREA;
  201. typedef struct tagEMBHEAD {
  202. TCHAR W_Code[MAXCODELEN];
  203. TCHAR C_Char[USER_WORD_SIZE];
  204. } EMB_Head,FAR *LPEMB_Head;
  205. typedef struct tagWORDINDEX {
  206. TCHAR szCode[MAXCODELEN+1];
  207. WORD wDBCSLen;
  208. DWORD dwOffset;
  209. } WORDINDEX,FAR *LPWORDINDEX;
  210. typedef struct tagImeRes{
  211. TCHAR Version[NAMESIZE];
  212. TCHAR Depart[NAMESIZE/2];
  213. TCHAR BmpName[MAX_PATH];
  214. TCHAR IcoName[MAX_PATH];
  215. TCHAR HlpFile[MAX_PATH];
  216. WORD Value;
  217. }IMERES,FAR *LPIMERES;
  218. extern HANDLE hDlgless;
  219. extern HGLOBAL hRule;
  220. HGLOBAL hEncode;
  221. HINSTANCE hInst;
  222. DWORD dwLineNo;
  223. WORD EMB_Count;
  224. HANDLE HmemEMB_Table;
  225. HANDLE hSRCFile,hMBFile;
  226. HANDLE hCmbFile;
  227. BYTE WriteCrtFlag[(NUM_OF_ENCODE+7)/8];
  228. BOOL InitApplication(HINSTANCE);
  229. BOOL ConvConv (HANDLE, LPCTSTR, LPCTSTR);
  230. BOOL ConvReConv (HANDLE, LPCTSTR, LPCTSTR);
  231. BOOL ConvGetMainID (HANDLE, LPMAINID);
  232. BOOL ConvWriteMainID (HANDLE, LPMAINID);
  233. BOOL ConvGetMainIndex (HANDLE, HANDLE, LPMAININDEX);
  234. BOOL ConvWriteMainIndex (HANDLE, LPMAININDEX);
  235. BOOL ConvReadFile (HANDLE, LPCTSTR, LPCTSTR);
  236. BOOL WriteSortFile (HANDLE, HANDLE, HANDLE, LPWORDINDEX, LPCREATEWORD);
  237. BOOL ConvReadDescript (HANDLE, LPDESCRIPTION, LPMAININDEX);
  238. BOOL ConvWriteDescript (HANDLE, LPDESCRIPTION, LPMAININDEX);
  239. int ConvGetDescript (HANDLE, LPCTSTR, LPDWORD, LPDWORD, LPDESCRIPTION,BOOL);
  240. BOOL ConvSaveDescript (LPCTSTR, LPDESCRIPTION, DWORD, DWORD);
  241. BOOL ConvReadRule (HANDLE, int, LPRULE, LPMAININDEX);
  242. BOOL ConvWriteRule (HANDLE, int, LPRULE, LPMAININDEX);
  243. int ConvGetRule (HANDLE, LPCTSTR, LPDWORD, LPDWORD, LPRULE, LPDESCRIPTION);
  244. BOOL ConvSaveRule (HANDLE, LPCTSTR, DWORD, DWORD, LPRULE, DWORD);
  245. BOOL ConvInitEncode (HGLOBAL hEncode);
  246. BOOL ConvGetEncode (HANDLE, LPENCODEAREA, LPDWORD, LPDWORD, LPMAININDEX);
  247. BOOL ConvWriteEncode (HANDLE, LPENCODEAREA, LPMAININDEX);
  248. BOOL ConvGetCrtData (HANDLE, LPCREATEWORD, LPMAININDEX);
  249. BOOL ConvWriteCrtData (HANDLE, LPCREATEWORD, LPMAININDEX);
  250. BOOL ConvGetReConvIndex (HANDLE, LPRECONVINDEX, LPMAININDEX);
  251. BOOL ConvWriteReConvIdx (HANDLE, LPRECONVINDEX, LPMAININDEX);
  252. BOOL ConvGetCodeIndex (HANDLE, LPDWORD, LPSTR, LPMAININDEX);
  253. BOOL ConvWriteCodeIndex (HANDLE, LPDWORD, LPTSTR, LPMAININDEX);
  254. BOOL ConvGetDicIndex (HANDLE, LPDWORD, DWORD, LPMAININDEX);
  255. BOOL ConvWriteDicIndex (HANDLE, LPDWORD, DWORD, LPMAININDEX);
  256. BOOL ConvGetNumXYWords (HANDLE, LPDWORD, DWORD, LPMAININDEX);
  257. BOOL ConvWriteNumXYWords(HANDLE, LPDWORD, DWORD, LPMAININDEX);
  258. BOOL ConvInsNewWord (HANDLE, HANDLE, EMB_Head);
  259. BOOL ConvSort (HANDLE, LPWORDINDEX, int);
  260. BOOL ConvBatCreate (HANDLE, DESCRIPTION, LPRULE, LPCREATEWORD, LPTSTR, LPTSTR);
  261. LPTSTR ConvCreateWord (HWND, LPCTSTR, LPTSTR);
  262. void ConvInit (LPDESCRIPTION,LPMAINID,LPMAININDEX);
  263. BOOL ConvGetBaseWord (HANDLE, WORDINDEX, LPTSTR);
  264. BOOL ConvWriteBaseWord (HANDLE, HANDLE, HANDLE, MAINID,DWORD,
  265. LPCREATEWORD, LPRECONVINDEX, DWORD);
  266. BOOL ReadSRCFile (HANDLE, LPINT, HANDLE, LPCREATEWORD, LPWORDINDEX,
  267. LPINT, LPDESCRIPTION,LPRECONVINDEX);
  268. BOOL ConvCalc (HANDLE ,HANDLE ,LPWORDINDEX ,LPMAININDEX ,LPDESCRIPTION);
  269. //BOOL WriteMBFile (HANDLE, HANDLE, HANDLE, LPWORDINDEX,
  270. // LPMAININDEX, LPDESCRIPTION, LPCREATEWORD, LPRECONVINDEX);
  271. BOOL WriteMBFile (HANDLE, HANDLE, HANDLE, LPWORDINDEX,
  272. LPMAININDEX, LPDESCRIPTION);
  273. int WordSplit (HANDLE, LPINT, LPTSTR, LPCREATEWORD, LPWORDINDEX,
  274. LPDESCRIPTION,LPRECONVINDEX);
  275. int SimpleSplit (HANDLE, LPINT, LPTSTR, LPCREATEWORD, LPWORDINDEX, WORD);
  276. void qSort (LPWORDINDEX, DWORD,DWORD);
  277. void qSortChar (LPTSTR , DWORD ,DWORD );
  278. HANDLE IndexReAlloc (HANDLE, LPINT);
  279. BOOL RuleParse (HANDLE, LPTSTR, DWORD, LPRULE, WORD);
  280. void RuleToText (LPRULE, LPTSTR);
  281. void MoveFileBlock (HANDLE, DWORD, DWORD, DWORD);
  282. DWORD EncodeToNo (LPTSTR);
  283. DWORD EncodeToGBNo (UCHAR szDBCS[3]);
  284. void NoToEncode (DWORD, LPBYTE, DWORD, LPENCODEAREA);
  285. BOOL CheckCrtData (HANDLE, LPCREATEWORD, LPENCODEAREA, DWORD);
  286. void DispInfo (HANDLE, WORD);
  287. void lstrncpy0 (LPTSTR ,int ,LPTSTR );
  288. BOOL ReadUserWord (HWND ,LPTSTR ,LPDWORD,WORD);
  289. INT ReadDescript (LPCTSTR , LPDESCRIPTION ,DWORD);
  290. BOOL ReadRule (HWND, LPCTSTR , int ,LPRULE );
  291. int CheckUserWord (HWND ,LPTSTR, WORD);
  292. BOOL CheckUserDBCS (HWND ,LPTSTR);
  293. BOOL CheckCodeLegal (HWND ,LPTSTR ,LPTSTR, LPTSTR, LPDESCRIPTION );
  294. BOOL CheckCodeCollection(HWND ,LPTSTR ) ;
  295. BOOL SaveFileAs (HWND , LPTSTR );
  296. BOOL CreateMbKey (PHKEY ,LPCTSTR ,LPCTSTR);
  297. BOOL SetRegValue (HKEY ,LPDWORD );
  298. BOOL GetRegValue (HWND, HKEY ,LPDWORD );
  299. extern void DelSpace();
  300. extern void trim();
  301. extern BOOL ParseDBCSstr();
  302. extern void lstrncpy();
  303. extern HANDLE Create_File();
  304. extern BOOL Copy_File();
  305. extern void ProcessError();
  306. extern BOOL QueryKey();
  307. extern BOOL ErrMessage();
  308. extern VOID WarnMessage();
  309. extern VOID FatalMessage();
  310. extern VOID InfoMessage();
  311. extern void ErrorOut();
  312. extern HANDLE CreateMapFile ();
  313. extern HANDLE CreateMap ();
  314. extern LPVOID MapView ();
  315. extern HANDLE OpenMap ();
  316. extern BOOL WriteEMBToFile();
  317. extern BOOL ReadEMBFromFile();
  318. extern void DelSelCU();
  319. extern int AddZCItem();
  320. extern void fnsplit();
  321. extern int GetEntryInt(LPTSTR , LPTSTR, int ,LPINT);
  322. extern int GetEntryString();
  323. extern void GetEntryName();
  324. extern int CheckDescription();
  325. extern int GetDescriptEntry();
  326. extern BOOL searchPos(LPWORDINDEX , DWORD );
  327. extern DWORD bSearch(LPWORDINDEX , DWORD , DWORD , WORDINDEX );
  328. int ConvReconvIndex(HANDLE ,LPTSTR ,LPCREATEWORD ,WORDINDEX ,LPDESCRIPTION ,LPRECONVINDEX );
  329. void DelIllegalCode(TCHAR *);
  330. LPTSTR _tcschr(LPTSTR, TCHAR);
  331. LPTSTR _tcsrchr(LPTSTR, TCHAR);
  332. LPTSTR _tcsstr(LPTSTR, LPTSTR);
  333. LPTSTR _tcsupr(LPTSTR);
  334. int _taccess(LPTSTR, int);
  335. int _ttoi(LPTSTR);
  336. #endif //__CONV_H