conf.cc 964 B

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