Changeset 8b863a62 in mainline for uspace/app/dnsres/dnsres.c
- Timestamp:
- 2014-04-16T17:14:06Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f857e8b
- Parents:
- dba3e2c (diff), 70b570c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
uspace/app/dnsres/dnsres.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/dnsres/dnsres.c
rdba3e2c r8b863a62 39 39 #include <stdlib.h> 40 40 41 #define NAME "dnsres"41 #define NAME "dnsres" 42 42 43 43 static void print_syntax(void) 44 44 { 45 printf(" syntax: " NAME " <host-name>\n");45 printf("Syntax: %s [-4|-6] <host-name>\n", NAME); 46 46 } 47 47 48 48 int main(int argc, char *argv[]) 49 49 { 50 int rc; 51 dnsr_hostinfo_t *hinfo; 52 char *hname; 53 char *saddr; 54 55 if (argc != 2) { 50 if ((argc < 2) || (argc > 3)) { 56 51 print_syntax(); 57 52 return 1; 58 53 } 59 60 hname = argv[1]; 61 62 rc = dnsr_name2host(hname, &hinfo); 54 55 uint16_t ver; 56 char *hname; 57 58 if (str_cmp(argv[1], "-4") == 0) { 59 if (argc < 3) { 60 print_syntax(); 61 return 1; 62 } 63 64 ver = ip_v4; 65 hname = argv[2]; 66 } else if (str_cmp(argv[1], "-6") == 0) { 67 if (argc < 3) { 68 print_syntax(); 69 return 1; 70 } 71 72 ver = ip_v6; 73 hname = argv[2]; 74 } else { 75 ver = ip_any; 76 hname = argv[1]; 77 } 78 79 dnsr_hostinfo_t *hinfo; 80 int rc = dnsr_name2host(hname, &hinfo, ver); 63 81 if (rc != EOK) { 64 printf( NAME ": Error resolving '%s'.\n", argv[1]);65 return 1;82 printf("%s: Error resolving '%s'.\n", NAME, hname); 83 return rc; 66 84 } 67 85 86 char *saddr; 68 87 rc = inet_addr_format(&hinfo->addr, &saddr); 69 88 if (rc != EOK) { 70 89 dnsr_hostinfo_destroy(hinfo); 71 printf( NAME ": Out of memory.\n");72 return 1;90 printf("%s: Error formatting address.\n", NAME); 91 return rc; 73 92 } 74 93 75 94 printf("Host name: %s\n", hname); 95 76 96 if (str_cmp(hname, hinfo->cname) != 0) 77 97 printf("Canonical name: %s\n", hinfo->cname); 98 78 99 printf("Address: %s\n", saddr); 79 100 80 101 dnsr_hostinfo_destroy(hinfo); 81 102 free(saddr); 82 103 83 104 return 0; 84 105 }
Note:
See TracChangeset
for help on using the changeset viewer.
