Rev 9620 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9620 | Rev 9766 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | WHOIS port for KolibriOS (Adapted by turbocat2001). |
2 | WHOIS port for KolibriOS (Adapted by turbocat2001). |
3 | The main code is taken from the site: |
3 | The main code is taken from the site: |
4 | https://www.binarytides.com/whois-client-code-in-c-with-linux-sockets/ |
4 | https://www.binarytides.com/whois-client-code-in-c-with-linux-sockets/ |
5 | */ |
5 | */ |
Line 6... | Line -... | ||
6 | - | ||
7 | #include |
6 | |
- | 7 | #include "sys/ksys.h" |
|
- | 8 | #include |
|
- | 9 | #include |
|
8 | #include "sys/ksys.h" |
10 | #include |
9 | #include |
- | |
10 | #include |
11 | #include |
- | 12 | #include |
|
11 | #include |
13 | #include |
12 | #include |
- | |
13 | #include |
- | |
Line 14... | Line 14... | ||
14 | #include |
14 | #include |
Line 15... | Line 15... | ||
15 | 15 | ||
16 | FILE *out=stdout; |
16 | FILE* out = stdout; |
Line 36... | Line 36... | ||
36 | int hostname_to_ip(char * , char *); |
36 | int hostname_to_ip(char*, char*); |
37 | int whois_query(char * , char * , char **); |
37 | int whois_query(char*, char*, char**); |
38 | char *str_replace(char *search , char *replace , char *subject ); |
38 | char* str_replace(char* search, char* replace, char* subject); |
39 | char* str_copy(char*); |
39 | char* str_copy(char*); |
Line 40... | Line -... | ||
40 | - | ||
41 | 40 | ||
42 | int main(int argc , char *argv[]) |
41 | int main(int argc, char* argv[]) |
43 | { |
42 | { |
44 | char *domain , *data = NULL; |
43 | char *domain, *data = NULL; |
Line 229... | Line 228... | ||
229 | Get the ip address of a given hostname |
228 | Get the ip address of a given hostname |
230 | */ |
229 | */ |
231 | int hostname_to_ip(char *hostname , char *ip) |
230 | int hostname_to_ip(char* hostname, char* ip) |
232 | { |
231 | { |
233 | struct addrinfo *addr_info; |
232 | struct addrinfo* addr_info; |
- | 233 | char port_str[16]; |
|
234 | char port_str[16]; sprintf(port_str, "%d", 80); |
234 | sprintf(port_str, "%d", 80); |
235 | struct addrinfo hints; |
235 | struct addrinfo hints; |
236 | memset(&hints, 0, sizeof(hints)); |
236 | memset(&hints, 0, sizeof(hints)); |
237 | hints.ai_family = AF_UNSPEC; // IPv4 or IPv6 doesnt matter |
237 | hints.ai_family = AF_UNSPEC; // IPv4 or IPv6 doesnt matter |
238 | hints.ai_socktype = SOCK_STREAM; // TCP stream sockets |
238 | hints.ai_socktype = SOCK_STREAM; // TCP stream sockets |
239 | if (getaddrinfo(hostname, port_str, 0, &addr_info) != 0) { |
239 | if (getaddrinfo(hostname, port_str, 0, &addr_info) != 0) { |