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.

105 lines
2.5 KiB

  1. /*** hlback.c - help library historical back-trace routines & data
  2. *
  3. * Copyright <C> 1988, Microsoft Corporation
  4. *
  5. * Purpose:
  6. *
  7. * Revision History:
  8. *
  9. * 02-Aug-1988 ln Correct HelpNcBack
  10. * 19-May-1988 LN Split off from help.c
  11. *
  12. *************************************************************************/
  13. #include <assert.h> /* debugging assertions */
  14. #include <stdio.h>
  15. #if defined (OS2)
  16. #else
  17. #include <windows.h>
  18. #endif
  19. #include "help.h" /* global (help & user) decl */
  20. #include "helpfile.h" /* help file format definition */
  21. #include "helpsys.h" /* internal (help sys only) decl*/
  22. /*************************************************************************
  23. **
  24. ** cBack, iBackLast, rgncBack
  25. ** System context back-trace list.
  26. **
  27. ** cBack - Number of entries in back-trace list
  28. ** iBackLast - Index to last back trace entry
  29. ** rgncBack - Array of back-trace entries
  30. */
  31. extern ushort cBack; /* Number of Back-List entries */
  32. static ushort iBackLast; /* Back-List Last entry index */
  33. static nc rgncBack[MAXBACK+1]; /* Back-List */
  34. /************************************************************************
  35. **
  36. ** HelpNcRecord - Remember context for back-trace
  37. **
  38. ** Purpose:
  39. ** records a context number for back-trace.
  40. **
  41. ** Entry:
  42. ** ncCur = context number to record.
  43. **
  44. ** Exit:
  45. ** none
  46. **
  47. ** Exceptions:
  48. ** none
  49. */
  50. void far pascal LOADDS HelpNcRecord(ncCur)
  51. nc ncCur;
  52. {
  53. ushort *pcBack = &cBack;
  54. if ((ncCur.mh || ncCur.cn) &&
  55. ((ncCur.mh != rgncBack[iBackLast].mh) ||
  56. (ncCur.cn != rgncBack[iBackLast].cn))) {
  57. iBackLast = (ushort)(((int)iBackLast + 1) % MAXBACK);
  58. rgncBack[iBackLast] = ncCur;
  59. if (*pcBack < MAXBACK)
  60. (*pcBack)++;
  61. }
  62. /* end HelpNcRecord */}
  63. /******************************************************************************
  64. **
  65. ** HelpNcBack - Return previously viewed context
  66. **
  67. ** Purpose:
  68. ** Returns the context number corresponding to the historically previously
  69. ** viewed topic.
  70. **
  71. ** Entry:
  72. ** None
  73. **
  74. ** Exit:
  75. ** Returns context number
  76. **
  77. ** Exceptions:
  78. ** Returns NULL on backup list exhuasted
  79. **
  80. ** Algorithm:
  81. **
  82. ** If backlist not empty
  83. ** context is last entry in back list
  84. ** remove last entry
  85. ** else
  86. ** return NULL
  87. */
  88. nc far pascal LOADDS HelpNcBack(void) {
  89. nc ncLast = {0,0}; /* return value */
  90. ushort *pcBack = &cBack;
  91. if (*pcBack) {
  92. ncLast = rgncBack[iBackLast];
  93. iBackLast = iBackLast == 0 ? (ushort)MAXBACK-1 : (ushort)iBackLast-1;
  94. (*pcBack)--;
  95. }
  96. return ncLast;
  97. /* end HelpNcBack */}