summaryrefslogtreecommitdiff
path: root/src/users.cpp
blob: b179fabddf7f11ccdb20e8063b2ae9aefe8cb765 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*

*/

#include "inspircd_config.h" 
#include "channels.h"
#include "users.h"
#include "inspircd.h"
#include <stdio.h>

userrec::userrec()
{
	// the PROPER way to do it, AVOID bzero at *ALL* costs
	strcpy(nick,"");
	ip = 0;
	strcpy(ident,"");
	strcpy(host,"");
	strcpy(dhost,"");
	strcpy(fullname,"");
	strcpy(modes,"");
	strcpy(inbuf,"");
	strcpy(server,"");
	strcpy(awaymsg,"");
	fd = lastping = signon = idle_lastmsg = nping = registered = 0;
	port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
	haspassed = false;
	strcpy(result,"");
	for (int i = 0; i < MAXCHANS; i++)
	{
		chans[i].channel = NULL;
	}
	invites.clear();
}

 
char* userrec::GetFullHost()
{
	sprintf(result,"%s!%s@%s",nick,ident,dhost);
	return result;
}


char* userrec::GetFullRealHost()
{
	sprintf(result,"%s!%s@%s",nick,ident,host);
	return result;
}

bool userrec::IsInvited(char* channel)
{
	for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
	{
		if (!strcasecmp(i->channel,channel))
		{
			return true;
		}
	}
}

void userrec::InviteTo(char* channel)
{
	Invited i;
	strcpy(i.channel,channel);
	invites.push_back(i);
}

void userrec::RemoveInvite(char* channel)
{
        for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
        {
                if (!strcasecmp(i->channel,channel))
                {
                        invites.erase(i);
			return;
                }
        }
}