]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/users.cpp
4a9ada90dc9ba0edbf239d39fc81e5f2831e1432
[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         strcpy(ident,"");
17         strcpy(host,"");
18         strcpy(dhost,"");
19         strcpy(fullname,"");
20         strcpy(modes,"");
21         strcpy(inbuf,"");
22         strcpy(server,"");
23         strcpy(awaymsg,"");
24         fd = lastping = signon = idle_lastmsg = nping = registered = 0;
25         port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
26         haspassed = false;
27         strcpy(result,"");
28         for (int i = 0; i < MAXCHANS; i++)
29         {
30                 chans[i].channel = NULL;
31         }
32         invites.clear();
33 }
34
35  
36 char* userrec::GetFullHost()
37 {
38         sprintf(result,"%s!%s@%s",nick,ident,dhost);
39         return result;
40 }
41
42
43 char* userrec::GetFullRealHost()
44 {
45         sprintf(result,"%s!%s@%s",nick,ident,host);
46         return result;
47 }
48
49 bool userrec::IsInvited(char* channel)
50 {
51         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
52         {
53                 if (i->channel) {
54                         if (!strcasecmp(i->channel,channel))
55                         {
56                                 return true;
57                         }
58                 }
59         }
60         return false;
61 }
62
63 void userrec::InviteTo(char* channel)
64 {
65         Invited i;
66         strcpy(i.channel,channel);
67         invites.push_back(i);
68 }
69
70 void userrec::RemoveInvite(char* channel)
71 {
72         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
73         {
74                 if (i->channel) {
75                         if (!strcasecmp(i->channel,channel))
76                         {
77                                 invites.erase(i);
78                                 return;
79                         }
80                 }
81         }
82 }