1 /* 2 * host.h -- DNS lookups of hostnames 3 * 4 * Yet Another FTP Client 5 * Copyright (C) 1998-2001, Martin Hedenfalk <mhe@stacken.kth.se> 6 * Copyright (C) 2012, Sebastian Ramacher <sebastian+dev@ramacher.at> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. See COPYING for more details. 12 */ 13 14 #ifndef _host_h_included 15 #define _host_h_included 16 17 #include "syshdr.h" 18 #include "url.h" 19 20 typedef struct Host_ Host; 21 22 /** Create a Host instance from the given URL info. */ 23 Host* host_create(const url_t* urlp); 24 /** Destroy a Host instance. */ 25 void host_destroy(Host *hostp); 26 27 /** Perform host lookup. */ 28 bool host_lookup(Host *hostp); 29 uint16_t host_getport(const Host *hostp); /* returns port in network byte order */ 30 uint16_t host_gethport(const Host *hostp); /* returns port in host byte order */ 31 const char* host_getname(const Host *hostp); /* returns name as passed to host_set() */ 32 const char* host_geterror(const Host* hostp); /* returns error message of command that filed */ 33 /** Returns the IP address we're connected to. 34 * 35 * A value different from NULL is returned if and only if host_connect_addr has 36 * been called before. The value returned from host_getip has to be passed to 37 * free after use. 38 */ 39 char* host_getip(const Host* hostp); 40 /* returns official name (as returned from gethostbyname()) */ 41 const char* host_getoname(const Host *hostp); 42 43 const struct addrinfo* host_getaddrinfo(const Host* hostp); 44 void host_connect_addr(Host* hostp, const struct addrinfo* info); 45 46 char* printable_address(const struct sockaddr* sockaddr); 47 48 #endif 49