1 /*
2  * Copyright (c) 2013 Derelict Developers
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  *   notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  *   notice, this list of conditions and the following disclaimer in the
14  *   documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the names 'Derelict', 'DerelictILUT', nor the names of its contributors
17  *   may be used to endorse or promote products derived from this software
18  *   without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 module enet.funcs;
33 
34 private
35 {
36     import enet.types;
37 }
38 
39 extern(C) @nogc nothrow
40 {
41     // enet.h
42     int enet_initialize();
43     int enet_initialize_with_callbacks(ENetVersion version_, const ENetCallbacks * inits);
44     void enet_deinitialize();
45     ENetVersion enet_linked_version();
46     enet_uint32 enet_time_get();
47     void enet_time_set(enet_uint32);
48     ENetSocket enet_socket_create(ENetSocketType);
49     int        enet_socket_bind(ENetSocket, const ENetAddress *);
50     int        enet_socket_get_address(ENetSocket, ENetAddress *);
51     int        enet_socket_listen(ENetSocket, int);
52     ENetSocket enet_socket_accept(ENetSocket, ENetAddress *);
53     int        enet_socket_connect(ENetSocket, const ENetAddress *);
54     int        enet_socket_send(ENetSocket, const ENetAddress *, const ENetBuffer *, size_t);
55     int        enet_socket_receive(ENetSocket, ENetAddress *, ENetBuffer *, size_t);
56     int        enet_socket_wait(ENetSocket, enet_uint32 *, enet_uint32);
57     int        enet_socket_set_option(ENetSocket, ENetSocketOption, int);
58     int        enet_socket_get_option(ENetSocket, ENetSocketOption, int *);
59     int        enet_socket_shutdown(ENetSocket, ENetSocketShutdown);
60     void       enet_socket_destroy(ENetSocket);
61     int        enet_socketset_select(ENetSocket, ENetSocketSet *, ENetSocketSet *, enet_uint32);
62     int enet_address_set_host(ENetAddress * address, const char * hostName);
63     int enet_address_get_host_ip(const ENetAddress * address, char * hostName, size_t nameLength);
64     int enet_address_get_host(const ENetAddress * address, char * hostName, size_t nameLength);
65     ENetPacket * enet_packet_create(const void *, size_t, enet_uint32);
66     void         enet_packet_destroy(ENetPacket *);
67     int          enet_packet_resize(ENetPacket *, size_t);
68     enet_uint32  enet_crc32(const ENetBuffer *, size_t);
69     ENetHost * enet_host_create(const ENetAddress *, size_t, size_t, enet_uint32, enet_uint32);
70     void       enet_host_destroy(ENetHost *);
71     ENetPeer * enet_host_connect(ENetHost *, const ENetAddress *, size_t, enet_uint32);
72     int        enet_host_check_events(ENetHost *, ENetEvent *);
73     int        enet_host_service(ENetHost *, ENetEvent *, enet_uint32);
74     void       enet_host_flush(ENetHost *);
75     void       enet_host_broadcast(ENetHost *, enet_uint8, ENetPacket *);
76     void       enet_host_compress(ENetHost *, const ENetCompressor *);
77     int        enet_host_compress_with_range_coder(ENetHost * host);
78     void       enet_host_channel_limit(ENetHost *, size_t);
79     void       enet_host_bandwidth_limit(ENetHost *, enet_uint32, enet_uint32);
80     int                 enet_peer_send(ENetPeer *, enet_uint8, ENetPacket *);
81     ENetPacket *        enet_peer_receive(ENetPeer *, enet_uint8 * channelID);
82     void                enet_peer_ping(ENetPeer *);
83     void                enet_peer_ping_interval(ENetPeer *, enet_uint32);
84     void                enet_peer_timeout(ENetPeer *, enet_uint32, enet_uint32, enet_uint32);
85     void                enet_peer_reset(ENetPeer *);
86     void                enet_peer_disconnect(ENetPeer *, enet_uint32);
87     void                enet_peer_disconnect_now(ENetPeer *, enet_uint32);
88     void                enet_peer_disconnect_later(ENetPeer *, enet_uint32);
89     void                enet_peer_throttle_configure(ENetPeer *, enet_uint32, enet_uint32, enet_uint32);
90     void * enet_range_coder_create();
91     void   enet_range_coder_destroy(void *);
92     size_t enet_range_coder_compress(void *, const ENetBuffer *, size_t, size_t, enet_uint8 *, size_t);
93     size_t enet_range_coder_decompress(void *, const enet_uint8 *, size_t, enet_uint8 *, size_t);
94     int       enet_address_set_host_ip(ENetAddress * address, const char * hostName);
95 }