diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2015-09-24 13:48:37 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2015-09-24 13:48:37 (GMT) |
commit | 6f3388528ef453d29fbddba3f5a054d2f5268207 (patch) | |
tree | 51b638cc0fe1a9d9ca7a4590d9eb8d38b6f79307 /compat/fake-rfc2553.c | |
parent | bf1e2150cc603698bc042d0552c49930e86b2ca9 (diff) | |
parent | f9465250b939d54021e85ba03eaf63f31b4b3037 (diff) | |
download | tcl-6f3388528ef453d29fbddba3f5a054d2f5268207.zip tcl-6f3388528ef453d29fbddba3f5a054d2f5268207.tar.gz tcl-6f3388528ef453d29fbddba3f5a054d2f5268207.tar.bz2 |
merge trunk
Diffstat (limited to 'compat/fake-rfc2553.c')
-rw-r--r-- | compat/fake-rfc2553.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/compat/fake-rfc2553.c b/compat/fake-rfc2553.c index 3b91041..c8e69400 100644 --- a/compat/fake-rfc2553.c +++ b/compat/fake-rfc2553.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2000-2003 Damien Miller. All rights reserved. * Copyright (C) 1999 WIDE Project. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -67,7 +67,7 @@ strlcpy(char *dst, const char *src, size_t siz) } #endif -int fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, +int fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { struct sockaddr_in *sin = (struct sockaddr_in *)sa; @@ -96,7 +96,7 @@ int fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, } else { int ret; Tcl_MutexLock(&netdbMutex); - hp = gethostbyaddr((char *)&sin->sin_addr, + hp = gethostbyaddr((char *)&sin->sin_addr, sizeof(struct in_addr), AF_INET); if (hp == NULL) { ret = EAI_NODATA; @@ -130,7 +130,7 @@ fake_gai_strerror(int err) default: return ("unknown/invalid error."); } -} +} #endif /* !HAVE_GAI_STRERROR */ #ifndef HAVE_FREEADDRINFO @@ -156,9 +156,9 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) ai = malloc(sizeof(*ai) + sizeof(struct sockaddr_in)); if (ai == NULL) return (NULL); - + memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in)); - + ai->ai_addr = (struct sockaddr *)(ai + 1); /* XXX -- ssh doesn't use sa_len */ ai->ai_addrlen = sizeof(struct sockaddr_in); @@ -166,7 +166,7 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port; ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr; - + /* XXX: the following is not generally correct, but does what we want */ if (hints->ai_socktype) ai->ai_socktype = hints->ai_socktype; @@ -180,7 +180,7 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) } int -fake_getaddrinfo(const char *hostname, const char *servname, +fake_getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res) { struct hostent *hp; @@ -211,29 +211,29 @@ fake_getaddrinfo(const char *hostname, const char *servname, if (hostname && inet_aton(hostname, &in) != 0) addr = in.s_addr; *res = malloc_ai(port, addr, hints); - if (*res == NULL) + if (*res == NULL) return (EAI_MEMORY); return (0); } - + if (!hostname) { *res = malloc_ai(port, htonl(0x7f000001), hints); - if (*res == NULL) + if (*res == NULL) return (EAI_MEMORY); return (0); } - + if (inet_aton(hostname, &in)) { *res = malloc_ai(port, in.s_addr, hints); - if (*res == NULL) + if (*res == NULL) return (EAI_MEMORY); return (0); } - + /* Don't try DNS if AI_NUMERICHOST is set */ if (hints && hints->ai_flags & AI_NUMERICHOST) return (EAI_NONAME); - + Tcl_MutexLock(&netdbMutex); hp = gethostbyname(hostname); if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { |