Source code of Windows XP (NT5)
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.

213 lines
6.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: U P D I A G P . H
  7. //
  8. // Contents: Private definitions for UPDIAG
  9. //
  10. // Notes:
  11. //
  12. // Author: danielwe 28 Oct 1999
  13. //
  14. //----------------------------------------------------------------------------
  15. #ifndef _UPDIAGP_H
  16. #define _UPDIAGP_H
  17. #include <wininet.h>
  18. #include <stdio.h>
  19. #include "ssdpapi.h"
  20. #include "updiag.h"
  21. #include "util.h"
  22. typedef BOOL (* PFNCMD)(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  23. static const DWORD MAX_DEV = 32;
  24. static const DWORD MAX_SVC = 32;
  25. static const DWORD MAX_EVTSRC = MAX_SVC;
  26. static const DWORD MAX_CD = 100;
  27. static const DWORD MAX_UCP = 5;
  28. static const DWORD MAX_ARGS = 8;
  29. static const DWORD MAX_RESULT = 32;
  30. static const DWORD MAX_RESULT_MSGS = 256;
  31. static const DWORD MAX_DEV_STACK = 8;
  32. static const TCHAR c_szSeps[] = TEXT(" \n\r\t");
  33. struct COMMAND
  34. {
  35. LPCTSTR szCommand;
  36. LPCTSTR szCmdDesc;
  37. DWORD dwCtx;
  38. BOOL fValidOnMillen;
  39. PFNCMD pfnCommand;
  40. LPCTSTR szUsage;
  41. };
  42. struct UPNPDEV
  43. {
  44. BOOL fRoot;
  45. UPNPSVC * rgSvcs[MAX_SVC];
  46. DWORD cSvcs;
  47. UPNPDEV * rgDevs[MAX_DEV];
  48. DWORD cDevs;
  49. TCHAR szFriendlyName[256];
  50. TCHAR szUdn[256];
  51. TCHAR szDeviceType[256];
  52. TCHAR szPresentationUrl[256];
  53. TCHAR szManufaturer[256];
  54. TCHAR szManufaturerUrl[INTERNET_MAX_URL_LENGTH];
  55. TCHAR szModelName[256];
  56. TCHAR szModelNumber[256];
  57. TCHAR szModelDesc[256];
  58. TCHAR szModelUrl[INTERNET_MAX_URL_LENGTH];
  59. TCHAR szUpc[256];
  60. TCHAR szSerialNumber[256];
  61. HANDLE hSvc[3];
  62. };
  63. enum RESULT_TYPE
  64. {
  65. RES_SUBS,
  66. RES_FIND,
  67. RES_NOTIFY,
  68. };
  69. struct UPNPRESULT
  70. {
  71. SSDP_MESSAGE * rgmsgResult[MAX_RESULT_MSGS];
  72. DWORD cResult;
  73. TCHAR szType[256];
  74. HANDLE hResult;
  75. RESULT_TYPE resType;
  76. };
  77. struct UPNPUCP
  78. {
  79. TCHAR szName[256];
  80. UPNPRESULT * rgResults[MAX_RESULT];
  81. DWORD cResults;
  82. };
  83. enum ECMD_CONTEXT
  84. {
  85. CTX_ROOT = 0x00000001, // Root context (start of app)
  86. CTX_DEVICE = 0x00000002, // Looking at specific device
  87. CTX_CD_SVC = 0x00000004, // Looking at specific service on CD
  88. CTX_EVTSRC = 0x00000008, // Looking at specific event source
  89. CTX_RESULT = 0x00000010, // Looking at specific search/subscription result
  90. CTX_UCP = 0x00000020, // Root of UCP context
  91. CTX_CD = 0x00000040, // Root of CD context
  92. CTX_UCP_SVC = 0x00000200, // Looking at specific service on UCP
  93. CTX_AUTO = 0x80000000, // Automation only (won't appear in menus)
  94. CTX_ANY = 0xFFFFFFFF, // Any context
  95. };
  96. struct UPDIAG_CONTEXT
  97. {
  98. ECMD_CONTEXT ectx;
  99. UPNPDEV * pdevCur[MAX_DEV_STACK];
  100. DWORD idevStackIndex;
  101. UPNPSVC * psvcCur;
  102. UPNPUCP * pucpCur;
  103. UPNPRESULT * presCur;
  104. };
  105. struct UPDIAG_PARAMS
  106. {
  107. UPNPDEV * rgCd[MAX_CD];
  108. DWORD cCd;
  109. UPNPUCP * rgUcp[MAX_UCP];
  110. DWORD cUcp;
  111. };
  112. extern const DEMO_SERVICE_CTL c_rgSvc[];
  113. extern const DWORD c_cDemoSvc;
  114. extern UPDIAG_PARAMS g_params;
  115. extern UPDIAG_CONTEXT g_ctx;
  116. extern SHARED_DATA * g_pdata;
  117. extern HANDLE g_hEvent;
  118. extern HANDLE g_hEventRet;
  119. extern HANDLE g_hEventCleanup;
  120. extern HANDLE g_hMutex;
  121. extern HANDLE g_hThreadTime;
  122. VOID Usage(DWORD iCmd);
  123. BOOL DoHelp(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  124. BOOL DoBack(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  125. BOOL DoRoot(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  126. BOOL DoFindServices(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  127. BOOL DoListEventSources(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  128. BOOL DoExit(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  129. BOOL DoAlive(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  130. BOOL DoNothing(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  131. BOOL DoSleep(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  132. BOOL DoInfo(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  133. BOOL DoPrompt(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  134. BOOL DoScript(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  135. BOOL DoNewCd(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  136. BOOL DoDelCd(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  137. BOOL DoNewUcp(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  138. BOOL DoDelUcp(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  139. BOOL DoSwitchUcp(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  140. BOOL DoSwitchCd(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  141. BOOL DoSwitchEs(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  142. BOOL DoSwitchSvc(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  143. BOOL DoSwitchSearch(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  144. BOOL DoUnsubscribe(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  145. BOOL DoNewService(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  146. BOOL DoListDevices(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  147. BOOL DoListUcp(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  148. BOOL DoListServices(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  149. BOOL DoSubmitEvent(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  150. BOOL DoListProps(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  151. VOID DoEvtSrcInfo(VOID);
  152. BOOL DoSubscribe(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  153. BOOL DoListUpnpResultMsgs(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  154. BOOL DoListUpnpResults(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  155. BOOL DoSwitchResult(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  156. BOOL DoDelResult(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  157. BOOL DoPrintSST(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  158. BOOL DoPrintActionSet(DWORD iCmd, DWORD cArgs, LPTSTR *rgArgs);
  159. VOID NotifyCallback(SSDP_CALLBACK_TYPE ct,
  160. CONST SSDP_MESSAGE *pSsdpService,
  161. LPVOID pContext);
  162. DWORD WINAPI RequestHandlerThreadStart(LPVOID pvParam);
  163. VOID CleanupUcp(UPNPUCP *pucp);
  164. VOID CleanupCd(UPNPDEV *pcd);
  165. VOID CleanupResult(UPNPRESULT *psrch);
  166. VOID CleanupService(UPNPSVC *psvc);
  167. UPNPSVC *PSvcFromId(LPCTSTR szId);
  168. VOID LocalFreeSsdpMessage(PSSDP_MESSAGE pSsdpMessage);
  169. DWORD WINAPI TimeThreadProc(LPVOID lpvThreadParam);
  170. // Device stack functions
  171. //
  172. UPNPDEV *PDevCur(VOID);
  173. VOID PushDev(UPNPDEV *pdev);
  174. UPNPDEV *PopDev(VOID);
  175. // For filetime coversions
  176. //
  177. #define _SECOND ((__int64) 10000000)
  178. #define _MINUTE (60 * _SECOND)
  179. #define _HOUR (60 * _MINUTE)
  180. #define _DAY (24 * _HOUR)
  181. #endif // _UPDIAGP_H