source: bootcd/isolinux/syslinux-6.03/com32/samples/resolv.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: 1.3 KB
Line 
1/* ----------------------------------------------------------------------- *
2 *
3 *   Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
4 *
5 *   This program is free software; you can redistribute it and/or modify
6 *   it under the terms of the GNU General Public License as published by
7 *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 *   Boston MA 02111-1307, USA; either version 2 of the License, or
9 *   (at your option) any later version; incorporated herein by reference.
10 *
11 * ----------------------------------------------------------------------- */
12
13/*
14 * resolv.c
15 *
16 * Resolve an IP address
17 */
18
19#include <syslinux/pxe_api.h>
20#include <string.h>
21#include <stdio.h>
22#include <console.h>
23#include <stdlib.h>
24#include <com32.h>
25
26uint32_t resolv(const char *name)
27{
28    return dns_resolv(name);
29}
30
31int main(int argc, char *argv[])
32{
33    uint32_t ip;
34
35#if 0
36        /* this hangs! */
37    openconsole(&dev_null_r, &dev_stdcon_w);
38#else
39        /* this works */
40    openconsole(&dev_rawcon_r, &dev_ansiserial_w);
41#endif
42
43    if (argc < 2) {
44        fputs("Usage: resolv hostname\n", stderr);
45        exit(1);
46    }
47
48    ip = resolv(argv[1]);
49
50    if (ip) {
51        printf("%s = %u.%u.%u.%u\n", argv[1],
52               (ip & 0xff), (ip >> 8) & 0xff,
53               (ip >> 16) & 0xff, (ip >> 24) & 0xff);
54    } else {
55        printf("%s not found\n", argv[1]);
56    }
57
58    return 0;
59}
Note: See TracBrowser for help on using the repository browser.