Kaydet (Commit) af19d9f5 authored tarafından Arnaud Versini's avatar Arnaud Versini Kaydeden (comit) Michael Meeks

Remove internal gethostbyname_r implementation.

üst 161ff9a4
...@@ -32,100 +32,6 @@ ...@@ -32,100 +32,6 @@
static pthread_mutex_t getrtl_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t getrtl_mutex = PTHREAD_MUTEX_INITIALIZER;
/* struct passwd differs on some platforms */
#if !defined(FREEBSD) || (__FreeBSD_version < 601103)
extern int h_errno;
struct hostent *gethostbyname_r(const char *name, struct hostent *result,
char *buffer, int buflen, int *h_errnop)
{
/* buffer layout: name\0
* array_of_pointer_to_aliases
* NULL
* alias1\0...aliasn\0
* array_of_pointer_to_addresses
* NULL
* addr1addr2addr3...addrn
*/
struct hostent* res;
pthread_mutex_lock(&getrtl_mutex);
if ( (res = gethostbyname(name)) )
{
int nname, naliases, naddr_list, naliasesdata, n;
char **p, **parray, *data;
/* Check buffer size before copying, we want to leave the
* buffers unmodified in case something goes wrong.
*
* Is this required?
*/
nname= strlen(res->h_name)+1;
naliases = naddr_list = naliasesdata = 0;
for ( p = res->h_aliases; *p != NULL; p++) {
naliases++;
naliasesdata += strlen(*p)+1;
}
for ( p = res->h_addr_list; *p != NULL; p++)
naddr_list++;
if ( nname
+ (naliases+1)*sizeof(char*) + naliasesdata
+ (naddr_list+1)*sizeof(char*) + naddr_list*res->h_length
<= buflen )
{
memcpy(result, res, sizeof(struct hostent));
strcpy(buffer, res->h_name);
result->h_name = buffer;
buffer += nname;
parray = (char**)buffer;
result->h_aliases = parray;
data = buffer + (naliases+1)*sizeof(char*);
for ( p = res->h_aliases; *p != NULL; p++) {
n = strlen(*p)+1;
*parray++ = data;
memcpy(data, *p, n);
data += n;
}
*parray = NULL;
buffer = data;
parray = (char**)buffer;
result->h_addr_list = parray;
data = buffer + (naddr_list+1)*sizeof(char*);
for ( p = res->h_addr_list; *p != NULL; p++) {
*parray++ = data;
memcpy(data, *p, res->h_length);
data += res->h_length;
}
*parray = NULL;
res = result;
}
else
{
errno = ERANGE;
res = NULL;
}
}
else
{
*h_errnop = h_errno;
}
pthread_mutex_unlock(&getrtl_mutex);
return res;
}
#endif /* !defined(FREEBSD) || (__FreeBSD_version < 601103) */
#if defined(MACOSX) #if defined(MACOSX)
/* /*
* Add support for resolving Mac native alias files (not the same as unix alias files) * Add support for resolving Mac native alias files (not the same as unix alias files)
......
...@@ -504,10 +504,6 @@ extern struct spwd *getspnam_r(const char *name, struct spwd *result, ...@@ -504,10 +504,6 @@ extern struct spwd *getspnam_r(const char *name, struct spwd *result,
struct tm *localtime_r(const time_t *timep, struct tm *buffer); struct tm *localtime_r(const time_t *timep, struct tm *buffer);
struct tm *gmtime_r(const time_t *timep, struct tm *buffer); struct tm *gmtime_r(const time_t *timep, struct tm *buffer);
#endif /* !defined FREEBSD || (__FreeBSD_version < 500112) */ #endif /* !defined FREEBSD || (__FreeBSD_version < 500112) */
#if !defined(FREEBSD) || (__FreeBSD_version < 601103)
struct hostent *gethostbyname_r(const char *name, struct hostent *result,
char *buffer, int buflen, int *h_errnop);
#endif /* !defined(FREEBSD) || (__FreeBSD_version < 601103) */
#endif #endif
#endif /* __OSL_SYSTEM_H__ */ #endif /* __OSL_SYSTEM_H__ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment