Rev 3364 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3364 | Rev 3403 | ||
---|---|---|---|
1 | #ifndef RM_H |
1 | #ifndef RM_H |
2 | #define RM_H |
2 | #define RM_H |
3 | 3 | ||
4 | /* Return values for rm_scope() */ |
4 | /* Return values for rm_scope() */ |
5 | #define RM_BOGUS 0 |
5 | #define RM_BOGUS 0 |
6 | #define RM_FILE 1 |
6 | #define RM_FILE 1 |
7 | #define RM_DIR 2 |
7 | #define RM_DIR 2 |
8 | 8 | ||
9 | /* Flags for rm_update() */ |
9 | /* Flags for rm_update() */ |
10 | #define _RM_ENTRY 0 |
10 | #define _RM_ENTRY 0 |
11 | #define _RM_ADVANCE 1 |
11 | #define _RM_ADVANCE 1 |
12 | #define _RM_REWIND 2 |
12 | #define _RM_REWIND 2 |
13 | #define _RM_EXIT 3 |
13 | #define _RM_EXIT 3 |
14 | 14 | ||
15 | /* A simple job structure */ |
15 | /* A simple job structure */ |
16 | typedef struct { |
16 | typedef struct { |
17 | /* Options set at run time */ |
17 | /* Options set at run time */ |
18 | unsigned int force; /* -f option */ |
18 | unsigned int force; /* -f option */ |
19 | unsigned int recursive; /* -r option */ |
19 | unsigned int recursive; /* -r option */ |
20 | unsigned int safe; /* -s option */ |
20 | unsigned int safe; /* -s option */ |
21 | 21 | ||
22 | /* Keeps track of the job in progress */ |
22 | /* Keeps track of the job in progress */ |
23 | int advance; /* How far deep we've gone since entering */ |
23 | int advance; /* How far deep we've gone since entering */ |
24 | DIR *entry; /* Entry point to the tree being removed */ |
24 | DIR *entry; /* Entry point to the tree being removed */ |
25 | char *owd; /* Where we were when we invoked rm */ |
25 | char *owd; /* Where we were when we invoked rm */ |
26 | char *cwd; /* Current directory being transversed */ |
26 | char *cwd; /* Current directory being transversed */ |
27 | char *nwd; /* Next directory to be transversed */ |
27 | char *nwd; /* Next directory to be transversed */ |
28 | 28 | ||
29 | /* Counters */ |
29 | /* Counters */ |
30 | int f_removed; /* Number of files unlinked */ |
30 | int f_removed; /* Number of files unlinked */ |
31 | int d_removed; /* Number of directories unlinked */ |
31 | int d_removed; /* Number of directories unlinked */ |
32 | } rm_job_t; |
32 | } rm_job_t; |
33 | 33 | ||
34 | 34 | ||
35 | /* Prototypes for the rm command, excluding entry points */ |
35 | /* Prototypes for the rm command, excluding entry points */ |
36 | static unsigned int rm_start(rm_job_t *); |
36 | static unsigned int rm_start(rm_job_t *); |
37 | static void rm_end(rm_job_t *rm); |
37 | static void rm_end(rm_job_t *rm); |
38 | static unsigned int rm_recursive(const char *); |
38 | static unsigned int rm_recursive(const char *); |
39 | static unsigned int rm_single(const char *); |
39 | static unsigned int rm_single(const char *); |
40 | static unsigned int rm_scope(const char *); |
40 | static unsigned int rm_scope(const char *); |
41 | 41 | ||
42 | #endif /* RM_H */ |
42 | #endif /* RM_H */ |
43 | 43 | ||
44 | 44 |