Version 0.0
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@387 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
23
appl/ftp/common/inet_aton.c
Normal file
23
appl/ftp/common/inet_aton.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
int inet_aton(char *cp, struct in_addr *adr)
|
||||
{
|
||||
int a, b, c, d;
|
||||
|
||||
if(sscanf(cp, "%d.%d.%d.%d", &a, &b, &c, &d) != 4)
|
||||
return 0;
|
||||
if(a < 0 || a > 255 ||
|
||||
b < 0 || b > 255 ||
|
||||
c < 0 || c > 255 ||
|
||||
d < 0 || d > 255)
|
||||
return 0;
|
||||
adr->s_addr = htonl((a << 24) | (b << 16) | (c << 8) | d);
|
||||
return 1;
|
||||
}
|
Reference in New Issue
Block a user