diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-11-01 10:25:35 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-11-01 10:25:35 +0000 |
commit | 92258541449581302e180d05e827e27d35030a18 (patch) | |
tree | 99c5ad443f69860833c8ef37e142fddfedb90872 /findutils/find.c | |
parent | 048c93cc5593d53d6243c3e15dc8a5b0072a6083 (diff) | |
download | busybox-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.c | 58 |
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 *); | |||
56 | typedef struct { | 56 | typedef 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;) |
63 | USE_FEATURE_FIND_PRINT0(SACT(print0)) | 63 | USE_FEATURE_FIND_PRINT0(ACTS(print0)) |
64 | USE_FEATURE_FIND_TYPE( SACT(type, int type_mask;)) | 64 | USE_FEATURE_FIND_TYPE( ACTS(type, int type_mask;)) |
65 | USE_FEATURE_FIND_PERM( SACT(perm, char perm_char; int perm_mask;)) | 65 | USE_FEATURE_FIND_PERM( ACTS(perm, char perm_char; int perm_mask;)) |
66 | USE_FEATURE_FIND_MTIME( SACT(mtime, char mtime_char; int mtime_days;)) | 66 | USE_FEATURE_FIND_MTIME( ACTS(mtime, char mtime_char; int mtime_days;)) |
67 | USE_FEATURE_FIND_MMIN( SACT(mmin, char mmin_char; int mmin_mins;)) | 67 | USE_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; int mmin_mins;)) |
68 | USE_FEATURE_FIND_NEWER( SACT(newer, time_t newer_mtime;)) | 68 | USE_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;)) |
69 | USE_FEATURE_FIND_INUM( SACT(inum, ino_t inode_num;)) | 69 | USE_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;)) |
70 | USE_FEATURE_FIND_EXEC( SACT(exec, char **exec_argv; int *subst_count; int exec_argc;)) | 70 | USE_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; int *subst_count; int exec_argc;)) |
71 | USE_DESKTOP( SACT(paren, action ***subexpr;)) | 71 | USE_DESKTOP( ACTS(paren, action ***subexpr;)) |
72 | USE_DESKTOP( SACT(prune)) | 72 | USE_DESKTOP( ACTS(prune)) |
73 | 73 | ||
74 | static action ***actions; | 74 | static action ***actions; |
75 | static int need_print = 1; | 75 | static 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 | ||
134 | SFUNC(name) | 134 | ACTF(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 |
144 | SFUNC(type) | 144 | ACTF(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 |
150 | SFUNC(perm) | 150 | ACTF(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 |
158 | SFUNC(mtime) | 158 | ACTF(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 |
169 | SFUNC(mmin) | 169 | ACTF(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 |
180 | SFUNC(newer) | 180 | ACTF(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 |
186 | SFUNC(inum) | 186 | ACTF(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 |
192 | SFUNC(exec) | 192 | ACTF(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 |
210 | SFUNC(print0) | 210 | ACTF(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 | ||
217 | SFUNC(print) | 217 | ACTF(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 |
224 | SFUNC(paren) | 224 | ACTF(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 | */ |
234 | SFUNC(prune) | 234 | ACTF(prune) |
235 | { | 235 | { |
236 | return SKIP; | 236 | return SKIP; |
237 | } | 237 | } |
@@ -501,6 +501,7 @@ action*** parse_params(char **argv) | |||
501 | int find_main(int argc, char **argv) | 501 | int 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"; |