summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/contrib/mmap.cc5
-rw-r--r--apt-pkg/deb/deblistparser.cc78
-rw-r--r--apt-pkg/deb/deblistparser.h3
-rw-r--r--apt-pkg/pkgcache.cc13
-rw-r--r--apt-pkg/pkgcache.h5
-rw-r--r--apt-pkg/pkgcachegen.cc26
-rw-r--r--apt-pkg/tagfile.cc15
7 files changed, 119 insertions, 26 deletions
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index 9febc5cdd..41ea02aec 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: mmap.cc,v 1.2 1998/07/04 05:57:42 jgg Exp $
+// $Id: mmap.cc,v 1.3 1998/07/04 22:32:15 jgg Exp $
/* ######################################################################
MMap Class - Provides 'real' mmap or a faked mmap using read().
@@ -94,7 +94,8 @@ bool MMap::Close(bool DoClose)
/*}}}*/
// MMap::Sync - Syncronize the map with the disk /*{{{*/
// ---------------------------------------------------------------------
-/* */
+/* This is done in syncronous mode - the docs indicate that this will
+ not return till all IO is complete */
bool MMap::Sync()
{
if ((Flags & ReadOnly) == ReadOnly)
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 28298aa36..97ee88183 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: deblistparser.cc,v 1.1 1998/07/04 05:58:08 jgg Exp $
+// $Id: deblistparser.cc,v 1.2 1998/07/04 22:32:17 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -20,7 +20,6 @@
/* */
debListParser::debListParser(File &File) : Tags(File)
{
- Step();
}
/*}}}*/
// ListParser::FindTag - Find the tag and return a string /*{{{*/
@@ -35,6 +34,30 @@ string debListParser::FindTag(const char *Tag)
return string(Start,Stop - Start);
}
/*}}}*/
+// ListParser::FindTagI - Find the tag and return an int /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+signed long debListParser::FindTagI(const char *Tag,signed long Default)
+{
+ const char *Start;
+ const char *Stop;
+ if (Section.Find(Tag,Start,Stop) == false)
+ return Default;
+
+ // Copy it into a temp buffer so we can use strtol
+ char S[300];
+ if ((unsigned)(Stop - Start) >= sizeof(S))
+ return Default;
+ strncpy(S,Start,Stop-Start);
+ S[Stop - Start] = 0;
+
+ char *End;
+ signed long Result = strtol(S,&End,10);
+ if (S == End)
+ return Default;
+ return Result;
+}
+ /*}}}*/
// ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -115,7 +138,35 @@ bool debListParser::NewPackage(pkgCache::PkgIterator Pkg)
// ---------------------------------------------------------------------
/* */
bool debListParser::NewVersion(pkgCache::VerIterator Ver)
-{
+{
+ // Parse the section
+ if ((Ver->Section = UniqFindTagWrite("Section")) == 0)
+ return _error->Warning("Missing Section tag");
+
+ // Archive Size
+ if ((Ver->Size = (unsigned)FindTagI("Size")) == 0)
+ return _error->Error("Unparsable Size field");
+
+ // Unpacked Size (in K)
+ if ((Ver->InstalledSize = (unsigned)FindTagI("Installed-Size")) == 0)
+ return _error->Error("Unparsable Installed-Size field");
+ Ver->InstalledSize *= 1024;
+
+ // Priority
+ const char *Start;
+ const char *Stop;
+ if (Section.Find("Priority",Start,Stop) == true)
+ {
+ WordList PrioList[] = {{"important",pkgCache::Important},
+ {"required",pkgCache::Required},
+ {"standard",pkgCache::Standard},
+ {"optional",pkgCache::Optional},
+ {"extra",pkgCache::Extra}};
+ if (GrabWord(string(Start,Stop-Start),PrioList,
+ _count(PrioList),Ver->Priority) == false)
+ return _error->Error("Malformed Priority line");
+ }
+
return true;
}
/*}}}*/
@@ -247,9 +298,26 @@ bool debListParser::GrabWord(string Word,WordList *List,int Count,
/*}}}*/
// ListParser::Step - Move to the next section in the file /*{{{*/
// ---------------------------------------------------------------------
-/* */
+/* This has to be carefull to only process the correct architecture */
bool debListParser::Step()
{
- return Tags.Step(Section);
+ while (Tags.Step(Section) == true)
+ {
+ /* See if this is the correct Architecture, if it isnt then we
+ drop the whole section */
+ const char *Start;
+ const char *Stop;
+ if (Section.Find("Architecture",Start,Stop) == false)
+ return true;
+
+ if (strncmp(Start,"i386",Stop - Start) == 0 &&
+ strlen("i386") == (unsigned)(Stop - Start))
+ return true;
+
+ if (strncmp(Start,"all",Stop - Start) == 0 &&
+ 3 == (unsigned)(Stop - Start))
+ return true;
+ }
+ return false;
}
/*}}}*/
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 30eb869ad..a458eb60c 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: deblistparser.h,v 1.1 1998/07/04 05:58:08 jgg Exp $
+// $Id: deblistparser.h,v 1.2 1998/07/04 22:32:18 jgg Exp $
/* ######################################################################
Debian Package List Parser - This implements the abstract parser
@@ -28,6 +28,7 @@ class debListParser : public pkgCacheGenerator::ListParser
};
string FindTag(const char *Tag);
+ signed long FindTagI(const char *Tag,signed long Default = 0);
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);
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index fa0c363f7..e2602c88f 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcache.cc,v 1.2 1998/07/04 05:57:35 jgg Exp $
+// $Id: pkgcache.cc,v 1.3 1998/07/04 22:32:11 jgg Exp $
/* ######################################################################
Package Cache - Accessor code for the cache
@@ -158,6 +158,17 @@ pkgCache::PkgIterator pkgCache::FindPkg(string Name)
return PkgIterator(*this,0);
}
/*}}}*/
+// Cache::Priority - Convert a priority value to a string /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+const char *pkgCache::Priority(unsigned char Prio)
+{
+ const char *Mapping[] = {0,"important","required","standard","optional","extra"};
+ if (Prio < _count(Mapping))
+ return Mapping[Prio];
+ return 0;
+}
+ /*}}}*/
// Bases for iterator classes /*{{{*/
void pkgCache::VerIterator::_dummy() {}
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index c8fe3a8de..3324a2aa2 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcache.h,v 1.2 1998/07/04 05:57:36 jgg Exp $
+// $Id: pkgcache.h,v 1.3 1998/07/04 22:32:12 jgg Exp $
/* ######################################################################
Cache - Structure definitions for the cache file
@@ -94,6 +94,9 @@ class pkgCache
inline unsigned long Hash(string S) const {return sHash(S);};
inline unsigned long Hash(const char *S) const {return sHash(S);};
+ // Usefull transformation things
+ const char *Priority(unsigned char Priority);
+
// Accessors
PkgIterator FindPkg(string Name);
Header &Head() {return *HeaderP;};
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 8a5423e69..d3d5d1547 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcachegen.cc,v 1.2 1998/07/04 05:57:37 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.3 1998/07/04 22:32:13 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -58,7 +58,8 @@ pkgCacheGenerator::~pkgCacheGenerator()
bool pkgCacheGenerator::MergeList(ListParser &List)
{
List.Owner = this;
- do
+
+ while (List.Step() == true)
{
// Get a pointer to the package structure
string Package = List.Package();
@@ -112,15 +113,14 @@ bool pkgCacheGenerator::MergeList(ListParser &List)
Ver->ParentPkg = Pkg.Index();
if (List.NewVersion(Ver) == false)
return false;
-
+
if (List.UsePackage(Pkg,Ver) == false)
return false;
if (NewFileVer(Ver,List) == false)
return false;
}
- while (List.Step() == true);
-
+
return true;
}
/*}}}*/
@@ -169,7 +169,7 @@ unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
// Get a structure
unsigned long Version = Map.Allocate(sizeof(pkgCache::Version));
if (Version == 0)
- return false;
+ return 0;
// Fill it in
Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version);
@@ -178,9 +178,9 @@ unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
Ver->ID = Cache.HeaderP->VersionCount++;
Ver->VerStr = Map.WriteString(VerStr);
if (Ver->VerStr == 0)
- return false;
+ return 0;
- return true;
+ return Version;
}
/*}}}*/
// CacheGenerator::SelectFile - Select the current file being parsed /*{{{*/
@@ -233,21 +233,21 @@ unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
// Match
if (Res == 0)
- return I - Cache.StringItemP;
+ return I->String;
// Get a structure
unsigned long Item = Map.Allocate(sizeof(pkgCache::StringItem));
if (Item == 0)
- return false;
-
+ return 0;
+
// Fill in the structure
pkgCache::StringItem *ItemP = Cache.StringItemP + Item;
ItemP->NextItem = I - Cache.StringItemP;
*Last = Item;
ItemP->String = Map.WriteString(S,Size);
if (ItemP->String == 0)
- return false;
+ return 0;
- return true;
+ return ItemP->String;
}
/*}}}*/
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 62d66590b..6c4bdd9ac 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: tagfile.cc,v 1.2 1998/07/04 05:57:39 jgg Exp $
+// $Id: tagfile.cc,v 1.3 1998/07/04 22:32:14 jgg Exp $
/* ######################################################################
Fast scanner for RFC-822 type header information
@@ -164,12 +164,21 @@ int main(int argc,char *argv[])
{
File CacheF("./cache",File::WriteExists);
- MMap Map(CacheF,MMap::Public);
+ MMap Map(CacheF,MMap::Public | MMap::ReadOnly);
pkgCache Cache(Map);
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
{
cout << "Package: " << I.Name() << endl;
- }
+ for (pkgCache::VerIterator V = I.VersionList(); V.end() == false; V++)
+ {
+ cout << "Version: " << V.VerStr() << endl;
+ cout << "Size: " << V->Size << endl;
+ cout << "Installed-Size: " << V->InstalledSize << endl;
+ cout << "Section: " << V.Section() << endl;
+ cout << "Priority: " << Cache.Priority(V->Priority) << endl;
+ }
+ cout << endl;
+ }
}
#if 0