]>
git.proxmox.com Git - wasi-libc.git/blob - libc-bottom-half/cloudlibc/src/libc/arpa/inet/inet_aton.c
42f4c2f299d78f24c6da8f36ce8fcd792fb98b83
1 // Copyright (c) 2016 Nuxi, https://nuxi.nl/
3 // SPDX-License-Identifier: BSD-2-Clause
10 int inet_aton(const char *cp
, struct in_addr
*inp
) {
11 uint32_t max
= UINT32_MAX
;
15 // Parse next part of the IPv4 address.
16 typedef uint32_t int_t
;
19 bool allow_negative
= false;
25 #include <common/parser_strtoint.h>
28 if (!have_number
|| have_overflow
)
32 // End of string. Return the IPv4 address, combining the
33 // previously parsed leading bytes with the trailing number.
34 inp
->s_addr
= htonl(leading
| number
);
36 } else if (shift
> 0 && number
<= UINT8_MAX
&& *cp
++ == '.') {
37 // More components follow.
38 leading
|= number
<< shift
;