c - gethostbyname() 函数的源码实现在哪里?
问题描述
从 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));
}
什么文件存储实现?
编辑: uname -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
解决方案
推荐阅读
- sql - 在带有 presto 驱动程序的 sql workbench/j 上使用 wbimport
- firefox - gcc:错误:无法识别的命令行选项“-fsanitize-coverage=trace-pc-guard”
- amazon-web-services - AWS 上用于 Docker 应用程序的持久 UGC 文件存储
- node.js - 将应用程序连接到 mongodb
- c++ - VSCode 说如果 operator<< 重载,std::chrono 是不明确的
- sas - 在 SAS 9.4 中计算多行和多列的中位数
- java - 在 sqlite 中移动一行(位置列)
- json - 如何使用 jq 对输出进行排序/唯一化
- c - 将 Linux grep 命令捕获到 C 中的变量
- html - 具有响应式 iframe 的 Bootstrap 4 模态