aboutsummaryrefslogtreecommitdiff
path: root/findutils/find.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-01 10:25:35 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-01 10:25:35 +0000
commit92258541449581302e180d05e827e27d35030a18 (patch)
tree99c5ad443f69860833c8ef37e142fddfedb90872 /findutils/find.c
parent048c93cc5593d53d6243c3e15dc8a5b0072a6083 (diff)
downloadbusybox-w32-92258541449581302e180d05e827e27d35030a18.tar.gz
busybox-w32-92258541449581302e180d05e827e27d35030a18.tar.bz2
busybox-w32-92258541449581302e180d05e827e27d35030a18.zip
mostly style fixes
Diffstat (limited to 'findutils/find.c')
-rw-r--r--findutils/find.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/findutils/find.c b/findutils/find.c
index f3f4d959d..edb8482d8 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -56,20 +56,20 @@ typedef int (*action_fp)(const char *fileName, struct stat *statbuf, void *);
56typedef struct { 56typedef struct {
57 action_fp f; 57 action_fp f;
58} action; 58} action;
59#define SACT(name, arg...) typedef struct { action a; arg; } action_##name; 59#define ACTS(name, arg...) typedef struct { action a; arg; } action_##name;
60#define SFUNC(name) static int func_##name(const char *fileName, struct stat *statbuf, action_##name* ap) 60#define ACTF(name) static int func_##name(const char *fileName, struct stat *statbuf, action_##name* ap)
61 SACT(print) 61 ACTS(print)
62 SACT(name, char *pattern;) 62 ACTS(name, char *pattern;)
63USE_FEATURE_FIND_PRINT0(SACT(print0)) 63USE_FEATURE_FIND_PRINT0(ACTS(print0))
64USE_FEATURE_FIND_TYPE( SACT(type, int type_mask;)) 64USE_FEATURE_FIND_TYPE( ACTS(type, int type_mask;))
65USE_FEATURE_FIND_PERM( SACT(perm, char perm_char; int perm_mask;)) 65USE_FEATURE_FIND_PERM( ACTS(perm, char perm_char; int perm_mask;))
66USE_FEATURE_FIND_MTIME( SACT(mtime, char mtime_char; int mtime_days;)) 66USE_FEATURE_FIND_MTIME( ACTS(mtime, char mtime_char; int mtime_days;))
67USE_FEATURE_FIND_MMIN( SACT(mmin, char mmin_char; int mmin_mins;)) 67USE_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; int mmin_mins;))
68USE_FEATURE_FIND_NEWER( SACT(newer, time_t newer_mtime;)) 68USE_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;))
69USE_FEATURE_FIND_INUM( SACT(inum, ino_t inode_num;)) 69USE_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;))
70USE_FEATURE_FIND_EXEC( SACT(exec, char **exec_argv; int *subst_count; int exec_argc;)) 70USE_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; int *subst_count; int exec_argc;))
71USE_DESKTOP( SACT(paren, action ***subexpr;)) 71USE_DESKTOP( ACTS(paren, action ***subexpr;))
72USE_DESKTOP( SACT(prune)) 72USE_DESKTOP( ACTS(prune))
73 73
74static action ***actions; 74static action ***actions;
75static int need_print = 1; 75static int need_print = 1;
@@ -131,7 +131,7 @@ static int exec_actions(action ***appp, const char *fileName, struct stat *statb
131} 131}
132 132
133 133
134SFUNC(name) 134ACTF(name)
135{ 135{
136 const char *tmp = strrchr(fileName, '/'); 136 const char *tmp = strrchr(fileName, '/');
137 if (tmp == NULL) 137 if (tmp == NULL)
@@ -141,13 +141,13 @@ SFUNC(name)
141 return fnmatch(ap->pattern, tmp, FNM_PERIOD) == 0; 141 return fnmatch(ap->pattern, tmp, FNM_PERIOD) == 0;
142} 142}
143#if ENABLE_FEATURE_FIND_TYPE 143#if ENABLE_FEATURE_FIND_TYPE
144SFUNC(type) 144ACTF(type)
145{ 145{
146 return ((statbuf->st_mode & S_IFMT) == ap->type_mask); 146 return ((statbuf->st_mode & S_IFMT) == ap->type_mask);
147} 147}
148#endif 148#endif
149#if ENABLE_FEATURE_FIND_PERM 149#if ENABLE_FEATURE_FIND_PERM
150SFUNC(perm) 150ACTF(perm)
151{ 151{
152 return !((isdigit(ap->perm_char) && (statbuf->st_mode & 07777) == ap->perm_mask) 152 return !((isdigit(ap->perm_char) && (statbuf->st_mode & 07777) == ap->perm_mask)
153 || (ap->perm_char == '-' && (statbuf->st_mode & ap->perm_mask) == ap->perm_mask) 153 || (ap->perm_char == '-' && (statbuf->st_mode & ap->perm_mask) == ap->perm_mask)
@@ -155,7 +155,7 @@ SFUNC(perm)
155} 155}
156#endif 156#endif
157#if ENABLE_FEATURE_FIND_MTIME 157#if ENABLE_FEATURE_FIND_MTIME
158SFUNC(mtime) 158ACTF(mtime)
159{ 159{
160 time_t file_age = time(NULL) - statbuf->st_mtime; 160 time_t file_age = time(NULL) - statbuf->st_mtime;
161 time_t mtime_secs = ap->mtime_days * 24 * 60 * 60; 161 time_t mtime_secs = ap->mtime_days * 24 * 60 * 60;
@@ -166,7 +166,7 @@ SFUNC(mtime)
166} 166}
167#endif 167#endif
168#if ENABLE_FEATURE_FIND_MMIN 168#if ENABLE_FEATURE_FIND_MMIN
169SFUNC(mmin) 169ACTF(mmin)
170{ 170{
171 time_t file_age = time(NULL) - statbuf->st_mtime; 171 time_t file_age = time(NULL) - statbuf->st_mtime;
172 time_t mmin_secs = ap->mmin_mins * 60; 172 time_t mmin_secs = ap->mmin_mins * 60;
@@ -177,19 +177,19 @@ SFUNC(mmin)
177} 177}
178#endif 178#endif
179#if ENABLE_FEATURE_FIND_NEWER 179#if ENABLE_FEATURE_FIND_NEWER
180SFUNC(newer) 180ACTF(newer)
181{ 181{
182 return (ap->newer_mtime >= statbuf->st_mtime); 182 return (ap->newer_mtime >= statbuf->st_mtime);
183} 183}
184#endif 184#endif
185#if ENABLE_FEATURE_FIND_INUM 185#if ENABLE_FEATURE_FIND_INUM
186SFUNC(inum) 186ACTF(inum)
187{ 187{
188 return (statbuf->st_ino != ap->inode_num); 188 return (statbuf->st_ino != ap->inode_num);
189} 189}
190#endif 190#endif
191#if ENABLE_FEATURE_FIND_EXEC 191#if ENABLE_FEATURE_FIND_EXEC
192SFUNC(exec) 192ACTF(exec)
193{ 193{
194 int i, rc; 194 int i, rc;
195 char *argv[ap->exec_argc+1]; 195 char *argv[ap->exec_argc+1];
@@ -207,21 +207,21 @@ SFUNC(exec)
207#endif 207#endif
208 208
209#if ENABLE_FEATURE_FIND_PRINT0 209#if ENABLE_FEATURE_FIND_PRINT0
210SFUNC(print0) 210ACTF(print0)
211{ 211{
212 printf("%s%c", fileName, '\0'); 212 printf("%s%c", fileName, '\0');
213 return TRUE; 213 return TRUE;
214} 214}
215#endif 215#endif
216 216
217SFUNC(print) 217ACTF(print)
218{ 218{
219 puts(fileName); 219 puts(fileName);
220 return TRUE; 220 return TRUE;
221} 221}
222 222
223#if ENABLE_DESKTOP 223#if ENABLE_DESKTOP
224SFUNC(paren) 224ACTF(paren)
225{ 225{
226 return exec_actions(ap->subexpr, fileName, statbuf); 226 return exec_actions(ap->subexpr, fileName, statbuf);
227} 227}
@@ -231,7 +231,7 @@ SFUNC(paren)
231 * Example: 231 * Example:
232 * find dir -name 'asm-*' -prune -o -name '*.[chS]' -print 232 * find dir -name 'asm-*' -prune -o -name '*.[chS]' -print
233 */ 233 */
234SFUNC(prune) 234ACTF(prune)
235{ 235{
236 return SKIP; 236 return SKIP;
237} 237}
@@ -501,6 +501,7 @@ action*** parse_params(char **argv)
501int find_main(int argc, char **argv) 501int find_main(int argc, char **argv)
502{ 502{
503 int dereference = FALSE; 503 int dereference = FALSE;
504 char *arg;
504 char **argp; 505 char **argp;
505 int i, firstopt, status = EXIT_SUCCESS; 506 int i, firstopt, status = EXIT_SUCCESS;
506 507
@@ -524,10 +525,9 @@ int find_main(int argc, char **argv)
524// We implement: -follow, -xdev 525// We implement: -follow, -xdev
525 526
526 /* Process options, and replace then with -a */ 527 /* Process options, and replace then with -a */
527 /* (that will be ignored by recursive parser later) */ 528 /* (-a will be ignored by recursive parser later) */
528 argp = &argv[firstopt]; 529 argp = &argv[firstopt];
529 while (*argp) { 530 while ((arg = argp[0])) {
530 char *arg = argp[0];
531 if (strcmp(arg, "-follow") == 0) { 531 if (strcmp(arg, "-follow") == 0) {
532 dereference = TRUE; 532 dereference = TRUE;
533 argp[0] = "-a"; 533 argp[0] = "-a";