]>
git.saurik.com Git - apt.git/blob - apt-pkg/deb/debrecords.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: debrecords.cc,v 1.9 2001/02/20 07:03:17 jgg Exp $
4 /* ######################################################################
6 Debian Package Records - Parser for debian package records
8 ##################################################################### */
10 // Include Files /*{{{*/
12 #pragma implementation "apt-pkg/debrecords.h"
14 #include <apt-pkg/debrecords.h>
15 #include <apt-pkg/error.h>
18 // RecordParser::debRecordParser - Constructor /*{{{*/
19 // ---------------------------------------------------------------------
21 debRecordParser::debRecordParser(string FileName
,pkgCache
&Cache
) :
22 File(FileName
,FileFd::ReadOnly
),
23 Tags(&File
,Cache
.Head().MaxVerFileSize
+ 200)
27 // RecordParser::Jump - Jump to a specific record /*{{{*/
28 // ---------------------------------------------------------------------
30 bool debRecordParser::Jump(pkgCache::VerFileIterator
const &Ver
)
32 return Tags
.Jump(Section
,Ver
->Offset
);
35 // RecordParser::FileName - Return the archive filename on the site /*{{{*/
36 // ---------------------------------------------------------------------
38 string
debRecordParser::FileName()
40 return Section
.FindS("Filename");
43 // RecordParser::Name - Return the package name /*{{{*/
44 // ---------------------------------------------------------------------
46 string
debRecordParser::Name()
48 return Section
.FindS("Package");
51 // RecordParser::MD5Hash - Return the archive hash /*{{{*/
52 // ---------------------------------------------------------------------
54 string
debRecordParser::MD5Hash()
56 return Section
.FindS("MD5sum");
59 // RecordParser::Maintainer - Return the maintainer email /*{{{*/
60 // ---------------------------------------------------------------------
62 string
debRecordParser::Maintainer()
64 return Section
.FindS("Maintainer");
67 // RecordParser::ShortDesc - Return a 1 line description /*{{{*/
68 // ---------------------------------------------------------------------
70 string
debRecordParser::ShortDesc()
72 string Res
= Section
.FindS("Description");
73 string::size_type Pos
= Res
.find('\n');
74 if (Pos
== string::npos
)
76 return string(Res
,0,Pos
);
79 // RecordParser::LongDesc - Return a longer description /*{{{*/
80 // ---------------------------------------------------------------------
82 string
debRecordParser::LongDesc()
84 return Section
.FindS("Description");
87 // RecordParser::SourcePkg - Return the source package name if any /*{{{*/
88 // ---------------------------------------------------------------------
90 string
debRecordParser::SourcePkg()
92 string Res
= Section
.FindS("Source");
93 string::size_type Pos
= Res
.find(' ');
94 if (Pos
== string::npos
)
96 return string(Res
,0,Pos
);
99 // RecordParser::GetRec - Return the whole record /*{{{*/
100 // ---------------------------------------------------------------------
102 void debRecordParser::GetRec(const char *&Start
,const char *&Stop
)
104 Section
.GetSection(Start
,Stop
);