diff options
author | phk <phk@FreeBSD.org> | 1994-09-25 20:45:55 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1994-09-25 20:45:55 +0000 |
commit | 962026360d12c06819c626b7e393d6f2eb4f7eff (patch) | |
tree | f742ae8e2486a849f8605b5944733e0535a1f19d /usr.sbin/ctm | |
parent | f13b791bdb0c6558d92061a3e8b192b806060c99 (diff) | |
download | FreeBSD-src-962026360d12c06819c626b7e393d6f2eb4f7eff.zip FreeBSD-src-962026360d12c06819c626b7e393d6f2eb4f7eff.tar.gz |
Added a '-c' option: This will warn you if any file in the directory-tree
you run it on are unsuitable food for diff/patch. Can you use it as it
is now Rod ?
Diffstat (limited to 'usr.sbin/ctm')
-rw-r--r-- | usr.sbin/ctm/ctm_scan/ctm_scan.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/usr.sbin/ctm/ctm_scan/ctm_scan.c b/usr.sbin/ctm/ctm_scan/ctm_scan.c index 21145d7..0f6e3de 100644 --- a/usr.sbin/ctm/ctm_scan/ctm_scan.c +++ b/usr.sbin/ctm/ctm_scan/ctm_scan.c @@ -20,6 +20,7 @@ #include <md5.h> int barf[256]; +int CheckMode = 0; int pstrcmp(const void *pp, const void *qq) @@ -93,22 +94,34 @@ Do(char *path) continue; } MD5Init(&ctx); - l = j = 0; + l = 1; + j = 0; while(0 < (i = read(fd,data,sizeof data))) { l = (data[i-1] == '\n'); - MD5Update(&ctx,data,i); + if(!CheckMode) + MD5Update(&ctx,data,i); for(q=data;i && !j;i--) if(barf[*q++]) j=1; } - if(!l) - j=1; close(fd); - i = printf("f %s %o %d %d %d %d %s\n", - buf,st.st_mode & (~S_IFMT),st.st_uid,st.st_gid, - j,st.st_size,MD5End(&ctx)); - if(!i) - exit(-1); + if(CheckMode) { + if(j || !l) { + i = printf("%s",buf); + if(!i) exit(-1); + if(j) printf(" Illegal characters."); + if(!l) printf(" No final newline."); + i = printf(".\n"); + if(!i) exit(-1); + } + } else { + if(!l) + j=2; + i = printf("f %s %o %d %d %d %d %s\n", + buf,st.st_mode & (~S_IFMT),st.st_uid,st.st_gid, + j,st.st_size,MD5End(&ctx)); + if(!i) exit(-1); + } break; default: fprintf(stderr,"%s: type 0%o\n",buf, st.st_mode & S_IFMT); @@ -133,6 +146,15 @@ main(int argc, char **argv) barf[0xff] = 1; /* + * -c is CheckMode + */ + if (argc > 1 && !strcmp(argv[1],"-c")) { + CheckMode=1; + argc--; + argv++; + } + + /* * First argument, if any, is where to do the work. */ if (argc > 1) { |