summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/deb/deblistparser.cc4
-rw-r--r--apt-pkg/deb/debrecords.cc32
-rw-r--r--apt-pkg/deb/debrecords.h38
-rw-r--r--apt-pkg/makefile6
-rw-r--r--apt-pkg/pkgcachegen.h72
-rw-r--r--apt-pkg/pkgrecords.cc65
-rw-r--r--apt-pkg/pkgrecords.h67
7 files changed, 243 insertions, 41 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index f1c1925e1..8b778a726 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.9 1998/07/26 04:49:37 jgg Exp $
+// $Id: deblistparser.cc,v 1.10 1998/08/09 00:51:35 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -167,7 +167,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
return false;
if (ParseDepends(Ver,"Conflicts",pkgCache::Dep::Conflicts) == false)
return false;
- if (ParseDepends(Ver,"Replaces",pkgCache::Dep::Depends) == false)
+ if (ParseDepends(Ver,"Replaces",pkgCache::Dep::Replaces) == false)
return false;
if (ParseProvides(Ver) == false)
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
new file mode 100644
index 000000000..ae0acce18
--- /dev/null
+++ b/apt-pkg/deb/debrecords.cc
@@ -0,0 +1,32 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+// $Id: debrecords.cc,v 1.1 1998/08/09 00:51:36 jgg Exp $
+/* ######################################################################
+
+ Debian Package Records - Parser for debian package records
+
+ ##################################################################### */
+ /*}}}*/
+// Include Files /*{{{*/
+#ifdef __GNUG__
+#pragma implementation "apt-pkg/debrecords.h"
+#endif
+#include <apt-pkg/debrecords.h>
+#include <apt-pkg/error.h>
+ /*}}}*/
+
+// RecordParser::debRecordParser - Constructor /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+debRecordParser::debRecordParser(FileFd &File) : Tags(File,4*1024)
+{
+}
+ /*}}}*/
+// RecordParser::Jump - Jump to a specific record /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool debRecordParser::Jump(pkgCache::VerFileIterator &Ver)
+{
+ return Tags.Jump(Section,Ver->Offset);
+}
+ /*}}}*/
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h
new file mode 100644
index 000000000..0bd8da921
--- /dev/null
+++ b/apt-pkg/deb/debrecords.h
@@ -0,0 +1,38 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+// $Id: debrecords.h,v 1.1 1998/08/09 00:51:36 jgg Exp $
+/* ######################################################################
+
+ Debian Package Records - Parser for debian package records
+
+ This provides display-type parsing for the Packages file. This is
+ different than the the list parser which provides cache generation
+ services. There should be no overlap between these two.
+
+ ##################################################################### */
+ /*}}}*/
+// Header section: pkglib
+#ifndef PKGLIB_DEBRECORDS_H
+#define PKGLIB_DEBRECORDS_H
+
+#ifdef __GNUG__
+#pragma interface "apt-pkg/debrecords.h"
+#endif
+
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/tagfile.h>
+
+class debRecordParser : public pkgRecords::Parser
+{
+ pkgTagFile Tags;
+ pkgTagSection Section;
+
+ public:
+
+ virtual bool Jump(pkgCache::VerFileIterator &Ver);
+
+ debRecordParser(FileFd &File);
+};
+
+
+#endif
diff --git a/apt-pkg/makefile b/apt-pkg/makefile
index e067bb617..f06e1afd2 100644
--- a/apt-pkg/makefile
+++ b/apt-pkg/makefile
@@ -20,16 +20,16 @@ SOURCE = contrib/mmap.cc contrib/error.cc contrib/strutl.cc \
# Source code for the main library
SOURCE+= pkgcache.cc version.cc fileutl.cc pkgcachegen.cc depcache.cc \
orderlist.cc tagfile.cc sourcelist.cc packagemanager.cc \
- algorithms.cc init.cc templates.cc
+ pkgrecords.cc algorithms.cc init.cc templates.cc
# Source code for the debian specific components
-SOURCE+= deb/deblistparser.cc
+SOURCE+= deb/deblistparser.cc deb/debrecords.cc
# Public apt-pkg header files
HEADERS = algorithms.h depcache.h mmap.h pkgcachegen.h cacheiterators.h \
error.h orderlist.h sourcelist.h configuration.h fileutl.h \
packagemanager.h tagfile.h deblistparser.h init.h pkgcache.h \
- version.h progress.h
+ version.h progress.h pkgrecords.h debrecords.h
HEADERS := $(addprefix apt-pkg/,$(HEADERS))
# Private header files
diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h
index c572f828a..093f979d7 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.9 1998/07/26 04:49:32 jgg Exp $
+// $Id: pkgcachegen.h,v 1.10 1998/08/09 00:51:34 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -34,6 +34,7 @@ class pkgCacheGenerator
public:
class ListParser;
+ friend ListParser;
protected:
@@ -51,41 +52,7 @@ class pkgCacheGenerator
unsigned long WriteUniqString(const char *S,unsigned int Size);
inline unsigned long WriteUniqString(string S) {return WriteUniqString(S);};
- public:
-
- // This is the abstract package list parser class.
- class ListParser
- {
- pkgCacheGenerator *Owner;
- friend pkgCacheGenerator;
-
- protected:
-
- inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
- inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
- inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
- inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
- bool NewDepends(pkgCache::VerIterator Ver,string Package,
- string Version,unsigned int Op,
- unsigned int Type);
- bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version);
-
- public:
-
- // These all operate against the current section
- virtual string Package() = 0;
- virtual string Version() = 0;
- virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
- virtual bool UsePackage(pkgCache::PkgIterator Pkg,
- pkgCache::VerIterator Ver) = 0;
- virtual unsigned long Offset() = 0;
- virtual unsigned long Size() = 0;
-
- virtual bool Step() = 0;
-
- virtual ~ListParser() {};
- };
- friend ListParser;
+ public:
bool SelectFile(string File,unsigned long Flags = 0);
bool MergeList(ListParser &List);
@@ -99,4 +66,37 @@ bool pkgSrcCacheCheck(pkgSourceList &List);
bool pkgPkgCacheCheck(string CacheFile);
bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress);
+// This is the abstract package list parser class.
+class pkgCacheGenerator::ListParser
+{
+ pkgCacheGenerator *Owner;
+ friend pkgCacheGenerator;
+
+ protected:
+
+ inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
+ inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
+ inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
+ inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
+ bool NewDepends(pkgCache::VerIterator Ver,string Package,
+ string Version,unsigned int Op,
+ unsigned int Type);
+ bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version);
+
+ public:
+
+ // These all operate against the current section
+ virtual string Package() = 0;
+ virtual string Version() = 0;
+ virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
+ virtual bool UsePackage(pkgCache::PkgIterator Pkg,
+ pkgCache::VerIterator Ver) = 0;
+ virtual unsigned long Offset() = 0;
+ virtual unsigned long Size() = 0;
+
+ virtual bool Step() = 0;
+
+ virtual ~ListParser() {};
+};
+
#endif
diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc
new file mode 100644
index 000000000..b3105da44
--- /dev/null
+++ b/apt-pkg/pkgrecords.cc
@@ -0,0 +1,65 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+// $Id: pkgrecords.cc,v 1.1 1998/08/09 00:51:35 jgg Exp $
+/* ######################################################################
+
+ Package Records - Allows access to complete package description records
+ directly from the file.
+
+ ##################################################################### */
+ /*}}}*/
+// Include Files /*{{{*/
+#ifdef __GNUG__
+#pragma implementation "apt-pkg/pkgrecords.h"
+#endif
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/debrecords.h>
+#include <apt-pkg/error.h>
+ /*}}}*/
+
+// Records::pkgRecords - Constructor /*{{{*/
+// ---------------------------------------------------------------------
+/* This will create the necessary structures to access the status files */
+pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0)
+{
+ Files = new PkgFile[Cache.HeaderP->PackageFileCount];
+ for (pkgCache::PkgFileIterator I = Cache.FileBegin();
+ I.end() == false; I++)
+ {
+ Files[I->ID].File = new FileFd(I.FileName(),FileFd::ReadOnly);
+ if (_error->PendingError() == true)
+ return;
+ Files[I->ID].Parse = new debRecordParser(*Files[I->ID].File);
+ if (_error->PendingError() == true)
+ return;
+ }
+}
+ /*}}}*/
+// Records::~pkgRecords - Destructor /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgRecords::~pkgRecords()
+{
+ delete [] Files;
+}
+ /*}}}*/
+// Records::Lookup - Get a parser for the package version file /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgRecords::Parser &pkgRecords::Lookup(pkgCache::VerFileIterator &Ver)
+{
+ PkgFile &File = Files[Ver.File()->ID];
+ File.Parse->Jump(Ver);
+
+ return *File.Parse;
+}
+ /*}}}*/
+// Records::Pkgfile::~PkgFile - Destructor /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgRecords::PkgFile::~PkgFile()
+{
+ delete Parse;
+ delete File;
+}
+ /*}}}*/
diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h
new file mode 100644
index 000000000..e129c65eb
--- /dev/null
+++ b/apt-pkg/pkgrecords.h
@@ -0,0 +1,67 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+// $Id: pkgrecords.h,v 1.1 1998/08/09 00:51:35 jgg Exp $
+/* ######################################################################
+
+ Package Records - Allows access to complete package description records
+ directly from the file.
+
+ The package record system abstracts the actual parsing of the
+ package files. This is different than the generators parser in that
+ it is used to access information not generate information. No
+ information touched by the generator should be parable from here as
+ it can always be retreived directly from the cache.
+
+ ##################################################################### */
+ /*}}}*/
+// Header section: pkglib
+#ifndef PKGLIB_PKGRECORDS_H
+#define PKGLIB_PKGRECORDS_H
+
+#ifdef __GNUG__
+#pragma interface "apt-pkg/pkgrecords.h"
+#endif
+
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/fileutl.h>
+
+class pkgRecords
+{
+ public:
+ class Parser;
+
+ private:
+
+ pkgCache &Cache;
+
+ // List of package files
+ struct PkgFile
+ {
+ FileFd *File;
+ Parser *Parse;
+
+ PkgFile() : File(0), Parse(0) {};
+ ~PkgFile();
+ };
+ PkgFile *Files;
+
+ public:
+
+ // Lookup function
+ Parser &Lookup(pkgCache::VerFileIterator &Ver);
+
+ // Construct destruct
+ pkgRecords(pkgCache &Cache);
+ ~pkgRecords();
+};
+
+class pkgRecords::Parser
+{
+ public:
+
+ virtual bool Jump(pkgCache::VerFileIterator &Ver) = 0;
+
+ virtual ~Parser() {};
+};
+
+#endif