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.

392 lines
14 KiB

  1. //
  2. // MODULE: APGTS.H
  3. //
  4. // PURPOSE: Main header file for DLL
  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. // further work by Richard Meadows (RWM), Joe Mabel, Oleg Kalosha
  12. //
  13. // ORIGINAL DATE: 8-2-96
  14. //
  15. // NOTES:
  16. // 1. Based on Print Troubleshooter DLL
  17. //
  18. // Version Date By Comments
  19. //--------------------------------------------------------------------
  20. // V0.1 - RM Original
  21. // V0.2 6/4/97 RWM Local Version for Memphis
  22. // V0.3 3/24/98 JM/OK+ Local Version for NT5
  23. //
  24. //#define __DEBUG_HTTPQUERY_ 1
  25. //-----------------------
  26. // !!! NOTE !!!
  27. // THIS DEFINE IS USED TO CREATE "Single Thread" VERSION FOR DEVELOPMENT
  28. // MAKE SURE THIS IS COMMENTED OUT FOR RELEASE VERSION!
  29. //
  30. // Purpose of Single Thread Version: To allow noncaching of DLL to allow easy
  31. // update of dll w/o dealing with shutting down server/starting it up.
  32. //
  33. #define SINGLE_THREAD_VER
  34. //-----------------------
  35. // for belief networks
  36. #define MAXBNCFG 1 // An allocation unit, not really relevant here in the Local Troubleshooter,
  37. // because (unlike the Online Troubleshooter) this is _not_ a server which
  38. // handles multiple troubleshooting networks simultaneously.
  39. //
  40. #define MAXBUF 256 * 2 // length of text buffers used for filenames and other purposes
  41. // *2 is because we need a larger buffer for the MBCS strings.
  42. #define STRBUFSIZE 258 // CString buffer size for calling BNTS functions.
  43. #define CHOOSE_TS_PROBLEM_NODE _T("TShootProblem")
  44. #define TRY_TS_AT_MICROSOFT_SZ _T("TShootGotoMicroSoft")
  45. #define TRY_TS_AT_MICROSOFT_ID 2020
  46. // Note: put no trailing slashes on this...
  47. #define TSREGKEY_MAIN _T("SOFTWARE\\Microsoft\\TShoot")
  48. #define TSREGKEY_TL _T("SOFTWARE\\Microsoft\\TShoot\\TroubleshooterList")
  49. #define TSREGKEY_SFL _T("SOFTWARE\\Microsoft\\TShoot\\SupportFileList")
  50. #define FULLRESOURCE_STR _T("FullPathToResource")
  51. #define LOCALHOST_STR _T("LocalHost")
  52. #define TS_REG_CLASS _T("Generic_Troubleshooter_DLL")
  53. #define REG_EVT_PATH _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application")
  54. #define REG_EVT_MF _T("EventMessageFile")
  55. #define REG_EVT_TS _T("TypesSupported")
  56. #define REGSZ_TSTYPES _T("TroubleShooterList")
  57. #define FRIENDLY_NAME _T("FName")
  58. #define FRIENDLY_PATH _T("Path")
  59. // reg class (optional)
  60. #define TSLCL_REG_CLASS _T("LOCALTS")
  61. // value names under file type
  62. #define TSLCL_FVERSION _T("Version")
  63. #define TSLCL_FMAINEXT _T("FExtension")
  64. // DSC file extensions.
  65. #define DSC_COMPRESSED _T(".dsz")
  66. #define DSC_UNCOMPRESSED _T(".dsc")
  67. #define DSC_DEFAULT _T(".dsz")
  68. #define CHM_DEFAULT _T(".chm")
  69. #define HTI_DEFAULT _T(".hti")
  70. // max search terms to send to index server
  71. #define MAX_TERMS_PER_SEARCH 8
  72. // maximum cache for belief networks
  73. #define MAXCACHESIZE 200
  74. #define evtype(e) ( 1 << (3 - ((e >> 30))))
  75. //------------- Growable string object ---------------//
  76. #define CSTRALLOCGRAN 4096
  77. //------------- Log File ---------------
  78. #define LOGFILEPREFACE _T("gt")
  79. #define MAXLOGSBEFOREFLUSH 5
  80. #define MAXLOGSIZE 1000
  81. //------------- Generic Object list ---------------
  82. // This really should have been a template class, but when it was first written that
  83. // technology was not available. VOID *m_tlist should really be a pointer to the type
  84. // specified in this use of the template.
  85. class COBList {
  86. public:
  87. COBList(UINT incsize);
  88. ~COBList();
  89. DWORD GetStatus();
  90. VOID *AddItemSpace(UINT itemsize); // caller must pass in token size in bytes,
  91. // because this class doesn't know.
  92. VOID *GetList();
  93. UINT GetCount();
  94. VOID IncrementCount();
  95. protected:
  96. UINT m_tokencount; // number of tokens actually used. Mostly managed from outside
  97. // the class by calls to IncrementCount(). Grows monotonically.
  98. UINT m_tokenlistsize; // number of "chunks" we've allocated to the list of tokens
  99. UINT m_incsize; // size of a chunk (number of tokens)
  100. VOID *m_tlist, // points to array of "tokens" (e.g. WORD_TOKEN). Type here really
  101. // ought to be argument to a template.
  102. *m_memerror; // after a memory reallocation failure, this takes on the old value
  103. // of m_tlist so the caller, aware of what the underlying type is,
  104. // can clean it up.
  105. DWORD m_dwErr; // NOTE: once this is set nonzero, it can never be cleared, effectively
  106. // disabling AddItemSpace.
  107. };
  108. //------------- Word List Manager ---------------
  109. // Not currently used in Local TS. Commented-out code here from Online TS.
  110. /*
  111. typedef struct _WORD_TOKEN {
  112. TCHAR *token; // pointer to the keyword (or other) text
  113. // >> what else besides keywords are typical uses?
  114. UINT state; // >>> (a guess JM 10/24/97:)state number: small integer indicating
  115. // state of a node. *token is the name of this state.
  116. BOOL bDiscard; // >>> what does it mean to "discard" a token?
  117. BOOL bKeyword; // keyword >>> vs. what?
  118. } WORD_TOKEN;
  119. //
  120. class CWordList {
  121. public:
  122. CWordList(BOOL bSorted, BOOL bAddDuplicates, BOOL bExceptCheck);
  123. ~CWordList();
  124. DWORD GetStatus();
  125. VOID ReadWordsFromFile(TCHAR *filepath);
  126. WORD_TOKEN *FindWord(TCHAR *token, UINT state, BOOL bDiscard);
  127. WORD_TOKEN *FindWordContained(TCHAR *token, UINT *puStartOff);
  128. BOOL AddWord(TCHAR *token, UINT state, BOOL bDiscard, BOOL bKeyword);
  129. VOID ScanInString(CWordList *pWL, const TCHAR *txtptr, UINT state, BOOL bDiscard);
  130. VOID ScanInKeywordString(CWordList *pWL, const TCHAR *txtptr, UINT state, BOOL bDiscard);
  131. BOOL ProcessToken(CWordList *pWL, TCHAR *token, UINT state, BOOL bDiscard, BOOL bKeyword);
  132. VOID SetOffset(UINT uOff, BOOL bSkipDiscard);
  133. UINT GetOffset();
  134. WORD_TOKEN *GetAtCurrOffset();
  135. VOID IncCurrOffset(BOOL bSkipDiscard);
  136. BOOL IsValidChar(int ch);
  137. BOOL IsTokenChar(INT ch);
  138. UINT CountNonDiscard();
  139. VOID OrderContents(UINT uMaxCount);
  140. VOID DumpContents(UINT nodeid);
  141. protected:
  142. void CleanStr(TCHAR *str);
  143. VOID SkipDiscards();
  144. protected:
  145. // The text associated with an item (indexed by i) in the list is
  146. // *((static_cast<WORD_TOKEN *>(m_list->m_tlist))[i].token)
  147. // For simplicity, the following comments refer to that as "TOKEN"
  148. COBList *m_list;
  149. DWORD m_dwErr; // NOTE: once this is set nonzero, it can never be cleared.
  150. UINT m_uOff; // an index into m_list->m_tlist. "Current Offset"
  151. BOOL m_bSorted, // if true, m_list->m_tlist is sorted by alphabetical order on
  152. // TOKEN
  153. m_bAddDuplicates, // TRUE ==> may have two or more identical TOKEN values.
  154. m_bExceptCheck; // (>>> conjecture JM 10/28/97) do not allow words from
  155. // ARTICLES.TXT in this list
  156. };
  157. */
  158. //------------- Node-Word List Manager ---------------
  159. // Not currently used in Local TS. Commented-out code here from Online TS.
  160. /*
  161. typedef struct _WNODE_ELEM {
  162. UINT nodeid;
  163. CWordList *words; // a word-list associated with this node, >>>but just what is
  164. // in this word list?
  165. } WNODE_ELEM;
  166. //
  167. class CWNodeList {
  168. public:
  169. CWNodeList();
  170. ~CWNodeList();
  171. DWORD GetStatus();
  172. WNODE_ELEM *FindNode(UINT nodeid);
  173. CWordList *AddNode(UINT nodeid);
  174. UINT GetNodeCount();
  175. WNODE_ELEM *GetNodeAt(UINT uOffset);
  176. VOID DumpContents();
  177. protected:
  178. COBList *m_list;
  179. DWORD m_dwErr; // NOTE: once this is set nonzero, it can never be cleared.
  180. };
  181. */
  182. //------- cache classes ------------
  183. //
  184. typedef struct _BN_CACHE_ITEM {
  185. UINT uNodeCount, // number of items in array pointed to by uName (& also uValue)
  186. uRecCount; // number of items in array pointed to by uRec
  187. UINT *uName; // array of Node IDs from a single belief network. Typically not all
  188. // the nodes in the belief network, just the ones on which we
  189. // have state data from the user.
  190. UINT *uValue; // array of States. These are in 1-1 correspondence to *uName.
  191. // uValue is a state # within the states of the corresponding node.
  192. UINT *uRec; // array of Node IDs. Only the first one really matters because we will
  193. // only give one recommendation at a time. This is effectively an
  194. // output we give on a perfect match to the network state expressed
  195. // by arrays *uName and *uValue.
  196. } BN_CACHE_ITEM;
  197. //
  198. //
  199. class CBNCacheItem
  200. {
  201. public:
  202. CBNCacheItem(const BN_CACHE_ITEM *, CBNCacheItem*);
  203. ~CBNCacheItem();
  204. BN_CACHE_ITEM m_CItem;
  205. CBNCacheItem* m_pcitNext;
  206. DWORD GetStatus();
  207. protected:
  208. DWORD m_dwErr; // NOTE: once this is set nonzero, it can never be cleared.
  209. };
  210. //
  211. //
  212. class CBNCache
  213. {
  214. public:
  215. CBNCache();
  216. ~CBNCache();
  217. BOOL AddCacheItem(const BN_CACHE_ITEM *);
  218. BOOL FindCacheItem(const BN_CACHE_ITEM *pList, UINT& count, UINT Name[]);
  219. UINT CountCacheItems() const;
  220. DWORD GetStatus();
  221. protected:
  222. protected:
  223. CBNCacheItem* m_pcit; // points to most recently used cache item, which is head
  224. // of a singly linked list
  225. DWORD m_dwErr; // NOTE: once this is set nonzero, it can never be cleared.
  226. };
  227. //------- index server search file -----------
  228. // Not currently used in Local TS. Commented-out code here from Online TS.
  229. /*
  230. class CSearchForm {
  231. public:
  232. CSearchForm(TCHAR *filepath);
  233. ~CSearchForm();
  234. DWORD Initialize();
  235. DWORD Reload();
  236. TCHAR *GetEncodedSearchString();
  237. TCHAR *GetHTMLSearchString();
  238. static void ToURLString(TCHAR *ptr, TCHAR *tostr);
  239. BOOL IsAND();
  240. protected:
  241. VOID Destroy();
  242. DWORD HTMLFormToURLEncoded(TCHAR *szStr, CString *pCOutStr); // Note arg type is our CString, not MFC - JM 10/97
  243. static DWORD DecodeInputAttrib(TCHAR *str, TCHAR **ptrtype, TCHAR **ptrname, TCHAR **ptrvalue);
  244. protected:
  245. CString // Note this is our CString, not MFC - 10/97
  246. *m_pCOutStr, // URL encoded string derived from contents of BES file indicated by
  247. // m_filepath, and sufficient to reconstruct that BES file
  248. *m_pCFormStr; // Raw copy of entire contents of BES file indicated by m_filepath
  249. TCHAR m_filepath[MAXBUF]; // fully qualified filename of a BES file
  250. BOOL m_bIsAND; // Normally TRUE. Set FALSE if we encounter " OR" in the search string
  251. };
  252. */
  253. //------- property types -----------
  254. //
  255. // Node Properties ---------------------------------------
  256. #define H_ST_NORM_TXT_STR _T("HStNormTxt") // text for radio button for "normal" state
  257. // (state 0)
  258. #define H_ST_AB_TXT_STR _T("HStAbTxt") // text for radio button for "abnormal" state
  259. // (state 1)
  260. #define H_ST_UKN_TXT_STR _T("HStUknTxt") // text for radio button for "no state" (e.g.
  261. // "I don't want to answer this right now"
  262. // (pseudo state 102)
  263. #define H_NODE_HD_STR _T("HNodeHd") // Header text for this node
  264. #define H_NODE_TXT_STR _T("HNodeTxt") // Body text for this node
  265. #define H_NODE_DCT_STR _T("HNodeDct") // Special text to indicate that this node
  266. // was sniffed as being in an abnormal
  267. // state. Only relevant for a fixable node
  268. // that can be sniffed.
  269. #define H_PROB_TXT_STR _T("HProbTxt") // Only relevant to problem nodes. Problem
  270. // text (e.g. "Gazonk is broken.")
  271. #define H_PROB_SPECIAL_STR _T("HProbSpecial") // If this contains the string "hide", then
  272. // this problem is never actually shown on a
  273. // problem page
  274. // Network Properties -------------------------------------
  275. #define H_PROB_HD_STR _T("HProbHd") // Header text for problem page
  276. #define HTK_BACK_BTN _T("HTKBackBtn") // Text for "BACK" button
  277. #define HTK_NEXT_BTN _T("HTKNextBtn") // Text for "NEXT" button
  278. #define HTK_START_BTN _T("HTKStartBtn") // Text for "START OVER" button
  279. #define HX_SER_HD_STR _T("HXSERHd") // Header text for server page
  280. #define HX_SER_TXT_STR _T("HXSERTxt") // Body text for server page
  281. #define HX_SER_MS_STR _T("HXSERMs") // NOT CURRENTLY USED 3/98. For service page,
  282. // offers option of downloading a TS from
  283. // Microsoft's site.
  284. #define HX_SKIP_HD_STR _T("HXSKIPHd") // Header for "skip" page (e.g. "This
  285. // troubleshooter was unable to solve your
  286. // problem.")
  287. #define HX_SKIP_TXT_STR _T("HXSKIPTxt") // Text for "skip" page (e.g."Some questions
  288. // were skipped. Try providing answers..."
  289. #define HX_SKIP_MS_STR _T("HXSKIPMs") // NOT CURRENTLY USED 3/98. For skip page,
  290. // offers option of downloading a TS from
  291. // Microsoft's site.
  292. #define HX_SKIP_SK_STR _T("HXSKIPSk") // for "skip" page (e.g. "I want to see the
  293. // questions that I skipped.")
  294. #define HX_IMP_HD_STR _T("HXIMPHd") // Header text for "impossible" page
  295. #define HX_IMP_TXT_STR _T("HXIMPTxt") // Body text for "impossible" page
  296. #define HX_FAIL_HD_STR _T("HXFAILHd") // Header text for "fail" page
  297. #define HX_FAIL_TXT_STR _T("HXFAILTxt") // Body text for "fail" page
  298. #define HX_FAIL_NORM_STR _T("HXFAILNorm") // NOT CURRENTLY USED 3/98.
  299. #define HX_BYE_HD_STR _T("HXBYEHd") // Header text for "Bye" (success) page
  300. #define HX_BYE_TXT_STR _T("HXBYETxt") // Body text for "Bye" (success) page
  301. #define HX_SNIFF_AOK_HD_STR _T("HXSnOkHd") // Header text for "Sniff AOK" page (page
  302. // you hit when there is nothing at all to
  303. // recommend for a problem because sniffing
  304. // says every single node on the path is OK)
  305. // If missing, "fail" page header should be
  306. // used
  307. #define HX_SNIFF_AOK_TXT_STR _T("HXSnOkTxt") // Body text for "Sniff AOK" page
  308. // If missing, "fail" page body should be
  309. // used
  310. //------------- Event Handling ---------------
  311. // event name (goes under application)
  312. #define REG_EVT_ITEM_STR _T("APGTS")
  313. // event prototypes
  314. VOID ReportWFEvent(LPTSTR string1,LPTSTR string2,LPTSTR string3,LPTSTR string4,DWORD eventID);