diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/libskrewt.c | 39 | ||||
| -rw-r--r-- | tools/libskrewt.h | 40 | ||||
| -rw-r--r-- | tools/skrewt.c | 2 | ||||
| -rw-r--r-- | tools/ward.c | 79 | 
4 files changed, 82 insertions, 78 deletions
| diff --git a/tools/libskrewt.c b/tools/libskrewt.c index a756863..602fdb7 100644 --- a/tools/libskrewt.c +++ b/tools/libskrewt.c @@ -1,5 +1,7 @@ -#include <iostream>  #include "libskrewt.h" +#include "utils.h" +#include <iostream> +#include <sstream>  using namespace std; @@ -47,3 +49,38 @@ void parse_content(const string type_spec_line,      //xxxxxxx cerr << "boundary= not found in " << type_spec_line << endl;    }  } + +int skrewt::krunch_rfrom(){ +  stringstream parse; +  parse.str(received_from); +  string word; +  parse >> word; +  if (word != "from") { +    cerr << progid << " bad 'Received: from' line ... '" +        << word << "'" << endl; +    return ex_syserr; +  } +  parse >> proximta_rDNS; +  parse >> word; +  if (word == "(HELO" /*)*/) { +    parse >> proximta_HELO; +    proximta_HELO = rtrim(proximta_HELO, "()"); +    parse >> word; +  } else { +    proximta_HELO = proximta_rDNS; +  } +  size_t len = word.length(); +  if (len<2 || word[0] != '(' || word[len-1] != ')') { +    cerr << progid << " bad 'Received: from' line ;;; '" +        << word << "'" << endl; +    return ex_syserr; +  } +  proximta_IP = word.substr(1, len-2); +  size_t where = proximta_IP.find("@"); +  if (where != string::npos){ +    proximta_AuthUser = proximta_IP.substr(0, where); +    proximta_IP = proximta_IP.substr(1+where); +  } + +  return 0; +} diff --git a/tools/libskrewt.h b/tools/libskrewt.h index c9d6721..94d06dd 100644 --- a/tools/libskrewt.h +++ b/tools/libskrewt.h @@ -1,4 +1,44 @@  #include <string> +#include <vector> +#include "qq_exit_codes.h"              // a bit of a kludge +extern std::string progid; + +class skrewt{ +public: +  std::string received_from;         // envelope HELO among other things +    std::string proximta_HELO; +    std::string proximta_rDNS; +    std::string proximta_IP; +    std::string proximta_AuthUser; +  std::string return_path;           // envelope MAIL FROM +  std::string boundary; +  std::string to; +  std::string from; +  std::string subject; +  std::string date; +  std::string message_id; +  std::string content_type; +  std::string delivered_to; +  int msgsize; +  std::vector<std::string> bigbuf; +  int saw_blank_line; +  int recno; + +  int maxsize; +  int error_exit; +  int mid_required; + +  // constructor +  skrewt() +  : boundary("x-xx-x"), msgsize(0), saw_blank_line(0), recno(0), +    maxsize(1000*1000), error_exit(0), mid_required(0) +  {} + +  int headers(); +  int interstage(); +  int body(); +  int krunch_rfrom(); +};  void parse_content(const std::string type_spec_line,          std::string &maintype, std::string &boundary); diff --git a/tools/skrewt.c b/tools/skrewt.c index 8c07974..63c6be6 100644 --- a/tools/skrewt.c +++ b/tools/skrewt.c @@ -435,7 +435,7 @@ int skrewt::interstage(){    }    if (delivered_to.length()){ -    cerr << progid <<  "Delivered-to: <<<" << delivered_to << ">>>" << endl; +    cerr << progid <<  " Delivered-to: <<<" << delivered_to << ">>>" << endl;    }    if (toLower(trim(delivered_to)) == "jean@av8n.com") {      badnews.push_back("Looping Delivered-to: " + delivered_to); diff --git a/tools/ward.c b/tools/ward.c index 56e626d..6280a28 100644 --- a/tools/ward.c +++ b/tools/ward.c @@ -37,9 +37,9 @@ void usage(const int sts){    exit(sts);  } -#include "qq_exit_codes.h" -#include "utils.h" +#include "libskrewt.h"  #include "sepofra.h" +#include "utils.h"  void maybe_exeunt(const int sts, const int really){    if (!really) return; @@ -72,44 +72,6 @@ int mypid;  /* Content-Type: multipart/mixed; boundary="1170861315-1262462055-1341954763=:92165"    */  // -#include "libskrewt.h" - -class skrewt{ -public: -  string received_from;         // envelope HELO among other things -    string proximta_HELO; -    string proximta_rDNS; -    string proximta_IP; -    string proximta_AuthUser; -  string return_path;           // envelope MAIL FROM -  string boundary; -  string to; -  string from; -  string subject; -  string date; -  string message_id; -  string content_type; -  string delivered_to; -  int msgsize; -  vector<string> bigbuf; -  int saw_blank_line; -  int recno; - -  int maxsize; -  int error_exit; -  int mid_required; - -  // constructor -  skrewt() -  : boundary("x-xx-x"), msgsize(0), saw_blank_line(0), recno(0), -    maxsize(1000*1000), error_exit(0), mid_required(0) -  {} - -  int headers(); -  int interstage(); -  int body(); -  int krunch_rfrom(); -};  #if 0   /* typical "Received: from" lines */  Received: from lists.sourceforge.net (216.34.181.88) @@ -135,41 +97,6 @@ Received: from ip68-231-191-153.tc.ph.cox.net (HELO asclepias.av8n.net) (smtp@68  /home/jsd/Maildir/cur/1342363199.24320.cloud:2,  #endif -int skrewt::krunch_rfrom(){ -  stringstream parse; -  parse.str(received_from); -  string word; -  parse >> word; -  if (word != "from") { -    cerr << progid << " bad 'Received: from' line ... '" -        << word << "'" << endl; -    return ex_syserr; -  } -  parse >> proximta_rDNS; -  parse >> word; -  if (word == "(HELO") { -    parse >> proximta_HELO; -    proximta_HELO = rtrim(proximta_HELO, "()"); -    parse >> word; -  } else { -    proximta_HELO = proximta_rDNS; -  } -  size_t len = word.length(); -  if (len<2 || word[0] != '(' || word[len-1] != ')') { -    cerr << progid << " bad 'Received: from' line ;;; '" -        << word << "'" << endl; -    return ex_syserr; -  } -  proximta_IP = word.substr(1, len-2); -  size_t where = proximta_IP.find("@"); -  if (where != string::npos){ -    proximta_AuthUser = proximta_IP.substr(0, where); -    proximta_IP = proximta_IP.substr(1+where); -  } - -  return 0; -} -  int skrewt::headers(){    //xxxx cerr << progid << " begins" << endl;    for (;;){             // outer loop over all records in the header @@ -392,7 +319,7 @@ int skrewt::interstage(){    }    if (delivered_to.length()){ -    cerr << progid <<  "Delivered-to: <<<" << delivered_to << ">>>" << endl; +    cerr << progid <<  " Delivered-to: <<<" << delivered_to << ">>>" << endl;    }    if (toLower(trim(delivered_to)) == "jean@av8n.com") {      badnews.push_back("Looping Delivered-to: " + delivered_to); | 
