From 9d13c14fe5ad5dff32c09b1c5c13af9518b3e727 Mon Sep 17 00:00:00 2001 From: John Denker Date: Thu, 22 Nov 2012 18:31:19 -0800 Subject: separate parsing headers from dumping headers --- tools/libskrewt.c | 15 +++++++++++---- tools/libskrewt.h | 3 ++- tools/ward.c | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/libskrewt.c b/tools/libskrewt.c index fb1cd4a..68fe741 100644 --- a/tools/libskrewt.c +++ b/tools/libskrewt.c @@ -85,7 +85,7 @@ int skrewt::krunch_rfrom(){ return 0; } -int skrewt::headers(istream& xin, std::ostream& xout){ +int skrewt::headers(istream& xin){ //xxxx cerr << progid << " begins" << endl; for (;;){ // outer loop over all records in the header if (xin.eof()) break; @@ -99,7 +99,6 @@ int skrewt::headers(istream& xin, std::ostream& xout){ cerr << progid << " rejection: bigger than " << maxsize << endl; exeunt(ex_spam); } - xout << line << endl; bigbuf.push_back(line); string headrec = noCR(line); // for a folded record, this is the first line @@ -118,7 +117,6 @@ int skrewt::headers(istream& xin, std::ostream& xout){ cerr << progid << " rejection: bigger than " << maxsize << endl; exeunt(ex_spam); } - xout << line << endl; bigbuf.push_back(line); headrec += "\n" + noCR(line); } @@ -161,7 +159,6 @@ int skrewt::headers(istream& xin, std::ostream& xout){ } else if (headword == "delivered-to") { delivered_to = rest; } - //xxxx xout << headrec.length() << " ... "; recno++; if (0) if (recno <= 6) cerr << progid << "#" << recno << " " << headrec << endl; @@ -169,6 +166,14 @@ int skrewt::headers(istream& xin, std::ostream& xout){ return 0; } +int skrewt::dump_headers(std::ostream& xout){ + for (vector::const_iterator foo = bigbuf.begin(); + foo != bigbuf.end(); foo++){ + xout << *foo << endl; + } + return 0; +} + int skrewt::interstage(){ if (saw_blank_line) {/* ignore */} // Note that the headers are in reverse-chronological order: @@ -347,6 +352,8 @@ int skrewt::body(std::istream& xin, std::ostream& xout){ // early-stage thinking has been done. // Now spew the rest of the message +// Note that multipart messages can have sub-headers. + //xxxx cerr << "body begins: " << main_contype << " " << currently_text << " " << boundary << endl; int in_subheads(0); int textlines(0); diff --git a/tools/libskrewt.h b/tools/libskrewt.h index 8b0045f..cfbbb79 100644 --- a/tools/libskrewt.h +++ b/tools/libskrewt.h @@ -36,7 +36,8 @@ public: maxsize(1000*1000), error_exit(0), mid_required(0) {} - int headers(std::istream& xin, std::ostream& xout); + int headers(std::istream& xin); + int dump_headers(std::ostream& xout); int interstage(); int body(std::istream& xin, std::ostream& xout); int krunch_rfrom(); diff --git a/tools/ward.c b/tools/ward.c index 19d9d02..b6f5a15 100644 --- a/tools/ward.c +++ b/tools/ward.c @@ -114,8 +114,9 @@ int main(int _argc, const char** _argv){ exit(ex_usage); } - int rslt = mysk.headers(cin, cout); + int rslt = mysk.headers(cin); if (rslt) return rslt; + mysk.dump_headers(cout); // Headers are done. // Do some early-stage thinking. -- cgit v1.2.3