chiark / gitweb /
[PATCH] added klibc version 0.82 (cvs tree) to the udev tree.
[elogind.git] / klibc / klibc / inet / inet_aton.c
1 /*
2  * inet/inet_aton.c
3  */
4
5 #include <arpa/inet.h>
6 #include <stdio.h>
7
8 int inet_aton(const char *str, struct in_addr *addr)
9 {
10   union {
11     uint8_t  b[4];
12     uint32_t l;
13   } a;
14
15   if ( sscanf(str, "%hhu.%hhu.%hhu.%hhu", &a.b[0], &a.b[1], &a.b[2], &a.b[3]) == 4 ) {
16     addr->s_addr = a.l;         /* Always in network byte order */
17     return 1;
18   } else {
19     return 0;
20   }
21 }
22
23