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.

179 lines
4.6 KiB

  1. //
  2. // util.h
  3. //
  4. // utility functions used by updiag
  5. //
  6. //+---------------------------------------------------------------------------
  7. //
  8. // Microsoft Windows
  9. // Copyright (C) Microsoft Corporation, 1997.
  10. //
  11. // File: U T I L . H
  12. //
  13. // Contents: Common data structure and function used by mulriple tools
  14. //
  15. // Notes:
  16. //
  17. // Author: tongl 25 Jan 2000
  18. //
  19. //----------------------------------------------------------------------------
  20. #ifndef _UTIL_H
  21. #define _UTIL_H
  22. #include <setupapi.h>
  23. #include <wininet.h>
  24. #include <updiag.h>
  25. static const DWORD MAX_SST_ROWS = 32;
  26. static const MAX_ACTION_ARGUMENTS = 8;
  27. static const MAX_ACTIONS = 32;
  28. static const DWORD MAX_OPERATIONS = 10;
  29. static const DWORD MAX_STD_OPERATIONS = 20;
  30. // service state table
  31. //
  32. struct SST_ROW
  33. {
  34. TCHAR szPropName[256];
  35. VARIANT varValue;
  36. TCHAR mszAllowedValueList[256];
  37. TCHAR szMin[256];
  38. TCHAR szMax[256];
  39. TCHAR szStep[256];
  40. };
  41. struct SST
  42. {
  43. SST_ROW rgRows[MAX_SST_ROWS];
  44. DWORD cRows;
  45. };
  46. // service action set
  47. //
  48. struct OPERATION_DATA
  49. {
  50. // Assumptions:
  51. // 1) one operation affects one and only one state variable
  52. // 2) operations in the same action do NOT share the same argument
  53. // (if they do the argument has to be passed in twice)
  54. // 3) the order of input arguments to an action must be in the same
  55. // order as the operations and arguments for each operation
  56. // 4) the number of arguments each operation takes is uniquely
  57. // determined by the name of the operation
  58. TCHAR szOpName[256];
  59. // The state variable this operation affects
  60. TCHAR szVariableName[256];
  61. // The list of constants and their values this operation takes
  62. TCHAR mszConstantList[256];
  63. };
  64. struct ACTION
  65. {
  66. TCHAR szActionName[256];
  67. OPERATION_DATA rgOperations[MAX_OPERATIONS];
  68. DWORD cOperations;
  69. };
  70. struct ACTION_SET
  71. {
  72. ACTION rgActions[MAX_ACTIONS];
  73. DWORD cActions;
  74. };
  75. // Control structures for demo services
  76. //
  77. typedef DWORD (WINAPI * PFNACTION)(DWORD cArgs, ARG *rgArgs);
  78. struct DEMO_ACTION
  79. {
  80. LPCTSTR szAction;
  81. PFNACTION pfnValidate;
  82. PFNACTION pfnAction;
  83. };
  84. struct DEMO_SERVICE_CTL
  85. {
  86. LPCTSTR szServiceId;
  87. DWORD cActions;
  88. DEMO_ACTION rgActions[MAX_ACTIONS];
  89. };
  90. struct UPNPSVC
  91. {
  92. TCHAR szSti[256];
  93. TCHAR szId[256];
  94. TCHAR szServiceType[256];
  95. TCHAR szControlUrl[INTERNET_MAX_URL_LENGTH];
  96. TCHAR szEvtUrl[INTERNET_MAX_URL_LENGTH];
  97. TCHAR szScpdUrl[INTERNET_MAX_URL_LENGTH];
  98. TCHAR szConfigFile[MAX_PATH];
  99. SST sst;
  100. ACTION_SET action_set;
  101. TCHAR szControlId[256];
  102. HANDLE hSvc;
  103. const DEMO_SERVICE_CTL* psvcDemoCtl;
  104. };
  105. // Standard state table operation list
  106. //
  107. typedef DWORD (WINAPI * PFNOPERATION)(UPNPSVC * psvc, OPERATION_DATA * pOpData,
  108. DWORD cArgs, ARG *rgArgs);
  109. struct STANDARD_OPERATION
  110. {
  111. LPCTSTR szOperation;
  112. DWORD nArguments;
  113. DWORD nConstants;
  114. PFNOPERATION pfnOperation;
  115. };
  116. struct STANDARD_OPERATION_LIST
  117. {
  118. DWORD cOperations;
  119. STANDARD_OPERATION rgOperations[MAX_STD_OPERATIONS];
  120. };
  121. VOID WcharToTcharInPlace(LPTSTR szT, LPWSTR szW);
  122. inline BOOL
  123. IsValidHandle(HANDLE h)
  124. {
  125. return (h && INVALID_HANDLE_VALUE != h);
  126. }
  127. HRESULT HrSetupOpenConfigFile( PCTSTR pszFileName,
  128. UINT* punErrorLine,
  129. HINF* phinf);
  130. HRESULT HrSetupFindFirstLine( HINF hinf,
  131. PCTSTR pszSection,
  132. PCTSTR pszKey,
  133. INFCONTEXT* pctx);
  134. HRESULT HrSetupFindNextLine( const INFCONTEXT& ctxIn,
  135. INFCONTEXT* pctxOut);
  136. HRESULT HrSetupGetStringField( const INFCONTEXT& ctx,
  137. DWORD dwFieldIndex,
  138. PTSTR pszBuf,
  139. DWORD cchBuf,
  140. DWORD* pcchRequired);
  141. HRESULT HrSetupGetLineText( const INFCONTEXT& ctx,
  142. PTSTR pszBuf,
  143. DWORD ReturnBufferSize,
  144. DWORD* pcchRequired);
  145. VOID SetupCloseInfFileSafe(HINF hinf);
  146. BOOL fGetNextField(TCHAR ** pszLine, TCHAR * szBuffer);
  147. BOOL IsStandardOperation(TCHAR * szOpName, DWORD * pnArgs, DWORD * pnConsts);
  148. #endif // _UTIL_H