[vlc-commits] network: Remove httpd_handler_sys_t (refs #17018)
Rémi Denis-Courmont
git at videolan.org
Sun Feb 19 21:59:01 CET 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Feb 18 13:04:16 2017 +0200| [2b9c72c07bcc6bacf1f883efedfefe10ab628d91] | committer: Rémi Denis-Courmont
network: Remove httpd_handler_sys_t (refs #17018)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2b9c72c07bcc6bacf1f883efedfefe10ab628d91
---
include/vlc_httpd.h | 7 +++----
modules/lua/libs/httpd.c | 12 ++++++------
src/missing.c | 10 +++++-----
src/network/httpd.c | 14 +++++++-------
4 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/include/vlc_httpd.h b/include/vlc_httpd.h
index 852a7a8..dc3b96b 100644
--- a/include/vlc_httpd.h
+++ b/include/vlc_httpd.h
@@ -128,10 +128,9 @@ VLC_API httpd_file_sys_t * httpd_FileDelete( httpd_file_t * );
typedef struct httpd_handler_t httpd_handler_t;
-typedef struct httpd_handler_sys_t httpd_handler_sys_t;
-typedef int (*httpd_handler_callback_t)( httpd_handler_sys_t *, httpd_handler_t *, char *psz_url, uint8_t *psz_request, int i_type, uint8_t *p_in, int i_in, char *psz_remote_addr, char *psz_remote_host, uint8_t **pp_data, int *pi_data );
-VLC_API httpd_handler_t * httpd_HandlerNew( httpd_host_t *, const char *psz_url, const char *psz_user, const char *psz_password, httpd_handler_callback_t pf_fill, httpd_handler_sys_t * ) VLC_USED;
-VLC_API httpd_handler_sys_t * httpd_HandlerDelete( httpd_handler_t * );
+typedef int (*httpd_handler_callback_t)( void *, httpd_handler_t *, char *psz_url, uint8_t *psz_request, int i_type, uint8_t *p_in, int i_in, char *psz_remote_addr, char *psz_remote_host, uint8_t **pp_data, int *pi_data );
+VLC_API httpd_handler_t * httpd_HandlerNew( httpd_host_t *, const char *psz_url, const char *psz_user, const char *psz_password, httpd_handler_callback_t pf_fill, void * ) VLC_USED;
+VLC_API void * httpd_HandlerDelete( httpd_handler_t * );
typedef struct httpd_redirect_t httpd_redirect_t;
VLC_API httpd_redirect_t * httpd_RedirectNew( httpd_host_t *, const char *psz_url_dst, const char *psz_url_src ) VLC_USED;
diff --git a/modules/lua/libs/httpd.c b/modules/lua/libs/httpd.c
index 1205102..f0d28e9 100644
--- a/modules/lua/libs/httpd.c
+++ b/modules/lua/libs/httpd.c
@@ -112,20 +112,21 @@ static int vlclua_httpd_host_delete( lua_State *L )
/*****************************************************************************
* HTTPd Handler
*****************************************************************************/
-struct httpd_handler_sys_t
+typedef struct
{
lua_State *L;
bool password;
int ref;
-};
+} httpd_handler_lua_t;
static int vlclua_httpd_handler_callback(
- httpd_handler_sys_t *p_sys, httpd_handler_t *p_handler, char *psz_url,
+ void *opaque, httpd_handler_t *p_handler, char *psz_url,
uint8_t *psz_request, int i_type, uint8_t *p_in, int i_in,
char *psz_remote_addr, char *psz_remote_host,
uint8_t **pp_data, int *pi_data )
{
VLC_UNUSED(p_handler);
+ httpd_handler_lua_t *p_sys = opaque;
lua_State *L = p_sys->L;
/* function data */
@@ -190,8 +191,7 @@ static int vlclua_httpd_handler_new( lua_State * L )
luaL_argcheck( L, lua_isfunction( L, 5 ), 5, "Should be a function" );
/* Stack item 6 is the callback data */
lua_settop( L, 6 );
- httpd_handler_sys_t *p_sys = (httpd_handler_sys_t*)
- malloc( sizeof( httpd_handler_sys_t ) );
+ httpd_handler_lua_t *p_sys = malloc( sizeof( *p_sys ) );
if( !p_sys )
return luaL_error( L, "Failed to allocate private buffer." );
p_sys->L = lua_newthread( L );
@@ -225,7 +225,7 @@ static int vlclua_httpd_handler_new( lua_State * L )
static int vlclua_httpd_handler_delete( lua_State *L )
{
httpd_handler_t **pp_handler = (httpd_handler_t**)luaL_checkudata( L, 1, "httpd_handler" );
- httpd_handler_sys_t *p_sys = httpd_HandlerDelete( *pp_handler );
+ httpd_handler_lua_t *p_sys = httpd_HandlerDelete( *pp_handler );
luaL_unref( p_sys->L, LUA_REGISTRYINDEX, p_sys->ref );
free( p_sys );
return 0;
diff --git a/src/missing.c b/src/missing.c
index 1ff22e2..b1e4a81 100644
--- a/src/missing.c
+++ b/src/missing.c
@@ -65,16 +65,16 @@ httpd_file_t *httpd_FileNew (httpd_host_t *host,
vlc_assert_unreachable ();
}
-httpd_handler_sys_t *httpd_HandlerDelete (httpd_handler_t *handler)
+void *httpd_HandlerDelete(httpd_handler_t *handler)
{
(void) handler;
vlc_assert_unreachable ();
}
-httpd_handler_t *httpd_HandlerNew (httpd_host_t *host, const char *url,
- const char *login, const char *password,
- httpd_handler_callback_t cb,
- httpd_handler_sys_t *data)
+httpd_handler_t *httpd_HandlerNew(httpd_host_t *host, const char *url,
+ const char *login, const char *password,
+ httpd_handler_callback_t cb,
+ void *data)
{
(void) host; (void) url;
(void) login; (void) password;
diff --git a/src/network/httpd.c b/src/network/httpd.c
index 5eec4a2..ace040a 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -408,7 +408,7 @@ struct httpd_handler_t
httpd_url_t *url;
httpd_handler_callback_t pf_fill;
- httpd_handler_sys_t *p_sys;
+ void *p_sys;
};
@@ -483,10 +483,10 @@ httpd_HandlerCallBack(httpd_callback_sys_t *p_sys, httpd_client_t *cl,
}
httpd_handler_t *httpd_HandlerNew(httpd_host_t *host, const char *psz_url,
- const char *psz_user,
- const char *psz_password,
- httpd_handler_callback_t pf_fill,
- httpd_handler_sys_t *p_sys)
+ const char *psz_user,
+ const char *psz_password,
+ httpd_handler_callback_t pf_fill,
+ void *p_sys)
{
httpd_handler_t *handler = malloc(sizeof(*handler));
if (!handler)
@@ -511,9 +511,9 @@ httpd_handler_t *httpd_HandlerNew(httpd_host_t *host, const char *psz_url,
return handler;
}
-httpd_handler_sys_t *httpd_HandlerDelete(httpd_handler_t *handler)
+void *httpd_HandlerDelete(httpd_handler_t *handler)
{
- httpd_handler_sys_t *p_sys = handler->p_sys;
+ void *p_sys = handler->p_sys;
httpd_UrlDelete(handler->url);
free(handler);
return p_sys;
More information about the vlc-commits
mailing list