# HG changeset patch # User jbe # Date 1474192958 -7200 # Node ID 56c12449bba0db4f2095826e5c610f891a7a0d4c # Parent 77a7ca00ad34870ad9c0f85749ed336a0be9a180 Code reformatting (of #ifdef MOONBR_IO_USE_TLS) diff -r 77a7ca00ad34 -r 56c12449bba0 moonbridge_io.c --- a/moonbridge_io.c Sun Sep 18 02:19:21 2016 +0200 +++ b/moonbridge_io.c Sun Sep 18 12:02:38 2016 +0200 @@ -62,13 +62,15 @@ #define MOONBR_IO_CHILD_PT_REGKEY "moonbridge_io_child_pt" #ifdef MOONBR_IO_USE_TLS + #define MOONBR_IO_TLSCONF_MT_REGKEY "moonbridge_io_tlsconf" typedef struct { struct tls_config *config; int server; } moonbr_io_tlsconf_t; -#endif + +#endif /* MOONBR_IO_USE_TLS */ typedef struct { int fd; @@ -458,6 +460,7 @@ moonbr_io_yield_wrapper(moonbr_io_drain_yield, moonbr_io_drain_call); #ifdef MOONBR_IO_USE_TLS + #define moonbr_io_write_tls(buf, buflen) \ if (handle->tls) { \ do { \ @@ -490,7 +493,8 @@ } while (0); \ } \ else -#endif + +#endif /* MOONBR_IO_USE_TLS */ static int moonbr_io_write_impl(lua_State *L, int nonblocking, int flush) { moonbr_io_handle_t *handle; @@ -1560,6 +1564,7 @@ moonbr_io_yield_wrapper(moonbr_io_wait_yield, moonbr_io_wait_call); #ifdef MOONBR_IO_USE_TLS + #define moonbr_io_poll_tls() \ if (!handle->tlshandshake) { \ lua_pushboolean(L, 1); \ @@ -1584,7 +1589,8 @@ continue; \ } \ while (0) -#endif + +#endif /* MOONBR_IO_USE_TLS */ static int moonbr_io_poll(lua_State *L) { moonbr_io_handle_t *handle; @@ -1806,9 +1812,7 @@ tlsconf = luaL_checkudata(L, 2, MOONBR_IO_TLSCONF_MT_REGKEY); if (handle->closed) return luaL_error(L, "Attempt to start TLS on a closed I/O handle"); if (handle->finished) return luaL_error(L, "Attempt to start TLS on a finished I/O handle"); -#ifdef MOONBR_IO_USE_TLS if (handle->tls) return luaL_error(L, "Attempt to start TLS twice"); -#endif if (handle->readbufin || handle->writebufin) { return luaL_error(L, "Attempt to start TLS on an I/O handle with non-empty buffers"); } @@ -1838,7 +1842,7 @@ return 2; } -#endif +#endif /* MOONBR_IO_USE_TLS */ static const struct luaL_Reg moonbr_io_handle_methods[] = { {"read", moonbr_io_read}, @@ -1918,11 +1922,13 @@ }; #ifdef MOONBR_IO_USE_TLS + static const struct luaL_Reg moonbr_io_tlsconf_metamethods[] = { {"__gc", moonbr_io_tlsconfgc}, {NULL, NULL} }; -#endif + +#endif /* MOONBR_IO_USE_TLS */ int luaopen_moonbridge_io(lua_State *L) {