mirror of
https://github.com/sheumann/hush.git
synced 2024-12-27 01:32:08 +00:00
Some updates for better portability.
-Erik
This commit is contained in:
parent
969f9b0486
commit
499f65fb98
16
Makefile
16
Makefile
@ -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)"'
|
||||
|
@ -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
4
date.c
@ -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
31
dutmp.c
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user