Changeset 7262f89 in mainline for uspace/srv/net/dnsres/dnsres.c
- Timestamp:
- 2013-04-20T10:42:13Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dc95342
- Parents:
- f1dcf6d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/dnsres/dnsres.c
rf1dcf6d r7262f89 35 35 36 36 #include <stdio.h> 37 #include <stdlib.h> 37 38 #include <errno.h> 38 39 … … 43 44 #define NAME "dnsres" 44 45 46 static int addr_format(inet_addr_t *addr, char **bufp) 47 { 48 int rc; 49 50 rc = asprintf(bufp, "%d.%d.%d.%d", addr->ipv4 >> 24, 51 (addr->ipv4 >> 16) & 0xff, (addr->ipv4 >> 8) & 0xff, 52 addr->ipv4 & 0xff); 53 54 if (rc < 0) 55 return ENOMEM; 56 57 return EOK; 58 } 59 45 60 int main(int argc, char *argv[]) 46 61 { 47 62 dns_host_info_t hinfo; 63 char *astr; 48 64 int rc; 49 65 50 66 printf("%s: DNS Resolution Service\n", NAME); 51 rc = dns_name2host( "helenos.org", &hinfo);67 rc = dns_name2host(argc < 2 ? "helenos.org" : argv[1], &hinfo); 52 68 printf("dns_name2host() -> rc = %d\n", rc); 69 70 if (rc == EOK) { 71 rc = addr_format(&hinfo.addr, &astr); 72 if (rc != EOK) { 73 printf("Out of memory\n"); 74 return ENOMEM; 75 } 76 77 printf("hostname: %s\n", hinfo.name); 78 printf("IPv4 address: %s\n", astr); 79 free(astr); 80 } 53 81 54 82 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.