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.

104 lines
2.7 KiB

  1. //================================================================================
  2. // Copyright (C) 1997 Microsoft Corporation
  3. // Author: RameshV
  4. // Description: implements the basic structures for a list of options
  5. // ThreadSafe: no
  6. // Locks: none
  7. // Please read stdinfo.txt for programming style.
  8. //================================================================================
  9. #include <mm.h>
  10. #include <opt.h>
  11. #include <array.h>
  12. #include "optl.h"
  13. #include "server\uniqid.h"
  14. //BeginExport(function)
  15. DWORD
  16. MemOptListDelOption(
  17. IN PM_OPTLIST OptList,
  18. IN DWORD OptId
  19. ) //EndExport(function)
  20. {
  21. ARRAY_LOCATION Loc;
  22. DWORD Error;
  23. PM_OPTION Opt;
  24. AssertRet(OptList, ERROR_INVALID_PARAMETER );
  25. Error = MemArrayInitLoc(OptList, &Loc);
  26. while( ERROR_FILE_NOT_FOUND != Error ) {
  27. Require(ERROR_SUCCESS == Error);
  28. Error = MemArrayGetElement(OptList, &Loc, (LPVOID*)&Opt);
  29. Require(ERROR_SUCCESS == Error && Opt);
  30. if( Opt->OptId == OptId ) {
  31. Error = DeleteRecord( Opt->UniqId );
  32. if ( ERROR_SUCCESS != Error ) {
  33. return Error;
  34. }
  35. Error = MemArrayDelElement(OptList, &Loc, (LPVOID*)&Opt);
  36. Require(ERROR_SUCCESS == Error && Opt);
  37. Error = MemOptCleanup(Opt);
  38. Require(ERROR_SUCCESS == Error);
  39. return ERROR_SUCCESS;
  40. } // if
  41. Error = MemArrayNextLoc(OptList, &Loc);
  42. } // while
  43. return ERROR_FILE_NOT_FOUND;
  44. } // MemOptListDelOption()
  45. DWORD
  46. MemOptListDelList(
  47. IN PM_OPTLIST OptList
  48. )
  49. {
  50. PM_OPTION Opt;
  51. ARRAY_LOCATION Loc;
  52. DWORD Error;
  53. AssertRet( OptList, ERROR_INVALID_PARAMETER );
  54. Error = MemArrayInitLoc( OptList, &Loc );
  55. while(( MemArraySize( OptList ) > 0 ) &&
  56. ( ERROR_FILE_NOT_FOUND != Error )) {
  57. Require( ERROR_SUCCESS == Error );
  58. Error = MemArrayGetElement( OptList, &Loc, ( LPVOID * ) &Opt );
  59. Require( ERROR_SUCCESS == Error && Opt );
  60. Error = DeleteRecord( Opt->UniqId );
  61. if ( ERROR_SUCCESS != Error ) {
  62. return Error;
  63. }
  64. Error = MemArrayDelElement( OptList, &Loc, ( LPVOID * ) &Opt );
  65. Require( ERROR_SUCCESS == Error && Opt );
  66. Error = MemOptCleanup( Opt );
  67. Require( ERROR_SUCCESS == Error);
  68. } // while
  69. if ( ERROR_FILE_NOT_FOUND == Error ) {
  70. Error = ERROR_SUCCESS;
  71. }
  72. return Error;
  73. } // MemOptListDelList()
  74. //================================================================================
  75. // end of file
  76. //================================================================================