summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:50:51 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:50:51 +0000
commitad00ae81eb9e1f5384f8fe32879d483c72bbdace (patch)
tree90dc3818bc981902022cf43d1f44dc0c1fd2a45c /apt-pkg
parent8efa2a3ba4ae833415223a888e4561e57e4bf132 (diff)
DumpAvail works and apt-cache is complete
Author: jgg Date: 1998-07-19 04:22:00 GMT DumpAvail works and apt-cache is complete
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/strutl.cc21
-rw-r--r--apt-pkg/contrib/strutl.h3
-rw-r--r--apt-pkg/pkgcache.cc3
-rw-r--r--apt-pkg/pkgcache.h11
-rw-r--r--apt-pkg/pkgcachegen.cc8
-rw-r--r--apt-pkg/pkgcachegen.h7
-rw-r--r--apt-pkg/sourcelist.cc41
-rw-r--r--apt-pkg/sourcelist.h4
-rw-r--r--apt-pkg/tagfile.cc49
-rw-r--r--apt-pkg/tagfile.h8
10 files changed, 84 insertions, 71 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 8c1f7005c..f30d9ffe7 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: strutl.cc,v 1.2 1998/07/16 06:08:41 jgg Exp $
+// $Id: strutl.cc,v 1.3 1998/07/19 04:22:08 jgg Exp $
/* ######################################################################
String Util - Some usefull string functions.
@@ -243,6 +243,25 @@ string SubstVar(string Str,string Subst,string Contents)
return Temp + string(Str,OldPos);
}
/*}}}*/
+// URItoFileName - Convert the uri into a unique file name /*{{{*/
+// ---------------------------------------------------------------------
+/* This converts a URI into a safe filename. It quotes all unsafe characters
+ and converts / to _ and removes the scheme identifier. The resulting
+ file name should be unique and never occur again for a different file */
+string URItoFileName(string URI)
+{
+ string::const_iterator I = URI.begin() + URI.find(':') + 1;
+ for (; I < URI.end() && *I == '/'; I++);
+
+ // "\x00-\x20{}|\\\\^\\[\\]<>\"\x7F-\xFF";
+ URI = QuoteString(string(I,URI.end() - I),"\\|{}[]<>\"^~_=!@#$%^&*");
+ string::iterator J = URI.begin();
+ for (; J != URI.end(); J++)
+ if (*J == '/')
+ *J = '_';
+ return URI;
+}
+ /*}}}*/
// Base64Encode - Base64 Encoding routine for short strings /*{{{*/
// ---------------------------------------------------------------------
/* This routine performs a base64 transformation on a string. It was ripped
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index 0aabf0186..b49b1a52d 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: strutl.h,v 1.2 1998/07/09 05:12:35 jgg Exp $
+// $Id: strutl.h,v 1.3 1998/07/19 04:22:09 jgg Exp $
/* ######################################################################
String Util - These are some usefull string functions
@@ -29,6 +29,7 @@ string SizeToStr(double Bytes);
string TimeToStr(unsigned long Sec);
string SubstVar(string Str,string Subst,string Contents);
string Base64Encode(string Str);
+string URItoFileName(string URI);
int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
inline int stringcmp(const char *A,const char *AEnd,const char *B) {return stringcmp(A,AEnd,B,B+strlen(B));};
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index 20590e971..02b28fa47 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.7 1998/07/12 23:58:32 jgg Exp $
+// $Id: pkgcache.cc,v 1.8 1998/07/19 04:22:00 jgg Exp $
/* ######################################################################
Package Cache - Accessor code for the cache
@@ -59,6 +59,7 @@ pkgCache::Header::Header()
VersionCount = 0;
DependsCount = 0;
PackageFileCount = 0;
+ MaxVerFileSize = 0;
FileList = 0;
StringList = 0;
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index 5ff29cfb4..2e695ab7b 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.6 1998/07/12 23:58:33 jgg Exp $
+// $Id: pkgcache.h,v 1.7 1998/07/19 04:22:01 jgg Exp $
/* ######################################################################
Cache - Structure definitions for the cache file
@@ -120,7 +120,9 @@ class pkgCache
Header &Head() {return *HeaderP;};
inline PkgIterator PkgBegin();
inline PkgIterator PkgEnd();
-
+ inline PkgFileIterator FileBegin();
+ inline PkgFileIterator FileEnd();
+
pkgCache(MMap &Map);
virtual ~pkgCache() {};
};
@@ -152,6 +154,7 @@ struct pkgCache::Header
// Offsets
unsigned long FileList; // struct PackageFile
unsigned long StringList; // struct StringItem
+ unsigned long MaxVerFileSize;
/* Allocation pools, there should be one of these for each structure
excluding the header */
@@ -264,5 +267,9 @@ inline pkgCache::PkgIterator pkgCache::PkgBegin()
{return PkgIterator(*this);};
inline pkgCache::PkgIterator pkgCache::PkgEnd()
{return PkgIterator(*this,PkgP);};
+inline pkgCache::PkgFileIterator pkgCache::FileBegin()
+ {return PkgFileIterator(*this);};
+inline pkgCache::PkgFileIterator pkgCache::FileEnd()
+ {return PkgFileIterator(*this,PkgFileP);};
#endif
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 452caa74a..f5bf5c589 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.10 1998/07/16 06:08:38 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.11 1998/07/19 04:22:02 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -170,7 +170,8 @@ bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver,
Ver->FileList = VF.Index();
VF->Offset = List.Offset();
VF->Size = List.Size();
-
+ if (Cache.HeaderP->MaxVerFileSize < VF->Size)
+ Cache.HeaderP->MaxVerFileSize = VF->Size;
return true;
}
/*}}}*/
@@ -313,7 +314,8 @@ bool pkgCacheGenerator::SelectFile(string File,unsigned long Flags)
CurrentFile->NextFile = Cache.HeaderP->FileList;
CurrentFile->Flags = Flags;
PkgFileName = File;
-
+ Cache.HeaderP->FileList = CurrentFile - Cache.PkgFileP;
+
if (CurrentFile->FileName == 0)
return false;
return true;
diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h
index 0a4881057..a2eab8d43 100644
--- a/apt-pkg/pkgcachegen.h
+++ b/apt-pkg/pkgcachegen.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcachegen.h,v 1.5 1998/07/12 23:58:35 jgg Exp $
+// $Id: pkgcachegen.h,v 1.6 1998/07/19 04:22:03 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -69,7 +69,7 @@ class pkgCacheGenerator
pkgCache::VerIterator Ver) = 0;
virtual unsigned long Offset() = 0;
virtual unsigned long Size() = 0;
-
+
virtual bool Step() = 0;
virtual ~ListParser() {};
@@ -78,7 +78,8 @@ class pkgCacheGenerator
bool SelectFile(string File,unsigned long Flags = 0);
bool MergeList(ListParser &List);
-
+ inline pkgCache &GetCache() {return Cache;};
+
pkgCacheGenerator(DynamicMMap &Map);
~pkgCacheGenerator();
};
diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc
index f9de99584..faae6a330 100644
--- a/apt-pkg/sourcelist.cc
+++ b/apt-pkg/sourcelist.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: sourcelist.cc,v 1.3 1998/07/12 23:58:36 jgg Exp $
+// $Id: sourcelist.cc,v 1.4 1998/07/19 04:22:04 jgg Exp $
/* ######################################################################
List of Sources
@@ -108,45 +108,6 @@ bool pkgSourceList::Read(string File)
return true;
}
/*}}}*/
-// SourceList::SanitizeURI - Hash the uri /*{{{*/
-// ---------------------------------------------------------------------
-/* This converts a URI into a safe filename. It quotes all unsafe characters
- and converts / to _ and removes the scheme identifier. */
-string pkgSourceList::SanitizeURI(string URI)
-{
- string::const_iterator I = URI.begin() + URI.find(':') + 1;
- for (; I < URI.end() && *I == '/'; I++);
-
- // "\x00-\x20{}|\\\\^\\[\\]<>\"\x7F-\xFF";
- URI = QuoteString(string(I,URI.end() - I),"\\|{}[]<>\"^~_=!@#$%^&*");
- string::iterator J = URI.begin();
- for (; J != URI.end(); J++)
- if (*J == '/')
- *J = '_';
- return URI;
-}
- /*}}}*/
-// SourceList::MatchPkgFile - Find the package file that has the ver /*{{{*/
-// ---------------------------------------------------------------------
-/* This will return List.end() if it could not find the matching
- file */
-pkgSourceList::const_iterator pkgSourceList::MatchPkgFile(pkgCache::VerIterator Ver)
-{
- string Base = _config->Find("APT::Architecture");
- for (const_iterator I = List.begin(); I != List.end(); I++)
- {
- string URI = I->PackagesURI();
- switch (I->Type)
- {
- case Item::Deb:
-/* if (Base + SanitizeURI(URI) == Ver.File().FileName())
- return I;*/
- break;
- };
- }
- return List.end();
-}
- /*}}}*/
// SourceList::Item << - Writes the item to a stream /*{{{*/
// ---------------------------------------------------------------------
/* This is not suitable for rebuilding the sourcelist file but it good for
diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h
index 57a648b97..2cf5a6ed2 100644
--- a/apt-pkg/sourcelist.h
+++ b/apt-pkg/sourcelist.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: sourcelist.h,v 1.3 1998/07/12 23:58:38 jgg Exp $
+// $Id: sourcelist.h,v 1.4 1998/07/19 04:22:05 jgg Exp $
/* ######################################################################
SourceList - Manage a list of sources
@@ -56,8 +56,6 @@ class pkgSourceList
bool ReadMainList();
bool Read(string File);
- string SanitizeURI(string URI);
- const_iterator MatchPkgFile(pkgCache::VerIterator Ver);
// List accessors
inline const_iterator begin() const {return List.begin();};
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 9ae55b7d8..953f8b4a6 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -1,11 +1,11 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: tagfile.cc,v 1.8 1998/07/16 06:08:39 jgg Exp $
+// $Id: tagfile.cc,v 1.9 1998/07/19 04:22:06 jgg Exp $
/* ######################################################################
Fast scanner for RFC-822 type header information
- This uses a rotating 64K buffer to load the package information into.
+ This uses a rotating buffer to load the package information into.
The scanner runs over it and isolates and indexes a single section.
##################################################################### */
@@ -25,10 +25,10 @@
// TagFile::pkgTagFile - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-pkgTagFile::pkgTagFile(File &Fd) : Fd(Fd)
+pkgTagFile::pkgTagFile(File &Fd,unsigned long Size) : Fd(Fd), Size(Size)
{
- Buffer = new char[64*1024];
- Start = End = Buffer + 64*1024;
+ Buffer = new char[Size];
+ Start = End = Buffer;
Left = Fd.Size();
iOffset = 0;
Fill();
@@ -59,35 +59,56 @@ bool pkgTagFile::Step(pkgTagSection &Tag)
then fills the rest from the file */
bool pkgTagFile::Fill()
{
- unsigned long Size = End - Start;
+ unsigned long EndSize = End - Start;
if (Left == 0)
{
- if (Size <= 1)
+ if (EndSize <= 1)
return false;
return true;
}
- memmove(Buffer,Start,Size);
+ memmove(Buffer,Start,EndSize);
Start = Buffer;
+ End = Buffer + EndSize;
- // See if only a bit of the file is left or if
- if (Left < End - Buffer - Size)
+ // See if only a bit of the file is left
+ if (Left < Size)
{
- if (Fd.Read(Buffer + Size,Left) == false)
+ if (Fd.Read(End,Left) == false)
return false;
- End = Buffer + Size + Left;
+ End += Left;
Left = 0;
}
else
{
- if (Fd.Read(Buffer + Size, End - Buffer - Size) == false)
+ if (Fd.Read(End,Size - (End - Buffer)) == false)
return false;
- Left -= End - Buffer - Size;
+ Left -= Size - (End - Buffer);
+ End = Buffer + Size;
}
return true;
}
/*}}}*/
+// TagFile::Jump - Jump to a pre-recorded location in the file /*{{{*/
+// ---------------------------------------------------------------------
+/* This jumps to a pre-recorded file location and */
+bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset)
+{
+ iOffset = Offset;
+ Left = Fd.Size() - Offset;
+ if (Fd.Seek(Offset) == false)
+ return false;
+ End = Start = Buffer;
+
+ if (Fill() == false)
+ return false;
+
+ if (Tag.Scan(Start,End - Start) == false)
+ return _error->Error("Unable to parse package file");
+ return true;
+}
+ /*}}}*/
// TagSection::Scan - Scan for the end of the header information /*{{{*/
// ---------------------------------------------------------------------
/* This looks for the first double new line in the data stream. It also
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index 446b5bf12..8e3dba33d 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: tagfile.h,v 1.5 1998/07/16 06:08:40 jgg Exp $
+// $Id: tagfile.h,v 1.6 1998/07/19 04:22:07 jgg Exp $
/* ######################################################################
Fast scanner for RFC-822 type header information
@@ -56,6 +56,7 @@ class pkgTagFile
char *End;
unsigned long Left;
unsigned long iOffset;
+ unsigned long Size;
bool Fill();
@@ -63,8 +64,9 @@ class pkgTagFile
bool Step(pkgTagSection &Section);
inline unsigned long Offset() {return iOffset;};
-
- pkgTagFile(File &F);
+ bool Jump(pkgTagSection &Tag,unsigned long Offset);
+
+ pkgTagFile(File &F,unsigned long Size = 32*1024);
};
#endif