]>
git.saurik.com Git - apt.git/blob - apt-pkg/deb/debrecords.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: debrecords.cc,v 1.5 1999/02/22 03:30:06 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(FileFd
&File
,pkgCache
&Cache
) :
22 Tags(File
,Cache
.Head().MaxVerFileSize
+ 20)
26 // RecordParser::Jump - Jump to a specific record /*{{{*/
27 // ---------------------------------------------------------------------
29 bool debRecordParser::Jump(pkgCache::VerFileIterator
const &Ver
)
31 return Tags
.Jump(Section
,Ver
->Offset
);
34 // RecordParser::FindTag - Locate a tag and return a string /*{{{*/
35 // ---------------------------------------------------------------------
37 string
debRecordParser::FindTag(const char *Tag
)
41 if (Section
.Find(Tag
,Start
,Stop
) == false)
43 return string(Start
,Stop
- Start
);
46 // RecordParser::FileName - Return the archive filename on the site /*{{{*/
47 // ---------------------------------------------------------------------
49 string
debRecordParser::FileName()
51 return FindTag("Filename");
54 // RecordParser::MD5Hash - Return the archive hash /*{{{*/
55 // ---------------------------------------------------------------------
57 string
debRecordParser::MD5Hash()
59 return FindTag("MD5sum");
62 // RecordParser::Maintainer - Return the maintainer email /*{{{*/
63 // ---------------------------------------------------------------------
65 string
debRecordParser::Maintainer()
67 return FindTag("Maintainer");
70 // RecordParser::ShortDesc - Return a 1 line description /*{{{*/
71 // ---------------------------------------------------------------------
73 string
debRecordParser::ShortDesc()
75 string Res
= FindTag("Description");
76 string::size_type Pos
= Res
.find('\n');
77 if (Pos
== string::npos
)
79 return string(Res
,0,Pos
);
82 // RecordParser::LongDesc - Return a longer description /*{{{*/
83 // ---------------------------------------------------------------------
85 string
debRecordParser::LongDesc()
87 return FindTag("Description");