-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommon.c
More file actions
33 lines (22 loc) · 695 Bytes
/
Copy pathcommon.c
File metadata and controls
33 lines (22 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "common.h"
char *ptime(void) // ÷ÏÚ×ÒÁÝÁÅÍÏÅ ÚÎÁÞÅÎÉÅ: ÓÓÙÌËÁ ÎÁ ÔÅËÓÔÏ×ÕÀ ÓÔÒÏËÕ Ó ÔÅËÕÝÉÍ ×ÒÅÍÅÎÅÍ
{
char *tmstr;
time_t mytime;
mytime = time(0);
tmstr = (char *) asctime(localtime(&mytime));
*(tmstr + strlen(tmstr) - 1) = '\0';
return tmstr;
}
char *nslookup(const char *ip)
// example: input "217.12.192.65", returned output "www.itl.ua"
{
struct in_addr ip0;
struct hostent *hp;
if (!inet_aton(ip, &ip0))
/* printf("can't parse IP address %s", ip) */;
if ((hp = gethostbyaddr(&ip0, sizeof ip0, AF_INET)) == NULL)
/* printf("no name associated with %s", ip) */;
// printf("name associated with %s is %s\n", ip, hp->h_name);
return (hp!=NULL)?hp->h_name:"*";
}