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.

127 lines
3.8 KiB

  1. //================================================================================
  2. // Copyright (C) 1997 Microsoft Corporation
  3. // Author: RameshV
  4. // Description: implements the basic structures for storing complete option configuration info
  5. // ThreadSafe: no
  6. // Locks: none
  7. // Please read stdinfo.txt for programming style.
  8. //================================================================================
  9. #include <mm.h>
  10. #include <array.h>
  11. #include <optdefl.h>
  12. #include "oclassdl.h"
  13. #include "server\uniqid.h"
  14. //BeginExport(function)
  15. DWORD
  16. MemOptClassDefListFindOptDefList(
  17. IN OUT PM_OPTCLASSDEFLIST OptClassDefList,
  18. IN DWORD ClassId,
  19. IN DWORD VendorId,
  20. OUT PM_OPTDEFLIST *OptDefList
  21. ) //EndExport(function)
  22. {
  23. ARRAY_LOCATION Location;
  24. DWORD Error;
  25. PM_OPTCLASSDEFL_ONE OneClassDefList;
  26. AssertRet(OptClassDefList && OptDefList, ERROR_INVALID_PARAMETER);
  27. *OptDefList = NULL;
  28. for( Error = MemArrayInitLoc(&OptClassDefList->Array, &Location)
  29. ; ERROR_FILE_NOT_FOUND != Error ;
  30. Error = MemArrayNextLoc(&OptClassDefList->Array, &Location)
  31. ) {
  32. Require(ERROR_SUCCESS == Error );
  33. Error = MemArrayGetElement(
  34. &OptClassDefList->Array,
  35. &Location,
  36. (LPVOID*)&OneClassDefList
  37. );
  38. Require(ERROR_SUCCESS == Error && OneClassDefList);
  39. if( OneClassDefList->ClassId == ClassId &&
  40. OneClassDefList->VendorId == VendorId ) {
  41. *OptDefList = &OneClassDefList->OptDefList;
  42. return ERROR_SUCCESS;
  43. }
  44. }
  45. return ERROR_FILE_NOT_FOUND;
  46. }
  47. //BeginExport(function)
  48. DWORD
  49. MemOptClassDefListAddOptDef(
  50. IN OUT PM_OPTCLASSDEFLIST OptClassDefList,
  51. IN DWORD ClassId,
  52. IN DWORD VendorId,
  53. IN DWORD OptId,
  54. IN DWORD Type,
  55. IN LPWSTR Name,
  56. IN LPWSTR Comment,
  57. IN LPBYTE OptVal,
  58. IN DWORD OptLen,
  59. IN ULONG UniqId
  60. ) //EndExport(function)
  61. {
  62. DWORD Error;
  63. PM_OPTCLASSDEFL_ONE OneClassDefList;
  64. PM_OPTDEFLIST OptDefList;
  65. AssertRet(OptClassDefList, ERROR_INVALID_PARAMETER);
  66. OneClassDefList = NULL;
  67. Error = MemOptClassDefListFindOptDefList(
  68. OptClassDefList,
  69. ClassId,
  70. VendorId,
  71. &OptDefList
  72. );
  73. if( ERROR_SUCCESS != Error ) {
  74. Require(ERROR_FILE_NOT_FOUND == Error);
  75. OneClassDefList = MemAlloc(sizeof(*OneClassDefList));
  76. if( NULL == OneClassDefList) return ERROR_NOT_ENOUGH_MEMORY;
  77. // RefCount on ClassId needs to be bumped up?
  78. OneClassDefList->ClassId = ClassId;
  79. OneClassDefList->VendorId = VendorId;
  80. Error = MemOptDefListInit(&OneClassDefList->OptDefList);
  81. if( ERROR_SUCCESS != Error ) {
  82. MemFree(OneClassDefList);
  83. return Error;
  84. }
  85. Error = MemArrayAddElement(&OptClassDefList->Array, OneClassDefList);
  86. if( ERROR_SUCCESS != Error) {
  87. MemFree(OneClassDefList);
  88. return Error;
  89. }
  90. OptDefList = &OneClassDefList->OptDefList;
  91. }
  92. Error = MemOptDefListAddOptDef(
  93. OptDefList,
  94. OptId,
  95. Type,
  96. Name,
  97. Comment,
  98. OptVal,
  99. OptLen,
  100. UniqId
  101. );
  102. return Error;
  103. } // MemOptDefListAddOptDef()
  104. //================================================================================
  105. // end of file
  106. //================================================================================