numtohost.c
来自「网络时间协议NTP 源码 版本v4.2.0b 该源码用于linux平台下」· C语言 代码 · 共 39 行
C
39 行
/* * numtohost - convert network number to host name. */#include "ntp_fp.h"#include "ntp_stdlib.h"#include "lib_strbuf.h"#define LOOPBACKNET 0x7f000000#define LOOPBACKHOST 0x7f000001#define LOOPBACKNETMASK 0xff000000char *numtohost( u_int32 netnum ){ char *bp; struct hostent *hp; /* * This is really gross, but saves lots of hanging looking for * hostnames for the radio clocks. Don't bother looking up * addresses on the loopback network except for the loopback * host itself. */ if ((((ntohl(netnum) & LOOPBACKNETMASK) == LOOPBACKNET) && (ntohl(netnum) != LOOPBACKHOST)) || ((hp = gethostbyaddr((char *)&netnum, sizeof netnum, AF_INET)) == 0)) return numtoa(netnum); LIB_GETBUF(bp); bp[LIB_BUFLENGTH-1] = '\0'; (void) strncpy(bp, hp->h_name, LIB_BUFLENGTH-1); return bp;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?