]>
Commit | Line | Data |
---|---|---|
1 | // -*- mode: cpp; mode: fold -*- | |
2 | // Description /*{{{*/ | |
3 | // $Id: tagfile.h,v 1.1 1998/07/02 02:58:13 jgg Exp $ | |
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); | |
42 | inline unsigned long Length() {return Stop - Section;}; | |
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; | |
54 | ||
55 | bool Fill(); | |
56 | ||
57 | public: | |
58 | ||
59 | bool Step(pkgTagSection &Section); | |
60 | ||
61 | pkgTagFile(File &F); | |
62 | }; | |
63 | ||
64 | #endif |