]> git.saurik.com Git - apt.git/blame - apt-pkg/deb/debrecords.cc
Sync with apt@packages.debian.org/apt--main--0--patch-74
[apt.git] / apt-pkg / deb / debrecords.cc
CommitLineData
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>
a52f938b 15#include <apt-pkg/strutl.h>
f55ece0e 16#include <apt-pkg/error.h>
a52f938b 17#include <langinfo.h>
f55ece0e
AL
18 /*}}}*/
19
20// RecordParser::debRecordParser - Constructor /*{{{*/
21// ---------------------------------------------------------------------
22/* */
b2e465d6
AL
23debRecordParser::debRecordParser(string FileName,pkgCache &Cache) :
24 File(FileName,FileFd::ReadOnly),
25 Tags(&File,Cache.Head().MaxVerFileSize + 200)
f55ece0e
AL
26{
27}
28 /*}}}*/
29// RecordParser::Jump - Jump to a specific record /*{{{*/
30// ---------------------------------------------------------------------
31/* */
03e39e59 32bool debRecordParser::Jump(pkgCache::VerFileIterator const &Ver)
f55ece0e
AL
33{
34 return Tags.Jump(Section,Ver->Offset);
a52f938b
OS
35}
36bool debRecordParser::Jump(pkgCache::DescFileIterator const &Desc)
37{
38 return Tags.Jump(Section,Desc->Offset);
f55ece0e
AL
39}
40 /*}}}*/
7e798dd7
AL
41// RecordParser::FileName - Return the archive filename on the site /*{{{*/
42// ---------------------------------------------------------------------
43/* */
44string debRecordParser::FileName()
45{
7974b907 46 return Section.FindS("Filename");
7e798dd7
AL
47}
48 /*}}}*/
b2e465d6
AL
49// RecordParser::Name - Return the package name /*{{{*/
50// ---------------------------------------------------------------------
51/* */
52string debRecordParser::Name()
53{
54 return Section.FindS("Package");
55}
56 /*}}}*/
7e798dd7
AL
57// RecordParser::MD5Hash - Return the archive hash /*{{{*/
58// ---------------------------------------------------------------------
59/* */
60string debRecordParser::MD5Hash()
61{
a7c835af
AL
62 return Section.FindS("MD5Sum");
63}
64 /*}}}*/
65// RecordParser::SHA1Hash - Return the archive hash /*{{{*/
66// ---------------------------------------------------------------------
67/* */
68string debRecordParser::SHA1Hash()
69{
70 return Section.FindS("SHA1Sum");
7e798dd7
AL
71}
72 /*}}}*/
73// RecordParser::Maintainer - Return the maintainer email /*{{{*/
74// ---------------------------------------------------------------------
75/* */
76string debRecordParser::Maintainer()
77{
7974b907 78 return Section.FindS("Maintainer");
7e798dd7
AL
79}
80 /*}}}*/
81// RecordParser::ShortDesc - Return a 1 line description /*{{{*/
82// ---------------------------------------------------------------------
83/* */
84string debRecordParser::ShortDesc()
85{
a52f938b 86 string Res = LongDesc();
7e798dd7
AL
87 string::size_type Pos = Res.find('\n');
88 if (Pos == string::npos)
89 return Res;
90 return string(Res,0,Pos);
91}
92 /*}}}*/
93// RecordParser::LongDesc - Return a longer description /*{{{*/
94// ---------------------------------------------------------------------
95/* */
96string debRecordParser::LongDesc()
97{
a52f938b
OS
98 string orig, dest;
99 char *codeset = nl_langinfo(CODESET);
100
101 if (!Section.FindS("Description").empty())
102 orig = Section.FindS("Description").c_str();
103 else
104 orig = Section.FindS(("Description-" + pkgIndexFile::LanguageCode()).c_str()).c_str();
105
106 if (strcmp(codeset,"UTF-8") != 0) {
107 UTF8ToCodeset(codeset, orig, &dest);
108 orig = dest;
109 }
110
111 return orig;
7e798dd7
AL
112}
113 /*}}}*/
04f232fc 114// RecordParser::SourcePkg - Return the source package name if any /*{{{*/
36375005
AL
115// ---------------------------------------------------------------------
116/* */
117string debRecordParser::SourcePkg()
118{
04f232fc
AL
119 string Res = Section.FindS("Source");
120 string::size_type Pos = Res.find(' ');
121 if (Pos == string::npos)
122 return Res;
123 return string(Res,0,Pos);
36375005
AL
124}
125 /*}}}*/
b2e465d6
AL
126// RecordParser::GetRec - Return the whole record /*{{{*/
127// ---------------------------------------------------------------------
128/* */
129void debRecordParser::GetRec(const char *&Start,const char *&Stop)
130{
131 Section.GetSection(Start,Stop);
132}
133 /*}}}*/