mirror of
https://gitlab.xiph.org/xiph/icecast-common.git
synced 2024-12-04 14:46:31 -05:00
Feature: Added a igloo_socket_new_simple()
This commit is contained in:
parent
4787991208
commit
0150c49f73
@ -70,6 +70,7 @@ typedef enum {
|
||||
} igloo_socket_endpoint_t;
|
||||
|
||||
igloo_socket_t * igloo_socket_new(igloo_socketaddr_domain_t domain, igloo_socketaddr_type_t type, igloo_socketaddr_protocol_t protocol, const char *name, igloo_ro_t associated, igloo_ro_t instance);
|
||||
igloo_socket_t * igloo_socket_new_simple(igloo_socket_endpoint_t endpoint, igloo_socketaddr_t *addr, igloo_error_t *error);
|
||||
igloo_error_t igloo_socket_alter_address(igloo_socket_t *sock, igloo_socket_addressop_t op, igloo_socket_endpoint_t endpoint, igloo_socketaddr_t *addr);
|
||||
igloo_socketaddr_t * igloo_socket_get_main_address(igloo_socket_t *sock, igloo_socket_endpoint_t endpoint, igloo_error_t *error);
|
||||
igloo_list_t * igloo_socket_get_address(igloo_socket_t *sock, igloo_socket_endpoint_t endpoint, igloo_error_t *error);
|
||||
|
33
src/socket.c
33
src/socket.c
@ -283,6 +283,39 @@ igloo_socket_t * igloo_socket_new(igloo_socketaddr_domain_t domain, igloo_socket
|
||||
return sock;
|
||||
}
|
||||
|
||||
igloo_socket_t * igloo_socket_new_simple(igloo_socket_endpoint_t endpoint, igloo_socketaddr_t *addr, igloo_error_t *error)
|
||||
{
|
||||
igloo_socketaddr_domain_t domain;
|
||||
igloo_socketaddr_type_t type;
|
||||
igloo_socketaddr_protocol_t protocol;
|
||||
igloo_error_t err;
|
||||
igloo_socket_t *sock;
|
||||
|
||||
err = igloo_socketaddr_get_base(addr, &domain, &type, &protocol);
|
||||
if (err != igloo_ERROR_NONE) {
|
||||
if (error)
|
||||
*error = err;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sock = igloo_socket_new(domain, type, protocol, NULL, igloo_RO_NULL, addr);
|
||||
if (!sock) {
|
||||
if (error)
|
||||
*error = igloo_ERROR_GENERIC;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = igloo_socket_alter_address(sock, igloo_SOCKET_ADDRESSOP_ADD, endpoint, addr);
|
||||
if (err != igloo_ERROR_NONE) {
|
||||
igloo_ro_unref(sock);
|
||||
if (error)
|
||||
*error = err;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
static inline igloo_error_t _replace_addr(igloo_socketaddr_t **storage, igloo_socketaddr_t *addr)
|
||||
{
|
||||
igloo_error_t ret;
|
||||
|
Loading…
Reference in New Issue
Block a user