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.

190 lines
4.1 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1998 - 1999
  3. Module Name:
  4. tclRdCmd
  5. Abstract:
  6. This header file describes the Tcl Command Line parser object.
  7. Author:
  8. Doug Barlow (dbarlow) 3/14/1998
  9. Environment:
  10. Win32, C++ w/ exceptions, Tcl
  11. --*/
  12. #ifndef _TCLRDCMD_H_
  13. #define _TCLRDCMD_H_
  14. extern "C" {
  15. #include <tcl.h>
  16. }
  17. #ifndef _LPCBYTE_DEFINED
  18. #define _LPCBYTE_DEFINED
  19. typedef const BYTE *LPCBYTE;
  20. #endif
  21. #ifndef _LPCVOID_DEFINED
  22. #define _LPCVOID_DEFINED
  23. typedef const VOID *LPCVOID;
  24. #endif
  25. #include <scardlib.h>
  26. #define SZ(x) ((LPSTR)((LPCSTR)(x)))
  27. typedef struct {
  28. LPCTSTR szValue;
  29. LONG lValue;
  30. } ValueMap;
  31. //
  32. //==============================================================================
  33. //
  34. // CRenderableData
  35. //
  36. class CRenderableData
  37. {
  38. public:
  39. typedef enum {
  40. Undefined,
  41. Text,
  42. Ansi,
  43. Unicode,
  44. Hexidecimal,
  45. File
  46. } DisplayType;
  47. // Constructors & Destructor
  48. CRenderableData();
  49. ~CRenderableData();
  50. // Properties
  51. // Methods
  52. void LoadData(LPCTSTR szData, DisplayType dwType = Undefined);
  53. void LoadData(LPCBYTE pbData, DWORD cbLength)
  54. { m_bfData.Set(pbData, cbLength); };
  55. LPCTSTR RenderData(DisplayType dwType = Undefined);
  56. LPCBYTE Value(void) const
  57. { return m_bfData.Access(); };
  58. DWORD Length(void) const
  59. { return m_bfData.Length(); };
  60. void SetDisplayType(DisplayType dwType)
  61. { m_dwType = dwType; };
  62. // Operators
  63. protected:
  64. // Properties
  65. DisplayType m_dwType;
  66. CBuffer m_bfData;
  67. CString m_szString;
  68. CString m_szFile;
  69. // Methods
  70. // Friends
  71. friend class CTclCommand;
  72. };
  73. //
  74. //==============================================================================
  75. //
  76. // CArgArray
  77. //
  78. class CArgArray
  79. {
  80. public:
  81. // Constructors & Destructor
  82. CArgArray(CTclCommand &tclCmd);
  83. virtual ~CArgArray();
  84. void LoadList(LPCSTR szList);
  85. DWORD Count(void) const
  86. { return m_dwElements; };
  87. void Fetch(DWORD dwIndex, CString &szValue) const
  88. { szValue = m_rgszElements[dwIndex]; };
  89. // Properties
  90. // Methods
  91. // Operators
  92. protected:
  93. // Properties
  94. CTclCommand *m_pTclCmd;
  95. CDynamicArray<CHAR> m_rgszElements;
  96. LPSTR *m_pszMemory;
  97. DWORD m_dwElements;
  98. // Methods
  99. };
  100. //
  101. //==============================================================================
  102. //
  103. // CTclCommand
  104. //
  105. class CTclCommand
  106. {
  107. public:
  108. // Constructors & Destructor
  109. CTclCommand(void);
  110. CTclCommand(IN Tcl_Interp *interp, IN int argc, IN char *argv[]);
  111. ~CTclCommand();
  112. // Properties
  113. // Methods
  114. void Initialize(IN Tcl_Interp *interp, IN int argc, IN char *argv[]);
  115. void SetError(IN DWORD dwError);
  116. void SetError(IN LPCTSTR szMessage, IN DWORD dwError);
  117. void SetError(IN LPCTSTR szMsg1, ...);
  118. DWORD TclError(void);
  119. LONG Keyword(IN LPCTSTR szKey, ...);
  120. BOOL IsMoreArguments(DWORD dwCount = 1) const;
  121. void NoMoreArguments(void);
  122. void PeekArgument(CString &szToken);
  123. void NextArgument(void);
  124. void NextArgument(CString &szToken);
  125. DWORD BadSyntax(LPCTSTR szOffender = NULL);
  126. void GetArgument(DWORD dwArgId, CString &szToken);
  127. LONG Value(void);
  128. LONG Value(LONG lDefault);
  129. LONG MapValue(const ValueMap *rgvmMap, BOOL fValueOk = TRUE);
  130. LONG MapValue(const ValueMap *rgvmMap, CString &szValue, BOOL fValueOk = TRUE);
  131. DWORD MapFlags(const ValueMap *rgvmMap, BOOL fValueOk = TRUE);
  132. void OutputStyle(CRenderableData &outData);
  133. void InputStyle(CRenderableData &inData);
  134. void IOStyle(CRenderableData &inData, CRenderableData &outData);
  135. void Render(CRenderableData &outData);
  136. void ReadData(CRenderableData &inData);
  137. // Operators
  138. operator Tcl_Interp*()
  139. { return m_pInterp; };
  140. protected:
  141. // Properties
  142. BOOL m_fErrorDeclared;
  143. Tcl_Interp *m_pInterp;
  144. DWORD m_dwArgCount;
  145. DWORD m_dwArgIndex;
  146. char **m_rgszArgs;
  147. // Methods
  148. void Constructor(void);
  149. };
  150. #endif // _TCLRDCMD_H_