source: bootcd/isolinux/syslinux-6.03/com32/modules/host.c

Last change on this file was e16e8f2, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

bootstuff

  • Property mode set to 100644
File size: 885 bytes
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <console.h>
5#include <netinet/in.h>
6#include <com32.h>
7#include <syslinux/pxe.h>
8
9static inline uint32_t dns_resolve(const char *hostname)
10{
11    return pxe_dns(hostname);
12}
13
14static inline void usage(const char *s)
15{
16    fprintf(stderr, "Usage: %s hostname [, hostname_1, hostname_2, ...]\n", s);
17}
18
19int main(int argc, char *argv[])
20{
21    int i;
22    uint32_t ip;
23
24    openconsole(&dev_null_r, &dev_stdcon_w);
25
26    if (argc < 2) {
27        usage(argv[0]);
28        return 1;
29    }
30
31    for (i = 1; i < argc; i++) {
32        ip = dns_resolve(argv[i]);
33        if (!ip) {
34            printf("%s not found.\n", argv[i]);
35        } else {
36            printf("%-39s %08X %u.%u.%u.%u\n", argv[i], ntohl(ip), ip & 0xFF,
37                   (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, (ip >> 24) & 0xFF);
38        }
39    }
40
41    return 0;
42}
Note: See TracBrowser for help on using the repository browser.