summaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
Diffstat (limited to 'findutils')
-rw-r--r--findutils/Makefile39
-rw-r--r--findutils/config.in14
-rw-r--r--findutils/find.c24
-rw-r--r--findutils/grep.c36
-rw-r--r--findutils/which.c4
-rw-r--r--findutils/xargs.c8
6 files changed, 89 insertions, 36 deletions
diff --git a/findutils/Makefile b/findutils/Makefile
new file mode 100644
index 0000000..ac590cc
--- /dev/null
+++ b/findutils/Makefile
@@ -0,0 +1,39 @@
+# Makefile for busybox
+#
+# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+#
+# 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
+#
+
+TOPDIR :=..
+L_TARGET := findutils.a
+
+obj-y :=
+obj-n :=
+obj- :=
+
+
+obj-$(CONFIG_FIND) += find.o
+obj-$(CONFIG_GREP) += grep.o
+obj-$(CONFIG_WHICH) += which.o
+obj-$(CONFIG_XARGS) += xargs.o
+
+
+# Hand off to toplevel Rules.mak
+include $(TOPDIR)/Rules.mak
+
+clean:
+ rm -f $(L_TARGET) *.o core
+
diff --git a/findutils/config.in b/findutils/config.in
new file mode 100644
index 0000000..8e41bd5
--- /dev/null
+++ b/findutils/config.in
@@ -0,0 +1,14 @@
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+mainmenu_option next_comment
+comment 'Finding Utilities'
+
+bool 'find' CONFIG_FIND
+bool 'grep' CONFIG_GREP
+bool 'which' CONFIG_WHICH
+bool 'xargs' CONFIG_XARGS
+endmenu
+
diff --git a/findutils/find.c b/findutils/find.c
index e814c97..262213e 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -2,9 +2,9 @@
/*
* Mini find implementation for busybox
*
+ * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
- * Copyright (C) 1999,2000,2001 by Lineo, inc.
- * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Reworked by David Douthitt <n9ubh@callsign.net> and
* Matt Kraai <kraai@alumni.carnegiemellon.edu>.
*
@@ -37,16 +37,16 @@
static char *pattern;
-#ifdef BB_FEATURE_FIND_TYPE
+#ifdef CONFIG_FEATURE_FIND_TYPE
static int type_mask = 0;
#endif
-#ifdef BB_FEATURE_FIND_PERM
+#ifdef CONFIG_FEATURE_FIND_PERM
static char perm_char = 0;
static int perm_mask = 0;
#endif
-#ifdef BB_FEATURE_FIND_MTIME
+#ifdef CONFIG_FEATURE_FIND_MTIME
static char mtime_char;
static int mtime_days;
#endif
@@ -63,13 +63,13 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
if (!(fnmatch(pattern, tmp, FNM_PERIOD) == 0))
goto no_match;
}
-#ifdef BB_FEATURE_FIND_TYPE
+#ifdef CONFIG_FEATURE_FIND_TYPE
if (type_mask != 0) {
if (!((statbuf->st_mode & S_IFMT) == type_mask))
goto no_match;
}
#endif
-#ifdef BB_FEATURE_FIND_PERM
+#ifdef CONFIG_FEATURE_FIND_PERM
if (perm_mask != 0) {
if (!((isdigit(perm_char) && (statbuf->st_mode & 07777) == perm_mask) ||
(perm_char == '-' && (statbuf->st_mode & perm_mask) == perm_mask) ||
@@ -77,7 +77,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
goto no_match;
}
#endif
-#ifdef BB_FEATURE_FIND_MTIME
+#ifdef CONFIG_FEATURE_FIND_MTIME
if (mtime_days != 0) {
time_t file_age = time(NULL) - statbuf->st_mtime;
time_t mtime_secs = mtime_days * 24 * 60 * 60;
@@ -93,7 +93,7 @@ no_match:
return (TRUE);
}
-#ifdef BB_FEATURE_FIND_TYPE
+#ifdef CONFIG_FEATURE_FIND_TYPE
static int find_type(char *type)
{
int mask = 0;
@@ -150,13 +150,13 @@ int find_main(int argc, char **argv)
if (++i == argc)
error_msg_and_die("option `-name' requires an argument");
pattern = argv[i];
-#ifdef BB_FEATURE_FIND_TYPE
+#ifdef CONFIG_FEATURE_FIND_TYPE
} else if (strcmp(argv[i], "-type") == 0) {
if (++i == argc)
error_msg_and_die("option `-type' requires an argument");
type_mask = find_type(argv[i]);
#endif
-#ifdef BB_FEATURE_FIND_PERM
+#ifdef CONFIG_FEATURE_FIND_PERM
} else if (strcmp(argv[i], "-perm") == 0) {
char *end;
if (++i == argc)
@@ -169,7 +169,7 @@ int find_main(int argc, char **argv)
if ((perm_char = argv[i][0]) == '-')
perm_mask = -perm_mask;
#endif
-#ifdef BB_FEATURE_FIND_MTIME
+#ifdef CONFIG_FEATURE_FIND_MTIME
} else if (strcmp(argv[i], "-mtime") == 0) {
char *end;
if (++i == argc)
diff --git a/findutils/grep.c b/findutils/grep.c
index eff7c3f..a97a8bb 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -1,8 +1,8 @@
/*
* Mini grep implementation for busybox using libc regex.
*
- * Copyright (C) 1999,2000,2001 by Lineo, inc.
- * Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
+ * Copyright (C) 1999,2000,2001 by Lineo, inc. and Mark Whitley
+ * Copyright (C) 1999,2000,2001 by Mark Whitley <markw@codepoet.org>
*
* 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
@@ -42,13 +42,13 @@ static int invert_search = 0;
static int suppress_err_msgs = 0;
static int print_files_with_matches = 0;
-#ifdef BB_FEATURE_GREP_CONTEXT
+#ifdef CONFIG_FEATURE_GREP_CONTEXT
extern char *optarg; /* in getopt.h */
static int lines_before = 0;
static int lines_after = 0;
static char **before_buf = NULL;
static int last_line_printed = 0;
-#endif /* BB_FEATURE_GREP_CONTEXT */
+#endif /* CONFIG_FEATURE_GREP_CONTEXT */
/* globals used internally */
static regex_t *regexes = NULL; /* growable array of compiled regular expressions */
@@ -59,7 +59,7 @@ static char *cur_file = NULL; /* the current file we are reading */
static void print_line(const char *line, int linenum, char decoration)
{
-#ifdef BB_FEATURE_GREP_CONTEXT
+#ifdef CONFIG_FEATURE_GREP_CONTEXT
/* possibly print the little '--' seperator */
if ((lines_before || lines_after) && last_line_printed &&
last_line_printed < linenum - 1) {
@@ -82,11 +82,11 @@ static void grep_file(FILE *file)
int linenum = 0;
int nmatches = 0;
int i;
-#ifdef BB_FEATURE_GREP_CONTEXT
+#ifdef CONFIG_FEATURE_GREP_CONTEXT
int print_n_lines_after = 0;
int curpos = 0; /* track where we are in the circular 'before' buffer */
int idx = 0; /* used for iteration through the circular buffer */
-#endif /* BB_FEATURE_GREP_CONTEXT */
+#endif /* CONFIG_FEATURE_GREP_CONTEXT */
while ((line = get_line_from_file(file)) != NULL) {
chomp(line);
@@ -116,7 +116,7 @@ static void grep_file(FILE *file)
/* print the matched line */
if (print_match_counts == 0) {
-#ifdef BB_FEATURE_GREP_CONTEXT
+#ifdef CONFIG_FEATURE_GREP_CONTEXT
int prevpos = (curpos == 0) ? lines_before - 1 : curpos - 1;
/* if we were told to print 'before' lines and there is at least
@@ -145,11 +145,11 @@ static void grep_file(FILE *file)
/* make a note that we need to print 'after' lines */
print_n_lines_after = lines_after;
-#endif /* BB_FEATURE_GREP_CONTEXT */
+#endif /* CONFIG_FEATURE_GREP_CONTEXT */
print_line(line, linenum, ':');
}
}
-#ifdef BB_FEATURE_GREP_CONTEXT
+#ifdef CONFIG_FEATURE_GREP_CONTEXT
else { /* no match */
/* Add the line to the circular 'before' buffer */
if(lines_before) {
@@ -165,7 +165,7 @@ static void grep_file(FILE *file)
print_line(line, linenum, '-');
print_n_lines_after--;
}
-#endif /* BB_FEATURE_GREP_CONTEXT */
+#endif /* CONFIG_FEATURE_GREP_CONTEXT */
} /* for */
free(line);
}
@@ -215,7 +215,7 @@ static void load_regexes_from_file(const char *filename)
}
-#ifdef BB_FEATURE_CLEAN_UP
+#ifdef CONFIG_FEATURE_CLEAN_UP
static void destroy_regexes()
{
if (regexes == NULL)
@@ -233,11 +233,11 @@ static void destroy_regexes()
extern int grep_main(int argc, char **argv)
{
int opt;
-#ifdef BB_FEATURE_GREP_CONTEXT
+#ifdef CONFIG_FEATURE_GREP_CONTEXT
char *junk;
#endif
-#ifdef BB_FEATURE_CLEAN_UP
+#ifdef CONFIG_FEATURE_CLEAN_UP
/* destroy command strings on exit */
if (atexit(destroy_regexes) == -1)
perror_msg_and_die("atexit");
@@ -245,7 +245,7 @@ extern int grep_main(int argc, char **argv)
/* do normal option parsing */
while ((opt = getopt(argc, argv, "iHhlnqvsce:f:"
-#ifdef BB_FEATURE_GREP_CONTEXT
+#ifdef CONFIG_FEATURE_GREP_CONTEXT
"A:B:C:"
#endif
)) > 0) {
@@ -283,7 +283,7 @@ extern int grep_main(int argc, char **argv)
case 'f':
load_regexes_from_file(optarg);
break;
-#ifdef BB_FEATURE_GREP_CONTEXT
+#ifdef CONFIG_FEATURE_GREP_CONTEXT
case 'A':
lines_after = strtoul(optarg, &junk, 10);
if(*junk != '\0')
@@ -301,7 +301,7 @@ extern int grep_main(int argc, char **argv)
error_msg_and_die("invalid context length argument");
before_buf = (char **)calloc(lines_before, sizeof(char *));
break;
-#endif /* BB_FEATURE_GREP_CONTEXT */
+#endif /* CONFIG_FEATURE_GREP_CONTEXT */
default:
show_usage();
}
@@ -321,7 +321,7 @@ extern int grep_main(int argc, char **argv)
/* sanity checks */
if (print_match_counts || be_quiet || print_files_with_matches) {
print_line_num = 0;
-#ifdef BB_FEATURE_GREP_CONTEXT
+#ifdef CONFIG_FEATURE_GREP_CONTEXT
lines_before = 0;
lines_after = 0;
#endif
diff --git a/findutils/which.c b/findutils/which.c
index c460ffd..eec5fdb 100644
--- a/findutils/which.c
+++ b/findutils/which.c
@@ -2,8 +2,8 @@
/*
* Which implementation for busybox
*
- * Copyright (C) 1999,2000,2001 by Lineo, inc.
- * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+ * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* 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
diff --git a/findutils/xargs.c b/findutils/xargs.c
index 48adae9..5d64d0c 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -1,9 +1,9 @@
/*
* Mini xargs implementation for busybox
*
- * Copyright (C) 1999,2000,2001 by Lineo, inc.
- * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
- * Remixed by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
+ * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ * Remixed by Mark Whitley <markw@codepoet.org>
*
* 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
@@ -95,7 +95,7 @@ int xargs_main(int argc, char **argv)
free(file_to_act_on);
}
-#ifdef BB_FEATURE_CLEAN_UP
+#ifdef CONFIG_FEATURE_CLEAN_UP
free(cmd_to_be_executed);
#endif