More stuff.
No binary (build failed)
—
(log yok)
| @@ -1,30 +1,38 @@ | |
| VERSION=0.29alpha1 | |
| BUILDTIME=$(shell date "+%Y%m%d-%H%M") | |
| + | DODEBUG=true |
| #This will choke on a non-debian system | |
| ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'` | |
| - | STRIP= strip --remove-section=.note --remove-section=.comment busybox |
| - | LDFLAGS= -s |
| - | |
| # -D_GNU_SOURCE is needed because environ is used in init.c | |
| - | CFLAGS=-Wall -O2 -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE |
| - | # For debugging only |
| - | #CFLAGS=-Wall -g -D_GNU_SOURCE |
| + | ifeq ($(DODEBUG),true) |
| + | CFLAGS=-Wall -g -D_GNU_SOURCE |
| + | STRIP= |
| + | else |
| + | CFLAGS=-Wall -O2 -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE |
| + | STRIP= strip --remove-section=.note --remove-section=.comment busybox |
| + | endif |
| + | |
| + | ifndef $(prefix) |
| + | prefix=`pwd` |
| + | endif |
| + | BINDIR=$(prefix) |
| + | |
| + | LDFLAGS= -s |
| LIBRARIES=-lc | |
| OBJECTS=$(shell ./busybox.sh) utility.o | |
| - | |
| CFLAGS+= -DBB_VER='"$(VERSION)"' | |
| CFLAGS+= -DBB_BT='"$(BUILDTIME)"' | |
| - | #all: busybox links |
| - | all: busybox |
| + | all: busybox links |
| + | #all: busybox |
| busybox: $(OBJECTS) | |
| $(CC) $(CFLAGS) $(LDFLAGS) -o busybox $(OBJECTS) $(LIBRARIES) | |
| - | #$(STRIP) |
| + | $(STRIP) |
| links: | |
| - ./busybox.mkll | sort >busybox.links | |
| @@ -38,3 +46,7 @@ distclean: clean | |
| force: | |
| $(OBJECTS): busybox.def.h internal.h Makefile | |
| + | |
| + | install: busybox |
| + | install.sh $(BINDIR) |
| + | |
| @@ -195,6 +195,7 @@ int main(int argc, char **argv) | |
| int busybox_main(int argc, char **argv) | |
| { | |
| + | int col=0; |
| argc--; | |
| argv++; | |
| @@ -208,18 +209,19 @@ int busybox_main(int argc, char **argv) | |
| fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n", | |
| BB_VER, BB_BT); | |
| fprintf(stderr, "Usage: busybox [function] [arguments]...\n"); | |
| + | fprintf(stderr, "or\nUsage: [function] [arguments]...\n"); |
| fprintf(stderr, | |
| "\n\tMost people will create a symlink to busybox for each\n" | |
| "\tfunction name, and busybox will act like whatever you invoke it as.\n"); | |
| fprintf(stderr, "\nCurrently defined functions:\n"); | |
| - | if (a->name != 0) { |
| - | fprintf(stderr, "%s", a->name); |
| - | a++; |
| - | } |
| while (a->name != 0) { | |
| - | fprintf(stderr, ", %s", a->name); |
| + | col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), a->name); |
| a++; | |
| + | if (col>60) { |
| + | fprintf(stderr, ",\n"); |
| + | col=0; |
| + | } |
| } | |
| fprintf(stderr, "\n\n"); | |
| exit(-1); | |
| @@ -2,16 +2,14 @@ | |
| #Make busybox links list file | |
| DF="busybox.def.h" | |
| - | MF="main.c" |
| + | MF="busybox.c" |
| LIST="$(sed -n '/^#define/{s/^#define //p;}' $DF)" | |
| - | for def in ${LIST}; do |
| - | |
| - | set -- $(sed -n '/^#ifdef '$def'[ +| +].*/,/^#endif/{s/.*\/\///p; /^{ /{ s/^{ "//; s/",.*$//p;}; }' $MF) |
| - | path=$1; shift |
| - | |
| - | for n in $@; do |
| - | echo "$path/$n" |
| - | done |
| + | for def in ${LIST}; do |
| + | i=`sed -n 's/^#ifdef '$def'.*\/\/\(.*$\)/\/\1\//gp' $MF` |
| + | j=`sed -n '/^#ifdef '$def'.*/,/^#endif/{ s/.*\"\(.*\)\".*/\1/gp; }' $MF` |
| + | for k in $j; do |
| + | echo $i$k |
| done | |
| + | done |
| @@ -380,7 +380,7 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */ | |
| # undef LZW | |
| #endif | |
| - | /* $Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $ */ |
| + | /* $Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $ */ |
| /* tailor.h -- target dependent definitions | |
| * Copyright (C) 1992-1993 Jean-loup Gailly. | |
| * This is free software; you can redistribute it and/or modify it under the | |
| @@ -391,7 +391,7 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */ | |
| * The target dependent functions should be defined in tailor.c. | |
| */ | |
| - | /* $Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $ */ |
| + | /* $Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $ */ |
| #if defined(__MSDOS__) && !defined(MSDOS) | |
| # define MSDOS | |
| @@ -767,7 +767,7 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */ | |
| #endif | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| /* =========================================================================== | |
| @@ -976,7 +976,7 @@ void copy_block(buf, len, header) | |
| #include <stdio.h> | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| /* =========================================================================== | |
| @@ -1592,7 +1592,7 @@ ulg deflate() | |
| */ | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| #include <ctype.h> | |
| @@ -1781,7 +1781,7 @@ static int (*work) OF((int infile, int outfile)) = zip; /* function to call */ | |
| // int main (argc, argv) | |
| // int argc; | |
| // char **argv; | |
| - | int gzip_main(struct FileInfo * i, int argc, char * * argv) |
| + | int gzip_main(int argc, char * * argv) |
| { | |
| foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; | |
| if (foreground) { | |
| @@ -1925,7 +1925,7 @@ local void do_exit(int exitcode) | |
| #include <ctype.h> | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| /* =========================================================================== | |
| @@ -2943,7 +2943,7 @@ local void set_file_type() | |
| */ | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| #include <ctype.h> | |
| @@ -3142,7 +3142,7 @@ void display_ratio(num, den, file) | |
| */ | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| #include <ctype.h> | |
| @@ -131,14 +131,10 @@ static void writeHeader(const char * fileName, | |
| static void writeTarFile(int fileCount, char ** fileTable); | |
| static void writeTarBlock(const char * buf, int len); | |
| static BOOL putOctal(char * cp, int len, long value); | |
| - | extern const char * modeString(int mode); |
| - | extern const char * timeString(time_t timeVal); |
| - | extern int fullWrite(int fd, const char * buf, int len); |
| - | extern int fullRead(int fd, char * buf, int len); |
| extern int | |
| - | tar_main(struct FileInfo *unused, int argc, char ** argv) |
| + | tar_main(int argc, char ** argv) |
| { | |
| const char * options; | |
| @@ -1258,167 +1254,6 @@ wantFileName(const char * fileName, int fileCount, char ** fileTable) | |
| - | /* |
| - | * Return the standard ls-like mode string from a file mode. |
| - | * This is static and so is overwritten on each call. |
| - | */ |
| - | const char * |
| - | modeString(int mode) |
| - | { |
| - | static char buf[12]; |
| - | |
| - | strcpy(buf, "----------"); |
| - | |
| - | /* |
| - | * Fill in the file type. |
| - | */ |
| - | if (S_ISDIR(mode)) |
| - | buf[0] = 'd'; |
| - | if (S_ISCHR(mode)) |
| - | buf[0] = 'c'; |
| - | if (S_ISBLK(mode)) |
| - | buf[0] = 'b'; |
| - | if (S_ISFIFO(mode)) |
| - | buf[0] = 'p'; |
| - | #ifdef S_ISLNK |
| - | if (S_ISLNK(mode)) |
| - | buf[0] = 'l'; |
| - | #endif |
| - | #ifdef S_ISSOCK |
| - | if (S_ISSOCK(mode)) |
| - | buf[0] = 's'; |
| - | #endif |
| - | |
| - | /* |
| - | * Now fill in the normal file permissions. |
| - | */ |
| - | if (mode & S_IRUSR) |
| - | buf[1] = 'r'; |
| - | if (mode & S_IWUSR) |
| - | buf[2] = 'w'; |
| - | if (mode & S_IXUSR) |
| - | buf[3] = 'x'; |
| - | if (mode & S_IRGRP) |
| - | buf[4] = 'r'; |
| - | if (mode & S_IWGRP) |
| - | buf[5] = 'w'; |
| - | if (mode & S_IXGRP) |
| - | buf[6] = 'x'; |
| - | if (mode & S_IROTH) |
| - | buf[7] = 'r'; |
| - | if (mode & S_IWOTH) |
| - | buf[8] = 'w'; |
| - | if (mode & S_IXOTH) |
| - | buf[9] = 'x'; |
| - | |
| - | /* |
| - | * Finally fill in magic stuff like suid and sticky text. |
| - | */ |
| - | if (mode & S_ISUID) |
| - | buf[3] = ((mode & S_IXUSR) ? 's' : 'S'); |
| - | if (mode & S_ISGID) |
| - | buf[6] = ((mode & S_IXGRP) ? 's' : 'S'); |
| - | if (mode & S_ISVTX) |
| - | buf[9] = ((mode & S_IXOTH) ? 't' : 'T'); |
| - | |
| - | return buf; |
| - | } |
| - | |
| - | |
| - | /* |
| - | * Get the time string to be used for a file. |
| - | * This is down to the minute for new files, but only the date for old files. |
| - | * The string is returned from a static buffer, and so is overwritten for |
| - | * each call. |
| - | */ |
| - | const char * |
| - | timeString(time_t timeVal) |
| - | { |
| - | time_t now; |
| - | char * str; |
| - | static char buf[26]; |
| - | |
| - | time(&now); |
| - | |
| - | str = ctime(&timeVal); |
| - | |
| - | strcpy(buf, &str[4]); |
| - | buf[12] = '\0'; |
| - | |
| - | if ((timeVal > now) || (timeVal < now - 365*24*60*60L)) |
| - | { |
| - | strcpy(&buf[7], &str[20]); |
| - | buf[11] = '\0'; |
| - | } |
| - | |
| - | return buf; |
| - | } |
| - | |
| - | |
| - | |
| - | /* |
| - | * Write all of the supplied buffer out to a file. |
| - | * This does multiple writes as necessary. |
| - | * Returns the amount written, or -1 on an error. |
| - | */ |
| - | int |
| - | fullWrite(int fd, const char * buf, int len) |
| - | { |
| - | int cc; |
| - | int total; |
| - | |
| - | total = 0; |
| - | |
| - | while (len > 0) |
| - | { |
| - | cc = write(fd, buf, len); |
| - | |
| - | if (cc < 0) |
| - | return -1; |
| - | |
| - | buf += cc; |
| - | total+= cc; |
| - | len -= cc; |
| - | } |
| - | |
| - | return total; |
| - | } |
| - | |
| - | |
| - | /* |
| - | * Read all of the supplied buffer from a file. |
| - | * This does multiple reads as necessary. |
| - | * Returns the amount read, or -1 on an error. |
| - | * A short read is returned on an end of file. |
| - | */ |
| - | int |
| - | fullRead(int fd, char * buf, int len) |
| - | { |
| - | int cc; |
| - | int total; |
| - | |
| - | total = 0; |
| - | |
| - | while (len > 0) |
| - | { |
| - | cc = read(fd, buf, len); |
| - | |
| - | if (cc < 0) |
| - | return -1; |
| - | |
| - | if (cc == 0) |
| - | break; |
| - | |
| - | buf += cc; |
| - | total+= cc; |
| - | len -= cc; |
| - | } |
| - | |
| - | return total; |
| - | } |
| - | |
| - | |
| - | |
| #endif | |
| /* END CODE */ | |
| @@ -195,6 +195,7 @@ int main(int argc, char **argv) | |
| int busybox_main(int argc, char **argv) | |
| { | |
| + | int col=0; |
| argc--; | |
| argv++; | |
| @@ -208,18 +209,19 @@ int busybox_main(int argc, char **argv) | |
| fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n", | |
| BB_VER, BB_BT); | |
| fprintf(stderr, "Usage: busybox [function] [arguments]...\n"); | |
| + | fprintf(stderr, "or\nUsage: [function] [arguments]...\n"); |
| fprintf(stderr, | |
| "\n\tMost people will create a symlink to busybox for each\n" | |
| "\tfunction name, and busybox will act like whatever you invoke it as.\n"); | |
| fprintf(stderr, "\nCurrently defined functions:\n"); | |
| - | if (a->name != 0) { |
| - | fprintf(stderr, "%s", a->name); |
| - | a++; |
| - | } |
| while (a->name != 0) { | |
| - | fprintf(stderr, ", %s", a->name); |
| + | col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), a->name); |
| a++; | |
| + | if (col>60) { |
| + | fprintf(stderr, ",\n"); |
| + | col=0; |
| + | } |
| } | |
| fprintf(stderr, "\n\n"); | |
| exit(-1); | |
| @@ -14,15 +14,14 @@ | |
| #define BB_DATE | |
| #define BB_DD | |
| //#define BB_DESCEND | |
| - | //#define BB_DF |
| + | #define BB_DF |
| #define BB_DMESG | |
| //#define BB_DUTMP | |
| //#define BB_DYADIC | |
| #define BB_FALSE | |
| //#define BB_FDFLUSH | |
| - | //#define BB_FIND |
| - | //#define BB_FINDMOUNT |
| - | //#define BB_GREP |
| + | #define BB_FIND |
| + | #define BB_GREP |
| ////#define BB_HALT | |
| //#define BB_INIT | |
| //#define BB_KILL | |
| @@ -53,11 +52,11 @@ | |
| ////#define BB_SWAPOFF | |
| //#define BB_SWAPON | |
| //#define BB_SYNC | |
| - | //#define BB_TAR |
| + | #define BB_TAR |
| //#define BB_TOUCH | |
| #define BB_TRUE | |
| //#define BB_UMOUNT | |
| //#define BB_UPDATE | |
| //#define BB_UTILITY | |
| - | //#define BB_ZCAT |
| - | //#define BB_GZIP |
| + | #define BB_ZCAT |
| + | #define BB_GZIP |
| @@ -2,16 +2,14 @@ | |
| #Make busybox links list file | |
| DF="busybox.def.h" | |
| - | MF="main.c" |
| + | MF="busybox.c" |
| LIST="$(sed -n '/^#define/{s/^#define //p;}' $DF)" | |
| - | for def in ${LIST}; do |
| - | |
| - | set -- $(sed -n '/^#ifdef '$def'[ +| +].*/,/^#endif/{s/.*\/\///p; /^{ /{ s/^{ "//; s/",.*$//p;}; }' $MF) |
| - | path=$1; shift |
| - | |
| - | for n in $@; do |
| - | echo "$path/$n" |
| - | done |
| + | for def in ${LIST}; do |
| + | i=`sed -n 's/^#ifdef '$def'.*\/\/\(.*$\)/\/\1\//gp' $MF` |
| + | j=`sed -n '/^#ifdef '$def'.*/,/^#endif/{ s/.*\"\(.*\)\".*/\1/gp; }' $MF` |
| + | for k in $j; do |
| + | echo $i$k |
| done | |
| + | done |
| @@ -17,7 +17,7 @@ df(const char * device, const char * mountPoint) | |
| long blocks_percent_used; | |
| if ( statfs(mountPoint, &s) != 0 ) { | |
| - | name_and_error(mountPoint); |
| + | perror(mountPoint); |
| return 1; | |
| } | |
| @@ -52,7 +52,7 @@ df(const char * device, const char * mountPoint) | |
| } | |
| extern int | |
| - | df_main(struct FileInfo * i, int argc, char * * argv) |
| + | df_main(int argc, char * * argv) |
| { | |
| static const char header[] = | |
| "Filesystem 1024-blocks Used Available Capacity Mounted on\n"; | |
| @@ -63,11 +63,9 @@ df_main(struct FileInfo * i, int argc, char * * argv) | |
| int status; | |
| while ( argc > 1 ) { | |
| - | if ( (mountEntry = findMountPoint(argv[1], "/etc/mtab")) == 0 |
| - | && (mountEntry = findMountPoint(argv[1], "/proc/mounts")) == 0 ) |
| + | if ( (mountEntry = findMountPoint(argv[1], "/proc/mounts")) == 0 ) |
| { | |
| - | fprintf(stderr, "%s: can't find mount point.\n" |
| - | ,argv[1]); |
| + | fprintf(stderr, "%s: can't find mount point.\n" ,argv[1]); |
| return 1; | |
| } | |
| status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir); | |
| @@ -82,10 +80,8 @@ df_main(struct FileInfo * i, int argc, char * * argv) | |
| FILE * mountTable; | |
| struct mntent * mountEntry; | |
| - | if ( (mountTable = setmntent("/etc/mtab", "r")) == 0 |
| - | && (mountTable = setmntent("/proc/mounts", "r")) == 0 |
| - | ) { |
| - | name_and_error("/etc/mtab"); |
| + | if ( (mountTable = setmntent("/proc/mounts", "r")) == 0) { |
| + | perror("/proc/mounts"); |
| return 1; | |
| } | |
| @@ -101,3 +97,48 @@ df_main(struct FileInfo * i, int argc, char * * argv) | |
| return 0; | |
| } | |
| + | |
| + | |
| + | |
| + | |
| + | /* |
| + | * Given a block device, find the mount table entry if that block device |
| + | * is mounted. |
| + | * |
| + | * Given any other file (or directory), find the mount table entry for its |
| + | * filesystem. |
| + | */ |
| + | extern struct mntent * |
| + | findMountPoint(const char * name, const char * table) |
| + | { |
| + | struct stat s; |
| + | dev_t mountDevice; |
| + | FILE * mountTable; |
| + | struct mntent * mountEntry; |
| + | |
| + | if ( stat(name, &s) != 0 ) |
| + | return 0; |
| + | |
| + | if ( (s.st_mode & S_IFMT) == S_IFBLK ) |
| + | mountDevice = s.st_rdev; |
| + | else |
| + | mountDevice = s.st_dev; |
| + | |
| + | |
| + | if ( (mountTable = setmntent(table, "r")) == 0 ) |
| + | return 0; |
| + | |
| + | while ( (mountEntry = getmntent(mountTable)) != 0 ) { |
| + | if ( strcmp(name, mountEntry->mnt_dir) == 0 |
| + | || strcmp(name, mountEntry->mnt_fsname) == 0 ) /* String match. */ |
| + | break; |
| + | if ( stat(mountEntry->mnt_fsname, &s) == 0 |
| + | && s.st_rdev == mountDevice ) /* Match the device. */ |
| + | break; |
| + | if ( stat(mountEntry->mnt_dir, &s) == 0 |
| + | && s.st_dev == mountDevice ) /* Match the directory's mount point. */ |
| + | break; |
| + | } |
| + | endmntent(mountTable); |
| + | return mountEntry; |
| + | } |
| @@ -17,7 +17,7 @@ df(const char * device, const char * mountPoint) | |
| long blocks_percent_used; | |
| if ( statfs(mountPoint, &s) != 0 ) { | |
| - | name_and_error(mountPoint); |
| + | perror(mountPoint); |
| return 1; | |
| } | |
| @@ -52,7 +52,7 @@ df(const char * device, const char * mountPoint) | |
| } | |
| extern int | |
| - | df_main(struct FileInfo * i, int argc, char * * argv) |
| + | df_main(int argc, char * * argv) |
| { | |
| static const char header[] = | |
| "Filesystem 1024-blocks Used Available Capacity Mounted on\n"; | |
| @@ -63,11 +63,9 @@ df_main(struct FileInfo * i, int argc, char * * argv) | |
| int status; | |
| while ( argc > 1 ) { | |
| - | if ( (mountEntry = findMountPoint(argv[1], "/etc/mtab")) == 0 |
| - | && (mountEntry = findMountPoint(argv[1], "/proc/mounts")) == 0 ) |
| + | if ( (mountEntry = findMountPoint(argv[1], "/proc/mounts")) == 0 ) |
| { | |
| - | fprintf(stderr, "%s: can't find mount point.\n" |
| - | ,argv[1]); |
| + | fprintf(stderr, "%s: can't find mount point.\n" ,argv[1]); |
| return 1; | |
| } | |
| status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir); | |
| @@ -82,10 +80,8 @@ df_main(struct FileInfo * i, int argc, char * * argv) | |
| FILE * mountTable; | |
| struct mntent * mountEntry; | |
| - | if ( (mountTable = setmntent("/etc/mtab", "r")) == 0 |
| - | && (mountTable = setmntent("/proc/mounts", "r")) == 0 |
| - | ) { |
| - | name_and_error("/etc/mtab"); |
| + | if ( (mountTable = setmntent("/proc/mounts", "r")) == 0) { |
| + | perror("/proc/mounts"); |
| return 1; | |
| } | |
| @@ -101,3 +97,48 @@ df_main(struct FileInfo * i, int argc, char * * argv) | |
| return 0; | |
| } | |
| + | |
| + | |
| + | |
| + | |
| + | /* |
| + | * Given a block device, find the mount table entry if that block device |
| + | * is mounted. |
| + | * |
| + | * Given any other file (or directory), find the mount table entry for its |
| + | * filesystem. |
| + | */ |
| + | extern struct mntent * |
| + | findMountPoint(const char * name, const char * table) |
| + | { |
| + | struct stat s; |
| + | dev_t mountDevice; |
| + | FILE * mountTable; |
| + | struct mntent * mountEntry; |
| + | |
| + | if ( stat(name, &s) != 0 ) |
| + | return 0; |
| + | |
| + | if ( (s.st_mode & S_IFMT) == S_IFBLK ) |
| + | mountDevice = s.st_rdev; |
| + | else |
| + | mountDevice = s.st_dev; |
| + | |
| + | |
| + | if ( (mountTable = setmntent(table, "r")) == 0 ) |
| + | return 0; |
| + | |
| + | while ( (mountEntry = getmntent(mountTable)) != 0 ) { |
| + | if ( strcmp(name, mountEntry->mnt_dir) == 0 |
| + | || strcmp(name, mountEntry->mnt_fsname) == 0 ) /* String match. */ |
| + | break; |
| + | if ( stat(mountEntry->mnt_fsname, &s) == 0 |
| + | && s.st_rdev == mountDevice ) /* Match the device. */ |
| + | break; |
| + | if ( stat(mountEntry->mnt_dir, &s) == 0 |
| + | && s.st_dev == mountDevice ) /* Match the directory's mount point. */ |
| + | break; |
| + | } |
| + | endmntent(mountTable); |
| + | return mountEntry; |
| + | } |
| @@ -28,7 +28,7 @@ static inline _syscall3(int,klog,int,type,char *,b,int,len) | |
| const char dmesg_usage[] = "dmesg"; | |
| int | |
| - | dmesg_main(struct FileInfo * info, int argc, char * * argv) |
| + | dmesg_main(int argc, char * * argv) |
| { | |
| char buf[4096]; | |
| @@ -50,7 +50,7 @@ dmesg_main(struct FileInfo * info, int argc, char * * argv) | |
| break; | |
| case '?': | |
| default: | |
| - | usage(dmesg_usage); |
| + | fprintf(stderr, "%s\n", dmesg_usage); |
| exit(1); | |
| } | |
| } | |
| @@ -58,7 +58,7 @@ dmesg_main(struct FileInfo * info, int argc, char * * argv) | |
| argv += optind; | |
| if (argc > 1) { | |
| - | usage(dmesg_usage); |
| + | fprintf(stderr, "%s\n", dmesg_usage); |
| exit(1); | |
| } | |
| @@ -1,3 +1,133 @@ | |
| + | /* |
| + | * Mini find implementation for busybox |
| + | * |
| + | * Copyright (C) 1998 by Erik Andersen <[email protected]> |
| + | * |
| + | * 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 <stdio.h> |
| + | #include <unistd.h> |
| + | #include <dirent.h> |
| + | #include "internal.h" |
| + | |
| + | |
| + | static char* pattern=NULL; |
| + | static char* directory=NULL; |
| + | int dereferenceFlag=FALSE; |
| + | |
| + | static const char find_usage[] = "find [path...] [expression]\n" |
| + | "default path is the current directory; default expression is -print\n" |
| + | "expression may consist of:\n"; |
| + | |
| + | |
| + | |
| + | static int fileAction(const char *fileName) |
| + | { |
| + | if (pattern==NULL) |
| + | fprintf(stdout, "%s\n", fileName); |
| + | else if (match(fileName, pattern) == TRUE) |
| + | fprintf(stdout, "%s\n", fileName); |
| + | return( TRUE); |
| + | } |
| + | |
| + | static int dirAction(const char *fileName) |
| + | { |
| + | DIR *dir; |
| + | struct dirent *entry; |
| + | |
| + | if (pattern==NULL) |
| + | fprintf(stdout, "%s\n", fileName); |
| + | else if (match(fileName, pattern) == TRUE) |
| + | fprintf(stdout, "%s\n", fileName); |
| + | |
| + | dir = opendir( fileName); |
| + | if (!dir) { |
| + | perror("Can't open directory"); |
| + | exit(FALSE); |
| + | } |
| + | while ((entry = readdir(dir)) != NULL) { |
| + | char dirName[NAME_MAX]; |
| + | sprintf(dirName, "%s/%s", fileName, entry->d_name); |
| + | recursiveAction( dirName, TRUE, dereferenceFlag, fileAction, dirAction); |
| + | } |
| + | return( TRUE); |
| + | } |
| + | |
| + | int find_main(int argc, char **argv) |
| + | { |
| + | if (argc <= 1) { |
| + | dirAction( "."); |
| + | } |
| + | |
| + | /* peel off the "find" */ |
| + | argc--; |
| + | argv++; |
| + | |
| + | if (**argv != '-') { |
| + | directory=*argv; |
| + | argc--; |
| + | argv++; |
| + | } |
| + | |
| + | /* Parse any options */ |
| + | while (**argv == '-') { |
| + | int stopit=FALSE; |
| + | while (*++(*argv) && stopit==FALSE) switch (**argv) { |
| + | case 'f': |
| + | if (strcmp(*argv, "follow")==0) { |
| + | argc--; |
| + | argv++; |
| + | dereferenceFlag=TRUE; |
| + | } |
| + | break; |
| + | case 'n': |
| + | if (strcmp(*argv, "name")==0) { |
| + | if (argc-- > 1) { |
| + | pattern=*(++argv); |
| + | stopit=-TRUE; |
| + | } else { |
| + | fprintf(stderr, "Usage: %s\n", find_usage); |
| + | exit( FALSE); |
| + | } |
| + | } |
| + | break; |
| + | case '-': |
| + | /* Ignore all long options */ |
| + | break; |
| + | default: |
| + | fprintf(stderr, "Usage: %s\n", find_usage); |
| + | exit( FALSE); |
| + | } |
| + | if (argc-- > 1) |
| + | argv++; |
| + | if (**argv != '-') |
| + | break; |
| + | else |
| + | break; |
| + | } |
| + | |
| + | dirAction( directory); |
| + | exit(TRUE); |
| + | } |
| + | |
| + | |
| + | |
| + | #ifdef foobar |
| + | |
| #include "internal.h" | |
| #include <errno.h> | |
| #include <stdio.h> | |
| @@ -21,3 +151,6 @@ find_fn(const struct FileInfo * i) | |
| return(0); | |
| } | |
| + | |
| + | |
| + | #endif |
| @@ -1,3 +1,133 @@ | |
| + | /* |
| + | * Mini find implementation for busybox |
| + | * |
| + | * Copyright (C) 1998 by Erik Andersen <[email protected]> |
| + | * |
| + | * 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 <stdio.h> |
| + | #include <unistd.h> |
| + | #include <dirent.h> |
| + | #include "internal.h" |
| + | |
| + | |
| + | static char* pattern=NULL; |
| + | static char* directory=NULL; |
| + | int dereferenceFlag=FALSE; |
| + | |
| + | static const char find_usage[] = "find [path...] [expression]\n" |
| + | "default path is the current directory; default expression is -print\n" |
| + | "expression may consist of:\n"; |
| + | |
| + | |
| + | |
| + | static int fileAction(const char *fileName) |
| + | { |
| + | if (pattern==NULL) |
| + | fprintf(stdout, "%s\n", fileName); |
| + | else if (match(fileName, pattern) == TRUE) |
| + | fprintf(stdout, "%s\n", fileName); |
| + | return( TRUE); |
| + | } |
| + | |
| + | static int dirAction(const char *fileName) |
| + | { |
| + | DIR *dir; |
| + | struct dirent *entry; |
| + | |
| + | if (pattern==NULL) |
| + | fprintf(stdout, "%s\n", fileName); |
| + | else if (match(fileName, pattern) == TRUE) |
| + | fprintf(stdout, "%s\n", fileName); |
| + | |
| + | dir = opendir( fileName); |
| + | if (!dir) { |
| + | perror("Can't open directory"); |
| + | exit(FALSE); |
| + | } |
| + | while ((entry = readdir(dir)) != NULL) { |
| + | char dirName[NAME_MAX]; |
| + | sprintf(dirName, "%s/%s", fileName, entry->d_name); |
| + | recursiveAction( dirName, TRUE, dereferenceFlag, fileAction, dirAction); |
| + | } |
| + | return( TRUE); |
| + | } |
| + | |
| + | int find_main(int argc, char **argv) |
| + | { |
| + | if (argc <= 1) { |
| + | dirAction( "."); |
| + | } |
| + | |
| + | /* peel off the "find" */ |
| + | argc--; |
| + | argv++; |
| + | |
| + | if (**argv != '-') { |
| + | directory=*argv; |
| + | argc--; |
| + | argv++; |
| + | } |
| + | |
| + | /* Parse any options */ |
| + | while (**argv == '-') { |
| + | int stopit=FALSE; |
| + | while (*++(*argv) && stopit==FALSE) switch (**argv) { |
| + | case 'f': |
| + | if (strcmp(*argv, "follow")==0) { |
| + | argc--; |
| + | argv++; |
| + | dereferenceFlag=TRUE; |
| + | } |
| + | break; |
| + | case 'n': |
| + | if (strcmp(*argv, "name")==0) { |
| + | if (argc-- > 1) { |
| + | pattern=*(++argv); |
| + | stopit=-TRUE; |
| + | } else { |
| + | fprintf(stderr, "Usage: %s\n", find_usage); |
| + | exit( FALSE); |
| + | } |
| + | } |
| + | break; |
| + | case '-': |
| + | /* Ignore all long options */ |
| + | break; |
| + | default: |
| + | fprintf(stderr, "Usage: %s\n", find_usage); |
| + | exit( FALSE); |
| + | } |
| + | if (argc-- > 1) |
| + | argv++; |
| + | if (**argv != '-') |
| + | break; |
| + | else |
| + | break; |
| + | } |
| + | |
| + | dirAction( directory); |
| + | exit(TRUE); |
| + | } |
| + | |
| + | |
| + | |
| + | #ifdef foobar |
| + | |
| #include "internal.h" | |
| #include <errno.h> | |
| #include <stdio.h> | |
| @@ -21,3 +151,6 @@ find_fn(const struct FileInfo * i) | |
| return(0); | |
| } | |
| + | |
| + | |
| + | #endif |
| @@ -36,7 +36,7 @@ static BOOL search | |
| extern int | |
| - | grep_main(struct FileInfo * unused, int argc, char ** argv) |
| + | grep_main(int argc, char ** argv) |
| { | |
| FILE * fp; | |
| const char * word; | |
| @@ -36,7 +36,7 @@ static BOOL search | |
| extern int | |
| - | grep_main(struct FileInfo * unused, int argc, char ** argv) |
| + | grep_main(int argc, char ** argv) |
| { | |
| FILE * fp; | |
| const char * word; | |
| @@ -380,7 +380,7 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */ | |
| # undef LZW | |
| #endif | |
| - | /* $Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $ */ |
| + | /* $Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $ */ |
| /* tailor.h -- target dependent definitions | |
| * Copyright (C) 1992-1993 Jean-loup Gailly. | |
| * This is free software; you can redistribute it and/or modify it under the | |
| @@ -391,7 +391,7 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */ | |
| * The target dependent functions should be defined in tailor.c. | |
| */ | |
| - | /* $Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $ */ |
| + | /* $Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $ */ |
| #if defined(__MSDOS__) && !defined(MSDOS) | |
| # define MSDOS | |
| @@ -767,7 +767,7 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */ | |
| #endif | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| /* =========================================================================== | |
| @@ -976,7 +976,7 @@ void copy_block(buf, len, header) | |
| #include <stdio.h> | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| /* =========================================================================== | |
| @@ -1592,7 +1592,7 @@ ulg deflate() | |
| */ | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| #include <ctype.h> | |
| @@ -1781,7 +1781,7 @@ static int (*work) OF((int infile, int outfile)) = zip; /* function to call */ | |
| // int main (argc, argv) | |
| // int argc; | |
| // char **argv; | |
| - | int gzip_main(struct FileInfo * i, int argc, char * * argv) |
| + | int gzip_main(int argc, char * * argv) |
| { | |
| foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; | |
| if (foreground) { | |
| @@ -1925,7 +1925,7 @@ local void do_exit(int exitcode) | |
| #include <ctype.h> | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| /* =========================================================================== | |
| @@ -2943,7 +2943,7 @@ local void set_file_type() | |
| */ | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| #include <ctype.h> | |
| @@ -3142,7 +3142,7 @@ void display_ratio(num, den, file) | |
| */ | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: gzip.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: gzip.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| #include <ctype.h> | |
| @@ -183,6 +183,8 @@ int fullRead(int fd, char *buf, int len); | |
| int recursiveAction(const char *fileName, BOOL recurse, BOOL followLinks, | |
| int (*fileAction) (const char *fileName), | |
| int (*dirAction) (const char *fileName)); | |
| + | BOOL match(const char* text, const char * pattern); |
| + | const char* timeString(time_t timeVal); |
| #endif | |
| @@ -131,14 +131,10 @@ static void writeHeader(const char * fileName, | |
| static void writeTarFile(int fileCount, char ** fileTable); | |
| static void writeTarBlock(const char * buf, int len); | |
| static BOOL putOctal(char * cp, int len, long value); | |
| - | extern const char * modeString(int mode); |
| - | extern const char * timeString(time_t timeVal); |
| - | extern int fullWrite(int fd, const char * buf, int len); |
| - | extern int fullRead(int fd, char * buf, int len); |
| extern int | |
| - | tar_main(struct FileInfo *unused, int argc, char ** argv) |
| + | tar_main(int argc, char ** argv) |
| { | |
| const char * options; | |
| @@ -1258,167 +1254,6 @@ wantFileName(const char * fileName, int fileCount, char ** fileTable) | |
| - | /* |
| - | * Return the standard ls-like mode string from a file mode. |
| - | * This is static and so is overwritten on each call. |
| - | */ |
| - | const char * |
| - | modeString(int mode) |
| - | { |
| - | static char buf[12]; |
| - | |
| - | strcpy(buf, "----------"); |
| - | |
| - | /* |
| - | * Fill in the file type. |
| - | */ |
| - | if (S_ISDIR(mode)) |
| - | buf[0] = 'd'; |
| - | if (S_ISCHR(mode)) |
| - | buf[0] = 'c'; |
| - | if (S_ISBLK(mode)) |
| - | buf[0] = 'b'; |
| - | if (S_ISFIFO(mode)) |
| - | buf[0] = 'p'; |
| - | #ifdef S_ISLNK |
| - | if (S_ISLNK(mode)) |
| - | buf[0] = 'l'; |
| - | #endif |
| - | #ifdef S_ISSOCK |
| - | if (S_ISSOCK(mode)) |
| - | buf[0] = 's'; |
| - | #endif |
| - | |
| - | /* |
| - | * Now fill in the normal file permissions. |
| - | */ |
| - | if (mode & S_IRUSR) |
| - | buf[1] = 'r'; |
| - | if (mode & S_IWUSR) |
| - | buf[2] = 'w'; |
| - | if (mode & S_IXUSR) |
| - | buf[3] = 'x'; |
| - | if (mode & S_IRGRP) |
| - | buf[4] = 'r'; |
| - | if (mode & S_IWGRP) |
| - | buf[5] = 'w'; |
| - | if (mode & S_IXGRP) |
| - | buf[6] = 'x'; |
| - | if (mode & S_IROTH) |
| - | buf[7] = 'r'; |
| - | if (mode & S_IWOTH) |
| - | buf[8] = 'w'; |
| - | if (mode & S_IXOTH) |
| - | buf[9] = 'x'; |
| - | |
| - | /* |
| - | * Finally fill in magic stuff like suid and sticky text. |
| - | */ |
| - | if (mode & S_ISUID) |
| - | buf[3] = ((mode & S_IXUSR) ? 's' : 'S'); |
| - | if (mode & S_ISGID) |
| - | buf[6] = ((mode & S_IXGRP) ? 's' : 'S'); |
| - | if (mode & S_ISVTX) |
| - | buf[9] = ((mode & S_IXOTH) ? 't' : 'T'); |
| - | |
| - | return buf; |
| - | } |
| - | |
| - | |
| - | /* |
| - | * Get the time string to be used for a file. |
| - | * This is down to the minute for new files, but only the date for old files. |
| - | * The string is returned from a static buffer, and so is overwritten for |
| - | * each call. |
| - | */ |
| - | const char * |
| - | timeString(time_t timeVal) |
| - | { |
| - | time_t now; |
| - | char * str; |
| - | static char buf[26]; |
| - | |
| - | time(&now); |
| - | |
| - | str = ctime(&timeVal); |
| - | |
| - | strcpy(buf, &str[4]); |
| - | buf[12] = '\0'; |
| - | |
| - | if ((timeVal > now) || (timeVal < now - 365*24*60*60L)) |
| - | { |
| - | strcpy(&buf[7], &str[20]); |
| - | buf[11] = '\0'; |
| - | } |
| - | |
| - | return buf; |
| - | } |
| - | |
| - | |
| - | |
| - | /* |
| - | * Write all of the supplied buffer out to a file. |
| - | * This does multiple writes as necessary. |
| - | * Returns the amount written, or -1 on an error. |
| - | */ |
| - | int |
| - | fullWrite(int fd, const char * buf, int len) |
| - | { |
| - | int cc; |
| - | int total; |
| - | |
| - | total = 0; |
| - | |
| - | while (len > 0) |
| - | { |
| - | cc = write(fd, buf, len); |
| - | |
| - | if (cc < 0) |
| - | return -1; |
| - | |
| - | buf += cc; |
| - | total+= cc; |
| - | len -= cc; |
| - | } |
| - | |
| - | return total; |
| - | } |
| - | |
| - | |
| - | /* |
| - | * Read all of the supplied buffer from a file. |
| - | * This does multiple reads as necessary. |
| - | * Returns the amount read, or -1 on an error. |
| - | * A short read is returned on an end of file. |
| - | */ |
| - | int |
| - | fullRead(int fd, char * buf, int len) |
| - | { |
| - | int cc; |
| - | int total; |
| - | |
| - | total = 0; |
| - | |
| - | while (len > 0) |
| - | { |
| - | cc = read(fd, buf, len); |
| - | |
| - | if (cc < 0) |
| - | return -1; |
| - | |
| - | if (cc == 0) |
| - | break; |
| - | |
| - | buf += cc; |
| - | total+= cc; |
| - | len -= cc; |
| - | } |
| - | |
| - | return total; |
| - | } |
| - | |
| - | |
| - | |
| #endif | |
| /* END CODE */ | |
| @@ -28,7 +28,7 @@ static inline _syscall3(int,klog,int,type,char *,b,int,len) | |
| const char dmesg_usage[] = "dmesg"; | |
| int | |
| - | dmesg_main(struct FileInfo * info, int argc, char * * argv) |
| + | dmesg_main(int argc, char * * argv) |
| { | |
| char buf[4096]; | |
| @@ -50,7 +50,7 @@ dmesg_main(struct FileInfo * info, int argc, char * * argv) | |
| break; | |
| case '?': | |
| default: | |
| - | usage(dmesg_usage); |
| + | fprintf(stderr, "%s\n", dmesg_usage); |
| exit(1); | |
| } | |
| } | |
| @@ -58,7 +58,7 @@ dmesg_main(struct FileInfo * info, int argc, char * * argv) | |
| argv += optind; | |
| if (argc > 1) { | |
| - | usage(dmesg_usage); |
| + | fprintf(stderr, "%s\n", dmesg_usage); |
| exit(1); | |
| } | |
| @@ -405,6 +405,131 @@ freeChunks(void) | |
| } | |
| + | /* |
| + | * Get the time string to be used for a file. |
| + | * This is down to the minute for new files, but only the date for old files. |
| + | * The string is returned from a static buffer, and so is overwritten for |
| + | * each call. |
| + | */ |
| + | const char * |
| + | timeString(time_t timeVal) |
| + | { |
| + | time_t now; |
| + | char * str; |
| + | static char buf[26]; |
| + | |
| + | time(&now); |
| + | |
| + | str = ctime(&timeVal); |
| + | |
| + | strcpy(buf, &str[4]); |
| + | buf[12] = '\0'; |
| + | |
| + | if ((timeVal > now) || (timeVal < now - 365*24*60*60L)) |
| + | { |
| + | strcpy(&buf[7], &str[20]); |
| + | buf[11] = '\0'; |
| + | } |
| + | |
| + | return buf; |
| + | } |
| + | |
| + | |
| + | /* |
| + | * Routine to see if a text string is matched by a wildcard pattern. |
| + | * Returns TRUE if the text is matched, or FALSE if it is not matched |
| + | * or if the pattern is invalid. |
| + | * * matches zero or more characters |
| + | * ? matches a single character |
| + | * [abc] matches 'a', 'b' or 'c' |
| + | * \c quotes character c |
| + | * Adapted from code written by Ingo Wilken. |
| + | */ |
| + | BOOL |
| + | match(const char * text, const char * pattern) |
| + | { |
| + | const char * retryPat; |
| + | const char * retryText; |
| + | int ch; |
| + | BOOL found; |
| + | |
| + | retryPat = NULL; |
| + | retryText = NULL; |
| + | |
| + | while (*text || *pattern) |
| + | { |
| + | ch = *pattern++; |
| + | |
| + | switch (ch) |
| + | { |
| + | case '*': |
| + | retryPat = pattern; |
| + | retryText = text; |
| + | break; |
| + | |
| + | case '[': |
| + | found = FALSE; |
| + | |
| + | while ((ch = *pattern++) != ']') |
| + | { |
| + | if (ch == '\\') |
| + | ch = *pattern++; |
| + | |
| + | if (ch == '\0') |
| + | return FALSE; |
| + | |
| + | if (*text == ch) |
| + | found = TRUE; |
| + | } |
| + | |
| + | if (!found) |
| + | { |
| + | pattern = retryPat; |
| + | text = ++retryText; |
| + | } |
| + | |
| + | /* fall into next case */ |
| + | |
| + | case '?': |
| + | if (*text++ == '\0') |
| + | return FALSE; |
| + | |
| + | break; |
| + | |
| + | case '\\': |
| + | ch = *pattern++; |
| + | |
| + | if (ch == '\0') |
| + | return FALSE; |
| + | |
| + | /* fall into next case */ |
| + | |
| + | default: |
| + | if (*text == ch) |
| + | { |
| + | if (*text) |
| + | text++; |
| + | break; |
| + | } |
| + | |
| + | if (*text) |
| + | { |
| + | pattern = retryPat; |
| + | text = ++retryText; |
| + | break; |
| + | } |
| + | |
| + | return FALSE; |
| + | } |
| + | |
| + | if (pattern == NULL) |
| + | return FALSE; |
| + | } |
| + | |
| + | return TRUE; |
| + | } |
| + | |
| + | |
| /* | |
| * Write all of the supplied buffer out to a file. | |
| * This does multiple writes as necessary. | |
| @@ -543,3 +668,14 @@ recursiveAction( const char *fileName, BOOL recurse, BOOL followLinks, | |
| /* END CODE */ | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| @@ -59,7 +59,7 @@ static char *license_msg[] = { | |
| */ | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: zcat.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: zcat.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| #include <ctype.h> | |
| @@ -80,7 +80,7 @@ static char rcsid[] = "$Id: zcat.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; | |
| * The target dependent functions should be defined in tailor.c. | |
| */ | |
| - | /* $Id: zcat.c,v 1.1 1999/10/05 16:24:56 andersen Exp $ */ |
| + | /* $Id: zcat.c,v 1.2 1999/10/06 20:25:32 andersen Exp $ */ |
| #define RECORD_IO 0 | |
| @@ -436,7 +436,7 @@ extern int unlzw OF((int in, int out)); | |
| # undef LZW | |
| #endif | |
| - | /* $Id: zcat.c,v 1.1 1999/10/05 16:24:56 andersen Exp $ */ |
| + | /* $Id: zcat.c,v 1.2 1999/10/06 20:25:32 andersen Exp $ */ |
| /* #include "getopt.h" */ | |
| @@ -698,7 +698,7 @@ int (*work) OF((int infile, int outfile)) = unzip; /* function to call */ | |
| #define strequ(s1, s2) (strcmp((s1),(s2)) == 0) | |
| /* ======================================================================== */ | |
| - | int zcat_main (struct FileInfo * i, int argc, char * * argv) |
| + | int zcat_main (int argc, char * * argv) |
| { | |
| int file_count; /* number of files to precess */ | |
| @@ -895,7 +895,7 @@ RETSIGTYPE abort_gzip() | |
| */ | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: zcat.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: zcat.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| /* #include "crypt.h" */ | |
| @@ -1021,7 +1021,7 @@ int unzip(in, out) | |
| */ | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: zcat.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: zcat.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| #include <ctype.h> | |
| @@ -1408,7 +1408,7 @@ ulg crc_32_tab[] = { | |
| */ | |
| #ifdef RCSID | |
| - | static char rcsid[] = "$Id: zcat.c,v 1.1 1999/10/05 16:24:56 andersen Exp $"; |
| + | static char rcsid[] = "$Id: zcat.c,v 1.2 1999/10/06 20:25:32 andersen Exp $"; |
| #endif | |
| #include <sys/types.h> | |