summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-11-22 18:31:19 -0800
committerJohn Denker <jsd@av8n.com>2012-11-22 18:31:19 -0800
commit9d13c14fe5ad5dff32c09b1c5c13af9518b3e727 (patch)
treed6396cc9e5c38fb27a4a215792d816acc72897a0 /tools
parent33981cf1aba48b7589fbdc685eeaa8a52ece8c4f (diff)
separate parsing headers from dumping headers
Diffstat (limited to 'tools')
-rw-r--r--tools/libskrewt.c15
-rw-r--r--tools/libskrewt.h3
-rw-r--r--tools/ward.c3
3 files changed, 15 insertions, 6 deletions
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<string>::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.