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.

108 lines
4.4 KiB

  1. //
  2. // MODULE: TSMapClient.cpp
  3. //
  4. // PURPOSE: Part of launching a Local Troubleshooter from an arbitrary NT5 application
  5. // Class TSMapClient is available at runtime for mapping from the application's
  6. // way of naming a problem to the Troubleshooter's way.
  7. // Only a single thread should operate on any one object of class TSMapClient. The object is not
  8. // threadsafe.
  9. // In addition to the overtly noted returns, many methods can return a preexisting error.
  10. // However, if the calling program has wishes to ignore an error and continue, we
  11. // recommend an explicit call to inherited method ClearStatus().
  12. // Note that the mapping file is always strictly SBCS (Single Byte Character Set), but the
  13. // calls into this code may use Unicode. This file consequently mixes char and TCHAR.
  14. //
  15. // COMPANY: Saltmine Creative, Inc. (206)-633-4743 [email protected]
  16. //
  17. // AUTHOR: Joe Mabel
  18. //
  19. // ORIGINAL DATE: 2-26-98
  20. //
  21. //
  22. // Version Date By Comments
  23. //--------------------------------------------------------------------
  24. // V0.1 - JM Original
  25. ///////////////////////
  26. #ifndef _TSMAPCLIENT_
  27. #define _TSMAPCLIENT_ 1
  28. // ----------------- TSMapClient ---------------
  29. // Class providing mapping methods which will be available
  30. // at runtime when launching a troubleshooter.
  31. class TSMapClient: public TSMapRuntimeAbstract {
  32. public:
  33. TSMapClient(const TCHAR * const sztMapFile);
  34. ~TSMapClient();
  35. DWORD Initialize();
  36. private:
  37. // redefined inherited methods
  38. DWORD ClearAll ();
  39. DWORD SetApp (const TCHAR * const sztApp);
  40. DWORD SetVer (const TCHAR * const sztVer);
  41. DWORD SetProb (const TCHAR * const sztProb);
  42. DWORD SetDevID (const TCHAR * const sztDevID);
  43. DWORD SetDevClassGUID (const TCHAR * const sztDevClassGUID);
  44. DWORD FromProbToTS (TCHAR * const sztTSBN, TCHAR * const sztNode );
  45. DWORD FromDevToTS (TCHAR * const sztTSBN, TCHAR * const sztNode );
  46. DWORD FromDevClassToTS (TCHAR * const sztTSBN, TCHAR * const sztNode );
  47. DWORD ApplyDefaultVer();
  48. bool HardMappingError (DWORD dwStatus);
  49. UID GetGenericMapToUID (const TCHAR * const sztName, DWORD dwOffFirst, DWORD dwOffLast,
  50. bool bAlphaOrder);
  51. DWORD SetFilePointerAbsolute( DWORD dwMoveTo );
  52. bool Read(LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead);
  53. bool ReadUIDMap (UIDMAP &uidmap, DWORD &dwPosition, bool bSetPosition = false);
  54. bool ReadAppMap (APPMAP &appmap, DWORD &dwPosition, bool bSetPosition = false);
  55. bool ReadVerMap (VERMAP &vermap, DWORD &dwPosition, bool bSetPosition = false);
  56. bool ReadProbMap (PROBMAP &probmap, DWORD &dwPosition, bool bSetPosition = false);
  57. bool ReadDevMap (DEVMAP &devmap, DWORD &dwPosition, bool bSetPosition = false);
  58. bool ReadDevClassMap (DEVCLASSMAP &devclassmap, DWORD &dwPosition, bool bSetPosition = false);
  59. bool ReadString (char * sz, DWORD cbMax, DWORD &dwPosition, bool bSetPosition);
  60. private:
  61. TCHAR m_sztMapFile[BUFSIZE]; // pathname of file from which to draw mappings
  62. HANDLE m_hMapFile; // corresponding handle
  63. TSMAPFILEHEADER m_header; // header portion of map file
  64. // If we satisf ourselves that the SQL Server database used in preparing the mapping file
  65. // will produce the collating order we want, we could gain some runtime efficiency
  66. // by setting the following true: when we are reading through a file for a match, we
  67. // could bail if we got past it.
  68. bool m_bAppAlphaOrder;
  69. bool m_bVerAlphaOrder;
  70. bool m_bDevIDAlphaOrder;
  71. bool m_bDevClassGUIDAlphaOrder;
  72. bool m_bProbAlphaOrder;
  73. // NOTE: because the mapping file is strictly SBCS, so are the cache values. Typically,
  74. // this requires conversion between these values and Unicode arguments to methods.
  75. // Cache info about selected app. This lets us know (for example) at what offset
  76. // to start a search for relevant versions.
  77. char m_szApp[BUFSIZE];
  78. APPMAP m_appmap;
  79. // Cache info about selected version. This lets us know (for example) at what offset
  80. // to start a search for relevant mappings to troubleshooting belief networks.
  81. char m_szVer[BUFSIZE];
  82. VERMAP m_vermap;
  83. // Cache info about selected device (just name & UID)
  84. char m_szDevID[BUFSIZE];
  85. UID m_uidDev;
  86. // Cache info about selected device class (just name -- a string representing a GUID --
  87. // & UID)
  88. char m_szDevClassGUID[BUFSIZE];
  89. UID m_uidDevClass;
  90. // Cache info about selected problem (just name & UID)
  91. char m_szProb[BUFSIZE];
  92. UID m_uidProb;
  93. };
  94. #endif // _TSMAPCLIENT_