Commit | Line | Data |
---|---|---|
578bfd0a AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
dcb79bae | 3 | // $Id: tagfile.h,v 1.2 1998/07/05 05:33:59 jgg Exp $ |
578bfd0a AL |
4 | /* ###################################################################### |
5 | ||
6 | Fast scanner for RFC-822 type header information | |
7 | ||
8 | This parser handles Debian package files (and others). Their form is | |
9 | RFC-822 type header fields in groups seperated by a blank line. | |
10 | ||
11 | The parser reads the and provides methods to step linearly | |
12 | over it or to jump to a pre-recorded start point and read that record. | |
13 | ||
14 | A second class is used to perform pre-parsing of the record. It works | |
15 | by indexing the start of each header field and providing lookup | |
16 | functions for header fields. | |
17 | ||
18 | ##################################################################### */ | |
19 | /*}}}*/ | |
20 | // Header section: pkglib | |
21 | #ifndef PKGLIB_TAGFILE_H | |
22 | #define PKGLIB_TAGFILE_H | |
23 | ||
24 | #include <pkglib/fileutl.h> | |
25 | ||
26 | class pkgTagSection | |
27 | { | |
28 | const char *Section; | |
29 | const char *Stop; | |
30 | ||
31 | // We have a limit of 256 tags per section. | |
32 | unsigned short Indexes[256]; | |
33 | unsigned int TagCount; | |
34 | ||
35 | public: | |
36 | ||
37 | inline bool operator ==(const pkgTagSection &rhs) {return Section == rhs.Section;}; | |
38 | inline bool operator !=(const pkgTagSection &rhs) {return Section != rhs.Section;}; | |
39 | ||
40 | bool Find(const char *Tag,const char *&Start, const char *&End); | |
41 | bool Scan(const char *Start,unsigned long MaxLength); | |
dcb79bae | 42 | inline unsigned long size() {return Stop - Section;}; |
578bfd0a AL |
43 | |
44 | pkgTagSection() : Section(0), Stop(0) {}; | |
45 | }; | |
46 | ||
47 | class pkgTagFile | |
48 | { | |
49 | File Fd; | |
50 | char *Buffer; | |
51 | char *Start; | |
52 | char *End; | |
53 | unsigned long Left; | |
dcb79bae | 54 | unsigned long iOffset; |
578bfd0a AL |
55 | |
56 | bool Fill(); | |
57 | ||
58 | public: | |
59 | ||
60 | bool Step(pkgTagSection &Section); | |
dcb79bae | 61 | inline unsigned long Offset() {return iOffset;}; |
578bfd0a AL |
62 | |
63 | pkgTagFile(File &F); | |
64 | }; | |
65 | ||
66 | #endif |