This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zsIRC_Hostmask.cpp
67 lines (51 loc) · 1.56 KB
/
zsIRC_Hostmask.cpp
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
// zsIRC_Hostmask.cpp: implementation of the zsIRC_Hostmask class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "zsIRC.h"
#include "zsIRC_Hostmask.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
zsIRC_Hostmask::zsIRC_Hostmask(TCHAR * szHostmask)
{
ZeroMemory(szNick,100*sizeof(TCHAR));
ZeroMemory(szUser,100*sizeof(TCHAR));
ZeroMemory(szHost,1024*sizeof(TCHAR));
CString sHostmask = szHostmask;
if (sHostmask.Find(_T('!'))==-1 && sHostmask.Find(_T('@'))==-1) {
if (_tcsrchr(szHostmask,_T('.')))
_tcsncpy(szHost,szHostmask,1024);
else
_tcsncpy(szNick,szHostmask,1024);
} else {
int nEMPos = sHostmask.Find(_T('!'));
int nAtPos = sHostmask.Find(_T('@'));
CString t;
t = sHostmask.Left(nEMPos);
_tcsncpy(szNick,t.LockBuffer(),100);
t = sHostmask.Mid(nEMPos+1,nAtPos-nEMPos-1);
_tcsncpy(szUser,t.LockBuffer(),100);
t = sHostmask.Right(sHostmask.GetLength()-nAtPos-1);
_tcsncpy(szHost,t.LockBuffer(),1024);
}
}
zsIRC_Hostmask::~zsIRC_Hostmask()
{
}
CString zsIRC_Hostmask::GetShortHost() {
CString str;
str += szUser;
str += _T("@");
str += szHost;
return str;
}
TCHAR * zsIRC_Hostmask::GetName() {
if (_tcslen(szNick)) return szNick;
return szHost;
}