1 // ShitList.C -*- C++ -*-
2 // Copyright (c) 1998 Etienne BERNARD
3 // Copyright (C) 2002,2005 Clinton Ebadi
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 #include "StringTokenizer.H"
30 ShitList::ShitList(String filename)
31 : listFileName(filename)
47 std::ifstream file(listFileName);
54 std::cerr << "I cannot find the file " << listFileName << std::endl;
58 while (file >> temp, temp.length() != 0) {
59 StringTokenizer st(temp);
60 String mask = st.next_token(':');
61 String channelMask = st.next_token(':');
62 String level = st.next_token(':');
63 String expiration = st.next_token(':');
64 String reason = Utils::trim_str (st.rest());
65 l.push_back (new ShitEntry(mask, channelMask, std::atoi(level),
66 std::atol(expiration), reason));
75 std::list<ShitEntry *>::iterator it = l.begin();
76 std::ofstream file(listFileName);
81 for ( ; it != l.end(); ++it)
82 if ((*it)->isStillValid()) {
83 file << (*it)->shitMask.getMask() << ":"
84 << (*it)->shitChannelMask.getMask() << ":"
85 << (*it)->shitLevel << ":"
86 << (*it)->expirationDate << ":"
87 << (*it)->shitReason << std::endl;
104 ShitList::addShit(String m, String mc, int lev, time_t e, String r)
106 l.push_back (new ShitEntry(m, mc, lev, e, r));
111 ShitList::delShit(String mask, String channelMask)
113 for (std::list<ShitEntry *>::iterator it = l.begin();
116 if ((*it)->shitMask.getMask() == mask &&
117 (*it)->shitChannelMask.getMask() == channelMask) {
125 ShitList::getShit(String nuh, String channel)
127 for (std::list<ShitEntry *>::iterator it = l.begin();
130 if ((*it)->matches(nuh, channel)) {