build system overhaul
This commit is contained in:
@@ -5,14 +5,14 @@
|
||||
|
||||
menu "Busybox Library Tuning"
|
||||
|
||||
config CONFIG_PASSWORD_MINLEN
|
||||
config PASSWORD_MINLEN
|
||||
int "Minimum password length"
|
||||
default 6
|
||||
range 5 32
|
||||
help
|
||||
Minimum allowable password length.
|
||||
|
||||
config CONFIG_MD5_SIZE_VS_SPEED
|
||||
config MD5_SIZE_VS_SPEED
|
||||
int " MD5: Trade Bytes for Speed"
|
||||
default 2
|
||||
range 0 3
|
||||
|
61
libbb/Kbuild
Normal file
61
libbb/Kbuild
Normal file
@@ -0,0 +1,61 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
lib-y:= \
|
||||
ask_confirmation.o change_identity.o chomp.o \
|
||||
compare_string_array.o concat_path_file.o copy_file.o copyfd.o \
|
||||
crc32.o create_icmp_socket.o create_icmp6_socket.o \
|
||||
device_open.o dump.o error_msg.o error_msg_and_die.o \
|
||||
find_pid_by_name.o find_root_device.o fgets_str.o full_read.o \
|
||||
full_write.o get_last_path_component.o get_line_from_file.o \
|
||||
herror_msg.o herror_msg_and_die.o \
|
||||
human_readable.o inet_common.o inode_hash.o isdirectory.o \
|
||||
kernel_version.o last_char_is.o login.o \
|
||||
make_directory.o md5.o mode_string.o mtab_file.o \
|
||||
obscure.o parse_mode.o parse_number.o perror_msg.o \
|
||||
perror_msg_and_die.o get_console.o \
|
||||
process_escape_sequence.o procps.o \
|
||||
recursive_action.o remove_file.o \
|
||||
restricted_shell.o run_parts.o run_shell.o safe_read.o safe_write.o \
|
||||
safe_strncpy.o setup_environment.o sha1.o simplify_path.o \
|
||||
trim.o u_signal_names.o vdprintf.o verror_msg.o \
|
||||
vherror_msg.o vperror_msg.o wfopen.o xconnect.o xgetcwd.o \
|
||||
xgethostbyname.o xgethostbyname2.o xreadlink.o xgetlarg.o \
|
||||
fclose_nonstdin.o fflush_stdout_and_exit.o \
|
||||
getopt32.o default_error_retval.o wfopen_input.o speed_table.o \
|
||||
perror_nomsg_and_die.o perror_nomsg.o skip_whitespace.o bb_askpass.o \
|
||||
warn_ignoring_args.o concat_subpath_file.o vfork_daemon_rexec.o \
|
||||
bb_do_delay.o uuencode.o info_msg.o vinfo_msg.o
|
||||
|
||||
# conditionally compiled objects:
|
||||
lib-$(CONFIG_FEATURE_MOUNT_LOOP) += loop.o
|
||||
lib-$(CONFIG_LOSETUP) += loop.o
|
||||
lib-$(CONFIG_FEATURE_MTAB_SUPPORT) += mtab.o
|
||||
lib-$(CONFIG_PASSWD) += pw_encrypt.o
|
||||
lib-$(CONFIG_SULOGIN) += pw_encrypt.o
|
||||
lib-$(CONFIG_FEATURE_HTTPD_AUTH_MD5) += pw_encrypt.o
|
||||
lib-$(CONFIG_VLOCK) += correct_password.o
|
||||
lib-$(CONFIG_SU) += correct_password.o
|
||||
lib-$(CONFIG_LOGIN) += correct_password.o
|
||||
lib-$(CONFIG_DF) += find_mount_point.o
|
||||
lib-$(CONFIG_EJECT) += find_mount_point.o
|
||||
|
||||
# We shouldn't build xregcomp.c if we don't need it - this ensures we don't
|
||||
# require regex.h to be in the include dir even if we don't need it thereby
|
||||
# allowing us to build busybox even if uclibc regex support is disabled.
|
||||
|
||||
lib-$(CONFIG_AWK) += xregcomp.o
|
||||
lib-$(CONFIG_SED) += xregcomp.o
|
||||
lib-$(CONFIG_LESS) += xregcomp.o
|
||||
lib-$(CONFIG_DEVFSD) += xregcomp.o
|
||||
|
||||
lib-y += messages.o
|
||||
lib-y += xfuncs.o
|
||||
lib-y += printf.o
|
||||
lib-y += xgetularg.o
|
||||
lib-y += safe_strtol.o
|
||||
lib-y += bb_pwd.o
|
||||
lib-y += llist.o
|
@@ -1,29 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
ifndef top_srcdir
|
||||
top_srcdir=..
|
||||
endif
|
||||
ifndef top_builddir
|
||||
top_builddir=..
|
||||
endif
|
||||
srcdir=$(top_srcdir)/libbb
|
||||
LIBBB_DIR:=./
|
||||
|
||||
# Ensure "all" is still the default target when make is run by itself in
|
||||
# libbb, even if the files we include define rules for targets.
|
||||
|
||||
all:
|
||||
|
||||
include $(top_srcdir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
@@ -1,155 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
ifndef $(LIBBB_DIR)
|
||||
LIBBB_DIR:=$(top_builddir)/libbb
|
||||
endif
|
||||
srcdir=$(top_srcdir)/libbb
|
||||
|
||||
LIBBB-n:=
|
||||
LIBBB-y:= \
|
||||
ask_confirmation.c change_identity.c chomp.c \
|
||||
compare_string_array.c concat_path_file.c copy_file.c copyfd.c \
|
||||
crc32.c create_icmp_socket.c create_icmp6_socket.c \
|
||||
device_open.c dump.c error_msg.c error_msg_and_die.c \
|
||||
find_pid_by_name.c find_root_device.c fgets_str.c full_read.c \
|
||||
full_write.c get_last_path_component.c get_line_from_file.c \
|
||||
herror_msg.c herror_msg_and_die.c \
|
||||
human_readable.c inet_common.c inode_hash.c isdirectory.c \
|
||||
kernel_version.c last_char_is.c login.c \
|
||||
make_directory.c md5.c mode_string.c mtab_file.c \
|
||||
obscure.c parse_mode.c parse_number.c perror_msg.c \
|
||||
perror_msg_and_die.c get_console.c process_escape_sequence.c procps.c \
|
||||
recursive_action.c remove_file.c info_msg.c vinfo_msg.c \
|
||||
restricted_shell.c run_parts.c run_shell.c safe_read.c safe_write.c \
|
||||
safe_strncpy.c setup_environment.c sha1.c simplify_path.c \
|
||||
trim.c u_signal_names.c vdprintf.c verror_msg.c \
|
||||
vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \
|
||||
xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \
|
||||
fclose_nonstdin.c fflush_stdout_and_exit.c \
|
||||
getopt32.c default_error_retval.c wfopen_input.c speed_table.c \
|
||||
perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \
|
||||
warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \
|
||||
bb_do_delay.c
|
||||
|
||||
# conditionally compiled objects:
|
||||
LIBBB-$(CONFIG_FEATURE_MOUNT_LOOP)+= loop.c
|
||||
LIBBB-$(CONFIG_LOSETUP)+= loop.c
|
||||
LIBBB-$(CONFIG_FEATURE_MTAB_SUPPORT)+= mtab.c
|
||||
LIBBB-$(CONFIG_PASSWD)+= pw_encrypt.c
|
||||
LIBBB-$(CONFIG_SULOGIN)+= pw_encrypt.c
|
||||
LIBBB-$(CONFIG_FEATURE_HTTPD_AUTH_MD5)+= pw_encrypt.c
|
||||
LIBBB-$(CONFIG_VLOCK)+= correct_password.c
|
||||
LIBBB-$(CONFIG_SU)+= correct_password.c
|
||||
LIBBB-$(CONFIG_LOGIN)+= correct_password.c
|
||||
LIBBB-$(CONFIG_DF)+= find_mount_point.c
|
||||
LIBBB-$(CONFIG_EJECT)+= find_mount_point.c
|
||||
LIBBB-$(CONFIG_UUENCODE)+= uuencode.c
|
||||
LIBBB-$(CONFIG_WGET)+= uuencode.c
|
||||
|
||||
# We shouldn't build xregcomp.c if we don't need it - this ensures we don't
|
||||
# require regex.h to be in the include dir even if we don't need it thereby
|
||||
# allowing us to build busybox even if uclibc regex support is disabled.
|
||||
|
||||
regex-y:=
|
||||
regex-$(CONFIG_AWK) += xregcomp.c
|
||||
regex-$(CONFIG_SED) += xregcomp.c
|
||||
regex-$(CONFIG_LESS) += xregcomp.c
|
||||
regex-$(CONFIG_DEVFSD) += xregcomp.c
|
||||
regex-$(CONFIG_MDEV) += xregcomp.c
|
||||
regex-$(CONFIG_GREP) += xregcomp.c
|
||||
|
||||
# Sort has the happy side efect of returning a unique list
|
||||
LIBBB-y += $(sort $(regex-y))
|
||||
|
||||
LIBBB-y:=$(patsubst %,$(srcdir)/%,$(LIBBB-y))
|
||||
|
||||
get-file-subparts = $(addsuffix .o,$(shell sed -n -e "s/^\#ifdef L_//p" ${1}))
|
||||
|
||||
# 1:N objects
|
||||
LIBBB_MSRC0:=$(srcdir)/messages.c
|
||||
LIBBB_MOBJ0:=$(call get-file-subparts, ${LIBBB_MSRC0})
|
||||
LIBBB_MOBJ0:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ0))
|
||||
$(LIBBB_MOBJ0):$(LIBBB_MSRC0)
|
||||
$(compile.c) -DL_$(notdir $*)
|
||||
|
||||
LIBBB_MSRC1:=$(srcdir)/xfuncs.c
|
||||
LIBBB_MOBJ1:=$(call get-file-subparts, ${LIBBB_MSRC1})
|
||||
LIBBB_MOBJ1:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ1))
|
||||
$(LIBBB_MOBJ1):$(LIBBB_MSRC1)
|
||||
$(compile.c) -DL_$(notdir $*)
|
||||
|
||||
LIBBB_MSRC2:=$(srcdir)/printf.c
|
||||
LIBBB_MOBJ2:=$(call get-file-subparts, ${LIBBB_MSRC2})
|
||||
LIBBB_MOBJ2:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ2))
|
||||
$(LIBBB_MOBJ2):$(LIBBB_MSRC2)
|
||||
$(compile.c) -DL_$(notdir $*)
|
||||
|
||||
LIBBB_MSRC3:=$(srcdir)/xgetularg.c
|
||||
LIBBB_MOBJ3:=$(call get-file-subparts, ${LIBBB_MSRC3})
|
||||
LIBBB_MOBJ3:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ3))
|
||||
$(LIBBB_MOBJ3):$(LIBBB_MSRC3)
|
||||
$(compile.c) -DL_$(notdir $*)
|
||||
|
||||
LIBBB_MSRC4:=$(srcdir)/safe_strtol.c
|
||||
LIBBB_MOBJ4:=$(call get-file-subparts, ${LIBBB_MSRC4})
|
||||
LIBBB_MOBJ4:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ4))
|
||||
$(LIBBB_MOBJ4):$(LIBBB_MSRC4)
|
||||
$(compile.c) -DL_$(notdir $*)
|
||||
|
||||
LIBBB_MSRC5:=$(srcdir)/bb_pwd.c
|
||||
LIBBB_MOBJ5:=$(call get-file-subparts, ${LIBBB_MSRC5})
|
||||
LIBBB_MOBJ5:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ5))
|
||||
$(LIBBB_MOBJ5):$(LIBBB_MSRC5)
|
||||
$(compile.c) -DL_$(notdir $*)
|
||||
|
||||
LIBBB_MSRC6:=$(srcdir)/llist.c
|
||||
LIBBB_MOBJ6:=$(call get-file-subparts, ${LIBBB_MSRC6})
|
||||
LIBBB_MOBJ6:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ6))
|
||||
$(LIBBB_MOBJ6):$(LIBBB_MSRC6)
|
||||
$(compile.c) -DL_$(notdir $*)
|
||||
|
||||
# We need the names of the object files built from MSRC for the L_ defines
|
||||
LIBBB_ALL_MOBJ:=$(LIBBB_MOBJ0) $(LIBBB_MOBJ1) $(LIBBB_MOBJ2) $(LIBBB_MOBJ3) \
|
||||
$(LIBBB_MOBJ4) $(LIBBB_MOBJ5) $(LIBBB_MOBJ6)
|
||||
|
||||
LIBBB_ALL_MSRC:=$(LIBBB_MSRC0) $(LIBBB_MSRC1) $(LIBBB_MSRC2) $(LIBBB_MSRC3) \
|
||||
$(LIBBB_MSRC4) $(LIBBB_MSRC5) $(LIBBB_MSRC6)
|
||||
|
||||
LIBBB-y:=$(sort $(LIBBB-y) $(LIBBB_ALL_MSRC))
|
||||
|
||||
LIBBB_AR:=$(LIBBB_DIR)/libbb.a
|
||||
libraries-y+=$(LIBBB_AR)
|
||||
|
||||
needcrypt-y:=
|
||||
ifneq ($(filter $(srcdir)/pw_encrypt.c,$(LIBBB-y)),)
|
||||
needcrypt-y:=y
|
||||
else
|
||||
ifneq ($(filter $(srcdir)/correct_password.c,$(LIBBB-y)),)
|
||||
needcrypt-y:=y
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(needcrypt-y),y)
|
||||
LIBRARIES := -lcrypt $(filter-out -lcrypt,$(LIBRARIES))
|
||||
endif
|
||||
|
||||
# all 1:1 objects
|
||||
LIBBB_OBJS:=$(patsubst $(srcdir)/%.c,$(LIBBB_DIR)/%.o, $(LIBBB-y))
|
||||
$(LIBBB_DIR)/%.o: $(srcdir)/%.c
|
||||
$(compile.c)
|
||||
|
||||
LIBBB_SRC-a:=$(wildcard $(srcdir)/*.c)
|
||||
LIBRARY_SRC-y+=$(LIBBB-y)
|
||||
LIBRARY_SRC-a+=$(LIBBB_SRC-a)
|
||||
|
||||
# all defines needed for 1:N objects
|
||||
LIBBB_DEFINE-y:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(LIBBB_ALL_MOBJ))))
|
||||
LIBRARY_DEFINE-y+=$(LIBBB_DEFINE-y)
|
||||
LIBRARY_DEFINE-a+=$(LIBBB_DEFINE-y)
|
||||
|
||||
$(LIBBB_AR): $(LIBBB_OBJS) $(LIBBB_ALL_MOBJ)
|
||||
$(do_ar)
|
@@ -7,8 +7,11 @@
|
||||
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "libbb.h"
|
||||
|
||||
#ifdef L_bb_getgrgid
|
||||
/* Hacked by Tito Ragusa (c) 2004 <farmatito@tiscali.it> to make it more
|
||||
* flexible :
|
||||
*
|
||||
@@ -26,9 +29,6 @@
|
||||
* the program exits.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "grp_.h"
|
||||
|
||||
/* gets a groupname given a gid */
|
||||
char * bb_getgrgid(char *group, long gid, int bufsize)
|
||||
{
|
||||
@@ -37,15 +37,6 @@ char * bb_getgrgid(char *group, long gid, int bufsize)
|
||||
return bb_getug(group, (mygroup) ?
|
||||
mygroup->gr_name : (char *)mygroup, gid, bufsize, 'g');
|
||||
}
|
||||
#endif /* L_bb_getgrgid */
|
||||
|
||||
#ifdef L_bb_xgetgrnam
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "libbb.h"
|
||||
#include "pwd_.h"
|
||||
#include "grp_.h"
|
||||
|
||||
|
||||
/* returns a gid given a group name */
|
||||
long bb_xgetgrnam(const char *name)
|
||||
@@ -58,15 +49,6 @@ long bb_xgetgrnam(const char *name)
|
||||
|
||||
return (mygroup->gr_gid);
|
||||
}
|
||||
#endif /* L_bb_xgetgrnam */
|
||||
|
||||
#ifdef L_bb_xgetpwnam
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "libbb.h"
|
||||
#include "pwd_.h"
|
||||
#include "grp_.h"
|
||||
|
||||
|
||||
/* returns a uid given a username */
|
||||
long bb_xgetpwnam(const char *name)
|
||||
@@ -79,9 +61,7 @@ long bb_xgetpwnam(const char *name)
|
||||
|
||||
return myuser->pw_uid;
|
||||
}
|
||||
#endif /* L_bb_xgetpwnam */
|
||||
|
||||
#ifdef L_bb_getpwuid
|
||||
/* Hacked by Tito Ragusa (c) 2004 <farmatito@tiscali.it> to make it more
|
||||
* flexible :
|
||||
*
|
||||
@@ -99,9 +79,6 @@ long bb_xgetpwnam(const char *name)
|
||||
* the program exits.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "pwd_.h"
|
||||
|
||||
/* gets a username given a uid */
|
||||
char * bb_getpwuid(char *name, long uid, int bufsize)
|
||||
{
|
||||
@@ -110,9 +87,7 @@ char * bb_getpwuid(char *name, long uid, int bufsize)
|
||||
return bb_getug(name, (myuser) ?
|
||||
myuser->pw_name : (char *)myuser , uid, bufsize, 'u');
|
||||
}
|
||||
#endif /* L_bb_getpwuid */
|
||||
|
||||
#ifdef L_bb_getug
|
||||
/*
|
||||
* if bufsize is > 0 char *buffer can not be set to NULL.
|
||||
* If idname is not NULL it is written on the static
|
||||
@@ -127,11 +102,6 @@ char * bb_getpwuid(char *name, long uid, int bufsize)
|
||||
* else an error message is printed and the program exits.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "libbb.h"
|
||||
|
||||
|
||||
/* internal function for bb_getpwuid and bb_getgrgid */
|
||||
char * bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix)
|
||||
{
|
||||
@@ -146,13 +116,6 @@ char * bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix)
|
||||
}
|
||||
return idname;
|
||||
}
|
||||
#endif /* L_bb_getug */
|
||||
|
||||
|
||||
#ifdef L_get_ug_id
|
||||
/* indirect dispatcher for pwd helpers. */
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
|
||||
unsigned long get_ug_id(const char *s,
|
||||
long (*__bb_getxxnam)(const char *))
|
||||
@@ -167,4 +130,3 @@ unsigned long get_ug_id(const char *s,
|
||||
|
||||
return r;
|
||||
}
|
||||
#endif /* L_get_ug_id */
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
|
||||
#ifdef L_llist_add_to
|
||||
/* Add data to the start of the linked list. */
|
||||
void llist_add_to(llist_t **old_head, void *data)
|
||||
{
|
||||
@@ -22,9 +21,7 @@ void llist_add_to(llist_t **old_head, void *data)
|
||||
new_head->link = *old_head;
|
||||
*old_head = new_head;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_llist_add_to_end
|
||||
/* Add data to the end of the linked list. */
|
||||
void llist_add_to_end(llist_t **list_head, void *data)
|
||||
{
|
||||
@@ -39,9 +36,7 @@ void llist_add_to_end(llist_t **list_head, void *data)
|
||||
tail->link = new_item;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_llist_pop
|
||||
/* Remove first element from the list and return it */
|
||||
void *llist_pop(llist_t **head)
|
||||
{
|
||||
@@ -57,9 +52,7 @@ void *llist_pop(llist_t **head)
|
||||
|
||||
return data;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_llist_free
|
||||
/* Recursively free all elements in the linked list. If freeit != NULL
|
||||
* call it on each datum in the list */
|
||||
void llist_free(llist_t *elm, void (*freeit)(void *data))
|
||||
@@ -69,4 +62,3 @@ void llist_free(llist_t *elm, void (*freeit)(void *data))
|
||||
if (freeit) freeit(data);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
105
libbb/messages.c
105
libbb/messages.c
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
#ifdef L_full_version
|
||||
#ifndef BB_EXTRA_VERSION
|
||||
#define BANNER "BusyBox v" BB_VER " (" BB_BT ")"
|
||||
#else
|
||||
@@ -15,92 +14,30 @@
|
||||
#endif
|
||||
const char BB_BANNER[] = BANNER;
|
||||
const char bb_msg_full_version[] = BANNER " multi-call binary";
|
||||
#endif
|
||||
|
||||
#ifdef L_memory_exhausted
|
||||
const char bb_msg_memory_exhausted[] = "memory exhausted";
|
||||
#endif
|
||||
#ifdef L_invalid_date
|
||||
const char bb_msg_invalid_date[] = "invalid date `%s'";
|
||||
#endif
|
||||
#ifdef L_io_error
|
||||
const char bb_msg_io_error[] = "%s: input/output error -- %m";
|
||||
#endif
|
||||
#ifdef L_write_error
|
||||
const char bb_msg_write_error[] = "write error";
|
||||
#endif
|
||||
#ifdef L_read_error
|
||||
const char bb_msg_read_error[] = "read error";
|
||||
#endif
|
||||
#ifdef L_name_longer_than_foo
|
||||
const char bb_msg_name_longer_than_foo[] = "names longer than %d chars not supported";
|
||||
#endif
|
||||
#ifdef L_unknown
|
||||
const char bb_msg_unknown[] = "(unknown)";
|
||||
#endif
|
||||
#ifdef L_can_not_create_raw_socket
|
||||
const char bb_msg_can_not_create_raw_socket[] = "can't create raw socket";
|
||||
#endif
|
||||
#ifdef L_perm_denied_are_you_root
|
||||
const char bb_msg_perm_denied_are_you_root[] = "permission denied. (are you root?)";
|
||||
#endif
|
||||
#ifdef L_msg_requires_arg
|
||||
const char bb_msg_requires_arg[] = "%s requires an argument";
|
||||
#endif
|
||||
#ifdef L_msg_invalid_arg
|
||||
const char bb_msg_invalid_arg[] = "invalid argument `%s' to `%s'";
|
||||
#endif
|
||||
#ifdef L_msg_standard_input
|
||||
const char bb_msg_standard_input[] = "standard input";
|
||||
#endif
|
||||
#ifdef L_msg_standard_output
|
||||
const char bb_msg_standard_output[] = "standard output";
|
||||
#endif
|
||||
const char bb_msg_memory_exhausted[] = "memory exhausted";
|
||||
const char bb_msg_invalid_date[] = "invalid date '%s'";
|
||||
const char bb_msg_write_error[] = "write error";
|
||||
const char bb_msg_read_error[] = "read error";
|
||||
const char bb_msg_name_longer_than_foo[] = "names longer than %d chars not supported";
|
||||
const char bb_msg_unknown[] = "(unknown)";
|
||||
const char bb_msg_can_not_create_raw_socket[] = "can't create raw socket";
|
||||
const char bb_msg_perm_denied_are_you_root[] = "permission denied. (are you root?)";
|
||||
const char bb_msg_requires_arg[] = "%s requires an argument";
|
||||
const char bb_msg_invalid_arg[] = "invalid argument '%s' to '%s'";
|
||||
const char bb_msg_standard_input[] = "standard input";
|
||||
const char bb_msg_standard_output[] = "standard output";
|
||||
|
||||
#ifdef L_passwd_file
|
||||
#define PASSWD_FILE "/etc/passwd"
|
||||
const char bb_path_passwd_file[] = PASSWD_FILE;
|
||||
#endif
|
||||
|
||||
#ifdef L_shadow_file
|
||||
#define SHADOW_FILE "/etc/shadow"
|
||||
const char bb_path_shadow_file[] = SHADOW_FILE;
|
||||
#endif
|
||||
|
||||
#ifdef L_group_file
|
||||
#define GROUP_FILE "/etc/group"
|
||||
const char bb_path_group_file[] = GROUP_FILE;
|
||||
#endif
|
||||
|
||||
#ifdef L_gshadow_file
|
||||
#define GSHADOW_FILE "/etc/gshadow"
|
||||
const char bb_path_gshadow_file[] = GSHADOW_FILE;
|
||||
#endif
|
||||
|
||||
#ifdef L_nologin_file
|
||||
#define NOLOGIN_FILE "/etc/nologin"
|
||||
const char bb_path_nologin_file[] = NOLOGIN_FILE;
|
||||
#endif
|
||||
|
||||
#ifdef L_securetty_file
|
||||
#define SECURETTY_FILE "/etc/securetty"
|
||||
const char bb_path_securetty_file[] = SECURETTY_FILE;
|
||||
#endif
|
||||
|
||||
#ifdef L_motd_file
|
||||
#define MOTD_FILE "/etc/motd"
|
||||
const char bb_path_motd_file[] = MOTD_FILE;
|
||||
#endif
|
||||
|
||||
#ifdef L_shell_file
|
||||
const char bb_path_passwd_file[] = "/etc/passwd";
|
||||
const char bb_path_shadow_file[] = "/etc/shadow";
|
||||
const char bb_path_group_file[] = "/etc/group";
|
||||
const char bb_path_gshadow_file[] = "/etc/gshadow";
|
||||
const char bb_path_nologin_file[] = "/etc/nologin";
|
||||
const char bb_path_securetty_file[] = "/etc/securetty";
|
||||
const char bb_path_motd_file[] = "/etc/motd";
|
||||
const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL;
|
||||
#endif
|
||||
|
||||
#ifdef L_bb_dev_null
|
||||
const char bb_dev_null[] = "/dev/null";
|
||||
#endif
|
||||
|
||||
#ifdef L_bb_path_wtmp_file
|
||||
#include <utmp.h>
|
||||
/* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */
|
||||
const char bb_path_wtmp_file[] =
|
||||
@@ -111,9 +48,5 @@ WTMP_FILE;
|
||||
#else
|
||||
# error unknown path to wtmp file
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef L_bb_common_bufsiz1
|
||||
char bb_common_bufsiz1[BUFSIZ+1];
|
||||
#endif
|
||||
|
@@ -37,7 +37,6 @@
|
||||
#include <errno.h>
|
||||
#include "libbb.h"
|
||||
|
||||
#ifdef L_bb_vfprintf
|
||||
int bb_vfprintf(FILE * __restrict stream,
|
||||
const char * __restrict format,
|
||||
va_list arg)
|
||||
@@ -65,16 +64,12 @@ int bb_vfprintf(FILE * __restrict stream,
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_bb_vprintf
|
||||
int bb_vprintf(const char * __restrict format, va_list arg)
|
||||
{
|
||||
return bb_vfprintf(stdout, format, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_bb_fprintf
|
||||
int bb_fprintf(FILE * __restrict stream,
|
||||
const char * __restrict format, ...)
|
||||
{
|
||||
@@ -87,9 +82,7 @@ int bb_fprintf(FILE * __restrict stream,
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_bb_printf
|
||||
int bb_printf(const char * __restrict format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
@@ -101,4 +94,3 @@ int bb_printf(const char * __restrict format, ...)
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
@@ -12,7 +12,6 @@
|
||||
#include <assert.h>
|
||||
#include "libbb.h"
|
||||
|
||||
#ifdef L_safe_strtoi
|
||||
int safe_strtoi(char *arg, int* value)
|
||||
{
|
||||
int error;
|
||||
@@ -21,9 +20,7 @@ int safe_strtoi(char *arg, int* value)
|
||||
*value = (int) lvalue;
|
||||
return error;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_safe_strtod
|
||||
int safe_strtod(char *arg, double* value)
|
||||
{
|
||||
char *endptr;
|
||||
@@ -38,9 +35,7 @@ int safe_strtod(char *arg, double* value)
|
||||
errno = errno_save;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_safe_strtol
|
||||
int safe_strtol(char *arg, long* value)
|
||||
{
|
||||
char *endptr;
|
||||
@@ -55,9 +50,7 @@ int safe_strtol(char *arg, long* value)
|
||||
errno = errno_save;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_safe_strtoul
|
||||
int safe_strtoul(char *arg, unsigned long* value)
|
||||
{
|
||||
char *endptr;
|
||||
@@ -72,9 +65,7 @@ int safe_strtoul(char *arg, unsigned long* value)
|
||||
errno = errno_save;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_safe_strtoll
|
||||
int safe_strtoll(char *arg, long long* value)
|
||||
{
|
||||
char *endptr;
|
||||
@@ -89,9 +80,7 @@ int safe_strtoll(char *arg, long long* value)
|
||||
errno = errno_save;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_safe_strtoull
|
||||
int safe_strtoull(char *arg, unsigned long long* value)
|
||||
{
|
||||
char *endptr;
|
||||
@@ -106,5 +95,3 @@ int safe_strtoull(char *arg, unsigned long long* value)
|
||||
errno = errno_save;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -20,7 +20,6 @@
|
||||
* Since dmalloc's prototypes overwrite the impls here as they are
|
||||
* included after these prototypes in libbb.h, all is well.
|
||||
*/
|
||||
#ifdef L_xmalloc
|
||||
// Die if we can't allocate size bytes of memory.
|
||||
void *xmalloc(size_t size)
|
||||
{
|
||||
@@ -29,9 +28,7 @@ void *xmalloc(size_t size)
|
||||
bb_error_msg_and_die(bb_msg_memory_exhausted);
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xrealloc
|
||||
// Die if we can't resize previously allocated memory. (This returns a pointer
|
||||
// to the new memory, which may or may not be the same as the old memory.
|
||||
// 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)
|
||||
bb_error_msg_and_die(bb_msg_memory_exhausted);
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
#endif /* DMALLOC */
|
||||
|
||||
|
||||
#ifdef L_xzalloc
|
||||
// Die if we can't allocate and zero size bytes of memory.
|
||||
void *xzalloc(size_t size)
|
||||
{
|
||||
@@ -54,9 +48,7 @@ void *xzalloc(size_t size)
|
||||
memset(ptr, 0, size);
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xstrdup
|
||||
// Die if we can't copy a string to freshly allocated memory.
|
||||
char * xstrdup(const char *s)
|
||||
{
|
||||
@@ -72,9 +64,7 @@ char * xstrdup(const char *s)
|
||||
|
||||
return t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xstrndup
|
||||
// Die if we can't allocate n+1 bytes (space for the null terminator) and copy
|
||||
// the (possibly truncated to length n) string into it.
|
||||
char * xstrndup(const char *s, int n)
|
||||
@@ -88,9 +78,7 @@ char * xstrndup(const char *s, int n)
|
||||
|
||||
return safe_strncpy(t,s,n);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xfopen
|
||||
// Die if we can't open a file and return a FILE * to it.
|
||||
// Notice we haven't got xfread(), This is for use with fscanf() and friends.
|
||||
FILE *xfopen(const char *path, const char *mode)
|
||||
@@ -100,9 +88,7 @@ FILE *xfopen(const char *path, const char *mode)
|
||||
bb_perror_msg_and_die("%s", path);
|
||||
return fp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xopen
|
||||
// Die if we can't open an existing file and return an fd.
|
||||
int xopen(const char *pathname, int flags)
|
||||
{
|
||||
@@ -111,9 +97,7 @@ int xopen(const char *pathname, int flags)
|
||||
|
||||
return xopen3(pathname, flags, 0777);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xopen3
|
||||
// Die if we can't open a new file and return an fd.
|
||||
int xopen3(const char *pathname, int flags, int mode)
|
||||
{
|
||||
@@ -125,9 +109,7 @@ int xopen3(const char *pathname, int flags, int mode)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xread
|
||||
// Die with an error message if we can't read the entire buffer.
|
||||
void xread(int fd, void *buf, size_t count)
|
||||
{
|
||||
@@ -140,9 +122,7 @@ void xread(int fd, void *buf, size_t count)
|
||||
buf = ((char *) buf) + size;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xwrite
|
||||
// Die with an error message if we can't write the entire buffer.
|
||||
void xwrite(int fd, void *buf, size_t count)
|
||||
{
|
||||
@@ -155,17 +135,13 @@ void xwrite(int fd, void *buf, size_t count)
|
||||
buf = ((char *) buf) + size;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xlseek
|
||||
// Die with an error message if we can't lseek to the right spot.
|
||||
void xlseek(int fd, off_t offset, int whence)
|
||||
{
|
||||
if (offset != lseek(fd, offset, whence)) bb_error_msg_and_die("lseek");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xread_char
|
||||
// Die with an error message if we can't read one character.
|
||||
unsigned char xread_char(int fd)
|
||||
{
|
||||
@@ -175,9 +151,7 @@ unsigned char xread_char(int fd)
|
||||
|
||||
return(tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xferror
|
||||
// Die with supplied error message if this FILE * has ferror set.
|
||||
void xferror(FILE *fp, const char *fn)
|
||||
{
|
||||
@@ -185,17 +159,13 @@ void xferror(FILE *fp, const char *fn)
|
||||
bb_error_msg_and_die("%s", fn);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xferror_stdout
|
||||
// Die with an error message if stdout has ferror set.
|
||||
void xferror_stdout(void)
|
||||
{
|
||||
xferror(stdout, bb_msg_standard_output);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xfflush_stdout
|
||||
// Die with an error message if we have trouble flushing stdout.
|
||||
void xfflush_stdout(void)
|
||||
{
|
||||
@@ -203,9 +173,7 @@ void xfflush_stdout(void)
|
||||
bb_perror_msg_and_die(bb_msg_standard_output);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_spawn
|
||||
// This does a fork/exec in one call, using vfork(). Return PID of new child,
|
||||
// -1 for failure. Runs argv[0], searching path if that has no / in it.
|
||||
pid_t spawn(char **argv)
|
||||
@@ -230,9 +198,7 @@ pid_t spawn(char **argv)
|
||||
}
|
||||
return failed ? failed : pid;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xspawn
|
||||
// Die with an error message if we can't spawn a child process.
|
||||
pid_t xspawn(char **argv)
|
||||
{
|
||||
@@ -240,9 +206,7 @@ pid_t xspawn(char **argv)
|
||||
if (pid < 0) bb_perror_msg_and_die("%s", *argv);
|
||||
return pid;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_wait4
|
||||
// Wait for the specified child PID to exit, returning child's error return.
|
||||
int wait4pid(int pid)
|
||||
{
|
||||
@@ -253,17 +217,13 @@ int wait4pid(int pid)
|
||||
if (WIFSIGNALED(status)) return WTERMSIG(status);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xsetenv
|
||||
void xsetenv(const char *key, const char *value)
|
||||
{
|
||||
if(setenv(key, value, 1))
|
||||
bb_error_msg_and_die(bb_msg_memory_exhausted);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_itoa
|
||||
// Convert unsigned integer to ascii, writing into supplied buffer. A
|
||||
// truncated result is always null terminated (unless buflen is 0), and
|
||||
// contains the first few digits of the result ala strncpy.
|
||||
@@ -319,9 +279,7 @@ char *itoa(int n)
|
||||
|
||||
return local_buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_setuid
|
||||
// Die with an error message if we can't set gid. (Because resource limits may
|
||||
// limit this user to a given number of processes, and if that fills up the
|
||||
// setgid() will fail and we'll _still_be_root_, which is bad.)
|
||||
@@ -335,9 +293,7 @@ void xsetuid(uid_t uid)
|
||||
{
|
||||
if (setuid(uid)) bb_error_msg_and_die("setuid");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_fdlength
|
||||
// Return how long the file at fd is, if there's any way to determine it.
|
||||
off_t fdlength(int fd)
|
||||
{
|
||||
@@ -375,9 +331,7 @@ off_t fdlength(int fd)
|
||||
|
||||
return pos + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xasprintf
|
||||
// Die with an error message if we can't malloc() enough space and do an
|
||||
// sprintf() into that space.
|
||||
char *xasprintf(const char *format, ...)
|
||||
@@ -405,9 +359,7 @@ char *xasprintf(const char *format, ...)
|
||||
if (r < 0) bb_error_msg_and_die(bb_msg_memory_exhausted);
|
||||
return string_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xprint_and_close_file
|
||||
// Die with an error message if we can't copy an entire FILE * to stdout, then
|
||||
// close that file.
|
||||
void xprint_and_close_file(FILE *file)
|
||||
@@ -418,18 +370,14 @@ void xprint_and_close_file(FILE *file)
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xchdir
|
||||
// Die if we can't chdir to a new path.
|
||||
void xchdir(const char *path)
|
||||
{
|
||||
if (chdir(path))
|
||||
bb_perror_msg_and_die("chdir(%s)", path);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_warn_opendir
|
||||
// Print a warning message if opendir() fails, but don't die.
|
||||
DIR *warn_opendir(const char *path)
|
||||
{
|
||||
@@ -441,9 +389,7 @@ DIR *warn_opendir(const char *path)
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xopendir
|
||||
// Die with an error message if opendir() fails.
|
||||
DIR *xopendir(const char *path)
|
||||
{
|
||||
@@ -453,9 +399,7 @@ DIR *xopendir(const char *path)
|
||||
bb_perror_msg_and_die("unable to open `%s'", path);
|
||||
return dp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xdaemon
|
||||
#ifndef BB_NOMMU
|
||||
// Die with an error message if we can't daemonize.
|
||||
void xdaemon(int nochdir, int noclose)
|
||||
@@ -463,9 +407,7 @@ void xdaemon(int nochdir, int noclose)
|
||||
if (daemon(nochdir, noclose)) bb_perror_msg_and_die("daemon");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef L_xsocket
|
||||
// Die with an error message if we can't open a new socket.
|
||||
int xsocket(int domain, int type, int protocol)
|
||||
{
|
||||
@@ -475,34 +417,26 @@ int xsocket(int domain, int type, int protocol)
|
||||
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xbind
|
||||
// Die with an error message if we can't bind a socket to an address.
|
||||
void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen)
|
||||
{
|
||||
if (bind(sockfd, my_addr, addrlen)) bb_perror_msg_and_die("bind");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xlisten
|
||||
// Die with an error message if we can't listen for connections on a socket.
|
||||
void xlisten(int s, int backlog)
|
||||
{
|
||||
if (listen(s, backlog)) bb_perror_msg_and_die("listen");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xstat
|
||||
// xstat() - a stat() which dies on failure with meaningful error message
|
||||
void xstat(char *name, struct stat *stat_buf)
|
||||
{
|
||||
if (stat(name, stat_buf))
|
||||
bb_perror_msg_and_die("can't stat '%s'", name);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_get_terminal_width_height
|
||||
/* It is perfectly ok to pass in a NULL for either width or for
|
||||
* * height, in which case that value will not be set. */
|
||||
int 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)
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
@@ -15,7 +15,6 @@
|
||||
#include <assert.h>
|
||||
#include "libbb.h"
|
||||
|
||||
#ifdef L_xgetularg_bnd_sfx
|
||||
unsigned long bb_xgetularg_bnd_sfx(const char *arg, int base,
|
||||
unsigned long lower,
|
||||
unsigned long upper,
|
||||
@@ -75,9 +74,7 @@ unsigned long bb_xgetularg_bnd_sfx(const char *arg, int base,
|
||||
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xgetlarg_bnd_sfx
|
||||
long bb_xgetlarg_bnd_sfx(const char *arg, int base,
|
||||
long lower,
|
||||
long upper,
|
||||
@@ -104,36 +101,27 @@ long bb_xgetlarg_bnd_sfx(const char *arg, int base,
|
||||
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_getlarg10_sfx
|
||||
long bb_xgetlarg10_sfx(const char *arg, const struct suffix_mult *suffixes)
|
||||
{
|
||||
return bb_xgetlarg_bnd_sfx(arg, 10, LONG_MIN, LONG_MAX, suffixes);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xgetularg_bnd
|
||||
unsigned long bb_xgetularg_bnd(const char *arg, int base,
|
||||
unsigned long lower,
|
||||
unsigned long upper)
|
||||
{
|
||||
return bb_xgetularg_bnd_sfx(arg, base, lower, upper, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xgetularg10_bnd
|
||||
unsigned long bb_xgetularg10_bnd(const char *arg,
|
||||
unsigned long lower,
|
||||
unsigned long upper)
|
||||
{
|
||||
return bb_xgetularg_bnd(arg, 10, lower, upper);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_xgetularg10
|
||||
unsigned long bb_xgetularg10(const char *arg)
|
||||
{
|
||||
return bb_xgetularg10_bnd(arg, 0, ULONG_MAX);
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user