Pārlūkot izejas kodu

added stdint types, updated changelog

Vladyslav Hrytsenko 6 gadi atpakaļ
vecāks
revīzija
b508c761fd
3 mainītis faili ar 28 papildinājumiem un 157 dzēšanām
  1. 8 8
      include/enet.h
  2. 20 15
      misc/ChangeLog
  3. 0 134
      misc/build-singleheader.js

+ 8 - 8
include/enet.h

@@ -195,10 +195,10 @@ extern "C" {
 // !
 // =======================================================================//
 
-    typedef unsigned char enet_uint8;       /**< unsigned 8-bit type  */
-    typedef unsigned short enet_uint16;     /**< unsigned 16-bit type */
-    typedef unsigned int enet_uint32;      /**< unsigned 32-bit type */
-    typedef uint64_t enet_uint64;
+    typedef uint8_t   enet_uint8;   /**< unsigned 8-bit type  */
+    typedef uint16_t enet_uint16;   /**< unsigned 16-bit type */
+    typedef uint32_t enet_uint32;   /**< unsigned 32-bit type */
+    typedef uint64_t enet_uint64;   /**< unsigned 64-bit type */
 
     typedef enet_uint32 ENetVersion;
 
@@ -4881,10 +4881,10 @@ extern "C" {
                 if (result->ai_family == AF_INET) {
                     struct sockaddr_in * sin = (struct sockaddr_in *) result->ai_addr;
 
-                    ((uint32_t *) & address->host.s6_addr)[0] = 0;
-                    ((uint32_t *) & address->host.s6_addr)[1] = 0;
-                    ((uint32_t *) & address->host.s6_addr)[2] = htonl(0xffff);
-                    ((uint32_t *) & address->host.s6_addr)[3] = sin->sin_addr.s_addr;
+                    ((uint32_t *)&address->host.s6_addr)[0] = 0;
+                    ((uint32_t *)&address->host.s6_addr)[1] = 0;
+                    ((uint32_t *)&address->host.s6_addr)[2] = htonl(0xffff);
+                    ((uint32_t *)&address->host.s6_addr)[3] = sin->sin_addr.s_addr;
 
                     freeaddrinfo(resultList);
 

+ 20 - 15
misc/ChangeLog

@@ -1,5 +1,10 @@
 * use getaddrinfo and getnameinfo where available
 
+ENet 2.0.0 (April 22, 2018):
+* changed library format to single header
+* applied project-wide code style change
+* integrated ipv6 changes from @proller
+
 ENet 1.3.13 (April 30, 2015):
 
 * miscellaneous bug fixes
@@ -8,7 +13,7 @@ ENet 1.3.13 (April 30, 2015):
 
 ENet 1.3.12 (April 24, 2014):
 
-* added maximumPacketSize and maximumWaitingData fields to ENetHost to limit the amount of 
+* added maximumPacketSize and maximumWaitingData fields to ENetHost to limit the amount of
 data waiting to be delivered on a peer (beware that the default maximumPacketSize is
 32MB and should be set higher if desired as should maximumWaitingData)
 
@@ -31,7 +36,7 @@ ENet 1.3.9 (August 19, 2013):
 
 ENet 1.3.8 (June 2, 2013):
 
-* added enet_linked_version() for checking the linked version 
+* added enet_linked_version() for checking the linked version
 * added enet_socket_get_address() for querying the local address of a socket
 * silenced some debugging prints unless ENET_DEBUG is defined during compilation
 * handle EINTR in enet_socket_wait() so that enet_host_service() doesn't propagate errors from signals
@@ -50,7 +55,7 @@ ENet 1.3.6 (December 11, 2012):
 * added enet_socket_shutdown() for issuing shutdown on a socket
 * fixed enet_socket_connect() to not error on non-blocking connects
 * fixed bug in MTU negotiation during connections
- 
+
 ENet 1.3.5 (July 31, 2012):
 
 * fixed bug in unreliable packet fragment queuing
@@ -82,7 +87,7 @@ ENet 1.3.0 (June 5, 2010):
 
 * enet_host_create() now requires the channel limit to be specified as
 a parameter
-* enet_host_connect() now accepts a data parameter which is supplied 
+* enet_host_connect() now accepts a data parameter which is supplied
 to the receiving receiving host in the event data field for a connect event
 * added an adaptive order-2 PPM range coder as a built-in compressor option
 which can be set with enet_host_compress_with_range_coder()
@@ -91,7 +96,7 @@ which can be set with enet_host_compress_with_range_coder()
 field, saving 4 bytes per packet unless the checksum option is used
 * removed the dependence on the rand callback for session number handling
 
-Caveats: This version is not protocol compatible with the 1.2 series or 
+Caveats: This version is not protocol compatible with the 1.2 series or
 earlier. The enet_host_connect and enet_host_create API functions require
 supplying additional parameters.
 
@@ -122,15 +127,15 @@ unscalable array walking
 * added no_memory callback that is called when a malloc attempt fails,
 such that if no_memory returns rather than aborts (the default behavior),
 then the error is propagated to the return value of the API calls
-* now uses packed attribute for protocol structures on platforms with 
+* now uses packed attribute for protocol structures on platforms with
 strange alignment rules
-* improved autoconf build system contributed by Nathan Brink allowing 
+* improved autoconf build system contributed by Nathan Brink allowing
 for easier building as a shared library
 
 Caveats: If you were using the compile-time option that enabled checksums,
 make sure to set the checksum callback inside ENetHost to enet_crc32 to
 regain the old behavior. The ENetCallbacks structure has added new fields,
-so make sure to clear the structure to zero before use if 
+so make sure to clear the structure to zero before use if
 using enet_initialize_with_callbacks().
 
 ENet 1.2.1 (November 12, 2009):
@@ -160,17 +165,17 @@ random disconnects.
 
 ENet 1.1 (June 6, 2007):
 
-* optional CRC32 just in case someone needs a stronger checksum than UDP 
+* optional CRC32 just in case someone needs a stronger checksum than UDP
 provides (--enable-crc32 configure option)
-* the size of packet headers are half the size they used to be (so less 
+* the size of packet headers are half the size they used to be (so less
 overhead when sending small packets)
-* enet_peer_disconnect_later() that waits till all queued outgoing 
+* enet_peer_disconnect_later() that waits till all queued outgoing
 packets get sent before issuing an actual disconnect
-* freeCallback field in individual packets for notification of when a 
+* freeCallback field in individual packets for notification of when a
 packet is about to be freed
-* ENET_PACKET_FLAG_NO_ALLOCATE for supplying pre-allocated data to a 
-packet (can be used in concert with freeCallback to support some custom 
-allocation schemes that the normal memory allocation callbacks would 
+* ENET_PACKET_FLAG_NO_ALLOCATE for supplying pre-allocated data to a
+packet (can be used in concert with freeCallback to support some custom
+allocation schemes that the normal memory allocation callbacks would
 normally not allow)
 * enet_address_get_host_ip() for printing address numbers
 * promoted the enet_socket_*() functions to be part of the API now

+ 0 - 134
misc/build-singleheader.js

@@ -1,134 +0,0 @@
-const fs = require('fs')
-
-function read_file(name) {
-    return fs
-        .readFileSync(name)
-        .toString('utf-8')
-        .trim()
-}
-
-function include_enet(src) {
-    return src
-        .split('\n')
-        .map(line => {
-            // include enet header files for header
-            if (line.indexOf('#include "enet/') !== -1) {
-                return read_file('include/' + line.slice(10, -1))
-            }
-
-            return line
-        })
-        .join('\n')
-}
-
-function filter_libs(src, unqiue_lib_list) {
-    return src
-        .split('\n')
-        .map((line, i) => {
-            // remove references to enet across all file
-            if (line.indexOf('#include "enet/') !== -1) {
-                return ''
-            }
-
-            // reduce amount of includes to get rid of dublications
-            if (line.indexOf('#include <') !== -1) {
-                if (!unqiue_lib_list[line.slice(10, -1)]) {
-                    unqiue_lib_list[line.slice(10, -1)] = 1;
-                    return line
-                } else {
-                    unqiue_lib_list[line.slice(10, -1)]++
-                    return ''
-                }
-            }
-
-            return line
-                .replace(/\s*$/, '') /* remove trailing spaces */
-                .replace(/^\s{3}(\w)/, '    $1') /* make sure all tabulated lines have minumun 4 spaces */
-        })
-        .join('\n')
-}
-
-function attach_src(src, unqiue_lib_list, sources_list, scr_template) {
-    let files = sources_list
-        .map(file => {
-            return '\n// @from_file: ' + file + '\n' +
-                filter_libs(read_file(file), unqiue_lib_list)
-        })
-        .join('\n')
-
-    // add 4 spaces in front
-    files = files
-        .split('\n')
-        .map(line => line !== '' ? "    " + line : line)
-        .join('\n')
-
-    src = src.replace('#endif /* __ENET_ENET_H__ */', '')
-    src = src + scr_template[0] + files + scr_template[1]
-
-    return src
-}
-
-let sources = [
-    'src/callbacks.c',
-    'src/compress.c',
-    'src/host.c',
-    'src/list.c',
-    'src/packet.c',
-    'src/peer.c',
-    'src/protocol.c',
-    'src/unix.c',
-    'src/win32.c',
-]
-
-let scr_template = [
-`
-#if defined(ENET_IMPLEMENTATION) && !defined(ENET_IMPLEMENTATION_DONE)
-#define ENET_IMPLEMENTATION_DONE
-
-    #ifdef __cplusplus
-    extern "C"
-    {
-    #endif
-`,
-    // code there
-`
-    #ifdef __cplusplus
-    }
-    #endif
-
-#endif
-
-#endif /* __ENET_ENET_H__ */
-`];
-
-let prefix =
-`/**
- * include/enet.h - a Single-Header auto-generated variant of enet.h library.
- *
- * Usage:
- * #define ENET_IMPLEMENTATION exactly in ONE source file right BEFORE including the library, like:
- *
- * #define ENET_IMPLEMENTATION
- * #include <enet.h>
- *
- */
-
-#ifdef ENET_IMPLEMENTATION
-#define ENET_BUILDING_LIB 1
-#endif
-
-`;
-
-(function main() {
-    let list = {};
-    let src  = read_file('include/enet/enet.h')
-
-    src = include_enet(src)
-    src = filter_libs(src, list)
-    src = attach_src(src, list, sources, scr_template)
-
-    console.log(list)
-    // console.log('all included libs:\n', Object.keys(list).sort())
-
-    fs.writeFileSync('include/enet.h', prefix + src)
-})();