1 /* ********************************************************************	*
2  *	inet_aton.c							*
3  *									*
4  *     COPYRIGHT 2006-2009 Michael Robinton <michael@bizsystems.com>	*
5  *									*
6  * This program is free software; you can redistribute it and/or modify	*
7  * it under the terms of either:					*
8  *									*
9  *  a) the GNU General Public License as published by the Free		*
10  *  Software Foundation; either version 2, or (at your option) any	*
11  *  later version, or							*
12  *									*
13  *  b) the "Artistic License" which comes with this distribution.	*
14  *									*
15  * This program is distributed in the hope that it will be useful,	*
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of	*
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See either	*
18  * the GNU General Public License or the Artistic License for more 	*
19  * details.								*
20  *									*
21  * You should have received a copy of the Artistic License with this	*
22  * distribution, in the file named "Artistic".  If not, I'll be glad 	*
23  * to provide one.							*
24  *									*
25  * You should also have received a copy of the GNU General Public 	*
26  * License along with this program in the file named "Copying". If not, *
27  * write to the 							*
28  *									*
29  *	Free Software Foundation, Inc.					*
30  *	59 Temple Place, Suite 330					*
31  *	Boston, MA  02111-1307, USA					*
32  *									*
33  * or visit their web page on the internet at:				*
34  *									*
35  *	http://www.gnu.org/copyleft/gpl.html.				*
36  * ********************************************************************	*/
37 
38 #ifndef HAVE_INET_ATON
39 
40 int
my_inet_aton(const char * cp,struct in_addr * inp)41 my_inet_aton(const char *cp, struct in_addr *inp)
42 {
43 # ifdef HAVE_INET_PTON
44   return inet_pton(AF_INET,cp,inp);
45 # else
46 #  ifdef HAVE_INET_ADDR
47   inp->s_addr = inet_addr(cp);
48   if (inp->s_addr == -1) {
49     if (strncmp("255.255.255.255",cp,15))
50       return 0;
51     else
52       return 1;
53   }
54   return 1;
55 #  else
56 # error inet_aton, inet_pton, inet_addr not defined on this platform
57 #  endif
58 # endif
59 }
60 #define inet_aton my_inet_aton
61 #endif
62