]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-method.cc
add default and override handling for Cnf::FindVector
[apt.git] / apt-pkg / acquire-method.cc
index 25c6c674d8cb5cfcaf3ed98e0264e39ab8bd58d8..5bc1c159a9b968a3cd7b501cacc46799c3debee5 100644 (file)
@@ -15,6 +15,8 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
+#include <config.h>
+
 #include <apt-pkg/acquire-method.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/acquire-method.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
@@ -93,12 +95,7 @@ void pkgAcqMethod::Fail(string Err,bool Transient)
    {
       std::cout << "400 URI Failure\nURI: " << Queue->Uri << "\n"
                << "Message: " << Err << " " << IP << "\n";
    {
       std::cout << "400 URI Failure\nURI: " << Queue->Uri << "\n"
                << "Message: " << Err << " " << IP << "\n";
-      // Dequeue
-      FetchItem *Tmp = Queue;
-      Queue = Queue->Next;
-      delete Tmp;
-      if (Tmp == QueueBack)
-        QueueBack = Queue;
+      Dequeue();
    }
    else
       std::cout << "400 URI Failure\nURI: <UNKNOWN>\nMessage: " << Err << "\n";
    }
    else
       std::cout << "400 URI Failure\nURI: <UNKNOWN>\nMessage: " << Err << "\n";
@@ -209,13 +206,7 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
    }
 
    std::cout << "\n" << std::flush;
    }
 
    std::cout << "\n" << std::flush;
-
-   // Dequeue
-   FetchItem *Tmp = Queue;
-   Queue = Queue->Next;
-   delete Tmp;
-   if (Tmp == QueueBack)
-      QueueBack = Queue;
+   Dequeue();
 }
                                                                        /*}}}*/
 // AcqMethod::MediaFail - Syncronous request for new media             /*{{{*/
 }
                                                                        /*}}}*/
 // AcqMethod::MediaFail - Syncronous request for new media             /*{{{*/
@@ -289,12 +280,12 @@ bool pkgAcqMethod::Configuration(string Message)
       I += Length + 1;
       
       for (; I < MsgEnd && *I == ' '; I++);
       I += Length + 1;
       
       for (; I < MsgEnd && *I == ' '; I++);
-      const char *Equals = I;
-      for (; Equals < MsgEnd && *Equals != '='; Equals++);
-      const char *End = Equals;
-      for (; End < MsgEnd && *End != '\n'; End++);
-      if (End == Equals)
+      const char *Equals = (const char*) memchr(I, '=', MsgEnd - I);
+      if (Equals == NULL)
         return false;
         return false;
+      const char *End = (const char*) memchr(Equals, '\n', MsgEnd - Equals);
+      if (End == NULL)
+        End = MsgEnd;
       
       Cnf.Set(DeQuoteString(string(I,Equals-I)),
              DeQuoteString(string(Equals+1,End-Equals-1)));
       
       Cnf.Set(DeQuoteString(string(I,Equals-I)),
              DeQuoteString(string(Equals+1,End-Equals-1)));
@@ -421,26 +412,14 @@ void pkgAcqMethod::Status(const char *Format,...)
                                                                        /*}}}*/
 // AcqMethod::Redirect - Send a redirect message                       /*{{{*/
 // ---------------------------------------------------------------------
                                                                        /*}}}*/
 // AcqMethod::Redirect - Send a redirect message                       /*{{{*/
 // ---------------------------------------------------------------------
-/* This method sends the redirect message and also manipulates the queue
  to keep the pipeline synchronized. */
+/* This method sends the redirect message and dequeues the item as
* the worker will enqueue again later on to the right queue */
 void pkgAcqMethod::Redirect(const string &NewURI)
 {
    std::cout << "103 Redirect\nURI: " << Queue->Uri << "\n"
             << "New-URI: " << NewURI << "\n"
             << "\n" << std::flush;
 void pkgAcqMethod::Redirect(const string &NewURI)
 {
    std::cout << "103 Redirect\nURI: " << Queue->Uri << "\n"
             << "New-URI: " << NewURI << "\n"
             << "\n" << std::flush;
-
-   // Change the URI for the request.
-   Queue->Uri = NewURI;
-
-   /* To keep the pipeline synchronized, move the current request to
-      the end of the queue, past the end of the current pipeline. */
-   FetchItem *I;
-   for (I = Queue; I->Next != 0; I = I->Next) ;
-   I->Next = Queue;
-   Queue = Queue->Next;
-   I->Next->Next = 0;
-   if (QueueBack == 0)
-      QueueBack = I->Next;
+   Dequeue();
 }
                                                                         /*}}}*/
 // AcqMethod::FetchResult::FetchResult - Constructor                   /*{{{*/
 }
                                                                         /*}}}*/
 // AcqMethod::FetchResult::FetchResult - Constructor                   /*{{{*/
@@ -463,3 +442,11 @@ void pkgAcqMethod::FetchResult::TakeHashes(Hashes &Hash)
    SHA512Sum = Hash.SHA512.Result();
 }
                                                                        /*}}}*/
    SHA512Sum = Hash.SHA512.Result();
 }
                                                                        /*}}}*/
+void pkgAcqMethod::Dequeue() {                                         /*{{{*/
+   FetchItem const * const Tmp = Queue;
+   Queue = Queue->Next;
+   if (Tmp == QueueBack)
+      QueueBack = Queue;
+   delete Tmp;
+}
+                                                                       /*}}}*/