From: Guus Sliepen Date: Sat, 24 Jan 2009 19:22:59 +0000 (+0100) Subject: Some more const. X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=72b105bd2a79bc0fd720b4a0aacd2c25dd1944cd;p=fides Some more const. --- diff --git a/lib/fides.cc b/lib/fides.cc index 46dcd7f..e035e84 100644 --- a/lib/fides.cc +++ b/lib/fides.cc @@ -267,7 +267,7 @@ fides::certificate *fides::certificate_from_string(const string &data) { if(e == string::npos) throw exception("Invalid certificate"); string fingerprint = hexdecode(data.substr(0, e)); - publickey *signer = find_key(fingerprint); + const publickey *signer = find_key(fingerprint); if(!signer) throw exception("Unknown public key"); b = e + 1; @@ -359,9 +359,9 @@ fides::fides(const string &dir): homedir(dir) { fides::~fides() { cerr << "Fides exitting\n"; - for(map::iterator i = certs.begin(); i != certs.end(); ++i) + for(map::const_iterator i = certs.begin(); i != certs.end(); ++i) delete i->second; - for(map::iterator i = keys.begin(); i != keys.end(); ++i) + for(map::const_iterator i = keys.begin(); i != keys.end(); ++i) if(i->second != &mykey) delete i->second; } @@ -397,8 +397,8 @@ fides::publickey *fides::find_key(const string &fingerprint) const { return 0; } -vector fides::find_certificates(const publickey *signer, const string ®ex) const { - vector found; +vector fides::find_certificates(const publickey *signer, const string ®ex) const { + vector found; map::const_iterator i; regexp regexp(regex); for(i = certs.begin(); i != certs.end(); ++i) { @@ -413,8 +413,8 @@ vector fides::find_certificates(const publickey *signer, c return found; } -vector fides::find_certificates(const string ®ex) const { - vector found; +vector fides::find_certificates(const string ®ex) const { + vector found; map::const_iterator i; regexp regexp(regex); for(i = certs.begin(); i != certs.end(); ++i) @@ -423,8 +423,8 @@ vector fides::find_certificates(const string ®ex) const return found; } -vector fides::find_certificates(const publickey *signer) const { - vector found; +vector fides::find_certificates(const publickey *signer) const { + vector found; map::const_iterator i; for(i = certs.begin(); i != certs.end(); ++i) if(i->second->signer == signer) @@ -484,7 +484,7 @@ void fides::dctrust(const publickey *key) { void fides::update_trust() { // clear trust on all keys - for(map::iterator i = keys.begin(); i != keys.end(); ++i) + for(map::const_iterator i = keys.begin(); i != keys.end(); ++i) i->second->trust = 0; // Start by checking all trust certificates from ourself. @@ -520,7 +520,7 @@ void fides::update_trust() { // find all non-zero trust certificates of this key - vector matches = find_certificates(*i, "^t[+-] "); + vector matches = find_certificates(*i, "^t[+-] "); // update trust value of those keys @@ -584,7 +584,7 @@ void fides::merge(certificate *cert) { // TODO: move these regexps to the class? regexp authexp("^a[+0-] "); regexp trustexp("^t[+0-] "); - vector others; + vector others; // Is this an authorisation cert? if(authexp.match(cert->statement)) { @@ -671,7 +671,7 @@ void fides::merge(certificate *cert) { void fides::auth_stats(const string &statement, int &self, int &trusted, int &all) const { self = trusted = all = 0; - vector matches = find_certificates(string("^a[+0-] ") + statement + '$'); + vector matches = find_certificates(string("^a[+0-] ") + statement + '$'); for(size_t i = 0; i < matches.size(); ++i) { char code = matches[i]->statement[1]; int diff = 0; diff --git a/lib/fides.h b/lib/fides.h index f513769..fcb34cc 100644 --- a/lib/fides.h +++ b/lib/fides.h @@ -136,7 +136,6 @@ class fides { privatekey mykey; std::map keys; std::map certs; - std::set trustedkeys; void merge(certificate *cert); void merge(publickey *key); @@ -166,14 +165,14 @@ class fides { publickey *find_key(const std::string &fingerprint) const; void update_trust(); - std::vector find_certificates(const publickey *key, const std::string &statement) const; - std::vector find_certificates(const std::string &statement) const; - std::vector find_certificates(const publickey *key) const; + std::vector find_certificates(const publickey *key, const std::string &statement) const; + std::vector find_certificates(const std::string &statement) const; + std::vector find_certificates(const publickey *key) const; - certificate *import_certificate(const std::string &certificate); + const certificate *import_certificate(const std::string &certificate); std::string export_certificate(const certificate *) const; - publickey *import_key(const std::string &key); + const publickey *import_key(const std::string &key); std::string export_key(const publickey *key) const; void import_all(std::istream &in);