00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifdef HAVE_CONFIG_H
00020 # include <config.h>
00021 #endif
00022
00023 #include <fstream>
00024
00025 #include "keyring.h"
00026 #include "utils.h"
00027 #include "fnames.h"
00028 #include "exceptions.h"
00029
00030 using std::ifstream;
00031 using std::ofstream;
00032
00033 void Keyring::read()
00034 {
00035 ifstream in;
00036
00037
00038 keys.clear();
00039
00040 try
00041 {
00042 U7open(in, KEYRINGDAT);
00043 }
00044 catch(exult_exception &e) {
00045
00046 return;
00047 }
00048
00049 do {
00050 int val = Read2(in);
00051 if (in.good())
00052 addkey(val);
00053 } while (in.good());
00054
00055 in.close();
00056 }
00057
00058 void Keyring::write()
00059 {
00060 ofstream out;
00061
00062 U7open(out, KEYRINGDAT);
00063
00064 std::set<int>::iterator iter;
00065
00066 for (iter = keys.begin(); iter != keys.end(); ++iter)
00067 Write2(out, *iter);
00068
00069 out.close();
00070 }
00071
00072 void Keyring::clear()
00073 {
00074 keys.clear();
00075 }
00076
00077 void Keyring::addkey(int qual)
00078 {
00079 keys.insert(qual);
00080 }
00081
00082 bool Keyring::checkkey(int qual)
00083 {
00084 return (keys.find(qual) != keys.end());
00085 }