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.

149 lines
4.2 KiB

  1. //+------------------------------------------------------------------
  2. //
  3. // File: cbaseall.cxx
  4. //
  5. // Contents: implementation for base class for all command line
  6. // classes, both the individual command line object
  7. // classes and the overall parsing class
  8. //
  9. // Synoposis: This base class contains the print function pointer
  10. // the default print implementation and the constructor
  11. // error value.
  12. //
  13. // Classes: CBaseCmdline
  14. //
  15. // Functions:
  16. //
  17. // History: 12/27/91 Lizch Created
  18. // 04/17/92 Lizch Converted to NLS_STR
  19. // 09/09/92 Lizch Changed SUCCESS to NO_ERROR
  20. // 09/18/92 Lizch Precompile headers
  21. // 10/13/93 DeanE Converted to WCHAR
  22. //
  23. //-------------------------------------------------------------------
  24. #include <comtpch.hxx>
  25. #pragma hdrstop
  26. #include <cmdlinew.hxx> // public cmdlinew stuff
  27. #include "_clw.hxx" // private cmdlinew stuff
  28. #include <ctype.h> // is functions
  29. void DefaultDisplayMethod(LPCNSTR nszMessage);
  30. void (* CBaseCmdline::_pfnDisplay)(LPCNSTR nszMessage) = DefaultDisplayMethod;
  31. NCHAR CBaseCmdline::_nszErrorBuf[];
  32. //+------------------------------------------------------------------
  33. //
  34. // Function: CBaseCmdline Constructor
  35. //
  36. // Member: CBaseCmdline
  37. //
  38. // Synoposis: Initialises error string and print function pointer
  39. //
  40. // History: Created 05/17/92 Lizch
  41. //
  42. //-------------------------------------------------------------------
  43. CBaseCmdline::CBaseCmdline()
  44. {
  45. _pfnDisplay = DefaultDisplayMethod;
  46. _iLastError = CMDLINE_NO_ERROR;
  47. }
  48. //+------------------------------------------------------------------
  49. //
  50. // Function: CBaseCmdline::SetDisplayMethod, public
  51. //
  52. // Member: CBaseCmdline
  53. //
  54. // Synoposis: Sets the print function pointer to the passed value. This
  55. // enables client programs to replace the default printf
  56. // print method with their own (eg. wprintf).
  57. //
  58. // Arguments: [pfnNewDisplayMethod] - Function pointer that replaces
  59. // current display function.
  60. //
  61. // Returns: none
  62. //
  63. // History: Created 05/17/92 Lizch
  64. //
  65. //-------------------------------------------------------------------
  66. void CBaseCmdline::SetDisplayMethod(
  67. void (* pfnNewDisplayMethod)(LPCNSTR nszMessage))
  68. {
  69. _pfnDisplay = pfnNewDisplayMethod;
  70. }
  71. //+------------------------------------------------------------------
  72. //
  73. // Function: DefaultDisplayMethod
  74. //
  75. // Synoposis: Used to wrap the printf function to get around problems
  76. // equating a function pointer expecting a char * to the
  77. // printf function expecting (char *,...)
  78. //
  79. // Arguments: [nszMessage] - Message to display.
  80. //
  81. // Returns: none
  82. //
  83. // History: Created 05/17/92 Lizch
  84. //
  85. //-------------------------------------------------------------------
  86. void DefaultDisplayMethod(LPCNSTR nszMessage)
  87. {
  88. _nprintf(_TEXTN("%s"), nszMessage);
  89. }
  90. //+------------------------------------------------------------------
  91. //
  92. // Function: CBaseCmdline::QueryError, public
  93. //
  94. // Member: CBaseCmdline
  95. //
  96. // Synoposis: Returns the internal error indicator and resets it
  97. // to CMDLINE_NO_ERROR.
  98. //
  99. // Effects: sets _iLastError to CMDLINE_NO_ERROR.
  100. //
  101. // Arguments: none
  102. //
  103. // Returns: the last error
  104. //
  105. // History: Created 05/17/92 Lizch
  106. //
  107. //-------------------------------------------------------------------
  108. INT CBaseCmdline::QueryError()
  109. {
  110. INT iLastError = _iLastError;
  111. SetError(CMDLINE_NO_ERROR);
  112. return(iLastError);
  113. }
  114. //+------------------------------------------------------------------
  115. //
  116. // Function: CBaseCmdline::SetError, public
  117. //
  118. // Member: CBaseCmdline
  119. //
  120. // Synoposis: Sets the internal error indicator to the passed value
  121. //
  122. // Effects: sets _iLastError to passed value.
  123. //
  124. // Arguments: [iLastError] - the new error value
  125. //
  126. // Returns: nothing
  127. //
  128. // History: Created 05/17/92 Lizch
  129. //
  130. //-------------------------------------------------------------------
  131. void CBaseCmdline::SetError(INT iLastError)
  132. {
  133. _iLastError = iLastError;
  134. }