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.

235 lines
8.2 KiB

  1. /*
  2. ** help.h
  3. **
  4. ** typedefs & definitions used in the help system and by those who use it.
  5. **
  6. ** define:
  7. ** HOFFSET - to define buffer pointers (PB's) as handle/offset, else
  8. ** they are defined as void far *.
  9. */
  10. typedef char f; /* boolean */
  11. typedef unsigned char uchar;
  12. typedef unsigned long ulong;
  13. typedef unsigned short ushort;
  14. /*
  15. ** lineattr
  16. ** external representation of line attributes, as returned by HelpGetLineAttr
  17. */
  18. typedef struct lineattr { /* LA */
  19. ushort attr; /* attribute index */
  20. ushort cb; /* count of bytes */
  21. } lineattr;
  22. /*
  23. ** mh
  24. ** a memory handle is defined for use with systems that use dynamic, moveable
  25. ** memory. It is long, so that in simple cases where memory is NOT moveable,
  26. ** the handle can contain the far pointer to the base.
  27. */
  28. typedef void * mh; /* dynamic memory handle */
  29. /*
  30. ** nc
  31. ** a context number is a unique id associated with each context string.
  32. **
  33. ** fhnc returns the file memory handle from the nc
  34. ** fLocal returns TRUE if the context is a uniq context number (local, or
  35. ** result of explicit uniq call.
  36. */
  37. typedef struct _nc {
  38. mh mh;
  39. ulong cn;
  40. } nc ; /* context number */
  41. // rjsa #define fmhnc(x) ((unsigned)(((unsigned long)x & 0xffff0000L) >> 16))
  42. #define fmhnc(x) ((x).mh)
  43. #define fUniq(x) ((x).cn & 0x8000)
  44. /*
  45. ** topichdr
  46. ** header placed (by HelpDecomp) at the begining of every decompressed topic
  47. */
  48. typedef struct topichdr { /* TH */
  49. uchar appChar; /* app-specific character const */
  50. uchar linChar; /* character for line removal */
  51. uchar ftype; /* source file type */
  52. ushort lnCur; /* line number last accessed */
  53. ushort lnOff; /* offset into topic for that line*/
  54. } topichdr;
  55. /*
  56. ** hotspot
  57. ** defines the position of an embedded cross reference, or "hotspot". Used by
  58. ** HelpHlNext and HelpXRef
  59. */
  60. typedef struct hotspot { /* HS */
  61. ushort line; /* the topic line with an xref */
  62. ushort col; /* the starting column of xref */
  63. ushort ecol; /* the ending columng of xref */
  64. uchar far *pXref; /* pointer to xref string */
  65. } hotspot;
  66. /*
  67. ** helpheader
  68. ** This defines the actual structure of a help file header. Provided here
  69. ** for HelpGetInfo
  70. */
  71. #define HS_count 9 /* number-1 of sections defined */
  72. #pragma pack(1)
  73. typedef struct helpheader { /* HH */
  74. ushort wMagic; /* word indicating help file */
  75. ushort wVersion; /* helpfile version */
  76. ushort wFlags; /* flags */
  77. ushort appChar; /* application specific char */
  78. ushort cTopics; /* count of topics */
  79. ushort cContexts; /* count of context strings */
  80. ushort cbWidth; /* fixed width */
  81. ushort cPreDef; /* count of pre-defined contexts*/
  82. uchar fname[14]; /* base file name */
  83. ushort reserved[2]; /* unused */
  84. ulong tbPos[HS_count]; /* positions for file sections */
  85. } helpheader;
  86. #pragma pack()
  87. /*
  88. ** fdb
  89. ** Dynamically allocated structure which is created for each open help file.
  90. ** Remains allocated for the life of the file.
  91. **
  92. ** rgmhSections contains dynamic memory handles. Each open file has various
  93. ** dynamic memory buffers associated with it. Each can be present or discarded,
  94. ** as memory constrictions determine. If needed and not present, they are
  95. ** reloaded from the associated help file. All may be discarded when memory
  96. ** gets tight. An entry is defined for each help file section, except for the
  97. ** Topics themselves.
  98. **
  99. */
  100. typedef struct fdb { /* FDB */
  101. FILE * fhHelp; /* OS file handle */
  102. nc ncInit; /* initial context (includes mh)*/
  103. mh rgmhSections[HS_count-1]; /* dynamic memory handles */
  104. uchar ftype; /* file type */
  105. uchar fname[14]; /* base file name */
  106. ulong foff; /* our file offset, if appended */
  107. nc ncLink; /* nc linking any appended file */
  108. helpheader hdr; /* file header */
  109. } fdb;
  110. /*
  111. ** helpinfo
  112. ** structure of information relating to a help file and/or context returned
  113. ** by HelpGetInfo
  114. */
  115. typedef struct helpinfo { /* HI */
  116. fdb fileinfo; /* entire fdb copied out */
  117. char filename[1]; /* filename appended to data */
  118. } helpinfo;
  119. /*
  120. ** Macros for accessing helpinfo data
  121. */
  122. #define FHHELP(x) ((x)->fileinfo.fhHelp)
  123. #define NCINIT(x) ((x)->fileinfo.ncInit)
  124. #define FTYPE(x) ((x)->fileinfo.ftype)
  125. #define FNAME(x) ((x)->fileinfo.fname)
  126. #define FOFF(x) ((x)->fileinfo.foff)
  127. #define NCLINK(x) ((x)->fileinfo.ncLink)
  128. #define WMAGIC(x) ((x)->fileinfo.hdr.wMagic)
  129. #define WVERSION(x) ((x)->fileinfo.hdr.wVersion)
  130. #define WFLAGS(x) ((x)->fileinfo.hdr.wFlags)
  131. #define APPCHAR(x) ((x)->fileinfo.hdr.appChar)
  132. #define CTOPICS(x) ((x)->fileinfo.hdr.cTopics)
  133. #define CCONTEXTS(x) ((x)->fileinfo.hdr.cContexts)
  134. #define CBWIDTH(x) ((x)->fileinfo.hdr.cbWidth)
  135. #define CPREDEF(x) ((x)->fileinfo.hdr.cPreDef)
  136. #define HFNAME(x) ((x)->fileinfo.hdr.fname)
  137. #define TBPOS(x) ((x)->fileinfo.hdr.tbPos)
  138. /******************************************************************************
  139. **
  140. ** Some versions of the help engine run with SS!=DS, and thus require the
  141. ** _loadds attribute on function calls.
  142. */
  143. #ifdef DSLOAD
  144. #define LOADDS _loadds
  145. #else
  146. #define LOADDS
  147. #endif
  148. /******************************************************************************
  149. **
  150. ** PB
  151. ** pointer to a buffer. Based on the switch HOFFSET, it is either a
  152. ** handle-offset or a far pointer. In the handle/offset case, the high word
  153. ** contains a memory handle which must be locked, to get a "real" address, to
  154. ** which the offset is added.
  155. */
  156. #ifdef HOFFSET
  157. #define PB ulong
  158. #else
  159. #define PB void far *
  160. #endif
  161. typedef PB pb;
  162. /******************************************************************************
  163. **
  164. ** Forward declarations
  165. */
  166. void far pascal LOADDS HelpInit (void);
  167. void far pascal LOADDS HelpClose(nc);
  168. nc far pascal LOADDS HelpOpen(char far *);
  169. nc far pascal LOADDS HelpNc(char far *, nc);
  170. nc far pascal LOADDS HelpNcCmp (char far *, nc,
  171. f (pascal far *)(uchar far *, uchar far *, ushort, f, f));
  172. ushort far pascal LOADDS HelpNcCb(nc);
  173. ushort far pascal LOADDS HelpLook(nc, PB);
  174. f far pascal LOADDS HelpDecomp(PB, PB, nc);
  175. void far pascal LOADDS HelpCtl(PB, f);
  176. nc far pascal LOADDS HelpNcNext(nc);
  177. nc far pascal LOADDS HelpNcPrev(nc);
  178. nc far pascal LOADDS HelpNcUniq(nc);
  179. void far pascal LOADDS HelpNcRecord(nc);
  180. nc far pascal LOADDS HelpNcBack(void);
  181. f far pascal LOADDS HelpSzContext(uchar far *, nc);
  182. int far pascal LOADDS HelpGetInfo (nc, helpinfo far *, int);
  183. void far pascal LOADDS HelpShrink(void);
  184. int far pascal LOADDS HelpGetCells(int, int, char far *, PB, uchar far *);
  185. ushort far pascal LOADDS HelpGetLine(ushort, ushort, uchar far *, PB);
  186. ushort far pascal LOADDS HelpGetLineAttr(ushort, int, lineattr far *, PB);
  187. int far pascal LOADDS HelpcLines(PB);
  188. f far pascal LOADDS HelpHlNext(int, PB, hotspot far *);
  189. char far * pascal far LOADDS HelpXRef(PB, hotspot far *);
  190. /******************************************************************************
  191. **
  192. ** constant declarations
  193. **
  194. ** Character attribute bits. These bits are order together to form attribute
  195. ** indecies. Data in the help file has associated with it attribute information
  196. ** encoded in length/index pairs. Each index is simply a constant which
  197. ** indicates which of several attributes should be applied to the characters in
  198. ** that portion of the line.
  199. */
  200. #define A_PLAIN 0 /* plain, "normal" text */
  201. #define A_BOLD 1 /* emboldened text */
  202. #define A_ITALICS 2 /* italicised text */
  203. #define A_UNDERLINE 4 /* underlined text */
  204. /******************************************************************************
  205. **
  206. ** Help Error Codes.
  207. **
  208. ** Return values greater than HELPERR_MAX are valid nc's.
  209. */
  210. #define HELPERR_FNF 1 /* OpenFileOnPath failed */
  211. #define HELPERR_READ 2 /* ReadHelpFile failed on header*/
  212. #define HELPERR_LIMIT 3 /* to many open helpfiles */
  213. #define HELPERR_BADAPPEND 4 /* bad appeneded file */
  214. #define HELPERR_NOTHELP 5 /* Not a help file */
  215. #define HELPERR_BADVERS 6 /* newer or incompatible help file */
  216. #define HELPERR_MEMORY 7 /* memory allocation failed */
  217. #define HELPERR_MAX 10 /* max help error */