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.

215 lines
7.3 KiB

  1. /*****************************************************************************
  2. *
  3. * $Workfile: TcpMon.h $
  4. *
  5. * Copyright (C) 1997 - 1999 Hewlett-Packard Company.
  6. * Copyright (C) 1997 - 1999 Microsoft Corporation.
  7. * All rights reserved.
  8. *
  9. * 11311 Chinden Blvd.
  10. * Boise, Idaho 83714
  11. *
  12. *****************************************************************************/
  13. #ifndef INC_HPSPPMON_H
  14. #define INC_HPSPPMON_H
  15. #include <wininet.h>
  16. #include <splcom.h>
  17. #include "debug.h"
  18. #include "tcpxcv.h"
  19. typedef BOOL (* SETPORTPARAM)(LPTSTR, LPTSTR, DWORD, LPBYTE);
  20. typedef BOOL (* ENUMPORTPARAM)(LPTSTR, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD);
  21. // externs
  22. extern int g_cntGlobalAlloc;
  23. extern int g_csGlobalCount;
  24. extern HINSTANCE g_hInstance;
  25. extern HINSTANCE g_hTcpMib;
  26. extern HINSTANCE g_hSpoolLib;
  27. extern SETPORTPARAM g_pfnSetPort;
  28. extern ENUMPORTPARAM g_pfnEnumPorts;
  29. // Additional Dll's
  30. #define TCPMIB_DLL_NAME TEXT("tcpmib.dll")
  31. // macros
  32. #define ENTER_CRITICAL_SECTION(cs, fn, ln, csrc) ( debugCSect("DEBUG -- EnterCriticalSection count = ", ++g_csGlobalCount, fn, ln, csrc), EnterCriticalSection(cs) )
  33. #define EXIT_CRITICAL_SECTION(cs, fn, ln, csrc) ( debugCSect("DEBUG -- ExitCriticalSection count = ", --g_csGlobalCount, fn, ln, csrc), LeaveCriticalSection(cs) )
  34. #if defined (UNICODE) || defined (_UNICODE)
  35. #define MBCS_TO_UNICODE(dest, destsize, src) \
  36. { \
  37. _ASSERTE(strlen(src)<(size_t)destsize); /* make sure dest is big enough -- should a bigger buffer be allocated? */ \
  38. MultiByteToWideChar(CP_ACP, 0L, src, -1, dest, destsize); \
  39. (dest)[destsize - 1 ] = '\0'; \
  40. }
  41. #define UNICODE_TO_MBCS(dest, destsize, src, srcsize) \
  42. { \
  43. _ASSERTE((int)srcsize == -1 || _tcslen(src)<=(size_t)srcsize); /* make sure the source string did not go past the provided buffer size */ \
  44. WideCharToMultiByte(CP_ACP, 0L, src, -1, dest, destsize, NULL, NULL); \
  45. (dest)[destsize - 1 ] = '\0'; \
  46. }
  47. #define SIZEOF_IN_CHAR(buf) (sizeof(buf)/sizeof(buf[0]))
  48. #define STRLEN_IN_BYTES(buf) (_tcslen(buf)*sizeof(TCHAR)) // String length in bytes
  49. #define STRLENN_IN_BYTES(buf) (_tcslen(buf)*sizeof(TCHAR)+sizeof(TCHAR)) // string length including NULL terminator
  50. #endif
  51. // Required Winsock version info
  52. #define WS_VERSION_REQUIRED (0x0101) // WinSock V1.1 is required
  53. #define WS_VERSION_MAJOR HIBYTE(WS_VERSION_REQUIRED)
  54. #define WS_VERSION_MINOR LOBYTE(WS_VERSION_REQUIRED)
  55. // strings
  56. #define NULLSTR TEXT("");
  57. #ifdef HP_BUILD
  58. #define PORTMONITOR_CLASS_NAME TEXT("STDTCPMON")
  59. #define PORTMONITOR_HELP_FILE TEXT("HPTCPMUI.HLP")
  60. #define PORTMONITOR_NAME TEXT("HPTCPMON.DLL")
  61. #define PORTMONITOR_UI_NAME TEXT("HPTcpMUI.dll")
  62. #define PORTMONITOR_DESC TEXT("HP Standard TCP/IP Port")
  63. #define SZEVENTLOG_NAME TEXT("HPTcpMon")
  64. #define PORTMONITOR_INI_FILE TEXT("\\HPTcpMon.ini")
  65. #else
  66. #define PORTMONITOR_CLASS_NAME TEXT("HPJETADMIN")
  67. #define PORTMONITOR_HELP_FILE TEXT("TCPMON.HLP")
  68. #define PORTMONITOR_NAME TEXT("TCPMON.DLL")
  69. #define PORTMONITOR_UI_NAME TEXT("TCPMonUI.dll")
  70. #define PORTMONITOR_DESC TEXT("Standard TCP/IP Port")
  71. #define SZEVENTLOG_NAME TEXT("TCPMon")
  72. #define PORTMONITOR_INI_FILE TEXT("\\TcpMon.ini")
  73. #endif
  74. #define DEFAULT_SNMP_COMMUNITYA "public"
  75. #define DEFAULT_SNMP_COMUNITY TEXT( DEFAULT_SNMP_COMMUNITYA )
  76. #define DEFAULT_QUEUE TEXT( "LPR" )
  77. #define TCP_PROTOCOL TEXT( "TCP_IP" )
  78. // Defaults
  79. #define DEFAULT_PORT_NUMBER 9100
  80. #define DEFAULT_PROTOCOL 1
  81. #define DEFAULT_VERSION 1
  82. // SNMP Constants
  83. #define DEFAULT_SNMP_DEVICE_INDEX 1
  84. // lengths
  85. #define MAX_SECTION_NAME 64
  86. #define MAX_PRINTERNAME_LEN MAX_UNC_PRINTER_NAME // printer name
  87. #define MAX_FULLY_QUALIFIED_HOSTNAME_LEN 128 // fully qualified hostname length
  88. #define MAX_PORT_DESCRIPTION_LEN 256
  89. #define MAX_NUM_OF_DEVICEPORTS 1024
  90. //Status Constants
  91. #define PORT_STATUS_IDLE 0
  92. #define PORT_STATUS_ERROR 1
  93. #define PORT_STATUS_PRINTING 2
  94. #define STATUS_ERROR_FACTOR 20
  95. #define STATUS_PRINTINT_FACTOR 10
  96. #define STATUS_ERROR_MIN 10 // Seconds
  97. class CPortMgr;
  98. #define MONITOR_SIGNATURE (0xE9324C33)
  99. typedef struct _MONITOR_HANDLE {
  100. DWORD cb;
  101. DWORD dSignature;
  102. CPortMgr *pPortMgr;
  103. } MONITOR_HANDLE, *PMONITOR_HANDLE;
  104. typedef struct _SNMP_INFO
  105. {
  106. TCHAR sztSNMPCommunity[MAX_SNMP_COMMUNITY_STR_LEN];
  107. TCHAR sztAddress[MAX_NETWORKNAME_LEN];
  108. DWORD dwSNMPEnabled;
  109. DWORD dwSNMPDeviceIndex;
  110. } SNMP_INFO, *PSNMP_INFO;
  111. // This must be included after the length definitions because
  112. // the structures in it depend on these definitions.
  113. #define SPOOLER_SUPPORTED_LEVEL 2 // spooler supported level
  114. #ifdef __cplusplus
  115. extern "C" {
  116. #endif
  117. DWORD EncodeMonitorHandle( PHANDLE phMonitor, CPortMgr *pPortMgr );
  118. DWORD ValidateMonitorHandle( HANDLE hMonitor );
  119. DWORD FreeMonitorHandle( HANDLE hMonitor );
  120. BOOL WINAPI EndDocPort (HANDLE hPort);
  121. BOOL WINAPI StartDocPort(HANDLE hPort,
  122. LPTSTR pPrinterName,
  123. DWORD jobId,
  124. DWORD level,
  125. LPBYTE pDocInfo);
  126. BOOL AddPortExW(LPTSTR psztName,
  127. DWORD Level,
  128. LPBYTE lpBuffer,
  129. LPTSTR psztMonitorName);
  130. BOOL WINAPI AddPortUIEx(LPBYTE pData);
  131. BOOL WINAPI ConfigPortUIEx(const LPBYTE pData);
  132. BOOL ClusterOpenPort(HANDLE hcKey,
  133. LPTSTR pName,
  134. PHANDLE pHandle);
  135. BOOL ClusterXcvOpenPort( HANDLE hcKey,
  136. LPCTSTR pszObject,
  137. ACCESS_MASK GrantedAccess,
  138. PHANDLE phXcv);
  139. BOOL ClusterAddPort(HANDLE hcKey,
  140. LPTSTR psztName,
  141. HWND hWnd,
  142. LPTSTR psztMonitorName);
  143. BOOL ClusterAddPortExW( HANDLE hcKey,
  144. LPTSTR psztName,
  145. DWORD Level,
  146. LPBYTE lpBuffer,
  147. LPTSTR psztMonitorName);
  148. BOOL ClusterConfigurePort( HANDLE hcKey,
  149. LPTSTR psztName,
  150. HWND hWnd,
  151. LPTSTR psztPortName);
  152. BOOL ClusterDeletePort( HANDLE hcKey,
  153. LPTSTR psztName,
  154. HWND hWnd,
  155. LPTSTR psztPortName);
  156. BOOL ClusterEnumPorts( HANDLE hcKey,
  157. LPTSTR psztName,
  158. DWORD Level, // 1 (PORT_INFO_1) or 2 (PORT_INFO_2)
  159. LPBYTE pPorts, // port data is written to
  160. DWORD cbBuf, // buffer size of pPorts points to
  161. LPDWORD pcbNeeded, // needed buffer size
  162. LPDWORD pcReturned) ; // number of structs written to pPorts
  163. VOID ClusterShutdown( HANDLE hTcpMon );
  164. _inline char *strncpyn(char *pszdest, const char *pszsrc, size_t n) {
  165. (strncpy( pszdest, pszsrc, n))[n - 1] = NULL;
  166. return pszdest;
  167. }
  168. #ifdef __cplusplus
  169. }
  170. #endif
  171. #endif // INC_HPSPPMON_H