+void TidyBan(char *ban)
+{
+ if (!ban) {
+ log(DEFAULT,"*** BUG *** TidyBan was given an invalid parameter");
+ return;
+ }
+
+ char temp[MAXBUF],NICK[MAXBUF],IDENT[MAXBUF],HOST[MAXBUF];
+
+ strlcpy(temp,ban,MAXBUF);
+
+ char* pos_of_pling = strchr(temp,'!');
+ char* pos_of_at = strchr(temp,'@');
+
+ pos_of_pling[0] = '\0';
+ pos_of_at[0] = '\0';
+ pos_of_pling++;
+ pos_of_at++;
+
+ strlcpy(NICK,temp,NICKMAX);
+ strlcpy(IDENT,pos_of_pling,IDENTMAX+1);
+ strlcpy(HOST,pos_of_at,160);
+
+ snprintf(ban,MAXBUF,"%s!%s@%s",NICK,IDENT,HOST);
+}
+
+char lst[MAXBUF];
+
+std::string chlist(userrec *user,userrec* source)
+{
+ std::string cmp = "";
+ std::string lst = "";
+ log(DEBUG,"chlist: %s",user->nick);
+ if (!user)
+ {
+ return lst;
+ }
+ for (unsigned int i = 0; i < user->chans.size(); i++)
+ {
+ if (user->chans[i].channel != NULL)
+ {
+ if (user->chans[i].channel->name)
+ {
+ cmp = std::string(user->chans[i].channel->name) + " ";
+ if (!strstr(lst.c_str(),cmp.c_str()))
+ {
+ // if the channel is NOT private/secret, OR the source user is on the channel
+ if (((!(user->chans[i].channel->binarymodes & CM_PRIVATE)) && (!(user->chans[i].channel->binarymodes & CM_SECRET))) || (has_channel(source,user->chans[i].channel)))
+ {
+ lst = lst + std::string(cmode(user,user->chans[i].channel)) + std::string(user->chans[i].channel->name) + " ";
+ }
+ }
+ }
+ }
+ }
+ return lst;
+}