X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Ftool%2Ftool.c;h=52d7be88e090dc7c149a168a6da6fe6a3b8d7c0c;hp=01d892fd97a903c4e21cdde716bccbad2ffef67a;hb=20ce56cc5bdbee652f73499e3b03714ecbb45085;hpb=097c7bd741931bfbb9deef26fca4861b42e3bda6 diff --git a/src/tool/tool.c b/src/tool/tool.c index 01d892fd..52d7be88 100644 --- a/src/tool/tool.c +++ b/src/tool/tool.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: tool.c,v 1.6 2006/04/09 12:53:07 alex Exp $"; +static char UNUSED id[] = "$Id: tool.c,v 1.8 2007/11/25 18:42:38 fw Exp $"; #include "imp.h" #include @@ -22,6 +22,8 @@ static char UNUSED id[] = "$Id: tool.c,v 1.6 2006/04/09 12:53:07 alex Exp $"; #include #include +#include + #include "exp.h" #include "tool.h" @@ -105,4 +107,22 @@ ngt_TrimLastChr( char *String, const char Chr) } /* ngt_TrimLastChr */ +GLOBAL bool +ngt_IPStrToBin(const char *ip_str, struct in_addr *inaddr) +{ + /* AF is always AF_INET for now */ +#ifdef HAVE_INET_ATON + if (inet_aton(ip_str, inaddr) == 0) + return false; +#else + inaddr->s_addr = inet_addr(ip_str); + if (inaddr->s_addr == (unsigned)-1) + return false; +#endif + return true; +} + + + + /* -eof- */