【发布时间】:2021-04-29 19:19:26
【问题描述】:
从 glibc 树中,我只能看到文件 gethstbynm.c (glibc-2.32/inet/gethstbynm.c),但没有实现代码:
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
#include <string.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#define LOOKUP_TYPE struct hostent
#define FUNCTION_NAME gethostbyname
#define DATABASE_NAME hosts
#define ADD_PARAMS const char *name
#define ADD_VARIABLES name
#define BUFLEN 1024
#define NEED_H_ERRNO 1
#define HANDLE_DIGITS_DOTS 1
#include <nss/getXXbyYY.c>
我想找到https://www.amazon.com/Unix-Network-Programming-Sockets-Networking/dp/0131411551建议的实现:
static struct hostent host ;
/* result stored here */
struct hostent *
gethostbyname (const char *hostname)
{
return (gethostbyname2 (hostname, family));
}
什么文件存储了实现?
编辑: unname -a:
Linux 5.8.0-40-generic #45-Ubuntu SMP Fri Jan 15 11:05:36 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
【问题讨论】:
-
查看编辑......
标签: c implementation glibc gethostbyname