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.

293 lines
4.3 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. Mode.hxx
  5. Abstract:
  6. Header file for the Mode utility
  7. Author:
  8. Ramon Juan San Andres (ramonsa) 26-Jun-1991
  9. Revision History:
  10. --*/
  11. #include "ulib.hxx"
  12. #include "smsg.hxx"
  13. #include "wstring.hxx"
  14. #include "rtmsg.h"
  15. // ==================================================================
  16. //
  17. // Types
  18. //
  19. // ==================================================================
  20. //
  21. // Device types
  22. //
  23. typedef enum _DEVICE_TTYPE {
  24. DEVICE_TYPE_LPT = 0,
  25. DEVICE_TYPE_COM = 1,
  26. DEVICE_TYPE_CON = 2,
  27. DEVICE_TYPE_ALL = 3
  28. } DEVICE_TTYPE, *PDEVICE_TTYPE;
  29. //
  30. // Number of device types
  31. //
  32. #define NUMBER_OF_DEVICE_TYPES (DEVICE_TYPE_ALL + 1)
  33. #define LAST_LPT 9
  34. #define LAST_COM 9
  35. //
  36. // Request types
  37. //
  38. typedef enum _REQUEST_TYPE {
  39. //
  40. // NULL request (for operations accepted but that are no-ops )
  41. //
  42. REQUEST_TYPE_NULL,
  43. //
  44. // Requests common to 2 or more devices
  45. //
  46. REQUEST_TYPE_STATUS,
  47. REQUEST_TYPE_CODEPAGE_PREPARE,
  48. REQUEST_TYPE_CODEPAGE_SELECT,
  49. REQUEST_TYPE_CODEPAGE_REFRESH,
  50. REQUEST_TYPE_CODEPAGE_STATUS,
  51. //
  52. // LPT
  53. //
  54. REQUEST_TYPE_LPT_SETUP,
  55. REQUEST_TYPE_LPT_REDIRECT,
  56. REQUEST_TYPE_LPT_ENDREDIR,
  57. //
  58. // COM
  59. //
  60. REQUEST_TYPE_COM_SET,
  61. //
  62. // CONSOLE
  63. //
  64. REQUEST_TYPE_CON_SET_ROWCOL,
  65. REQUEST_TYPE_CON_SET_TYPEMATIC
  66. } REQUEST_TYPE, *PREQUEST_TYPE;
  67. //
  68. // Request packet header
  69. //
  70. typedef struct _REQUEST_HEADER {
  71. DEVICE_TTYPE DeviceType; // Device type
  72. LONG DeviceNumber; // Device number
  73. PWSTRING DeviceName; // Optional device name
  74. REQUEST_TYPE RequestType; // Request type
  75. } REQUEST_HEADER, *PREQUEST_HEADER;
  76. //
  77. // ALL_DEVICES is a magic DeviceNumber that means "all devices available
  78. // of this type"
  79. //
  80. #define ALL_DEVICES ((LONG)-1)
  81. //
  82. // Device handler. A device handler is the function that takes care of
  83. // handling all requests for a device. There is one per device type.
  84. //
  85. typedef BOOLEAN( *DEVICE_HANDLER )( IN PREQUEST_HEADER Request );
  86. // ==================================================================
  87. //
  88. // Macros
  89. //
  90. // ==================================================================
  91. //
  92. // Exit codes
  93. //
  94. #define EXIT_SUCCESS 0
  95. #define EXIT_ERROR ((int)-1)
  96. // ==================================================================
  97. //
  98. // Global Data
  99. //
  100. // ==================================================================
  101. //
  102. // The message stream, for displaying messages
  103. //
  104. extern PSTREAM_MESSAGE Message;
  105. //
  106. // DeviceHandler is an array of pointers to the different device
  107. // handlers.
  108. //
  109. extern DEVICE_HANDLER DeviceHandler[];
  110. // ==================================================================
  111. //
  112. // Prototypes
  113. //
  114. // ==================================================================
  115. //
  116. // Argument.hxx
  117. //
  118. PREQUEST_HEADER
  119. GetRequest(
  120. );
  121. VOID
  122. ParseError (
  123. );
  124. //
  125. // common.cxx
  126. //
  127. BOOLEAN
  128. CommonHandler(
  129. IN PREQUEST_HEADER Request
  130. );
  131. BOOLEAN
  132. IsAValidDevice (
  133. IN DEVICE_TTYPE DeviceType,
  134. IN ULONG DeviceNumber,
  135. OUT PPATH *DeviceName
  136. );
  137. BOOLEAN
  138. IsAValidLptDevice (
  139. IN DEVICE_TTYPE DeviceType,
  140. IN ULONG DeviceNumber,
  141. OUT PPATH *DeviceName
  142. );
  143. BOOLEAN
  144. IsAValidCommDevice (
  145. IN DEVICE_TTYPE DeviceType,
  146. IN ULONG DeviceNumber,
  147. OUT PPATH *DeviceName
  148. );
  149. BOOLEAN
  150. WriteStatusHeader (
  151. IN PCPATH DevicePath
  152. );
  153. //
  154. // lpt.cxx
  155. //
  156. BOOLEAN
  157. LptHandler(
  158. IN PREQUEST_HEADER Request
  159. );
  160. //
  161. // Com.cxx
  162. //
  163. BOOLEAN
  164. ComAllocateStuff(
  165. );
  166. BOOLEAN
  167. ComDeAllocateStuff(
  168. );
  169. BOOLEAN
  170. ComHandler(
  171. IN PREQUEST_HEADER Request
  172. );
  173. //
  174. // con.cxx
  175. //
  176. BOOLEAN
  177. ConHandler(
  178. IN PREQUEST_HEADER Request
  179. );
  180. //
  181. // support.cxx
  182. //
  183. VOID
  184. DisplayMessage (
  185. IN MSGID MsgId,
  186. IN PCWSTRING String
  187. );
  188. VOID
  189. DisplayMessageAndExit (
  190. IN MSGID MsgId,
  191. IN PCWSTRING String,
  192. IN ULONG ExitCode
  193. );
  194. PWSTRING
  195. QueryMessageString (
  196. IN MSGID MsgId
  197. );
  198. VOID
  199. ExitWithError(
  200. IN DWORD ErrorCode
  201. );
  202. VOID
  203. ExitMode(
  204. IN DWORD ExitCode
  205. );
  206. PSTREAM
  207. Get_Standard_Input_Stream();
  208. PSTREAM
  209. Get_Standard_Output_Stream();
  210. PSTREAM
  211. Get_Standard_Error_Stream();