From 66ade4b4d9c74fbe40981015cbbb98f2b3320c31 Mon Sep 17 00:00:00 2001 From: John Denker Date: Mon, 16 Jul 2012 18:45:15 -0700 Subject: add "group" feature --- tools/mail-scan.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/mail-scan.c b/tools/mail-scan.c index c70a1de..3749945 100644 --- a/tools/mail-scan.c +++ b/tools/mail-scan.c @@ -40,6 +40,9 @@ void usage(const int sts){ " Options\n" " -help print this msg (and exit immediately).\n" " -maxsize ii msg size in bytes; anything bigger will be rejected.\n" +" -vert invert: print only if *no* match.\n" +" -l print filename only, not matching text.\n" +" -group print a blank line after every match.\n" "\n" " Messages containing the string '-please-bounce-this-' will be rejected.\n" " Messages with no date will be rejected.\n" @@ -182,6 +185,7 @@ int main(int _argc, const char** _argv){ list watchword; list dofile; int vflag(0); + int group_flag(0); int multi(0); int fname_only(0); @@ -191,9 +195,12 @@ int main(int _argc, const char** _argv){ if (prefix(arg, "-help")) { usage(0); } - if (prefix(arg, "-verify")){ + if (prefix(arg, "-vert")){ vflag++; continue; + } if (prefix(arg, "-group")){ + group_flag++; + continue; } else if (prefix(arg, "-l")){ fname_only++; continue; @@ -212,9 +219,10 @@ int main(int _argc, const char** _argv){ } } +// loop over all files for (list::const_iterator file = dofile.begin(); file != dofile.end(); file++) { - + int didprint(0); struct stat filestatus; stat(file->c_str(), &filestatus ); if (S_ISDIR(filestatus.st_mode)) { @@ -283,18 +291,22 @@ int main(int _argc, const char** _argv){ cout << *file; if (!fname_only) cout << " :: " << header; cout << endl; + didprint++; } } } } } -// cout << header << endl; } else { // not in header break; } } - if (vflag && !foundsome_infile) cout << foundsome_infile + if (vflag && !foundsome_infile) { + cout << foundsome_infile << " ... " << *file << endl; + didprint++; + } + if (group_flag && didprint) cout << endl; } } -- cgit v1.2.3