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.

1441 lines
39 KiB

  1. /*** htest - help engine test harness
  2. *
  3. * Copyright <C> 1987, Microsoft Corporation
  4. *
  5. * Revision History:
  6. *
  7. * 15-Dec-1988 ln Added dump command
  8. * [] 21-Oct-1988 LN New Version
  9. *
  10. *************************************************************************/
  11. #include <io.h>
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #if defined (OS2)
  16. #define INCL_SUB
  17. #define INCL_DOSMODULEMGR
  18. #define INCL_DOSFILEMGR
  19. #define INCL_DOSMISC
  20. #include <ctype.h>
  21. #include <os2.h>
  22. #else
  23. #include <windows.h>
  24. #endif
  25. #include "cons.h"
  26. #include "help.h"
  27. #include "helpfile.h" /* help file format definition */
  28. #include "helpsys.h" /* internal (help sys only) decl*/
  29. #if defined (OS2)
  30. #define HELPDLL_NAME "mshelp1.dll"
  31. #define HELPDLL_BASE "mshelp1"
  32. #else
  33. #define HELPDLL_NAME "mshelp.dll"
  34. #define HELPDLL_BASE "mshelp"
  35. #endif
  36. /*
  37. * text color values
  38. */
  39. #define BLACK 0
  40. #define BLUE 1
  41. #define GREEN 2
  42. #define CYAN 3
  43. #define RED 4
  44. #define MAGENTA 5
  45. #define BROWN 6
  46. #define WHITE 7
  47. #define GREY 8
  48. #define LIGHTBLUE 9
  49. #define LIGHTGREEN 10
  50. #define LIGHTCYAN 11
  51. #define LIGHTRED 12
  52. #define LIGHTMAGENTA 13
  53. #define YELLOW 14
  54. #define BRIGHTWHITE 15
  55. #define BUFSIZE 128 /* text buffer size */
  56. #define ISERROR(x) (((x).mh == 0L) && ((x).cn <= HELPERR_MAX))
  57. #define SETERROR(x,y) { (x).mh = 0L; (x).cn = y;}
  58. typedef void pascal (*void_F) (void);
  59. typedef int pascal (*int_F) (void);
  60. typedef ushort pascal (*ushort_F) (void);
  61. typedef f pascal (*f_F) (void);
  62. typedef char * pascal (*pchar_F) (void);
  63. typedef nc pascal (*nc_F) (void);
  64. typedef mh pascal (*mh_F) (void);
  65. #if !defined (HELP_HACK)
  66. #define HelpcLines ((int_F) (pEntry[P_HelpcLines ]))
  67. #define HelpClose ((void_F) (pEntry[P_HelpClose ]))
  68. #define HelpCtl ((void_F) (pEntry[P_HelpCtl ]))
  69. #define HelpDecomp ((f_F) (pEntry[P_HelpDecomp ]))
  70. #define HelpGetCells ((int_F) (pEntry[P_HelpGetCells ]))
  71. #define HelpGetInfo ((inf_F) (pEntry[P_HelpGetInfo ]))
  72. #define HelpGetLine ((ushort_F) (pEntry[P_HelpGetLine ]))
  73. #define HelpGetLineAttr ((ushort_F) (pEntry[P_HelpGetLineAttr]))
  74. #define HelpHlNext ((f_F) (pEntry[P_HelpHlNext ]))
  75. #define HelpLook ((ushort_F) (pEntry[P_HelpLook ]))
  76. #define HelpNc ((nc_F) (pEntry[P_HelpNc ]))
  77. #define HelpNcBack ((nc_F) (pEntry[P_HelpNcBack ]))
  78. #define HelpNcCb ((ushort_F) (pEntry[P_HelpNcCb ]))
  79. #define HelpNcCmp ((nc_F) (pEntry[P_HelpNcCmp ]))
  80. #define HelpNcNext ((nc_F) (pEntry[P_HelpNcNext ]))
  81. #define HelpNcPrev ((nc_F) (pEntry[P_HelpNcPrev ]))
  82. #define HelpNcRecord ((void_F) (pEntry[P_HelpNcRecord ]))
  83. #define HelpNcUniq ((nc_F) (pEntry[P_HelpNcUniq ]))
  84. #define HelpOpen ((nc_F) (pEntry[P_HelpOpen ]))
  85. #define HelpShrink ((void_F) (pEntry[P_HelpShrink ]))
  86. #define HelpSzContext ((f_F) (pEntry[P_HelpSzContext ]))
  87. #define HelpXRef ((pchar_F) (pEntry[P_HelpXRef ]))
  88. #define LoadFdb ((f_F) (pEntry[P_LoadFdb ]))
  89. #define LoadPortion ((mh_F) (pEntry[P_LoadPortion ]))
  90. #endif
  91. enum {
  92. P_HelpcLines,
  93. P_HelpClose,
  94. P_HelpCtl,
  95. P_HelpDecomp,
  96. P_HelpGetCells,
  97. P_HelpGetInfo,
  98. P_HelpGetLine,
  99. P_HelpGetLineAttr,
  100. P_HelpHlNext,
  101. P_HelpLook,
  102. P_HelpNc,
  103. P_HelpNcBack,
  104. P_HelpNcCb,
  105. P_HelpNcCmp,
  106. P_HelpNcNext,
  107. P_HelpNcPrev,
  108. P_HelpNcRecord,
  109. P_HelpNcUniq,
  110. P_HelpOpen,
  111. P_HelpShrink,
  112. P_HelpSzContext,
  113. P_HelpXRef,
  114. P_LoadFdb,
  115. P_LoadPortion,
  116. LASTENTRYPOINT
  117. } ENTRYPOINTS;
  118. #define NUM_ENTRYPOINTS (LASTENTRYPOINT - P_HelpcLines)
  119. typedef nc pascal (*PHF) (void);
  120. /*
  121. * Global Data
  122. */
  123. char buf[BUFSIZ]; /* text buffer */
  124. char cell[2] = {' ',0x1f}; /* background clearing cell */
  125. #define ColorByte cell[1]
  126. int curline; /* current line output */
  127. char *errTbl[] = {
  128. "",
  129. "help file not found",
  130. "ReadHelpFile failed on header",
  131. "to many open helpfiles",
  132. "bad appeneded file",
  133. "Not a help file",
  134. "newer or incompatible help file",
  135. "memory allocation failed"
  136. };
  137. f fBoth = FALSE; /* both stdout & screen */
  138. f fEnable = FALSE; /* enable control lines in disp */
  139. int iNcCur; /* current index in ncTbl */
  140. int lastline;
  141. int lLast; /* last starting line number disp*/
  142. mh mhTopicCur; /* mem handle for most recent */
  143. uchar mpAttr[] = { /* on-screen color map */
  144. 0x1f, /* 0: normal text */
  145. 0x1c, /* 1: bold */
  146. 0x1a, /* 2: italics */
  147. 0x1e, /* 3: bold italics */
  148. 0x7f, /* 4: underline */
  149. 0x7c, /* 5: bold ul */
  150. 0x7a, /* 6: italics ul */
  151. 0x7e /* 7: bold italics ul */
  152. };
  153. nc ncCur; /* most recently read in topic */
  154. nc ncTbl[MAXFILES]; /* table of open nc's */
  155. char far * pTopicCur; /* ptr to most recent topic */
  156. char *spaces = " \r\n";
  157. #if defined (OS2)
  158. HMODULE hModule;
  159. #else
  160. HANDLE hModule;
  161. #endif
  162. PHF pEntry[NUM_ENTRYPOINTS] = {0};
  163. #if defined (OS2)
  164. char * szEntryName[NUM_ENTRYPOINTS] = {
  165. "_HelpcLines",
  166. "_HelpClose",
  167. "_HelpCtl",
  168. "_HelpDecomp",
  169. "_HelpGetCells",
  170. "_HelpGetInfo",
  171. "_HelpGetLine",
  172. "_HelpGetLineAttr",
  173. "_HelpHlNext",
  174. "_HelpLook",
  175. "_HelpNc",
  176. "_HelpNcBack",
  177. "_HelpNcCb",
  178. "_HelpNcCmp",
  179. "_HelpNcNext",
  180. "_HelpNcPrev",
  181. "_HelpNcRecord",
  182. "_HelpNcUniq",
  183. "_HelpOpen",
  184. "_HelpShrink",
  185. "_HelpSzContext",
  186. "_HelpXRef",
  187. "_LoadFdb",
  188. "_LoadPortion",
  189. };
  190. #else
  191. char * szEntryName[NUM_ENTRYPOINTS] = {
  192. "HelpcLines",
  193. "HelpClose",
  194. "HelpCtl",
  195. "HelpDecomp",
  196. "HelpGetCells",
  197. "HelpGetInfo",
  198. "HelpGetLine",
  199. "HelpGetLineAttr",
  200. "HelpHlNext",
  201. "HelpLook",
  202. "HelpNc",
  203. "HelpNcBack",
  204. "HelpNcCb",
  205. "HelpNcCmp",
  206. "HelpNcNext",
  207. "HelpNcPrev",
  208. "HelpNcRecord",
  209. "HelpNcUniq",
  210. "HelpOpen",
  211. "HelpShrink",
  212. "HelpSzContext",
  213. "HelpXRef",
  214. "LoadFdb",
  215. "LoadPortion",
  216. };
  217. #endif
  218. // rjsa VIOMODEINFO screen;
  219. /*
  220. * Forward declarations
  221. */
  222. #define ASSERTDOS(x) assertDos(x, __FILE__, __LINE__)
  223. void pascal near assertDos (USHORT, CHAR *, USHORT);
  224. void pascal near cls (void);
  225. void pascal near dispCmd (int, int);
  226. void pascal near dumpCmd ();
  227. void pascal near dumpfileCmd ( char *);
  228. void pascal near fileCmd (char *);
  229. void pascal near helpCmd (void);
  230. void pascal near lookupCmd (char *, int);
  231. void pascal near outtext (char *, BYTE);
  232. void pascal near outtextat (char *, int, int, BYTE);
  233. uchar far * pascal near phrasecopy (uchar *, uchar far *);
  234. void pascal near xrefCmd (char *);
  235. #undef HelpDealloc
  236. #undef HelpLock
  237. #undef HelpUnlock
  238. void pascal far HelpDealloc (mh);
  239. void far * pascal far HelpLock (mh);
  240. void pascal far HelpUnlock (mh);
  241. f pascal near LoadFdb (mh, fdb far *);
  242. mh pascal near LoadPortion (USHORT, mh);
  243. //char far * pascal near hfstrcpy(char far *, char far *);
  244. //ushort pascal near hfstrlen(char far *);
  245. void LoadTheDll(void);
  246. USHORT WrtCellStr (PBYTE buf, int cb, int row, int col);
  247. USHORT WrtLineAttr( PBYTE buf, lineattr* rgAttr, int cb, int row, int col );
  248. USHORT WrtCharStrAtt (PBYTE pText, int cb, int row, int col, PBYTE pcolor);
  249. PSCREEN Scr;
  250. /*** main - main program
  251. *
  252. * Input:
  253. * Standard C main, all ignored
  254. *
  255. * Output:
  256. * Returns via exit()
  257. *
  258. *************************************************************************/
  259. void main(
  260. USHORT argc,
  261. char **argv
  262. ) {
  263. char c;
  264. nc ncNull = {0,0};
  265. SCREEN_INFORMATION ScrInfo;
  266. /*
  267. * parse any options
  268. */
  269. if (argc > 1)
  270. while ((** ++argv) == '-') {
  271. c = *(++(*argv));
  272. switch (toupper(c)) {
  273. case 'B': /* -b: both screen and stdout */
  274. fBoth = TRUE;
  275. break;
  276. default:
  277. fputs ("Unknown switch ignored", stderr);
  278. break;
  279. }
  280. }
  281. // InitializeGlobalState();
  282. Scr = consoleGetCurrentScreen();
  283. // Load help engine DLL and initialize pointers to entry
  284. // points.
  285. //
  286. LoadTheDll();
  287. #if defined(CLEAR)
  288. HelpInit();
  289. #endif
  290. /*
  291. * Start by getting the current config & clearing screen.
  292. */
  293. // rjsa screen.cb = sizeof(screen);
  294. // rjsa assertDos (VioGetMode (&screen, 0));
  295. // rjsa lastline = screen.row-1;
  296. consoleGetScreenInformation( Scr, &ScrInfo );
  297. lastline = ScrInfo.NumberOfRows-2;
  298. // lastline = 22;
  299. cls();
  300. helpCmd();
  301. /*
  302. * main loop. Position at bottom of screen, and accept one command at at time
  303. * from there. Interpret commands until done.
  304. */
  305. do {
  306. outtextat ("\r\n", lastline, 0, BRIGHTWHITE);
  307. outtextat (spaces, lastline, 0, BRIGHTWHITE);
  308. outtextat ("HTEST Command> ", lastline, 0, BRIGHTWHITE);
  309. // rjsa VioSetCurPos (lastline, 15, 0);
  310. consoleSetCursor(Scr, lastline, 16);
  311. gets (buf);
  312. cls ();
  313. outtextat ("\r\n", lastline, 0, BRIGHTWHITE);
  314. outtextat ("Processing: ", lastline, 0, LIGHTRED);
  315. outtextat (buf, lastline, 12, BRIGHTWHITE);
  316. outtextat ("\r\n", lastline, 0, BRIGHTWHITE);
  317. /*
  318. * ctrl on/off
  319. */
  320. if (!strcmp (buf,"ctrl on")) {
  321. fEnable = TRUE;
  322. cls ();
  323. outtextat ("Control Lines Displayed", 0, 0, BRIGHTWHITE);
  324. }
  325. else if (!strcmp (buf,"ctrl off")) {
  326. fEnable = FALSE;
  327. cls ();
  328. outtextat ("Control Lines NOT Displayed", 0, 0, BRIGHTWHITE);
  329. }
  330. /*
  331. * disp
  332. */
  333. else if (!strcmp (buf,"disp"))
  334. dispCmd (1,lastline);
  335. /*
  336. * down
  337. */
  338. else if (!strcmp (buf,"down"))
  339. dispCmd (lLast+1,lLast + lastline);
  340. /*
  341. * dump
  342. */
  343. else if (!strncmp (buf, "dump ", 5))
  344. dumpfileCmd(buf+5);
  345. else if (!strcmp (buf,"dump"))
  346. dumpCmd ();
  347. /*
  348. * file newhelpfilename
  349. */
  350. else if (!strncmp (buf,"file ", 5))
  351. fileCmd (buf+5);
  352. /*
  353. * help
  354. */
  355. else if (!strcmp (buf,"help"))
  356. helpCmd ();
  357. /*
  358. * look helpstring
  359. */
  360. else if (!strncmp (buf,"look ", 5))
  361. lookupCmd (buf+5,0);
  362. /*
  363. * look
  364. */
  365. else if (!strcmp (buf,"look"))
  366. lookupCmd (NULL,0);
  367. /*
  368. * next
  369. */
  370. else if (!strcmp (buf,"next"))
  371. lookupCmd (NULL,1);
  372. /*
  373. * prev
  374. */
  375. else if (!strcmp (buf,"prev"))
  376. lookupCmd (NULL,-1);
  377. /*
  378. * up
  379. */
  380. else if (!strcmp (buf,"up")) {
  381. lLast = max (1, lLast-1);
  382. dispCmd (lLast,lLast + lastline);
  383. }
  384. /*
  385. * xref xrefnumber
  386. */
  387. else if (!strncmp (buf,"xref", 4))
  388. xrefCmd (buf+4);
  389. /*
  390. * + page down
  391. */
  392. else if (!strcmp (buf,"+")) {
  393. lLast += lastline;
  394. dispCmd (lLast,lLast + lastline);
  395. }
  396. /*
  397. * - page up
  398. */
  399. else if (!strcmp (buf,"-")) {
  400. lLast = max (1, lLast - (lastline));
  401. dispCmd (lLast,lLast + lastline);
  402. }
  403. }
  404. /*
  405. * exit
  406. */
  407. while (strncmp(buf,"exit",4));
  408. outtextat (spaces, lastline, 0, BRIGHTWHITE);
  409. HelpClose (ncNull);
  410. /* end main */}
  411. /*** dispCmd - display topic text
  412. *
  413. * displays the topic text on the screen.
  414. *
  415. * Input:
  416. * lStart - starting line
  417. * lEnd - ending line
  418. *
  419. * Output:
  420. * Returns nothing
  421. *
  422. *************************************************************************/
  423. void pascal near dispCmd (
  424. int lStart,
  425. int lEnd
  426. ) {
  427. char buf[BUFSIZ*2];
  428. lineattr rgAttr[BUFSIZ];
  429. int cb;
  430. int lineCur = 0;
  431. HelpCtl (pTopicCur, fEnable);
  432. cls ();
  433. lLast = lStart;
  434. while (lStart<lEnd) {
  435. if (!isatty(_fileno(stdout)) || fBoth) {
  436. cb = (int)HelpGetLine (lStart, BUFSIZ*2, (char far *)buf, pTopicCur);
  437. if (cb == 0)
  438. lStart = lEnd;
  439. buf[cb-1] = '\r';
  440. buf[cb] = '\n';
  441. buf[cb+1] = 0;
  442. outtext (buf, BLACK);
  443. buf[cb-1] = 0;
  444. }
  445. if (isatty(_fileno(stdout)) || fBoth) {
  446. cb = HelpGetLine(lStart, BUFSIZ*2, (char far*)buf, pTopicCur );
  447. HelpGetLineAttr( lStart, BUFSIZ*sizeof(lineattr), rgAttr, pTopicCur );
  448. WrtLineAttr(buf, rgAttr, cb, lineCur++, 0 );
  449. }
  450. //if (isatty(fileno(stdout)) || fBoth) {
  451. // cb = HelpGetCells (lStart, BUFSIZ*2, buf, pTopicCur, mpAttr);
  452. // if (cb == -1)
  453. // lStart = lEnd;
  454. // else
  455. // ASSERTDOS (WrtCellStr (buf, cb, lineCur++, 0));
  456. // }
  457. lStart++;
  458. }
  459. /* end dispCmd */}
  460. static char *szHS[] = { "HS_INDEX",
  461. "HS_CONTEXTSTRINGS",
  462. "HS_CONTEXTMAP",
  463. "HS_KEYPHRASE",
  464. "HS_HUFFTREE",
  465. "HS_TOPICS",
  466. "unused (6)",
  467. "unused (7)",
  468. "HS_NEXT" };
  469. /*** dumpCmd - process dump command
  470. *
  471. * Dumps the contents of the current help file
  472. *
  473. * NOTE:
  474. * This function uses all sorts of "internal" knowledge and calls to
  475. * do it's job.
  476. *
  477. * Input:
  478. *
  479. * Output:
  480. * Returns nothing
  481. *
  482. *************************************************************************/
  483. void pascal near dumpCmd () {
  484. char buf[BUFSIZ];
  485. int cbKeyPhrase;
  486. fdb fdbLocal; /* local copy of fdb to use */
  487. uchar far *fpT;
  488. ushort far *fpW;
  489. int i;
  490. nc ncNext; /* nc init of appended file */
  491. //uchar uc;
  492. cls();
  493. ncNext = ncCur;
  494. while (ncNext.cn) {
  495. if (LoadFdb (ncNext.mh, &fdbLocal)) {
  496. sprintf (buf,"fhHelp %u\r\n", fdbLocal.fhHelp);
  497. outtext (buf, BRIGHTWHITE);
  498. sprintf (buf,"ncInit %08lx\r\n", fdbLocal.ncInit);
  499. outtext (buf, BRIGHTWHITE);
  500. for (i=0; i<HS_count; i++) {
  501. sprintf (buf,"rgmhSections[%18s] %04x\r\n", szHS[i], fdbLocal.rgmhSections[i]);
  502. outtext (buf, BRIGHTWHITE);
  503. }
  504. sprintf (buf,"ftype %02x\r\n", fdbLocal.ftype );
  505. outtext (buf, BRIGHTWHITE);
  506. sprintf (buf,"fname %14s\r\n", fdbLocal.fname );
  507. outtext (buf, BRIGHTWHITE);
  508. sprintf (buf,"foff %08lx\r\n", fdbLocal.foff );
  509. outtext (buf, BRIGHTWHITE);
  510. sprintf (buf,"ncLink %08lx\r\n", fdbLocal.ncLink);
  511. outtext (buf, BRIGHTWHITE);
  512. sprintf (buf,"hdr.wMagic %04x\r\n", fdbLocal.hdr.wMagic );
  513. outtext (buf, BRIGHTWHITE);
  514. sprintf (buf,"hdr.wVersion %04x\r\n", fdbLocal.hdr.wVersion );
  515. outtext (buf, BRIGHTWHITE);
  516. sprintf (buf,"hdr.wFlags %04x\r\n", fdbLocal.hdr.wFlags );
  517. outtext (buf, BRIGHTWHITE);
  518. sprintf (buf,"hdr.appChar %04x\r\n", fdbLocal.hdr.appChar );
  519. outtext (buf, BRIGHTWHITE);
  520. sprintf (buf,"hdr.cTopics %04x\r\n", fdbLocal.hdr.cTopics );
  521. outtext (buf, BRIGHTWHITE);
  522. sprintf (buf,"hdr.cContexts %04x\r\n", fdbLocal.hdr.cContexts );
  523. outtext (buf, BRIGHTWHITE);
  524. sprintf (buf,"hdr.cbWidth %04x\r\n", fdbLocal.hdr.cbWidth );
  525. outtext (buf, BRIGHTWHITE);
  526. sprintf (buf,"hdr.cPreDef %04x\r\n", fdbLocal.hdr.cPreDef );
  527. outtext (buf, BRIGHTWHITE);
  528. sprintf (buf,"hdr.fname %s\r\n", fdbLocal.hdr.fname );
  529. outtext (buf, BRIGHTWHITE);
  530. sprintf (buf,"hdr.reserved[0] %04x\r\n", fdbLocal.hdr.reserved[0]);
  531. outtext (buf, BRIGHTWHITE);
  532. sprintf (buf,"hdr.reserved[1] %04x\r\n", fdbLocal.hdr.reserved[1]);
  533. for (i=0; i<HS_count; i++) {
  534. sprintf (buf,"hdr.tbPos[%18s] %08lx\r\n", szHS[i], fdbLocal.hdr.tbPos[i]);
  535. outtext (buf, BRIGHTWHITE);
  536. }
  537. outtext ("----- ----- -----\r\n", LIGHTGREEN);
  538. /*
  539. * Topic Index
  540. * This is just a table of (long) offsets within the current file. We just
  541. * report the values, and also calculate the size of each entry by looking
  542. * at the position of the entry following.
  543. */
  544. fpT = HelpLock (LoadPortion( HS_INDEX ,ncNext.mh));
  545. if (fpT) {
  546. outtext ("Topic Index:\r\n", LIGHTRED);
  547. for (i = 0; i < (int)fdbLocal.hdr.cTopics; i++) {
  548. sprintf (buf, " %2d: %08lx, %ld bytes\r\n", i, ((long far *)fpT)[i], ((long far *)fpT)[i+1]-((long far *)fpT)[i]);
  549. outtext (buf, BRIGHTWHITE);
  550. }
  551. outtext ("----- ----- -----\r\n", LIGHTGREEN);
  552. }
  553. /*
  554. * context strings
  555. * This is just a table of null terminated strings, in no particular order.
  556. * We just list them out sequentially.
  557. */
  558. fpT = HelpLock (LoadPortion( HS_CONTEXTSTRINGS ,ncNext.mh));
  559. if (fpT) {
  560. outtext ("Context strings:\r\n", LIGHTRED);
  561. for (i=0; i<(int)fdbLocal.hdr.cContexts; i++) {
  562. sprintf (buf, " %03d: ", i);
  563. // rjsa hfstrcpy ((char far *)buf+7, fpT);
  564. strcpy ((char far *)buf+7, fpT);
  565. strcat (buf, "\r\n");
  566. outtext (buf, BRIGHTWHITE);
  567. // rjsa fpT += hfstrlen(fpT) +1;
  568. fpT += strlen(fpT) +1;
  569. }
  570. outtext ("----- ----- -----\r\n", LIGHTGREEN);
  571. }
  572. /*
  573. * Context Map
  574. * This is the mapping of context strings to actual topic numbers. The context
  575. * strings map one to one to the entries in this table, which in turn contains
  576. * indexes into the topic index at the head of the file. We just dump this
  577. * table sequentially.
  578. */
  579. fpT = HelpLock (LoadPortion( HS_CONTEXTMAP ,ncNext.mh));
  580. if (fpT) {
  581. outtext ("Context map:\r\n", LIGHTRED);
  582. outtext (" Ctx Topic\r\n",BRIGHTWHITE);
  583. outtext (" --- -----\r\n",BRIGHTWHITE);
  584. for (i=0; i<(int)fdbLocal.hdr.cContexts; i++) {
  585. sprintf (buf, " %03d: %04d\r\n", i, ((ushort far *)fpT)[i]);
  586. outtext (buf, BRIGHTWHITE);
  587. }
  588. outtext ("----- ----- -----\r\n", LIGHTGREEN);
  589. }
  590. /*
  591. * keyword table
  592. * This is a table of byte-prefixed strings, which we output in order,
  593. * synthesizing the tokens that they would be in the text as well.
  594. */
  595. fpT = HelpLock (LoadPortion( HS_KEYPHRASE, ncNext.mh));
  596. if (fpT) {
  597. cbKeyPhrase = 0;
  598. for (i=HS_HUFFTREE; i<HS_count; i++)
  599. if (fdbLocal.hdr.tbPos[i]) {
  600. cbKeyPhrase = (ushort)(fdbLocal.hdr.tbPos[i] - fdbLocal.hdr.tbPos[HS_KEYPHRASE]);
  601. break;
  602. }
  603. outtext ("Keyphrase Table:\r\n", LIGHTRED);
  604. outtext (" Token Phrase\r\n",BRIGHTWHITE);
  605. outtext (" ----- ------\r\n",BRIGHTWHITE);
  606. i = 0;
  607. fpT += 1024 * sizeof (PVOID);
  608. fpW = (ushort far *)(fpT + cbKeyPhrase);
  609. while (fpT < (uchar far *)fpW) {
  610. sprintf (buf, " %04x: ", i+(C_KEYPHRASE0 << 8));
  611. fpT = phrasecopy (buf+8, fpT);
  612. strcat (buf, "\r\n");
  613. outtext (buf, BRIGHTWHITE);
  614. i++;
  615. }
  616. outtext ("----- ----- -----\r\n", LIGHTGREEN);
  617. }
  618. /*
  619. * huffman table
  620. * here we try to get fancy and output some information about the table format
  621. */
  622. fpW = HelpLock (LoadPortion( HS_HUFFTREE, ncNext.mh));
  623. if (fpW) {
  624. outtext ("Huffman Tree:\r\n", LIGHTRED);
  625. i = 0;
  626. while (*fpW) {
  627. sprintf (buf, " 0x%03x: 0x%04x, %s\r\n", i++, *fpW, *fpW & 0x8000 ? "Leaf" : "Node");
  628. fpW++;
  629. outtext (buf, BRIGHTWHITE);
  630. }
  631. }
  632. outtext ("===== ===== =====\r\n", YELLOW);
  633. ncNext = fdbLocal.ncLink;
  634. }
  635. else {
  636. sprintf(buf, "Cannot load fdb for %08lx\r\n",ncCur);
  637. outtext (buf, LIGHTRED);
  638. return;
  639. }
  640. }
  641. /* end dumpCmd */}
  642. /*** dumpfileCmd - process dump command
  643. *
  644. * Dumps the contents of the current help file
  645. *
  646. * NOTE:
  647. * This function uses all sorts of "internal" knowledge and calls to
  648. * do it's job.
  649. *
  650. * Input:
  651. *
  652. * Output:
  653. * Returns nothing
  654. *
  655. *************************************************************************/
  656. void pascal near dumpfileCmd (char *fname) {
  657. char buf[BUFSIZ];
  658. int cbKeyPhrase;
  659. fdb fdbLocal; /* local copy of fdb to use */
  660. uchar far *fpT;
  661. ushort far *fpW;
  662. int i;
  663. nc ncNext; /* nc init of appended file */
  664. //uchar uc;
  665. FILE* fh = fopen(fname, "w");
  666. if (!fh) {
  667. return;
  668. }
  669. ncNext = ncCur;
  670. while (ncNext.cn) {
  671. if (LoadFdb (ncNext.mh, &fdbLocal)) {
  672. sprintf (buf,"fhHelp %u\r\n", fdbLocal.fhHelp);
  673. fprintf( fh, buf );
  674. sprintf (buf,"ncInit %08lx\r\n", fdbLocal.ncInit);
  675. fprintf( fh, buf );
  676. for (i=0; i<HS_count; i++) {
  677. sprintf (buf,"rgmhSections[%18s] %04x\r\n", szHS[i], fdbLocal.rgmhSections[i]);
  678. fprintf( fh, buf );
  679. }
  680. sprintf (buf,"ftype %02x\r\n", fdbLocal.ftype );
  681. fprintf( fh, buf );
  682. sprintf (buf,"fname %14s\r\n", fdbLocal.fname );
  683. fprintf( fh, buf );
  684. fprintf( fh, buf );
  685. sprintf (buf,"foff %08lx\r\n", fdbLocal.foff );
  686. fprintf( fh, buf );
  687. sprintf (buf,"ncLink %08lx\r\n", fdbLocal.ncLink);
  688. fprintf( fh, buf );
  689. sprintf (buf,"hdr.wMagic %04x\r\n", fdbLocal.hdr.wMagic );
  690. fprintf( fh, buf );
  691. sprintf (buf,"hdr.wVersion %04x\r\n", fdbLocal.hdr.wVersion );
  692. fprintf( fh, buf );
  693. sprintf (buf,"hdr.wFlags %04x\r\n", fdbLocal.hdr.wFlags );
  694. fprintf( fh, buf );
  695. sprintf (buf,"hdr.appChar %04x\r\n", fdbLocal.hdr.appChar );
  696. fprintf( fh, buf );
  697. sprintf (buf,"hdr.cTopics %04x\r\n", fdbLocal.hdr.cTopics );
  698. fprintf( fh, buf );
  699. sprintf (buf,"hdr.cContexts %04x\r\n", fdbLocal.hdr.cContexts );
  700. fprintf( fh, buf );
  701. sprintf (buf,"hdr.cbWidth %04x\r\n", fdbLocal.hdr.cbWidth );
  702. fprintf( fh, buf );
  703. sprintf (buf,"hdr.cPreDef %04x\r\n", fdbLocal.hdr.cPreDef );
  704. fprintf( fh, buf );
  705. sprintf (buf,"hdr.fname %s\r\n", fdbLocal.hdr.fname );
  706. fprintf( fh, buf );
  707. sprintf (buf,"hdr.reserved[0] %04x\r\n", fdbLocal.hdr.reserved[0]);
  708. fprintf( fh, buf );
  709. sprintf (buf,"hdr.reserved[1] %04x\r\n", fdbLocal.hdr.reserved[1]);
  710. for (i=0; i<HS_count; i++) {
  711. sprintf (buf,"hdr.tbPos[%18s] %08lx\r\n", szHS[i], fdbLocal.hdr.tbPos[i]);
  712. fprintf( fh, buf );
  713. }
  714. fprintf( fh,"----- ----- -----\r\n" );
  715. /*
  716. * Topic Index
  717. * This is just a table of (long) offsets within the current file. We just
  718. * report the values, and also calculate the size of each entry by looking
  719. * at the position of the entry following.
  720. */
  721. fpT = HelpLock (LoadPortion( HS_INDEX ,ncNext.mh));
  722. if (fpT) {
  723. fprintf( fh,"Topic Index:\r\n" );
  724. for (i = 0; i < (int)fdbLocal.hdr.cTopics; i++) {
  725. sprintf (buf, " %2d: %08lx, %ld bytes\r\n", i, ((long far *)fpT)[i], ((long far *)fpT)[i+1]-((long far *)fpT)[i]);
  726. fprintf( fh, buf );
  727. }
  728. fprintf( fh,"----- ----- -----\r\n" );
  729. }
  730. /*
  731. * context strings
  732. * This is just a table of null terminated strings, in no particular order.
  733. * We just list them out sequentially.
  734. */
  735. fpT = HelpLock (LoadPortion( HS_CONTEXTSTRINGS ,ncNext.mh));
  736. if (fpT) {
  737. fprintf( fh, "Context strings:\r\n" );
  738. for (i=0; i<(int)fdbLocal.hdr.cContexts; i++) {
  739. sprintf (buf, " %03d: ", i);
  740. // rjsa hfstrcpy ((char far *)buf+7, fpT);
  741. strcpy ((char far *)buf+7, fpT);
  742. strcat (buf, "\r\n");
  743. fprintf( fh, buf );
  744. // rjsa fpT += hfstrlen(fpT) +1;
  745. fpT += strlen(fpT) +1;
  746. }
  747. fprintf( fh,"----- ----- -----\r\n" );
  748. }
  749. /*
  750. * Context Map
  751. * This is the mapping of context strings to actual topic numbers. The context
  752. * strings map one to one to the entries in this table, which in turn contains
  753. * indexes into the topic index at the head of the file. We just dump this
  754. * table sequentially.
  755. */
  756. fpT = HelpLock (LoadPortion( HS_CONTEXTMAP ,ncNext.mh));
  757. if (fpT) {
  758. fprintf( fh, "Context map:\r\n" );
  759. fprintf( fh, " Ctx Topic\r\n" );
  760. fprintf( fh, " --- -----\r\n" );
  761. for (i=0; i<(int)fdbLocal.hdr.cContexts; i++) {
  762. sprintf (buf, " %03d: %04d\r\n", i, ((ushort far *)fpT)[i]);
  763. fprintf( fh, buf );
  764. }
  765. fprintf( fh, "----- ----- -----\r\n" );
  766. }
  767. /*
  768. * keyword table
  769. * This is a table of byte-prefixed strings, which we output in order,
  770. * synthesizing the tokens that they would be in the text as well.
  771. */
  772. fpT = HelpLock (LoadPortion( HS_KEYPHRASE, ncNext.mh));
  773. if (fpT) {
  774. cbKeyPhrase = 0;
  775. for (i=HS_HUFFTREE; i<HS_count; i++)
  776. if (fdbLocal.hdr.tbPos[i]) {
  777. cbKeyPhrase = (ushort)(fdbLocal.hdr.tbPos[i] - fdbLocal.hdr.tbPos[HS_KEYPHRASE]);
  778. break;
  779. }
  780. fprintf( fh, "Keyphrase Table:\r\n" );
  781. fprintf( fh, " Token Phrase\r\n" );
  782. fprintf( fh, " ----- ------\r\n" );
  783. i = 0;
  784. fpT += 1024 * sizeof (PVOID);
  785. fpW = (ushort far *)(fpT + cbKeyPhrase);
  786. while (fpT < (uchar far *)fpW) {
  787. sprintf (buf, " %04x: ", i+(C_KEYPHRASE0 << 8));
  788. fpT = phrasecopy (buf+8, fpT);
  789. strcat (buf, "\r\n");
  790. fprintf( fh, buf );
  791. i++;
  792. }
  793. fprintf( fh,"----- ----- -----\r\n" );
  794. }
  795. /*
  796. * huffman table
  797. * here we try to get fancy and output some information about the table format
  798. */
  799. fpW = HelpLock (LoadPortion( HS_HUFFTREE, ncNext.mh));
  800. if (fpW) {
  801. fprintf( fh, "Huffman Tree:\r\n" );
  802. i = 0;
  803. while (*fpW) {
  804. sprintf (buf, " 0x%03x: 0x%04x, %s\r\n", i++, *fpW, *fpW & 0x8000 ? "Leaf" : "Node");
  805. fpW++;
  806. fprintf( fh, buf );
  807. }
  808. }
  809. fprintf( fh, "===== ===== =====\r\n" );
  810. ncNext = fdbLocal.ncLink;
  811. }
  812. else {
  813. sprintf(buf, "Cannot load fdb for %08lx\r\n",ncCur);
  814. fprintf( fh, buf );
  815. fclose(fh);
  816. return;
  817. }
  818. }
  819. /* end dumpCmd */}
  820. /*** fileCmd - process file command
  821. *
  822. * Opens the help file specified.
  823. *
  824. * Input:
  825. * pName = name of help file to be added
  826. *
  827. * Output:
  828. * Returns nothing
  829. *
  830. *************************************************************************/
  831. void pascal near fileCmd (
  832. char *pName
  833. ) {
  834. char buf[BUFSIZ];
  835. int i;
  836. nc ncInit;
  837. sprintf (buf,"Opening %s...\r\n",pName);
  838. outtext (buf, BRIGHTWHITE);
  839. /*
  840. * search file table for available slot
  841. */
  842. for (i=0; i<MAXFILES; i++)
  843. if (!ncTbl[i].cn)
  844. break;
  845. if (i >= MAXFILES) {
  846. sprintf(buf, "Cannot open %s: htest's open file limit exceeded\r\n",pName);
  847. outtext (buf, LIGHTRED);
  848. return;
  849. }
  850. iNcCur = i;
  851. ncInit = HelpOpen(pName);
  852. for (i=0; i<MAXFILES; i++)
  853. if ((ncTbl[i].mh == ncInit.mh) && (ncTbl[i].cn == ncInit.cn)) {
  854. iNcCur = i;
  855. sprintf (buf, "File #%d; Initial Context: 0x%04lx (file already open)\r\n",iNcCur,ncInit);
  856. outtext (buf, BRIGHTWHITE);
  857. return;
  858. }
  859. if (ISERROR(ncInit)) {
  860. sprintf(buf, "Cannot open %s: 0x%04lx, %s\r\n",pName,ncInit, errTbl[ncInit.cn]);
  861. outtext (buf, LIGHTRED);
  862. return;
  863. }
  864. /*
  865. * output initial context, and the available memory
  866. */
  867. ncCur = ncTbl[iNcCur] = ncInit;
  868. sprintf (buf, "File #%d; Initial Context: 0x%04lx\r\n",iNcCur,ncInit.cn);
  869. outtext (buf, BRIGHTWHITE);
  870. lookupCmd(NULL, 0);
  871. /* end fileCmd */}
  872. /*** helpCmd - display help on commands
  873. *
  874. * Input:
  875. * none
  876. *
  877. * Output:
  878. * Returns nothing
  879. *
  880. *************************************************************************/
  881. void pascal near helpCmd () {
  882. outtext ("HTEST - Help Engine Test Harness\r\n", BRIGHTWHITE);
  883. outtext ("\r\n", BRIGHTWHITE);
  884. outtext ("Comands:\r\n", BRIGHTWHITE);
  885. outtext ("\r\n", BRIGHTWHITE);
  886. outtext ("ctrl on/off - turn on/off display of control lines\r\n", BRIGHTWHITE);
  887. outtext ("disp - display first screen of most recently read topic\r\n", BRIGHTWHITE);
  888. outtext ("down - move ahead one line in topic and display\r\n", BRIGHTWHITE);
  889. outtext ("dump - dump file info (very large)\r\n", BRIGHTWHITE);
  890. outtext ("exit - exit htest\r\n", BRIGHTWHITE);
  891. outtext ("file x - open new help file, or make help file current\r\n", BRIGHTWHITE);
  892. outtext ("help - display this screen\r\n", BRIGHTWHITE);
  893. outtext ("look x - loop up context string & fetch topic\r\n", BRIGHTWHITE);
  894. outtext ("next - fetch next physical topic\r\n", BRIGHTWHITE);
  895. outtext ("prev - fetch previous physical topic\r\n", BRIGHTWHITE);
  896. outtext ("up - move back one line in topic and display\r\n", BRIGHTWHITE);
  897. outtext ("xref x - display all xrefs in current topic, or look up #x\r\n", BRIGHTWHITE);
  898. outtext ("+ - move & redisplay one page down\r\n", BRIGHTWHITE);
  899. outtext ("- - move & redisplay one page up\r\n", BRIGHTWHITE);
  900. /* end helpCmd */}
  901. /*** lookupCmd - process file command
  902. *
  903. * Looks up the specified string in the current helpfile, or the next help
  904. * topic.
  905. *
  906. * Input:
  907. * pString = help string to look up
  908. * dir = direction: 0= look up string, 1=get next, -1= get previous
  909. *
  910. * Output:
  911. * Returns nothing
  912. *
  913. *************************************************************************/
  914. void pascal near lookupCmd (
  915. char *pString,
  916. int dir
  917. ) {
  918. char buf[BUFSIZ];
  919. unsigned cbCompressed;
  920. unsigned cbUncompressed;
  921. char far *pCompressed;
  922. /*
  923. * Start with the simple look up of the conetxt to get an nc. Report on
  924. * failure.
  925. */
  926. if (pString)
  927. ncCur = HelpNc(pString,ncTbl[iNcCur]);
  928. else if (dir>0) {
  929. if (!ncCur.cn)
  930. ncCur = ncTbl[iNcCur];
  931. else
  932. ncCur = HelpNcNext(ncCur);
  933. }
  934. else if (dir<0) {
  935. if (!ncCur.cn)
  936. ncCur = ncTbl[iNcCur];
  937. else if (ncCur.cn != ncTbl[iNcCur].cn)
  938. ncCur = HelpNcPrev(ncCur);
  939. }
  940. else
  941. ncCur = ncTbl[iNcCur];
  942. if (!ncCur.cn) {
  943. outtext ("Lookup Failed: HelpNc/HelpNcNext/HelpNcPrev returned 0", LIGHTRED);
  944. return;
  945. }
  946. /*
  947. * It exists. Indicate what file we're looking in, what we found, and the
  948. * nc that was returned
  949. */
  950. sprintf (buf, "File #%d; Looking up:%s\r\n",iNcCur,
  951. pString ? (*pString ? pString : "local context")
  952. : (dir ? ((dir>0) ? "**NEXT**" : "**PREV**")
  953. : "current"));
  954. outtext (buf, BRIGHTWHITE);
  955. sprintf (buf, "nc returned = %08lx\r\n",ncCur.cn);
  956. outtext (buf, BRIGHTWHITE);
  957. /*
  958. * Free up memory for previously current topic
  959. */
  960. if (mhTopicCur)
  961. free(mhTopicCur);
  962. /*
  963. * Get the compressed memory size required, and report it. Alloc it.
  964. */
  965. cbCompressed = HelpNcCb(ncCur);
  966. sprintf (buf, "size of compressed topic = %d\r\n",cbCompressed);
  967. outtext (buf, BRIGHTWHITE);
  968. pCompressed = malloc(cbCompressed);
  969. /*
  970. * read in the compressed topic, getting the size required for the
  971. * uncompressed results. Report that, and allocate it.
  972. */
  973. cbUncompressed = HelpLook(ncCur,pCompressed);
  974. sprintf (buf, "size of UNcompressed topic = %d\r\n",cbUncompressed);
  975. outtext (buf, BRIGHTWHITE);
  976. mhTopicCur = malloc(cbUncompressed);
  977. //pTopicCur = MAKEP (mhTopicCur, 0);
  978. pTopicCur = mhTopicCur;
  979. /*
  980. * Decompress the topic.
  981. */
  982. HelpDecomp(pCompressed,pTopicCur,ncCur);
  983. outtext ("Decompressed\r\n", BRIGHTWHITE);
  984. /*
  985. * exercise SzContext and cLines routines, reporting results
  986. */
  987. HelpSzContext(buf,ncCur);
  988. strcat (buf, "\r\n");
  989. outtext (buf, BRIGHTWHITE);
  990. sprintf(buf,"%d lines\r\n", HelpcLines(pTopicCur));
  991. outtext (buf, BRIGHTWHITE);
  992. /*
  993. * Report the amount of available memory at this point, and then free up the
  994. * compressed text
  995. */
  996. free(pCompressed);
  997. /* end lookupCmd */}
  998. /*** xrefCmd - process xref command
  999. *
  1000. * Display or execute cross reference
  1001. *
  1002. * Input:
  1003. * pText = pointer to ascii text which, if a non-zero number, indicates the
  1004. * xref to execute. If zero, display all
  1005. *
  1006. * Output:
  1007. * Returns nothing
  1008. *
  1009. *************************************************************************/
  1010. void pascal near xrefCmd (
  1011. char *pText
  1012. ) {
  1013. hotspot hsCur; /* hot spot definition */
  1014. int i; /* working counter */
  1015. int iReq; /* request value */
  1016. char *pT; /* temp pointer */
  1017. iReq = atoi (pText);
  1018. hsCur.line = hsCur.col = 1;
  1019. i = 1;
  1020. while (HelpHlNext(0,pTopicCur,&hsCur)) {
  1021. /*
  1022. * if not explicit request, then list as much as we can
  1023. */
  1024. if (!iReq) {
  1025. sprintf (buf, "Xref [%d] @ line: %05d columns %02d to %02d = "
  1026. ,i
  1027. ,hsCur.line
  1028. ,hsCur.col
  1029. ,hsCur.ecol);
  1030. pT = buf + strlen(buf);
  1031. if (*hsCur.pXref)
  1032. while (*pT++ = *hsCur.pXref++);
  1033. else
  1034. sprintf(pT, "Local >> topic # 0x%04x ",*(ushort far *)(hsCur.pXref+1));
  1035. strcat (buf, "\r\n");
  1036. outtext (buf, LIGHTGREEN);
  1037. }
  1038. else if (i == iReq) {
  1039. pT = buf;
  1040. if (*hsCur.pXref)
  1041. while (*pT++ = *hsCur.pXref++);
  1042. else {
  1043. *pT++ = *hsCur.pXref++;
  1044. *pT++ = *hsCur.pXref++;
  1045. *pT++ = *hsCur.pXref++;
  1046. }
  1047. lookupCmd (buf, 0);
  1048. return;
  1049. }
  1050. ++i;
  1051. hsCur.col = hsCur.ecol+(ushort)1;
  1052. }
  1053. /* end xrefCmd */}
  1054. /*** outtext - output text with specific colors
  1055. *
  1056. * sets the forground color and location as appropriate, and displays the
  1057. * desired text. Checks for redirection, and if redirected, just outputs the
  1058. * text to stdout.
  1059. *
  1060. * Input:
  1061. * ptext = pointer to text to output
  1062. * color = color to use
  1063. *
  1064. * Output:
  1065. * Returns
  1066. *
  1067. *************************************************************************/
  1068. void pascal near outtext (
  1069. char *pText,
  1070. BYTE color
  1071. ) {
  1072. outtextat (pText, curline++, 0, color);
  1073. if (curline >= lastline) {
  1074. if (isatty(_fileno(stdout))
  1075. && !fBoth) {
  1076. outtextat ("More...", lastline, 0, BRIGHTWHITE);
  1077. // rjsa VioSetCurPos (lastline, 8, 0);
  1078. #if defined (OS2)
  1079. consoleSetCursor(lastline,8);
  1080. #else
  1081. consoleSetCursor(Scr,lastline,8);
  1082. #endif
  1083. gets (buf);
  1084. }
  1085. curline = 0;
  1086. cls ();
  1087. }
  1088. /* end outtext */}
  1089. /*** outtextat - put text with specific colors at a specific place
  1090. *
  1091. * sets the forground color and location as appropriate, and displays the
  1092. * desired text. Checks for redirection, and if redirected, just outputs the
  1093. * text to stdout.
  1094. *
  1095. * Input:
  1096. * ptext = pointer to text to output
  1097. * col = column to put into
  1098. * color = color to use
  1099. *
  1100. * Output:
  1101. * Returns
  1102. *
  1103. *************************************************************************/
  1104. void pascal near outtextat (
  1105. char *pText,
  1106. int line,
  1107. int col,
  1108. BYTE color
  1109. ) {
  1110. char *pEol; /* ptr to nl, if present */
  1111. int len;
  1112. color |= (ColorByte & 0xf0);
  1113. if ((isatty(_fileno(stdout)) || fBoth) && (line <= lastline)) {
  1114. len = strlen(pText);
  1115. if (pEol = strchr (pText, '\r'))
  1116. *pEol = 0;
  1117. // rjsa VioWrtCharStrAtt (pText, strlen(pText), line, col, (PBYTE)&color, 0);
  1118. WrtCharStrAtt (pText, strlen(pText), line, col, (PBYTE)&color);
  1119. if (pEol)
  1120. *pEol = '\r';
  1121. }
  1122. if (!isatty(_fileno(stdout)) || fBoth)
  1123. printf ("%s",pText);
  1124. /* end outtextat */}
  1125. /*** assertDos - asserts that a dos call returned a zero
  1126. *
  1127. * Just prints the number passed it if non-zero, and quits
  1128. *
  1129. * Input:
  1130. * Return code from a dos call
  1131. *
  1132. * Output:
  1133. * Returns only if zero passed in
  1134. *
  1135. *************************************************************************/
  1136. void pascal near assertDos (
  1137. USHORT rv,
  1138. CHAR * pFile,
  1139. USHORT LineNo
  1140. ) {
  1141. if (rv) {
  1142. printf ("assertDos: %u (0x%04x) File %s, line %u\n", rv, rv, pFile, LineNo);
  1143. exit (1);
  1144. }
  1145. /* end assertDos*/}
  1146. /*** cls - clear screen
  1147. *
  1148. * Clear screen to current backround color
  1149. *
  1150. * Input:
  1151. * none
  1152. *
  1153. * Output:
  1154. * Returns screen clear
  1155. *
  1156. *************************************************************************/
  1157. void pascal near cls () {
  1158. curline = 0;
  1159. // rjsa VioScrollUp (0, 0, 0xffff, 0xffff, 0xffff, cell, 0);
  1160. consoleSetAttribute( Scr, 0x1f );
  1161. consoleClearScreen(Scr, TRUE);
  1162. /* end cls */}
  1163. /*** phrasecopy - copy a keyword phrase from the table
  1164. *
  1165. * Copies a byte-length-prefixed string from far memory to a null terminated
  1166. * string in near memory.
  1167. *
  1168. * Input:
  1169. * dst - near pointer to destination
  1170. * src - far pointer to source
  1171. *
  1172. * Output:
  1173. * Returns far pointer to byte following source string
  1174. *
  1175. *************************************************************************/
  1176. uchar far * pascal near phrasecopy (
  1177. uchar *dst,
  1178. uchar far *src
  1179. ) {
  1180. register int i;
  1181. if (i = (int)*src++)
  1182. while (i--)
  1183. *dst++ = *src++;
  1184. *dst = 0;
  1185. return src;
  1186. /* end phrasecopy */}
  1187. void far * pascal HelpLock(mhCur)
  1188. mh mhCur;
  1189. {
  1190. //return MAKEP(mhCur,0);
  1191. return mhCur;
  1192. }
  1193. void pascal HelpUnlock(mhCur)
  1194. mh mhCur;
  1195. {
  1196. mhCur;
  1197. }
  1198. void pascal HelpDealloc(mhCur)
  1199. mh mhCur;
  1200. {
  1201. if (mhCur)
  1202. free(mhCur);
  1203. }
  1204. USHORT WrtCellStr (PBYTE buf, int cb, int row, int col) {
  1205. int cl = col;
  1206. //consoleSetCursor(Scr,row,col);
  1207. while (cb) {
  1208. UCHAR c;
  1209. UCHAR attr;
  1210. c = *buf++;
  1211. attr = *buf++;
  1212. //consoleSetAttribute(Scr,attr);
  1213. //consoleWrite(Scr,&c,1);
  1214. consoleWriteLine( Scr, &c, 1, row, cl, attr, FALSE );
  1215. cl++;
  1216. cb -= 2;
  1217. }
  1218. consoleShowScreen(Scr);
  1219. return 0;
  1220. }
  1221. USHORT WrtLineAttr ( PBYTE pText,
  1222. lineattr *rgAttr,
  1223. int cb,
  1224. int row,
  1225. int col
  1226. ) {
  1227. lineattr *Attr = rgAttr;
  1228. char *p = pText;
  1229. int l = cb;
  1230. int len;
  1231. consoleSetCursor(Scr, row, col );
  1232. while (cb > 0) {
  1233. if ( Attr->cb == 0xFFFF || Attr->attr == 0xFFFF ) {
  1234. len = cb;
  1235. } else {
  1236. len = Attr->cb;
  1237. }
  1238. outtextat (p, row, col, mpAttr[Attr->attr] );
  1239. col += len;
  1240. p += len;
  1241. cb -= len;
  1242. Attr++;
  1243. }
  1244. return (USHORT)l;
  1245. }
  1246. USHORT WrtCharStrAtt (PBYTE pText, int cb, int row, int col, PBYTE pcolor) {
  1247. //consoleSetCursor(Scr,row,col);
  1248. //consoleSetAttribute(Scr,*pcolor);
  1249. //consoleWrite( Scr,pText, cb );
  1250. consoleWriteLine( Scr, pText, cb, row, col, *pcolor, FALSE );
  1251. consoleShowScreen(Scr);
  1252. return 0;
  1253. }
  1254. /**********************************************************************
  1255. *
  1256. * LoadTheDll
  1257. *
  1258. * Loads the help engine dll (mshelp.dll) and initializes the
  1259. * pointers to the dll's entry points.
  1260. *
  1261. **********************************************************************/
  1262. void
  1263. LoadTheDll (
  1264. void) {
  1265. #if defined (OS2)
  1266. USHORT rc;
  1267. CHAR szFullName[256];
  1268. CHAR szErrorName[256];
  1269. USHORT i;
  1270. strcpy(szFullName, HELPDLL_BASE);
  1271. strcpy(szErrorName, HELPDLL_NAME);
  1272. ASSERTDOS(rc = DosLoadModule(szErrorName,
  1273. 256,
  1274. szFullName,
  1275. &hModule));
  1276. for (i=0; i<LASTENTRYPOINT; i++) {
  1277. ASSERTDOS (rc = DosQueryProcAddr(hModule,
  1278. 0L,
  1279. szEntryName[i],
  1280. (PFN*)&(pEntry[i])));
  1281. }
  1282. #else
  1283. #if defined (HELP_HACK)
  1284. //pEntry[0] = (PHF)HelpcLines;
  1285. //pEntry[1] = (PHF)HelpClose;
  1286. //pEntry[2] = (PHF)HelpCtl;
  1287. //pEntry[3] = (PHF)HelpDecomp;
  1288. //pEntry[4] = (PHF)HelpGetCells;
  1289. //pEntry[5] = (PHF)HelpGetInfo;
  1290. //pEntry[6] = (PHF)HelpGetLine;
  1291. //pEntry[7] = (PHF)HelpGetLineAttr;
  1292. //pEntry[8] = (PHF)HelpHlNext;
  1293. //pEntry[9] = (PHF)HelpLook;
  1294. //pEntry[10] = (PHF)HelpNc;
  1295. //pEntry[11] = (PHF)HelpNcBack;
  1296. //pEntry[12] = (PHF)HelpNcCb;
  1297. //pEntry[13] = (PHF)HelpNcCmp;
  1298. //pEntry[14] = (PHF)HelpNcNext;
  1299. //pEntry[15] = (PHF)HelpNcPrev;
  1300. //pEntry[16] = (PHF)HelpNcRecord;
  1301. //pEntry[17] = (PHF)HelpNcUniq;
  1302. //pEntry[18] = (PHF)HelpOpen;
  1303. //pEntry[19] = (PHF)HelpShrink;
  1304. //pEntry[20] = (PHF)HelpSzContext;
  1305. //pEntry[21] = (PHF)HelpXRef;
  1306. //pEntry[22] = (PHF)LoadFdb;
  1307. //pEntry[23] = (PHF)LoadPortion;
  1308. #else
  1309. USHORT i;
  1310. hModule = LoadLibrary(HELPDLL_NAME);
  1311. for (i=0; i<LASTENTRYPOINT; i++) {
  1312. pEntry[i] = (PHF)GetProcAddress(hModule, (LPSTR)szEntryName[i]);
  1313. }
  1314. #endif
  1315. #endif
  1316. }