mirror of
https://gitlab.xiph.org/xiph/icecast-common.git
synced 2024-11-03 04:17:20 -05:00
Feature: Added error parameter to igloo_socketaddr_new()
This commit is contained in:
parent
3ab83f7cf1
commit
f5dbb83092
@ -64,7 +64,7 @@ typedef enum {
|
||||
igloo_SOCKETADDR_PROTOCOL_UDPLITE
|
||||
} igloo_socketaddr_protocol_t;
|
||||
|
||||
igloo_socketaddr_t * igloo_socketaddr_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_socketaddr_t * igloo_socketaddr_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_error_t *error);
|
||||
igloo_error_t igloo_socketaddr_get_base(igloo_socketaddr_t *addr, igloo_socketaddr_domain_t *domain, igloo_socketaddr_type_t *type, igloo_socketaddr_protocol_t *protocol);
|
||||
|
||||
igloo_error_t igloo_socketaddr_set_node(igloo_socketaddr_t *addr, const char *node);
|
||||
|
@ -375,12 +375,15 @@ static igloo_error_t _get_service(igloo_socketaddr_t *addr, const char *name, ui
|
||||
|
||||
#endif
|
||||
|
||||
igloo_socketaddr_t * igloo_socketaddr_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_socketaddr_t * igloo_socketaddr_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_error_t *error)
|
||||
{
|
||||
igloo_socketaddr_t *addr = igloo_ro_new_raw(igloo_socketaddr_t, name, associated, instance);
|
||||
|
||||
if (!addr)
|
||||
if (!addr) {
|
||||
if (error)
|
||||
*error = igloo_ERROR_NOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
addr->domain = domain;
|
||||
addr->type = type;
|
||||
@ -388,6 +391,9 @@ igloo_socketaddr_t * igloo_socketaddr_new(igloo_socketaddr_domain_t domain, i
|
||||
|
||||
igloo_socketaddr_complete(addr);
|
||||
|
||||
if (error)
|
||||
*error = igloo_ERROR_NONE;
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
@ -406,12 +412,9 @@ igloo_socketaddr_t * igloo_socketaddr_new_from_sockaddr(igloo_socketaddr_doma
|
||||
|
||||
domain_hint = igloo_socketaddr_get_id_domain(sysaddr->sa_family);
|
||||
|
||||
ret = igloo_socketaddr_new(domain_hint, type_hint, protocol_hint, name, associated, instance);
|
||||
if (ret == NULL) {
|
||||
if (error)
|
||||
*error = igloo_ERROR_GENERIC;
|
||||
ret = igloo_socketaddr_new(domain_hint, type_hint, protocol_hint, name, associated, instance, error);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (getnameinfo(sysaddr, addr_len, ip, sizeof(ip), service, sizeof(service), NI_NUMERICHOST|NI_NUMERICSERV) == 0) {
|
||||
igloo_socketaddr_set_node(ret, ip);
|
||||
|
Loading…
Reference in New Issue
Block a user