Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: webrtc/base/proxydetect.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/profiler.cc ('k') | webrtc/base/ratetracker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 *port++ = '\0'; 206 *port++ = '\0';
207 if (url.port() != atol(port)) { 207 if (url.port() != atol(port)) {
208 return false; 208 return false;
209 } 209 }
210 } 210 }
211 211
212 // A.B.C.D or A.B.C.D/24 212 // A.B.C.D or A.B.C.D/24
213 int a, b, c, d, m; 213 int a, b, c, d, m;
214 int match = sscanf(item, "%d.%d.%d.%d/%d", &a, &b, &c, &d, &m); 214 int match = sscanf(item, "%d.%d.%d.%d/%d", &a, &b, &c, &d, &m);
215 if (match >= 4) { 215 if (match >= 4) {
216 uint32 ip = ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | 216 uint32_t ip = ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) |
217 (d & 0xFF); 217 (d & 0xFF);
218 if ((match < 5) || (m > 32)) 218 if ((match < 5) || (m > 32))
219 m = 32; 219 m = 32;
220 else if (m < 0) 220 else if (m < 0)
221 m = 0; 221 m = 0;
222 uint32 mask = (m == 0) ? 0 : (~0UL) << (32 - m); 222 uint32_t mask = (m == 0) ? 0 : (~0UL) << (32 - m);
223 SocketAddress addr(url.host(), 0); 223 SocketAddress addr(url.host(), 0);
224 // TODO: Support IPv6 proxyitems. This code block is IPv4 only anyway. 224 // TODO: Support IPv6 proxyitems. This code block is IPv4 only anyway.
225 return !addr.IsUnresolved() && 225 return !addr.IsUnresolved() &&
226 ((addr.ipaddr().v4AddressAsHostOrderInteger() & mask) == (ip & mask)); 226 ((addr.ipaddr().v4AddressAsHostOrderInteger() & mask) == (ip & mask));
227 } 227 }
228 228
229 // .foo.com 229 // .foo.com
230 if (*item == '.') { 230 if (*item == '.') {
231 size_t hostlen = url.host().length(); 231 size_t hostlen = url.host().length();
232 return (hostlen > len) 232 return (hostlen > len)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 return (PROXY_VALUE[lhs] > PROXY_VALUE[rhs]); 282 return (PROXY_VALUE[lhs] > PROXY_VALUE[rhs]);
283 } 283 }
284 284
285 bool ParseProxy(const std::string& saddress, ProxyInfo* proxy) { 285 bool ParseProxy(const std::string& saddress, ProxyInfo* proxy) {
286 const size_t kMaxAddressLength = 1024; 286 const size_t kMaxAddressLength = 1024;
287 // Allow semicolon, space, or tab as an address separator 287 // Allow semicolon, space, or tab as an address separator
288 const char* const kAddressSeparator = " ;\t"; 288 const char* const kAddressSeparator = " ;\t";
289 289
290 ProxyType ptype; 290 ProxyType ptype;
291 std::string host; 291 std::string host;
292 uint16 port; 292 uint16_t port;
293 293
294 const char* address = saddress.c_str(); 294 const char* address = saddress.c_str();
295 while (*address) { 295 while (*address) {
296 size_t len; 296 size_t len;
297 const char * start = address; 297 const char * start = address;
298 if (const char * sep = strchr(address, kAddressSeparator)) { 298 if (const char * sep = strchr(address, kAddressSeparator)) {
299 len = (sep - address); 299 len = (sep - address);
300 address += len + 1; 300 address += len + 1;
301 while (*address != '\0' && ::strchr(kAddressSeparator, *address)) { 301 while (*address != '\0' && ::strchr(kAddressSeparator, *address)) {
302 address += 1; 302 address += 1;
(...skipping 13 matching lines...) Expand all
316 buffer[len] = 0; 316 buffer[len] = 0;
317 317
318 char * colon = ::strchr(buffer, ':'); 318 char * colon = ::strchr(buffer, ':');
319 if (!colon) { 319 if (!colon) {
320 LOG(LS_WARNING) << "Proxy address without port [" << buffer << "]"; 320 LOG(LS_WARNING) << "Proxy address without port [" << buffer << "]";
321 continue; 321 continue;
322 } 322 }
323 323
324 *colon = 0; 324 *colon = 0;
325 char * endptr; 325 char * endptr;
326 port = static_cast<uint16>(strtol(colon + 1, &endptr, 0)); 326 port = static_cast<uint16_t>(strtol(colon + 1, &endptr, 0));
327 if (*endptr != 0) { 327 if (*endptr != 0) {
328 LOG(LS_WARNING) << "Proxy address with invalid port [" << buffer << "]"; 328 LOG(LS_WARNING) << "Proxy address with invalid port [" << buffer << "]";
329 continue; 329 continue;
330 } 330 }
331 331
332 if (char * equals = ::strchr(buffer, '=')) { 332 if (char * equals = ::strchr(buffer, '=')) {
333 *equals = 0; 333 *equals = 0;
334 host = equals + 1; 334 host = equals + 1;
335 if (_stricmp(buffer, "socks") == 0) { 335 if (_stricmp(buffer, "socks") == 0) {
336 ptype = PROXY_SOCKS5; 336 ptype = PROXY_SOCKS5;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 path->AppendFolder("Mozilla"); 390 path->AppendFolder("Mozilla");
391 path->AppendFolder("Firefox"); 391 path->AppendFolder("Firefox");
392 #elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) 392 #elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
393 FSRef fr; 393 FSRef fr;
394 if (0 != FSFindFolder(kUserDomain, kApplicationSupportFolderType, 394 if (0 != FSFindFolder(kUserDomain, kApplicationSupportFolderType,
395 kCreateFolder, &fr)) { 395 kCreateFolder, &fr)) {
396 LOG(LS_ERROR) << "FSFindFolder failed"; 396 LOG(LS_ERROR) << "FSFindFolder failed";
397 return false; 397 return false;
398 } 398 }
399 char buffer[NAME_MAX + 1]; 399 char buffer[NAME_MAX + 1];
400 if (0 != FSRefMakePath(&fr, reinterpret_cast<uint8*>(buffer), 400 if (0 != FSRefMakePath(&fr, reinterpret_cast<uint8_t*>(buffer),
401 ARRAY_SIZE(buffer))) { 401 ARRAY_SIZE(buffer))) {
402 LOG(LS_ERROR) << "FSRefMakePath failed"; 402 LOG(LS_ERROR) << "FSRefMakePath failed";
403 return false; 403 return false;
404 } 404 }
405 path->SetFolder(std::string(buffer)); 405 path->SetFolder(std::string(buffer));
406 path->AppendFolder("Firefox"); 406 path->AppendFolder("Firefox");
407 #else 407 #else
408 char* user_home = getenv("HOME"); 408 char* user_home = getenv("HOME");
409 if (user_home == NULL) { 409 if (user_home == NULL) {
410 return false; 410 return false;
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 if (!result) { 1294 if (!result) {
1295 // Either auto detection is not supported or we simply didn't 1295 // Either auto detection is not supported or we simply didn't
1296 // find any proxy, reset type. 1296 // find any proxy, reset type.
1297 proxy->type = rtc::PROXY_NONE; 1297 proxy->type = rtc::PROXY_NONE;
1298 } 1298 }
1299 } 1299 }
1300 return result; 1300 return result;
1301 } 1301 }
1302 1302
1303 } // namespace rtc 1303 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/profiler.cc ('k') | webrtc/base/ratetracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698