moonbridge

changeset 258:56c12449bba0

Code reformatting (of #ifdef MOONBR_IO_USE_TLS)
author jbe
date Sun Sep 18 12:02:38 2016 +0200 (2016-09-18)
parents 77a7ca00ad34
children 385b6607785a
files moonbridge_io.c
line diff
     1.1 --- a/moonbridge_io.c	Sun Sep 18 02:19:21 2016 +0200
     1.2 +++ b/moonbridge_io.c	Sun Sep 18 12:02:38 2016 +0200
     1.3 @@ -62,13 +62,15 @@
     1.4  #define MOONBR_IO_CHILD_PT_REGKEY "moonbridge_io_child_pt"
     1.5  
     1.6  #ifdef MOONBR_IO_USE_TLS
     1.7 +
     1.8  #define MOONBR_IO_TLSCONF_MT_REGKEY "moonbridge_io_tlsconf"
     1.9  
    1.10  typedef struct {
    1.11    struct tls_config *config;
    1.12    int server;
    1.13  } moonbr_io_tlsconf_t;
    1.14 -#endif
    1.15 +
    1.16 +#endif /* MOONBR_IO_USE_TLS */
    1.17  
    1.18  typedef struct {
    1.19    int fd;
    1.20 @@ -458,6 +460,7 @@
    1.21  moonbr_io_yield_wrapper(moonbr_io_drain_yield, moonbr_io_drain_call);
    1.22  
    1.23  #ifdef MOONBR_IO_USE_TLS
    1.24 +
    1.25  #define moonbr_io_write_tls(buf, buflen) \
    1.26    if (handle->tls) { \
    1.27      do { \
    1.28 @@ -490,7 +493,8 @@
    1.29      } while (0); \
    1.30    } \
    1.31    else
    1.32 -#endif
    1.33 +
    1.34 +#endif /* MOONBR_IO_USE_TLS */
    1.35  
    1.36  static int moonbr_io_write_impl(lua_State *L, int nonblocking, int flush) {
    1.37    moonbr_io_handle_t *handle;
    1.38 @@ -1560,6 +1564,7 @@
    1.39  moonbr_io_yield_wrapper(moonbr_io_wait_yield, moonbr_io_wait_call);
    1.40  
    1.41  #ifdef MOONBR_IO_USE_TLS
    1.42 +
    1.43  #define moonbr_io_poll_tls() \
    1.44    if (!handle->tlshandshake) { \
    1.45      lua_pushboolean(L, 1); \
    1.46 @@ -1584,7 +1589,8 @@
    1.47      continue; \
    1.48    } \
    1.49    while (0)
    1.50 -#endif
    1.51 +
    1.52 +#endif /* MOONBR_IO_USE_TLS */
    1.53  
    1.54  static int moonbr_io_poll(lua_State *L) {
    1.55    moonbr_io_handle_t *handle;
    1.56 @@ -1806,9 +1812,7 @@
    1.57    tlsconf = luaL_checkudata(L, 2, MOONBR_IO_TLSCONF_MT_REGKEY);
    1.58    if (handle->closed) return luaL_error(L, "Attempt to start TLS on a closed I/O handle");
    1.59    if (handle->finished) return luaL_error(L, "Attempt to start TLS on a finished I/O handle");
    1.60 -#ifdef MOONBR_IO_USE_TLS
    1.61    if (handle->tls) return luaL_error(L, "Attempt to start TLS twice");
    1.62 -#endif
    1.63    if (handle->readbufin || handle->writebufin) {
    1.64      return luaL_error(L, "Attempt to start TLS on an I/O handle with non-empty buffers");
    1.65    }
    1.66 @@ -1838,7 +1842,7 @@
    1.67    return 2;
    1.68  }
    1.69  
    1.70 -#endif
    1.71 +#endif /* MOONBR_IO_USE_TLS */
    1.72  
    1.73  static const struct luaL_Reg moonbr_io_handle_methods[] = {
    1.74    {"read", moonbr_io_read},
    1.75 @@ -1918,11 +1922,13 @@
    1.76  };
    1.77  
    1.78  #ifdef MOONBR_IO_USE_TLS
    1.79 +
    1.80  static const struct luaL_Reg moonbr_io_tlsconf_metamethods[] = {
    1.81    {"__gc", moonbr_io_tlsconfgc},
    1.82    {NULL, NULL}
    1.83  };
    1.84 -#endif
    1.85 +
    1.86 +#endif /* MOONBR_IO_USE_TLS */
    1.87  
    1.88  int luaopen_moonbridge_io(lua_State *L) {
    1.89  

Impressum / About Us