]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/pkgcache.cc
* merged with mainline
[apt.git] / apt-pkg / pkgcache.cc
index ea5c264dc9e9291b35daef30577540f6807484c8..f76afb9357acc94e034f5002f539473b0084fcad 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcache.cc,v 1.33 2001/03/05 02:43:28 jgg Exp $
+// $Id: pkgcache.cc,v 1.37 2003/02/10 01:40:58 doogie Exp $
 /* ######################################################################
    
    Package Cache - Accessor code for the cache
 /* ######################################################################
    
    Package Cache - Accessor code for the cache
 #include <sys/stat.h>
 #include <unistd.h>
 
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include <ctype.h>
 #include <system.h>
 #include <system.h>
-
                                                                        /*}}}*/
 
                                                                        /*}}}*/
 
+using std::string;
+
 // Cache::Header::Header - Constructor                                 /*{{{*/
 // ---------------------------------------------------------------------
 /* Simply initialize the header */
 // Cache::Header::Header - Constructor                                 /*{{{*/
 // ---------------------------------------------------------------------
 /* Simply initialize the header */
@@ -50,25 +52,30 @@ pkgCache::Header::Header()
    
    /* Whenever the structures change the major version should be bumped,
       whenever the generator changes the minor version should be bumped. */
    
    /* Whenever the structures change the major version should be bumped,
       whenever the generator changes the minor version should be bumped. */
-   MajorVersion = 3;
-   MinorVersion = 5;
+   MajorVersion = 5;
+   MinorVersion = 0;
    Dirty = false;
    
    HeaderSz = sizeof(pkgCache::Header);
    PackageSz = sizeof(pkgCache::Package);
    PackageFileSz = sizeof(pkgCache::PackageFile);
    VersionSz = sizeof(pkgCache::Version);
    Dirty = false;
    
    HeaderSz = sizeof(pkgCache::Header);
    PackageSz = sizeof(pkgCache::Package);
    PackageFileSz = sizeof(pkgCache::PackageFile);
    VersionSz = sizeof(pkgCache::Version);
+   DescriptionSz = sizeof(pkgCache::Description);
    DependencySz = sizeof(pkgCache::Dependency);
    ProvidesSz = sizeof(pkgCache::Provides);
    VerFileSz = sizeof(pkgCache::VerFile);
    DependencySz = sizeof(pkgCache::Dependency);
    ProvidesSz = sizeof(pkgCache::Provides);
    VerFileSz = sizeof(pkgCache::VerFile);
+   DescFileSz = sizeof(pkgCache::DescFile);
    
    PackageCount = 0;
    VersionCount = 0;
    
    PackageCount = 0;
    VersionCount = 0;
+   DescriptionCount = 0;
    DependsCount = 0;
    PackageFileCount = 0;
    VerFileCount = 0;
    DependsCount = 0;
    PackageFileCount = 0;
    VerFileCount = 0;
+   DescFileCount = 0;
    ProvidesCount = 0;
    MaxVerFileSize = 0;
    ProvidesCount = 0;
    MaxVerFileSize = 0;
+   MaxDescFileSize = 0;
    
    FileList = 0;
    StringList = 0;
    
    FileList = 0;
    StringList = 0;
@@ -87,8 +94,10 @@ bool pkgCache::Header::CheckSizes(Header &Against) const
        PackageSz == Against.PackageSz &&
        PackageFileSz == Against.PackageFileSz &&
        VersionSz == Against.VersionSz &&
        PackageSz == Against.PackageSz &&
        PackageFileSz == Against.PackageFileSz &&
        VersionSz == Against.VersionSz &&
+       DescriptionSz == Against.DescriptionSz &&
        DependencySz == Against.DependencySz &&
        VerFileSz == Against.VerFileSz &&
        DependencySz == Against.DependencySz &&
        VerFileSz == Against.VerFileSz &&
+       DescFileSz == Against.DescFileSz &&
        ProvidesSz == Against.ProvidesSz)
       return true;
    return false;
        ProvidesSz == Against.ProvidesSz)
       return true;
    return false;
@@ -113,8 +122,10 @@ bool pkgCache::ReMap()
    HeaderP = (Header *)Map.Data();
    PkgP = (Package *)Map.Data();
    VerFileP = (VerFile *)Map.Data();
    HeaderP = (Header *)Map.Data();
    PkgP = (Package *)Map.Data();
    VerFileP = (VerFile *)Map.Data();
+   DescFileP = (DescFile *)Map.Data();
    PkgFileP = (PackageFile *)Map.Data();
    VerP = (Version *)Map.Data();
    PkgFileP = (PackageFile *)Map.Data();
    VerP = (Version *)Map.Data();
+   DescP = (Description *)Map.Data();
    ProvideP = (Provides *)Map.Data();
    DepP = (Dependency *)Map.Data();
    StringItemP = (StringItem *)Map.Data();
    ProvideP = (Provides *)Map.Data();
    DepP = (Dependency *)Map.Data();
    StringItemP = (StringItem *)Map.Data();
@@ -137,12 +148,12 @@ bool pkgCache::ReMap()
    // Locate our VS..
    if (HeaderP->VerSysName == 0 ||
        (VS = pkgVersioningSystem::GetVS(StrP + HeaderP->VerSysName)) == 0)
    // Locate our VS..
    if (HeaderP->VerSysName == 0 ||
        (VS = pkgVersioningSystem::GetVS(StrP + HeaderP->VerSysName)) == 0)
-      return _error->Error(_("This APT does not support the Versioning System '%s'"),StrP + HeaderP->VerSysName);
+      return _error->Error(_("This APT does not support the versioning system '%s'"),StrP + HeaderP->VerSysName);
 
    // Chcek the arhcitecture
    if (HeaderP->Architecture == 0 ||
        _config->Find("APT::Architecture") != StrP + HeaderP->Architecture)
 
    // Chcek the arhcitecture
    if (HeaderP->Architecture == 0 ||
        _config->Find("APT::Architecture") != StrP + HeaderP->Architecture)
-      return _error->Error(_("The package cache was build for a different architecture"));
+      return _error->Error(_("The package cache was built for a different architecture"));
    return true;
 }
                                                                        /*}}}*/
    return true;
 }
                                                                        /*}}}*/
@@ -154,7 +165,7 @@ bool pkgCache::ReMap()
 unsigned long pkgCache::sHash(string Str) const
 {
    unsigned long Hash = 0;
 unsigned long pkgCache::sHash(string Str) const
 {
    unsigned long Hash = 0;
-   for (const char *I = Str.begin(); I != Str.end(); I++)
+   for (string::const_iterator I = Str.begin(); I != Str.end(); I++)
       Hash = 5*Hash + tolower(*I);
    return Hash % _count(HeaderP->HashTable);
 }
       Hash = 5*Hash + tolower(*I);
    return Hash % _count(HeaderP->HashTable);
 }
@@ -178,7 +189,7 @@ pkgCache::PkgIterator pkgCache::FindPkg(string Name)
    for (; Pkg != PkgP; Pkg = PkgP + Pkg->NextPackage)
    {
       if (Pkg->Name != 0 && StrP[Pkg->Name] == Name[0] &&
    for (; Pkg != PkgP; Pkg = PkgP + Pkg->NextPackage)
    {
       if (Pkg->Name != 0 && StrP[Pkg->Name] == Name[0] &&
-         stringcasecmp(Name.begin(),Name.end(),StrP + Pkg->Name) == 0)
+         stringcasecmp(Name,StrP + Pkg->Name) == 0)
         return PkgIterator(*this,Pkg);
    }
    return PkgIterator(*this,0);
         return PkgIterator(*this,Pkg);
    }
    return PkgIterator(*this,0);
@@ -233,11 +244,11 @@ const char *pkgCache::Priority(unsigned char Prio)
    return 0;
 }
                                                                        /*}}}*/
    return 0;
 }
                                                                        /*}}}*/
-
 // Bases for iterator classes                                          /*{{{*/
 void pkgCache::VerIterator::_dummy() {}
 void pkgCache::DepIterator::_dummy() {}
 void pkgCache::PrvIterator::_dummy() {}
 // Bases for iterator classes                                          /*{{{*/
 void pkgCache::VerIterator::_dummy() {}
 void pkgCache::DepIterator::_dummy() {}
 void pkgCache::PrvIterator::_dummy() {}
+void pkgCache::DescIterator::_dummy() {}
                                                                        /*}}}*/
 // PkgIterator::operator ++ - Postfix incr                             /*{{{*/
 // ---------------------------------------------------------------------
                                                                        /*}}}*/
 // PkgIterator::operator ++ - Postfix incr                             /*{{{*/
 // ---------------------------------------------------------------------
@@ -578,3 +589,22 @@ bool pkgCache::PkgFileIterator::IsOk()
    return true;
 }
                                                                        /*}}}*/
    return true;
 }
                                                                        /*}}}*/
+// PkgFileIterator::RelStr - Return the release string                 /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string pkgCache::PkgFileIterator::RelStr()
+{
+   string Res;
+   if (Version() != 0)
+      Res = Res + (Res.empty() == true?"v=":",v=") + Version();
+   if (Origin() != 0)
+      Res = Res + (Res.empty() == true?"o=":",o=")  + Origin();
+   if (Archive() != 0)
+      Res = Res + (Res.empty() == true?"a=":",a=")  + Archive();
+   if (Label() != 0)
+      Res = Res + (Res.empty() == true?"l=":",l=")  + Label();
+   if (Component() != 0)
+      Res = Res + (Res.empty() == true?"c=":",c=")  + Component();
+   return Res;
+}
+                                                                       /*}}}*/