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.

879 lines
27 KiB

  1. #include <windows.h>
  2. #include <assert.h>
  3. #include <ctype.h>
  4. #include <malloc.h>
  5. #include <process.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <tchar.h>
  10. #include "windefs.h"
  11. #include "toklist.h"
  12. #include "restok.h"
  13. #include "resread.h"
  14. #include "showerrs.h"
  15. #define MAXLINE 1024
  16. #ifdef WIN32
  17. extern HINSTANCE hInst; // Instance of the main window
  18. #else
  19. extern HWND hInst; // Instance of the main window
  20. #endif
  21. extern HWND hListWnd;
  22. extern HWND hMainWnd;
  23. extern HCURSOR hHourGlass;
  24. extern int nUpdateMode;
  25. extern HWND hStatusWnd;
  26. extern UCHAR szDHW[];
  27. /**
  28. *
  29. *
  30. * Function:
  31. *
  32. * Returns:
  33. *
  34. * History:
  35. * 01/92, Implemented. TerryRu.
  36. *
  37. *
  38. **/
  39. int MatchToken(TOKEN tToken,
  40. TCHAR * szFindType,
  41. TCHAR *szFindText,
  42. WORD wStatus,
  43. WORD wStatusMask)
  44. {
  45. TCHAR szResIDStr[20];
  46. if (tToken.wType <= 16)
  47. {
  48. LoadString( hInst,
  49. IDS_RESOURCENAMES + tToken.wType,
  50. szResIDStr,
  51. TCHARSIN( sizeof(szResIDStr)));
  52. }
  53. else
  54. {
  55. #ifndef UNICODE
  56. _itoa(tToken.wType,szResIDStr, 10);
  57. #else
  58. CHAR szTemp[32];
  59. _itoa(tToken.wType, szTemp, 10);
  60. _MBSTOWCS( szResIDStr,
  61. szTemp,
  62. WCHARSIN( sizeof( szResIDStr)),
  63. ACHARSIN( lstrlenA(szTemp) + 1));
  64. #endif
  65. }
  66. // need to both check because checking szFindType[0]
  67. // when string is null cause exception
  68. if (szFindType && szFindType[0])
  69. {
  70. if (_tcsicmp((TCHAR *)szFindType, (TCHAR *)szResIDStr))
  71. {
  72. return FALSE;
  73. }
  74. }
  75. // this has case problems.
  76. // how do I work around this and work with extened characters?
  77. if ( szFindText && szFindText[0] )
  78. {
  79. if (!_tcsstr( (TCHAR *)tToken.szText, (TCHAR *)szFindText))
  80. {
  81. return FALSE;
  82. }
  83. }
  84. // if we made it to here,
  85. // all search criteria exept the status bits have matched.
  86. return (wStatus == (WORD) (wStatusMask & tToken.wReserved));
  87. }
  88. /**
  89. *
  90. *
  91. * Function: DoTokenSearch
  92. * BiDirection token search utility to find tokens.
  93. * Search is based on, the status field, token type, and token text.
  94. *
  95. * Paramaters:
  96. * *szFindType, type of token to search for.
  97. * *szFindText, token text to search for.
  98. * wStatus, status values to search for
  99. * wStatusMask, status mask to search with
  100. * fDirection, direction to search through tokens 0 = down, 1 = up
  101. *
  102. * Returns:
  103. * TRUE, token located and selected.
  104. * FALSE token not found.
  105. *
  106. * History:
  107. * 01/92, Implemented. TerryRu.
  108. * 02/92, mask parameter added SteveBl
  109. * 01/93 Added support for var length token text strings. MHotchin
  110. *
  111. **/
  112. int DoTokenSearch (TCHAR *szFindType,
  113. TCHAR *szFindText,
  114. WORD wStatus,
  115. WORD wStatusMask,
  116. BOOL fDirection,
  117. BOOL fSkipFirst)
  118. {
  119. UINT wLbCount; // number of tokens in list box
  120. LPTSTR lpstrToken;
  121. int wCurSelection; // current selected token.
  122. UINT wSaveSelection; // location in token list where the search began
  123. TOKEN tToken; // info of current token
  124. BOOL fWrapped = FALSE; // flag to indicate whether we wrapped during the search
  125. TCHAR *szBuffer;
  126. // get the number of tokens in the list
  127. wLbCount = (UINT)SendMessage( hListWnd,
  128. LB_GETCOUNT,
  129. (WPARAM)0,
  130. (LPARAM)0);
  131. // save the current in the token list
  132. wCurSelection = (UINT)SendMessage( hListWnd,
  133. LB_GETCURSEL,
  134. (WPARAM)0,
  135. (LPARAM)0);
  136. wSaveSelection = wCurSelection;
  137. // check for case where there is no current selection.
  138. if (wCurSelection == (UINT) -1)
  139. {
  140. wSaveSelection = wCurSelection = 0;
  141. }
  142. while (TRUE)
  143. {
  144. // get current token info in the tToken sturcture
  145. HGLOBAL hMem = (HGLOBAL)SendMessage( hListWnd,
  146. LB_GETITEMDATA,
  147. (WPARAM)wCurSelection,
  148. (LPARAM)0);
  149. lpstrToken = (LPTSTR)GlobalLock( hMem);
  150. if ( lpstrToken )
  151. {
  152. szBuffer = (TCHAR *) FALLOC( MEMSIZE( lstrlen( lpstrToken)+1));
  153. lstrcpy( szBuffer, lpstrToken);
  154. GlobalUnlock( hMem);
  155. ParseBufToTok(szBuffer, &tToken);
  156. RLFREE( szBuffer);
  157. // is it a match?
  158. if ( MatchToken( tToken,
  159. szFindType,
  160. szFindText,
  161. wStatus,
  162. wStatusMask)
  163. && ! fSkipFirst)
  164. {
  165. // yes, select and return TRUE
  166. RLFREE( tToken.szText);
  167. SendMessage( hListWnd,
  168. LB_SETCURSEL,
  169. (WPARAM)wCurSelection,
  170. (LPARAM)0);
  171. return (TRUE);
  172. }
  173. RLFREE( tToken.szText);
  174. }
  175. fSkipFirst = FALSE;
  176. // no, continue search
  177. if (fDirection)
  178. {
  179. // going upward during the search
  180. if (--wCurSelection < 0)
  181. {
  182. LPSTR pszFind = NULL;
  183. DWORD dwMsgLen = 0;
  184. // reached beginning of the tokens, do we want to wrap
  185. dwMsgLen = B_FormatMessage((FORMAT_MESSAGE_MAX_WIDTH_MASK & 78)
  186. | FORMAT_MESSAGE_IGNORE_INSERTS
  187. | FORMAT_MESSAGE_FROM_HMODULE,
  188. NULL,
  189. IDS_REACHEDBEGIN,
  190. szDHW,
  191. DHWSIZE,
  192. NULL);
  193. pszFind = szDHW + dwMsgLen + 2;
  194. B_FormatMessage( (FORMAT_MESSAGE_MAX_WIDTH_MASK & 78)
  195. | FORMAT_MESSAGE_IGNORE_INSERTS
  196. | FORMAT_MESSAGE_FROM_HMODULE,
  197. NULL,
  198. IDS_FINDTOKENS,
  199. pszFind,
  200. DHWSIZE - dwMsgLen - 2,
  201. NULL);
  202. if ( nUpdateMode == 0
  203. && wSaveSelection != wLbCount
  204. && !fWrapped
  205. && (MessageBoxA( hMainWnd,
  206. szDHW,
  207. pszFind,
  208. MB_ICONQUESTION | MB_YESNO) == IDYES) )
  209. {
  210. // yes, so wrap and reset counters
  211. fWrapped = TRUE;
  212. wCurSelection = wLbCount-1;
  213. wLbCount = wSaveSelection;
  214. }
  215. // no, so return FALSE
  216. else
  217. {
  218. break;
  219. }
  220. }
  221. }
  222. else
  223. {
  224. // going downward during the search
  225. if (++wCurSelection >= (int) wLbCount)
  226. {
  227. LPSTR pszFind = NULL;
  228. DWORD dwMsgLen = 0;
  229. // reached end of the tokens, do we want to wrap
  230. dwMsgLen = B_FormatMessage((FORMAT_MESSAGE_MAX_WIDTH_MASK & 78)
  231. | FORMAT_MESSAGE_IGNORE_INSERTS
  232. | FORMAT_MESSAGE_FROM_HMODULE,
  233. NULL,
  234. IDS_REACHEDEND,
  235. szDHW,
  236. DHWSIZE,
  237. NULL);
  238. pszFind = szDHW + dwMsgLen + 2;
  239. B_FormatMessage( (FORMAT_MESSAGE_MAX_WIDTH_MASK & 78)
  240. | FORMAT_MESSAGE_IGNORE_INSERTS
  241. | FORMAT_MESSAGE_FROM_HMODULE,
  242. NULL,
  243. IDS_FINDTOKENS,
  244. pszFind,
  245. DHWSIZE - dwMsgLen - 2,
  246. NULL);
  247. if ( nUpdateMode == 0
  248. && wSaveSelection != wLbCount
  249. && !fWrapped
  250. && (MessageBoxA( hMainWnd,
  251. szDHW,
  252. pszFind,
  253. MB_ICONQUESTION | MB_YESNO) == IDYES) )
  254. {
  255. // yes, so wrap and reset counters
  256. fWrapped = TRUE;
  257. wCurSelection = 0;
  258. wLbCount = wSaveSelection;
  259. }
  260. // no, so return FALSE
  261. else
  262. {
  263. break;
  264. }
  265. }
  266. }
  267. }
  268. return FALSE;
  269. }
  270. //.......................................................................
  271. int DoTokenSearchForRledit (TCHAR *szFindType,
  272. TCHAR *szFindText,
  273. WORD wStatus,
  274. WORD wStatusMask,
  275. BOOL fDirection,
  276. BOOL fSkipFirst)
  277. {
  278. UINT wLbCount; // number of tokens in list box
  279. LPTSTR lpstrToken;
  280. int wCurSelection; // current selected token.
  281. UINT wSaveSelection; // location in token list where the search began
  282. TOKEN tToken; // info of current token
  283. BOOL fWrapped = FALSE; // flag to indicate whether we wrapped during the search
  284. TCHAR *szBuffer;
  285. LPTOKDATA lpTokData;
  286. // get the number of tokens in the list
  287. wLbCount = (UINT)SendMessage( hListWnd,
  288. LB_GETCOUNT,
  289. (WPARAM)0,
  290. (LPARAM)0);
  291. // save the current in the token list
  292. wCurSelection = (UINT)SendMessage( hListWnd,
  293. LB_GETCURSEL,
  294. (WPARAM)0,
  295. (LPARAM)0);
  296. wSaveSelection = wCurSelection;
  297. // check for case where there is no current selection.
  298. if (wCurSelection == (UINT) -1)
  299. {
  300. wSaveSelection = wCurSelection = 0;
  301. }
  302. while (TRUE)
  303. {
  304. // get current token info in the tToken sturcture
  305. HGLOBAL hMem = (HGLOBAL)SendMessage( hListWnd,
  306. LB_GETITEMDATA,
  307. (WPARAM)wCurSelection,
  308. (LPARAM)0);
  309. //RLedit has different format data.
  310. lpTokData = (LPTOKDATA)GlobalLock( hMem );
  311. lpstrToken = (LPTSTR)GlobalLock( lpTokData->hToken );
  312. if ( lpstrToken )
  313. {
  314. szBuffer = (TCHAR *) FALLOC( MEMSIZE( lstrlen( lpstrToken)+1));
  315. lstrcpy( szBuffer, lpstrToken);
  316. GlobalUnlock( lpTokData->hToken );
  317. GlobalUnlock( hMem);
  318. ParseBufToTok(szBuffer, &tToken);
  319. RLFREE( szBuffer);
  320. // is it a match?
  321. if ( MatchToken( tToken,
  322. szFindType,
  323. szFindText,
  324. wStatus,
  325. wStatusMask)
  326. && ! fSkipFirst)
  327. {
  328. // yes, select and return TRUE
  329. RLFREE( tToken.szText);
  330. SendMessage( hListWnd,
  331. LB_SETCURSEL,
  332. (WPARAM)wCurSelection,
  333. (LPARAM)0);
  334. return (TRUE);
  335. }
  336. RLFREE( tToken.szText);
  337. }
  338. fSkipFirst = FALSE;
  339. // no, continue search
  340. if (fDirection)
  341. {
  342. // going upward during the search
  343. if (--wCurSelection < 0)
  344. {
  345. LPSTR pszFind = NULL;
  346. DWORD dwMsgLen = 0;
  347. // reached beginning of the tokens, do we want to wrap
  348. dwMsgLen = B_FormatMessage((FORMAT_MESSAGE_MAX_WIDTH_MASK & 78)
  349. | FORMAT_MESSAGE_IGNORE_INSERTS
  350. | FORMAT_MESSAGE_FROM_HMODULE,
  351. NULL,
  352. IDS_REACHEDBEGIN,
  353. szDHW,
  354. DHWSIZE,
  355. NULL);
  356. pszFind = szDHW + dwMsgLen + 2;
  357. B_FormatMessage( (FORMAT_MESSAGE_MAX_WIDTH_MASK & 78)
  358. | FORMAT_MESSAGE_IGNORE_INSERTS
  359. | FORMAT_MESSAGE_FROM_HMODULE,
  360. NULL,
  361. IDS_FINDTOKENS,
  362. pszFind,
  363. DHWSIZE - dwMsgLen - 2,
  364. NULL);
  365. if ( nUpdateMode == 0
  366. && wSaveSelection != wLbCount
  367. && !fWrapped
  368. && (MessageBoxA( hMainWnd,
  369. szDHW,
  370. pszFind,
  371. MB_ICONQUESTION | MB_YESNO) == IDYES) )
  372. {
  373. // yes, so wrap and reset counters
  374. fWrapped = TRUE;
  375. wCurSelection = wLbCount-1;
  376. wLbCount = wSaveSelection;
  377. }
  378. // no, so return FALSE
  379. else
  380. {
  381. break;
  382. }
  383. }
  384. }
  385. else
  386. {
  387. // going downward during the search
  388. if (++wCurSelection >= (int) wLbCount)
  389. {
  390. LPSTR pszFind = NULL;
  391. DWORD dwMsgLen = 0;
  392. // reached end of the tokens, do we want to wrap
  393. dwMsgLen = B_FormatMessage((FORMAT_MESSAGE_MAX_WIDTH_MASK & 78)
  394. | FORMAT_MESSAGE_IGNORE_INSERTS
  395. | FORMAT_MESSAGE_FROM_HMODULE,
  396. NULL,
  397. IDS_REACHEDEND,
  398. szDHW,
  399. DHWSIZE,
  400. NULL);
  401. pszFind = szDHW + dwMsgLen + 2;
  402. B_FormatMessage( (FORMAT_MESSAGE_MAX_WIDTH_MASK & 78)
  403. | FORMAT_MESSAGE_IGNORE_INSERTS
  404. | FORMAT_MESSAGE_FROM_HMODULE,
  405. NULL,
  406. IDS_FINDTOKENS,
  407. pszFind,
  408. DHWSIZE - dwMsgLen - 2,
  409. NULL);
  410. if ( nUpdateMode == 0
  411. && wSaveSelection != wLbCount
  412. && !fWrapped
  413. && (MessageBoxA( hMainWnd,
  414. szDHW,
  415. pszFind,
  416. MB_ICONQUESTION | MB_YESNO) == IDYES) )
  417. {
  418. // yes, so wrap and reset counters
  419. fWrapped = TRUE;
  420. wCurSelection = 0;
  421. wLbCount = wSaveSelection;
  422. }
  423. // no, so return FALSE
  424. else
  425. {
  426. break;
  427. }
  428. }
  429. }
  430. }
  431. return FALSE;
  432. }
  433. /**
  434. *
  435. *
  436. * Function:
  437. *
  438. *
  439. * Arguments:
  440. *
  441. * Returns:
  442. *
  443. * Errors Codes:
  444. *
  445. * History:
  446. *
  447. *
  448. **/
  449. #ifdef NO
  450. void FindAllDirtyTokens(void)
  451. {
  452. int wSaveSelection;
  453. extern int wIndex;
  454. LONG lListParam = 0L;
  455. // set listbox selection to begining of the token list
  456. wSaveSelection = SendMessage( hListWnd, LB_GETCURSEL, 0 , 0L);
  457. wIndex = 0;
  458. SendMessage(hListWnd, LB_SETCURSEL, wIndex, 0L);
  459. while (DoTokenSearch (NULL, NULL, ST_TRANSLATED | ST_DIRTY , NULL))
  460. {
  461. // go into edit mode
  462. wIndex = (UINT) SendMessage(hListWnd, LB_GETCURSEL, 0 , 0L);
  463. lListParam = MAKELONG(NULL, LBN_DBLCLK);
  464. SendMessage(hMainWnd, WM_COMMAND, IDC_LIST, lListParam);
  465. // move selection to next token
  466. wIndex++;
  467. SendMessage(hListWnd, LB_SETCURSEL, wIndex, 0L);
  468. }
  469. wIndex = wSaveSelection;
  470. SendMessage(hListWnd, LB_SETCURSEL, wIndex, 0L);
  471. }
  472. #endif
  473. /**
  474. *
  475. *
  476. * Function:
  477. *
  478. *
  479. * Arguments:
  480. *
  481. * Returns:
  482. *
  483. * Errors Codes:
  484. *
  485. * History:
  486. *
  487. *
  488. **/
  489. TCHAR FAR *FindDeltaToken(TOKEN tToken,
  490. TOKENDELTAINFO FAR *pTokenDeltaInfo,
  491. UINT wStatus)
  492. {
  493. TOKENDELTAINFO FAR *ptTokenDeltaInfo;
  494. int found;
  495. ptTokenDeltaInfo = pTokenDeltaInfo;
  496. while (ptTokenDeltaInfo)
  497. {
  498. found = ((tToken.wType == ptTokenDeltaInfo->DeltaToken.wType)
  499. && (tToken.wName == ptTokenDeltaInfo->DeltaToken.wName)
  500. && (tToken.wID == ptTokenDeltaInfo->DeltaToken.wID)
  501. && (tToken.wFlag == ptTokenDeltaInfo->DeltaToken.wFlag)
  502. && (wStatus == (UINT)ptTokenDeltaInfo->DeltaToken.wReserved)
  503. #ifdef UNICODE
  504. && !_tcscmp((TCHAR FAR *)tToken.szName,
  505. (TCHAR *)ptTokenDeltaInfo->DeltaToken.szName)
  506. #else
  507. // !lstrcmp((TCHAR FAR *)tToken.szName,
  508. // (TCHAR *)ptTokenDeltaInfo->DeltaToken.szName)
  509. && CompareStringW( MAKELCID( gMstr.wLanguageID, SORT_DEFAULT),
  510. SORT_STRINGSORT,
  511. tToken.szName,
  512. -1,
  513. ptTokenDeltaInfo->DeltaToken.szName,
  514. -1) == 2
  515. #endif
  516. );
  517. if (found)
  518. {
  519. return ((TCHAR FAR *)ptTokenDeltaInfo->DeltaToken.szText);
  520. }
  521. ptTokenDeltaInfo = ptTokenDeltaInfo->pNextTokenDelta;
  522. }
  523. // token not found in token delta info
  524. return NULL;
  525. }
  526. /**
  527. *
  528. *
  529. * Function:
  530. *
  531. *
  532. * Arguments:
  533. *
  534. * Returns:
  535. *
  536. * Errors Codes:
  537. *
  538. * History:
  539. *
  540. *
  541. **/
  542. TOKENDELTAINFO FAR *UpdateTokenDeltaInfo(TOKEN *pDeltaToken)
  543. {
  544. TOKENDELTAINFO FAR *pTokenDeltaInfo = NULL;
  545. int cTextLen;
  546. if ( pDeltaToken )
  547. {
  548. pTokenDeltaInfo = (TOKENDELTAINFO FAR *)FALLOC( sizeof( TOKENDELTAINFO));
  549. if ( pTokenDeltaInfo )
  550. {
  551. memcpy( (void *)&(pTokenDeltaInfo->DeltaToken),
  552. (void *)pDeltaToken,
  553. sizeof( TOKEN));
  554. cTextLen = lstrlen( pDeltaToken->szText) + 1;
  555. pTokenDeltaInfo->DeltaToken.szText =
  556. (TCHAR *)FALLOC( MEMSIZE( cTextLen));
  557. memcpy( (void *)pTokenDeltaInfo->DeltaToken.szText,
  558. (void *)pDeltaToken->szText,
  559. MEMSIZE( cTextLen));
  560. pTokenDeltaInfo->pNextTokenDelta = NULL;
  561. }
  562. }
  563. return(pTokenDeltaInfo);
  564. }
  565. /**
  566. *
  567. *
  568. * Function:
  569. *
  570. *
  571. * Arguments:
  572. *
  573. * Returns:
  574. *
  575. * Errors Codes:
  576. *
  577. * History:
  578. * 02/93 - changed to use GetToken, rather that reading directly
  579. * from the file. This provides support for long token
  580. * text. MHotchin.
  581. *
  582. **/
  583. TOKENDELTAINFO FAR *InsertTokMtkList(FILE * fpTokFile, FILE *fpMtkFile )
  584. {
  585. int rcFileCode;
  586. TOKENDELTAINFO FAR * ptTokenDeltaInfo, FAR * pTokenDeltaInfo = NULL;
  587. TOKEN tToken;
  588. UINT wcChars = 0;
  589. HANDLE hTokData;
  590. LPTSTR lpstrToken;
  591. LPSTR lpstrDmy=0;
  592. LPTOKDATA lpstrTokData=0;
  593. rewind(fpTokFile);
  594. rewind( fpMtkFile );
  595. //only make Dmy buffer
  596. lpstrDmy = (LPSTR)FALLOC( MEMSIZE(MAXLINE) );
  597. while ((rcFileCode = GetToken(fpTokFile, &tToken)) >= 0)
  598. {
  599. if (rcFileCode == 0)
  600. {
  601. //For fast moving, save Mtk position
  602. //Create Data
  603. hTokData = GlobalAlloc( GMEM_MOVEABLE, sizeof(TOKDATA) );
  604. if( !hTokData ){
  605. RLFREE(tToken.szText);
  606. RLFREE( lpstrDmy );
  607. QuitA( IDS_ENGERR_16, (LPSTR)IDS_ENGERR_11, NULL);
  608. }
  609. lpstrTokData = (LPTOKDATA)GlobalLock( hTokData );
  610. //MtkFilePointer get
  611. if( (lpstrTokData->lMtkPointer=ftell(fpMtkFile)) >= 0 ){
  612. TOKEN cToken, ccToken;
  613. BOOL fFound;
  614. if( !GetToken(fpMtkFile,&cToken) )
  615. {
  616. RLFREE(cToken.szText);
  617. if( cToken.wReserved & ST_CHANGED ){
  618. if( !GetToken(fpMtkFile,&ccToken) )
  619. {
  620. RLFREE(ccToken.szText);
  621. fFound = ((cToken.wType ==ccToken.wType)
  622. && (cToken.wName == ccToken.wName)
  623. && (cToken.wID == ccToken.wID)
  624. && (cToken.wFlag == ccToken.wFlag)
  625. && (_tcscmp((TCHAR *)cToken.szName,
  626. (TCHAR *)ccToken.szName) == 0));
  627. fseek( fpMtkFile,
  628. lpstrTokData->lMtkPointer, SEEK_SET);
  629. fgets( lpstrDmy, MAXLINE, fpMtkFile );
  630. if( fFound )
  631. fgets( lpstrDmy, MAXLINE, fpMtkFile );
  632. }
  633. }
  634. }
  635. }
  636. if(tToken.wReserved & ST_TRANSLATED)
  637. {
  638. TCHAR *szTokBuf;
  639. szTokBuf = (TCHAR *) FALLOC(MEMSIZE(TokenToTextSize(&tToken)));
  640. ParseTokToBuf(szTokBuf, &tToken);
  641. // only add tokens with the translated status bit set to the token list
  642. lpstrTokData->hToken = GlobalAlloc(GMEM_MOVEABLE,
  643. MEMSIZE(lstrlen((TCHAR *)szTokBuf)+1));
  644. if (!lpstrTokData->hToken){
  645. RLFREE(tToken.szText); // MHotchin
  646. RLFREE(szTokBuf);
  647. RLFREE( lpstrDmy );
  648. QuitA(IDS_ENGERR_16, (LPSTR)IDS_ENGERR_11, NULL);
  649. }
  650. lpstrToken = (LPTSTR) GlobalLock( lpstrTokData->hToken );
  651. lstrcpy (lpstrToken, szTokBuf);
  652. GlobalUnlock( lpstrTokData->hToken );
  653. GlobalUnlock( hTokData );
  654. RLFREE(szTokBuf);
  655. if( SendMessage(hListWnd,LB_ADDSTRING,0,(LONG_PTR)hTokData) < 0){
  656. RLFREE(tToken.szText); // MHotchin
  657. RLFREE( lpstrDmy );
  658. QuitA (IDS_ENGERR_16, (LPSTR)IDS_ENGERR_11, NULL);
  659. }
  660. }
  661. else
  662. {
  663. // the current token is delta info so save in delta list.
  664. if (!pTokenDeltaInfo){
  665. ptTokenDeltaInfo = pTokenDeltaInfo =
  666. UpdateTokenDeltaInfo(&tToken);
  667. }
  668. else{
  669. ptTokenDeltaInfo->pNextTokenDelta =
  670. UpdateTokenDeltaInfo(&tToken);
  671. ptTokenDeltaInfo = ptTokenDeltaInfo->pNextTokenDelta;
  672. }
  673. //don't use TokData
  674. GlobalUnlock( hTokData );
  675. GlobalFree( hTokData );
  676. }
  677. RLFREE(tToken.szText); // MHotchin
  678. }
  679. }
  680. RLFREE( lpstrDmy );
  681. return(pTokenDeltaInfo);
  682. }
  683. /**
  684. *
  685. *
  686. * Function:
  687. *
  688. *
  689. * Arguments:
  690. *
  691. * Returns:
  692. *
  693. * Errors Codes:
  694. *
  695. * History:
  696. *
  697. *
  698. **/
  699. void GenStatusLine( TOKEN *pTok)
  700. {
  701. TCHAR szName[32];
  702. TCHAR szStatus[20];
  703. #ifdef UNICODE
  704. CHAR szTmpBuf[32];
  705. #endif //UNICODE
  706. TCHAR szResIDStr[20];
  707. static BOOL fFirstCall = TRUE;
  708. if (fFirstCall)
  709. {
  710. SendMessage( hStatusWnd,
  711. WM_FMTSTATLINE,
  712. (WPARAM)0,
  713. (LPARAM)TEXT("15s7s4i5s4i"));
  714. fFirstCall = FALSE;
  715. }
  716. if (pTok->szName[0])
  717. {
  718. lstrcpy( szName, pTok->szName);
  719. }
  720. else
  721. {
  722. #ifdef UNICODE
  723. _itoa(pTok->wName, szTmpBuf, 10);
  724. _MBSTOWCS( szName,
  725. szTmpBuf,
  726. WCHARSIN( sizeof( szTmpBuf)),
  727. ACHARSIN( lstrlenA( szTmpBuf) + 1));
  728. #else
  729. _itoa(pTok->wName, szName, 10);
  730. #endif
  731. }
  732. if (pTok->wReserved & ST_READONLY)
  733. {
  734. LoadString( hInst, IDS_READONLY, szStatus, TCHARSIN( sizeof( szStatus)));
  735. }
  736. else if (pTok->wReserved & ST_DIRTY)
  737. {
  738. LoadString( hInst, IDS_DIRTY, szStatus, TCHARSIN( sizeof( szStatus)));
  739. }
  740. else
  741. {
  742. LoadString( hInst, IDS_CLEAN, szStatus, TCHARSIN( sizeof( szStatus)));
  743. }
  744. SendMessage( hStatusWnd, WM_UPDSTATLINE, (WPARAM)3, (LPARAM)szStatus);
  745. if (pTok->wType <= 16)
  746. {
  747. LoadString( hInst,
  748. IDS_RESOURCENAMES+pTok->wType,
  749. szResIDStr,
  750. TCHARSIN( sizeof( szResIDStr)));
  751. }
  752. else
  753. {
  754. #ifdef UNICODE
  755. _itoa(pTok->wType, szTmpBuf, 10);
  756. _MBSTOWCS( szResIDStr,
  757. szTmpBuf,
  758. WCHARSIN( sizeof( szTmpBuf)),
  759. ACHARSIN( lstrlenA( szTmpBuf) + 1));
  760. #else
  761. _itoa(pTok->wType, szResIDStr, 10);
  762. #endif
  763. }
  764. SendMessage( hStatusWnd,
  765. WM_UPDSTATLINE,
  766. (WPARAM)0,
  767. (LPARAM)szName);
  768. SendMessage( hStatusWnd,
  769. WM_UPDSTATLINE,
  770. (WPARAM)1,
  771. (LPARAM)szResIDStr);
  772. SendMessage( hStatusWnd,
  773. WM_UPDSTATLINE,
  774. (WPARAM)2,
  775. (LPARAM)pTok->wID);
  776. SendMessage( hStatusWnd,
  777. WM_UPDSTATLINE,
  778. (WPARAM)4,
  779. (LPARAM)lstrlen( pTok->szText));
  780. }