More Doc updates. cmdedit and more termio fixes.
authorErik Andersen <andersen@codepoet.org>
Fri, 21 Apr 2000 01:26:49 +0000 (01:26 -0000)
committerErik Andersen <andersen@codepoet.org>
Fri, 21 Apr 2000 01:26:49 +0000 (01:26 -0000)
35 files changed:
Makefile
archival/tar.c
basename.c
busybox.def.h
cat.c
chmod_chown_chgrp.c
chroot.c
chvt.c
cmdedit.c
cmdedit.h
console-tools/chvt.c
coreutils/basename.c
coreutils/cat.c
coreutils/chroot.c
coreutils/date.c
coreutils/length.c
cp_mv.c
date.c
init.c
init/init.c
lash.c
length.c
modutils/rmmod.c
more.c
networking/ping.c
ping.c
rmmod.c
sh.c
shell/cmdedit.c
shell/cmdedit.h
shell/lash.c
sysklogd/syslogd.c
syslogd.c
tar.c
util-linux/more.c

index aaa0eddc49e8521fef8ca7dc6f94be33e936eff4..eea01d383b19b7a57230df7d81e4d7d2be220ef9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -95,17 +95,19 @@ ifdef BB_INIT_SCRIPT
     CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
 endif
 
-all: busybox busybox.links
+all: busybox busybox.links docs
 
 busybox: $(OBJECTS)
        $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES)
        $(STRIP)
-       $(MAKE) -C docs
        
+docs:
+       $(MAKE) -C docs
+
 busybox.links: busybox.def.h
        - ./busybox.mkll | sort >$@
 
-regexp.o nfsmount.o: %.o: %.h
+regexp.o nfsmount.o cmdedit.o: %.o: %.h
 $(OBJECTS): %.o: busybox.def.h internal.h  %.c Makefile
 
 test tests:
index 2284fd06d71e008e0f57b0d0904385853a14f08a..0177d5188b51e18114505f3a3d7688c6154b40e5 100644 (file)
@@ -608,7 +608,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
                                len1=snprintf(buf, sizeof(buf), "%ld,%-ld ", 
                                                header.devmajor, header.devminor);
                        } else {
-                               len1=snprintf(buf, sizeof(buf), "%d ", header.size);
+                               len1=snprintf(buf, sizeof(buf), "%lu ", (long)header.size);
                        }
                        /* Jump through some hoops to make the columns match up */
                        for(;(len+len1)<31;len++)
index 5fe5e0f0391da740cba9c6a0dd0ce8c978944819..efd07e27207f5231bd6b2adfc8c28d46712301f4 100644 (file)
@@ -29,7 +29,11 @@ extern int basename_main(int argc, char **argv)
        char* s, *s1;
 
        if ((argc < 2) || (**(argv + 1) == '-')) {
-               usage("basename [file ...]\n");
+               usage("basename [FILE ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+                               "\nStrips directory path and suffixes from FILE(s).\n"
+#endif
+                               );
        }
        argv++;
 
index f1c7b4f139abce5d9dee89dcf29241657d4137d5..786b1a5d16925c8ecf4eebf2ff80c25e058da46b 100644 (file)
 // normal strings.
 #define BB_FEATURE_FULL_REGULAR_EXPRESSIONS
 //
-// Use only simple command help
-#define BB_FEATURE_TRIVIAL_HELP
+// This compiles out everything but the most 
+// trivial --help usage information (i.e. reduces binary size)
+//#define BB_FEATURE_TRIVIAL_HELP
 //
 // Use termios to manipulate the screen ('more' is prettier with this on)
 #define BB_FEATURE_USE_TERMIOS
diff --git a/cat.c b/cat.c
index f7a6bfa7b8df122f86358feab8c5491506260998..561b24f3f39f44ee12878e2865b059c1d5a597d1 100644 (file)
--- a/cat.c
+++ b/cat.c
@@ -45,7 +45,11 @@ extern int cat_main(int argc, char **argv)
        }
 
        if (**(argv + 1) == '-') {
-               usage("cat [file ...]\n");
+               usage("cat [FILE ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+                               "\nConcatenates FILE(s) and prints them to the standard output.\n"
+#endif
+                               );
        }
        argc--;
 
index fb93f3ff81f8d8240c7c69f492fec22e5451e636..d5c21a220d5e3ee15bdf3976763dcc50693fb7a6 100644 (file)
@@ -43,21 +43,27 @@ static char *theMode = NULL;
 #define CHOWN_APP   2
 #define CHMOD_APP   3
 
-static const char chgrp_usage[] = "chgrp [OPTION]... GROUP FILE...\n\n"
-       "Change the group membership of each FILE to GROUP.\n"
-
-       "\nOptions:\n\t-R\tchange files and directories recursively\n";
+static const char chgrp_usage[] = "chgrp [OPTION]... GROUP FILE...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+       "\nChange the group membership of each FILE to GROUP.\n"
+       "\nOptions:\n\t-R\tChanges files and directories recursively.\n"
+#endif
+       ;
 static const char chown_usage[] =
-       "chown [OPTION]...  OWNER[<.|:>[GROUP] FILE...\n\n"
-       "Change the owner and/or group of each FILE to OWNER and/or GROUP.\n"
-
-       "\nOptions:\n\t-R\tchange files and directories recursively\n";
+       "chown [OPTION]...  OWNER[<.|:>[GROUP] FILE...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+       "\nChange the owner and/or group of each FILE to OWNER and/or GROUP.\n"
+       "\nOptions:\n\t-R\tChanges files and directories recursively.\n"
+#endif
+       ;
 static const char chmod_usage[] =
-       "chmod [-R] MODE[,MODE]... FILE...\n\n"
-       "Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n"
-
+       "chmod [-R] MODE[,MODE]... FILE...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+       "\nEach MODE is one or more of the letters ugoa, one of the symbols +-= and\n"
        "one or more of the letters rwxst.\n\n"
-       "\nOptions:\n\t-R\tchange files and directories recursively.\n";
+       "\nOptions:\n\t-R\tChanges files and directories recursively.\n"
+#endif
+       ;
 
 
 static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
index 63fa4d14602caa6461c23b4b6a6e0885db4ca328..34116a60eb9d2eac4d2dd0399f72f9e0c42f3688 100644 (file)
--- a/chroot.c
+++ b/chroot.c
 #include <errno.h>
 
 
-static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n\n"
-
-       "Run COMMAND with root directory set to NEWROOT.\n";
+static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+       "\nRun COMMAND with root directory set to NEWROOT.\n"
+#endif
+       ;
 
 
 
diff --git a/chvt.c b/chvt.c
index 635022a57e4354f16c75b485cf3cc2281497567e..bf1ed609bf005bce75769d1cf8e2c364fc01863a 100644 (file)
--- a/chvt.c
+++ b/chvt.c
@@ -19,8 +19,11 @@ int chvt_main(int argc, char **argv)
        int fd, num;
 
        if ((argc != 2) || (**(argv + 1) == '-')) {
-               usage
-                       ("chvt N\n\nChange foreground virtual terminal to /dev/ttyN\n");
+               usage ("chvt N\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+                               "\nChanges the foreground virtual terminal to /dev/ttyN\n"
+#endif
+                               );
        }
        fd = get_console_fd("/dev/console");
        num = atoi(argv[1]);
index ebc6b969653b89b5110dfc563c15eeed0ec098e7..e4c88c265ac744165d475cb5f3cced4cf2973581 100644 (file)
--- a/cmdedit.c
+++ b/cmdedit.c
@@ -39,7 +39,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
-#include <termio.h>
+#include <sys/ioctl.h>
 #include <ctype.h>
 #include <signal.h>
 
 
 static struct history *his_front = NULL;       /* First element in command line list */
 static struct history *his_end = NULL; /* Last element in command line list */
-static struct termio old_term, new_term;       /* Current termio and the previous termio before starting ash */
+
+/* ED: sparc termios is broken: revert back to old termio handling. */
+#ifdef BB_FEATURE_USE_TERMIOS
+
+#if #cpu(sparc)
+#      include <termio.h>
+#      define termios termio
+#      define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp)
+#      define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp)
+#else
+#      include <termios.h>
+#      define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp)
+#      define getTermSettings(fd,argp) tcgetattr(fd, argp);
+#endif
+
+/* Current termio and the previous termio before starting sh */
+struct termios initial_settings, new_settings;
+#endif
+
+
 
 static int cmdedit_termw = 80;  /* actual terminal width */
 static int cmdedit_scroll = 27; /* width of EOL scrolling region */
@@ -84,14 +103,15 @@ void cmdedit_reset_term(void)
 {
        if (reset_term)
                /* sparc and other have broken termios support: use old termio handling. */
-               ioctl(fileno(stdin), TCSETA, (void *) &old_term);
+               setTermSettings(fileno(stdin), (void*) &initial_settings);
 }
 
 void clean_up_and_die(int sig)
 {
        cmdedit_reset_term();
        fprintf(stdout, "\n");
-       exit(TRUE);
+       if (sig!=SIGINT)
+               exit(TRUE);
 }
 
 /* Go to HOME position */
@@ -233,7 +253,7 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches)
        return (matches);
 }
 
-void input_tab(char* command, int outputFd, int *cursor, int *len)
+void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
 {
        /* Do TAB completion */
        static int num_matches=0;
@@ -379,19 +399,17 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
 
        memset(command, 0, sizeof(command));
        if (!reset_term) {
-               /* sparc and other have broken termios support: use old termio handling. */
-               ioctl(inputFd, TCGETA, (void *) &old_term);
-               memcpy(&new_term, &old_term, sizeof(struct termio));
-
-               new_term.c_cc[VMIN] = 1;
-               new_term.c_cc[VTIME] = 0;
-               new_term.c_lflag &= ~ICANON;    /* unbuffered input */
-               new_term.c_lflag &= ~ECHO;
+               
+               getTermSettings(inputFd, (void*) &initial_settings);
+               memcpy(&new_settings, &initial_settings, sizeof(struct termios));
+               new_settings.c_cc[VMIN] = 1;
+               new_settings.c_cc[VTIME] = 0;
+               new_settings.c_cc[VINTR] = _POSIX_VDISABLE; /* Turn off CTRL-C, so we can trap it */
+               new_settings.c_lflag &= ~ICANON;        /* unbuffered input */
+               new_settings.c_lflag &= ~(ECHO|ECHOCTL|ECHONL); /* Turn off echoing */
                reset_term = 1;
-               ioctl(inputFd, TCSETA, (void *) &new_term);
-       } else {
-               ioctl(inputFd, TCSETA, (void *) &new_term);
        }
+       setTermSettings(inputFd, (void*) &new_settings);
 
        memset(command, 0, BUFSIZ);
 
@@ -399,6 +417,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
 
                if ((ret = read(inputFd, &c, 1)) < 1)
                        return;
+               //fprintf(stderr, "got a '%c' (%d)\n", c, c);
 
                switch (c) {
                case '\n':
@@ -414,6 +433,21 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
                case 2:
                        /* Control-b -- Move back one character */
                        input_backward(outputFd, &cursor);
+                       break;
+               case 3:
+                       /* Control-c -- leave the current line, 
+                        * and start over on the next line */ 
+
+                       /* Go to the next line */
+                       xwrite(outputFd, "\n", 1);
+
+                       /* Rewrite the prompt */
+                       xwrite(outputFd, prompt, strlen(prompt));
+
+                       /* Reset the command string */
+                       memset(command, 0, sizeof(command));
+                       len = cursor = 0;
+
                        break;
                case 4:
                        /* Control-d -- Delete one character, or exit 
@@ -435,12 +469,12 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
                        break;
                case '\b':
                case DEL:
-                       /* control-h and DEL */
+                       /* Control-h and DEL */
                        input_backspace(command, outputFd, &cursor, &len);
                        break;
                case '\t':
 #ifdef BB_FEATURE_SH_TAB_COMPLETION
-                       input_tab(command, outputFd, &cursor, &len);
+                       input_tab(command, prompt, outputFd, &cursor, &len);
 #endif
                        break;
                case 14:
@@ -591,8 +625,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
        }
 
        nr = len + 1;
-       /* sparc and other have broken termios support: use old termio handling. */
-       ioctl(inputFd, TCSETA, (void *) &old_term);
+       setTermSettings(inputFd, (void *) &initial_settings);
        reset_term = 0;
 
 
@@ -644,6 +677,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
 extern void cmdedit_init(void)
 {
        atexit(cmdedit_reset_term);
+       signal(SIGKILL, clean_up_and_die);
        signal(SIGINT, clean_up_and_die);
        signal(SIGQUIT, clean_up_and_die);
        signal(SIGTERM, clean_up_and_die);
index 0e465e50e3a503d4eb088da46edbec75e8efe5fd..9ac7daca3c338168bee805d39386e3fecbca81b5 100644 (file)
--- a/cmdedit.h
+++ b/cmdedit.h
@@ -10,6 +10,7 @@
 
 typedef size_t (*cmdedit_strwidth_proc)(char *);
 
+void cmdedit_init(void);
 void cmdedit_read_input(char* promptStr, char* command);               /* read a line of input */
 void cmdedit_setwidth(int);            /* specify width of screen */
 void cmdedit_histadd(char *);          /* adds entries to hist */
@@ -21,6 +22,7 @@ extern int    (*cmdedit_tab_hook)(char *, int, int *);
 
 #else  /* not __STDC__ */
 
+void cmdedit_init(void);
 void cmdedit_read_input(char* promptStr, char* command);
 void cmdedit_setwidth();
 void cmdedit_histadd();
index 635022a57e4354f16c75b485cf3cc2281497567e..bf1ed609bf005bce75769d1cf8e2c364fc01863a 100644 (file)
@@ -19,8 +19,11 @@ int chvt_main(int argc, char **argv)
        int fd, num;
 
        if ((argc != 2) || (**(argv + 1) == '-')) {
-               usage
-                       ("chvt N\n\nChange foreground virtual terminal to /dev/ttyN\n");
+               usage ("chvt N\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+                               "\nChanges the foreground virtual terminal to /dev/ttyN\n"
+#endif
+                               );
        }
        fd = get_console_fd("/dev/console");
        num = atoi(argv[1]);
index 5fe5e0f0391da740cba9c6a0dd0ce8c978944819..efd07e27207f5231bd6b2adfc8c28d46712301f4 100644 (file)
@@ -29,7 +29,11 @@ extern int basename_main(int argc, char **argv)
        char* s, *s1;
 
        if ((argc < 2) || (**(argv + 1) == '-')) {
-               usage("basename [file ...]\n");
+               usage("basename [FILE ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+                               "\nStrips directory path and suffixes from FILE(s).\n"
+#endif
+                               );
        }
        argv++;
 
index f7a6bfa7b8df122f86358feab8c5491506260998..561b24f3f39f44ee12878e2865b059c1d5a597d1 100644 (file)
@@ -45,7 +45,11 @@ extern int cat_main(int argc, char **argv)
        }
 
        if (**(argv + 1) == '-') {
-               usage("cat [file ...]\n");
+               usage("cat [FILE ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+                               "\nConcatenates FILE(s) and prints them to the standard output.\n"
+#endif
+                               );
        }
        argc--;
 
index 63fa4d14602caa6461c23b4b6a6e0885db4ca328..34116a60eb9d2eac4d2dd0399f72f9e0c42f3688 100644 (file)
 #include <errno.h>
 
 
-static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n\n"
-
-       "Run COMMAND with root directory set to NEWROOT.\n";
+static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+       "\nRun COMMAND with root directory set to NEWROOT.\n"
+#endif
+       ;
 
 
 
index 25ce05d2d3f12a67083a5401bd717db86440cc37..dd054be6634c650066bbd95155339f7f036f1868 100644 (file)
    mail commands */
 
 static const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
-       "  or:  date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n\n"
-       "Display the current time in the given FORMAT, or set the system date.\n"
-       "\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
-       "\t-s\t\tset time described by STRING\n"
-
-       "\t-u\t\tprint or set Coordinated Universal Time\n";
+       "  or:  date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+       "\nDisplays the current time in the given FORMAT, or sets the system date.\n"
+       "\nOptions:\n\t-R\tOutputs RFC-822 compliant date string\n"
+       "\t-s\tSets time described by STRING\n"
+       "\t-u\tPrints or sets Coordinated Universal Time\n"
+#endif
+       ;
 
 
 /* Input parsing code is always bulky - used heavy duty libc stuff as
index 00e5a171bf5208c8a6d2c559d3c5fe71ef65f16c..4cbe7e17b088b2c105dda17a1036d3d8f3c0e2b0 100644 (file)
@@ -9,6 +9,6 @@ extern int length_main(int argc, char **argv)
        if (argc != 2 || **(argv + 1) == '-') {
                usage("length string\n");
        }
-       printf("%d\n", strlen(argv[1]));
+       printf("%lu\n", (long)strlen(argv[1]));
        return (TRUE);
 }
diff --git a/cp_mv.c b/cp_mv.c
index 9a308493585992ac844f27c1be9c489bfd995b80..f4104e57356e60c325c635132f20e061ed051ed4 100644 (file)
--- a/cp_mv.c
+++ b/cp_mv.c
@@ -49,16 +49,21 @@ static const char *dz;                      /* dollar zero, .bss */
 static const char *cp_mv_usage[] =     /* .rodata */
 {
        "cp [OPTION]... SOURCE DEST\n"
-               "   or: cp [OPTION]... SOURCE... DIRECTORY\n\n"
-               "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n"
+               "   or: cp [OPTION]... SOURCE... DIRECTORY\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+               "\nCopies SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n"
                "\n"
-               "\t-a\tsame as -dpR\n"
-               "\t-d\tpreserve links\n"
-               "\t-p\tpreserve file attributes if possible\n"
-               "\t-R\tcopy directories recursively\n",
+               "\t-a\tSame as -dpR\n"
+               "\t-d\tPreserves links\n"
+               "\t-p\tPreserves file attributes if possible\n"
+               "\t-R\tCopies directories recursively\n"
+#endif
+               ,
        "mv SOURCE DEST\n"
-               "   or: mv SOURCE... DIRECTORY\n\n"
-               "Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n"
+               "   or: mv SOURCE... DIRECTORY\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+               "\nRename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n"
+#endif
 };
 
 static int recursiveFlag;
diff --git a/date.c b/date.c
index 25ce05d2d3f12a67083a5401bd717db86440cc37..dd054be6634c650066bbd95155339f7f036f1868 100644 (file)
--- a/date.c
+++ b/date.c
    mail commands */
 
 static const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
-       "  or:  date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n\n"
-       "Display the current time in the given FORMAT, or set the system date.\n"
-       "\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
-       "\t-s\t\tset time described by STRING\n"
-
-       "\t-u\t\tprint or set Coordinated Universal Time\n";
+       "  or:  date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+       "\nDisplays the current time in the given FORMAT, or sets the system date.\n"
+       "\nOptions:\n\t-R\tOutputs RFC-822 compliant date string\n"
+       "\t-s\tSets time described by STRING\n"
+       "\t-u\tPrints or sets Coordinated Universal Time\n"
+#endif
+       ;
 
 
 /* Input parsing code is always bulky - used heavy duty libc stuff as
diff --git a/init.c b/init.c
index e8a5f74d31782e3f6660a8613801198db02c6957..af10f98f06efb8c5a77dc683a3c24f8e013e33f5 100644 (file)
--- a/init.c
+++ b/init.c
@@ -201,6 +201,7 @@ static void message(int device, char *fmt, ...)
        }
 }
 
+#define CTRLCHAR(ch)   ((ch)&0x1f)
 
 /* Set terminal settings to reasonable defaults */
 void set_term(int fd)
@@ -210,14 +211,14 @@ void set_term(int fd)
        tcgetattr(fd, &tty);
 
        /* set control chars */
-       tty.c_cc[VINTR]  = 3;   /* C-c */
-       tty.c_cc[VQUIT]  = 28;  /* C-\ */
-       tty.c_cc[VERASE] = 127; /* C-? */
-       tty.c_cc[VKILL]  = 21;  /* C-u */
-       tty.c_cc[VEOF]   = 4;   /* C-d */
-       tty.c_cc[VSTART] = 17;  /* C-q */
-       tty.c_cc[VSTOP]  = 19;  /* C-s */
-       tty.c_cc[VSUSP]  = 26;  /* C-z */
+       tty.c_cc[VINTR]  = CTRLCHAR('C');       /* Ctrl-C */
+       tty.c_cc[VQUIT]  = CTRLCHAR('\\');      /* Ctrl-\ */
+       tty.c_cc[VERASE] = CTRLCHAR('?');       /* Ctrl-? */
+       tty.c_cc[VKILL]  = CTRLCHAR('U');       /* Ctrl-U */
+       tty.c_cc[VEOF]   = CTRLCHAR('D');       /* Ctrl-D */
+       tty.c_cc[VSTOP]  = CTRLCHAR('S');       /* Ctrl-S */
+       tty.c_cc[VSTART] = CTRLCHAR('Q');       /* Ctrl-Q */
+       tty.c_cc[VSUSP]  = CTRLCHAR('Z');       /* Ctrl-Z */
 
        /* use line dicipline 0 */
        tty.c_line = 0;
index e8a5f74d31782e3f6660a8613801198db02c6957..af10f98f06efb8c5a77dc683a3c24f8e013e33f5 100644 (file)
@@ -201,6 +201,7 @@ static void message(int device, char *fmt, ...)
        }
 }
 
+#define CTRLCHAR(ch)   ((ch)&0x1f)
 
 /* Set terminal settings to reasonable defaults */
 void set_term(int fd)
@@ -210,14 +211,14 @@ void set_term(int fd)
        tcgetattr(fd, &tty);
 
        /* set control chars */
-       tty.c_cc[VINTR]  = 3;   /* C-c */
-       tty.c_cc[VQUIT]  = 28;  /* C-\ */
-       tty.c_cc[VERASE] = 127; /* C-? */
-       tty.c_cc[VKILL]  = 21;  /* C-u */
-       tty.c_cc[VEOF]   = 4;   /* C-d */
-       tty.c_cc[VSTART] = 17;  /* C-q */
-       tty.c_cc[VSTOP]  = 19;  /* C-s */
-       tty.c_cc[VSUSP]  = 26;  /* C-z */
+       tty.c_cc[VINTR]  = CTRLCHAR('C');       /* Ctrl-C */
+       tty.c_cc[VQUIT]  = CTRLCHAR('\\');      /* Ctrl-\ */
+       tty.c_cc[VERASE] = CTRLCHAR('?');       /* Ctrl-? */
+       tty.c_cc[VKILL]  = CTRLCHAR('U');       /* Ctrl-U */
+       tty.c_cc[VEOF]   = CTRLCHAR('D');       /* Ctrl-D */
+       tty.c_cc[VSTOP]  = CTRLCHAR('S');       /* Ctrl-S */
+       tty.c_cc[VSTART] = CTRLCHAR('Q');       /* Ctrl-Q */
+       tty.c_cc[VSUSP]  = CTRLCHAR('Z');       /* Ctrl-Z */
 
        /* use line dicipline 0 */
        tty.c_line = 0;
diff --git a/lash.c b/lash.c
index 97db8afafad9e7b2850734cb66d556642dcca4b0..b96b46456814a4e36e6d5d9458c2b39fbf06f7d0 100644 (file)
--- a/lash.c
+++ b/lash.c
@@ -947,6 +947,7 @@ int shell_main(int argc, char **argv)
        getcwd(cwd, sizeof(cwd));
 
 #ifdef BB_FEATURE_SH_COMMAND_EDITING
+       cmdedit_init();
        signal(SIGWINCH, win_changed);
        win_changed(0);
 #endif
index 00e5a171bf5208c8a6d2c559d3c5fe71ef65f16c..4cbe7e17b088b2c105dda17a1036d3d8f3c0e2b0 100644 (file)
--- a/length.c
+++ b/length.c
@@ -9,6 +9,6 @@ extern int length_main(int argc, char **argv)
        if (argc != 2 || **(argv + 1) == '-') {
                usage("length string\n");
        }
-       printf("%d\n", strlen(argv[1]));
+       printf("%lu\n", (long)strlen(argv[1]));
        return (TRUE);
 }
index d01725329e923fb7ca7cfcaad523732731232f7d..bc5c03e62fe546e6330c090ecbd650b6bdc2339b 100644 (file)
@@ -25,7 +25,9 @@
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
-#include <sys/syscall.h>
+#define __LIBRARY__
+#include <asm/unistd.h>
+/* #include <sys/syscall.h> */
 
 
 
diff --git a/more.c b/more.c
index f8421490588ad1c4a43727c1d6ba5d9ef7de6231..20aa37095a416e4abf50c7b359b83b328196d674 100644 (file)
--- a/more.c
+++ b/more.c
 
 static const char more_usage[] = "more [file ...]\n";
 
+/* ED: sparc termios is broken: revert back to old termio handling. */
 #ifdef BB_FEATURE_USE_TERMIOS
 
-#include <termio.h>
+#if #cpu(sparc)
+#      include <termio.h>
+#      define termios termio
+#      define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp)
+#      define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp)
+#else
+#      include <termios.h>
+#      define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp)
+#      define getTermSettings(fd,argp) tcgetattr(fd, argp);
+#endif
 
 FILE *cin;
-/* sparc and other have broken termios support: use old termio handling. */
-struct termio initial_settings, new_settings;
+struct termios initial_settings, new_settings;
 
 void gotsig(int sig)
 {
-       ioctl(fileno(cin), TCSETAF, &initial_settings);
+       setTermSettings(fileno(cin), &initial_settings);
        fprintf(stdout, "\n");
        exit(TRUE);
 }
@@ -98,11 +107,11 @@ extern int more_main(int argc, char **argv)
                cin = fopen("/dev/tty", "r");
                if (!cin)
                        cin = fopen("/dev/console", "r");
-               ioctl(fileno(cin), TCGETA, &initial_settings);
+               getTermSettings(fileno(cin), &initial_settings);
                new_settings = initial_settings;
                new_settings.c_lflag &= ~ICANON;
                new_settings.c_lflag &= ~ECHO;
-               ioctl(fileno(cin), TCSETAF, &new_settings);
+               setTermSettings(fileno(cin), &new_settings);
 
 #ifdef BB_FEATURE_AUTOWIDTH
                ioctl(fileno(stdout), TIOCGWINSZ, &win);
index ef6503aeb2547b2f3080b882fdd4a3bb0db197f6..dca4c3cfe8e1b5bea0de3ea34d174d48fdd0b1c3 100644 (file)
@@ -1,6 +1,6 @@
 /* vi: set sw=4 ts=4: */
 /*
- * $Id: ping.c,v 1.12 2000/04/13 18:49:43 erik Exp $
+ * $Id: ping.c,v 1.13 2000/04/21 01:26:49 erik Exp $
  * Mini ping implementation for busybox
  *
  * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -248,7 +248,7 @@ static void sendping(int ign)
                if (i < 0)
                        perror("ping");
                fprintf(stderr, "ping wrote %d chars; %d expected\n", i,
-                               sizeof(packet));
+                               (int)sizeof(packet));
                exit(1);
        }
 
@@ -393,7 +393,7 @@ static void ping(char *host)
        /* listen for replies */
        while (1) {
                struct sockaddr_in from;
-               size_t fromlen = sizeof(from);
+               socklen_t fromlen = (socklen_t) sizeof(from);
                int c;
 
                if ((c = recvfrom(pingsock, packet, sizeof(packet), 0,
diff --git a/ping.c b/ping.c
index ef6503aeb2547b2f3080b882fdd4a3bb0db197f6..dca4c3cfe8e1b5bea0de3ea34d174d48fdd0b1c3 100644 (file)
--- a/ping.c
+++ b/ping.c
@@ -1,6 +1,6 @@
 /* vi: set sw=4 ts=4: */
 /*
- * $Id: ping.c,v 1.12 2000/04/13 18:49:43 erik Exp $
+ * $Id: ping.c,v 1.13 2000/04/21 01:26:49 erik Exp $
  * Mini ping implementation for busybox
  *
  * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -248,7 +248,7 @@ static void sendping(int ign)
                if (i < 0)
                        perror("ping");
                fprintf(stderr, "ping wrote %d chars; %d expected\n", i,
-                               sizeof(packet));
+                               (int)sizeof(packet));
                exit(1);
        }
 
@@ -393,7 +393,7 @@ static void ping(char *host)
        /* listen for replies */
        while (1) {
                struct sockaddr_in from;
-               size_t fromlen = sizeof(from);
+               socklen_t fromlen = (socklen_t) sizeof(from);
                int c;
 
                if ((c = recvfrom(pingsock, packet, sizeof(packet), 0,
diff --git a/rmmod.c b/rmmod.c
index d01725329e923fb7ca7cfcaad523732731232f7d..bc5c03e62fe546e6330c090ecbd650b6bdc2339b 100644 (file)
--- a/rmmod.c
+++ b/rmmod.c
@@ -25,7 +25,9 @@
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
-#include <sys/syscall.h>
+#define __LIBRARY__
+#include <asm/unistd.h>
+/* #include <sys/syscall.h> */
 
 
 
diff --git a/sh.c b/sh.c
index 97db8afafad9e7b2850734cb66d556642dcca4b0..b96b46456814a4e36e6d5d9458c2b39fbf06f7d0 100644 (file)
--- a/sh.c
+++ b/sh.c
@@ -947,6 +947,7 @@ int shell_main(int argc, char **argv)
        getcwd(cwd, sizeof(cwd));
 
 #ifdef BB_FEATURE_SH_COMMAND_EDITING
+       cmdedit_init();
        signal(SIGWINCH, win_changed);
        win_changed(0);
 #endif
index ebc6b969653b89b5110dfc563c15eeed0ec098e7..e4c88c265ac744165d475cb5f3cced4cf2973581 100644 (file)
@@ -39,7 +39,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
-#include <termio.h>
+#include <sys/ioctl.h>
 #include <ctype.h>
 #include <signal.h>
 
 
 static struct history *his_front = NULL;       /* First element in command line list */
 static struct history *his_end = NULL; /* Last element in command line list */
-static struct termio old_term, new_term;       /* Current termio and the previous termio before starting ash */
+
+/* ED: sparc termios is broken: revert back to old termio handling. */
+#ifdef BB_FEATURE_USE_TERMIOS
+
+#if #cpu(sparc)
+#      include <termio.h>
+#      define termios termio
+#      define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp)
+#      define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp)
+#else
+#      include <termios.h>
+#      define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp)
+#      define getTermSettings(fd,argp) tcgetattr(fd, argp);
+#endif
+
+/* Current termio and the previous termio before starting sh */
+struct termios initial_settings, new_settings;
+#endif
+
+
 
 static int cmdedit_termw = 80;  /* actual terminal width */
 static int cmdedit_scroll = 27; /* width of EOL scrolling region */
@@ -84,14 +103,15 @@ void cmdedit_reset_term(void)
 {
        if (reset_term)
                /* sparc and other have broken termios support: use old termio handling. */
-               ioctl(fileno(stdin), TCSETA, (void *) &old_term);
+               setTermSettings(fileno(stdin), (void*) &initial_settings);
 }
 
 void clean_up_and_die(int sig)
 {
        cmdedit_reset_term();
        fprintf(stdout, "\n");
-       exit(TRUE);
+       if (sig!=SIGINT)
+               exit(TRUE);
 }
 
 /* Go to HOME position */
@@ -233,7 +253,7 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches)
        return (matches);
 }
 
-void input_tab(char* command, int outputFd, int *cursor, int *len)
+void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
 {
        /* Do TAB completion */
        static int num_matches=0;
@@ -379,19 +399,17 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
 
        memset(command, 0, sizeof(command));
        if (!reset_term) {
-               /* sparc and other have broken termios support: use old termio handling. */
-               ioctl(inputFd, TCGETA, (void *) &old_term);
-               memcpy(&new_term, &old_term, sizeof(struct termio));
-
-               new_term.c_cc[VMIN] = 1;
-               new_term.c_cc[VTIME] = 0;
-               new_term.c_lflag &= ~ICANON;    /* unbuffered input */
-               new_term.c_lflag &= ~ECHO;
+               
+               getTermSettings(inputFd, (void*) &initial_settings);
+               memcpy(&new_settings, &initial_settings, sizeof(struct termios));
+               new_settings.c_cc[VMIN] = 1;
+               new_settings.c_cc[VTIME] = 0;
+               new_settings.c_cc[VINTR] = _POSIX_VDISABLE; /* Turn off CTRL-C, so we can trap it */
+               new_settings.c_lflag &= ~ICANON;        /* unbuffered input */
+               new_settings.c_lflag &= ~(ECHO|ECHOCTL|ECHONL); /* Turn off echoing */
                reset_term = 1;
-               ioctl(inputFd, TCSETA, (void *) &new_term);
-       } else {
-               ioctl(inputFd, TCSETA, (void *) &new_term);
        }
+       setTermSettings(inputFd, (void*) &new_settings);
 
        memset(command, 0, BUFSIZ);
 
@@ -399,6 +417,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
 
                if ((ret = read(inputFd, &c, 1)) < 1)
                        return;
+               //fprintf(stderr, "got a '%c' (%d)\n", c, c);
 
                switch (c) {
                case '\n':
@@ -414,6 +433,21 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
                case 2:
                        /* Control-b -- Move back one character */
                        input_backward(outputFd, &cursor);
+                       break;
+               case 3:
+                       /* Control-c -- leave the current line, 
+                        * and start over on the next line */ 
+
+                       /* Go to the next line */
+                       xwrite(outputFd, "\n", 1);
+
+                       /* Rewrite the prompt */
+                       xwrite(outputFd, prompt, strlen(prompt));
+
+                       /* Reset the command string */
+                       memset(command, 0, sizeof(command));
+                       len = cursor = 0;
+
                        break;
                case 4:
                        /* Control-d -- Delete one character, or exit 
@@ -435,12 +469,12 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
                        break;
                case '\b':
                case DEL:
-                       /* control-h and DEL */
+                       /* Control-h and DEL */
                        input_backspace(command, outputFd, &cursor, &len);
                        break;
                case '\t':
 #ifdef BB_FEATURE_SH_TAB_COMPLETION
-                       input_tab(command, outputFd, &cursor, &len);
+                       input_tab(command, prompt, outputFd, &cursor, &len);
 #endif
                        break;
                case 14:
@@ -591,8 +625,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
        }
 
        nr = len + 1;
-       /* sparc and other have broken termios support: use old termio handling. */
-       ioctl(inputFd, TCSETA, (void *) &old_term);
+       setTermSettings(inputFd, (void *) &initial_settings);
        reset_term = 0;
 
 
@@ -644,6 +677,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
 extern void cmdedit_init(void)
 {
        atexit(cmdedit_reset_term);
+       signal(SIGKILL, clean_up_and_die);
        signal(SIGINT, clean_up_and_die);
        signal(SIGQUIT, clean_up_and_die);
        signal(SIGTERM, clean_up_and_die);
index 0e465e50e3a503d4eb088da46edbec75e8efe5fd..9ac7daca3c338168bee805d39386e3fecbca81b5 100644 (file)
@@ -10,6 +10,7 @@
 
 typedef size_t (*cmdedit_strwidth_proc)(char *);
 
+void cmdedit_init(void);
 void cmdedit_read_input(char* promptStr, char* command);               /* read a line of input */
 void cmdedit_setwidth(int);            /* specify width of screen */
 void cmdedit_histadd(char *);          /* adds entries to hist */
@@ -21,6 +22,7 @@ extern int    (*cmdedit_tab_hook)(char *, int, int *);
 
 #else  /* not __STDC__ */
 
+void cmdedit_init(void);
 void cmdedit_read_input(char* promptStr, char* command);
 void cmdedit_setwidth();
 void cmdedit_histadd();
index 97db8afafad9e7b2850734cb66d556642dcca4b0..b96b46456814a4e36e6d5d9458c2b39fbf06f7d0 100644 (file)
@@ -947,6 +947,7 @@ int shell_main(int argc, char **argv)
        getcwd(cwd, sizeof(cwd));
 
 #ifdef BB_FEATURE_SH_COMMAND_EDITING
+       cmdedit_init();
        signal(SIGWINCH, win_changed);
        win_changed(0);
 #endif
index 4ebd2a28a48be0964ac6356c4e3d3fa27efbf5ab..0d400e5353f699b74d0e03b5b95d92e579b04b36 100644 (file)
@@ -171,7 +171,8 @@ static void doSyslogd (void) __attribute__ ((noreturn));
 static void doSyslogd (void)
 {
        struct sockaddr_un sunx;
-       size_t addrLength;
+       socklen_t addrLength;
+
 
        int sock_fd;
        fd_set fds;
index 4ebd2a28a48be0964ac6356c4e3d3fa27efbf5ab..0d400e5353f699b74d0e03b5b95d92e579b04b36 100644 (file)
--- a/syslogd.c
+++ b/syslogd.c
@@ -171,7 +171,8 @@ static void doSyslogd (void) __attribute__ ((noreturn));
 static void doSyslogd (void)
 {
        struct sockaddr_un sunx;
-       size_t addrLength;
+       socklen_t addrLength;
+
 
        int sock_fd;
        fd_set fds;
diff --git a/tar.c b/tar.c
index 2284fd06d71e008e0f57b0d0904385853a14f08a..0177d5188b51e18114505f3a3d7688c6154b40e5 100644 (file)
--- a/tar.c
+++ b/tar.c
@@ -608,7 +608,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
                                len1=snprintf(buf, sizeof(buf), "%ld,%-ld ", 
                                                header.devmajor, header.devminor);
                        } else {
-                               len1=snprintf(buf, sizeof(buf), "%d ", header.size);
+                               len1=snprintf(buf, sizeof(buf), "%lu ", (long)header.size);
                        }
                        /* Jump through some hoops to make the columns match up */
                        for(;(len+len1)<31;len++)
index f8421490588ad1c4a43727c1d6ba5d9ef7de6231..20aa37095a416e4abf50c7b359b83b328196d674 100644 (file)
 
 static const char more_usage[] = "more [file ...]\n";
 
+/* ED: sparc termios is broken: revert back to old termio handling. */
 #ifdef BB_FEATURE_USE_TERMIOS
 
-#include <termio.h>
+#if #cpu(sparc)
+#      include <termio.h>
+#      define termios termio
+#      define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp)
+#      define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp)
+#else
+#      include <termios.h>
+#      define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp)
+#      define getTermSettings(fd,argp) tcgetattr(fd, argp);
+#endif
 
 FILE *cin;
-/* sparc and other have broken termios support: use old termio handling. */
-struct termio initial_settings, new_settings;
+struct termios initial_settings, new_settings;
 
 void gotsig(int sig)
 {
-       ioctl(fileno(cin), TCSETAF, &initial_settings);
+       setTermSettings(fileno(cin), &initial_settings);
        fprintf(stdout, "\n");
        exit(TRUE);
 }
@@ -98,11 +107,11 @@ extern int more_main(int argc, char **argv)
                cin = fopen("/dev/tty", "r");
                if (!cin)
                        cin = fopen("/dev/console", "r");
-               ioctl(fileno(cin), TCGETA, &initial_settings);
+               getTermSettings(fileno(cin), &initial_settings);
                new_settings = initial_settings;
                new_settings.c_lflag &= ~ICANON;
                new_settings.c_lflag &= ~ECHO;
-               ioctl(fileno(cin), TCSETAF, &new_settings);
+               setTermSettings(fileno(cin), &new_settings);
 
 #ifdef BB_FEATURE_AUTOWIDTH
                ioctl(fileno(stdout), TIOCGWINSZ, &win);