/* Add a hostname entry to list. */ static int add_host_to_list(struct serverlist *list, const char *hostname, int port, k5_transport transport, int family, const char *uri_path, int master) { struct server_entry *entry; entry = new_server_entry(list); if (entry == NULL) return ENOMEM; entry->transport = transport; entry->family = family; entry->hostname = strdup(hostname); if (entry->hostname == NULL) goto oom; if (uri_path != NULL) { entry->uri_path = strdup(uri_path); if (entry->uri_path == NULL) goto oom; } entry->port = port; entry->master = master; list->nservers++; return 0; oom: free(entry->hostname); entry->hostname = NULL; return ENOMEM; }
/* Add an address entry to list. */ static int add_addr_to_list(struct serverlist *list, int socktype, int family, size_t addrlen, struct sockaddr *addr) { struct server_entry *entry; entry = new_server_entry(list); if (entry == NULL) return ENOMEM; entry->socktype = socktype; entry->family = family; entry->hostname = NULL; entry->addrlen = addrlen; memcpy(&entry->addr, addr, addrlen); list->nservers++; return 0; }
/* Add a hostname entry to list. */ static int add_host_to_list(struct serverlist *list, const char *hostname, int port, int socktype, int family) { struct server_entry *entry; entry = new_server_entry(list); if (entry == NULL) return ENOMEM; entry->socktype = socktype; entry->family = family; entry->hostname = strdup(hostname); if (entry->hostname == NULL) return ENOMEM; entry->port = port; list->nservers++; return 0; }
/* Add an address entry to list. */ static int add_addr_to_list(struct serverlist *list, k5_transport transport, int family, size_t addrlen, struct sockaddr *addr) { struct server_entry *entry; entry = new_server_entry(list); if (entry == NULL) return ENOMEM; entry->transport = transport; entry->family = family; entry->hostname = NULL; entry->uri_path = NULL; entry->addrlen = addrlen; memcpy(&entry->addr, addr, addrlen); list->nservers++; return 0; }