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.

324 lines
7.5 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. #ifndef SIMC_UI_H
  5. #define SIMC_UI_H
  6. typedef CList<CString, const CString&> SIMCFileList;
  7. typedef CList<CString, const CString&> SIMCPathList;
  8. /*
  9. * This class has methods for parsing and storing the information
  10. * in the command-line, used to invoke the SNMP compiler
  11. */
  12. class SIMCUI
  13. {
  14. public:
  15. enum CommandArgumentType;
  16. private:
  17. // Error Messages that can occur on the commandline
  18. // 1-to-1 correspondence with the symbolic error constants
  19. // defined by the enum ErrorMessageSymbol below
  20. static const char * const commandLineErrors[];
  21. int _snmpVersion;
  22. BOOL _simcDebug;
  23. CString _inputFileOrModuleName;
  24. int _diagnosticLevel;
  25. long _diagnosticMaximumCount;
  26. CommandArgumentType _commandArgument;
  27. BOOL _suppressText; // Set by the /s switch
  28. BOOL _classDefinitionsOnly; // Set by the /gc switch
  29. BOOL _notificationsOnly; // Set by the /o switch
  30. BOOL _extendedNotifications;// Set by the /ext switch
  31. BOOL _notifications ; // Set by the /t switche
  32. BOOL _autoRefresh; // Set by the /auto switch
  33. BOOL _contextInfo; // Set by the /c switch
  34. BOOL _authenticateUser; // Set by the /u switch
  35. BOOL _confirmedPurge; // Set by the /y switch
  36. // The exe in the command used to invoke the compiler. argv[0]
  37. CString _applicationName;
  38. CString _commandLine;
  39. CString _currentDirectory;
  40. CString _userName;
  41. CString _dateAndTime;
  42. CString _hostName;
  43. SIMCFileList _subsidiaryFiles;
  44. SIMCPathList _includePaths;
  45. CString _authenticationUserName;
  46. void CheckIncludePaths(int& nextArg, int argc, const char *argv[]);
  47. public:
  48. // Symbolic constants for the various error messages on the command-line
  49. enum ErrorMessageSymbol
  50. {
  51. ERROR_NONE,
  52. USAGE,
  53. INVALID_ARGS,
  54. MISSING_DIAG_LEVEL,
  55. WRONG_DIAG_LEVEL,
  56. MISSING_DIAG_COUNT,
  57. WRONG_DIAG_COUNT,
  58. MISSING_FILE_NAME,
  59. MISSING_COMMAND_ARG,
  60. MISSING_MODULE_NAME,
  61. MISSING_INCLUDE_PATH,
  62. NOTIFICATIONS_ONLY_USELESS,
  63. INVALID_COMBINATION_OF_SWITCHES,
  64. INVALID_SWITCH,
  65. // And a delimiter. No error message corresponds to this.
  66. // Used to check up whether a symbolic value is within limits
  67. MAX_COMMAND_LINE_ERROR
  68. };
  69. // Symbolic constants for the action requested by the user on the module
  70. enum CommandArgumentType
  71. {
  72. COMMAND_NONE,
  73. COMMAND_LOCAL_CHECK,
  74. COMMAND_EXTERNAL_CHECK,
  75. COMMAND_ADD,
  76. COMMAND_SILENT_ADD,
  77. COMMAND_GENERATE,
  78. COMMAND_GENERATE_CLASSES_ONLY,
  79. COMMAND_DELETE,
  80. COMMAND_PURGE,
  81. COMMAND_LIST,
  82. COMMAND_HELP1,
  83. COMMAND_HELP2,
  84. COMMAND_MODULE_NAME,
  85. COMMAND_IMPORTS_INFO,
  86. COMMAND_REBUILD_TABLE,
  87. COMMAND_ADD_DIRECTORY,
  88. COMMAND_DELETE_DIRECTORY_ENTRY,
  89. COMMAND_LIST_MIB_PATHS,
  90. COMMAND_MAX
  91. };
  92. static CString commandArgumentStrings[COMMAND_MAX];
  93. static CString diagnosticLevelSwitch,
  94. maxDiagnosticCountSwitch,
  95. snmpV1VersionSwitch,
  96. snmpV2VersionSwitch,
  97. suppressTextSwitch,
  98. undocumentedDebugSwitch,
  99. includePathSwitch,
  100. autoSwitch,
  101. contextInfoSwitch,
  102. notificationsSwitch,
  103. notificationsOnlySwitch,
  104. extendedNotificationsSwitch,
  105. yesSwitch;
  106. SIMCUI();
  107. BOOL ProcessCommandLine(int argc, const char *argv[]);
  108. void Usage (ErrorMessageSymbol messageSymbol = ERROR_NONE,
  109. const char *infoString = NULL, BOOL shouldAbort = TRUE);
  110. inline int GetSnmpVersion() const { return _snmpVersion; }
  111. // These two functions get/set the main input MIB module
  112. inline void SetInputFileName(const char * const inputFileName)
  113. {
  114. _inputFileOrModuleName = inputFileName;
  115. }
  116. inline CString GetInputFileName() const
  117. {
  118. return _inputFileOrModuleName;
  119. }
  120. inline CString GetApplicationName() const
  121. {
  122. return _applicationName;
  123. }
  124. inline CString GetCommandLine() const
  125. {
  126. return _commandLine;
  127. }
  128. inline CString GetUserName() const
  129. {
  130. return _userName;
  131. }
  132. inline BOOL AuthenticateUser () const
  133. {
  134. return _authenticateUser;
  135. }
  136. inline CString GetProcessDirectory() const
  137. {
  138. return _currentDirectory;
  139. }
  140. inline CString GetDateAndTime() const
  141. {
  142. return _dateAndTime;
  143. }
  144. inline CString GetHostName() const
  145. {
  146. return _hostName;
  147. }
  148. inline BOOL ConfirmedPurge()
  149. {
  150. return _confirmedPurge;
  151. }
  152. // This is set by the undocumented /z switch
  153. BOOL IsSimcDebug() const
  154. {
  155. return _simcDebug;
  156. }
  157. // These two set the diagnostic level of the errors generated
  158. // No symbolic constants here. As specified in the requirements
  159. // spec, "diagnosticLevel" can be :
  160. // 0 - Fatal errors only
  161. // 1 - Fatal errors and Warnings
  162. // 2 - Fatal errors, Warnings and Information messages
  163. inline void SetDiagnosticLevel(const int diagnosticLevel = 0)
  164. {
  165. _diagnosticLevel = diagnosticLevel;
  166. }
  167. inline int GetDiagnosticLevel() const
  168. {
  169. return _diagnosticLevel;
  170. }
  171. // These two get/set the maximum diagnostic count
  172. inline void SetMaxDiagnosticCount(const int diagnosticMaximumCount = INT_MAX)
  173. {
  174. _diagnosticMaximumCount = diagnosticMaximumCount;
  175. }
  176. inline long GetMaxDiagnosticCount() const
  177. {
  178. return _diagnosticMaximumCount;
  179. }
  180. // These two deal with the action to be taken on the main
  181. // input file.
  182. inline CommandArgumentType GetCommandArgument() const
  183. {
  184. return _commandArgument;
  185. }
  186. inline void SetCommandArgument(CommandArgumentType commandArgument)
  187. {
  188. _commandArgument = commandArgument;
  189. }
  190. // These two deal with the /s switch
  191. inline BOOL SuppressText() const
  192. {
  193. return _suppressText;
  194. }
  195. inline void SetSuppressText( BOOL suppressText = FALSE)
  196. {
  197. _suppressText = suppressText;
  198. }
  199. // These two deal with the /auto switch
  200. inline BOOL AutoRefresh() const
  201. {
  202. return _autoRefresh;
  203. }
  204. inline void SetAutoRefresh( BOOL autoRefresh = FALSE)
  205. {
  206. _autoRefresh = autoRefresh;
  207. }
  208. // These two get/set the module specified on the /d switch
  209. inline CString GetModuleName() const
  210. {
  211. return _inputFileOrModuleName;
  212. }
  213. inline void SetModuleName( const CString& moduleName)
  214. {
  215. _inputFileOrModuleName = moduleName;
  216. }
  217. // These two get/set the subsidiary files
  218. inline const SIMCFileList *GetSubsidiaryFiles() const
  219. {
  220. return &_subsidiaryFiles;
  221. }
  222. inline void AddSubsidiaryFile( const CString& fileName)
  223. {
  224. _subsidiaryFiles.AddTail(fileName);
  225. }
  226. // These two get/set the path specified on the /pa and /px switch
  227. inline CString GetDirectory() const
  228. {
  229. return _inputFileOrModuleName;
  230. }
  231. inline void SetDirectory( const CString& directory)
  232. {
  233. _inputFileOrModuleName = directory;
  234. }
  235. // These two get/set the paths specified on the /i switch
  236. inline const SIMCPathList *GetPaths() const
  237. {
  238. return &_includePaths;
  239. }
  240. inline void AddPath( const CString& path)
  241. {
  242. _includePaths.AddTail(path);
  243. }
  244. // This is set by the /gc switch
  245. inline BOOL ClassDefinitionsOnly() const
  246. {
  247. return _classDefinitionsOnly;
  248. }
  249. // This is set by the /c switch
  250. inline BOOL GenerateContextInfo() const
  251. {
  252. return _contextInfo;
  253. }
  254. // This is set by the /t switch
  255. inline BOOL DoNotifications() const
  256. {
  257. return _notifications;
  258. }
  259. // This is set by the /ext switch
  260. inline BOOL DoExtendedNotifications() const
  261. {
  262. return _extendedNotifications;
  263. }
  264. // This is set by the /o switch
  265. inline BOOL DoNotificationsOnly() const
  266. {
  267. return _notificationsOnly;
  268. }
  269. // This gets the FileVersion resource from the resource of the exe
  270. CString GetVersionNumber();
  271. friend ostream& operator << ( ostream&, const SIMCUI&);
  272. };
  273. #endif // SIMC_UI_H