aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-16 15:40:51 +0000
committerkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-16 15:40:51 +0000
commit7ee6d7639da2e6f8ec5c282f2dab4e66fa359743 (patch)
tree03c1fca61c1b577b7c527d2b8482c5b7f6972bcd /libbb
parentbbb602f480533eb3bdc18187065b3b5616482f4a (diff)
downloadbusybox-w32-7ee6d7639da2e6f8ec5c282f2dab4e66fa359743.tar.gz
busybox-w32-7ee6d7639da2e6f8ec5c282f2dab4e66fa359743.tar.bz2
busybox-w32-7ee6d7639da2e6f8ec5c282f2dab4e66fa359743.zip
Add xgethostbyname and herror_msg* functions.
git-svn-id: svn://busybox.net/trunk/busybox@2654 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/herror_msg.c50
-rw-r--r--libbb/herror_msg_and_die.c51
-rw-r--r--libbb/libbb.h7
-rw-r--r--libbb/vherror_msg.c45
-rw-r--r--libbb/xgethostbyname.c35
5 files changed, 188 insertions, 0 deletions
diff --git a/libbb/herror_msg.c b/libbb/herror_msg.c
new file mode 100644
index 000000000..f4210edad
--- /dev/null
+++ b/libbb/herror_msg.c
@@ -0,0 +1,50 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Utility routines.
4 *
5 * Copyright (C) tons of folks. Tracking down who wrote what
6 * isn't something I'm going to worry about... If you wrote something
7 * here, please feel free to acknowledge your work.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
24 * Permission has been granted to redistribute this code under the GPL.
25 *
26 */
27
28#include <stdarg.h>
29#include <stdlib.h>
30
31#include "libbb.h"
32
33extern void herror_msg(const char *s, ...)
34{
35 va_list p;
36
37 va_start(p, s);
38 vherror_msg(s, p);
39 va_end(p);
40}
41
42
43/* END CODE */
44/*
45Local Variables:
46c-file-style: "linux"
47c-basic-offset: 4
48tab-width: 4
49End:
50*/
diff --git a/libbb/herror_msg_and_die.c b/libbb/herror_msg_and_die.c
new file mode 100644
index 000000000..0df5ed016
--- /dev/null
+++ b/libbb/herror_msg_and_die.c
@@ -0,0 +1,51 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Utility routines.
4 *
5 * Copyright (C) tons of folks. Tracking down who wrote what
6 * isn't something I'm going to worry about... If you wrote something
7 * here, please feel free to acknowledge your work.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
24 * Permission has been granted to redistribute this code under the GPL.
25 *
26 */
27
28#include <stdarg.h>
29#include <stdlib.h>
30
31#include "libbb.h"
32
33extern void herror_msg_and_die(const char *s, ...)
34{
35 va_list p;
36
37 va_start(p, s);
38 vherror_msg(s, p);
39 va_end(p);
40 exit(EXIT_FAILURE);
41}
42
43
44/* END CODE */
45/*
46Local Variables:
47c-file-style: "linux"
48c-basic-offset: 4
49tab-width: 4
50End:
51*/
diff --git a/libbb/libbb.h b/libbb/libbb.h
index 7ab06388a..29a756b7f 100644
--- a/libbb/libbb.h
+++ b/libbb/libbb.h
@@ -29,6 +29,8 @@
29#include <sys/stat.h> 29#include <sys/stat.h>
30#include <sys/types.h> 30#include <sys/types.h>
31 31
32#include <netdb.h>
33
32#ifdef DMALLOC 34#ifdef DMALLOC
33#include "dmalloc.h" 35#include "dmalloc.h"
34#endif 36#endif
@@ -77,6 +79,9 @@ extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))
77extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); 79extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
78extern void perror_msg(const char *s, ...); 80extern void perror_msg(const char *s, ...);
79extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn)); 81extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
82extern void vherror_msg(const char *s, va_list p);
83extern void herror_msg(const char *s, ...);
84extern void herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
80 85
81/* These two are used internally -- you shouldn't need to use them */ 86/* These two are used internally -- you shouldn't need to use them */
82extern void verror_msg(const char *s, va_list p); 87extern void verror_msg(const char *s, va_list p);
@@ -252,6 +257,8 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file);
252extern void gz_close(int gunzip_pid); 257extern void gz_close(int gunzip_pid);
253extern int gz_open(FILE *compressed_file, int *pid); 258extern int gz_open(FILE *compressed_file, int *pid);
254 259
260extern struct hostent *xgethostbyname(const char *name);
261
255#define CT_AUTO 0 262#define CT_AUTO 0
256#define CT_UNIX2DOS 1 263#define CT_UNIX2DOS 1
257#define CT_DOS2UNIX 2 264#define CT_DOS2UNIX 2
diff --git a/libbb/vherror_msg.c b/libbb/vherror_msg.c
new file mode 100644
index 000000000..9a06f3a38
--- /dev/null
+++ b/libbb/vherror_msg.c
@@ -0,0 +1,45 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Utility routines.
4 *
5 * Copyright (C) tons of folks. Tracking down who wrote what
6 * isn't something I'm going to worry about... If you wrote something
7 * here, please feel free to acknowledge your work.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
24 * Permission has been granted to redistribute this code under the GPL.
25 *
26 */
27
28#include <stdarg.h>
29#include <netdb.h>
30extern int h_errno;
31
32#include <stdio.h>
33
34#include "libbb.h"
35
36extern void vherror_msg(const char *s, va_list p)
37{
38 int err = h_errno;
39 if(s == 0)
40 s = "";
41 verror_msg(s, p);
42 if (*s)
43 s = ": ";
44 fprintf(stderr, "%s%s\n", s, hstrerror(err));
45}
diff --git a/libbb/xgethostbyname.c b/libbb/xgethostbyname.c
new file mode 100644
index 000000000..c722951cf
--- /dev/null
+++ b/libbb/xgethostbyname.c
@@ -0,0 +1,35 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Mini xgethostbyname implementation.
4 *
5 *
6 * Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#include <netdb.h>
25extern int h_errno;
26
27struct hostent *xgethostbyname(const char *name)
28{
29 struct hostent *retval;
30
31 if ((retval = gethostbyname(name)) == NULL)
32 herror_msg_and_die("%s", name);
33
34 return retval;
35}