Source code of Windows XP (NT5)
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.

171 lines
2.6 KiB

  1. /*++ BUILD Version: 0000 // Increment this if a change has global effects
  2. Copyright (c) 2000-2002 Microsoft Corporation
  3. Module Name:
  4. util.h
  5. Abstract:
  6. Header file for utility functions / classes
  7. Author:
  8. Xiaohai Zhang (xzhang) 22-March-2000
  9. Revision History:
  10. --*/
  11. #ifndef __UTIL_H__
  12. #define __UTIL_H__
  13. #include "tchar.h"
  14. #include "error.h"
  15. #include "resource.h"
  16. int MessagePrint(
  17. LPTSTR szText,
  18. LPTSTR szTitle
  19. );
  20. int MessagePrintIds (
  21. int idsText
  22. );
  23. LPTSTR AppendStringAndFree (
  24. LPTSTR szOld,
  25. LPTSTR szToAppend
  26. );
  27. void ReportError (
  28. HANDLE hFile,
  29. HRESULT hr
  30. );
  31. class TsecCommandLine
  32. {
  33. public:
  34. //
  35. // Constructor/destructor
  36. //
  37. TsecCommandLine (LPTSTR szCommand)
  38. {
  39. m_fShowHelp = FALSE;
  40. m_fError = FALSE;
  41. m_fValidateOnly = FALSE;
  42. m_fValidateDU = FALSE;
  43. m_fDumpConfig = FALSE;
  44. m_szInFile = NULL;
  45. ParseCommandLine (szCommand);
  46. }
  47. ~TsecCommandLine ()
  48. {
  49. if (m_szInFile)
  50. {
  51. delete [] m_szInFile;
  52. }
  53. }
  54. BOOL FShowHelp ()
  55. {
  56. return m_fShowHelp;
  57. }
  58. BOOL FValidateOnly()
  59. {
  60. return m_fValidateOnly;
  61. }
  62. BOOL FError()
  63. {
  64. return m_fError;
  65. }
  66. BOOL FValidateUser ()
  67. {
  68. return m_fValidateDU;
  69. }
  70. BOOL FDumpConfig ()
  71. {
  72. return m_fDumpConfig;
  73. }
  74. BOOL FHasFile ()
  75. {
  76. return ((m_szInFile != NULL) && (*m_szInFile != 0));
  77. }
  78. LPCTSTR GetInFileName ()
  79. {
  80. return m_szInFile;
  81. }
  82. void PrintUsage()
  83. {
  84. MessagePrintIds (IDS_USAGE);
  85. }
  86. private:
  87. void ParseCommandLine (LPTSTR szCommand);
  88. private:
  89. BOOL m_fShowHelp;
  90. BOOL m_fValidateOnly;
  91. BOOL m_fError;
  92. BOOL m_fValidateDU;
  93. BOOL m_fDumpConfig;
  94. LPTSTR m_szInFile;
  95. };
  96. #define MAX_IDS_BUFFER_SIZE 512
  97. class CIds
  98. {
  99. public:
  100. //
  101. // Constructor/destructor
  102. //
  103. CIds (UINT resourceID)
  104. {
  105. GetModuleHnd ();
  106. LoadIds (resourceID);
  107. }
  108. ~CIds ()
  109. {
  110. if (m_szString)
  111. {
  112. delete [] m_szString;
  113. }
  114. }
  115. LPTSTR GetString (void)
  116. {
  117. return (m_szString ? m_szString : (LPTSTR) m_szEmptyString);
  118. }
  119. BOOL StringFound (void)
  120. {
  121. return (m_szString != NULL);
  122. }
  123. private:
  124. void LoadIds (UINT resourceID);
  125. void GetModuleHnd (void);
  126. private:
  127. LPTSTR m_szString;
  128. static const TCHAR m_szEmptyString[2];
  129. static HMODULE m_hModule;
  130. };
  131. #endif // util.h