summaryrefslogtreecommitdiff
path: root/apt-pkg/tagfile.h
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:50:36 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:50:36 +0000
commit578bfd0aed2ec993f4ad85fa6a7094a852261422 (patch)
tree737f52267f6468a4b6754f8c6665824767352746 /apt-pkg/tagfile.h
Base revisions
Author: jgg Date: 1998-07-02 02:58:12 GMT Base revisions
Diffstat (limited to 'apt-pkg/tagfile.h')
-rw-r--r--apt-pkg/tagfile.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
new file mode 100644
index 000000000..a7a82dd1c
--- /dev/null
+++ b/apt-pkg/tagfile.h
@@ -0,0 +1,64 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+// $Id: tagfile.h,v 1.1 1998/07/02 02:58:13 jgg Exp $
+/* ######################################################################
+
+ Fast scanner for RFC-822 type header information
+
+ 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
+ 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
+ by indexing the start of each header field and providing lookup
+ functions for header fields.
+
+ ##################################################################### */
+ /*}}}*/
+// Header section: pkglib
+#ifndef PKGLIB_TAGFILE_H
+#define PKGLIB_TAGFILE_H
+
+#include <pkglib/fileutl.h>
+
+class pkgTagSection
+{
+ const char *Section;
+ const char *Stop;
+
+ // We have a limit of 256 tags per section.
+ unsigned short Indexes[256];
+ unsigned int TagCount;
+
+ public:
+
+ inline bool operator ==(const pkgTagSection &rhs) {return Section == rhs.Section;};
+ inline bool operator !=(const pkgTagSection &rhs) {return Section != rhs.Section;};
+
+ bool Find(const char *Tag,const char *&Start, const char *&End);
+ bool Scan(const char *Start,unsigned long MaxLength);
+ inline unsigned long Length() {return Stop - Section;};
+
+ pkgTagSection() : Section(0), Stop(0) {};
+};
+
+class pkgTagFile
+{
+ File Fd;
+ char *Buffer;
+ char *Start;
+ char *End;
+ unsigned long Left;
+
+ bool Fill();
+
+ public:
+
+ bool Step(pkgTagSection &Section);
+
+ pkgTagFile(File &F);
+};
+
+#endif