]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/users.cpp
Fixes to channel join checks
[user/henk/code/inspircd.git] / src / users.cpp
1 /*
2
3 */
4
5 #include "inspircd_config.h" 
6 #include "channels.h"
7 #include "users.h"
8 #include "inspircd.h"
9 #include <stdio.h>
10
11 userrec::userrec()
12 {
13         // the PROPER way to do it, AVOID bzero at *ALL* costs
14         strcpy(nick,"");
15         ip = 0;
16         timeout = 0;
17         strcpy(ident,"");
18         strcpy(host,"");
19         strcpy(dhost,"");
20         strcpy(fullname,"");
21         strcpy(modes,"");
22         strcpy(inbuf,"");
23         strcpy(server,"");
24         strcpy(awaymsg,"");
25         fd = lastping = signon = idle_lastmsg = nping = registered = 0;
26         flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
27         haspassed = false;
28         strcpy(result,"");
29         for (int i = 0; i < MAXCHANS; i++)
30         {
31                 this->chans[i].channel = NULL;
32                 this->chans[i].uc_modes = 0;
33         }
34         invites.clear();
35 }
36
37
38  
39 char* userrec::GetFullHost()
40 {
41         sprintf(result,"%s!%s@%s",nick,ident,dhost);
42         return result;
43 }
44
45
46 char* userrec::GetFullRealHost()
47 {
48         sprintf(result,"%s!%s@%s",nick,ident,host);
49         return result;
50 }
51
52 bool userrec::IsInvited(char* channel)
53 {
54         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
55         {
56                 if (i->channel) {
57                         if (!strcasecmp(i->channel,channel))
58                         {
59                                 return true;
60                         }
61                 }
62         }
63         return false;
64 }
65
66 void userrec::InviteTo(char* channel)
67 {
68         Invited i;
69         strcpy(i.channel,channel);
70         invites.push_back(i);
71 }
72
73 void userrec::RemoveInvite(char* channel)
74 {
75         log(DEBUG,"Removing invites");
76         if (channel)
77         {
78                 if (invites.size())
79                 {
80                         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
81                         {
82                                 if (i->channel)
83                                 {
84                                         if (!strcasecmp(i->channel,channel))
85                                         {
86                                                 invites.erase(i);
87                                                 return;
88                                         }
89                                 }
90                         }
91                 }
92         }
93 }