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.

184 lines
6.9 KiB

  1. /* com.hh -- Internal definitions for communications routines
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 3 $
  7. * $Date: 5/01/01 3:33p $
  8. */
  9. // -=-=-=-=-=-=-=-=-=-=-=-=-=- DEBUG CONTROL -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  10. // These constants are used to turn on various types of debug display
  11. // #define DBG_NORMAL
  12. // #define DBG_RCV
  13. // #define DBG_SEND
  14. #if defined(DBG_NORMAL)
  15. #define DEBUGSTR
  16. #define DBGOUT_NORMAL(s,a1,a2,a3,a4,a5) DbgOutStr(s,a1,a2,a3,a4,a5)
  17. #else
  18. #define DBGOUT_NORMAL(s,a1,a2,a3,a4,a5)
  19. #endif
  20. #if defined(DBG_RCV)
  21. #define DEBUGSTR
  22. #define DBGOUT_RCV(s,a1,a2,a3,a4,a5) DbgOutStr(s,a1,a2,a3,a4,a5)
  23. #else
  24. #define DBGOUT_RCV(s,a1,a2,a3,a4,a5)
  25. #endif
  26. #if defined(DBG_SEND)
  27. #define DEBUGSTR
  28. #define DBGOUT_SEND(s,a1,a2,a3,a4,a5) DbgOutStr(s,a1,a2,a3,a4,a5)
  29. #else
  30. #define DBGOUT_SEND(s,a1,a2,a3,a4,a5)
  31. #endif
  32. // -=-=-=-=-=-=-=-=-=-=-=-=-=- DEFINITIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  33. #define STANDARD_RBUFR_SIZE 100
  34. #define STANDARD_SBUFR_SIZE 100
  35. // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= TYPES =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  36. typedef struct
  37. {
  38. TCHAR szDeviceFile[MAX_PATH]; // Name of driver file
  39. TCHAR szPortName[COM_MAX_PORT_NAME]; // Name of individual port
  40. } ST_COM_SETTINGS;
  41. // This is the main com structure used to hang on to all the working details
  42. typedef struct s_com
  43. {
  44. // The s_com_control structure must always be the first item in this
  45. // structure so that a pointer to this structure can be cast into
  46. // a pointer to it.
  47. ST_COM_CONTROL stComCntrl; // The exported part of the structure
  48. // User-settable com values
  49. ST_COM_SETTINGS stFileSettings;
  50. ST_COM_SETTINGS stWorkSettings;
  51. // Control fields for com routines
  52. HSESSION hSession; // Session we belong to
  53. int fPortActive; // TRUE when port has been activated
  54. int fErrorReported; // TRUE if driver has encountered error
  55. HINSTANCE hDriverModule; // Handle of .DLL module
  56. TCHAR szDeviceName[COM_MAX_DEVICE_NAME]; // Name of device type
  57. TCHAR chDummy; // Dummy address for buffer pointers
  58. unsigned afOverride; // Allows tmp. override of com details
  59. HANDLE hRcvEvent; // Signalled whenever rcv data is avail
  60. HANDLE hSndReady; // Signalled whenever send is not busy
  61. // Control fields for sending:
  62. TCHAR * puchSendBufr1; // allocated buffers for holding
  63. TCHAR * puchSendBufr2; // chars. waiting to be sent
  64. TCHAR * puchSendBufr; // pointer to bufr being filled
  65. TCHAR * puchSendPut; // Insertion point in current buffer
  66. TCHAR auchDummyBufr[5]; // Place to rest idle pointers
  67. int nSBufrSize; // Size of send buffers
  68. int nSendCount; // Chars. in current bufr.
  69. int fUserCalled; // TRUE if status function called
  70. STATUSFUNCT pfUserFunction; // User supplied status function
  71. void (*pfIdleFunction)(void); // Registered idle function
  72. // These funtion pointers get set to point into whatever com device
  73. // driver is loaded. (If no driver is loaded or if the driver is invalid,
  74. // they are set to point to default, mostly do-nothing routines
  75. // There are two groups of function pointers, the first group is set to
  76. // point into the device driver as soon as the driver is loaded and stay
  77. // there until the driver us unloaded. The second group are not set to
  78. // point into the driver until an actual port is activated. These are
  79. // set to point back to default routines whenever the port is deactivated.
  80. // -------------------------------------------------------------------
  81. // These are the function pointers that point into the driver whenever
  82. // it is loaded.
  83. int (WINAPI *pfDeviceClose)(void *pvDevData);
  84. int (WINAPI *pfDeviceDialog)(void *pvDevData, HWND hwndParent);
  85. int (WINAPI *pfDeviceGetCommon)(void *pvDevData, ST_COMMON *pstCommon);
  86. int (WINAPI *pfDeviceSetCommon)(void *pvDevData, ST_COMMON *pstCommon);
  87. int (WINAPI *pfDeviceSpecial)(void *, const TCHAR *, TCHAR *, int);
  88. int (WINAPI *pfDeviceLoadHdl)(void *pvDevData, SF_HANDLE sfHdl);
  89. int (WINAPI *pfDeviceSaveHdl)(void *pvDevData, SF_HANDLE sfHdl);
  90. int (WINAPI *pfPortConfigure)(void *pvDevData);
  91. int (WINAPI *pfPortActivate)(void *pvDevData,
  92. TCHAR *pszPortName,
  93. DWORD_PTR dwMediaHdl);
  94. int (WINAPI *pfPortPreconnect)(void *pvDevData,
  95. TCHAR *pszPortName, HWND hwndParent);
  96. // These function pointers point into the driver only when a port has
  97. // been activated.
  98. int (WINAPI *pfPortDeactivate)(void *pvDevData);
  99. int (WINAPI *pfPortConnected)(void *pvDevData);
  100. int (WINAPI *pfRcvRefill)(void *pvDevData);
  101. int (WINAPI *pfRcvClear)(void *pvDevData);
  102. int (WINAPI *pfSndBufrSend)(void *pvDevData,
  103. void *pvBufr, int nCount);
  104. int (WINAPI *pfSndBufrIsBusy)(void *pvDevData);
  105. int (WINAPI *pfSndBufrClear)(void *pvDevData);
  106. int (WINAPI *pfSndBufrQuery)(void *pvDevData, unsigned *pafStatus,
  107. long *plHandshakeDelay);
  108. int (WINAPI *pfSendXon)(void *pvDevData);
  109. //----------------------------------------------------------------------
  110. void * pvDriverData; // Space for drivers data
  111. unsigned nGuard; // to check for memory overwrites
  112. } ST_COM;
  113. // -=-=-=-=-=-=-=-=-=-=-=- INTERNAL PROTOTYPES -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  114. extern void ComReportError(const HCOM pstCom,
  115. int iErrStr,
  116. const TCHAR * const pszOptInfo,
  117. const int fFirstOnly);
  118. extern void ComFreeDevice(const HCOM pstCom);
  119. extern int ComSendDefaultStatusFunction(int iReason,
  120. unsigned fusHsStatus, long lDelay);
  121. // These are the set of default functions that the function pointers in
  122. // the com handle point to when there is no com driver loaded or when
  123. // it is inactive
  124. int WINAPI ComDefDoNothing(void *pvDriverData);
  125. int WINAPI ComDefPortPreconnect(void *pvDriverData,
  126. TCHAR *pszPortName,
  127. HWND hwndParent);
  128. int WINAPI ComDefDeviceDialog(void *pvDriverData, HWND hwndParent);
  129. int WINAPI ComDefPortActivate(void *pvDriverData,
  130. TCHAR *pszPortName,
  131. DWORD_PTR dwMediaHdl);
  132. int WINAPI ComDefBufrRefill(void *pvDriverData);
  133. int WINAPI ComDefSndBufrSend(void *pvDriverData, void *pvBufr, int nCount);
  134. int WINAPI ComDefSndBufrBusy(void *pvDriverData);
  135. int WINAPI ComDefSndBufrClear(void *pvDriverData);
  136. int WINAPI ComDefSndBufrQuery(void *pvDriverData,
  137. unsigned *pafStatus,
  138. long *plHandshakeDelay);
  139. void WINAPI ComDefIdle(void);
  140. int WINAPI ComDefDeviceGetCommon(void *pvPrivate, ST_COMMON *pstCommon);
  141. int WINAPI ComDefDeviceSetCommon(void *pvPrivate, struct s_common *pstCommon);
  142. int WINAPI ComDefDeviceSpecial(void *pvPrivate,
  143. const TCHAR *pszInstructions,
  144. TCHAR *pszResult,
  145. int nBufrSize);
  146. int WINAPI ComDefDeviceLoadSaveHdl(void *pvPrivate, SF_HANDLE sfHdl);
  147. // Functions made available to driver .DLLs through func. pointers
  148. extern void * ComMalloc(size_t size);
  149. extern void ComFree(void *pvItem);