/[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 5135 - (show annotations)
Thu Dec 25 18:51:51 2014 UTC (5 years, 5 months ago) by michael
File MIME type: text/x-chdr
File size: 1610 byte(s)
- propset svn:eol-style native

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

Properties

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

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