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.

77 lines
1.5 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. //
  3. // global utility functions
  4. //
  5. // 8-14-97 sburns
  6. #ifndef UTILITY_HPP_INCLUDED
  7. #define UTILITY_HPP_INCLUDED
  8. // Returns true if current process token contains administrators membership.
  9. bool
  10. IsCurrentUserAdministrator();
  11. // Reboots the machine. Returns S_OK on success.
  12. HRESULT
  13. Reboot();
  14. enum NetbiosValidationResult
  15. {
  16. VALID_NAME,
  17. INVALID_NAME, // contains illegal characters
  18. NAME_TOO_LONG
  19. };
  20. NetbiosValidationResult
  21. ValidateNetbiosComputerName(const String& s);
  22. NetbiosValidationResult
  23. ValidateNetbiosDomainName(const String& s);
  24. // Inserts a value into the end of the container (by calling push_back on the
  25. // container) iff the value is not already present in the container. Returns
  26. // true if the value was inserted, or false if it was not.
  27. //
  28. // Container - class that supports methods begin() and end(), which return
  29. // forward iterators positioned in the usual STL fashion, and push_back. Also
  30. // must support a nested typedef named value_type indicating the type of
  31. // values that the container contains.
  32. //
  33. // c - the container
  34. //
  35. // value - the value to conditionally insert
  36. template <class Container>
  37. bool
  38. push_back_unique(Container& c, const Container::value_type& value)
  39. {
  40. bool result = false;
  41. if (std::find(c.begin(), c.end(), value) == c.end())
  42. {
  43. // value is not already present, so push it onto the end
  44. c.push_back(value);
  45. result = true;
  46. }
  47. return result;
  48. }
  49. #endif // UTILITY_HPP_INCLUDED