comparison druntime/import/core/sys/posix/arpa/inet.d @ 1458:e0b2d67cfe7c

Added druntime (this should be removed once it works).
author Robert Clipsham <robert@octarineparrot.com>
date Tue, 02 Jun 2009 17:43:06 +0100
parents
children
comparison
equal deleted inserted replaced
1456:7b218ec1044f 1458:e0b2d67cfe7c
1 /**
2 * D header file for POSIX.
3 *
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
6 * Authors: Sean Kelly
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 *
9 * Copyright Sean Kelly 2005 - 2009.
10 * Distributed under the Boost Software License, Version 1.0.
11 * (See accompanying file LICENSE_1_0.txt or copy at
12 * http://www.boost.org/LICENSE_1_0.txt)
13 */
14 module core.sys.posix.arpa.inet;
15
16 private import core.sys.posix.config;
17 public import core.stdc.inttypes; // for uint32_t, uint16_t
18 public import core.sys.posix.sys.socket; // for socklen_t
19
20 extern (C):
21
22 //
23 // Required
24 //
25 /*
26 in_port_t // from core.sys.posix.netinet.in_
27 in_addr_t // from core.sys.posix.netinet.in_
28
29 struct in_addr // from core.sys.posix.netinet.in_
30 INET_ADDRSTRLEN // from core.sys.posix.netinet.in_
31
32 uint32_t // from core.stdc.inttypes
33 uint16_t // from core.stdc.inttypes
34
35 uint32_t htonl(uint32_t);
36 uint16_t htons(uint16_t);
37 uint32_t ntohl(uint32_t);
38 uint16_t ntohs(uint16_t);
39
40 in_addr_t inet_addr(in char*);
41 char* inet_ntoa(in_addr);
42 // per spec: const char* inet_ntop(int, const void*, char*, socklen_t);
43 char* inet_ntop(int, in void*, char*, socklen_t);
44 int inet_pton(int, in char*, void*);
45 */
46
47 version( linux )
48 {
49 alias uint16_t in_port_t;
50 alias uint32_t in_addr_t;
51
52 struct in_addr
53 {
54 in_addr_t s_addr;
55 }
56
57 enum INET_ADDRSTRLEN = 16;
58
59 uint32_t htonl(uint32_t);
60 uint16_t htons(uint16_t);
61 uint32_t ntohl(uint32_t);
62 uint16_t ntohs(uint16_t);
63
64 in_addr_t inet_addr(in char*);
65 char* inet_ntoa(in_addr);
66 char* inet_ntop(int, in void*, char*, socklen_t);
67 int inet_pton(int, in char*, void*);
68 }
69 else version( OSX )
70 {
71 alias uint16_t in_port_t; // TODO: verify
72 alias uint32_t in_addr_t; // TODO: verify
73
74 struct in_addr
75 {
76 in_addr_t s_addr;
77 }
78
79 enum INET_ADDRSTRLEN = 16;
80
81 uint32_t htonl(uint32_t);
82 uint16_t htons(uint16_t);
83 uint32_t ntohl(uint32_t);
84 uint16_t ntohs(uint16_t);
85
86 in_addr_t inet_addr(in char*);
87 char* inet_ntoa(in_addr);
88 char* inet_ntop(int, in void*, char*, socklen_t);
89 int inet_pton(int, in char*, void*);
90 }
91 else version( freebsd )
92 {
93 alias uint16_t in_port_t; // TODO: verify
94 alias uint32_t in_addr_t; // TODO: verify
95
96 struct in_addr
97 {
98 in_addr_t s_addr;
99 }
100
101 enum INET_ADDRSTRLEN = 16;
102
103 uint32_t htonl(uint32_t);
104 uint16_t htons(uint16_t);
105 uint32_t ntohl(uint32_t);
106 uint16_t ntohs(uint16_t);
107
108 in_addr_t inet_addr(in char*);
109 char* inet_ntoa(in_addr);
110 char* inet_ntop(int, in void*, char*, socklen_t);
111 int inet_pton(int, in char*, void*);
112 }
113
114 //
115 // IPV6 (IP6)
116 //
117 /*
118 INET6_ADDRSTRLEN // from core.sys.posix.netinet.in_
119 */
120
121 version( linux )
122 {
123 enum INET6_ADDRSTRLEN = 46;
124 }
125 else version( OSX )
126 {
127 enum INET6_ADDRSTRLEN = 46;
128 }
129 else version( freebsd )
130 {
131 enum INET6_ADDRSTRLEN = 46;
132 }