[pan2/testing: 169/279] moved xzver support to "experimental"



commit 8f91ce0c2c40d41e9bce8d3759ed6d44fcbc7601
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Tue Jul 12 21:18:36 2011 +0200

    moved xzver support to "experimental"

 pan/general/debug.cc    |    2 -
 pan/general/debug.h     |    2 -
 pan/gui/pan.cc          |    2 -
 pan/tasks/nntp.cc       |   23 +--------
 pan/tasks/nntp.h        |   11 +----
 pan/tasks/task-xover.cc |  132 +---------------------------------------------
 pan/tasks/task-xover.h  |    8 +---
 7 files changed, 7 insertions(+), 173 deletions(-)
---
diff --git a/pan/general/debug.cc b/pan/general/debug.cc
index 749f27f..d3b549f 100644
--- a/pan/general/debug.cc
+++ b/pan/general/debug.cc
@@ -6,6 +6,4 @@ namespace pan
   bool _debug_flag = false;
   bool _debug_verbose_flag = false;
 
-  // imhotep
-  bool _xzver_support = false;
 }
diff --git a/pan/general/debug.h b/pan/general/debug.h
index 1d06c0f..ebaed84 100644
--- a/pan/general/debug.h
+++ b/pan/general/debug.h
@@ -27,8 +27,6 @@ namespace pan
   extern bool _debug_flag;
   extern bool _debug_verbose_flag;
 
-  // imhotep
-  extern bool _xzver_support;
 }
 
 #define LINE_ID '(' << __FILE__ << ':' << __LINE__ << ':' << __func__ << ')'
diff --git a/pan/gui/pan.cc b/pan/gui/pan.cc
index c3afc2f..5d8a8e4 100644
--- a/pan/gui/pan.cc
+++ b/pan/gui/pan.cc
@@ -286,8 +286,6 @@ main (int argc, char *argv[])
       nzb_output_path = tok+9;
     else if (!strcmp(tok,"-h") || !strcmp(tok,"--help"))
       { usage (); return 0; }
-    else if (!strcmp(tok,"--xzver"))
-      _xzver_support = true;
     else {
       nzb = true;
       nzb_files.push_back (tok);
diff --git a/pan/tasks/nntp.cc b/pan/tasks/nntp.cc
index f4cb2c7..b284996 100644
--- a/pan/tasks/nntp.cc
+++ b/pan/tasks/nntp.cc
@@ -63,7 +63,6 @@ NNTP :: fire_done_func (Health health, const StringView& response)
       debug ("I (" << (void*)this << ") am setting my _listener to 0");
       _listener = 0;
       l->on_nntp_done (this, health, response);
-      _xzver = false;
    }
 }
 
@@ -79,7 +78,7 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
    StringView line (line_in);
 
    // strip off trailing \r\n
-   if (line.len>=2 && line.str[line.len-2]=='\r' && line.str[line.len-1]=='\n' && !_xzver)
+   if (line.len>=2 && line.str[line.len-2]=='\r' && line.str[line.len-1]=='\n')
      line.truncate (line.len-2);
 
 //    std::cerr <<"_nntp_response_text: " << _nntp_response_text<<std::endl;
@@ -94,7 +93,7 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
       {
          state = CMD_MORE;
 
-         if (line.len>=2 && line.str[0]=='.' && line.str[1]=='.' && !_xzver) // rfc 977: 2.4.1
+         if (line.len>=2 && line.str[0]=='.' && line.str[1]=='.') // rfc 977: 2.4.1
             line.rtruncate (line.len-1);
 
          assert (_listener != 0);
@@ -319,24 +318,6 @@ NNTP :: xover (const Quark   & group,
 }
 
 void
-NNTP :: xzver (const Quark   & group,
-               uint64_t        low,
-               uint64_t        high,
-               Listener      * l)
-{
-   _listener = l;
-   _xzver = true;
-
-   if (group != _group)
-      _commands.push_back (build_command ("GROUP %s\r\n", group.c_str()));
-
-   _commands.push_back (build_command ("XZVER %"G_GUINT64_FORMAT"-%"G_GUINT64_FORMAT"\r\n", low, high));
-
-   write_next_command ();
-}
-
-
-void
 NNTP :: list_newsgroups (Listener * l)
 {
    _listener = l;
diff --git a/pan/tasks/nntp.h b/pan/tasks/nntp.h
index c83de4b..3c11970 100644
--- a/pan/tasks/nntp.h
+++ b/pan/tasks/nntp.h
@@ -153,8 +153,7 @@ namespace pan
           _listener(0),
           _username(username),
           _password(password),
-          _nntp_response_text(false),
-          _xzver(false)
+          _nntp_response_text(false)
        {}
 
        virtual ~NNTP ()
@@ -191,12 +190,6 @@ namespace pan
                              Listener           * l);
 
 
-      /** Experimental XZVER header compression support */
-      void  xzver           (const Quark   & group,
-                             uint64_t        low,
-                             uint64_t        high,
-                             Listener      * l) ;
-
       /**
        * Executes a LIST command: "LIST"
        *
@@ -310,8 +303,6 @@ namespace pan
       /** True if the server told us that we're getting a list back. */
       bool _nntp_response_text;
 
-      bool _xzver;
-
       typedef std::deque<std::string> strings_t;
       strings_t _commands;
       std::string _previous_command;
diff --git a/pan/tasks/task-xover.cc b/pan/tasks/task-xover.cc
index 8b48c7c..a027d89 100644
--- a/pan/tasks/task-xover.cc
+++ b/pan/tasks/task-xover.cc
@@ -110,19 +110,9 @@ TaskXOver :: TaskXOver (Data         & data,
   _bytes_so_far (0),
   _parts_so_far (0ul),
   _articles_so_far (0ul),
-  _total_minitasks (0),
-  _running_minitasks (0),
-  _xzver (_xzver_support)
+  _total_minitasks (0)
 {
 
-
-
-  if (_xzver)
-  {
-    char buf[4096];
-    _headers.open(build_cachename(buf,sizeof(buf), "xzver_test"), std::ios::out | std::ios::binary);
-  }
-
   debug ("ctor for " << group);
 
   // add a ``GROUP'' MiniTask for each server that has this group
@@ -185,11 +175,7 @@ TaskXOver :: use_nntp (NNTP* nntp)
       case MiniTask::XOVER:
         debug ("XOVER " << mt._low << '-' << mt._high << " to " << server);
         _last_xover_number[nntp] = mt._low;
-        if (_xzver)
-          nntp->xzver (_group, mt._low, mt._high, this);
-        else
-          nntp->xover (_group, mt._low, mt._high, this);
-        --_running_minitasks;
+        nntp->xover (_group, mt._low, mt._high, this);
         break;
       default:
         assert (0);
@@ -243,7 +229,7 @@ TaskXOver :: on_nntp_group (NNTP          * nntp,
   {
     //std::cerr << LINE_ID << " okay, I'll try to get articles in [" << l << "..." << h << ']' << std::endl;
     add_steps (h-l);
-    int INCREMENT = _xzver ? 100000 : 1000;
+    const int INCREMENT(1000);
     MiniTasks_t& minitasks (_server_to_minitasks[servername]);
     for (uint64_t m=l; m<=h; m+=INCREMENT) {
       MiniTask mt (MiniTask::XOVER, m, m+INCREMENT);
@@ -251,7 +237,6 @@ TaskXOver :: on_nntp_group (NNTP          * nntp,
       minitasks.push_front (mt);
       ++_total_minitasks;
     }
-    _running_minitasks = _total_minitasks;
   }
   else
   {
@@ -302,21 +287,6 @@ TaskXOver :: on_nntp_line         (NNTP               * nntp,
                                    const StringView   & line)
 {
 
-    if (_xzver ) {
-        if (line.strstr("=ybegin line=128"))
-          _headers << line.str << " name=xzver_decoded\n";
-        else
-          _headers << line.str <<"\n";
-    }
-    else
-      on_nntp_line_process (nntp, line);
-}
-
-void
-TaskXOver :: on_nntp_line_process (NNTP               * nntp,
-                                   const StringView   & line)
-{
-
   pan_return_if_fail (nntp != 0);
   pan_return_if_fail (!nntp->_server.empty());
   pan_return_if_fail (!nntp->_group.empty());
@@ -414,8 +384,6 @@ TaskXOver :: on_nntp_done (NNTP              * nntp,
                            Health              health,
                            const StringView  & response UNUSED)
 {
-  if (_running_minitasks == 0 && _xzver) process_headers(nntp);
-
   update_work (true);
   check_in (nntp, health);
 }
@@ -445,100 +413,6 @@ TaskXOver :: update_work (bool subtract_one_from_nntp_count)
   }
 }
 
-namespace
-{
-
-  #define CHUNK 16384
-
-  int inf(FILE *source, FILE *dest)
-  {
-    int ret;
-    unsigned have;
-    z_stream strm;
-    unsigned char in[CHUNK];
-    unsigned char out[CHUNK];
-
-    /* allocate inflate state */
-    strm.zalloc = Z_NULL;
-    strm.zfree = Z_NULL;
-    strm.opaque = Z_NULL;
-    strm.avail_in = 0;
-    strm.next_in = Z_NULL;
-    ret = inflateInit2(&strm,-15); //raw inflate
-    if (ret != Z_OK)
-        return ret;
-
-    /* decompress until deflate stream ends or end of file */
-    do {
-        strm.avail_in = fread(in, 1, CHUNK, source);
-        if (ferror(source)) {
-            (void)inflateEnd(&strm);
-            return Z_ERRNO;
-        }
-        if (strm.avail_in == 0)
-            break;
-        strm.next_in = in;
-
-        /* run inflate() on input until output buffer not full */
-        do {
-            strm.avail_out = CHUNK;
-            strm.next_out = out;
-            ret = inflate(&strm, Z_NO_FLUSH);
-            assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
-            switch (ret) {
-            case Z_NEED_DICT:
-                ret = Z_DATA_ERROR;     /* and fall through */
-            case Z_DATA_ERROR:
-            case Z_MEM_ERROR:
-                (void)inflateEnd(&strm);
-                return ret;
-            }
-            have = CHUNK - strm.avail_out;
-            if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
-                (void)inflateEnd(&strm);
-                return Z_ERRNO;
-            }
-        } while (strm.avail_out == 0);
-
-        /* done when inflate() says it's done */
-    } while (ret != Z_STREAM_END);
-
-    /* clean up and return */
-    (void)inflateEnd(&strm);
-    return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
-  }
-}
-
-void
- TaskXOver :: process_headers (NNTP* nntp)
-{
-  char buf[4096];
-
-  _headers.close();
-  /* yenc-decode */
-  UUInitialize ();
-  UULoadFile (build_cachename(buf,sizeof(buf), "xzver_test"), 0, 1);
-  UUDecodeFile (UUGetFileListItem (0), build_cachename(buf,sizeof(buf), "xzver_decoded"));
-  UUCleanUp ();
-
-  /* raw zlib inflate */
-  FILE * in = fopen (buf, "rb");
-  FILE * out = fopen (build_cachename(buf,sizeof(buf), "xzver_out"), "wb");
-  int res(Z_OK);
-  if (in && out) res = inf (in,out);
-
-  /* feed to on_nntp_line */
-  if (in) fclose(in);
-  if (out) fclose(out);
-  if (res==Z_OK)
-  {
-    std::ifstream f(buf, std::ios::in);
-    char buf[4096];
-    while (f.getline(buf,sizeof(buf))) on_nntp_line_process(nntp,StringView(buf));
-  }
-
-}
-
 unsigned long
 TaskXOver :: get_bytes_remaining () const
 {
diff --git a/pan/tasks/task-xover.h b/pan/tasks/task-xover.h
index ba146e1..d1784de 100644
--- a/pan/tasks/task-xover.h
+++ b/pan/tasks/task-xover.h
@@ -50,7 +50,6 @@ namespace pan
       virtual void use_nntp (NNTP * nntp);
 
     private: // NNTP::Listener
-      void on_nntp_line_process (NNTP*, const StringView&);
       virtual void on_nntp_line (NNTP*, const StringView&);
       virtual void on_nntp_done (NNTP*, Health, const StringView&);
       virtual void on_nntp_group (NNTP*, const Quark&, unsigned long, uint64_t, uint64_t);
@@ -68,7 +67,6 @@ namespace pan
       server_to_minitasks_t _server_to_minitasks;
 
     private: // implementation
-      void process_headers (NNTP*);
       Data& _data;
       const Quark _group;
       std::string _short_group_name;
@@ -84,12 +82,8 @@ namespace pan
       unsigned long _bytes_so_far;
       unsigned long _parts_so_far;
       unsigned long _articles_so_far;
-      unsigned long _lines_so_far;
       unsigned long _total_minitasks;
-      int           _running_minitasks;
-      bool _xzver;
-//      FILE * _headers;
-      std::ofstream _headers;
+
   };
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]