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