]>
git.saurik.com Git - apt.git/blob - apt-pkg/indexrecords.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: indexrecords.cc,v 1.1.2.4 2003/12/30 02:11:43 mdz Exp $
5 // Include Files /*{{{*/
7 #pragma implementation "apt-pkg/indexrecords.h"
9 #include <apt-pkg/indexrecords.h>
10 #include <apt-pkg/tagfile.h>
11 #include <apt-pkg/error.h>
12 #include <apt-pkg/strutl.h>
16 string
indexRecords::GetDist() const
21 bool indexRecords::CheckDist(const string MaybeDist
) const
23 return (this->Dist
== MaybeDist
24 || this->Suite
== MaybeDist
);
27 string
indexRecords::GetExpectedDist() const
29 return this->ExpectedDist
;
32 const indexRecords::checkSum
*indexRecords::Lookup(const string MetaKey
)
34 return Entries
[MetaKey
];
37 bool indexRecords::Load(const string Filename
)
39 FileFd
Fd(Filename
, FileFd::ReadOnly
);
40 pkgTagFile
TagFile(&Fd
, Fd
.Size() + 256); // XXX
41 if (_error
->PendingError() == true)
43 ErrorText
= _(("Unable to parse Release file " + Filename
).c_str());
47 pkgTagSection Section
;
48 if (TagFile
.Step(Section
) == false)
50 ErrorText
= _(("No sections in Release file " + Filename
).c_str());
54 const char *Start
, *End
;
55 Section
.Get (Start
, End
, 0);
56 Suite
= Section
.FindS("Suite");
57 Dist
= Section
.FindS("Codename");
60 // ErrorText = _(("No Codename entry in Release file " + Filename).c_str());
63 if (!Section
.Find("MD5Sum", Start
, End
))
65 ErrorText
= _(("No MD5Sum entry in Release file " + Filename
).c_str());
73 if (!parseSumData(Start
, End
, Name
, MD5Hash
, Size
))
75 indexRecords::checkSum
*Sum
= new indexRecords::checkSum
;
76 Sum
->MetaKeyFilename
= Name
;
77 Sum
->MD5Hash
= MD5Hash
;
82 string Strdate
= Section
.FindS("Date"); // FIXME: verify this somehow?
86 bool indexRecords::parseSumData(const char *&Start
, const char *End
,
87 string
&Name
, string
&Hash
, size_t &Size
)
92 /* Skip over the first blank */
93 while ((*Start
== '\t' || *Start
== ' ' || *Start
== '\n')
99 /* Move EntryEnd to the end of the first entry (the hash) */
100 const char *EntryEnd
= Start
;
101 while ((*EntryEnd
!= '\t' && *EntryEnd
!= ' ')
107 Hash
.append(Start
, EntryEnd
-Start
);
109 /* Skip over intermediate blanks */
111 while (*Start
== '\t' || *Start
== ' ')
117 /* Find the end of the second entry (the size) */
118 while ((*EntryEnd
!= '\t' && *EntryEnd
!= ' ' )
124 Size
= strtol (Start
, NULL
, 10);
126 /* Skip over intermediate blanks */
128 while (*Start
== '\t' || *Start
== ' ')
134 /* Find the end of the third entry (the filename) */
135 while ((*EntryEnd
!= '\t' && *EntryEnd
!= ' ' && *EntryEnd
!= '\n')
139 Name
.append(Start
, EntryEnd
-Start
);
140 Start
= EntryEnd
; //prepare for the next round
144 indexRecords::indexRecords()
148 indexRecords::indexRecords(const string ExpectedDist
) :
149 ExpectedDist(ExpectedDist
)