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.

846 lines
17 KiB

  1. //
  2. // MODULE: APGTSDTG.CPP
  3. //
  4. // PURPOSE: Wrapper for inference api
  5. //
  6. // PROJECT: Generic Troubleshooter DLL for Microsoft AnswerPoint
  7. //
  8. // COMPANY: Saltmine Creative, Inc. (206)-633-4743 [email protected]
  9. //
  10. // AUTHOR: Roman Mach
  11. //
  12. // ORIGINAL DATE: 8-2-96
  13. //
  14. // NOTES:
  15. // 1. Based on Print Troubleshooter DLL
  16. //
  17. // Version Date By Comments
  18. //--------------------------------------------------------------------
  19. // V0.1 - RM Original
  20. // V0.2 6/4/97 RWM Local Version for Memphis
  21. // V0.3 04/09/98 JM/OK+ Local Version for NT5
  22. //
  23. //#include "windows.h"
  24. #include "stdafx.h"
  25. #include "time.h"
  26. #include "apgts.h"
  27. #include "ErrorEnums.h"
  28. #include "bnts.h"
  29. #include "BackupInfo.h"
  30. #include "cachegen.h"
  31. #include "apgtsinf.h"
  32. #include "apgtscmd.h"
  33. #include "apgtshtx.h"
  34. #include "apgtscls.h"
  35. #include <string.h>
  36. #include <memory.h>
  37. #include "CabUnCompress.h"
  38. #include "crc.h"
  39. #include "sniff.h"
  40. #include "chmread.h"
  41. BCache::BCache(TCHAR *binfile, TCHAR *tagstr, TCHAR *szResourcePath, const CString& strFile)
  42. : GTSAPI(binfile, tagstr, szResourcePath),
  43. CSniffedNodeContainer(),
  44. m_NodeState(30),
  45. m_strFile(strFile)
  46. {
  47. SetBNTS(this);
  48. m_bNeedModel = TRUE; // TRUE -> Need to read the model before querying the bnts library.
  49. m_bModelRead = FALSE;
  50. m_bDeleteModelFile = FALSE;
  51. m_strModelFile = _T("");
  52. m_CurNode = 0;
  53. m_pHttpQuery = NULL;
  54. m_strResult = _T("");
  55. m_NodeState.InitHashTable(47);
  56. m_bReverse = false;
  57. m_bRunWithKnownProblem = false;
  58. return;
  59. }
  60. BCache::~BCache()
  61. {
  62. m_NodeState.RemoveAll();
  63. if (m_bDeleteModelFile)
  64. {
  65. DeleteFile((LPCTSTR) m_strModelFile);
  66. m_bDeleteModelFile = FALSE;
  67. }
  68. return;
  69. }
  70. //
  71. //
  72. GTSAPI::GTSAPI(TCHAR *binfile, TCHAR *tagstr, TCHAR *szResourcePath) :
  73. m_CacheGen(TRUE, NULL, NULL)
  74. {
  75. // InitializeCriticalSection( &m_csAPI );
  76. m_cnid = 0;
  77. m_dwErr = 0;
  78. m_pchHtml = NULL;
  79. m_currid = 0;
  80. m_pCache = NULL;
  81. _tcscpy(m_binfile,binfile);// full path
  82. _tcscpy(m_tagstr,tagstr);
  83. _tcscpy(m_szResourcePath,szResourcePath);
  84. }
  85. //
  86. //
  87. GTSAPI::~GTSAPI()
  88. {
  89. Destroy();
  90. }
  91. void WideToMB(const WCHAR *szIn, CHAR *szOut)
  92. {
  93. VERIFY(WideCharToMultiByte(CP_ACP,
  94. NULL,
  95. szIn,
  96. -1,
  97. szOut,
  98. MAXBUF,
  99. NULL, NULL));
  100. return;
  101. }
  102. #ifdef _UNICODE
  103. // Temporary BNTS wrappers for unicode build with non unicode bnts.dll
  104. BOOL GTSAPI::BMultiByteReadModel(LPCTSTR szcFn, LPCSTR szFnError)
  105. {
  106. CHAR szFn[MAXBUF];
  107. WideToMB(szcFn, szFn);
  108. return BNTS::BReadModel(szFn, szFnError);
  109. }
  110. BOOL GTSAPI::BMultiByteNodePropItemStr(LPCTSTR szcPropType, int index)
  111. {
  112. CHAR szPropType[MAXBUF];
  113. WideToMB(szcPropType, szPropType);
  114. return BNTS::BNodePropItemStr(szPropType, index);
  115. }
  116. BOOL GTSAPI::BMultiByteNetPropItemStr(LPCTSTR szcPropType, int index)
  117. {
  118. CHAR szPropType[MAXBUF];
  119. WideToMB(szcPropType, szPropType);
  120. return BNTS::BNetPropItemStr(szPropType, index);
  121. }
  122. const WCHAR * GTSAPI::SzcMultiByteResult()
  123. {
  124. int len = strlen(BNTS::SzcResult());
  125. int size = MultiByteToWideChar(CP_ACP,
  126. NULL,
  127. BNTS::SzcResult(),
  128. len,
  129. NULL,
  130. 0);
  131. MultiByteToWideChar(CP_ACP,
  132. NULL,
  133. BNTS::SzcResult(),
  134. len + 1,
  135. m_strResult.GetBufferSetLength(size),
  136. size);
  137. m_strResult.ReleaseBuffer();
  138. return (LPCTSTR) m_strResult;
  139. }
  140. int GTSAPI::IMultiByteNode(LPCTSTR szSymName)
  141. {
  142. CHAR szMBSymName[MAXBUF];
  143. WideToMB(szSymName, szMBSymName);
  144. return BNTS::INode(szMBSymName);
  145. }
  146. #endif // _UNICODE
  147. void BCache::ReadTheDscModel(int From)
  148. {
  149. if (m_bNeedModel)
  150. {
  151. if (!BReadModel((LPCTSTR) m_strModelFile
  152. #ifdef _DEBUG
  153. , "BNTSError.log"
  154. #endif
  155. ))
  156. ReportError((DLSTATTYPES) From);
  157. // Add the nodes that are already instantiated.
  158. if (m_pHttpQuery)
  159. m_pHttpQuery->AddNodes(this);
  160. m_bNeedModel = FALSE;
  161. if (m_bDeleteModelFile)
  162. {
  163. DeleteFile((LPCTSTR) m_strModelFile);
  164. m_bDeleteModelFile = FALSE;
  165. }
  166. }
  167. }
  168. VOID BCache::AddToCache(CString &strCacheFile, const CString& strCacheFileWithinCHM)
  169. {
  170. if (m_CacheGen.ReadCacheFileHeader(strCacheFile, strCacheFileWithinCHM))
  171. {
  172. BOOL bErr;
  173. ASSERT(m_pCache);
  174. while (m_CacheGen.GetNextCacheEntryFromFile(bErr, m_pCache))
  175. ;
  176. if (bErr)
  177. {
  178. delete m_pCache;
  179. m_pCache = new CBNCache();
  180. TRACE(_T("Errors occured while reading the cache file.\n"));
  181. ReadTheDscModel(TSERR_ENGINE_BNTS_READ_NCAB);
  182. }
  183. }
  184. return;
  185. }
  186. DWORD BCache::ReadModel()
  187. {
  188. BOOL bDelete = FALSE;
  189. // this should be fixed eventually to not require a string compare
  190. // but maybe a flag check that gets passed in
  191. CString sFilename = m_binfile;
  192. CString strCacheFile;
  193. CString strCacheFileWithinCHM;
  194. if (m_strFile.GetLength())
  195. {
  196. // form Cache file path here assuming it is NOT in chm file
  197. strCacheFile = m_binfile;
  198. strCacheFileWithinCHM = m_strFile.Left(m_strFile.GetLength() - 4);
  199. strCacheFileWithinCHM += SZ_CACHE_NAME;
  200. }
  201. else
  202. {
  203. strCacheFile = sFilename.Left(sFilename.GetLength() - 4);
  204. strCacheFile += SZ_CACHE_NAME;
  205. }
  206. if (m_strFile.GetLength() || !sFilename.Right(4).CompareNoCase(DSC_COMPRESSED))
  207. {
  208. CCabUnCompress cab;
  209. CString strDirBuf;
  210. if (!GetTempPath( MAX_PATH , strDirBuf.GetBufferSetLength(MAX_PATH + 1)))
  211. {
  212. strDirBuf.ReleaseBuffer();
  213. strDirBuf = m_szResourcePath;
  214. }
  215. else
  216. {
  217. strDirBuf.ReleaseBuffer();
  218. }
  219. if (!cab.ExtractCab(sFilename, strDirBuf, m_strFile))
  220. {
  221. if (NOT_A_CAB == cab.m_nError)
  222. { // The file may be uncompressed already.
  223. bDelete = FALSE;
  224. }
  225. else
  226. {
  227. ReportError(TSERR_ENGINE_EXTRACT);
  228. }
  229. }
  230. else
  231. { // Normal cab file expanded successfully.
  232. sFilename = strDirBuf;
  233. sFilename += cab.GetLastFile();
  234. DWORD dwAttribs = GetFileAttributes((LPCTSTR) sFilename);
  235. dwAttribs = dwAttribs & ~FILE_ATTRIBUTE_READONLY;
  236. SetFileAttributes((LPCTSTR) sFilename, dwAttribs);
  237. bDelete = TRUE;
  238. }
  239. }
  240. /*
  241. if (!BReadModel(sFilename
  242. #ifdef _DEBUG
  243. , "BNTSError.log"
  244. #endif
  245. ))
  246. ReportError(TSERR_ENGINE);
  247. */
  248. m_strModelFile = sFilename;
  249. m_bDeleteModelFile = bDelete;
  250. // Compare the crc value in the cache file with the crc of the dsc file.
  251. // If they match, fill the cache.
  252. CCRC crc;
  253. try
  254. {
  255. if (crc.Decode(sFilename, strCacheFile, strCacheFileWithinCHM))
  256. AddToCache(strCacheFile, strCacheFileWithinCHM);
  257. else
  258. ReadTheDscModel(TSERR_ENGINE_BNTS_READ_CACH);
  259. }
  260. catch(CGenException *p)
  261. {
  262. delete p;
  263. ReadTheDscModel(TSERR_ENGINE_BNTS_READ_GEN);
  264. }
  265. // if (bDelete)
  266. // DeleteFile(sFilename);
  267. m_probask = idhFirst + CNode();
  268. m_bModelRead = TRUE;
  269. return m_dwErr;
  270. }
  271. // Number of nodes whose states were set at program startup by TSLaunchServ.
  272. UINT BCache::StatesFromServ()
  273. {
  274. return m_pHttpQuery ? m_pHttpQuery->StatesFromServ() : 0;
  275. }
  276. // Number of nodes whose states are now set
  277. UINT BCache::StatesNowSet()
  278. {
  279. return (UINT)m_NodeState.GetCount();
  280. }
  281. //
  282. //
  283. DWORD BCache::Initialize(/*CWordList *pWXList*/)
  284. {
  285. if (NULL != m_pCache)
  286. delete m_pCache;
  287. m_pCache = new CBNCache();
  288. if (!m_pCache)
  289. m_dwErr = EV_GTS_ERROR_IDX_ALLOC_CACHE;
  290. ResetNodes();
  291. if (!BValidNet())
  292. ReadModel();
  293. return m_dwErr;
  294. }
  295. // override the default function
  296. //
  297. // look for possible returns in the header file
  298. //
  299. int BCache::GTSGetRecommendations(CNID& cnid, NID rgnid[], bool bSniffed)
  300. {
  301. BN_CACHE_ITEM SetupItem;
  302. SetupItem.uNodeCount = m_cnid;
  303. SetupItem.uName = m_rgnid;
  304. SetupItem.uValue = m_rgist;
  305. int state = SNIFF_INVALID_STATE;
  306. int label = SNIFF_INVALID_NODE_LABEL;
  307. //AfxDebugBreak();
  308. // set initial non-sniffed value in array of sniffed states
  309. if (!bSniffed && !IsReverse())
  310. m_rgsniff[m_cnid-1] = 0;
  311. // flush array of sniffed nodes recently traversed
  312. if (!bSniffed)
  313. m_arrNidLastSniffed.RemoveAll();
  314. if (m_pCache->FindCacheItem(&SetupItem, cnid, rgnid))
  315. {
  316. if (GetState(*rgnid, &state)) // sniffer has this information and can answer what state this node has
  317. {
  318. if (NodeSet(*rgnid, state, false)) // set sniffed node current and set its state
  319. {
  320. SetAdditionalDataOnNodeSet(*rgnid);
  321. return GTSGetRecommendations(cnid, rgnid, true); // recursive call - hope BNTS will not recommend a node which is set
  322. }
  323. }
  324. else
  325. {
  326. return RECOMMEND_SUCCESS;
  327. }
  328. }
  329. if (m_bNeedModel)
  330. {
  331. ReadTheDscModel(TSERR_ENGINE_BNTS_REC);
  332. }
  333. if (BGetRecommendations())
  334. {
  335. cnid = CInt();
  336. if (cnid > 0)
  337. {
  338. const int *pInt = RgInt();
  339. memcpy(rgnid, pInt, cnid * sizeof(pInt[0]));
  340. SetupItem.uNodeCount = m_cnid;
  341. SetupItem.uName = m_rgnid;
  342. SetupItem.uValue = m_rgist;
  343. SetupItem.uRecCount = cnid;
  344. SetupItem.uRec = rgnid;
  345. m_pCache->AddCacheItem(&SetupItem);
  346. if (GetState(*rgnid, &state)) // sniffer has this information and can answer what state this node has
  347. {
  348. if (NodeSet(*rgnid, state, false)) // set sniffed node current and set its state
  349. {
  350. SetAdditionalDataOnNodeSet(*rgnid);
  351. return GTSGetRecommendations(cnid, rgnid, true); // recursive call - hope BNTS will not recommend a node which is set
  352. }
  353. }
  354. return RECOMMEND_SUCCESS;
  355. }
  356. else
  357. {
  358. rgnid[0] = nidService;
  359. cnid = 1;
  360. return RECOMMEND_NO_MORE_DATA;
  361. }
  362. }
  363. else
  364. {
  365. // the last node was sniffed and its state was set
  366. // after that we received FALSE from BGetRecommendation;
  367. // we unset this node (in order to be able to use BGetRecommendation later on);
  368. // we return value indicating that BNTS cannot give us any recommendations
  369. NodeSet(m_rgnid[m_cnid-1], -1, false);
  370. return RECOMMEND_NO_MORE_DATA;
  371. }
  372. return RECOMMEND_FAIL;
  373. }
  374. void BCache::SetAdditionalDataOnNodeSet(NID nid)
  375. {
  376. m_rgsniff[m_cnid-1] = 1;
  377. m_arrNidLastSniffed.Add(nid);
  378. }
  379. BOOL InArray(UINT num, UINT aNums[], UINT max)
  380. {
  381. UINT x = max;
  382. BOOL bRes = FALSE;
  383. for (UINT y = 0; y < x; y++)
  384. {
  385. if (aNums[y] == num)
  386. {
  387. bRes = TRUE;
  388. break;
  389. }
  390. }
  391. return bRes;
  392. }
  393. // RemoveRecommendations is called for nodes whos' state is less than 100.
  394. void BCache::RemoveRecommendation(int Nid)
  395. {
  396. VERIFY(BNodeSetCurrent(Nid));
  397. BNodeSet(-1, false);
  398. if (m_cnid)
  399. m_cnid--;
  400. return;
  401. }
  402. //
  403. //
  404. UINT GTSAPI::GetNodeList(NID **pNid, IST **pIst)
  405. {
  406. *pNid = m_rgnid;
  407. *pIst = m_rgist;
  408. return m_cnid;
  409. }
  410. BOOL GTSAPI::BNodeSetCurrent(int node)
  411. {
  412. return BNTS::BNodeSetCurrent(node);
  413. }
  414. //
  415. //
  416. BOOL BCache::NodeSet(NID nid, IST ist, bool bPrevious)
  417. {
  418. BOOL bRes = FALSE;
  419. // shouldn't happen...but to be safe
  420. if (m_cnid >= MAX_NID)
  421. return FALSE;
  422. m_rgnid[m_cnid] = nid;
  423. m_rgist[m_cnid] = ist;
  424. if (false == bPrevious)
  425. {
  426. VERIFY(BNodeSetCurrent(nid));
  427. bRes = BNodeSet(ist, false);
  428. if (bRes && // bnts worked successfully
  429. -1 == GetIndexNodeInCache(nid) // this nid is not present in the cache
  430. )
  431. m_cnid++;
  432. }
  433. else
  434. {
  435. bRes = TRUE;
  436. }
  437. return bRes;
  438. }
  439. //
  440. //
  441. int BCache::GetIndexNodeInCache(NID nid)
  442. {
  443. for (unsigned int i = 0; i < m_cnid; i++)
  444. if (m_rgnid[i] == nid)
  445. return i;
  446. return -1;
  447. }
  448. //
  449. //
  450. VOID BCache::ResetNodes()
  451. {
  452. for (UINT inid = 0; inid < m_cnid; inid++)
  453. {
  454. VERIFY(BNodeSetCurrent(m_rgnid[inid]));
  455. BNodeSet(-1, false); // Nil value
  456. }
  457. m_cnid = 0;
  458. }
  459. //
  460. //
  461. DWORD GTSAPI::GetStatus()
  462. {
  463. return m_dwErr;
  464. }
  465. //
  466. //
  467. VOID GTSAPI::Destroy()
  468. {
  469. if (m_pchHtml) {
  470. delete [] m_pchHtml;
  471. m_pchHtml = NULL;
  472. }
  473. /*
  474. if (m_pWNList) {
  475. if (!m_dwErr)
  476. m_dwErr = m_pWNList->GetStatus();
  477. delete m_pWNList;
  478. m_pWNList = NULL;
  479. }
  480. */
  481. if (m_pCache) {
  482. if (!m_dwErr)
  483. m_dwErr = m_pCache->GetStatus();
  484. delete m_pCache;
  485. m_pCache = NULL;
  486. }
  487. }
  488. //
  489. //
  490. UINT GTSAPI::GetProblemArray(IDH **idh)
  491. {
  492. *idh = m_idstore;
  493. return m_currid;
  494. }
  495. //
  496. //
  497. IDH GTSAPI::GetProblemAsk()
  498. {
  499. return m_probask;
  500. }
  501. void GTSAPI::AddValue(int value)
  502. {
  503. ASSERT(m_currid < MAXPROBID);
  504. m_idstore[m_currid++] = value;
  505. return;
  506. }
  507. BOOL BCache::CheckNode(int Node)
  508. {
  509. BOOL bCached = m_CacheGen.IsNodePresent(Node);
  510. if (!bCached && m_bNeedModel)
  511. {
  512. ReadTheDscModel(TSERR_ENGINE_BNTS_CHECK);
  513. }
  514. return bCached;
  515. }
  516. //-------------------------------------------------------------
  517. // BNTS Overrides to replace the dsc file with our cache.
  518. // Need to override everything but BReadModel and BGetRecommendations.
  519. int BCache::CNode()
  520. {
  521. int cNodes;
  522. if (FALSE == m_bNeedModel)
  523. cNodes = GTSAPI::CNode();
  524. else
  525. cNodes = m_CacheGen.GetNodeCount();
  526. return cNodes;
  527. }
  528. BOOL BCache::BImpossible()
  529. {
  530. BOOL bImpossible = FALSE;
  531. if (FALSE == m_bNeedModel)
  532. bImpossible = GTSAPI::BImpossible();
  533. return bImpossible;
  534. }
  535. BOOL BCache::BNetPropItemStr(LPCTSTR szPropType, int index)
  536. {
  537. BOOL bGoodIndex = FALSE;
  538. char sznPropType[MAX_SYM_NAME_BUF_LEN];
  539. int nPropLen = MAX_SYM_NAME_BUF_LEN;
  540. if (!GTSCacheGenerator::TcharToChar(sznPropType, szPropType, nPropLen))
  541. return FALSE;
  542. if (CheckNode(m_CurNode))
  543. {
  544. bGoodIndex = m_CacheGen.FindNetworkProperty(sznPropType, m_strResult, index);
  545. if (!bGoodIndex && !m_bNeedModel)
  546. {
  547. bGoodIndex = GTSAPI::BNetPropItemStr(szPropType, index);
  548. m_strResult = GTSAPI::SzcResult();
  549. }
  550. }
  551. else
  552. {
  553. bGoodIndex = GTSAPI::BNetPropItemStr(szPropType, index);
  554. m_strResult = GTSAPI::SzcResult();
  555. }
  556. return bGoodIndex;
  557. }
  558. BOOL BCache::BNodeSetCurrent(int node)
  559. {
  560. BOOL bNodeSet = TRUE;
  561. if (CheckNode(node) && TRUE == m_bNeedModel)
  562. {
  563. m_CurNode = node;
  564. }
  565. else
  566. {
  567. bNodeSet = GTSAPI::BNodeSetCurrent(node);
  568. m_CurNode = node;
  569. }
  570. return bNodeSet;
  571. }
  572. int BCache::INode(LPCTSTR szNodeSymName)
  573. {
  574. UINT index = 0;
  575. if (FALSE == m_bNeedModel)
  576. index = GTSAPI::INode(szNodeSymName);
  577. else
  578. if (!m_CacheGen.GetNodeIDFromSymName(szNodeSymName, index))
  579. { // Have to have BNTS load the network and the the symbolic name.
  580. ReadTheDscModel(TSERR_ENGINE_CACHE_LOW);
  581. index = GTSAPI::INode(szNodeSymName);
  582. }
  583. return (signed int) index;
  584. }
  585. ESTDLBL BCache::ELblNode()
  586. {
  587. UINT NodeLable;
  588. ESTDLBL Lable;
  589. if (FALSE == m_bNeedModel)
  590. {
  591. Lable = GTSAPI::ELblNode();
  592. }
  593. else
  594. {
  595. VERIFY(m_CacheGen.GetLabelOfNode(m_CurNode, NodeLable));
  596. Lable = (ESTDLBL) NodeLable;
  597. }
  598. return Lable;
  599. }
  600. int BCache::INodeCst()
  601. {
  602. int cStates = 2;
  603. return cStates;
  604. }
  605. BOOL GTSAPI::BNodeSet(int state, bool bset)
  606. {
  607. return BNTS::BNodeSet(state, bset);
  608. }
  609. BOOL BCache::BNodeSet(int istate, bool bSet)
  610. {
  611. BOOL bNodeWasSet = TRUE;
  612. if (FALSE == m_bNeedModel)
  613. bNodeWasSet = GTSAPI::BNodeSet(istate, bSet);
  614. if (bNodeWasSet)
  615. {
  616. if (-1 != istate)
  617. m_NodeState.SetAt(m_CurNode, istate);
  618. else
  619. m_NodeState.RemoveKey(m_CurNode);
  620. }
  621. return bNodeWasSet;
  622. }
  623. int BCache::INodeState()
  624. { // This is ok. See BNodeSet.
  625. int state;
  626. if (!m_NodeState.Lookup(m_CurNode, state))
  627. state = 0;
  628. return state;
  629. }
  630. void BCache::NodeStateName(int istate)
  631. {
  632. if (FALSE == m_bNeedModel)
  633. {
  634. GTSAPI::NodeStateName(istate);
  635. m_strResult = GTSAPI::SzcResult();
  636. }
  637. else
  638. {
  639. BOOL bFound;
  640. switch(istate)
  641. {
  642. case 0:
  643. bFound = m_CacheGen.FindNodeProperty(m_CurNode, G_S0_NAME, m_strResult, 0);
  644. break;
  645. case 1:
  646. bFound = m_CacheGen.FindNodeProperty(m_CurNode, G_S1_NAME, m_strResult, 0);
  647. break;
  648. default:
  649. bFound = FALSE;
  650. }
  651. if (!bFound)
  652. {
  653. ASSERT(FALSE);
  654. m_strResult = _T("");
  655. }
  656. }
  657. return;
  658. }
  659. void BCache::NodeSymName()
  660. {
  661. if (FALSE == m_bNeedModel)
  662. {
  663. GTSAPI::NodeSymName();
  664. m_strResult = GTSAPI::SzcResult();
  665. }
  666. else if (CheckNode(m_CurNode))
  667. {
  668. VERIFY(m_CacheGen.FindNodeProperty(m_CurNode, G_SYMBOLIC_NAME, m_strResult, 0));
  669. }
  670. return;
  671. }
  672. void BCache::NodeFullName()
  673. {
  674. if (FALSE == m_bNeedModel)
  675. {
  676. GTSAPI::NodeFullName();
  677. m_strResult = GTSAPI::SzcResult();
  678. }
  679. else
  680. {
  681. VERIFY(m_CacheGen.FindNodeProperty(m_CurNode, G_FULL_NAME, m_strResult, 0));
  682. }
  683. return;
  684. }
  685. BOOL BCache::BNodePropItemStr(LPCTSTR szPropType, int index)
  686. {
  687. BOOL bGoodIndex = FALSE;
  688. char sznPropType[MAX_SYM_NAME_BUF_LEN];
  689. int nPropTypeLen = MAX_SYM_NAME_BUF_LEN;
  690. if (!GTSCacheGenerator::TcharToChar(sznPropType, szPropType, nPropTypeLen))
  691. return FALSE;
  692. if (FALSE == m_bNeedModel)
  693. {
  694. bGoodIndex = GTSAPI::BNodePropItemStr(szPropType, index);
  695. m_strResult = GTSAPI::SzcResult();
  696. }
  697. else
  698. {
  699. bGoodIndex = m_CacheGen.FindNodeProperty(m_CurNode, sznPropType, m_strResult, index);
  700. }
  701. return bGoodIndex;
  702. }
  703. bool BCache::BValidNet()
  704. {
  705. bool bValidNet;
  706. if (FALSE == m_bModelRead) // Set to true in BCache::ReadModel.
  707. bValidNet = false; // Causes the readmodel function to be called.
  708. else if (FALSE == m_bNeedModel)
  709. bValidNet = GTSAPI::BValidNet();
  710. else
  711. bValidNet = true;
  712. return bValidNet;
  713. }
  714. LPCTSTR BCache::SzcResult() const
  715. {
  716. return (LPCTSTR) m_strResult;
  717. }
  718. const CArray<int, int>& BCache::GetArrLastSniffed()
  719. {
  720. return m_arrNidLastSniffed;
  721. }
  722. int BCache::GetCountRecommendedNodes()
  723. {
  724. return m_cnid;
  725. }
  726. int BCache::GetCountSniffedRecommendedNodes()
  727. {
  728. for (unsigned int i = 0, j = 0; i < m_cnid; i++)
  729. if (m_rgsniff[i] == 1)
  730. j++;
  731. return j;
  732. }
  733. bool BCache::IsReverse()
  734. {
  735. return m_bReverse;
  736. }
  737. void BCache::SetReverse(bool reverse)
  738. {
  739. m_bReverse = reverse;
  740. }
  741. void BCache::SetRunWithKnownProblem(bool yes)
  742. {
  743. m_bRunWithKnownProblem = yes;
  744. }
  745. bool BCache::IsRunWithKnownProblem()
  746. {
  747. return m_bRunWithKnownProblem;
  748. }
  749.