#define bb_need_name_too_long
#include "messages.c"
-#define RECORD_IO 0
+static const int RECORD_IO = 0;
/* Return codes from gzip */
-#define OK 0
-#define ERROR 1
-#define WARNING 2
+static const int OK = 0;
+static const int ERROR = 1;
+static const int WARNING = 2;
-#define DEFLATED 8
-#define INBUFSIZ 0x2000 /* input buffer size */
-#define INBUF_EXTRA 64 /* required by unlzw() */
-#define OUTBUFSIZ 8192 /* output buffer size */
-#define OUTBUF_EXTRA 2048 /* required by unlzw() */
-#define DIST_BUFSIZE 0x2000 /* buffer for distances, see trees.c */
+static const int DEFLATED = 8;
+static const int INBUFSIZ = 0x2000; /* input buffer size */
+static const int INBUF_EXTRA = 64; /* required by unlzw() */
+static const int OUTBUFSIZ = 8192; /* output buffer size */
+static const int OUTBUF_EXTRA = 2048; /* required by unlzw() */
+static const int DIST_BUFSIZE = 0x2000; /* buffer for distances, see trees.c */
#define GZIP_MAGIC "\037\213" /* Magic header for gzip files, 1F 8B */
/* gzip flag byte */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define WSIZE 0x8000 /* window size--must be a power of two, and */
+static const int EXTRA_FIELD = 0x04; /* bit 2 set: extra field present */
+static const int ORIG_NAME = 0x08; /* bit 3 set: original file name present */
+static const int COMMENT = 0x10; /* bit 4 set: file comment present */
+static const int WSIZE = 0x8000; /* window size--must be a power of two, and */
/* at least 32K for zip's deflate method */
/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
-#define BMAX 16 /* maximum bit length of any code (16 for explode) */
-#define N_MAX 288 /* maximum number of codes in any set */
+static const int BMAX = 16; /* maximum bit length of any code (16 for explode) */
+static const int N_MAX = 288; /* maximum number of codes in any set */
/* PKZIP header definitions */
-#define LOCSIG 0x04034b50L /* four-byte lead-in (lsb first) */
-#define LOCCRC 14 /* offset of crc */
-#define LOCLEN 22 /* offset of uncompressed length */
-#define EXTHDR 16 /* size of extended local header, inc sig */
+static const int LOCSIG = 0x04034b50L; /* four-byte lead-in (lsb first) */
+static const int LOCCRC = 14; /* offset of crc */
+static const int LOCLEN = 22; /* offset of uncompressed length */
+static const int EXTHDR = 16; /* size of extended local header, inc sig */
-#define BITS 16
+static const int BITS = 16;
/* Diagnostic functions */
#ifdef DEBUG
# ifdef BUFSIZ
# define MAX_PATH_LEN BUFSIZ
# else
-# define MAX_PATH_LEN 1024
+static const int MAX_PATH_LEN = 1024;
# endif
#endif
/* local variables */
static int test_mode = 0; /* check file integrity option */
static int foreground; /* set if program run in foreground */
-static int method = DEFLATED; /* compression method */
-static int exit_code = OK; /* program exit code */
+static int method; /* compression method */
+static int exit_code; /* program exit code */
static int last_member; /* set for .zip and .Z files */
static int part_nb; /* number of parts in .gz file */
static long ifile_size; /* input file size, -1 for devices (debug only) */
char ifname[MAX_PATH_LEN + 1]; /* input file name */
char ofname[MAX_PATH_LEN + 1]; /* output file name */
+ method = DEFLATED; /* default compression method */
+ exit_code = OK; /* let's go out on a limb and assume everything will run fine (wink wink) */
+
if (strcmp(applet_name, "zcat") == 0) {
force = 1;
tostdout = 1;
#define MINOR(dev) ((dev)&0xff)
#endif
-#define NAME_SIZE 100
+enum { NAME_SIZE = 100 }; /* because gcc won't let me use 'static const int' */
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
struct TarHeader
/* A few useful constants */
#define TAR_MAGIC "ustar" /* ustar and a null */
#define TAR_VERSION " " /* Be compatable with GNU tar format */
-#define TAR_MAGIC_LEN 6
-#define TAR_VERSION_LEN 2
-#define TAR_BLOCK_SIZE 512
+static const int TAR_MAGIC_LEN = 6;
+static const int TAR_VERSION_LEN = 2;
+static const int TAR_BLOCK_SIZE = 512;
/* A nice enum with all the possible tar file content types */
enum TarFileType
#include <sys/ioctl.h>
/* From <linux/vt.h> */
-#define VT_ACTIVATE 0x5606 /* make vt active */
-#define VT_WAITACTIVE 0x5607 /* wait for vt active */
+static const int VT_ACTIVATE = 0x5606; /* make vt active */
+static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
int chvt_main(int argc, char **argv)
{
#include <signal.h>
-#define MAX_HISTORY 15 /* Maximum length of the linked list for the command line history */
+static const int MAX_HISTORY = 15; /* Maximum length of the linked list for the command line history */
+
+enum {
+ ESC = 27,
+ DEL = 127,
+};
-#define ESC 27
-#define DEL 127
#define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
#include <sys/ioctl.h>
/* From <linux/vt.h> */
-#define VT_ACTIVATE 0x5606 /* make vt active */
-#define VT_WAITACTIVE 0x5607 /* wait for vt active */
+static const int VT_ACTIVATE = 0x5606; /* make vt active */
+static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
int chvt_main(int argc, char **argv)
{
#include <sys/ioctl.h>
/* From <linux/vt.h> */
-#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
+static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
int deallocvt_main(int argc, char *argv[])
{
unsigned char kb_index;
unsigned short kb_value;
};
-#define KDGKBENT 0x4B46 /* gets one entry in translation table */
+static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
/* From <linux/keyboard.h> */
-#define NR_KEYS 128
-#define MAX_NR_KEYMAPS 256
+static const int NR_KEYS = 128;
+static const int MAX_NR_KEYMAPS = 256;
int dumpkmap_main(int argc, char **argv)
{
#include <sys/kd.h>
#include <endian.h>
-#define PSF_MAGIC1 0x36
-#define PSF_MAGIC2 0x04
+static const int PSF_MAGIC1 = 0x36;
+static const int PSF_MAGIC2 = 0x04;
-#define PSF_MODE512 0x01
-#define PSF_MODEHASTAB 0x02
-#define PSF_MAXMODE 0x03
-#define PSF_SEPARATOR 0xFFFF
+static const int PSF_MODE512 = 0x01;
+static const int PSF_MODEHASTAB = 0x02;
+static const int PSF_MAXMODE = 0x03;
+static const int PSF_SEPARATOR = 0xFFFF;
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
unsigned char kb_index;
unsigned short kb_value;
};
-#define KDSKBENT 0x4B47 /* sets one entry in translation table */
+static const int KDSKBENT = 0x4B47; /* sets one entry in translation table */
/* From <linux/keyboard.h> */
-#define NR_KEYS 128
-#define MAX_NR_KEYMAPS 256
+static const int NR_KEYS = 128;
+static const int MAX_NR_KEYMAPS = 256;
int loadkmap_main(int argc, char **argv)
{
struct kbkeycode {
unsigned int scancode, keycode;
};
-#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
+static const int KDSETKEYCODE = 0x4B4D; /* write kernel keycode table entry */
extern int
setkeycodes_main(int argc, char** argv)
#include <dirent.h>
#include <errno.h>
-#define LN_SYMLINK 1
-#define LN_FORCE 2
-#define LN_NODEREFERENCE 4
+static const int LN_SYMLINK = 1;
+static const int LN_FORCE = 2;
+static const int LN_NODEREFERENCE = 4;
/*
* linkDestName is where the link points to,
* 1. requires lstat (BSD) - how do you do it without?
*/
-#define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */
-#define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */
-#define COLUMN_GAP 2 /* includes the file type char, if present */
+static const int TERMINAL_WIDTH = 80; /* use 79 if your terminal has linefold bug */
+static const int COLUMN_WIDTH = 14; /* default if AUTOWIDTH not defined */
+static const int COLUMN_GAP = 2; /* includes the file type char, if present */
/************************************************************************/
#endif
/* what is the overall style of the listing */
-#define STYLE_AUTO 0
-#define STYLE_LONG 1 /* one record per line, extended info */
-#define STYLE_SINGLE 2 /* one record per line */
-#define STYLE_COLUMNS 3 /* fill columns */
+enum {
+STYLE_AUTO = 0,
+STYLE_LONG = 1, /* one record per line, extended info */
+STYLE_SINGLE = 2, /* one record per line */
+STYLE_COLUMNS = 3 /* fill columns */
+};
/* 51306 lrwxrwxrwx 1 root root 2 May 11 01:43 /bin/view -> vi* */
/* what file information will be listed */
#ifdef BB_FEATURE_LS_SORTFILES
/* how will the files be sorted */
-#define SORT_FORWARD 0 /* sort in reverse order */
-#define SORT_REVERSE 1 /* sort in reverse order */
-#define SORT_NAME 2 /* sort by file name */
-#define SORT_SIZE 3 /* sort by file size */
-#define SORT_ATIME 4 /* sort by last access time */
-#define SORT_CTIME 5 /* sort by last change time */
-#define SORT_MTIME 6 /* sort by last modification time */
-#define SORT_VERSION 7 /* sort by version */
-#define SORT_EXT 8 /* sort by file name extension */
-#define SORT_DIR 9 /* sort by file or directory */
+static const int SORT_FORWARD = 0; /* sort in reverse order */
+static const int SORT_REVERSE = 1; /* sort in reverse order */
+static const int SORT_NAME = 2; /* sort by file name */
+static const int SORT_SIZE = 3; /* sort by file size */
+static const int SORT_ATIME = 4; /* sort by last access time */
+static const int SORT_CTIME = 5; /* sort by last change time */
+static const int SORT_MTIME = 6; /* sort by last modification time */
+static const int SORT_VERSION = 7; /* sort by version */
+static const int SORT_EXT = 8; /* sort by file name extension */
+static const int SORT_DIR = 9; /* sort by file or directory */
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
/* which of the three times will be used */
-#define TIME_MOD 0
-#define TIME_CHANGE 1
-#define TIME_ACCESS 2
+static const int TIME_MOD = 0;
+static const int TIME_CHANGE = 1;
+static const int TIME_ACCESS = 2;
#endif
#define LIST_SHORT (LIST_FILENAME)
LIST_SYMLINK)
#define LIST_ILONG (LIST_INO | LIST_LONG)
-#define SPLIT_DIR 0
-#define SPLIT_FILE 1
-#define SPLIT_SUBDIR 2
+static const int SPLIT_DIR = 0;
+static const int SPLIT_FILE = 1;
+static const int SPLIT_SUBDIR = 2;
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
struct dnode **dnalloc(int);
int list_single(struct dnode *);
-static unsigned int disp_opts= DISP_NORMAL;
-static unsigned int style_fmt= STYLE_AUTO ;
-static unsigned int list_fmt= LIST_SHORT ;
+static unsigned int disp_opts;
+static unsigned int style_fmt;
+static unsigned int list_fmt;
#ifdef BB_FEATURE_LS_SORTFILES
-static unsigned int sort_opts= SORT_FORWARD;
-static unsigned int sort_order= SORT_FORWARD;
+static unsigned int sort_opts;
+static unsigned int sort_order;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
-static unsigned int time_fmt= TIME_MOD;
+static unsigned int time_fmt;
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
static unsigned int follow_links=FALSE;
static unsigned short column = 0;
#ifdef BB_FEATURE_AUTOWIDTH
-static unsigned short terminal_width = TERMINAL_WIDTH;
-static unsigned short column_width = COLUMN_WIDTH;
-static unsigned short tabstops = 8;
-#else
-#define terminal_width TERMINAL_WIDTH
-#define column_width COLUMN_WIDTH
+static unsigned short terminal_width;
+static unsigned short column_width;
+static unsigned short tabstops;
#endif
static int status = EXIT_SUCCESS;
list_fmt= LIST_SHORT;
#ifdef BB_FEATURE_LS_SORTFILES
sort_opts= SORT_NAME;
+ sort_order= SORT_FORWARD;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
time_fmt= TIME_MOD;
+#endif
+#ifdef BB_FEATURE_AUTOWIDTH
+ terminal_width = TERMINAL_WIDTH;
+ column_width = COLUMN_WIDTH;
+ tabstops = 8;
#endif
nfiles=0;
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _MD5_H
-#define _MD5_H 1
+static const int _MD5_H = 1;
#include <stdio.h>
int md5_stream(FILE *stream, void *resblock)
{
/* Important: BLOCKSIZE must be a multiple of 64. */
-#define BLOCKSIZE 4096
+static const int BLOCKSIZE = 4096;
struct md5_ctx ctx;
char buffer[BLOCKSIZE + 72];
size_t sum;
/* The minimum length of a valid digest line in a file produced
by `md5sum FILE' and read by `md5sum -c'. This length does
not include any newline character at the end of a line. */
-#define MIN_DIGEST_LINE_LENGTH 35 /* 32 - message digest length
+static const int MIN_DIGEST_LINE_LENGTH = 35; /* 32 - message digest length
2 - blank and binary indicator
1 - minimum filename length */
#ifndef S_IFMT
-# define S_IFMT 0170000
+static const int S_IFMT = 0170000;
#endif
#if !defined(S_ISBLK) && defined(S_IFBLK)
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define bb_need_write_error
#include "messages.c"
-#define ASCII 0377
+static const int ASCII = 0377;
/* some glabals shared across this file */
static char com_fl, del_fl, sq_fl;
-static unsigned char output[BUFSIZ], input[BUFSIZ];
-static unsigned char vector[ASCII + 1];
-static char invec[ASCII + 1], outvec[ASCII + 1];
static short in_index, out_index;
+/* these last are pointers to static buffers declared in tr_main */
+static unsigned char *poutput, *pinput;
+static unsigned char *pvector;
+static char *pinvec, *poutvec;
static void convert()
for (;;) {
if (in_index == read_chars) {
- if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) {
- if (write(1, (char *) output, out_index) != out_index)
+ if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) {
+ if (write(1, (char *) poutput, out_index) != out_index)
write(2, write_error, strlen(write_error));
exit(0);
}
in_index = 0;
}
- c = input[in_index++];
- coded = vector[c];
- if (del_fl && invec[c])
+ c = pinput[in_index++];
+ coded = pvector[c];
+ if (del_fl && pinvec[c])
continue;
- if (sq_fl && last == coded && (invec[c] || outvec[coded]))
+ if (sq_fl && last == coded && (pinvec[c] || poutvec[coded]))
continue;
- output[out_index++] = last = coded;
+ poutput[out_index++] = last = coded;
if (out_index == BUFSIZ) {
- if (write(1, (char *) output, out_index) != out_index) {
+ if (write(1, (char *) poutput, out_index) != out_index) {
write(2, write_error, strlen(write_error));
exit(1);
}
for (j = 0, i = 0; i < string1_len; i++) {
if (string2_len <= j)
- vector[string1[i]] = last;
+ pvector[string1[i]] = last;
else
- vector[string1[i]] = last = string2[j++];
+ pvector[string1[i]] = last = string2[j++];
}
}
int output_length=0, input_length;
int index = 1;
int i;
+ /* set up big arrays here (better than making a bunch of static arrays up top) */
+ unsigned char output[BUFSIZ], input[BUFSIZ];
+ unsigned char vector[ASCII + 1];
+ char invec[ASCII + 1], outvec[ASCII + 1];
+
+ /* ... but make them available globally */
+ poutput = output;
+ pinput = input;
+ pvector = vector;
+ pinvec = invec;
+ poutvec = outvec;
if (argc > 1 && argv[index][0] == '-') {
for (ptr = (unsigned char *) &argv[index][1]; *ptr; ptr++) {
/* Values that are bitwise or'd into `toprint'. */
/* Operating system name. */
-#define PRINT_SYSNAME 1
+static const int PRINT_SYSNAME = 1;
/* Node name on a communications network. */
-#define PRINT_NODENAME 2
+static const int PRINT_NODENAME = 2;
/* Operating system release. */
-#define PRINT_RELEASE 4
+static const int PRINT_RELEASE = 4;
/* Operating system version. */
-#define PRINT_VERSION 8
+static const int PRINT_VERSION = 8;
/* Machine hardware name. */
-#define PRINT_MACHINE 16
+static const int PRINT_MACHINE = 16;
/* Host processor type. */
-#define PRINT_PROCESSOR 32
+static const int PRINT_PROCESSOR = 32;
/* Mask indicating which elements of the name to print. */
static unsigned char toprint;
#include <errno.h>
#include <getopt.h>
-#define is_cp 0
-#define is_mv 1
+static const int is_cp = 0;
+static const int is_mv = 1;
static int dz_i; /* index into cp_mv_usage */
static const char *cp_mv_usage[] = /* .rodata */
static int srcDirFlag;
static struct stat srcStatBuf;
-static char baseDestName[BUFSIZ + 1];
+static char *pBaseDestName;
static size_t baseDestLen;
static int destDirFlag;
static struct stat destStatBuf;
const char *srcBasename;
char *name;
- strcpy(destName, baseDestName);
+ strcpy(destName, pBaseDestName);
destLen = strlen(destName);
if (srcDirFlag == TRUE) {
{
volatile int i;
int c;
+ char baseDestName[BUFSIZ + 1]; /* not declared globally == less bss used */
+ pBaseDestName = baseDestName; /* but available globally */
if (*applet_name == 'c' && *(applet_name + 1) == 'p')
dz_i = is_cp;
#include <sys/ioctl.h>
/* From <linux/vt.h> */
-#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
+static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
int deallocvt_main(int argc, char *argv[])
{
unsigned char kb_index;
unsigned short kb_value;
};
-#define KDGKBENT 0x4B46 /* gets one entry in translation table */
+static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
/* From <linux/keyboard.h> */
-#define NR_KEYS 128
-#define MAX_NR_KEYMAPS 256
+static const int NR_KEYS = 128;
+static const int MAX_NR_KEYMAPS = 256;
int dumpkmap_main(int argc, char **argv)
{
#define DEFAULTFBDEV "/dev/fb0"
#define DEFAULTFBMODE "/etc/fb.modes"
-#define OPT_CHANGE 1
-#define OPT_INFO (1 << 1)
-#define OPT_READMODE (1 << 2)
-
-#define CMD_HELP 0
-#define CMD_FB 1
-#define CMD_DB 2
-#define CMD_GEOMETRY 3
-#define CMD_TIMING 4
-#define CMD_ACCEL 5
-#define CMD_HSYNC 6
-#define CMD_VSYNC 7
-#define CMD_LACED 8
-#define CMD_DOUBLE 9
-/* #define CMD_XCOMPAT 10 */
-#define CMD_ALL 11
-#define CMD_INFO 12
-#define CMD_CHANGE 13
+static const int OPT_CHANGE = (1 << 0);
+static const int OPT_INFO = (1 << 1);
+static const int OPT_READMODE = (1 << 2);
+
+enum {
+ CMD_HELP = 0,
+ CMD_FB = 1,
+ CMD_DB = 2,
+ CMD_GEOMETRY = 3,
+ CMD_TIMING = 4,
+ CMD_ACCEL = 5,
+ CMD_HSYNC = 6,
+ CMD_VSYNC = 7,
+ CMD_LACED = 8,
+ CMD_DOUBLE = 9,
+/* CMD_XCOMPAT = 10, */
+ CMD_ALL = 11,
+ CMD_INFO = 12,
+ CMD_CHANGE = 13,
#ifdef BB_FEATURE_FBSET_FANCY
-#define CMD_XRES 100
-#define CMD_YRES 101
-#define CMD_VXRES 102
-#define CMD_VYRES 103
-#define CMD_DEPTH 104
-#define CMD_MATCH 105
-#define CMD_PIXCLOCK 106
-#define CMD_LEFT 107
-#define CMD_RIGHT 108
-#define CMD_UPPER 109
-#define CMD_LOWER 110
-#define CMD_HSLEN 111
-#define CMD_VSLEN 112
-#define CMD_CSYNC 113
-#define CMD_GSYNC 114
-#define CMD_EXTSYNC 115
-#define CMD_BCAST 116
-#define CMD_RGBA 117
-#define CMD_STEP 118
-#define CMD_MOVE 119
+ CMD_XRES = 100,
+ CMD_YRES = 101,
+ CMD_VXRES = 102,
+ CMD_VYRES = 103,
+ CMD_DEPTH = 104,
+ CMD_MATCH = 105,
+ CMD_PIXCLOCK = 106,
+ CMD_LEFT = 107,
+ CMD_RIGHT = 108,
+ CMD_UPPER = 109,
+ CMD_LOWER = 110,
+ CMD_HSLEN = 111,
+ CMD_VSLEN = 112,
+ CMD_CSYNC = 113,
+ CMD_GSYNC = 114,
+ CMD_EXTSYNC = 115,
+ CMD_BCAST = 116,
+ CMD_RGBA = 117,
+ CMD_STEP = 118,
+ CMD_MOVE = 119,
#endif
+};
static unsigned int g_options = 0;
/* Stuff stolen from the kernel's fb.h */
-#define FBIOGET_VSCREENINFO 0x4600
-#define FBIOPUT_VSCREENINFO 0x4601
+static const int FBIOGET_VSCREENINFO = 0x4600;
+static const int FBIOPUT_VSCREENINFO = 0x4601;
#define __u32 unsigned int
struct fb_bitfield {
__u32 offset; /* beginning of bitfield */
#ifdef BB_FEATURE_FBSET_READMODE
/* taken from linux/fb.h */
-#define FB_VMODE_INTERLACED 1 /* interlaced */
-#define FB_VMODE_DOUBLE 2 /* double scan */
-#define FB_SYNC_HOR_HIGH_ACT 1 /* horizontal sync high active */
-#define FB_SYNC_VERT_HIGH_ACT 2 /* vertical sync high active */
-#define FB_SYNC_EXT 4 /* external sync */
-#define FB_SYNC_COMP_HIGH_ACT 8 /* composite sync high active */
+static const int FB_VMODE_INTERLACED = 1; /* interlaced */
+static const int FB_VMODE_DOUBLE = 2; /* double scan */
+static const int FB_SYNC_HOR_HIGH_ACT = 1; /* horizontal sync high active */
+static const int FB_SYNC_VERT_HIGH_ACT = 2; /* vertical sync high active */
+static const int FB_SYNC_EXT = 4; /* external sync */
+static const int FB_SYNC_COMP_HIGH_ACT = 8; /* composite sync high active */
#endif
static int readmode(struct fb_var_screeninfo *base, const char *fn,
const char *mode)
typedef unsigned int u32;
-#define MINIX_ROOT_INO 1
-#define MINIX_LINK_MAX 250
-#define MINIX2_LINK_MAX 65530
-
-#define MINIX_I_MAP_SLOTS 8
-#define MINIX_Z_MAP_SLOTS 64
-#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
-#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
-#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
-#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
-#define MINIX_VALID_FS 0x0001 /* Clean fs. */
-#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
+static const int MINIX_ROOT_INO = 1;
+static const int MINIX_LINK_MAX = 250;
+static const int MINIX2_LINK_MAX = 65530;
+
+static const int MINIX_I_MAP_SLOTS = 8;
+static const int MINIX_Z_MAP_SLOTS = 64;
+static const int MINIX_SUPER_MAGIC = 0x137F; /* original minix fs */
+static const int MINIX_SUPER_MAGIC2 = 0x138F; /* minix fs, 30 char names */
+static const int MINIX2_SUPER_MAGIC = 0x2468; /* minix V2 fs */
+static const int MINIX2_SUPER_MAGIC2 = 0x2478; /* minix V2 fs, 30 char names */
+static const int MINIX_VALID_FS = 0x0001; /* Clean fs. */
+static const int MINIX_ERROR_FS = 0x0002; /* fs has errors. */
#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
#define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode)))
-#define MINIX_V1 0x0001 /* original minix fs */
-#define MINIX_V2 0x0002 /* minix V2 fs */
+static const int MINIX_V1 = 0x0001; /* original minix fs */
+static const int MINIX_V2 = 0x0002; /* minix V2 fs */
#define INODE_VERSION(inode) inode->i_sb->u.minix_sb.s_version
#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
-#define MINIX_VALID_FS 0x0001 /* Clean fs. */
-#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
-
-#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
-#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
-
#ifndef BLKGETSIZE
#define BLKGETSIZE _IO(0x12,96) /* return device size */
#endif
#define volatile
#endif
-#define ROOT_INO 1
+static const int ROOT_INO = 1;
#define UPPER(size,n) ((size+((n)-1))/(n))
#define INODE_SIZE (sizeof(struct minix_inode))
static int termios_set = 0;
/* File-name data */
-#define MAX_DEPTH 32
+static const int MAX_DEPTH = 32;
static int name_depth = 0;
// static char name_list[MAX_DEPTH][BUFSIZ + 1];
static char **name_list = NULL;
/* NON_OPT is the code that is returned when a non-option is found in '+'
mode */
-#define NON_OPT 1
+static const int NON_OPT = 1;
/* LONG_OPT is the code that is returned when a long option is found. */
-#define LONG_OPT 2
+static const int LONG_OPT = 2;
/* The shells recognized. */
typedef enum {BASH,TCSH} shell_t;
static struct option *long_options=NULL;
static int long_options_length=0; /* Length of array */
static int long_options_nr=0; /* Nr of used elements in array */
-#define LONG_OPTIONS_INCR 10
+static const int LONG_OPTIONS_INCR = 10;
#define init_longopt() add_longopt(NULL,0)
/* Register a long option. The contents of name is copied. */
#define bb_need_name_too_long
#include "messages.c"
-#define RECORD_IO 0
+static const int RECORD_IO = 0;
/* Return codes from gzip */
-#define OK 0
-#define ERROR 1
-#define WARNING 2
+static const int OK = 0;
+static const int ERROR = 1;
+static const int WARNING = 2;
-#define DEFLATED 8
-#define INBUFSIZ 0x2000 /* input buffer size */
-#define INBUF_EXTRA 64 /* required by unlzw() */
-#define OUTBUFSIZ 8192 /* output buffer size */
-#define OUTBUF_EXTRA 2048 /* required by unlzw() */
-#define DIST_BUFSIZE 0x2000 /* buffer for distances, see trees.c */
+static const int DEFLATED = 8;
+static const int INBUFSIZ = 0x2000; /* input buffer size */
+static const int INBUF_EXTRA = 64; /* required by unlzw() */
+static const int OUTBUFSIZ = 8192; /* output buffer size */
+static const int OUTBUF_EXTRA = 2048; /* required by unlzw() */
+static const int DIST_BUFSIZE = 0x2000; /* buffer for distances, see trees.c */
#define GZIP_MAGIC "\037\213" /* Magic header for gzip files, 1F 8B */
/* gzip flag byte */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define WSIZE 0x8000 /* window size--must be a power of two, and */
+static const int EXTRA_FIELD = 0x04; /* bit 2 set: extra field present */
+static const int ORIG_NAME = 0x08; /* bit 3 set: original file name present */
+static const int COMMENT = 0x10; /* bit 4 set: file comment present */
+static const int WSIZE = 0x8000; /* window size--must be a power of two, and */
/* at least 32K for zip's deflate method */
/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
-#define BMAX 16 /* maximum bit length of any code (16 for explode) */
-#define N_MAX 288 /* maximum number of codes in any set */
+static const int BMAX = 16; /* maximum bit length of any code (16 for explode) */
+static const int N_MAX = 288; /* maximum number of codes in any set */
/* PKZIP header definitions */
-#define LOCSIG 0x04034b50L /* four-byte lead-in (lsb first) */
-#define LOCCRC 14 /* offset of crc */
-#define LOCLEN 22 /* offset of uncompressed length */
-#define EXTHDR 16 /* size of extended local header, inc sig */
+static const int LOCSIG = 0x04034b50L; /* four-byte lead-in (lsb first) */
+static const int LOCCRC = 14; /* offset of crc */
+static const int LOCLEN = 22; /* offset of uncompressed length */
+static const int EXTHDR = 16; /* size of extended local header, inc sig */
-#define BITS 16
+static const int BITS = 16;
/* Diagnostic functions */
#ifdef DEBUG
# ifdef BUFSIZ
# define MAX_PATH_LEN BUFSIZ
# else
-# define MAX_PATH_LEN 1024
+static const int MAX_PATH_LEN = 1024;
# endif
#endif
/* local variables */
static int test_mode = 0; /* check file integrity option */
static int foreground; /* set if program run in foreground */
-static int method = DEFLATED; /* compression method */
-static int exit_code = OK; /* program exit code */
+static int method; /* compression method */
+static int exit_code; /* program exit code */
static int last_member; /* set for .zip and .Z files */
static int part_nb; /* number of parts in .gz file */
static long ifile_size; /* input file size, -1 for devices (debug only) */
char ifname[MAX_PATH_LEN + 1]; /* input file name */
char ofname[MAX_PATH_LEN + 1]; /* output file name */
+ method = DEFLATED; /* default compression method */
+ exit_code = OK; /* let's go out on a limb and assume everything will run fine (wink wink) */
+
if (strcmp(applet_name, "zcat") == 0) {
force = 1;
tostdout = 1;
unsigned short v_signal; /* signal to send */
unsigned short v_state; /* vt bitmask */
};
-#define VT_GETSTATE 0x5603 /* get global vt state info */
+static const int VT_GETSTATE = 0x5603; /* get global vt state info */
/* From <linux/serial.h> */
struct serial_struct {
#ifndef RB_HALT_SYSTEM
-#define RB_HALT_SYSTEM 0xcdef0123
-#define RB_ENABLE_CAD 0x89abcdef
-#define RB_DISABLE_CAD 0
+static const int RB_HALT_SYSTEM = 0xcdef0123;
+static const int RB_ENABLE_CAD = 0x89abcdef;
+static const int RB_DISABLE_CAD = 0;
#define RB_POWER_OFF 0x4321fedc
-#define RB_AUTOBOOT 0x01234567
+static const int RB_AUTOBOOT = 0x01234567;
#if defined(__GLIBC__) || defined (__UCLIBC__)
#include <sys/reboot.h>
#define init_reboot(magic) reboot(magic)
#define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */
#endif
-#define LOG 0x1
-#define CONSOLE 0x2
+static const int LOG = 0x1;
+static const int CONSOLE = 0x2;
/* Allowed init action types */
typedef enum {
unsigned short v_signal; /* signal to send */
unsigned short v_state; /* vt bitmask */
};
-#define VT_GETSTATE 0x5603 /* get global vt state info */
+static const int VT_GETSTATE = 0x5603; /* get global vt state info */
/* From <linux/serial.h> */
struct serial_struct {
#ifndef RB_HALT_SYSTEM
-#define RB_HALT_SYSTEM 0xcdef0123
-#define RB_ENABLE_CAD 0x89abcdef
-#define RB_DISABLE_CAD 0
+static const int RB_HALT_SYSTEM = 0xcdef0123;
+static const int RB_ENABLE_CAD = 0x89abcdef;
+static const int RB_DISABLE_CAD = 0;
#define RB_POWER_OFF 0x4321fedc
-#define RB_AUTOBOOT 0x01234567
+static const int RB_AUTOBOOT = 0x01234567;
#if defined(__GLIBC__) || defined (__UCLIBC__)
#include <sys/reboot.h>
#define init_reboot(magic) reboot(magic)
#define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */
#endif
-#define LOG 0x1
-#define CONSOLE 0x2
+static const int LOG = 0x1;
+static const int CONSOLE = 0x2;
/* Allowed init action types */
typedef enum {
#ifndef MODUTILS_MODULE_H
-#define MODUTILS_MODULE_H 1
+static const int MODUTILS_MODULE_H = 1;
-#ident "$Id: insmod.c,v 1.35 2001/01/04 02:00:17 kraai Exp $"
+#ident "$Id: insmod.c,v 1.36 2001/01/23 22:30:04 markw Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
};
/* Sent to init_module(2) or'ed into the code size parameter. */
-#define OLD_MOD_AUTOCLEAN 0x40000000 /* big enough, but no sign problems... */
+static const int OLD_MOD_AUTOCLEAN = 0x40000000; /* big enough, but no sign problems... */
int get_kernel_syms(struct old_kernel_sym *);
int old_sys_init_module(const char *name, char *code, unsigned codesize,
#undef tgt_sizeof_char_p
#undef tgt_sizeof_void_p
#undef tgt_long
-#define tgt_sizeof_long 8
-#define tgt_sizeof_char_p 8
-#define tgt_sizeof_void_p 8
+static const int tgt_sizeof_long = 8;
+static const int tgt_sizeof_char_p = 8;
+static const int tgt_sizeof_void_p = 8;
#define tgt_long long long
#endif
};
/* Bits of module.flags. */
-#define NEW_MOD_RUNNING 1
-#define NEW_MOD_DELETED 2
-#define NEW_MOD_AUTOCLEAN 4
-#define NEW_MOD_VISITED 8
-#define NEW_MOD_USED_ONCE 16
+static const int NEW_MOD_RUNNING = 1;
+static const int NEW_MOD_DELETED = 2;
+static const int NEW_MOD_AUTOCLEAN = 4;
+static const int NEW_MOD_VISITED = 8;
+static const int NEW_MOD_USED_ONCE = 16;
int new_sys_init_module(const char *name, const struct new_module *);
int query_module(const char *name, int which, void *buf, size_t bufsize,
/* Values for query_module's which. */
-#define QM_MODULES 1
-#define QM_DEPS 2
-#define QM_REFS 3
-#define QM_SYMBOLS 4
-#define QM_INFO 5
+static const int QM_MODULES = 1;
+static const int QM_DEPS = 2;
+static const int QM_REFS = 3;
+static const int QM_SYMBOLS = 4;
+static const int QM_INFO = 5;
/*======================================================================*/
/* The system calls unchanged between 2.0 and 2.1. */
#ifndef MODUTILS_OBJ_H
-#define MODUTILS_OBJ_H 1
+static const int MODUTILS_OBJ_H = 1;
-#ident "$Id: insmod.c,v 1.35 2001/01/04 02:00:17 kraai Exp $"
+#ident "$Id: insmod.c,v 1.36 2001/01/23 22:30:04 markw Exp $"
/* The relocatable object is manipulated using elfin types. */
#define _PATH_MODULES "/lib/modules"
-#define STRVERSIONLEN 32
+static const int STRVERSIONLEN = 32;
#if !defined(BB_FEATURE_INSMOD_NEW_KERNEL) && !defined(BB_FEATURE_INSMOD_OLD_KERNEL)
#error "Must have ether BB_FEATURE_INSMOD_NEW_KERNEL or BB_FEATURE_INSMOD_OLD_KERNEL defined"
#include <ctype.h>
#include <unistd.h>
-#define KILL 0
-#define KILLALL 1
+static const int KILL = 0;
+static const int KILLALL = 1;
struct signal_name {
const char *name;
#include <getopt.h>
#include "cmdedit.h"
-#define MAX_LINE 256 /* size of input buffer for cwd data */
-#define MAX_READ 128 /* size of input buffer for `read' builtin */
+static const int MAX_LINE = 256; /* size of input buffer for cwd data */
+static const int MAX_READ = 128; /* size of input buffer for `read' builtin */
#define JOB_STATUS_FORMAT "[%d] %-22s %.40s\n"
extern size_t NUM_APPLETS;
#include <dirent.h>
#include <errno.h>
-#define LN_SYMLINK 1
-#define LN_FORCE 2
-#define LN_NODEREFERENCE 4
+static const int LN_SYMLINK = 1;
+static const int LN_FORCE = 2;
+static const int LN_NODEREFERENCE = 4;
/*
* linkDestName is where the link points to,
#include <sys/kd.h>
#include <endian.h>
-#define PSF_MAGIC1 0x36
-#define PSF_MAGIC2 0x04
+static const int PSF_MAGIC1 = 0x36;
+static const int PSF_MAGIC2 = 0x04;
-#define PSF_MODE512 0x01
-#define PSF_MODEHASTAB 0x02
-#define PSF_MAXMODE 0x03
-#define PSF_SEPARATOR 0xFFFF
+static const int PSF_MODE512 = 0x01;
+static const int PSF_MODEHASTAB = 0x02;
+static const int PSF_MAXMODE = 0x03;
+static const int PSF_SEPARATOR = 0xFFFF;
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
unsigned char kb_index;
unsigned short kb_value;
};
-#define KDSKBENT 0x4B47 /* sets one entry in translation table */
+static const int KDSKBENT = 0x4B47; /* sets one entry in translation table */
/* From <linux/keyboard.h> */
-#define NR_KEYS 128
-#define MAX_NR_KEYMAPS 256
+static const int NR_KEYS = 128;
+static const int MAX_NR_KEYMAPS = 256;
int loadkmap_main(int argc, char **argv)
{
* 1. requires lstat (BSD) - how do you do it without?
*/
-#define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */
-#define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */
-#define COLUMN_GAP 2 /* includes the file type char, if present */
+static const int TERMINAL_WIDTH = 80; /* use 79 if your terminal has linefold bug */
+static const int COLUMN_WIDTH = 14; /* default if AUTOWIDTH not defined */
+static const int COLUMN_GAP = 2; /* includes the file type char, if present */
/************************************************************************/
#endif
/* what is the overall style of the listing */
-#define STYLE_AUTO 0
-#define STYLE_LONG 1 /* one record per line, extended info */
-#define STYLE_SINGLE 2 /* one record per line */
-#define STYLE_COLUMNS 3 /* fill columns */
+enum {
+STYLE_AUTO = 0,
+STYLE_LONG = 1, /* one record per line, extended info */
+STYLE_SINGLE = 2, /* one record per line */
+STYLE_COLUMNS = 3 /* fill columns */
+};
/* 51306 lrwxrwxrwx 1 root root 2 May 11 01:43 /bin/view -> vi* */
/* what file information will be listed */
#ifdef BB_FEATURE_LS_SORTFILES
/* how will the files be sorted */
-#define SORT_FORWARD 0 /* sort in reverse order */
-#define SORT_REVERSE 1 /* sort in reverse order */
-#define SORT_NAME 2 /* sort by file name */
-#define SORT_SIZE 3 /* sort by file size */
-#define SORT_ATIME 4 /* sort by last access time */
-#define SORT_CTIME 5 /* sort by last change time */
-#define SORT_MTIME 6 /* sort by last modification time */
-#define SORT_VERSION 7 /* sort by version */
-#define SORT_EXT 8 /* sort by file name extension */
-#define SORT_DIR 9 /* sort by file or directory */
+static const int SORT_FORWARD = 0; /* sort in reverse order */
+static const int SORT_REVERSE = 1; /* sort in reverse order */
+static const int SORT_NAME = 2; /* sort by file name */
+static const int SORT_SIZE = 3; /* sort by file size */
+static const int SORT_ATIME = 4; /* sort by last access time */
+static const int SORT_CTIME = 5; /* sort by last change time */
+static const int SORT_MTIME = 6; /* sort by last modification time */
+static const int SORT_VERSION = 7; /* sort by version */
+static const int SORT_EXT = 8; /* sort by file name extension */
+static const int SORT_DIR = 9; /* sort by file or directory */
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
/* which of the three times will be used */
-#define TIME_MOD 0
-#define TIME_CHANGE 1
-#define TIME_ACCESS 2
+static const int TIME_MOD = 0;
+static const int TIME_CHANGE = 1;
+static const int TIME_ACCESS = 2;
#endif
#define LIST_SHORT (LIST_FILENAME)
LIST_SYMLINK)
#define LIST_ILONG (LIST_INO | LIST_LONG)
-#define SPLIT_DIR 0
-#define SPLIT_FILE 1
-#define SPLIT_SUBDIR 2
+static const int SPLIT_DIR = 0;
+static const int SPLIT_FILE = 1;
+static const int SPLIT_SUBDIR = 2;
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
struct dnode **dnalloc(int);
int list_single(struct dnode *);
-static unsigned int disp_opts= DISP_NORMAL;
-static unsigned int style_fmt= STYLE_AUTO ;
-static unsigned int list_fmt= LIST_SHORT ;
+static unsigned int disp_opts;
+static unsigned int style_fmt;
+static unsigned int list_fmt;
#ifdef BB_FEATURE_LS_SORTFILES
-static unsigned int sort_opts= SORT_FORWARD;
-static unsigned int sort_order= SORT_FORWARD;
+static unsigned int sort_opts;
+static unsigned int sort_order;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
-static unsigned int time_fmt= TIME_MOD;
+static unsigned int time_fmt;
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
static unsigned int follow_links=FALSE;
static unsigned short column = 0;
#ifdef BB_FEATURE_AUTOWIDTH
-static unsigned short terminal_width = TERMINAL_WIDTH;
-static unsigned short column_width = COLUMN_WIDTH;
-static unsigned short tabstops = 8;
-#else
-#define terminal_width TERMINAL_WIDTH
-#define column_width COLUMN_WIDTH
+static unsigned short terminal_width;
+static unsigned short column_width;
+static unsigned short tabstops;
#endif
static int status = EXIT_SUCCESS;
list_fmt= LIST_SHORT;
#ifdef BB_FEATURE_LS_SORTFILES
sort_opts= SORT_NAME;
+ sort_order= SORT_FORWARD;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
time_fmt= TIME_MOD;
+#endif
+#ifdef BB_FEATURE_AUTOWIDTH
+ terminal_width = TERMINAL_WIDTH;
+ column_width = COLUMN_WIDTH;
+ tabstops = 8;
#endif
nfiles=0;
size_t *ret);
/* Values for query_module's which. */
-#define QM_MODULES 1
-#define QM_DEPS 2
-#define QM_REFS 3
-#define QM_SYMBOLS 4
-#define QM_INFO 5
+static const int QM_MODULES = 1;
+static const int QM_DEPS = 2;
+static const int QM_REFS = 3;
+static const int QM_SYMBOLS = 4;
+static const int QM_INFO = 5;
/* Bits of module.flags. */
-#define NEW_MOD_RUNNING 1
-#define NEW_MOD_DELETED 2
-#define NEW_MOD_AUTOCLEAN 4
-#define NEW_MOD_VISITED 8
-#define NEW_MOD_USED_ONCE 16
-#define NEW_MOD_INITIALIZING 64
+static const int NEW_MOD_RUNNING = 1;
+static const int NEW_MOD_DELETED = 2;
+static const int NEW_MOD_AUTOCLEAN = 4;
+static const int NEW_MOD_VISITED = 8;
+static const int NEW_MOD_USED_ONCE = 16;
+static const int NEW_MOD_INITIALIZING = 64;
extern int lsmod_main(int argc, char **argv)
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _MD5_H
-#define _MD5_H 1
+static const int _MD5_H = 1;
#include <stdio.h>
int md5_stream(FILE *stream, void *resblock)
{
/* Important: BLOCKSIZE must be a multiple of 64. */
-#define BLOCKSIZE 4096
+static const int BLOCKSIZE = 4096;
struct md5_ctx ctx;
char buffer[BLOCKSIZE + 72];
size_t sum;
/* The minimum length of a valid digest line in a file produced
by `md5sum FILE' and read by `md5sum -c'. This length does
not include any newline character at the end of a line. */
-#define MIN_DIGEST_LINE_LENGTH 35 /* 32 - message digest length
+static const int MIN_DIGEST_LINE_LENGTH = 35; /* 32 - message digest length
2 - blank and binary indicator
1 - minimum filename length */
#ifndef _IO
/* pre-1.3.45 */
-#define BLKGETSIZE 0x1260
+static const int BLKGETSIZE = 0x1260;
#else
/* same on i386, m68k, arm; different on alpha, mips, sparc, ppc */
#define BLKGETSIZE _IO(0x12,96)
#ifndef MODUTILS_MODULE_H
-#define MODUTILS_MODULE_H 1
+static const int MODUTILS_MODULE_H = 1;
-#ident "$Id: insmod.c,v 1.35 2001/01/04 02:00:17 kraai Exp $"
+#ident "$Id: insmod.c,v 1.36 2001/01/23 22:30:04 markw Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
};
/* Sent to init_module(2) or'ed into the code size parameter. */
-#define OLD_MOD_AUTOCLEAN 0x40000000 /* big enough, but no sign problems... */
+static const int OLD_MOD_AUTOCLEAN = 0x40000000; /* big enough, but no sign problems... */
int get_kernel_syms(struct old_kernel_sym *);
int old_sys_init_module(const char *name, char *code, unsigned codesize,
#undef tgt_sizeof_char_p
#undef tgt_sizeof_void_p
#undef tgt_long
-#define tgt_sizeof_long 8
-#define tgt_sizeof_char_p 8
-#define tgt_sizeof_void_p 8
+static const int tgt_sizeof_long = 8;
+static const int tgt_sizeof_char_p = 8;
+static const int tgt_sizeof_void_p = 8;
#define tgt_long long long
#endif
};
/* Bits of module.flags. */
-#define NEW_MOD_RUNNING 1
-#define NEW_MOD_DELETED 2
-#define NEW_MOD_AUTOCLEAN 4
-#define NEW_MOD_VISITED 8
-#define NEW_MOD_USED_ONCE 16
+static const int NEW_MOD_RUNNING = 1;
+static const int NEW_MOD_DELETED = 2;
+static const int NEW_MOD_AUTOCLEAN = 4;
+static const int NEW_MOD_VISITED = 8;
+static const int NEW_MOD_USED_ONCE = 16;
int new_sys_init_module(const char *name, const struct new_module *);
int query_module(const char *name, int which, void *buf, size_t bufsize,
/* Values for query_module's which. */
-#define QM_MODULES 1
-#define QM_DEPS 2
-#define QM_REFS 3
-#define QM_SYMBOLS 4
-#define QM_INFO 5
+static const int QM_MODULES = 1;
+static const int QM_DEPS = 2;
+static const int QM_REFS = 3;
+static const int QM_SYMBOLS = 4;
+static const int QM_INFO = 5;
/*======================================================================*/
/* The system calls unchanged between 2.0 and 2.1. */
#ifndef MODUTILS_OBJ_H
-#define MODUTILS_OBJ_H 1
+static const int MODUTILS_OBJ_H = 1;
-#ident "$Id: insmod.c,v 1.35 2001/01/04 02:00:17 kraai Exp $"
+#ident "$Id: insmod.c,v 1.36 2001/01/23 22:30:04 markw Exp $"
/* The relocatable object is manipulated using elfin types. */
#define _PATH_MODULES "/lib/modules"
-#define STRVERSIONLEN 32
+static const int STRVERSIONLEN = 32;
#if !defined(BB_FEATURE_INSMOD_NEW_KERNEL) && !defined(BB_FEATURE_INSMOD_OLD_KERNEL)
#error "Must have ether BB_FEATURE_INSMOD_NEW_KERNEL or BB_FEATURE_INSMOD_OLD_KERNEL defined"
size_t *ret);
/* Values for query_module's which. */
-#define QM_MODULES 1
-#define QM_DEPS 2
-#define QM_REFS 3
-#define QM_SYMBOLS 4
-#define QM_INFO 5
+static const int QM_MODULES = 1;
+static const int QM_DEPS = 2;
+static const int QM_REFS = 3;
+static const int QM_SYMBOLS = 4;
+static const int QM_INFO = 5;
/* Bits of module.flags. */
-#define NEW_MOD_RUNNING 1
-#define NEW_MOD_DELETED 2
-#define NEW_MOD_AUTOCLEAN 4
-#define NEW_MOD_VISITED 8
-#define NEW_MOD_USED_ONCE 16
-#define NEW_MOD_INITIALIZING 64
+static const int NEW_MOD_RUNNING = 1;
+static const int NEW_MOD_DELETED = 2;
+static const int NEW_MOD_AUTOCLEAN = 4;
+static const int NEW_MOD_VISITED = 8;
+static const int NEW_MOD_USED_ONCE = 16;
+static const int NEW_MOD_INITIALIZING = 64;
extern int lsmod_main(int argc, char **argv)
#include <linux/devmtab.h> /* For Erik's nifty devmtab device driver */
#endif
-
-#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
-#define MS_RDONLY 1 /* Mount read-only */
-#define MS_NOSUID 2 /* Ignore suid and sgid bits */
-#define MS_NODEV 4 /* Disallow access to device special files */
-#define MS_NOEXEC 8 /* Disallow program execution */
-#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
-#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
-#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
-#define S_QUOTA 128 /* Quota initialized for file/directory/symlink */
-#define S_APPEND 256 /* Append-only file */
-#define S_IMMUTABLE 512 /* Immutable file */
-#define MS_NOATIME 1024 /* Do not update access times. */
-#define MS_NODIRATIME 2048 /* Do not update directory access times */
-
+enum {
+ MS_MGC_VAL = 0xc0ed0000, /* Magic number indicatng "new" flags */
+ MS_RDONLY = 1, /* Mount read-only */
+ MS_NOSUID = 2, /* Ignore suid and sgid bits */
+ MS_NODEV = 4, /* Disallow access to device special files */
+ MS_NOEXEC = 8, /* Disallow program execution */
+ MS_SYNCHRONOUS = 16, /* Writes are synced at once */
+ MS_REMOUNT = 32, /* Alter flags of a mounted FS */
+ MS_MANDLOCK = 64, /* Allow mandatory locks on an FS */
+ S_QUOTA = 128, /* Quota initialized for file/directory/symlink */
+ S_APPEND = 256, /* Append-only file */
+ S_IMMUTABLE = 512, /* Immutable file */
+ MS_NOATIME = 1024, /* Do not update access times. */
+ MS_NODIRATIME = 2048, /* Do not update directory access times */
+};
#if defined BB_FEATURE_MOUNT_LOOP
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.31 2001/01/22 22:48:42 andersen Exp $
+ * $Id: ping.c,v 1.32 2001/01/23 22:30:04 markw Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
#if ! defined __GLIBC__ && ! defined __UCLIBC__
typedef unsigned int socklen_t;
-#define ICMP_MINLEN 8 /* abs minimum */
+static const int ICMP_MINLEN = 8; /* abs minimum */
struct icmp_ra_addr
{
};
#endif
-#define DEFDATALEN 56
-#define MAXIPLEN 60
-#define MAXICMPLEN 76
-#define MAXPACKET 65468
+static const int DEFDATALEN = 56;
+static const int MAXIPLEN = 60;
+static const int MAXICMPLEN = 76;
+static const int MAXPACKET = 65468;
#define MAX_DUP_CHK (8 * 128)
-#define MAXWAIT 10
-#define PINGINTERVAL 1 /* second */
+static const int MAXWAIT = 10;
+static const int PINGINTERVAL = 1; /* second */
#define O_QUIET (1 << 0)
static char *hostname = NULL;
static struct sockaddr_in pingaddr;
static int pingsock = -1;
-static int datalen = DEFDATALEN;
+static int datalen; /* intentionally uninitialized to work around gcc bug */
static long ntransmitted = 0, nreceived = 0, nrepeats = 0, pingcount = 0;
static int myid = 0, options = 0;
{
char *thisarg;
+ datalen = DEFDATALEN; /* initialized here rather than in global scope to work around gcc bug */
+
argc--;
argv++;
options = 0;
#include <netdb.h>
#if 0
-#define DOTRACE 1
+static const int DOTRACE = 1;
#endif
#ifdef DOTRACE
#include <sys/time.h>
#endif
-#define DATABUFSIZE 128
-#define IACBUFSIZE 128
+static const int DATABUFSIZE = 128;
+static const int IACBUFSIZE = 128;
-#define CHM_TRY 0
-#define CHM_ON 1
-#define CHM_OFF 2
+static const int CHM_TRY = 0;
+static const int CHM_ON = 1;
+static const int CHM_OFF = 2;
-#define UF_ECHO 0x01
-#define UF_SGA 0x02
+static const int UF_ECHO = 0x01;
+static const int UF_SGA = 0x02;
-#define TS_0 1
-#define TS_IAC 2
-#define TS_OPT 3
-#define TS_SUB1 4
-#define TS_SUB2 5
+enum {
+ TS_0 = 1,
+ TS_IAC = 2,
+ TS_OPT = 3,
+ TS_SUB1 = 4,
+ TS_SUB2 = 5,
+};
#define WriteCS(fd, str) write(fd, str, sizeof str -1)
static struct timeval start; /* Time a transfer started. */
volatile unsigned long statbytes; /* Number of bytes transferred so far. */
/* For progressmeter() -- number of seconds before xfer considered "stalled" */
-#define STALLTIME 5
+static const int STALLTIME = 5;
#endif
int wget_main(int argc, char **argv)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: wget.c,v 1.17 2001/01/22 22:48:42 andersen Exp $
+ * $Id: wget.c,v 1.18 2001/01/23 22:30:04 markw Exp $
*/
#include <linux/nfs.h> /* For the kernels nfs stuff */
#ifndef NFS_FHSIZE
-#define NFS_FHSIZE 32
+static const int NFS_FHSIZE = 32;
#endif
#ifndef NFS_PORT
-#define NFS_PORT 2049
+static const int NFS_PORT = 2049;
#endif
/* Disable the nls stuff */
# define _(Text) (Text)
# define N_(Text) (Text)
-#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
-#define MS_RDONLY 1 /* Mount read-only */
-#define MS_NOSUID 2 /* Ignore suid and sgid bits */
-#define MS_NODEV 4 /* Disallow access to device special files */
-#define MS_NOEXEC 8 /* Disallow program execution */
-#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
-#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
-#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
-#define S_QUOTA 128 /* Quota initialized for file/directory/symlink */
-#define S_APPEND 256 /* Append-only file */
-#define S_IMMUTABLE 512 /* Immutable file */
-#define MS_NOATIME 1024 /* Do not update access times. */
-#define MS_NODIRATIME 2048 /* Do not update directory access times */
+static const int MS_MGC_VAL = 0xc0ed0000; /* Magic number indicatng "new" flags */
+static const int MS_RDONLY = 1; /* Mount read-only */
+static const int MS_NOSUID = 2; /* Ignore suid and sgid bits */
+static const int MS_NODEV = 4; /* Disallow access to device special files */
+static const int MS_NOEXEC = 8; /* Disallow program execution */
+static const int MS_SYNCHRONOUS = 16; /* Writes are synced at once */
+static const int MS_REMOUNT = 32; /* Alter flags of a mounted FS */
+static const int MS_MANDLOCK = 64; /* Allow mandatory locks on an FS */
+static const int S_QUOTA = 128; /* Quota initialized for file/directory/symlink */
+static const int S_APPEND = 256; /* Append-only file */
+static const int S_IMMUTABLE = 512; /* Immutable file */
+static const int MS_NOATIME = 1024; /* Do not update access times. */
+static const int MS_NODIRATIME = 2048; /* Do not update directory access times */
/*
* so it is easiest to ignore the kernel altogether (at compile time).
*/
-#define NFS_MOUNT_VERSION 4
+static const int NFS_MOUNT_VERSION = 4;
struct nfs2_fh {
char data[32];
/* bits in the flags field */
-#define NFS_MOUNT_SOFT 0x0001 /* 1 */
-#define NFS_MOUNT_INTR 0x0002 /* 1 */
-#define NFS_MOUNT_SECURE 0x0004 /* 1 */
-#define NFS_MOUNT_POSIX 0x0008 /* 1 */
-#define NFS_MOUNT_NOCTO 0x0010 /* 1 */
-#define NFS_MOUNT_NOAC 0x0020 /* 1 */
-#define NFS_MOUNT_TCP 0x0040 /* 2 */
-#define NFS_MOUNT_VER3 0x0080 /* 3 */
-#define NFS_MOUNT_KERBEROS 0x0100 /* 3 */
-#define NFS_MOUNT_NONLM 0x0200 /* 3 */
+static const int NFS_MOUNT_SOFT = 0x0001; /* 1 */
+static const int NFS_MOUNT_INTR = 0x0002; /* 1 */
+static const int NFS_MOUNT_SECURE = 0x0004; /* 1 */
+static const int NFS_MOUNT_POSIX = 0x0008; /* 1 */
+static const int NFS_MOUNT_NOCTO = 0x0010; /* 1 */
+static const int NFS_MOUNT_NOAC = 0x0020; /* 1 */
+static const int NFS_MOUNT_TCP = 0x0040; /* 2 */
+static const int NFS_MOUNT_VER3 = 0x0080; /* 3 */
+static const int NFS_MOUNT_KERBEROS = 0x0100; /* 3 */
+static const int NFS_MOUNT_NONLM = 0x0200; /* 3 */
#define UTIL_LINUX_VERSION "2.10m"
#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
-#define EX_FAIL 32 /* mount failure */
-#define EX_BG 256 /* retry in background (internal only) */
+static const int EX_FAIL = 32; /* mount failure */
+static const int EX_BG = 256; /* retry in background (internal only) */
/*
* nfs_mount_version according to the sources seen at compile time.
*/
-int nfs_mount_version = NFS_MOUNT_VERSION;
+static int nfs_mount_version;
/*
* Unfortunately, the kernel prints annoying console messages
if (kernel_version)
return;
- kernel_version = get_kernel_revision();
+ nfs_mount_version = NFS_MOUNT_VERSION; /* default */
+ kernel_version = get_kernel_revision();
if (kernel_version) {
if (kernel_version < MAKE_VERSION(2,1,32))
nfs_mount_version = 1;
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.31 2001/01/22 22:48:42 andersen Exp $
+ * $Id: ping.c,v 1.32 2001/01/23 22:30:04 markw Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
#if ! defined __GLIBC__ && ! defined __UCLIBC__
typedef unsigned int socklen_t;
-#define ICMP_MINLEN 8 /* abs minimum */
+static const int ICMP_MINLEN = 8; /* abs minimum */
struct icmp_ra_addr
{
};
#endif
-#define DEFDATALEN 56
-#define MAXIPLEN 60
-#define MAXICMPLEN 76
-#define MAXPACKET 65468
+static const int DEFDATALEN = 56;
+static const int MAXIPLEN = 60;
+static const int MAXICMPLEN = 76;
+static const int MAXPACKET = 65468;
#define MAX_DUP_CHK (8 * 128)
-#define MAXWAIT 10
-#define PINGINTERVAL 1 /* second */
+static const int MAXWAIT = 10;
+static const int PINGINTERVAL = 1; /* second */
#define O_QUIET (1 << 0)
static char *hostname = NULL;
static struct sockaddr_in pingaddr;
static int pingsock = -1;
-static int datalen = DEFDATALEN;
+static int datalen; /* intentionally uninitialized to work around gcc bug */
static long ntransmitted = 0, nreceived = 0, nrepeats = 0, pingcount = 0;
static int myid = 0, options = 0;
{
char *thisarg;
+ datalen = DEFDATALEN; /* initialized here rather than in global scope to work around gcc bug */
+
argc--;
argv++;
options = 0;
#ifndef S_IFMT
-# define S_IFMT 0170000
+static const int S_IFMT = 0170000;
#endif
#if !defined(S_ISBLK) && defined(S_IFBLK)
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#include <ctype.h>
#include <unistd.h>
-#define KILL 0
-#define KILLALL 1
+static const int KILL = 0;
+static const int KILLALL = 1;
struct signal_name {
const char *name;
#define bb_need_help
#include "messages.c"
-#define TERMINAL_WIDTH 79 /* not 80 in case terminal has linefold bug */
+static const int TERMINAL_WIDTH = 79; /* not 80 in case terminal has linefold bug */
#include <time.h>
#include <errno.h>
-#define FSHIFT 16 /* nr of bits of precision */
+static const int FSHIFT = 16; /* nr of bits of precision */
#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
#define LOAD_INT(x) ((x) >> FSHIFT)
#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
#define bb_need_help
#include "messages.c"
-#define TERMINAL_WIDTH 79 /* not 80 in case terminal has linefold bug */
+static const int TERMINAL_WIDTH = 79; /* not 80 in case terminal has linefold bug */
#include <getopt.h>
-#define RFC_868_BIAS 2208988800UL
+static const int RFC_868_BIAS = 2208988800UL;
int setdate= 0;
int printdate= 0;
/*
* Some general definitions
*/
-#define BUFSIZE 512
+
#define RPM_MAGIC "\355\253\356\333"
#define GZ_MAGIC_1 '\037'
#define GZ_MAGIC_2 '\213'
/*
* Global variables
*/
-static char buffer[BUFSIZE];
static char *progname;
static int infile, outfile;
/*
* Read a specified number of bytes from input file
*/
-static void myread(int num)
+static void myread(int num, char *buffer)
{
int err;
int rpmunpack_main(int argc, char **argv)
{
int len, status = 0;
+ char buffer[BUFSIZ];
/* Get our own program name */
if ((progname = strrchr(argv[0], '/')) == NULL)
perror_msg_and_die("%s", argv[1]);
/* Read magic ID and output filename */
- myread(4);
+ myread(4, buffer);
if (strncmp(buffer, RPM_MAGIC, 4)) {
fprintf(stderr, "Input file is not in RPM format!\n");
exit(1);
}
- myread(6); /* Skip flags */
- myread(64);
+ myread(6, buffer); /* Skip flags */
+ myread(64, buffer);
buffer[64] = '\0';
/* Open output file */
* never appears before offset 0x200, so we skip these first couple of
* bytes to make the signature scan a little more reliable.
*/
- myread(0x200 - 74);
+ myread(0x200 - 74, buffer);
while (status < 2) {
- myread(1);
+ myread(1, buffer);
if (status == 0 && buffer[0] == GZ_MAGIC_1)
status++;
else if (status == 1 && buffer[0] == GZ_MAGIC_2)
perror_msg_and_die("write");
/* Now simply copy the GZIP archive into the output file */
- while ((len = read(infile, buffer, BUFSIZE)) > 0) {
+ while ((len = read(infile, buffer, BUFSIZ)) > 0) {
if (write(outfile, buffer, len) < 0)
perror_msg_and_die("write");
}
struct kbkeycode {
unsigned int scancode, keycode;
};
-#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
+static const int KDSETKEYCODE = 0x4B4D; /* write kernel keycode table entry */
extern int
setkeycodes_main(int argc, char** argv)
#include <getopt.h>
#include "cmdedit.h"
-#define MAX_LINE 256 /* size of input buffer for cwd data */
-#define MAX_READ 128 /* size of input buffer for `read' builtin */
+static const int MAX_LINE = 256; /* size of input buffer for cwd data */
+static const int MAX_READ = 128; /* size of input buffer for `read' builtin */
#define JOB_STATUS_FORMAT "[%d] %-22s %.40s\n"
extern size_t NUM_APPLETS;
#include <signal.h>
-#define MAX_HISTORY 15 /* Maximum length of the linked list for the command line history */
+static const int MAX_HISTORY = 15; /* Maximum length of the linked list for the command line history */
+
+enum {
+ ESC = 27,
+ DEL = 127,
+};
-#define ESC 27
-#define DEL 127
#define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
#include <getopt.h>
#include "cmdedit.h"
-#define MAX_LINE 256 /* size of input buffer for cwd data */
-#define MAX_READ 128 /* size of input buffer for `read' builtin */
+static const int MAX_LINE = 256; /* size of input buffer for cwd data */
+static const int MAX_READ = 128; /* size of input buffer for `read' builtin */
#define JOB_STATUS_FORMAT "[%d] %-22s %.40s\n"
extern size_t NUM_APPLETS;
static int whichApp;
-#define SWAPON_APP 1
-#define SWAPOFF_APP 2
+static const int SWAPON_APP = 1;
+static const int SWAPOFF_APP = 2;
static void swap_enable_disable(char *device)
#ifdef BB_FEATURE_REMOTE_LOG
/* send message to remote logger */
if ( -1 != remotefd){
-#define IOV_COUNT 2
+static const int IOV_COUNT = 2;
struct iovec iov[IOV_COUNT];
struct iovec *v = iov;
}
}
-#define BUFSIZE 1023
+static const int BUFSIZE = 1023;
static int serveConnection (int conn)
{
char buf[ BUFSIZE + 1 ];
#ifdef BB_FEATURE_REMOTE_LOG
/* send message to remote logger */
if ( -1 != remotefd){
-#define IOV_COUNT 2
+static const int IOV_COUNT = 2;
struct iovec iov[IOV_COUNT];
struct iovec *v = iov;
}
}
-#define BUFSIZE 1023
+static const int BUFSIZE = 1023;
static int serveConnection (int conn)
{
char buf[ BUFSIZE + 1 ];
#define MINOR(dev) ((dev)&0xff)
#endif
-#define NAME_SIZE 100
+enum { NAME_SIZE = 100 }; /* because gcc won't let me use 'static const int' */
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
struct TarHeader
/* A few useful constants */
#define TAR_MAGIC "ustar" /* ustar and a null */
#define TAR_VERSION " " /* Be compatable with GNU tar format */
-#define TAR_MAGIC_LEN 6
-#define TAR_VERSION_LEN 2
-#define TAR_BLOCK_SIZE 512
+static const int TAR_MAGIC_LEN = 6;
+static const int TAR_VERSION_LEN = 2;
+static const int TAR_BLOCK_SIZE = 512;
/* A nice enum with all the possible tar file content types */
enum TarFileType
#include <netdb.h>
#if 0
-#define DOTRACE 1
+static const int DOTRACE = 1;
#endif
#ifdef DOTRACE
#include <sys/time.h>
#endif
-#define DATABUFSIZE 128
-#define IACBUFSIZE 128
+static const int DATABUFSIZE = 128;
+static const int IACBUFSIZE = 128;
-#define CHM_TRY 0
-#define CHM_ON 1
-#define CHM_OFF 2
+static const int CHM_TRY = 0;
+static const int CHM_ON = 1;
+static const int CHM_OFF = 2;
-#define UF_ECHO 0x01
-#define UF_SGA 0x02
+static const int UF_ECHO = 0x01;
+static const int UF_SGA = 0x02;
-#define TS_0 1
-#define TS_IAC 2
-#define TS_OPT 3
-#define TS_SUB1 4
-#define TS_SUB2 5
+enum {
+ TS_0 = 1,
+ TS_IAC = 2,
+ TS_OPT = 3,
+ TS_SUB1 = 4,
+ TS_SUB2 = 5,
+};
#define WriteCS(fd, str) write(fd, str, sizeof str -1)
#define bb_need_write_error
#include "messages.c"
-#define ASCII 0377
+static const int ASCII = 0377;
/* some glabals shared across this file */
static char com_fl, del_fl, sq_fl;
-static unsigned char output[BUFSIZ], input[BUFSIZ];
-static unsigned char vector[ASCII + 1];
-static char invec[ASCII + 1], outvec[ASCII + 1];
static short in_index, out_index;
+/* these last are pointers to static buffers declared in tr_main */
+static unsigned char *poutput, *pinput;
+static unsigned char *pvector;
+static char *pinvec, *poutvec;
static void convert()
for (;;) {
if (in_index == read_chars) {
- if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) {
- if (write(1, (char *) output, out_index) != out_index)
+ if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) {
+ if (write(1, (char *) poutput, out_index) != out_index)
write(2, write_error, strlen(write_error));
exit(0);
}
in_index = 0;
}
- c = input[in_index++];
- coded = vector[c];
- if (del_fl && invec[c])
+ c = pinput[in_index++];
+ coded = pvector[c];
+ if (del_fl && pinvec[c])
continue;
- if (sq_fl && last == coded && (invec[c] || outvec[coded]))
+ if (sq_fl && last == coded && (pinvec[c] || poutvec[coded]))
continue;
- output[out_index++] = last = coded;
+ poutput[out_index++] = last = coded;
if (out_index == BUFSIZ) {
- if (write(1, (char *) output, out_index) != out_index) {
+ if (write(1, (char *) poutput, out_index) != out_index) {
write(2, write_error, strlen(write_error));
exit(1);
}
for (j = 0, i = 0; i < string1_len; i++) {
if (string2_len <= j)
- vector[string1[i]] = last;
+ pvector[string1[i]] = last;
else
- vector[string1[i]] = last = string2[j++];
+ pvector[string1[i]] = last = string2[j++];
}
}
int output_length=0, input_length;
int index = 1;
int i;
+ /* set up big arrays here (better than making a bunch of static arrays up top) */
+ unsigned char output[BUFSIZ], input[BUFSIZ];
+ unsigned char vector[ASCII + 1];
+ char invec[ASCII + 1], outvec[ASCII + 1];
+
+ /* ... but make them available globally */
+ poutput = output;
+ pinput = input;
+ pvector = vector;
+ pinvec = invec;
+ poutvec = outvec;
if (argc > 1 && argv[index][0] == '-') {
for (ptr = (unsigned char *) &argv[index][1]; *ptr; ptr++) {
#include <errno.h>
-#define MNT_FORCE 1
-#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
-#define MS_REMOUNT 32 /* Alter flags of a mounted FS. */
-#define MS_RDONLY 1 /* Mount read-only. */
+static const int MNT_FORCE = 1;
+static const int MS_MGC_VAL = 0xc0ed0000; /* Magic number indicatng "new" flags */
+static const int MS_REMOUNT = 32; /* Alter flags of a mounted FS. */
+static const int MS_RDONLY = 1; /* Mount read-only. */
extern int mount (__const char *__special_file, __const char *__dir,
__const char *__fstype, unsigned long int __rwflag,
/* Values that are bitwise or'd into `toprint'. */
/* Operating system name. */
-#define PRINT_SYSNAME 1
+static const int PRINT_SYSNAME = 1;
/* Node name on a communications network. */
-#define PRINT_NODENAME 2
+static const int PRINT_NODENAME = 2;
/* Operating system release. */
-#define PRINT_RELEASE 4
+static const int PRINT_RELEASE = 4;
/* Operating system version. */
-#define PRINT_VERSION 8
+static const int PRINT_VERSION = 8;
/* Machine hardware name. */
-#define PRINT_MACHINE 16
+static const int PRINT_MACHINE = 16;
/* Host processor type. */
-#define PRINT_PROCESSOR 32
+static const int PRINT_PROCESSOR = 32;
/* Mask indicating which elements of the name to print. */
static unsigned char toprint;
#include <time.h>
#include <errno.h>
-#define FSHIFT 16 /* nr of bits of precision */
+static const int FSHIFT = 16; /* nr of bits of precision */
#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
#define LOAD_INT(x) ((x) >> FSHIFT)
#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
#define DEFAULTFBDEV "/dev/fb0"
#define DEFAULTFBMODE "/etc/fb.modes"
-#define OPT_CHANGE 1
-#define OPT_INFO (1 << 1)
-#define OPT_READMODE (1 << 2)
-
-#define CMD_HELP 0
-#define CMD_FB 1
-#define CMD_DB 2
-#define CMD_GEOMETRY 3
-#define CMD_TIMING 4
-#define CMD_ACCEL 5
-#define CMD_HSYNC 6
-#define CMD_VSYNC 7
-#define CMD_LACED 8
-#define CMD_DOUBLE 9
-/* #define CMD_XCOMPAT 10 */
-#define CMD_ALL 11
-#define CMD_INFO 12
-#define CMD_CHANGE 13
+static const int OPT_CHANGE = (1 << 0);
+static const int OPT_INFO = (1 << 1);
+static const int OPT_READMODE = (1 << 2);
+
+enum {
+ CMD_HELP = 0,
+ CMD_FB = 1,
+ CMD_DB = 2,
+ CMD_GEOMETRY = 3,
+ CMD_TIMING = 4,
+ CMD_ACCEL = 5,
+ CMD_HSYNC = 6,
+ CMD_VSYNC = 7,
+ CMD_LACED = 8,
+ CMD_DOUBLE = 9,
+/* CMD_XCOMPAT = 10, */
+ CMD_ALL = 11,
+ CMD_INFO = 12,
+ CMD_CHANGE = 13,
#ifdef BB_FEATURE_FBSET_FANCY
-#define CMD_XRES 100
-#define CMD_YRES 101
-#define CMD_VXRES 102
-#define CMD_VYRES 103
-#define CMD_DEPTH 104
-#define CMD_MATCH 105
-#define CMD_PIXCLOCK 106
-#define CMD_LEFT 107
-#define CMD_RIGHT 108
-#define CMD_UPPER 109
-#define CMD_LOWER 110
-#define CMD_HSLEN 111
-#define CMD_VSLEN 112
-#define CMD_CSYNC 113
-#define CMD_GSYNC 114
-#define CMD_EXTSYNC 115
-#define CMD_BCAST 116
-#define CMD_RGBA 117
-#define CMD_STEP 118
-#define CMD_MOVE 119
+ CMD_XRES = 100,
+ CMD_YRES = 101,
+ CMD_VXRES = 102,
+ CMD_VYRES = 103,
+ CMD_DEPTH = 104,
+ CMD_MATCH = 105,
+ CMD_PIXCLOCK = 106,
+ CMD_LEFT = 107,
+ CMD_RIGHT = 108,
+ CMD_UPPER = 109,
+ CMD_LOWER = 110,
+ CMD_HSLEN = 111,
+ CMD_VSLEN = 112,
+ CMD_CSYNC = 113,
+ CMD_GSYNC = 114,
+ CMD_EXTSYNC = 115,
+ CMD_BCAST = 116,
+ CMD_RGBA = 117,
+ CMD_STEP = 118,
+ CMD_MOVE = 119,
#endif
+};
static unsigned int g_options = 0;
/* Stuff stolen from the kernel's fb.h */
-#define FBIOGET_VSCREENINFO 0x4600
-#define FBIOPUT_VSCREENINFO 0x4601
+static const int FBIOGET_VSCREENINFO = 0x4600;
+static const int FBIOPUT_VSCREENINFO = 0x4601;
#define __u32 unsigned int
struct fb_bitfield {
__u32 offset; /* beginning of bitfield */
#ifdef BB_FEATURE_FBSET_READMODE
/* taken from linux/fb.h */
-#define FB_VMODE_INTERLACED 1 /* interlaced */
-#define FB_VMODE_DOUBLE 2 /* double scan */
-#define FB_SYNC_HOR_HIGH_ACT 1 /* horizontal sync high active */
-#define FB_SYNC_VERT_HIGH_ACT 2 /* vertical sync high active */
-#define FB_SYNC_EXT 4 /* external sync */
-#define FB_SYNC_COMP_HIGH_ACT 8 /* composite sync high active */
+static const int FB_VMODE_INTERLACED = 1; /* interlaced */
+static const int FB_VMODE_DOUBLE = 2; /* double scan */
+static const int FB_SYNC_HOR_HIGH_ACT = 1; /* horizontal sync high active */
+static const int FB_SYNC_VERT_HIGH_ACT = 2; /* vertical sync high active */
+static const int FB_SYNC_EXT = 4; /* external sync */
+static const int FB_SYNC_COMP_HIGH_ACT = 8; /* composite sync high active */
#endif
static int readmode(struct fb_var_screeninfo *base, const char *fn,
const char *mode)
typedef unsigned int u32;
-#define MINIX_ROOT_INO 1
-#define MINIX_LINK_MAX 250
-#define MINIX2_LINK_MAX 65530
-
-#define MINIX_I_MAP_SLOTS 8
-#define MINIX_Z_MAP_SLOTS 64
-#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
-#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
-#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
-#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
-#define MINIX_VALID_FS 0x0001 /* Clean fs. */
-#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
+static const int MINIX_ROOT_INO = 1;
+static const int MINIX_LINK_MAX = 250;
+static const int MINIX2_LINK_MAX = 65530;
+
+static const int MINIX_I_MAP_SLOTS = 8;
+static const int MINIX_Z_MAP_SLOTS = 64;
+static const int MINIX_SUPER_MAGIC = 0x137F; /* original minix fs */
+static const int MINIX_SUPER_MAGIC2 = 0x138F; /* minix fs, 30 char names */
+static const int MINIX2_SUPER_MAGIC = 0x2468; /* minix V2 fs */
+static const int MINIX2_SUPER_MAGIC2 = 0x2478; /* minix V2 fs, 30 char names */
+static const int MINIX_VALID_FS = 0x0001; /* Clean fs. */
+static const int MINIX_ERROR_FS = 0x0002; /* fs has errors. */
#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
#define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode)))
-#define MINIX_V1 0x0001 /* original minix fs */
-#define MINIX_V2 0x0002 /* minix V2 fs */
+static const int MINIX_V1 = 0x0001; /* original minix fs */
+static const int MINIX_V2 = 0x0002; /* minix V2 fs */
#define INODE_VERSION(inode) inode->i_sb->u.minix_sb.s_version
#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
-#define MINIX_VALID_FS 0x0001 /* Clean fs. */
-#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
-
-#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
-#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
-
#ifndef BLKGETSIZE
#define BLKGETSIZE _IO(0x12,96) /* return device size */
#endif
#define volatile
#endif
-#define ROOT_INO 1
+static const int ROOT_INO = 1;
#define UPPER(size,n) ((size+((n)-1))/(n))
#define INODE_SIZE (sizeof(struct minix_inode))
static int termios_set = 0;
/* File-name data */
-#define MAX_DEPTH 32
+static const int MAX_DEPTH = 32;
static int name_depth = 0;
// static char name_list[MAX_DEPTH][BUFSIZ + 1];
static char **name_list = NULL;
/* NON_OPT is the code that is returned when a non-option is found in '+'
mode */
-#define NON_OPT 1
+static const int NON_OPT = 1;
/* LONG_OPT is the code that is returned when a long option is found. */
-#define LONG_OPT 2
+static const int LONG_OPT = 2;
/* The shells recognized. */
typedef enum {BASH,TCSH} shell_t;
static struct option *long_options=NULL;
static int long_options_length=0; /* Length of array */
static int long_options_nr=0; /* Nr of used elements in array */
-#define LONG_OPTIONS_INCR 10
+static const int LONG_OPTIONS_INCR = 10;
#define init_longopt() add_longopt(NULL,0)
/* Register a long option. The contents of name is copied. */
#ifndef _IO
/* pre-1.3.45 */
-#define BLKGETSIZE 0x1260
+static const int BLKGETSIZE = 0x1260;
#else
/* same on i386, m68k, arm; different on alpha, mips, sparc, ppc */
#define BLKGETSIZE _IO(0x12,96)
#include <linux/devmtab.h> /* For Erik's nifty devmtab device driver */
#endif
-
-#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
-#define MS_RDONLY 1 /* Mount read-only */
-#define MS_NOSUID 2 /* Ignore suid and sgid bits */
-#define MS_NODEV 4 /* Disallow access to device special files */
-#define MS_NOEXEC 8 /* Disallow program execution */
-#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
-#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
-#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
-#define S_QUOTA 128 /* Quota initialized for file/directory/symlink */
-#define S_APPEND 256 /* Append-only file */
-#define S_IMMUTABLE 512 /* Immutable file */
-#define MS_NOATIME 1024 /* Do not update access times. */
-#define MS_NODIRATIME 2048 /* Do not update directory access times */
-
+enum {
+ MS_MGC_VAL = 0xc0ed0000, /* Magic number indicatng "new" flags */
+ MS_RDONLY = 1, /* Mount read-only */
+ MS_NOSUID = 2, /* Ignore suid and sgid bits */
+ MS_NODEV = 4, /* Disallow access to device special files */
+ MS_NOEXEC = 8, /* Disallow program execution */
+ MS_SYNCHRONOUS = 16, /* Writes are synced at once */
+ MS_REMOUNT = 32, /* Alter flags of a mounted FS */
+ MS_MANDLOCK = 64, /* Allow mandatory locks on an FS */
+ S_QUOTA = 128, /* Quota initialized for file/directory/symlink */
+ S_APPEND = 256, /* Append-only file */
+ S_IMMUTABLE = 512, /* Immutable file */
+ MS_NOATIME = 1024, /* Do not update access times. */
+ MS_NODIRATIME = 2048, /* Do not update directory access times */
+};
#if defined BB_FEATURE_MOUNT_LOOP
#include <linux/nfs.h> /* For the kernels nfs stuff */
#ifndef NFS_FHSIZE
-#define NFS_FHSIZE 32
+static const int NFS_FHSIZE = 32;
#endif
#ifndef NFS_PORT
-#define NFS_PORT 2049
+static const int NFS_PORT = 2049;
#endif
/* Disable the nls stuff */
# define _(Text) (Text)
# define N_(Text) (Text)
-#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
-#define MS_RDONLY 1 /* Mount read-only */
-#define MS_NOSUID 2 /* Ignore suid and sgid bits */
-#define MS_NODEV 4 /* Disallow access to device special files */
-#define MS_NOEXEC 8 /* Disallow program execution */
-#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
-#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
-#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
-#define S_QUOTA 128 /* Quota initialized for file/directory/symlink */
-#define S_APPEND 256 /* Append-only file */
-#define S_IMMUTABLE 512 /* Immutable file */
-#define MS_NOATIME 1024 /* Do not update access times. */
-#define MS_NODIRATIME 2048 /* Do not update directory access times */
+static const int MS_MGC_VAL = 0xc0ed0000; /* Magic number indicatng "new" flags */
+static const int MS_RDONLY = 1; /* Mount read-only */
+static const int MS_NOSUID = 2; /* Ignore suid and sgid bits */
+static const int MS_NODEV = 4; /* Disallow access to device special files */
+static const int MS_NOEXEC = 8; /* Disallow program execution */
+static const int MS_SYNCHRONOUS = 16; /* Writes are synced at once */
+static const int MS_REMOUNT = 32; /* Alter flags of a mounted FS */
+static const int MS_MANDLOCK = 64; /* Allow mandatory locks on an FS */
+static const int S_QUOTA = 128; /* Quota initialized for file/directory/symlink */
+static const int S_APPEND = 256; /* Append-only file */
+static const int S_IMMUTABLE = 512; /* Immutable file */
+static const int MS_NOATIME = 1024; /* Do not update access times. */
+static const int MS_NODIRATIME = 2048; /* Do not update directory access times */
/*
* so it is easiest to ignore the kernel altogether (at compile time).
*/
-#define NFS_MOUNT_VERSION 4
+static const int NFS_MOUNT_VERSION = 4;
struct nfs2_fh {
char data[32];
/* bits in the flags field */
-#define NFS_MOUNT_SOFT 0x0001 /* 1 */
-#define NFS_MOUNT_INTR 0x0002 /* 1 */
-#define NFS_MOUNT_SECURE 0x0004 /* 1 */
-#define NFS_MOUNT_POSIX 0x0008 /* 1 */
-#define NFS_MOUNT_NOCTO 0x0010 /* 1 */
-#define NFS_MOUNT_NOAC 0x0020 /* 1 */
-#define NFS_MOUNT_TCP 0x0040 /* 2 */
-#define NFS_MOUNT_VER3 0x0080 /* 3 */
-#define NFS_MOUNT_KERBEROS 0x0100 /* 3 */
-#define NFS_MOUNT_NONLM 0x0200 /* 3 */
+static const int NFS_MOUNT_SOFT = 0x0001; /* 1 */
+static const int NFS_MOUNT_INTR = 0x0002; /* 1 */
+static const int NFS_MOUNT_SECURE = 0x0004; /* 1 */
+static const int NFS_MOUNT_POSIX = 0x0008; /* 1 */
+static const int NFS_MOUNT_NOCTO = 0x0010; /* 1 */
+static const int NFS_MOUNT_NOAC = 0x0020; /* 1 */
+static const int NFS_MOUNT_TCP = 0x0040; /* 2 */
+static const int NFS_MOUNT_VER3 = 0x0080; /* 3 */
+static const int NFS_MOUNT_KERBEROS = 0x0100; /* 3 */
+static const int NFS_MOUNT_NONLM = 0x0200; /* 3 */
#define UTIL_LINUX_VERSION "2.10m"
#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
-#define EX_FAIL 32 /* mount failure */
-#define EX_BG 256 /* retry in background (internal only) */
+static const int EX_FAIL = 32; /* mount failure */
+static const int EX_BG = 256; /* retry in background (internal only) */
/*
* nfs_mount_version according to the sources seen at compile time.
*/
-int nfs_mount_version = NFS_MOUNT_VERSION;
+static int nfs_mount_version;
/*
* Unfortunately, the kernel prints annoying console messages
if (kernel_version)
return;
- kernel_version = get_kernel_revision();
+ nfs_mount_version = NFS_MOUNT_VERSION; /* default */
+ kernel_version = get_kernel_revision();
if (kernel_version) {
if (kernel_version < MAKE_VERSION(2,1,32))
nfs_mount_version = 1;
#include <getopt.h>
-#define RFC_868_BIAS 2208988800UL
+static const int RFC_868_BIAS = 2208988800UL;
int setdate= 0;
int printdate= 0;
static int whichApp;
-#define SWAPON_APP 1
-#define SWAPOFF_APP 2
+static const int SWAPON_APP = 1;
+static const int SWAPOFF_APP = 2;
static void swap_enable_disable(char *device)
#include <errno.h>
-#define MNT_FORCE 1
-#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
-#define MS_REMOUNT 32 /* Alter flags of a mounted FS. */
-#define MS_RDONLY 1 /* Mount read-only. */
+static const int MNT_FORCE = 1;
+static const int MS_MGC_VAL = 0xc0ed0000; /* Magic number indicatng "new" flags */
+static const int MS_REMOUNT = 32; /* Alter flags of a mounted FS. */
+static const int MS_RDONLY = 1; /* Mount read-only. */
extern int mount (__const char *__special_file, __const char *__dir,
__const char *__fstype, unsigned long int __rwflag,
#if defined BB_MOUNT || defined BB_UMOUNT
#ifndef __NR_umount2
-#define __NR_umount2 52
+static const int __NR_umount2 = 52;
#endif
/* Include our own version of <sys/mount.h>, since libc5 doesn't
#if defined BB_INSMOD || defined BB_LSMOD
#ifndef __NR_query_module
-#define __NR_query_module 167
+static const int __NR_query_module = 167;
#endif
_syscall5(int, query_module, const char *, name, int, which,
void *, buf, size_t, bufsize, size_t*, ret);
#if (defined BB_CHVT) || (defined BB_DEALLOCVT) || (defined BB_SETKEYCODES)
/* From <linux/kd.h> */
-#define KDGKBTYPE 0x4B33 /* get keyboard type */
-#define KB_84 0x01
-#define KB_101 0x02 /* this is what we always answer */
+static const int KDGKBTYPE = 0x4B33; /* get keyboard type */
+static const int KB_84 = 0x01;
+static const int KB_101 = 0x02; /* this is what we always answer */
int is_a_console(int fd)
{
static struct timeval start; /* Time a transfer started. */
volatile unsigned long statbytes; /* Number of bytes transferred so far. */
/* For progressmeter() -- number of seconds before xfer considered "stalled" */
-#define STALLTIME 5
+static const int STALLTIME = 5;
#endif
int wget_main(int argc, char **argv)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: wget.c,v 1.17 2001/01/22 22:48:42 andersen Exp $
+ * $Id: wget.c,v 1.18 2001/01/23 22:30:04 markw Exp $
*/