Final testing
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:50:39 +0000 (16:50 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:50:39 +0000 (16:50 +0000)
Author: jgg
Date: 1998-07-05 05:33:52 GMT
Final testing

apt-pkg/cacheiterators.h
apt-pkg/deb/deblistparser.cc
apt-pkg/deb/deblistparser.h
apt-pkg/pkgcache.cc
apt-pkg/pkgcache.h
apt-pkg/pkgcachegen.cc
apt-pkg/pkgcachegen.h
apt-pkg/tagfile.cc
apt-pkg/tagfile.h

index 17d2be8..f12491f 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: cacheiterators.h,v 1.2 1998/07/04 05:57:34 jgg Exp $
+// $Id: cacheiterators.h,v 1.3 1998/07/05 05:33:52 jgg Exp $
 /* ######################################################################
    
    Cache Iterators - Iterators for navigating the cache structure
@@ -113,11 +113,11 @@ class pkgCache::VerIterator
    inline operator Version const *() const {return Ver == Owner.VerP?0:Ver;};
    inline const char *VerStr() const {return Ver->VerStr == 0?0:Owner.StrP + Ver->VerStr;};
    inline const char *Section() const {return Ver->Section == 0?0:Owner.StrP + Ver->Section;};
-   inline PkgFileIterator File() const;
    inline PkgIterator ParentPkg() const {return PkgIterator(Owner,Owner.PkgP + Ver->ParentPkg);};
    inline DepIterator DependsList() const;
    inline PrvIterator ProvidesList() const;
    inline unsigned long Index() const {return Ver - Owner.VerP;};
+   inline VerFileIterator FileList() const;
 
    inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Ver(Trg), Owner(Owner) 
    { 
@@ -265,6 +265,36 @@ class pkgCache::PkgFileIterator
    inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Owner(&Owner), File(Trg) {};
 };
 
+// Version File 
+class pkgCache::VerFileIterator
+{
+   pkgCache *Owner;
+   VerFile *FileP;
+
+   public:
+
+   // Iteration
+   void operator ++(int) {if (FileP != Owner->VerFileP) FileP = Owner->VerFileP + FileP->NextFile;};
+   inline void operator ++() {operator ++(0);};
+   inline bool end() const {return FileP == Owner->VerFileP?true:false;};
+
+   // Comparison
+   inline bool operator ==(const VerFileIterator &B) const {return FileP == B.FileP;};
+   inline bool operator !=(const VerFileIterator &B) const {return FileP != B.FileP;};
+                          
+   // Accessors
+   inline VerFile *operator ->() {return FileP;};
+   inline VerFile const *operator ->() const {return FileP;};
+   inline VerFile const &operator *() const {return *FileP;};
+   inline operator VerFile *() {return FileP == Owner->VerFileP?0:FileP;};
+   inline operator VerFile const *() const {return FileP == Owner->VerFileP?0:FileP;};
+  
+   inline PkgFileIterator File() const {return PkgFileIterator(*Owner,FileP->File + Owner->PkgFileP);};
+   inline unsigned long Index() const {return FileP - Owner->VerFileP;};
+
+   inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Owner(&Owner), FileP(Trg) {};
+};
+
 // Inlined Begin functions cant be in the class because of order problems
 inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const
        {return VerIterator(*Owner,Owner->VerP + Pkg->VersionList);};
@@ -280,7 +310,7 @@ inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const
        {return PrvIterator(Owner,Owner.ProvideP + Ver->ProvidesList,Ver);};
 inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const
        {return DepIterator(Owner,Owner.DepP + Ver->DependsList,Ver);};
-inline pkgCache::PkgFileIterator pkgCache::VerIterator::File() const
-       {return PkgFileIterator(Owner,Owner.PkgFileP + Ver->File);};
+inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const
+       {return VerFileIterator(Owner,Owner.VerFileP + Ver->FileList);};
 
 #endif
index 97ee881..4c37eb7 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: deblistparser.cc,v 1.2 1998/07/04 22:32:17 jgg Exp $
+// $Id: deblistparser.cc,v 1.3 1998/07/05 05:34:00 jgg Exp $
 /* ######################################################################
    
    Package Cache Generator - Generator for the cache structure.
@@ -124,16 +124,6 @@ string debListParser::Version()
    return FindTag("Version");
 }
                                                                        /*}}}*/
-// ListParser::NewPackage - Fill in the package structure              /*{{{*/
-// ---------------------------------------------------------------------
-/* This is called when a new package structure is created. It must fill
-   in the static package information. */
-bool debListParser::NewPackage(pkgCache::PkgIterator Pkg)
-{
-   // Debian doesnt have anything, everything is condionally megered
-   return true;
-}
-                                                                       /*}}}*/
 // ListParser::NewVersion - Fill in the version structure              /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -166,6 +156,22 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
                   _count(PrioList),Ver->Priority) == false)
         return _error->Error("Malformed Priority line");
    }
+
+   if (ParseDepends(Ver,"Depends",pkgCache::Depends) == false)
+      return false;
+   if (ParseDepends(Ver,"PreDepends",pkgCache::PreDepends) == false)
+      return false;
+   if (ParseDepends(Ver,"Suggests",pkgCache::Suggests) == false)
+      return false;
+   if (ParseDepends(Ver,"Recommends",pkgCache::Recommends) == false)
+      return false;
+   if (ParseDepends(Ver,"Conflicts",pkgCache::Conflicts) == false)
+      return false;
+   if (ParseDepends(Ver,"Replaces",pkgCache::Depends) == false)
+      return false;
+
+   if (ParseProvides(Ver) == false)
+      return false;
    
    return true;
 }
@@ -189,7 +195,7 @@ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg,
    return true;
 }
                                                                        /*}}}*/
-// ListParser::ParseStatus - Parse the status feild                    /*{{{*/
+// ListParser::ParseStatus - Parse the status field                    /*{{{*/
 // ---------------------------------------------------------------------
 /* Status lines are of the form,
      Status: want flag status
@@ -276,6 +282,187 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator Pkg,
         Pkg->CurrentVer = Ver.Index();
    }
    
+   return true;
+}
+                                                                       /*}}}*/
+// ListParser::ParseDepends - Parse a dependency element               /*{{{*/
+// ---------------------------------------------------------------------
+/* This parses the dependency elements out of a standard string in place,
+   bit by bit. */
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+                                       string &Package,string &Ver,
+                                       unsigned int &Op)
+{
+   // Strip off leading space
+   for (;Start != Stop && isspace(*Start) != 0; Start++);
+   
+   // Parse off the package name
+   const char *I = Start;
+   for (;I != Stop && isspace(*I) == 0 && *I != '(' && *I != ')' &&
+       *I != ',' && *I != '|'; I++);
+   
+   // Malformed, no '('
+   if (I != Stop && *I == ')')
+      return 0;
+
+   if (I == Start)
+      return 0;
+   
+   // Stash the package name
+   Package.assign(Start,I - Start);
+   
+   // Skip white space to the '('
+   for (;I != Stop && isspace(*I) != 0 ; I++);
+   
+   // Parse a version
+   if (I != Stop && *I == '(')
+   {
+      // Skip the '('
+      for (I++; I != Stop && isspace(*I) != 0 ; I++);
+      if (I + 3 >= Stop)
+        return 0;
+      
+      // Determine the operator
+      switch (*I)
+      {
+        case '<':
+        I++;
+        if (*I == '=')
+        {
+           I++;
+           Op = pkgCache::LessEq;
+           break;
+        }
+        
+        if (*I == '<')
+        {
+           I++;
+           Op = pkgCache::Less;
+           break;
+        }
+        
+        // < is the same as <= and << is really Cs < for some reason
+        Op = pkgCache::LessEq;
+        break;
+        
+        case '>':
+        I++;
+        if (*I == '=')
+        {
+           I++;
+           Op = pkgCache::GreaterEq;
+           break;
+        }
+        
+        if (*I == '>')
+        {
+           I++;
+           Op = pkgCache::Greater;
+           break;
+        }
+        
+        // > is the same as >= and >> is really Cs > for some reason
+        Op = pkgCache::GreaterEq;
+        break;
+        
+        case '=':
+        Op = pkgCache::Equals;
+        I++;
+        break;
+        
+        // HACK around bad package definitions
+        default:
+        Op = pkgCache::Equals;
+        break;
+      }
+      
+      // Skip whitespace
+      for (;I != Stop && isspace(*I) != 0; I++);
+      Start = I;
+      for (;I != Stop && *I != ')'; I++);
+      if (I == Stop || Start == I)
+        return 0;     
+      
+      Ver = string(Start,I-Start);
+      I++;
+   }
+   else
+   {
+      Ver = string();
+      Op = pkgCache::NoOp;
+   }
+   
+   // Skip whitespace
+   for (;I != Stop && isspace(*I) != 0; I++);
+   if (I != Stop && *I == '|')
+      Op |= pkgCache::Or;
+   
+   if (I == Stop || *I == ',' || *I == '|')
+   {
+      if (I != Stop)
+        for (I++; I != Stop && isspace(*I) != 0; I++);
+      return I;
+   }
+   
+   return 0;
+}
+                                                                       /*}}}*/
+// ListParser::ParseDepends - Parse a dependency list                  /*{{{*/
+// ---------------------------------------------------------------------
+/* This is the higher level depends parser. It takes a tag and generates
+   a complete depends tree for the given version. */
+bool debListParser::ParseDepends(pkgCache::VerIterator Ver,
+                                const char *Tag,unsigned int Type)
+{
+   const char *Start;
+   const char *Stop;
+   if (Section.Find(Tag,Start,Stop) == false)
+      return true;
+   
+   string Package;
+   string Version;
+   unsigned int Op;
+
+   while ((Start = ParseDepends(Start,Stop,Package,Version,Op)) != Stop)
+   {
+      if (Start == 0)
+        return _error->Error("Problem parsing dependency %s",Tag);
+
+      if (NewDepends(Ver,Package,Version,Op,Type) == false)
+        return false;
+   }
+   return true;
+}
+                                                                       /*}}}*/
+// ListParser::ParseProvides - Parse the provides list                 /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool debListParser::ParseProvides(pkgCache::VerIterator Ver)
+{
+   const char *Start;
+   const char *Stop;
+   if (Section.Find("Provides",Start,Stop) == false)
+      return true;
+   
+   string Package;
+   string Version;
+   unsigned int Op;
+
+   while (1)
+   {
+      Start = ParseDepends(Start,Stop,Package,Version,Op);
+      if (Start == 0)
+        return _error->Error("Problem parsing Provides line");
+      if (Op != pkgCache::NoOp)
+        return _error->Error("Malformed provides line");
+
+      if (NewProvides(Ver,Package,Version) == false)
+        return false;
+
+      if (Start == Stop)
+        break;
+   }
+   
    return true;
 }
                                                                        /*}}}*/
@@ -301,6 +488,7 @@ bool debListParser::GrabWord(string Word,WordList *List,int Count,
 /* This has to be carefull to only process the correct architecture */
 bool debListParser::Step()
 {
+   iOffset = Tags.Offset();
    while (Tags.Step(Section) == true)
    {
       /* See if this is the correct Architecture, if it isnt then we
@@ -317,6 +505,8 @@ bool debListParser::Step()
       if (strncmp(Start,"all",Stop - Start) == 0 &&
          3 == (unsigned)(Stop - Start))
         return true;
+
+      iOffset = Tags.Offset();
    }   
    return false;
 }
index a458eb6..c7a97c1 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: deblistparser.h,v 1.2 1998/07/04 22:32:18 jgg Exp $
+// $Id: deblistparser.h,v 1.3 1998/07/05 05:34:01 jgg Exp $
 /* ######################################################################
    
    Debian Package List Parser - This implements the abstract parser 
@@ -19,6 +19,7 @@ class debListParser : public pkgCacheGenerator::ListParser
 {
    pkgTagFile Tags;
    pkgTagSection Section;
+   unsigned long iOffset;
    
    // Parser Helper
    struct WordList
@@ -32,6 +33,11 @@ class debListParser : public pkgCacheGenerator::ListParser
    unsigned long UniqFindTagWrite(const char *Tag);
    bool HandleFlag(const char *Tag,unsigned long &Flags,unsigned long Flag);
    bool ParseStatus(pkgCache::PkgIterator Pkg,pkgCache::VerIterator Ver);
+   const char *ParseDepends(const char *Start,const char *Stop,
+                           string &Package,string &Ver,unsigned int &Op);
+   bool ParseDepends(pkgCache::VerIterator Ver,const char *Tag,
+                    unsigned int Type);
+   bool ParseProvides(pkgCache::VerIterator Ver);
    bool GrabWord(string Word,WordList *List,int Count,unsigned char &Out);
    
    public:
@@ -40,9 +46,10 @@ class debListParser : public pkgCacheGenerator::ListParser
    virtual string Package();
    virtual string Version();
    virtual bool NewVersion(pkgCache::VerIterator Ver);
-   virtual bool NewPackage(pkgCache::PkgIterator Pkg);
    virtual bool UsePackage(pkgCache::PkgIterator Pkg,
                           pkgCache::VerIterator Ver);
+   virtual unsigned long Offset() {return iOffset;};
+   virtual unsigned long Size() {return Section.size();};
 
    virtual bool Step();
    
index e2602c8..b9dbf34 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcache.cc,v 1.3 1998/07/04 22:32:11 jgg Exp $
+// $Id: pkgcache.cc,v 1.4 1998/07/05 05:33:53 jgg Exp $
 /* ######################################################################
    
    Package Cache - Accessor code for the cache
@@ -49,7 +49,8 @@ pkgCache::Header::Header()
    VersionSz = sizeof(pkgCache::Version);
    DependencySz = sizeof(pkgCache::Dependency);
    ProvidesSz = sizeof(pkgCache::Provides);
-
+   VerFileSz = sizeof(pkgCache::VerFile);
+   
    PackageCount = 0;
    VersionCount = 0;
    DependsCount = 0;
@@ -70,7 +71,8 @@ bool pkgCache::Header::CheckSizes(Header &Against) const
        PackageSz == Against.PackageSz &&
        PackageFileSz == Against.PackageFileSz &&
        VersionSz == Against.VersionSz &&
-       DependencySz == Against.DependencySz && 
+       DependencySz == Against.DependencySz &&
+       VerFileSz == Against.VerFileSz &&
        ProvidesSz == Against.ProvidesSz)
       return true;
    return false;
@@ -93,6 +95,7 @@ bool pkgCache::ReMap()
    // Apply the typecasts.
    HeaderP = (Header *)Map.Data();
    PkgP = (Package *)Map.Data();
+   VerFileP = (VerFile *)Map.Data();
    PkgFileP = (PackageFile *)Map.Data();
    VerP = (Version *)Map.Data();
    ProvideP = (Provides *)Map.Data();
@@ -100,7 +103,6 @@ bool pkgCache::ReMap()
    StringItemP = (StringItem *)Map.Data();
    StrP = (char *)Map.Data();
 
-   cout << "Size is " << Map.Size() << endl;
    if (Map.Size() == 0)
       return false;
    
index 3324a2a..836418c 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcache.h,v 1.3 1998/07/04 22:32:12 jgg Exp $
+// $Id: pkgcache.h,v 1.4 1998/07/05 05:33:55 jgg Exp $
 /* ######################################################################
    
    Cache - Structure definitions for the cache file
@@ -35,6 +35,7 @@ class pkgCache
    struct Provides;
    struct Dependency;
    struct StringItem;
+   struct VerFile;
    
    // Iterators
    class PkgIterator;
@@ -42,12 +43,14 @@ class pkgCache
    class DepIterator;
    class PrvIterator;
    class PkgFileIterator;
+   class VerFileIterator;
    friend PkgIterator;
    friend VerIterator;
    friend DepIterator;
    friend PrvIterator;
    friend PkgFileIterator;
-
+   friend VerFileIterator;
+   
    // These are all the constants used in the cache structures
    enum DepType {Depends=1,PreDepends=2,Suggests=3,Recommends=4,
                  Conflicts=5,Replaces=6};
@@ -60,7 +63,7 @@ class pkgCache
                          UnInstalled=3,HalfInstalled=4,ConfigFiles=5,
                          Installed=6};
    enum PkgFFlags {NotSource=(1<<0)};
-   enum DepCompareOp {Or=0x10,LessEq=0x1,GreaterEq=0x2,Less=0x3,
+   enum DepCompareOp {Or=0x10,NoOp=0,LessEq=0x1,GreaterEq=0x2,Less=0x3,
                       Greater=0x4,Equals=0x5,NotEquals=0x6};
    
    protected:
@@ -80,13 +83,14 @@ class pkgCache
    // Pointers to the arrays of items
    Header *HeaderP;
    Package *PkgP;
+   VerFile *VerFileP;
    PackageFile *PkgFileP;
    Version *VerP;
    Provides *ProvideP;
    Dependency *DepP;
    StringItem *StringItemP;
    char *StrP;
-   
+
    virtual bool ReMap();
    inline bool Sync() {return Map.Sync();};
    
@@ -123,7 +127,8 @@ struct pkgCache::Header
    unsigned short VersionSz;
    unsigned short DependencySz;
    unsigned short ProvidesSz;
-
+   unsigned short VerFileSz;
+   
    // Structure counts
    unsigned long PackageCount;
    unsigned long VersionCount;
@@ -136,7 +141,7 @@ struct pkgCache::Header
 
    /* Allocation pools, there should be one of these for each structure
       excluding the header */
-   DynamicMMap::Pool Pools[6];
+   DynamicMMap::Pool Pools[7];
    
    // Rapid package name lookup
    unsigned long HashTable[512];
@@ -184,19 +189,26 @@ struct pkgCache::PackageFile
    time_t mtime;                  // Modification time for the file
 };
 
+struct pkgCache::VerFile
+{
+   unsigned long File;           // PackageFile
+   unsigned long NextFile;       // PkgVerFile
+   unsigned long Offset;
+   unsigned short Size;
+};
+
 struct pkgCache::Version
 {
    unsigned long VerStr;            // Stringtable
-   unsigned long File;              // PackageFile
    unsigned long Section;           // StringTable (StringItem)
    
    // Lists
+   unsigned long FileList;          // VerFile
    unsigned long NextVer;           // Version
    unsigned long DependsList;       // Dependency
    unsigned long ParentPkg;         // Package
    unsigned long ProvidesList;      // Provides
    
-   unsigned long Offset;
    unsigned long Size;
    unsigned long InstalledSize;
    unsigned short ID;
index d3d5d15..634179b 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcachegen.cc,v 1.3 1998/07/04 22:32:13 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.4 1998/07/05 05:33:56 jgg Exp $
 /* ######################################################################
    
    Package Cache Generator - Generator for the cache structure.
@@ -68,9 +68,6 @@ bool pkgCacheGenerator::MergeList(ListParser &List)
       {
         if (NewPackage(Pkg,Package) == false)
            return false;
-
-        if (List.NewPackage(Pkg) == false)
-           return false;
       }
       
       /* Get a pointer to the version structure. We know the list is sorted
@@ -156,6 +153,18 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,string Name)
 bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver,
                                   ListParser &List)
 {
+   // Get a structure
+   unsigned long VerFile = Map.Allocate(sizeof(pkgCache::VerFile));
+   if (VerFile == 0)
+      return 0;
+   
+   pkgCache::VerFileIterator VF(Cache,Cache.VerFileP + VerFile);
+   VF->File = CurrentFile - Cache.PkgFileP;
+   VF->NextFile = Ver->FileList;
+   Ver->FileList = VF.Index();
+   VF->Offset = List.Offset();
+   VF->Size = List.Size();
+      
    return true;
 }
                                                                        /*}}}*/
@@ -173,7 +182,6 @@ unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
    
    // Fill it in
    Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version);
-   Ver->File = CurrentFile - Cache.PkgFileP;
    Ver->NextVer = Next;
    Ver->ID = Cache.HeaderP->VersionCount++;
    Ver->VerStr = Map.WriteString(VerStr);
@@ -183,6 +191,96 @@ unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
    return Version;
 }
                                                                        /*}}}*/
+// ListParser::NewDepends - Create a dependency element                        /*{{{*/
+// ---------------------------------------------------------------------
+/* This creates a dependency element in the tree. It is linked to the
+   version and to the package that it is pointing to. */
+bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver,
+                                              string Package,string Version,
+                                              unsigned int Op,
+                                              unsigned int Type)
+{
+   pkgCache &Cache = Owner->Cache;
+   
+   // Get a structure
+   unsigned long Dependency = Owner->Map.Allocate(sizeof(pkgCache::Dependency));
+   if (Dependency == 0)
+      return false;
+   
+   // Fill it in
+   pkgCache::DepIterator Dep(Cache,Cache.DepP + Dependency);
+   Dep->ParentVer = Ver.Index();
+   Dep->Type = Type;
+   Dep->CompareOp = Op;
+   Dep->ID = Cache.HeaderP->DependsCount++;
+   
+   // Locate the target package
+   pkgCache::PkgIterator Pkg = Cache.FindPkg(Package);
+   if (Pkg.end() == true)
+      if (Owner->NewPackage(Pkg,Package) == false)
+        return false;
+   
+   // Probe the reverse dependency list for a version string that matches
+   if (Version.empty() == false)
+   {
+      for (pkgCache::DepIterator I = Pkg.RevDependsList(); I.end() == false; I++)
+        if (I->Version != 0 && I.TargetVer() == Version)
+           Dep->Version = I->Version;
+      if (Dep->Version == 0)
+        if ((Dep->Version = WriteString(Version)) == 0)
+           return false;
+   }
+   
+   // Link it to the package
+   Dep->Package = Pkg.Index();
+   Dep->NextRevDepends = Pkg->RevDepends;
+   Pkg->RevDepends = Dep.Index();
+   
+   // Link it to the version (at the end of the list)
+   unsigned long *Last = &Ver->DependsList;
+   for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++)
+      Last = &D->NextDepends;
+   Dep->NextDepends = *Last;
+   *Last = Dep.Index();
+   
+   return true;
+}
+                                                                       /*}}}*/
+// ListParser::NewProvides - Create a Provides element                 /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver,
+                                              string Package,string Version)
+{
+   pkgCache &Cache = Owner->Cache;
+   
+   // Get a structure
+   unsigned long Provides = Owner->Map.Allocate(sizeof(pkgCache::Provides));
+   if (Provides == 0)
+      return false;
+   
+   // Fill it in
+   pkgCache::PrvIterator Prv(Cache,Cache.ProvideP + Provides,Cache.PkgP);
+   Prv->Version = Ver.Index();
+   Prv->NextPkgProv = Ver->ProvidesList;
+   Ver->ProvidesList = Prv.Index();
+   if (Version.empty() == false && (Prv->Version = WriteString(Version)) == 0)
+      return false;
+   
+   // Locate the target package
+   pkgCache::PkgIterator Pkg = Cache.FindPkg(Package);
+   if (Pkg.end() == true)
+      if (Owner->NewPackage(Pkg,Package) == false)
+        return false;
+   
+   // Link it to the package
+   Prv->ParentPkg = Pkg.Index();
+   Prv->NextProvides = Pkg->ProvidesList;
+   Pkg->ProvidesList = Prv.Index();
+   
+   return true;
+}
+                                                                       /*}}}*/
 // CacheGenerator::SelectFile - Select the current file being parsed   /*{{{*/
 // ---------------------------------------------------------------------
 /* This is used to select which file is to be associated with all newly
index 6ce1ed8..395afdc 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcachegen.h,v 1.2 1998/07/04 05:57:38 jgg Exp $
+// $Id: pkgcachegen.h,v 1.3 1998/07/05 05:33:57 jgg Exp $
 /* ######################################################################
    
    Package Cache Generator - Generator for the cache structure.
@@ -50,6 +50,10 @@ class pkgCacheGenerator
       inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
       inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
       inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
+      bool NewDepends(pkgCache::VerIterator Ver,string Package,
+                        string Version,unsigned int Op,
+                        unsigned int Type);
+      bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version);
       
       public:
       
@@ -57,11 +61,13 @@ class pkgCacheGenerator
       virtual string Package() = 0;
       virtual string Version() = 0;
       virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
-      virtual bool NewPackage(pkgCache::PkgIterator Pkg) = 0;
       virtual bool UsePackage(pkgCache::PkgIterator Pkg,
                              pkgCache::VerIterator Ver) = 0;
-                                  
+      virtual unsigned long Offset() = 0;
+      virtual unsigned long Size() = 0;
+
       virtual bool Step() = 0;
+      
       virtual ~ListParser() {};
    };
    friend ListParser;
index 6c4bdd9..9710b76 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: tagfile.cc,v 1.3 1998/07/04 22:32:14 jgg Exp $
+// $Id: tagfile.cc,v 1.4 1998/07/05 05:33:58 jgg Exp $
 /* ######################################################################
 
    Fast scanner for RFC-822 type header information
@@ -26,6 +26,7 @@ pkgTagFile::pkgTagFile(File &Fd) : Fd(Fd)
    Buffer = new char[64*1024];
    Start = End = Buffer + 64*1024;
    Left = Fd.Size();
+   iOffset = 0;
    Fill();
 }
                                                                        /*}}}*/
@@ -42,7 +43,9 @@ bool pkgTagFile::Step(pkgTagSection &Tag)
       if (Tag.Scan(Start,End - Start) == false)
         return _error->Error("Unable to parse package file");
    }   
-   Start += Tag.Length();
+   Start += Tag.size();
+   iOffset += Tag.size();
+   
    return true;
 }
                                                                        /*}}}*/
@@ -152,16 +155,20 @@ bool pkgTagSection::Find(const char *Tag,const char *&Start,
 int main(int argc,char *argv[])
 {
    {
-      File F(argv[1],File::ReadOnly);
       File CacheF("./cache",File::WriteEmpty);
       DynamicMMap Map(CacheF,MMap::Public);
       pkgCacheGenerator Gen(Map);
-      Gen.SelectFile(argv[1]);
-      
-      debListParser Parser(F);
-      Gen.MergeList(Parser);
-   }
 
+      for (int I = 1; I != argc; I++)
+      {
+        cout << "Merging in " << argv[I] << endl;
+        File F(argv[I],File::ReadOnly);
+        Gen.SelectFile(argv[I]);
+        debListParser Parser(F);
+        Gen.MergeList(Parser);
+      }      
+   }
+/*
    {
       File CacheF("./cache",File::WriteExists);
       MMap Map(CacheF,MMap::Public | MMap::ReadOnly);
@@ -176,11 +183,20 @@ int main(int argc,char *argv[])
            cout << "Installed-Size: " << V->InstalledSize << endl;
            cout << "Section: " << V.Section() << endl;
            cout << "Priority: " << Cache.Priority(V->Priority) << endl;
-        }       
+           
+           pkgCache::PrvIterator P = V.ProvidesList();
+           if (P.end() == false)
+           {
+              cout << "Provides: ";
+              for (; P.end() == false; P++)
+                 cout << P.Name() << ", ";
+              cout << endl;
+           }       
+        }
         cout << endl;
       }
    }
-   
+*/   
 #if 0 
    pkgTagSection I;
    while (Test.Step(I) == true)
index a7a82dd..661ac4f 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: tagfile.h,v 1.1 1998/07/02 02:58:13 jgg Exp $
+// $Id: tagfile.h,v 1.2 1998/07/05 05:33:59 jgg Exp $
 /* ######################################################################
 
    Fast scanner for RFC-822 type header information
@@ -39,7 +39,7 @@ class pkgTagSection
    
    bool Find(const char *Tag,const char *&Start, const char *&End);
    bool Scan(const char *Start,unsigned long MaxLength);
-   inline unsigned long Length() {return Stop - Section;};
+   inline unsigned long size() {return Stop - Section;};
 
    pkgTagSection() : Section(0), Stop(0) {};
 };
@@ -51,12 +51,14 @@ class pkgTagFile
    char *Start;
    char *End;
    unsigned long Left;
+   unsigned long iOffset;
    
    bool Fill();
    
    public:
 
    bool Step(pkgTagSection &Section);
+   inline unsigned long Offset() {return iOffset;};
    
    pkgTagFile(File &F);
 };