]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_filter.h
More (last of extra)
[user/henk/code/inspircd.git] / src / modules / m_filter.h
index 9d0fff34b2e4e1f6118383b74e9b8ab3540f53b9..f2986804c3fe63a67df338b7d487693faba887d8 100644 (file)
 
 enum FilterFlags
 {
-       FLAG_NOOPERS,
-       FLAG_PART,
-       FLAG_QUIT,
-       FLAG_PRIVMSG,
-       FLAG_NOTICE
+       FLAG_NOOPERS = 1,
+       FLAG_PART = 2,
+       FLAG_QUIT = 4,
+       FLAG_PRIVMSG = 8,
+       FLAG_NOTICE = 16
 };
 
 class FilterResult : public classbase
@@ -43,8 +43,9 @@ class FilterResult : public classbase
                this->FillFlags(flags);
        }
 
-       int FillFlags(const std::string &flags)
+       int FillFlags(const std::string &fl)
        {
+               flags = fl;
                flag_no_opers = flag_part_message = flag_quit_message = flag_privmsg = flag_notice = false;
                size_t x = 0;
 
@@ -401,28 +402,29 @@ std::string FilterBase::EncodeFilter(FilterResult* filter)
        std::ostringstream stream;
        std::string x = filter->freeform;
 
+       /* Hax to allow spaces in the freeform without changing the design of the irc protocol */
        for (std::string::iterator n = x.begin(); n != x.end(); n++)
                if (*n == ' ')
                        *n = '\7';
 
-       stream << x << " " << filter->action << " " << (filter->flags.empty() ? "-" : filter->flags) << " " << filter->gline_time << " " << filter->reason;
+       stream << x << " " << filter->action << " " << (filter->flags.empty() ? "-" : filter->flags) << " " << filter->gline_time << " :" << filter->reason;
        return stream.str();
 }
 
 FilterResult FilterBase::DecodeFilter(const std::string &data)
 {
        FilterResult res;
-       std::istringstream stream(data);
-
-       stream >> res.freeform;
-       stream >> res.action;
-       stream >> res.flags;
+       irc::tokenstream tokens(data);
+       tokens.GetToken(res.freeform);
+       tokens.GetToken(res.action);
+       tokens.GetToken(res.flags);
        if (res.flags == "-")
                res.flags = "";
        res.FillFlags(res.flags);
-       stream >> res.gline_time;
-       res.reason = stream.str();
+       tokens.GetToken(res.gline_time);
+       tokens.GetToken(res.reason);
 
+       /* Hax to allow spaces in the freeform without changing the design of the irc protocol */
        for (std::string::iterator n = res.freeform.begin(); n != res.freeform.end(); n++)
                if (*n == '\7')
                        *n = ' ';