Some updates for better portability.

-Erik
This commit is contained in:
Erik Andersen 2000-05-16 20:07:38 +00:00
parent 969f9b0486
commit 499f65fb98
7 changed files with 48 additions and 52 deletions

View File

@ -31,6 +31,12 @@ DODEBUG = false
# If you want a static binary, turn this on.
DOSTATIC = false
# To compile vs an alternative libc, you may need to use/adjust
# the following lines to meet your needs. This is how I did it...
#CFLAGS+=-nostdinc -I/home/andersen/CVS/uC-libc/include -I/usr/include/linux
#LDFLAGS+=-nostdlib -L/home/andersen/CVS/libc.a
CC = gcc
# use '-Os' optimization if available, else use -O2
@ -43,10 +49,6 @@ ifndef $(STRIPTOOL)
STRIPTOOL = strip
endif
# TODO: Try compiling vs other libcs.
# See what -nostdinc and -nostdlib do for them.
# also try --prefix=/usr/my-libc-stuff
# -D_GNU_SOURCE is needed because environ is used in init.c
ifeq ($(DODEBUG),true)
CFLAGS += -Wall -g -D_GNU_SOURCE
@ -65,11 +67,10 @@ else
#want to give it a shot...
#
#ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
# -o /dev/null -xc /dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1)
# CFLAGS += -ffunction-sections -fdata-sections -DFUNCTION_SECTIONS
# -o /dev/null -xc /dev/null 2>/dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1)
# CFLAGS += -ffunction-sections -fdata-sections
# LDFLAGS += --gc-sections
#endif
#
endif
endif
@ -77,6 +78,7 @@ ifndef $(PREFIX)
PREFIX = `pwd`/_install
endif
LIBRARIES =
OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o
CFLAGS += -DBB_VER='"$(VERSION)"'

View File

@ -181,7 +181,7 @@ int date_main(int argc, char **argv)
set_time = 1;
if (date_str != NULL)
usage(date_usage);
date_str = optarg;
date_str = *argv;
break;
case 'u':
utc = 1;
@ -192,7 +192,7 @@ int date_main(int argc, char **argv)
use_arg = 1;
if (date_str != NULL)
usage(date_usage);
date_str = optarg;
date_str = *argv;
break;
case '-':
usage(date_usage);

4
date.c
View File

@ -181,7 +181,7 @@ int date_main(int argc, char **argv)
set_time = 1;
if (date_str != NULL)
usage(date_usage);
date_str = optarg;
date_str = *argv;
break;
case 'u':
utc = 1;
@ -192,7 +192,7 @@ int date_main(int argc, char **argv)
use_arg = 1;
if (date_str != NULL)
usage(date_usage);
date_str = optarg;
date_str = *argv;
break;
case '-':
usage(date_usage);

31
dutmp.c
View File

@ -8,22 +8,20 @@
* versions of 'who', 'last', etc. IP Addr is output in hex,
* little endian on x86.
*
* made against libc6
* Modified to support all sort of libcs by
* Erik Andersen <andersen@lineo.com>
*/
#include "internal.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#define BB_DECLARE_EXTERN
#define bb_need_io_error
#include "messages.c"
#if defined(__GLIBC__)
#include <utmp.h>
#else
#include <utmp-wrap.h>
#define utmp new_utmp
#endif
static const char dutmp_usage[] = "dutmp [FILE]\n"
@ -36,27 +34,26 @@ static const char dutmp_usage[] = "dutmp [FILE]\n"
extern int dutmp_main(int argc, char **argv)
{
FILE *f;
int file;
struct utmp ut;
if (argc<2) {
f = stdin;
file = fileno(stdin);
} else if (*argv[1] == '-' ) {
usage(dutmp_usage);
} else {
f = fopen(argv[1], "r");
if (f == NULL) {
file = open(argv[1], O_RDONLY);
if (file < 0) {
fatalError(io_error, argv[1], strerror(errno));
}
}
while (fread(&ut, sizeof(struct utmp), 1, f)) {
printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
while (read(file, (void*)&ut, sizeof(struct utmp))) {
printf("%d|%d|%s|%s|%s|%s|%s|%lx\n",
ut.ut_type, ut.ut_pid, ut.ut_line,
ut.ut_id, ut.ut_user, ut.ut_host,
ut.ut_exit.e_termination, ut.ut_exit.e_exit,
ut.ut_session, ut.ut_tv.tv_sec, ut.ut_tv.tv_usec,
ut.ut_addr_v6[0]);
ctime(&(ut.ut_time)),
(long)ut.ut_addr);
}
exit(TRUE);

View File

@ -8,22 +8,20 @@
* versions of 'who', 'last', etc. IP Addr is output in hex,
* little endian on x86.
*
* made against libc6
* Modified to support all sort of libcs by
* Erik Andersen <andersen@lineo.com>
*/
#include "internal.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#define BB_DECLARE_EXTERN
#define bb_need_io_error
#include "messages.c"
#if defined(__GLIBC__)
#include <utmp.h>
#else
#include <utmp-wrap.h>
#define utmp new_utmp
#endif
static const char dutmp_usage[] = "dutmp [FILE]\n"
@ -36,27 +34,26 @@ static const char dutmp_usage[] = "dutmp [FILE]\n"
extern int dutmp_main(int argc, char **argv)
{
FILE *f;
int file;
struct utmp ut;
if (argc<2) {
f = stdin;
file = fileno(stdin);
} else if (*argv[1] == '-' ) {
usage(dutmp_usage);
} else {
f = fopen(argv[1], "r");
if (f == NULL) {
file = open(argv[1], O_RDONLY);
if (file < 0) {
fatalError(io_error, argv[1], strerror(errno));
}
}
while (fread(&ut, sizeof(struct utmp), 1, f)) {
printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
while (read(file, (void*)&ut, sizeof(struct utmp))) {
printf("%d|%d|%s|%s|%s|%s|%s|%lx\n",
ut.ut_type, ut.ut_pid, ut.ut_line,
ut.ut_id, ut.ut_user, ut.ut_host,
ut.ut_exit.e_termination, ut.ut_exit.e_exit,
ut.ut_session, ut.ut_tv.tv_sec, ut.ut_tv.tv_usec,
ut.ut_addr_v6[0]);
ctime(&(ut.ut_time)),
(long)ut.ut_addr);
}
exit(TRUE);

View File

@ -61,7 +61,7 @@ extern int mt_main(int argc, char **argv)
struct mtop op;
int fd;
if ((argc != 2 && argc != 3) || **(argv + 1) == '-') {
if ((argc != 2 && argc != 3) && **(argv + 1) != '-') {
usage(mt_usage);
}

2
mt.c
View File

@ -61,7 +61,7 @@ extern int mt_main(int argc, char **argv)
struct mtop op;
int fd;
if ((argc != 2 && argc != 3) || **(argv + 1) == '-') {
if ((argc != 2 && argc != 3) && **(argv + 1) != '-') {
usage(mt_usage);
}