2
0

HelpCache.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: HelpCache.c /main/4 1995/11/08 09:17:54 rswiston $ */
  24. /*************************************<+>*************************************
  25. *****************************************************************************
  26. **
  27. ** File: HelpCache.c
  28. **
  29. ** Project: dthelpdemo demo program
  30. **
  31. ** Description: Contains the Help Callbacks and Utility functions for our
  32. ** demo tool dthelpdemo.
  33. **
  34. **
  35. ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
  36. ** Hewlett-Packard Company
  37. ** (c) Copyright 1993, 1994 International Business Machines Corp.
  38. ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  39. ** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  40. ** Novell, Inc.
  41. **
  42. ****************************************************************************
  43. ************************************<+>*************************************/
  44. /* System Include Files */
  45. #include <stdlib.h>
  46. #include <stdio.h>
  47. #include <Xm/Xm.h>
  48. #include <Xm/XmP.h>
  49. #include <Dt/Help.h>
  50. #include <Dt/HelpDialog.h>
  51. #include <Dt/HelpQuickD.h>
  52. /* Local Includes */
  53. #include "Main.h"
  54. #include "HelpCacheI.h"
  55. #include "HourGlassI.h"
  56. /******** Static Function Declarations ********/
  57. static void CloseHelpCB (
  58. Widget w,
  59. XtPointer clientData,
  60. XtPointer callData);
  61. static Boolean GetFromCache(
  62. Widget parent,
  63. CacheListStruct **pCurrentNode);
  64. /* Global Main Help Dialog Widget */
  65. static Widget helpMain=NULL;
  66. static Widget versionMain=NULL;
  67. /*****************************************************************************
  68. * Function: void HelpMapCB()
  69. *
  70. *
  71. *
  72. * Parameters: clientData is the widget in reference to
  73. * which widget w is placed
  74. *
  75. * Return Value: Void.
  76. *
  77. * Purpose: Determins where a new child dialog should be mapped in
  78. * relation to its parent.
  79. *
  80. * Algorithm: 1. attempt left or right placement with no overlap
  81. * 2. if fails, attempt up or down placement with no overlap
  82. * 3. if fails, determines location with least
  83. * amount of overlap, and places there.
  84. *
  85. *****************************************************************************/
  86. XtCallbackProc HelpMapCB(
  87. Widget w,
  88. XtPointer clientData,
  89. XtPointer callData)
  90. {
  91. Arg args[2];
  92. Widget parent;
  93. Position centeredY, bestX, bestY, pX, pY;
  94. Dimension pHeight, myHeight, pWidth, myWidth;
  95. Dimension maxX, maxY;
  96. int rhsX, lhsX, topY, botY; /* needs to be int, not Dimension */
  97. Display * display;
  98. Screen * screen;
  99. int screenNumber;
  100. parent = (Widget)clientData;
  101. display = XtDisplay(w);
  102. screen = XtScreen(w);
  103. screenNumber = XScreenNumberOfScreen(screen);
  104. pX = XtX(parent);
  105. pY = XtY(parent);
  106. if (pX < 0) pX = 0;
  107. if (pY < 0) pY = 0;
  108. pHeight = XtHeight(parent);
  109. pWidth = XtWidth(parent);
  110. myHeight = XtHeight(w);
  111. myWidth = XtWidth(w);
  112. maxX = XDisplayWidth(display,screenNumber);
  113. maxY = XDisplayHeight(display,screenNumber);
  114. /* algorithm
  115. * 1. attempt left or right placement with no overlap
  116. * 2. if fails, attempt up or down placement with no overlap
  117. * 3. if fails, places on the right in the middle
  118. */
  119. /* first try left right placement */
  120. bestY = pY + pHeight/2 - myHeight/2;
  121. centeredY = bestY;
  122. rhsX = pX + pWidth;
  123. lhsX = pX - myWidth - 8; /* 8: account for border */
  124. if ( (rhsX + myWidth) < maxX ) bestX = rhsX;
  125. else if ( lhsX > 0 ) bestX = lhsX;
  126. else
  127. {
  128. /* then try up down placement */
  129. bestX = pX + pWidth/2 - myWidth/2;
  130. botY = pY + pHeight;
  131. topY = pY - myHeight - 44; /* 44: account for menu border */
  132. if ( (botY + myWidth) < maxY ) bestY = botY;
  133. else if ( topY > 0 ) bestY = topY;
  134. else
  135. {
  136. /* otherwise, center vertically and on the right */
  137. bestX = maxX - myWidth;
  138. bestY = centeredY;
  139. }
  140. }
  141. XtSetArg(args[0], XmNx, bestX);
  142. XtSetArg(args[1], XmNy, bestY);
  143. XtSetValues(w, args, 2);
  144. return((XtCallbackProc) NULL);
  145. }
  146. /****************************************************************************
  147. * Function: CloseHelpCB(
  148. * Widget w,
  149. * XtPointer clientData,
  150. * XtPointer callData
  151. *
  152. * Parameters:
  153. *
  154. * Return Value: Void.
  155. *
  156. * Purpose: Process close requests on all Help Dialog widgets
  157. * created and managed by this application.
  158. *
  159. ***************************************************************************/
  160. static void CloseHelpCB (
  161. Widget w,
  162. XtPointer clientData,
  163. XtPointer callData)
  164. {
  165. Widget helpDialog = (Widget) clientData;
  166. CacheListStruct *pTemp;
  167. pTemp = pCacheListHead;
  168. /* Search our Cache List for the closed help dialog */
  169. while ((pTemp != NULL) && (pTemp->helpDialog != helpDialog))
  170. pTemp = pTemp->pNext;
  171. if (pTemp == NULL)
  172. /* ERROR */
  173. printf("We did not find our help dialog widget in the cache list??? /n");
  174. /* Un Map and Clean up the help widget */
  175. XtUnmanageChild(helpDialog);
  176. pTemp->inUseFlag = FALSE;
  177. }
  178. /****************************************************************************
  179. * Function: CloseMainCB(
  180. * Widget w,
  181. * XtPointer clientData,
  182. * XtPointer callData
  183. *
  184. * Parameters:
  185. *
  186. * Return Value: Void.
  187. *
  188. * Purpose: Process close requests on our main help dialog.
  189. *
  190. ***************************************************************************/
  191. static void CloseMainCB (
  192. Widget w,
  193. XtPointer clientData,
  194. XtPointer callData)
  195. {
  196. Widget currentDialog = (Widget) clientData;
  197. /* Un Map and Clean up the help widget */
  198. XtUnmanageChild(currentDialog);
  199. }
  200. /****************************************************************************
  201. * Function: void ProcessLinkCB(
  202. * Widget w,
  203. * XtPointer clientData,
  204. * XtPointer callData
  205. *
  206. * Parameters:
  207. *
  208. * Return Value: Void.
  209. *
  210. * Purpose: Process JUMP-NEW and APP-LINK hypertext requests in a
  211. * given Help Dialog Window.
  212. *
  213. * This is the callback used for the DtNhyperLinkCallback
  214. * on each of the help dialog widges created.
  215. *
  216. ****************************************************************************/
  217. void ProcessLinkCB (
  218. Widget w,
  219. XtPointer clientData,
  220. XtPointer callData)
  221. {
  222. Arg args[20];
  223. int n;
  224. Position xPos, yPos;
  225. int appLinkNum=0;
  226. int count;
  227. static Dimension width=0;
  228. static Dimension height=0;
  229. static Boolean goBigger=TRUE;
  230. DtHelpDialogCallbackStruct * hyperData =
  231. (DtHelpDialogCallbackStruct *) callData;
  232. switch (hyperData->hyperType)
  233. {
  234. case DtHELP_LINK_JUMP_NEW:
  235. DisplayTopic (XtParent(w), hyperData->helpVolume,
  236. hyperData->locationId);
  237. break;
  238. case DtHELP_LINK_MAN_PAGE:
  239. /* Create and display the requested man page */
  240. DisplayMan(XtParent(w), hyperData->specification);
  241. break;
  242. case DtHELP_LINK_TEXT_FILE:
  243. /* Create a quick help dialog and display the text file in it */
  244. break;
  245. case DtHELP_LINK_APP_DEFINE:
  246. appLinkNum = atoi(hyperData->specification);
  247. if (appLinkNum == 100) /* Move the window */
  248. {
  249. /* First Place the window in the upper left */
  250. n = 0;
  251. XtSetArg(args[n], XmNx, 0); ++n;
  252. XtSetArg(args[n], XmNy, 0); ++n;
  253. XtSetValues(topLevel, args, n);
  254. /* Now move it down to the center of the display */
  255. for (count = 1;count < 500; count= count+5)
  256. {
  257. n = 0;
  258. XtSetArg(args[n], XmNx, count); ++n;
  259. XtSetArg(args[n], XmNy, count); ++n;
  260. XtSetValues(topLevel, args, n);
  261. XmUpdateDisplay(topLevel);
  262. }
  263. }
  264. if (appLinkNum == 101) /* Resize the window */
  265. {
  266. if (width == 0)
  267. {
  268. /* Get the current dialog size */
  269. n =0;
  270. XtSetArg (args[n], XmNheight, &height); n++;
  271. XtSetArg (args[n], XmNwidth, &width); n++;
  272. XtGetValues(topLevel, args, n);
  273. }
  274. if (goBigger)
  275. {
  276. n =0;
  277. XtSetArg (args[n], XmNheight, height+100); n++;
  278. XtSetArg (args[n], XmNwidth, width+50); n++;
  279. XtSetValues(topLevel, args, n);
  280. goBigger = FALSE;
  281. }
  282. else
  283. {
  284. /* Go smaller */
  285. n =0;
  286. XtSetArg (args[n], XmNheight, height); n++;
  287. XtSetArg (args[n], XmNwidth, width); n++;
  288. XtSetValues(topLevel, args, n);
  289. goBigger = TRUE;
  290. }
  291. }
  292. if (appLinkNum == 102)
  293. {
  294. }
  295. if (appLinkNum == 103)
  296. {
  297. }
  298. break;
  299. default: /* Catches any other applicaion definded link types */
  300. printf("We some how got a bogus hyptertext link type/n");
  301. } /* End Switch Statement */
  302. }
  303. /****************************************************************************
  304. * Function: void DisplayMan()
  305. *
  306. * Parameters:
  307. *
  308. * Return Value: Void.
  309. *
  310. * Purpose: Displays a UNIX man page in a quick help dialog.
  311. *
  312. ****************************************************************************/
  313. void DisplayMan(
  314. Widget parent,
  315. char *man)
  316. {
  317. Arg args[20];
  318. int n;
  319. Widget helpWidget;
  320. char *title;
  321. XmUpdateDisplay(topLevel);
  322. if (manWidget == NULL)
  323. {
  324. /* Create the QuickHelpDialog widget for help on help */
  325. title = XtNewString(man);
  326. n =0;
  327. XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
  328. XtSetArg (args[n], XmNtitle, title); n++;
  329. XtSetArg (args[n], DtNhelpType,DtHELP_TYPE_MAN_PAGE); n++;
  330. XtSetArg (args[n], DtNmanPage, man); n++;
  331. manWidget = DtCreateHelpQuickDialog(topLevel,"manBox", args, n);
  332. XtFree((char*) title);
  333. XtAddCallback(manWidget, DtNcloseCallback,
  334. CloseMainCB, (XtPointer) manWidget);
  335. /* Add the popup position callback to our man dialog */
  336. XtAddCallback (XtParent(manWidget), XmNpopupCallback,
  337. (XtCallbackProc)HelpMapCB,
  338. (XtPointer)topLevel);
  339. /* We do not want a help button for now so we unmap it */
  340. helpWidget = DtHelpQuickDialogGetChild (manWidget,
  341. DtHELP_QUICK_HELP_BUTTON);
  342. XtUnmanageChild (helpWidget);
  343. XtManageChild(manWidget);
  344. }
  345. else
  346. {
  347. _DtHelpTurnOnHourGlass(manWidget);
  348. /* We already have a quick help dialog so re-use it */
  349. n = 0;
  350. XtSetArg (args[n], DtNhelpType,DtHELP_TYPE_MAN_PAGE); n++;
  351. XtSetArg (args[n], DtNmanPage, man); n++;
  352. XtSetValues(manWidget, args, n);
  353. title = XtNewString(man);
  354. n = 0;
  355. XtSetArg (args[n], XmNtitle, title); n++;
  356. XtSetValues(XtParent(manWidget), args, n);
  357. XtFree((char*) title);
  358. XtManageChild(manWidget);
  359. XtMapWidget(XtParent(manWidget));
  360. XRaiseWindow(XtDisplay(parent), XtWindow(XtParent(manWidget)));
  361. _DtHelpTurnOffHourGlass(manWidget);
  362. }
  363. }
  364. /****************************************************************************
  365. * Function: void DisplayTopic(
  366. * Widget parent,
  367. * char *helpVolume,
  368. * char *locationId)
  369. *
  370. * Parameters:
  371. *
  372. * Return Value: Void.
  373. *
  374. * Purpose: Creats and displays a new help dialog w/the requested help
  375. * volume and topic.
  376. *
  377. ****************************************************************************/
  378. void DisplayTopic(
  379. Widget parent,
  380. char *helpVolume,
  381. char *locationId)
  382. {
  383. Arg args[10];
  384. int n;
  385. CacheListStruct *pCurrentNode = NULL;
  386. Boolean cachedNode = FALSE;
  387. /* Get a inuse node if we have one or a Cached one */
  388. cachedNode = GetFromCache(parent, &pCurrentNode);
  389. /* If we got a free one from the Cache, use it */
  390. /* Set Values on current free one, then map it */
  391. if (cachedNode)
  392. {
  393. n = 0;
  394. XtSetArg (args[n], XmNtitle, "HelpDemo Help"); n++;
  395. if (helpVolume != NULL)
  396. {
  397. XtSetArg (args[n],DtNhelpVolume,helpVolume); n++;
  398. }
  399. XtSetArg (args[n], DtNlocationId,locationId); n++;
  400. XtSetValues(pCurrentNode->helpDialog, args, n);
  401. XtManageChild(pCurrentNode->helpDialog);
  402. XtMapWidget(XtParent(pCurrentNode->helpDialog));
  403. }
  404. else
  405. {
  406. while (!XtIsSubclass(parent, applicationShellWidgetClass))
  407. parent = XtParent(parent);
  408. /* Build a new one in our cached list */
  409. n = 0;
  410. XtSetArg (args[n], XmNtitle, "Helpdemo Help"); n++;
  411. if (helpVolume != NULL)
  412. {
  413. XtSetArg (args[n],DtNhelpVolume,helpVolume); n++;
  414. }
  415. XtSetArg (args[n], DtNlocationId,locationId); n++;
  416. pCurrentNode->helpDialog =
  417. DtCreateHelpDialog(parent, "helpWidget", args, n);
  418. XtAddCallback(pCurrentNode->helpDialog, DtNhyperLinkCallback,
  419. ProcessLinkCB, NULL);
  420. XtAddCallback(pCurrentNode->helpDialog, DtNcloseCallback,
  421. CloseHelpCB, (XtPointer) pCurrentNode->helpDialog);
  422. XtManageChild(pCurrentNode->helpDialog);
  423. XtMapWidget(XtParent(pCurrentNode->helpDialog));
  424. }
  425. }
  426. /****************************************************************************
  427. * Function: void DisplayMain(
  428. * Widget parent,
  429. * char *helpVolume,
  430. * char *locationId)
  431. *
  432. * Parameters:
  433. *
  434. * Return Value: Void.
  435. *
  436. * Purpose: Displays help for helpdemo in the one helpDialog window
  437. * created for the applicaiton.
  438. *
  439. ****************************************************************************/
  440. void DisplayMain (
  441. Widget parent,
  442. char *helpVolume,
  443. char *locationId)
  444. {
  445. Arg args[10];
  446. int n;
  447. if (helpMain != NULL)
  448. {
  449. n = 0;
  450. XtSetArg (args[n], XmNtitle, "hemodemo Help"); n++;
  451. if (helpVolume != NULL)
  452. {
  453. XtSetArg (args[n],DtNhelpVolume,helpVolume); n++;
  454. }
  455. XtSetArg (args[n], DtNlocationId,locationId); n++;
  456. XtSetValues(helpMain, args, n);
  457. XtManageChild(helpMain);
  458. }
  459. else
  460. {
  461. while (!XtIsSubclass(parent, applicationShellWidgetClass))
  462. parent = XtParent(parent);
  463. /* Build a new one in our cached list */
  464. n = 0;
  465. XtSetArg (args[n], XmNtitle, "Helpdemo Help"); n++;
  466. if (helpVolume != NULL)
  467. {
  468. XtSetArg (args[n],DtNhelpVolume,helpVolume); n++;
  469. }
  470. XtSetArg (args[n], DtNlocationId,locationId); n++;
  471. helpMain = DtCreateHelpDialog(parent, "helpWidget", args, n);
  472. XtAddCallback(helpMain, DtNhyperLinkCallback,
  473. ProcessLinkCB, NULL);
  474. XtAddCallback(helpMain, DtNcloseCallback,
  475. CloseMainCB, (XtPointer) helpMain);
  476. /* Add the popup position callback to our main help dialog */
  477. XtAddCallback (XtParent(helpMain), XmNpopupCallback,
  478. (XtCallbackProc)HelpMapCB,
  479. (XtPointer)parent);
  480. XtManageChild(helpMain);
  481. }
  482. }
  483. /****************************************************************************
  484. * Function: void DisplayVersion(
  485. * Widget parent,
  486. * char *helpVolume,
  487. * char *locationId)
  488. *
  489. * Parameters:
  490. *
  491. * Return Value: Void.
  492. *
  493. * Purpose: Displays the version dialog for the helpdemo program.
  494. *
  495. ****************************************************************************/
  496. void DisplayVersion (
  497. Widget parent,
  498. char *helpVolume,
  499. char *locationId)
  500. {
  501. Arg args[10];
  502. int n;
  503. Widget printWidget;
  504. Widget helpWidget;
  505. Widget backWidget;
  506. if (versionMain != NULL)
  507. {
  508. n = 0;
  509. XtSetArg (args[n], XmNtitle, "Helpdemo Version Dialog"); n++;
  510. if (helpVolume != NULL)
  511. {
  512. XtSetArg (args[n],DtNhelpVolume,helpVolume); n++;
  513. }
  514. XtSetArg (args[n], DtNlocationId,locationId); n++;
  515. XtSetValues(versionMain, args, n);
  516. XtManageChild(versionMain);
  517. }
  518. else
  519. {
  520. while (!XtIsSubclass(parent, applicationShellWidgetClass))
  521. parent = XtParent(parent);
  522. /* Build a new one in our cached list */
  523. n = 0;
  524. XtSetArg (args[n], XmNtitle, "Helpdemo Version Dialog"); n++;
  525. if (helpVolume != NULL)
  526. {
  527. XtSetArg (args[n],DtNhelpVolume,helpVolume); n++;
  528. }
  529. XtSetArg (args[n], DtNlocationId,locationId); n++;
  530. XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
  531. versionMain = DtCreateHelpQuickDialog(parent,"versionWidget",args,n);
  532. XtAddCallback(versionMain, DtNcloseCallback,
  533. CloseMainCB, (XtPointer) versionMain);
  534. /* We do not want a print button for now so we unmap it */
  535. printWidget = DtHelpQuickDialogGetChild (versionMain,
  536. DtHELP_QUICK_PRINT_BUTTON);
  537. XtUnmanageChild (printWidget);
  538. /* We do not want a help button for now so we unmap it */
  539. helpWidget = DtHelpQuickDialogGetChild (versionMain,
  540. DtHELP_QUICK_HELP_BUTTON);
  541. XtUnmanageChild (helpWidget);
  542. backWidget = DtHelpQuickDialogGetChild (versionMain,
  543. DtHELP_QUICK_BACK_BUTTON);
  544. XtUnmanageChild (backWidget);
  545. XtManageChild(versionMain);
  546. }
  547. }
  548. /****************************************************************************
  549. * Function: static CacheListStruct GetFromCache(
  550. * Widget parent);
  551. *
  552. * Parameters:
  553. *
  554. * Return Value: Void.
  555. *
  556. * Purpose: Gets a free help node form our cache list. If none are
  557. * free, it will return fallse and the calling routine will
  558. * create a new help dialog widget.
  559. *
  560. ****************************************************************************/
  561. static Boolean GetFromCache(
  562. Widget parent,
  563. CacheListStruct **pCurrentNode)
  564. {
  565. CacheListStruct *pTemp;
  566. if (pCacheListHead == NULL)
  567. {
  568. /* We have a new list so lets create one and pass it back */
  569. pCacheListHead =
  570. (CacheListStruct *) XtMalloc((sizeof(CacheListStruct)));
  571. /* Assign the default values to our node */
  572. pCacheListHead->helpDialog = NULL;
  573. pCacheListHead->inUseFlag = TRUE;
  574. pCacheListHead->pNext = NULL;
  575. pCacheListHead->pPrevious = NULL;
  576. /* Assign our tale pointer */
  577. pCacheListTale = pCacheListHead;
  578. /* Make sure or totalNodes counter is correct, e.g. force it to 1 */
  579. totalCacheNodes = 1;
  580. /* Return our head pointer because it's our first and only node */
  581. *pCurrentNode = pCacheListHead;
  582. return (FALSE);
  583. }
  584. else
  585. {
  586. /* We have need for an in-use help dialog or a new one, so look */
  587. pTemp = pCacheListHead;
  588. while (pTemp != NULL)
  589. {
  590. if (pTemp->inUseFlag == FALSE)
  591. {
  592. pTemp->inUseFlag = TRUE;
  593. *pCurrentNode = pTemp;
  594. return (TRUE);
  595. }
  596. else
  597. pTemp = pTemp->pNext;
  598. }
  599. /* If we did not find a free nod then we must add a new one to the
  600. * top of the list, and return it.
  601. */
  602. pTemp = (CacheListStruct *) XtMalloc((sizeof(CacheListStruct)));
  603. /* Assign the default values to our node */
  604. pTemp->helpDialog = NULL;
  605. pTemp->inUseFlag = TRUE;
  606. pTemp->pNext = pCacheListHead;
  607. pTemp->pPrevious = NULL;
  608. pCacheListHead->pPrevious = pTemp;
  609. /* Re-Assign our head pointer to point to the new head of the list */
  610. pCacheListHead = pTemp;
  611. /* Make sure or totalNodes counter is correct, e.g. force it to 1 */
  612. totalCacheNodes = totalCacheNodes + 1;
  613. /* Return our head pointer because it's our new node */
  614. *pCurrentNode = pCacheListHead;
  615. return (FALSE);
  616. }
  617. }