~ubuntu-core-dev/apt/oneiric

« back to all changes in this revision

Viewing changes to test/conf.cc

  • Committer: Michael Vogt
  • Date: 2011-08-17 09:27:50 UTC
  • mfrom: (1327.115.5 apt-sid)
  • Revision ID: michael.vogt@ubuntu.com-20110817092750-fyiaei2cymigqc72
mergedĀ lp:~donkult/apt/sid

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <apt-pkg/configuration.h>
2
 
#include <apt-pkg/error.h>
3
 
 
4
 
using namespace std;
5
 
 
6
 
int main(int argc,const char *argv[])
7
 
{
8
 
   Configuration Cnf;
9
 
   
10
 
   ReadConfigFile(Cnf,argv[1],true);
11
 
   
12
 
   // Process 'simple-key' type sections
13
 
   const Configuration::Item *Top = Cnf.Tree("simple-key");
14
 
   for (Top = (Top == 0?0:Top->Child); Top != 0; Top = Top->Next)
15
 
   {
16
 
      Configuration Block(Top);
17
 
      
18
 
      string VendorID = Top->Tag;
19
 
      string FingerPrint = Block.Find("Fingerprint");
20
 
      string Name = Block.Find("Name"); // Description?
21
 
      
22
 
      if (FingerPrint.empty() == true || Name.empty() == true)
23
 
         _error->Error("Block %s is invalid",VendorID.c_str());
24
 
      
25
 
      cout << VendorID << ' ' << FingerPrint << ' ' << Name << endl;
26
 
   }   
27
 
         
28
 
   // Print any errors or warnings found during parsing
29
 
   if (_error->empty() == false)
30
 
   {
31
 
      bool Errors = _error->PendingError();
32
 
      _error->DumpErrors();
33
 
      return Errors == true?100:0;
34
 
   }
35
 
   
36
 
   return 0;
37
 
}