aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/Config.in4
-rw-r--r--libbb/Kbuild61
-rw-r--r--libbb/Makefile29
-rw-r--r--libbb/Makefile.in155
-rw-r--r--libbb/bb_pwd.c46
-rw-r--r--libbb/llist.c8
-rw-r--r--libbb/messages.c107
-rw-r--r--libbb/printf.c8
-rw-r--r--libbb/safe_strtol.c13
-rw-r--r--libbb/xfuncs.c67
-rw-r--r--libbb/xgetularg.c12
11 files changed, 87 insertions, 423 deletions
diff --git a/libbb/Config.in b/libbb/Config.in
index c5406cbb9..92ee55cbc 100644
--- a/libbb/Config.in
+++ b/libbb/Config.in
@@ -5,14 +5,14 @@
5 5
6menu "Busybox Library Tuning" 6menu "Busybox Library Tuning"
7 7
8config CONFIG_PASSWORD_MINLEN 8config PASSWORD_MINLEN
9 int "Minimum password length" 9 int "Minimum password length"
10 default 6 10 default 6
11 range 5 32 11 range 5 32
12 help 12 help
13 Minimum allowable password length. 13 Minimum allowable password length.
14 14
15config CONFIG_MD5_SIZE_VS_SPEED 15config MD5_SIZE_VS_SPEED
16 int " MD5: Trade Bytes for Speed" 16 int " MD5: Trade Bytes for Speed"
17 default 2 17 default 2
18 range 0 3 18 range 0 3
diff --git a/libbb/Kbuild b/libbb/Kbuild
new file mode 100644
index 000000000..909f527ba
--- /dev/null
+++ b/libbb/Kbuild
@@ -0,0 +1,61 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7lib-y:= \
8 ask_confirmation.o change_identity.o chomp.o \
9 compare_string_array.o concat_path_file.o copy_file.o copyfd.o \
10 crc32.o create_icmp_socket.o create_icmp6_socket.o \
11 device_open.o dump.o error_msg.o error_msg_and_die.o \
12 find_pid_by_name.o find_root_device.o fgets_str.o full_read.o \
13 full_write.o get_last_path_component.o get_line_from_file.o \
14 herror_msg.o herror_msg_and_die.o \
15 human_readable.o inet_common.o inode_hash.o isdirectory.o \
16 kernel_version.o last_char_is.o login.o \
17 make_directory.o md5.o mode_string.o mtab_file.o \
18 obscure.o parse_mode.o parse_number.o perror_msg.o \
19 perror_msg_and_die.o get_console.o \
20 process_escape_sequence.o procps.o \
21 recursive_action.o remove_file.o \
22 restricted_shell.o run_parts.o run_shell.o safe_read.o safe_write.o \
23 safe_strncpy.o setup_environment.o sha1.o simplify_path.o \
24 trim.o u_signal_names.o vdprintf.o verror_msg.o \
25 vherror_msg.o vperror_msg.o wfopen.o xconnect.o xgetcwd.o \
26 xgethostbyname.o xgethostbyname2.o xreadlink.o xgetlarg.o \
27 fclose_nonstdin.o fflush_stdout_and_exit.o \
28 getopt32.o default_error_retval.o wfopen_input.o speed_table.o \
29 perror_nomsg_and_die.o perror_nomsg.o skip_whitespace.o bb_askpass.o \
30 warn_ignoring_args.o concat_subpath_file.o vfork_daemon_rexec.o \
31 bb_do_delay.o uuencode.o info_msg.o vinfo_msg.o
32
33# conditionally compiled objects:
34lib-$(CONFIG_FEATURE_MOUNT_LOOP) += loop.o
35lib-$(CONFIG_LOSETUP) += loop.o
36lib-$(CONFIG_FEATURE_MTAB_SUPPORT) += mtab.o
37lib-$(CONFIG_PASSWD) += pw_encrypt.o
38lib-$(CONFIG_SULOGIN) += pw_encrypt.o
39lib-$(CONFIG_FEATURE_HTTPD_AUTH_MD5) += pw_encrypt.o
40lib-$(CONFIG_VLOCK) += correct_password.o
41lib-$(CONFIG_SU) += correct_password.o
42lib-$(CONFIG_LOGIN) += correct_password.o
43lib-$(CONFIG_DF) += find_mount_point.o
44lib-$(CONFIG_EJECT) += find_mount_point.o
45
46# We shouldn't build xregcomp.c if we don't need it - this ensures we don't
47# require regex.h to be in the include dir even if we don't need it thereby
48# allowing us to build busybox even if uclibc regex support is disabled.
49
50lib-$(CONFIG_AWK) += xregcomp.o
51lib-$(CONFIG_SED) += xregcomp.o
52lib-$(CONFIG_LESS) += xregcomp.o
53lib-$(CONFIG_DEVFSD) += xregcomp.o
54
55lib-y += messages.o
56lib-y += xfuncs.o
57lib-y += printf.o
58lib-y += xgetularg.o
59lib-y += safe_strtol.o
60lib-y += bb_pwd.o
61lib-y += llist.o
diff --git a/libbb/Makefile b/libbb/Makefile
deleted file mode 100644
index 336398641..000000000
--- a/libbb/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef top_srcdir
8top_srcdir=..
9endif
10ifndef top_builddir
11top_builddir=..
12endif
13srcdir=$(top_srcdir)/libbb
14LIBBB_DIR:=./
15
16# Ensure "all" is still the default target when make is run by itself in
17# libbb, even if the files we include define rules for targets.
18
19all:
20
21include $(top_srcdir)/Rules.mak
22include $(top_builddir)/.config
23include Makefile.in
24all: $(libraries-y)
25-include $(top_builddir)/.depend
26
27clean:
28 rm -f *.o *.a $(AR_TARGET)
29
diff --git a/libbb/Makefile.in b/libbb/Makefile.in
deleted file mode 100644
index ef5c6b97a..000000000
--- a/libbb/Makefile.in
+++ /dev/null
@@ -1,155 +0,0 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7ifndef $(LIBBB_DIR)
8LIBBB_DIR:=$(top_builddir)/libbb
9endif
10srcdir=$(top_srcdir)/libbb
11
12LIBBB-n:=
13LIBBB-y:= \
14 ask_confirmation.c change_identity.c chomp.c \
15 compare_string_array.c concat_path_file.c copy_file.c copyfd.c \
16 crc32.c create_icmp_socket.c create_icmp6_socket.c \
17 device_open.c dump.c error_msg.c error_msg_and_die.c \
18 find_pid_by_name.c find_root_device.c fgets_str.c full_read.c \
19 full_write.c get_last_path_component.c get_line_from_file.c \
20 herror_msg.c herror_msg_and_die.c \
21 human_readable.c inet_common.c inode_hash.c isdirectory.c \
22 kernel_version.c last_char_is.c login.c \
23 make_directory.c md5.c mode_string.c mtab_file.c \
24 obscure.c parse_mode.c parse_number.c perror_msg.c \
25 perror_msg_and_die.c get_console.c process_escape_sequence.c procps.c \
26 recursive_action.c remove_file.c info_msg.c vinfo_msg.c \
27 restricted_shell.c run_parts.c run_shell.c safe_read.c safe_write.c \
28 safe_strncpy.c setup_environment.c sha1.c simplify_path.c \
29 trim.c u_signal_names.c vdprintf.c verror_msg.c \
30 vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \
31 xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \
32 fclose_nonstdin.c fflush_stdout_and_exit.c \
33 getopt32.c default_error_retval.c wfopen_input.c speed_table.c \
34 perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \
35 warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \
36 bb_do_delay.c
37
38# conditionally compiled objects:
39LIBBB-$(CONFIG_FEATURE_MOUNT_LOOP)+= loop.c
40LIBBB-$(CONFIG_LOSETUP)+= loop.c
41LIBBB-$(CONFIG_FEATURE_MTAB_SUPPORT)+= mtab.c
42LIBBB-$(CONFIG_PASSWD)+= pw_encrypt.c
43LIBBB-$(CONFIG_SULOGIN)+= pw_encrypt.c
44LIBBB-$(CONFIG_FEATURE_HTTPD_AUTH_MD5)+= pw_encrypt.c
45LIBBB-$(CONFIG_VLOCK)+= correct_password.c
46LIBBB-$(CONFIG_SU)+= correct_password.c
47LIBBB-$(CONFIG_LOGIN)+= correct_password.c
48LIBBB-$(CONFIG_DF)+= find_mount_point.c
49LIBBB-$(CONFIG_EJECT)+= find_mount_point.c
50LIBBB-$(CONFIG_UUENCODE)+= uuencode.c
51LIBBB-$(CONFIG_WGET)+= uuencode.c
52
53# We shouldn't build xregcomp.c if we don't need it - this ensures we don't
54# require regex.h to be in the include dir even if we don't need it thereby
55# allowing us to build busybox even if uclibc regex support is disabled.
56
57regex-y:=
58regex-$(CONFIG_AWK) += xregcomp.c
59regex-$(CONFIG_SED) += xregcomp.c
60regex-$(CONFIG_LESS) += xregcomp.c
61regex-$(CONFIG_DEVFSD) += xregcomp.c
62regex-$(CONFIG_MDEV) += xregcomp.c
63regex-$(CONFIG_GREP) += xregcomp.c
64
65# Sort has the happy side efect of returning a unique list
66LIBBB-y += $(sort $(regex-y))
67
68LIBBB-y:=$(patsubst %,$(srcdir)/%,$(LIBBB-y))
69
70get-file-subparts = $(addsuffix .o,$(shell sed -n -e "s/^\#ifdef L_//p" ${1}))
71
72# 1:N objects
73LIBBB_MSRC0:=$(srcdir)/messages.c
74LIBBB_MOBJ0:=$(call get-file-subparts, ${LIBBB_MSRC0})
75LIBBB_MOBJ0:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ0))
76$(LIBBB_MOBJ0):$(LIBBB_MSRC0)
77 $(compile.c) -DL_$(notdir $*)
78
79LIBBB_MSRC1:=$(srcdir)/xfuncs.c
80LIBBB_MOBJ1:=$(call get-file-subparts, ${LIBBB_MSRC1})
81LIBBB_MOBJ1:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ1))
82$(LIBBB_MOBJ1):$(LIBBB_MSRC1)
83 $(compile.c) -DL_$(notdir $*)
84
85LIBBB_MSRC2:=$(srcdir)/printf.c
86LIBBB_MOBJ2:=$(call get-file-subparts, ${LIBBB_MSRC2})
87LIBBB_MOBJ2:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ2))
88$(LIBBB_MOBJ2):$(LIBBB_MSRC2)
89 $(compile.c) -DL_$(notdir $*)
90
91LIBBB_MSRC3:=$(srcdir)/xgetularg.c
92LIBBB_MOBJ3:=$(call get-file-subparts, ${LIBBB_MSRC3})
93LIBBB_MOBJ3:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ3))
94$(LIBBB_MOBJ3):$(LIBBB_MSRC3)
95 $(compile.c) -DL_$(notdir $*)
96
97LIBBB_MSRC4:=$(srcdir)/safe_strtol.c
98LIBBB_MOBJ4:=$(call get-file-subparts, ${LIBBB_MSRC4})
99LIBBB_MOBJ4:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ4))
100$(LIBBB_MOBJ4):$(LIBBB_MSRC4)
101 $(compile.c) -DL_$(notdir $*)
102
103LIBBB_MSRC5:=$(srcdir)/bb_pwd.c
104LIBBB_MOBJ5:=$(call get-file-subparts, ${LIBBB_MSRC5})
105LIBBB_MOBJ5:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ5))
106$(LIBBB_MOBJ5):$(LIBBB_MSRC5)
107 $(compile.c) -DL_$(notdir $*)
108
109LIBBB_MSRC6:=$(srcdir)/llist.c
110LIBBB_MOBJ6:=$(call get-file-subparts, ${LIBBB_MSRC6})
111LIBBB_MOBJ6:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ6))
112$(LIBBB_MOBJ6):$(LIBBB_MSRC6)
113 $(compile.c) -DL_$(notdir $*)
114
115# We need the names of the object files built from MSRC for the L_ defines
116LIBBB_ALL_MOBJ:=$(LIBBB_MOBJ0) $(LIBBB_MOBJ1) $(LIBBB_MOBJ2) $(LIBBB_MOBJ3) \
117 $(LIBBB_MOBJ4) $(LIBBB_MOBJ5) $(LIBBB_MOBJ6)
118
119LIBBB_ALL_MSRC:=$(LIBBB_MSRC0) $(LIBBB_MSRC1) $(LIBBB_MSRC2) $(LIBBB_MSRC3) \
120 $(LIBBB_MSRC4) $(LIBBB_MSRC5) $(LIBBB_MSRC6)
121
122LIBBB-y:=$(sort $(LIBBB-y) $(LIBBB_ALL_MSRC))
123
124LIBBB_AR:=$(LIBBB_DIR)/libbb.a
125libraries-y+=$(LIBBB_AR)
126
127needcrypt-y:=
128ifneq ($(filter $(srcdir)/pw_encrypt.c,$(LIBBB-y)),)
129needcrypt-y:=y
130else
131ifneq ($(filter $(srcdir)/correct_password.c,$(LIBBB-y)),)
132needcrypt-y:=y
133endif
134endif
135
136ifeq ($(needcrypt-y),y)
137 LIBRARIES := -lcrypt $(filter-out -lcrypt,$(LIBRARIES))
138endif
139
140# all 1:1 objects
141LIBBB_OBJS:=$(patsubst $(srcdir)/%.c,$(LIBBB_DIR)/%.o, $(LIBBB-y))
142$(LIBBB_DIR)/%.o: $(srcdir)/%.c
143 $(compile.c)
144
145LIBBB_SRC-a:=$(wildcard $(srcdir)/*.c)
146LIBRARY_SRC-y+=$(LIBBB-y)
147LIBRARY_SRC-a+=$(LIBBB_SRC-a)
148
149# all defines needed for 1:N objects
150LIBBB_DEFINE-y:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(LIBBB_ALL_MOBJ))))
151LIBRARY_DEFINE-y+=$(LIBBB_DEFINE-y)
152LIBRARY_DEFINE-a+=$(LIBBB_DEFINE-y)
153
154$(LIBBB_AR): $(LIBBB_OBJS) $(LIBBB_ALL_MOBJ)
155 $(do_ar)
diff --git a/libbb/bb_pwd.c b/libbb/bb_pwd.c
index e4d327340..3a214ca33 100644
--- a/libbb/bb_pwd.c
+++ b/libbb/bb_pwd.c
@@ -7,8 +7,11 @@
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
8 */ 8 */
9 9
10#include <stdio.h>
11#include <string.h>
12#include <assert.h>
13#include "libbb.h"
10 14
11#ifdef L_bb_getgrgid
12 /* Hacked by Tito Ragusa (c) 2004 <farmatito@tiscali.it> to make it more 15 /* Hacked by Tito Ragusa (c) 2004 <farmatito@tiscali.it> to make it more
13 * flexible : 16 * flexible :
14 * 17 *
@@ -26,9 +29,6 @@
26 * the program exits. 29 * the program exits.
27 */ 30 */
28 31
29#include "libbb.h"
30#include "grp_.h"
31
32/* gets a groupname given a gid */ 32/* gets a groupname given a gid */
33char * bb_getgrgid(char *group, long gid, int bufsize) 33char * bb_getgrgid(char *group, long gid, int bufsize)
34{ 34{
@@ -37,15 +37,6 @@ char * bb_getgrgid(char *group, long gid, int bufsize)
37 return bb_getug(group, (mygroup) ? 37 return bb_getug(group, (mygroup) ?
38 mygroup->gr_name : (char *)mygroup, gid, bufsize, 'g'); 38 mygroup->gr_name : (char *)mygroup, gid, bufsize, 'g');
39} 39}
40#endif /* L_bb_getgrgid */
41
42#ifdef L_bb_xgetgrnam
43#include <stdio.h>
44#include <string.h>
45#include "libbb.h"
46#include "pwd_.h"
47#include "grp_.h"
48
49 40
50/* returns a gid given a group name */ 41/* returns a gid given a group name */
51long bb_xgetgrnam(const char *name) 42long bb_xgetgrnam(const char *name)
@@ -58,15 +49,6 @@ long bb_xgetgrnam(const char *name)
58 49
59 return (mygroup->gr_gid); 50 return (mygroup->gr_gid);
60} 51}
61#endif /* L_bb_xgetgrnam */
62
63#ifdef L_bb_xgetpwnam
64#include <stdio.h>
65#include <string.h>
66#include "libbb.h"
67#include "pwd_.h"
68#include "grp_.h"
69
70 52
71/* returns a uid given a username */ 53/* returns a uid given a username */
72long bb_xgetpwnam(const char *name) 54long bb_xgetpwnam(const char *name)
@@ -79,9 +61,7 @@ long bb_xgetpwnam(const char *name)
79 61
80 return myuser->pw_uid; 62 return myuser->pw_uid;
81} 63}
82#endif /* L_bb_xgetpwnam */
83 64
84#ifdef L_bb_getpwuid
85 /* Hacked by Tito Ragusa (c) 2004 <farmatito@tiscali.it> to make it more 65 /* Hacked by Tito Ragusa (c) 2004 <farmatito@tiscali.it> to make it more
86 * flexible : 66 * flexible :
87 * 67 *
@@ -99,9 +79,6 @@ long bb_xgetpwnam(const char *name)
99 * the program exits. 79 * the program exits.
100 */ 80 */
101 81
102#include "libbb.h"
103#include "pwd_.h"
104
105/* gets a username given a uid */ 82/* gets a username given a uid */
106char * bb_getpwuid(char *name, long uid, int bufsize) 83char * bb_getpwuid(char *name, long uid, int bufsize)
107{ 84{
@@ -110,9 +87,7 @@ char * bb_getpwuid(char *name, long uid, int bufsize)
110 return bb_getug(name, (myuser) ? 87 return bb_getug(name, (myuser) ?
111 myuser->pw_name : (char *)myuser , uid, bufsize, 'u'); 88 myuser->pw_name : (char *)myuser , uid, bufsize, 'u');
112} 89}
113#endif /* L_bb_getpwuid */
114 90
115#ifdef L_bb_getug
116 /* 91 /*
117 * if bufsize is > 0 char *buffer can not be set to NULL. 92 * if bufsize is > 0 char *buffer can not be set to NULL.
118 * If idname is not NULL it is written on the static 93 * If idname is not NULL it is written on the static
@@ -127,11 +102,6 @@ char * bb_getpwuid(char *name, long uid, int bufsize)
127 * else an error message is printed and the program exits. 102 * else an error message is printed and the program exits.
128 */ 103 */
129 104
130#include <stdio.h>
131#include <assert.h>
132#include "libbb.h"
133
134
135/* internal function for bb_getpwuid and bb_getgrgid */ 105/* internal function for bb_getpwuid and bb_getgrgid */
136char * bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix) 106char * bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix)
137{ 107{
@@ -146,13 +116,6 @@ char * bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix)
146 } 116 }
147 return idname; 117 return idname;
148} 118}
149#endif /* L_bb_getug */
150
151
152#ifdef L_get_ug_id
153/* indirect dispatcher for pwd helpers. */
154#include <stdlib.h>
155#include "libbb.h"
156 119
157unsigned long get_ug_id(const char *s, 120unsigned long get_ug_id(const char *s,
158 long (*__bb_getxxnam)(const char *)) 121 long (*__bb_getxxnam)(const char *))
@@ -167,4 +130,3 @@ unsigned long get_ug_id(const char *s,
167 130
168 return r; 131 return r;
169} 132}
170#endif /* L_get_ug_id */
diff --git a/libbb/llist.c b/libbb/llist.c
index 0e727c496..8bf89a595 100644
--- a/libbb/llist.c
+++ b/libbb/llist.c
@@ -13,7 +13,6 @@
13#include <stdlib.h> 13#include <stdlib.h>
14#include "libbb.h" 14#include "libbb.h"
15 15
16#ifdef L_llist_add_to
17/* Add data to the start of the linked list. */ 16/* Add data to the start of the linked list. */
18void llist_add_to(llist_t **old_head, void *data) 17void llist_add_to(llist_t **old_head, void *data)
19{ 18{
@@ -22,9 +21,7 @@ void llist_add_to(llist_t **old_head, void *data)
22 new_head->link = *old_head; 21 new_head->link = *old_head;
23 *old_head = new_head; 22 *old_head = new_head;
24} 23}
25#endif
26 24
27#ifdef L_llist_add_to_end
28/* Add data to the end of the linked list. */ 25/* Add data to the end of the linked list. */
29void llist_add_to_end(llist_t **list_head, void *data) 26void llist_add_to_end(llist_t **list_head, void *data)
30{ 27{
@@ -39,9 +36,7 @@ void llist_add_to_end(llist_t **list_head, void *data)
39 tail->link = new_item; 36 tail->link = new_item;
40 } 37 }
41} 38}
42#endif
43 39
44#ifdef L_llist_pop
45/* Remove first element from the list and return it */ 40/* Remove first element from the list and return it */
46void *llist_pop(llist_t **head) 41void *llist_pop(llist_t **head)
47{ 42{
@@ -57,9 +52,7 @@ void *llist_pop(llist_t **head)
57 52
58 return data; 53 return data;
59} 54}
60#endif
61 55
62#ifdef L_llist_free
63/* Recursively free all elements in the linked list. If freeit != NULL 56/* Recursively free all elements in the linked list. If freeit != NULL
64 * call it on each datum in the list */ 57 * call it on each datum in the list */
65void llist_free(llist_t *elm, void (*freeit)(void *data)) 58void llist_free(llist_t *elm, void (*freeit)(void *data))
@@ -69,4 +62,3 @@ void llist_free(llist_t *elm, void (*freeit)(void *data))
69 if (freeit) freeit(data); 62 if (freeit) freeit(data);
70 } 63 }
71} 64}
72#endif
diff --git a/libbb/messages.c b/libbb/messages.c
index 5aba7e693..bd41216a5 100644
--- a/libbb/messages.c
+++ b/libbb/messages.c
@@ -7,7 +7,6 @@
7 7
8#include "libbb.h" 8#include "libbb.h"
9 9
10#ifdef L_full_version
11#ifndef BB_EXTRA_VERSION 10#ifndef BB_EXTRA_VERSION
12#define BANNER "BusyBox v" BB_VER " (" BB_BT ")" 11#define BANNER "BusyBox v" BB_VER " (" BB_BT ")"
13#else 12#else
@@ -15,92 +14,30 @@
15#endif 14#endif
16const char BB_BANNER[] = BANNER; 15const char BB_BANNER[] = BANNER;
17const char bb_msg_full_version[] = BANNER " multi-call binary"; 16const char bb_msg_full_version[] = BANNER " multi-call binary";
18#endif
19
20#ifdef L_memory_exhausted
21 const char bb_msg_memory_exhausted[] = "memory exhausted";
22#endif
23#ifdef L_invalid_date
24 const char bb_msg_invalid_date[] = "invalid date `%s'";
25#endif
26#ifdef L_io_error
27 const char bb_msg_io_error[] = "%s: input/output error -- %m";
28#endif
29#ifdef L_write_error
30 const char bb_msg_write_error[] = "write error";
31#endif
32#ifdef L_read_error
33 const char bb_msg_read_error[] = "read error";
34#endif
35#ifdef L_name_longer_than_foo
36 const char bb_msg_name_longer_than_foo[] = "names longer than %d chars not supported";
37#endif
38#ifdef L_unknown
39 const char bb_msg_unknown[] = "(unknown)";
40#endif
41#ifdef L_can_not_create_raw_socket
42 const char bb_msg_can_not_create_raw_socket[] = "can't create raw socket";
43#endif
44#ifdef L_perm_denied_are_you_root
45 const char bb_msg_perm_denied_are_you_root[] = "permission denied. (are you root?)";
46#endif
47#ifdef L_msg_requires_arg
48 const char bb_msg_requires_arg[] = "%s requires an argument";
49#endif
50#ifdef L_msg_invalid_arg
51 const char bb_msg_invalid_arg[] = "invalid argument `%s' to `%s'";
52#endif
53#ifdef L_msg_standard_input
54 const char bb_msg_standard_input[] = "standard input";
55#endif
56#ifdef L_msg_standard_output
57 const char bb_msg_standard_output[] = "standard output";
58#endif
59
60#ifdef L_passwd_file
61#define PASSWD_FILE "/etc/passwd"
62const char bb_path_passwd_file[] = PASSWD_FILE;
63#endif
64 17
65#ifdef L_shadow_file 18const char bb_msg_memory_exhausted[] = "memory exhausted";
66#define SHADOW_FILE "/etc/shadow" 19const char bb_msg_invalid_date[] = "invalid date '%s'";
67const char bb_path_shadow_file[] = SHADOW_FILE; 20const char bb_msg_write_error[] = "write error";
68#endif 21const char bb_msg_read_error[] = "read error";
69 22const char bb_msg_name_longer_than_foo[] = "names longer than %d chars not supported";
70#ifdef L_group_file 23const char bb_msg_unknown[] = "(unknown)";
71#define GROUP_FILE "/etc/group" 24const char bb_msg_can_not_create_raw_socket[] = "can't create raw socket";
72const char bb_path_group_file[] = GROUP_FILE; 25const char bb_msg_perm_denied_are_you_root[] = "permission denied. (are you root?)";
73#endif 26const char bb_msg_requires_arg[] = "%s requires an argument";
74 27const char bb_msg_invalid_arg[] = "invalid argument '%s' to '%s'";
75#ifdef L_gshadow_file 28const char bb_msg_standard_input[] = "standard input";
76#define GSHADOW_FILE "/etc/gshadow" 29const char bb_msg_standard_output[] = "standard output";
77const char bb_path_gshadow_file[] = GSHADOW_FILE; 30
78#endif 31const char bb_path_passwd_file[] = "/etc/passwd";
79 32const char bb_path_shadow_file[] = "/etc/shadow";
80#ifdef L_nologin_file 33const char bb_path_group_file[] = "/etc/group";
81#define NOLOGIN_FILE "/etc/nologin" 34const char bb_path_gshadow_file[] = "/etc/gshadow";
82const char bb_path_nologin_file[] = NOLOGIN_FILE; 35const char bb_path_nologin_file[] = "/etc/nologin";
83#endif 36const char bb_path_securetty_file[] = "/etc/securetty";
84 37const char bb_path_motd_file[] = "/etc/motd";
85#ifdef L_securetty_file
86#define SECURETTY_FILE "/etc/securetty"
87const char bb_path_securetty_file[] = SECURETTY_FILE;
88#endif
89
90#ifdef L_motd_file
91#define MOTD_FILE "/etc/motd"
92const char bb_path_motd_file[] = MOTD_FILE;
93#endif
94
95#ifdef L_shell_file
96const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL; 38const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL;
97#endif
98
99#ifdef L_bb_dev_null
100const char bb_dev_null[] = "/dev/null"; 39const char bb_dev_null[] = "/dev/null";
101#endif
102 40
103#ifdef L_bb_path_wtmp_file
104#include <utmp.h> 41#include <utmp.h>
105/* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */ 42/* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */
106const char bb_path_wtmp_file[] = 43const char bb_path_wtmp_file[] =
@@ -111,9 +48,5 @@ WTMP_FILE;
111#else 48#else
112# error unknown path to wtmp file 49# error unknown path to wtmp file
113#endif 50#endif
114#endif
115 51
116
117#ifdef L_bb_common_bufsiz1
118char bb_common_bufsiz1[BUFSIZ+1]; 52char bb_common_bufsiz1[BUFSIZ+1];
119#endif
diff --git a/libbb/printf.c b/libbb/printf.c
index 2e79555b5..f0ddb862e 100644
--- a/libbb/printf.c
+++ b/libbb/printf.c
@@ -37,7 +37,6 @@
37#include <errno.h> 37#include <errno.h>
38#include "libbb.h" 38#include "libbb.h"
39 39
40#ifdef L_bb_vfprintf
41int bb_vfprintf(FILE * __restrict stream, 40int bb_vfprintf(FILE * __restrict stream,
42 const char * __restrict format, 41 const char * __restrict format,
43 va_list arg) 42 va_list arg)
@@ -65,16 +64,12 @@ int bb_vfprintf(FILE * __restrict stream,
65 64
66 return rv; 65 return rv;
67} 66}
68#endif
69 67
70#ifdef L_bb_vprintf
71int bb_vprintf(const char * __restrict format, va_list arg) 68int bb_vprintf(const char * __restrict format, va_list arg)
72{ 69{
73 return bb_vfprintf(stdout, format, arg); 70 return bb_vfprintf(stdout, format, arg);
74} 71}
75#endif
76 72
77#ifdef L_bb_fprintf
78int bb_fprintf(FILE * __restrict stream, 73int bb_fprintf(FILE * __restrict stream,
79 const char * __restrict format, ...) 74 const char * __restrict format, ...)
80{ 75{
@@ -87,9 +82,7 @@ int bb_fprintf(FILE * __restrict stream,
87 82
88 return rv; 83 return rv;
89} 84}
90#endif
91 85
92#ifdef L_bb_printf
93int bb_printf(const char * __restrict format, ...) 86int bb_printf(const char * __restrict format, ...)
94{ 87{
95 va_list arg; 88 va_list arg;
@@ -101,4 +94,3 @@ int bb_printf(const char * __restrict format, ...)
101 94
102 return rv; 95 return rv;
103} 96}
104#endif
diff --git a/libbb/safe_strtol.c b/libbb/safe_strtol.c
index 2e8fa9558..027fc1e62 100644
--- a/libbb/safe_strtol.c
+++ b/libbb/safe_strtol.c
@@ -12,7 +12,6 @@
12#include <assert.h> 12#include <assert.h>
13#include "libbb.h" 13#include "libbb.h"
14 14
15#ifdef L_safe_strtoi
16int safe_strtoi(char *arg, int* value) 15int safe_strtoi(char *arg, int* value)
17{ 16{
18 int error; 17 int error;
@@ -21,9 +20,7 @@ int safe_strtoi(char *arg, int* value)
21 *value = (int) lvalue; 20 *value = (int) lvalue;
22 return error; 21 return error;
23} 22}
24#endif
25 23
26#ifdef L_safe_strtod
27int safe_strtod(char *arg, double* value) 24int safe_strtod(char *arg, double* value)
28{ 25{
29 char *endptr; 26 char *endptr;
@@ -38,9 +35,7 @@ int safe_strtod(char *arg, double* value)
38 errno = errno_save; 35 errno = errno_save;
39 return 0; 36 return 0;
40} 37}
41#endif
42 38
43#ifdef L_safe_strtol
44int safe_strtol(char *arg, long* value) 39int safe_strtol(char *arg, long* value)
45{ 40{
46 char *endptr; 41 char *endptr;
@@ -55,9 +50,7 @@ int safe_strtol(char *arg, long* value)
55 errno = errno_save; 50 errno = errno_save;
56 return 0; 51 return 0;
57} 52}
58#endif
59 53
60#ifdef L_safe_strtoul
61int safe_strtoul(char *arg, unsigned long* value) 54int safe_strtoul(char *arg, unsigned long* value)
62{ 55{
63 char *endptr; 56 char *endptr;
@@ -72,9 +65,7 @@ int safe_strtoul(char *arg, unsigned long* value)
72 errno = errno_save; 65 errno = errno_save;
73 return 0; 66 return 0;
74} 67}
75#endif
76 68
77#ifdef L_safe_strtoll
78int safe_strtoll(char *arg, long long* value) 69int safe_strtoll(char *arg, long long* value)
79{ 70{
80 char *endptr; 71 char *endptr;
@@ -89,9 +80,7 @@ int safe_strtoll(char *arg, long long* value)
89 errno = errno_save; 80 errno = errno_save;
90 return 0; 81 return 0;
91} 82}
92#endif
93 83
94#ifdef L_safe_strtoull
95int safe_strtoull(char *arg, unsigned long long* value) 84int safe_strtoull(char *arg, unsigned long long* value)
96{ 85{
97 char *endptr; 86 char *endptr;
@@ -106,5 +95,3 @@ int safe_strtoull(char *arg, unsigned long long* value)
106 errno = errno_save; 95 errno = errno_save;
107 return 0; 96 return 0;
108} 97}
109#endif
110
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index f1d4486c3..de765a32d 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -20,7 +20,6 @@
20 * Since dmalloc's prototypes overwrite the impls here as they are 20 * Since dmalloc's prototypes overwrite the impls here as they are
21 * included after these prototypes in libbb.h, all is well. 21 * included after these prototypes in libbb.h, all is well.
22 */ 22 */
23#ifdef L_xmalloc
24// Die if we can't allocate size bytes of memory. 23// Die if we can't allocate size bytes of memory.
25void *xmalloc(size_t size) 24void *xmalloc(size_t size)
26{ 25{
@@ -29,9 +28,7 @@ void *xmalloc(size_t size)
29 bb_error_msg_and_die(bb_msg_memory_exhausted); 28 bb_error_msg_and_die(bb_msg_memory_exhausted);
30 return ptr; 29 return ptr;
31} 30}
32#endif
33 31
34#ifdef L_xrealloc
35// Die if we can't resize previously allocated memory. (This returns a pointer 32// Die if we can't resize previously allocated memory. (This returns a pointer
36// to the new memory, which may or may not be the same as the old memory. 33// to the new memory, which may or may not be the same as the old memory.
37// It'll copy the contents to a new chunk and free the old one if necessary.) 34// It'll copy the contents to a new chunk and free the old one if necessary.)
@@ -42,11 +39,8 @@ void *xrealloc(void *ptr, size_t size)
42 bb_error_msg_and_die(bb_msg_memory_exhausted); 39 bb_error_msg_and_die(bb_msg_memory_exhausted);
43 return ptr; 40 return ptr;
44} 41}
45#endif
46#endif /* DMALLOC */ 42#endif /* DMALLOC */
47 43
48
49#ifdef L_xzalloc
50// Die if we can't allocate and zero size bytes of memory. 44// Die if we can't allocate and zero size bytes of memory.
51void *xzalloc(size_t size) 45void *xzalloc(size_t size)
52{ 46{
@@ -54,9 +48,7 @@ void *xzalloc(size_t size)
54 memset(ptr, 0, size); 48 memset(ptr, 0, size);
55 return ptr; 49 return ptr;
56} 50}
57#endif
58 51
59#ifdef L_xstrdup
60// Die if we can't copy a string to freshly allocated memory. 52// Die if we can't copy a string to freshly allocated memory.
61char * xstrdup(const char *s) 53char * xstrdup(const char *s)
62{ 54{
@@ -72,9 +64,7 @@ char * xstrdup(const char *s)
72 64
73 return t; 65 return t;
74} 66}
75#endif
76 67
77#ifdef L_xstrndup
78// Die if we can't allocate n+1 bytes (space for the null terminator) and copy 68// Die if we can't allocate n+1 bytes (space for the null terminator) and copy
79// the (possibly truncated to length n) string into it. 69// the (possibly truncated to length n) string into it.
80char * xstrndup(const char *s, int n) 70char * xstrndup(const char *s, int n)
@@ -88,9 +78,7 @@ char * xstrndup(const char *s, int n)
88 78
89 return safe_strncpy(t,s,n); 79 return safe_strncpy(t,s,n);
90} 80}
91#endif
92 81
93#ifdef L_xfopen
94// Die if we can't open a file and return a FILE * to it. 82// Die if we can't open a file and return a FILE * to it.
95// Notice we haven't got xfread(), This is for use with fscanf() and friends. 83// Notice we haven't got xfread(), This is for use with fscanf() and friends.
96FILE *xfopen(const char *path, const char *mode) 84FILE *xfopen(const char *path, const char *mode)
@@ -100,9 +88,7 @@ FILE *xfopen(const char *path, const char *mode)
100 bb_perror_msg_and_die("%s", path); 88 bb_perror_msg_and_die("%s", path);
101 return fp; 89 return fp;
102} 90}
103#endif
104 91
105#ifdef L_xopen
106// Die if we can't open an existing file and return an fd. 92// Die if we can't open an existing file and return an fd.
107int xopen(const char *pathname, int flags) 93int xopen(const char *pathname, int flags)
108{ 94{
@@ -111,9 +97,7 @@ int xopen(const char *pathname, int flags)
111 97
112 return xopen3(pathname, flags, 0777); 98 return xopen3(pathname, flags, 0777);
113} 99}
114#endif
115 100
116#ifdef L_xopen3
117// Die if we can't open a new file and return an fd. 101// Die if we can't open a new file and return an fd.
118int xopen3(const char *pathname, int flags, int mode) 102int xopen3(const char *pathname, int flags, int mode)
119{ 103{
@@ -125,9 +109,7 @@ int xopen3(const char *pathname, int flags, int mode)
125 } 109 }
126 return ret; 110 return ret;
127} 111}
128#endif
129 112
130#ifdef L_xread
131// Die with an error message if we can't read the entire buffer. 113// Die with an error message if we can't read the entire buffer.
132void xread(int fd, void *buf, size_t count) 114void xread(int fd, void *buf, size_t count)
133{ 115{
@@ -140,9 +122,7 @@ void xread(int fd, void *buf, size_t count)
140 buf = ((char *) buf) + size; 122 buf = ((char *) buf) + size;
141 } 123 }
142} 124}
143#endif
144 125
145#ifdef L_xwrite
146// Die with an error message if we can't write the entire buffer. 126// Die with an error message if we can't write the entire buffer.
147void xwrite(int fd, void *buf, size_t count) 127void xwrite(int fd, void *buf, size_t count)
148{ 128{
@@ -155,17 +135,13 @@ void xwrite(int fd, void *buf, size_t count)
155 buf = ((char *) buf) + size; 135 buf = ((char *) buf) + size;
156 } 136 }
157} 137}
158#endif
159 138
160#ifdef L_xlseek
161// Die with an error message if we can't lseek to the right spot. 139// Die with an error message if we can't lseek to the right spot.
162void xlseek(int fd, off_t offset, int whence) 140void xlseek(int fd, off_t offset, int whence)
163{ 141{
164 if (offset != lseek(fd, offset, whence)) bb_error_msg_and_die("lseek"); 142 if (offset != lseek(fd, offset, whence)) bb_error_msg_and_die("lseek");
165} 143}
166#endif
167 144
168#ifdef L_xread_char
169// Die with an error message if we can't read one character. 145// Die with an error message if we can't read one character.
170unsigned char xread_char(int fd) 146unsigned char xread_char(int fd)
171{ 147{
@@ -175,9 +151,7 @@ unsigned char xread_char(int fd)
175 151
176 return(tmp); 152 return(tmp);
177} 153}
178#endif
179 154
180#ifdef L_xferror
181// Die with supplied error message if this FILE * has ferror set. 155// Die with supplied error message if this FILE * has ferror set.
182void xferror(FILE *fp, const char *fn) 156void xferror(FILE *fp, const char *fn)
183{ 157{
@@ -185,17 +159,13 @@ void xferror(FILE *fp, const char *fn)
185 bb_error_msg_and_die("%s", fn); 159 bb_error_msg_and_die("%s", fn);
186 } 160 }
187} 161}
188#endif
189 162
190#ifdef L_xferror_stdout
191// Die with an error message if stdout has ferror set. 163// Die with an error message if stdout has ferror set.
192void xferror_stdout(void) 164void xferror_stdout(void)
193{ 165{
194 xferror(stdout, bb_msg_standard_output); 166 xferror(stdout, bb_msg_standard_output);
195} 167}
196#endif
197 168
198#ifdef L_xfflush_stdout
199// Die with an error message if we have trouble flushing stdout. 169// Die with an error message if we have trouble flushing stdout.
200void xfflush_stdout(void) 170void xfflush_stdout(void)
201{ 171{
@@ -203,9 +173,7 @@ void xfflush_stdout(void)
203 bb_perror_msg_and_die(bb_msg_standard_output); 173 bb_perror_msg_and_die(bb_msg_standard_output);
204 } 174 }
205} 175}
206#endif
207 176
208#ifdef L_spawn
209// This does a fork/exec in one call, using vfork(). Return PID of new child, 177// This does a fork/exec in one call, using vfork(). Return PID of new child,
210// -1 for failure. Runs argv[0], searching path if that has no / in it. 178// -1 for failure. Runs argv[0], searching path if that has no / in it.
211pid_t spawn(char **argv) 179pid_t spawn(char **argv)
@@ -230,9 +198,7 @@ pid_t spawn(char **argv)
230 } 198 }
231 return failed ? failed : pid; 199 return failed ? failed : pid;
232} 200}
233#endif
234 201
235#ifdef L_xspawn
236// Die with an error message if we can't spawn a child process. 202// Die with an error message if we can't spawn a child process.
237pid_t xspawn(char **argv) 203pid_t xspawn(char **argv)
238{ 204{
@@ -240,9 +206,7 @@ pid_t xspawn(char **argv)
240 if (pid < 0) bb_perror_msg_and_die("%s", *argv); 206 if (pid < 0) bb_perror_msg_and_die("%s", *argv);
241 return pid; 207 return pid;
242} 208}
243#endif
244 209
245#ifdef L_wait4
246// Wait for the specified child PID to exit, returning child's error return. 210// Wait for the specified child PID to exit, returning child's error return.
247int wait4pid(int pid) 211int wait4pid(int pid)
248{ 212{
@@ -253,17 +217,13 @@ int wait4pid(int pid)
253 if (WIFSIGNALED(status)) return WTERMSIG(status); 217 if (WIFSIGNALED(status)) return WTERMSIG(status);
254 return 0; 218 return 0;
255} 219}
256#endif
257 220
258#ifdef L_xsetenv
259void xsetenv(const char *key, const char *value) 221void xsetenv(const char *key, const char *value)
260{ 222{
261 if(setenv(key, value, 1)) 223 if(setenv(key, value, 1))
262 bb_error_msg_and_die(bb_msg_memory_exhausted); 224 bb_error_msg_and_die(bb_msg_memory_exhausted);
263} 225}
264#endif
265 226
266#ifdef L_itoa
267// Convert unsigned integer to ascii, writing into supplied buffer. A 227// Convert unsigned integer to ascii, writing into supplied buffer. A
268// truncated result is always null terminated (unless buflen is 0), and 228// truncated result is always null terminated (unless buflen is 0), and
269// contains the first few digits of the result ala strncpy. 229// contains the first few digits of the result ala strncpy.
@@ -319,9 +279,7 @@ char *itoa(int n)
319 279
320 return local_buf; 280 return local_buf;
321} 281}
322#endif
323 282
324#ifdef L_setuid
325// Die with an error message if we can't set gid. (Because resource limits may 283// Die with an error message if we can't set gid. (Because resource limits may
326// limit this user to a given number of processes, and if that fills up the 284// limit this user to a given number of processes, and if that fills up the
327// setgid() will fail and we'll _still_be_root_, which is bad.) 285// setgid() will fail and we'll _still_be_root_, which is bad.)
@@ -335,9 +293,7 @@ void xsetuid(uid_t uid)
335{ 293{
336 if (setuid(uid)) bb_error_msg_and_die("setuid"); 294 if (setuid(uid)) bb_error_msg_and_die("setuid");
337} 295}
338#endif
339 296
340#ifdef L_fdlength
341// Return how long the file at fd is, if there's any way to determine it. 297// Return how long the file at fd is, if there's any way to determine it.
342off_t fdlength(int fd) 298off_t fdlength(int fd)
343{ 299{
@@ -375,9 +331,7 @@ off_t fdlength(int fd)
375 331
376 return pos + 1; 332 return pos + 1;
377} 333}
378#endif
379 334
380#ifdef L_xasprintf
381// Die with an error message if we can't malloc() enough space and do an 335// Die with an error message if we can't malloc() enough space and do an
382// sprintf() into that space. 336// sprintf() into that space.
383char *xasprintf(const char *format, ...) 337char *xasprintf(const char *format, ...)
@@ -405,9 +359,7 @@ char *xasprintf(const char *format, ...)
405 if (r < 0) bb_error_msg_and_die(bb_msg_memory_exhausted); 359 if (r < 0) bb_error_msg_and_die(bb_msg_memory_exhausted);
406 return string_ptr; 360 return string_ptr;
407} 361}
408#endif
409 362
410#ifdef L_xprint_and_close_file
411// Die with an error message if we can't copy an entire FILE * to stdout, then 363// Die with an error message if we can't copy an entire FILE * to stdout, then
412// close that file. 364// close that file.
413void xprint_and_close_file(FILE *file) 365void xprint_and_close_file(FILE *file)
@@ -418,18 +370,14 @@ void xprint_and_close_file(FILE *file)
418 370
419 fclose(file); 371 fclose(file);
420} 372}
421#endif
422 373
423#ifdef L_xchdir
424// Die if we can't chdir to a new path. 374// Die if we can't chdir to a new path.
425void xchdir(const char *path) 375void xchdir(const char *path)
426{ 376{
427 if (chdir(path)) 377 if (chdir(path))
428 bb_perror_msg_and_die("chdir(%s)", path); 378 bb_perror_msg_and_die("chdir(%s)", path);
429} 379}
430#endif
431 380
432#ifdef L_warn_opendir
433// Print a warning message if opendir() fails, but don't die. 381// Print a warning message if opendir() fails, but don't die.
434DIR *warn_opendir(const char *path) 382DIR *warn_opendir(const char *path)
435{ 383{
@@ -441,9 +389,7 @@ DIR *warn_opendir(const char *path)
441 } 389 }
442 return dp; 390 return dp;
443} 391}
444#endif
445 392
446#ifdef L_xopendir
447// Die with an error message if opendir() fails. 393// Die with an error message if opendir() fails.
448DIR *xopendir(const char *path) 394DIR *xopendir(const char *path)
449{ 395{
@@ -453,9 +399,7 @@ DIR *xopendir(const char *path)
453 bb_perror_msg_and_die("unable to open `%s'", path); 399 bb_perror_msg_and_die("unable to open `%s'", path);
454 return dp; 400 return dp;
455} 401}
456#endif
457 402
458#ifdef L_xdaemon
459#ifndef BB_NOMMU 403#ifndef BB_NOMMU
460// Die with an error message if we can't daemonize. 404// Die with an error message if we can't daemonize.
461void xdaemon(int nochdir, int noclose) 405void xdaemon(int nochdir, int noclose)
@@ -463,9 +407,7 @@ void xdaemon(int nochdir, int noclose)
463 if (daemon(nochdir, noclose)) bb_perror_msg_and_die("daemon"); 407 if (daemon(nochdir, noclose)) bb_perror_msg_and_die("daemon");
464} 408}
465#endif 409#endif
466#endif
467 410
468#ifdef L_xsocket
469// Die with an error message if we can't open a new socket. 411// Die with an error message if we can't open a new socket.
470int xsocket(int domain, int type, int protocol) 412int xsocket(int domain, int type, int protocol)
471{ 413{
@@ -475,34 +417,26 @@ int xsocket(int domain, int type, int protocol)
475 417
476 return r; 418 return r;
477} 419}
478#endif
479 420
480#ifdef L_xbind
481// Die with an error message if we can't bind a socket to an address. 421// Die with an error message if we can't bind a socket to an address.
482void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) 422void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen)
483{ 423{
484 if (bind(sockfd, my_addr, addrlen)) bb_perror_msg_and_die("bind"); 424 if (bind(sockfd, my_addr, addrlen)) bb_perror_msg_and_die("bind");
485} 425}
486#endif
487 426
488#ifdef L_xlisten
489// Die with an error message if we can't listen for connections on a socket. 427// Die with an error message if we can't listen for connections on a socket.
490void xlisten(int s, int backlog) 428void xlisten(int s, int backlog)
491{ 429{
492 if (listen(s, backlog)) bb_perror_msg_and_die("listen"); 430 if (listen(s, backlog)) bb_perror_msg_and_die("listen");
493} 431}
494#endif
495 432
496#ifdef L_xstat
497// xstat() - a stat() which dies on failure with meaningful error message 433// xstat() - a stat() which dies on failure with meaningful error message
498void xstat(char *name, struct stat *stat_buf) 434void xstat(char *name, struct stat *stat_buf)
499{ 435{
500 if (stat(name, stat_buf)) 436 if (stat(name, stat_buf))
501 bb_perror_msg_and_die("can't stat '%s'", name); 437 bb_perror_msg_and_die("can't stat '%s'", name);
502} 438}
503#endif
504 439
505#ifdef L_get_terminal_width_height
506/* It is perfectly ok to pass in a NULL for either width or for 440/* It is perfectly ok to pass in a NULL for either width or for
507 * * height, in which case that value will not be set. */ 441 * * height, in which case that value will not be set. */
508int get_terminal_width_height(int fd, int *width, int *height) 442int get_terminal_width_height(int fd, int *width, int *height)
@@ -524,4 +458,3 @@ int get_terminal_width_height(int fd, int *width, int *height)
524 458
525 return ret; 459 return ret;
526} 460}
527#endif
diff --git a/libbb/xgetularg.c b/libbb/xgetularg.c
index 21b0d12f7..17ba581f7 100644
--- a/libbb/xgetularg.c
+++ b/libbb/xgetularg.c
@@ -15,7 +15,6 @@
15#include <assert.h> 15#include <assert.h>
16#include "libbb.h" 16#include "libbb.h"
17 17
18#ifdef L_xgetularg_bnd_sfx
19unsigned long bb_xgetularg_bnd_sfx(const char *arg, int base, 18unsigned long bb_xgetularg_bnd_sfx(const char *arg, int base,
20 unsigned long lower, 19 unsigned long lower,
21 unsigned long upper, 20 unsigned long upper,
@@ -75,9 +74,7 @@ unsigned long bb_xgetularg_bnd_sfx(const char *arg, int base,
75 74
76 return r; 75 return r;
77} 76}
78#endif
79 77
80#ifdef L_xgetlarg_bnd_sfx
81long bb_xgetlarg_bnd_sfx(const char *arg, int base, 78long bb_xgetlarg_bnd_sfx(const char *arg, int base,
82 long lower, 79 long lower,
83 long upper, 80 long upper,
@@ -104,36 +101,27 @@ long bb_xgetlarg_bnd_sfx(const char *arg, int base,
104 101
105 return r; 102 return r;
106} 103}
107#endif
108 104
109#ifdef L_getlarg10_sfx
110long bb_xgetlarg10_sfx(const char *arg, const struct suffix_mult *suffixes) 105long bb_xgetlarg10_sfx(const char *arg, const struct suffix_mult *suffixes)
111{ 106{
112 return bb_xgetlarg_bnd_sfx(arg, 10, LONG_MIN, LONG_MAX, suffixes); 107 return bb_xgetlarg_bnd_sfx(arg, 10, LONG_MIN, LONG_MAX, suffixes);
113} 108}
114#endif
115 109
116#ifdef L_xgetularg_bnd
117unsigned long bb_xgetularg_bnd(const char *arg, int base, 110unsigned long bb_xgetularg_bnd(const char *arg, int base,
118 unsigned long lower, 111 unsigned long lower,
119 unsigned long upper) 112 unsigned long upper)
120{ 113{
121 return bb_xgetularg_bnd_sfx(arg, base, lower, upper, NULL); 114 return bb_xgetularg_bnd_sfx(arg, base, lower, upper, NULL);
122} 115}
123#endif
124 116
125#ifdef L_xgetularg10_bnd
126unsigned long bb_xgetularg10_bnd(const char *arg, 117unsigned long bb_xgetularg10_bnd(const char *arg,
127 unsigned long lower, 118 unsigned long lower,
128 unsigned long upper) 119 unsigned long upper)
129{ 120{
130 return bb_xgetularg_bnd(arg, 10, lower, upper); 121 return bb_xgetularg_bnd(arg, 10, lower, upper);
131} 122}
132#endif
133 123
134#ifdef L_xgetularg10
135unsigned long bb_xgetularg10(const char *arg) 124unsigned long bb_xgetularg10(const char *arg)
136{ 125{
137 return bb_xgetularg10_bnd(arg, 0, ULONG_MAX); 126 return bb_xgetularg10_bnd(arg, 0, ULONG_MAX);
138} 127}
139#endif