summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:50:38 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:50:38 +0000
commit0149949bce07d3a15cb8a197df1240d56f7bcd26 (patch)
tree480da4e027332ba1d69d9e38a5bf67a0a946ea65 /apt-pkg/deb
parentf55a958ff2251f0061ab907157c99a350e56025f (diff)
Checkpoint
Author: jgg Date: 1998-07-04 22:32:11 GMT Checkpoint
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/deblistparser.cc78
-rw-r--r--apt-pkg/deb/deblistparser.h3
2 files changed, 75 insertions, 6 deletions
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);