summaryrefslogtreecommitdiff
path: root/src/HelpFileHeader.pas
blob: 799547d275e5141ac9e006853a3d9aa6fced27e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Unit HelpFileHeader;

{$mode objfpc}{$H+}

// NewView - a new OS/2 Help Viewer
// Copyright 2001 Aaron Lawrence (aaronl at consultant dot com)
// This software is released under the Gnu Public License - see readme.txt

Interface

// Definition of IPF file header and other structures

uses
  DataTypes;

Type
  THelpFileHeader = packed record
    ID: int16;           // ID magic word (5348h = "HS")
    unknown1: byte;      // unknown purpose, could be third letter of ID
    flags: byte;         // probably a flag word...
                         //  bit 0: set if INF style file
                         //  bit 4: set if HLP style file
                         // patching this byte allows reading HLP files
                         // using the VIEW command, while help files 
                         // seem to work with INF settings here as well.
    hdrsize: word;       // total size of header
    unknown2: word;      // unknown purpose
    ntoc: int16;         // number of entries in the tocarray
    tocstart: int32;     // file offset of the start of the toc
    toclen: int32;       // number of bytes in file occupied by the toc
    tocoffsetsstart: int32;     // file offset of the start of array of toc offsets
    nres: int16;         // number of panels with ressource numbers
    resstart: int32;     // 32 bit file offset of ressource number table
    nname: int16;        // number of panels with textual name
    namestart: int32;    // 32 bit file offset to panel name table
    nindex: int16;       // number of index entries
    indexstart: int32;   // 32 bit file offset to index table
    indexlen: int32;     // size of index table
    unknown3: array[0..9] of byte; // unknown purpose
    searchstart: int32;  // 32 bit file offset of full text search table
    searchlen: int32;    // size of full text search table
    nslots: int16;       // number of "slots"
    slotsstart: int32;   // file offset of the slots array
    dictlen: int32;      // number of bytes occupied by the "dictionary"
    ndict: int16;        // number of entries in the dictionary
    dictstart: int32;    // file offset of the start of the dictionary
    imgstart: int32;     // file offset of image data
    unknown4: byte;      // unknown purpose
    nlsstart: int32;     // 32 bit file offset of NLS table
    nlslen: int32;       // size of NLS table
    extstart: int32;     // 32 bit file offset of extended data block
    reserved: array[0..11] of byte; // for future use. set to zero.
    title: array[ 0..47 ] of char;    // ASCII title of database
  end;
  pTHelpFileHeader = ^THelpFileHeader;

Type
  TTOCEntryStart = packed record
    length: int8; // length of the entry including this byte
    flags: int8; // flag byte, description folows (MSB first)
                 // bit7 haschildren;  // following nodes are a higher level
                 // bit6 hidden;       // this entry doesn't appear in VIEW.EXE's
                                       // presentation of the toc
                 // bit5 extended;     // extended entry format
                 // bit4 stuff;        // ??
                 // int4 level;        // nesting level
    numSlots: int8; // number of "slots" occupied by the text for this toc entry
    Slots    : record end;
  end;
  pTTOCEntryStart = ^TTOCEntryStart;

  TExtendedTOCEntry = packed record
    w1: byte;
               // bit 3: Window controls are specified
               // bit 2: Viewport
               // bit 1: Size is specified.
               // bit 0: Position is specified.
    w2: byte;
               // bit 3:
               // bit 2: Group is specified.
               // bit 1
               // bit 0: Clear (all windows before display)
  end;
  pExtendedTOCEntry = ^TExtendedTOCEntry;

  TTOCEntryOffsetArray =  packed array[ 0..0 ] of int32;
  pTTOCEntryOffsetArray = ^TTOCEntryOffsetArray;

const
  TOCEntryExtended      = $20; { extended entry format }
  TOCEntryHidden        = $40; { this entry doesn't appear in VIEW.EXE's presentation of the toc }
  TOCEntryHasChildren   = $80; { following nodes are a higher level }
  TOCEntryLevelMask     = $0f;


type
  THelpXYPair = packed record
    Flags: int8;
    X: int16;
    Y: int16;
  end;
  pHelpXYPair = ^ THelpXYPair;

  TSlotHeader = packed record
    stuff: int8;              // always 0??
    localdictpos: int32;      // file offset of the local dictionary
    nlocaldict: int8;         // number of entries in the local dict
    ntext: int16;             // number of bytes in the text
  end;
  pSlotHeader = ^TSlotHeader;

Implementation

Initialization
End.