]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/tagfile.cc
Patchs for apt-cdrom
[apt.git] / apt-pkg / tagfile.cc
index 50d669977df6c24da063c0717d9c378ccf90f5f7..a55d5214a86bd6356ee09dcca30f0b058172b9d6 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: tagfile.cc,v 1.11 1998/10/02 04:39:48 jgg Exp $
+// $Id: tagfile.cc,v 1.15 1998/11/27 01:14:06 jgg Exp $
 /* ######################################################################
 
    Fast scanner for RFC-822 type header information
@@ -45,10 +45,7 @@ bool pkgTagFile::Step(pkgTagSection &Tag)
         return false;
       
       if (Tag.Scan(Start,End - Start) == false)
-      {
-        cout << string(Start,End-Start) << endl;
         return _error->Error("Unable to parse package file");
-      }      
    }   
    Start += Tag.size();
    iOffset += Tag.size();
@@ -75,11 +72,12 @@ bool pkgTagFile::Fill()
    Start = Buffer;
    End = Buffer + EndSize;
    
-   // See if only a bit of the file is left 
-   if (Left < Size)
+   // See if only a bit of the file is left
+   if (Left < Size - (End - Buffer))
    {
       if (Fd.Read(End,Left) == false)
         return false;
+      
       End += Left;
       Left = 0;
    }
@@ -87,6 +85,7 @@ bool pkgTagFile::Fill()
    {
       if (Fd.Read(End,Size - (End - Buffer)) == false)
         return false;
+      
       Left -= Size - (End - Buffer);
       End = Buffer + Size;
    }   
@@ -95,7 +94,8 @@ bool pkgTagFile::Fill()
                                                                        /*}}}*/
 // TagFile::Jump - Jump to a pre-recorded location in the file         /*{{{*/
 // ---------------------------------------------------------------------
-/* This jumps to a pre-recorded file location and */
+/* This jumps to a pre-recorded file location and reads the record
+   that is there */
 bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset)
 {
    iOffset = Offset;
@@ -180,3 +180,28 @@ bool pkgTagSection::Find(const char *Tag,const char *&Start,
    return false;
 }
                                                                        /*}}}*/
+// pkgTagSection::FindS - Find a string                                        /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string pkgTagSection::FindS(const char *Tag)
+{
+   const char *Start;
+   const char *End;
+   if (Find(Tag,Start,End) == false)
+      return string();
+   return string(Start,End);      
+}
+                                                                       /*}}}*/
+// TagSection::FindI - Find an integer                                 /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+unsigned int pkgTagSection::FindI(const char *Tag)
+{
+   const char *Start;
+   const char *End;
+   if (Find(Tag,Start,End) == false)
+      return 0;
+   
+   return atoi(string(Start,End).c_str());
+}
+                                                                       /*}}}*/