diff options
author | joe <joe@FreeBSD.org> | 2000-06-17 14:19:33 +0000 |
---|---|---|
committer | joe <joe@FreeBSD.org> | 2000-06-17 14:19:33 +0000 |
commit | 8de98cc2fa7b119cc8deb33c61c9496d25825b49 (patch) | |
tree | 33363d4028bb162e624a3a2c5257ab020378f6e0 | |
parent | 3e8b2c512359fd536c5f66fbd9e265064d461886 (diff) | |
download | FreeBSD-src-8de98cc2fa7b119cc8deb33c61c9496d25825b49.zip FreeBSD-src-8de98cc2fa7b119cc8deb33c61c9496d25825b49.tar.gz |
Switch over to using the new fflagstostr and strtofflags library calls.
-rw-r--r-- | bin/chflags/Makefile | 3 | ||||
-rw-r--r-- | bin/chflags/chflags.c | 4 | ||||
-rw-r--r-- | bin/ls/Makefile | 3 | ||||
-rw-r--r-- | bin/ls/extern.h | 1 | ||||
-rw-r--r-- | bin/ls/ls.c | 11 | ||||
-rw-r--r-- | bin/rm/Makefile | 3 | ||||
-rw-r--r-- | bin/rm/rm.c | 14 | ||||
-rw-r--r-- | libexec/ftpd/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/chflags/Makefile | 3 | ||||
-rw-r--r-- | usr.bin/chflags/chflags.c | 4 | ||||
-rw-r--r-- | usr.bin/find/Makefile | 3 | ||||
-rw-r--r-- | usr.bin/find/function.c | 4 | ||||
-rw-r--r-- | usr.bin/xinstall/Makefile | 3 | ||||
-rw-r--r-- | usr.bin/xinstall/xinstall.c | 2 | ||||
-rw-r--r-- | usr.sbin/mtree/Makefile | 5 | ||||
-rw-r--r-- | usr.sbin/mtree/compare.c | 13 | ||||
-rw-r--r-- | usr.sbin/mtree/create.c | 18 | ||||
-rw-r--r-- | usr.sbin/mtree/extern.h | 3 | ||||
-rw-r--r-- | usr.sbin/mtree/misc.c | 18 | ||||
-rw-r--r-- | usr.sbin/mtree/spec.c | 2 |
20 files changed, 69 insertions, 52 deletions
diff --git a/bin/chflags/Makefile b/bin/chflags/Makefile index b545bfa..ebc9c0f 100644 --- a/bin/chflags/Makefile +++ b/bin/chflags/Makefile @@ -5,7 +5,6 @@ NOSHARED?=yes PROG= chflags CFLAGS+=-Wall -.PATH: ${.CURDIR}/../../lib/libc/gen -SRCS= chflags.c setflags.c +SRCS= chflags.c .include <bsd.prog.mk> diff --git a/bin/chflags/chflags.c b/bin/chflags/chflags.c index c19c7e4..3ff36ef 100644 --- a/bin/chflags/chflags.c +++ b/bin/chflags/chflags.c @@ -56,8 +56,6 @@ static const char rcsid[] = #include <string.h> #include <unistd.h> -int setflags __P((char **, u_long *, u_long *)); - void usage __P((void)); int @@ -123,7 +121,7 @@ main(argc, argv) set = val; oct = 1; } else { - if (setflags(&flags, &set, &clear)) + if (strtofflags(&flags, &set, &clear)) errx(1, "invalid flag: %s", flags); clear = ~clear; oct = 0; diff --git a/bin/ls/Makefile b/bin/ls/Makefile index 86b91b4..96dffe1 100644 --- a/bin/ls/Makefile +++ b/bin/ls/Makefile @@ -3,8 +3,7 @@ PROG= ls -SRCS= cmp.c setflags.c ls.c print.c util.c -.PATH: ${.CURDIR}/../../lib/libc/gen +SRCS= cmp.c ls.c print.c util.c .if !defined(RELEASE_BUILD_FIXIT) CFLAGS+= -DCOLORLS diff --git a/bin/ls/extern.h b/bin/ls/extern.h index 9ba00ee..4b27be6 100644 --- a/bin/ls/extern.h +++ b/bin/ls/extern.h @@ -43,7 +43,6 @@ int revnamecmp __P((const FTSENT *, const FTSENT *)); int statcmp __P((const FTSENT *, const FTSENT *)); int revstatcmp __P((const FTSENT *, const FTSENT *)); -char *flags_to_string __P((u_long, char *)); void prcopy __P((char *, char *, int)); void printcol __P((DISPLAY *)); void printlong __P((DISPLAY *)); diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 0bf1666..69b8d77 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -78,8 +78,6 @@ static const char rcsid[] = */ #define STRBUF_SIZEOF(t) (1 + CHAR_BIT * sizeof(t) / 3 + 1) -char *getflags __P((u_long, char *)); - static void display __P((FTSENT *, FTSENT *)); static u_quad_t makenines __P((u_long)); static int mastercmp __P((const FTSENT **, const FTSENT **)); @@ -605,7 +603,13 @@ display(p, list) if ((glen = strlen(group)) > maxgroup) maxgroup = glen; if (f_flags) { - flags = getflags(sp->st_flags, "-"); + flags = fflagstostr(sp->st_flags); + if (flags != NULL && *flags == '\0') { + free(flags); + flags = strdup("-"); + } + if (flags == NULL) + err(1, NULL); if ((flen = strlen(flags)) > maxflags) maxflags = flen; } else @@ -627,6 +631,7 @@ display(p, list) if (f_flags) { np->flags = &np->data[ulen + glen + 2]; (void)strcpy(np->flags, flags); + free(flags); } cur->fts_pointer = np; } diff --git a/bin/rm/Makefile b/bin/rm/Makefile index 2bbcdf8..7b85cdf 100644 --- a/bin/rm/Makefile +++ b/bin/rm/Makefile @@ -2,10 +2,9 @@ # $FreeBSD$ PROG= rm -SRCS= rm.c setflags.c +SRCS= rm.c LINKS= ${BINDIR}/rm ${BINDIR}/unlink MLINKS= rm.1 unlink.1 -.PATH: ${.CURDIR}/../../lib/libc/gen .include <bsd.prog.mk> diff --git a/bin/rm/rm.c b/bin/rm/rm.c index c977373..7d01346 100644 --- a/bin/rm/rm.c +++ b/bin/rm/rm.c @@ -60,8 +60,6 @@ static const char rcsid[] = #include <sysexits.h> #include <unistd.h> -char *getflags __P((u_long, char *)); - int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok; uid_t uid; @@ -423,7 +421,7 @@ check(path, name, sp) struct stat *sp; { int ch, first; - char modep[15], flagsp[128]; + char modep[15], *flagsp; /* Check -i first. */ if (iflag) @@ -441,15 +439,15 @@ check(path, name, sp) (!(sp->st_flags & (UF_APPEND|UF_IMMUTABLE)) || !uid))) return (1); strmode(sp->st_mode, modep); - strcpy(flagsp, getflags(sp->st_flags, NULL)); - if (*flagsp) - strcat(flagsp, " "); - (void)fprintf(stderr, "override %s%s%s/%s %sfor %s? ", + if ((flagsp = fflagstostr(sp->st_flags)) == NULL) + err(1, NULL); + (void)fprintf(stderr, "override %s%s%s/%s %s%sfor %s? ", modep + 1, modep[9] == ' ' ? "" : " ", user_from_uid(sp->st_uid, 0), group_from_gid(sp->st_gid, 0), - *flagsp ? flagsp : "", + *flagsp ? flagsp : "", *flagsp ? " " : "", path); + free(flagsp); } (void)fflush(stderr); diff --git a/libexec/ftpd/Makefile b/libexec/ftpd/Makefile index dd0dac0..75e9206 100644 --- a/libexec/ftpd/Makefile +++ b/libexec/ftpd/Makefile @@ -14,8 +14,8 @@ LDADD= -lskey -lmd -lcrypt -lutil DPADD= ${LIBSKEY} ${LIBMD} ${LIBCRYPT} ${LIBUTIL} LSDIR= ../../bin/ls -.PATH: ${.CURDIR}/${LSDIR} ${.CURDIR}/../../lib/libc/gen -SRCS+= ls.c cmp.c print.c setflags.c util.c +.PATH: ${.CURDIR}/${LSDIR} +SRCS+= ls.c cmp.c print.c util.c CFLAGS+=-Dmain=ls_main -I${.CURDIR}/${LSDIR} .if defined(NOPAM) diff --git a/usr.bin/chflags/Makefile b/usr.bin/chflags/Makefile index b545bfa..ebc9c0f 100644 --- a/usr.bin/chflags/Makefile +++ b/usr.bin/chflags/Makefile @@ -5,7 +5,6 @@ NOSHARED?=yes PROG= chflags CFLAGS+=-Wall -.PATH: ${.CURDIR}/../../lib/libc/gen -SRCS= chflags.c setflags.c +SRCS= chflags.c .include <bsd.prog.mk> diff --git a/usr.bin/chflags/chflags.c b/usr.bin/chflags/chflags.c index c19c7e4..3ff36ef 100644 --- a/usr.bin/chflags/chflags.c +++ b/usr.bin/chflags/chflags.c @@ -56,8 +56,6 @@ static const char rcsid[] = #include <string.h> #include <unistd.h> -int setflags __P((char **, u_long *, u_long *)); - void usage __P((void)); int @@ -123,7 +121,7 @@ main(argc, argv) set = val; oct = 1; } else { - if (setflags(&flags, &set, &clear)) + if (strtofflags(&flags, &set, &clear)) errx(1, "invalid flag: %s", flags); clear = ~clear; oct = 0; diff --git a/usr.bin/find/Makefile b/usr.bin/find/Makefile index 6ca99d0..9691657 100644 --- a/usr.bin/find/Makefile +++ b/usr.bin/find/Makefile @@ -3,7 +3,6 @@ CFLAGS+= -Wall PROG= find -SRCS= find.c function.c ls.c main.c misc.c operator.c option.c setflags.c -.PATH: ${.CURDIR}/../../lib/libc/gen +SRCS= find.c function.c ls.c main.c misc.c operator.c option.c .include <bsd.prog.mk> diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index d833a91..1534ee2 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -75,8 +75,6 @@ static const char rcsid[] = } \ } -u_long setflags __P((char **, u_long *, u_long *)); - static PLAN *palloc __P((enum ntype, int (*) __P((PLAN *, FTSENT *)))); /* @@ -1060,7 +1058,7 @@ c_flags(flags_str) new->flags = F_ATLEAST; flags_str++; } - if (setflags(&flags_str, &flags, ¬flags) == 1) + if (strtofflags(&flags_str, &flags, ¬flags) == 1) errx(1, "-flags: %s: illegal flags string", flags_str); new->fl_flags = flags; diff --git a/usr.bin/xinstall/Makefile b/usr.bin/xinstall/Makefile index c8bd6e3..f41f80e 100644 --- a/usr.bin/xinstall/Makefile +++ b/usr.bin/xinstall/Makefile @@ -2,8 +2,7 @@ # $FreeBSD$ PROG= xinstall -SRCS= setflags.c xinstall.c -.PATH: ${.CURDIR}/../../lib/libc/gen +SRCS= xinstall.c MAN1= install.1 install: maninstall diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 1db50f1..87c0b1c 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -151,7 +151,7 @@ main(argc, argv) break; case 'f': flags = optarg; - if (setflags(&flags, &fset, NULL)) + if (strtofflags(&flags, &fset, NULL)) errx(EX_USAGE, "%s: invalid flag", flags); iflags |= SETFLAGS; break; diff --git a/usr.sbin/mtree/Makefile b/usr.sbin/mtree/Makefile index f6b46ef..8213854 100644 --- a/usr.sbin/mtree/Makefile +++ b/usr.sbin/mtree/Makefile @@ -2,10 +2,9 @@ # $FreeBSD$ PROG= mtree -SRCS= compare.c crc.c create.c excludes.c misc.c mtree.c spec.c verify.c \ - setflags.c +SRCS= compare.c crc.c create.c excludes.c misc.c mtree.c spec.c verify.c MAN8= mtree.8 -.PATH: ${.CURDIR}/../../usr.bin/cksum ${.CURDIR}/../../lib/libc/gen +.PATH: ${.CURDIR}/../../usr.bin/cksum .if !defined(WORLD) DPADD+= ${LIBMD} diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c index 007edb7..4168121 100644 --- a/usr.sbin/mtree/compare.c +++ b/usr.sbin/mtree/compare.c @@ -88,6 +88,7 @@ compare(name, s, p) u_long len, val; int fd, label; char *cp, *tab = ""; + char *fflags; label = 0; switch(s->type) { @@ -224,10 +225,14 @@ typeerr: LABEL; */ if ((s->flags & F_FLAGS) && s->st_flags != p->fts_statp->st_flags) { LABEL; - (void)printf("%sflags (\"%s\" is not ", tab, - getflags(s->st_flags, "none")); - (void)printf("\"%s\"", - getflags(p->fts_statp->st_flags, "none")); + fflags = flags_to_string(s->st_flags); + (void)printf("%sflags (\"%s\" is not ", tab, fflags); + free(fflags); + + fflags = flags_to_string(p->fts_statp->st_flags); + (void)printf("\"%s\"", fflags); + free(fflags); + if (uflag) if (chflags(p->fts_accpath, s->st_flags)) (void)printf(", not modified: %s)\n", diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c index bc1ae0d..6a2d005 100644 --- a/usr.sbin/mtree/create.c +++ b/usr.sbin/mtree/create.c @@ -153,6 +153,7 @@ statf(indent, p) struct passwd *pw; u_long len, val; int fd, offset; + char *fflags; char *escaped_name; escaped_name = calloc(1, p->fts_namelen * 4 + 1); @@ -256,9 +257,11 @@ statf(indent, p) if (keys & F_SLINK && (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) output(indent, &offset, "link=%s", rlink(p->fts_accpath)); - if (keys & F_FLAGS && p->fts_statp->st_flags != flags) - output(indent, &offset, "flags=%s", - getflags(p->fts_statp->st_flags, "none")); + if (keys & F_FLAGS && p->fts_statp->st_flags != flags) { + fflags = flags_to_string(p->fts_statp->st_flags); + output(indent, &offset, "flags=%s", fflags); + free(fflags); + } (void)putchar('\n'); } @@ -290,6 +293,7 @@ statd(t, parent, puid, pgid, pmode, pflags) u_long saveflags = 0; u_short maxgid, maxuid, maxmode, maxflags; u_short g[MAXGID], u[MAXUID], m[MAXMODE], f[MAXFLAGS]; + char *fflags; static int first = 1; if ((p = fts_children(t, 0)) == NULL) { @@ -374,9 +378,11 @@ statd(t, parent, puid, pgid, pmode, pflags) (void)printf(" mode=%#o", savemode); if (keys & F_NLINK) (void)printf(" nlink=1"); - if (keys & F_FLAGS && saveflags) - (void)printf(" flags=%s", - getflags(saveflags, "none")); + if (keys & F_FLAGS && saveflags) { + fflags = flags_to_string(saveflags); + (void)printf(" flags=%s", fflags); + free(fflags); + } (void)printf("\n"); *puid = saveuid; *pgid = savegid; diff --git a/usr.sbin/mtree/extern.h b/usr.sbin/mtree/extern.h index c57a338..54dafdf 100644 --- a/usr.sbin/mtree/extern.h +++ b/usr.sbin/mtree/extern.h @@ -37,8 +37,7 @@ int compare __P((char *, NODE *, FTSENT *)); int crc __P((int, u_long *, u_long *)); void cwalk __P((void)); -char *flags_to_string __P((u_long, char *)); -int string_to_flags __P((char **, u_long *, u_long *)); +char *flags_to_string __P((u_long)); char *inotype __P((u_int)); u_int parsekey __P((char *, int *)); diff --git a/usr.sbin/mtree/misc.c b/usr.sbin/mtree/misc.c index ea413dd..7721ff4 100644 --- a/usr.sbin/mtree/misc.c +++ b/usr.sbin/mtree/misc.c @@ -44,6 +44,7 @@ static const char rcsid[] = #include <err.h> #include <fts.h> #include <stdio.h> +#include <unistd.h> #include "mtree.h" #include "extern.h" @@ -109,3 +110,20 @@ keycompare(a, b) { return (strcmp(((KEY *)a)->name, ((KEY *)b)->name)); } + +char * +flags_to_string(fflags) + u_long fflags; +{ + char *string; + + string = fflagstostr(fflags); + if (string != NULL && *string == '\0') { + free(string); + string = strdup("none"); + } + if (string == NULL) + err(1, NULL); + + return string; +} diff --git a/usr.sbin/mtree/spec.c b/usr.sbin/mtree/spec.c index 10c3704..4cbf80b 100644 --- a/usr.sbin/mtree/spec.c +++ b/usr.sbin/mtree/spec.c @@ -214,7 +214,7 @@ set(t, ip) case F_FLAGS: if (strcmp("none", val) == 0) ip->st_flags = 0; - else if (setflags(&val, &ip->st_flags, NULL) != 0) + else if (strtofflags(&val, &ip->st_flags, NULL) != 0) errx(1, "line %d: invalid flag %s",lineno, val); break; case F_GID: |