| 1 | /* |
| 2 | * uriparser - RFC 3986 URI parsing library |
| 3 | * |
| 4 | * Copyright (C) 2007, Weijia Song <[email protected]> |
| 5 | * Copyright (C) 2007, Sebastian Pipping <[email protected]> |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * |
| 12 | * 1. Redistributions of source code must retain the above |
| 13 | * copyright notice, this list of conditions and the following |
| 14 | * disclaimer. |
| 15 | * |
| 16 | * 2. Redistributions in binary form must reproduce the above |
| 17 | * copyright notice, this list of conditions and the following |
| 18 | * disclaimer in the documentation and/or other materials |
| 19 | * provided with the distribution. |
| 20 | * |
| 21 | * 3. Neither the name of the copyright holder nor the names of |
| 22 | * its contributors may be used to endorse or promote products |
| 23 | * derived from this software without specific prior written |
| 24 | * permission. |
| 25 | * |
| 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 27 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 29 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 30 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 31 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 32 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 33 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 35 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 36 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 37 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 38 | */ |
| 39 | |
| 40 | /** |
| 41 | * @file UriIp4.h |
| 42 | * Holds the IPv4 parser interface. |
| 43 | * NOTE: This header includes itself twice. |
| 44 | */ |
| 45 | |
| 46 | #if (defined(URI_PASS_ANSI) && !defined(URI_IP4_TWICE_H_ANSI)) \ |
| 47 | || (defined(URI_PASS_UNICODE) && !defined(URI_IP4_TWICE_H_UNICODE)) \ |
| 48 | || (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) |
| 49 | /* What encodings are enabled? */ |
| 50 | # include "UriDefsConfig.h" |
| 51 | # if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) |
| 52 | /* Include SELF twice */ |
| 53 | # ifdef URI_ENABLE_ANSI |
| 54 | # define URI_PASS_ANSI 1 |
| 55 | # include "UriIp4.h" |
| 56 | # undef URI_PASS_ANSI |
| 57 | # endif |
| 58 | # ifdef URI_ENABLE_UNICODE |
| 59 | # define URI_PASS_UNICODE 1 |
| 60 | # include "UriIp4.h" |
| 61 | # undef URI_PASS_UNICODE |
| 62 | # endif |
| 63 | /* Only one pass for each encoding */ |
| 64 | # elif (defined(URI_PASS_ANSI) && !defined(URI_IP4_TWICE_H_ANSI) \ |
| 65 | && defined(URI_ENABLE_ANSI)) \ |
| 66 | || (defined(URI_PASS_UNICODE) && !defined(URI_IP4_TWICE_H_UNICODE) \ |
| 67 | && defined(URI_ENABLE_UNICODE)) |
| 68 | # ifdef URI_PASS_ANSI |
| 69 | # define URI_IP4_TWICE_H_ANSI 1 |
| 70 | # include "UriDefsAnsi.h" |
| 71 | # else |
| 72 | # define URI_IP4_TWICE_H_UNICODE 1 |
| 73 | # include "UriDefsUnicode.h" |
| 74 | # include <wchar.h> |
| 75 | # endif |
| 76 | |
| 77 | # ifdef __cplusplus |
| 78 | extern "C" { |
| 79 | # endif |
| 80 | |
| 81 | # ifndef URI_DOXYGEN |
| 82 | # include "UriBase.h" |
| 83 | # endif |
| 84 | |
| 85 | /** |
| 86 | * Converts an IPv4 text representation into four bytes. |
| 87 | * |
| 88 | * @param octetOutput Output destination |
| 89 | * @param first First character of IPv4 text to parse |
| 90 | * @param afterLast Position to stop parsing at |
| 91 | * @return Error code or 0 on success |
| 92 | * |
| 93 | * @see uriParseIpSixAddressA |
| 94 | * @see uriParseIpSixAddressMmA |
| 95 | */ |
| 96 | URI_PUBLIC int URI_FUNC(ParseIpFourAddress)(unsigned char * octetOutput, |
| 97 | const URI_CHAR * first, |
| 98 | const URI_CHAR * afterLast); |
| 99 | |
| 100 | # ifdef __cplusplus |
| 101 | } |
| 102 | # endif |
| 103 | |
| 104 | # endif |
| 105 | #endif |