1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-12-04 14:46:31 -05:00

Feature: Added error parameter to igloo_socketaddr_new()

This commit is contained in:
Philipp Schafft 2019-09-25 07:00:11 +00:00
parent 3ab83f7cf1
commit f5dbb83092
2 changed files with 11 additions and 8 deletions

View File

@ -64,7 +64,7 @@ typedef enum {
igloo_SOCKETADDR_PROTOCOL_UDPLITE igloo_SOCKETADDR_PROTOCOL_UDPLITE
} igloo_socketaddr_protocol_t; } 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_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); igloo_error_t igloo_socketaddr_set_node(igloo_socketaddr_t *addr, const char *node);

View File

@ -375,12 +375,15 @@ static igloo_error_t _get_service(igloo_socketaddr_t *addr, const char *name, ui
#endif #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); 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; return NULL;
}
addr->domain = domain; addr->domain = domain;
addr->type = type; addr->type = type;
@ -388,6 +391,9 @@ igloo_socketaddr_t * igloo_socketaddr_new(igloo_socketaddr_domain_t domain, i
igloo_socketaddr_complete(addr); igloo_socketaddr_complete(addr);
if (error)
*error = igloo_ERROR_NONE;
return addr; 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); domain_hint = igloo_socketaddr_get_id_domain(sysaddr->sa_family);
ret = igloo_socketaddr_new(domain_hint, type_hint, protocol_hint, name, associated, instance); ret = igloo_socketaddr_new(domain_hint, type_hint, protocol_hint, name, associated, instance, error);
if (ret == NULL) { if (ret == NULL)
if (error)
*error = igloo_ERROR_GENERIC;
return NULL; return NULL;
}
if (getnameinfo(sysaddr, addr_len, ip, sizeof(ip), service, sizeof(service), NI_NUMERICHOST|NI_NUMERICSERV) == 0) { if (getnameinfo(sysaddr, addr_len, ip, sizeof(ip), service, sizeof(service), NI_NUMERICHOST|NI_NUMERICSERV) == 0) {
igloo_socketaddr_set_node(ret, ip); igloo_socketaddr_set_node(ret, ip);