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.

100 lines
2.7 KiB

  1. //================================================================================
  2. // Copyright (C) 1997 Microsoft Corporation
  3. // Author: RameshV
  4. // Description: implements the basic structures for superscopes
  5. // ThreadSafe: no
  6. // Locks: none
  7. // Please read stdinfo.txt for programming style.
  8. //================================================================================
  9. #include <mm.h>
  10. #include <winbase.h>
  11. #include <array.h>
  12. #include <opt.h>
  13. #include <optl.h>
  14. #include <optclass.h>
  15. #include <bitmask.h>
  16. #include <range.h>
  17. #include <reserve.h>
  18. #include <subnet.h>
  19. //BeginExport(typedef)
  20. typedef struct _M_SSCOPE {
  21. DWORD SScopeId;
  22. DWORD Policy;
  23. LPWSTR Name;
  24. M_OPTCLASS Options;
  25. } M_SSCOPE, *PM_SSCOPE, *LPM_SSCOPE;
  26. //EndExport(typedef)
  27. ULONG ScopeIdCount = 1;
  28. //BeginExport(extern)
  29. extern ULONG ScopeIdCount;
  30. //EndExport(extern)
  31. //BeginExport(inline)
  32. DWORD _inline
  33. MemSScopeInit(
  34. OUT PM_SSCOPE *SScope,
  35. IN DWORD Policy,
  36. IN LPWSTR Name
  37. ) {
  38. PM_SSCOPE RetVal;
  39. DWORD Size;
  40. DWORD Error;
  41. AssertRet(SScope, ERROR_INVALID_PARAMETER);
  42. Size = ROUND_UP_COUNT(sizeof(M_SSCOPE), ALIGN_WORST);
  43. Size += (1+wcslen(Name))*sizeof(WCHAR);
  44. RetVal = MemAlloc(Size);
  45. if( NULL == RetVal ) return ERROR_NOT_ENOUGH_MEMORY;
  46. RetVal->SScopeId = InterlockedIncrement(&ScopeIdCount);
  47. RetVal->Policy = Policy;
  48. RetVal->Name = (LPWSTR)(ROUND_UP_COUNT(sizeof(M_SSCOPE),ALIGN_WORST) + (LPBYTE)RetVal);
  49. wcscpy(RetVal->Name, Name);
  50. Error = MemOptClassInit(&RetVal->Options);
  51. if( ERROR_SUCCESS != Error ) {
  52. MemFree(RetVal);
  53. RetVal = NULL;
  54. }
  55. *SScope = RetVal;
  56. return Error;
  57. }
  58. //EndExport(inline)
  59. //BeginExport(inline)
  60. DWORD _inline
  61. MemSScopeCleanup(
  62. IN OUT PM_SSCOPE SScope
  63. ) {
  64. DWORD Error;
  65. AssertRet(SScope, ERROR_INVALID_PARAMETER);
  66. Error = MemOptClassCleanup(&SScope->Options);
  67. MemFree(SScope);
  68. return Error;
  69. }
  70. //EndExport(inline)
  71. //BeginExport(inline)
  72. DWORD _inline
  73. MemSubnetSetSuperScope(
  74. IN OUT PM_SUBNET Subnet,
  75. IN PM_SSCOPE SScope
  76. ) {
  77. AssertRet(Subnet && SScope, ERROR_INVALID_PARAMETER);
  78. Subnet->SuperScopeId = SScope->SScopeId;
  79. return ERROR_SUCCESS;
  80. }
  81. //EndExport(inline)
  82. //================================================================================
  83. // end of file
  84. //================================================================================