summaryrefslogtreecommitdiff
path: root/test/conf.cc
blob: 340647b5f6058e29b0bda774dd5d88e977a585b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>

using namespace std;

int main(int argc,const char *argv[])
{
   Configuration Cnf;
   
   ReadConfigFile(Cnf,argv[1],true);
   
   // Process 'simple-key' type sections
   const Configuration::Item *Top = Cnf.Tree("simple-key");
   for (Top = (Top == 0?0:Top->Child); Top != 0; Top = Top->Next)
   {
      Configuration Block(Top);
      
      string VendorID = Top->Tag;
      string FingerPrint = Block.Find("Fingerprint");
      string Name = Block.Find("Name"); // Description?
      
      if (FingerPrint.empty() == true || Name.empty() == true)
	 _error->Error("Block %s is invalid",VendorID.c_str());
      
      cout << VendorID << ' ' << FingerPrint << ' ' << Name << endl;
   }   
	 
   // Print any errors or warnings found during parsing
   if (_error->empty() == false)
   {
      bool Errors = _error->PendingError();
      _error->DumpErrors();
      return Errors == true?100:0;
   }
   
   return 0;
}