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 |
11 #include "webrtc/base/win32.h" | 11 #include "webrtc/base/win32.h" |
12 | 12 |
13 #include <winsock2.h> | 13 #include <winsock2.h> |
14 #include <ws2tcpip.h> | 14 #include <ws2tcpip.h> |
15 #include <algorithm> | 15 #include <algorithm> |
16 | 16 |
| 17 #include "webrtc/base/arraysize.h" |
17 #include "webrtc/base/basictypes.h" | 18 #include "webrtc/base/basictypes.h" |
18 #include "webrtc/base/byteorder.h" | 19 #include "webrtc/base/byteorder.h" |
19 #include "webrtc/base/common.h" | 20 #include "webrtc/base/common.h" |
20 #include "webrtc/base/logging.h" | 21 #include "webrtc/base/logging.h" |
21 | 22 |
22 namespace rtc { | 23 namespace rtc { |
23 | 24 |
24 // Helper function declarations for inet_ntop/inet_pton. | 25 // Helper function declarations for inet_ntop/inet_pton. |
25 static const char* inet_ntop_v4(const void* src, char* dst, socklen_t size); | 26 static const char* inet_ntop_v4(const void* src, char* dst, socklen_t size); |
26 static const char* inet_ntop_v6(const void* src, char* dst, socklen_t size); | 27 static const char* inet_ntop_v6(const void* src, char* dst, socklen_t size); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Helper function for inet_ntop for IPv6 addresses. | 81 // Helper function for inet_ntop for IPv6 addresses. |
81 const char* inet_ntop_v6(const void* src, char* dst, socklen_t size) { | 82 const char* inet_ntop_v6(const void* src, char* dst, socklen_t size) { |
82 if (size < INET6_ADDRSTRLEN) { | 83 if (size < INET6_ADDRSTRLEN) { |
83 return NULL; | 84 return NULL; |
84 } | 85 } |
85 const uint16_t* as_shorts = reinterpret_cast<const uint16_t*>(src); | 86 const uint16_t* as_shorts = reinterpret_cast<const uint16_t*>(src); |
86 int runpos[8]; | 87 int runpos[8]; |
87 int current = 1; | 88 int current = 1; |
88 int max = 0; | 89 int max = 0; |
89 int maxpos = -1; | 90 int maxpos = -1; |
90 int run_array_size = ARRAY_SIZE(runpos); | 91 int run_array_size = arraysize(runpos); |
91 // Run over the address marking runs of 0s. | 92 // Run over the address marking runs of 0s. |
92 for (int i = 0; i < run_array_size; ++i) { | 93 for (int i = 0; i < run_array_size; ++i) { |
93 if (as_shorts[i] == 0) { | 94 if (as_shorts[i] == 0) { |
94 runpos[i] = current; | 95 runpos[i] = current; |
95 if (current > max) { | 96 if (current > max) { |
96 maxpos = i; | 97 maxpos = i; |
97 max = current; | 98 max = current; |
98 } | 99 } |
99 ++current; | 100 ++current; |
100 } else { | 101 } else { |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 *level = *GetSidSubAuthority(til->Label.Sid, count - 1); | 448 *level = *GetSidSubAuthority(til->Label.Sid, count - 1); |
448 ret = true; | 449 ret = true; |
449 } | 450 } |
450 } | 451 } |
451 CloseHandle(token); | 452 CloseHandle(token); |
452 } | 453 } |
453 return ret; | 454 return ret; |
454 } | 455 } |
455 | 456 |
456 } // namespace rtc | 457 } // namespace rtc |
OLD | NEW |