X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/6c139d6e362f04a1582e8a8f511f8aeab031fecf..a4edf53b885ce8559115eaf2c4836ec1f76b07ec:/apt-pkg/tagfile.h diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index c1fffcf13..82c856f8d 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.3 1998/07/07 04:17:07 jgg Exp $ +// $Id: tagfile.h,v 1.13 1998/12/14 02:23:47 jgg Exp $ /* ###################################################################### Fast scanner for RFC-822 type header information @@ -8,7 +8,7 @@ This parser handles Debian package files (and others). Their form is RFC-822 type header fields in groups seperated by a blank line. - The parser reads the and provides methods to step linearly + The parser reads the file and provides methods to step linearly over it or to jump to a pre-recorded start point and read that record. A second class is used to perform pre-parsing of the record. It works @@ -22,10 +22,10 @@ #define PKGLIB_TAGFILE_H #ifdef __GNUG__ -#pragma interface "pkglib/tagfile.h" +#pragma interface "apt-pkg/tagfile.h" #endif -#include +#include class pkgTagSection { @@ -34,6 +34,8 @@ class pkgTagSection // We have a limit of 256 tags per section. unsigned short Indexes[256]; + unsigned short AlphaIndexes[26 + 26*26]; + unsigned int TagCount; public: @@ -42,20 +44,35 @@ class pkgTagSection inline bool operator !=(const pkgTagSection &rhs) {return Section != rhs.Section;}; bool Find(const char *Tag,const char *&Start, const char *&End); + string FindS(const char *Tag); + signed int FindI(const char *Tag,signed long Default = 0); + bool pkgTagSection::FindFlag(const char *Tag,unsigned long &Flags, + unsigned long Flag); bool Scan(const char *Start,unsigned long MaxLength); inline unsigned long size() {return Stop - Section;}; + inline unsigned int Count() {return TagCount;}; + inline void Get(const char *&Start,const char *&Stop,unsigned int I) + {Start = Section + Indexes[I]; Stop = Section + Indexes[I+1];} + + inline void GetSection(const char *&Start,const char *&Stop) + { + Start = Section; + Stop = this->Stop; + }; + pkgTagSection() : Section(0), Stop(0) {}; }; class pkgTagFile { - File Fd; + FileFd &Fd; char *Buffer; char *Start; char *End; unsigned long Left; unsigned long iOffset; + unsigned long Size; bool Fill(); @@ -63,8 +80,9 @@ class pkgTagFile bool Step(pkgTagSection &Section); inline unsigned long Offset() {return iOffset;}; + bool Jump(pkgTagSection &Tag,unsigned long Offset); - pkgTagFile(File &F); + pkgTagFile(FileFd &F,unsigned long Size = 32*1024); }; #endif