diff options
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r-- | apt-pkg/deb/deblistparser.cc | 37 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.h | 3 |
2 files changed, 38 insertions, 2 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 9adc60044..273b7fd42 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.18 1999/04/12 19:16:11 jgg Exp $ +// $Id: deblistparser.cc,v 1.19 1999/05/23 22:55:54 jgg Exp $ /* ###################################################################### Package Cache Generator - Generator for the cache structure. @@ -14,6 +14,7 @@ #include <apt-pkg/error.h> #include <apt-pkg/configuration.h> #include <apt-pkg/strutl.h> +#include <apt-pkg/crc-16.h> #include <system.h> /*}}}*/ @@ -130,6 +131,40 @@ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg, return true; } /*}}}*/ +// ListParser::VersionHash - Compute a unique hash for this version /*{{{*/ +// --------------------------------------------------------------------- +/* */ +unsigned short debListParser::VersionHash() +{ + const char *Sections[] ={"Installed-Size", + "Depends", + "Pre-Depends", + "Suggests", + "Recommends", + "Conflicts", + "Replaces",0}; + unsigned long Result = INIT_FCS; + char S[300]; + for (const char **I = Sections; *I != 0; I++) + { + const char *Start; + const char *End; + if (Section.Find(*I,Start,End) == false || End - Start >= (signed)sizeof(S)) + continue; + + /* Strip out any spaces from the text, this undoes dpkgs reformatting + of certain fields */ + char *I = S; + for (; Start != End; Start++) + if (isspace(*Start) == 0) + *I++ = *Start; + + Result = AddCRC16(Result,S,I - S); + } + + return Result; +} + /*}}}*/ // ListParser::ParseStatus - Parse the status field /*{{{*/ // --------------------------------------------------------------------- /* Status lines are of the form, diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 6888c1a5e..3c8ea5b0a 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.6 1998/12/14 02:23:47 jgg Exp $ +// $Id: deblistparser.h,v 1.7 1999/05/23 22:55:55 jgg Exp $ /* ###################################################################### Debian Package List Parser - This implements the abstract parser @@ -43,6 +43,7 @@ class debListParser : public pkgCacheGenerator::ListParser virtual string Package(); virtual string Version(); virtual bool NewVersion(pkgCache::VerIterator Ver); + virtual unsigned short VersionHash(); virtual bool UsePackage(pkgCache::PkgIterator Pkg, pkgCache::VerIterator Ver); virtual unsigned long Offset() {return iOffset;}; |