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.

879 lines
32 KiB

  1. /*************************************************************************
  2. * *
  3. * COMMON.H *
  4. * *
  5. * Copyright (C) Microsoft Corporation 1990-1992 *
  6. * All Rights reserved. *
  7. * *
  8. **************************************************************************
  9. * *
  10. * Module Intent *
  11. * All typedefs and defines needed for internal indexing and retrieval *
  12. * *
  13. **************************************************************************
  14. * *
  15. * Current Owner: BinhN *
  16. * *
  17. **************************************************************************
  18. * *
  19. * Released by Development: (date) *
  20. * *
  21. *************************************************************************/
  22. #ifndef __FTSCOMMON_H__
  23. #define __FTSCOMMON_H__
  24. #include <_mvutil.h>
  25. // Critical structures that gets messed up in /Zp8
  26. #pragma pack(1)
  27. /*************************************************************************
  28. * Basic defines.
  29. *************************************************************************/
  30. #if defined( __cplusplus )
  31. extern "C" {
  32. #endif
  33. /*
  34. * Various files stamps.
  35. * This is to distinguish one file's type from another
  36. */
  37. #define INDEX_STAMP 0x0000
  38. #define CATALOG_STAMP 0x1111
  39. #define STOP_STAMP 0x2222
  40. //#define GROUP_STAMP 0x3333
  41. #define WHEEL_STAMP 0x4444
  42. #define CHRTAB_STAMP 0x5555
  43. #define OPTAB_STAMP 0x6666
  44. /*
  45. * Various subfiles' default names
  46. */
  47. #define SZ_DEFAULT_INDEXNAME "|MVINDEX"
  48. #define SZ_DEFAULT_CATNAME "|CATALOG"
  49. #define SZ_DEFAULT_STOPNAME "|MVSTOP"
  50. #define SZ_DEFAULT_GROUPNAME "|MVGROUP"
  51. #define SZ_DEFAULT_CHARTABNAME "|MVCHARTAB"
  52. #define SZ_DEFAULT_WWBTREE_NAME "|MVWWHEEL.WWT"
  53. #define SZ_DEFAULT_WWMAP_NAME "|MVWWHEEL.WWM"
  54. #define SZ_DEFAULT_OPTABNAME "|MVOPTAB"
  55. #define cbitWORD (CBIT)16 // Number of bits in a word.
  56. #define cbitBYTE (CBIT)8 // Number of bits in a byte.
  57. typedef WORD CSKP;
  58. typedef CSKP FAR * LPCSKP;
  59. typedef CSKP FAR * SPCSKP;
  60. #define CSKP_IGNORE ((CSKP)0) // If the skip count is zero, don't
  61. // decrement it, just use the current
  62. // length until you run out of stuff.
  63. #define CSKP_MAX ((CSKP)-1) // Largest possible skip count.
  64. #define CSKP_MIN ((CSKP)1) // Smallest meaningful skip count.
  65. // Zero is reserved for something else.
  66. #define KEEP_SEARCHING ((int)-1)
  67. #define STRING_MATCH 0
  68. #define NOT_FOUND 1
  69. /*************************************************************************
  70. * Typedef
  71. *************************************************************************/
  72. typedef HANDLE GHANDLE;
  73. //typedef HANDLE HFS;
  74. typedef GHANDLE HIDX;
  75. typedef unsigned short USHORT;
  76. //typedef BYTE NEAR * NRGB; // Pointers to unsigned characters.
  77. typedef BYTE FAR * LRGB;
  78. //typedef BYTE HUGE * HRGB;
  79. typedef BYTE NEAR * NST; // Pascal-style strings.
  80. typedef DWORD FAR * LPDW;
  81. typedef DWORD FAR * LRGDW;
  82. typedef VOID FAR * LPV; // Pointer to void
  83. typedef VOID FAR* FAR* LPLPV; // Pointer to far pointer
  84. typedef WORD FAR * LPW;
  85. typedef GHANDLE HBI;
  86. typedef WORD OCCIF;
  87. //typedef GHANDLE HF;
  88. /************************************************************************
  89. *
  90. * Character Mapping Table Structure
  91. *
  92. ************************************************************************/
  93. typedef struct
  94. {
  95. WORD Class; // Action controlled class
  96. WORD SortOrder; // Sorting order
  97. BYTE Norm; // Normalized character (for search)
  98. BYTE WinCaseSensitiveNorm; // For text copy
  99. BYTE MacDisplay; // Mac's display
  100. BYTE MacCaseSensitiveNorm; // For text copy
  101. BYTE MacToWin; // Mapping back from Mac to Win
  102. BYTE Pad1; // Padding purpose for dword alignment
  103. } CHARMAP, FAR *LPCMAP;
  104. /*************************************************
  105. * Character related information table structure
  106. * Must match the one in mvfs\btpriv.h
  107. *************************************************/
  108. typedef struct CHARTAB
  109. {
  110. HANDLE hStruct; // Handle to this structure
  111. LPV lpLigature; // Ligature table
  112. HANDLE hLigature; // Handle to ligature table
  113. LPCMAP lpCMapTab; // Character mapping table
  114. WORD wcLigature; // Number of ligature entries
  115. WORD wcTabEntries; // Number of table entries
  116. WORD fFlag; // Various flags
  117. WORD Pad; // Padding to make DWORD align
  118. } CHARTAB, FAR *LPCHARTAB;
  119. #define DEF_LIGATURE_COUNT 5 // Default number of ligature entries
  120. /* Operator table support */
  121. typedef struct OPSYM {
  122. LPB OpName; /* Operator name */
  123. WORD OpVal; /* Operator value */
  124. } OPSYM, FAR *LPOPSYM;
  125. /* Number of entries in the default OperatorArray */
  126. #define OPERATOR_ENTRY_COUNT 7
  127. /* Size of the buffer used for Operator table */
  128. #define OPTABLE_SIZE 100
  129. typedef struct OPTABLE
  130. {
  131. LPB lpbOptable; /* Pointer operator symbol table buffer */
  132. HANDLE hOpTab; /* Handle to table buffer */
  133. LPOPSYM lpOpsymTab; /* Pointer to operator symbol table */
  134. HANDLE hOpSym; /* Handle to operator symbol table */
  135. HANDLE hStruct; /* Handle to this structure */
  136. WORD cbLeft; /* Byte left in the buffer */
  137. WORD wsize; /* Size of the table */
  138. WORD cEntry; /* Number of operator entries */
  139. BYTE fFlag[OPERATOR_ENTRY_COUNT];
  140. } OPTABLE, FAR *_LPOPTAB;
  141. /* Functions' types */
  142. typedef ERR (FAR PASCAL * FWORDCB)(LST, LST, DWORD, LPV);
  143. #define ACCEPT_WILDCARD 1
  144. /* Functions' types */
  145. typedef ERR (FAR PASCAL * FWORDCB)(LST, LST, DWORD, LPV);
  146. typedef ERR (FAR PASCAL * BREAKER_FUNC) (LPBRK_PARMS);
  147. typedef LPIBI (FAR PASCAL * BREAKER_INIT)(VOID);
  148. typedef short (FAR PASCAL * ICMPWORDS)(LST, LST);
  149. typedef void (FAR PASCAL * BREAKER_FREE)(LPIBI);
  150. /* Breaker's information structure. All scanning functions will
  151. be called indirectly through the functions pointers
  152. */
  153. typedef ERR (FAR PASCAL * FSTEM)(LST, LST);
  154. typedef struct BreakerInfo
  155. {
  156. HANDLE hbi; // Handle to this structure.
  157. HANDLE hModule; // "LoadLibrary" handle.
  158. LPIBI lpibi; // Internal break info pointer.
  159. BREAKER_FUNC lpfnFBreakWords; // Pointer to word-breaker function
  160. BREAKER_FUNC lpfnFBreakDate; // Pointer to date-breaker function
  161. BREAKER_FUNC lpfnFBreakNumber; // Pointer to number-breaker function
  162. BREAKER_FUNC lpfnFBreakEpoch; // Pointer to epoch-breaker function
  163. BREAKER_FUNC lpfnFBreakTime; // Pointer to time-breaker function
  164. BREAKER_FREE lpfnBreakerFree; // Ptr to function freeing the breaker
  165. BREAKER_INIT lpfnBreakerInit; // Ptr to function initializing breaker
  166. FSTEM lpfnFStem; // Pointer to stemming function
  167. ICMPWORDS lpfnICmpWords; // Word comparison function
  168. } BI, FAR *_LPBRKI;
  169. // Information about these is kept on a per-topicID basis.
  170. #define OCCF_PER_TOPICID (OCCF_COUNT | OCCF_OFFSET | OCCF_LENGTH)
  171. #define CB_MAX_PACKED_OCC_SIZE (sizeof(OCC) + 8)
  172. // Largest possible packed (either sort-packed
  173. // or byte-packed) occurence record. This is
  174. // equal to "sizeof(OCC)" plus one byte for
  175. // each field in an OCC.
  176. #define CB_DEF_NODE_SIZE ((WORD)4096) // B-tree node size.
  177. #define DW_NIL_FIELD ((DWORD)0L) // Dead field-ID.
  178. // Compression-key defines.
  179. // The order of the following defines is important.
  180. typedef BYTE CSCH;
  181. #define CSCH_NONE ((CSCH)0x00)
  182. // Indicates default compression schemes,
  183. // which is the "bitstream" scheme.
  184. // --------
  185. // Delta-compression schemes:
  186. // --------
  187. #define CSCH_FIXED ((CSCH)0x01)
  188. // If this is set, "nWidth" contains the
  189. // number of bits that is used in all cases
  190. // to store the delta. If this bit is not
  191. // set, the following bits are tested. The
  192. // value of this should be "one".
  193. #define CSCH_BELL ((CSCH)0x02)
  194. // If this is set, the "bell curve" scheme is
  195. // used, and "nWidth" contains the "center"
  196. // value that the scheme will use. If this
  197. // bit is not set, the run will be compressed
  198. // with bitstream encoding. The value of
  199. // this should be "two".
  200. // ----
  201. // If more delta compression scheme selectors
  202. // are inserted here, they should use the
  203. // least-significant un-used bits, in order.
  204. // --------
  205. // Other flags:
  206. // --------
  207. #define CSCH_UNARY ((CSCH)0x80)
  208. // This is set if for the given word no more
  209. // that one occurence of the word appears in
  210. // any one topic. The word can appear
  211. // in more than one topic, it only needs
  212. // to occur EXACTLY ONCE in each topic
  213. // that it appears in. The value of this
  214. // bit should be set apart from the values
  215. // for delta compression scheme selection.
  216. // The width of the "center" value.
  217. #define CBIT_WIDTH_BITS ((CBIT)5)
  218. // Index to different slot for compression scheme
  219. #define CKEY_TOPIC_ID 0
  220. #define CKEY_OCC_COUNT 1
  221. #define CKEY_OCC_BASE 2
  222. typedef struct CompressionKey
  223. {
  224. CSCH cschScheme;
  225. BYTE ucCenter;
  226. } CKEY,
  227. FAR *LPCKEY;
  228. // Index b-tree node-ID.
  229. typedef DWORD NID; // Node-ID.
  230. typedef NID FAR *LPNID;
  231. #define NID_NIL ((NID)-1L)
  232. #define CB_HUGE_BUF (cbMAX_IO_SIZE) // A very large file buffer.
  233. // This is 32767, which is
  234. // not a power of two.
  235. // These were used for version 8 and are no longer needed in v20
  236. #define MAX_WEIGHT (WORD)-1 // The maximum weight
  237. // A couple of FBI utility defines.
  238. #define CB_BIG_BUF ((CB)16384) // A large file buffer.
  239. // Maximum height of B-tree that we support
  240. #define MAX_TREE_HEIGHT 10
  241. typedef struct FILEDATA
  242. {
  243. HFPB fFile; // Handle to file
  244. HANDLE hMem; // Handle to memory buffer
  245. LPB pMem; // Pointer to memory buffer
  246. LPB pCurrent; // Pointer to current position in buffer
  247. LONG dwMax; // Size of the buffer
  248. FILEOFFSET foPhysicalOffset; // The physical offset into the file that
  249. // pCurrent should be pointing to
  250. FILEOFFSET foStartOffset; // The physical offset into the file that
  251. // beginning of a FileWrite
  252. LONG cbLeft; // Number of bytes left in buffer
  253. char ibit; // Index of the current bit in the current
  254. // byte. Used for bit-aligned compresssion
  255. // Must be signed!!
  256. BYTE pad1;
  257. BYTE pad2;
  258. BYTE pad3;
  259. } FILEDATA, FAR *PFILEDATA;
  260. typedef struct NODEINFO
  261. {
  262. HANDLE hStruct; // Handle to this structure. MUST BE 1ST!
  263. HFPB hfpbIdx; // Index file.
  264. FILEOFFSET nodeOffset; // File offset of this node
  265. FILEOFFSET nextNodeOffset; // Next node offset
  266. FILEOFFSET prevNodeOffset; // Next node offset
  267. DWORD dwBlockSize; // Size of the block
  268. LPB pTopNode; // Pointer to the index top node.
  269. LPB pStemNode; // Pointer to stem buffer
  270. LPB pLeafNode; // Pointer to leaf buffer
  271. LPB pDataNode; // Pointer to data node
  272. HANDLE hMem; // Handle to the data buffer
  273. LPB pBuffer; // Pointer to the data
  274. LPB pCurPtr; // Pointer to the end of written data
  275. LPB pMaxAddress; // Maximum address of the block
  276. LONG cbLeft; // Number of bytes left in buffer
  277. // Buffer to hold the last word processed
  278. // Currently allocate dwMaxWLen + 50
  279. HANDLE hLastWord; // Handle to last word
  280. LPB pLastWord;
  281. // Buffer to hold the current word processed
  282. // Currently allocate dwMaxWLen + 50 + sizeof fields
  283. HANDLE hTmp;
  284. LPB pTmpResult;
  285. DWORD dwDataSizeLeft; // Number of data byte left
  286. USHORT Slack; // Amount of slack to leave
  287. char ibit; // Number of bit left. MUST BE SIGNED!
  288. BYTE iLeafLevel; // Index b-tree leaf level.
  289. BYTE fFlag;
  290. BYTE Pad;
  291. } NODEINFO, FAR *PNODEINFO;
  292. #define TO_BE_UPDATE 0x01
  293. /*************************************************************************
  294. *
  295. * Index Structure
  296. *
  297. *************************************************************************/
  298. // Index header. One of these records resides as the first thing in
  299. // any index.
  300. typedef WORD VER; // Index version. This is simply
  301. // a WORD because there's probably
  302. // no need to specify major and
  303. // minor version stuff.
  304. #define VERCURRENT ((VER)40) // Current index-format version.
  305. // #define GROUPVER ((VER)20) // Current group version
  306. #define CHARTABVER ((VER)20) // Current chartable version
  307. #define cLOG_MAX 1000 // Number of pre-calculated log values
  308. #define FILE_HEADER 1024 // Size of the file header
  309. #define FILE_BUFFER 0xFFFF // Size of file buffers. This mus be at
  310. // least as large as BTREE_NODE_SIZE.
  311. #if 0
  312. #define BTREE_NODE_SIZE 50 // Size of each B-Tree node
  313. #define STEM_SLACK 10 // Slack space in stem nodes
  314. #define LEAF_SLACK 10 // Slack space in leaf nodes
  315. #else
  316. #define BTREE_NODE_SIZE 0x1000 // Size of each B-Tree node
  317. #define STEM_SLACK 64 // Slack space in stem nodes
  318. #define LEAF_SLACK 128 // Slack space in leaf nodes
  319. #endif
  320. #define FOFFSET_SIZE 6
  321. #define DATABLOCK_ALIGN 4 // This should never be 0
  322. typedef struct IdxHeader20
  323. {
  324. unsigned short FileStamp; // Index stamp (WORD)
  325. VER version; // Index format version number. (WORD)
  326. DWORD lcTopics; // The number of distinct topics
  327. // in the index.
  328. FILEOFFSET foIdxRoot; // Physical address of top node in tree
  329. NID nidLast; // Highest node-ID allocated. (DWORD)
  330. NID nidIdxRoot; // (DWORD)
  331. WORD cIdxLevels; // Number of levels in the b-tree. (WORD)
  332. WORD occf; // Occurence flags, tells me which (WORD)
  333. // occurence fields are kept.
  334. WORD idxf; // Index flags, tells me which other (WORD)
  335. // indexing options were selected.
  336. //
  337. // Index b-tree compression keys.
  338. //
  339. CKEY ckeyTopicId; // 2-bytes
  340. CKEY ckeyOccCount; // 2-bytes
  341. CKEY ckeyWordCount;
  342. CKEY ckeyOffset;
  343. CKEY ckeyUnused1; // Future use
  344. CKEY ckeyUnused2; // Future use
  345. CKEY ckeyUnused3; // Future use
  346. CKEY ckeyUnused4; // Future use
  347. // Block size
  348. DWORD dwBlockSize; // Index block size
  349. //
  350. // Index statistics
  351. //
  352. DWORD dwMaxFieldId; // Maximum field value
  353. DWORD dwMaxWCount; // Maximum word count value
  354. DWORD dwMaxOffset; // Maximum offset value
  355. DWORD dwMaxWLen; // Maximum word's length value
  356. DWORD dwTotalWords; // Total indexed words
  357. DWORD dwUniqueWords; // Total unique words
  358. DWORD dwTotal3bWordLen; // Total of all words lengths > 2 bytes
  359. DWORD dwTotal2bWordLen; // Total of all words lengths <= 2 bytes
  360. DWORD dwUniqueWordLen; // Total of all unique words lengths
  361. DWORD dwSlackCount; // Total slack reserved in data nodes
  362. DWORD dwMinTopicId; // Minimum topic ID
  363. DWORD dwMaxTopicId; // Maximum topic ID
  364. // Weight table
  365. FILEOFFSET WeightTabOffset; // Weight table offset
  366. DWORD WeightTabSize; // Weight table size
  367. // Superceded by dwCodePageID and lcid in file version 4.0.
  368. // DWORD dwLanguage; // Language
  369. FILEOFFSET foFreeListOffset; // Offset of the FreeList
  370. DWORD dwFreeListSize; // Size of the FreeList.
  371. // If High byte set, need to FreeListAdd().
  372. //--------------- New Members for Index File Version 4.0 ----------------
  373. DWORD dwCodePageID; // ANSI code page no. specified at build time
  374. LCID lcid; // WIN32 locale ID specified at build time
  375. DWORD dwBreakerInstID; // breaker instance that was used to parse
  376. // terms for the index at build time.
  377. } IH20,
  378. FAR *PIH20;
  379. #define CB_IDX_HEADER_SIZE ((CB)2048) // Number of bytes allowed
  380. // for an IH record. Excess
  381. #if 0
  382. typedef struct LeafInfo
  383. {
  384. FILEOFFSET nodeOffset; // Node I'm working on.
  385. LRGB lrgbNode; // Pointer to its bytes.
  386. LRGB lrgbTopNode; // Pointer to the index top node.
  387. LRGB lrgbNodeBuf; // Pointer to a pre-allocated node buffer I can use.
  388. HFPB hfpbIdx; // Index file.
  389. LPB pMaxAddress; // Maximum address we can reach
  390. LPB pCurPtr; // Current pointer to the buffer
  391. LPERRB lperrb;
  392. DWORD dwBlockSize; // Index block size
  393. short iLeafLevel; // Index b-tree leaf level.
  394. WORD wSlackSize; // Slack size for each node
  395. BYTE ibit; // Bit index into it.
  396. } LI,
  397. FAR * SPLI, FAR *LPLI;
  398. #endif
  399. /*
  400. * Using GMEM_SHARED assures that the memory is owned by the DLL and not
  401. * the task. The piece of memory will be released only either the DLL or
  402. * the system when the DLL's last instance is closed
  403. */
  404. #ifndef _MAC
  405. #define DLLGMEM (GMEM_MOVEABLE)
  406. #define DLLGMEM_ZEROINIT (GMEM_MOVEABLE | GMEM_ZEROINIT)
  407. #else
  408. #define DLLGMEM (GMEM_MOVEABLE | GMEM_SHARE)
  409. #define DLLGMEM_ZEROINIT (GMEM_MOVEABLE | GMEM_SHARE | GMEM_ZEROINIT | GMEM_PMODELOCKSTRATEGY)
  410. #endif
  411. PUBLIC VOID FAR PASCAL DisposeFpb (GHANDLE);
  412. typedef ERR (PASCAL NEAR *FENCODE) (PFILEDATA, DWORD, int);
  413. typedef ERR (PASCAL FAR *FDECODE) (PNODEINFO, CKEY, LPDW);
  414. /* Compound file system related macros and typedef */
  415. #define FS_SYSTEMFILE 1
  416. #define FS_SUBFILE 2
  417. #define REGULAR_FILE 3
  418. /*************************************************************************
  419. *
  420. * Error Functions
  421. *
  422. *************************************************************************/
  423. //#if defined(_DEBUG)
  424. //#define VSetUserErr(lperrb, errCode, iUserCode) DebugSetErr(lperrb, errCode, \
  425. // __LINE__, s_aszModule, iUserCode)
  426. //#else
  427. #define VSetUserErr(lperrb, errCode, iUserCode) SetErr(lperrb, errCode)
  428. //#endif
  429. #ifndef DOS_ONLY
  430. #define RET_ASSERT(ex) if (!(ex)) return E_ASSERT;
  431. #else
  432. #define RET_ASSERT(ex) assert((ex));
  433. #endif
  434. #define DO_ASSERT(ex) if (!(ex)) { \
  435. DebugSetErr(lperrb, ERR_ASSERT, __LINE__, s_aszModule,0); \
  436. return FAIL; }
  437. #define UNREACHED FALSE // We should never reach this code !!!
  438. #define BAD_STATE FALSE
  439. #ifdef _DEBUG
  440. #define DB_ASSERT(p) DO_ASSERT(p)
  441. #else
  442. #define DB_ASSERT(p)
  443. #endif
  444. /*************************************************************************
  445. *
  446. * HIGH LEVEL FILE SYSTEM I/O (IO.C)
  447. *
  448. *************************************************************************/
  449. #define cbIO_ERROR ((WORD)-1) // Low-level I/O error return.
  450. #define cbMAX_IO_SIZE ((WORD)32767) // Largest physical I/O I can do.
  451. #ifdef DLL // {
  452. #define LPF_HFCREATEFILEHFS HfCreateFileHfs
  453. #define LPF_RCCLOSEHFS RcCloseHfs
  454. #define LPF_HFOPENHFS HfOpenHfs
  455. #define LPF_RCCLOSEHF RcCloseHf
  456. #define LPF_LCBREADHF LcbReadHf
  457. #define LPF_LCBWRITEHF LcbWriteHf
  458. #define LPF_LSEEKHF LSeekHf
  459. #define LPF_RCFLUSHHF RcFlushHf
  460. #define LPF_GETFSERR RcGetFSError
  461. #define LPF_HFSOPENSZ HfsOpenSz
  462. #else
  463. #define LPF_HFSCREATEFILESYS VfsCreate
  464. #define LPF_HFCREATEFILEHFS HfCreateFileHfs
  465. #define LPF_HFSOPENSZ HfsOpenSz
  466. #define LPF_RCCLOSEHFS RcCloseHfs
  467. #define LPF_HFOPENHFS HfOpenHfs
  468. #define LPF_RCCLOSEHF RcCloseHf
  469. #define LPF_LCBREADHF LcbReadHf
  470. #define LPF_LCBWRITEHF LcbWriteHf
  471. #define LPF_LSEEKHF LSeekHf
  472. #define LPF_RCFLUSHHF RcFlushHf
  473. #define LPF_GETFSERR RcGetFSError
  474. #endif //} LOMEM
  475. /*********************************************************************
  476. * *
  477. * COMMON FUNCTIONS PROTOTYPES *
  478. * *
  479. *********************************************************************/
  480. PUBLIC BOOL PASCAL FAR StringDiff2 (LPB, LPB);
  481. PUBLIC BOOL PASCAL FAR StrCmpPascal2 (LPB, LPB);
  482. PUBLIC WORD PASCAL FAR CbByteUnpack(LPDW, LPB);
  483. PUBLIC int PASCAL FAR NCmpS (LPB, LPB);
  484. PUBLIC VOID PASCAL FAR FreeHandle (HANDLE);
  485. PUBLIC LPV PASCAL FAR GlobalLockedStructMemAlloc (unsigned int);
  486. PUBLIC LPV PASCAL FAR
  487. DebugGlobalLockedStructMemAlloc (unsigned int, LSZ, WORD);
  488. PUBLIC VOID PASCAL FAR GlobalLockedStructMemFree (LPV);
  489. PUBLIC int PASCAL FAR StrNoCaseCmp (LPB, LPB, WORD);
  490. PUBLIC LST PASCAL FAR ExtractWord(LST, LST, LPW);
  491. PUBLIC ERR PASCAL FAR ReadStemNode (PNODEINFO, int);
  492. PUBLIC ERR PASCAL FAR ReadLeafNode (PNODEINFO, int);
  493. PUBLIC ERR PASCAL FAR ReadNewData(PNODEINFO pNodeInfo);
  494. PUBLIC int PASCAL FAR StrCmpPascal2(LPB lpStr1, LPB lpStr2);
  495. PUBLIC ERR PASCAL FAR FGetBits(PNODEINFO, LPDW, CBIT);
  496. PUBLIC ERR PASCAL FAR GetBellDWord (PNODEINFO, CKEY, LPDW);
  497. PUBLIC ERR PASCAL FAR GetBitStreamDWord (PNODEINFO, CKEY, LPDW);
  498. PUBLIC ERR PASCAL FAR GetFixedDWord (PNODEINFO, CKEY, LPDW);
  499. PUBLIC void PASCAL FAR IndexCloseFile(LPIDX lpidx);
  500. PUBLIC ERR PASCAL FAR TopNodeRead( LPIDX lpidx);
  501. PUBLIC ERR PASCAL FAR ReadIndexHeader(HFPB, PIH20);
  502. PUBLIC void FAR PASCAL TopNodePurge(LPIDX lpidx);
  503. PUBLIC int PASCAL FAR ReadFileOffset (FILEOFFSET FAR *, LPB);
  504. PUBLIC ERR PASCAL FAR CopyFileOffset (LPB pDest, FILEOFFSET fo);
  505. #if defined(_DEBUG) && !defined(_MSDN) && !defined(MOSMAP)
  506. #define GLOBALLOCKEDSTRUCTMEMALLOC(a) DebugGlobalLockedStructMemAlloc(a,s_aszModule,__LINE__)
  507. #define ALLOCTEMPFPB(a,s) DebugAllocTempFPB(a,s,s_aszModule,__LINE__)
  508. #else
  509. #define GLOBALLOCKEDSTRUCTMEMALLOC(a) GlobalLockedStructMemAlloc(a)
  510. #define ALLOCTEMPFPB(a,s) AllocTempFPB(a,s)
  511. #endif
  512. #define CB_MAX_PACKED_DWORD_LEN 5 // The maximum size (in bytes) of
  513. // either a sort-packed or
  514. // byte-packed DWORD.
  515. //
  516. // Sorting routines
  517. //
  518. PUBLIC ERR PASCAL NEAR IndexSort (LPW, LPB, int);
  519. PUBLIC BOOL FAR PASCAL LibMain(HANDLE, WORD, LSZ);
  520. PUBLIC BOOL FAR PASCAL WEP(BOOL);
  521. #define FILE_HDR_SIZE 40
  522. #define CB_BREAKER_LEN 16 // Size in characters of the word breaker
  523. // filename. This is not a path, since all
  524. // word breakers are assumed to reside in the
  525. // searcher system directory.
  526. /*************************************************************************
  527. *
  528. * Catalog related structures and defines
  529. *
  530. *************************************************************************/
  531. /* Useful catalog flags */
  532. #define CAT_SORTED 0x1 // All items are in increasing order
  533. /* Catalog header size */
  534. #define CATALOG_HDR_SIZE FILE_HDR_SIZE
  535. /* Those data are to be written at the beginning of the catalog file */
  536. #define CAT_HEADER_DATA \
  537. unsigned short FileStamp; /* Catalog version's number */ \
  538. VER version; /* Catalog format version number.*/ \
  539. unsigned short wElemSize; /* Size of each element. */ \
  540. DWORD cElement; /* Number of elements in the catalog */ \
  541. DWORD dwFirstElem /* First element in the list */
  542. typedef struct CAT_HEADER
  543. {
  544. CAT_HEADER_DATA;
  545. } CAT_HEADER;
  546. #define CAT_COMMON_DATA \
  547. DWORD dwCurElem; /* Current element in the list */ \
  548. GHANDLE hCat; /* Handle to this structure */ \
  549. HANDLE hfpbSysFile; /* Pointer to system file info. */ \
  550. HANDLE hfpbCatalog; /* Pointer to catalog subfile info. */ \
  551. GHANDLE hCatBuf; /* Handle to catalog buffer */ \
  552. WORD fCloseSysFile; /* Flag telling to close the system file */ \
  553. LPB lpCatBuf; /* Pointer to catalog buffer */ \
  554. LPERRB lperrb /* Pointer to error buffer */
  555. /* Catalog structure for retrieval */
  556. typedef struct CAT_RETRIEV
  557. {
  558. CAT_HEADER_DATA;
  559. CAT_COMMON_DATA;
  560. } CAT_RETRIEV;
  561. /* Catalog structure for indexing */
  562. typedef struct CAT_INDEX {
  563. CAT_HEADER_DATA; // Various catalog's important data
  564. CAT_COMMON_DATA;
  565. /* Indexing specific fields */
  566. WORD fFlags; /* Various flags */
  567. WORD ibBufOffset; // Offset to the lpCatBuf buffer
  568. GHANDLE hIndexArray; // Handle to array of indices
  569. LPW IndexArray; // Pointer to array of indices
  570. LSZ aszTempFile; // Name of the temporary catalog file
  571. HFILE hResultFile; // Temporary result file DOS handle
  572. DWORD lfoTmp; // Tmp file offset
  573. BYTE TmpFileNames[cbMAX_PATH];
  574. // Buffer for various tmp files names
  575. } CAT_INDEX;
  576. typedef BOOL (PASCAL FAR *STRING_COMP)(LSZ, LSZ);
  577. typedef int (PASCAL FAR *FCOMPARE) (LPB, LPB, LPV);
  578. /*************************************************************************
  579. *
  580. * Stop File Structure
  581. *
  582. *************************************************************************/
  583. #define STOP_HDR_SIZE FILE_HDR_SIZE
  584. typedef struct STOP_HDR
  585. {
  586. unsigned short FileStamp; // File stamp
  587. VER version; // Version number
  588. DWORD dwFileSize; // File size
  589. } STOP_HDR, FAR *LPSTOP;
  590. /* Only allow 5K for stop words. This is roughly equivalent to 900 stop
  591. * words, which should be enough for most cases. This is just a arbitrary
  592. * limitation, and not the memory size allocated
  593. */
  594. #define MAX_STOPWORD_BUFSIZE (1024 * 5)
  595. #define HASH_SIZE 23 // Hash Table buckets (some prime number)
  596. #define WORDBUF_SIZE 1024 // Word buffer size
  597. #define CB_STOP_BUF ((WORD)512) // Number of bytes read at a time
  598. // from the stop-word file.
  599. #define MB_NEXT(p) (((LPBLOCK )p)->lpNext)
  600. #define MB_BUFFER(p) (((LPBLOCK )p)->Buffer)
  601. typedef struct CHAIN
  602. {
  603. struct CHAIN UNALIGNED *UNALIGNED lpNext;
  604. DWORD dwCount; // How many times this word has been added
  605. BYTE Word; // Beginning of the buff
  606. } CHAIN;
  607. typedef CHAIN UNALIGNED * UNALIGNED LPCHAIN;
  608. #define CH_NEXT(p) (((LPCHAIN )p)->lpNext)
  609. #define CH_WORD(p) (((LPCHAIN )p)->Word)
  610. typedef struct StopInfo
  611. {
  612. GHANDLE hStruct; /* Handle to this structure. THIS MUST BE 1ST!! */
  613. LPV lpBlkMgr; /* Pointer to block manager */
  614. STOPLKUP lpfnStopListLookup;
  615. LPCHAIN *HashTab;
  616. WORD cbTextUsed; /* Length of all stop words */
  617. WORD wTabSize;
  618. } SIPB;
  619. typedef SIPB FAR *_LPSIPB;
  620. /*************************************************************************
  621. *
  622. * Word Wheel File Structure
  623. *
  624. *************************************************************************/
  625. #define CB_WHEEL_BLOCK 1024 // Word wheel block size
  626. #define NT_SZI "i" // Get from btree.h
  627. #define LPF_HBTCREATEBTREESZ HbtCreateBtreeSz
  628. #define LPF_RCABANDONHBT RcAbandonHbt
  629. #define LPF_RCCLOSEBTREEHBT RcCloseBtreeHbt
  630. #define LPF_RCINSERTHBT RcInsertHbt
  631. //PUBLIC BOOL PASCAL FAR StringDiff (LPB, LPB);
  632. /*************************************************************************
  633. *
  634. * CharTab File Structure
  635. *
  636. *************************************************************************/
  637. #define CHARTAB_HDR_SIZE FILE_HDR_SIZE
  638. typedef struct CHARTAB_HDR {
  639. unsigned short FileStamp; // File stamp
  640. VER version; // Version number
  641. DWORD dwTabSize; // File size
  642. unsigned short wcTabEntries; // Character table entries
  643. unsigned short wcLigature; // Number of ligature entries
  644. unsigned short fFlag; // Various flag
  645. } CHARTAB_HDR;
  646. /* Default number of characters in the US character table */
  647. #define MAX_CHAR_COUNT 256
  648. /* Ligature flags */
  649. #define USE_DEF_LIGATURE 1 // Use default ligature table
  650. #define NO_LIGATURE 2 // No ligature
  651. #define LIGATURE_PROVIDED 3 // Author provides ligature table
  652. #define DEF_LIGATURE_COUNT 5 // Default number of ligature entries
  653. #define OP_PROCESSED 1 /* This operator has been processed */
  654. typedef struct OPTAB_HDR {
  655. unsigned short FileStamp; /* Operator file stamp */
  656. VER version; /* Version number */
  657. unsigned short cEntry; /* Item's count */
  658. unsigned short wSize; /* Size of the table */
  659. } OPTAB_HDR;
  660. #define OPTAB_HDR_SIZE FILE_HDR_SIZE
  661. /* Low level query operators */
  662. #define UO_OR_OP 2
  663. #define UO_AND_OP 3
  664. #define UO_NOT_OP 4
  665. #define UO_PHRASE_OP 5
  666. #define UO_NEAR_OP 6
  667. #define UO_RANGE_OP 7
  668. #define UO_GROUP_OP 8
  669. #define UO_FBRK_OP 11
  670. #define UO_FIELD_OP 14
  671. PUBLIC ERR PASCAL FAR EXPORT_API FStem (LPB lpbStemWord, LPB lpbWord);
  672. /*************************************************************************
  673. *
  674. * Global Variables
  675. *
  676. * Those variables should be read only
  677. *************************************************************************/
  678. extern BYTE LigatureTable[];
  679. extern OPSYM OperatorSymbolTable[];
  680. extern OPSYM FlatOpSymbolTable[];
  681. extern CHARMAP DefaultCMap[];
  682. typedef ERR (PASCAL FAR *FDECODE) (PNODEINFO, CKEY, LPDW);
  683. extern FDECODE DecodeTable[];
  684. WORD FAR PASCAL GetMacWord (LPB);
  685. WORD FAR PASCAL SwapWord (WORD);
  686. DWORD FAR PASCAL SwapLong (DWORD);
  687. DWORD FAR PASCAL GetMacLong (LPB);
  688. int PASCAL FAR SwapBuffer (LPW, DWORD);
  689. /* Mac handler */
  690. #ifdef _BIG_E
  691. #define SWAPBUFFER(a,b); SwapBuffer(a,b);
  692. #else
  693. #define SWAPBUFFER(a,b);
  694. #endif
  695. /*************************************************************************
  696. * Catalog's Retrieval API
  697. *************************************************************************/
  698. PUBLIC LPCAT EXPORT_API PASCAL FAR CatalogOpen (HANDLE, LSZ, LPERRB);
  699. PUBLIC ERR EXPORT_API PASCAL FAR CatalogLookUp (LPCAT, LPB, DWORD);
  700. PUBLIC VOID EXPORT_API PASCAL FAR CatalogClose(LPCAT);
  701. /*************************************************************************
  702. * Catalog Index API functions
  703. *************************************************************************/
  704. PUBLIC LPCAT EXPORT_API PASCAL FAR CatalogInitiate (WORD, LPERRB);
  705. PUBLIC ERR EXPORT_API PASCAL FAR CatalogAddItem (LPCAT, DWORD, LPB);
  706. PUBLIC ERR EXPORT_API PASCAL FAR CatalogBuild (HFPB, LPCAT, LSZ,
  707. INTERRUPT_FUNC, LPV);
  708. PUBLIC VOID EXPORT_API PASCAL FAR CatalogDispose (LPCAT);
  709. #if defined( __cplusplus )
  710. }
  711. #endif
  712. // Critical structures that gets messed up in /Zp8
  713. #pragma pack()
  714. #endif /* __FTSCOMMON_H__ */