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.

124 lines
4.4 KiB

  1. #ifndef _ENVIRONMENT_HPP_
  2. #define _ENVIRONMENT_HPP_
  3. // Ruler
  4. // 1 2 3 4 5 6 7 8
  5. //345678901234567890123456789012345678901234567890123456789012345678901234567890
  6. /********************************************************************/
  7. /* */
  8. /* The standard layout. */
  9. /* */
  10. /* The standard layout for 'hpp' files for this code is as */
  11. /* follows: */
  12. /* */
  13. /* 1. Include files. */
  14. /* 2. Constants exported from the class. */
  15. /* 3. Data structures exported from the class. */
  16. /* 4. Forward references to other data structures. */
  17. /* 5. Class specifications (including inline functions). */
  18. /* 6. Additional large inline functions. */
  19. /* */
  20. /* Any portion that is not required is simply omitted. */
  21. /* */
  22. /********************************************************************/
  23. #include "Global.hpp"
  24. #include "Assembly.hpp"
  25. /********************************************************************/
  26. /* */
  27. /* Environment configuration values. */
  28. /* */
  29. /* This class provides a information about the environment. */
  30. /* The information can be accessed repeatedly with very little */
  31. /* cost as the data is slaved in static memory. */
  32. /* */
  33. /********************************************************************/
  34. class ENVIRONMENT : public ASSEMBLY
  35. {
  36. #ifndef DISABLE_ENVIRONMENT_VARIABLES
  37. //
  38. // Private structures.
  39. //
  40. typedef struct
  41. {
  42. CHAR *Name;
  43. SBIT32 SizeOfName;
  44. CHAR *Value;
  45. SBIT32 SizeOfValue;
  46. }
  47. VARIABLE;
  48. #endif
  49. //
  50. // Private data.
  51. //
  52. STATIC SBIT32 Activations;
  53. STATIC SBIT32 AllocationGranularity;
  54. STATIC SBIT16 NumberOfProcessors;
  55. #ifndef DISABLE_ENVIRONMENT_VARIABLES
  56. STATIC CHAR *ProgramName;
  57. STATIC CHAR *ProgramPath;
  58. #endif
  59. STATIC SBIT32 SizeOfMemory;
  60. STATIC SBIT32 SizeOfPage;
  61. #ifndef DISABLE_ENVIRONMENT_VARIABLES
  62. STATIC SBIT32 MaxVariables;
  63. STATIC SBIT32 VariablesUsed;
  64. STATIC VARIABLE *Variables;
  65. #endif
  66. public:
  67. //
  68. // Public functions.
  69. //
  70. ENVIRONMENT( VOID );
  71. #ifndef DISABLE_ENVIRONMENT_VARIABLES
  72. STATIC CONST CHAR *ReadEnvironmentVariable( CONST CHAR *Name );
  73. #endif
  74. ~ENVIRONMENT( VOID );
  75. //
  76. // Public inline functions.
  77. //
  78. STATIC INLINE SBIT32 AllocationSize(VOID )
  79. { return AllocationGranularity; };
  80. STATIC INLINE SBIT32 CacheAlignSize( SBIT32 Size )
  81. { return ((Size + CacheLineMask) & ~CacheLineMask); }
  82. STATIC INLINE CONST CHAR *DirectorySeperator( VOID )
  83. { return "\\"; };
  84. STATIC INLINE SBIT16 NumberOfCpus( VOID )
  85. { return NumberOfProcessors; }
  86. STATIC INLINE SBIT32 MemorySize( VOID )
  87. { return SizeOfMemory; };
  88. STATIC INLINE SBIT32 PageSize( VOID )
  89. { return SizeOfPage; };
  90. #ifndef DISABLE_ENVIRONMENT_VARIABLES
  91. STATIC INLINE CONST CHAR *ProgramFileName( VOID )
  92. { return ((CONST CHAR*) ProgramName); };
  93. STATIC INLINE CONST CHAR *ProgramFilePath( VOID )
  94. { return ((CONST CHAR*) ProgramPath); };
  95. #endif
  96. private:
  97. //
  98. // Disabled operations.
  99. //
  100. ENVIRONMENT( CONST ENVIRONMENT & Copy );
  101. VOID operator=( CONST ENVIRONMENT & Copy );
  102. };
  103. #endif