/[svn]/hopm/trunk/src/libopm/src/compat.c
ViewVC logotype

Contents of /hopm/trunk/src/libopm/src/compat.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5137 - (show annotations)
Thu Dec 25 19:36:37 2014 UTC (7 years, 7 months ago) by michael
File MIME type: text/x-chdr
File size: 1555 byte(s)
- Removed vim settings from the source files

1 /*
2 * Copyright (C) 2002 Andy Smith
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to
16 *
17 * The Free Software Foundation, Inc.
18 * 59 Temple Place - Suite 330
19 * Boston, MA 02111-1307, USA
20 */
21
22 #include "setup.h"
23
24 #include <stdio.h>
25
26 #ifdef STDC_HEADERS
27 # include <string.h>
28 #endif
29
30 #ifndef HAVE_INET_ATON
31 # include <netinet/in.h>
32 #endif
33
34 #include "compat.h"
35 #include "opm.h"
36
37
38 #ifndef HAVE_INET_ATON
39 /*
40 * An implementation of inet_aton for those systems that don't have it
41 * (Solaris, ...)
42 */
43 int libopm_inet_aton(const char *cp, struct in_addr *inp)
44 {
45 unsigned int a1, a2, a3, a4;
46 unsigned long ret;
47
48 if (strcmp(cp, "255.255.255.255") == 0) {
49 inp->s_addr = (unsigned) -1;
50 return 0;
51 }
52
53 if (sscanf(cp, "%u.%u.%u.%u", &a1, &a2, &a3, &a4) != 4 ||
54 a1 > 255 || a2 > 255 || a3 > 255 || a4 > 255) {
55 return 0;
56 }
57
58 ret = (a1 << 24) | (a2 << 16) | (a3 << 8) | a4;
59
60 inp->s_addr = htonl(ret);
61
62 if (inp->s_addr == (unsigned) -1) {
63 return 0;
64 }
65 return 1;
66 }
67 #endif

Properties

Name Value
svn:eol-style native
svn:keywords Id

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28