/* TOP.H ---------------------------------------------- * * Topic-Enumeration Handle and internal procedure Defintions * *-----------------------------------------------------*/ // typedef struct _TOPIC NEAR *HTOPIC; /* =========== Definition of Data block needed to be loaded with HlpTopicOpen =========== */ /* ---------- Font-Selection String Tables ---------------------------------------------- */ typedef struct { LOGFONT lf; /* Well a rather usual font-definition */ COLORREF FGcolor, /* a font-Color */ BGcolor; /* a Background-color (?) */ } FONTINFO, FAR *LPFONTINFO; typedef struct { int FontCount; FONTINFO Font[1]; } FONTSELECTORS, FAR * LPFONTSELECTORS; // ---------- Data read from |CONTEXT -------------------- typedef struct { int ContextCount, /* Number of entries used in this array */ ContextAllocated; /* Number of entries allocated */ CONTEXTREC *Context; /* Pointer to the array Data */ } CONTEXTARRAY, FAR *LPCONTEXTARRAY; // ---------- Keyword-Handling... ------------------------ typedef struct { DWORD TopicOffset; /* Offset to Topic-Text */ DWORD KeyWordOffset; /* Offset of Keyword-String in Helpfile */ } KWREC, FAR *LPKWREC; typedef struct { int KWCount; /* Number of Entries in KWRec */ int KWAllocated; /* Number of Entries currently allocated in KWRec */ char KWTableName[4]; /* Keyword-Table-Name (K,0K,A,...) */ HIFSFILE hWBTree; /* Open file to retrieve the Strings from */ LPKWREC KWRec; /* Pointer to the sorted Array of Keyword-Records */ } KWARRAY, FAR *LPKWARRAY; /* ----------- Definition of a Topic-Handle --------------------------------------------- */ typedef struct _TOPIC { //----------- File-Access Data -------------------------------------------- HIFS ifs; /* Internal file-System */ HIFSFILE topicfile; /* Handle of opened |TOPIC - File */ HELPFILETITLE NEAR *tit; /* Title and Revision... */ //----------- Global maintainance Data ------------------------------------ BOOL CancelEnumeration; /* True if Callback requested to cancel enumeration */ //----------- Phrases-Data ------------------------------------------------ LPSTR PhrasesPtr, /* Phrase-Table HC31 */ PhrImage; /* Phrases-Table HCW Image */ LPINT PhrIndex; /* Phrases-Table HCW Index */ //----------- Topic Read -------------------------------------------------- DWORD TopicOffset; /* Current Topic-Offset */ UINT BlockSize, /* Size of one (Compressed) Topic-Block (0x200/0x800)*/ NettoBlockSize, /* Size of one (Compressed) Topic-Block minus TOPICBLOCKHEADER */ BlockNoShift, /* Number of shift-Operations from a Block-Number to a Topic-Offset (11/14) */ BlockOffsetMask; /* Mask to retrieve Offset in a Block from a TopicOffset (0x3fff or 0x7fff) */ LPBYTE DCmpBlock; /* Block of decompressed data */ LONG CurrBlockLoc; /* Where we are in the DCmpBlock */ LONG DecompSize; /* Size of DCmpBlock after decomp */ LONG BlkNum; /* Blocknumber since Start of |TOPIC file */ LONG NextTopicLink; /* Offset where the next TOPICLINK is to be found */ LONG BytesInLink, /* Number of Bytes in one Topic Link Block */ TopicFileLength; /* Length of the |TOPIC internal File */ TOPICBLOCKHEADER TopicBlockHeader; //----------- Optional additional Informations ---------------------------- LPFONTSELECTORS FontSelectors; /* Table of Strings to Access by Font-Number... */ BOOL FontShowsItsMVCC; /* TRUE if Font-Table shows that this is a MVCC-File */ LPCONTEXTARRAY ContextArray; /* Data read from |CONTEXT-File */ LPKWARRAY *KWArry; /* Data read from xWBTREE */ int KWArryCount; /* Number of Keyword-Tables read */ struct contentsentry *contents; /* Informations retrieved from the .cnt file(s) */ } TOPIC, NEAR *NPTOPIC; #define ISV30(topic) (topic->tit->Revision == 0x0F) #define ISV40(topic) (topic->tit->Revision == 0x21) #define ISMVB(topic) (topic->tit->Revision == 0x1b) #define ISCOMPRESSED(topic) (((topic->tit->Flags & COMPRESSION_310) || \ (topic->tit->Flags & COMPRESSION_UNKN) ) && \ topic->tit->Revision != 0x0f) // And not WinHelp 3.0 Format #define ISMVCC(topic) (topic->FontShowsItsMVCC) // HACK! Hlp2rtf find out about that by the Fonts-File but this is not a parsed here... /* ----------- Internal function prototypes --------------------------------------------- */ void iPhrasesLoad(NPTOPIC topic); /* Load |Prases, |PhrIndex, |PhrImage... */ void iPhrasesFree(NPTOPIC topic); /* Free up memory blocks required by Phrases*/ LPSTR iGetPhrase(HTOPIC topic, int PhraseNum); /* Return Memory Block with a Phrase */ void iFontsLoad(NPTOPIC topic); /* Load Fonts-Table */ void iFontsFree(NPTOPIC topic); /* Free Memory used by Fonts-Table */ LPCSTR iFontsGetRtfSelection(NPTOPIC topic, int); /* Get a Font as an rtf-String */ LPCSTR iFontsGetRtfTable(NPTOPIC topic); /* Get RTF colortable */ void iKeyWordsLoad(NPTOPIC topic); /* Load all Keyword Tables */ void iKeyWordsFree(NPTOPIC topic); /* Free Memory used by Keyword-Tables */ void iKeyWordsForTopic(HTOPIC topic, TOPICENUMPROC fnenum, DWORD TopicOffset, LPARAM lParam); /* Transfer all keyword-Data mathcing this TopicOffset */ void iContextLoad(NPTOPIC topic); /* Load Fonts-Table */ void iContextFree(NPTOPIC topic); /* Free Memory used by Fonts-Table */ LPSTR iContextFind(NPTOPIC topic, DWORD TopicOffset);/* Retrieve Context-Id if connected to this TopicOffset */ void iTopicReadInit(HTOPIC topic); /* Prepare Data blocks for iTopicRead */ void iTopicReadFree(HTOPIC topic); /* Free up Data blocks fpr iTopicRead */ LONG iTopicRead(HTOPIC topic, LPBYTE Dest, LONG NumBytes); /* read a number of bytes from blocked |TOPIC file */ int iGetShortValue(BYTE **from, UINT *length); LONG iGetLongValue(BYTE **from, UINT *length); short iGetWordValue(BYTE **from, UINT *length); WORD iGetLeWordValue(BYTE **from, UINT *length); DWORD iGetLeDWordValue(BYTE **from, UINT *length); UINT iTopicString(HTOPIC topic, TOPICENUMPROC fnenumproc, LPARAM lParam, LPBYTE *String, UINT *pLength, TEXTTYPE TextType); void iFormatString(HTOPIC topic, TOPICENUMPROC fnenumproc, LPARAM lParam, LPSTR String, ...); UINT iTopicParagraph(HTOPIC topic, TOPICENUMPROC fnenum, LPARAM lParam, BYTE **String, UINT *Length, BYTE **FormatData, UINT *FormatLength, DWORD TopicOffset, BOOL InNonScrollingRegion, BOOL InTable); void iTopicTable( HTOPIC topic, TOPICENUMPROC fnenum, LPARAM lParam, LPCSTR String, UINT Length, BYTE *FormatData, UINT FormatLength, DWORD TopicOffset, BOOL InNonScrollingRegion); void iGetTopics(HTOPIC topic, TOPICENUMPROC fnenum, LPARAM lParam); typedef struct contentsentry { int ibooklevel; char *title; char *contextstring; DWORD dwHashValue; struct contentsentry **subtopics; int subtopiccount; } CONTENTSENTRY; struct contentsentry * iReadContentsFile(HIFS ifs); void iFreeContentsFile(struct contentsentry *contents); char *iContentsFromHash(struct contentsentry *contents, DWORD dwHashValue); // ---------- Decompression related Stuff ---------------- UINT iLZDecompress(HIFSFILE SourceFile, UINT CompSize, LPSTR Buffer); /* Decompess a LZ77-Compressed Data-Block from the HelpFile to the Buffer. returns: Count of Bytes of the decompressed Data Stream */ /*#define Hlpmalloc(x) malloc(x) #define Hlpfree(x) free(x) #define Hlpcalloc(x,y) calloc(x,y) #define Hlpstrdup(s) strdup(s) #define Hlprealloc(x,y) realloc(x,y) */ void *Hlpmalloc(DWORD size); void *Hlpcalloc(int size, int c); void *Hlprealloc(void *blk, int nsize); void Hlpfree(void *blk); char *Hlpstrdup(const char *src); // --------- Help Data structures ----------------------- #pragma pack(1) typedef struct { LONG DoubleOfFormatLength; // moreLength*2 + 4 // BYTE EightZero; // 80H WORD DoubleDataLength; // Length*2 } PACKED FORMATHEADER, FAR *LPFORMATHEADER; typedef struct { BYTE Zero; // Zero... BYTE EightZeroSecond; // 80H WORD Zero2; // 00 00H WORD Flags; } PACKED FORMAT, FAR *LPFORMAT; #pragma pack() //------------ Hlp2rtf hacker ---------------------------- #define HLPTRACE(x) #define HlpDisplayWarning(ifs, id) #ifndef __FLAT__ # define MAX_PATH 144 #endif /* * Local variables: * tab-width: 8 * End: */