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

Side by Side Diff: url/url_canon_ip.h

Issue 13998025: url: Build it as a static library. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « url/url_canon_internal_file.h ('k') | url/url_canon_ip.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008, Google Inc. 1 // Copyright 2008, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer 11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the 12 // in the documentation and/or other materials provided with the
13 // distribution. 13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its 14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from 15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission. 16 // this software without specific prior written permission.
17 // 17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 #ifndef GOOGLEURL_SRC_URL_CANON_IP_H__ 30 #ifndef URL_URL_CANON_IP_H_
31 #define GOOGLEURL_SRC_URL_CANON_IP_H__ 31 #define URL_URL_CANON_IP_H_
32 32
33 #include "base/string16.h" 33 #include "base/string16.h"
34 #include "googleurl/src/url_canon.h" 34 #include "url/url_canon.h"
35 #include "googleurl/src/url_common.h" 35 #include "url/url_parse.h"
36 #include "googleurl/src/url_parse.h"
37 36
38 namespace url_canon { 37 namespace url_canon {
39 38
40 // Writes the given IPv4 address to |output|. 39 // Writes the given IPv4 address to |output|.
41 GURL_API void AppendIPv4Address(const unsigned char address[4], 40 void AppendIPv4Address(const unsigned char address[4],
42 CanonOutput* output); 41 CanonOutput* output);
43 42
44 // Writes the given IPv6 address to |output|. 43 // Writes the given IPv6 address to |output|.
45 GURL_API void AppendIPv6Address(const unsigned char address[16], 44 void AppendIPv6Address(const unsigned char address[16],
46 CanonOutput* output); 45 CanonOutput* output);
47 46
48 // Searches the host name for the portions of the IPv4 address. On success, 47 // Searches the host name for the portions of the IPv4 address. On success,
49 // each component will be placed into |components| and it will return true. 48 // each component will be placed into |components| and it will return true.
50 // It will return false if the host can not be separated as an IPv4 address 49 // It will return false if the host can not be separated as an IPv4 address
51 // or if there are any non-7-bit characters or other characters that can not 50 // or if there are any non-7-bit characters or other characters that can not
52 // be in an IP address. (This is important so we fail as early as possible for 51 // be in an IP address. (This is important so we fail as early as possible for
53 // common non-IP hostnames.) 52 // common non-IP hostnames.)
54 // 53 //
55 // Not all components may exist. If there are only 3 components, for example, 54 // Not all components may exist. If there are only 3 components, for example,
56 // the last one will have a length of -1 or 0 to indicate it does not exist. 55 // the last one will have a length of -1 or 0 to indicate it does not exist.
57 // 56 //
58 // Note that many platform's inet_addr will ignore everything after a space 57 // Note that many platform's inet_addr will ignore everything after a space
59 // in certain curcumstances if the stuff before the space looks like an IP 58 // in certain curcumstances if the stuff before the space looks like an IP
60 // address. IE6 is included in this. We do NOT handle this case. In many cases, 59 // address. IE6 is included in this. We do NOT handle this case. In many cases,
61 // the browser's canonicalization will get run before this which converts 60 // the browser's canonicalization will get run before this which converts
62 // spaces to %20 (in the case of IE7) or rejects them (in the case of 61 // spaces to %20 (in the case of IE7) or rejects them (in the case of
63 // Mozilla), so this code path never gets hit. Our host canonicalization will 62 // Mozilla), so this code path never gets hit. Our host canonicalization will
64 // notice these spaces and escape them, which will make IP address finding 63 // notice these spaces and escape them, which will make IP address finding
65 // fail. This seems like better behavior than stripping after a space. 64 // fail. This seems like better behavior than stripping after a space.
66 GURL_API bool FindIPv4Components(const char* spec, 65 bool FindIPv4Components(const char* spec,
67 const url_parse::Component& host, 66 const url_parse::Component& host,
68 url_parse::Component components[4]); 67 url_parse::Component components[4]);
69 GURL_API bool FindIPv4Components(const char16* spec, 68 bool FindIPv4Components(const char16* spec,
70 const url_parse::Component& host, 69 const url_parse::Component& host,
71 url_parse::Component components[4]); 70 url_parse::Component components[4]);
72 71
73 // Converts an IPv4 address to a 32-bit number (network byte order). 72 // Converts an IPv4 address to a 32-bit number (network byte order).
74 // 73 //
75 // Possible return values: 74 // Possible return values:
76 // IPV4 - IPv4 address was successfully parsed. 75 // IPV4 - IPv4 address was successfully parsed.
77 // BROKEN - Input was formatted like an IPv4 address, but overflow occurred 76 // BROKEN - Input was formatted like an IPv4 address, but overflow occurred
78 // during parsing. 77 // during parsing.
79 // NEUTRAL - Input couldn't possibly be interpreted as an IPv4 address. 78 // NEUTRAL - Input couldn't possibly be interpreted as an IPv4 address.
80 // It might be an IPv6 address, or a hostname. 79 // It might be an IPv6 address, or a hostname.
81 // 80 //
82 // On success, |num_ipv4_components| will be populated with the number of 81 // On success, |num_ipv4_components| will be populated with the number of
83 // components in the IPv4 address. 82 // components in the IPv4 address.
84 GURL_API CanonHostInfo::Family IPv4AddressToNumber( 83 CanonHostInfo::Family IPv4AddressToNumber(
85 const char* spec, 84 const char* spec,
86 const url_parse::Component& host, 85 const url_parse::Component& host,
87 unsigned char address[4], 86 unsigned char address[4],
88 int* num_ipv4_components); 87 int* num_ipv4_components);
89 GURL_API CanonHostInfo::Family IPv4AddressToNumber( 88 CanonHostInfo::Family IPv4AddressToNumber(
90 const char16* spec, 89 const char16* spec,
91 const url_parse::Component& host, 90 const url_parse::Component& host,
92 unsigned char address[4], 91 unsigned char address[4],
93 int* num_ipv4_components); 92 int* num_ipv4_components);
94 93
95 // Converts an IPv6 address to a 128-bit number (network byte order), returning 94 // Converts an IPv6 address to a 128-bit number (network byte order), returning
96 // true on success. False means that the input was not a valid IPv6 address. 95 // true on success. False means that the input was not a valid IPv6 address.
97 // 96 //
98 // NOTE that |host| is expected to be surrounded by square brackets. 97 // NOTE that |host| is expected to be surrounded by square brackets.
99 // i.e. "[::1]" rather than "::1". 98 // i.e. "[::1]" rather than "::1".
100 GURL_API bool IPv6AddressToNumber(const char* spec, 99 bool IPv6AddressToNumber(const char* spec,
101 const url_parse::Component& host, 100 const url_parse::Component& host,
102 unsigned char address[16]); 101 unsigned char address[16]);
103 GURL_API bool IPv6AddressToNumber(const char16* spec, 102 bool IPv6AddressToNumber(const char16* spec,
104 const url_parse::Component& host, 103 const url_parse::Component& host,
105 unsigned char address[16]); 104 unsigned char address[16]);
106 105
107 } // namespace url_canon 106 } // namespace url_canon
108 107
109 #endif // GOOGLEURL_SRC_URL_CANON_IP_H__ 108 #endif // URL_URL_CANON_IP_H_
OLDNEW
« no previous file with comments | « url/url_canon_internal_file.h ('k') | url/url_canon_ip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698