OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "webrtc/base/stringutils.h" | 41 #include "webrtc/base/stringutils.h" |
42 #include "webrtc/base/basictypes.h" | 42 #include "webrtc/base/basictypes.h" |
43 | 43 |
44 namespace rtc { | 44 namespace rtc { |
45 | 45 |
46 const char* win32_inet_ntop(int af, const void *src, char* dst, socklen_t size); | 46 const char* win32_inet_ntop(int af, const void *src, char* dst, socklen_t size); |
47 int win32_inet_pton(int af, const char* src, void *dst); | 47 int win32_inet_pton(int af, const char* src, void *dst); |
48 | 48 |
49 inline std::wstring ToUtf16(const char* utf8, size_t len) { | 49 inline std::wstring ToUtf16(const char* utf8, size_t len) { |
50 int len16 = ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast<int>(len), | 50 int len16 = ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast<int>(len), |
51 NULL, 0); | 51 nullptr, 0); |
52 wchar_t* ws = STACK_ARRAY(wchar_t, len16); | 52 wchar_t* ws = STACK_ARRAY(wchar_t, len16); |
53 ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast<int>(len), ws, len16); | 53 ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast<int>(len), ws, len16); |
54 return std::wstring(ws, len16); | 54 return std::wstring(ws, len16); |
55 } | 55 } |
56 | 56 |
57 inline std::wstring ToUtf16(const std::string& str) { | 57 inline std::wstring ToUtf16(const std::string& str) { |
58 return ToUtf16(str.data(), str.length()); | 58 return ToUtf16(str.data(), str.length()); |
59 } | 59 } |
60 | 60 |
61 inline std::string ToUtf8(const wchar_t* wide, size_t len) { | 61 inline std::string ToUtf8(const wchar_t* wide, size_t len) { |
62 int len8 = ::WideCharToMultiByte(CP_UTF8, 0, wide, static_cast<int>(len), | 62 int len8 = ::WideCharToMultiByte(CP_UTF8, 0, wide, static_cast<int>(len), |
63 NULL, 0, NULL, NULL); | 63 nullptr, 0, nullptr, nullptr); |
64 char* ns = STACK_ARRAY(char, len8); | 64 char* ns = STACK_ARRAY(char, len8); |
65 ::WideCharToMultiByte(CP_UTF8, 0, wide, static_cast<int>(len), ns, len8, | 65 ::WideCharToMultiByte(CP_UTF8, 0, wide, static_cast<int>(len), ns, len8, |
66 NULL, NULL); | 66 nullptr, nullptr); |
67 return std::string(ns, len8); | 67 return std::string(ns, len8); |
68 } | 68 } |
69 | 69 |
70 inline std::string ToUtf8(const wchar_t* wide) { | 70 inline std::string ToUtf8(const wchar_t* wide) { |
71 return ToUtf8(wide, wcslen(wide)); | 71 return ToUtf8(wide, wcslen(wide)); |
72 } | 72 } |
73 | 73 |
74 inline std::string ToUtf8(const std::wstring& wstr) { | 74 inline std::string ToUtf8(const std::wstring& wstr) { |
75 return ToUtf8(wstr.data(), wstr.length()); | 75 return ToUtf8(wstr.data(), wstr.length()); |
76 } | 76 } |
(...skipping 14 matching lines...) Expand all Loading... |
91 } | 91 } |
92 | 92 |
93 enum WindowsMajorVersions { | 93 enum WindowsMajorVersions { |
94 kWindows2000 = 5, | 94 kWindows2000 = 5, |
95 kWindowsVista = 6, | 95 kWindowsVista = 6, |
96 }; | 96 }; |
97 bool GetOsVersion(int* major, int* minor, int* build); | 97 bool GetOsVersion(int* major, int* minor, int* build); |
98 | 98 |
99 inline bool IsWindowsVistaOrLater() { | 99 inline bool IsWindowsVistaOrLater() { |
100 int major; | 100 int major; |
101 return (GetOsVersion(&major, NULL, NULL) && major >= kWindowsVista); | 101 return (GetOsVersion(&major, nullptr, nullptr) && major >= kWindowsVista); |
102 } | 102 } |
103 | 103 |
104 inline bool IsWindowsXpOrLater() { | 104 inline bool IsWindowsXpOrLater() { |
105 int major, minor; | 105 int major, minor; |
106 return (GetOsVersion(&major, &minor, NULL) && | 106 return (GetOsVersion(&major, &minor, nullptr) && |
107 (major >= kWindowsVista || | 107 (major >= kWindowsVista || (major == kWindows2000 && minor >= 1))); |
108 (major == kWindows2000 && minor >= 1))); | |
109 } | 108 } |
110 | 109 |
111 inline bool IsWindows8OrLater() { | 110 inline bool IsWindows8OrLater() { |
112 int major, minor; | 111 int major, minor; |
113 return (GetOsVersion(&major, &minor, NULL) && | 112 return (GetOsVersion(&major, &minor, nullptr) && |
114 (major > kWindowsVista || | 113 (major > kWindowsVista || (major == kWindowsVista && minor >= 2))); |
115 (major == kWindowsVista && minor >= 2))); | |
116 } | 114 } |
117 | 115 |
118 // Determine the current integrity level of the process. | 116 // Determine the current integrity level of the process. |
119 bool GetCurrentProcessIntegrityLevel(int* level); | 117 bool GetCurrentProcessIntegrityLevel(int* level); |
120 | 118 |
121 inline bool IsCurrentProcessLowIntegrity() { | 119 inline bool IsCurrentProcessLowIntegrity() { |
122 int level; | 120 int level; |
123 return (GetCurrentProcessIntegrityLevel(&level) && | 121 return (GetCurrentProcessIntegrityLevel(&level) && |
124 level < SECURITY_MANDATORY_MEDIUM_RID); | 122 level < SECURITY_MANDATORY_MEDIUM_RID); |
125 } | 123 } |
126 | 124 |
127 bool AdjustCurrentProcessPrivilege(const TCHAR* privilege, bool to_enable); | 125 bool AdjustCurrentProcessPrivilege(const TCHAR* privilege, bool to_enable); |
128 | 126 |
129 } // namespace rtc | 127 } // namespace rtc |
130 | 128 |
131 #endif // WEBRTC_WIN | 129 #endif // WEBRTC_WIN |
132 #endif // WEBRTC_BASE_WIN32_H_ | 130 #endif // WEBRTC_BASE_WIN32_H_ |
OLD | NEW |