diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-05-05 07:47:11 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-05-05 07:47:11 +0000 |
commit | 83b26b97b580d12579d28007a79d5921d448517b (patch) | |
tree | 6da3db2e8cbeae98791abd67eee69fe738cbdc28 /libssh | |
parent | ce1a5d75785c4954b8729107ae663fcb6c6e7265 (diff) | |
download | libssh-83b26b97b580d12579d28007a79d5921d448517b.tar.gz libssh-83b26b97b580d12579d28007a79d5921d448517b.tar.xz libssh-83b26b97b580d12579d28007a79d5921d448517b.zip |
Improve getai().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@726 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh')
-rw-r--r-- | libssh/connect.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/libssh/connect.c b/libssh/connect.c index 0b0fc83..8c74f57 100644 --- a/libssh/connect.c +++ b/libssh/connect.c @@ -89,23 +89,25 @@ static void sock_set_blocking(socket_t sock) { } #endif /* _WIN32 */ -static int getai(const char *host, int port, struct addrinfo **ai) -{ - struct addrinfo hints; - char *service=NULL; - char s_port[10]; - - memset(&hints,0,sizeof(hints)); - hints.ai_protocol=IPPROTO_TCP; - hints.ai_family=PF_UNSPEC; - hints.ai_socktype=SOCK_STREAM; - if(port==0){ - hints.ai_flags=AI_PASSIVE; - } else { - snprintf(s_port,sizeof(s_port),"%hu",port); - service=s_port; - } - return getaddrinfo(host,service,&hints,ai); +static int getai(const char *host, int port, struct addrinfo **ai) { + const char *service = NULL; + struct addrinfo hints; + char s_port[10]; + + ZERO_STRUCT(hints); + + hints.ai_protocol = IPPROTO_TCP; + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + + if (port == 0) { + hints.ai_flags = AI_PASSIVE; + } else { + snprintf(s_port, sizeof(s_port), "%hu", port); + service = s_port; + } + + return getaddrinfo(host, service, &hints, ai); } static int ssh_connect_ai_timeout(SSH_SESSION *session, const char *host, |