]>
git.saurik.com Git - apt.git/blob - apt-pkg/srcrecords.cc
8c1de2ea5da1a3e7d25860713c3b803b5a5fe949
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: srcrecords.cc,v 1.7.2.2 2003/12/26 16:27:34 mdz Exp $
4 /* ######################################################################
6 Source Package Records - Allows access to source package records
8 Parses and allows access to the list of source records and searching by
9 source name on that list.
11 ##################################################################### */
13 // Include Files /*{{{*/
16 #include <apt-pkg/srcrecords.h>
17 #include <apt-pkg/error.h>
18 #include <apt-pkg/sourcelist.h>
19 #include <apt-pkg/strutl.h>
24 // SrcRecords::pkgSrcRecords - Constructor /*{{{*/
25 // ---------------------------------------------------------------------
26 /* Open all the source index files */
27 pkgSrcRecords::pkgSrcRecords(pkgSourceList
&List
) : Files(0), Current(0)
29 for (pkgSourceList::const_iterator I
= List
.begin(); I
!= List
.end(); ++I
)
31 vector
<pkgIndexFile
*> *Indexes
= (*I
)->GetIndexFiles();
32 for (vector
<pkgIndexFile
*>::const_iterator J
= Indexes
->begin();
33 J
!= Indexes
->end(); ++J
)
35 Parser
* P
= (*J
)->CreateSrcParser();
36 if (_error
->PendingError() == true)
43 // Doesn't work without any source index files
44 if (Files
.size() == 0)
46 _error
->Error(_("You must put some 'source' URIs"
47 " in your sources.list"));
54 // SrcRecords::~pkgSrcRecords - Destructor /*{{{*/
55 // ---------------------------------------------------------------------
57 pkgSrcRecords::~pkgSrcRecords()
59 // Blow away all the parser objects
60 for(vector
<Parser
*>::iterator I
= Files
.begin(); I
!= Files
.end(); ++I
)
64 // SrcRecords::Restart - Restart the search /*{{{*/
65 // ---------------------------------------------------------------------
66 /* Return all of the parsers to their starting position */
67 bool pkgSrcRecords::Restart()
69 Current
= Files
.begin();
70 for (vector
<Parser
*>::iterator I
= Files
.begin();
71 I
!= Files
.end(); ++I
)
77 // SrcRecords::Find - Find the first source package with the given name /*{{{*/
78 // ---------------------------------------------------------------------
79 /* This searches on both source package names and output binary names and
80 returns the first found. A 'cursor' like system is used to allow this
81 function to be called multiple times to get successive entries */
82 pkgSrcRecords::Parser
*pkgSrcRecords::Find(const char *Package
,bool const &SrcOnly
)
84 if (Current
== Files
.end())
89 // Step to the next record, possibly switching files
90 while ((*Current
)->Step() == false)
92 if (_error
->PendingError() == true)
95 if (Current
== Files
.end())
100 if (_error
->PendingError() == true)
104 if ((*Current
)->Package() == Package
)
110 // Check for a binary hit
111 const char **I
= (*Current
)->Binaries();
112 for (; I
!= 0 && *I
!= 0; ++I
)
113 if (strcmp(Package
,*I
) == 0)
118 // Parser::BuildDepType - Convert a build dep to a string /*{{{*/
119 // ---------------------------------------------------------------------
121 const char *pkgSrcRecords::Parser::BuildDepType(unsigned char const &Type
)
123 const char *fields
[] = {"Build-Depends",
124 "Build-Depends-Indep",
126 "Build-Conflicts-Indep"};