diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-10-24 05:00:29 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-10-24 05:00:29 +0000 |
commit | bdfd0d78bc44e73d693510e70087857785b3b521 (patch) | |
tree | 153a573095afac8d8d0ea857759ecabd77fb28b7 /findutils | |
parent | 9260fc5552a3ee52eb95823aa6689d52a1ffd33c (diff) | |
download | busybox-w32-bdfd0d78bc44e73d693510e70087857785b3b521.tar.gz busybox-w32-bdfd0d78bc44e73d693510e70087857785b3b521.tar.bz2 busybox-w32-bdfd0d78bc44e73d693510e70087857785b3b521.zip |
Major rework of the directory structure and the entire build system.
-Erik
Diffstat (limited to 'findutils')
-rw-r--r-- | findutils/Makefile | 39 | ||||
-rw-r--r-- | findutils/config.in | 14 | ||||
-rw-r--r-- | findutils/find.c | 24 | ||||
-rw-r--r-- | findutils/grep.c | 36 | ||||
-rw-r--r-- | findutils/which.c | 4 | ||||
-rw-r--r-- | findutils/xargs.c | 8 |
6 files changed, 89 insertions, 36 deletions
diff --git a/findutils/Makefile b/findutils/Makefile new file mode 100644 index 000000000..ac590ccf4 --- /dev/null +++ b/findutils/Makefile | |||
@@ -0,0 +1,39 @@ | |||
1 | # Makefile for busybox | ||
2 | # | ||
3 | # Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org> | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License as published by | ||
7 | # the Free Software Foundation; either version 2 of the License, or | ||
8 | # (at your option) any later version. | ||
9 | # | ||
10 | # This program is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | # General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with this program; if not, write to the Free Software | ||
17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | # | ||
19 | |||
20 | TOPDIR :=.. | ||
21 | L_TARGET := findutils.a | ||
22 | |||
23 | obj-y := | ||
24 | obj-n := | ||
25 | obj- := | ||
26 | |||
27 | |||
28 | obj-$(CONFIG_FIND) += find.o | ||
29 | obj-$(CONFIG_GREP) += grep.o | ||
30 | obj-$(CONFIG_WHICH) += which.o | ||
31 | obj-$(CONFIG_XARGS) += xargs.o | ||
32 | |||
33 | |||
34 | # Hand off to toplevel Rules.mak | ||
35 | include $(TOPDIR)/Rules.mak | ||
36 | |||
37 | clean: | ||
38 | rm -f $(L_TARGET) *.o core | ||
39 | |||
diff --git a/findutils/config.in b/findutils/config.in new file mode 100644 index 000000000..8e41bd50c --- /dev/null +++ b/findutils/config.in | |||
@@ -0,0 +1,14 @@ | |||
1 | # | ||
2 | # For a description of the syntax of this configuration file, | ||
3 | # see scripts/kbuild/config-language.txt. | ||
4 | # | ||
5 | |||
6 | mainmenu_option next_comment | ||
7 | comment 'Finding Utilities' | ||
8 | |||
9 | bool 'find' CONFIG_FIND | ||
10 | bool 'grep' CONFIG_GREP | ||
11 | bool 'which' CONFIG_WHICH | ||
12 | bool 'xargs' CONFIG_XARGS | ||
13 | endmenu | ||
14 | |||
diff --git a/findutils/find.c b/findutils/find.c index e814c97b9..262213e8b 100644 --- a/findutils/find.c +++ b/findutils/find.c | |||
@@ -2,9 +2,9 @@ | |||
2 | /* | 2 | /* |
3 | * Mini find implementation for busybox | 3 | * Mini find implementation for busybox |
4 | * | 4 | * |
5 | * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen | ||
6 | * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org> | ||
5 | * | 7 | * |
6 | * Copyright (C) 1999,2000,2001 by Lineo, inc. | ||
7 | * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> | ||
8 | * Reworked by David Douthitt <n9ubh@callsign.net> and | 8 | * Reworked by David Douthitt <n9ubh@callsign.net> and |
9 | * Matt Kraai <kraai@alumni.carnegiemellon.edu>. | 9 | * Matt Kraai <kraai@alumni.carnegiemellon.edu>. |
10 | * | 10 | * |
@@ -37,16 +37,16 @@ | |||
37 | 37 | ||
38 | static char *pattern; | 38 | static char *pattern; |
39 | 39 | ||
40 | #ifdef BB_FEATURE_FIND_TYPE | 40 | #ifdef CONFIG_FEATURE_FIND_TYPE |
41 | static int type_mask = 0; | 41 | static int type_mask = 0; |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #ifdef BB_FEATURE_FIND_PERM | 44 | #ifdef CONFIG_FEATURE_FIND_PERM |
45 | static char perm_char = 0; | 45 | static char perm_char = 0; |
46 | static int perm_mask = 0; | 46 | static int perm_mask = 0; |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #ifdef BB_FEATURE_FIND_MTIME | 49 | #ifdef CONFIG_FEATURE_FIND_MTIME |
50 | static char mtime_char; | 50 | static char mtime_char; |
51 | static int mtime_days; | 51 | static int mtime_days; |
52 | #endif | 52 | #endif |
@@ -63,13 +63,13 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk) | |||
63 | if (!(fnmatch(pattern, tmp, FNM_PERIOD) == 0)) | 63 | if (!(fnmatch(pattern, tmp, FNM_PERIOD) == 0)) |
64 | goto no_match; | 64 | goto no_match; |
65 | } | 65 | } |
66 | #ifdef BB_FEATURE_FIND_TYPE | 66 | #ifdef CONFIG_FEATURE_FIND_TYPE |
67 | if (type_mask != 0) { | 67 | if (type_mask != 0) { |
68 | if (!((statbuf->st_mode & S_IFMT) == type_mask)) | 68 | if (!((statbuf->st_mode & S_IFMT) == type_mask)) |
69 | goto no_match; | 69 | goto no_match; |
70 | } | 70 | } |
71 | #endif | 71 | #endif |
72 | #ifdef BB_FEATURE_FIND_PERM | 72 | #ifdef CONFIG_FEATURE_FIND_PERM |
73 | if (perm_mask != 0) { | 73 | if (perm_mask != 0) { |
74 | if (!((isdigit(perm_char) && (statbuf->st_mode & 07777) == perm_mask) || | 74 | if (!((isdigit(perm_char) && (statbuf->st_mode & 07777) == perm_mask) || |
75 | (perm_char == '-' && (statbuf->st_mode & perm_mask) == perm_mask) || | 75 | (perm_char == '-' && (statbuf->st_mode & perm_mask) == perm_mask) || |
@@ -77,7 +77,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk) | |||
77 | goto no_match; | 77 | goto no_match; |
78 | } | 78 | } |
79 | #endif | 79 | #endif |
80 | #ifdef BB_FEATURE_FIND_MTIME | 80 | #ifdef CONFIG_FEATURE_FIND_MTIME |
81 | if (mtime_days != 0) { | 81 | if (mtime_days != 0) { |
82 | time_t file_age = time(NULL) - statbuf->st_mtime; | 82 | time_t file_age = time(NULL) - statbuf->st_mtime; |
83 | time_t mtime_secs = mtime_days * 24 * 60 * 60; | 83 | time_t mtime_secs = mtime_days * 24 * 60 * 60; |
@@ -93,7 +93,7 @@ no_match: | |||
93 | return (TRUE); | 93 | return (TRUE); |
94 | } | 94 | } |
95 | 95 | ||
96 | #ifdef BB_FEATURE_FIND_TYPE | 96 | #ifdef CONFIG_FEATURE_FIND_TYPE |
97 | static int find_type(char *type) | 97 | static int find_type(char *type) |
98 | { | 98 | { |
99 | int mask = 0; | 99 | int mask = 0; |
@@ -150,13 +150,13 @@ int find_main(int argc, char **argv) | |||
150 | if (++i == argc) | 150 | if (++i == argc) |
151 | error_msg_and_die("option `-name' requires an argument"); | 151 | error_msg_and_die("option `-name' requires an argument"); |
152 | pattern = argv[i]; | 152 | pattern = argv[i]; |
153 | #ifdef BB_FEATURE_FIND_TYPE | 153 | #ifdef CONFIG_FEATURE_FIND_TYPE |
154 | } else if (strcmp(argv[i], "-type") == 0) { | 154 | } else if (strcmp(argv[i], "-type") == 0) { |
155 | if (++i == argc) | 155 | if (++i == argc) |
156 | error_msg_and_die("option `-type' requires an argument"); | 156 | error_msg_and_die("option `-type' requires an argument"); |
157 | type_mask = find_type(argv[i]); | 157 | type_mask = find_type(argv[i]); |
158 | #endif | 158 | #endif |
159 | #ifdef BB_FEATURE_FIND_PERM | 159 | #ifdef CONFIG_FEATURE_FIND_PERM |
160 | } else if (strcmp(argv[i], "-perm") == 0) { | 160 | } else if (strcmp(argv[i], "-perm") == 0) { |
161 | char *end; | 161 | char *end; |
162 | if (++i == argc) | 162 | if (++i == argc) |
@@ -169,7 +169,7 @@ int find_main(int argc, char **argv) | |||
169 | if ((perm_char = argv[i][0]) == '-') | 169 | if ((perm_char = argv[i][0]) == '-') |
170 | perm_mask = -perm_mask; | 170 | perm_mask = -perm_mask; |
171 | #endif | 171 | #endif |
172 | #ifdef BB_FEATURE_FIND_MTIME | 172 | #ifdef CONFIG_FEATURE_FIND_MTIME |
173 | } else if (strcmp(argv[i], "-mtime") == 0) { | 173 | } else if (strcmp(argv[i], "-mtime") == 0) { |
174 | char *end; | 174 | char *end; |
175 | if (++i == argc) | 175 | if (++i == argc) |
diff --git a/findutils/grep.c b/findutils/grep.c index eff7c3ff5..a97a8bbb7 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * Mini grep implementation for busybox using libc regex. | 2 | * Mini grep implementation for busybox using libc regex. |
3 | * | 3 | * |
4 | * Copyright (C) 1999,2000,2001 by Lineo, inc. | 4 | * Copyright (C) 1999,2000,2001 by Lineo, inc. and Mark Whitley |
5 | * Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org> | 5 | * Copyright (C) 1999,2000,2001 by Mark Whitley <markw@codepoet.org> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
@@ -42,13 +42,13 @@ static int invert_search = 0; | |||
42 | static int suppress_err_msgs = 0; | 42 | static int suppress_err_msgs = 0; |
43 | static int print_files_with_matches = 0; | 43 | static int print_files_with_matches = 0; |
44 | 44 | ||
45 | #ifdef BB_FEATURE_GREP_CONTEXT | 45 | #ifdef CONFIG_FEATURE_GREP_CONTEXT |
46 | extern char *optarg; /* in getopt.h */ | 46 | extern char *optarg; /* in getopt.h */ |
47 | static int lines_before = 0; | 47 | static int lines_before = 0; |
48 | static int lines_after = 0; | 48 | static int lines_after = 0; |
49 | static char **before_buf = NULL; | 49 | static char **before_buf = NULL; |
50 | static int last_line_printed = 0; | 50 | static int last_line_printed = 0; |
51 | #endif /* BB_FEATURE_GREP_CONTEXT */ | 51 | #endif /* CONFIG_FEATURE_GREP_CONTEXT */ |
52 | 52 | ||
53 | /* globals used internally */ | 53 | /* globals used internally */ |
54 | static regex_t *regexes = NULL; /* growable array of compiled regular expressions */ | 54 | 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 */ | |||
59 | 59 | ||
60 | static void print_line(const char *line, int linenum, char decoration) | 60 | static void print_line(const char *line, int linenum, char decoration) |
61 | { | 61 | { |
62 | #ifdef BB_FEATURE_GREP_CONTEXT | 62 | #ifdef CONFIG_FEATURE_GREP_CONTEXT |
63 | /* possibly print the little '--' seperator */ | 63 | /* possibly print the little '--' seperator */ |
64 | if ((lines_before || lines_after) && last_line_printed && | 64 | if ((lines_before || lines_after) && last_line_printed && |
65 | last_line_printed < linenum - 1) { | 65 | last_line_printed < linenum - 1) { |
@@ -82,11 +82,11 @@ static void grep_file(FILE *file) | |||
82 | int linenum = 0; | 82 | int linenum = 0; |
83 | int nmatches = 0; | 83 | int nmatches = 0; |
84 | int i; | 84 | int i; |
85 | #ifdef BB_FEATURE_GREP_CONTEXT | 85 | #ifdef CONFIG_FEATURE_GREP_CONTEXT |
86 | int print_n_lines_after = 0; | 86 | int print_n_lines_after = 0; |
87 | int curpos = 0; /* track where we are in the circular 'before' buffer */ | 87 | int curpos = 0; /* track where we are in the circular 'before' buffer */ |
88 | int idx = 0; /* used for iteration through the circular buffer */ | 88 | int idx = 0; /* used for iteration through the circular buffer */ |
89 | #endif /* BB_FEATURE_GREP_CONTEXT */ | 89 | #endif /* CONFIG_FEATURE_GREP_CONTEXT */ |
90 | 90 | ||
91 | while ((line = get_line_from_file(file)) != NULL) { | 91 | while ((line = get_line_from_file(file)) != NULL) { |
92 | chomp(line); | 92 | chomp(line); |
@@ -116,7 +116,7 @@ static void grep_file(FILE *file) | |||
116 | 116 | ||
117 | /* print the matched line */ | 117 | /* print the matched line */ |
118 | if (print_match_counts == 0) { | 118 | if (print_match_counts == 0) { |
119 | #ifdef BB_FEATURE_GREP_CONTEXT | 119 | #ifdef CONFIG_FEATURE_GREP_CONTEXT |
120 | int prevpos = (curpos == 0) ? lines_before - 1 : curpos - 1; | 120 | int prevpos = (curpos == 0) ? lines_before - 1 : curpos - 1; |
121 | 121 | ||
122 | /* if we were told to print 'before' lines and there is at least | 122 | /* if we were told to print 'before' lines and there is at least |
@@ -145,11 +145,11 @@ static void grep_file(FILE *file) | |||
145 | 145 | ||
146 | /* make a note that we need to print 'after' lines */ | 146 | /* make a note that we need to print 'after' lines */ |
147 | print_n_lines_after = lines_after; | 147 | print_n_lines_after = lines_after; |
148 | #endif /* BB_FEATURE_GREP_CONTEXT */ | 148 | #endif /* CONFIG_FEATURE_GREP_CONTEXT */ |
149 | print_line(line, linenum, ':'); | 149 | print_line(line, linenum, ':'); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | #ifdef BB_FEATURE_GREP_CONTEXT | 152 | #ifdef CONFIG_FEATURE_GREP_CONTEXT |
153 | else { /* no match */ | 153 | else { /* no match */ |
154 | /* Add the line to the circular 'before' buffer */ | 154 | /* Add the line to the circular 'before' buffer */ |
155 | if(lines_before) { | 155 | if(lines_before) { |
@@ -165,7 +165,7 @@ static void grep_file(FILE *file) | |||
165 | print_line(line, linenum, '-'); | 165 | print_line(line, linenum, '-'); |
166 | print_n_lines_after--; | 166 | print_n_lines_after--; |
167 | } | 167 | } |
168 | #endif /* BB_FEATURE_GREP_CONTEXT */ | 168 | #endif /* CONFIG_FEATURE_GREP_CONTEXT */ |
169 | } /* for */ | 169 | } /* for */ |
170 | free(line); | 170 | free(line); |
171 | } | 171 | } |
@@ -215,7 +215,7 @@ static void load_regexes_from_file(const char *filename) | |||
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | #ifdef BB_FEATURE_CLEAN_UP | 218 | #ifdef CONFIG_FEATURE_CLEAN_UP |
219 | static void destroy_regexes() | 219 | static void destroy_regexes() |
220 | { | 220 | { |
221 | if (regexes == NULL) | 221 | if (regexes == NULL) |
@@ -233,11 +233,11 @@ static void destroy_regexes() | |||
233 | extern int grep_main(int argc, char **argv) | 233 | extern int grep_main(int argc, char **argv) |
234 | { | 234 | { |
235 | int opt; | 235 | int opt; |
236 | #ifdef BB_FEATURE_GREP_CONTEXT | 236 | #ifdef CONFIG_FEATURE_GREP_CONTEXT |
237 | char *junk; | 237 | char *junk; |
238 | #endif | 238 | #endif |
239 | 239 | ||
240 | #ifdef BB_FEATURE_CLEAN_UP | 240 | #ifdef CONFIG_FEATURE_CLEAN_UP |
241 | /* destroy command strings on exit */ | 241 | /* destroy command strings on exit */ |
242 | if (atexit(destroy_regexes) == -1) | 242 | if (atexit(destroy_regexes) == -1) |
243 | perror_msg_and_die("atexit"); | 243 | perror_msg_and_die("atexit"); |
@@ -245,7 +245,7 @@ extern int grep_main(int argc, char **argv) | |||
245 | 245 | ||
246 | /* do normal option parsing */ | 246 | /* do normal option parsing */ |
247 | while ((opt = getopt(argc, argv, "iHhlnqvsce:f:" | 247 | while ((opt = getopt(argc, argv, "iHhlnqvsce:f:" |
248 | #ifdef BB_FEATURE_GREP_CONTEXT | 248 | #ifdef CONFIG_FEATURE_GREP_CONTEXT |
249 | "A:B:C:" | 249 | "A:B:C:" |
250 | #endif | 250 | #endif |
251 | )) > 0) { | 251 | )) > 0) { |
@@ -283,7 +283,7 @@ extern int grep_main(int argc, char **argv) | |||
283 | case 'f': | 283 | case 'f': |
284 | load_regexes_from_file(optarg); | 284 | load_regexes_from_file(optarg); |
285 | break; | 285 | break; |
286 | #ifdef BB_FEATURE_GREP_CONTEXT | 286 | #ifdef CONFIG_FEATURE_GREP_CONTEXT |
287 | case 'A': | 287 | case 'A': |
288 | lines_after = strtoul(optarg, &junk, 10); | 288 | lines_after = strtoul(optarg, &junk, 10); |
289 | if(*junk != '\0') | 289 | if(*junk != '\0') |
@@ -301,7 +301,7 @@ extern int grep_main(int argc, char **argv) | |||
301 | error_msg_and_die("invalid context length argument"); | 301 | error_msg_and_die("invalid context length argument"); |
302 | before_buf = (char **)calloc(lines_before, sizeof(char *)); | 302 | before_buf = (char **)calloc(lines_before, sizeof(char *)); |
303 | break; | 303 | break; |
304 | #endif /* BB_FEATURE_GREP_CONTEXT */ | 304 | #endif /* CONFIG_FEATURE_GREP_CONTEXT */ |
305 | default: | 305 | default: |
306 | show_usage(); | 306 | show_usage(); |
307 | } | 307 | } |
@@ -321,7 +321,7 @@ extern int grep_main(int argc, char **argv) | |||
321 | /* sanity checks */ | 321 | /* sanity checks */ |
322 | if (print_match_counts || be_quiet || print_files_with_matches) { | 322 | if (print_match_counts || be_quiet || print_files_with_matches) { |
323 | print_line_num = 0; | 323 | print_line_num = 0; |
324 | #ifdef BB_FEATURE_GREP_CONTEXT | 324 | #ifdef CONFIG_FEATURE_GREP_CONTEXT |
325 | lines_before = 0; | 325 | lines_before = 0; |
326 | lines_after = 0; | 326 | lines_after = 0; |
327 | #endif | 327 | #endif |
diff --git a/findutils/which.c b/findutils/which.c index c460ffdd1..eec5fdbfb 100644 --- a/findutils/which.c +++ b/findutils/which.c | |||
@@ -2,8 +2,8 @@ | |||
2 | /* | 2 | /* |
3 | * Which implementation for busybox | 3 | * Which implementation for busybox |
4 | * | 4 | * |
5 | * Copyright (C) 1999,2000,2001 by Lineo, inc. | 5 | * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen |
6 | * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> | 6 | * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
diff --git a/findutils/xargs.c b/findutils/xargs.c index 48adae90a..5d64d0c9f 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * Mini xargs implementation for busybox | 2 | * Mini xargs implementation for busybox |
3 | * | 3 | * |
4 | * Copyright (C) 1999,2000,2001 by Lineo, inc. | 4 | * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen |
5 | * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> | 5 | * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org> |
6 | * Remixed by Mark Whitley <markw@lineo.com>, <markw@codepoet.org> | 6 | * Remixed by Mark Whitley <markw@codepoet.org> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
@@ -95,7 +95,7 @@ int xargs_main(int argc, char **argv) | |||
95 | free(file_to_act_on); | 95 | free(file_to_act_on); |
96 | } | 96 | } |
97 | 97 | ||
98 | #ifdef BB_FEATURE_CLEAN_UP | 98 | #ifdef CONFIG_FEATURE_CLEAN_UP |
99 | free(cmd_to_be_executed); | 99 | free(cmd_to_be_executed); |
100 | #endif | 100 | #endif |
101 | 101 | ||