[vlc-devel] [PATCH 7/9] lua: httpd: Expose server port

Hugo Beauzée-Luyssen hugo at beauzee.fr
Wed Sep 2 15:47:29 CEST 2020


---
 modules/lua/libs/httpd.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/modules/lua/libs/httpd.c b/modules/lua/libs/httpd.c
index 986f1e5564..b8756a2a90 100644
--- a/modules/lua/libs/httpd.c
+++ b/modules/lua/libs/httpd.c
@@ -49,6 +49,7 @@ static int vlclua_httpd_file_new( lua_State * );
 static int vlclua_httpd_file_delete( lua_State * );
 static int vlclua_httpd_redirect_new( lua_State * );
 static int vlclua_httpd_redirect_delete( lua_State * );
+static int vlclua_httpd_port( lua_State * );
 
 /*****************************************************************************
  * HTTPD Host
@@ -57,6 +58,7 @@ static const luaL_Reg vlclua_httpd_reg[] = {
     { "handler", vlclua_httpd_handler_new },
     { "file", vlclua_httpd_file_new },
     { "redirect", vlclua_httpd_redirect_new },
+    { "port", vlclua_httpd_port },
     { NULL, NULL }
 };
 
@@ -382,6 +384,13 @@ static uint8_t *vlclua_todata( lua_State *L, int narg, int *pi_data )
     return p_data;
 }
 
+static int vlclua_httpd_port( lua_State *L )
+{
+    httpd_host_t **pp_host = (httpd_host_t **)luaL_checkudata( L, 1, "httpd_host" );
+    lua_pushinteger( L, httpd_ServerPort( *pp_host ) );
+    return 1;
+}
+
 /*****************************************************************************
  *
  *****************************************************************************/
-- 
2.20.1



More information about the vlc-devel mailing list