svn commit: r240795 - projects/mtree/contrib/mtree
Brooks Davis
brooks at FreeBSD.org
Fri Sep 21 21:52:15 UTC 2012
Author: brooks
Date: Fri Sep 21 21:52:14 2012
New Revision: 240795
URL: http://svn.freebsd.org/changeset/base/240795
Log:
Abstract the naming of message digest keys so we can output foodigest= on
FreeBSD and foo= elsewhere when FreeBSD's mtree already supports only
the foodigest= form. SHA384KEY and SHA512KEY definitions are for
symmetry only and retain the NetBSD default in all cases.
Modified:
projects/mtree/contrib/mtree/compare.c
projects/mtree/contrib/mtree/create.c
projects/mtree/contrib/mtree/mtree.h
projects/mtree/contrib/mtree/spec.c
projects/mtree/contrib/mtree/specspec.c
Modified: projects/mtree/contrib/mtree/compare.c
==============================================================================
--- projects/mtree/contrib/mtree/compare.c Fri Sep 21 21:31:51 2012 (r240794)
+++ projects/mtree/contrib/mtree/compare.c Fri Sep 21 21:52:14 2012 (r240795)
@@ -396,14 +396,14 @@ typeerr: LABEL;
if (s->flags & F_MD5) {
if ((digestbuf = MD5File(p->fts_accpath, NULL)) == NULL) {
LABEL;
- printf("%smd5: %s: %s\n",
- tab, p->fts_accpath, strerror(errno));
+ printf("%s%s: %s: %s\n",
+ tab, MD5KEY, p->fts_accpath, strerror(errno));
tab = "\t";
} else {
if (strcmp(s->md5digest, digestbuf)) {
LABEL;
- printf("%smd5 (0x%s, 0x%s)\n",
- tab, s->md5digest, digestbuf);
+ printf("%s%s (0x%s, 0x%s)\n",
+ tab, MD5KEY, s->md5digest, digestbuf);
}
tab = "\t";
free(digestbuf);
@@ -414,23 +414,14 @@ typeerr: LABEL;
if (s->flags & F_RMD160) {
if ((digestbuf = RMD160File(p->fts_accpath, NULL)) == NULL) {
LABEL;
-#ifndef __FreeBSD__
- printf("%srmd160: %s: %s\n",
-#else
- printf("%sripemd160digest: %s: %s\n",
-#endif
-
- tab, p->fts_accpath, strerror(errno));
+ printf("%s%s: %s: %s\n",
+ tab, RMD160KEY, p->fts_accpath, strerror(errno));
tab = "\t";
} else {
if (strcmp(s->rmd160digest, digestbuf)) {
LABEL;
-#ifndef __FreeBSD__
- printf("%srmd160 (0x%s, 0x%s)\n",
-#else
- printf("%sripemd160digest (0x%s, 0x%s)\n",
-#endif
- tab, s->rmd160digest, digestbuf);
+ printf("%s%s (0x%s, 0x%s)\n",
+ tab, RMD160KEY, s->rmd160digest, digestbuf);
}
tab = "\t";
free(digestbuf);
@@ -441,14 +432,14 @@ typeerr: LABEL;
if (s->flags & F_SHA1) {
if ((digestbuf = SHA1File(p->fts_accpath, NULL)) == NULL) {
LABEL;
- printf("%ssha1: %s: %s\n",
- tab, p->fts_accpath, strerror(errno));
+ printf("%s%s: %s: %s\n",
+ tab, SHA1KEY, p->fts_accpath, strerror(errno));
tab = "\t";
} else {
if (strcmp(s->sha1digest, digestbuf)) {
LABEL;
- printf("%ssha1 (0x%s, 0x%s)\n",
- tab, s->sha1digest, digestbuf);
+ printf("%s%s (0x%s, 0x%s)\n",
+ tab, SHA1KEY, s->sha1digest, digestbuf);
}
tab = "\t";
free(digestbuf);
@@ -459,14 +450,14 @@ typeerr: LABEL;
if (s->flags & F_SHA256) {
if ((digestbuf = SHA256_File(p->fts_accpath, NULL)) == NULL) {
LABEL;
- printf("%ssha256: %s: %s\n",
- tab, p->fts_accpath, strerror(errno));
+ printf("%s%s: %s: %s\n",
+ tab, SHA256KEY, p->fts_accpath, strerror(errno));
tab = "\t";
} else {
if (strcmp(s->sha256digest, digestbuf)) {
LABEL;
- printf("%ssha256 (0x%s, 0x%s)\n",
- tab, s->sha256digest, digestbuf);
+ printf("%s%s (0x%s, 0x%s)\n",
+ tab, SHA256KEY, s->sha256digest, digestbuf);
}
tab = "\t";
free(digestbuf);
@@ -476,14 +467,14 @@ typeerr: LABEL;
if (s->flags & F_SHA384) {
if ((digestbuf = SHA384_File(p->fts_accpath, NULL)) == NULL) {
LABEL;
- printf("%ssha384: %s: %s\n",
- tab, p->fts_accpath, strerror(errno));
+ printf("%s%s: %s: %s\n",
+ tab, SHA384KEY, p->fts_accpath, strerror(errno));
tab = "\t";
} else {
if (strcmp(s->sha384digest, digestbuf)) {
LABEL;
- printf("%ssha384 (0x%s, 0x%s)\n",
- tab, s->sha384digest, digestbuf);
+ printf("%s%s (0x%s, 0x%s)\n",
+ tab, SHA384KEY, s->sha384digest, digestbuf);
}
tab = "\t";
free(digestbuf);
@@ -493,14 +484,14 @@ typeerr: LABEL;
if (s->flags & F_SHA512) {
if ((digestbuf = SHA512_File(p->fts_accpath, NULL)) == NULL) {
LABEL;
- printf("%ssha512: %s: %s\n",
- tab, p->fts_accpath, strerror(errno));
+ printf("%s%s: %s: %s\n",
+ tab, SHA512KEY, p->fts_accpath, strerror(errno));
tab = "\t";
} else {
if (strcmp(s->sha512digest, digestbuf)) {
LABEL;
- printf("%ssha512 (0x%s, 0x%s)\n",
- tab, s->sha512digest, digestbuf);
+ printf("%s%s (0x%s, 0x%s)\n",
+ tab, SHA512KEY, s->sha512digest, digestbuf);
}
tab = "\t";
free(digestbuf);
Modified: projects/mtree/contrib/mtree/create.c
==============================================================================
--- projects/mtree/contrib/mtree/create.c Fri Sep 21 21:31:51 2012 (r240794)
+++ projects/mtree/contrib/mtree/create.c Fri Sep 21 21:52:14 2012 (r240795)
@@ -233,7 +233,7 @@ statf(int indent, FTSENT *p)
if (keys & F_MD5 && S_ISREG(p->fts_statp->st_mode)) {
if ((digestbuf = MD5File(p->fts_accpath, NULL)) == NULL)
mtree_err("%s: MD5File failed: %s", p->fts_accpath, strerror(errno));
- output(indent, &offset, "md5=%s", digestbuf);
+ output(indent, &offset, "%s=%s", MD5KEY, digestbuf);
free(digestbuf);
}
#endif /* ! NO_MD5 */
@@ -241,11 +241,7 @@ statf(int indent, FTSENT *p)
if (keys & F_RMD160 && S_ISREG(p->fts_statp->st_mode)) {
if ((digestbuf = RMD160File(p->fts_accpath, NULL)) == NULL)
mtree_err("%s: RMD160File failed: %s", p->fts_accpath, strerror(errno));
-#ifndef __FreeBSD__
- output(indent, &offset, "rmd160=%s", digestbuf);
-#else
- output(indent, &offset, "ripemd160digest=%s", digestbuf);
-#endif
+ output(indent, &offset, "%s=%s", RMD160KEY, digestbuf);
free(digestbuf);
}
#endif /* ! NO_RMD160 */
@@ -253,7 +249,7 @@ statf(int indent, FTSENT *p)
if (keys & F_SHA1 && S_ISREG(p->fts_statp->st_mode)) {
if ((digestbuf = SHA1File(p->fts_accpath, NULL)) == NULL)
mtree_err("%s: SHA1File failed: %s", p->fts_accpath, strerror(errno));
- output(indent, &offset, "sha1=%s", digestbuf);
+ output(indent, &offset, "%s=%s", SHA1KEY, digestbuf);
free(digestbuf);
}
#endif /* ! NO_SHA1 */
@@ -261,21 +257,21 @@ statf(int indent, FTSENT *p)
if (keys & F_SHA256 && S_ISREG(p->fts_statp->st_mode)) {
if ((digestbuf = SHA256_File(p->fts_accpath, NULL)) == NULL)
mtree_err("%s: SHA256_File failed: %s", p->fts_accpath, strerror(errno));
- output(indent, &offset, "sha256=%s", digestbuf);
+ output(indent, &offset, "%s=%s", SHA256KEY, digestbuf);
free(digestbuf);
}
#ifndef NO_SHA384
if (keys & F_SHA384 && S_ISREG(p->fts_statp->st_mode)) {
if ((digestbuf = SHA384_File(p->fts_accpath, NULL)) == NULL)
mtree_err("%s: SHA384_File failed: %s", p->fts_accpath, strerror(errno));
- output(indent, &offset, "sha384=%s", digestbuf);
+ output(indent, &offset, "%s=%s", SHA384KEY, digestbuf);
free(digestbuf);
}
#endif
if (keys & F_SHA512 && S_ISREG(p->fts_statp->st_mode)) {
if ((digestbuf = SHA512_File(p->fts_accpath, NULL)) == NULL)
mtree_err("%s: SHA512_File failed: %s", p->fts_accpath, strerror(errno));
- output(indent, &offset, "sha512=%s", digestbuf);
+ output(indent, &offset, "%s=%s", SHA512KEY, digestbuf);
free(digestbuf);
}
#endif /* ! NO_SHA2 */
Modified: projects/mtree/contrib/mtree/mtree.h
==============================================================================
--- projects/mtree/contrib/mtree/mtree.h Fri Sep 21 21:31:51 2012 (r240794)
+++ projects/mtree/contrib/mtree/mtree.h Fri Sep 21 21:52:14 2012 (r240795)
@@ -124,6 +124,19 @@ int mtree_specspec(FILE *, FILE *);
void free_nodes(NODE *);
char *vispath(const char *);
+#ifndef __FreeBSD__
+#define MD5KEY "md5"
+#define RMD160KEY "rmd160"
+#define SHA1KEY "sha1"
+#define SHA256KEY "sha256"
+#else
+#define MD5KEY "md5digest"
+#define RMD160KEY "ripemd160digest"
+#define SHA1KEY "sha1digest"
+#define SHA256KEY "sha256digest"
+#endif
+#define SHA384KEY "sha384"
+#define SHA512KEY "sha512"
#define RP(p) \
((p)->fts_path[0] == '.' && (p)->fts_path[1] == '/' ? \
Modified: projects/mtree/contrib/mtree/spec.c
==============================================================================
--- projects/mtree/contrib/mtree/spec.c Fri Sep 21 21:31:51 2012 (r240794)
+++ projects/mtree/contrib/mtree/spec.c Fri Sep 21 21:52:14 2012 (r240795)
@@ -364,22 +364,22 @@ dump_nodes(const char *dir, NODE *root,
if (MATCHFLAG(F_CKSUM))
appendfield(pathlast, "cksum=%lu", cur->cksum);
if (MATCHFLAG(F_MD5))
- appendfield(pathlast, "md5=%s", cur->md5digest);
+ appendfield(pathlast, "%s=%s", MD5KEY, cur->md5digest);
if (MATCHFLAG(F_RMD160))
-#ifndef __FreeBSD__
- appendfield(pathlast, "rmd160=%s", cur->rmd160digest);
-#else
- appendfield(pathlast, "ripemd160digest=%s",
+ appendfield(pathlast, "%s=%s", RMD160KEY,
cur->rmd160digest);
-#endif
if (MATCHFLAG(F_SHA1))
- appendfield(pathlast, "sha1=%s", cur->sha1digest);
+ appendfield(pathlast, "%s=%s", SHA1KEY,
+ cur->sha1digest);
if (MATCHFLAG(F_SHA256))
- appendfield(pathlast, "sha256=%s", cur->sha256digest);
+ appendfield(pathlast, "%s=%s", SHA256KEY,
+ cur->sha256digest);
if (MATCHFLAG(F_SHA384))
- appendfield(pathlast, "sha384=%s", cur->sha384digest);
+ appendfield(pathlast, "%s=%s", SHA384KEY,
+ cur->sha384digest);
if (MATCHFLAG(F_SHA512))
- appendfield(pathlast, "sha512=%s", cur->sha512digest);
+ appendfield(pathlast, "%s=%s", SHA512KEY,
+ cur->sha512digest);
if (MATCHFLAG(F_FLAGS)) {
str = flags_to_string(cur->st_flags, "none");
appendfield(pathlast, "flags=%s", str);
Modified: projects/mtree/contrib/mtree/specspec.c
==============================================================================
--- projects/mtree/contrib/mtree/specspec.c Fri Sep 21 21:31:51 2012 (r240794)
+++ projects/mtree/contrib/mtree/specspec.c Fri Sep 21 21:52:14 2012 (r240795)
@@ -79,17 +79,19 @@ shownode(NODE *n, int f, char const *pat
printf(" uname=%s", pw->pw_name);
}
if (f & F_MD5)
- printf(" md5digest=%s", n->md5digest);
+ printf(" %s=%s", MD5KEY, n->md5digest);
if (f & F_SHA1)
- printf(" sha1digest=%s", n->sha1digest);
+ printf(" %s=%s", SHA1KEY, n->sha1digest);
if (f & F_RMD160)
- printf(" rmd160digest=%s", n->rmd160digest);
+ printf(" %s=%s", RMD160KEY, n->rmd160digest);
+ if (f & F_SHA1)
+ printf(" %s=%s", SHA1KEY, n->sha256digest);
if (f & F_SHA256)
- printf(" sha256digest=%s", n->sha256digest);
+ printf(" %s=%s", SHA256KEY, n->sha256digest);
if (f & F_SHA384)
- printf(" sha384=%s", n->sha384digest);
+ printf(" %s=%s", SHA384KEY, n->sha384digest);
if (f & F_SHA512)
- printf(" sha512=%s", n->sha512digest);
+ printf(" %s=%s", SHA512KEY, n->sha512digest);
if (f & F_FLAGS)
printf(" flags=%s", flags_to_string(n->st_flags, "none"));
printf("\n");
More information about the svn-src-projects
mailing list