// -*- 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.
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)
--- /dev/null
+// -*- 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);
+}
+ /*}}}*/
--- /dev/null
+// -*- 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
# 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
// -*- 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.
public:
class ListParser;
+ friend ListParser;
protected:
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);
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
--- /dev/null
+// -*- 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;
+}
+ /*}}}*/
--- /dev/null
+// -*- 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