]>
git.saurik.com Git - apt-legacy.git/blob - apt-pkg/srcrecords.cc
6cac477ef6e4f6098769fa42eceaeedf4b81f37c
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 /*{{{*/
15 #pragma implementation "apt-pkg/srcrecords.h"
18 #include <apt-pkg/srcrecords.h>
19 #include <apt-pkg/error.h>
20 #include <apt-pkg/sourcelist.h>
21 #include <apt-pkg/strutl.h>
26 // SrcRecords::pkgSrcRecords - Constructor /*{{{*/
27 // ---------------------------------------------------------------------
28 /* Open all the source index files */
29 pkgSrcRecords::pkgSrcRecords(pkgSourceList
&List
) : Files(0), Current(0)
31 for (pkgSourceList::const_iterator I
= List
.begin(); I
!= List
.end(); I
++)
33 vector
<pkgIndexFile
*> *Indexes
= (*I
)->GetIndexFiles();
34 for (vector
<pkgIndexFile
*>::const_iterator J
= Indexes
->begin();
35 J
!= Indexes
->end(); J
++)
37 Parser
* P
= (*J
)->CreateSrcParser();
38 if (_error
->PendingError() == true)
45 // Doesn't work without any source index files
46 if (Files
.size() == 0)
48 _error
->Error(_("You must put some 'source' URIs"
49 " in your sources.list"));
56 // SrcRecords::~pkgSrcRecords - Destructor /*{{{*/
57 // ---------------------------------------------------------------------
59 pkgSrcRecords::~pkgSrcRecords()
61 // Blow away all the parser objects
62 for(vector
<Parser
*>::iterator I
= Files
.begin(); I
!= Files
.end(); ++I
)
66 // SrcRecords::Restart - Restart the search /*{{{*/
67 // ---------------------------------------------------------------------
68 /* Return all of the parsers to their starting position */
69 bool pkgSrcRecords::Restart()
71 Current
= Files
.begin();
72 for (vector
<Parser
*>::iterator I
= Files
.begin();
73 I
!= Files
.end(); I
++)
79 // SrcRecords::Find - Find the first source package with the given name /*{{{*/
80 // ---------------------------------------------------------------------
81 /* This searches on both source package names and output binary names and
82 returns the first found. A 'cursor' like system is used to allow this
83 function to be called multiple times to get successive entries */
84 pkgSrcRecords::Parser
*pkgSrcRecords::Find(const char *Package
,bool SrcOnly
)
86 if (Current
== Files
.end())
91 // Step to the next record, possibly switching files
92 while ((*Current
)->Step() == false)
94 if (_error
->PendingError() == true)
97 if (Current
== Files
.end())
102 if (_error
->PendingError() == true)
106 if ((*Current
)->Package() == Package
)
112 // Check for a binary hit
113 const char **I
= (*Current
)->Binaries();
114 for (; I
!= 0 && *I
!= 0; I
++)
115 if (strcmp(Package
,*I
) == 0)
120 // Parser::BuildDepType - Convert a build dep to a string /*{{{*/
121 // ---------------------------------------------------------------------
123 const char *pkgSrcRecords::Parser::BuildDepType(unsigned char Type
)
125 const char *fields
[] = {"Build-Depends",
126 "Build-Depends-Indep",
128 "Build-Conflicts-Indep"};