]>
Commit | Line | Data |
---|---|---|
f55ece0e AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
a7c835af | 3 | // $Id: debrecords.cc,v 1.10 2001/03/13 06:51:46 jgg Exp $ |
f55ece0e AL |
4 | /* ###################################################################### |
5 | ||
6 | Debian Package Records - Parser for debian package records | |
7 | ||
8 | ##################################################################### */ | |
9 | /*}}}*/ | |
10 | // Include Files /*{{{*/ | |
11 | #ifdef __GNUG__ | |
12 | #pragma implementation "apt-pkg/debrecords.h" | |
13 | #endif | |
14 | #include <apt-pkg/debrecords.h> | |
15 | #include <apt-pkg/error.h> | |
16 | /*}}}*/ | |
17 | ||
18 | // RecordParser::debRecordParser - Constructor /*{{{*/ | |
19 | // --------------------------------------------------------------------- | |
20 | /* */ | |
b2e465d6 AL |
21 | debRecordParser::debRecordParser(string FileName,pkgCache &Cache) : |
22 | File(FileName,FileFd::ReadOnly), | |
23 | Tags(&File,Cache.Head().MaxVerFileSize + 200) | |
f55ece0e AL |
24 | { |
25 | } | |
26 | /*}}}*/ | |
27 | // RecordParser::Jump - Jump to a specific record /*{{{*/ | |
28 | // --------------------------------------------------------------------- | |
29 | /* */ | |
03e39e59 | 30 | bool debRecordParser::Jump(pkgCache::VerFileIterator const &Ver) |
f55ece0e AL |
31 | { |
32 | return Tags.Jump(Section,Ver->Offset); | |
33 | } | |
34 | /*}}}*/ | |
7e798dd7 AL |
35 | // RecordParser::FileName - Return the archive filename on the site /*{{{*/ |
36 | // --------------------------------------------------------------------- | |
37 | /* */ | |
38 | string debRecordParser::FileName() | |
39 | { | |
7974b907 | 40 | return Section.FindS("Filename"); |
7e798dd7 AL |
41 | } |
42 | /*}}}*/ | |
b2e465d6 AL |
43 | // RecordParser::Name - Return the package name /*{{{*/ |
44 | // --------------------------------------------------------------------- | |
45 | /* */ | |
46 | string debRecordParser::Name() | |
47 | { | |
48 | return Section.FindS("Package"); | |
49 | } | |
50 | /*}}}*/ | |
7e798dd7 AL |
51 | // RecordParser::MD5Hash - Return the archive hash /*{{{*/ |
52 | // --------------------------------------------------------------------- | |
53 | /* */ | |
54 | string debRecordParser::MD5Hash() | |
55 | { | |
a7c835af AL |
56 | return Section.FindS("MD5Sum"); |
57 | } | |
58 | /*}}}*/ | |
59 | // RecordParser::SHA1Hash - Return the archive hash /*{{{*/ | |
60 | // --------------------------------------------------------------------- | |
61 | /* */ | |
62 | string debRecordParser::SHA1Hash() | |
63 | { | |
59b46c41 | 64 | return Section.FindS("SHA1"); |
7e798dd7 AL |
65 | } |
66 | /*}}}*/ | |
67 | // RecordParser::Maintainer - Return the maintainer email /*{{{*/ | |
68 | // --------------------------------------------------------------------- | |
69 | /* */ | |
70 | string debRecordParser::Maintainer() | |
71 | { | |
7974b907 | 72 | return Section.FindS("Maintainer"); |
7e798dd7 AL |
73 | } |
74 | /*}}}*/ | |
75 | // RecordParser::ShortDesc - Return a 1 line description /*{{{*/ | |
76 | // --------------------------------------------------------------------- | |
77 | /* */ | |
78 | string debRecordParser::ShortDesc() | |
79 | { | |
7974b907 | 80 | string Res = Section.FindS("Description"); |
7e798dd7 AL |
81 | string::size_type Pos = Res.find('\n'); |
82 | if (Pos == string::npos) | |
83 | return Res; | |
84 | return string(Res,0,Pos); | |
85 | } | |
86 | /*}}}*/ | |
87 | // RecordParser::LongDesc - Return a longer description /*{{{*/ | |
88 | // --------------------------------------------------------------------- | |
89 | /* */ | |
90 | string debRecordParser::LongDesc() | |
91 | { | |
7974b907 | 92 | return Section.FindS("Description"); |
7e798dd7 AL |
93 | } |
94 | /*}}}*/ | |
c2f2b862 MV |
95 | |
96 | static const char *SourceVerSeparators = " ()"; | |
97 | ||
04f232fc | 98 | // RecordParser::SourcePkg - Return the source package name if any /*{{{*/ |
36375005 AL |
99 | // --------------------------------------------------------------------- |
100 | /* */ | |
101 | string debRecordParser::SourcePkg() | |
102 | { | |
04f232fc | 103 | string Res = Section.FindS("Source"); |
c2f2b862 | 104 | string::size_type Pos = Res.find_first_of(SourceVerSeparators); |
04f232fc AL |
105 | if (Pos == string::npos) |
106 | return Res; | |
107 | return string(Res,0,Pos); | |
36375005 AL |
108 | } |
109 | /*}}}*/ | |
c2f2b862 MV |
110 | // RecordParser::SourceVer - Return the source version number if present /*{{{*/ |
111 | // --------------------------------------------------------------------- | |
112 | /* */ | |
113 | string debRecordParser::SourceVer() | |
114 | { | |
115 | string Pkg = Section.FindS("Source"); | |
116 | string::size_type Pos = Pkg.find_first_of(SourceVerSeparators); | |
117 | if (Pos == string::npos) | |
118 | return ""; | |
119 | ||
120 | string::size_type VerStart = Pkg.find_first_not_of(SourceVerSeparators, Pos); | |
121 | if(VerStart == string::npos) | |
122 | return ""; | |
123 | ||
124 | string::size_type VerEnd = Pkg.find_first_of(SourceVerSeparators, VerStart); | |
125 | if(VerEnd == string::npos) | |
126 | // Corresponds to the case of, e.g., "foo (1.2" without a closing | |
127 | // paren. Be liberal and guess what it means. | |
128 | return string(Pkg, VerStart); | |
129 | else | |
130 | return string(Pkg, VerStart, VerEnd - VerStart); | |
131 | } | |
132 | /*}}}*/ | |
b2e465d6 AL |
133 | // RecordParser::GetRec - Return the whole record /*{{{*/ |
134 | // --------------------------------------------------------------------- | |
135 | /* */ | |
136 | void debRecordParser::GetRec(const char *&Start,const char *&Stop) | |
137 | { | |
138 | Section.GetSection(Start,Stop); | |
139 | } | |
140 | /*}}}*/ |