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.

109 lines
3.5 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. #ifndef SIMC_REGISTRY_CONTROLLER
  5. #define SIMC_REGISTRY_CONTROLLER
  6. /*
  7. * This file contains the classes that are used to manipulate the
  8. * registry by the SNMP Compiler. The compiler stores MIB dependency
  9. * information in the registry, as per the "compiler requirements spec"
  10. */
  11. // The class that represents the mapping between a file name
  12. // and a module name
  13. class SIMCFileMapElement
  14. {
  15. public:
  16. CString fileName;
  17. CString moduleName;
  18. SIMCFileMapElement(const CString mName, const CString fName)
  19. : moduleName(mName), fileName(fName)
  20. {}
  21. SIMCFileMapElement() {}
  22. };
  23. // A list of such mappings
  24. typedef CList<SIMCFileMapElement, SIMCFileMapElement> SIMCFileMapList;
  25. // The class that controls the registry, and has functions for retreiving
  26. // mappings, adding/deleting mappings etc. from the registry. Most
  27. // functions are static
  28. class SIMCRegistryController
  29. {
  30. private:
  31. // The keys in the registry that the SNMP compiler uses.
  32. // These are defined in the "compiler requirements spec"
  33. static const char *rootKeyName;
  34. static const char *filePaths;
  35. static const char *fileSuffixes;
  36. static const char *mibTable;
  37. // Checks whether the file name is a path name
  38. static BOOL IsAbsolutePath(CString pathName);
  39. static BOOL GetMibFileFromMap(const SIMCFileMapList& theList,
  40. const CString& module,
  41. CString &file);
  42. static BOOL ShouldAddDependentFile(SIMCFileMapList& dependencyList,
  43. const CString& dependentModule,
  44. CString& dependentFile,
  45. const SIMCFileMapList& priorityList);
  46. static BOOL IsModulePresent(SIMCFileMapList& dependencyList,
  47. const CString& dependentModule);
  48. static BOOL IsFilePresent(SIMCFileMapList& dependencyList,
  49. const CString& dependentFile);
  50. public:
  51. // Gets the entry from the lookup table
  52. static BOOL GetMibFileFromRegistry(const char * const moduleName,
  53. CString &fullPathName);
  54. // Prints out the lookup table on to stdout
  55. static BOOL ListMibTable();
  56. // Gets the list of suffixes from teh registry
  57. static BOOL GetMibSuffixes(SIMCStringList & theList);
  58. // Gets the list of paths from teh registry
  59. static BOOL GetMibPaths(SIMCStringList & theList);
  60. // Deletes the lookup table from the registry
  61. static BOOL DeleteMibTable();
  62. // Deletes the lookup table and rebuilds it.
  63. // Returns the # of entries entered
  64. static long RebuildMibTable();
  65. // Builds the lookup table afresh, and gets it
  66. static long GetFileMap(SIMCFileMapList &theList);
  67. // Adds the mappings from a directory to theList
  68. static long RebuildDirectory(const CString& directory,
  69. const SIMCStringList& suffixList,
  70. SIMCFileMapList &theList);
  71. // Adds the mapping of a file to theList
  72. static BOOL ProcessFile(const char * const fileName,
  73. SIMCFileMapList &theList);
  74. // Given a priority list of mappings, builds a dependency list
  75. // using a depth first search using the priority mappings first,
  76. // and then the registry lookup table to locate any required mib modules
  77. static BOOL GetDependentModules(const char * const fileName,
  78. SIMCFileMapList& dependencyList,
  79. const SIMCFileMapList& priorityList);
  80. // Deletes a specified directory from the list of paths in the registry
  81. static BOOL DeleteRegistryDirectory(const CString& directoryName);
  82. // Adds a specified directory to the list of paths in the registry
  83. static BOOL AddRegistryDirectory(const CString& directoryName);
  84. };
  85. #endif