Fix recurse() prototype and convert char to int flags

This commit is contained in:
sin 2015-02-16 16:23:12 +00:00
parent d8fa891008
commit 8f068589fb
11 changed files with 15 additions and 15 deletions

View File

@ -10,13 +10,13 @@
static int gid; static int gid;
static int status; static int status;
static int rflag; static int rflag;
static char fflag = 'P'; static int fflag = 'P';
static struct stat st; static struct stat st;
static char *chown_f_name = "chown"; static char *chown_f_name = "chown";
static int (*chown_f)(const char *, uid_t, gid_t) = chown; static int (*chown_f)(const char *, uid_t, gid_t) = chown;
static void static void
chgrp(const char *path, char fflag) chgrp(const char *path, int fflag)
{ {
if (chown_f(path, st.st_uid, gid) < 0) { if (chown_f(path, st.st_uid, gid) < 0) {
weprintf("%s %s:", chown_f_name, path); weprintf("%s %s:", chown_f_name, path);

View File

@ -9,7 +9,7 @@ static mode_t mask = 0;
static int ret = 0; static int ret = 0;
void void
chmodr(const char *path, char fflag) chmodr(const char *path, int fflag)
{ {
struct stat st; struct stat st;
mode_t m; mode_t m;

2
du.c
View File

@ -21,7 +21,7 @@ static int dflag = 0;
static int sflag = 0; static int sflag = 0;
static int kflag = 0; static int kflag = 0;
static int hflag = 0; static int hflag = 0;
static char HLflag = 'P'; static int HLflag = 'P';
static char * static char *
xrealpath(const char *pathname, char *resolved) xrealpath(const char *pathname, char *resolved)

4
fs.h
View File

@ -4,7 +4,7 @@ extern int cp_fflag;
extern int cp_pflag; extern int cp_pflag;
extern int cp_rflag; extern int cp_rflag;
extern int cp_vflag; extern int cp_vflag;
extern char cp_HLPflag; extern int cp_HLPflag;
extern int cp_status; extern int cp_status;
extern int rm_fflag; extern int rm_fflag;
@ -12,4 +12,4 @@ extern int rm_rflag;
extern int rm_status; extern int rm_status;
int cp(const char *, const char *, char); int cp(const char *, const char *, char);
void rm(const char *); void rm(const char *, int);

View File

@ -21,7 +21,7 @@ int cp_pflag = 0;
int cp_rflag = 0; int cp_rflag = 0;
int cp_vflag = 0; int cp_vflag = 0;
int cp_status = 0; int cp_status = 0;
char cp_HLPflag = 'L'; int cp_HLPflag = 'L';
int int
cp(const char *s1, const char *s2, char ff) cp(const char *s1, const char *s2, char ff)

View File

@ -11,7 +11,7 @@
#include "../util.h" #include "../util.h"
void void
recurse(const char *path, void (*fn)(const char *, char), int follow) recurse(const char *path, void (*fn)(const char *, int), int follow)
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
struct dirent *d; struct dirent *d;

View File

@ -9,7 +9,7 @@ int rm_rflag = 0;
int rm_status = 0; int rm_status = 0;
void void
rm(const char *path) rm(const char *path, int unused)
{ {
if (rm_rflag) if (rm_rflag)
recurse(path, rm, 'P'); recurse(path, rm, 'P');

2
mv.c
View File

@ -18,7 +18,7 @@ mv(const char *s1, const char *s2, char ff)
cp_aflag = cp_rflag = cp_pflag = 1; cp_aflag = cp_rflag = cp_pflag = 1;
rm_rflag = 1; rm_rflag = 1;
cp(s1, s2, ff); cp(s1, s2, ff);
rm(s1); rm(s1, 0);
return (mv_status = cp_status || rm_status); return (mv_status = cp_status || rm_status);
} }
mv_status = 1; mv_status = 1;

2
rm.c
View File

@ -34,7 +34,7 @@ main(int argc, char *argv[])
} }
for (; argc > 0; argc--, argv++) for (; argc > 0; argc--, argv++)
rm(argv[0]); rm(argv[0], 0);
return rm_status; return rm_status;
} }

6
tar.c
View File

@ -44,7 +44,7 @@ static void putoctal(char *, unsigned, int);
static int archive(const char *); static int archive(const char *);
static int unarchive(char *, int, char[Blksiz]); static int unarchive(char *, int, char[Blksiz]);
static int print(char *, int , char[Blksiz]); static int print(char *, int , char[Blksiz]);
static void c(const char *, char); static void c(const char *, int);
static void xt(int (*)(char*, int, char[Blksiz])); static void xt(int (*)(char*, int, char[Blksiz]));
static FILE *tarfile; static FILE *tarfile;
@ -52,7 +52,7 @@ static ino_t tarinode;
static dev_t tardev; static dev_t tardev;
static int mflag; static int mflag;
static char fflag = 'P'; static int fflag = 'P';
static char filtermode; static char filtermode;
static FILE * static FILE *
@ -246,7 +246,7 @@ print(char * fname, int l, char b[Blksiz])
} }
static void static void
c(const char * path, char fflag) c(const char * path, int fflag)
{ {
archive(path); archive(path);
recurse(path, c, fflag); recurse(path, c, fflag);

2
util.h
View File

@ -60,7 +60,7 @@ mode_t getumask(void);
char *humansize(double); char *humansize(double);
mode_t parsemode(const char *, mode_t, mode_t); mode_t parsemode(const char *, mode_t, mode_t);
void putword(const char *); void putword(const char *);
void recurse(const char *, void (*)(const char *, char), int); void recurse(const char *, void (*)(const char *, int), int);
#undef strtonum #undef strtonum
long long strtonum(const char *, long long, long long, const char **); long long strtonum(const char *, long long, long long, const char **);
long long enstrtonum(int, const char *, long long, long long); long long enstrtonum(int, const char *, long long, long long);