]>
git.saurik.com Git - apt.git/blob - apt-pkg/srcrecords.cc
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 /*{{{*/
14 #include <apt-pkg/srcrecords.h>
15 #include <apt-pkg/error.h>
16 #include <apt-pkg/sourcelist.h>
17 #include <apt-pkg/strutl.h>
22 // SrcRecords::pkgSrcRecords - Constructor /*{{{*/
23 // ---------------------------------------------------------------------
24 /* Open all the source index files */
25 pkgSrcRecords::pkgSrcRecords(pkgSourceList
&List
) : Files(0), Current(0)
27 for (pkgSourceList::const_iterator I
= List
.begin(); I
!= List
.end(); I
++)
29 vector
<pkgIndexFile
*> *Indexes
= (*I
)->GetIndexFiles();
30 for (vector
<pkgIndexFile
*>::const_iterator J
= Indexes
->begin();
31 J
!= Indexes
->end(); J
++)
33 Parser
* P
= (*J
)->CreateSrcParser();
34 if (_error
->PendingError() == true)
41 // Doesn't work without any source index files
42 if (Files
.size() == 0)
44 _error
->Error(_("You must put some 'source' URIs"
45 " in your sources.list"));
52 // SrcRecords::~pkgSrcRecords - Destructor /*{{{*/
53 // ---------------------------------------------------------------------
55 pkgSrcRecords::~pkgSrcRecords()
57 // Blow away all the parser objects
58 for(vector
<Parser
*>::iterator I
= Files
.begin(); I
!= Files
.end(); ++I
)
62 // SrcRecords::Restart - Restart the search /*{{{*/
63 // ---------------------------------------------------------------------
64 /* Return all of the parsers to their starting position */
65 bool pkgSrcRecords::Restart()
67 Current
= Files
.begin();
68 for (vector
<Parser
*>::iterator I
= Files
.begin();
69 I
!= Files
.end(); I
++)
75 // SrcRecords::Find - Find the first source package with the given name /*{{{*/
76 // ---------------------------------------------------------------------
77 /* This searches on both source package names and output binary names and
78 returns the first found. A 'cursor' like system is used to allow this
79 function to be called multiple times to get successive entries */
80 pkgSrcRecords::Parser
*pkgSrcRecords::Find(const char *Package
,bool SrcOnly
)
82 if (Current
== Files
.end())
87 // Step to the next record, possibly switching files
88 while ((*Current
)->Step() == false)
90 if (_error
->PendingError() == true)
93 if (Current
== Files
.end())
98 if (_error
->PendingError() == true)
102 if ((*Current
)->Package() == Package
)
108 // Check for a binary hit
109 const char **I
= (*Current
)->Binaries();
110 for (; I
!= 0 && *I
!= 0; I
++)
111 if (strcmp(Package
,*I
) == 0)
116 // Parser::BuildDepType - Convert a build dep to a string /*{{{*/
117 // ---------------------------------------------------------------------
119 const char *pkgSrcRecords::Parser::BuildDepType(unsigned char Type
)
121 const char *fields
[] = {"Build-Depends",
122 "Build-Depends-Indep",
124 "Build-Conflicts-Indep"};