aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-05-16 20:07:38 +0000
committerErik Andersen <andersen@codepoet.org>2000-05-16 20:07:38 +0000
commit499f65fb98a8258f8704b52efb3a99da0c82f785 (patch)
tree8bb86bf2d07ab298eff29daea039449e87d90166
parent969f9b0486792829378ff7397ee53c1475b22cdc (diff)
downloadbusybox-w32-499f65fb98a8258f8704b52efb3a99da0c82f785.tar.gz
busybox-w32-499f65fb98a8258f8704b52efb3a99da0c82f785.tar.bz2
busybox-w32-499f65fb98a8258f8704b52efb3a99da0c82f785.zip
Some updates for better portability.
-Erik
-rw-r--r--Makefile18
-rw-r--r--coreutils/date.c4
-rw-r--r--date.c4
-rw-r--r--dutmp.c35
-rw-r--r--miscutils/dutmp.c35
-rw-r--r--miscutils/mt.c2
-rw-r--r--mt.c2
7 files changed, 48 insertions, 52 deletions
diff --git a/Makefile b/Makefile
index e9192f948..d3d71ad77 100644
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,12 @@ DODEBUG = false
31# If you want a static binary, turn this on. 31# If you want a static binary, turn this on.
32DOSTATIC = false 32DOSTATIC = false
33 33
34# To compile vs an alternative libc, you may need to use/adjust
35# the following lines to meet your needs. This is how I did it...
36#CFLAGS+=-nostdinc -I/home/andersen/CVS/uC-libc/include -I/usr/include/linux
37#LDFLAGS+=-nostdlib -L/home/andersen/CVS/libc.a
38
39
34CC = gcc 40CC = gcc
35 41
36# use '-Os' optimization if available, else use -O2 42# use '-Os' optimization if available, else use -O2
@@ -43,10 +49,6 @@ ifndef $(STRIPTOOL)
43 STRIPTOOL = strip 49 STRIPTOOL = strip
44endif 50endif
45 51
46# TODO: Try compiling vs other libcs.
47# See what -nostdinc and -nostdlib do for them.
48# also try --prefix=/usr/my-libc-stuff
49
50# -D_GNU_SOURCE is needed because environ is used in init.c 52# -D_GNU_SOURCE is needed because environ is used in init.c
51ifeq ($(DODEBUG),true) 53ifeq ($(DODEBUG),true)
52 CFLAGS += -Wall -g -D_GNU_SOURCE 54 CFLAGS += -Wall -g -D_GNU_SOURCE
@@ -65,11 +67,10 @@ else
65 #want to give it a shot... 67 #want to give it a shot...
66 # 68 #
67 #ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \ 69 #ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
68 # -o /dev/null -xc /dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1) 70 # -o /dev/null -xc /dev/null 2>/dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1)
69 # CFLAGS += -ffunction-sections -fdata-sections -DFUNCTION_SECTIONS 71 # CFLAGS += -ffunction-sections -fdata-sections
70 # LDFLAGS += --gc-sections 72 # LDFLAGS += --gc-sections
71 #endif 73 #endif
72 #
73 endif 74 endif
74endif 75endif
75 76
@@ -77,6 +78,7 @@ ifndef $(PREFIX)
77 PREFIX = `pwd`/_install 78 PREFIX = `pwd`/_install
78endif 79endif
79 80
81
80LIBRARIES = 82LIBRARIES =
81OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o 83OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o
82CFLAGS += -DBB_VER='"$(VERSION)"' 84CFLAGS += -DBB_VER='"$(VERSION)"'
diff --git a/coreutils/date.c b/coreutils/date.c
index dd054be66..67d61a510 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -181,7 +181,7 @@ int date_main(int argc, char **argv)
181 set_time = 1; 181 set_time = 1;
182 if (date_str != NULL) 182 if (date_str != NULL)
183 usage(date_usage); 183 usage(date_usage);
184 date_str = optarg; 184 date_str = *argv;
185 break; 185 break;
186 case 'u': 186 case 'u':
187 utc = 1; 187 utc = 1;
@@ -192,7 +192,7 @@ int date_main(int argc, char **argv)
192 use_arg = 1; 192 use_arg = 1;
193 if (date_str != NULL) 193 if (date_str != NULL)
194 usage(date_usage); 194 usage(date_usage);
195 date_str = optarg; 195 date_str = *argv;
196 break; 196 break;
197 case '-': 197 case '-':
198 usage(date_usage); 198 usage(date_usage);
diff --git a/date.c b/date.c
index dd054be66..67d61a510 100644
--- a/date.c
+++ b/date.c
@@ -181,7 +181,7 @@ int date_main(int argc, char **argv)
181 set_time = 1; 181 set_time = 1;
182 if (date_str != NULL) 182 if (date_str != NULL)
183 usage(date_usage); 183 usage(date_usage);
184 date_str = optarg; 184 date_str = *argv;
185 break; 185 break;
186 case 'u': 186 case 'u':
187 utc = 1; 187 utc = 1;
@@ -192,7 +192,7 @@ int date_main(int argc, char **argv)
192 use_arg = 1; 192 use_arg = 1;
193 if (date_str != NULL) 193 if (date_str != NULL)
194 usage(date_usage); 194 usage(date_usage);
195 date_str = optarg; 195 date_str = *argv;
196 break; 196 break;
197 case '-': 197 case '-':
198 usage(date_usage); 198 usage(date_usage);
diff --git a/dutmp.c b/dutmp.c
index fab1a7b99..f264fd75b 100644
--- a/dutmp.c
+++ b/dutmp.c
@@ -8,22 +8,20 @@
8 * versions of 'who', 'last', etc. IP Addr is output in hex, 8 * versions of 'who', 'last', etc. IP Addr is output in hex,
9 * little endian on x86. 9 * little endian on x86.
10 * 10 *
11 * made against libc6 11 * Modified to support all sort of libcs by
12 * Erik Andersen <andersen@lineo.com>
12 */ 13 */
13 14
14#include "internal.h" 15#include "internal.h"
15#include <stdio.h> 16#include <sys/types.h>
17#include <sys/stat.h>
18#include <fcntl.h>
19
16#include <errno.h> 20#include <errno.h>
17#define BB_DECLARE_EXTERN 21#define BB_DECLARE_EXTERN
18#define bb_need_io_error 22#define bb_need_io_error
19#include "messages.c" 23#include "messages.c"
20
21#if defined(__GLIBC__)
22#include <utmp.h> 24#include <utmp.h>
23#else
24#include <utmp-wrap.h>
25#define utmp new_utmp
26#endif
27 25
28 26
29static const char dutmp_usage[] = "dutmp [FILE]\n" 27static const char dutmp_usage[] = "dutmp [FILE]\n"
@@ -36,27 +34,26 @@ static const char dutmp_usage[] = "dutmp [FILE]\n"
36extern int dutmp_main(int argc, char **argv) 34extern int dutmp_main(int argc, char **argv)
37{ 35{
38 36
39 FILE *f; 37 int file;
40 struct utmp ut; 38 struct utmp ut;
41 39
42 if (argc<2) { 40 if (argc<2) {
43 f = stdin; 41 file = fileno(stdin);
44 } else if (*argv[1] == '-' ) { 42 } else if (*argv[1] == '-' ) {
45 usage(dutmp_usage); 43 usage(dutmp_usage);
46 } else { 44 } else {
47 f = fopen(argv[1], "r"); 45 file = open(argv[1], O_RDONLY);
48 if (f == NULL) { 46 if (file < 0) {
49 fatalError(io_error, argv[1], strerror(errno)); 47 fatalError(io_error, argv[1], strerror(errno));
50 } 48 }
51 } 49 }
52 50
53 while (fread(&ut, sizeof(struct utmp), 1, f)) { 51 while (read(file, (void*)&ut, sizeof(struct utmp))) {
54 printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n", 52 printf("%d|%d|%s|%s|%s|%s|%s|%lx\n",
55 ut.ut_type, ut.ut_pid, ut.ut_line, 53 ut.ut_type, ut.ut_pid, ut.ut_line,
56 ut.ut_id, ut.ut_user, ut.ut_host, 54 ut.ut_id, ut.ut_user, ut.ut_host,
57 ut.ut_exit.e_termination, ut.ut_exit.e_exit, 55 ctime(&(ut.ut_time)),
58 ut.ut_session, ut.ut_tv.tv_sec, ut.ut_tv.tv_usec, 56 (long)ut.ut_addr);
59 ut.ut_addr_v6[0]);
60 } 57 }
61 58
62 exit(TRUE); 59 exit(TRUE);
diff --git a/miscutils/dutmp.c b/miscutils/dutmp.c
index fab1a7b99..f264fd75b 100644
--- a/miscutils/dutmp.c
+++ b/miscutils/dutmp.c
@@ -8,22 +8,20 @@
8 * versions of 'who', 'last', etc. IP Addr is output in hex, 8 * versions of 'who', 'last', etc. IP Addr is output in hex,
9 * little endian on x86. 9 * little endian on x86.
10 * 10 *
11 * made against libc6 11 * Modified to support all sort of libcs by
12 * Erik Andersen <andersen@lineo.com>
12 */ 13 */
13 14
14#include "internal.h" 15#include "internal.h"
15#include <stdio.h> 16#include <sys/types.h>
17#include <sys/stat.h>
18#include <fcntl.h>
19
16#include <errno.h> 20#include <errno.h>
17#define BB_DECLARE_EXTERN 21#define BB_DECLARE_EXTERN
18#define bb_need_io_error 22#define bb_need_io_error
19#include "messages.c" 23#include "messages.c"
20
21#if defined(__GLIBC__)
22#include <utmp.h> 24#include <utmp.h>
23#else
24#include <utmp-wrap.h>
25#define utmp new_utmp
26#endif
27 25
28 26
29static const char dutmp_usage[] = "dutmp [FILE]\n" 27static const char dutmp_usage[] = "dutmp [FILE]\n"
@@ -36,27 +34,26 @@ static const char dutmp_usage[] = "dutmp [FILE]\n"
36extern int dutmp_main(int argc, char **argv) 34extern int dutmp_main(int argc, char **argv)
37{ 35{
38 36
39 FILE *f; 37 int file;
40 struct utmp ut; 38 struct utmp ut;
41 39
42 if (argc<2) { 40 if (argc<2) {
43 f = stdin; 41 file = fileno(stdin);
44 } else if (*argv[1] == '-' ) { 42 } else if (*argv[1] == '-' ) {
45 usage(dutmp_usage); 43 usage(dutmp_usage);
46 } else { 44 } else {
47 f = fopen(argv[1], "r"); 45 file = open(argv[1], O_RDONLY);
48 if (f == NULL) { 46 if (file < 0) {
49 fatalError(io_error, argv[1], strerror(errno)); 47 fatalError(io_error, argv[1], strerror(errno));
50 } 48 }
51 } 49 }
52 50
53 while (fread(&ut, sizeof(struct utmp), 1, f)) { 51 while (read(file, (void*)&ut, sizeof(struct utmp))) {
54 printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n", 52 printf("%d|%d|%s|%s|%s|%s|%s|%lx\n",
55 ut.ut_type, ut.ut_pid, ut.ut_line, 53 ut.ut_type, ut.ut_pid, ut.ut_line,
56 ut.ut_id, ut.ut_user, ut.ut_host, 54 ut.ut_id, ut.ut_user, ut.ut_host,
57 ut.ut_exit.e_termination, ut.ut_exit.e_exit, 55 ctime(&(ut.ut_time)),
58 ut.ut_session, ut.ut_tv.tv_sec, ut.ut_tv.tv_usec, 56 (long)ut.ut_addr);
59 ut.ut_addr_v6[0]);
60 } 57 }
61 58
62 exit(TRUE); 59 exit(TRUE);
diff --git a/miscutils/mt.c b/miscutils/mt.c
index 28922f8d9..44f23884c 100644
--- a/miscutils/mt.c
+++ b/miscutils/mt.c
@@ -61,7 +61,7 @@ extern int mt_main(int argc, char **argv)
61 struct mtop op; 61 struct mtop op;
62 int fd; 62 int fd;
63 63
64 if ((argc != 2 && argc != 3) || **(argv + 1) == '-') { 64 if ((argc != 2 && argc != 3) && **(argv + 1) != '-') {
65 usage(mt_usage); 65 usage(mt_usage);
66 } 66 }
67 67
diff --git a/mt.c b/mt.c
index 28922f8d9..44f23884c 100644
--- a/mt.c
+++ b/mt.c
@@ -61,7 +61,7 @@ extern int mt_main(int argc, char **argv)
61 struct mtop op; 61 struct mtop op;
62 int fd; 62 int fd;
63 63
64 if ((argc != 2 && argc != 3) || **(argv + 1) == '-') { 64 if ((argc != 2 && argc != 3) && **(argv + 1) != '-') {
65 usage(mt_usage); 65 usage(mt_usage);
66 } 66 }
67 67