Commit 209a00c6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Cleanup

parent 0dc1ef3e
......@@ -89,8 +89,10 @@ int net_Socket (vlc_object_t *obj, int family, int socktype, int proto);
#define net_OpenTCP(a, b, c) __net_ConnectTCP(VLC_OBJECT(a), b, c)
VLC_EXPORT( int, __net_ConnectTCP, ( vlc_object_t *p_this, const char *psz_host, int i_port ) );
int *net_Listen (vlc_object_t *p_this, const char *psz_host, int i_port,
int family, int socktype, int protocol);
/*int *net_Listen, (vlc_object_t *p_this, const char *psz_host, int i_port,
int family, int socktype, int protocol);*/
VLC_EXPORT( int, net_ListenSingle, (vlc_object_t *p_this, const char *psz_host, int i_port,
int family, int socktype, int protocol) );
#define net_ListenTCP(a, b, c) __net_ListenTCP(VLC_OBJECT(a), b, c)
VLC_EXPORT( int *, __net_ListenTCP, ( vlc_object_t *, const char *, int ) );
......@@ -101,7 +103,10 @@ VLC_EXPORT( int, __net_Accept, ( vlc_object_t *, int *, mtime_t ) );
#define net_ConnectUDP(a, b, c, d ) __net_ConnectUDP(VLC_OBJECT(a), b, c, d)
VLC_EXPORT( int, __net_ConnectUDP, ( vlc_object_t *p_this, const char *psz_host, int i_port, int hlim ) );
VLC_EXPORT( int, net_ListenUDP1, (vlc_object_t *obj, const char *host, int port) );
static inline int net_ListenUDP1 (vlc_object_t *obj, const char *host, int port)
{
return net_ListenSingle (obj, host, port, AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP);
}
#define net_OpenUDP(a, b, c, d, e ) __net_OpenUDP(VLC_OBJECT(a), b, c, d, e)
VLC_EXPORT( int, __net_OpenUDP, ( vlc_object_t *p_this, const char *psz_bind, int i_bind, const char *psz_server, int i_server ) );
......
......@@ -554,7 +554,6 @@ struct module_symbols_t
void (*config_ChainDestroy_inner) (config_chain_t *);
char * (*config_ChainCreate_inner) (char **, config_chain_t **, char *);
int (*utf8_open_inner) (const char *filename, int flags, mode_t mode);
int (*net_ListenUDP1_inner) (vlc_object_t *obj, const char *host, int port);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
......@@ -1032,7 +1031,6 @@ struct module_symbols_t
# define config_ChainDestroy (p_symbols)->config_ChainDestroy_inner
# define config_ChainCreate (p_symbols)->config_ChainCreate_inner
# define utf8_open (p_symbols)->utf8_open_inner
# define net_ListenUDP1 (p_symbols)->net_ListenUDP1_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
......@@ -1513,7 +1511,6 @@ struct module_symbols_t
((p_symbols)->config_ChainDestroy_inner) = config_ChainDestroy; \
((p_symbols)->config_ChainCreate_inner) = config_ChainCreate; \
((p_symbols)->utf8_open_inner) = utf8_open; \
((p_symbols)->net_ListenUDP1_inner) = net_ListenUDP1; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__sout_CfgParse_deprecated = NULL; \
(p_symbols)->sout_CfgCreate_deprecated = NULL; \
......
......@@ -114,8 +114,8 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype,
}
int *net_Listen (vlc_object_t *p_this, const char *psz_host, int i_port,
int family, int socktype, int protocol)
static int *net_Listen (vlc_object_t *p_this, const char *psz_host,
int i_port, int family, int socktype, int protocol)
{
struct addrinfo hints, *res;
......@@ -233,6 +233,28 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, int i_port,
}
int net_ListenSingle (vlc_object_t *obj, const char *host, int port,
int family, int socktype, int protocol)
{
int *fdv = net_Listen (obj, host, port, family, socktype, protocol);
if (fdv == NULL)
return -1;
for (unsigned i = 1; fdv[i] != -1; i++)
{
msg_Warn (obj, "A socket has been dropped!");
net_Close (fdv[i]);
}
int fd = fdv[0];
assert (fd != -1);
free (fdv);
return fd;
}
/*****************************************************************************
* __net_Close:
*****************************************************************************
......
......@@ -402,38 +402,6 @@ int __net_ConnectUDP( vlc_object_t *p_this, const char *psz_host, int i_port,
}
static inline
int *__net_ListenUDP (vlc_object_t *obj, const char *host, int port)
{
int *fdv = net_Listen (obj, host, port, 0, SOCK_DGRAM, IPPROTO_UDP);
if (fdv == NULL)
return NULL;
/* FIXME: handle multicast subscription */
return fdv;
}
int net_ListenUDP1 (vlc_object_t *obj, const char *host, int port)
{
int *fdv = __net_ListenUDP (obj, host, port);
if (fdv == NULL)
return -1;
for (unsigned i = 1; fdv[i] != -1; i++)
{
msg_Warn (obj, "A socket has been dropped!");
net_Close (fdv[i]);
}
int fd = fdv[0];
assert (fd != -1);
free (fdv);
return fd;
}
/*****************************************************************************
* __net_OpenUDP:
*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment