From 74578b918ceac9aad470f89d3320a375c0c900e8 Mon Sep 17 00:00:00 2001 From: John Denker Date: Sat, 24 Nov 2012 09:03:57 -0800 Subject: decrease verbosity --- tools/libskrewt.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/tools/libskrewt.c b/tools/libskrewt.c index 39b241a..b41d7d0 100644 --- a/tools/libskrewt.c +++ b/tools/libskrewt.c @@ -5,10 +5,12 @@ using namespace std; +static int verbosity(0); + void parse_content(const string type_spec_line, string &maintype, string &boundary, const string old_bdy) { - if (0) cerr << "parser called with: " << type_spec_line << endl; + if (verbosity > 1) cerr << "parser called with: " << type_spec_line << endl; string get_type(type_spec_line); size_t where = get_type.find_first_of(" \t;\n"); @@ -421,8 +423,10 @@ int skrewt::body(std::istream& xin, std::ostream& xout){ // Now spew the rest of the message // Note that multipart messages can have sub-headers. - cerr << "body begins: "; - dump(sitch); + if (verbosity) { + cerr << "body begins: "; + dump(sitch); + } int in_subheads(0); int textlines(0); @@ -433,17 +437,18 @@ int skrewt::body(std::istream& xin, std::ostream& xout){ xstr rec = getRecord(xin); if (rec.err) break; string line = rec.str; - if (0) cerr << "+++" << line << endl; + if (verbosity) cerr << "+++" << line << endl; if (in_subheads){ if (line == "" || line == "\r") { in_subheads = 0; - cerr << "+++ end of subhead" << endl; + if (verbosity) cerr << "+++ end of subhead" << endl; string tp, bdy; parse_content(sub_conntype, tp, bdy, sitch.front().bdy); sitch.push_front({tp, bdy}); - - cerr << "payload mode: "; - dump(sitch); + if (verbosity) { + cerr << "payload mode: "; + dump(sitch); + } } } if (/* still */in_subheads){ @@ -468,8 +473,10 @@ int skrewt::body(std::istream& xin, std::ostream& xout){ && line == "--" + sitch.front().bdy) { if (sitch.front().tp != "multipart") sitch.pop_front(); - cerr << "boundary: begin subhead block "; - dump(sitch); + if (verbosity) { + cerr << "boundary: begin subhead block "; + dump(sitch); + } in_subheads = 1; sub_conntype = ""; continue; @@ -479,8 +486,10 @@ int skrewt::body(std::istream& xin, std::ostream& xout){ string dead_bdy = sitch.front().bdy; sitch.pop_front(); if (sitch.front().bdy == dead_bdy) sitch.pop_front(); - cerr << "boundary: termination "; - dump(sitch); + if (verbosity) { + cerr << "boundary: termination "; + dump(sitch); + } in_subheads = 0; continue; } @@ -488,7 +497,7 @@ int skrewt::body(std::istream& xin, std::ostream& xout){ } } - if (0) cerr << "textlines: " << textlines << endl; + if (verbosity) cerr << "textlines: " << textlines << endl; if (!textlines) { cerr << progid << " rejection: no text: " << error_exit << endl; maybe_exeunt(ex_spam, error_exit); -- cgit v1.2.3