Upates to include copyright 2000 to everything

-Erik
This commit is contained in:
Erik Andersen 2000-04-13 01:18:56 +00:00
parent 62dc17a3b1
commit 61677feff7
85 changed files with 583 additions and 670 deletions

10
AUTHORS
View File

@ -1,8 +1,8 @@
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
@ -16,7 +16,7 @@ Bruce Perens <bruce@pixar.com>
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)

View File

@ -59,7 +59,7 @@
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

12
README
View File

@ -7,17 +7,17 @@ an editor such as "elvis-tiny" or "ae", and you have a working system.
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

View File

@ -234,9 +234,6 @@ static const struct Applet applets[] = {
{"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
@ -382,8 +379,9 @@ int busybox_main(int argc, char **argv)
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) {

View File

@ -1,13 +1,33 @@
/* 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"
@ -16,6 +36,18 @@ static const char gunzip_usage[] =
"\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.
@ -89,25 +121,6 @@ static char *license_msg[] = {
#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
@ -118,7 +131,7 @@ typedef char *voidp;
# 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
@ -329,49 +342,46 @@ extern int save_orig_name; /* set if original name must be saved */
#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" */
@ -415,8 +425,8 @@ extern int inflate OF((void));
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" */
@ -605,7 +615,7 @@ typedef struct direct dir_type;
#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() */
@ -644,7 +654,7 @@ typedef RETSIGTYPE(*sig_type) OF((int));
#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
@ -687,7 +697,7 @@ long header_bytes; /* number of bytes in gzip header */
/* local functions */
local int get_method OF((int in));
local int get_method (int in);
#define strequ(s1, s2) (strcmp((s1),(s2)) == 0)
@ -773,7 +783,7 @@ int gunzip_main(int argc, char **argv)
usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) {
fprintf(stderr, name_too_long, "gunzip");
do_exit(WARNING);
exit(WARNING);
}
strcpy(ifname, *argv);
@ -781,13 +791,13 @@ int gunzip_main(int argc, char **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;
}
@ -812,7 +822,7 @@ int gunzip_main(int argc, char **argv)
/* 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");
@ -836,7 +846,7 @@ int gunzip_main(int argc, char **argv)
#endif
if (outFileNum < 0) {
perror(ofname);
do_exit(WARNING);
exit(WARNING);
}
/* Set permissions on the file */
fchmod(outFileNum, statBuf.st_mode);
@ -860,7 +870,7 @@ int gunzip_main(int argc, char **argv)
exit(FALSE);
}
}
do_exit(exit_code);
exit(exit_code);
}
@ -953,7 +963,7 @@ int in; /* input file descriptor */
*/
RETSIGTYPE abort_gzip()
{
do_exit(ERROR);
exit(ERROR);
}
/* unzip.c -- decompress files in gzip or pkzip format.
@ -1027,7 +1037,7 @@ int in, out; /* input and output file descriptors */
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 */
@ -1218,7 +1228,7 @@ void flush_window()
*/
void write_buf(fd, buf, cnt)
int fd;
voidp buf;
void * buf;
unsigned cnt;
{
unsigned n;
@ -1228,7 +1238,7 @@ unsigned cnt;
write_error();
}
cnt -= n;
buf = (voidp) ((char *) buf + n);
buf = (void *) ((char *) buf + n);
}
}
@ -1240,8 +1250,8 @@ unsigned cnt;
# 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
@ -1493,15 +1503,15 @@ struct huft {
/* 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

View File

@ -1,16 +1,42 @@
/* 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
#include "internal.h"
/* 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"
@ -21,42 +47,12 @@ static const char gzip_usage[] =
"\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
@ -121,13 +117,13 @@ extern int method; /* compression method */
#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]
@ -284,55 +280,55 @@ extern int save_orig_name; /* set if original name must be saved */
/* 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.
@ -795,7 +791,7 @@ local int bi_valid;
* 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 */
@ -1148,16 +1144,16 @@ local config configuration_table =
/* ===========================================================================
* 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
/* ===========================================================================
@ -1708,7 +1704,7 @@ struct utimbuf {
# 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() */
@ -1743,7 +1739,7 @@ typedef RETSIGTYPE(*sig_type) OF((int));
#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()) */
@ -2246,17 +2242,17 @@ extern unsigned near strstart; /* window offset of current string */
* 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
@ -3161,12 +3157,8 @@ char *s;
/* 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
@ -3398,4 +3390,3 @@ unsigned size;
isize += (ulg) len;
return (int) len;
}
#endif

View File

@ -2,9 +2,9 @@
/*
* 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>

View File

@ -2,7 +2,7 @@
/*
* 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
@ -26,13 +26,16 @@
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);

View File

@ -234,9 +234,6 @@ static const struct Applet applets[] = {
{"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
@ -382,8 +379,9 @@ int busybox_main(int argc, char **argv)
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) {

View File

@ -7,7 +7,7 @@
//
//
// BusyBox Applications
//#define BB_BASENAME
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHROOT
@ -20,21 +20,21 @@
#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.
@ -42,39 +42,39 @@
#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
@ -86,7 +86,7 @@
#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
@ -111,7 +111,7 @@
//
//
// 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...
@ -153,7 +153,7 @@
//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
@ -181,19 +181,20 @@
#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

2
cat.c
View File

@ -2,7 +2,7 @@
/*
* 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

View File

@ -3,7 +3,7 @@
* 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

View File

@ -3,7 +3,7 @@
* 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

View File

@ -3,7 +3,7 @@
* 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

View File

@ -1,10 +1,12 @@
/* 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.
@ -77,6 +79,7 @@ cmdedit_setwidth(int w)
}
}
void cmdedit_reset_term(void)
{
if (reset_term)
@ -339,61 +342,8 @@ void get_next_history(struct history **hp, char* command)
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
* from the input file descriptor and allows you to

View File

@ -3,7 +3,7 @@
* 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

View File

@ -353,8 +353,8 @@ void saveoldmap(int fd, char *omfil)
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 {

View File

@ -2,7 +2,7 @@
/*
* 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
@ -26,13 +26,16 @@
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);

View File

@ -2,7 +2,7 @@
/*
* 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

View File

@ -3,7 +3,7 @@
* 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

View File

@ -2,10 +2,10 @@
/*
* 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.
*
* 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.

View File

@ -2,7 +2,7 @@
/*
* 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>.
*
@ -28,9 +28,8 @@
#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 */
@ -76,6 +75,9 @@ extern int df_main(int argc, char **argv)
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]);

View File

@ -3,7 +3,7 @@
* 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
@ -182,7 +182,7 @@ int du_main(int argc, char **argv)
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"

View File

@ -3,7 +3,7 @@
* 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
@ -109,4 +109,4 @@ int head_main(int argc, char **argv)
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 $ */

View File

@ -2,8 +2,7 @@
/*
* 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

View File

@ -2,8 +2,7 @@
/*
* 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

View File

@ -3,7 +3,7 @@
* 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

View File

@ -3,7 +3,7 @@
* 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

View File

@ -3,7 +3,7 @@
* 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
@ -320,4 +320,4 @@ int sort_main(int argc, char **argv)
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 $ */

View File

@ -3,7 +3,7 @@
* 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
@ -131,4 +131,4 @@ int tee_main(int argc, char **argv)
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 $ */

View File

@ -3,7 +3,7 @@
* 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

View File

@ -3,7 +3,7 @@
* 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
@ -190,4 +190,4 @@ int uniq_main(int argc, char **argv)
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 $ */

View File

@ -37,7 +37,7 @@
#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>

4
dd.c
View File

@ -2,10 +2,10 @@
/*
* 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.
*
* 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.

10
df.c
View File

@ -2,7 +2,7 @@
/*
* 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>.
*
@ -28,9 +28,8 @@
#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 */
@ -76,6 +75,9 @@ extern int df_main(int argc, char **argv)
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]);

4
du.c
View File

@ -3,7 +3,7 @@
* 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
@ -182,7 +182,7 @@ int du_main(int argc, char **argv)
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"

25
dutmp.c
View File

@ -13,34 +13,35 @@
#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,

View File

@ -3,7 +3,7 @@
* 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

View File

@ -228,10 +228,11 @@ static void fbset_usage(void)
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);
}

2
find.c
View File

@ -3,7 +3,7 @@
* 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

View File

@ -3,7 +3,7 @@
* 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

View File

@ -3,7 +3,7 @@
* 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

2
free.c
View File

@ -2,7 +2,7 @@
/*
* 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

2
grep.c
View File

@ -3,7 +3,7 @@
* 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

168
gunzip.c
View File

@ -1,13 +1,33 @@
/* 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"
@ -16,6 +36,18 @@ static const char gunzip_usage[] =
"\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.
@ -89,25 +121,6 @@ static char *license_msg[] = {
#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
@ -118,7 +131,7 @@ typedef char *voidp;
# 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
@ -329,49 +342,46 @@ extern int save_orig_name; /* set if original name must be saved */
#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" */
@ -415,8 +425,8 @@ extern int inflate OF((void));
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" */
@ -605,7 +615,7 @@ typedef struct direct dir_type;
#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() */
@ -644,7 +654,7 @@ typedef RETSIGTYPE(*sig_type) OF((int));
#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
@ -687,7 +697,7 @@ long header_bytes; /* number of bytes in gzip header */
/* local functions */
local int get_method OF((int in));
local int get_method (int in);
#define strequ(s1, s2) (strcmp((s1),(s2)) == 0)
@ -773,7 +783,7 @@ int gunzip_main(int argc, char **argv)
usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) {
fprintf(stderr, name_too_long, "gunzip");
do_exit(WARNING);
exit(WARNING);
}
strcpy(ifname, *argv);
@ -781,13 +791,13 @@ int gunzip_main(int argc, char **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;
}
@ -812,7 +822,7 @@ int gunzip_main(int argc, char **argv)
/* 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");
@ -836,7 +846,7 @@ int gunzip_main(int argc, char **argv)
#endif
if (outFileNum < 0) {
perror(ofname);
do_exit(WARNING);
exit(WARNING);
}
/* Set permissions on the file */
fchmod(outFileNum, statBuf.st_mode);
@ -860,7 +870,7 @@ int gunzip_main(int argc, char **argv)
exit(FALSE);
}
}
do_exit(exit_code);
exit(exit_code);
}
@ -953,7 +963,7 @@ int in; /* input file descriptor */
*/
RETSIGTYPE abort_gzip()
{
do_exit(ERROR);
exit(ERROR);
}
/* unzip.c -- decompress files in gzip or pkzip format.
@ -1027,7 +1037,7 @@ int in, out; /* input and output file descriptors */
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 */
@ -1218,7 +1228,7 @@ void flush_window()
*/
void write_buf(fd, buf, cnt)
int fd;
voidp buf;
void * buf;
unsigned cnt;
{
unsigned n;
@ -1228,7 +1238,7 @@ unsigned cnt;
write_error();
}
cnt -= n;
buf = (voidp) ((char *) buf + n);
buf = (void *) ((char *) buf + n);
}
}
@ -1240,8 +1250,8 @@ unsigned cnt;
# 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
@ -1493,15 +1503,15 @@ struct huft {
/* 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

193
gzip.c
View File

@ -1,16 +1,42 @@
/* 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
#include "internal.h"
/* 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"
@ -21,42 +47,12 @@ static const char gzip_usage[] =
"\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
@ -121,13 +117,13 @@ extern int method; /* compression method */
#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]
@ -284,55 +280,55 @@ extern int save_orig_name; /* set if original name must be saved */
/* 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.
@ -795,7 +791,7 @@ local int bi_valid;
* 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 */
@ -1148,16 +1144,16 @@ local config configuration_table =
/* ===========================================================================
* 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
/* ===========================================================================
@ -1708,7 +1704,7 @@ struct utimbuf {
# 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() */
@ -1743,7 +1739,7 @@ typedef RETSIGTYPE(*sig_type) OF((int));
#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()) */
@ -2246,17 +2242,17 @@ extern unsigned near strstart; /* window offset of current string */
* 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
@ -3161,12 +3157,8 @@ char *s;
/* 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
@ -3398,4 +3390,3 @@ unsigned size;
isize += (ulg) len;
return (int) len;
}
#endif

4
head.c
View File

@ -3,7 +3,7 @@
* 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
@ -109,4 +109,4 @@ int head_main(int argc, char **argv)
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 $ */

4
init.c
View File

@ -471,8 +471,10 @@ static void check_memory()
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

View File

@ -471,8 +471,10 @@ static void check_memory()
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

View File

@ -2,7 +2,7 @@
/*
* 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

3
ln.c
View File

@ -2,8 +2,7 @@
/*
* 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

View File

@ -353,8 +353,8 @@ void saveoldmap(int fd, char *omfil)
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 {

View File

@ -2,7 +2,7 @@
/*
* 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

View File

@ -2,7 +2,7 @@
/*
* 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

View File

@ -13,34 +13,35 @@
#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,

View File

@ -2,8 +2,7 @@
/*
* 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

View File

@ -2,7 +2,7 @@
/*
* 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

View File

@ -2,7 +2,7 @@
/*
* 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

View File

@ -2,7 +2,7 @@
/*
* 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

View File

@ -2,7 +2,6 @@
/*
* Mini nslookup implementation for busybox
*
*
* Copyright (C) 2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
@ -174,4 +173,4 @@ int nslookup_main(int argc, char **argv)
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 $ */

View File

@ -2,7 +2,6 @@
/*
* Mini nslookup implementation for busybox
*
*
* Copyright (C) 2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
@ -174,4 +173,4 @@ int nslookup_main(int argc, char **argv)
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 $ */

View File

@ -2,7 +2,7 @@
/*
* 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

View File

@ -2,7 +2,7 @@
/*
* 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>
*
*

View File

@ -2,7 +2,7 @@
/*
* 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

2
ps.c
View File

@ -2,7 +2,7 @@
/*
* 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>
*
*

2
rm.c
View File

@ -3,7 +3,7 @@
* 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

View File

@ -3,7 +3,7 @@
* 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

View File

@ -2,7 +2,7 @@
/*
* 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

2
sed.c
View File

@ -3,7 +3,7 @@
* 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

View File

@ -1,10 +1,12 @@
/* 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.
@ -77,6 +79,7 @@ cmdedit_setwidth(int w)
}
}
void cmdedit_reset_term(void)
{
if (reset_term)
@ -339,61 +342,8 @@ void get_next_history(struct history **hp, char* command)
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
* from the input file descriptor and allows you to

4
sort.c
View File

@ -3,7 +3,7 @@
* 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
@ -320,4 +320,4 @@ int sort_main(int argc, char **argv)
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 $ */

View File

@ -3,7 +3,7 @@
* 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

View File

@ -2,7 +2,7 @@
/*
* 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

View File

@ -2,7 +2,7 @@
/*
* 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
@ -37,6 +37,7 @@
#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);

View File

@ -2,7 +2,7 @@
/*
* 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
@ -37,6 +37,7 @@
#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);

6
tar.c
View File

@ -2,9 +2,9 @@
/*
* 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>

4
tee.c
View File

@ -3,7 +3,7 @@
* 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
@ -131,4 +131,4 @@ int tee_main(int argc, char **argv)
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 $ */

View File

@ -3,7 +3,7 @@
* 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

View File

@ -3,7 +3,7 @@
* 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

View File

@ -3,7 +3,7 @@
* 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

4
uniq.c
View File

@ -3,7 +3,7 @@
* 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
@ -190,4 +190,4 @@ int uniq_main(int argc, char **argv)
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 $ */

View File

@ -2,7 +2,7 @@
/*
* 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

View File

@ -228,10 +228,11 @@ static void fbset_usage(void)
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);
}

View File

@ -3,7 +3,7 @@
* 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

View File

@ -3,7 +3,7 @@
* 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