Mirror of git://git.busybox.net/busybox with our patches on top
Source
static struct hostent *hostent_fprint(struct hostent *host, const char *server_host)
/* vi: set sw=4 ts=4: */
/*
* Mini nslookup implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc. and John Beppu
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org>
*
* Correct default name server display and explicit name server option
* added by Ben Zeckel <bzeckel@hmc.edu> June 2001
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
| I'm only implementing non-interactive mode;
| I totally forgot nslookup even had an interactive mode.
*/
/* only works for IPv4 */
static int addr_fprint(char *addr)
{
uint8_t split[4];
uint32_t ip;
uint32_t *x = (uint32_t *) addr;
ip = ntohl(*x);
split[0] = (ip & 0xff000000) >> 24;
split[1] = (ip & 0x00ff0000) >> 16;
split[2] = (ip & 0x0000ff00) >> 8;
split[3] = (ip & 0x000000ff);
printf("%d.%d.%d.%d", split[0], split[1], split[2], split[3]);
return 0;
}
/* takes the NULL-terminated array h_addr_list, and