]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/users.cpp
Tons of buffering fixes and optimisations for user connections
[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         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                 chans[i].channel = NULL;
32         }
33         invites.clear();
34 }
35
36
37  
38 char* userrec::GetFullHost()
39 {
40         sprintf(result,"%s!%s@%s",nick,ident,dhost);
41         return result;
42 }
43
44
45 char* userrec::GetFullRealHost()
46 {
47         sprintf(result,"%s!%s@%s",nick,ident,host);
48         return result;
49 }
50
51 bool userrec::IsInvited(char* channel)
52 {
53         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
54         {
55                 if (i->channel) {
56                         if (!strcasecmp(i->channel,channel))
57                         {
58                                 return true;
59                         }
60                 }
61         }
62         return false;
63 }
64
65 void userrec::InviteTo(char* channel)
66 {
67         Invited i;
68         strcpy(i.channel,channel);
69         invites.push_back(i);
70 }
71
72 void userrec::RemoveInvite(char* channel)
73 {
74         log(DEBUG,"Removing invites");
75         if (invites.size())
76         {
77                 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
78                 {
79                         if (i->channel) {
80                                 if (!strcasecmp(i->channel,channel))
81                                 {
82                                         invites.erase(i);
83                                         return;
84                                 }
85                         }
86                 }
87         }
88 }