Deleted Added
full compact
fake-rfc2553.c (181110) fake-rfc2553.c (181111)
1/*
2 * Copyright (C) 2000-2003 Damien Miller. All rights reserved.
3 * Copyright (C) 1999 WIDE Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 37 unchanged lines hidden (view full) ---

46#ifndef HAVE_GETNAMEINFO
47int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
48 size_t hostlen, char *serv, size_t servlen, int flags)
49{
50 struct sockaddr_in *sin = (struct sockaddr_in *)sa;
51 struct hostent *hp;
52 char tmpserv[16];
53
1/*
2 * Copyright (C) 2000-2003 Damien Miller. All rights reserved.
3 * Copyright (C) 1999 WIDE Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 37 unchanged lines hidden (view full) ---

46#ifndef HAVE_GETNAMEINFO
47int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
48 size_t hostlen, char *serv, size_t servlen, int flags)
49{
50 struct sockaddr_in *sin = (struct sockaddr_in *)sa;
51 struct hostent *hp;
52 char tmpserv[16];
53
54 if (sa->sa_family != AF_UNSPEC && sa->sa_family != AF_INET)
55 return (EAI_FAMILY);
54 if (serv != NULL) {
55 snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port));
56 if (strlcpy(serv, tmpserv, servlen) >= servlen)
57 return (EAI_MEMORY);
58 }
59
60 if (host != NULL) {
61 if (flags & NI_NUMERICHOST) {

--- 28 unchanged lines hidden (view full) ---

90{
91 switch (err) {
92 case EAI_NODATA:
93 return ("no address associated with name");
94 case EAI_MEMORY:
95 return ("memory allocation failure.");
96 case EAI_NONAME:
97 return ("nodename nor servname provided, or not known");
56 if (serv != NULL) {
57 snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port));
58 if (strlcpy(serv, tmpserv, servlen) >= servlen)
59 return (EAI_MEMORY);
60 }
61
62 if (host != NULL) {
63 if (flags & NI_NUMERICHOST) {

--- 28 unchanged lines hidden (view full) ---

92{
93 switch (err) {
94 case EAI_NODATA:
95 return ("no address associated with name");
96 case EAI_MEMORY:
97 return ("memory allocation failure.");
98 case EAI_NONAME:
99 return ("nodename nor servname provided, or not known");
100 case EAI_FAMILY:
101 return ("ai_family not supported");
98 default:
99 return ("unknown/invalid error.");
100 }
101}
102#endif /* !HAVE_GAI_STRERROR */
103
104#ifndef HAVE_FREEADDRINFO
105void

--- 48 unchanged lines hidden (view full) ---

154 struct hostent *hp;
155 struct servent *sp;
156 struct in_addr in;
157 int i;
158 long int port;
159 u_long addr;
160
161 port = 0;
102 default:
103 return ("unknown/invalid error.");
104 }
105}
106#endif /* !HAVE_GAI_STRERROR */
107
108#ifndef HAVE_FREEADDRINFO
109void

--- 48 unchanged lines hidden (view full) ---

158 struct hostent *hp;
159 struct servent *sp;
160 struct in_addr in;
161 int i;
162 long int port;
163 u_long addr;
164
165 port = 0;
166 if (hints && hints->ai_family != AF_UNSPEC &&
167 hints->ai_family != AF_INET)
168 return (EAI_FAMILY);
162 if (servname != NULL) {
163 char *cp;
164
165 port = strtol(servname, &cp, 10);
166 if (port > 0 && port <= 65535 && *cp == '\0')
167 port = htons(port);
168 else if ((sp = getservbyname(servname, NULL)) != NULL)
169 port = sp->s_port;

--- 59 unchanged lines hidden ---
169 if (servname != NULL) {
170 char *cp;
171
172 port = strtol(servname, &cp, 10);
173 if (port > 0 && port <= 65535 && *cp == '\0')
174 port = htons(port);
175 else if ((sp = getservbyname(servname, NULL)) != NULL)
176 port = sp->s_port;

--- 59 unchanged lines hidden ---