Add xgethostbyname and herror_msg* functions.
This commit is contained in:
parent
59df6f7398
commit
c55b8d41c1
5
Makefile
5
Makefile
@ -248,8 +248,9 @@ parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c print_file.c \
|
||||
process_escape_sequence.c read_package_field.c read_text_file_to_buffer.c \
|
||||
recursive_action.c safe_read.c safe_strncpy.c seek_ared_file.c syscalls.c \
|
||||
syslog_msg_with_name.c time_string.c trim.c untar.c unzip.c vdprintf.c \
|
||||
verror_msg.c vperror_msg.c wfopen.c xfuncs.c xgetcwd.c xreadlink.c\
|
||||
xregcomp.c interface.c remove_file.c last_char_is.c copyfd.c
|
||||
verror_msg.c vperror_msg.c wfopen.c xfuncs.c xgetcwd.c xreadlink.c \
|
||||
xregcomp.c interface.c remove_file.c last_char_is.c copyfd.c \
|
||||
vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c
|
||||
LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC))
|
||||
LIBBB_CFLAGS = -I$(LIBBB)
|
||||
ifneq ($(strip $(BB_SRC_DIR)),)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* $Id: hostname.c,v 1.27 2001/05/16 14:21:09 kraai Exp $
|
||||
* $Id: hostname.c,v 1.28 2001/05/16 15:40:48 kraai Exp $
|
||||
* Mini hostname implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
|
||||
@ -117,11 +117,7 @@ int hostname_main(int argc, char **argv)
|
||||
s = strchr(buf, '.');
|
||||
puts(s ? s + 1 : "");
|
||||
} else if (opt_ip) {
|
||||
h = gethostbyname(buf);
|
||||
if (!h) {
|
||||
printf("Host not found\n");
|
||||
exit(1);
|
||||
}
|
||||
h = xgethostbyname(buf);
|
||||
puts(inet_ntoa(*(struct in_addr *) (h->h_addr)));
|
||||
} else {
|
||||
puts(buf);
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
#ifdef DMALLOC
|
||||
#include "dmalloc.h"
|
||||
#endif
|
||||
@ -77,6 +79,9 @@ extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
extern void perror_msg(const char *s, ...);
|
||||
extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
extern void vherror_msg(const char *s, va_list p);
|
||||
extern void herror_msg(const char *s, ...);
|
||||
extern void herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
|
||||
/* These two are used internally -- you shouldn't need to use them */
|
||||
extern void verror_msg(const char *s, va_list p);
|
||||
@ -252,6 +257,8 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file);
|
||||
extern void gz_close(int gunzip_pid);
|
||||
extern int gz_open(FILE *compressed_file, int *pid);
|
||||
|
||||
extern struct hostent *xgethostbyname(const char *name);
|
||||
|
||||
#define CT_AUTO 0
|
||||
#define CT_UNIX2DOS 1
|
||||
#define CT_DOS2UNIX 2
|
||||
|
50
libbb/herror_msg.c
Normal file
50
libbb/herror_msg.c
Normal file
@ -0,0 +1,50 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Utility routines.
|
||||
*
|
||||
* Copyright (C) tons of folks. Tracking down who wrote what
|
||||
* isn't something I'm going to worry about... If you wrote something
|
||||
* here, please feel free to acknowledge your work.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
extern void herror_msg(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
vherror_msg(s, p);
|
||||
va_end(p);
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
51
libbb/herror_msg_and_die.c
Normal file
51
libbb/herror_msg_and_die.c
Normal file
@ -0,0 +1,51 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Utility routines.
|
||||
*
|
||||
* Copyright (C) tons of folks. Tracking down who wrote what
|
||||
* isn't something I'm going to worry about... If you wrote something
|
||||
* here, please feel free to acknowledge your work.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
extern void herror_msg_and_die(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
vherror_msg(s, p);
|
||||
va_end(p);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
@ -29,6 +29,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
#ifdef DMALLOC
|
||||
#include "dmalloc.h"
|
||||
#endif
|
||||
@ -77,6 +79,9 @@ extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
extern void perror_msg(const char *s, ...);
|
||||
extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
extern void vherror_msg(const char *s, va_list p);
|
||||
extern void herror_msg(const char *s, ...);
|
||||
extern void herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
|
||||
/* These two are used internally -- you shouldn't need to use them */
|
||||
extern void verror_msg(const char *s, va_list p);
|
||||
@ -252,6 +257,8 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file);
|
||||
extern void gz_close(int gunzip_pid);
|
||||
extern int gz_open(FILE *compressed_file, int *pid);
|
||||
|
||||
extern struct hostent *xgethostbyname(const char *name);
|
||||
|
||||
#define CT_AUTO 0
|
||||
#define CT_UNIX2DOS 1
|
||||
#define CT_DOS2UNIX 2
|
||||
|
45
libbb/vherror_msg.c
Normal file
45
libbb/vherror_msg.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Utility routines.
|
||||
*
|
||||
* Copyright (C) tons of folks. Tracking down who wrote what
|
||||
* isn't something I'm going to worry about... If you wrote something
|
||||
* here, please feel free to acknowledge your work.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <netdb.h>
|
||||
extern int h_errno;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
extern void vherror_msg(const char *s, va_list p)
|
||||
{
|
||||
int err = h_errno;
|
||||
if(s == 0)
|
||||
s = "";
|
||||
verror_msg(s, p);
|
||||
if (*s)
|
||||
s = ": ";
|
||||
fprintf(stderr, "%s%s\n", s, hstrerror(err));
|
||||
}
|
35
libbb/xgethostbyname.c
Normal file
35
libbb/xgethostbyname.c
Normal file
@ -0,0 +1,35 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini xgethostbyname implementation.
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <netdb.h>
|
||||
extern int h_errno;
|
||||
|
||||
struct hostent *xgethostbyname(const char *name)
|
||||
{
|
||||
struct hostent *retval;
|
||||
|
||||
if ((retval = gethostbyname(name)) == NULL)
|
||||
herror_msg_and_die("%s", name);
|
||||
|
||||
return retval;
|
||||
}
|
3
nc.c
3
nc.c
@ -91,8 +91,7 @@ int nc_main(int argc, char **argv)
|
||||
close(sfd);
|
||||
sfd = tmpfd;
|
||||
} else {
|
||||
if ((hostinfo = gethostbyname(argv[optind])) == NULL)
|
||||
error_msg_and_die("cannot resolve %s\n", argv[optind]);
|
||||
hostinfo = xgethostbyname(argv[optind]);
|
||||
|
||||
address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
|
||||
address.sin_port = htons(atoi(argv[optind+1]));
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* $Id: hostname.c,v 1.27 2001/05/16 14:21:09 kraai Exp $
|
||||
* $Id: hostname.c,v 1.28 2001/05/16 15:40:48 kraai Exp $
|
||||
* Mini hostname implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
|
||||
@ -117,11 +117,7 @@ int hostname_main(int argc, char **argv)
|
||||
s = strchr(buf, '.');
|
||||
puts(s ? s + 1 : "");
|
||||
} else if (opt_ip) {
|
||||
h = gethostbyname(buf);
|
||||
if (!h) {
|
||||
printf("Host not found\n");
|
||||
exit(1);
|
||||
}
|
||||
h = xgethostbyname(buf);
|
||||
puts(inet_ntoa(*(struct in_addr *) (h->h_addr)));
|
||||
} else {
|
||||
puts(buf);
|
||||
|
@ -91,8 +91,7 @@ int nc_main(int argc, char **argv)
|
||||
close(sfd);
|
||||
sfd = tmpfd;
|
||||
} else {
|
||||
if ((hostinfo = gethostbyname(argv[optind])) == NULL)
|
||||
error_msg_and_die("cannot resolve %s\n", argv[optind]);
|
||||
hostinfo = xgethostbyname(argv[optind]);
|
||||
|
||||
address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
|
||||
address.sin_port = htons(atoi(argv[optind+1]));
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* $Id: ping.c,v 1.40 2001/04/09 23:52:18 andersen Exp $
|
||||
* $Id: ping.c,v 1.41 2001/05/16 15:40:48 kraai Exp $
|
||||
* Mini ping implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
|
||||
@ -200,10 +200,7 @@ static void ping(const char *host)
|
||||
memset(&pingaddr, 0, sizeof(struct sockaddr_in));
|
||||
|
||||
pingaddr.sin_family = AF_INET;
|
||||
if (!(h = gethostbyname(host))) {
|
||||
error_msg("unknown host %s", host);
|
||||
exit(1);
|
||||
}
|
||||
h = xgethostbyname(host);
|
||||
memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
|
||||
hostname = h->h_name;
|
||||
|
||||
@ -446,15 +443,9 @@ static void ping(const char *host)
|
||||
memset(&pingaddr, 0, sizeof(struct sockaddr_in));
|
||||
|
||||
pingaddr.sin_family = AF_INET;
|
||||
if (!(h = gethostbyname(host))) {
|
||||
error_msg("unknown host %s", host);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (h->h_addrtype != AF_INET) {
|
||||
error_msg("unknown address type; only AF_INET is currently supported.");
|
||||
exit(1);
|
||||
}
|
||||
h = gethostbyname(host);
|
||||
if (h->h_addrtype != AF_INET)
|
||||
error_msg_and_die("unknown address type; only AF_INET is currently supported.");
|
||||
|
||||
pingaddr.sin_family = AF_INET; /* h->h_addrtype */
|
||||
memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
|
||||
|
@ -644,18 +644,15 @@ static int getport(char * p)
|
||||
static struct in_addr getserver(char * host)
|
||||
{
|
||||
struct in_addr addr;
|
||||
|
||||
|
||||
struct hostent * he;
|
||||
if ((he = gethostbyname(host)) == NULL)
|
||||
{
|
||||
error_msg_and_die("%s: Unknown host", host);
|
||||
}
|
||||
he = xgethostbyname(host);
|
||||
memcpy(&addr, he->h_addr, sizeof addr);
|
||||
|
||||
TRACE(1, ("addr: %s\n", inet_ntoa(addr)));
|
||||
|
||||
|
||||
return addr;
|
||||
}
|
||||
}
|
||||
|
||||
static int create_socket()
|
||||
{
|
||||
|
@ -390,15 +390,10 @@ int tftp_main(int argc, char **argv)
|
||||
s = xstrdup(serverstr);
|
||||
s[cp - serverstr] = '\0';
|
||||
|
||||
if ((host = gethostbyname(s))) {
|
||||
bad = 0;
|
||||
}
|
||||
host = xgethostbyname(s);
|
||||
|
||||
free(s);
|
||||
}
|
||||
if (bad) {
|
||||
error_msg_and_die("bad \"server:file\" combination");
|
||||
}
|
||||
|
||||
if (BB_TFTP_DEBUG) {
|
||||
printf("using server \"%s\", serverfile \"%s\","
|
||||
|
@ -556,8 +556,7 @@ FILE *open_socket(char *host, int port)
|
||||
|
||||
memset(&s_in, 0, sizeof(s_in));
|
||||
s_in.sin_family = AF_INET;
|
||||
if ((hp = (struct hostent *) gethostbyname(host)) == NULL)
|
||||
error_msg_and_die("cannot resolve %s", host);
|
||||
hp = xgethostbyname(host);
|
||||
memcpy(&s_in.sin_addr, hp->h_addr_list[0], hp->h_length);
|
||||
s_in.sin_port = htons(port);
|
||||
|
||||
@ -813,7 +812,7 @@ progressmeter(int flag)
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: wget.c,v 1.40 2001/05/15 20:11:49 andersen Exp $
|
||||
* $Id: wget.c,v 1.41 2001/05/16 15:40:48 kraai Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
@ -335,7 +335,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
|
||||
#endif
|
||||
{
|
||||
if ((hp = gethostbyname(hostname)) == NULL) {
|
||||
error_msg("can't get address for %s", hostname);
|
||||
herror_msg("%s", hostname);
|
||||
goto fail;
|
||||
} else {
|
||||
if (hp->h_length > sizeof(struct in_addr)) {
|
||||
@ -580,7 +580,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
|
||||
mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
|
||||
} else {
|
||||
if ((hp = gethostbyname(mounthost)) == NULL) {
|
||||
error_msg("can't get address for %s", hostname);
|
||||
herror_msg("%s", mounthost);
|
||||
goto fail;
|
||||
} else {
|
||||
if (hp->h_length > sizeof(struct in_addr)) {
|
||||
|
19
ping.c
19
ping.c
@ -1,6 +1,6 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* $Id: ping.c,v 1.40 2001/04/09 23:52:18 andersen Exp $
|
||||
* $Id: ping.c,v 1.41 2001/05/16 15:40:48 kraai Exp $
|
||||
* Mini ping implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
|
||||
@ -200,10 +200,7 @@ static void ping(const char *host)
|
||||
memset(&pingaddr, 0, sizeof(struct sockaddr_in));
|
||||
|
||||
pingaddr.sin_family = AF_INET;
|
||||
if (!(h = gethostbyname(host))) {
|
||||
error_msg("unknown host %s", host);
|
||||
exit(1);
|
||||
}
|
||||
h = xgethostbyname(host);
|
||||
memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
|
||||
hostname = h->h_name;
|
||||
|
||||
@ -446,15 +443,9 @@ static void ping(const char *host)
|
||||
memset(&pingaddr, 0, sizeof(struct sockaddr_in));
|
||||
|
||||
pingaddr.sin_family = AF_INET;
|
||||
if (!(h = gethostbyname(host))) {
|
||||
error_msg("unknown host %s", host);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (h->h_addrtype != AF_INET) {
|
||||
error_msg("unknown address type; only AF_INET is currently supported.");
|
||||
exit(1);
|
||||
}
|
||||
h = gethostbyname(host);
|
||||
if (h->h_addrtype != AF_INET)
|
||||
error_msg_and_die("unknown address type; only AF_INET is currently supported.");
|
||||
|
||||
pingaddr.sin_family = AF_INET; /* h->h_addrtype */
|
||||
memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
|
||||
|
3
rdate.c
3
rdate.c
@ -45,8 +45,7 @@ static time_t askremotedate(const char *host)
|
||||
unsigned long int nett, localt;
|
||||
int fd;
|
||||
|
||||
if (!(h = gethostbyname(host))) /* get the IP addr */
|
||||
perror_msg_and_die("%s", host);
|
||||
h = xgethostbyname(host); /* get the IP addr */
|
||||
|
||||
if ((tserv = getservbyname("time", "tcp")) == NULL) /* find port # */
|
||||
perror_msg_and_die("%s", "time");
|
||||
|
@ -450,11 +450,7 @@ static void init_RemoteLog (void){
|
||||
error_msg_and_die("syslogd: cannot create socket");
|
||||
}
|
||||
|
||||
hostinfo = (struct hostent *) gethostbyname(RemoteHost);
|
||||
|
||||
if (!hostinfo) {
|
||||
error_msg_and_die("syslogd: cannot resolve remote host name [%s]", RemoteHost);
|
||||
}
|
||||
hostinfo = xgethostbyname(RemoteHost);
|
||||
|
||||
remoteaddr.sin_family = AF_INET;
|
||||
remoteaddr.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
|
||||
|
@ -450,11 +450,7 @@ static void init_RemoteLog (void){
|
||||
error_msg_and_die("syslogd: cannot create socket");
|
||||
}
|
||||
|
||||
hostinfo = (struct hostent *) gethostbyname(RemoteHost);
|
||||
|
||||
if (!hostinfo) {
|
||||
error_msg_and_die("syslogd: cannot resolve remote host name [%s]", RemoteHost);
|
||||
}
|
||||
hostinfo = xgethostbyname(RemoteHost);
|
||||
|
||||
remoteaddr.sin_family = AF_INET;
|
||||
remoteaddr.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
|
||||
|
11
telnet.c
11
telnet.c
@ -644,18 +644,15 @@ static int getport(char * p)
|
||||
static struct in_addr getserver(char * host)
|
||||
{
|
||||
struct in_addr addr;
|
||||
|
||||
|
||||
struct hostent * he;
|
||||
if ((he = gethostbyname(host)) == NULL)
|
||||
{
|
||||
error_msg_and_die("%s: Unknown host", host);
|
||||
}
|
||||
he = xgethostbyname(host);
|
||||
memcpy(&addr, he->h_addr, sizeof addr);
|
||||
|
||||
TRACE(1, ("addr: %s\n", inet_ntoa(addr)));
|
||||
|
||||
|
||||
return addr;
|
||||
}
|
||||
}
|
||||
|
||||
static int create_socket()
|
||||
{
|
||||
|
7
tftp.c
7
tftp.c
@ -390,15 +390,10 @@ int tftp_main(int argc, char **argv)
|
||||
s = xstrdup(serverstr);
|
||||
s[cp - serverstr] = '\0';
|
||||
|
||||
if ((host = gethostbyname(s))) {
|
||||
bad = 0;
|
||||
}
|
||||
host = xgethostbyname(s);
|
||||
|
||||
free(s);
|
||||
}
|
||||
if (bad) {
|
||||
error_msg_and_die("bad \"server:file\" combination");
|
||||
}
|
||||
|
||||
if (BB_TFTP_DEBUG) {
|
||||
printf("using server \"%s\", serverfile \"%s\","
|
||||
|
@ -335,7 +335,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
|
||||
#endif
|
||||
{
|
||||
if ((hp = gethostbyname(hostname)) == NULL) {
|
||||
error_msg("can't get address for %s", hostname);
|
||||
herror_msg("%s", hostname);
|
||||
goto fail;
|
||||
} else {
|
||||
if (hp->h_length > sizeof(struct in_addr)) {
|
||||
@ -580,7 +580,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
|
||||
mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
|
||||
} else {
|
||||
if ((hp = gethostbyname(mounthost)) == NULL) {
|
||||
error_msg("can't get address for %s", hostname);
|
||||
herror_msg("%s", mounthost);
|
||||
goto fail;
|
||||
} else {
|
||||
if (hp->h_length > sizeof(struct in_addr)) {
|
||||
|
@ -45,8 +45,7 @@ static time_t askremotedate(const char *host)
|
||||
unsigned long int nett, localt;
|
||||
int fd;
|
||||
|
||||
if (!(h = gethostbyname(host))) /* get the IP addr */
|
||||
perror_msg_and_die("%s", host);
|
||||
h = xgethostbyname(host); /* get the IP addr */
|
||||
|
||||
if ((tserv = getservbyname("time", "tcp")) == NULL) /* find port # */
|
||||
perror_msg_and_die("%s", "time");
|
||||
|
5
wget.c
5
wget.c
@ -556,8 +556,7 @@ FILE *open_socket(char *host, int port)
|
||||
|
||||
memset(&s_in, 0, sizeof(s_in));
|
||||
s_in.sin_family = AF_INET;
|
||||
if ((hp = (struct hostent *) gethostbyname(host)) == NULL)
|
||||
error_msg_and_die("cannot resolve %s", host);
|
||||
hp = xgethostbyname(host);
|
||||
memcpy(&s_in.sin_addr, hp->h_addr_list[0], hp->h_length);
|
||||
s_in.sin_port = htons(port);
|
||||
|
||||
@ -813,7 +812,7 @@ progressmeter(int flag)
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: wget.c,v 1.40 2001/05/15 20:11:49 andersen Exp $
|
||||
* $Id: wget.c,v 1.41 2001/05/16 15:40:48 kraai Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user