-List of the authors of code contained in busybox.
+List of the authors of code contained in BusyBox.
-If you should be listed here, or the description of
-what you have done needs more detail, or is incorect,
-_please_ let me know.
+If you have code in BusyBox, you should be listed here. If you should be
+listed, or the description of what you have done needs more detail, or is
+incorect, _please_ let me know.
-Erik
Original author of BusyBox. His code is still in many apps.
John Beppu <beppu@lineo.com>
- du, head, tee
+ du, head, nslookup, sort, tee, uniq
Brian Candler <B.Candler@pobox.com>
tiny-ls(ls)
the common error handling saves a few bytes. Thanks to
Bob Tinsley <bob@earthrise.demon.co.uk> for the patch.
* Fix "+" parsing bug in date, from "Merle F. McClelland" <mfm@cts.com>.
-
+ * BusyBox's bss size has been majorly reduced (was 384668, is now 28740).
-Erik Andersen
Busybox was begun to support the Debian Rescue/Install disks, but it
also makes an excellent environment for any small or embedded system.
-As of version 0.20 there is a version number. : ) Also as of version
-0.20, BB is now modularized to easily allow you to build of only the
-BB parts you need, thereby reducing binary size. To turn off unwanted
-Busybox components, simply edit the file busybox.def.h and comment out
-the parts you do not need using C++ style (//) comments.
+As of version 0.20 there is a version number. : ) Also as of version 0.20, BB
+is now modularized to easily allow you to build only the BB parts you need,
+thereby reducing binary size. To turn off unwanted Busybox components, simply
+edit the file busybox.def.h and comment out the parts you do not need using C++
+style (//) comments.
After the build is complete a busybox.links file is generated which is
then used by 'make install' to create symlinks to the busybox binary
for all compiled in functions. By default, 'make install' will place
the symlink forest into `pwd`/_install unless you have defined the
-PREFIX environment variable.
+PREFIX environment variable (i.e. make PREFIX="/tmp/foo" install)
Please feed suggestions, bug reports, insults, and bribes back to:
Erik Andersen
{"sh", shell_main, _BB_DIR_BIN},
#endif
#ifdef BB_SFDISK
- {"fdisk", sfdisk_main, _BB_DIR_SBIN},
-#ifdef BB_SFDISK
-#endif
{"sfdisk", sfdisk_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SLEEP
fprintf(stderr, "Usage: busybox [function] [arguments]...\n");
fprintf(stderr, " or: [function] [arguments]...\n\n");
fprintf(stderr,
- "\tMost people will create a link to busybox for each function\n"
- "\tname, and busybox will act like whatever you invoke it as.\n");
+ "\tBusyBox is a multi-call binary that combines many common Unix utilities into a\n"
+ "\tsingle executable. Most people will create a link to busybox for each function\n"
+ "\tthey wish to use, and BusyBox will act like whatever it was invoked as.\n");
fprintf(stderr, "\nCurrently defined functions:\n");
while (a->name != 0) {
/* vi: set sw=4 ts=4: */
-/* zcat : stripped version based on gzip sources
- Sven Rudolph <sr1@inf.tu-dresden.de>
- */
+/*
+ * Gzip implementation for busybox
+ *
+ * Based on GNU gzip Copyright (C) 1992-1993 Jean-loup Gailly.
+ *
+ * Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
+ * based on gzip sources
+ *
+ * Adjusted further by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+ * to support files as well as stdin/stdout, and to generally behave itself wrt
+ * command line handling.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
#include "internal.h"
-#define bb_need_name_too_long
-#define BB_DECLARE_EXTERN
-#include "messages.c"
-
static const char gunzip_usage[] =
"gunzip [OPTION]... FILE\n\n"
"Uncompress FILE (or standard input if FILE is '-').\n\n"
"\t-c\tWrite output to standard output\n"
"\t-t\tTest compressed file integrity\n";
+
+ /* These defines are very important for BusyBox. Without these,
+ * huge chunks of ram are pre-allocated making the BusyBox bss
+ * size Freaking Huge(tm), which is a bad thing.*/
+#define SMALL_MEM
+#define DYN_ALLOC
+
+#define bb_need_name_too_long
+#define BB_DECLARE_EXTERN
+#include "messages.c"
+
+
/* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
* Copyright (C) 1992-1993 Jean-loup Gailly
* The unzip code was written and put in the public domain by Mark Adler.
#define get_char() get_byte()
#define put_char(c) put_byte(c)
-/* #include "gzip.h" */
-
-/* gzip.h -- common declarations for all gzip modules
- * Copyright (C) 1992-1993 Jean-loup Gailly.
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-#if defined(__STDC__) || defined(PROTO)
-# define OF(args) args
-#else
-# define OF(args) ()
-#endif
-
-#ifdef __STDC__
-typedef void *voidp;
-#else
-typedef char *voidp;
-#endif
/* I don't like nested includes, but the string and io functions are used
* too often
# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
# include <memory.h>
# endif
-# define memzero(s, n) memset ((voidp)(s), 0, (n))
+# define memzero(s, n) memset ((void *)(s), 0, (n))
#else
# include <strings.h>
# define strchr index
#define WARN(msg) {fprintf msg ; \
if (exit_code == OK) exit_code = WARNING;}
-#define do_exit(c) exit(c)
-
-
/* in unzip.c */
-extern int unzip OF((int in, int out));
+extern int unzip (int in, int out);
/* in gzip.c */
-RETSIGTYPE abort_gzip OF((void));
+RETSIGTYPE abort_gzip (void);
/* in deflate.c */
-void lm_init OF((int pack_level, ush * flags));
-ulg deflate OF((void));
+void lm_init (int pack_level, ush * flags);
+ulg deflate (void);
/* in trees.c */
-void ct_init OF((ush * attr, int *method));
-int ct_tally OF((int dist, int lc));
-ulg flush_block OF((char *buf, ulg stored_len, int eof));
+void ct_init (ush * attr, int *method);
+int ct_tally (int dist, int lc);
+ulg flush_block (char *buf, ulg stored_len, int eof);
/* in bits.c */
-void bi_init OF((file_t zipfile));
-void send_bits OF((int value, int length));
-unsigned bi_reverse OF((unsigned value, int length));
-void bi_windup OF((void));
-void copy_block OF((char *buf, unsigned len, int header));
-extern int (*read_buf) OF((char *buf, unsigned size));
+void bi_init (file_t zipfile);
+void send_bits (int value, int length);
+unsigned bi_reverse (unsigned value, int length);
+void bi_windup (void);
+void copy_block (char *buf, unsigned len, int header);
+extern int (*read_buf) (char *buf, unsigned size);
/* in util.c: */
-extern int copy OF((int in, int out));
-extern ulg updcrc OF((uch * s, unsigned n));
-extern void clear_bufs OF((void));
-extern int fill_inbuf OF((int eof_ok));
-extern void flush_outbuf OF((void));
-extern void flush_window OF((void));
-extern void write_buf OF((int fd, voidp buf, unsigned cnt));
+extern int copy (int in, int out);
+extern ulg updcrc (uch * s, unsigned n);
+extern void clear_bufs (void);
+extern int fill_inbuf (int eof_ok);
+extern void flush_outbuf (void);
+extern void flush_window (void);
+extern void write_buf (int fd, void * buf, unsigned cnt);
#ifndef __linux__
-extern char *basename OF((char *fname));
+extern char *basename (char *fname);
#endif /* not __linux__ */
-extern void read_error OF((void));
-extern void write_error OF((void));
+extern void read_error (void);
+extern void write_error (void);
/* in inflate.c */
-extern int inflate OF((void));
+extern int inflate (void);
/* #include "lzw.h" */
extern int maxbits; /* max bits per code for LZW */
extern int block_mode; /* block compress mode -C compatible with 2.0 */
-extern int lzw OF((int in, int out));
-extern int unlzw OF((int in, int out));
+extern int lzw (int in, int out);
+extern int unlzw (int in, int out);
/* #include "revision.h" */
#if !defined(S_ISREG) && defined(S_IFREG)
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
-typedef RETSIGTYPE(*sig_type) OF((int));
+typedef RETSIGTYPE(*sig_type) (int);
#ifndef O_BINARY
# define O_BINARY 0 /* creation mode for open() */
#ifdef NO_OFF_T
typedef long off_t;
-off_t lseek OF((int fd, off_t offset, int whence));
+off_t lseek (int fd, off_t offset, int whence);
#endif
/* local functions */
-local int get_method OF((int in));
+local int get_method (int in);
#define strequ(s1, s2) (strcmp((s1),(s2)) == 0)
usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) {
fprintf(stderr, name_too_long, "gunzip");
- do_exit(WARNING);
+ exit(WARNING);
}
strcpy(ifname, *argv);
inFileNum = open(ifname, O_RDONLY);
if (inFileNum < 0) {
perror(ifname);
- do_exit(WARNING);
+ exit(WARNING);
}
/* Get the time stamp on the input file. */
result = stat(ifname, &statBuf);
if (result < 0) {
perror(ifname);
- do_exit(WARNING);
+ exit(WARNING);
}
ifile_size = statBuf.st_size;
}
/* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) {
fprintf(stderr, name_too_long, "gunzip");
- do_exit(WARNING);
+ exit(WARNING);
}
strcpy(ofname, ifname);
pos = strstr(ofname, ".gz");
#endif
if (outFileNum < 0) {
perror(ofname);
- do_exit(WARNING);
+ exit(WARNING);
}
/* Set permissions on the file */
fchmod(outFileNum, statBuf.st_mode);
exit(FALSE);
}
}
- do_exit(exit_code);
+ exit(exit_code);
}
*/
RETSIGTYPE abort_gzip()
{
- do_exit(ERROR);
+ exit(ERROR);
}
/* unzip.c -- decompress files in gzip or pkzip format.
ofd = out;
method = get_method(ifd);
if (method < 0) {
- do_exit(exit_code); /* error message already emitted */
+ exit(exit_code); /* error message already emitted */
}
updcrc(NULL, 0); /* initialize crc */
*/
void write_buf(fd, buf, cnt)
int fd;
-voidp buf;
+void * buf;
unsigned cnt;
{
unsigned n;
write_error();
}
cnt -= n;
- buf = (voidp) ((char *) buf + n);
+ buf = (void *) ((char *) buf + n);
}
}
# define const
# endif
-int strspn OF((const char *s, const char *accept));
-int strcspn OF((const char *s, const char *reject));
+int strspn (const char *s, const char *accept);
+int strcspn (const char *s, const char *reject);
/* ========================================================================
* Return the length of the maximum initial segment
/* Function prototypes */
-int huft_build OF((unsigned *, unsigned, unsigned, ush *, ush *,
- struct huft **, int *));
-int huft_free OF((struct huft *));
-int inflate_codes OF((struct huft *, struct huft *, int, int));
-int inflate_stored OF((void));
-int inflate_fixed OF((void));
-int inflate_dynamic OF((void));
-int inflate_block OF((int *));
-int inflate OF((void));
+int huft_build (unsigned *, unsigned, unsigned, ush *, ush *,
+ struct huft **, int *);
+int huft_free (struct huft *);
+int inflate_codes (struct huft *, struct huft *, int, int);
+int inflate_stored (void);
+int inflate_fixed (void);
+int inflate_dynamic (void);
+int inflate_block (int *);
+int inflate (void);
/* The inflate algorithm uses a sliding 32K byte window on the uncompressed
/* vi: set sw=4 ts=4: */
-/* gzip.c -- this is a stripped down version of gzip I put into busybox, it does
- * only standard in to standard out with -9 compression. It also requires the
- * zcat module for some important functions.
+/*
+ * Gzip implementation for busybox
+ *
+ * Based on GNU gzip Copyright (C) 1992-1993 Jean-loup Gailly.
+ *
+ * Originally adjusted for busybox by Charles P. Wright <cpw@unix.asb.com>
+ * "this is a stripped down version of gzip I put into busybox, it does
+ * only standard in to standard out with -9 compression. It also requires
+ * the zcat module for some important functions."
+ *
+ * Adjusted further by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+ * to support files as well as stdin/stdout, and to generally behave itself wrt
+ * command line handling.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Charles P. Wright <cpw@unix.asb.com>
*/
+
#include "internal.h"
-#ifdef BB_GZIP
-//#ifndef BB_ZCAT
-//#error you need zcat to have gzip support!
-//#endif
+/* These defines are very important for BusyBox. Without these,
+ * huge chunks of ram are pre-allocated making the BusyBox bss
+ * size Freaking Huge(tm), which is a bad thing.*/
+#define SMALL_MEM
+#define DYN_ALLOC
+
static const char gzip_usage[] =
"gzip [OPTION]... FILE\n\n"
"\t-c\tWrite output to standard output instead of FILE.gz\n";
-/* gzip.h -- common declarations for all gzip modules
- * Copyright (C) 1992-1993 Jean-loup Gailly.
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-#if defined(__STDC__) || defined(PROTO)
-# define OF(args) args
-#else
-# define OF(args) ()
-#endif
-
-#ifdef __STDC__
-typedef void *voidp;
-#else
-typedef char *voidp;
-#endif
-
/* I don't like nested includes, but the string and io functions are used
* too often
*/
#include <stdio.h>
-#if !defined(NO_STRING_H) || defined(STDC_HEADERS)
-# include <string.h>
-# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
-# include <memory.h>
-# endif
-# define memzero(s, n) memset ((voidp)(s), 0, (n))
-#else
-# include <strings.h>
-# define strchr index
-# define strrchr rindex
-# define memcpy(d, s, n) bcopy((s), (d), (n))
-# define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
-# define memzero(s, n) bzero((s), (n))
-#endif
+#include <string.h>
+#define memzero(s, n) memset ((void *)(s), 0, (n))
#ifndef RETSIGTYPE
# define RETSIGTYPE void
#endif
#ifdef DYN_ALLOC
-# define EXTERN(type, array) extern type * near array
-# define DECLARE(type, array, size) type * near array
+# define EXTERN(type, array) extern type * array
+# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
- array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
+ array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
if (array == NULL) errorMsg("insufficient memory"); \
}
-# define FREE(array) {if (array != NULL) fcfree(array), array=NULL;}
+# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
# define EXTERN(type, array) extern type array[]
# define DECLARE(type, array, size) type array[size]
/* in zip.c: */
-extern int zip OF((int in, int out));
-extern int file_read OF((char *buf, unsigned size));
+extern int zip (int in, int out);
+extern int file_read (char *buf, unsigned size);
/* in unzip.c */
-extern int unzip OF((int in, int out));
-extern int check_zipfile OF((int in));
+extern int unzip (int in, int out);
+extern int check_zipfile (int in);
/* in unpack.c */
-extern int unpack OF((int in, int out));
+extern int unpack (int in, int out);
/* in unlzh.c */
-extern int unlzh OF((int in, int out));
+extern int unlzh (int in, int out);
/* in gzip.c */
-RETSIGTYPE abort_gzip OF((void));
+RETSIGTYPE abort_gzip (void);
/* in deflate.c */
-void lm_init OF((ush * flags));
-ulg deflate OF((void));
+void lm_init (ush * flags);
+ulg deflate (void);
/* in trees.c */
-void ct_init OF((ush * attr, int *method));
-int ct_tally OF((int dist, int lc));
-ulg flush_block OF((char *buf, ulg stored_len, int eof));
+void ct_init (ush * attr, int *method);
+int ct_tally (int dist, int lc);
+ulg flush_block (char *buf, ulg stored_len, int eof);
/* in bits.c */
-void bi_init OF((file_t zipfile));
-void send_bits OF((int value, int length));
-unsigned bi_reverse OF((unsigned value, int length));
-void bi_windup OF((void));
-void copy_block OF((char *buf, unsigned len, int header));
-extern int (*read_buf) OF((char *buf, unsigned size));
+void bi_init (file_t zipfile);
+void send_bits (int value, int length);
+unsigned bi_reverse (unsigned value, int length);
+void bi_windup (void);
+void copy_block (char *buf, unsigned len, int header);
+extern int (*read_buf) (char *buf, unsigned size);
/* in util.c: */
-extern int copy OF((int in, int out));
-extern ulg updcrc OF((uch * s, unsigned n));
-extern void clear_bufs OF((void));
-extern int fill_inbuf OF((int eof_ok));
-extern void flush_outbuf OF((void));
-extern void flush_window OF((void));
-extern void write_buf OF((int fd, voidp buf, unsigned cnt));
-extern char *strlwr OF((char *s));
-extern char *add_envopt OF((int *argcp, char ***argvp, char *env));
-extern void read_error OF((void));
-extern void write_error OF((void));
-extern void display_ratio OF((long num, long den, FILE * file));
+extern int copy (int in, int out);
+extern ulg updcrc (uch * s, unsigned n);
+extern void clear_bufs (void);
+extern int fill_inbuf (int eof_ok);
+extern void flush_outbuf (void);
+extern void flush_window (void);
+extern void write_buf (int fd, void * buf, unsigned cnt);
+extern char *strlwr (char *s);
+extern char *add_envopt (int *argcp, char ***argvp, char *env);
+extern void read_error (void);
+extern void write_error (void);
+extern void display_ratio (long num, long den, FILE * file);
/* in inflate.c */
-extern int inflate OF((void));
+extern int inflate (void);
/* lzw.h -- define the lzw functions.
* Copyright (C) 1992-1993 Jean-loup Gailly.
* are always zero.
*/
-int (*read_buf) OF((char *buf, unsigned size));
+int (*read_buf) (char *buf, unsigned size);
/* Current input function. Set to mem_read for in-memory compression */
/* ===========================================================================
* Prototypes for local functions.
*/
-local void fill_window OF((void));
+local void fill_window (void);
-int longest_match OF((IPos cur_match));
+int longest_match (IPos cur_match);
#ifdef ASMV
-void match_init OF((void)); /* asm code initialization */
+void match_init (void); /* asm code initialization */
#endif
#ifdef DEBUG
-local void check_match OF((IPos start, IPos match, int length));
+local void check_match (IPos start, IPos match, int length);
#endif
/* ===========================================================================
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
-typedef RETSIGTYPE(*sig_type) OF((int));
+typedef RETSIGTYPE(*sig_type) (int);
#ifndef O_BINARY
# define O_BINARY 0 /* creation mode for open() */
#ifdef NO_OFF_T
typedef long off_t;
-off_t lseek OF((int fd, off_t offset, int whence));
+off_t lseek (int fd, off_t offset, int whence);
#endif
/* Separator for file name parts (see shorten_name()) */
* Local (static) routines in this file.
*/
-local void init_block OF((void));
-local void pqdownheap OF((ct_data near * tree, int k));
-local void gen_bitlen OF((tree_desc near * desc));
-local void gen_codes OF((ct_data near * tree, int max_code));
-local void build_tree OF((tree_desc near * desc));
-local void scan_tree OF((ct_data near * tree, int max_code));
-local void send_tree OF((ct_data near * tree, int max_code));
-local int build_bl_tree OF((void));
-local void send_all_trees OF((int lcodes, int dcodes, int blcodes));
-local void compress_block OF((ct_data near * ltree, ct_data near * dtree));
-local void set_file_type OF((void));
+local void init_block (void);
+local void pqdownheap (ct_data near * tree, int k);
+local void gen_bitlen (tree_desc near * desc);
+local void gen_codes (ct_data near * tree, int max_code);
+local void build_tree (tree_desc near * desc);
+local void scan_tree (ct_data near * tree, int max_code);
+local void send_tree (ct_data near * tree, int max_code);
+local int build_bl_tree (void);
+local void send_all_trees (int lcodes, int dcodes, int blcodes);
+local void compress_block (ct_data near * ltree, ct_data near * dtree);
+local void set_file_type (void);
#ifndef DEBUG
/* Provide missing strspn and strcspn functions. */
-# ifndef __STDC__
-# define const
-# endif
-
-int strspn OF((const char *s, const char *accept));
-int strcspn OF((const char *s, const char *reject));
+int strspn (const char *s, const char *accept);
+int strcspn (const char *s, const char *reject);
/* ========================================================================
* Return the length of the maximum initial segment
isize += (ulg) len;
return (int) len;
}
-#endif
/*
* Mini tar implementation for busybox
*
- * Note, that as of BusyBox 0.43 tar has been completely rewritten from the
- * ground up. It still has remnents of the old code lying about, but it pretty
- * different (i.e. cleaner, less global variables, etc)
+ * Note, that as of BusyBox-0.43, tar has been completely rewritten from the
+ * ground up. It still has remnents of the old code lying about, but it is
+ * very different now (i.e. cleaner, less global variables, etc)
*
* Copyright (C) 2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
/*
* Mini basename implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
extern int basename_main(int argc, char **argv)
{
- char* s;
+ char* s, *s1;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage("basename [file ...]\n");
}
argv++;
+ s1=*argv+strlen(*argv)-1;
+ if (*s1 == '/')
+ *s1 = '\0';
s = strrchr(*argv, '/');
printf("%s\n", (s)? s + 1 : *argv);
exit(TRUE);
{"sh", shell_main, _BB_DIR_BIN},
#endif
#ifdef BB_SFDISK
- {"fdisk", sfdisk_main, _BB_DIR_SBIN},
-#ifdef BB_SFDISK
-#endif
{"sfdisk", sfdisk_main, _BB_DIR_SBIN},
#endif
#ifdef BB_SLEEP
fprintf(stderr, "Usage: busybox [function] [arguments]...\n");
fprintf(stderr, " or: [function] [arguments]...\n\n");
fprintf(stderr,
- "\tMost people will create a link to busybox for each function\n"
- "\tname, and busybox will act like whatever you invoke it as.\n");
+ "\tBusyBox is a multi-call binary that combines many common Unix utilities into a\n"
+ "\tsingle executable. Most people will create a link to busybox for each function\n"
+ "\tthey wish to use, and BusyBox will act like whatever it was invoked as.\n");
fprintf(stderr, "\nCurrently defined functions:\n");
while (a->name != 0) {
//
//
// BusyBox Applications
-//#define BB_BASENAME
+#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHROOT
#define BB_DF
#define BB_DIRNAME
#define BB_DMESG
-//#define BB_DUTMP
+#define BB_DUTMP
#define BB_DU
#define BB_ECHO
-//#define BB_FBSET
-//#define BB_FDFLUSH
+#define BB_FBSET
+#define BB_FDFLUSH
#define BB_FIND
#define BB_FREE
-//#define BB_FREERAMDISK
-//#define BB_FSCK_MINIX
+#define BB_FREERAMDISK
+#define BB_FSCK_MINIX
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
//#define BB_HALT
#define BB_HEAD
-//#define BB_HOSTID
+#define BB_HOSTID
#define BB_HOSTNAME
#define BB_INIT
// Don't bother turning BB_INSMOD on. It doesn't work.
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
-//#define BB_LENGTH
+#define BB_LENGTH
#define BB_LN
-//#define BB_LOADACM
-//#define BB_LOADFONT
-//#define BB_LOADKMAP
-//#define BB_LOGGER
+#define BB_LOADACM
+#define BB_LOADFONT
+#define BB_LOADKMAP
+#define BB_LOGGER
#define BB_LOGNAME
#define BB_LS
-//#define BB_LSMOD
-//#define BB_MAKEDEVS
-//#define BB_MKFS_MINIX
-//#define BB_MATH
+#define BB_LSMOD
+#define BB_MAKEDEVS
+#define BB_MKFS_MINIX
+#define BB_MATH
#define BB_MKDIR
-//#define BB_MKFIFO
+#define BB_MKFIFO
#define BB_MKNOD
#define BB_MKSWAP
-//#define BB_MNC
+#define BB_MNC
#define BB_MORE
#define BB_MOUNT
-//#define BB_NFSMOUNT
-//#define BB_MT
+#define BB_NFSMOUNT
+#define BB_MT
#define BB_NSLOOKUP
#define BB_PING
-#define BB_POWEROFF
-//#define BB_PRINTF
+//#define BB_POWEROFF
+#define BB_PRINTF
#define BB_PS
#define BB_PWD
-#define BB_REBOOT
+//#define BB_REBOOT
#define BB_RM
#define BB_RMDIR
-//#define BB_RMMOD
+#define BB_RMMOD
#define BB_SED
-//#define BB_SFDISK
+#define BB_SFDISK
#define BB_SH
#define BB_SLEEP
#define BB_SORT
#define BB_TEE
#define BB_TEST
// Don't turn BB_TELNET on. It doesn't work.
-#define BB_TELNET
+//#define BB_TELNET
#define BB_TOUCH
#define BB_TR
#define BB_TRUE_FALSE
//
//
// Turn this on to use Erik's very cool devps, devmtab,
-// etc. kernel drivers, thereby eliminating the need for
+// etc kernel drivers, thereby eliminating the need for
// the /proc filesystem and thereby saving lots and lots
// memory for more important things.
// You can't use this and USE_PROCFS at the same time...
//Enable init being called as /linuxrc
//#define BB_FEATURE_LINUXRC
//
-//Have init enable core dumping for child processed (for debugging only)
+//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//
// Allow init to permenently chroot, and umount the old root fs
#define BB_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" for excluding files
-//#define BB_FEATURE_TAR_EXCLUDE
+#define BB_FEATURE_TAR_EXCLUDE
//
//// Enable reverse sort
-//#define BB_FEATURE_SORT_REVERSE
+#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell
-//#define BB_FEATURE_SH_COMMAND_EDITING
+#define BB_FEATURE_SH_COMMAND_EDITING
//
-// Enable tab completion in the shell (not yet working very well)
+// Enable tab completion in the shell (not yet
+// working very well -- so don't turn this on)
//#define BB_FEATURE_SH_TAB_COMPLETION
//
//Turn on extra fbset options
-//#define BB_FEATURE_FBSET_FANCY
+#define BB_FEATURE_FBSET_FANCY
//
//
// End of Features List
/*
* Mini Cat implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini chown/chmod/chgrp implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini chroot implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini clear implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/* vi: set sw=4 ts=4: */
/*
- * Termios command line History and Editting for NetBSD sh (ash)
+ * Termios command line History and Editting, originally
+ * intended for NetBSD sh (ash)
* Copyright (c) 1999
* Main code: Adam Rogoyski <rogoyski@cs.utexas.edu>
* Etc: Dave Cinege <dcinege@psychosis.com>
- * Adjusted for busybox: Erik Andersen <andersee@debian.org>
+ * Majorly adjusted/re-written for busybox:
+ * Erik Andersen <andersee@debian.org>
*
* You may use this code as you wish, so long as the original author(s)
* are attributed in any redistributions of the source code.
void
cmdedit_setwidth(int w)
{
- if (w > 20) {
+ if (w > 20) {
cmdedit_termw = w;
cmdedit_scroll = w / 3;
- } else {
+ } else {
errorMsg("\n*** Error: minimum screen width is 21\n");
- }
+ }
}
+
void cmdedit_reset_term(void)
{
if (reset_term)
free((*hp)->s);
(*hp)->s = strdup(command);
*hp = (*hp)->n;
-
- cmdedit_redraw( NULL, hp->s, -2, -2);
-}
-
-#if 0
-/* prompt : if !=NULL, print the prompt
- * command: the command line to be displayed
- * where : where to display changes from.
- * -1 for no change, -2 for new line
- * cursor : desired location for the cursor.
- * -1 for Beginning of line.
- * -2 for End of Line,
- */
-static void
-cmdedit_redraw(char* prompt, char* command, int where, int cursor)
-{
- static char* last_command;
- int cmdedit_width;
-
- if (where == -2) {
- /* Rewrite the prompt and clean up static variables */
- xwrite(outputFd, "\n", 1);
- if (prompt) {
- strcpy(last_command, prompt);
- xwrite(outputFd, prompt, strlen(prompt));
- } else {
- last_command[0] = '\0';
- xwrite(outputFd, "# ", 2);
- }
- cmdedit_width = cmdedit_termw - cmdedit_strlen(prompt);
- } else if (strcmp(command, last_command) != 0) {
- strcpy(last_command, prompt);
- }
-
- /* erase old command from command line */
- len = strlen(command)-strlen(last_command);
- while (len>0)
- input_backspace(command, outputFd, &cursor, &len);
- input_home(outputFd, &cursor);
-
- /* Rewrite the command */
- xwrite(outputFd, command+where, len);
-
- /* Put the where it is supposed to be */
- for (cursor=len; cursor > where; cursor--)
- xwrite(outputFd, "\b", 1);
-
- /* write new command */
- strcpy(command, hp->s);
- len = strlen(hp->s);
- xwrite(outputFd, command+where, len);
- cursor = len;
}
-#endif
/*
* This function is used to grab a character buffer
* Mini clear implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
unicode utf8_to_ucs2(char *buf)
{
int utf_count = 0;
- long utf_char;
- unicode tc;
+ long utf_char = 0;
+ unicode tc = 0;
unsigned char c;
do {
/*
* Mini basename implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
extern int basename_main(int argc, char **argv)
{
- char* s;
+ char* s, *s1;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage("basename [file ...]\n");
}
argv++;
+ s1=*argv+strlen(*argv)-1;
+ if (*s1 == '/')
+ *s1 = '\0';
s = strrchr(*argv, '/');
printf("%s\n", (s)? s + 1 : *argv);
exit(TRUE);
/*
* Mini Cat implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini chroot implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini dd implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999, 2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
- * based in part on code taken from sash.
*
- * Copyright (c) 1999 by David I. Bell
- * Permission is granted to use, distribute, or modify this source,
- * provided that this copyright notice remains intact.
+ * Based in part on code taken from sash.
+ * Copyright (c) 1999 by David I. Bell
+ * Permission is granted to use, distribute, or modify this source,
+ * provided that this copyright notice remains intact.
*
* Permission to distribute this code under the GPL has been granted.
*
/*
* Mini df implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
*
#include <sys/stat.h>
#include <sys/vfs.h>
-static const char df_usage[] = "df [filesystem ...]\n"
-
- "\n" "\tPrint the filesystem space used and space available.\n";
+static const char df_usage[] = "df [filesystem ...]\n\n"
+ "Print the filesystem space used and space available.\n";
extern const char mtab_file[]; /* Defined in utility.c */
struct mntent *mountEntry;
int status;
+ if (**(argv + 1) == '-') {
+ usage(df_usage);
+ }
while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
* Mini du implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
exit(0);
}
-/* $Id: du.c,v 1.16 2000/03/04 21:19:32 erik Exp $ */
+/* $Id: du.c,v 1.17 2000/04/13 01:18:56 erik Exp $ */
/*
Local Variables:
c-file-style: "linux"
* Mini head implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
exit(0);
}
-/* $Id: head.c,v 1.8 2000/02/08 19:58:47 erik Exp $ */
+/* $Id: head.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
/*
* Mini ln implementation for busybox
*
- *
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini mkdir implementation for busybox
*
- *
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini rm implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini rmdir implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini sort implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
exit(0);
}
-/* $Id: sort.c,v 1.12 2000/03/04 21:19:32 erik Exp $ */
+/* $Id: sort.c,v 1.13 2000/04/13 01:18:56 erik Exp $ */
* Mini tee implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
exit(0);
}
-/* $Id: tee.c,v 1.8 2000/03/23 01:09:18 erik Exp $ */
+/* $Id: tee.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
* Mini touch implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini uniq implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
exit(0);
}
-/* $Id: uniq.c,v 1.7 2000/02/08 19:58:47 erik Exp $ */
+/* $Id: uniq.c,v 1.8 2000/04/13 01:18:56 erik Exp $ */
#include <utime.h>
#include <dirent.h>
#include <sys/param.h>
-#include <setjmp.h> /* Ok to use this since `ash' does, therefore it's in the libc subset already. */
+#include <setjmp.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
/*
* Mini dd implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999, 2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
- * based in part on code taken from sash.
*
- * Copyright (c) 1999 by David I. Bell
- * Permission is granted to use, distribute, or modify this source,
- * provided that this copyright notice remains intact.
+ * Based in part on code taken from sash.
+ * Copyright (c) 1999 by David I. Bell
+ * Permission is granted to use, distribute, or modify this source,
+ * provided that this copyright notice remains intact.
*
* Permission to distribute this code under the GPL has been granted.
*
/*
* Mini df implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
*
#include <sys/stat.h>
#include <sys/vfs.h>
-static const char df_usage[] = "df [filesystem ...]\n"
-
- "\n" "\tPrint the filesystem space used and space available.\n";
+static const char df_usage[] = "df [filesystem ...]\n\n"
+ "Print the filesystem space used and space available.\n";
extern const char mtab_file[]; /* Defined in utility.c */
struct mntent *mountEntry;
int status;
+ if (**(argv + 1) == '-') {
+ usage(df_usage);
+ }
while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
* Mini du implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
exit(0);
}
-/* $Id: du.c,v 1.16 2000/03/04 21:19:32 erik Exp $ */
+/* $Id: du.c,v 1.17 2000/04/13 01:18:56 erik Exp $ */
/*
Local Variables:
c-file-style: "linux"
#include "internal.h"
#include <stdio.h>
+#include <errno.h>
#include <utmp.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_io_error
+#include "messages.c"
static const char dutmp_usage[] = "dutmp\n"
"\n"
-
"\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
"\tdutmp /var/run/utmp\n";
extern int dutmp_main(int argc, char **argv)
{
- FILE *f = stdin;
+ FILE *f;
struct utmp ut;
- if ((argc < 2) || (**(argv + 1) == '-')) {
+ if (argc<2) {
+ f = stdin;
+ } else if (*argv[1] == '-' ) {
usage(dutmp_usage);
- }
-
- if (**(++argv) == 0) {
- f = fopen(*(++argv), "r");
- if (f < 0) {
- perror(*argv);
- exit(FALSE);
+ } else {
+ f = fopen(argv[1], "r");
+ if (f == NULL) {
+ fatalError(io_error, argv[1], strerror(errno));
}
}
- while (fread(&ut, 1, sizeof(struct utmp), f)) {
- // printf("%d:%d:%s:%s:%s:%s:%d:%d:%ld:%ld:%ld:%x\n",
+ while (fread(&ut, sizeof(struct utmp), 1, f)) {
printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
ut.ut_type, ut.ut_pid, ut.ut_line,
ut.ut_id, ut.ut_user, ut.ut_host,
* Mini sed implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* Modifications for addresses and append command have been
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
#endif
- fprintf(stderr, "Usage: fbset [options] [mode]\n");
- fprintf(stderr, "\tThe following options are recognized:\n");
+ fprintf(stderr, "Usage: fbset [options] [mode]\n\n");
+ fprintf(stderr, "Show and modify frame buffer device settings\n\n");
+ fprintf(stderr, "The following options are recognized:\n");
for (i = 0; g_cmdoptions[i].name; i++)
- fprintf(stderr, "\t\t%s\n", g_cmdoptions[i].name);
+ fprintf(stderr, "\t%s\n", g_cmdoptions[i].name);
exit(-1);
}
* Mini find implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini find implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini grep implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini free implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini grep implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/* vi: set sw=4 ts=4: */
-/* zcat : stripped version based on gzip sources
- Sven Rudolph <sr1@inf.tu-dresden.de>
- */
+/*
+ * Gzip implementation for busybox
+ *
+ * Based on GNU gzip Copyright (C) 1992-1993 Jean-loup Gailly.
+ *
+ * Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
+ * based on gzip sources
+ *
+ * Adjusted further by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+ * to support files as well as stdin/stdout, and to generally behave itself wrt
+ * command line handling.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
#include "internal.h"
-#define bb_need_name_too_long
-#define BB_DECLARE_EXTERN
-#include "messages.c"
-
static const char gunzip_usage[] =
"gunzip [OPTION]... FILE\n\n"
"Uncompress FILE (or standard input if FILE is '-').\n\n"
"\t-c\tWrite output to standard output\n"
"\t-t\tTest compressed file integrity\n";
+
+ /* These defines are very important for BusyBox. Without these,
+ * huge chunks of ram are pre-allocated making the BusyBox bss
+ * size Freaking Huge(tm), which is a bad thing.*/
+#define SMALL_MEM
+#define DYN_ALLOC
+
+#define bb_need_name_too_long
+#define BB_DECLARE_EXTERN
+#include "messages.c"
+
+
/* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
* Copyright (C) 1992-1993 Jean-loup Gailly
* The unzip code was written and put in the public domain by Mark Adler.
#define get_char() get_byte()
#define put_char(c) put_byte(c)
-/* #include "gzip.h" */
-
-/* gzip.h -- common declarations for all gzip modules
- * Copyright (C) 1992-1993 Jean-loup Gailly.
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-#if defined(__STDC__) || defined(PROTO)
-# define OF(args) args
-#else
-# define OF(args) ()
-#endif
-
-#ifdef __STDC__
-typedef void *voidp;
-#else
-typedef char *voidp;
-#endif
/* I don't like nested includes, but the string and io functions are used
* too often
# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
# include <memory.h>
# endif
-# define memzero(s, n) memset ((voidp)(s), 0, (n))
+# define memzero(s, n) memset ((void *)(s), 0, (n))
#else
# include <strings.h>
# define strchr index
#define WARN(msg) {fprintf msg ; \
if (exit_code == OK) exit_code = WARNING;}
-#define do_exit(c) exit(c)
-
-
/* in unzip.c */
-extern int unzip OF((int in, int out));
+extern int unzip (int in, int out);
/* in gzip.c */
-RETSIGTYPE abort_gzip OF((void));
+RETSIGTYPE abort_gzip (void);
/* in deflate.c */
-void lm_init OF((int pack_level, ush * flags));
-ulg deflate OF((void));
+void lm_init (int pack_level, ush * flags);
+ulg deflate (void);
/* in trees.c */
-void ct_init OF((ush * attr, int *method));
-int ct_tally OF((int dist, int lc));
-ulg flush_block OF((char *buf, ulg stored_len, int eof));
+void ct_init (ush * attr, int *method);
+int ct_tally (int dist, int lc);
+ulg flush_block (char *buf, ulg stored_len, int eof);
/* in bits.c */
-void bi_init OF((file_t zipfile));
-void send_bits OF((int value, int length));
-unsigned bi_reverse OF((unsigned value, int length));
-void bi_windup OF((void));
-void copy_block OF((char *buf, unsigned len, int header));
-extern int (*read_buf) OF((char *buf, unsigned size));
+void bi_init (file_t zipfile);
+void send_bits (int value, int length);
+unsigned bi_reverse (unsigned value, int length);
+void bi_windup (void);
+void copy_block (char *buf, unsigned len, int header);
+extern int (*read_buf) (char *buf, unsigned size);
/* in util.c: */
-extern int copy OF((int in, int out));
-extern ulg updcrc OF((uch * s, unsigned n));
-extern void clear_bufs OF((void));
-extern int fill_inbuf OF((int eof_ok));
-extern void flush_outbuf OF((void));
-extern void flush_window OF((void));
-extern void write_buf OF((int fd, voidp buf, unsigned cnt));
+extern int copy (int in, int out);
+extern ulg updcrc (uch * s, unsigned n);
+extern void clear_bufs (void);
+extern int fill_inbuf (int eof_ok);
+extern void flush_outbuf (void);
+extern void flush_window (void);
+extern void write_buf (int fd, void * buf, unsigned cnt);
#ifndef __linux__
-extern char *basename OF((char *fname));
+extern char *basename (char *fname);
#endif /* not __linux__ */
-extern void read_error OF((void));
-extern void write_error OF((void));
+extern void read_error (void);
+extern void write_error (void);
/* in inflate.c */
-extern int inflate OF((void));
+extern int inflate (void);
/* #include "lzw.h" */
extern int maxbits; /* max bits per code for LZW */
extern int block_mode; /* block compress mode -C compatible with 2.0 */
-extern int lzw OF((int in, int out));
-extern int unlzw OF((int in, int out));
+extern int lzw (int in, int out);
+extern int unlzw (int in, int out);
/* #include "revision.h" */
#if !defined(S_ISREG) && defined(S_IFREG)
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
-typedef RETSIGTYPE(*sig_type) OF((int));
+typedef RETSIGTYPE(*sig_type) (int);
#ifndef O_BINARY
# define O_BINARY 0 /* creation mode for open() */
#ifdef NO_OFF_T
typedef long off_t;
-off_t lseek OF((int fd, off_t offset, int whence));
+off_t lseek (int fd, off_t offset, int whence);
#endif
/* local functions */
-local int get_method OF((int in));
+local int get_method (int in);
#define strequ(s1, s2) (strcmp((s1),(s2)) == 0)
usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) {
fprintf(stderr, name_too_long, "gunzip");
- do_exit(WARNING);
+ exit(WARNING);
}
strcpy(ifname, *argv);
inFileNum = open(ifname, O_RDONLY);
if (inFileNum < 0) {
perror(ifname);
- do_exit(WARNING);
+ exit(WARNING);
}
/* Get the time stamp on the input file. */
result = stat(ifname, &statBuf);
if (result < 0) {
perror(ifname);
- do_exit(WARNING);
+ exit(WARNING);
}
ifile_size = statBuf.st_size;
}
/* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) {
fprintf(stderr, name_too_long, "gunzip");
- do_exit(WARNING);
+ exit(WARNING);
}
strcpy(ofname, ifname);
pos = strstr(ofname, ".gz");
#endif
if (outFileNum < 0) {
perror(ofname);
- do_exit(WARNING);
+ exit(WARNING);
}
/* Set permissions on the file */
fchmod(outFileNum, statBuf.st_mode);
exit(FALSE);
}
}
- do_exit(exit_code);
+ exit(exit_code);
}
*/
RETSIGTYPE abort_gzip()
{
- do_exit(ERROR);
+ exit(ERROR);
}
/* unzip.c -- decompress files in gzip or pkzip format.
ofd = out;
method = get_method(ifd);
if (method < 0) {
- do_exit(exit_code); /* error message already emitted */
+ exit(exit_code); /* error message already emitted */
}
updcrc(NULL, 0); /* initialize crc */
*/
void write_buf(fd, buf, cnt)
int fd;
-voidp buf;
+void * buf;
unsigned cnt;
{
unsigned n;
write_error();
}
cnt -= n;
- buf = (voidp) ((char *) buf + n);
+ buf = (void *) ((char *) buf + n);
}
}
# define const
# endif
-int strspn OF((const char *s, const char *accept));
-int strcspn OF((const char *s, const char *reject));
+int strspn (const char *s, const char *accept);
+int strcspn (const char *s, const char *reject);
/* ========================================================================
* Return the length of the maximum initial segment
/* Function prototypes */
-int huft_build OF((unsigned *, unsigned, unsigned, ush *, ush *,
- struct huft **, int *));
-int huft_free OF((struct huft *));
-int inflate_codes OF((struct huft *, struct huft *, int, int));
-int inflate_stored OF((void));
-int inflate_fixed OF((void));
-int inflate_dynamic OF((void));
-int inflate_block OF((int *));
-int inflate OF((void));
+int huft_build (unsigned *, unsigned, unsigned, ush *, ush *,
+ struct huft **, int *);
+int huft_free (struct huft *);
+int inflate_codes (struct huft *, struct huft *, int, int);
+int inflate_stored (void);
+int inflate_fixed (void);
+int inflate_dynamic (void);
+int inflate_block (int *);
+int inflate (void);
/* The inflate algorithm uses a sliding 32K byte window on the uncompressed
/* vi: set sw=4 ts=4: */
-/* gzip.c -- this is a stripped down version of gzip I put into busybox, it does
- * only standard in to standard out with -9 compression. It also requires the
- * zcat module for some important functions.
+/*
+ * Gzip implementation for busybox
+ *
+ * Based on GNU gzip Copyright (C) 1992-1993 Jean-loup Gailly.
+ *
+ * Originally adjusted for busybox by Charles P. Wright <cpw@unix.asb.com>
+ * "this is a stripped down version of gzip I put into busybox, it does
+ * only standard in to standard out with -9 compression. It also requires
+ * the zcat module for some important functions."
+ *
+ * Adjusted further by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+ * to support files as well as stdin/stdout, and to generally behave itself wrt
+ * command line handling.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Charles P. Wright <cpw@unix.asb.com>
*/
+
#include "internal.h"
-#ifdef BB_GZIP
-//#ifndef BB_ZCAT
-//#error you need zcat to have gzip support!
-//#endif
+/* These defines are very important for BusyBox. Without these,
+ * huge chunks of ram are pre-allocated making the BusyBox bss
+ * size Freaking Huge(tm), which is a bad thing.*/
+#define SMALL_MEM
+#define DYN_ALLOC
+
static const char gzip_usage[] =
"gzip [OPTION]... FILE\n\n"
"\t-c\tWrite output to standard output instead of FILE.gz\n";
-/* gzip.h -- common declarations for all gzip modules
- * Copyright (C) 1992-1993 Jean-loup Gailly.
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-
-#if defined(__STDC__) || defined(PROTO)
-# define OF(args) args
-#else
-# define OF(args) ()
-#endif
-
-#ifdef __STDC__
-typedef void *voidp;
-#else
-typedef char *voidp;
-#endif
-
/* I don't like nested includes, but the string and io functions are used
* too often
*/
#include <stdio.h>
-#if !defined(NO_STRING_H) || defined(STDC_HEADERS)
-# include <string.h>
-# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
-# include <memory.h>
-# endif
-# define memzero(s, n) memset ((voidp)(s), 0, (n))
-#else
-# include <strings.h>
-# define strchr index
-# define strrchr rindex
-# define memcpy(d, s, n) bcopy((s), (d), (n))
-# define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
-# define memzero(s, n) bzero((s), (n))
-#endif
+#include <string.h>
+#define memzero(s, n) memset ((void *)(s), 0, (n))
#ifndef RETSIGTYPE
# define RETSIGTYPE void
#endif
#ifdef DYN_ALLOC
-# define EXTERN(type, array) extern type * near array
-# define DECLARE(type, array, size) type * near array
+# define EXTERN(type, array) extern type * array
+# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
- array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
+ array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
if (array == NULL) errorMsg("insufficient memory"); \
}
-# define FREE(array) {if (array != NULL) fcfree(array), array=NULL;}
+# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
# define EXTERN(type, array) extern type array[]
# define DECLARE(type, array, size) type array[size]
/* in zip.c: */
-extern int zip OF((int in, int out));
-extern int file_read OF((char *buf, unsigned size));
+extern int zip (int in, int out);
+extern int file_read (char *buf, unsigned size);
/* in unzip.c */
-extern int unzip OF((int in, int out));
-extern int check_zipfile OF((int in));
+extern int unzip (int in, int out);
+extern int check_zipfile (int in);
/* in unpack.c */
-extern int unpack OF((int in, int out));
+extern int unpack (int in, int out);
/* in unlzh.c */
-extern int unlzh OF((int in, int out));
+extern int unlzh (int in, int out);
/* in gzip.c */
-RETSIGTYPE abort_gzip OF((void));
+RETSIGTYPE abort_gzip (void);
/* in deflate.c */
-void lm_init OF((ush * flags));
-ulg deflate OF((void));
+void lm_init (ush * flags);
+ulg deflate (void);
/* in trees.c */
-void ct_init OF((ush * attr, int *method));
-int ct_tally OF((int dist, int lc));
-ulg flush_block OF((char *buf, ulg stored_len, int eof));
+void ct_init (ush * attr, int *method);
+int ct_tally (int dist, int lc);
+ulg flush_block (char *buf, ulg stored_len, int eof);
/* in bits.c */
-void bi_init OF((file_t zipfile));
-void send_bits OF((int value, int length));
-unsigned bi_reverse OF((unsigned value, int length));
-void bi_windup OF((void));
-void copy_block OF((char *buf, unsigned len, int header));
-extern int (*read_buf) OF((char *buf, unsigned size));
+void bi_init (file_t zipfile);
+void send_bits (int value, int length);
+unsigned bi_reverse (unsigned value, int length);
+void bi_windup (void);
+void copy_block (char *buf, unsigned len, int header);
+extern int (*read_buf) (char *buf, unsigned size);
/* in util.c: */
-extern int copy OF((int in, int out));
-extern ulg updcrc OF((uch * s, unsigned n));
-extern void clear_bufs OF((void));
-extern int fill_inbuf OF((int eof_ok));
-extern void flush_outbuf OF((void));
-extern void flush_window OF((void));
-extern void write_buf OF((int fd, voidp buf, unsigned cnt));
-extern char *strlwr OF((char *s));
-extern char *add_envopt OF((int *argcp, char ***argvp, char *env));
-extern void read_error OF((void));
-extern void write_error OF((void));
-extern void display_ratio OF((long num, long den, FILE * file));
+extern int copy (int in, int out);
+extern ulg updcrc (uch * s, unsigned n);
+extern void clear_bufs (void);
+extern int fill_inbuf (int eof_ok);
+extern void flush_outbuf (void);
+extern void flush_window (void);
+extern void write_buf (int fd, void * buf, unsigned cnt);
+extern char *strlwr (char *s);
+extern char *add_envopt (int *argcp, char ***argvp, char *env);
+extern void read_error (void);
+extern void write_error (void);
+extern void display_ratio (long num, long den, FILE * file);
/* in inflate.c */
-extern int inflate OF((void));
+extern int inflate (void);
/* lzw.h -- define the lzw functions.
* Copyright (C) 1992-1993 Jean-loup Gailly.
* are always zero.
*/
-int (*read_buf) OF((char *buf, unsigned size));
+int (*read_buf) (char *buf, unsigned size);
/* Current input function. Set to mem_read for in-memory compression */
/* ===========================================================================
* Prototypes for local functions.
*/
-local void fill_window OF((void));
+local void fill_window (void);
-int longest_match OF((IPos cur_match));
+int longest_match (IPos cur_match);
#ifdef ASMV
-void match_init OF((void)); /* asm code initialization */
+void match_init (void); /* asm code initialization */
#endif
#ifdef DEBUG
-local void check_match OF((IPos start, IPos match, int length));
+local void check_match (IPos start, IPos match, int length);
#endif
/* ===========================================================================
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
-typedef RETSIGTYPE(*sig_type) OF((int));
+typedef RETSIGTYPE(*sig_type) (int);
#ifndef O_BINARY
# define O_BINARY 0 /* creation mode for open() */
#ifdef NO_OFF_T
typedef long off_t;
-off_t lseek OF((int fd, off_t offset, int whence));
+off_t lseek (int fd, off_t offset, int whence);
#endif
/* Separator for file name parts (see shorten_name()) */
* Local (static) routines in this file.
*/
-local void init_block OF((void));
-local void pqdownheap OF((ct_data near * tree, int k));
-local void gen_bitlen OF((tree_desc near * desc));
-local void gen_codes OF((ct_data near * tree, int max_code));
-local void build_tree OF((tree_desc near * desc));
-local void scan_tree OF((ct_data near * tree, int max_code));
-local void send_tree OF((ct_data near * tree, int max_code));
-local int build_bl_tree OF((void));
-local void send_all_trees OF((int lcodes, int dcodes, int blcodes));
-local void compress_block OF((ct_data near * ltree, ct_data near * dtree));
-local void set_file_type OF((void));
+local void init_block (void);
+local void pqdownheap (ct_data near * tree, int k);
+local void gen_bitlen (tree_desc near * desc);
+local void gen_codes (ct_data near * tree, int max_code);
+local void build_tree (tree_desc near * desc);
+local void scan_tree (ct_data near * tree, int max_code);
+local void send_tree (ct_data near * tree, int max_code);
+local int build_bl_tree (void);
+local void send_all_trees (int lcodes, int dcodes, int blcodes);
+local void compress_block (ct_data near * ltree, ct_data near * dtree);
+local void set_file_type (void);
#ifndef DEBUG
/* Provide missing strspn and strcspn functions. */
-# ifndef __STDC__
-# define const
-# endif
-
-int strspn OF((const char *s, const char *accept));
-int strcspn OF((const char *s, const char *reject));
+int strspn (const char *s, const char *accept);
+int strcspn (const char *s, const char *reject);
/* ========================================================================
* Return the length of the maximum initial segment
isize += (ulg) len;
return (int) len;
}
-#endif
* Mini head implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
exit(0);
}
-/* $Id: head.c,v 1.8 2000/02/08 19:58:47 erik Exp $ */
+/* $Id: head.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
return;
if (stat("/etc/fstab", &statBuf) == 0) {
+ /* swapon -a requires /proc typically */
+ waitfor("mount proc /proc -t proc", console, FALSE);
/* Try to turn on swap */
- system("/sbin/swapon -a");
+ waitfor("swapon -a", console, FALSE);
if (check_free_memory() < 1000)
goto goodnight;
} else
return;
if (stat("/etc/fstab", &statBuf) == 0) {
+ /* swapon -a requires /proc typically */
+ waitfor("mount proc /proc -t proc", console, FALSE);
/* Try to turn on swap */
- system("/sbin/swapon -a");
+ waitfor("swapon -a", console, FALSE);
if (check_free_memory() < 1000)
goto goodnight;
} else
/*
* Mini insmod implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini ln implementation for busybox
*
- *
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
unicode utf8_to_ucs2(char *buf)
{
int utf_count = 0;
- long utf_char;
- unicode tc;
+ long utf_char = 0;
+ unicode tc = 0;
unsigned char c;
do {
/*
* Mini logger implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini lsmod implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
#include "internal.h"
#include <stdio.h>
+#include <errno.h>
#include <utmp.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_io_error
+#include "messages.c"
static const char dutmp_usage[] = "dutmp\n"
"\n"
-
"\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
"\tdutmp /var/run/utmp\n";
extern int dutmp_main(int argc, char **argv)
{
- FILE *f = stdin;
+ FILE *f;
struct utmp ut;
- if ((argc < 2) || (**(argv + 1) == '-')) {
+ if (argc<2) {
+ f = stdin;
+ } else if (*argv[1] == '-' ) {
usage(dutmp_usage);
- }
-
- if (**(++argv) == 0) {
- f = fopen(*(++argv), "r");
- if (f < 0) {
- perror(*argv);
- exit(FALSE);
+ } else {
+ f = fopen(argv[1], "r");
+ if (f == NULL) {
+ fatalError(io_error, argv[1], strerror(errno));
}
}
- while (fread(&ut, 1, sizeof(struct utmp), f)) {
- // printf("%d:%d:%s:%s:%s:%s:%d:%d:%ld:%ld:%ld:%x\n",
+ while (fread(&ut, sizeof(struct utmp), 1, f)) {
printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
ut.ut_type, ut.ut_pid, ut.ut_line,
ut.ut_id, ut.ut_user, ut.ut_host,
/*
* Mini mkdir implementation for busybox
*
- *
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini insmod implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini lsmod implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini rmmod implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini nslookup implementation for busybox
*
- *
* Copyright (C) 2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
return 0;
}
-/* $Id: nslookup.c,v 1.5 2000/02/18 21:34:17 erik Exp $ */
+/* $Id: nslookup.c,v 1.6 2000/04/13 01:18:56 erik Exp $ */
/*
* Mini nslookup implementation for busybox
*
- *
* Copyright (C) 2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
return 0;
}
-/* $Id: nslookup.c,v 1.5 2000/02/18 21:34:17 erik Exp $ */
+/* $Id: nslookup.c,v 1.6 2000/04/13 01:18:56 erik Exp $ */
/*
* Mini free implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini ps implementation(s) for busybox
*
- * Copyright (C) 1999 by Lineo, inc. Written by Erik Andersen
+ * Copyright (C) 1999,2000 by Lineo, inc. Written by Erik Andersen
* <andersen@lineo.com>, <andersee@debian.org>
*
*
/*
* Mini uptime implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini ps implementation(s) for busybox
*
- * Copyright (C) 1999 by Lineo, inc. Written by Erik Andersen
+ * Copyright (C) 1999,2000 by Lineo, inc. Written by Erik Andersen
* <andersen@lineo.com>, <andersee@debian.org>
*
*
* Mini rm implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini rmdir implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini rmmod implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini sed implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* Modifications for addresses and append command have been
/* vi: set sw=4 ts=4: */
/*
- * Termios command line History and Editting for NetBSD sh (ash)
+ * Termios command line History and Editting, originally
+ * intended for NetBSD sh (ash)
* Copyright (c) 1999
* Main code: Adam Rogoyski <rogoyski@cs.utexas.edu>
* Etc: Dave Cinege <dcinege@psychosis.com>
- * Adjusted for busybox: Erik Andersen <andersee@debian.org>
+ * Majorly adjusted/re-written for busybox:
+ * Erik Andersen <andersee@debian.org>
*
* You may use this code as you wish, so long as the original author(s)
* are attributed in any redistributions of the source code.
void
cmdedit_setwidth(int w)
{
- if (w > 20) {
+ if (w > 20) {
cmdedit_termw = w;
cmdedit_scroll = w / 3;
- } else {
+ } else {
errorMsg("\n*** Error: minimum screen width is 21\n");
- }
+ }
}
+
void cmdedit_reset_term(void)
{
if (reset_term)
free((*hp)->s);
(*hp)->s = strdup(command);
*hp = (*hp)->n;
-
- cmdedit_redraw( NULL, hp->s, -2, -2);
-}
-
-#if 0
-/* prompt : if !=NULL, print the prompt
- * command: the command line to be displayed
- * where : where to display changes from.
- * -1 for no change, -2 for new line
- * cursor : desired location for the cursor.
- * -1 for Beginning of line.
- * -2 for End of Line,
- */
-static void
-cmdedit_redraw(char* prompt, char* command, int where, int cursor)
-{
- static char* last_command;
- int cmdedit_width;
-
- if (where == -2) {
- /* Rewrite the prompt and clean up static variables */
- xwrite(outputFd, "\n", 1);
- if (prompt) {
- strcpy(last_command, prompt);
- xwrite(outputFd, prompt, strlen(prompt));
- } else {
- last_command[0] = '\0';
- xwrite(outputFd, "# ", 2);
- }
- cmdedit_width = cmdedit_termw - cmdedit_strlen(prompt);
- } else if (strcmp(command, last_command) != 0) {
- strcpy(last_command, prompt);
- }
-
- /* erase old command from command line */
- len = strlen(command)-strlen(last_command);
- while (len>0)
- input_backspace(command, outputFd, &cursor, &len);
- input_home(outputFd, &cursor);
-
- /* Rewrite the command */
- xwrite(outputFd, command+where, len);
-
- /* Put the where it is supposed to be */
- for (cursor=len; cursor > where; cursor--)
- xwrite(outputFd, "\b", 1);
-
- /* write new command */
- strcpy(command, hp->s);
- len = strlen(hp->s);
- xwrite(outputFd, command+where, len);
- cursor = len;
}
-#endif
/*
* This function is used to grab a character buffer
* Mini sort implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
exit(0);
}
-/* $Id: sort.c,v 1.12 2000/03/04 21:19:32 erik Exp $ */
+/* $Id: sort.c,v 1.13 2000/04/13 01:18:56 erik Exp $ */
* Mini swapon/swapoff implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini logger implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
/*
* Mini syslogd implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
#include <sys/un.h>
#include <time.h>
#include <unistd.h>
+#include <limits.h>
#define ksyslog klogctl
extern int ksyslog(int type, char *buf, int len);
/*
* Mini syslogd implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
#include <sys/un.h>
#include <time.h>
#include <unistd.h>
+#include <limits.h>
#define ksyslog klogctl
extern int ksyslog(int type, char *buf, int len);
/*
* Mini tar implementation for busybox
*
- * Note, that as of BusyBox 0.43 tar has been completely rewritten from the
- * ground up. It still has remnents of the old code lying about, but it pretty
- * different (i.e. cleaner, less global variables, etc)
+ * Note, that as of BusyBox-0.43, tar has been completely rewritten from the
+ * ground up. It still has remnents of the old code lying about, but it is
+ * very different now (i.e. cleaner, less global variables, etc)
*
* Copyright (C) 2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Mini tee implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
exit(0);
}
-/* $Id: tee.c,v 1.8 2000/03/23 01:09:18 erik Exp $ */
+/* $Id: tee.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
* Mini touch implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini true/false implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini umount implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini uniq implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
exit(0);
}
-/* $Id: uniq.c,v 1.7 2000/02/08 19:58:47 erik Exp $ */
+/* $Id: uniq.c,v 1.8 2000/04/13 01:18:56 erik Exp $ */
/*
* Mini uptime implementation for busybox
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
#endif
- fprintf(stderr, "Usage: fbset [options] [mode]\n");
- fprintf(stderr, "\tThe following options are recognized:\n");
+ fprintf(stderr, "Usage: fbset [options] [mode]\n\n");
+ fprintf(stderr, "Show and modify frame buffer device settings\n\n");
+ fprintf(stderr, "The following options are recognized:\n");
for (i = 0; g_cmdoptions[i].name; i++)
- fprintf(stderr, "\t\t%s\n", g_cmdoptions[i].name);
+ fprintf(stderr, "\t%s\n", g_cmdoptions[i].name);
exit(-1);
}
* Mini swapon/swapoff implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* Mini umount implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
+ * Copyright (C) 1999,2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify